@openforis/arena-core 2.3.41 → 2.4.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.
Files changed (176) hide show
  1. package/dist/esm/index.js.map +1 -1
  2. package/dist/esm/node/nodes.js +12 -4
  3. package/dist/esm/node/nodes.js.map +1 -1
  4. package/dist/esm/record/_records/recordCompletion.js +3 -3
  5. package/dist/esm/record/_records/recordCompletion.js.map +1 -1
  6. package/dist/esm/record/_records/recordGetters.js +221 -143
  7. package/dist/esm/record/_records/recordGetters.js.map +1 -1
  8. package/dist/esm/record/_records/recordNodesIndexUpdater.js +6 -4
  9. package/dist/esm/record/_records/recordNodesIndexUpdater.js.map +1 -1
  10. package/dist/esm/record/_records/recordPagesValidation.js +5 -5
  11. package/dist/esm/record/_records/recordPagesValidation.js.map +1 -1
  12. package/dist/esm/record/_records/recordUpdateOptions.js.map +1 -1
  13. package/dist/esm/record/_records/recordUpdater.js +1 -1
  14. package/dist/esm/record/_records/recordUpdater.js.map +1 -1
  15. package/dist/esm/record/_records/recordUtils.js +3 -7
  16. package/dist/esm/record/_records/recordUtils.js.map +1 -1
  17. package/dist/esm/record/nodePointers.js +1 -1
  18. package/dist/esm/record/nodePointers.js.map +1 -1
  19. package/dist/esm/record/recordCloner.js +1 -1
  20. package/dist/esm/record/recordCloner.js.map +1 -1
  21. package/dist/esm/record/recordExpressionEvaluator/functions.js +4 -5
  22. package/dist/esm/record/recordExpressionEvaluator/functions.js.map +1 -1
  23. package/dist/esm/record/recordExpressionEvaluator/node/identifier/identifier.js +1 -1
  24. package/dist/esm/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
  25. package/dist/esm/record/recordExpressionEvaluator/node/identifier/nodesFinder.js +2 -2
  26. package/dist/esm/record/recordExpressionEvaluator/node/identifier/nodesFinder.js.map +1 -1
  27. package/dist/esm/record/recordExpressionEvaluator/recordExpressionEvaluator.js +1 -1
  28. package/dist/esm/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
  29. package/dist/esm/record/recordFixer.js +5 -5
  30. package/dist/esm/record/recordFixer.js.map +1 -1
  31. package/dist/esm/record/recordNodesUpdater/recordExpressionValueConverter.js +2 -8
  32. package/dist/esm/record/recordNodesUpdater/recordExpressionValueConverter.js.map +1 -1
  33. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js +7 -7
  34. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js.map +1 -1
  35. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js +1 -1
  36. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js.map +1 -1
  37. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js +1 -1
  38. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js.map +1 -1
  39. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsCountUpdater.js +1 -6
  40. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsCountUpdater.js.map +1 -1
  41. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js +3 -4
  42. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js.map +1 -1
  43. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEditableUpdater.js +1 -1
  44. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEditableUpdater.js.map +1 -1
  45. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js +3 -3
  46. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js.map +1 -1
  47. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js +4 -9
  48. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js.map +1 -1
  49. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js +2 -3
  50. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
  51. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsVisibleUpdater.js +1 -1
  52. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsVisibleUpdater.js.map +1 -1
  53. package/dist/esm/record/recordNodesUpdater/recordNodesDeleter.js +2 -6
  54. package/dist/esm/record/recordNodesUpdater/recordNodesDeleter.js.map +1 -1
  55. package/dist/esm/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js +2 -9
  56. package/dist/esm/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
  57. package/dist/esm/record/recordNodesUpdater/recordNodesUpdater.js +1 -1
  58. package/dist/esm/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
  59. package/dist/esm/record/recordPrettyPrinter.js +14 -12
  60. package/dist/esm/record/recordPrettyPrinter.js.map +1 -1
  61. package/dist/esm/record/recordUpdater.js +2 -2
  62. package/dist/esm/record/recordUpdater.js.map +1 -1
  63. package/dist/esm/record/recordValidator/attributeKeyValidator.js +4 -4
  64. package/dist/esm/record/recordValidator/attributeKeyValidator.js.map +1 -1
  65. package/dist/esm/record/recordValidator/attributeUniqueValidator.js +1 -1
  66. package/dist/esm/record/recordValidator/attributeUniqueValidator.js.map +1 -1
  67. package/dist/esm/record/recordValidator/attributeValidator.js +8 -10
  68. package/dist/esm/record/recordValidator/attributeValidator.js.map +1 -1
  69. package/dist/esm/record/recordValidator/countVaildator.js +2 -2
  70. package/dist/esm/record/recordValidator/countVaildator.js.map +1 -1
  71. package/dist/esm/record/recordValidator/recordValidator.js +1 -2
  72. package/dist/esm/record/recordValidator/recordValidator.js.map +1 -1
  73. package/dist/esm/survey/nodeDefsFixer.js.map +1 -1
  74. package/dist/esm/survey/surveys/_nodeDefs/nodeDefsIndex.js +2 -2
  75. package/dist/esm/survey/surveys/_nodeDefs/nodeDefsIndex.js.map +1 -1
  76. package/dist/esm/utils/index.js.map +1 -1
  77. package/dist/esm/utils/mutationOptions.js +5 -0
  78. package/dist/esm/utils/mutationOptions.js.map +1 -0
  79. package/dist/esm/validation/index.js.map +1 -1
  80. package/dist/esm/validation/validations.js +26 -19
  81. package/dist/esm/validation/validations.js.map +1 -1
  82. package/dist/index.d.ts +2 -2
  83. package/dist/index.js.map +1 -1
  84. package/dist/node/nodes.d.ts +10 -3
  85. package/dist/node/nodes.js +12 -4
  86. package/dist/node/nodes.js.map +1 -1
  87. package/dist/record/_records/recordCompletion.js +3 -3
  88. package/dist/record/_records/recordCompletion.js.map +1 -1
  89. package/dist/record/_records/recordGetters.d.ts +104 -51
  90. package/dist/record/_records/recordGetters.js +221 -170
  91. package/dist/record/_records/recordGetters.js.map +1 -1
  92. package/dist/record/_records/recordNodesIndexUpdater.d.ts +6 -3
  93. package/dist/record/_records/recordNodesIndexUpdater.js +6 -4
  94. package/dist/record/_records/recordNodesIndexUpdater.js.map +1 -1
  95. package/dist/record/_records/recordPagesValidation.js +5 -5
  96. package/dist/record/_records/recordPagesValidation.js.map +1 -1
  97. package/dist/record/_records/recordUpdateOptions.d.ts +2 -2
  98. package/dist/record/_records/recordUpdateOptions.js.map +1 -1
  99. package/dist/record/_records/recordUpdater.js +1 -1
  100. package/dist/record/_records/recordUpdater.js.map +1 -1
  101. package/dist/record/_records/recordUtils.js +3 -7
  102. package/dist/record/_records/recordUtils.js.map +1 -1
  103. package/dist/record/nodePointers.js +1 -1
  104. package/dist/record/nodePointers.js.map +1 -1
  105. package/dist/record/recordCloner.js +1 -1
  106. package/dist/record/recordCloner.js.map +1 -1
  107. package/dist/record/recordExpressionEvaluator/functions.js +4 -5
  108. package/dist/record/recordExpressionEvaluator/functions.js.map +1 -1
  109. package/dist/record/recordExpressionEvaluator/node/identifier/identifier.js +1 -1
  110. package/dist/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
  111. package/dist/record/recordExpressionEvaluator/node/identifier/nodesFinder.js +2 -2
  112. package/dist/record/recordExpressionEvaluator/node/identifier/nodesFinder.js.map +1 -1
  113. package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.js +1 -1
  114. package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
  115. package/dist/record/recordFixer.js +5 -5
  116. package/dist/record/recordFixer.js.map +1 -1
  117. package/dist/record/recordNodesUpdater/recordExpressionValueConverter.js +2 -8
  118. package/dist/record/recordNodesUpdater/recordExpressionValueConverter.js.map +1 -1
  119. package/dist/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js +7 -7
  120. package/dist/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js.map +1 -1
  121. package/dist/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.d.ts +2 -1
  122. package/dist/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js +1 -1
  123. package/dist/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js.map +1 -1
  124. package/dist/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js +1 -1
  125. package/dist/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js.map +1 -1
  126. package/dist/record/recordNodesUpdater/recordNodeDependentsCountUpdater.js +1 -6
  127. package/dist/record/recordNodesUpdater/recordNodeDependentsCountUpdater.js.map +1 -1
  128. package/dist/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js +3 -4
  129. package/dist/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js.map +1 -1
  130. package/dist/record/recordNodesUpdater/recordNodeDependentsEditableUpdater.js +1 -1
  131. package/dist/record/recordNodesUpdater/recordNodeDependentsEditableUpdater.js.map +1 -1
  132. package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js +3 -3
  133. package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js.map +1 -1
  134. package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js +4 -9
  135. package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js.map +1 -1
  136. package/dist/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js +2 -3
  137. package/dist/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
  138. package/dist/record/recordNodesUpdater/recordNodeDependentsVisibleUpdater.js +1 -1
  139. package/dist/record/recordNodesUpdater/recordNodeDependentsVisibleUpdater.js.map +1 -1
  140. package/dist/record/recordNodesUpdater/recordNodesDeleter.js +2 -6
  141. package/dist/record/recordNodesUpdater/recordNodesDeleter.js.map +1 -1
  142. package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js +2 -9
  143. package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
  144. package/dist/record/recordNodesUpdater/recordNodesUpdater.js +1 -1
  145. package/dist/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
  146. package/dist/record/recordPrettyPrinter.js +14 -12
  147. package/dist/record/recordPrettyPrinter.js.map +1 -1
  148. package/dist/record/recordUpdater.js +2 -2
  149. package/dist/record/recordUpdater.js.map +1 -1
  150. package/dist/record/recordValidator/attributeKeyValidator.js +4 -4
  151. package/dist/record/recordValidator/attributeKeyValidator.js.map +1 -1
  152. package/dist/record/recordValidator/attributeUniqueValidator.js +1 -1
  153. package/dist/record/recordValidator/attributeUniqueValidator.js.map +1 -1
  154. package/dist/record/recordValidator/attributeValidator.js +8 -10
  155. package/dist/record/recordValidator/attributeValidator.js.map +1 -1
  156. package/dist/record/recordValidator/countVaildator.js +2 -2
  157. package/dist/record/recordValidator/countVaildator.js.map +1 -1
  158. package/dist/record/recordValidator/recordValidator.js +1 -2
  159. package/dist/record/recordValidator/recordValidator.js.map +1 -1
  160. package/dist/record/records.d.ts +340 -40
  161. package/dist/survey/nodeDefsFixer.d.ts +2 -2
  162. package/dist/survey/nodeDefsFixer.js.map +1 -1
  163. package/dist/survey/surveys/_nodeDefs/nodeDefsIndex.d.ts +3 -6
  164. package/dist/survey/surveys/_nodeDefs/nodeDefsIndex.js +2 -2
  165. package/dist/survey/surveys/_nodeDefs/nodeDefsIndex.js.map +1 -1
  166. package/dist/utils/index.d.ts +1 -0
  167. package/dist/utils/index.js.map +1 -1
  168. package/dist/utils/mutationOptions.d.ts +14 -0
  169. package/dist/utils/mutationOptions.js +9 -0
  170. package/dist/utils/mutationOptions.js.map +1 -0
  171. package/dist/validation/index.d.ts +1 -0
  172. package/dist/validation/index.js.map +1 -1
  173. package/dist/validation/validations.d.ts +17 -2
  174. package/dist/validation/validations.js +26 -19
  175. package/dist/validation/validations.js.map +1 -1
  176. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"recordGetters.js","sourceRoot":"","sources":["../../../src/record/_records/recordGetters.ts"],"names":[],"mappings":";;;AAAA,yCAAyD;AACzD,uCAAyC;AACzC,qCAA0E;AAC1E,sDAAkD;AAClD,2CAA2G;AAC3G,yCAAoD;AAEpD,uCAA2C;AAC3C,sCAA4D;AAC5D,8CAAsD;AACtD,qEAAiE;AACjE,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,EAA+B,EAAE,wBAAC,MAAM,CAAC,KAAK,mCAAI,EAAE,GAAA,CAAA;AAAnF,QAAA,QAAQ,GAAR,QAAQ,CAA2E;AAEzF,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;AAEjG,MAAM,aAAa,GACxB,CAAC,IAAY,EAAE,EAAE,CACjB,CAAC,MAAmB,EAA+B,EAAE,kBACnD,MAAA,MAAM,CAAC,KAAK,0CAAG,IAAI,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,CAAC,IAAA,QAAA,oBAAoB,EAAC,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,YAAK,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AAHlF,QAAA,kBAAkB,GAAlB,kBAAkB,CAGgE;AAExF,MAAM,WAAW,GACtB,CAAC,IAAqB,EAAE,EAAE,CAC1B,CAAC,MAAmB,EAAW,EAAE,CAC/B,CAAC,IAAA,QAAA,kBAAkB,EAAC,IAAI,CAAC,CAAC,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 { Dictionary, TraverseMethod } from '../../common'\nimport { SystemError } from '../../error'\nimport { ArenaRecordNode, NodePointer, Nodes, NodesMap } from '../../node'\nimport { NodeValues } from '../../node/nodeValues'\nimport { NodeDef, NodeDefCode, NodeDefCodeProps, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { defaultCycle, Surveys } from '../../survey'\nimport { Survey, SurveyDependencyType } from '../../survey/survey'\nimport { Arrays, Queue } from '../../utils'\nimport { ArenaRecord, RECORD_STEP_DEFAULT } from '../record'\nimport { RecordStepAnalysisCode } from '../recordStep'\nimport { RecordNodesIndexReader } from './recordNodesIndexReader'\nimport { NodeDefSelfReferences } from './nodeDefSelfReferences'\n\nexport const getCycle = (record: ArenaRecord): string => record.cycle ?? defaultCycle\n\nexport const getNodes = (record: ArenaRecord): Dictionary<ArenaRecordNode> => record.nodes ?? {}\n\nexport const getNodesArray = (record: ArenaRecord): ArenaRecordNode[] => Object.values(getNodes(record))\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) => getNodeByUuid(uuid)(record)) as ArenaRecordNode[]\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\nexport const getChild =\n (parentNode: ArenaRecordNode, childDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode => {\n const children = getChildren(parentNode, childDefUuid)(record)\n const errorParams = { childDefUuid, parentNodeUuid: parentNode.uuid, recordUuid: record.uuid }\n if (children.length === 1) {\n return children[0]\n }\n if (children.length > 1) {\n throw new SystemError('systemError.record.multipleNodesFound', errorParams)\n }\n throw new SystemError('systemError.record.childNotFound', errorParams)\n }\n\nexport const getParent =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n node.parentUuid ? getNodeByUuid(node.parentUuid)(record) : undefined\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 (params: { record: ArenaRecord; node: ArenaRecordNode }): boolean => {\n const { record, node } = params\n const ancestorsAndSelf = getAncestorsAndSelf({ record, node })\n for (let i = 0; i < ancestorsAndSelf.length - 1; i++) {\n const child = ancestorsAndSelf[i]\n const parent = ancestorsAndSelf[i + 1]\n if (!isChildFlagTrue(parent, child.nodeDefUuid)) return false\n }\n return true\n }\n\nexport const isNodeApplicable = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildApplicable(parent, nodeDefUuid))\nexport const isNodeEditable = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildEditable(parent, nodeDefUuid))\nexport const isNodeVisible = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildVisible(parent, nodeDefUuid))\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('record.nodesIndexNotInitialized')\n }\n\nexport const getParentCodeAttribute =\n (params: { parentNode: ArenaRecordNode; nodeDef: NodeDefCode }) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const { parentNode, nodeDef } = params\n\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(nodeDef)\n if (!parentCodeDefUuid) return undefined\n\n const ancestors = getAncestorsAndSelf({ record, node: parentNode })\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\nexport const visitAncestorsAndSelf =\n (node: ArenaRecordNode, visitor: (node: ArenaRecordNode) => void, stopIfFn?: () => boolean) =>\n (record: ArenaRecord): void => {\n let currentNode: ArenaRecordNode | undefined = node\n while (currentNode) {\n visitor(currentNode)\n if (stopIfFn?.()) break\n currentNode = getParent(currentNode)(record)\n }\n }\n\nexport const findAncestor =\n (node: ArenaRecordNode, predicate: (node: ArenaRecordNode) => boolean) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let result: ArenaRecordNode | undefined = undefined\n visitAncestorsAndSelf(\n node,\n (visitedNode) => {\n if (predicate(visitedNode)) {\n result = visitedNode\n }\n },\n () => !!result\n )(record)\n return result\n }\n\nexport const getAncestor = (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n ancestorDefUuid: string\n}): ArenaRecordNode | undefined => {\n const { record, node, ancestorDefUuid } = params\n if (node.nodeDefUuid === ancestorDefUuid) return node\n\n let ancestor = getParent(node)(record)\n while (ancestor && ancestor.nodeDefUuid !== ancestorDefUuid) {\n ancestor = getParent(ancestor)(record)\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 = (params: { record: ArenaRecord; node: ArenaRecordNode }): Array<ArenaRecordNode> => {\n const { record, node } = params\n const ancestors: Array<ArenaRecordNode> = []\n visitAncestorsAndSelf(node, (currentNode) => {\n ancestors.push(currentNode)\n })(record)\n return ancestors\n}\n\n// descendants\n\nexport const getDescendantsOrSelf = (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n nodeDefDescendant: NodeDef<any>\n}): ArenaRecordNode[] => {\n const { record, node, nodeDefDescendant } = params\n\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 currentDescendants.push(...getChildren(currentAncestor, currentDescendantDefUuid)(record))\n }\n currentAncestors = currentDescendants\n currentDescendants = []\n }\n return currentAncestors // currentAncestors is equal to the currentDescendants of the last level\n}\n\nexport const getDescendant = (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n nodeDefDescendant: NodeDef<any>\n}): ArenaRecordNode => {\n const { record, node, nodeDefDescendant } = params\n\n return getDescendantsOrSelf({ record, node, nodeDefDescendant })[0]\n}\n\nexport const isDescendantOf = (params: { node: ArenaRecordNode; ancestor: ArenaRecordNode }): boolean => {\n const { node, ancestor } = params\n return Nodes.getHierarchy(node).includes(ancestor.uuid)\n}\n\nexport const visitDescendantsAndSelf = (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n visitor: (node: ArenaRecordNode) => boolean | void\n traverseMethod?: TraverseMethod\n}): void => {\n const { record, node, visitor, traverseMethod = TraverseMethod.bfs } = params\n\n if (traverseMethod === TraverseMethod.bfs) {\n const queue = new Queue()\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({\n record,\n node,\n visitor: (currentNode) => {\n if (predicate(currentNode)) {\n found = currentNode\n return true\n }\n return false\n },\n })\n return found\n }\n\nconst getClosestAncestorNode = (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n dependentDef: NodeDef<NodeDefType, NodeDefProps>\n dependencyType: SurveyDependencyType\n}): ArenaRecordNode | undefined => {\n const { record, node, nodeDef, dependentDef, dependencyType } = params\n\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({ record, node, ancestorDefUuid: commonAncestorDefUuid })\n}\n\ntype EntityKeyNodesGetterParams = {\n survey: Survey\n cycle?: string\n record: ArenaRecord\n entity: ArenaRecordNode\n keyDefs?: NodeDef<NodeDefType, NodeDefProps>[]\n}\n\nexport const getEntityKeyNodesByDefUuid = (params: EntityKeyNodesGetterParams): NodesMap => {\n const { survey, cycle, record, entity, keyDefs } = params\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const nodeDefKeys = keyDefs ?? Surveys.getNodeDefKeys({ survey, cycle, nodeDef })\n return nodeDefKeys.reduce((acc: NodesMap, nodeDefKey) => {\n const nodeKey = getDescendant({ record, node: entity, nodeDefDescendant: nodeDefKey })\n acc[nodeDefKey.uuid] = nodeKey\n return acc\n }, {})\n}\n\nexport const getEntityKeyNodes = (params: EntityKeyNodesGetterParams): ArenaRecordNode[] =>\n Object.values(getEntityKeyNodesByDefUuid(params))\n\nexport const getEntityKeyValuesByDefUuid = (params: EntityKeyNodesGetterParams): Dictionary<any> => {\n const keyNodesByDefUuid = getEntityKeyNodesByDefUuid(params)\n return Object.entries(keyNodesByDefUuid).reduce((acc: Dictionary<any>, [uuid, keyNode]) => {\n acc[uuid] = keyNode?.value\n return acc\n }, {})\n}\n\nexport const getEntityKeyValues = (params: EntityKeyNodesGetterParams): any[] =>\n Object.values(getEntityKeyValuesByDefUuid(params))\n\nexport const getEntitySiblings = (params: { record: ArenaRecord; entity: ArenaRecordNode; includeSelf?: boolean }) => {\n const { record, entity, includeSelf = false } = params\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) => !Nodes.areEqual(sibling, entity))\n}\n\nexport const getAttributeSiblings = (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}) => {\n const { record, node, nodeDef } = params\n const parentEntity = getParent(node)(record)\n if (!parentEntity) return []\n const siblingParentEntities = getEntitySiblings({ record, entity: parentEntity })\n return siblingParentEntities.reduce((siblingsAcc: ArenaRecordNode[], siblingEntity) => {\n siblingsAcc.push(...getChildren(siblingEntity, nodeDef.uuid)(record))\n return siblingsAcc\n }, [])\n}\n\nexport const getNodeIndex = (params: { record: ArenaRecord; node: ArenaRecordNode }) => {\n const { record, node } = params\n const parentEntity = getParent(node)(record)\n if (!parentEntity) return 0 // root entity\n const siblings = getChildren(parentEntity, node.nodeDefUuid)(record)\n return siblings.indexOf(node)\n}\n\nexport const findEntityByKeyValues = (params: {\n survey: Survey\n cycle: string\n record: ArenaRecord\n parentEntity: ArenaRecordNode\n entityDefUuid: string\n keyValuesByDefUuid: Dictionary<any>\n}): ArenaRecordNode | undefined => {\n const { survey, cycle, record, parentEntity, entityDefUuid, keyValuesByDefUuid } = params\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 record,\n entity: siblingEntity,\n keyDefs,\n })\n return keyDefs.every((keyDef) => {\n const keyValue = siblingEntityKeyValuesByDefUuid[keyDef.uuid]\n const keyValueSearch = keyValuesByDefUuid[keyDef.uuid]\n return NodeValues.isValueEqual({\n survey,\n nodeDef: keyDef,\n value: keyValue,\n valueSearch: keyValueSearch,\n })\n })\n })\n}\n\nexport const findEntityWithSameKeysInAnotherRecord = (params: {\n survey: Survey\n cycle: string\n entityUuid: string\n record: ArenaRecord\n recordOther: ArenaRecord\n}): ArenaRecordNode | undefined => {\n const { survey, cycle, entityUuid, record, recordOther } = params\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({\n record,\n node: entity,\n })\n const ancestorDefUuidsAndKeys = entityAncestorsAndSelf.map((ancestor) => ({\n entityDefUuid: ancestor.nodeDefUuid,\n keyValuesByDefUuid: getEntityKeyValuesByDefUuid({\n survey,\n record,\n entity: ancestor,\n }),\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 record: recordOther,\n parentEntity: otherRecordCurrentParentEntity,\n entityDefUuid,\n keyValuesByDefUuid,\n })\n }\n return otherRecordCurrentParentEntity\n}\n\nexport const getDependentNodePointers = (params: {\n survey: Survey\n record: ArenaRecord\n node: ArenaRecordNode\n dependencyType: SurveyDependencyType\n includeSelf?: boolean\n filterFn?: (nodePointer: NodePointer) => boolean\n}) => {\n const { survey, record, node, dependencyType, includeSelf = false, filterFn = null } = params\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<NodePointer> = []\n\n const addToNodePointers = (nodePointer: NodePointer): 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({ record, node, nodeDef, dependentDef, dependencyType })\n if (!commonAncestorNode) continue\n\n const nodeDefDependentParent = Surveys.getNodeDefParent({ survey, nodeDef: dependentDef })\n if (!nodeDefDependentParent) throw new SystemError('record.nodes.dependents.dependencyOnRootFound')\n\n // 2 find descendant nodes of common parent node with nodeDefUuid = dependentDef uuid\n const dependentContextNodes = getDescendantsOrSelf({\n record,\n node: commonAncestorNode,\n nodeDefDescendant: nodeDefDependentParent,\n })\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\nexport const getAncestorCodePath = (params: {\n survey: Survey\n record: ArenaRecord\n parentNode: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>\n}): string[] => {\n const { record, parentNode, nodeDef, survey } = params\n\n const getCodeAttributeItemCode = (codeAttribute: ArenaRecordNode | undefined): string => {\n const codeItemUuid = codeAttribute ? NodeValues.getItemUuid(codeAttribute) : undefined\n if (!codeItemUuid) return ''\n const item = Surveys.getCategoryItemByUuid({ survey, itemUuid: codeItemUuid })\n return item?.props.code ?? ''\n }\n\n const codePaths = []\n let currentParentCodeAttribute = getParentCodeAttribute({ parentNode, nodeDef })(record)\n\n while (currentParentCodeAttribute) {\n const ancestorItemCode = getCodeAttributeItemCode(currentParentCodeAttribute)\n codePaths.unshift(ancestorItemCode)\n const ancestorCodeDef = Surveys.getNodeDefByUuid({\n survey,\n uuid: currentParentCodeAttribute.nodeDefUuid,\n }) as NodeDefCode\n currentParentCodeAttribute = getParentCodeAttribute({ parentNode, nodeDef: ancestorCodeDef })(record)\n }\n return codePaths\n}\n\nexport const getCategoryItemUuid = (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>\n record: ArenaRecord\n parentNode: ArenaRecordNode\n code: string\n}): string | undefined => {\n const { survey, nodeDef, record, parentNode, code } = params\n const categoryUuid = nodeDef.props.categoryUuid\n\n const codePaths = [...getAncestorCodePath({ survey, record, parentNode, nodeDef }), 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) => Nodes.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,yCAAyD;AACzD,uCAAyC;AACzC,qCAA0E;AAC1E,sDAAkD;AAClD,2CAA2G;AAC3G,yCAAoD;AAEpD,uCAA2C;AAC3C,sCAA4D;AAC5D,8CAAsD;AACtD,qEAAiE;AACjE,mEAA+D;AAc/D,MAAM,cAAc,GAAG,CAAC,MAAc,EAA0B,EAAE,CAAC,QAAQ,IAAI,MAAM,CAAA;AAErF,MAAM,YAAY,GAAG,CAA4B,MAAwB,EAAsB,EAAE,CAC/F,CAAC,CAAC,MAA6B,EAAE,EAAE,CACjC,cAAc,CAAC,MAAM,CAAC;IACpB,CAAC,CAAC,MAAM,CAAC,MAAW,CAAC;IACrB,CAAC,CAAC,CAAC,MAAmB,EAAE,EAAE,CAAC,MAAM,CAAC,gCAAK,MAAM,KAAE,MAAM,GAAO,CAAC,CAAuB,CAAA;AAY1F,MAAM,sBAAsB,GAAG,CAA4B,MAI1D,EAAmC,EAAE;IACpC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;IACjD,OAAO,CAAC,CAAC,GAAG,IAAe,EAAE,EAAE;QAC7B,MAAM,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ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,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 { Dictionary, TraverseMethod } from '../../common'\nimport { SystemError } from '../../error'\nimport { ArenaRecordNode, NodePointer, Nodes, NodesMap } from '../../node'\nimport { NodeValues } from '../../node/nodeValues'\nimport { NodeDef, NodeDefCode, NodeDefCodeProps, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { defaultCycle, Surveys } from '../../survey'\nimport { Survey, SurveyDependencyType } from '../../survey/survey'\nimport { Arrays, Queue } from '../../utils'\nimport { ArenaRecord, RECORD_STEP_DEFAULT } from '../record'\nimport { RecordStepAnalysisCode } from '../recordStep'\nimport { RecordNodesIndexReader } from './recordNodesIndexReader'\nimport { NodeDefSelfReferences } from './nodeDefSelfReferences'\n\ntype RecordParams = { record: ArenaRecord }\n\n/**\n * Record getter: takes the parameters first and the record as separate (curried) parameter: `getter(params)(record)`.\n * The deprecated form, with the record inside the parameters (`getter({ record, ...params })`), is still supported.\n */\ntype RecordGetter<P extends RecordParams, R> = {\n /** @deprecated Pass the record as separate parameter: `getter(params)(record)` */\n (params: P): R\n (params: Omit<P, 'record'>): (record: ArenaRecord) => R\n}\n\nconst isRecordParams = (params: object): params is RecordParams => 'record' in params\n\nconst recordGetter = <P extends RecordParams, R>(getter: (params: P) => R): RecordGetter<P, R> =>\n ((params: P | Omit<P, 'record'>) =>\n isRecordParams(params)\n ? getter(params as P)\n : (record: ArenaRecord) => getter({ ...params, record } as P)) as RecordGetter<P, R>\n\n/**\n * Record getter (with parameters object) that also supports the deprecated form with positional parameters:\n * `getter(arg1, arg2)(record)`.\n */\ntype PositionalRecordGetter<P, A extends unknown[], R> = {\n (params: P): (record: ArenaRecord) => R\n /** @deprecated Pass the parameters as an object: `getter({ ...params })(record)` */\n (...args: A): (record: ArenaRecord) => R\n}\n\nconst positionalRecordGetter = <P, A extends unknown[], R>(params: {\n getter: (params: P & RecordParams) => R\n isPositional: (firstArg: unknown) => boolean\n toParams: (...args: A) => NoInfer<P>\n}): PositionalRecordGetter<P, A, R> => {\n const { getter, isPositional, toParams } = params\n return ((...args: unknown[]) => {\n const getterParams = isPositional(args[0]) ? toParams(...(args as A)) : (args[0] as P)\n return (record: ArenaRecord) => getter({ ...getterParams, record })\n }) as PositionalRecordGetter<P, A, R>\n}\n\nconst isRecordNode = (arg: unknown): arg is ArenaRecordNode =>\n typeof arg === 'object' && arg !== null && 'uuid' in arg && 'nodeDefUuid' in arg\nconst isString = (arg: unknown): arg is string => typeof arg === 'string'\n\nexport const getCycle = (record: ArenaRecord): string => record.cycle ?? defaultCycle\n\nexport const getNodes = (record: ArenaRecord): Dictionary<ArenaRecordNode> => record.nodes ?? {}\n\nexport const getNodesArray = (record: ArenaRecord): ArenaRecordNode[] => Object.values(getNodes(record))\n\nexport const getNodeByUuid = positionalRecordGetter({\n getter: ({ record, uuid }: RecordParams & { uuid: string }): ArenaRecordNode | undefined => record.nodes?.[uuid],\n isPositional: isString,\n toParams: (uuid: string) => ({ uuid }),\n})\n\nexport const getNodesByUuids = positionalRecordGetter({\n getter: ({ record, uuids }: RecordParams & { uuids: string[] }): ArenaRecordNode[] =>\n uuids.map((uuid: string) => record.nodes?.[uuid]) as ArenaRecordNode[],\n isPositional: Array.isArray,\n toParams: (uuids: string[]) => ({ uuids }),\n})\n\nexport const getRoot = (record: ArenaRecord): ArenaRecordNode | undefined => {\n const rootUuid = record._nodesIndex ? RecordNodesIndexReader.getNodeRootUuid(record._nodesIndex) : null\n if (rootUuid) {\n return getNodeByUuid({ uuid: rootUuid })(record)\n }\n return getNodesArray(record).find((node) => !node.parentUuid)\n}\n\nexport const getChildren = positionalRecordGetter({\n getter: ({\n record,\n parentNode,\n childDefUuid,\n }: RecordParams & { parentNode: ArenaRecordNode; childDefUuid?: string }): 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({ uuids: childrenUuids })(record)\n }\n return getNodesArray(record).filter(\n (node) => node.parentUuid === parentNode.uuid && (!childDefUuid || node.nodeDefUuid == childDefUuid)\n )\n },\n isPositional: isRecordNode,\n toParams: (parentNode: ArenaRecordNode, childDefUuid?: string) => ({ parentNode, childDefUuid }),\n})\n\nexport const getChild = positionalRecordGetter({\n getter: ({\n record,\n parentNode,\n childDefUuid,\n }: RecordParams & { parentNode: ArenaRecordNode; childDefUuid: string }): ArenaRecordNode => {\n const children = getChildren({ parentNode, childDefUuid })(record)\n const errorParams = { childDefUuid, parentNodeUuid: parentNode.uuid, recordUuid: record.uuid }\n if (children.length === 1) {\n return children[0]\n }\n if (children.length > 1) {\n throw new SystemError('systemError.record.multipleNodesFound', errorParams)\n }\n throw new SystemError('systemError.record.childNotFound', errorParams)\n },\n isPositional: isRecordNode,\n toParams: (parentNode: ArenaRecordNode, childDefUuid: string) => ({ parentNode, childDefUuid }),\n})\n\nexport const getParent = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): ArenaRecordNode | undefined =>\n node.parentUuid ? getNodeByUuid({ uuid: node.parentUuid })(record) : undefined,\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const getNodesByDefUuid = positionalRecordGetter({\n getter: ({ record, nodeDefUuid }: RecordParams & { nodeDefUuid: string }): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeUuidsByDef(nodeDefUuid)(record._nodesIndex)\n return getNodesByUuids({ uuids: nodeUuids })(record)\n }\n return getNodesArray(record).filter((node) => node.nodeDefUuid === nodeDefUuid)\n },\n isPositional: isString,\n toParams: (nodeDefUuid: string) => ({ nodeDefUuid }),\n})\n\nconst isNodeFlagTrue = (isChildFlagTrue: (parent: ArenaRecordNode, nodeDefUuid: string) => boolean) =>\n recordGetter((params: RecordParams & { node: ArenaRecordNode }): boolean => {\n const { record, node } = params\n const ancestorsAndSelf = getAncestorsAndSelf({ node })(record)\n for (let i = 0; i < ancestorsAndSelf.length - 1; i++) {\n const child = ancestorsAndSelf[i]\n const parent = ancestorsAndSelf[i + 1]\n if (!isChildFlagTrue(parent, child.nodeDefUuid)) return false\n }\n return true\n })\n\nexport const isNodeApplicable = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildApplicable(parent, nodeDefUuid))\nexport const isNodeEditable = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildEditable(parent, nodeDefUuid))\nexport const isNodeVisible = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildVisible(parent, nodeDefUuid))\n\nexport const getDependentCodeAttributes = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeCodeDependentUuids(node.uuid)(record._nodesIndex)\n return getNodesByUuids({ uuids: nodeUuids })(record)\n }\n throw new SystemError('record.nodesIndexNotInitialized')\n },\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const getParentCodeAttribute =\n (params: { parentNode: ArenaRecordNode; nodeDef: NodeDefCode }) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const { parentNode, nodeDef } = params\n\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(nodeDef)\n if (!parentCodeDefUuid) return undefined\n\n const ancestors = getAncestorsAndSelf({ node: parentNode })(record)\n for (const ancestor of ancestors) {\n const children = getChildren({ parentNode: ancestor, childDefUuid: 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 = positionalRecordGetter({\n getter: ({\n record,\n node,\n visitor,\n }: RecordParams & { node: ArenaRecordNode; visitor: (node: ArenaRecordNode) => boolean | void }): void => {\n let currentNode: ArenaRecordNode | undefined = node\n while (currentNode) {\n if (visitor(currentNode)) return\n currentNode = getParent({ node: currentNode })(record)\n }\n },\n isPositional: isRecordNode,\n // deprecated form: the visit stops when stopIfFn returns true\n toParams: (node: ArenaRecordNode, visitor: (node: ArenaRecordNode) => void, stopIfFn?: () => boolean) => ({\n node,\n visitor: (visitedNode: ArenaRecordNode): boolean => {\n visitor(visitedNode)\n return !!stopIfFn?.()\n },\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 (params: { node: ArenaRecordNode; predicate: (node: ArenaRecordNode) => boolean }) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const { node, predicate } = params\n let result: ArenaRecordNode | undefined = undefined\n visitAncestorsAndSelf({\n node,\n visitor: (visitedNode) => {\n if (predicate(visitedNode)) {\n result = visitedNode\n return true\n }\n return false\n },\n })(record)\n return result\n }\n\nexport const getAncestor = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode; ancestorDefUuid: string }): ArenaRecordNode | undefined => {\n const { record, node, ancestorDefUuid } = params\n if (node.nodeDefUuid === ancestorDefUuid) return node\n\n let ancestor = getParent({ node })(record)\n while (ancestor && ancestor.nodeDefUuid !== ancestorDefUuid) {\n ancestor = getParent({ node: ancestor })(record)\n }\n return ancestor\n }\n)\n\n/**\n * Returns the list of ancestors from the given node to the root entity\n */\nexport const getAncestorsAndSelf = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode }): Array<ArenaRecordNode> => {\n const { record, node } = params\n const ancestors: Array<ArenaRecordNode> = []\n visitAncestorsAndSelf({\n node,\n visitor: (currentNode) => {\n ancestors.push(currentNode)\n },\n })(record)\n return ancestors\n }\n)\n\n// descendants\n\nexport const getDescendantsOrSelf = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode; nodeDefDescendant: NodeDef<any> }): ArenaRecordNode[] => {\n const { record, node, nodeDefDescendant } = params\n\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 currentDescendants.push(\n ...getChildren({ parentNode: currentAncestor, childDefUuid: currentDescendantDefUuid })(record)\n )\n }\n currentAncestors = currentDescendants\n currentDescendants = []\n }\n return currentAncestors // currentAncestors is equal to the currentDescendants of the last level\n }\n)\n\nexport const getDescendant = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode; nodeDefDescendant: NodeDef<any> }): ArenaRecordNode => {\n const { record, node, nodeDefDescendant } = params\n\n return getDescendantsOrSelf({ node, nodeDefDescendant })(record)[0]\n }\n)\n\nexport const isDescendantOf = (params: { node: ArenaRecordNode; ancestor: ArenaRecordNode }): boolean => {\n const { node, ancestor } = params\n return Nodes.getHierarchy(node).includes(ancestor.uuid)\n}\n\nexport const visitDescendantsAndSelf = recordGetter(\n (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n visitor: (node: ArenaRecordNode) => boolean | void\n traverseMethod?: TraverseMethod\n }): void => {\n const { record, node, visitor, traverseMethod = TraverseMethod.bfs } = params\n\n if (traverseMethod === TraverseMethod.bfs) {\n const queue = new Queue()\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({ parentNode: 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)\n\nexport const findDescendantOrSelf =\n (params: { node: ArenaRecordNode; predicate: (node: ArenaRecordNode) => boolean }) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const { node, predicate } = params\n let found = undefined\n\n visitDescendantsAndSelf({\n node,\n visitor: (currentNode) => {\n if (predicate(currentNode)) {\n found = currentNode\n return true\n }\n return false\n },\n })(record)\n return found\n }\n\nconst getClosestAncestorNode = recordGetter(\n (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n dependentDef: NodeDef<NodeDefType, NodeDefProps>\n dependencyType: SurveyDependencyType\n }): ArenaRecordNode | undefined => {\n const { record, node, nodeDef, dependentDef, dependencyType } = params\n\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, ancestorDefUuid: commonAncestorDefUuid })(record)\n }\n)\n\ntype EntityKeyNodesGetterParams = {\n survey: Survey\n cycle?: string\n record: ArenaRecord\n entity: ArenaRecordNode\n keyDefs?: NodeDef<NodeDefType, NodeDefProps>[]\n}\n\nexport const getEntityKeyNodesByDefUuid = recordGetter((params: EntityKeyNodesGetterParams): NodesMap => {\n const { survey, cycle, record, entity, keyDefs } = params\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const nodeDefKeys = keyDefs ?? Surveys.getNodeDefKeys({ survey, cycle, nodeDef })\n return nodeDefKeys.reduce((acc: NodesMap, nodeDefKey) => {\n const nodeKey = getDescendant({ node: entity, nodeDefDescendant: nodeDefKey })(record)\n acc[nodeDefKey.uuid] = nodeKey\n return acc\n }, {})\n})\n\nexport const getEntityKeyNodes = recordGetter(\n ({ record, ...otherParams }: EntityKeyNodesGetterParams): ArenaRecordNode[] =>\n Object.values(getEntityKeyNodesByDefUuid(otherParams)(record))\n)\n\nexport const getEntityKeyValuesByDefUuid = recordGetter((params: EntityKeyNodesGetterParams): Dictionary<any> => {\n const { record, ...otherParams } = params\n const keyNodesByDefUuid = getEntityKeyNodesByDefUuid(otherParams)(record)\n return Object.entries(keyNodesByDefUuid).reduce((acc: Dictionary<any>, [uuid, keyNode]) => {\n acc[uuid] = keyNode?.value\n return acc\n }, {})\n})\n\nexport const getEntityKeyValues = recordGetter(({ record, ...otherParams }: EntityKeyNodesGetterParams): any[] =>\n Object.values(getEntityKeyValuesByDefUuid(otherParams)(record))\n)\n\nexport const getEntitySiblings = recordGetter(\n (params: { record: ArenaRecord; entity: ArenaRecordNode; includeSelf?: boolean }) => {\n const { record, entity, includeSelf = false } = params\n const parentEntity = getParent({ node: entity })(record)\n if (!parentEntity) return []\n const siblingEntities = getChildren({ parentNode: parentEntity, childDefUuid: entity.nodeDefUuid })(record)\n return includeSelf ? siblingEntities : siblingEntities.filter((sibling) => !Nodes.areEqual(sibling, entity))\n }\n)\n\nexport const getAttributeSiblings = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode; nodeDef: NodeDef<NodeDefType, NodeDefProps> }) => {\n const { record, node, nodeDef } = params\n const parentEntity = getParent({ node })(record)\n if (!parentEntity) return []\n const siblingParentEntities = getEntitySiblings({ entity: parentEntity })(record)\n return siblingParentEntities.reduce((siblingsAcc: ArenaRecordNode[], siblingEntity) => {\n siblingsAcc.push(...getChildren({ parentNode: siblingEntity, childDefUuid: nodeDef.uuid })(record))\n return siblingsAcc\n }, [])\n }\n)\n\nexport const getNodeIndex = recordGetter((params: { record: ArenaRecord; node: ArenaRecordNode }) => {\n const { record, node } = params\n const parentEntity = getParent({ node })(record)\n if (!parentEntity) return 0 // root entity\n const siblings = getChildren({ parentNode: parentEntity, childDefUuid: node.nodeDefUuid })(record)\n return siblings.indexOf(node)\n})\n\nexport const findEntityByKeyValues = recordGetter(\n (params: {\n survey: Survey\n cycle: string\n record: ArenaRecord\n parentEntity: ArenaRecordNode\n entityDefUuid: string\n keyValuesByDefUuid: Dictionary<any>\n }): ArenaRecordNode | undefined => {\n const { survey, cycle, record, parentEntity, entityDefUuid, keyValuesByDefUuid } = params\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entityDefUuid })\n const siblingEntities = getChildren({ parentNode: parentEntity, childDefUuid: 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({ survey, entity: siblingEntity, keyDefs })(\n record\n )\n return keyDefs.every((keyDef) => {\n const keyValue = siblingEntityKeyValuesByDefUuid[keyDef.uuid]\n const keyValueSearch = keyValuesByDefUuid[keyDef.uuid]\n return NodeValues.isValueEqual({\n survey,\n nodeDef: keyDef,\n value: keyValue,\n valueSearch: keyValueSearch,\n })\n })\n })\n }\n)\n\nexport const findEntityWithSameKeysInAnotherRecord = recordGetter(\n (params: {\n survey: Survey\n cycle: string\n entityUuid: string\n record: ArenaRecord\n recordOther: ArenaRecord\n }): ArenaRecordNode | undefined => {\n const { survey, cycle, entityUuid, record, recordOther } = params\n const entity = getNodeByUuid({ uuid: entityUuid })(record)\n if (!entity) return undefined\n\n let otherRecordCurrentParentEntity = getRoot(recordOther)\n if (!otherRecordCurrentParentEntity) return undefined\n\n const entityAncestorsAndSelf = getAncestorsAndSelf({ node: entity })(record)\n const ancestorDefUuidsAndKeys = entityAncestorsAndSelf.map((ancestor) => ({\n entityDefUuid: ancestor.nodeDefUuid,\n keyValuesByDefUuid: getEntityKeyValuesByDefUuid({ survey, entity: 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 parentEntity: otherRecordCurrentParentEntity,\n entityDefUuid,\n keyValuesByDefUuid,\n })(recordOther)\n }\n return otherRecordCurrentParentEntity\n }\n)\n\nexport const getDependentNodePointers = recordGetter(\n (params: {\n survey: Survey\n record: ArenaRecord\n node: ArenaRecordNode\n dependencyType: SurveyDependencyType\n includeSelf?: boolean\n filterFn?: (nodePointer: NodePointer) => boolean\n }) => {\n const { survey, record, node, dependencyType, includeSelf = false, filterFn = null } = params\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<NodePointer> = []\n\n const addToNodePointers = (nodePointer: NodePointer): 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('record.nodes.dependents.dependencyOnRootFound')\n\n // 2 find descendant nodes of common parent node with nodeDefUuid = dependentDef uuid\n const dependentContextNodes = getDescendantsOrSelf({\n node: commonAncestorNode,\n nodeDefDescendant: nodeDefDependentParent,\n })(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\nexport const getAncestorCodePath = recordGetter(\n (params: {\n survey: Survey\n record: ArenaRecord\n parentNode: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>\n }): string[] => {\n const { record, parentNode, nodeDef, survey } = params\n\n const getCodeAttributeItemCode = (codeAttribute: ArenaRecordNode | undefined): string => {\n const codeItemUuid = codeAttribute ? NodeValues.getItemUuid(codeAttribute) : undefined\n if (!codeItemUuid) return ''\n const item = Surveys.getCategoryItemByUuid({ survey, itemUuid: codeItemUuid })\n return item?.props.code ?? ''\n }\n\n const codePaths = []\n let currentParentCodeAttribute = getParentCodeAttribute({ parentNode, nodeDef })(record)\n\n while (currentParentCodeAttribute) {\n const ancestorItemCode = getCodeAttributeItemCode(currentParentCodeAttribute)\n codePaths.unshift(ancestorItemCode)\n const ancestorCodeDef = Surveys.getNodeDefByUuid({\n survey,\n uuid: currentParentCodeAttribute.nodeDefUuid,\n }) as NodeDefCode\n currentParentCodeAttribute = getParentCodeAttribute({ parentNode, nodeDef: ancestorCodeDef })(record)\n }\n return codePaths\n }\n)\n\nexport const getCategoryItemUuid = recordGetter(\n (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>\n record: ArenaRecord\n parentNode: ArenaRecordNode\n code: string\n }): string | undefined => {\n const { survey, nodeDef, record, parentNode, code } = params\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)\n\nexport const isNodeFilledByUser = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): boolean =>\n !!findDescendantOrSelf({ node, predicate: (visitedNode) => Nodes.hasUserInputValue(visitedNode) })(record),\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const isNodeEmpty = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): boolean =>\n !isNodeFilledByUser({ node })(record),\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const isEmpty = (record: ArenaRecord): boolean => {\n const rootNode = getRoot(record)\n return rootNode ? isNodeEmpty({ node: 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,12 +1,15 @@
1
1
  import { ArenaRecordNode } from '../../node';
2
+ import { MutationOptions } from '../../utils/mutationOptions';
2
3
  import { ArenaRecord, RecordNodesIndex } from '../record';
3
4
  declare const addNodes: (nodes: {
4
5
  [key: string]: ArenaRecordNode;
5
- }, sideEffect?: boolean, sortNodes?: boolean) => (index: RecordNodesIndex) => RecordNodesIndex;
6
+ }, options?: MutationOptions & {
7
+ sortNodes?: boolean;
8
+ }) => (index: RecordNodesIndex) => RecordNodesIndex;
6
9
  declare const addNode: (node: ArenaRecordNode) => (index: RecordNodesIndex) => RecordNodesIndex;
7
10
  declare const initializeIndex: (record: ArenaRecord) => RecordNodesIndex;
8
- declare const removeNodes: (nodes: ArenaRecordNode[], sideEffect?: boolean) => (index: RecordNodesIndex) => RecordNodesIndex;
9
- declare const removeNode: (node: ArenaRecordNode, sideEffect?: boolean) => (index: RecordNodesIndex) => RecordNodesIndex;
11
+ declare const removeNodes: (nodes: ArenaRecordNode[], options?: MutationOptions) => (index: RecordNodesIndex) => RecordNodesIndex;
12
+ declare const removeNode: (node: ArenaRecordNode, options?: MutationOptions) => (index: RecordNodesIndex) => RecordNodesIndex;
10
13
  /**
11
14
  * Returns true if the index entries of the specified node would not change when the node replaces the previous version of it.
12
15
  */
@@ -119,7 +119,8 @@ class NodesIndexDraft {
119
119
  this.delete([keys.nodeCodeDependents, nodeUuid]);
120
120
  }
121
121
  }
122
- const addNodes = (nodes, sideEffect = false, sortNodes = false) => (index) => {
122
+ const addNodes = (nodes, options = {}) => (index) => {
123
+ const { sideEffect = false, sortNodes = false } = options;
123
124
  const draft = new NodesIndexDraft(index, sideEffect);
124
125
  const nodesArray = Object.values(nodes);
125
126
  if (sortNodes) {
@@ -131,15 +132,16 @@ const addNodes = (nodes, sideEffect = false, sortNodes = false) => (index) => {
131
132
  return draft.index;
132
133
  };
133
134
  const addNode = (node) => (index) => addNodes({ [node.uuid]: node })(index);
134
- const initializeIndex = (record) => { var _a; return addNodes((_a = record.nodes) !== null && _a !== void 0 ? _a : {}, true, true)({}); };
135
- const removeNodes = (nodes, sideEffect = false) => (index) => {
135
+ const initializeIndex = (record) => { var _a; return addNodes((_a = record.nodes) !== null && _a !== void 0 ? _a : {}, { sideEffect: true, sortNodes: true })({}); };
136
+ const removeNodes = (nodes, options = {}) => (index) => {
137
+ const { sideEffect = false } = options;
136
138
  const draft = new NodesIndexDraft(index, sideEffect);
137
139
  for (const node of nodes) {
138
140
  draft.removeNode(node);
139
141
  }
140
142
  return draft.index;
141
143
  };
142
- const removeNode = (node, sideEffect = false) => (index) => removeNodes([node], sideEffect)(index);
144
+ const removeNode = (node, options = {}) => (index) => removeNodes([node], options)(index);
143
145
  const _isSameHierarchyCode = (nodeA, nodeB) => {
144
146
  var _a, _b;
145
147
  var _c, _d;
@@ -1 +1 @@
1
- {"version":3,"file":"recordNodesIndexUpdater.js","sourceRoot":"","sources":["../../../src/record/_records/recordNodesIndexUpdater.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,uCAAqC;AAGrC,MAAM,IAAI,GAAG;IACX,YAAY,EAAE,cAAc;IAC5B,wBAAwB,EAAE,0BAA0B;IACpD,UAAU,EAAE,YAAY;IACxB,kBAAkB,EAAE,oBAAoB;CACzC,CAAA;AAED,MAAM,2BAA2B,GAAG,CAAC,KAAsB,EAAE,KAAsB,EAAU,EAAE;;;IAC7F,IAAI,CAAC,KAAK,CAAC,UAAU;QAAE,OAAO,CAAC,CAAC,CAAA;IAChC,IAAI,CAAC,KAAK,CAAC,UAAU;QAAE,OAAO,CAAC,CAAA;IAC/B,8FAA8F;IAC9F,MAAM,eAAe,SAAG,MAAA,MAAA,KAAK,CAAC,IAAI,0CAAE,CAAC,0CAAE,MAAM,mCAAI,CAAC,CAAA;IAClD,MAAM,eAAe,SAAG,MAAA,MAAA,KAAK,CAAC,IAAI,0CAAE,CAAC,0CAAE,MAAM,mCAAI,CAAC,CAAA;IAClD,MAAM,SAAS,GAAG,eAAe,GAAG,eAAe,CAAA;IACnD,IAAI,SAAS,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IACrC,IAAI,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,EAAE;QAAE,OAAO,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAA;IACpD,IAAI,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,WAAW;QAAE,OAAO,KA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,IAAI,CAAC,oBAAoB,CAAC,IAAI,EAAE,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAA;IACvD,IAAI,EAAC,MAAA,MAAA,KAAK,CAAC,UAAU,0CAAG,WAAW,CAAC,0CAAG,IAAI,CAAC,CAAA;QAAE,OAAO,KAAK,CAAA;IAC1D,OAAO,UAAU;QACf,CAAC,CAAC,CAAC,EAAC,MAAA,MAAA,MAAA,KAAK,CAAC,wBAAwB,0CAAG,UAAU,CAAC,0CAAG,WAAW,CAAC,0CAAG,IAAI,CAAC,CAAA;QACvE,CAAC,CAAC,KAAK,CAAC,YAAY,KAAK,IAAI,CAAA;AACjC,CAAC,CAAA;AAEY,QAAA,uBAAuB,GAAG;IACrC,OAAO;IACP,QAAQ;IACR,eAAe;IACf,oBAAoB;IACpB,UAAU;IACV,WAAW;CACZ,CAAA","sourcesContent":["import { ArenaRecordNode, Nodes } from '../../node'\nimport { Objects } from '../../utils'\nimport { ArenaRecord, RecordNodesIndex } from '../record'\n\nconst keys = {\n nodeRootUuid: 'nodeRootUuid',\n nodesByParentAndChildDef: 'nodesByParentAndChildDef',\n nodesByDef: 'nodesByDef',\n nodeCodeDependents: 'nodeCodeDependents',\n}\n\nconst sortNodesByIdOrCreationDate = (nodeA: ArenaRecordNode, nodeB: ArenaRecordNode): number => {\n if (!nodeA.parentUuid) return -1\n if (!nodeB.parentUuid) return 1\n // read the hierarchy length directly: Nodes.getHierarchy copies the array on every comparison\n const hierarchyDepthA = nodeA.meta?.h?.length ?? 0\n const hierarchyDepthB = nodeB.meta?.h?.length ?? 0\n const depthDiff = hierarchyDepthA - hierarchyDepthB\n if (depthDiff !== 0) return depthDiff\n if (nodeA.id && nodeB.id) return nodeA.id - nodeB.id\n if (nodeA.dateCreated && nodeB.dateCreated) return nodeA.dateCreated.localeCompare(nodeB.dateCreated)\n return 0\n}\n\n/**\n * Mutable copy of a nodes index, used to apply many changes to it at once.\n * When sideEffect is false, every object along a modified path is copied only the first time it is modified\n * (copy on write): applying N changes costs one copy of each touched object instead of N copies.\n */\nclass NodesIndexDraft {\n readonly index: RecordNodesIndex\n private readonly sideEffect: boolean\n private readonly copiedObjects = new Set<object>()\n\n constructor(index: RecordNodesIndex, sideEffect: boolean) {\n this.sideEffect = sideEffect\n this.index = sideEffect ? index : this.markCopied({ ...index })\n }\n\n private markCopied<T extends object>(obj: T): T {\n this.copiedObjects.add(obj)\n return obj\n }\n\n private getWritableChild(parent: any, key: string, createIfMissing: boolean): any {\n const child = parent[key]\n if (child === undefined || child === null) {\n if (!createIfMissing) return undefined\n const childCreated = this.markCopied({})\n parent[key] = childCreated\n return childCreated\n }\n if (this.sideEffect || this.copiedObjects.has(child)) return child\n const childCopy = this.markCopied({ ...child })\n parent[key] = childCopy\n return childCopy\n }\n\n set(path: string[], value: any): void {\n let current: any = this.index\n for (let i = 0; i < path.length - 1; i++) {\n current = this.getWritableChild(current, path[i], true)\n }\n current[path.at(-1)!] = value\n }\n\n /**\n * Deletes the value at the specified path, then removes the objects along the path left empty.\n */\n delete(path: string[]): void {\n const containers: any[] = [this.index]\n let current: any = this.index\n for (let i = 0; i < path.length - 1; i++) {\n if (current[path[i]] === undefined) return\n current = this.getWritableChild(current, path[i], false)\n containers.push(current)\n }\n delete current[path.at(-1)!]\n for (let i = path.length - 2; i >= 0; i--) {\n if (!Objects.isEmpty(containers[i + 1])) break\n delete containers[i][path[i]]\n }\n }\n\n addNode(node: ArenaRecordNode): void {\n const { uuid: nodeUuid, nodeDefUuid, parentUuid } = node\n if (parentUuid) {\n // nodes by parent and child def uuid\n this.set([keys.nodesByParentAndChildDef, parentUuid, nodeDefUuid, nodeUuid], true)\n } else {\n // root entity index\n this.index.nodeRootUuid = nodeUuid\n }\n // nodes by def uuid\n this.set([keys.nodesByDef, nodeDefUuid, nodeUuid], true)\n // code dependents\n for (const ancestorCodeAttributeUuid of node.meta?.hCode ?? []) {\n this.set([keys.nodeCodeDependents, ancestorCodeAttributeUuid, nodeUuid], true)\n }\n }\n\n removeNode(node: ArenaRecordNode): void {\n const { uuid: nodeUuid, parentUuid, nodeDefUuid } = node\n if (parentUuid) {\n this.delete([keys.nodesByParentAndChildDef, parentUuid, nodeDefUuid, nodeUuid])\n } else {\n delete this.index.nodeRootUuid\n }\n this.delete([keys.nodesByDef, nodeDefUuid, nodeUuid])\n // code dependents\n for (const ancestorCodeAttributeUuid of Nodes.getHierarchyCode(node)) {\n this.delete([keys.nodeCodeDependents, ancestorCodeAttributeUuid, nodeUuid])\n }\n this.delete([keys.nodeCodeDependents, nodeUuid])\n }\n}\n\nconst addNodes =\n (nodes: { [key: string]: ArenaRecordNode }, sideEffect = false, sortNodes = false) =>\n (index: RecordNodesIndex): RecordNodesIndex => {\n const draft = new NodesIndexDraft(index, sideEffect)\n const nodesArray = Object.values(nodes)\n if (sortNodes) {\n nodesArray.sort(sortNodesByIdOrCreationDate)\n }\n for (const node of nodesArray) {\n draft.addNode(node)\n }\n return draft.index\n }\n\nconst addNode =\n (node: ArenaRecordNode) =>\n (index: RecordNodesIndex): RecordNodesIndex =>\n addNodes({ [node.uuid]: node })(index)\n\nconst initializeIndex = (record: ArenaRecord): RecordNodesIndex => addNodes(record.nodes ?? {}, true, true)({})\n\nconst removeNodes =\n (nodes: ArenaRecordNode[], sideEffect = false) =>\n (index: RecordNodesIndex): RecordNodesIndex => {\n const draft = new NodesIndexDraft(index, sideEffect)\n for (const node of nodes) {\n draft.removeNode(node)\n }\n return draft.index\n }\n\nconst removeNode =\n (node: ArenaRecordNode, sideEffect = false) =>\n (index: RecordNodesIndex): RecordNodesIndex =>\n removeNodes([node], sideEffect)(index)\n\nconst _isSameHierarchyCode = (nodeA: ArenaRecordNode, nodeB: ArenaRecordNode): boolean => {\n const hCodeA = nodeA.meta?.hCode ?? []\n const hCodeB = nodeB.meta?.hCode ?? []\n return hCodeA.length === hCodeB.length && hCodeA.every((uuid, index) => uuid === hCodeB[index])\n}\n\n/**\n * Returns true if the index entries of the specified node would not change when the node replaces the previous version of it.\n */\nconst isNodeIndexUnchanged = (params: {\n index: RecordNodesIndex\n node: ArenaRecordNode\n nodePrev?: ArenaRecordNode\n}): boolean => {\n const { index, node, nodePrev } = params\n if (!nodePrev) return false\n const { uuid, parentUuid, nodeDefUuid } = node\n if (parentUuid !== nodePrev.parentUuid || nodeDefUuid !== nodePrev.nodeDefUuid) return false\n if (!_isSameHierarchyCode(node, nodePrev)) return false\n if (!index.nodesByDef?.[nodeDefUuid]?.[uuid]) return false\n return parentUuid\n ? !!index.nodesByParentAndChildDef?.[parentUuid]?.[nodeDefUuid]?.[uuid]\n : index.nodeRootUuid === uuid\n}\n\nexport const RecordNodesIndexUpdater = {\n addNode,\n addNodes,\n initializeIndex,\n isNodeIndexUnchanged,\n removeNode,\n removeNodes,\n}\n"]}
1
+ {"version":3,"file":"recordNodesIndexUpdater.js","sourceRoot":"","sources":["../../../src/record/_records/recordNodesIndexUpdater.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,uCAAqC;AAIrC,MAAM,IAAI,GAAG;IACX,YAAY,EAAE,cAAc;IAC5B,wBAAwB,EAAE,0BAA0B;IACpD,UAAU,EAAE,YAAY;IACxB,kBAAkB,EAAE,oBAAoB;CACzC,CAAA;AAED,MAAM,2BAA2B,GAAG,CAAC,KAAsB,EAAE,KAAsB,EAAU,EAAE;;;IAC7F,IAAI,CAAC,KAAK,CAAC,UAAU;QAAE,OAAO,CAAC,CAAC,CAAA;IAChC,IAAI,CAAC,KAAK,CAAC,UAAU;QAAE,OAAO,CAAC,CAAA;IAC/B,8FAA8F;IAC9F,MAAM,eAAe,SAAG,MAAA,MAAA,KAAK,CAAC,IAAI,0CAAE,CAAC,0CAAE,MAAM,mCAAI,CAAC,CAAA;IAClD,MAAM,eAAe,SAAG,MAAA,MAAA,KAAK,CAAC,IAAI,0CAAE,CAAC,0CAAE,MAAM,mCAAI,CAAC,CAAA;IAClD,MAAM,SAAS,GAAG,eAAe,GAAG,eAAe,CAAA;IACnD,IAAI,SAAS,KAAK,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;AAED;;GAEG;AACH,MAAM,oBAAoB,GAAG,CAAC,MAI7B,EAAW,EAAE;;IACZ,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;IACxC,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3B,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAC9C,IAAI,UAAU,KAAK,QAAQ,CAAC,UAAU,IAAI,WAAW,KAAK,QAAQ,CAAC,WAAW;QAAE,OAAO,KAAK,CAAA;IAC5F,IAAI,CAAC,oBAAoB,CAAC,IAAI,EAAE,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAA;IACvD,IAAI,EAAC,MAAA,MAAA,KAAK,CAAC,UAAU,0CAAG,WAAW,CAAC,0CAAG,IAAI,CAAC,CAAA;QAAE,OAAO,KAAK,CAAA;IAC1D,OAAO,UAAU;QACf,CAAC,CAAC,CAAC,EAAC,MAAA,MAAA,MAAA,KAAK,CAAC,wBAAwB,0CAAG,UAAU,CAAC,0CAAG,WAAW,CAAC,0CAAG,IAAI,CAAC,CAAA;QACvE,CAAC,CAAC,KAAK,CAAC,YAAY,KAAK,IAAI,CAAA;AACjC,CAAC,CAAA;AAEY,QAAA,uBAAuB,GAAG;IACrC,OAAO;IACP,QAAQ;IACR,eAAe;IACf,oBAAoB;IACpB,UAAU;IACV,WAAW;CACZ,CAAA","sourcesContent":["import { ArenaRecordNode, Nodes } from '../../node'\nimport { Objects } from '../../utils'\nimport { MutationOptions } from '../../utils/mutationOptions'\nimport { ArenaRecord, RecordNodesIndex } from '../record'\n\nconst keys = {\n nodeRootUuid: 'nodeRootUuid',\n nodesByParentAndChildDef: 'nodesByParentAndChildDef',\n nodesByDef: 'nodesByDef',\n nodeCodeDependents: 'nodeCodeDependents',\n}\n\nconst sortNodesByIdOrCreationDate = (nodeA: ArenaRecordNode, nodeB: ArenaRecordNode): number => {\n if (!nodeA.parentUuid) return -1\n if (!nodeB.parentUuid) return 1\n // read the hierarchy length directly: Nodes.getHierarchy copies the array on every comparison\n const hierarchyDepthA = nodeA.meta?.h?.length ?? 0\n const hierarchyDepthB = nodeB.meta?.h?.length ?? 0\n const depthDiff = hierarchyDepthA - hierarchyDepthB\n if (depthDiff !== 0) return depthDiff\n if (nodeA.id && nodeB.id) return nodeA.id - nodeB.id\n if (nodeA.dateCreated && nodeB.dateCreated) return nodeA.dateCreated.localeCompare(nodeB.dateCreated)\n return 0\n}\n\n/**\n * Mutable copy of a nodes index, used to apply many changes to it at once.\n * When sideEffect is false, every object along a modified path is copied only the first time it is modified\n * (copy on write): applying N changes costs one copy of each touched object instead of N copies.\n */\nclass NodesIndexDraft {\n readonly index: RecordNodesIndex\n private readonly sideEffect: boolean\n private readonly copiedObjects = new Set<object>()\n\n constructor(index: RecordNodesIndex, sideEffect: boolean) {\n this.sideEffect = sideEffect\n this.index = sideEffect ? index : this.markCopied({ ...index })\n }\n\n private markCopied<T extends object>(obj: T): T {\n this.copiedObjects.add(obj)\n return obj\n }\n\n private getWritableChild(parent: any, key: string, createIfMissing: boolean): any {\n const child = parent[key]\n if (child === undefined || child === null) {\n if (!createIfMissing) return undefined\n const childCreated = this.markCopied({})\n parent[key] = childCreated\n return childCreated\n }\n if (this.sideEffect || this.copiedObjects.has(child)) return child\n const childCopy = this.markCopied({ ...child })\n parent[key] = childCopy\n return childCopy\n }\n\n set(path: string[], value: any): void {\n let current: any = this.index\n for (let i = 0; i < path.length - 1; i++) {\n current = this.getWritableChild(current, path[i], true)\n }\n current[path.at(-1)!] = value\n }\n\n /**\n * Deletes the value at the specified path, then removes the objects along the path left empty.\n */\n delete(path: string[]): void {\n const containers: any[] = [this.index]\n let current: any = this.index\n for (let i = 0; i < path.length - 1; i++) {\n if (current[path[i]] === undefined) return\n current = this.getWritableChild(current, path[i], false)\n containers.push(current)\n }\n delete current[path.at(-1)!]\n for (let i = path.length - 2; i >= 0; i--) {\n if (!Objects.isEmpty(containers[i + 1])) break\n delete containers[i][path[i]]\n }\n }\n\n addNode(node: ArenaRecordNode): void {\n const { uuid: nodeUuid, nodeDefUuid, parentUuid } = node\n if (parentUuid) {\n // nodes by parent and child def uuid\n this.set([keys.nodesByParentAndChildDef, parentUuid, nodeDefUuid, nodeUuid], true)\n } else {\n // root entity index\n this.index.nodeRootUuid = nodeUuid\n }\n // nodes by def uuid\n this.set([keys.nodesByDef, nodeDefUuid, nodeUuid], true)\n // code dependents\n for (const ancestorCodeAttributeUuid of node.meta?.hCode ?? []) {\n this.set([keys.nodeCodeDependents, ancestorCodeAttributeUuid, nodeUuid], true)\n }\n }\n\n removeNode(node: ArenaRecordNode): void {\n const { uuid: nodeUuid, parentUuid, nodeDefUuid } = node\n if (parentUuid) {\n this.delete([keys.nodesByParentAndChildDef, parentUuid, nodeDefUuid, nodeUuid])\n } else {\n delete this.index.nodeRootUuid\n }\n this.delete([keys.nodesByDef, nodeDefUuid, nodeUuid])\n // code dependents\n for (const ancestorCodeAttributeUuid of Nodes.getHierarchyCode(node)) {\n this.delete([keys.nodeCodeDependents, ancestorCodeAttributeUuid, nodeUuid])\n }\n this.delete([keys.nodeCodeDependents, nodeUuid])\n }\n}\n\nconst addNodes =\n (nodes: { [key: string]: ArenaRecordNode }, options: MutationOptions & { sortNodes?: boolean } = {}) =>\n (index: RecordNodesIndex): RecordNodesIndex => {\n const { sideEffect = false, sortNodes = false } = options\n const draft = new NodesIndexDraft(index, sideEffect)\n const nodesArray = Object.values(nodes)\n if (sortNodes) {\n nodesArray.sort(sortNodesByIdOrCreationDate)\n }\n for (const node of nodesArray) {\n draft.addNode(node)\n }\n return draft.index\n }\n\nconst addNode =\n (node: ArenaRecordNode) =>\n (index: RecordNodesIndex): RecordNodesIndex =>\n addNodes({ [node.uuid]: node })(index)\n\nconst initializeIndex = (record: ArenaRecord): RecordNodesIndex =>\n addNodes(record.nodes ?? {}, { sideEffect: true, sortNodes: true })({})\n\nconst removeNodes =\n (nodes: ArenaRecordNode[], options: MutationOptions = {}) =>\n (index: RecordNodesIndex): RecordNodesIndex => {\n const { sideEffect = false } = options\n const draft = new NodesIndexDraft(index, sideEffect)\n for (const node of nodes) {\n draft.removeNode(node)\n }\n return draft.index\n }\n\nconst removeNode =\n (node: ArenaRecordNode, options: MutationOptions = {}) =>\n (index: RecordNodesIndex): RecordNodesIndex =>\n removeNodes([node], options)(index)\n\nconst _isSameHierarchyCode = (nodeA: ArenaRecordNode, nodeB: ArenaRecordNode): boolean => {\n const hCodeA = nodeA.meta?.hCode ?? []\n const hCodeB = nodeB.meta?.hCode ?? []\n return hCodeA.length === hCodeB.length && hCodeA.every((uuid, index) => uuid === hCodeB[index])\n}\n\n/**\n * Returns true if the index entries of the specified node would not change when the node replaces the previous version of it.\n */\nconst isNodeIndexUnchanged = (params: {\n index: RecordNodesIndex\n node: ArenaRecordNode\n nodePrev?: ArenaRecordNode\n}): boolean => {\n const { index, node, nodePrev } = params\n if (!nodePrev) return false\n const { uuid, parentUuid, nodeDefUuid } = node\n if (parentUuid !== nodePrev.parentUuid || nodeDefUuid !== nodePrev.nodeDefUuid) return false\n if (!_isSameHierarchyCode(node, nodePrev)) return false\n if (!index.nodesByDef?.[nodeDefUuid]?.[uuid]) return false\n return parentUuid\n ? !!index.nodesByParentAndChildDef?.[parentUuid]?.[nodeDefUuid]?.[uuid]\n : index.nodeRootUuid === uuid\n}\n\nexport const RecordNodesIndexUpdater = {\n addNode,\n addNodes,\n initializeIndex,\n isNodeIndexUnchanged,\n removeNode,\n removeNodes,\n}\n"]}
@@ -16,7 +16,7 @@ const nodeBelongsToPage = (params) => {
16
16
  if (node.nodeDefUuid === pageNodeDefUuid)
17
17
  return true;
18
18
  return node_1.Nodes.getHierarchy(node).some((ancestorUuid) => {
19
- const ancestor = (0, recordGetters_1.getNodeByUuid)(ancestorUuid)(record);
19
+ const ancestor = (0, recordGetters_1.getNodeByUuid)({ uuid: ancestorUuid })(record);
20
20
  return (ancestor === null || ancestor === void 0 ? void 0 : ancestor.nodeDefUuid) === pageNodeDefUuid;
21
21
  });
22
22
  };
@@ -101,7 +101,7 @@ const getOwnPageFieldValidationFlags = (params) => {
101
101
  recordValidation,
102
102
  });
103
103
  }
104
- const node = (0, recordGetters_1.getNodeByUuid)(nodeUuid)(record);
104
+ const node = (0, recordGetters_1.getNodeByUuid)({ uuid: nodeUuid })(record);
105
105
  if (!node || !(0, exports.nodeBelongsToOwnPage)({ node, pageNodeDefUuid, descendantPageUuids, record }))
106
106
  return null;
107
107
  if (scopeEntityUuid && !nodeIsUnderEntity({ node, entityUuid: scopeEntityUuid }))
@@ -129,7 +129,7 @@ const getOwnPageChildrenCountValidationFlags = (params) => {
129
129
  // Sub-page entity min/max counts belong to navigation of nested pages, not this page's fields.
130
130
  if (descendantPageUuids.includes(childDefUuid))
131
131
  return null;
132
- const parentNode = (0, recordGetters_1.getNodeByUuid)(parentUuid)(record);
132
+ const parentNode = (0, recordGetters_1.getNodeByUuid)({ uuid: parentUuid })(record);
133
133
  if (!parentNode || !(0, exports.nodeBelongsToOwnPage)({ node: parentNode, pageNodeDefUuid, descendantPageUuids, record })) {
134
134
  return null;
135
135
  }
@@ -186,7 +186,7 @@ const aggregatePageValidationStatuses = (statuses) => ({
186
186
  const getEntitySubtreeStatus = (params) => {
187
187
  var _a;
188
188
  const { survey, record, entityUuid } = params;
189
- const entity = (0, recordGetters_1.getNodeByUuid)(entityUuid)(record);
189
+ const entity = (0, recordGetters_1.getNodeByUuid)({ uuid: entityUuid })(record);
190
190
  if (!entity)
191
191
  return null;
192
192
  const entityDef = survey_1.Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid });
@@ -220,7 +220,7 @@ exports.getEntitySubtreeStatus = getEntitySubtreeStatus;
220
220
  */
221
221
  const getMultiplePageEntitiesStatus = (params) => {
222
222
  const { survey, record, pageNodeDefUuid, scopeEntityUuid } = params;
223
- const instances = (0, recordGetters_1.getNodesByDefUuid)(pageNodeDefUuid)(record).filter((instance) => scopeEntityUuid ? nodeIsUnderEntity({ node: instance, entityUuid: scopeEntityUuid }) : true);
223
+ const instances = (0, recordGetters_1.getNodesByDefUuid)({ nodeDefUuid: pageNodeDefUuid })(record).filter((instance) => scopeEntityUuid ? nodeIsUnderEntity({ node: instance, entityUuid: scopeEntityUuid }) : true);
224
224
  if (instances.length === 0) {
225
225
  return { hasErrors: false, hasWarnings: false, isComplete: false };
226
226
  }
@@ -1 +1 @@
1
- {"version":3,"file":"recordPagesValidation.js","sourceRoot":"","sources":["../../../src/record/_records/recordPagesValidation.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,2CAAuD;AACvD,yCAA8C;AAC9C,iDAA8C;AAE9C,4DAAwD;AACxD,yDAA6D;AAC7D,mDAAqF;AAmBrF;;GAEG;AACI,MAAM,iBAAiB,GAAG,CAAC,MAIjC,EAAW,EAAE;IACZ,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IAChD,IAAI,IAAI,CAAC,WAAW,KAAK,eAAe;QAAE,OAAO,IAAI,CAAA;IACrD,OAAO,YAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,EAAE;QACpD,MAAM,QAAQ,GAAG,IAAA,6BAAa,EAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;QACpD,OAAO,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,WAAW,MAAK,eAAe,CAAA;IAClD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAXY,QAAA,iBAAiB,GAAjB,iBAAiB,CAW7B;AAED;;;GAGG;AACI,MAAM,oBAAoB,GAAG,CAAC,MAKpC,EAAW,EAAE;IACZ,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IACrE,IAAI,CAAC,IAAA,QAAA,iBAAiB,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE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C,IAAA,QAAA,gBAAgB,EAAC,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;YACxE,UAAU,IAAI,CAAC,CAAA;QACjB,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,UAAU,GAAG,UAAU,CAAC,GAAG,GAAG,CAAC,CAAA;IAC3D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAA;AAC5C,CAAC,CAAA;AAxBY,QAAA,gCAAgC,GAAhC,gCAAgC,CAwB5C","sourcesContent":["import { ArenaRecordNode, Nodes } from '../../node'\nimport { NodeDefEntity, NodeDefs } from '../../nodeDef'\nimport { Survey, Surveys } from '../../survey'\nimport { Validations } from '../../validation'\nimport { ArenaRecord } from '../record'\nimport { RecordValidations } from '../recordValidations'\nimport { getEntityCompletionStats } from './recordCompletion'\nimport { getCycle, getNodeByUuid, getNodesByDefUuid, getRoot } from './recordGetters'\n\nexport type PageValidationStatus = {\n hasErrors: boolean\n hasWarnings: boolean\n}\n\nexport type EntitySubtreeStatus = {\n hasErrors: boolean\n hasWarnings: boolean\n isComplete: boolean\n}\n\nexport type PagesValidationProgress = {\n percent: number\n validCount: number\n totalCount: number\n}\n\n/**\n * Whether a node belongs under a page entity (itself or any descendant of that page).\n */\nexport const nodeBelongsToPage = (params: {\n node: ArenaRecordNode\n pageNodeDefUuid: string\n record: ArenaRecord\n}): boolean => {\n const { node, pageNodeDefUuid, record } = params\n if (node.nodeDefUuid === pageNodeDefUuid) return true\n return Nodes.getHierarchy(node).some((ancestorUuid) => {\n const ancestor = getNodeByUuid(ancestorUuid)(record)\n return ancestor?.nodeDefUuid === pageNodeDefUuid\n })\n}\n\n/**\n * Whether a node belongs to this page only — not to a nested descendant page entity.\n * When descendantPageUuids is empty, all nodes under the page hierarchy are included.\n */\nexport const nodeBelongsToOwnPage = (params: {\n node: ArenaRecordNode\n pageNodeDefUuid: string\n descendantPageUuids: string[]\n record: ArenaRecord\n}): boolean => {\n const { node, pageNodeDefUuid, descendantPageUuids, record } = params\n if (!nodeBelongsToPage({ node, pageNodeDefUuid, record })) return false\n if (descendantPageUuids.includes(node.nodeDefUuid)) return false\n return !descendantPageUuids.some((descendantUuid) =>\n nodeBelongsToPage({ node, pageNodeDefUuid: descendantUuid, record })\n )\n}\n\n/**\n * Child page-entity defs displayed in their own page under the given entity.\n */\nexport const getNodeDefChildrenInOwnPage = (params: {\n survey: Survey\n nodeDef: NodeDefEntity\n cycle: string\n}): NodeDefEntity[] => {\n const { survey, nodeDef, cycle } = params\n return Surveys.getNodeDefChildren({ survey, nodeDef, includeAnalysis: true }).filter(\n (child): child is NodeDefEntity => {\n if (!NodeDefs.isEntity(child)) return false\n return NodeDefs.isDisplayInOwnPage(cycle)(child as NodeDefEntity)\n }\n )\n}\n\n/**\n * Collects all page-entity node defs in the survey cycle (root + nested own-pages).\n */\nexport const getPageNodeDefs = (params: { survey: Survey; cycle: string }): NodeDefEntity[] => {\n const { survey, cycle } = params\n const root = Surveys.getNodeDefRoot({ survey }) as NodeDefEntity | undefined\n if (!root) return []\n\n const pages: NodeDefEntity[] = []\n const stack: NodeDefEntity[] = [root]\n while (stack.length > 0) {\n const current = stack.pop()\n if (!current) continue\n pages.push(current)\n stack.push(...getNodeDefChildrenInOwnPage({ survey, nodeDef: current, cycle }))\n }\n return pages\n}\n\n/**\n * Collects descendant page node def UUIDs under a page (not including the page itself).\n */\nexport const getDescendantPageNodeDefUuids = (params: {\n survey: Survey\n cycle: string\n pageNodeDef: NodeDefEntity\n}): string[] => {\n const { survey, cycle, pageNodeDef } = params\n const uuids: string[] = []\n const visit = (nodeDef: NodeDefEntity) => {\n const children = getNodeDefChildrenInOwnPage({ survey, nodeDef, cycle })\n for (const child of children) {\n uuids.push(child.uuid)\n visit(child)\n }\n }\n visit(pageNodeDef)\n return uuids\n}\n\nconst nodeIsUnderEntity = (params: { node: ArenaRecordNode; entityUuid: string }): boolean => {\n const { node, entityUuid } = params\n if (node.uuid === entityUuid) return true\n return Nodes.getHierarchy(node).includes(entityUuid)\n}\n\nconst getOwnPageFieldValidationFlags = (params: {\n nodeUuid: string\n pageNodeDefUuid: string\n descendantPageUuids: string[]\n scopeEntityUuid?: string\n record: ArenaRecord\n recordValidation: ReturnType<typeof Validations.getValidation>\n}): PageValidationStatus | null => {\n const { nodeUuid, pageNodeDefUuid, descendantPageUuids, scopeEntityUuid, record, recordValidation } = params\n\n if (RecordValidations.isValidationChildrenCountKey(nodeUuid)) {\n return getOwnPageChildrenCountValidationFlags({\n childrenCountKey: nodeUuid,\n pageNodeDefUuid,\n descendantPageUuids,\n scopeEntityUuid,\n record,\n recordValidation,\n })\n }\n\n const node = getNodeByUuid(nodeUuid)(record)\n if (!node || !nodeBelongsToOwnPage({ node, pageNodeDefUuid, descendantPageUuids, record })) return null\n if (scopeEntityUuid && !nodeIsUnderEntity({ node, entityUuid: scopeEntityUuid })) return null\n\n const nodeValidation = RecordValidations.getValidationNode({ nodeUuid })(recordValidation)\n if (!nodeValidation) return null\n\n return {\n hasErrors: Validations.hasErrors(nodeValidation),\n hasWarnings: Validations.hasWarnings(nodeValidation),\n }\n}\n\n/**\n * Children-count validations (file min count, inline multiple min/max, etc.) are keyed as\n * `childrenCount_{parentUuid}_{childDefUuid}`, not as node UUIDs.\n * Include them when the parent is on this page, but skip counts that refer to descendant\n * page entities (missing sub-page instances should not paint the parent page red).\n */\nconst getOwnPageChildrenCountValidationFlags = (params: {\n childrenCountKey: string\n pageNodeDefUuid: string\n descendantPageUuids: string[]\n scopeEntityUuid?: string\n record: ArenaRecord\n recordValidation: ReturnType<typeof Validations.getValidation>\n}): PageValidationStatus | null => {\n const { childrenCountKey, pageNodeDefUuid, descendantPageUuids, scopeEntityUuid, record, recordValidation } = params\n const parentUuid = RecordValidations.extractValidationChildrenCountKeyParentUuid(childrenCountKey)\n const childDefUuid = RecordValidations.extractValidationChildrenCountKeyNodeDefUuid(childrenCountKey)\n if (!parentUuid || !childDefUuid) return null\n\n // Sub-page entity min/max counts belong to navigation of nested pages, not this page's fields.\n if (descendantPageUuids.includes(childDefUuid)) return null\n\n const parentNode = getNodeByUuid(parentUuid)(record)\n if (!parentNode || !nodeBelongsToOwnPage({ node: parentNode, pageNodeDefUuid, descendantPageUuids, record })) {\n return null\n }\n if (scopeEntityUuid && !nodeIsUnderEntity({ node: parentNode, entityUuid: scopeEntityUuid })) return null\n\n const fieldValidation = Validations.getFieldValidation(childrenCountKey)(recordValidation)\n if (!fieldValidation) return null\n\n return {\n hasErrors: Validations.hasErrors(fieldValidation),\n hasWarnings: Validations.hasWarnings(fieldValidation),\n }\n}\n\n/**\n * Aggregates error/warning flags for a page.\n * When descendantPageUuids is non-empty, nested page entities are excluded (own-page scope).\n * When scopeEntityUuid is set, only validations for nodes under that entity instance are included.\n */\nexport const getPageValidationStatus = (params: {\n pageNodeDefUuid: string\n descendantPageUuids?: string[]\n record: ArenaRecord\n scopeEntityUuid?: string\n}): PageValidationStatus => {\n const { pageNodeDefUuid, descendantPageUuids = [], record, scopeEntityUuid } = params\n const recordValidation = Validations.getValidation(record)\n const fields = Validations.getFieldValidations(recordValidation)\n let hasErrors = false\n let hasWarnings = false\n\n for (const nodeUuid of Object.keys(fields)) {\n const flags = getOwnPageFieldValidationFlags({\n nodeUuid,\n pageNodeDefUuid,\n descendantPageUuids,\n scopeEntityUuid,\n record,\n recordValidation,\n })\n if (!flags) continue\n if (flags.hasErrors) hasErrors = true\n if (flags.hasWarnings) hasWarnings = true\n if (hasErrors && hasWarnings) break\n }\n\n return { hasErrors, hasWarnings }\n}\n\nconst aggregatePageValidationStatuses = (statuses: PageValidationStatus[]): PageValidationStatus => ({\n hasErrors: statuses.some((status) => status.hasErrors),\n hasWarnings: statuses.some((status) => status.hasWarnings),\n})\n\n/**\n * Validation and completion status for one entity instance and its descendant pages.\n * Returns null when the node is missing or is not an entity.\n */\nexport const getEntitySubtreeStatus = (params: {\n survey: Survey\n record: ArenaRecord\n entityUuid: string\n cycle?: string\n}): EntitySubtreeStatus | null => {\n const { survey, record, entityUuid } = params\n const entity = getNodeByUuid(entityUuid)(record)\n if (!entity) return null\n\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n if (!NodeDefs.isEntity(entityDef)) return null\n\n const cycle = params.cycle ?? getCycle(record)\n const entityPageDef = entityDef as NodeDefEntity\n const descendantPageUuids = getDescendantPageNodeDefUuids({ survey, cycle, pageNodeDef: entityPageDef })\n const pageUuidsToCheck = [entity.nodeDefUuid, ...descendantPageUuids]\n\n const validationStatuses = pageUuidsToCheck.map((pageNodeDefUuid) => {\n const pageNodeDef = Surveys.getNodeDefByUuid({ survey, uuid: pageNodeDefUuid }) as NodeDefEntity\n const pageDescendantUuids = getDescendantPageNodeDefUuids({ survey, cycle, pageNodeDef })\n return getPageValidationStatus({\n pageNodeDefUuid,\n descendantPageUuids: pageDescendantUuids,\n record,\n scopeEntityUuid: entityUuid,\n })\n })\n\n const { hasErrors, hasWarnings } = aggregatePageValidationStatuses(validationStatuses)\n const { total, filled } = getEntityCompletionStats({ survey, record, entity })\n const isComplete = total > 0 && filled === total && !hasErrors && !hasWarnings\n\n return { hasErrors, hasWarnings, isComplete }\n}\n\n/**\n * Aggregates subtree status across instances of a multiple page entity.\n * When `scopeEntityUuid` is set, only instances under that ancestor entity are included\n * (needed for nested multiples, e.g. Tree under the currently selected Plot).\n * Empty instance lists return a non-complete status with no validation flags.\n */\nexport const getMultiplePageEntitiesStatus = (params: {\n survey: Survey\n record: ArenaRecord\n pageNodeDefUuid: string\n cycle?: string\n /** When set, only instances under this ancestor entity are aggregated. */\n scopeEntityUuid?: string\n}): EntitySubtreeStatus => {\n const { survey, record, pageNodeDefUuid, scopeEntityUuid } = params\n const instances = getNodesByDefUuid(pageNodeDefUuid)(record).filter((instance) =>\n scopeEntityUuid ? nodeIsUnderEntity({ node: instance, entityUuid: scopeEntityUuid }) : true\n )\n\n if (instances.length === 0) {\n return { hasErrors: false, hasWarnings: false, isComplete: false }\n }\n\n const instanceStatuses = instances\n .map((instance) => getEntitySubtreeStatus({ survey, record, entityUuid: instance.uuid, cycle: params.cycle }))\n .filter((status): status is EntitySubtreeStatus => status !== null)\n\n return {\n hasErrors: instanceStatuses.some((status) => status.hasErrors),\n hasWarnings: instanceStatuses.some((status) => status.hasWarnings),\n isComplete: instanceStatuses.length > 0 && instanceStatuses.every((status) => status.isComplete),\n }\n}\n\n/**\n * Whether the page has validation errors on its own fields (excluding nested page entities).\n */\nexport const pageHasOwnErrors = (params: {\n pageNodeDefUuid: string\n descendantPageUuids: string[]\n record: ArenaRecord\n}): boolean => getPageValidationStatus(params).hasErrors\n\n/**\n * Progress of pages without own-field validation errors over all survey pages.\n * Warnings do not reduce the score (matches Arena sidebar red-icon signal).\n */\nexport const getRecordPagesValidationProgress = (params: {\n survey: Survey\n record: ArenaRecord\n cycle?: string\n}): PagesValidationProgress | null => {\n const { survey, record } = params\n if (!getRoot(record)) return null\n\n const cycle = params.cycle ?? getCycle(record)\n const pageNodeDefs = getPageNodeDefs({ survey, cycle })\n const totalCount = pageNodeDefs.length\n if (totalCount === 0) return null\n\n let validCount = 0\n for (const pageNodeDef of pageNodeDefs) {\n const pageNodeDefUuid = pageNodeDef.uuid\n const descendantPageUuids = getDescendantPageNodeDefUuids({ survey, cycle, pageNodeDef })\n if (!pageHasOwnErrors({ pageNodeDefUuid, descendantPageUuids, record })) {\n validCount += 1\n }\n }\n\n const percent = Math.round((validCount / totalCount) * 100)\n return { percent, validCount, totalCount }\n}\n"]}
1
+ {"version":3,"file":"recordPagesValidation.js","sourceRoot":"","sources":["../../../src/record/_records/recordPagesValidation.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,2CAAuD;AACvD,yCAA8C;AAC9C,iDAA8C;AAE9C,4DAAwD;AACxD,yDAA6D;AAC7D,mDAAqF;AAmBrF;;GAEG;AACI,MAAM,iBAAiB,GAAG,CAAC,MAIjC,EAAW,EAA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node'\nimport { NodeDefEntity, NodeDefs } from '../../nodeDef'\nimport { Survey, Surveys } from '../../survey'\nimport { Validations } from '../../validation'\nimport { ArenaRecord } from '../record'\nimport { RecordValidations } from '../recordValidations'\nimport { getEntityCompletionStats } from './recordCompletion'\nimport { getCycle, getNodeByUuid, getNodesByDefUuid, getRoot } from './recordGetters'\n\nexport type PageValidationStatus = {\n hasErrors: boolean\n hasWarnings: boolean\n}\n\nexport type EntitySubtreeStatus = {\n hasErrors: boolean\n hasWarnings: boolean\n isComplete: boolean\n}\n\nexport type PagesValidationProgress = {\n percent: number\n validCount: number\n totalCount: number\n}\n\n/**\n * Whether a node belongs under a page entity (itself or any descendant of that page).\n */\nexport const nodeBelongsToPage = (params: {\n node: ArenaRecordNode\n pageNodeDefUuid: string\n record: ArenaRecord\n}): boolean => {\n const { node, pageNodeDefUuid, record } = params\n if (node.nodeDefUuid === pageNodeDefUuid) return true\n return Nodes.getHierarchy(node).some((ancestorUuid) => {\n const ancestor = getNodeByUuid({ uuid: ancestorUuid })(record)\n return ancestor?.nodeDefUuid === pageNodeDefUuid\n })\n}\n\n/**\n * Whether a node belongs to this page only — not to a nested descendant page entity.\n * When descendantPageUuids is empty, all nodes under the page hierarchy are included.\n */\nexport const nodeBelongsToOwnPage = (params: {\n node: ArenaRecordNode\n pageNodeDefUuid: string\n descendantPageUuids: string[]\n record: ArenaRecord\n}): boolean => {\n const { node, pageNodeDefUuid, descendantPageUuids, record } = params\n if (!nodeBelongsToPage({ node, pageNodeDefUuid, record })) return false\n if (descendantPageUuids.includes(node.nodeDefUuid)) return false\n return !descendantPageUuids.some((descendantUuid) =>\n nodeBelongsToPage({ node, pageNodeDefUuid: descendantUuid, record })\n )\n}\n\n/**\n * Child page-entity defs displayed in their own page under the given entity.\n */\nexport const getNodeDefChildrenInOwnPage = (params: {\n survey: Survey\n nodeDef: NodeDefEntity\n cycle: string\n}): NodeDefEntity[] => {\n const { survey, nodeDef, cycle } = params\n return Surveys.getNodeDefChildren({ survey, nodeDef, includeAnalysis: true }).filter(\n (child): child is NodeDefEntity => {\n if (!NodeDefs.isEntity(child)) return false\n return NodeDefs.isDisplayInOwnPage(cycle)(child as NodeDefEntity)\n }\n )\n}\n\n/**\n * Collects all page-entity node defs in the survey cycle (root + nested own-pages).\n */\nexport const getPageNodeDefs = (params: { survey: Survey; cycle: string }): NodeDefEntity[] => {\n const { survey, cycle } = params\n const root = Surveys.getNodeDefRoot({ survey }) as NodeDefEntity | undefined\n if (!root) return []\n\n const pages: NodeDefEntity[] = []\n const stack: NodeDefEntity[] = [root]\n while (stack.length > 0) {\n const current = stack.pop()\n if (!current) continue\n pages.push(current)\n stack.push(...getNodeDefChildrenInOwnPage({ survey, nodeDef: current, cycle }))\n }\n return pages\n}\n\n/**\n * Collects descendant page node def UUIDs under a page (not including the page itself).\n */\nexport const getDescendantPageNodeDefUuids = (params: {\n survey: Survey\n cycle: string\n pageNodeDef: NodeDefEntity\n}): string[] => {\n const { survey, cycle, pageNodeDef } = params\n const uuids: string[] = []\n const visit = (nodeDef: NodeDefEntity) => {\n const children = getNodeDefChildrenInOwnPage({ survey, nodeDef, cycle })\n for (const child of children) {\n uuids.push(child.uuid)\n visit(child)\n }\n }\n visit(pageNodeDef)\n return uuids\n}\n\nconst nodeIsUnderEntity = (params: { node: ArenaRecordNode; entityUuid: string }): boolean => {\n const { node, entityUuid } = params\n if (node.uuid === entityUuid) return true\n return Nodes.getHierarchy(node).includes(entityUuid)\n}\n\nconst getOwnPageFieldValidationFlags = (params: {\n nodeUuid: string\n pageNodeDefUuid: string\n descendantPageUuids: string[]\n scopeEntityUuid?: string\n record: ArenaRecord\n recordValidation: ReturnType<typeof Validations.getValidation>\n}): PageValidationStatus | null => {\n const { nodeUuid, pageNodeDefUuid, descendantPageUuids, scopeEntityUuid, record, recordValidation } = params\n\n if (RecordValidations.isValidationChildrenCountKey(nodeUuid)) {\n return getOwnPageChildrenCountValidationFlags({\n childrenCountKey: nodeUuid,\n pageNodeDefUuid,\n descendantPageUuids,\n scopeEntityUuid,\n record,\n recordValidation,\n })\n }\n\n const node = getNodeByUuid({ uuid: nodeUuid })(record)\n if (!node || !nodeBelongsToOwnPage({ node, pageNodeDefUuid, descendantPageUuids, record })) return null\n if (scopeEntityUuid && !nodeIsUnderEntity({ node, entityUuid: scopeEntityUuid })) return null\n\n const nodeValidation = RecordValidations.getValidationNode({ nodeUuid })(recordValidation)\n if (!nodeValidation) return null\n\n return {\n hasErrors: Validations.hasErrors(nodeValidation),\n hasWarnings: Validations.hasWarnings(nodeValidation),\n }\n}\n\n/**\n * Children-count validations (file min count, inline multiple min/max, etc.) are keyed as\n * `childrenCount_{parentUuid}_{childDefUuid}`, not as node UUIDs.\n * Include them when the parent is on this page, but skip counts that refer to descendant\n * page entities (missing sub-page instances should not paint the parent page red).\n */\nconst getOwnPageChildrenCountValidationFlags = (params: {\n childrenCountKey: string\n pageNodeDefUuid: string\n descendantPageUuids: string[]\n scopeEntityUuid?: string\n record: ArenaRecord\n recordValidation: ReturnType<typeof Validations.getValidation>\n}): PageValidationStatus | null => {\n const { childrenCountKey, pageNodeDefUuid, descendantPageUuids, scopeEntityUuid, record, recordValidation } = params\n const parentUuid = RecordValidations.extractValidationChildrenCountKeyParentUuid(childrenCountKey)\n const childDefUuid = RecordValidations.extractValidationChildrenCountKeyNodeDefUuid(childrenCountKey)\n if (!parentUuid || !childDefUuid) return null\n\n // Sub-page entity min/max counts belong to navigation of nested pages, not this page's fields.\n if (descendantPageUuids.includes(childDefUuid)) return null\n\n const parentNode = getNodeByUuid({ uuid: parentUuid })(record)\n if (!parentNode || !nodeBelongsToOwnPage({ node: parentNode, pageNodeDefUuid, descendantPageUuids, record })) {\n return null\n }\n if (scopeEntityUuid && !nodeIsUnderEntity({ node: parentNode, entityUuid: scopeEntityUuid })) return null\n\n const fieldValidation = Validations.getFieldValidation(childrenCountKey)(recordValidation)\n if (!fieldValidation) return null\n\n return {\n hasErrors: Validations.hasErrors(fieldValidation),\n hasWarnings: Validations.hasWarnings(fieldValidation),\n }\n}\n\n/**\n * Aggregates error/warning flags for a page.\n * When descendantPageUuids is non-empty, nested page entities are excluded (own-page scope).\n * When scopeEntityUuid is set, only validations for nodes under that entity instance are included.\n */\nexport const getPageValidationStatus = (params: {\n pageNodeDefUuid: string\n descendantPageUuids?: string[]\n record: ArenaRecord\n scopeEntityUuid?: string\n}): PageValidationStatus => {\n const { pageNodeDefUuid, descendantPageUuids = [], record, scopeEntityUuid } = params\n const recordValidation = Validations.getValidation(record)\n const fields = Validations.getFieldValidations(recordValidation)\n let hasErrors = false\n let hasWarnings = false\n\n for (const nodeUuid of Object.keys(fields)) {\n const flags = getOwnPageFieldValidationFlags({\n nodeUuid,\n pageNodeDefUuid,\n descendantPageUuids,\n scopeEntityUuid,\n record,\n recordValidation,\n })\n if (!flags) continue\n if (flags.hasErrors) hasErrors = true\n if (flags.hasWarnings) hasWarnings = true\n if (hasErrors && hasWarnings) break\n }\n\n return { hasErrors, hasWarnings }\n}\n\nconst aggregatePageValidationStatuses = (statuses: PageValidationStatus[]): PageValidationStatus => ({\n hasErrors: statuses.some((status) => status.hasErrors),\n hasWarnings: statuses.some((status) => status.hasWarnings),\n})\n\n/**\n * Validation and completion status for one entity instance and its descendant pages.\n * Returns null when the node is missing or is not an entity.\n */\nexport const getEntitySubtreeStatus = (params: {\n survey: Survey\n record: ArenaRecord\n entityUuid: string\n cycle?: string\n}): EntitySubtreeStatus | null => {\n const { survey, record, entityUuid } = params\n const entity = getNodeByUuid({ uuid: entityUuid })(record)\n if (!entity) return null\n\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n if (!NodeDefs.isEntity(entityDef)) return null\n\n const cycle = params.cycle ?? getCycle(record)\n const entityPageDef = entityDef as NodeDefEntity\n const descendantPageUuids = getDescendantPageNodeDefUuids({ survey, cycle, pageNodeDef: entityPageDef })\n const pageUuidsToCheck = [entity.nodeDefUuid, ...descendantPageUuids]\n\n const validationStatuses = pageUuidsToCheck.map((pageNodeDefUuid) => {\n const pageNodeDef = Surveys.getNodeDefByUuid({ survey, uuid: pageNodeDefUuid }) as NodeDefEntity\n const pageDescendantUuids = getDescendantPageNodeDefUuids({ survey, cycle, pageNodeDef })\n return getPageValidationStatus({\n pageNodeDefUuid,\n descendantPageUuids: pageDescendantUuids,\n record,\n scopeEntityUuid: entityUuid,\n })\n })\n\n const { hasErrors, hasWarnings } = aggregatePageValidationStatuses(validationStatuses)\n const { total, filled } = getEntityCompletionStats({ survey, record, entity })\n const isComplete = total > 0 && filled === total && !hasErrors && !hasWarnings\n\n return { hasErrors, hasWarnings, isComplete }\n}\n\n/**\n * Aggregates subtree status across instances of a multiple page entity.\n * When `scopeEntityUuid` is set, only instances under that ancestor entity are included\n * (needed for nested multiples, e.g. Tree under the currently selected Plot).\n * Empty instance lists return a non-complete status with no validation flags.\n */\nexport const getMultiplePageEntitiesStatus = (params: {\n survey: Survey\n record: ArenaRecord\n pageNodeDefUuid: string\n cycle?: string\n /** When set, only instances under this ancestor entity are aggregated. */\n scopeEntityUuid?: string\n}): EntitySubtreeStatus => {\n const { survey, record, pageNodeDefUuid, scopeEntityUuid } = params\n const instances = getNodesByDefUuid({ nodeDefUuid: pageNodeDefUuid })(record).filter((instance) =>\n scopeEntityUuid ? nodeIsUnderEntity({ node: instance, entityUuid: scopeEntityUuid }) : true\n )\n\n if (instances.length === 0) {\n return { hasErrors: false, hasWarnings: false, isComplete: false }\n }\n\n const instanceStatuses = instances\n .map((instance) => getEntitySubtreeStatus({ survey, record, entityUuid: instance.uuid, cycle: params.cycle }))\n .filter((status): status is EntitySubtreeStatus => status !== null)\n\n return {\n hasErrors: instanceStatuses.some((status) => status.hasErrors),\n hasWarnings: instanceStatuses.some((status) => status.hasWarnings),\n isComplete: instanceStatuses.length > 0 && instanceStatuses.every((status) => status.isComplete),\n }\n}\n\n/**\n * Whether the page has validation errors on its own fields (excluding nested page entities).\n */\nexport const pageHasOwnErrors = (params: {\n pageNodeDefUuid: string\n descendantPageUuids: string[]\n record: ArenaRecord\n}): boolean => getPageValidationStatus(params).hasErrors\n\n/**\n * Progress of pages without own-field validation errors over all survey pages.\n * Warnings do not reduce the score (matches Arena sidebar red-icon signal).\n */\nexport const getRecordPagesValidationProgress = (params: {\n survey: Survey\n record: ArenaRecord\n cycle?: string\n}): PagesValidationProgress | null => {\n const { survey, record } = params\n if (!getRoot(record)) return null\n\n const cycle = params.cycle ?? getCycle(record)\n const pageNodeDefs = getPageNodeDefs({ survey, cycle })\n const totalCount = pageNodeDefs.length\n if (totalCount === 0) return null\n\n let validCount = 0\n for (const pageNodeDef of pageNodeDefs) {\n const pageNodeDefUuid = pageNodeDef.uuid\n const descendantPageUuids = getDescendantPageNodeDefUuids({ survey, cycle, pageNodeDef })\n if (!pageHasOwnErrors({ pageNodeDefUuid, descendantPageUuids, record })) {\n validCount += 1\n }\n }\n\n const percent = Math.round((validCount / totalCount) * 100)\n return { percent, validCount, totalCount }\n}\n"]}
@@ -1,6 +1,6 @@
1
- export interface RecordUpdateOptions {
1
+ import { MutationOptions } from '../../utils/mutationOptions';
2
+ export interface RecordUpdateOptions extends MutationOptions {
2
3
  updateNodesIndex?: boolean;
3
- sideEffect?: boolean;
4
4
  sortNodes?: boolean;
5
5
  }
6
6
  export declare const RecordUpdateOptionsDefaults: RecordUpdateOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"recordUpdateOptions.js","sourceRoot":"","sources":["../../../src/record/_records/recordUpdateOptions.ts"],"names":[],"mappings":";;;AAMa,QAAA,2BAA2B,GAAwB;IAC9D,gBAAgB,EAAE,IAAI;IACtB,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,KAAK;CACjB,CAAA","sourcesContent":["export interface RecordUpdateOptions {\n updateNodesIndex?: boolean\n sideEffect?: boolean\n sortNodes?: boolean\n}\n\nexport const RecordUpdateOptionsDefaults: RecordUpdateOptions = {\n updateNodesIndex: true,\n sideEffect: false,\n sortNodes: false,\n}\n"]}
1
+ {"version":3,"file":"recordUpdateOptions.js","sourceRoot":"","sources":["../../../src/record/_records/recordUpdateOptions.ts"],"names":[],"mappings":";;;AAOa,QAAA,2BAA2B,GAAwB;IAC9D,gBAAgB,EAAE,IAAI;IACtB,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,KAAK;CACjB,CAAA","sourcesContent":["import { MutationOptions } from '../../utils/mutationOptions'\n\nexport interface RecordUpdateOptions extends MutationOptions {\n updateNodesIndex?: boolean\n sortNodes?: boolean\n}\n\nexport const RecordUpdateOptionsDefaults: RecordUpdateOptions = {\n updateNodesIndex: true,\n sideEffect: false,\n sortNodes: false,\n}\n"]}
@@ -61,7 +61,7 @@ const addNodes = (nodes, options = recordUpdateOptions_1.RecordUpdateOptionsDefa
61
61
  recordUpdated.nodes = Object.assign(Object.assign({}, recordNodes), nodes);
62
62
  }
63
63
  if (updateNodesIndex && Object.keys(nodesToIndex).length > 0) {
64
- recordUpdated._nodesIndex = recordNodesIndexUpdater_1.RecordNodesIndexUpdater.addNodes(nodesToIndex, sideEffect, sortNodes)(index);
64
+ recordUpdated._nodesIndex = recordNodesIndexUpdater_1.RecordNodesIndexUpdater.addNodes(nodesToIndex, { sideEffect, sortNodes })(index);
65
65
  }
66
66
  return recordUpdated;
67
67
  };
@@ -1 +1 @@
1
- {"version":3,"file":"recordUpdater.js","sourceRoot":"","sources":["../../../src/record/_records/recordUpdater.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAY,aAAa,4CAAuB;AAChD,uEAAmE;AACnE,+DAAwF;AAEjF,MAAM,QAAQ,GACnB,CAAC,KAAyC,EAAE,OAAO,GAAwB,iDAA2B,EAAE,EAAE,CAC1G,CAAC,MAAmB,EAAe,EAAE;;IACnC,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,mCAAQ,iDAA2B,GAAK,OAAO,CAAE,CAAA;IAElG,MAAM,aAAa,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM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AC,MAAmB,EAAE,EAAE,CACtB,IAAA,QAAA,QAAQ,EAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,CAAA;AAHvC,QAAA,OAAO,GAAP,OAAO,CAGgC","sourcesContent":["import { ArenaRecordNode } from '../../node'\nimport { ArenaRecord } from '../record'\nimport * as RecordGetters from './recordGetters'\nimport { RecordNodesIndexUpdater } from './recordNodesIndexUpdater'\nimport { RecordUpdateOptions, RecordUpdateOptionsDefaults } from './recordUpdateOptions'\n\nexport const addNodes =\n (nodes: { [key: string]: ArenaRecordNode }, options: RecordUpdateOptions = RecordUpdateOptionsDefaults) =>\n (record: ArenaRecord): ArenaRecord => {\n const { sideEffect, updateNodesIndex, sortNodes } = { ...RecordUpdateOptionsDefaults, ...options }\n\n const recordUpdated = sideEffect ? record : { ...record }\n const recordNodes = RecordGetters.getNodes(recordUpdated)\n const index = recordUpdated._nodesIndex ?? {}\n\n // index only the nodes not already indexed with the same parent, node def and hierarchy code\n // (e.g. nodes with only an updated value don't need any index change)\n const nodesToIndex: { [key: string]: ArenaRecordNode } = {}\n if (updateNodesIndex) {\n for (const [nodeUuid, node] of Object.entries(nodes)) {\n const nodePrev = recordNodes[nodeUuid]\n if (!RecordNodesIndexUpdater.isNodeIndexUnchanged({ index, node, nodePrev })) {\n nodesToIndex[nodeUuid] = node\n }\n }\n }\n\n if (sideEffect) {\n recordUpdated.nodes = Object.assign(recordNodes, nodes)\n } else {\n recordUpdated.nodes = { ...recordNodes, ...nodes }\n }\n if (updateNodesIndex && Object.keys(nodesToIndex).length > 0) {\n recordUpdated._nodesIndex = RecordNodesIndexUpdater.addNodes(nodesToIndex, sideEffect, sortNodes)(index)\n }\n return recordUpdated\n }\n\nexport const addNode =\n (node: ArenaRecordNode, options: RecordUpdateOptions = RecordUpdateOptionsDefaults) =>\n (record: ArenaRecord) =>\n addNodes({ [node.uuid]: node }, options)(record)\n"]}
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,WAAW,GAAK,KAAK,CAAE,CAAA;IACpD,CAAC;IACD,IAAI,gBAAgB,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7D,aAAa,CAAC,WAAW,GAAG,iDAAuB,CAAC,QAAQ,CAAC,YAAY,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAA;IAC9G,CAAC;IACD,OAAO,aAAa,CAAA;AACtB,CAAC,CAAA;AA9BU,QAAA,QAAQ,GAAR,QAAQ,CA8BlB;AAEI,MAAM,OAAO,GAClB,CAAC,IAAqB,EAAE,OAAO,GAAwB,iDAA2B,EAAE,EAAE,CACtF,CAAC,MAAmB,EAAE,EAAE,CACtB,IAAA,QAAA,QAAQ,EAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,CAAA;AAHvC,QAAA,OAAO,GAAP,OAAO,CAGgC","sourcesContent":["import { ArenaRecordNode } from '../../node'\nimport { ArenaRecord } from '../record'\nimport * as RecordGetters from './recordGetters'\nimport { RecordNodesIndexUpdater } from './recordNodesIndexUpdater'\nimport { RecordUpdateOptions, RecordUpdateOptionsDefaults } from './recordUpdateOptions'\n\nexport const addNodes =\n (nodes: { [key: string]: ArenaRecordNode }, options: RecordUpdateOptions = RecordUpdateOptionsDefaults) =>\n (record: ArenaRecord): ArenaRecord => {\n const { sideEffect, updateNodesIndex, sortNodes } = { ...RecordUpdateOptionsDefaults, ...options }\n\n const recordUpdated = sideEffect ? record : { ...record }\n const recordNodes = RecordGetters.getNodes(recordUpdated)\n const index = recordUpdated._nodesIndex ?? {}\n\n // index only the nodes not already indexed with the same parent, node def and hierarchy code\n // (e.g. nodes with only an updated value don't need any index change)\n const nodesToIndex: { [key: string]: ArenaRecordNode } = {}\n if (updateNodesIndex) {\n for (const [nodeUuid, node] of Object.entries(nodes)) {\n const nodePrev = recordNodes[nodeUuid]\n if (!RecordNodesIndexUpdater.isNodeIndexUnchanged({ index, node, nodePrev })) {\n nodesToIndex[nodeUuid] = node\n }\n }\n }\n\n if (sideEffect) {\n recordUpdated.nodes = Object.assign(recordNodes, nodes)\n } else {\n recordUpdated.nodes = { ...recordNodes, ...nodes }\n }\n if (updateNodesIndex && Object.keys(nodesToIndex).length > 0) {\n recordUpdated._nodesIndex = RecordNodesIndexUpdater.addNodes(nodesToIndex, { sideEffect, sortNodes })(index)\n }\n return recordUpdated\n }\n\nexport const addNode =\n (node: ArenaRecordNode, options: RecordUpdateOptions = RecordUpdateOptionsDefaults) =>\n (record: ArenaRecord) =>\n addNodes({ [node.uuid]: node }, options)(record)\n"]}
@@ -25,12 +25,8 @@ const findDependentEnumeratedEntityDefs = (params) => {
25
25
  };
26
26
  const hasNodeNonEmptyDescendants = (params) => {
27
27
  const { record, parentNode, nodeDefDescendant } = params;
28
- const descendants = (0, recordGetters_1.getDescendantsOrSelf)({
29
- record,
30
- node: parentNode !== null && parentNode !== void 0 ? parentNode : (0, recordGetters_1.getRoot)(record),
31
- nodeDefDescendant,
32
- });
33
- const nonEmptyDescendants = descendants.filter((dependentEntity) => (0, recordGetters_1.getChildren)(dependentEntity)(record).some((childNode) => (0, recordGetters_1.isNodeFilledByUser)(childNode)(record)));
28
+ const descendants = (0, recordGetters_1.getDescendantsOrSelf)({ node: parentNode !== null && parentNode !== void 0 ? parentNode : (0, recordGetters_1.getRoot)(record), nodeDefDescendant })(record);
29
+ const nonEmptyDescendants = descendants.filter((dependentEntity) => (0, recordGetters_1.getChildren)({ parentNode: dependentEntity })(record).some((childNode) => (0, recordGetters_1.isNodeFilledByUser)({ node: childNode })(record)));
34
30
  return nonEmptyDescendants.length > 0;
35
31
  };
36
32
  const findDependentEnumeratedEntityDefsNotEmpty = (params) => (record) => {
@@ -38,7 +34,7 @@ const findDependentEnumeratedEntityDefsNotEmpty = (params) => (record) => {
38
34
  const dependentEnumeratedEntityDefs = findDependentEnumeratedEntityDefs({ survey, nodeDef });
39
35
  if (dependentEnumeratedEntityDefs.length === 0)
40
36
  return [];
41
- const parentNode = (0, recordGetters_1.getParent)(node)(record);
37
+ const parentNode = (0, recordGetters_1.getParent)({ node })(record);
42
38
  return dependentEnumeratedEntityDefs.filter((dependentEnumeratedEntityDef) => hasNodeNonEmptyDescendants({ record, parentNode, nodeDefDescendant: dependentEnumeratedEntityDef }));
43
39
  };
44
40
  exports.findDependentEnumeratedEntityDefsNotEmpty = findDependentEnumeratedEntityDefsNotEmpty;
@@ -1 +1 @@
1
- {"version":3,"file":"recordUtils.js","sourceRoot":"","sources":["../../../src/record/_records/recordUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAAwD;AACxD,2CAA0F;AAE1F,yCAA8C;AAE9C,mDAOwB;AAExB,MAAM,iCAAiC,GAAG,CAAC,MAAiD,EAAmB,EAAE;IAC/G,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IAClC,MAAM,6BAA6B,GACjC,kBAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,qBAAW,CAAC,IAAI;QAC5C,CAAC,CAAC,gBAAO,CAAC,gCAAgC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAsB,EAAE,CAAC;QACvF,CAAC,CAAC,EAAE,CAAA;IAER,MAAM,uCAAuC,GAAG,gBAAO,CAAC,2CAA2C,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAA;IACpH,6BAA6B,CAAC,IAAI,CAAC,GAAG,uCAAuC,CAAC,CAAA;IAE9E,OAAO,6BAA6B,CAAA;AACtC,CAAC,CAAA;AAED,MAAM,0BAA0B,GAAG,CAAC,MAInC,EAAW,EAAE;IACZ,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAAA;IACxD,MAAM,WAAW,GAAG,IAAA,oCAAoB,EAAC;QACvC,MAAM;QACN,IAAI,EAAE,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AA;IAC9F,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA,CAAA;AA9BU,QAAA,2BAA2B,GAA3B,2BAA2B,CA8BrC","sourcesContent":["import { CategoryItem } from '../../category'\nimport { ArenaRecordNode, NodeValues } from '../../node'\nimport { NodeDef, NodeDefCode, NodeDefEntity, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { CategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider'\nimport { Survey, Surveys } from '../../survey'\nimport { ArenaRecord } from '../record'\nimport {\n getChildren,\n getDescendantsOrSelf,\n getParent,\n getParentCodeAttribute,\n getRoot,\n isNodeFilledByUser,\n} from './recordGetters'\n\nconst findDependentEnumeratedEntityDefs = (params: { survey: Survey; nodeDef: NodeDef<any> }): NodeDefEntity[] => {\n const { survey, nodeDef } = params\n const dependentEnumeratedEntityDefs =\n NodeDefs.getType(nodeDef) === NodeDefType.code\n ? Surveys.getDependentEnumeratedEntityDefs({ survey, nodeDef: nodeDef as NodeDefCode })\n : []\n\n const applicableDependentEnumeratedEntityDefs = Surveys.findApplicableDependentEnumeratedEntityDefs(nodeDef)(survey)\n dependentEnumeratedEntityDefs.push(...applicableDependentEnumeratedEntityDefs)\n\n return dependentEnumeratedEntityDefs\n}\n\nconst hasNodeNonEmptyDescendants = (params: {\n record: ArenaRecord\n parentNode: ArenaRecordNode | undefined\n nodeDefDescendant: NodeDefEntity\n}): boolean => {\n const { record, parentNode, nodeDefDescendant } = params\n const descendants = getDescendantsOrSelf({\n record,\n node: parentNode ?? getRoot(record)!,\n nodeDefDescendant,\n })\n const nonEmptyDescendants = descendants.filter((dependentEntity) =>\n getChildren(dependentEntity)(record).some((childNode) => isNodeFilledByUser(childNode)(record))\n )\n return nonEmptyDescendants.length > 0\n}\n\nexport const findDependentEnumeratedEntityDefsNotEmpty =\n (params: { survey: Survey; node: ArenaRecordNode; nodeDef: NodeDef<any> }) => (record: ArenaRecord) => {\n const { survey, node, nodeDef } = params\n const dependentEnumeratedEntityDefs = findDependentEnumeratedEntityDefs({ survey, nodeDef })\n if (dependentEnumeratedEntityDefs.length === 0) return []\n\n const parentNode = getParent(node)(record)\n\n return dependentEnumeratedEntityDefs.filter((dependentEnumeratedEntityDef) =>\n hasNodeNonEmptyDescendants({ record, parentNode, nodeDefDescendant: dependentEnumeratedEntityDef })\n )\n }\n\nexport const getEnumeratingCategoryItems =\n (params: {\n survey: Survey\n enumeratorDef: NodeDefCode\n parentNode: ArenaRecordNode\n categoryItemProvider?: CategoryItemProvider\n allowedCodes?: Set<string>\n }) =>\n async (record: ArenaRecord): Promise<CategoryItem[]> => {\n const { survey, enumeratorDef, parentNode, categoryItemProvider, allowedCodes } = params\n const categoryUuid = NodeDefs.getCategoryUuid(enumeratorDef)\n if (!categoryUuid) return []\n const category = Surveys.getCategoryByUuid({ survey, categoryUuid })\n if (!category) return []\n\n let parentItemUuid\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(enumeratorDef)\n if (parentCodeDefUuid) {\n const parentCodeAttribute = getParentCodeAttribute({ parentNode, nodeDef: enumeratorDef })(record)\n parentItemUuid = parentCodeAttribute ? NodeValues.getItemUuid(parentCodeAttribute) : null\n if (!parentItemUuid) return []\n }\n let items = Surveys.getEnumeratingCategoryItems({ survey, enumerator: enumeratorDef, parentItemUuid })\n if (items.length === 0 && categoryItemProvider) {\n items = await categoryItemProvider.getItems({ survey, categoryUuid, parentItemUuid, draft: !!record.preview })\n }\n if (allowedCodes) {\n items = items.filter((item) => item.props.code != null && allowedCodes.has(item.props.code))\n }\n return items\n }\n"]}
1
+ {"version":3,"file":"recordUtils.js","sourceRoot":"","sources":["../../../src/record/_records/recordUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAAwD;AACxD,2CAA0F;AAE1F,yCAA8C;AAE9C,mDAOwB;AAExB,MAAM,iCAAiC,GAAG,CAAC,MAAiD,EAAmB,EAAE;IAC/G,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAA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AW,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QACzF,IAAI,CAAC,cAAc;YAAE,OAAO,EAAE,CAAA;IAChC,CAAC;IACD,IAAI,KAAK,GAAG,gBAAO,CAAC,2BAA2B,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC,CAAA;IACtG,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,oBAAoB,EAAE,CAAC;QAC/C,KAAK,GAAG,MAAM,oBAAoB,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAA;IAChH,CAAC;IACD,IAAI,YAAY,EAAE,CAAC;QACjB,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;IAC9F,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA,CAAA;AA9BU,QAAA,2BAA2B,GAA3B,2BAA2B,CA8BrC","sourcesContent":["import { CategoryItem } from '../../category'\nimport { ArenaRecordNode, NodeValues } from '../../node'\nimport { NodeDef, NodeDefCode, NodeDefEntity, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { CategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider'\nimport { Survey, Surveys } from '../../survey'\nimport { ArenaRecord } from '../record'\nimport {\n getChildren,\n getDescendantsOrSelf,\n getParent,\n getParentCodeAttribute,\n getRoot,\n isNodeFilledByUser,\n} from './recordGetters'\n\nconst findDependentEnumeratedEntityDefs = (params: { survey: Survey; nodeDef: NodeDef<any> }): NodeDefEntity[] => {\n const { survey, nodeDef } = params\n const dependentEnumeratedEntityDefs =\n NodeDefs.getType(nodeDef) === NodeDefType.code\n ? Surveys.getDependentEnumeratedEntityDefs({ survey, nodeDef: nodeDef as NodeDefCode })\n : []\n\n const applicableDependentEnumeratedEntityDefs = Surveys.findApplicableDependentEnumeratedEntityDefs(nodeDef)(survey)\n dependentEnumeratedEntityDefs.push(...applicableDependentEnumeratedEntityDefs)\n\n return dependentEnumeratedEntityDefs\n}\n\nconst hasNodeNonEmptyDescendants = (params: {\n record: ArenaRecord\n parentNode: ArenaRecordNode | undefined\n nodeDefDescendant: NodeDefEntity\n}): boolean => {\n const { record, parentNode, nodeDefDescendant } = params\n const descendants = getDescendantsOrSelf({ node: parentNode ?? getRoot(record)!, nodeDefDescendant })(record)\n const nonEmptyDescendants = descendants.filter((dependentEntity) =>\n getChildren({ parentNode: dependentEntity })(record).some((childNode) =>\n isNodeFilledByUser({ node: childNode })(record)\n )\n )\n return nonEmptyDescendants.length > 0\n}\n\nexport const findDependentEnumeratedEntityDefsNotEmpty =\n (params: { survey: Survey; node: ArenaRecordNode; nodeDef: NodeDef<any> }) => (record: ArenaRecord) => {\n const { survey, node, nodeDef } = params\n const dependentEnumeratedEntityDefs = findDependentEnumeratedEntityDefs({ survey, nodeDef })\n if (dependentEnumeratedEntityDefs.length === 0) return []\n\n const parentNode = getParent({ node })(record)\n\n return dependentEnumeratedEntityDefs.filter((dependentEnumeratedEntityDef) =>\n hasNodeNonEmptyDescendants({ record, parentNode, nodeDefDescendant: dependentEnumeratedEntityDef })\n )\n }\n\nexport const getEnumeratingCategoryItems =\n (params: {\n survey: Survey\n enumeratorDef: NodeDefCode\n parentNode: ArenaRecordNode\n categoryItemProvider?: CategoryItemProvider\n allowedCodes?: Set<string>\n }) =>\n async (record: ArenaRecord): Promise<CategoryItem[]> => {\n const { survey, enumeratorDef, parentNode, categoryItemProvider, allowedCodes } = params\n const categoryUuid = NodeDefs.getCategoryUuid(enumeratorDef)\n if (!categoryUuid) return []\n const category = Surveys.getCategoryByUuid({ survey, categoryUuid })\n if (!category) return []\n\n let parentItemUuid\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(enumeratorDef)\n if (parentCodeDefUuid) {\n const parentCodeAttribute = getParentCodeAttribute({ parentNode, nodeDef: enumeratorDef })(record)\n parentItemUuid = parentCodeAttribute ? NodeValues.getItemUuid(parentCodeAttribute) : null\n if (!parentItemUuid) return []\n }\n let items = Surveys.getEnumeratingCategoryItems({ survey, enumerator: enumeratorDef, parentItemUuid })\n if (items.length === 0 && categoryItemProvider) {\n items = await categoryItemProvider.getItems({ survey, categoryUuid, parentItemUuid, draft: !!record.preview })\n }\n if (allowedCodes) {\n items = items.filter((item) => item.props.code != null && allowedCodes.has(item.props.code))\n }\n return items\n }\n"]}