@openforis/arena-core 2.3.40 → 2.3.42

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 (208) hide show
  1. package/dist/auth/authorizer.d.ts +3 -3
  2. package/dist/auth/authorizer.js.map +1 -1
  3. package/dist/esm/auth/authorizer.js.map +1 -1
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/esm/node/factory.js.map +1 -1
  6. package/dist/esm/node/index.js.map +1 -1
  7. package/dist/esm/node/node.js.map +1 -1
  8. package/dist/esm/node/nodePointer.js.map +1 -1
  9. package/dist/esm/node/nodeValueFormatter.js.map +1 -1
  10. package/dist/esm/node/nodeValues.js.map +1 -1
  11. package/dist/esm/node/nodes.js +13 -5
  12. package/dist/esm/node/nodes.js.map +1 -1
  13. package/dist/esm/node/service.js.map +1 -1
  14. package/dist/esm/nodeDefExpressionEvaluator/functions.js.map +1 -1
  15. package/dist/esm/record/_records/recordCompletion.js.map +1 -1
  16. package/dist/esm/record/_records/recordGetters.js.map +1 -1
  17. package/dist/esm/record/_records/recordNodesIndexUpdater.js +6 -4
  18. package/dist/esm/record/_records/recordNodesIndexUpdater.js.map +1 -1
  19. package/dist/esm/record/_records/recordPagesValidation.js.map +1 -1
  20. package/dist/esm/record/_records/recordUpdateOptions.js.map +1 -1
  21. package/dist/esm/record/_records/recordUpdater.js +1 -1
  22. package/dist/esm/record/_records/recordUpdater.js.map +1 -1
  23. package/dist/esm/record/_records/recordUtils.js.map +1 -1
  24. package/dist/esm/record/factory.js.map +1 -1
  25. package/dist/esm/record/index.js.map +1 -1
  26. package/dist/esm/record/nodePointers.js.map +1 -1
  27. package/dist/esm/record/record.js.map +1 -1
  28. package/dist/esm/record/recordCloner.js.map +1 -1
  29. package/dist/esm/record/recordExpressionEvaluator/context.js.map +1 -1
  30. package/dist/esm/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
  31. package/dist/esm/record/recordExpressionEvaluator/node/identifier/nodesFinder.js.map +1 -1
  32. package/dist/esm/record/recordExpressionEvaluator/nodeValueExtractor.js.map +1 -1
  33. package/dist/esm/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
  34. package/dist/esm/record/recordFixer.js.map +1 -1
  35. package/dist/esm/record/recordNodesUpdater/recordEnumeratingItemsExpressionEvaluator.js.map +1 -1
  36. package/dist/esm/record/recordNodesUpdater/recordExpressionValueConverter.js.map +1 -1
  37. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js +1 -1
  38. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js.map +1 -1
  39. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js +1 -1
  40. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js.map +1 -1
  41. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js.map +1 -1
  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.map +1 -1
  46. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js.map +1 -1
  47. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
  48. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsUpdateParams.js.map +1 -1
  49. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsVisibleUpdater.js +1 -1
  50. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsVisibleUpdater.js.map +1 -1
  51. package/dist/esm/record/recordNodesUpdater/recordNodesCreator.js.map +1 -1
  52. package/dist/esm/record/recordNodesUpdater/recordNodesDeleter.js +1 -1
  53. package/dist/esm/record/recordNodesUpdater/recordNodesDeleter.js.map +1 -1
  54. package/dist/esm/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
  55. package/dist/esm/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
  56. package/dist/esm/record/recordNodesUpdater/recordUpdateResult.js.map +1 -1
  57. package/dist/esm/record/recordPrettyPrinter.js.map +1 -1
  58. package/dist/esm/record/recordUpdater.js.map +1 -1
  59. package/dist/esm/record/recordValidator/attributeKeyValidator.js.map +1 -1
  60. package/dist/esm/record/recordValidator/attributeTypeValidator.js.map +1 -1
  61. package/dist/esm/record/recordValidator/attributeUniqueValidator.js.map +1 -1
  62. package/dist/esm/record/recordValidator/attributeValidator.js.map +1 -1
  63. package/dist/esm/record/recordValidator/countVaildator.js.map +1 -1
  64. package/dist/esm/record/recordValidator/recordValidator.js.map +1 -1
  65. package/dist/esm/record/service.js.map +1 -1
  66. package/dist/esm/survey/nodeDefsFixer.js.map +1 -1
  67. package/dist/esm/survey/surveys/_nodeDefs/nodeDefsIndex.js +2 -2
  68. package/dist/esm/survey/surveys/_nodeDefs/nodeDefsIndex.js.map +1 -1
  69. package/dist/esm/tests/builder/recordBuilder/attributeBuilder.js.map +1 -1
  70. package/dist/esm/tests/builder/recordBuilder/entityBuilder.js.map +1 -1
  71. package/dist/esm/tests/builder/recordBuilder/nodeBuilder.js.map +1 -1
  72. package/dist/esm/tests/builder/recordBuilder/recordBuilder.js.map +1 -1
  73. package/dist/esm/utils/index.js.map +1 -1
  74. package/dist/esm/utils/mutationOptions.js +5 -0
  75. package/dist/esm/utils/mutationOptions.js.map +1 -0
  76. package/dist/esm/validation/index.js.map +1 -1
  77. package/dist/esm/validation/validations.js +26 -19
  78. package/dist/esm/validation/validations.js.map +1 -1
  79. package/dist/index.d.ts +4 -4
  80. package/dist/index.js.map +1 -1
  81. package/dist/node/factory.d.ts +4 -4
  82. package/dist/node/factory.js.map +1 -1
  83. package/dist/node/index.d.ts +1 -2
  84. package/dist/node/index.js.map +1 -1
  85. package/dist/node/node.d.ts +7 -2
  86. package/dist/node/node.js.map +1 -1
  87. package/dist/node/nodePointer.d.ts +2 -2
  88. package/dist/node/nodePointer.js.map +1 -1
  89. package/dist/node/nodeValueFormatter.d.ts +2 -2
  90. package/dist/node/nodeValueFormatter.js.map +1 -1
  91. package/dist/node/nodeValues.d.ts +21 -21
  92. package/dist/node/nodeValues.js.map +1 -1
  93. package/dist/node/nodes.d.ts +38 -31
  94. package/dist/node/nodes.js +13 -5
  95. package/dist/node/nodes.js.map +1 -1
  96. package/dist/node/service.d.ts +6 -6
  97. package/dist/node/service.js.map +1 -1
  98. package/dist/nodeDefExpressionEvaluator/functions.js.map +1 -1
  99. package/dist/record/_records/recordCompletion.d.ts +9 -9
  100. package/dist/record/_records/recordCompletion.js.map +1 -1
  101. package/dist/record/_records/recordGetters.d.ts +69 -69
  102. package/dist/record/_records/recordGetters.js.map +1 -1
  103. package/dist/record/_records/recordNodesIndexUpdater.d.ts +13 -10
  104. package/dist/record/_records/recordNodesIndexUpdater.js +6 -4
  105. package/dist/record/_records/recordNodesIndexUpdater.js.map +1 -1
  106. package/dist/record/_records/recordPagesValidation.d.ts +11 -11
  107. package/dist/record/_records/recordPagesValidation.js.map +1 -1
  108. package/dist/record/_records/recordUpdateOptions.d.ts +2 -2
  109. package/dist/record/_records/recordUpdateOptions.js.map +1 -1
  110. package/dist/record/_records/recordUpdater.d.ts +5 -5
  111. package/dist/record/_records/recordUpdater.js +1 -1
  112. package/dist/record/_records/recordUpdater.js.map +1 -1
  113. package/dist/record/_records/recordUtils.d.ts +6 -6
  114. package/dist/record/_records/recordUtils.js.map +1 -1
  115. package/dist/record/factory.d.ts +2 -2
  116. package/dist/record/factory.js.map +1 -1
  117. package/dist/record/index.d.ts +1 -2
  118. package/dist/record/index.js.map +1 -1
  119. package/dist/record/nodePointers.d.ts +6 -6
  120. package/dist/record/nodePointers.js.map +1 -1
  121. package/dist/record/record.d.ts +8 -5
  122. package/dist/record/record.js.map +1 -1
  123. package/dist/record/recordCloner.d.ts +3 -3
  124. package/dist/record/recordCloner.js.map +1 -1
  125. package/dist/record/recordExpressionEvaluator/context.d.ts +6 -6
  126. package/dist/record/recordExpressionEvaluator/context.js.map +1 -1
  127. package/dist/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
  128. package/dist/record/recordExpressionEvaluator/node/identifier/nodesFinder.d.ts +5 -5
  129. package/dist/record/recordExpressionEvaluator/node/identifier/nodesFinder.js.map +1 -1
  130. package/dist/record/recordExpressionEvaluator/nodeValueExtractor.d.ts +2 -2
  131. package/dist/record/recordExpressionEvaluator/nodeValueExtractor.js.map +1 -1
  132. package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.d.ts +4 -4
  133. package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
  134. package/dist/record/recordFixer.js.map +1 -1
  135. package/dist/record/recordNodesUpdater/recordEnumeratingItemsExpressionEvaluator.d.ts +4 -4
  136. package/dist/record/recordNodesUpdater/recordEnumeratingItemsExpressionEvaluator.js.map +1 -1
  137. package/dist/record/recordNodesUpdater/recordExpressionValueConverter.d.ts +4 -4
  138. package/dist/record/recordNodesUpdater/recordExpressionValueConverter.js.map +1 -1
  139. package/dist/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js +1 -1
  140. package/dist/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js.map +1 -1
  141. package/dist/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.d.ts +4 -3
  142. package/dist/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js +1 -1
  143. package/dist/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js.map +1 -1
  144. package/dist/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js.map +1 -1
  145. package/dist/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js.map +1 -1
  146. package/dist/record/recordNodesUpdater/recordNodeDependentsEditableUpdater.js +1 -1
  147. package/dist/record/recordNodesUpdater/recordNodeDependentsEditableUpdater.js.map +1 -1
  148. package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.d.ts +2 -2
  149. package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js.map +1 -1
  150. package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.d.ts +2 -2
  151. package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js.map +1 -1
  152. package/dist/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
  153. package/dist/record/recordNodesUpdater/recordNodeDependentsUpdateParams.d.ts +2 -2
  154. package/dist/record/recordNodesUpdater/recordNodeDependentsUpdateParams.js.map +1 -1
  155. package/dist/record/recordNodesUpdater/recordNodeDependentsVisibleUpdater.js +1 -1
  156. package/dist/record/recordNodesUpdater/recordNodeDependentsVisibleUpdater.js.map +1 -1
  157. package/dist/record/recordNodesUpdater/recordNodesCreator.d.ts +4 -4
  158. package/dist/record/recordNodesUpdater/recordNodesCreator.js.map +1 -1
  159. package/dist/record/recordNodesUpdater/recordNodesDeleter.d.ts +3 -3
  160. package/dist/record/recordNodesUpdater/recordNodesDeleter.js +1 -1
  161. package/dist/record/recordNodesUpdater/recordNodesDeleter.js.map +1 -1
  162. package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.d.ts +4 -4
  163. package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
  164. package/dist/record/recordNodesUpdater/recordNodesUpdater.d.ts +2 -2
  165. package/dist/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
  166. package/dist/record/recordNodesUpdater/recordUpdateResult.d.ts +6 -6
  167. package/dist/record/recordNodesUpdater/recordUpdateResult.js.map +1 -1
  168. package/dist/record/recordPrettyPrinter.d.ts +7 -7
  169. package/dist/record/recordPrettyPrinter.js.map +1 -1
  170. package/dist/record/recordUpdater.js.map +1 -1
  171. package/dist/record/recordValidator/attributeKeyValidator.d.ts +4 -4
  172. package/dist/record/recordValidator/attributeKeyValidator.js.map +1 -1
  173. package/dist/record/recordValidator/attributeTypeValidator.d.ts +4 -4
  174. package/dist/record/recordValidator/attributeTypeValidator.js.map +1 -1
  175. package/dist/record/recordValidator/attributeUniqueValidator.d.ts +4 -4
  176. package/dist/record/recordValidator/attributeUniqueValidator.js.map +1 -1
  177. package/dist/record/recordValidator/attributeValidator.d.ts +6 -6
  178. package/dist/record/recordValidator/attributeValidator.js.map +1 -1
  179. package/dist/record/recordValidator/countVaildator.d.ts +7 -7
  180. package/dist/record/recordValidator/countVaildator.js.map +1 -1
  181. package/dist/record/recordValidator/recordValidator.js.map +1 -1
  182. package/dist/record/records.d.ts +6 -6
  183. package/dist/record/service.d.ts +8 -8
  184. package/dist/record/service.js.map +1 -1
  185. package/dist/survey/nodeDefsFixer.d.ts +2 -2
  186. package/dist/survey/nodeDefsFixer.js.map +1 -1
  187. package/dist/survey/surveys/_nodeDefs/nodeDefsIndex.d.ts +3 -6
  188. package/dist/survey/surveys/_nodeDefs/nodeDefsIndex.js +2 -2
  189. package/dist/survey/surveys/_nodeDefs/nodeDefsIndex.js.map +1 -1
  190. package/dist/tests/builder/recordBuilder/attributeBuilder.d.ts +5 -5
  191. package/dist/tests/builder/recordBuilder/attributeBuilder.js.map +1 -1
  192. package/dist/tests/builder/recordBuilder/entityBuilder.d.ts +5 -5
  193. package/dist/tests/builder/recordBuilder/entityBuilder.js.map +1 -1
  194. package/dist/tests/builder/recordBuilder/nodeBuilder.d.ts +5 -5
  195. package/dist/tests/builder/recordBuilder/nodeBuilder.js.map +1 -1
  196. package/dist/tests/builder/recordBuilder/recordBuilder.d.ts +2 -2
  197. package/dist/tests/builder/recordBuilder/recordBuilder.js.map +1 -1
  198. package/dist/utils/index.d.ts +1 -0
  199. package/dist/utils/index.js.map +1 -1
  200. package/dist/utils/mutationOptions.d.ts +14 -0
  201. package/dist/utils/mutationOptions.js +9 -0
  202. package/dist/utils/mutationOptions.js.map +1 -0
  203. package/dist/validation/index.d.ts +1 -0
  204. package/dist/validation/index.js.map +1 -1
  205. package/dist/validation/validations.d.ts +17 -2
  206. package/dist/validation/validations.js +26 -19
  207. package/dist/validation/validations.js.map +1 -1
  208. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../src/nodeDefExpressionEvaluator/functions.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kCAA+B;AAE/B,oCAAsC;AAEtC,wDAAoD;AACpD,gCAAsC;AACtC,0CAAkD;AAElD,yDAA6D;AAC7D,yDAAuF;AACvF,qEAAoG;AAEpG,oCAAkD;AAGlD,MAAM,oBAAoB,GAAG;IAC3B,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE;QACR,IAAI,EAAE,SAAS;QACf,WAAW,EAAE;YACX;gBACE,CAAC,KAAK,EAAE,GAAG,CAAC;gBACZ,CAAC,KAAK,EAAE,GAAG,CAAC;gBACZ,CAAC,KAAK,EAAE,GAAG,CAAC;gBACZ,CAAC,KAAK,EAAE,GAAG,CAAC;gBACZ,CAAC,KAAK,EAAE,GAAG,CAAC;aACb;SACF;KACF;CACF,CAAA;AAED,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAW,EAAE,CAAC,eAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAA;AAExG,MAAM,aAAa,GAAG,CAAC,QAAkC,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAA;AAExE,MAAM,iBAAiB,GAAG,CAAC,OAAiC,EAAE,EAAE;IAC9D,kEAAkE;IAClE,MAAM,MAAM,GAAY,OAAe,CAAC,MAAM,CAAA;IAC9C,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAA;AACpC,CAAC,CAAA;AAED,MAAM,sBAAsB,GAAG,CAAO,MAIrC,EAAqC,EAAE;IACtC,MAAM,EAAE,O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CAAC,KAAK;KAC9D;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,CAAC;QACX,QAAQ,EAAE,CAAC;QACX,QAAQ,EAAE,CAAC,OAAiC,EAAE,EAAE,CAAC,GAAG,EAAE,kBAAC,MAAA,OAAO,CAAC,IAAI,0CAAE,IAAI,GAAA;KAC1E;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,CAAC;QACX,QAAQ,EAAE,CAAC;QACX,QAAQ,EAAE,CAAC,OAAiC,EAAE,EAAE,CAAC,CAAC,QAAgB,EAAE,EAAE;YACpE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;YAChC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI;gBAAE,OAAO,SAAS,CAAA;YACtC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,MAAM,CAAA;YACnC,MAAM,kBAAkB,GAAG,YAAK,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAA;YACxE,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAA;QACrC,CAAC;KACF;CACF,CAAA","sourcesContent":["import { Users } from '../auth'\nimport { CategoryItem } from '../category'\nimport { SystemError } from '../error'\nimport { ExpressionFunctions } from '../expression'\nimport { ExtraProps } from '../extraProp/extraProps'\nimport { Point, Points } from '../geo'\nimport { LanguagesISO639part2 } from '../language'\nimport { Record } from '../record'\nimport { getNodeDefParent } from '../survey/surveys/nodeDefs'\nimport { getCategoryItemByCodePaths, getTaxonByCode } from '../survey/surveys/refsData'\nimport { getCategoryByName, getSRSIndex, getTaxonomyByName } from '../survey/surveys/surveysGetters'\nimport { Taxon } from '../taxonomy'\nimport { Dates, Numbers, Objects } from '../utils'\nimport { NodeDefExpressionContext } from './context'\n\nconst sampleGeoJsonPolygon = {\n type: 'Feature',\n geometry: {\n type: 'Polygon',\n coordinates: [\n [\n [100.0, 0.0],\n [101.0, 0.0],\n [101.0, 1.0],\n [100.0, 1.0],\n [100.0, 0.0],\n ],\n ],\n },\n}\n\nconst isNotValidString = (value: string): boolean => Objects.isEmpty(value) || typeof value !== 'string'\n\nconst emptyExecutor = (_context: NodeDefExpressionContext) => () => null\n\nconst isUsingDraftProps = (context: NodeDefExpressionContext) => {\n // use draft props when validating expression or previewing record\n const record: Record = (context as any).record\n return !record || !!record.preview\n}\n\nconst getOrFetchCategoryItem = async (params: {\n context: NodeDefExpressionContext\n categoryUuid: string\n codePaths: string[]\n}): Promise<CategoryItem | undefined> => {\n const { context, categoryUuid, codePaths } = params\n // if any code path is empty, return null (no category item can be found)\n if (Objects.isEmpty(codePaths) || codePaths.some(Objects.isEmpty)) {\n return undefined\n }\n const { survey, categoryItemProvider } = context\n const categoryItem = getCategoryItemByCodePaths({ survey, categoryUuid, codePaths })\n const draft = isUsingDraftProps(context)\n return categoryItem ?? categoryItemProvider?.getItemByCodePaths({ survey, categoryUuid, codePaths, draft })\n}\n\nconst getOrFetchTaxon = async (params: {\n context: NodeDefExpressionContext\n taxonomyUuid: string\n taxonCode: string\n}): Promise<Taxon | undefined> => {\n const { context, taxonomyUuid, taxonCode } = params\n if (typeof taxonCode !== 'string' && typeof taxonCode !== 'number') {\n return undefined // node def expression validator could call it passing a node def object\n }\n // if taxonCode is empty, return undefined\n if (Objects.isEmpty(taxonCode)) {\n return undefined\n }\n const { survey, taxonProvider } = context\n const taxon = getTaxonByCode({ survey, taxonomyUuid, taxonCode })\n // fetch draft props when validating expression or previewing record\n const record: Record = (context as any).record\n const draft = !record || !!record.preview\n return taxon ?? taxonProvider?.getTaxonByCode({ survey, taxonomyUuid, taxonCode, draft })\n}\n\nconst geoDistanceExecutor =\n (context: NodeDefExpressionContext) =>\n (coordinateFrom: Point | string, coordinateTo: Point | string): number | null => {\n const { survey } = context\n const srsIndex = getSRSIndex(survey)\n\n const pointFrom = Points.parse(coordinateFrom)\n const pointTo = Points.parse(coordinateTo)\n\n return pointFrom && pointTo ? Points.distance(pointFrom, pointTo, srsIndex) : null\n }\n\nexport const nodeDefExpressionFunctions: ExpressionFunctions<NodeDefExpressionContext> = {\n categoryItemProp: {\n minArity: 3,\n executor:\n (context: NodeDefExpressionContext) =>\n async (categoryName: string, itemPropName: string, ...codePaths: string[]): Promise<any> => {\n const { survey } = context\n\n if (Objects.isEmpty(categoryName) || Objects.isEmpty(itemPropName) || Objects.isEmpty(codePaths))\n throw new SystemError('expression.missingFunctionParameters')\n\n const category = getCategoryByName({ survey, categoryName })\n if (!category) throw new SystemError('expression.invalidCategoryName', { name: categoryName })\n\n const extraPropDef = category.props.itemExtraDef?.[itemPropName]\n if (!extraPropDef) throw new SystemError('expression.invalidCategoryExtraProp', { propName: itemPropName })\n\n const { uuid: categoryUuid } = category\n const categoryItem = await getOrFetchCategoryItem({ context, categoryUuid, codePaths })\n if (!categoryItem) return null\n\n const value = categoryItem.props.extra?.[itemPropName]\n return ExtraProps.convertValue({ survey, extraPropDef, value })\n },\n },\n count: {\n minArity: 1,\n maxArity: 1,\n executor:\n (_context: NodeDefExpressionContext) =>\n (_nodeSet): number =>\n 1,\n },\n dateTimeDiff: {\n minArity: 4,\n maxArity: 4,\n executor:\n (_context: NodeDefExpressionContext) =>\n (date1: string, time1: string, date2: string, time2: string): number | null => {\n if (isNotValidString(date1) || isNotValidString(time1) || isNotValidString(date2) || isNotValidString(time2))\n return null\n const [hours1, minutes1] = time1.split(':')\n const [hours2, minutes2] = time2.split(':')\n let dt1 = Dates.addHours(date1, Number(hours1))\n dt1 = Dates.addMinutes(dt1, Number(minutes1))\n let dt2 = Dates.addHours(date2, Number(hours2))\n dt2 = Dates.addMinutes(dt2, Number(minutes2))\n return Dates.diffInMinutes(dt1, dt2)\n },\n },\n // deprecated, use geoDistance instead\n distance: { minArity: 2, maxArity: 2, executor: geoDistanceExecutor },\n first: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: emptyExecutor,\n },\n geoCoordinateAtDistance: {\n minArity: 3,\n maxArity: 3,\n executor:\n (context: NodeDefExpressionContext) =>\n (coordinate: Point | string, distanceMeters: number, bearingDeg: number): Point | null => {\n // validate parameters\n const origin = Points.parse(coordinate)\n if (!origin) return null\n\n const distanceMetersNumber = Number(distanceMeters)\n const bearingDegNumber = Number(bearingDeg)\n if (!Number.isFinite(distanceMetersNumber) || distanceMetersNumber < 0 || !Number.isFinite(bearingDegNumber)) {\n return null\n }\n\n const { survey } = context\n const srsIndex = getSRSIndex(survey)\n\n return Points.pointAtDistance({\n origin,\n distanceMeters: distanceMetersNumber,\n bearingDeg: bearingDegNumber,\n srsIndex,\n })\n },\n },\n geoDistance: { minArity: 2, maxArity: 2, executor: geoDistanceExecutor },\n geoPolygon: {\n minArity: 1,\n evaluateArgsToNodes: true,\n executor: () => () => sampleGeoJsonPolygon,\n },\n includes: {\n minArity: 2,\n maxArity: 2,\n evaluateArgsToNodes: false,\n executor:\n () =>\n (items: any, value: any): boolean =>\n Array.isArray(items) && items.map(String).includes(String(value)),\n },\n index: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: () => () => -1,\n },\n last: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: emptyExecutor,\n },\n now: {\n minArity: 0,\n maxArity: 0,\n evaluateToNode: false,\n executor: () => () => Dates.nowFormattedForStorage(),\n },\n numberToWords: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: false,\n executor:\n (context: NodeDefExpressionContext) =>\n (value: any): string | null => {\n if (Objects.isEmpty(value)) return null\n return Numbers.toWords(value, context.lang)\n },\n },\n parent: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n evaluateToNode: true,\n executor: (context: NodeDefExpressionContext) => (nodeDef) => {\n const { survey } = context\n return getNodeDefParent({ survey, nodeDef })\n },\n },\n prevCycleValue: {\n minArity: 1,\n maxArity: 1,\n executor: emptyExecutor,\n },\n prevCycleValues: {\n minArity: 1,\n maxArity: 1,\n executor: emptyExecutor,\n },\n recordCycle: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordDateCreated: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordDateLastModified: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordOwnerEmail: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordOwnerName: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordOwnerRole: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n sum: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: (_context: NodeDefExpressionContext) => (_nodeSet) => 1,\n },\n taxonProp: {\n minArity: 3,\n maxArity: 3,\n executor:\n (context: NodeDefExpressionContext) => async (taxonomyName: string, propName: string, taxonCode: string) => {\n if (Objects.isEmpty(taxonomyName) || Objects.isEmpty(propName))\n throw new SystemError('expression.missingFunctionParameters')\n if (Objects.isEmpty(taxonCode)) return null\n\n const { survey } = context\n const taxonomy = getTaxonomyByName({ survey, taxonomyName })\n if (!taxonomy) throw new SystemError('expression.invalidTaxonomyName', { name: taxonomyName })\n\n const extraPropDef = taxonomy.props.extraPropsDefs?.[propName]\n if (!extraPropDef) throw new SystemError('expression.invalidTaxonomyExtraProp', { propName })\n\n const taxon = await getOrFetchTaxon({ context, taxonomyUuid: taxonomy.uuid, taxonCode })\n if (!taxon) return null\n\n const value = taxon.props.extra?.[propName]\n return ExtraProps.convertValue({ survey, extraPropDef, value })\n },\n },\n taxonVernacularName: {\n minArity: 3,\n maxArity: 3,\n executor:\n (context: NodeDefExpressionContext) =>\n async (taxonomyName: string, vernacularLangCode: string, taxonCode: string) => {\n if (Objects.isEmpty(taxonomyName) || Objects.isEmpty(vernacularLangCode))\n throw new SystemError('expression.missingFunctionParameters')\n if (Objects.isEmpty(taxonCode)) return null\n\n const { survey } = context\n const taxonomy = getTaxonomyByName({ survey, taxonomyName })\n if (!taxonomy) throw new SystemError('expression.invalidTaxonomyName', { name: taxonomyName })\n\n if (!LanguagesISO639part2[vernacularLangCode]) {\n throw new SystemError('expression.invalidTaxonVernacularNameLanguageCode', { vernacularLangCode })\n }\n\n const taxon = await getOrFetchTaxon({ context, taxonomyUuid: taxonomy.uuid, taxonCode })\n if (!taxon) return null\n\n const vernacularNameArray = taxon.vernacularNames?.[vernacularLangCode]\n // consider first vernacular name object only\n const firstVernacularName = vernacularNameArray?.[0]\n return firstVernacularName?.props?.name\n },\n },\n unique: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: (_context: NodeDefExpressionContext) => (_nodeSet) => [],\n },\n userEmail: {\n minArity: 0,\n maxArity: 0,\n executor: (context: NodeDefExpressionContext) => () => context.user?.email,\n },\n userIsRecordOwner: {\n minArity: 0,\n maxArity: 0,\n executor: (_context: NodeDefExpressionContext) => () => false,\n },\n userName: {\n minArity: 0,\n maxArity: 0,\n executor: (context: NodeDefExpressionContext) => () => context.user?.name,\n },\n userProp: {\n minArity: 1,\n maxArity: 1,\n executor: (context: NodeDefExpressionContext) => (propName: string) => {\n const { user, survey } = context\n if (!survey || !user) return undefined\n const { uuid: surveyUuid } = survey\n const combinedExtraProps = Users.getCombinedExtraProps(surveyUuid)(user)\n return combinedExtraProps[propName]\n },\n },\n}\n"]}
1
+ {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../src/nodeDefExpressionEvaluator/functions.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kCAA+B;AAE/B,oCAAsC;AAEtC,wDAAoD;AACpD,gCAAsC;AACtC,0CAAkD;AAElD,yDAA6D;AAC7D,yDAAuF;AACvF,qEAAoG;AAEpG,oCAAkD;AAGlD,MAAM,oBAAoB,GAAG;IAC3B,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE;QACR,IAAI,EAAE,SAAS;QACf,WAAW,EAAE;YACX;gBACE,CAAC,KAAK,EAAE,GAAG,CAAC;gBACZ,CAAC,KAAK,EAAE,GAAG,CAAC;gBACZ,CAAC,KAAK,EAAE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,kBAAkB,CAAC,QAAQ,CAAC,CAAA;QACrC,CAAC;KACF;CACF,CAAA","sourcesContent":["import { Users } from '../auth'\nimport { CategoryItem } from '../category'\nimport { SystemError } from '../error'\nimport { ExpressionFunctions } from '../expression'\nimport { ExtraProps } from '../extraProp/extraProps'\nimport { Point, Points } from '../geo'\nimport { LanguagesISO639part2 } from '../language'\nimport { ArenaRecord } from '../record'\nimport { getNodeDefParent } from '../survey/surveys/nodeDefs'\nimport { getCategoryItemByCodePaths, getTaxonByCode } from '../survey/surveys/refsData'\nimport { getCategoryByName, getSRSIndex, getTaxonomyByName } from '../survey/surveys/surveysGetters'\nimport { Taxon } from '../taxonomy'\nimport { Dates, Numbers, Objects } from '../utils'\nimport { NodeDefExpressionContext } from './context'\n\nconst sampleGeoJsonPolygon = {\n type: 'Feature',\n geometry: {\n type: 'Polygon',\n coordinates: [\n [\n [100.0, 0.0],\n [101.0, 0.0],\n [101.0, 1.0],\n [100.0, 1.0],\n [100.0, 0.0],\n ],\n ],\n },\n}\n\nconst isNotValidString = (value: string): boolean => Objects.isEmpty(value) || typeof value !== 'string'\n\nconst emptyExecutor = (_context: NodeDefExpressionContext) => () => null\n\nconst isUsingDraftProps = (context: NodeDefExpressionContext) => {\n // use draft props when validating expression or previewing record\n const record: ArenaRecord = (context as any).record\n return !record || !!record.preview\n}\n\nconst getOrFetchCategoryItem = async (params: {\n context: NodeDefExpressionContext\n categoryUuid: string\n codePaths: string[]\n}): Promise<CategoryItem | undefined> => {\n const { context, categoryUuid, codePaths } = params\n // if any code path is empty, return null (no category item can be found)\n if (Objects.isEmpty(codePaths) || codePaths.some(Objects.isEmpty)) {\n return undefined\n }\n const { survey, categoryItemProvider } = context\n const categoryItem = getCategoryItemByCodePaths({ survey, categoryUuid, codePaths })\n const draft = isUsingDraftProps(context)\n return categoryItem ?? categoryItemProvider?.getItemByCodePaths({ survey, categoryUuid, codePaths, draft })\n}\n\nconst getOrFetchTaxon = async (params: {\n context: NodeDefExpressionContext\n taxonomyUuid: string\n taxonCode: string\n}): Promise<Taxon | undefined> => {\n const { context, taxonomyUuid, taxonCode } = params\n if (typeof taxonCode !== 'string' && typeof taxonCode !== 'number') {\n return undefined // node def expression validator could call it passing a node def object\n }\n // if taxonCode is empty, return undefined\n if (Objects.isEmpty(taxonCode)) {\n return undefined\n }\n const { survey, taxonProvider } = context\n const taxon = getTaxonByCode({ survey, taxonomyUuid, taxonCode })\n // fetch draft props when validating expression or previewing record\n const record: ArenaRecord = (context as any).record\n const draft = !record || !!record.preview\n return taxon ?? taxonProvider?.getTaxonByCode({ survey, taxonomyUuid, taxonCode, draft })\n}\n\nconst geoDistanceExecutor =\n (context: NodeDefExpressionContext) =>\n (coordinateFrom: Point | string, coordinateTo: Point | string): number | null => {\n const { survey } = context\n const srsIndex = getSRSIndex(survey)\n\n const pointFrom = Points.parse(coordinateFrom)\n const pointTo = Points.parse(coordinateTo)\n\n return pointFrom && pointTo ? Points.distance(pointFrom, pointTo, srsIndex) : null\n }\n\nexport const nodeDefExpressionFunctions: ExpressionFunctions<NodeDefExpressionContext> = {\n categoryItemProp: {\n minArity: 3,\n executor:\n (context: NodeDefExpressionContext) =>\n async (categoryName: string, itemPropName: string, ...codePaths: string[]): Promise<any> => {\n const { survey } = context\n\n if (Objects.isEmpty(categoryName) || Objects.isEmpty(itemPropName) || Objects.isEmpty(codePaths))\n throw new SystemError('expression.missingFunctionParameters')\n\n const category = getCategoryByName({ survey, categoryName })\n if (!category) throw new SystemError('expression.invalidCategoryName', { name: categoryName })\n\n const extraPropDef = category.props.itemExtraDef?.[itemPropName]\n if (!extraPropDef) throw new SystemError('expression.invalidCategoryExtraProp', { propName: itemPropName })\n\n const { uuid: categoryUuid } = category\n const categoryItem = await getOrFetchCategoryItem({ context, categoryUuid, codePaths })\n if (!categoryItem) return null\n\n const value = categoryItem.props.extra?.[itemPropName]\n return ExtraProps.convertValue({ survey, extraPropDef, value })\n },\n },\n count: {\n minArity: 1,\n maxArity: 1,\n executor:\n (_context: NodeDefExpressionContext) =>\n (_nodeSet): number =>\n 1,\n },\n dateTimeDiff: {\n minArity: 4,\n maxArity: 4,\n executor:\n (_context: NodeDefExpressionContext) =>\n (date1: string, time1: string, date2: string, time2: string): number | null => {\n if (isNotValidString(date1) || isNotValidString(time1) || isNotValidString(date2) || isNotValidString(time2))\n return null\n const [hours1, minutes1] = time1.split(':')\n const [hours2, minutes2] = time2.split(':')\n let dt1 = Dates.addHours(date1, Number(hours1))\n dt1 = Dates.addMinutes(dt1, Number(minutes1))\n let dt2 = Dates.addHours(date2, Number(hours2))\n dt2 = Dates.addMinutes(dt2, Number(minutes2))\n return Dates.diffInMinutes(dt1, dt2)\n },\n },\n // deprecated, use geoDistance instead\n distance: { minArity: 2, maxArity: 2, executor: geoDistanceExecutor },\n first: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: emptyExecutor,\n },\n geoCoordinateAtDistance: {\n minArity: 3,\n maxArity: 3,\n executor:\n (context: NodeDefExpressionContext) =>\n (coordinate: Point | string, distanceMeters: number, bearingDeg: number): Point | null => {\n // validate parameters\n const origin = Points.parse(coordinate)\n if (!origin) return null\n\n const distanceMetersNumber = Number(distanceMeters)\n const bearingDegNumber = Number(bearingDeg)\n if (!Number.isFinite(distanceMetersNumber) || distanceMetersNumber < 0 || !Number.isFinite(bearingDegNumber)) {\n return null\n }\n\n const { survey } = context\n const srsIndex = getSRSIndex(survey)\n\n return Points.pointAtDistance({\n origin,\n distanceMeters: distanceMetersNumber,\n bearingDeg: bearingDegNumber,\n srsIndex,\n })\n },\n },\n geoDistance: { minArity: 2, maxArity: 2, executor: geoDistanceExecutor },\n geoPolygon: {\n minArity: 1,\n evaluateArgsToNodes: true,\n executor: () => () => sampleGeoJsonPolygon,\n },\n includes: {\n minArity: 2,\n maxArity: 2,\n evaluateArgsToNodes: false,\n executor:\n () =>\n (items: any, value: any): boolean =>\n Array.isArray(items) && items.map(String).includes(String(value)),\n },\n index: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: () => () => -1,\n },\n last: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: emptyExecutor,\n },\n now: {\n minArity: 0,\n maxArity: 0,\n evaluateToNode: false,\n executor: () => () => Dates.nowFormattedForStorage(),\n },\n numberToWords: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: false,\n executor:\n (context: NodeDefExpressionContext) =>\n (value: any): string | null => {\n if (Objects.isEmpty(value)) return null\n return Numbers.toWords(value, context.lang)\n },\n },\n parent: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n evaluateToNode: true,\n executor: (context: NodeDefExpressionContext) => (nodeDef) => {\n const { survey } = context\n return getNodeDefParent({ survey, nodeDef })\n },\n },\n prevCycleValue: {\n minArity: 1,\n maxArity: 1,\n executor: emptyExecutor,\n },\n prevCycleValues: {\n minArity: 1,\n maxArity: 1,\n executor: emptyExecutor,\n },\n recordCycle: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordDateCreated: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordDateLastModified: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordOwnerEmail: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordOwnerName: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordOwnerRole: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n sum: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: (_context: NodeDefExpressionContext) => (_nodeSet) => 1,\n },\n taxonProp: {\n minArity: 3,\n maxArity: 3,\n executor:\n (context: NodeDefExpressionContext) => async (taxonomyName: string, propName: string, taxonCode: string) => {\n if (Objects.isEmpty(taxonomyName) || Objects.isEmpty(propName))\n throw new SystemError('expression.missingFunctionParameters')\n if (Objects.isEmpty(taxonCode)) return null\n\n const { survey } = context\n const taxonomy = getTaxonomyByName({ survey, taxonomyName })\n if (!taxonomy) throw new SystemError('expression.invalidTaxonomyName', { name: taxonomyName })\n\n const extraPropDef = taxonomy.props.extraPropsDefs?.[propName]\n if (!extraPropDef) throw new SystemError('expression.invalidTaxonomyExtraProp', { propName })\n\n const taxon = await getOrFetchTaxon({ context, taxonomyUuid: taxonomy.uuid, taxonCode })\n if (!taxon) return null\n\n const value = taxon.props.extra?.[propName]\n return ExtraProps.convertValue({ survey, extraPropDef, value })\n },\n },\n taxonVernacularName: {\n minArity: 3,\n maxArity: 3,\n executor:\n (context: NodeDefExpressionContext) =>\n async (taxonomyName: string, vernacularLangCode: string, taxonCode: string) => {\n if (Objects.isEmpty(taxonomyName) || Objects.isEmpty(vernacularLangCode))\n throw new SystemError('expression.missingFunctionParameters')\n if (Objects.isEmpty(taxonCode)) return null\n\n const { survey } = context\n const taxonomy = getTaxonomyByName({ survey, taxonomyName })\n if (!taxonomy) throw new SystemError('expression.invalidTaxonomyName', { name: taxonomyName })\n\n if (!LanguagesISO639part2[vernacularLangCode]) {\n throw new SystemError('expression.invalidTaxonVernacularNameLanguageCode', { vernacularLangCode })\n }\n\n const taxon = await getOrFetchTaxon({ context, taxonomyUuid: taxonomy.uuid, taxonCode })\n if (!taxon) return null\n\n const vernacularNameArray = taxon.vernacularNames?.[vernacularLangCode]\n // consider first vernacular name object only\n const firstVernacularName = vernacularNameArray?.[0]\n return firstVernacularName?.props?.name\n },\n },\n unique: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: (_context: NodeDefExpressionContext) => (_nodeSet) => [],\n },\n userEmail: {\n minArity: 0,\n maxArity: 0,\n executor: (context: NodeDefExpressionContext) => () => context.user?.email,\n },\n userIsRecordOwner: {\n minArity: 0,\n maxArity: 0,\n executor: (_context: NodeDefExpressionContext) => () => false,\n },\n userName: {\n minArity: 0,\n maxArity: 0,\n executor: (context: NodeDefExpressionContext) => () => context.user?.name,\n },\n userProp: {\n minArity: 1,\n maxArity: 1,\n executor: (context: NodeDefExpressionContext) => (propName: string) => {\n const { user, survey } = context\n if (!survey || !user) return undefined\n const { uuid: surveyUuid } = survey\n const combinedExtraProps = Users.getCombinedExtraProps(surveyUuid)(user)\n return combinedExtraProps[propName]\n },\n },\n}\n"]}
@@ -1,14 +1,14 @@
1
- import { Node } from '../../node';
1
+ import { ArenaRecordNode } from '../../node';
2
2
  import { Survey } from '../../survey';
3
- import { Record } from '../record';
3
+ import { ArenaRecord } from '../record';
4
4
  export interface EntityCompletionStats {
5
5
  total: number;
6
6
  filled: number;
7
7
  }
8
8
  export declare const getEntityCompletionStats: (params: {
9
9
  survey: Survey;
10
- record: Record;
11
- entity: Node;
10
+ record: ArenaRecord;
11
+ entity: ArenaRecordNode;
12
12
  includeNestedEntities?: boolean;
13
13
  }) => EntityCompletionStats;
14
14
  /**
@@ -18,8 +18,8 @@ export declare const getEntityCompletionStats: (params: {
18
18
  */
19
19
  export declare const getEntityCompletionPercent: (params: {
20
20
  survey: Survey;
21
- record: Record;
22
- entity: Node;
21
+ record: ArenaRecord;
22
+ entity: ArenaRecordNode;
23
23
  }) => number;
24
24
  /**
25
25
  * Returns the percentage of completion of the given entity (0-100), considering only its own attributes
@@ -27,13 +27,13 @@ export declare const getEntityCompletionPercent: (params: {
27
27
  */
28
28
  export declare const getEntityOwnCompletionPercent: (params: {
29
29
  survey: Survey;
30
- record: Record;
31
- entity: Node;
30
+ record: ArenaRecord;
31
+ entity: ArenaRecordNode;
32
32
  }) => number;
33
33
  /**
34
34
  * Returns the percentage of completion of the given record (0-100), i.e. the completion of its root entity.
35
35
  */
36
36
  export declare const getRecordCompletionPercent: (params: {
37
37
  survey: Survey;
38
- record: Record;
38
+ record: ArenaRecord;
39
39
  }) => number;
@@ -1 +1 @@
1
- {"version":3,"file":"recordCompletion.js","sourceRoot":"","sources":["../../../src/record/_records/recordCompletion.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AACxC,2CAA4E;AAC5E,yCAA8C;AAC9C,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,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC5F,CAAC,CAAA;AAJY,QAAA,0BAA0B,GAA1B,0BAA0B,CAItC","sourcesContent":["import { Node, Nodes } from '../../node'\nimport { NodeDef, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { Survey, Surveys } from '../../survey'\nimport { Numbers } from '../../utils'\nimport { Record } from '../record'\nimport { getChildren, getRoot } from './recordGetters'\n\nexport interface EntityCompletionStats {\n total: number\n filled: number\n}\n\nconst emptyStats = (): EntityCompletionStats => ({ total: 0, filled: 0 })\n\nconst addStats = (statsAcc: EntityCompletionStats, statsToAdd: EntityCompletionStats): void => {\n statsAcc.total += statsToAdd.total\n statsAcc.filled += statsToAdd.filled\n}\n\nconst getAttributeCompletionStats = (params: {\n record: Record\n entity: Node\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): EntityCompletionStats => {\n const { record, entity, nodeDef } = params\n\n if (NodeDefs.isMultiple(nodeDef)) {\n const minCount = Nodes.getChildrenMinCount({ parentNode: entity, nodeDef })\n if (Number.isNaN(minCount) || minCount <= 0) return emptyStats()\n\n const filledNodesCount = getChildren(entity, nodeDef.uuid)(record).filter(Nodes.isValueNotBlank).length\n\n return { total: minCount, filled: Math.min(filledNodesCount, minCount) }\n }\n\n if (!NodeDefs.isRequired(nodeDef) && !NodeDefs.isKey(nodeDef)) return emptyStats()\n\n const node = getChildren(entity, nodeDef.uuid)(record)[0]\n return { total: 1, filled: node && Nodes.isValueNotBlank(node) ? 1 : 0 }\n}\n\nconst getChildEntityCompletionStats = (params: {\n survey: Survey\n record: Record\n parentEntity: Node\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): EntityCompletionStats => {\n const { survey, record, parentEntity, nodeDef } = params\n const childEntities = getChildren(parentEntity, nodeDef.uuid)(record)\n\n if (NodeDefs.isSingle(nodeDef)) {\n const childEntity = childEntities[0]\n return childEntity ? getEntityCompletionStats({ survey, record, entity: childEntity }) : emptyStats()\n }\n\n const minCountRaw = Nodes.getChildrenMinCount({ parentNode: parentEntity, nodeDef })\n const minCount = Number.isNaN(minCountRaw) ? 0 : Math.max(minCountRaw, 0)\n // entities added beyond the min count are still expected to be complete\n const expectedCount = Math.max(minCount, childEntities.length)\n if (expectedCount === 0) return emptyStats()\n\n const stats = emptyStats()\n for (let index = 0; index < expectedCount; index++) {\n const childEntity = childEntities[index]\n // a missing repetition (below the min count) counts as a single incomplete unit\n addStats(\n stats,\n childEntity ? getEntityCompletionStats({ survey, record, entity: childEntity }) : { total: 1, filled: 0 }\n )\n }\n return stats\n}\n\nexport const getEntityCompletionStats = (params: {\n survey: Survey\n record: Record\n entity: Node\n includeNestedEntities?: boolean\n}): EntityCompletionStats => {\n const { survey, record, entity, includeNestedEntities = true } = params\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const childDefs = Surveys.getNodeDefChildren({ survey, nodeDef: entityDef })\n\n const stats = emptyStats()\n for (const childDef of childDefs) {\n if (!Nodes.isChildApplicable(entity, childDef.uuid)) continue\n\n if (NodeDefs.isEntity(childDef)) {\n if (!includeNestedEntities) continue\n addStats(stats, getChildEntityCompletionStats({ survey, record, parentEntity: entity, nodeDef: childDef }))\n } else {\n addStats(stats, getAttributeCompletionStats({ record, entity, nodeDef: childDef }))\n }\n }\n return stats\n}\n\nconst toCompletionPercent = (stats: EntityCompletionStats): number => {\n const { total, filled } = stats\n if (total <= 0) return 100\n return Numbers.roundToPrecision((filled / total) * 100, 2)\n}\n\n/**\n * Returns the percentage of completion of the given entity (0-100), considering every descendant recursively.\n * A required or key attribute is considered filled when it has a non empty value; multiple attributes and\n * entities are considered filled based on their min count (see Nodes.getChildrenMinCount).\n */\nexport const getEntityCompletionPercent = (params: { survey: Survey; record: Record; entity: Node }): number =>\n toCompletionPercent(getEntityCompletionStats(params))\n\n/**\n * Returns the percentage of completion of the given entity (0-100), considering only its own attributes\n * (nested entities are ignored).\n */\nexport const getEntityOwnCompletionPercent = (params: { survey: Survey; record: Record; entity: Node }): number =>\n toCompletionPercent(getEntityCompletionStats({ ...params, includeNestedEntities: false }))\n\n/**\n * Returns the percentage of completion of the given record (0-100), i.e. the completion of its root entity.\n */\nexport const getRecordCompletionPercent = (params: { survey: Survey; record: Record }): number => {\n const { survey, record } = params\n const rootEntity = getRoot(record)\n return rootEntity ? getEntityCompletionPercent({ survey, record, entity: rootEntity }) : 0\n}\n"]}
1
+ {"version":3,"file":"recordCompletion.js","sourceRoot":"","sources":["../../../src/record/_records/recordCompletion.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,2CAA4E;AAC5E,yCAA8C;AAC9C,uCAAqC;AAErC,mDAAsD;AAOtD,MAAM,UAAU,GAAG,GAA0B,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAA;AAEzE,MAAM,QAAQ,GAAG,CAAC,QAA+B,EAAE,UAAiC,EAAQ,EAAE;IAC5F,QAAQ,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAA;IAClC,QAAQ,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,CAAA;AACtC,CAAC,CAAA;AAED,MAAM,2BAA2B,GAAG,CAAC,MAIpC,EAAyB,EAAE;IAC1B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IAE1C,IAAI,kBAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,YAAK,CAAC,mBAAmB,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAA;QAC3E,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,QAAQ,IAAI,CAAC;YAAE,OAAO,UAAU,EAAE,CAAA;QAEhE,MAAM,gBAAgB,GAAG,IAAA,2BAAW,EAAC,MAAM,EAAE,OAAO,CAA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EAAU,EAAE,CAAC,mBAAmB,CAAC,IAAA,QAAA,wBAAwB,kCAAM,MAAM,KAAE,qBAAqB,EAAE,KAAK,IAAG,CAAC,CAAA;AAJ3F,QAAA,6BAA6B,GAA7B,6BAA6B,CAI8D;AAExG;;GAEG;AACI,MAAM,0BAA0B,GAAG,CAAC,MAA+C,EAAU,EAAE;IACpG,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IACjC,MAAM,UAAU,GAAG,IAAA,uBAAO,EAAC,MAAM,CAAC,CAAA;IAClC,OAAO,UAAU,CAAC,CAAC,CAAC,IAAA,QAAA,0BAA0B,EAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC5F,CAAC,CAAA;AAJY,QAAA,0BAA0B,GAA1B,0BAA0B,CAItC","sourcesContent":["import { ArenaRecordNode, Nodes } from '../../node'\nimport { NodeDef, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { Survey, Surveys } from '../../survey'\nimport { Numbers } from '../../utils'\nimport { ArenaRecord } from '../record'\nimport { getChildren, getRoot } from './recordGetters'\n\nexport interface EntityCompletionStats {\n total: number\n filled: number\n}\n\nconst emptyStats = (): EntityCompletionStats => ({ total: 0, filled: 0 })\n\nconst addStats = (statsAcc: EntityCompletionStats, statsToAdd: EntityCompletionStats): void => {\n statsAcc.total += statsToAdd.total\n statsAcc.filled += statsToAdd.filled\n}\n\nconst getAttributeCompletionStats = (params: {\n record: ArenaRecord\n entity: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): EntityCompletionStats => {\n const { record, entity, nodeDef } = params\n\n if (NodeDefs.isMultiple(nodeDef)) {\n const minCount = Nodes.getChildrenMinCount({ parentNode: entity, nodeDef })\n if (Number.isNaN(minCount) || minCount <= 0) return emptyStats()\n\n const filledNodesCount = getChildren(entity, nodeDef.uuid)(record).filter(Nodes.isValueNotBlank).length\n\n return { total: minCount, filled: Math.min(filledNodesCount, minCount) }\n }\n\n if (!NodeDefs.isRequired(nodeDef) && !NodeDefs.isKey(nodeDef)) return emptyStats()\n\n const node = getChildren(entity, nodeDef.uuid)(record)[0]\n return { total: 1, filled: node && Nodes.isValueNotBlank(node) ? 1 : 0 }\n}\n\nconst getChildEntityCompletionStats = (params: {\n survey: Survey\n record: ArenaRecord\n parentEntity: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): EntityCompletionStats => {\n const { survey, record, parentEntity, nodeDef } = params\n const childEntities = getChildren(parentEntity, nodeDef.uuid)(record)\n\n if (NodeDefs.isSingle(nodeDef)) {\n const childEntity = childEntities[0]\n return childEntity ? getEntityCompletionStats({ survey, record, entity: childEntity }) : emptyStats()\n }\n\n const minCountRaw = Nodes.getChildrenMinCount({ parentNode: parentEntity, nodeDef })\n const minCount = Number.isNaN(minCountRaw) ? 0 : Math.max(minCountRaw, 0)\n // entities added beyond the min count are still expected to be complete\n const expectedCount = Math.max(minCount, childEntities.length)\n if (expectedCount === 0) return emptyStats()\n\n const stats = emptyStats()\n for (let index = 0; index < expectedCount; index++) {\n const childEntity = childEntities[index]\n // a missing repetition (below the min count) counts as a single incomplete unit\n addStats(\n stats,\n childEntity ? getEntityCompletionStats({ survey, record, entity: childEntity }) : { total: 1, filled: 0 }\n )\n }\n return stats\n}\n\nexport const getEntityCompletionStats = (params: {\n survey: Survey\n record: ArenaRecord\n entity: ArenaRecordNode\n includeNestedEntities?: boolean\n}): EntityCompletionStats => {\n const { survey, record, entity, includeNestedEntities = true } = params\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const childDefs = Surveys.getNodeDefChildren({ survey, nodeDef: entityDef })\n\n const stats = emptyStats()\n for (const childDef of childDefs) {\n if (!Nodes.isChildApplicable(entity, childDef.uuid)) continue\n\n if (NodeDefs.isEntity(childDef)) {\n if (!includeNestedEntities) continue\n addStats(stats, getChildEntityCompletionStats({ survey, record, parentEntity: entity, nodeDef: childDef }))\n } else {\n addStats(stats, getAttributeCompletionStats({ record, entity, nodeDef: childDef }))\n }\n }\n return stats\n}\n\nconst toCompletionPercent = (stats: EntityCompletionStats): number => {\n const { total, filled } = stats\n if (total <= 0) return 100\n return Numbers.roundToPrecision((filled / total) * 100, 2)\n}\n\n/**\n * Returns the percentage of completion of the given entity (0-100), considering every descendant recursively.\n * A required or key attribute is considered filled when it has a non empty value; multiple attributes and\n * entities are considered filled based on their min count (see Nodes.getChildrenMinCount).\n */\nexport const getEntityCompletionPercent = (params: {\n survey: Survey\n record: ArenaRecord\n entity: ArenaRecordNode\n}): number => toCompletionPercent(getEntityCompletionStats(params))\n\n/**\n * Returns the percentage of completion of the given entity (0-100), considering only its own attributes\n * (nested entities are ignored).\n */\nexport const getEntityOwnCompletionPercent = (params: {\n survey: Survey\n record: ArenaRecord\n entity: ArenaRecordNode\n}): number => toCompletionPercent(getEntityCompletionStats({ ...params, includeNestedEntities: false }))\n\n/**\n * Returns the percentage of completion of the given record (0-100), i.e. the completion of its root entity.\n */\nexport const getRecordCompletionPercent = (params: { survey: Survey; record: ArenaRecord }): number => {\n const { survey, record } = params\n const rootEntity = getRoot(record)\n return rootEntity ? getEntityCompletionPercent({ survey, record, entity: rootEntity }) : 0\n}\n"]}
@@ -1,134 +1,134 @@
1
1
  import { Dictionary, TraverseMethod } from '../../common';
2
- import { Node, NodePointer, NodesMap } from '../../node';
2
+ import { ArenaRecordNode, NodePointer, NodesMap } from '../../node';
3
3
  import { NodeDef, NodeDefCode, NodeDefCodeProps, NodeDefProps, NodeDefType } from '../../nodeDef';
4
4
  import { Survey, SurveyDependencyType } from '../../survey/survey';
5
- import { Record } from '../record';
6
- export declare const getCycle: (record: Record) => string;
7
- export declare const getNodes: (record: Record) => Dictionary<Node>;
8
- export declare const getNodesArray: (record: Record) => Node[];
9
- export declare const getNodeByUuid: (uuid: string) => (record: Record) => Node | undefined;
10
- export declare const getNodesByUuids: (uuids: string[]) => (record: Record) => Node[];
11
- export declare const getRoot: (record: Record) => Node | undefined;
12
- export declare const getChildren: (parentNode: Node, childDefUuid?: string) => (record: Record) => Node[];
13
- export declare const getChild: (parentNode: Node, childDefUuid: string) => (record: Record) => Node;
14
- export declare const getParent: (node: Node) => (record: Record) => Node | undefined;
15
- export declare const getNodesByDefUuid: (nodeDefUuid: string) => (record: Record) => Node[];
5
+ import { ArenaRecord } from '../record';
6
+ export declare const getCycle: (record: ArenaRecord) => string;
7
+ export declare const getNodes: (record: ArenaRecord) => Dictionary<ArenaRecordNode>;
8
+ export declare const getNodesArray: (record: ArenaRecord) => ArenaRecordNode[];
9
+ export declare const getNodeByUuid: (uuid: string) => (record: ArenaRecord) => ArenaRecordNode | undefined;
10
+ export declare const getNodesByUuids: (uuids: string[]) => (record: ArenaRecord) => ArenaRecordNode[];
11
+ export declare const getRoot: (record: ArenaRecord) => ArenaRecordNode | undefined;
12
+ export declare const getChildren: (parentNode: ArenaRecordNode, childDefUuid?: string) => (record: ArenaRecord) => ArenaRecordNode[];
13
+ export declare const getChild: (parentNode: ArenaRecordNode, childDefUuid: string) => (record: ArenaRecord) => ArenaRecordNode;
14
+ export declare const getParent: (node: ArenaRecordNode) => (record: ArenaRecord) => ArenaRecordNode | undefined;
15
+ export declare const getNodesByDefUuid: (nodeDefUuid: string) => (record: ArenaRecord) => ArenaRecordNode[];
16
16
  export declare const isNodeApplicable: (params: {
17
- record: Record;
18
- node: Node;
17
+ record: ArenaRecord;
18
+ node: ArenaRecordNode;
19
19
  }) => boolean;
20
20
  export declare const isNodeEditable: (params: {
21
- record: Record;
22
- node: Node;
21
+ record: ArenaRecord;
22
+ node: ArenaRecordNode;
23
23
  }) => boolean;
24
24
  export declare const isNodeVisible: (params: {
25
- record: Record;
26
- node: Node;
25
+ record: ArenaRecord;
26
+ node: ArenaRecordNode;
27
27
  }) => boolean;
28
- export declare const getDependentCodeAttributes: (node: Node) => (record: Record) => Node[];
28
+ export declare const getDependentCodeAttributes: (node: ArenaRecordNode) => (record: ArenaRecord) => ArenaRecordNode[];
29
29
  export declare const getParentCodeAttribute: (params: {
30
- parentNode: Node;
30
+ parentNode: ArenaRecordNode;
31
31
  nodeDef: NodeDefCode;
32
- }) => (record: Record) => Node | undefined;
33
- export declare const visitAncestorsAndSelf: (node: Node, visitor: (node: Node) => void, stopIfFn?: () => boolean) => (record: Record) => void;
34
- export declare const findAncestor: (node: Node, predicate: (node: Node) => boolean) => (record: Record) => Node | undefined;
32
+ }) => (record: ArenaRecord) => ArenaRecordNode | undefined;
33
+ export declare const visitAncestorsAndSelf: (node: ArenaRecordNode, visitor: (node: ArenaRecordNode) => void, stopIfFn?: () => boolean) => (record: ArenaRecord) => void;
34
+ export declare const findAncestor: (node: ArenaRecordNode, predicate: (node: ArenaRecordNode) => boolean) => (record: ArenaRecord) => ArenaRecordNode | undefined;
35
35
  export declare const getAncestor: (params: {
36
- record: Record;
37
- node: Node;
36
+ record: ArenaRecord;
37
+ node: ArenaRecordNode;
38
38
  ancestorDefUuid: string;
39
- }) => Node | undefined;
39
+ }) => ArenaRecordNode | undefined;
40
40
  /**
41
41
  * Returns the list of ancestors from the given node to the root entity
42
42
  */
43
43
  export declare const getAncestorsAndSelf: (params: {
44
- record: Record;
45
- node: Node;
46
- }) => Array<Node>;
44
+ record: ArenaRecord;
45
+ node: ArenaRecordNode;
46
+ }) => Array<ArenaRecordNode>;
47
47
  export declare const getDescendantsOrSelf: (params: {
48
- record: Record;
49
- node: Node;
48
+ record: ArenaRecord;
49
+ node: ArenaRecordNode;
50
50
  nodeDefDescendant: NodeDef<any>;
51
- }) => Node[];
51
+ }) => ArenaRecordNode[];
52
52
  export declare const getDescendant: (params: {
53
- record: Record;
54
- node: Node;
53
+ record: ArenaRecord;
54
+ node: ArenaRecordNode;
55
55
  nodeDefDescendant: NodeDef<any>;
56
- }) => Node;
56
+ }) => ArenaRecordNode;
57
57
  export declare const isDescendantOf: (params: {
58
- node: Node;
59
- ancestor: Node;
58
+ node: ArenaRecordNode;
59
+ ancestor: ArenaRecordNode;
60
60
  }) => boolean;
61
61
  export declare const visitDescendantsAndSelf: (params: {
62
- record: Record;
63
- node: Node;
64
- visitor: (node: Node) => boolean | void;
62
+ record: ArenaRecord;
63
+ node: ArenaRecordNode;
64
+ visitor: (node: ArenaRecordNode) => boolean | void;
65
65
  traverseMethod?: TraverseMethod;
66
66
  }) => void;
67
- export declare const findDescendantOrSelf: (node: Node, predicate: (node: Node) => boolean) => (record: Record) => Node | undefined;
67
+ export declare const findDescendantOrSelf: (node: ArenaRecordNode, predicate: (node: ArenaRecordNode) => boolean) => (record: ArenaRecord) => ArenaRecordNode | undefined;
68
68
  type EntityKeyNodesGetterParams = {
69
69
  survey: Survey;
70
70
  cycle?: string;
71
- record: Record;
72
- entity: Node;
71
+ record: ArenaRecord;
72
+ entity: ArenaRecordNode;
73
73
  keyDefs?: NodeDef<NodeDefType, NodeDefProps>[];
74
74
  };
75
75
  export declare const getEntityKeyNodesByDefUuid: (params: EntityKeyNodesGetterParams) => NodesMap;
76
- export declare const getEntityKeyNodes: (params: EntityKeyNodesGetterParams) => Node[];
76
+ export declare const getEntityKeyNodes: (params: EntityKeyNodesGetterParams) => ArenaRecordNode[];
77
77
  export declare const getEntityKeyValuesByDefUuid: (params: EntityKeyNodesGetterParams) => Dictionary<any>;
78
78
  export declare const getEntityKeyValues: (params: EntityKeyNodesGetterParams) => any[];
79
79
  export declare const getEntitySiblings: (params: {
80
- record: Record;
81
- entity: Node;
80
+ record: ArenaRecord;
81
+ entity: ArenaRecordNode;
82
82
  includeSelf?: boolean;
83
- }) => Node[];
83
+ }) => ArenaRecordNode[];
84
84
  export declare const getAttributeSiblings: (params: {
85
- record: Record;
86
- node: Node;
85
+ record: ArenaRecord;
86
+ node: ArenaRecordNode;
87
87
  nodeDef: NodeDef<NodeDefType, NodeDefProps>;
88
- }) => Node[];
88
+ }) => ArenaRecordNode[];
89
89
  export declare const getNodeIndex: (params: {
90
- record: Record;
91
- node: Node;
90
+ record: ArenaRecord;
91
+ node: ArenaRecordNode;
92
92
  }) => number;
93
93
  export declare const findEntityByKeyValues: (params: {
94
94
  survey: Survey;
95
95
  cycle: string;
96
- record: Record;
97
- parentEntity: Node;
96
+ record: ArenaRecord;
97
+ parentEntity: ArenaRecordNode;
98
98
  entityDefUuid: string;
99
99
  keyValuesByDefUuid: Dictionary<any>;
100
- }) => Node | undefined;
100
+ }) => ArenaRecordNode | undefined;
101
101
  export declare const findEntityWithSameKeysInAnotherRecord: (params: {
102
102
  survey: Survey;
103
103
  cycle: string;
104
104
  entityUuid: string;
105
- record: Record;
106
- recordOther: Record;
107
- }) => Node | undefined;
105
+ record: ArenaRecord;
106
+ recordOther: ArenaRecord;
107
+ }) => ArenaRecordNode | undefined;
108
108
  export declare const getDependentNodePointers: (params: {
109
109
  survey: Survey;
110
- record: Record;
111
- node: Node;
110
+ record: ArenaRecord;
111
+ node: ArenaRecordNode;
112
112
  dependencyType: SurveyDependencyType;
113
113
  includeSelf?: boolean;
114
114
  filterFn?: (nodePointer: NodePointer) => boolean;
115
115
  }) => NodePointer[];
116
116
  export declare const getAncestorCodePath: (params: {
117
117
  survey: Survey;
118
- record: Record;
119
- parentNode: Node;
118
+ record: ArenaRecord;
119
+ parentNode: ArenaRecordNode;
120
120
  nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>;
121
121
  }) => string[];
122
122
  export declare const getCategoryItemUuid: (params: {
123
123
  survey: Survey;
124
124
  nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>;
125
- record: Record;
126
- parentNode: Node;
125
+ record: ArenaRecord;
126
+ parentNode: ArenaRecordNode;
127
127
  code: string;
128
128
  }) => string | undefined;
129
- export declare const isNodeFilledByUser: (node: Node) => (record: Record) => boolean;
130
- export declare const isNodeEmpty: (node: Node) => (record: Record) => boolean;
131
- export declare const isEmpty: (record: Record) => boolean;
132
- export declare const getStep: (record: Record) => string;
133
- export declare const isInAnalysisStep: (record: Record) => boolean;
129
+ export declare const isNodeFilledByUser: (node: ArenaRecordNode) => (record: ArenaRecord) => boolean;
130
+ export declare const isNodeEmpty: (node: ArenaRecordNode) => (record: ArenaRecord) => boolean;
131
+ export declare const isEmpty: (record: ArenaRecord) => boolean;
132
+ export declare const getStep: (record: ArenaRecord) => string;
133
+ export declare const isInAnalysisStep: (record: ArenaRecord) => boolean;
134
134
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"recordGetters.js","sourceRoot":"","sources":["../../../src/record/_records/recordGetters.ts"],"names":[],"mappings":";;;AAAA,yCAAyD;AACzD,uCAAyC;AACzC,qCAA+D;AAC/D,sDAAkD;AAClD,2CAA2G;AAC3G,yCAAoD;AAEpD,uCAA2C;AAC3C,sCAAuD;AACvD,8CAAsD;AACtD,qEAAiE;AACjE,mEAA+D;AAExD,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAU,EAAE,wBAAC,MAAM,CAAC,KAAK,mCAAI,qBAAY,GAAA,CAAA;AAAnE,QAAA,QAAQ,GAAR,QAAQ,CAA2D;AAEzE,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAoB,EAAE,wBAAC,MAAM,CAAC,KAAK,mCAAI,EAAE,GAAA,CAAA;AAAnE,QAAA,QAAQ,GAAR,QAAQ,CAA2D;AAEzE,MAAM,aAAa,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAA,QAAA,QAAQ,EAAC,MAAM,CAAC,CAAC,CAAA;AAA3E,QAAA,aAAa,GAAb,aAAa,CAA8D;AAEjF,MAAM,aAAa,GACxB,CAAC,IAAY,EAAE,EAAE,CACjB,CAAC,MAAc,EAAoB,EAAE,kBACnC,MAAA,MAAM,CAAC,KAAK,0CAAG,IAAI,CAAC,GAAA,CAAA;AAHX,QAAA,aAAa,GAAb,aAAa,CAGF;AAEjB,MAAM,eAAe,GAC1B,CAAC,KAAe,EAAE,EAAE,CACpB,CAAC,MAAc,EAAU,EAAE,CACzB,KAAK,CAAC,GAA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AAM,WAAW,GACtB,CAAC,IAAU,EAAE,EAAE,CACf,CAAC,MAAc,EAAW,EAAE,CAC1B,CAAC,IAAA,QAAA,kBAAkB,EAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAA;AAHxB,QAAA,WAAW,GAAX,WAAW,CAGa;AAE9B,MAAM,OAAO,GAAG,CAAC,MAAc,EAAW,EAAE;IACjD,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,MAAc,EAAU,EAAE,wBAAC,MAAM,CAAC,IAAI,mCAAI,4BAAmB,GAAA,CAAA;AAAxE,QAAA,OAAO,GAAP,OAAO,CAAiE;AAE9E,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAW,EAAE,CAAC,IAAA,QAAA,OAAO,EAAC,MAAM,CAAC,KAAK,mCAAsB,CAAA;AAA1F,QAAA,gBAAgB,GAAhB,gBAAgB,CAA0E","sourcesContent":["import { Dictionary, TraverseMethod } from '../../common'\nimport { SystemError } from '../../error'\nimport { Node, 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 { Record, RECORD_STEP_DEFAULT } from '../record'\nimport { RecordStepAnalysisCode } from '../recordStep'\nimport { RecordNodesIndexReader } from './recordNodesIndexReader'\nimport { NodeDefSelfReferences } from './nodeDefSelfReferences'\n\nexport const getCycle = (record: Record): string => record.cycle ?? defaultCycle\n\nexport const getNodes = (record: Record): Dictionary<Node> => record.nodes ?? {}\n\nexport const getNodesArray = (record: Record): Node[] => Object.values(getNodes(record))\n\nexport const getNodeByUuid =\n (uuid: string) =>\n (record: Record): Node | undefined =>\n record.nodes?.[uuid]\n\nexport const getNodesByUuids =\n (uuids: string[]) =>\n (record: Record): Node[] =>\n uuids.map((uuid: string) => getNodeByUuid(uuid)(record)) as Node[]\n\nexport const getRoot = (record: Record): Node | 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: Node, childDefUuid?: string) =>\n (record: Record): Node[] => {\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: Node, childDefUuid: string) =>\n (record: Record): Node => {\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: Node) =>\n (record: Record): Node | undefined =>\n node.parentUuid ? getNodeByUuid(node.parentUuid)(record) : undefined\n\nexport const getNodesByDefUuid =\n (nodeDefUuid: string) =>\n (record: Record): Node[] => {\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: Node, nodeDefUuid: string) => boolean) =>\n (params: { record: Record; node: Node }): 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: Node) =>\n (record: Record): Node[] => {\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: Node; nodeDef: NodeDefCode }) =>\n (record: Record): Node | 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: Node, visitor: (node: Node) => void, stopIfFn?: () => boolean) =>\n (record: Record): void => {\n let currentNode: Node | 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: Node, predicate: (node: Node) => boolean) =>\n (record: Record): Node | undefined => {\n let result: Node | 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: { record: Record; node: Node; ancestorDefUuid: string }): Node | 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: Record; node: Node }): Array<Node> => {\n const { record, node } = params\n const ancestors: Array<Node> = []\n visitAncestorsAndSelf(node, (currentNode) => {\n ancestors.push(currentNode)\n })(record)\n return ancestors\n}\n\n// descendants\n\nexport const getDescendantsOrSelf = (params: {\n record: Record\n node: Node\n nodeDefDescendant: NodeDef<any>\n}): Node[] => {\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: Node[] = []\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: { record: Record; node: Node; nodeDefDescendant: NodeDef<any> }): Node => {\n const { record, node, nodeDefDescendant } = params\n\n return getDescendantsOrSelf({ record, node, nodeDefDescendant })[0]\n}\n\nexport const isDescendantOf = (params: { node: Node; ancestor: Node }): boolean => {\n const { node, ancestor } = params\n return Nodes.getHierarchy(node).includes(ancestor.uuid)\n}\n\nexport const visitDescendantsAndSelf = (params: {\n record: Record\n node: Node\n visitor: (node: Node) => 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 Node\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: Node, predicate: (node: Node) => boolean) =>\n (record: Record): Node | 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: Record\n node: Node\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n dependentDef: NodeDef<NodeDefType, NodeDefProps>\n dependencyType: SurveyDependencyType\n}): Node | 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: Record\n entity: Node\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): Node[] =>\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: Record; entity: Node; 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: Record\n node: Node\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: Node[], siblingEntity) => {\n siblingsAcc.push(...getChildren(siblingEntity, nodeDef.uuid)(record))\n return siblingsAcc\n }, [])\n}\n\nexport const getNodeIndex = (params: { record: Record; node: Node }) => {\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: Record\n parentEntity: Node\n entityDefUuid: string\n keyValuesByDefUuid: Dictionary<any>\n}): Node | 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: Record\n recordOther: Record\n}): Node | 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: Record\n node: Node\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: Record\n parentNode: Node\n nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>\n}): string[] => {\n const { record, parentNode, nodeDef, survey } = params\n\n const getCodeAttributeItemCode = (codeAttribute: Node | 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: Record\n parentNode: Node\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: Node) =>\n (record: Record): boolean =>\n !!findDescendantOrSelf(node, (visitedNode) => Nodes.hasUserInputValue(visitedNode))(record)\n\nexport const isNodeEmpty =\n (node: Node) =>\n (record: Record): boolean =>\n !isNodeFilledByUser(node)(record)\n\nexport const isEmpty = (record: Record): boolean => {\n const rootNode = getRoot(record)\n return rootNode ? isNodeEmpty(rootNode)(record) : true\n}\n\nexport const getStep = (record: Record): string => record.step ?? RECORD_STEP_DEFAULT\n\nexport const isInAnalysisStep = (record: Record): 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;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,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ystemError } 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"]}