import TreeNode from './treenode';
import ContextNode from './contextnode';
import type { Message, NodeProps } from './types';
interface MutateObject {
type: string;
messages?: Message[];
fieldName?: string;
rowIndex?: string;
}
declare class ContextTreeManager {
rootNodes: {
[key: string]: ContextNode;
};
constructor();
/**
* @description This method checks whether the contextName passed exists as a root Node
* @example
Example for _isContextNodeExist()
* // In this example, the API checks if the contextName passed exists as a root Node
* this._isContextNodeExist("app/primary_1")
* // returns - if the contextName passed exists as a root node
* @param contextName Name of the context we are checking for
* @returns if the contextName passed exists as a root node
* @function
* @private
*/
_isContextNodeExist(contextName: string): boolean;
/**
* @description This method checks if the contextName passed already exists as a root Node otherwise adds the contextNode to
* the tree manager as a root Node
* @example Example for addContextNode()
* // In this example, the API adds the given context to the Tree Manager as a root node
* viewNode = this.addContextNode("app/primary_1")
* // returns - ContextNode that was added
* @param contextName contextName of the root node we want to add
* @returns ContextNode that was added
* @function
* @private
*/
addContextNode(contextName: string): ContextNode;
/**
* @description This method searches for the context name provided in the root nodes and returns if the node is found
* @example Example for getContextNode()
* // In this example, the API gives the node we are looking for
* contextNode = this.getContextNode("app/primary_1")
* // returns - The root node for the context name provided
* @param contextName contextName of the root node we want
* @returns The root node for the context name provided
* @function
* @private
*/
getContextNode(contextName?: string | null): ContextNode | undefined;
/**
* @description This method adds the page node to the context name provided based on the page name.
* @example Example for addPageNode()
* // In this example, the API adds the page node we are looking for
* node = this.addPageNode("app/primary_1/workarea_1", "caseInfo.content")
* // returns - The page node for the context name, page name provided which was added
* @param contextName context in which we want to add the page node
* @param pageName name of the page node
* @returns The page node for the context name, page name provided which was added
* @function
* @private
*/
addPageNode(contextName: string, pageName: string): TreeNode;
/**
* @description This method adds the parentviewnode based on the context name, page name, parent view provided.
* @example Example for _addParentViewNode()
* // In this example, the API adds the parent view node we are looking for
* parentViewNode = this._addParentViewNode("app/primary_1/workarea_1", "caseInfo.content", "Registrar")
* // returns - The parent view node for the context name, page name, parent view name provided
* @param contextName context in which we want to add the view
* @param pageName page in which we want to add the view
* @param parentView name of the view we want to add
* @returns The parent view node for the context name, page name, parent view name provided which was added
* @function
* @private
*/
_addParentViewNode(contextName: string, pageName: string, parentView: string): TreeNode;
pushChildPageNodeToParentView(parentViewNode: TreeNode, pageNode: TreeNode, pageName: string): void;
/**
* @description This method adds the viewnode based on the context name, page name,view name, parent view name provided.
* @example Example for addViewNode()
* // In this example, the API adds the view node we are looking for
* viewNode = this.addViewNode("app/primary_1/workarea_1", "caseInfo.content", "HYDERABAD", "Registrar")
* // returns - The view node for the context name, page name, view name, parent view name provided
* @param contextName context in which we want to add the view
* @param pageName page in which we want to add the view
* @param viewName name of the view we want to add
* @param parentViewName name of the parent view in which we want to add the view
* @returns The added view node for the context name, page name, view name, parent view name provided
* @function
* @private
*/
addViewNode(contextName: string, pageName: string, viewName: string, parentViewName?: string): TreeNode;
/**
* @description This method gets the viewnode based on the context name, page name,view name provided.
* @example Example for getViewNode()
* // In this example, the API gives the view node we are looking for
* viewNode = this.getViewNode("app/primary_1/workarea_1", "caseInfo.content", "HYDERABAD")
* // returns - The view node for the context name, page name, view name provided
* @param contextName context from which we want to get the view
* @param pageName from which we want to get the view
* @param viewName name of the view we want
* @returns The view node for the context name, page name, view name provided
* @function
* @private
*/
getViewNode(contextName: string, pageName: string, viewName: string): TreeNode | undefined;
/**
* @description This method adds the page list node based on the context name, page name,view name, page list name provided.
* @example Example for addPageListNode()
* // In this example, the API adds the page list node we are looking for
* fieldNode = this.addPageListNode("app/primary_1/workarea_1", "caseInfo.content", "TOP_EmbeddedData_5", ".EmbeddedData")
* // returns - The page list node for the context name, page name, view name, page list name provided
* @param contextName contextName of the page list node we want to add
* @param pageName pageName of the page list node we want to add
* @param viewName viewName of the page list node we want to add
* @param pageListName pageListName of the page list node we want to add
* @returns The added page list node for the context name, page name, view name, page list name provided
* @function
* @private
*/
addPageListNode(contextName: string, pageName: string, viewName: string, pageListName: string, options: NodeProps): TreeNode | undefined;
/**
* @description - This API updates all the fields present in the pageList property in the contextTree.
* @param contextName - name of the context in which pagelist field present.
* @param pageName - pagereference of the pagelist field which needs to be updated.
* @param pageListName - name of the pagelist field which needs to be updated.
* @param length - Length of the pagelist array that came as response. It will be taken from redux store.
* @returns {void}
* @private
*/
updatePageListNode(contextName: string, pageName: string, pageListName: string, length: number): void;
removeFieldNode(contextName: string, pageReference: string, viewName: string, fieldName: string, index: number): void;
removeViewNode(contextName: string, pageReference: string, viewName: string, index?: number): void;
removeChildViewNodes(contextName: string, pageReference: string, viewName: string, index?: number): void;
deleteAllListNodes(contextName: string, pageReference: string, deleteParentListNode?: boolean): void;
deleteListNode(contextName: string, nodeKey: string[], index: number): void;
/**
* @description This method gives the page list node based on the context name, page name,view name, page list name provided.
* @example Example for getPageListNode()
* // In this example, the API gives the page list node we are looking for
* pagelistnode = this.getPageListNode("app/primary_1/workarea_1", "caseInfo.content", "TOP_EmbeddedData_5", ".EmbeddedData")
* // returns - The page list node for the context name, page name, view name, page list name provided
* @param contextName contextName of the page list node we want
* @param pageName pageName of the page list node we want
* @param viewName viewName of the page list node we want
* @param pageListName pageListName of the page list node we want
* @returns The page list node for the context name, page name, view name, page list name provided
* @function
* @private
*/
getPageListNode(contextName: string, pageName: string, viewName: string, pageListName: string): TreeNode | undefined;
/**
* @description This method gives the field node based on the context name, page name,view name, field name provided.
* @example Example for getFieldNode()
* // In this example, the API gets the field node we are looking for
* fieldNode = this.getFieldNode("app/primary_1/workarea_1", "caseInfo.content", "TOP_EmbeddedData_5", ".EmpName")
* // returns - The field node for the context name, page name, view name, field name provided
* @param contextName contextName of the field node we want
* @param pageName pageName of the field node we want
* @param viewName viewName of the field node we want
* @param fieldName fieldName of the field node we want
* @returns The field node for the context name, page name, view name, field name provided
* @function
* @private
*/
getFieldNode(contextName: string, pageName: string, viewName: string, fieldName: string): TreeNode | undefined;
_findViewNode(contextName: string, pageName: string, viewName: string, contextNode: ContextNode): TreeNode;
/**
* @description This method adds the field node based on the context name, page name,view name, field name provided.
* @example Example for addFieldNode()
* // In this example, the API adds the field node we are looking for
* fieldNode = this.addFieldNode("app/primary_1/workarea_1", "caseInfo.content", "TOP_EmbeddedData_5", ".EmpName")
* // returns - The field node for the context name, page name, view name, field name provided
* @param contextName contextName of the field node we want to add
* @param pageName pageName of the field node we want to add
* @param viewName viewName of the field node we want to add
* @param fieldName fieldName of the field node we want to add
* @returns The added field node for the context name, page name, view name, field name provided
* @function
* @private
*/
addFieldNode(contextName: string, pageName: string, viewName: string, fieldName: string, value: string, options?: NodeProps): TreeNode | undefined;
createFieldNode(referenceNode: TreeNode, pageName: string, fieldName: string, options: NodeProps): TreeNode | undefined;
updateFieldNode(contextNode: ContextNode, referenceNode: TreeNode, fieldNode: TreeNode, contextName: string, pageName: string, fieldName: string, value: string): void;
handleFieldInsideList(contextNode: ContextNode, referenceNode: TreeNode, contextName: string, pageName: string, fieldName: string): void;
createListNodeIfNotExist(contextNode: ContextNode, referenceNode: TreeNode, property: string): void;
/**
* @description This method remove the root node based on the context name provided
* @example Example for removeContextTreeNode()
* // In this example, the API removes the root node based on the context name provided
* this.removeContextTreeNode("app/primary_1/workarea_1")
* // returns - if the root node can be removed based on context name provided
* @param contextName context name of the root node to be removed
* @returns if the root node can be removed based on context name provided
* @function
* @private
*/
removeContextTreeNode(contextName: string): void;
/**
* @description This method adds a callback to be executed whenever any mutation occurs to any of the view's children .
* @example Example for onViewMutate()
* // In this example, the API registers a callback to listen to any changes/mutations in the current view's hierarchy
* PCore.getContextTreeManager().onViewMutate("app/primary_1/workarea_1", "caseInfo.content", "View-Name", (errors) => {
* setErrorStateOnView((fieldErrors) => {
* const errors = [...fieldErrors];
* ...
* }
* })
* @param context context of the view we want to listen for changes/mutation that might occur on fields inside the current view hierarchy
* @param pageName page Name of the view we want to listen for changes/mutation that might occur on fields inside the current view hierarchy
* @param viewName view Name of the view we want to listen for changes/mutation that might occur on fields inside the current view hierarchy
* @param callback callback to be executed on mutation i.e when mutateField() is called on any field inside this view hierarchy. Callbacks can generally be used to modify the view state
* @function
* @public
*/
onViewMutate(context: string, pageName: string, viewName: string, callback: (object: {
type: string;
}) => void): void;
/**
* @description This method triggers the callback that have been registered using onViewMutate on any of its parent views.
* This method is usually called when we want to propagate the changes on the field to its parent views.
* @example Example for mutateField()
* // In this example, triggers the callback set on any of its parent views
* PCore.getContextTreeManager().mutateField("app/primary_1/workarea_1", "caseInfo.content", ".FieldName",
* [{fieldName: "FieldName",type:"error",message:"Field can't be blank"}]);
* @param context context in which field is present
* @param pageName name of the page in which field is present
* @param fieldName name of the field on which mutation has occurred
* @param mutateObject mutation object which needs to be passed as a parameter to the callback
* @param mutateObject.type type of the mutation object
* @function
* @public
*/
mutateField(context: string | undefined | null, pageName: string | undefined, fieldName: string, mutateObject: {
type: string;
messages?: Message[];
fieldName: string;
}): void;
/**
* @description This method adds a callback to be executed whenever any mutation occurs to any of the page list's children.
* @example Example for onPageListMutate()
* // In this example, the API registers a callback to listen to any changes/mutations in the current pagelist's hierarchy
* PCore.getContextTreeManager().onPageListMutate("app/primary_1/workarea_1", "caseInfo.content", "View-Name", ".PageListName", (errors) => {
* setErrorStateOnPagelist((fieldErrors) => {
* const errors = [...fieldErrors];
* ...
* }
* })
* @param context context of the pagelist we want to listen for changes/mutation that might occur on fields inside the current pagelist hierarchy
* @param pageName page Name of the pagelist we want to listen for changes/mutation that might occur on fields inside the current pagelist hierarchy
* @param viewName view Name of the pagelist we want to listen for changes/mutation that might occur on fields inside the current pagelist hierarchy
* @param pageListName name of the pagelist we want to listen for changes/mutation that might occur on fields inside the current pagelist hierarchy
* @param callback callback to be executed on mutation i.e when mutatePageList() is called on any field inside this pagelist hierarchy. Callbacks can generally be used to modify the pagelist's view state
* @function
* @public
*/
onPageListMutate(context: string, pageName: string, viewName: string, pageListName: string, callback: (object: {
type: string;
}) => void): void;
/**
* @description This method triggers the callback that have been registered using onPageListMutate on any of its parent views.
* This method is usually called when we want to propagate the changes on the pagelist fields to its parent views.
* @example Example for mutatePageList()
* // In this example, triggers the callback set on any of its parent views
* PCore.getContextTreeManager().mutatePageList("app/primary_1/workarea_1", "caseInfo.content", "Page-List-Name",
* [{fieldName: "Employees",type:"error",message:"Employees can't be blank"}]);
* @param context context in which field is present
* @param pageName name of the page in which field is present
* @param pageListName name of the pagelist on which mutation has occurred
* @param mutateObject mutation object which needs to be passed as a parameter to the callback
* @param mutateObject.type type of the mutation object
* @param stopPropagation stop propagating the event to parent
* @function
* @public
*/
mutatePageList(context: string | undefined | null, pageName: string | undefined, pageListName: string | undefined, mutateObject: MutateObject, stopPropagation?: boolean): void;
/**
* This method gives the list of Editable & fields which are present in the provided context.
* @param context - name of the context
* @returns
*/
getFieldsList(context: string): Map;
/**
* This method gives the list of Editable & calculated fields which are present in the provided context.
* @param context - name of the context
* @param propertyReference - unique key for identifying the property
* @function
* @private
*/
getFieldReferenceForProperty(context: string, propertyReference: string): TreeNode;
getFieldReferencePreviousValue(context: string, propertyReference: string): any;
updateFieldNodeValue(context: string, propertyReference: string, currentValue: string | number | boolean | null): void;
/**
* @description - This methods retrieves the map of fields which are present in the context.
* @param context - name of the context
* @returns This returns the Map of fields present in the provided context.
* @example Example usage for getContextReferences
* ContextTreeManager.getContextReferences("app/primary_1/workarea_1")
* @private
*/
getContextReferences(context: string | null): Map | undefined;
/**
* @description - This methods retrives either the fields or whens or declarative targets which are present in the context.
* @param context - name of the context
* @returns {Map} - This returns the Map of fields present in the provided context.
* @example Example usage for getContextReferencesByType
* ContextTreeManager.getContextReferencesByType("app/primary_1/workarea_1", "FIELD")
* @private
*/
getContextReferencesByType(context: string | null, type: string): Map;
isFieldExists(context: string, propertyReference: string): boolean;
/**
* @description - This method adds the when node based on the context name, page name,reference name, field name and type provided.
* @example Example for addWhenNode()
* // In this example, the API adds the when node we are looking for
* fieldNode = ContextTreeManager.addWhenNode("app/primary_1/workarea_1", "caseInfo.content", 'FIELD', "FirstName", ".Always")
* // returns - The when node for the context name, page name, view name, field name provided.
* @param {string} contextName contextName of the when node we want to add.
* @param {string} subType - type of the reference that when is configured. 'FIELD' and VIEW are available sub types.
* @param {string} pageName pageName of the when node we want to add.
* @param {string} referenceName viewName or when name of the when node we want to add.
* @param {string} whenName name of the when node we want to add.
* @returns {TreeNode} The added when node for the context name, page name, reference name, field name and type provided.
* @function
* @private
*/
addWhenNode(contextName: string, pageName: string, subType: string, referenceName: string, whenName: string, options?: NodeProps): void;
/**
* @description - Retrieves fields and views configured with when condition from the provided context.
* @param {object} context The context containing the configuration.
* @returns {Array<{ name: string; pageReference: string }>} An array of objects representing fields configured with declarative target.
* @function
* @example Usage of getWhens
* ContextTreeManager.getDeclarativeTargets('app/primary_1/workarea_1')
* @private
*/
getDeclarativeTargets(context: string): {
name: string;
pageReference: string;
}[];
/**
* @description - Retrieves fields and views configured with when condition from the provided context.
* @param {object} context The context containing the configuration.
* @returns {Array<{ name: string; pageReference: string; referenceName: string; type: string }>} An array of objects representing fields and views configured with when condition.
* @function
* @example Usage of getWhens
* ContextTreeManager.getWhens('app/primary_1/workarea_1')
* @private
*/
getWhens(context: string): {
name: string;
pageReference: string;
referenceName: string;
type: string;
}[];
}
declare const _default: ContextTreeManager;
export default _default;