@openforis/arena-core 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node/nodePointer.js.map +1 -1
- package/dist/esm/node/nodeValueFormatter.js.map +1 -1
- package/dist/esm/node/nodeValues.js.map +1 -1
- package/dist/esm/nodeDef/factory.js.map +1 -1
- package/dist/esm/nodeDef/index.js.map +1 -1
- package/dist/esm/nodeDef/nodeDef.js.map +1 -1
- package/dist/esm/nodeDef/nodeDefs.js.map +1 -1
- package/dist/esm/nodeDef/service.js.map +1 -1
- package/dist/esm/nodeDefExpressionEvaluator/context.js.map +1 -1
- package/dist/esm/nodeDefExpressionEvaluator/node/identifier.js.map +1 -1
- package/dist/esm/record/_records/nodeDefSelfReferences.js.map +1 -1
- package/dist/esm/record/_records/recordCompletion.js.map +1 -1
- package/dist/esm/record/_records/recordGetters.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeKeyValidator.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeTypeValidator.js +1 -1
- package/dist/esm/record/recordValidator/attributeTypeValidator.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeUniqueValidator.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeValidator.js.map +1 -1
- package/dist/esm/record/recordValidator/countValidator.js.map +1 -1
- package/dist/esm/survey/survey.js.map +1 -1
- package/dist/esm/survey/surveys/_nodeDefs/nodeDefsReader.js.map +1 -1
- package/dist/esm/survey/surveys/dependencies.js.map +1 -1
- package/dist/esm/survey/surveys/nodeDefs.js.map +1 -1
- package/dist/esm/tests/builder/recordBuilder/nodeBuilder.js.map +1 -1
- package/dist/esm/tests/builder/surveyBuilder/nodeDefAttributeBuilder.js.map +1 -1
- package/dist/esm/tests/builder/surveyBuilder/nodeDefBuilder.js.map +1 -1
- package/dist/esm/tests/builder/surveyBuilder/nodeDefCodeBuilder.js.map +1 -1
- package/dist/esm/tests/builder/surveyBuilder/nodeDefEntityBuilder.js.map +1 -1
- package/dist/esm/tests/builder/surveyBuilder/nodeDefTaxonBuilder.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/node/nodePointer.d.ts +2 -2
- package/dist/node/nodePointer.js.map +1 -1
- package/dist/node/nodeValueFormatter.d.ts +2 -2
- package/dist/node/nodeValueFormatter.js.map +1 -1
- package/dist/node/nodeValues.d.ts +3 -3
- package/dist/node/nodeValues.js.map +1 -1
- package/dist/nodeDef/factory.d.ts +3 -3
- package/dist/nodeDef/factory.js.map +1 -1
- package/dist/nodeDef/index.d.ts +1 -1
- package/dist/nodeDef/index.js.map +1 -1
- package/dist/nodeDef/nodeDef.d.ts +2 -0
- package/dist/nodeDef/nodeDef.js.map +1 -1
- package/dist/nodeDef/nodeDefs.d.ts +50 -50
- package/dist/nodeDef/nodeDefs.js.map +1 -1
- package/dist/nodeDef/service.d.ts +7 -7
- package/dist/nodeDef/service.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/context.d.ts +3 -4
- package/dist/nodeDefExpressionEvaluator/context.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/node/identifier.d.ts +2 -2
- package/dist/nodeDefExpressionEvaluator/node/identifier.js.map +1 -1
- package/dist/record/_records/nodeDefSelfReferences.d.ts +2 -2
- package/dist/record/_records/nodeDefSelfReferences.js.map +1 -1
- package/dist/record/_records/recordCompletion.js.map +1 -1
- package/dist/record/_records/recordGetters.d.ts +4 -4
- package/dist/record/_records/recordGetters.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.d.ts +2 -2
- package/dist/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.d.ts +2 -2
- package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
- package/dist/record/recordValidator/attributeKeyValidator.d.ts +3 -3
- package/dist/record/recordValidator/attributeKeyValidator.js.map +1 -1
- package/dist/record/recordValidator/attributeTypeValidator.d.ts +2 -2
- package/dist/record/recordValidator/attributeTypeValidator.js.map +1 -1
- package/dist/record/recordValidator/attributeUniqueValidator.d.ts +2 -2
- package/dist/record/recordValidator/attributeUniqueValidator.js.map +1 -1
- package/dist/record/recordValidator/attributeValidator.js.map +1 -1
- package/dist/record/recordValidator/countValidator.d.ts +2 -2
- package/dist/record/recordValidator/countValidator.js.map +1 -1
- package/dist/survey/survey.d.ts +2 -2
- package/dist/survey/survey.js.map +1 -1
- package/dist/survey/surveys/_nodeDefs/nodeDefsReader.d.ts +3 -3
- package/dist/survey/surveys/_nodeDefs/nodeDefsReader.js.map +1 -1
- package/dist/survey/surveys/dependencies.d.ts +4 -4
- package/dist/survey/surveys/dependencies.js.map +1 -1
- package/dist/survey/surveys/nodeDefs.d.ts +28 -28
- package/dist/survey/surveys/nodeDefs.js.map +1 -1
- package/dist/tests/builder/recordBuilder/nodeBuilder.d.ts +2 -2
- package/dist/tests/builder/recordBuilder/nodeBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/nodeDefAttributeBuilder.d.ts +2 -2
- package/dist/tests/builder/surveyBuilder/nodeDefAttributeBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/nodeDefBuilder.d.ts +3 -3
- package/dist/tests/builder/surveyBuilder/nodeDefBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/nodeDefCodeBuilder.d.ts +2 -2
- package/dist/tests/builder/surveyBuilder/nodeDefCodeBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/nodeDefEntityBuilder.d.ts +2 -2
- package/dist/tests/builder/surveyBuilder/nodeDefEntityBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/nodeDefTaxonBuilder.d.ts +2 -2
- package/dist/tests/builder/surveyBuilder/nodeDefTaxonBuilder.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordGetters.js","sourceRoot":"","sources":["../../../src/record/_records/recordGetters.ts"],"names":[],"mappings":";;;AAAA,yCAA8D;AAC9D,uCAA0D;AAC1D,qCAAsG;AACtG,sDAAwD;AACxD,2CAOsB;AACtB,yCAAoD;AAEpD,uCAA2C;AAC3C,sCAA8E;AAC9E,8CAAsD;AACtD,qEAAiE;AACjE,uEAAmE;AACnE,mEAA+D;AAExD,MAAM,QAAQ,GAAG,CAAC,MAAmB,EAAU,EAAE,wBAAC,MAAM,CAAC,KAAK,mCAAI,qBAAY,GAAA,CAAA;AAAxE,QAAA,QAAQ,GAAR,QAAQ,CAAgE;AAE9E,MAAM,QAAQ,GAAG,CAAC,MAAmB,EAAoC,EAAE,wBAAC,MAAM,CAAC,KAAK,mCAAI,EAAE,GAAA,CAAA;AAAxF,QAAA,QAAQ,GAAR,QAAQ,CAAgF;AAE9F,MAAM,aAAa,GAAG,CAAC,MAAmB,EAAqB,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAA,QAAA,QAAQ,EAAC,MAAM,CAAC,CAAC,CAAA;AAA3F,QAAA,aAAa,GAAb,aAAa,CAA8E;AAExG;;;GAGG;AACI,MAAM,oBAAoB,GAAG,CAAC,MAAmB,EAAoB,EAAE,wBAC5E,MAAM,CAAC,WAAW,mCAAI,iDAAuB,CAAC,eAAe,CAAC,MAAM,CAAC,GAAA,CAAA;AAD1D,QAAA,oBAAoB,GAApB,oBAAoB,CACsC;AAEvE;;;GAGG;AACI,MAAM,aAAa,GACxB,CAAC,IAAY,EAAE,EAAE,CACjB,CAAC,MAAmB,EAA+B,EAAE,kBACnD,MAAA,MAAM,CAAC,KAAK,0CAAG,IAAI,CAAC,GAAA,CAAA;AAHX,QAAA,aAAa,GAAb,aAAa,CAGF;AAEjB,MAAM,eAAe,GAC1B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;AAA/F,QAAA,gBAAgB,GAAhB,gBAAgB,CAA+E","sourcesContent":["import { ArenaDictionary, TraverseMethod } from '../../common'\nimport { SystemError, SystemErrorKeys } from '../../error'\nimport { ArenaRecordNode, ArenaRecordNodePointer, RecordNodes, ArenaRecordNodesMap } from '../../node'\nimport { RecordNodeValues } from '../../node/nodeValues'\nimport {\n ArenaNodeDef,\n ArenaNodeDefCode,\n ArenaNodeDefCodeProps,\n ArenaNodeDefProps,\n NodeDefs,\n NodeDefType,\n} from '../../nodeDef'\nimport { defaultCycle, Surveys } from '../../survey'\nimport { ArenaSurvey, SurveyDependencyType } from '../../survey/survey'\nimport { Arrays, Queue } from '../../utils'\nimport { ArenaRecord, RECORD_STEP_DEFAULT, RecordNodesIndex } from '../record'\nimport { RecordStepAnalysisCode } from '../recordStep'\nimport { RecordNodesIndexReader } from './recordNodesIndexReader'\nimport { RecordNodesIndexUpdater } from './recordNodesIndexUpdater'\nimport { NodeDefSelfReferences } from './nodeDefSelfReferences'\n\nexport const getCycle = (record: ArenaRecord): string => record.cycle ?? defaultCycle\n\nexport const getNodes = (record: ArenaRecord): ArenaDictionary<ArenaRecordNode> => record.nodes ?? {}\n\nexport const getNodesArray = (record: ArenaRecord): ArenaRecordNode[] => Object.values(getNodes(record))\n\n/**\n * Returns the nodes index of the record or, if missing, a new index built from all the record nodes (not stored in the record).\n * To be used before updating the index: a partial index would be trusted by the getters.\n */\nexport const getNodesIndexOrBuild = (record: ArenaRecord): RecordNodesIndex =>\n record._nodesIndex ?? RecordNodesIndexUpdater.initializeIndex(record)\n\n/**\n * Returns the node with the specified uuid, or undefined if not found.\n * Like the other node getters, it does not throw an error when the node is not found.\n */\nexport const getNodeByUuid =\n (uuid: string) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n record.nodes?.[uuid]\n\nexport const getNodesByUuids =\n (uuids: string[]) =>\n (record: ArenaRecord): ArenaRecordNode[] =>\n uuids.map((uuid: string) => record.nodes?.[uuid]) as ArenaRecordNode[]\n\n/**\n * Returns the root node, or undefined if the record has no nodes.\n */\nexport const getRoot = (record: ArenaRecord): ArenaRecordNode | undefined => {\n const rootUuid = record._nodesIndex ? RecordNodesIndexReader.getNodeRootUuid(record._nodesIndex) : null\n if (rootUuid) {\n return getNodeByUuid(rootUuid)(record)\n }\n return getNodesArray(record).find((node) => !node.parentUuid)\n}\n\nexport const getChildren =\n (parentNode: ArenaRecordNode, childDefUuid?: string) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const childrenUuids = childDefUuid\n ? RecordNodesIndexReader.getNodeUuidsByParentAndChildDef({\n parentNodeUuid: parentNode.uuid,\n childDefUuid,\n })(record._nodesIndex)\n : RecordNodesIndexReader.getNodeUuidsByParent(parentNode.uuid)(record._nodesIndex)\n return getNodesByUuids(childrenUuids)(record)\n }\n return getNodesArray(record).filter(\n (node) => node.parentUuid === parentNode.uuid && (!childDefUuid || node.nodeDefUuid == childDefUuid)\n )\n }\n\n/**\n * Returns the only child of the parent node with the specified node def, or undefined if not found.\n * Throws an error if more than one child is found.\n */\nexport const getChild =\n (parentNode: ArenaRecordNode, childDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const children = getChildren(parentNode, childDefUuid)(record)\n if (children.length > 1) {\n const errorParams = { childDefUuid, parentNodeUuid: parentNode.uuid, recordUuid: record.uuid }\n throw new SystemError(SystemErrorKeys.record.multipleNodesFound, errorParams)\n }\n return children[0]\n }\n\n// called for every ancestor in the record update loops: keep it a plain lookup\nconst getParentNode = (record: ArenaRecord, node: ArenaRecordNode): ArenaRecordNode | undefined =>\n node.parentUuid ? record.nodes?.[node.parentUuid] : undefined\n\nexport const getParent =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n getParentNode(record, node)\n\nexport const getNodesByDefUuid =\n (nodeDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeUuidsByDef(nodeDefUuid)(record._nodesIndex)\n return getNodesByUuids(nodeUuids)(record)\n }\n return getNodesArray(record).filter((node) => node.nodeDefUuid === nodeDefUuid)\n }\n\nconst isNodeFlagTrue =\n (isChildFlagTrue: (parent: ArenaRecordNode, nodeDefUuid: string) => boolean) =>\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean => {\n let child = node\n let parent = getParentNode(record, child)\n while (parent) {\n if (!isChildFlagTrue(parent, child.nodeDefUuid)) return false\n child = parent\n parent = getParentNode(record, child)\n }\n return true\n }\n\nexport const isNodeApplicable = isNodeFlagTrue((parent, nodeDefUuid) =>\n RecordNodes.isChildApplicable(parent, nodeDefUuid)\n)\nexport const isNodeEditable = isNodeFlagTrue((parent, nodeDefUuid) => RecordNodes.isChildEditable(parent, nodeDefUuid))\nexport const isNodeVisible = isNodeFlagTrue((parent, nodeDefUuid) => RecordNodes.isChildVisible(parent, nodeDefUuid))\n\n/**\n * Whether a value is required for the node: key or always required attribute, or attribute with a \"required if\"\n * condition met in its parent entity (evaluated condition stored in the parent node meta).\n */\nexport const isNodeRequired =\n (nodeDef: ArenaNodeDef<NodeDefType>, node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean => {\n if (NodeDefs.isKey(nodeDef) || NodeDefs.isRequired(nodeDef)) return true\n if (!NodeDefs.isRequiredIfDefined(nodeDef)) return false\n const parent = getParentNode(record, node)\n return !!parent && RecordNodes.isChildRequired(parent, nodeDef.uuid)\n }\n\nexport const getDependentCodeAttributes =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeCodeDependentUuids(node.uuid)(record._nodesIndex)\n return getNodesByUuids(nodeUuids)(record)\n }\n throw new SystemError(SystemErrorKeys.record.nodesIndexNotInitialized)\n }\n\nexport const getParentCodeAttribute =\n (parentNode: ArenaRecordNode, nodeDef: ArenaNodeDefCode) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(nodeDef)\n if (!parentCodeDefUuid) return undefined\n\n const ancestors = getAncestorsAndSelf(parentNode)(record)\n for (const ancestor of ancestors) {\n const children = getChildren(ancestor, parentCodeDefUuid)(record)\n if (children.length === 1) {\n return children[0]\n }\n }\n return undefined\n }\n\n// ancestors\n\n/**\n * Visits the specified node and its ancestors, from the node up to the root: the visit stops when the visitor returns true.\n */\nexport const visitAncestorsAndSelf =\n (node: ArenaRecordNode, visitor: (node: ArenaRecordNode) => boolean | void) =>\n (record: ArenaRecord): void => {\n let currentNode: ArenaRecordNode | undefined = node\n while (currentNode) {\n if (visitor(currentNode)) return\n currentNode = getParentNode(record, currentNode)\n }\n }\n\n/**\n * Returns the first node satisfying the predicate among the specified node and its ancestors (from the node up to the root).\n */\nexport const findAncestor =\n (node: ArenaRecordNode, predicate: (node: ArenaRecordNode) => boolean) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let result: ArenaRecordNode | undefined = undefined\n visitAncestorsAndSelf(node, (visitedNode) => {\n if (predicate(visitedNode)) {\n result = visitedNode\n return true\n }\n return false\n })(record)\n return result\n }\n\n/**\n * Returns the specified node, if it has the specified node def, or its ancestor with that node def; undefined if not found.\n */\nexport const getAncestor =\n (node: ArenaRecordNode, ancestorDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let ancestor: ArenaRecordNode | undefined = node\n while (ancestor && ancestor.nodeDefUuid !== ancestorDefUuid) {\n ancestor = getParentNode(record, ancestor)\n }\n return ancestor\n }\n\n/**\n * Returns the list of ancestors from the given node to the root entity\n */\nexport const getAncestorsAndSelf =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): Array<ArenaRecordNode> => {\n const ancestors: Array<ArenaRecordNode> = []\n let currentNode: ArenaRecordNode | undefined = node\n while (currentNode) {\n ancestors.push(currentNode)\n currentNode = getParentNode(record, currentNode)\n }\n return ancestors\n }\n\n// descendants\n\nexport const getDescendantsOrSelf =\n (node: ArenaRecordNode, nodeDefDescendant: ArenaNodeDef<any>) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (nodeDefDescendant.uuid === node.nodeDefUuid) return [node]\n\n const nodeDefDescendantFullHierarchy = [...nodeDefDescendant.meta.h, nodeDefDescendant.uuid]\n\n // 1. get the descendant node defs uuids starting from node nodeDefUuid (not inclusive) down to the specified nodeDefDescendant uuid\n const descendantNodeDefUuids = nodeDefDescendantFullHierarchy.slice(\n nodeDefDescendantFullHierarchy.indexOf(node.nodeDefUuid) + 1\n )\n // 2. for every level in the hierarchy, find the children having the nodeDefUuid equal to the current one\n let currentAncestors = [node]\n let currentDescendants: ArenaRecordNode[] = []\n for (const currentDescendantDefUuid of descendantNodeDefUuids) {\n for (const currentAncestor of currentAncestors) {\n for (const child of getChildren(currentAncestor, currentDescendantDefUuid)(record)) {\n currentDescendants.push(child)\n }\n }\n currentAncestors = currentDescendants\n currentDescendants = []\n }\n return currentAncestors // currentAncestors is equal to the currentDescendants of the last level\n }\n\n/**\n * Returns the first descendant (or the node itself) with the specified node def, or undefined if not found.\n */\nexport const getDescendant =\n (node: ArenaRecordNode, nodeDefDescendant: ArenaNodeDef<any>) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n getDescendantsOrSelf(node, nodeDefDescendant)(record)[0]\n\nexport const isDescendantOf = (node: ArenaRecordNode, ancestor: ArenaRecordNode): boolean =>\n RecordNodes.getHierarchy(node).includes(ancestor.uuid)\n\nexport const visitDescendantsAndSelf =\n (\n node: ArenaRecordNode,\n visitor: (node: ArenaRecordNode) => boolean | void,\n traverseMethod: TraverseMethod = TraverseMethod.bfs\n ) =>\n (record: ArenaRecord): void => {\n if (traverseMethod === TraverseMethod.bfs) {\n const queue = new Queue<ArenaRecordNode>()\n\n queue.enqueue(node)\n\n while (!queue.isEmpty()) {\n const visitedNode = queue.dequeue()!\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren(visitedNode)(record)\n queue.enqueueItems(children)\n }\n } else {\n const stack = []\n\n stack.push(node)\n\n while (stack.length > 0) {\n const visitedNode = stack.pop() as ArenaRecordNode\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren(visitedNode)(record)\n\n // add children to stack in reverse order\n for (let index = children.length - 1; index >= 0; index--) {\n const child = children[index]\n stack.push(child)\n }\n }\n }\n }\n\nexport const findDescendantOrSelf =\n (node: ArenaRecordNode, predicate: (node: ArenaRecordNode) => boolean) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let found = undefined\n\n visitDescendantsAndSelf(node, (currentNode) => {\n if (predicate(currentNode)) {\n found = currentNode\n return true\n }\n return false\n })(record)\n return found\n }\n\nconst getClosestAncestorNode =\n (\n node: ArenaRecordNode,\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>,\n dependentDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>,\n dependencyType: SurveyDependencyType\n ) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n // 1a if dependent def is the same as node def, potentially all nodes with\n // nodeDefUuid === dependentDef.uuid in record could be dependent of nodeDef;\n // consider the root node as the closest ancestor node,\n // unless the node def references itself only among the children of its parent entity (e.g. validation \"dbh > 0\")\n if (nodeDef.uuid === dependentDef.uuid) {\n return NodeDefSelfReferences.isSelfReferenceLocal({ nodeDef, dependencyType })\n ? getParent(node)(record)\n : getRoot(record)\n }\n // 1 find common ancestor def\n const commonAncestorDefUuid = Arrays.last(Arrays.intersection(nodeDef.meta.h, dependentDef.meta.h))\n if (!commonAncestorDefUuid) return undefined\n\n // 2 get ancestor node with common parent def\n return getAncestor(node, commonAncestorDefUuid)(record)\n }\n\ntype KeyDefs = ArenaNodeDef<NodeDefType, ArenaNodeDefProps>[]\n\n/**\n * Returns the key nodes of the entity, indexed by key def uuid; keyDefs, when specified, are used instead of the\n * entity def keys in the cycle.\n */\nexport const getEntityKeyNodesByDefUuid =\n (survey: ArenaSurvey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): ArenaRecordNodesMap => {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const nodeDefKeys = keyDefs ?? Surveys.getNodeDefKeys({ survey, cycle, nodeDef })\n return nodeDefKeys.reduce((acc: ArenaRecordNodesMap, nodeDefKey) => {\n const nodeKey = getDescendant(entity, nodeDefKey)(record)\n // missing key nodes are kept as undefined entries\n acc[nodeDefKey.uuid] = nodeKey as ArenaRecordNode\n return acc\n }, {})\n }\n\nexport const getEntityKeyNodes =\n (survey: ArenaSurvey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): ArenaRecordNode[] =>\n Object.values(getEntityKeyNodesByDefUuid(survey, entity, cycle, keyDefs)(record))\n\nexport const getEntityKeyValuesByDefUuid =\n (survey: ArenaSurvey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): ArenaDictionary<any> => {\n const keyNodesByDefUuid = getEntityKeyNodesByDefUuid(survey, entity, cycle, keyDefs)(record)\n return Object.entries(keyNodesByDefUuid).reduce((acc: ArenaDictionary<any>, [uuid, keyNode]) => {\n acc[uuid] = keyNode?.value\n return acc\n }, {})\n }\n\nexport const getEntityKeyValues =\n (survey: ArenaSurvey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): any[] =>\n Object.values(getEntityKeyValuesByDefUuid(survey, entity, cycle, keyDefs)(record))\n\nexport const getEntitySiblings =\n (entity: ArenaRecordNode, includeSelf = false) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n const parentEntity = getParent(entity)(record)\n if (!parentEntity) return []\n const siblingEntities = getChildren(parentEntity, entity.nodeDefUuid)(record)\n return includeSelf ? siblingEntities : siblingEntities.filter((sibling) => !RecordNodes.areEqual(sibling, entity))\n }\n\nexport const getAttributeSiblings =\n (node: ArenaRecordNode, nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n const parentEntity = getParent(node)(record)\n if (!parentEntity) return []\n const siblingParentEntities = getEntitySiblings(parentEntity)(record)\n return siblingParentEntities.reduce((siblingsAcc: ArenaRecordNode[], siblingEntity) => {\n for (const sibling of getChildren(siblingEntity, nodeDef.uuid)(record)) {\n siblingsAcc.push(sibling)\n }\n return siblingsAcc\n }, [])\n }\n\nexport const getNodeIndex = (node: ArenaRecordNode) => (record: ArenaRecord) => {\n const parentEntity = getParent(node)(record)\n if (!parentEntity) return 0 // root entity\n const siblings = getChildren(parentEntity, node.nodeDefUuid)(record)\n // compared by uuid: the specified node can be a copy of the one in the record (e.g. an updated version of it)\n return siblings.findIndex((sibling) => sibling.uuid === node.uuid)\n}\n\nexport const findEntityByKeyValues =\n (\n survey: ArenaSurvey,\n cycle: string,\n parentEntity: ArenaRecordNode,\n entityDefUuid: string,\n keyValuesByDefUuid: ArenaDictionary<any>\n ) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entityDefUuid })\n const siblingEntities = getChildren(parentEntity, entityDefUuid)(record)\n if (NodeDefs.isSingle(entityDef)) {\n return siblingEntities[0]\n }\n const keyDefs = Surveys.getNodeDefKeys({ survey, cycle, nodeDef: entityDef })\n\n return siblingEntities.find((siblingEntity) => {\n const siblingEntityKeyValuesByDefUuid = getEntityKeyValuesByDefUuid(\n survey,\n siblingEntity,\n undefined,\n keyDefs\n )(record)\n return keyDefs.every((keyDef) => {\n const keyValue = siblingEntityKeyValuesByDefUuid[keyDef.uuid]\n const keyValueSearch = keyValuesByDefUuid[keyDef.uuid]\n return RecordNodeValues.isValueEqual({\n survey,\n nodeDef: keyDef,\n value: keyValue,\n valueSearch: keyValueSearch,\n })\n })\n })\n }\n\nexport const findEntityWithSameKeysInAnotherRecord =\n (survey: ArenaSurvey, cycle: string, entityUuid: string, recordOther: ArenaRecord) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const entity = getNodeByUuid(entityUuid)(record)\n if (!entity) return undefined\n\n let otherRecordCurrentParentEntity = getRoot(recordOther)\n if (!otherRecordCurrentParentEntity) return undefined\n\n const entityAncestorsAndSelf = getAncestorsAndSelf(entity)(record)\n const ancestorDefUuidsAndKeys = entityAncestorsAndSelf.map((ancestor) => ({\n entityDefUuid: ancestor.nodeDefUuid,\n keyValuesByDefUuid: getEntityKeyValuesByDefUuid(survey, ancestor)(record),\n }))\n\n const ancestorDefUuidsAndKeysToVisit = [...ancestorDefUuidsAndKeys].reverse()\n\n for (let index = 1; otherRecordCurrentParentEntity && index < ancestorDefUuidsAndKeysToVisit.length; index++) {\n const { entityDefUuid, keyValuesByDefUuid } = ancestorDefUuidsAndKeysToVisit[index]\n otherRecordCurrentParentEntity = findEntityByKeyValues(\n survey,\n cycle,\n otherRecordCurrentParentEntity,\n entityDefUuid,\n keyValuesByDefUuid\n )(recordOther)\n }\n return otherRecordCurrentParentEntity\n }\n\nexport const getDependentNodePointers =\n (\n survey: ArenaSurvey,\n node: ArenaRecordNode,\n dependencyType: SurveyDependencyType,\n includeSelf = false,\n filterFn: ((nodePointer: ArenaRecordNodePointer) => boolean) | null = null\n ) =>\n (record: ArenaRecord): ArenaRecordNodePointer[] => {\n const nodeDefUuid = node.nodeDefUuid\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: nodeDefUuid })\n const dependentDefs = Surveys.getNodeDefDependents({ survey, nodeDefUuid, dependencyType })\n const nodePointers: Array<ArenaRecordNodePointer> = []\n\n const addToNodePointers = (nodePointer: ArenaRecordNodePointer): void => {\n if (filterFn === null || filterFn(nodePointer)) {\n nodePointers.push(nodePointer)\n }\n }\n\n for (const dependentDef of dependentDefs) {\n // 1 find common ancestor node\n const commonAncestorNode = getClosestAncestorNode(node, nodeDef, dependentDef, dependencyType)(record)\n if (!commonAncestorNode) continue\n\n const nodeDefDependentParent = Surveys.getNodeDefParent({ survey, nodeDef: dependentDef })\n if (!nodeDefDependentParent) throw new SystemError(SystemErrorKeys.record.dependencyOnRootFound)\n\n // 2 find descendant nodes of common parent node with nodeDefUuid = dependentDef uuid\n const dependentContextNodes = getDescendantsOrSelf(commonAncestorNode, nodeDefDependentParent)(record)\n\n for (const dependentContextNode of dependentContextNodes) {\n addToNodePointers({\n nodeCtx: dependentContextNode,\n nodeDef: dependentDef,\n })\n }\n }\n if (includeSelf) {\n const parentNode = getParent(node)(record)\n if (parentNode) {\n addToNodePointers({\n nodeCtx: parentNode,\n nodeDef,\n })\n }\n }\n\n return nodePointers\n }\n\n/**\n * Returns the code attributes the specified code attribute depends on, from the top level one to the parent one.\n */\nexport const getAncestorCodeAttributes =\n (survey: ArenaSurvey, parentNode: ArenaRecordNode, nodeDef: ArenaNodeDefCode) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n const ancestorCodeAttributes = []\n let currentParentCodeAttribute = getParentCodeAttribute(parentNode, nodeDef)(record)\n while (currentParentCodeAttribute) {\n ancestorCodeAttributes.unshift(currentParentCodeAttribute)\n const ancestorCodeDef = Surveys.getNodeDefByUuid({\n survey,\n uuid: currentParentCodeAttribute.nodeDefUuid,\n }) as ArenaNodeDefCode\n currentParentCodeAttribute = getParentCodeAttribute(parentNode, ancestorCodeDef)(record)\n }\n return ancestorCodeAttributes\n }\n\nexport const getAncestorCodePath =\n (survey: ArenaSurvey, parentNode: ArenaRecordNode, nodeDef: ArenaNodeDef<NodeDefType.code, ArenaNodeDefCodeProps>) =>\n (record: ArenaRecord): string[] =>\n getAncestorCodeAttributes(\n survey,\n parentNode,\n nodeDef\n )(record).map((codeAttribute) => {\n const codeItemUuid = RecordNodeValues.getItemUuid(codeAttribute)\n if (!codeItemUuid) return ''\n // items of big categories are not in the survey ref data: they can be in the node ref data\n const item =\n codeAttribute.refData?.categoryItem ?? Surveys.getCategoryItemByUuid({ survey, itemUuid: codeItemUuid })\n return item?.props.code ?? ''\n })\n\nexport const getCategoryItemUuid =\n (\n survey: ArenaSurvey,\n nodeDef: ArenaNodeDef<NodeDefType.code, ArenaNodeDefCodeProps>,\n parentNode: ArenaRecordNode,\n code: string\n ) =>\n (record: ArenaRecord): string | undefined => {\n const categoryUuid = nodeDef.props.categoryUuid\n\n const codePaths = [...getAncestorCodePath(survey, parentNode, nodeDef)(record), code]\n\n const item = Surveys.getCategoryItemByCodePaths({ survey, categoryUuid, codePaths })\n\n return item?.uuid\n }\n\nexport const isNodeFilledByUser =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean =>\n !!findDescendantOrSelf(node, (visitedNode) => RecordNodes.hasUserInputValue(visitedNode))(record)\n\nexport const isNodeEmpty =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean =>\n !isNodeFilledByUser(node)(record)\n\nexport const isEmpty = (record: ArenaRecord): boolean => {\n const rootNode = getRoot(record)\n return rootNode ? isNodeEmpty(rootNode)(record) : true\n}\n\nexport const getStep = (record: ArenaRecord): string => record.step ?? RECORD_STEP_DEFAULT\n\nexport const isInAnalysisStep = (record: ArenaRecord): boolean => getStep(record) === RecordStepAnalysisCode\n"]}
|
|
1
|
+
{"version":3,"file":"recordGetters.js","sourceRoot":"","sources":["../../../src/record/_records/recordGetters.ts"],"names":[],"mappings":";;;AAAA,yCAA8D;AAC9D,uCAA0D;AAC1D,qCAAsG;AACtG,sDAAwD;AACxD,2CAOsB;AACtB,yCAAoD;AAEpD,uCAA2C;AAC3C,sCAA8E;AAC9E,8CAAsD;AACtD,qEAAiE;AACjE,uEAAmE;AACnE,mEAA+D;AAExD,MAAM,QAAQ,GAAG,CAAC,MAAmB,EAAU,EAAE,wBAAC,MAAM,CAAC,KAAK,mCAAI,qBAAY,GAAA,CAAA;AAAxE,QAAA,QAAQ,GAAR,QAAQ,CAAgE;AAE9E,MAAM,QAAQ,GAAG,CAAC,MAAmB,EAAoC,EAAE,wBAAC,MAAM,CAAC,KAAK,mCAAI,EAAE,GAAA,CAAA;AAAxF,QAAA,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,MAAM,CAAC,CAAA;AAHxB,QAAA,WAAW,GAAX,WAAW,CAGa;AAE9B,MAAM,OAAO,GAAG,CAAC,MAAmB,EAAW,EAAE;IACtD,MAAM,QAAQ,GAAG,IAAA,QAAA,OAAO,EAAC,MAAM,CAAC,CAAA;IAChC,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAA,QAAA,WAAW,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACxD,CAAC,CAAA;AAHY,QAAA,OAAO,GAAP,OAAO,CAGnB;AAEM,MAAM,OAAO,GAAG,CAAC,MAAmB,EAAU,EAAE,wBAAC,MAAM,CAAC,IAAI,mCAAI,4BAAmB,GAAA,CAAA;AAA7E,QAAA,OAAO,GAAP,OAAO,CAAsE;AAEnF,MAAM,gBAAgB,GAAG,CAAC,MAAmB,EAAW,EAAE,CAAC,IAAA,QAAA,OAAO,EAAC,MAAM,CAAC,KAAK,mCAAsB,CAAA;AAA/F,QAAA,gBAAgB,GAAhB,gBAAgB,CAA+E","sourcesContent":["import { ArenaDictionary, TraverseMethod } from '../../common'\nimport { SystemError, SystemErrorKeys } from '../../error'\nimport { ArenaRecordNode, ArenaRecordNodePointer, RecordNodes, ArenaRecordNodesMap } from '../../node'\nimport { RecordNodeValues } from '../../node/nodeValues'\nimport {\n ArenaAnyNodeDef,\n ArenaNodeDef,\n ArenaNodeDefCode,\n ArenaNodeDefCodeProps,\n NodeDefs,\n NodeDefType,\n} from '../../nodeDef'\nimport { defaultCycle, Surveys } from '../../survey'\nimport { ArenaSurvey, SurveyDependencyType } from '../../survey/survey'\nimport { Arrays, Queue } from '../../utils'\nimport { ArenaRecord, RECORD_STEP_DEFAULT, RecordNodesIndex } from '../record'\nimport { RecordStepAnalysisCode } from '../recordStep'\nimport { RecordNodesIndexReader } from './recordNodesIndexReader'\nimport { RecordNodesIndexUpdater } from './recordNodesIndexUpdater'\nimport { NodeDefSelfReferences } from './nodeDefSelfReferences'\n\nexport const getCycle = (record: ArenaRecord): string => record.cycle ?? defaultCycle\n\nexport const getNodes = (record: ArenaRecord): ArenaDictionary<ArenaRecordNode> => record.nodes ?? {}\n\nexport const getNodesArray = (record: ArenaRecord): ArenaRecordNode[] => Object.values(getNodes(record))\n\n/**\n * Returns the nodes index of the record or, if missing, a new index built from all the record nodes (not stored in the record).\n * To be used before updating the index: a partial index would be trusted by the getters.\n */\nexport const getNodesIndexOrBuild = (record: ArenaRecord): RecordNodesIndex =>\n record._nodesIndex ?? RecordNodesIndexUpdater.initializeIndex(record)\n\n/**\n * Returns the node with the specified uuid, or undefined if not found.\n * Like the other node getters, it does not throw an error when the node is not found.\n */\nexport const getNodeByUuid =\n (uuid: string) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n record.nodes?.[uuid]\n\nexport const getNodesByUuids =\n (uuids: string[]) =>\n (record: ArenaRecord): ArenaRecordNode[] =>\n uuids.map((uuid: string) => record.nodes?.[uuid]) as ArenaRecordNode[]\n\n/**\n * Returns the root node, or undefined if the record has no nodes.\n */\nexport const getRoot = (record: ArenaRecord): ArenaRecordNode | undefined => {\n const rootUuid = record._nodesIndex ? RecordNodesIndexReader.getNodeRootUuid(record._nodesIndex) : null\n if (rootUuid) {\n return getNodeByUuid(rootUuid)(record)\n }\n return getNodesArray(record).find((node) => !node.parentUuid)\n}\n\nexport const getChildren =\n (parentNode: ArenaRecordNode, childDefUuid?: string) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const childrenUuids = childDefUuid\n ? RecordNodesIndexReader.getNodeUuidsByParentAndChildDef({\n parentNodeUuid: parentNode.uuid,\n childDefUuid,\n })(record._nodesIndex)\n : RecordNodesIndexReader.getNodeUuidsByParent(parentNode.uuid)(record._nodesIndex)\n return getNodesByUuids(childrenUuids)(record)\n }\n return getNodesArray(record).filter(\n (node) => node.parentUuid === parentNode.uuid && (!childDefUuid || node.nodeDefUuid == childDefUuid)\n )\n }\n\n/**\n * Returns the only child of the parent node with the specified node def, or undefined if not found.\n * Throws an error if more than one child is found.\n */\nexport const getChild =\n (parentNode: ArenaRecordNode, childDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const children = getChildren(parentNode, childDefUuid)(record)\n if (children.length > 1) {\n const errorParams = { childDefUuid, parentNodeUuid: parentNode.uuid, recordUuid: record.uuid }\n throw new SystemError(SystemErrorKeys.record.multipleNodesFound, errorParams)\n }\n return children[0]\n }\n\n// called for every ancestor in the record update loops: keep it a plain lookup\nconst getParentNode = (record: ArenaRecord, node: ArenaRecordNode): ArenaRecordNode | undefined =>\n node.parentUuid ? record.nodes?.[node.parentUuid] : undefined\n\nexport const getParent =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n getParentNode(record, node)\n\nexport const getNodesByDefUuid =\n (nodeDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeUuidsByDef(nodeDefUuid)(record._nodesIndex)\n return getNodesByUuids(nodeUuids)(record)\n }\n return getNodesArray(record).filter((node) => node.nodeDefUuid === nodeDefUuid)\n }\n\nconst isNodeFlagTrue =\n (isChildFlagTrue: (parent: ArenaRecordNode, nodeDefUuid: string) => boolean) =>\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean => {\n let child = node\n let parent = getParentNode(record, child)\n while (parent) {\n if (!isChildFlagTrue(parent, child.nodeDefUuid)) return false\n child = parent\n parent = getParentNode(record, child)\n }\n return true\n }\n\nexport const isNodeApplicable = isNodeFlagTrue((parent, nodeDefUuid) =>\n RecordNodes.isChildApplicable(parent, nodeDefUuid)\n)\nexport const isNodeEditable = isNodeFlagTrue((parent, nodeDefUuid) => RecordNodes.isChildEditable(parent, nodeDefUuid))\nexport const isNodeVisible = isNodeFlagTrue((parent, nodeDefUuid) => RecordNodes.isChildVisible(parent, nodeDefUuid))\n\n/**\n * Whether a value is required for the node: key or always required attribute, or attribute with a \"required if\"\n * condition met in its parent entity (evaluated condition stored in the parent node meta).\n */\nexport const isNodeRequired =\n (nodeDef: ArenaAnyNodeDef, node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean => {\n if (NodeDefs.isKey(nodeDef) || NodeDefs.isRequired(nodeDef)) return true\n if (!NodeDefs.isRequiredIfDefined(nodeDef)) return false\n const parent = getParentNode(record, node)\n return !!parent && RecordNodes.isChildRequired(parent, nodeDef.uuid)\n }\n\nexport const getDependentCodeAttributes =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeCodeDependentUuids(node.uuid)(record._nodesIndex)\n return getNodesByUuids(nodeUuids)(record)\n }\n throw new SystemError(SystemErrorKeys.record.nodesIndexNotInitialized)\n }\n\nexport const getParentCodeAttribute =\n (parentNode: ArenaRecordNode, nodeDef: ArenaNodeDefCode) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(nodeDef)\n if (!parentCodeDefUuid) return undefined\n\n const ancestors = getAncestorsAndSelf(parentNode)(record)\n for (const ancestor of ancestors) {\n const children = getChildren(ancestor, parentCodeDefUuid)(record)\n if (children.length === 1) {\n return children[0]\n }\n }\n return undefined\n }\n\n// ancestors\n\n/**\n * Visits the specified node and its ancestors, from the node up to the root: the visit stops when the visitor returns true.\n */\nexport const visitAncestorsAndSelf =\n (node: ArenaRecordNode, visitor: (node: ArenaRecordNode) => boolean | void) =>\n (record: ArenaRecord): void => {\n let currentNode: ArenaRecordNode | undefined = node\n while (currentNode) {\n if (visitor(currentNode)) return\n currentNode = getParentNode(record, currentNode)\n }\n }\n\n/**\n * Returns the first node satisfying the predicate among the specified node and its ancestors (from the node up to the root).\n */\nexport const findAncestor =\n (node: ArenaRecordNode, predicate: (node: ArenaRecordNode) => boolean) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let result: ArenaRecordNode | undefined = undefined\n visitAncestorsAndSelf(node, (visitedNode) => {\n if (predicate(visitedNode)) {\n result = visitedNode\n return true\n }\n return false\n })(record)\n return result\n }\n\n/**\n * Returns the specified node, if it has the specified node def, or its ancestor with that node def; undefined if not found.\n */\nexport const getAncestor =\n (node: ArenaRecordNode, ancestorDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let ancestor: ArenaRecordNode | undefined = node\n while (ancestor && ancestor.nodeDefUuid !== ancestorDefUuid) {\n ancestor = getParentNode(record, ancestor)\n }\n return ancestor\n }\n\n/**\n * Returns the list of ancestors from the given node to the root entity\n */\nexport const getAncestorsAndSelf =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): Array<ArenaRecordNode> => {\n const ancestors: Array<ArenaRecordNode> = []\n let currentNode: ArenaRecordNode | undefined = node\n while (currentNode) {\n ancestors.push(currentNode)\n currentNode = getParentNode(record, currentNode)\n }\n return ancestors\n }\n\n// descendants\n\nexport const getDescendantsOrSelf =\n (node: ArenaRecordNode, nodeDefDescendant: ArenaNodeDef<any>) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (nodeDefDescendant.uuid === node.nodeDefUuid) return [node]\n\n const nodeDefDescendantFullHierarchy = [...nodeDefDescendant.meta.h, nodeDefDescendant.uuid]\n\n // 1. get the descendant node defs uuids starting from node nodeDefUuid (not inclusive) down to the specified nodeDefDescendant uuid\n const descendantNodeDefUuids = nodeDefDescendantFullHierarchy.slice(\n nodeDefDescendantFullHierarchy.indexOf(node.nodeDefUuid) + 1\n )\n // 2. for every level in the hierarchy, find the children having the nodeDefUuid equal to the current one\n let currentAncestors = [node]\n let currentDescendants: ArenaRecordNode[] = []\n for (const currentDescendantDefUuid of descendantNodeDefUuids) {\n for (const currentAncestor of currentAncestors) {\n for (const child of getChildren(currentAncestor, currentDescendantDefUuid)(record)) {\n currentDescendants.push(child)\n }\n }\n currentAncestors = currentDescendants\n currentDescendants = []\n }\n return currentAncestors // currentAncestors is equal to the currentDescendants of the last level\n }\n\n/**\n * Returns the first descendant (or the node itself) with the specified node def, or undefined if not found.\n */\nexport const getDescendant =\n (node: ArenaRecordNode, nodeDefDescendant: ArenaNodeDef<any>) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n getDescendantsOrSelf(node, nodeDefDescendant)(record)[0]\n\nexport const isDescendantOf = (node: ArenaRecordNode, ancestor: ArenaRecordNode): boolean =>\n RecordNodes.getHierarchy(node).includes(ancestor.uuid)\n\nexport const visitDescendantsAndSelf =\n (\n node: ArenaRecordNode,\n visitor: (node: ArenaRecordNode) => boolean | void,\n traverseMethod: TraverseMethod = TraverseMethod.bfs\n ) =>\n (record: ArenaRecord): void => {\n if (traverseMethod === TraverseMethod.bfs) {\n const queue = new Queue<ArenaRecordNode>()\n\n queue.enqueue(node)\n\n while (!queue.isEmpty()) {\n const visitedNode = queue.dequeue()!\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren(visitedNode)(record)\n queue.enqueueItems(children)\n }\n } else {\n const stack = []\n\n stack.push(node)\n\n while (stack.length > 0) {\n const visitedNode = stack.pop() as ArenaRecordNode\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren(visitedNode)(record)\n\n // add children to stack in reverse order\n for (let index = children.length - 1; index >= 0; index--) {\n const child = children[index]\n stack.push(child)\n }\n }\n }\n }\n\nexport const findDescendantOrSelf =\n (node: ArenaRecordNode, predicate: (node: ArenaRecordNode) => boolean) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let found = undefined\n\n visitDescendantsAndSelf(node, (currentNode) => {\n if (predicate(currentNode)) {\n found = currentNode\n return true\n }\n return false\n })(record)\n return found\n }\n\nconst getClosestAncestorNode =\n (\n node: ArenaRecordNode,\n nodeDef: ArenaAnyNodeDef,\n dependentDef: ArenaAnyNodeDef,\n dependencyType: SurveyDependencyType\n ) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n // 1a if dependent def is the same as node def, potentially all nodes with\n // nodeDefUuid === dependentDef.uuid in record could be dependent of nodeDef;\n // consider the root node as the closest ancestor node,\n // unless the node def references itself only among the children of its parent entity (e.g. validation \"dbh > 0\")\n if (nodeDef.uuid === dependentDef.uuid) {\n return NodeDefSelfReferences.isSelfReferenceLocal({ nodeDef, dependencyType })\n ? getParent(node)(record)\n : getRoot(record)\n }\n // 1 find common ancestor def\n const commonAncestorDefUuid = Arrays.last(Arrays.intersection(nodeDef.meta.h, dependentDef.meta.h))\n if (!commonAncestorDefUuid) return undefined\n\n // 2 get ancestor node with common parent def\n return getAncestor(node, commonAncestorDefUuid)(record)\n }\n\ntype KeyDefs = ArenaAnyNodeDef[]\n\n/**\n * Returns the key nodes of the entity, indexed by key def uuid; keyDefs, when specified, are used instead of the\n * entity def keys in the cycle.\n */\nexport const getEntityKeyNodesByDefUuid =\n (survey: ArenaSurvey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): ArenaRecordNodesMap => {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const nodeDefKeys = keyDefs ?? Surveys.getNodeDefKeys({ survey, cycle, nodeDef })\n return nodeDefKeys.reduce((acc: ArenaRecordNodesMap, nodeDefKey) => {\n const nodeKey = getDescendant(entity, nodeDefKey)(record)\n // missing key nodes are kept as undefined entries\n acc[nodeDefKey.uuid] = nodeKey as ArenaRecordNode\n return acc\n }, {})\n }\n\nexport const getEntityKeyNodes =\n (survey: ArenaSurvey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): ArenaRecordNode[] =>\n Object.values(getEntityKeyNodesByDefUuid(survey, entity, cycle, keyDefs)(record))\n\nexport const getEntityKeyValuesByDefUuid =\n (survey: ArenaSurvey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): ArenaDictionary<any> => {\n const keyNodesByDefUuid = getEntityKeyNodesByDefUuid(survey, entity, cycle, keyDefs)(record)\n return Object.entries(keyNodesByDefUuid).reduce((acc: ArenaDictionary<any>, [uuid, keyNode]) => {\n acc[uuid] = keyNode?.value\n return acc\n }, {})\n }\n\nexport const getEntityKeyValues =\n (survey: ArenaSurvey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): any[] =>\n Object.values(getEntityKeyValuesByDefUuid(survey, entity, cycle, keyDefs)(record))\n\nexport const getEntitySiblings =\n (entity: ArenaRecordNode, includeSelf = false) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n const parentEntity = getParent(entity)(record)\n if (!parentEntity) return []\n const siblingEntities = getChildren(parentEntity, entity.nodeDefUuid)(record)\n return includeSelf ? siblingEntities : siblingEntities.filter((sibling) => !RecordNodes.areEqual(sibling, entity))\n }\n\nexport const getAttributeSiblings =\n (node: ArenaRecordNode, nodeDef: ArenaAnyNodeDef) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n const parentEntity = getParent(node)(record)\n if (!parentEntity) return []\n const siblingParentEntities = getEntitySiblings(parentEntity)(record)\n return siblingParentEntities.reduce((siblingsAcc: ArenaRecordNode[], siblingEntity) => {\n for (const sibling of getChildren(siblingEntity, nodeDef.uuid)(record)) {\n siblingsAcc.push(sibling)\n }\n return siblingsAcc\n }, [])\n }\n\nexport const getNodeIndex = (node: ArenaRecordNode) => (record: ArenaRecord) => {\n const parentEntity = getParent(node)(record)\n if (!parentEntity) return 0 // root entity\n const siblings = getChildren(parentEntity, node.nodeDefUuid)(record)\n // compared by uuid: the specified node can be a copy of the one in the record (e.g. an updated version of it)\n return siblings.findIndex((sibling) => sibling.uuid === node.uuid)\n}\n\nexport const findEntityByKeyValues =\n (\n survey: ArenaSurvey,\n cycle: string,\n parentEntity: ArenaRecordNode,\n entityDefUuid: string,\n keyValuesByDefUuid: ArenaDictionary<any>\n ) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entityDefUuid })\n const siblingEntities = getChildren(parentEntity, entityDefUuid)(record)\n if (NodeDefs.isSingle(entityDef)) {\n return siblingEntities[0]\n }\n const keyDefs = Surveys.getNodeDefKeys({ survey, cycle, nodeDef: entityDef })\n\n return siblingEntities.find((siblingEntity) => {\n const siblingEntityKeyValuesByDefUuid = getEntityKeyValuesByDefUuid(\n survey,\n siblingEntity,\n undefined,\n keyDefs\n )(record)\n return keyDefs.every((keyDef) => {\n const keyValue = siblingEntityKeyValuesByDefUuid[keyDef.uuid]\n const keyValueSearch = keyValuesByDefUuid[keyDef.uuid]\n return RecordNodeValues.isValueEqual({\n survey,\n nodeDef: keyDef,\n value: keyValue,\n valueSearch: keyValueSearch,\n })\n })\n })\n }\n\nexport const findEntityWithSameKeysInAnotherRecord =\n (survey: ArenaSurvey, cycle: string, entityUuid: string, recordOther: ArenaRecord) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const entity = getNodeByUuid(entityUuid)(record)\n if (!entity) return undefined\n\n let otherRecordCurrentParentEntity = getRoot(recordOther)\n if (!otherRecordCurrentParentEntity) return undefined\n\n const entityAncestorsAndSelf = getAncestorsAndSelf(entity)(record)\n const ancestorDefUuidsAndKeys = entityAncestorsAndSelf.map((ancestor) => ({\n entityDefUuid: ancestor.nodeDefUuid,\n keyValuesByDefUuid: getEntityKeyValuesByDefUuid(survey, ancestor)(record),\n }))\n\n const ancestorDefUuidsAndKeysToVisit = [...ancestorDefUuidsAndKeys].reverse()\n\n for (let index = 1; otherRecordCurrentParentEntity && index < ancestorDefUuidsAndKeysToVisit.length; index++) {\n const { entityDefUuid, keyValuesByDefUuid } = ancestorDefUuidsAndKeysToVisit[index]\n otherRecordCurrentParentEntity = findEntityByKeyValues(\n survey,\n cycle,\n otherRecordCurrentParentEntity,\n entityDefUuid,\n keyValuesByDefUuid\n )(recordOther)\n }\n return otherRecordCurrentParentEntity\n }\n\nexport const getDependentNodePointers =\n (\n survey: ArenaSurvey,\n node: ArenaRecordNode,\n dependencyType: SurveyDependencyType,\n includeSelf = false,\n filterFn: ((nodePointer: ArenaRecordNodePointer) => boolean) | null = null\n ) =>\n (record: ArenaRecord): ArenaRecordNodePointer[] => {\n const nodeDefUuid = node.nodeDefUuid\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: nodeDefUuid })\n const dependentDefs = Surveys.getNodeDefDependents({ survey, nodeDefUuid, dependencyType })\n const nodePointers: Array<ArenaRecordNodePointer> = []\n\n const addToNodePointers = (nodePointer: ArenaRecordNodePointer): void => {\n if (filterFn === null || filterFn(nodePointer)) {\n nodePointers.push(nodePointer)\n }\n }\n\n for (const dependentDef of dependentDefs) {\n // 1 find common ancestor node\n const commonAncestorNode = getClosestAncestorNode(node, nodeDef, dependentDef, dependencyType)(record)\n if (!commonAncestorNode) continue\n\n const nodeDefDependentParent = Surveys.getNodeDefParent({ survey, nodeDef: dependentDef })\n if (!nodeDefDependentParent) throw new SystemError(SystemErrorKeys.record.dependencyOnRootFound)\n\n // 2 find descendant nodes of common parent node with nodeDefUuid = dependentDef uuid\n const dependentContextNodes = getDescendantsOrSelf(commonAncestorNode, nodeDefDependentParent)(record)\n\n for (const dependentContextNode of dependentContextNodes) {\n addToNodePointers({\n nodeCtx: dependentContextNode,\n nodeDef: dependentDef,\n })\n }\n }\n if (includeSelf) {\n const parentNode = getParent(node)(record)\n if (parentNode) {\n addToNodePointers({\n nodeCtx: parentNode,\n nodeDef,\n })\n }\n }\n\n return nodePointers\n }\n\n/**\n * Returns the code attributes the specified code attribute depends on, from the top level one to the parent one.\n */\nexport const getAncestorCodeAttributes =\n (survey: ArenaSurvey, parentNode: ArenaRecordNode, nodeDef: ArenaNodeDefCode) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n const ancestorCodeAttributes = []\n let currentParentCodeAttribute = getParentCodeAttribute(parentNode, nodeDef)(record)\n while (currentParentCodeAttribute) {\n ancestorCodeAttributes.unshift(currentParentCodeAttribute)\n const ancestorCodeDef = Surveys.getNodeDefByUuid({\n survey,\n uuid: currentParentCodeAttribute.nodeDefUuid,\n }) as ArenaNodeDefCode\n currentParentCodeAttribute = getParentCodeAttribute(parentNode, ancestorCodeDef)(record)\n }\n return ancestorCodeAttributes\n }\n\nexport const getAncestorCodePath =\n (survey: ArenaSurvey, parentNode: ArenaRecordNode, nodeDef: ArenaNodeDef<NodeDefType.code, ArenaNodeDefCodeProps>) =>\n (record: ArenaRecord): string[] =>\n getAncestorCodeAttributes(\n survey,\n parentNode,\n nodeDef\n )(record).map((codeAttribute) => {\n const codeItemUuid = RecordNodeValues.getItemUuid(codeAttribute)\n if (!codeItemUuid) return ''\n // items of big categories are not in the survey ref data: they can be in the node ref data\n const item =\n codeAttribute.refData?.categoryItem ?? Surveys.getCategoryItemByUuid({ survey, itemUuid: codeItemUuid })\n return item?.props.code ?? ''\n })\n\nexport const getCategoryItemUuid =\n (\n survey: ArenaSurvey,\n nodeDef: ArenaNodeDef<NodeDefType.code, ArenaNodeDefCodeProps>,\n parentNode: ArenaRecordNode,\n code: string\n ) =>\n (record: ArenaRecord): string | undefined => {\n const categoryUuid = nodeDef.props.categoryUuid\n\n const codePaths = [...getAncestorCodePath(survey, parentNode, nodeDef)(record), code]\n\n const item = Surveys.getCategoryItemByCodePaths({ survey, categoryUuid, codePaths })\n\n return item?.uuid\n }\n\nexport const isNodeFilledByUser =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean =>\n !!findDescendantOrSelf(node, (visitedNode) => RecordNodes.hasUserInputValue(visitedNode))(record)\n\nexport const isNodeEmpty =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean =>\n !isNodeFilledByUser(node)(record)\n\nexport const isEmpty = (record: ArenaRecord): boolean => {\n const rootNode = getRoot(record)\n return rootNode ? isNodeEmpty(rootNode)(record) : true\n}\n\nexport const getStep = (record: ArenaRecord): string => record.step ?? RECORD_STEP_DEFAULT\n\nexport const isInAnalysisStep = (record: ArenaRecord): boolean => getStep(record) === RecordStepAnalysisCode\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ArenaRecordNode } from '../../node';
|
|
2
|
-
import {
|
|
2
|
+
import { ArenaAnyNodeDef } from '../../nodeDef';
|
|
3
3
|
import { ArenaRecordExpressionEvaluationContext } from './recordExpressionEvaluationContext';
|
|
4
4
|
import { RecordNodeDependentsUpdateParams } from './recordNodeDependentsUpdateParams';
|
|
5
5
|
import { RecordUpdateResult } from './recordUpdateResult';
|
|
@@ -8,7 +8,7 @@ import { RecordUpdateResult } from './recordUpdateResult';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const evaluateRequiredIf: (params: ArenaRecordExpressionEvaluationContext & {
|
|
10
10
|
nodeCtx: ArenaRecordNode;
|
|
11
|
-
nodeDef:
|
|
11
|
+
nodeDef: ArenaAnyNodeDef;
|
|
12
12
|
}) => Promise<boolean>;
|
|
13
13
|
/**
|
|
14
14
|
* Updates the "required if" flags (parent node meta `cReq`) of the node itself (if attribute) and of its dependents.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordNodeDependentsRequiredUpdater.js","sourceRoot":"","sources":["../../../src/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAyD;AACzD,
|
|
1
|
+
{"version":3,"file":"recordNodeDependentsRequiredUpdater.js","sourceRoot":"","sources":["../../../src/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAyD;AACzD,2CAAyD;AACzD,yCAAsC;AACtC,gDAA0D;AAC1D,6DAA6D;AAC7D,4EAAwE;AAExE,+FAAsF;AAEtF,6DAAyD;AAEzD,MAAM,mBAAmB,GAAG,IAAI,qDAAyB,EAAE,CAAA;AAE3D;;GAEG;AACI,MAAM,kBAAkB,GAAG,CAChC,MAGC,EACiB,EAAE;IACpB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IACnC,MAAM,QAAQ,GA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,EAAE,EAAE,UAAU,EAAE,CAAC,CAAA;YACnG,YAAY,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,UAAU,EAAE,CAAC,CAAA;QACtD,CAAC;IACH,CAAC;AACH,CAAC,CAAA,CAAA;AAED;;;GAGG;AACI,MAAM,mBAAmB,GAAG,CACjC,MAA2E,EAC9C,EAAE;IAC/B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,CAAA;IAC/C,MAAM,YAAY,GAAG,IAAI,uCAAkB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IAEvD,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,gBAAO,CAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAA;QACxE,IAAI,EAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,CAAA;YAAE,SAAQ;QAClC,mFAAmF;QACnF,MAAM,0BAA0B,iCAAM,MAAM,KAAE,OAAO,EAAE,YAAY,IAAG,CAAA,CAAC,UAAU;IACnF,CAAC;IACD,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA,CAAA;AAbY,QAAA,mBAAmB,GAAnB,mBAAmB,CAa/B","sourcesContent":["import { ArenaRecordNode, RecordNodes } from '../../node'\nimport { ArenaAnyNodeDef, NodeDefs } from '../../nodeDef'\nimport { Surveys } from '../../survey'\nimport { SurveyDependencyType } from '../../survey/survey'\nimport { getNodesByDefUuid } from '../_records/recordGetters'\nimport { RecordExpressionEvaluator } from '../recordExpressionEvaluator'\nimport { ArenaRecordExpressionEvaluationContext } from './recordExpressionEvaluationContext'\nimport { getDependentNodePointersByType } from './recordNodesDependentsUpdaterCommons'\nimport { RecordNodeDependentsUpdateParams } from './recordNodeDependentsUpdateParams'\nimport { RecordUpdateResult } from './recordUpdateResult'\n\nconst expressionEvaluator = new RecordExpressionEvaluator()\n\n/**\n * Evaluates the \"required if\" condition of the specified child def in the context of the specified parent entity.\n */\nexport const evaluateRequiredIf = async (\n params: ArenaRecordExpressionEvaluationContext & {\n nodeCtx: ArenaRecordNode\n nodeDef: ArenaAnyNodeDef\n }\n): Promise<boolean> => {\n const { nodeCtx, nodeDef } = params\n const exprEval = await expressionEvaluator.evalApplicableExpression({\n ...params,\n nodeCtx,\n expressions: NodeDefs.getRequiredIf(nodeDef),\n })\n return !!exprEval?.value\n}\n\n/**\n * Updates the \"required if\" flags (parent node meta `cReq`) of the node itself (if attribute) and of its dependents.\n */\nexport const updateSelfAndDependentsRequired = async (\n params: RecordNodeDependentsUpdateParams\n): Promise<RecordUpdateResult> => {\n const { survey, record, node, sideEffect = false } = params\n const updateResult = new RecordUpdateResult({ record })\n\n const nodePointersToUpdate = getDependentNodePointersByType({\n survey,\n record,\n node,\n dependencyType: SurveyDependencyType.required,\n includeSelfWhenSourceIsAttribute: true,\n filterFn: (nodePointer) => NodeDefs.isRequiredIfDefined(nodePointer.nodeDef),\n })\n\n // NOTE: don't do it in parallel, same nodeCtx metadata could be overwritten\n for (const { nodeCtx: nodeCtxNodePointer, nodeDef } of nodePointersToUpdate) {\n const nodeCtx = updateResult.getNodeByUuid(nodeCtxNodePointer.uuid) ?? nodeCtxNodePointer\n const valuePrev = RecordNodes.isChildRequired(nodeCtx, nodeDef.uuid)\n // NOSONAR: sequential evaluation needed (see note above)\n const value = await evaluateRequiredIf({ ...params, record: updateResult.record, nodeCtx, nodeDef }) // NOSONAR\n if (valuePrev === value) continue\n\n const nodeCtxUpdated = RecordNodes.assocChildRequired(nodeCtx, nodeDef.uuid, value, { sideEffect })\n updateResult.addNode(nodeCtxUpdated, { sideEffect })\n }\n return updateResult\n}\n\nconst updateNodeDefRequiredFlags = async (\n params: ArenaRecordExpressionEvaluationContext & {\n nodeDef: ArenaAnyNodeDef\n updateResult: RecordUpdateResult\n }\n): Promise<void> => {\n const { nodeDef, updateResult, sideEffect = false } = params\n const requiredIfDefined = NodeDefs.isRequiredIfDefined(nodeDef)\n const parentNodes = getNodesByDefUuid(nodeDef.parentUuid!)(updateResult.record)\n\n for (const parentNode of parentNodes) {\n const nodeCtx = updateResult.getNodeByUuid(parentNode.uuid) ?? parentNode\n const valuePrev = RecordNodes.isChildRequired(nodeCtx, nodeDef.uuid)\n // sequential evaluation: the same parent node can be updated for different child defs\n const value =\n requiredIfDefined && (await evaluateRequiredIf({ ...params, record: updateResult.record, nodeCtx, nodeDef })) // NOSONAR\n if (value !== valuePrev) {\n const nodeCtxUpdated = RecordNodes.assocChildRequired(nodeCtx, nodeDef.uuid, value, { sideEffect })\n updateResult.addNode(nodeCtxUpdated, { sideEffect })\n }\n }\n}\n\n/**\n * Recomputes the \"required if\" flags (parent node meta `cReq`) of the specified node defs in the whole record,\n * e.g. after their \"required if\" condition has been added, changed or removed. Validation is not updated.\n */\nexport const updateRequiredFlags = async (\n params: ArenaRecordExpressionEvaluationContext & { nodeDefUuids: string[] }\n): Promise<RecordUpdateResult> => {\n const { survey, record, nodeDefUuids } = params\n const updateResult = new RecordUpdateResult({ record })\n\n for (const nodeDefUuid of nodeDefUuids) {\n const nodeDef = Surveys.findNodeDefByUuid({ survey, uuid: nodeDefUuid })\n if (!nodeDef?.parentUuid) continue\n // sequential: each node def update works on the record updated by the previous one\n await updateNodeDefRequiredFlags({ ...params, nodeDef, updateResult }) // NOSONAR\n }\n return updateResult\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ArenaRecordNode, ArenaRecordNodePointer } from '../../node';
|
|
2
|
-
import {
|
|
2
|
+
import { ArenaAnyNodeDef, ArenaNodeDefExpression } from '../../nodeDef';
|
|
3
3
|
import { ArenaSurvey, SurveyDependencyType } from '../../survey';
|
|
4
4
|
import { ArenaRecord } from '../record';
|
|
5
5
|
export declare const throwError: (params: {
|
|
@@ -7,7 +7,7 @@ export declare const throwError: (params: {
|
|
|
7
7
|
errorKey: string;
|
|
8
8
|
expressionType: SurveyDependencyType;
|
|
9
9
|
survey: ArenaSurvey;
|
|
10
|
-
nodeDef:
|
|
10
|
+
nodeDef: ArenaAnyNodeDef;
|
|
11
11
|
expressionsToEvaluate: ArenaNodeDefExpression[];
|
|
12
12
|
}) => never;
|
|
13
13
|
export declare const getDependentNodePointersByType: (params: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordNodesDependentsUpdaterCommons.js","sourceRoot":"","sources":["../../../src/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.ts"],"names":[],"mappings":";;;AAAA,uCAAyC;AAEzC,
|
|
1
|
+
{"version":3,"file":"recordNodesDependentsUpdaterCommons.js","sourceRoot":"","sources":["../../../src/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.ts"],"names":[],"mappings":";;;AAAA,uCAAyC;AAEzC,2CAAiF;AACjF,yCAAyE;AAEzE,wCAAoC;AAE7B,MAAM,UAAU,GAAG,CAAC,MAO1B,EAAE,EAAE;IACH,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,EAAE,GAAG,MAAM,CAAA;IAC1F,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAA;IACtC,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAA;IAE/D,MAAM,IAAI,mBAAW,CACnB,QAAQ,EACR;QACE,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI;QAC7B,WAAW;QACX,cAAc;QACd,iBAAiB;QACjB,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE;QACvB,SAAS,EAAE,KAAK,YAAY,mBAAW,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI;KAChE,EACD,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAA;AACH,CAAC,CAAA;AAxBY,QAAA,UAAU,GAAV,UAAU,CAwBtB;AAED,MAAM,oBAAo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ode, ArenaRecordNodePointer } from '../../node'\nimport { ArenaAnyNodeDef, ArenaNodeDefExpression, NodeDefs } from '../../nodeDef'\nimport { ArenaSurvey, SurveyDependencyType, Surveys } from '../../survey'\nimport { ArenaRecord } from '../record'\nimport { Records } from '../records'\n\nexport const throwError = (params: {\n error: any\n errorKey: string\n expressionType: SurveyDependencyType\n survey: ArenaSurvey\n nodeDef: ArenaAnyNodeDef\n expressionsToEvaluate: ArenaNodeDefExpression[]\n}) => {\n const { error, errorKey, expressionType, survey, nodeDef, expressionsToEvaluate } = params\n const nodeDefName = nodeDef.props.name\n const expressionsString = JSON.stringify(expressionsToEvaluate)\n\n throw new SystemError(\n errorKey,\n {\n surveyName: survey.props.name,\n nodeDefName,\n expressionType,\n expressionsString,\n error: error.toString(),\n errorJson: error instanceof SystemError ? error.toJSON() : null,\n },\n { cause: error }\n )\n}\n\nconst addPointerIfAccepted = (params: {\n nodePointers: ArenaRecordNodePointer[]\n pointer: ArenaRecordNodePointer\n filterFn?: (nodePointer: ArenaRecordNodePointer) => boolean\n}) => {\n const { nodePointers, pointer, filterFn } = params\n if (!filterFn || filterFn(pointer)) {\n nodePointers.push(pointer)\n }\n}\n\nconst addNewEntitySelfPointer = (params: {\n nodePointers: ArenaRecordNodePointer[]\n survey: ArenaSurvey\n record: ArenaRecord\n node: ArenaRecordNode\n sourceNodeDef: ArenaAnyNodeDef\n filterFn?: (nodePointer: ArenaRecordNodePointer) => boolean\n}) => {\n const { nodePointers, record, node, sourceNodeDef, filterFn } = params\n if (!node.parentUuid) {\n return\n }\n const parentNode = Records.getNodeByUuid(node.parentUuid)(record)\n if (!parentNode) {\n return\n }\n addPointerIfAccepted({\n nodePointers,\n pointer: { nodeCtx: parentNode, nodeDef: sourceNodeDef },\n filterFn,\n })\n}\n\nconst addNewEntityChildMultiplePointers = (params: {\n nodePointers: ArenaRecordNodePointer[]\n survey: ArenaSurvey\n node: ArenaRecordNode\n sourceNodeDef: ArenaAnyNodeDef\n filterFn?: (nodePointer: ArenaRecordNodePointer) => boolean\n}) => {\n const { nodePointers, survey, node, sourceNodeDef, filterFn } = params\n const multipleNodeDefs = Surveys.getNodeDefChildren({ survey, nodeDef: sourceNodeDef }).filter(NodeDefs.isMultiple)\n\n for (const childDef of multipleNodeDefs) {\n addPointerIfAccepted({\n nodePointers,\n pointer: { nodeCtx: node, nodeDef: childDef },\n filterFn,\n })\n }\n}\n\nexport const getDependentNodePointersByType = (params: {\n survey: ArenaSurvey\n record: ArenaRecord\n node: ArenaRecordNode\n dependencyType: SurveyDependencyType\n includeSelfWhenSourceIsAttribute?: boolean\n includeNewEntitySelf?: boolean\n includeNewEntityChildPointers?: boolean\n filterFn?: (nodePointer: ArenaRecordNodePointer) => boolean\n}): ArenaRecordNodePointer[] => {\n const {\n survey,\n record,\n node,\n dependencyType,\n includeSelfWhenSourceIsAttribute = false,\n includeNewEntitySelf = false,\n includeNewEntityChildPointers = false,\n filterFn,\n } = params\n\n const sourceNodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid })\n const includeSelf = includeSelfWhenSourceIsAttribute && !NodeDefs.isEntity(sourceNodeDef)\n\n const nodePointers = Records.getDependentNodePointers(survey, node, dependencyType, includeSelf, filterFn)(record)\n\n if (!NodeDefs.isEntity(sourceNodeDef) || !node.created) {\n return nodePointers\n }\n\n // For newly created entities, include a self-pointer for the source node.\n if (includeNewEntitySelf) {\n addNewEntitySelfPointer({ nodePointers, survey, record, node, sourceNodeDef, filterFn })\n }\n\n // For new entities, include child multiple nodes so their dependency metadata/status gets updated too.\n if (includeNewEntityChildPointers) {\n addNewEntityChildMultiplePointers({ nodePointers, survey, node, sourceNodeDef, filterFn })\n }\n\n return nodePointers\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ArenaRecord } from '../record';
|
|
2
|
-
import {
|
|
2
|
+
import { ArenaAnyNodeDef } from '../../nodeDef';
|
|
3
3
|
import { ArenaRecordNode } from '../../node';
|
|
4
4
|
import { ArenaValidationResult } from '../../validation';
|
|
5
5
|
import { ArenaSurvey } from '../../survey';
|
|
@@ -19,7 +19,7 @@ type SiblingEntitiesKeysIndex = {
|
|
|
19
19
|
* and compare them S times with the key values of every sibling.
|
|
20
20
|
*/
|
|
21
21
|
export type EntityKeysCache = {
|
|
22
|
-
keyDefsByEntityDefUuid: Map<string,
|
|
22
|
+
keyDefsByEntityDefUuid: Map<string, ArenaAnyNodeDef[]>;
|
|
23
23
|
keyValuesByEntityUuid: Map<string, ArenaDictionary<any>>;
|
|
24
24
|
equalityKeyByEntityUuid: Map<string, string | undefined>;
|
|
25
25
|
siblingEntitiesKeysIndexByParentAndDefUuid: Map<string, SiblingEntitiesKeysIndex>;
|
|
@@ -28,7 +28,7 @@ export declare const createEntityKeysCache: () => EntityKeysCache;
|
|
|
28
28
|
declare const validateAttributeKey: (params: {
|
|
29
29
|
survey: ArenaSurvey;
|
|
30
30
|
record: ArenaRecord;
|
|
31
|
-
nodeDef:
|
|
31
|
+
nodeDef: ArenaAnyNodeDef;
|
|
32
32
|
entityKeysCache?: EntityKeysCache;
|
|
33
33
|
}) => (_propName: string, node: ArenaRecordNode) => Promise<ArenaValidationResult>;
|
|
34
34
|
export declare const AttributeKeyValidator: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributeKeyValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/attributeKeyValidator.ts"],"names":[],"mappings":";;;AACA,wCAAoC;AACpC,2CAAsF;AACtF,qCAA2E;AAC3E,sDAA2D;AAC3D,iDAAqG;AACrG,yCAAmD;AAGnD,uCAAqC;AAwB9B,MAAM,qBAAqB,GAAG,GAAoB,EAAE,CAAC,CAAC;IAC3D,sBAAsB,EAAE,IAAI,GAAG,EAAE;IACjC,qBAAqB,EAAE,IAAI,GAAG,EAAE;IAChC,uBAAuB,EAAE,IAAI,GAAG,EAAE;IAClC,0CAA0C,EAAE,IAAI,GAAG,EAAE;CACtD,CAAC,CAAA;AALW,QAAA,q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AC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAA;IACnE,oEAAoE;IACpE,OAAO,CAAC,CAAC,aAAa,IAAI,CAAC,kBAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;AAC3D,CAAC,CAAA;AAED,MAAM,oBAAoB,GACxB,CAAC,MAKA,EAAE,EAAE,CACL,CAAC,SAAiB,EAAE,IAAqB,EAAkC,EAAE;IAC3E,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CAAA;IAE3D,IAAI,sBAAsB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;QAChD,MAAM,MAAM,GAAG,iBAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAA;QAC9C,IAAI,MAAM,IAAI,kBAAkB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC,EAAE,CAAC;YAC9E,OAAO,OAAO,CAAC,OAAO,CACpB,oCAAuB,CAAC,cAAc,CAAC;gBACrC,KAAK,EAAE,KAAK;gBACZ,QAAQ,EAAE,+BAAkB,CAAC,KAAK;gBAClC,GAAG,EAAE,4BAA4B;aAClC,CAAC,CACH,CAAA;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,oCAAuB,CAAC,cAAc,EAAE,CAAC,CAAA;AAClE,CAAC,CAAA;AAEU,QAAA,qBAAqB,GAAG;IACnC,oBAAoB;CACrB,CAAA","sourcesContent":["import { ArenaRecord } from '../record'\nimport { Records } from '../records'\nimport { ArenaNodeDef, NodeDefs, ArenaNodeDefProps, NodeDefType } from '../../nodeDef'\nimport { ArenaRecordNode, RecordNodes, RecordNodeValues } from '../../node'\nimport { getValueEqualityKey } from '../../node/nodeValues'\nimport { ArenaValidationResult, ValidationResultFactory, ValidationSeverity } from '../../validation'\nimport { ArenaSurvey, Surveys } from '../../survey'\n\nimport { ArenaDictionary } from '../../common'\nimport { Objects } from '../../utils'\n\n/**\n * Sibling entities (same parent and entity def) indexed by the equality key of their key values:\n * entities with the same equality key are duplicates; entities whose equality key cannot be built (see getValueEqualityKey)\n * are compared with every sibling.\n */\ntype SiblingEntitiesKeysIndex = {\n entitiesByEqualityKey: Map<string, ArenaRecordNode[]>\n entitiesWithoutEqualityKey: ArenaRecordNode[]\n}\n\n/**\n * Cache of entity key values (and key defs by entity def) used during a single validation run (the record doesn't change):\n * without it, validating the keys of S sibling entities would compute the key values of every sibling S times\n * and compare them S times with the key values of every sibling.\n */\nexport type EntityKeysCache = {\n keyDefsByEntityDefUuid: Map<string, ArenaNodeDef<NodeDefType, ArenaNodeDefProps>[]>\n keyValuesByEntityUuid: Map<string, ArenaDictionary<any>>\n equalityKeyByEntityUuid: Map<string, string | undefined>\n siblingEntitiesKeysIndexByParentAndDefUuid: Map<string, SiblingEntitiesKeysIndex>\n}\n\nexport const createEntityKeysCache = (): EntityKeysCache => ({\n keyDefsByEntityDefUuid: new Map(),\n keyValuesByEntityUuid: new Map(),\n equalityKeyByEntityUuid: new Map(),\n siblingEntitiesKeysIndexByParentAndDefUuid: new Map(),\n})\n\nconst _getKeyDefs = (params: {\n survey: ArenaSurvey\n entityDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n cache?: EntityKeysCache\n}): ArenaNodeDef<NodeDefType, ArenaNodeDefProps>[] => {\n const { survey, entityDef, cache } = params\n let keyDefs = cache?.keyDefsByEntityDefUuid.get(entityDef.uuid)\n if (!keyDefs) {\n keyDefs = Surveys.getNodeDefKeys({ survey, nodeDef: entityDef })\n cache?.keyDefsByEntityDefUuid.set(entityDef.uuid, keyDefs)\n }\n return keyDefs\n}\n\nconst _getKeyValuesByDefUuid = (params: {\n survey: ArenaSurvey\n record: ArenaRecord\n entity: ArenaRecordNode\n keyDefs: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>[]\n cache?: EntityKeysCache\n}): ArenaDictionary<any> => {\n const { survey, record, entity, keyDefs, cache } = params\n let keyValues = cache?.keyValuesByEntityUuid.get(entity.uuid)\n if (!keyValues) {\n keyValues = Records.getEntityKeyValuesByDefUuid(survey, entity, undefined, keyDefs)(record)\n cache?.keyValuesByEntityUuid.set(entity.uuid, keyValues)\n }\n return keyValues\n}\n\nconst _getEqualityKey = (params: {\n survey: ArenaSurvey\n entity: ArenaRecordNode\n keyDefs: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>[]\n keyValuesByDefUuid: ArenaDictionary<any>\n cache: EntityKeysCache\n}): string | undefined => {\n const { survey, entity, keyDefs, keyValuesByDefUuid, cache } = params\n if (cache.equalityKeyByEntityUuid.has(entity.uuid)) return cache.equalityKeyByEntityUuid.get(entity.uuid)\n\n const keyParts: string[] = []\n for (const keyDef of keyDefs) {\n const keyPart = getValueEqualityKey({ survey, nodeDef: keyDef, value: keyValuesByDefUuid[keyDef.uuid] })\n if (keyPart === undefined) {\n keyParts.length = 0\n break\n }\n keyParts.push(keyPart)\n }\n const equalityKey = keyParts.length > 0 ? JSON.stringify(keyParts) : undefined\n cache.equalityKeyByEntityUuid.set(entity.uuid, equalityKey)\n return equalityKey\n}\n\nconst _areKeyValuesEqual = (params: {\n survey: ArenaSurvey\n keyDefs: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>[]\n keyValuesByDefUuid: ArenaDictionary<any>\n siblingKeyValuesByDefUuid: ArenaDictionary<any>\n}): boolean => {\n const { survey, keyDefs, keyValuesByDefUuid, siblingKeyValuesByDefUuid } = params\n return keyDefs.every((keyDef) =>\n RecordNodeValues.isValueEqual({\n survey,\n nodeDef: keyDef,\n value: keyValuesByDefUuid[keyDef.uuid],\n valueSearch: siblingKeyValuesByDefUuid[keyDef.uuid],\n })\n )\n}\n\nconst _getSiblingEntitiesKeysIndex = (params: {\n survey: ArenaSurvey\n record: ArenaRecord\n nodeParent: ArenaRecordNode\n entityDefUuid: string\n keyDefs: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>[]\n cache: EntityKeysCache\n}): SiblingEntitiesKeysIndex => {\n const { survey, record, nodeParent, entityDefUuid, keyDefs, cache } = params\n const indexKey = `${nodeParent.uuid}_${entityDefUuid}`\n let index = cache.siblingEntitiesKeysIndexByParentAndDefUuid.get(indexKey)\n if (!index) {\n index = { entitiesByEqualityKey: new Map(), entitiesWithoutEqualityKey: [] }\n for (const siblingEntity of Records.getChildren(nodeParent, entityDefUuid)(record)) {\n const keyValuesByDefUuid = _getKeyValuesByDefUuid({ survey, record, entity: siblingEntity, keyDefs, cache })\n const equalityKey = _getEqualityKey({ survey, entity: siblingEntity, keyDefs, keyValuesByDefUuid, cache })\n if (equalityKey === undefined) {\n index.entitiesWithoutEqualityKey.push(siblingEntity)\n } else {\n const entitiesWithSameKey = index.entitiesByEqualityKey.get(equalityKey)\n if (entitiesWithSameKey) {\n entitiesWithSameKey.push(siblingEntity)\n } else {\n index.entitiesByEqualityKey.set(equalityKey, [siblingEntity])\n }\n }\n }\n cache.siblingEntitiesKeysIndexByParentAndDefUuid.set(indexKey, index)\n }\n return index\n}\n\nconst _isEntityDuplicate = (params: {\n survey: ArenaSurvey\n record: ArenaRecord\n entity: ArenaRecordNode\n entityKeysCache?: EntityKeysCache\n}): boolean => {\n const { survey, entity, record, entityKeysCache: cache } = params\n const nodeParent = Records.getParent(entity)(record)\n if (!nodeParent) return false\n\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const keyDefs = _getKeyDefs({ survey, entityDef, cache })\n if (Objects.isEmpty(keyDefs)) return false\n\n const keyValuesByDefUuid = _getKeyValuesByDefUuid({ survey, record, entity, keyDefs, cache })\n // entities with all key values empty are never duplicates (they are reported as missing values)\n if (Object.values(keyValuesByDefUuid).every(Objects.isEmpty)) return false\n\n const isDuplicateOf = (siblingEntity: ArenaRecordNode): boolean =>\n !RecordNodes.areEqual(entity, siblingEntity) &&\n _areKeyValuesEqual({\n survey,\n keyDefs,\n keyValuesByDefUuid,\n siblingKeyValuesByDefUuid: _getKeyValuesByDefUuid({ survey, record, entity: siblingEntity, keyDefs, cache }),\n })\n\n const equalityKey = cache ? _getEqualityKey({ survey, entity, keyDefs, keyValuesByDefUuid, cache }) : undefined\n if (!cache || equalityKey === undefined) {\n // compare the key values with the ones of every sibling entity\n return Records.getChildren(nodeParent, entity.nodeDefUuid)(record).some(isDuplicateOf)\n }\n // look up the sibling entities with the same key values in the index (built once for all the siblings)\n const index = _getSiblingEntitiesKeysIndex({\n survey,\n record,\n nodeParent,\n entityDefUuid: entity.nodeDefUuid,\n keyDefs,\n cache,\n })\n return (\n !!index.entitiesByEqualityKey\n .get(equalityKey)\n ?.some((siblingEntity) => !RecordNodes.areEqual(entity, siblingEntity)) ||\n index.entitiesWithoutEqualityKey.some(isDuplicateOf)\n )\n}\n\nconst isNodeDefToBeValidated = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n}): boolean => {\n const { survey, nodeDef } = params\n if (!NodeDefs.isKey(nodeDef)) return false\n\n const nodeDefParent = Surveys.getNodeDefParent({ survey, nodeDef })\n // root entity key attributes will be validated by another validator\n return !!nodeDefParent && !NodeDefs.isRoot(nodeDefParent)\n}\n\nconst validateAttributeKey =\n (params: {\n survey: ArenaSurvey\n record: ArenaRecord\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n entityKeysCache?: EntityKeysCache\n }) =>\n (_propName: string, node: ArenaRecordNode): Promise<ArenaValidationResult> => {\n const { survey, nodeDef, record, entityKeysCache } = params\n\n if (isNodeDefToBeValidated({ survey, nodeDef })) {\n const entity = Records.getParent(node)(record)\n if (entity && _isEntityDuplicate({ survey, record, entity, entityKeysCache })) {\n return Promise.resolve(\n ValidationResultFactory.createInstance({\n valid: false,\n severity: ValidationSeverity.error,\n key: 'record.entity.keyDuplicate',\n })\n )\n }\n }\n\n return Promise.resolve(ValidationResultFactory.createInstance())\n }\n\nexport const AttributeKeyValidator = {\n validateAttributeKey,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"attributeKeyValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/attributeKeyValidator.ts"],"names":[],"mappings":";;;AACA,wCAAoC;AACpC,2CAAyD;AACzD,qCAA2E;AAC3E,sDAA2D;AAC3D,iDAAqG;AACrG,yCAAmD;AAGnD,uCAAqC;AAwB9B,MAAM,qBAAqB,GAAG,GAAoB,EAAE,CAAC,CAAC;IAC3D,sBAAsB,EAAE,IAAI,GAAG,EAAE;IACjC,qBAAqB,EAAE,IAAI,GAAG,EAAE;IAChC,uBAAuB,EAAE,IAAI,GAAG,EAAE;IAClC,0CAA0C,EAAE,IAAI,GAAG,EAAE;CACtD,CAAC,CAAA;AALW,QAAA,qBAAqB,GAArB,qBAAqB,CAKhC;AAEF,MAAM,WAAW,GAAG,CAAC,MAIpB,EAAqB,EAAE;IACtB,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IAC3C,IAAI,OAAO,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAC/D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,gBAAO,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAA;QAChE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAC5D,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,sBAAsB,GAAG,CAAC,MAM/B,EAAwB,EAAE;IACzB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IACzD,IAAI,SAAS,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE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aAClC,CAAC,CACH,CAAA;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,oCAAuB,CAAC,cAAc,EAAE,CAAC,CAAA;AAClE,CAAC,CAAA;AAEU,QAAA,qBAAqB,GAAG;IACnC,oBAAoB;CACrB,CAAA","sourcesContent":["import { ArenaRecord } from '../record'\nimport { Records } from '../records'\nimport { ArenaAnyNodeDef, NodeDefs } from '../../nodeDef'\nimport { ArenaRecordNode, RecordNodes, RecordNodeValues } from '../../node'\nimport { getValueEqualityKey } from '../../node/nodeValues'\nimport { ArenaValidationResult, ValidationResultFactory, ValidationSeverity } from '../../validation'\nimport { ArenaSurvey, Surveys } from '../../survey'\n\nimport { ArenaDictionary } from '../../common'\nimport { Objects } from '../../utils'\n\n/**\n * Sibling entities (same parent and entity def) indexed by the equality key of their key values:\n * entities with the same equality key are duplicates; entities whose equality key cannot be built (see getValueEqualityKey)\n * are compared with every sibling.\n */\ntype SiblingEntitiesKeysIndex = {\n entitiesByEqualityKey: Map<string, ArenaRecordNode[]>\n entitiesWithoutEqualityKey: ArenaRecordNode[]\n}\n\n/**\n * Cache of entity key values (and key defs by entity def) used during a single validation run (the record doesn't change):\n * without it, validating the keys of S sibling entities would compute the key values of every sibling S times\n * and compare them S times with the key values of every sibling.\n */\nexport type EntityKeysCache = {\n keyDefsByEntityDefUuid: Map<string, ArenaAnyNodeDef[]>\n keyValuesByEntityUuid: Map<string, ArenaDictionary<any>>\n equalityKeyByEntityUuid: Map<string, string | undefined>\n siblingEntitiesKeysIndexByParentAndDefUuid: Map<string, SiblingEntitiesKeysIndex>\n}\n\nexport const createEntityKeysCache = (): EntityKeysCache => ({\n keyDefsByEntityDefUuid: new Map(),\n keyValuesByEntityUuid: new Map(),\n equalityKeyByEntityUuid: new Map(),\n siblingEntitiesKeysIndexByParentAndDefUuid: new Map(),\n})\n\nconst _getKeyDefs = (params: {\n survey: ArenaSurvey\n entityDef: ArenaAnyNodeDef\n cache?: EntityKeysCache\n}): ArenaAnyNodeDef[] => {\n const { survey, entityDef, cache } = params\n let keyDefs = cache?.keyDefsByEntityDefUuid.get(entityDef.uuid)\n if (!keyDefs) {\n keyDefs = Surveys.getNodeDefKeys({ survey, nodeDef: entityDef })\n cache?.keyDefsByEntityDefUuid.set(entityDef.uuid, keyDefs)\n }\n return keyDefs\n}\n\nconst _getKeyValuesByDefUuid = (params: {\n survey: ArenaSurvey\n record: ArenaRecord\n entity: ArenaRecordNode\n keyDefs: ArenaAnyNodeDef[]\n cache?: EntityKeysCache\n}): ArenaDictionary<any> => {\n const { survey, record, entity, keyDefs, cache } = params\n let keyValues = cache?.keyValuesByEntityUuid.get(entity.uuid)\n if (!keyValues) {\n keyValues = Records.getEntityKeyValuesByDefUuid(survey, entity, undefined, keyDefs)(record)\n cache?.keyValuesByEntityUuid.set(entity.uuid, keyValues)\n }\n return keyValues\n}\n\nconst _getEqualityKey = (params: {\n survey: ArenaSurvey\n entity: ArenaRecordNode\n keyDefs: ArenaAnyNodeDef[]\n keyValuesByDefUuid: ArenaDictionary<any>\n cache: EntityKeysCache\n}): string | undefined => {\n const { survey, entity, keyDefs, keyValuesByDefUuid, cache } = params\n if (cache.equalityKeyByEntityUuid.has(entity.uuid)) return cache.equalityKeyByEntityUuid.get(entity.uuid)\n\n const keyParts: string[] = []\n for (const keyDef of keyDefs) {\n const keyPart = getValueEqualityKey({ survey, nodeDef: keyDef, value: keyValuesByDefUuid[keyDef.uuid] })\n if (keyPart === undefined) {\n keyParts.length = 0\n break\n }\n keyParts.push(keyPart)\n }\n const equalityKey = keyParts.length > 0 ? JSON.stringify(keyParts) : undefined\n cache.equalityKeyByEntityUuid.set(entity.uuid, equalityKey)\n return equalityKey\n}\n\nconst _areKeyValuesEqual = (params: {\n survey: ArenaSurvey\n keyDefs: ArenaAnyNodeDef[]\n keyValuesByDefUuid: ArenaDictionary<any>\n siblingKeyValuesByDefUuid: ArenaDictionary<any>\n}): boolean => {\n const { survey, keyDefs, keyValuesByDefUuid, siblingKeyValuesByDefUuid } = params\n return keyDefs.every((keyDef) =>\n RecordNodeValues.isValueEqual({\n survey,\n nodeDef: keyDef,\n value: keyValuesByDefUuid[keyDef.uuid],\n valueSearch: siblingKeyValuesByDefUuid[keyDef.uuid],\n })\n )\n}\n\nconst _getSiblingEntitiesKeysIndex = (params: {\n survey: ArenaSurvey\n record: ArenaRecord\n nodeParent: ArenaRecordNode\n entityDefUuid: string\n keyDefs: ArenaAnyNodeDef[]\n cache: EntityKeysCache\n}): SiblingEntitiesKeysIndex => {\n const { survey, record, nodeParent, entityDefUuid, keyDefs, cache } = params\n const indexKey = `${nodeParent.uuid}_${entityDefUuid}`\n let index = cache.siblingEntitiesKeysIndexByParentAndDefUuid.get(indexKey)\n if (!index) {\n index = { entitiesByEqualityKey: new Map(), entitiesWithoutEqualityKey: [] }\n for (const siblingEntity of Records.getChildren(nodeParent, entityDefUuid)(record)) {\n const keyValuesByDefUuid = _getKeyValuesByDefUuid({ survey, record, entity: siblingEntity, keyDefs, cache })\n const equalityKey = _getEqualityKey({ survey, entity: siblingEntity, keyDefs, keyValuesByDefUuid, cache })\n if (equalityKey === undefined) {\n index.entitiesWithoutEqualityKey.push(siblingEntity)\n } else {\n const entitiesWithSameKey = index.entitiesByEqualityKey.get(equalityKey)\n if (entitiesWithSameKey) {\n entitiesWithSameKey.push(siblingEntity)\n } else {\n index.entitiesByEqualityKey.set(equalityKey, [siblingEntity])\n }\n }\n }\n cache.siblingEntitiesKeysIndexByParentAndDefUuid.set(indexKey, index)\n }\n return index\n}\n\nconst _isEntityDuplicate = (params: {\n survey: ArenaSurvey\n record: ArenaRecord\n entity: ArenaRecordNode\n entityKeysCache?: EntityKeysCache\n}): boolean => {\n const { survey, entity, record, entityKeysCache: cache } = params\n const nodeParent = Records.getParent(entity)(record)\n if (!nodeParent) return false\n\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const keyDefs = _getKeyDefs({ survey, entityDef, cache })\n if (Objects.isEmpty(keyDefs)) return false\n\n const keyValuesByDefUuid = _getKeyValuesByDefUuid({ survey, record, entity, keyDefs, cache })\n // entities with all key values empty are never duplicates (they are reported as missing values)\n if (Object.values(keyValuesByDefUuid).every(Objects.isEmpty)) return false\n\n const isDuplicateOf = (siblingEntity: ArenaRecordNode): boolean =>\n !RecordNodes.areEqual(entity, siblingEntity) &&\n _areKeyValuesEqual({\n survey,\n keyDefs,\n keyValuesByDefUuid,\n siblingKeyValuesByDefUuid: _getKeyValuesByDefUuid({ survey, record, entity: siblingEntity, keyDefs, cache }),\n })\n\n const equalityKey = cache ? _getEqualityKey({ survey, entity, keyDefs, keyValuesByDefUuid, cache }) : undefined\n if (!cache || equalityKey === undefined) {\n // compare the key values with the ones of every sibling entity\n return Records.getChildren(nodeParent, entity.nodeDefUuid)(record).some(isDuplicateOf)\n }\n // look up the sibling entities with the same key values in the index (built once for all the siblings)\n const index = _getSiblingEntitiesKeysIndex({\n survey,\n record,\n nodeParent,\n entityDefUuid: entity.nodeDefUuid,\n keyDefs,\n cache,\n })\n return (\n !!index.entitiesByEqualityKey\n .get(equalityKey)\n ?.some((siblingEntity) => !RecordNodes.areEqual(entity, siblingEntity)) ||\n index.entitiesWithoutEqualityKey.some(isDuplicateOf)\n )\n}\n\nconst isNodeDefToBeValidated = (params: { survey: ArenaSurvey; nodeDef: ArenaAnyNodeDef }): boolean => {\n const { survey, nodeDef } = params\n if (!NodeDefs.isKey(nodeDef)) return false\n\n const nodeDefParent = Surveys.getNodeDefParent({ survey, nodeDef })\n // root entity key attributes will be validated by another validator\n return !!nodeDefParent && !NodeDefs.isRoot(nodeDefParent)\n}\n\nconst validateAttributeKey =\n (params: { survey: ArenaSurvey; record: ArenaRecord; nodeDef: ArenaAnyNodeDef; entityKeysCache?: EntityKeysCache }) =>\n (_propName: string, node: ArenaRecordNode): Promise<ArenaValidationResult> => {\n const { survey, nodeDef, record, entityKeysCache } = params\n\n if (isNodeDefToBeValidated({ survey, nodeDef })) {\n const entity = Records.getParent(node)(record)\n if (entity && _isEntityDuplicate({ survey, record, entity, entityKeysCache })) {\n return Promise.resolve(\n ValidationResultFactory.createInstance({\n valid: false,\n severity: ValidationSeverity.error,\n key: 'record.entity.keyDuplicate',\n })\n )\n }\n }\n\n return Promise.resolve(ValidationResultFactory.createInstance())\n }\n\nexport const AttributeKeyValidator = {\n validateAttributeKey,\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArenaAnyNodeDef } from '../../nodeDef';
|
|
2
2
|
import { ArenaRecordNode } from '../../node';
|
|
3
3
|
import { ArenaValidationResult } from '../../validation';
|
|
4
4
|
import { ArenaSurvey } from '../../survey';
|
|
@@ -10,7 +10,7 @@ interface AttributeTypeValidatorParams {
|
|
|
10
10
|
categoryItemProvider?: ArenaCategoryItemProvider;
|
|
11
11
|
taxonProvider?: ArenaTaxonProvider;
|
|
12
12
|
record: ArenaRecord;
|
|
13
|
-
nodeDef:
|
|
13
|
+
nodeDef: ArenaAnyNodeDef;
|
|
14
14
|
}
|
|
15
15
|
declare const validateValueType: (params: AttributeTypeValidatorParams) => (_propName: string, node: ArenaRecordNode) => Promise<ArenaValidationResult>;
|
|
16
16
|
export declare const AttributeTypeValidator: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributeTypeValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/attributeTypeValidator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAOsB;AACtB,qCAAyD;AACzD,iDAAiF;AACjF,yCAAmD;AACnD,sDAAwD;AACxD,mCAAkC;AAClC,uCAA4C;AAG5C,6CAAqC;AAgBrC,MAAM,eAAe,GAAG,CAAC,MAA4C,EAAW,EAAE;IAChF,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IACxB,sHAAsH;IACtH,OAAO,eAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC/B,CAAC,CAAA;AAED,MAAM,Y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E,GAAG,MAAM,CAAA;QACvB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG;YAC9B,6BAAgB,CAAC,WAAW,CAAC,IAAI,CAAC;YAClC,6BAAgB,CAAC,aAAa,CAAC,IAAI,CAAC;YACpC,6BAAgB,CAAC,cAAc,CAAC,IAAI,CAAC;SACtC,CAAA;QACD,OAAO,aAAK,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC;CACF,CAAA;AAED,MAAM,iBAAiB,GACrB,CAAC,MAAoC,EAAE,EAAE,CACzC,CAAO,SAAiB,EAAE,IAAqB,EAAkC,EAAE;;IACjF,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,aAAa,EAAE,GAAG,MAAM,CAAA;IAE/E,IAAI,kBAAW,CAAC,YAAY,CAAC,IAAI,CAAC;QAAE,OAAO,oCAAuB,CAAC,cAAc,EAAE,CAAA;IAEnF,MAAM,eAAe,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACtD,MAAM,KAAK,SACT,CAAC,MAAM,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAG;QACvB,MAAM;QACN,oBAAoB;QACpB,aAAa;QACb,MAAM;QACN,OAAO;QACP,IAAI;QACJ,KAAK,EAAE,IAAI,CAAC,KAAK;KAClB,CAAC,CAAC,mCAAI,IAAI,CAAA;IACb,OAAO,oCAAuB,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,+BAA+B,EAAE,KAAK,EAAE,CAAC,CAAA;AAChG,CAAC,CAAA,CAAA;AAEU,QAAA,sBAAsB,GAAG;IACpC,iBAAiB;CAClB,CAAA","sourcesContent":["import {\n ArenaNodeDef,\n ArenaNodeDefCode,\n ArenaNodeDefProps,\n NodeDefs,\n ArenaNodeDefTaxon,\n NodeDefType,\n} from '../../nodeDef'\nimport { ArenaRecordNode, RecordNodes } from '../../node'\nimport { ArenaValidationResult, ValidationResultFactory } from '../../validation'\nimport { ArenaSurvey, Surveys } from '../../survey'\nimport { RecordNodeValues } from '../../node/nodeValues'\nimport { Points } from '../../geo'\nimport { Numbers, Dates } from '../../utils'\nimport { ArenaCategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider'\nimport { ArenaTaxonProvider } from '../../nodeDefExpressionEvaluator/taxonProvider'\nimport { Taxa } from '../../taxonomy'\nimport { ArenaRecord } from '../record'\n\ninterface AttributeTypeValidatorParams {\n survey: ArenaSurvey\n categoryItemProvider?: ArenaCategoryItemProvider\n taxonProvider?: ArenaTaxonProvider\n record: ArenaRecord\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n}\n\ninterface AttributeTypeValidatorInternalParams extends AttributeTypeValidatorParams {\n node: ArenaRecordNode\n value: any\n}\n\nconst validateDecimal = (params: AttributeTypeValidatorInternalParams): boolean => {\n const { value } = params\n // the max number of decimal digits is not validated: it is applied when formatting the value (see nodeValueFormatter)\n return Numbers.isFloat(value)\n}\n\nconst validateCode = async (params: AttributeTypeValidatorInternalParams) => {\n const { survey, record, node, categoryItemProvider } = params\n const itemUuid = RecordNodeValues.getItemUuid(node)\n if (!itemUuid) return true\n\n let item = Surveys.getCategoryItemByUuid({ survey, itemUuid })\n if (item) return true\n\n if (!categoryItemProvider) return false\n\n // loookup item with categoryItemProvider\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid }) as ArenaNodeDefCode\n const categoryUuid = NodeDefs.getCategoryUuid(nodeDef)\n if (!categoryUuid) return false\n const draft = !!record.preview\n item = await categoryItemProvider.getItemByUuid({ survey, categoryUuid, itemUuid, draft })\n return Boolean(item)\n}\n\nconst validateTaxon = async (params: AttributeTypeValidatorInternalParams): Promise<boolean> => {\n const { survey, record, node, taxonProvider } = params\n const taxonUuid = RecordNodeValues.getTaxonUuid(node)\n if (!taxonUuid) return true\n\n let taxon = Surveys.getTaxonByUuid({ survey, taxonUuid })\n if (!taxon && taxonProvider) {\n // lookup taxon with taxonProvider\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid }) as ArenaNodeDefTaxon\n const taxonomyUuid = NodeDefs.getTaxonomyUuid(nodeDef)\n if (!taxonomyUuid) return false\n const draft = !!record.preview\n taxon = await taxonProvider.getTaxonByUuid({ survey, taxonomyUuid, taxonUuid, draft })\n }\n if (!taxon) return false\n\n const vernacularNameUuid = RecordNodeValues.getVernacularNameUuid(node)\n if (!vernacularNameUuid) return true\n\n const vernacularName = Taxa.getVernacularNameByUuid(vernacularNameUuid)(taxon)\n return !!vernacularName\n}\n\nconst typeValidatorFns: {\n [key in NodeDefType]?: (params: AttributeTypeValidatorInternalParams) => boolean | Promise<boolean>\n} = {\n [NodeDefType.boolean]: (params: AttributeTypeValidatorInternalParams): boolean =>\n ['true', 'false'].includes(params.value),\n [NodeDefType.code]: validateCode,\n [NodeDefType.coordinate]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { survey, node } = params\n\n const point = RecordNodeValues.getValueAsPoint({ survey, node })\n if (!point) return false\n\n const srsIndex = Surveys.getSRSIndex(survey)\n\n return Points.isValid(point, srsIndex)\n },\n\n [NodeDefType.date]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { node } = params\n const [year, month, day] = [\n RecordNodeValues.getDateYear(node),\n RecordNodeValues.getDateMonth(node),\n RecordNodeValues.getDateDay(node),\n ]\n return Dates.isValidDate(year, month, day)\n },\n\n [NodeDefType.decimal]: validateDecimal,\n\n [NodeDefType.integer]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { value } = params\n return Numbers.isInteger(value)\n },\n\n [NodeDefType.taxon]: validateTaxon,\n\n [NodeDefType.text]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { value } = params\n return typeof value === 'string'\n },\n\n [NodeDefType.time]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { node } = params\n const [hour, minute, seconds] = [\n RecordNodeValues.getTimeHour(node),\n RecordNodeValues.getTimeMinute(node),\n RecordNodeValues.getTimeSeconds(node),\n ]\n return Dates.isValidTime(hour, minute, seconds)\n },\n}\n\nconst validateValueType =\n (params: AttributeTypeValidatorParams) =>\n async (_propName: string, node: ArenaRecordNode): Promise<ArenaValidationResult> => {\n const { survey, nodeDef, record, categoryItemProvider, taxonProvider } = params\n\n if (RecordNodes.isValueBlank(node)) return ValidationResultFactory.createInstance()\n\n const typeValidatorFn = typeValidatorFns[nodeDef.type]\n const valid =\n (await typeValidatorFn?.({\n survey,\n categoryItemProvider,\n taxonProvider,\n record,\n nodeDef,\n node,\n value: node.value,\n })) ?? true\n return ValidationResultFactory.createInstance({ key: 'record.attribute.valueInvalid', valid })\n }\n\nexport const AttributeTypeValidator = {\n validateValueType,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"attributeTypeValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/attributeTypeValidator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA2G;AAC3G,qCAAyD;AACzD,iDAAiF;AACjF,yCAAmD;AACnD,sDAAwD;AACxD,mCAAkC;AAClC,uCAA4C;AAG5C,6CAAqC;AAgBrC,MAAM,eAAe,GAAG,CAAC,MAA4C,EAAW,EAAE;IAChF,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IACxB,sHAAsH;IACtH,OAAO,eAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC/B,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,CAAO,MAA4C,EAAE,EAAE;IAC1E,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAA;IAC7D,MAAM,QAAQ,GAAG,6BAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IACnD,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAA;IAE1B,IAAI,IAAI,GAAG,gBAAO,CAAC,qBAAqB,CAAC,EAAE,MAAM,EAAE,QAAQ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,CAAA;AAED,MAAM,iBAAiB,GACrB,CAAC,MAAoC,EAAE,EAAE,CACzC,CAAO,SAAiB,EAAE,IAAqB,EAAkC,EAAE;;IACjF,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,aAAa,EAAE,GAAG,MAAM,CAAA;IAE/E,IAAI,kBAAW,CAAC,YAAY,CAAC,IAAI,CAAC;QAAE,OAAO,oCAAuB,CAAC,cAAc,EAAE,CAAA;IAEnF,MAAM,eAAe,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACtD,MAAM,KAAK,SACT,CAAC,MAAM,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAG;QACvB,MAAM;QACN,oBAAoB;QACpB,aAAa;QACb,MAAM;QACN,OAAO;QACP,IAAI;QACJ,KAAK,EAAE,IAAI,CAAC,KAAK;KAClB,CAAC,CAAC,mCAAI,IAAI,CAAA;IACb,OAAO,oCAAuB,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,+BAA+B,EAAE,KAAK,EAAE,CAAC,CAAA;AAChG,CAAC,CAAA,CAAA;AAEU,QAAA,sBAAsB,GAAG;IACpC,iBAAiB;CAClB,CAAA","sourcesContent":["import { ArenaAnyNodeDef, ArenaNodeDefCode, NodeDefs, ArenaNodeDefTaxon, NodeDefType } from '../../nodeDef'\nimport { ArenaRecordNode, RecordNodes } from '../../node'\nimport { ArenaValidationResult, ValidationResultFactory } from '../../validation'\nimport { ArenaSurvey, Surveys } from '../../survey'\nimport { RecordNodeValues } from '../../node/nodeValues'\nimport { Points } from '../../geo'\nimport { Numbers, Dates } from '../../utils'\nimport { ArenaCategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider'\nimport { ArenaTaxonProvider } from '../../nodeDefExpressionEvaluator/taxonProvider'\nimport { Taxa } from '../../taxonomy'\nimport { ArenaRecord } from '../record'\n\ninterface AttributeTypeValidatorParams {\n survey: ArenaSurvey\n categoryItemProvider?: ArenaCategoryItemProvider\n taxonProvider?: ArenaTaxonProvider\n record: ArenaRecord\n nodeDef: ArenaAnyNodeDef\n}\n\ninterface AttributeTypeValidatorInternalParams extends AttributeTypeValidatorParams {\n node: ArenaRecordNode\n value: any\n}\n\nconst validateDecimal = (params: AttributeTypeValidatorInternalParams): boolean => {\n const { value } = params\n // the max number of decimal digits is not validated: it is applied when formatting the value (see nodeValueFormatter)\n return Numbers.isFloat(value)\n}\n\nconst validateCode = async (params: AttributeTypeValidatorInternalParams) => {\n const { survey, record, node, categoryItemProvider } = params\n const itemUuid = RecordNodeValues.getItemUuid(node)\n if (!itemUuid) return true\n\n let item = Surveys.getCategoryItemByUuid({ survey, itemUuid })\n if (item) return true\n\n if (!categoryItemProvider) return false\n\n // loookup item with categoryItemProvider\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid }) as ArenaNodeDefCode\n const categoryUuid = NodeDefs.getCategoryUuid(nodeDef)\n if (!categoryUuid) return false\n const draft = !!record.preview\n item = await categoryItemProvider.getItemByUuid({ survey, categoryUuid, itemUuid, draft })\n return Boolean(item)\n}\n\nconst validateTaxon = async (params: AttributeTypeValidatorInternalParams): Promise<boolean> => {\n const { survey, record, node, taxonProvider } = params\n const taxonUuid = RecordNodeValues.getTaxonUuid(node)\n if (!taxonUuid) return true\n\n let taxon = Surveys.getTaxonByUuid({ survey, taxonUuid })\n if (!taxon && taxonProvider) {\n // lookup taxon with taxonProvider\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid }) as ArenaNodeDefTaxon\n const taxonomyUuid = NodeDefs.getTaxonomyUuid(nodeDef)\n if (!taxonomyUuid) return false\n const draft = !!record.preview\n taxon = await taxonProvider.getTaxonByUuid({ survey, taxonomyUuid, taxonUuid, draft })\n }\n if (!taxon) return false\n\n const vernacularNameUuid = RecordNodeValues.getVernacularNameUuid(node)\n if (!vernacularNameUuid) return true\n\n const vernacularName = Taxa.getVernacularNameByUuid(vernacularNameUuid)(taxon)\n return !!vernacularName\n}\n\nconst typeValidatorFns: {\n [key in NodeDefType]?: (params: AttributeTypeValidatorInternalParams) => boolean | Promise<boolean>\n} = {\n [NodeDefType.boolean]: (params: AttributeTypeValidatorInternalParams): boolean =>\n ['true', 'false'].includes(params.value),\n [NodeDefType.code]: validateCode,\n [NodeDefType.coordinate]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { survey, node } = params\n\n const point = RecordNodeValues.getValueAsPoint({ survey, node })\n if (!point) return false\n\n const srsIndex = Surveys.getSRSIndex(survey)\n\n return Points.isValid(point, srsIndex)\n },\n\n [NodeDefType.date]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { node } = params\n const [year, month, day] = [\n RecordNodeValues.getDateYear(node),\n RecordNodeValues.getDateMonth(node),\n RecordNodeValues.getDateDay(node),\n ]\n return Dates.isValidDate(year, month, day)\n },\n\n [NodeDefType.decimal]: validateDecimal,\n\n [NodeDefType.integer]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { value } = params\n return Numbers.isInteger(value)\n },\n\n [NodeDefType.taxon]: validateTaxon,\n\n [NodeDefType.text]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { value } = params\n return typeof value === 'string'\n },\n\n [NodeDefType.time]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { node } = params\n const [hour, minute, seconds] = [\n RecordNodeValues.getTimeHour(node),\n RecordNodeValues.getTimeMinute(node),\n RecordNodeValues.getTimeSeconds(node),\n ]\n return Dates.isValidTime(hour, minute, seconds)\n },\n}\n\nconst validateValueType =\n (params: AttributeTypeValidatorParams) =>\n async (_propName: string, node: ArenaRecordNode): Promise<ArenaValidationResult> => {\n const { survey, nodeDef, record, categoryItemProvider, taxonProvider } = params\n\n if (RecordNodes.isValueBlank(node)) return ValidationResultFactory.createInstance()\n\n const typeValidatorFn = typeValidatorFns[nodeDef.type]\n const valid =\n (await typeValidatorFn?.({\n survey,\n categoryItemProvider,\n taxonProvider,\n record,\n nodeDef,\n node,\n value: node.value,\n })) ?? true\n return ValidationResultFactory.createInstance({ key: 'record.attribute.valueInvalid', valid })\n }\n\nexport const AttributeTypeValidator = {\n validateValueType,\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ArenaRecordNode } from '../../node';
|
|
2
|
-
import {
|
|
2
|
+
import { ArenaAnyNodeDef } from '../../nodeDef';
|
|
3
3
|
import { ArenaSurvey } from '../../survey';
|
|
4
4
|
import { ArenaValidationResult } from '../../validation';
|
|
5
5
|
import { ArenaRecord } from '../record';
|
|
6
6
|
export declare const validateAttributeUnique: (params: {
|
|
7
7
|
survey: ArenaSurvey;
|
|
8
8
|
record: ArenaRecord;
|
|
9
|
-
nodeDef:
|
|
9
|
+
nodeDef: ArenaAnyNodeDef;
|
|
10
10
|
}) => (_propName: string, node: ArenaRecordNode) => Promise<ArenaValidationResult>;
|
|
11
11
|
export declare const AttributeUniqueValidator: {
|
|
12
12
|
validateAttributeUnique: typeof validateAttributeUnique;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributeUniqueValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/attributeUniqueValidator.ts"],"names":[],"mappings":";;;AAAA,qCAA2E;AAC3E,
|
|
1
|
+
{"version":3,"file":"attributeUniqueValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/attributeUniqueValidator.ts"],"names":[],"mappings":";;;AAAA,qCAA2E;AAC3E,2CAAyD;AACzD,yCAAmD;AACnD,iDAAqG;AAErG,wCAAoC;AAEpC,MAAM,qBAAqB,GAAG,CAAC,MAK9B,EAAW,EAAE;IACZ,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IACrD,+CAA+C;IAC/C,IAAI,kBAAW,CAAC,YAAY,CAAC,SAAS,CAAC;QAAE,OAAO,KAAK,CAAA;IACrD,MAAM,YAAY,GAAG,iBAAO,CAAC,oBAAoB,CAAC,SAAS,EAAE,OA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KAAK;YACZ,QAAQ,EAAE,+BAAkB,CAAC,KAAK;YAClC,GAAG,EAAE,kCAAkC;SACxC,CAAC,CACH,CAAA;IACH,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,oCAAuB,CAAC,cAAc,EAAE,CAAC,CAAA;AAClE,CAAC,CAAA;AAnBU,QAAA,uBAAuB,GAAvB,uBAAuB,CAmBjC;AAEU,QAAA,wBAAwB,GAAG;IACtC,uBAAuB,EAAvB,QAAA,uBAAuB;CACxB,CAAA","sourcesContent":["import { ArenaRecordNode, RecordNodes, RecordNodeValues } from '../../node'\nimport { ArenaAnyNodeDef, NodeDefs } from '../../nodeDef'\nimport { ArenaSurvey, Surveys } from '../../survey'\nimport { ArenaValidationResult, ValidationResultFactory, ValidationSeverity } from '../../validation'\nimport { ArenaRecord } from '../record'\nimport { Records } from '../records'\n\nconst _isAttributeDuplicate = (params: {\n survey: ArenaSurvey\n record: ArenaRecord\n attribute: ArenaRecordNode\n nodeDef: ArenaAnyNodeDef\n}): boolean => {\n const { survey, attribute, record, nodeDef } = params\n // blank values are never considered duplicates\n if (RecordNodes.isValueBlank(attribute)) return false\n const nodeSiblings = Records.getAttributeSiblings(attribute, nodeDef)(record)\n return nodeSiblings.some((sibling) =>\n RecordNodeValues.isValueEqual({ survey, nodeDef, value: sibling.value, valueSearch: attribute.value })\n )\n}\n\nconst isNodeDefToBeValidated = (params: { survey: ArenaSurvey; nodeDef: ArenaAnyNodeDef }): boolean => {\n const { survey, nodeDef } = params\n const nodeDefValidations = NodeDefs.getValidations(nodeDef)\n if (!nodeDefValidations?.unique) return false\n\n const nodeDefParent = Surveys.getNodeDefParent({ survey, nodeDef })\n if (!nodeDefParent || NodeDefs.isRoot(nodeDefParent)) {\n // uniqueness at record level evaluated elsewhere\n return false\n }\n return true\n}\n\nexport const validateAttributeUnique =\n (params: { survey: ArenaSurvey; record: ArenaRecord; nodeDef: ArenaAnyNodeDef }) =>\n (_propName: string, node: ArenaRecordNode): Promise<ArenaValidationResult> => {\n const { survey, record, nodeDef } = params\n\n if (\n isNodeDefToBeValidated({ survey, nodeDef }) &&\n _isAttributeDuplicate({ survey, record, attribute: node, nodeDef })\n ) {\n return Promise.resolve(\n ValidationResultFactory.createInstance({\n valid: false,\n severity: ValidationSeverity.error,\n key: 'record.attribute.uniqueDuplicate',\n })\n )\n }\n\n return Promise.resolve(ValidationResultFactory.createInstance())\n }\n\nexport const AttributeUniqueValidator = {\n validateAttributeUnique,\n}\n"]}
|