@openforis/arena-core 3.0.0 → 3.1.1

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 (98) hide show
  1. package/dist/auth/authorizer.d.ts +0 -2
  2. package/dist/auth/authorizer.js +0 -4
  3. package/dist/auth/authorizer.js.map +1 -1
  4. package/dist/esm/auth/authorizer.js +0 -4
  5. package/dist/esm/auth/authorizer.js.map +1 -1
  6. package/dist/esm/index.js.map +1 -1
  7. package/dist/esm/node/nodePointer.js.map +1 -1
  8. package/dist/esm/node/nodeValueFormatter.js.map +1 -1
  9. package/dist/esm/node/nodeValues.js.map +1 -1
  10. package/dist/esm/nodeDef/factory.js.map +1 -1
  11. package/dist/esm/nodeDef/index.js.map +1 -1
  12. package/dist/esm/nodeDef/nodeDef.js.map +1 -1
  13. package/dist/esm/nodeDef/nodeDefs.js.map +1 -1
  14. package/dist/esm/nodeDef/service.js.map +1 -1
  15. package/dist/esm/nodeDefExpressionEvaluator/context.js.map +1 -1
  16. package/dist/esm/nodeDefExpressionEvaluator/node/identifier.js.map +1 -1
  17. package/dist/esm/record/_records/nodeDefSelfReferences.js.map +1 -1
  18. package/dist/esm/record/_records/recordCompletion.js.map +1 -1
  19. package/dist/esm/record/_records/recordGetters.js.map +1 -1
  20. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.js.map +1 -1
  21. package/dist/esm/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
  22. package/dist/esm/record/recordValidator/attributeKeyValidator.js.map +1 -1
  23. package/dist/esm/record/recordValidator/attributeTypeValidator.js +1 -1
  24. package/dist/esm/record/recordValidator/attributeTypeValidator.js.map +1 -1
  25. package/dist/esm/record/recordValidator/attributeUniqueValidator.js.map +1 -1
  26. package/dist/esm/record/recordValidator/attributeValidator.js.map +1 -1
  27. package/dist/esm/record/recordValidator/countValidator.js.map +1 -1
  28. package/dist/esm/survey/survey.js.map +1 -1
  29. package/dist/esm/survey/surveys/_nodeDefs/nodeDefsReader.js.map +1 -1
  30. package/dist/esm/survey/surveys/dependencies.js.map +1 -1
  31. package/dist/esm/survey/surveys/nodeDefs.js.map +1 -1
  32. package/dist/esm/tests/builder/recordBuilder/nodeBuilder.js.map +1 -1
  33. package/dist/esm/tests/builder/surveyBuilder/nodeDefAttributeBuilder.js.map +1 -1
  34. package/dist/esm/tests/builder/surveyBuilder/nodeDefBuilder.js.map +1 -1
  35. package/dist/esm/tests/builder/surveyBuilder/nodeDefCodeBuilder.js.map +1 -1
  36. package/dist/esm/tests/builder/surveyBuilder/nodeDefEntityBuilder.js.map +1 -1
  37. package/dist/esm/tests/builder/surveyBuilder/nodeDefTaxonBuilder.js.map +1 -1
  38. package/dist/index.d.ts +1 -1
  39. package/dist/index.js.map +1 -1
  40. package/dist/node/nodePointer.d.ts +2 -2
  41. package/dist/node/nodePointer.js.map +1 -1
  42. package/dist/node/nodeValueFormatter.d.ts +2 -2
  43. package/dist/node/nodeValueFormatter.js.map +1 -1
  44. package/dist/node/nodeValues.d.ts +3 -3
  45. package/dist/node/nodeValues.js.map +1 -1
  46. package/dist/nodeDef/factory.d.ts +3 -3
  47. package/dist/nodeDef/factory.js.map +1 -1
  48. package/dist/nodeDef/index.d.ts +1 -1
  49. package/dist/nodeDef/index.js.map +1 -1
  50. package/dist/nodeDef/nodeDef.d.ts +2 -0
  51. package/dist/nodeDef/nodeDef.js.map +1 -1
  52. package/dist/nodeDef/nodeDefs.d.ts +50 -50
  53. package/dist/nodeDef/nodeDefs.js.map +1 -1
  54. package/dist/nodeDef/service.d.ts +7 -7
  55. package/dist/nodeDef/service.js.map +1 -1
  56. package/dist/nodeDefExpressionEvaluator/context.d.ts +3 -4
  57. package/dist/nodeDefExpressionEvaluator/context.js.map +1 -1
  58. package/dist/nodeDefExpressionEvaluator/node/identifier.d.ts +2 -2
  59. package/dist/nodeDefExpressionEvaluator/node/identifier.js.map +1 -1
  60. package/dist/record/_records/nodeDefSelfReferences.d.ts +2 -2
  61. package/dist/record/_records/nodeDefSelfReferences.js.map +1 -1
  62. package/dist/record/_records/recordCompletion.js.map +1 -1
  63. package/dist/record/_records/recordGetters.d.ts +4 -4
  64. package/dist/record/_records/recordGetters.js.map +1 -1
  65. package/dist/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.d.ts +2 -2
  66. package/dist/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.js.map +1 -1
  67. package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.d.ts +2 -2
  68. package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
  69. package/dist/record/recordValidator/attributeKeyValidator.d.ts +3 -3
  70. package/dist/record/recordValidator/attributeKeyValidator.js.map +1 -1
  71. package/dist/record/recordValidator/attributeTypeValidator.d.ts +2 -2
  72. package/dist/record/recordValidator/attributeTypeValidator.js.map +1 -1
  73. package/dist/record/recordValidator/attributeUniqueValidator.d.ts +2 -2
  74. package/dist/record/recordValidator/attributeUniqueValidator.js.map +1 -1
  75. package/dist/record/recordValidator/attributeValidator.js.map +1 -1
  76. package/dist/record/recordValidator/countValidator.d.ts +2 -2
  77. package/dist/record/recordValidator/countValidator.js.map +1 -1
  78. package/dist/survey/survey.d.ts +2 -2
  79. package/dist/survey/survey.js.map +1 -1
  80. package/dist/survey/surveys/_nodeDefs/nodeDefsReader.d.ts +3 -3
  81. package/dist/survey/surveys/_nodeDefs/nodeDefsReader.js.map +1 -1
  82. package/dist/survey/surveys/dependencies.d.ts +4 -4
  83. package/dist/survey/surveys/dependencies.js.map +1 -1
  84. package/dist/survey/surveys/nodeDefs.d.ts +28 -28
  85. package/dist/survey/surveys/nodeDefs.js.map +1 -1
  86. package/dist/tests/builder/recordBuilder/nodeBuilder.d.ts +2 -2
  87. package/dist/tests/builder/recordBuilder/nodeBuilder.js.map +1 -1
  88. package/dist/tests/builder/surveyBuilder/nodeDefAttributeBuilder.d.ts +2 -2
  89. package/dist/tests/builder/surveyBuilder/nodeDefAttributeBuilder.js.map +1 -1
  90. package/dist/tests/builder/surveyBuilder/nodeDefBuilder.d.ts +3 -3
  91. package/dist/tests/builder/surveyBuilder/nodeDefBuilder.js.map +1 -1
  92. package/dist/tests/builder/surveyBuilder/nodeDefCodeBuilder.d.ts +2 -2
  93. package/dist/tests/builder/surveyBuilder/nodeDefCodeBuilder.js.map +1 -1
  94. package/dist/tests/builder/surveyBuilder/nodeDefEntityBuilder.d.ts +2 -2
  95. package/dist/tests/builder/surveyBuilder/nodeDefEntityBuilder.js.map +1 -1
  96. package/dist/tests/builder/surveyBuilder/nodeDefTaxonBuilder.d.ts +2 -2
  97. package/dist/tests/builder/surveyBuilder/nodeDefTaxonBuilder.js.map +1 -1
  98. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"nodeDefs.js","sourceRoot":"","sources":["../../../src/nodeDef/nodeDefs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAGL,gBAAgB,EAKhB,WAAW,GAEZ,MAAM,WAAW,CAAA;AAMlB,OAAO,EAIL,uBAAuB,GAExB,MAAM,gBAAgB,CAAA;AAMvB,OAAO,EAAoB,qBAAqB,EAAwB,MAAM,cAAc,CAAA;AAG5F,MAAM,MAAM,GAAG,CAAC,OAAkC,EAAW,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAA;AAEnF,MAAM,WAAW,GAAG,CAAC,OAAkC,EAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;AAEvF,MAAM,QAAQ,GAAG,CAAC,OAAkC,EAAiC,EAAE,CACrF,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,MAAM,CAAA;AAErC,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AAW;IACX,WAAW;IACX,uBAAuB;IACvB,eAAe;IACf,WAAW;IACX,gBAAgB;CACjB,CAAA","sourcesContent":["import { LanguageCode } from '../language'\nimport { getLabelOrDefault } from '../language/labels'\nimport { ValuePropsCoordinate } from '../node/nodeValueProps'\nimport { defaultCycle } from '../survey'\nimport { Objects } from '../utils'\nimport {\n ArenaNodeDef,\n ArenaNodeDefCountExpression,\n NodeDefCountType,\n ArenaNodeDefExpression,\n ArenaNodeDefLayout,\n ArenaNodeDefProps,\n ArenaNodeDefPropsWithLayout,\n NodeDefType,\n ArenaNodeDefValidations,\n} from './nodeDef'\nimport { ArenaNodeDefBoolean } from './types/boolean'\nimport { ArenaNodeDefCode } from './types/code'\nimport { ArenaNodeDefCoordinate } from './types/coordinate'\nimport { ArenaNodeDefDate } from './types/date'\nimport { ArenaNodeDefDecimal } from './types/decimal'\nimport {\n ArenaNodeDefEntity,\n ArenaNodeDefEntityLayout,\n ArenaNodeDefEntityLayoutChildItem,\n NodeDefEntityRenderType,\n ArenaNodeDefPrintOrientation,\n} from './types/entity'\nimport { ArenaNodeDefFile, NodeDefFileType } from './types/file'\nimport { ArenaNodeDefFormHeader } from './types/formHeader'\nimport { ArenaNodeDefGeo } from './types/geo'\nimport { ArenaNodeDefInteger } from './types/integer'\nimport { ArenaNodeDefTaxon } from './types/taxon'\nimport { ArenaNodeDefText, NodeDefTextRenderType, NodeDefTextInputType } from './types/text'\nimport { ArenaNodeDefTime } from './types/time'\n\nconst isRoot = (nodeDef: ArenaNodeDef<NodeDefType>): boolean => !nodeDef.parentUuid\n\nconst isAttribute = (nodeDef: ArenaNodeDef<NodeDefType>): boolean => !isEntity(nodeDef)\n\nconst isEntity = (nodeDef: ArenaNodeDef<NodeDefType>): nodeDef is ArenaNodeDefEntity =>\n nodeDef.type === NodeDefType.entity\n\nconst isBoolean = (nodeDef: ArenaNodeDef<NodeDefType>): nodeDef is ArenaNodeDefBoolean =>\n nodeDef.type === NodeDefType.boolean\n\nconst isCode = (nodeDef: ArenaNodeDef<NodeDefType>): nodeDef is ArenaNodeDefCode => nodeDef.type === NodeDefType.code\n\nconst isCoordinate = (nodeDef: ArenaNodeDef<NodeDefType>): nodeDef is ArenaNodeDefCoordinate =>\n nodeDef.type === NodeDefType.coordinate\n\nconst isDate = (nodeDef: ArenaNodeDef<NodeDefType>): nodeDef is ArenaNodeDefDate => nodeDef.type === NodeDefType.date\n\nconst isDecimal = (nodeDef: ArenaNodeDef<NodeDefType>): nodeDef is ArenaNodeDefDecimal =>\n nodeDef.type === NodeDefType.decimal\n\nconst isFile = (nodeDef: ArenaNodeDef<NodeDefType>): nodeDef is ArenaNodeDefFile => nodeDef.type === NodeDefType.file\n\nconst isGeo = (nodeDef: ArenaNodeDef<NodeDefType>): nodeDef is ArenaNodeDefGeo => nodeDef.type === NodeDefType.geo\n\nconst isInteger = (nodeDef: ArenaNodeDef<NodeDefType>): nodeDef is ArenaNodeDefInteger =>\n nodeDef.type === NodeDefType.integer\n\nconst isTaxon = (nodeDef: ArenaNodeDef<NodeDefType>): nodeDef is ArenaNodeDefTaxon => nodeDef.type === NodeDefType.taxon\n\nconst isText = (nodeDef: ArenaNodeDef<NodeDefType>): nodeDef is ArenaNodeDefText => nodeDef.type === NodeDefType.text\n\nconst isTime = (nodeDef: ArenaNodeDef<NodeDefType>): nodeDef is ArenaNodeDefTime => nodeDef.type === NodeDefType.time\n\nconst isMultiple = (nodeDef: ArenaNodeDef<NodeDefType>): boolean => nodeDef.props.multiple ?? false\n\nconst isSingle = (nodeDef: ArenaNodeDef<NodeDefType>): boolean => !isMultiple(nodeDef)\n\nconst isSingleEntity = (nodeDef: ArenaNodeDef<NodeDefType>): nodeDef is ArenaNodeDefEntity =>\n isEntity(nodeDef) && isSingle(nodeDef)\n\nconst isSingleAttribute = (nodeDef: ArenaNodeDef<NodeDefType>): boolean => isAttribute(nodeDef) && isSingle(nodeDef)\n\nconst isMultipleEntity = (nodeDef: ArenaNodeDef<NodeDefType>): nodeDef is ArenaNodeDefEntity =>\n isEntity(nodeDef) && isMultiple(nodeDef)\n\nconst isMultipleAttribute = (nodeDef: ArenaNodeDef<NodeDefType>): boolean => isAttribute(nodeDef) && isMultiple(nodeDef)\n\nconst isKey = (nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>): boolean => nodeDef.props.key ?? false\n\nconst isAutoIncrementalKey = (nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>): boolean =>\n nodeDef.props.autoIncrementalKey ?? false\n\nconst isAnalysis = (nodeDef: ArenaNodeDef<NodeDefType>): boolean => nodeDef.analysis ?? false\n\nconst getType = (nodeDef: ArenaNodeDef<NodeDefType>): NodeDefType => nodeDef.type\n\nconst isLayoutElement = (nodeDef: ArenaNodeDef<NodeDefType>): nodeDef is ArenaNodeDefFormHeader =>\n nodeDef.type === NodeDefType.formHeader\n\nconst getName = (nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>): string => nodeDef.props.name ?? ''\n\nconst getLabelOrName = (nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>, lang: LanguageCode): string =>\n getLabelOrDefault(nodeDef.props.labels, lang, getName(nodeDef))\n\nconst getDescription = (nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>, lang: LanguageCode): string =>\n getLabelOrDefault(nodeDef.props.descriptions, lang)\n\nconst isQualifier = (nodeDef: ArenaNodeDef<NodeDefType>): boolean => nodeDef.props.qualifier ?? false\n\nconst isReadOnly = (nodeDef: ArenaNodeDef<any>): boolean => nodeDef.props.readOnly ?? false\n\nconst isHidden = (nodeDef: ArenaNodeDef<any>): boolean => nodeDef.props.hidden ?? false\n\nconst isEnumerate = (nodeDef: ArenaNodeDefEntity): boolean => nodeDef.props.enumerate ?? false\n\nconst getEnumeratingItemsExpression = (nodeDef: ArenaNodeDefEntity): string | undefined =>\n nodeDef.propsAdvanced?.enumeratingItemsExpression\n\nconst isAutoCreateMinCountItems = (nodeDef: ArenaNodeDefEntity): boolean =>\n isMultipleEntity(nodeDef) && (nodeDef.props.autoCreateMinCountItems ?? false)\n\nconst getPrintOrientation = (nodeDef: ArenaNodeDefEntity): ArenaNodeDefPrintOrientation | undefined =>\n nodeDef.props.printOrientation\n\nconst getDefaultValues = (nodeDef: ArenaNodeDef<NodeDefType>): ArenaNodeDefExpression[] =>\n nodeDef.propsAdvanced?.defaultValues ?? []\n\nconst isDefaultValueEvaluatedOneTime = (nodeDef: ArenaNodeDef<NodeDefType>): boolean =>\n !!nodeDef.propsAdvanced?.defaultValueEvaluatedOneTime\n\nconst getApplicable = (nodeDef: ArenaNodeDef<NodeDefType>): ArenaNodeDefExpression[] =>\n nodeDef.propsAdvanced?.applicable ?? []\n\nconst getVisibleFields = (nodeDef: ArenaNodeDef<NodeDefType>): string[] | undefined => nodeDef.props.visibleFields\n\nconst isFieldVisible = (field: string) => (nodeDef: ArenaNodeDef<any>) => {\n const visibleFields = getVisibleFields(nodeDef)\n return !visibleFields || visibleFields.includes(field)\n}\n\nconst isInCycle =\n (cycle: string) =>\n (nodeDef: ArenaNodeDef<NodeDefType>): boolean => {\n const cycles = nodeDef.props.cycles ?? [defaultCycle]\n return cycles.includes(cycle)\n }\n\nconst isExcludedInClone = (nodeDef: ArenaNodeDef<NodeDefType>): boolean => !!nodeDef.propsAdvanced?.excludedInClone\n\nconst getEditableIf = (nodeDef: ArenaNodeDef<NodeDefType>): ArenaNodeDefExpression[] =>\n nodeDef.propsAdvanced?.editableIf ?? []\n\nconst isAlwaysEditable = (nodeDef: ArenaNodeDef<NodeDefType>): boolean => getEditableIf(nodeDef).length === 0\n\nconst getVisibleIf = (nodeDef: ArenaNodeDef<NodeDefType>): ArenaNodeDefExpression[] =>\n nodeDef.propsAdvanced?.visibleIf ?? []\n\nconst isAlwaysVisible = (nodeDef: ArenaNodeDef<NodeDefType>): boolean => getVisibleIf(nodeDef).length === 0\n\n// code\nconst getCategoryUuid = (nodeDef: ArenaNodeDefCode): string | undefined => nodeDef.props.categoryUuid\nconst getParentCodeDefUuid = (nodeDef: ArenaNodeDefCode): string | undefined => nodeDef.props.parentCodeDefUuid\n\n// coordinate\nconst isAllowOnlyDeviceCoordinate = (nodeDef: ArenaNodeDefCoordinate): boolean =>\n !!nodeDef.props.allowOnlyDeviceCoordinate\n\nconst getCoordinateAdditionalFields = (nodeDef: ArenaNodeDefCoordinate): string[] => {\n const result = []\n if (nodeDef.props.includeAccuracy) result.push(ValuePropsCoordinate[ValuePropsCoordinate.accuracy])\n if (nodeDef.props.includeAltitude) result.push(ValuePropsCoordinate[ValuePropsCoordinate.altitude])\n if (nodeDef.props.includeAltitudeAccuracy) result.push(ValuePropsCoordinate[ValuePropsCoordinate.altitudeAccuracy])\n return result\n}\n\n// decimal\nconst getMaxNumberDecimalDigits = (nodeDef: ArenaNodeDefDecimal) => {\n const decimalDigits = nodeDef.props.maxNumberDecimalDigits\n return Objects.isEmpty(decimalDigits) ? Number.NaN : Number(decimalDigits)\n}\n\n// file\nconst getFileType = (nodeDef: ArenaNodeDefFile): NodeDefFileType | undefined => nodeDef.props.fileType\nconst getFileNameExpression = (nodeDef: ArenaNodeDefFile): string | undefined =>\n nodeDef.propsAdvanced?.fileNameExpression\nconst getFileMaxSize = (nodeDef: ArenaNodeDefFile): number | undefined => nodeDef.props.maxFileSize\nconst isGeotagInformationShown = (nodeDef: ArenaNodeDefFile): boolean => !!nodeDef.props.geotagInformationShown\nconst isScreenCaptureInMapAllowed = (nodeDef: ArenaNodeDefFile): boolean => !!nodeDef.props.screenCaptureInMapAllowed\n\n// geo\nconst isPositionTracking = (nodeDef: ArenaNodeDefGeo): boolean => !!nodeDef.props.positionTracking\n\n// time\nconst isSecondsIncluded = (nodeDef: ArenaNodeDefTime): boolean => !!nodeDef.props.includeSeconds\n\n// taxon\nconst getTaxonomyUuid = (nodeDef: ArenaNodeDefTaxon): string | undefined => nodeDef.props.taxonomyUuid\n\nconst isVernacularNameSelectionKept = (nodeDef: ArenaNodeDefTaxon): boolean =>\n !!nodeDef.props.vernacularNameSelectionKept\n\nconst isVernacularNameAlwaysIncludedIfSingle = (nodeDef: ArenaNodeDefTaxon): boolean =>\n !!nodeDef.props.vernacularNameAlwaysIncludedIfSingle\n\n// text\nconst getTextTransform = (nodeDef: ArenaNodeDefText): string | undefined => nodeDef.props?.textTransform\nconst getTextInputType = (nodeDef: ArenaNodeDefText): NodeDefTextInputType | undefined => nodeDef.props?.textInputType\n\n// code and taxon\nconst getItemsFilter = (nodeDef: ArenaNodeDef<any>): string | undefined => nodeDef.propsAdvanced?.itemsFilter\n\n// Validations\nconst getValidations = (nodeDef: ArenaNodeDef<NodeDefType>): ArenaNodeDefValidations | undefined =>\n nodeDef.propsAdvanced?.validations\n\nconst getValidationsExpressions = (nodeDef: ArenaNodeDef<NodeDefType>): ArenaNodeDefExpression[] =>\n getValidations(nodeDef)?.expressions ?? []\n\nconst isRequired = (nodeDef: ArenaNodeDef<NodeDefType>): boolean => getValidations(nodeDef)?.required ?? false\n\nconst getRequiredIf = (nodeDef: ArenaNodeDef<NodeDefType>): ArenaNodeDefExpression[] =>\n getValidations(nodeDef)?.requiredIf ?? []\n\nconst isRequiredIfDefined = (nodeDef: ArenaNodeDef<NodeDefType>): boolean => getRequiredIf(nodeDef).length > 0\n\n/**\n * True if the node def is always required or required when a condition is met (node def level, not record level).\n */\nconst isRequiredOrConditionallyRequired = (nodeDef: ArenaNodeDef<NodeDefType>): boolean =>\n isRequired(nodeDef) || isRequiredIfDefined(nodeDef)\n\n// // Min/max count\n\nconst getCount = (\n nodeDef: ArenaNodeDef<NodeDefType>,\n countType: NodeDefCountType\n): ArenaNodeDefCountExpression | undefined => {\n const countValidations = getValidations(nodeDef)?.count\n if (!countValidations) return undefined\n return countType === NodeDefCountType.max ? countValidations.max : countValidations.min\n}\n\nconst getMinCount = (nodeDef: ArenaNodeDef<NodeDefType>): ArenaNodeDefCountExpression | undefined =>\n getCount(nodeDef, NodeDefCountType.min)\n\nconst getMaxCount = (nodeDef: ArenaNodeDef<NodeDefType>): ArenaNodeDefCountExpression | undefined =>\n getCount(nodeDef, NodeDefCountType.max)\n\nconst hasMinOrMaxCount = (nodeDef: ArenaNodeDef<NodeDefType>): boolean =>\n Objects.isNotEmpty(getMinCount(nodeDef)) || Objects.isNotEmpty(getMaxCount(nodeDef))\n\n// layout\nconst getLayoutProps =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDef<any, ArenaNodeDefPropsWithLayout<any>>): any =>\n nodeDef?.props?.layout?.[cycle] ?? {}\n\nconst getLayoutRenderType =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDef<any, ArenaNodeDefPropsWithLayout<any>>): string | undefined =>\n getLayoutProps(cycle)(nodeDef).renderType\n\nconst isLayoutRenderTypeForm =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDefEntity): boolean =>\n getLayoutRenderType(cycle)(nodeDef) === NodeDefEntityRenderType.form\n\nconst isLayoutRenderTypeTable =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDefEntity): boolean =>\n getLayoutRenderType(cycle)(nodeDef) === NodeDefEntityRenderType.table\n\nconst isLayoutRenderTypeHyperlink =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDefText): boolean =>\n getLayoutRenderType(cycle)(nodeDef) === NodeDefTextRenderType.hyperlink\n\nconst isLayoutRenderTypeMarkdown =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDefText): boolean =>\n getLayoutRenderType(cycle)(nodeDef) === NodeDefTextRenderType.markdown\n\nconst getChildrenEntitiesInOwnPageUuids =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDefEntity): string[] =>\n (getLayoutProps(cycle)(nodeDef) as ArenaNodeDefEntityLayout).indexChildren ?? []\n\nconst getLayoutChildren =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDefEntity): ArenaNodeDefEntityLayoutChildItem[] =>\n (getLayoutProps(cycle)(nodeDef) as ArenaNodeDefEntityLayout).layoutChildren ?? []\n\nconst getPageUuid =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDefEntity): string | undefined =>\n (getLayoutProps(cycle)(nodeDef) as ArenaNodeDefEntityLayout).pageUuid\n\nconst isDisplayInOwnPage =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDefEntity): boolean =>\n !!getPageUuid(cycle)(nodeDef)\n\nconst isHiddenInMobile =\n (cycle = defaultCycle) =>\n <L extends ArenaNodeDefLayout>(nodeDef: ArenaNodeDef<any, ArenaNodeDefPropsWithLayout<L>>): boolean =>\n getLayoutProps(cycle)(nodeDef).hiddenInMobile ?? false\n\nconst isIncludedInMultipleEntitySummary =\n (cycle = defaultCycle) =>\n <L extends ArenaNodeDefLayout>(nodeDef: ArenaNodeDef<any, ArenaNodeDefPropsWithLayout<L>>): boolean =>\n getLayoutProps(cycle)(nodeDef).includedInMultipleEntitySummary ?? false\n\nconst isIncludedInPreviousCycleLink =\n (cycle = defaultCycle) =>\n <L extends ArenaNodeDefLayout>(nodeDef: ArenaNodeDef<any, ArenaNodeDefPropsWithLayout<L>>): boolean =>\n getLayoutProps(cycle)(nodeDef).includedInPreviousCycleLink ?? true\n\nconst isHiddenWhenNotRelevant =\n (cycle = defaultCycle) =>\n <L extends ArenaNodeDefLayout>(nodeDef: ArenaNodeDef<any, ArenaNodeDefPropsWithLayout<L>>): boolean =>\n getLayoutProps(cycle)(nodeDef).hiddenWhenNotRelevant ?? false\n\nconst isCodeShown =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDefCode): boolean =>\n !!(getLayoutProps(cycle)(nodeDef).codeShown ?? true)\n\n// Analysis\nconst getAreaBasedEstimatedOf = (nodeDef: ArenaNodeDef<any>): string | undefined =>\n nodeDef.propsAdvancedDraft?.areaBasedEstimatedOf ?? nodeDef.propsAdvanced?.areaBasedEstimatedOf\n\nconst getIndexInChain = (nodeDef: ArenaNodeDef<any>): number | undefined => nodeDef.propsAdvanced?.index\n\n// Metadata\nconst getMetaHierarchy = (nodeDef: ArenaNodeDef<any>): string[] => nodeDef.meta?.h ?? []\n\nexport const NodeDefs = {\n isEntity,\n isBoolean,\n isCode,\n isCoordinate,\n isDate,\n isDecimal,\n isFile,\n isGeo,\n isInteger,\n isTaxon,\n isText,\n isTime,\n isMultiple,\n isMultipleEntity,\n isSingle,\n isSingleEntity,\n isAttribute,\n isSingleAttribute,\n isMultipleAttribute,\n isKey,\n isAutoIncrementalKey,\n isQualifier,\n isReadOnly,\n isHidden,\n isEnumerate,\n getEnumeratingItemsExpression,\n isAutoCreateMinCountItems,\n getPrintOrientation,\n isAnalysis,\n isRoot,\n getType,\n isLayoutElement,\n getName,\n getLabelOrName,\n getDescription,\n getDefaultValues,\n isDefaultValueEvaluatedOneTime,\n getApplicable,\n getVisibleFields,\n isFieldVisible,\n isInCycle,\n isExcludedInClone,\n getEditableIf,\n isAlwaysEditable,\n getVisibleIf,\n isAlwaysVisible,\n\n getCategoryUuid,\n getParentCodeDefUuid,\n isAllowOnlyDeviceCoordinate,\n getCoordinateAdditionalFields,\n getMaxNumberDecimalDigits,\n getFileNameExpression,\n getFileType,\n getFileMaxSize,\n isGeotagInformationShown,\n isScreenCaptureInMapAllowed,\n isPositionTracking,\n isSecondsIncluded,\n getTaxonomyUuid,\n isVernacularNameSelectionKept,\n isVernacularNameAlwaysIncludedIfSingle,\n getTextTransform,\n getTextInputType,\n getItemsFilter,\n\n // layout\n getLayoutProps,\n getLayoutRenderType,\n isLayoutRenderTypeForm,\n isLayoutRenderTypeTable,\n getChildrenEntitiesInOwnPageUuids,\n getLayoutChildren,\n getPageUuid,\n isDisplayInOwnPage,\n isHiddenInMobile,\n isIncludedInMultipleEntitySummary,\n isIncludedInPreviousCycleLink,\n isHiddenWhenNotRelevant,\n isCodeShown,\n isLayoutRenderTypeHyperlink,\n isLayoutRenderTypeMarkdown,\n // validations\n getValidations,\n getValidationsExpressions,\n isRequired,\n getRequiredIf,\n isRequiredIfDefined,\n isRequiredOrConditionallyRequired,\n // // Min Max\n hasMinOrMaxCount,\n getCount,\n getMaxCount,\n getMinCount,\n // Analysis\n getAreaBasedEstimatedOf,\n getIndexInChain,\n // Metadata\n getMetaHierarchy,\n}\n"]}
1
+ {"version":3,"file":"nodeDefs.js","sourceRoot":"","sources":["../../../src/nodeDef/nodeDefs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAIL,gBAAgB,EAIhB,WAAW,GAEZ,MAAM,WAAW,CAAA;AAMlB,OAAO,EAIL,uBAAuB,GAExB,MAAM,gBAAgB,CAAA;AAMvB,OAAO,EAAoB,qBAAqB,EAAwB,MAAM,cAAc,CAAA;AAG5F,MAAM,MAAM,GAAG,CAAC,OAAwB,EAAW,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAA;AAEzE,MAAM,WAAW,GAAG,CAAC,OAAwB,EAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;AAE7E,MAAM,QAAQ,GAAG,CAAC,OAAwB,EAAiC,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,MAAM,CAAA;AAEjH,MAAM,SAAS,GAAG,CAAC,OAAwB,EAAkC,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,OAAO,CAAA;AAEpH,MAAM,MAAM,GAAG,CAAC,OAAwB,EAA+B,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,CAAA;AAE3G,MAAM,YAAY,GAAG,CAAC,OAAwB,EAAqC,EAAE,CACnF,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,UAAU,CAAA;AAEzC,MAAM,MAAM,GAAG,CAAC,OAAwB,EAA+B,EAAE,CAAC,OAAO,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X,6BAA6B;IAC7B,yBAAyB;IACzB,mBAAmB;IACnB,UAAU;IACV,MAAM;IACN,OAAO;IACP,eAAe;IACf,OAAO;IACP,cAAc;IACd,cAAc;IACd,gBAAgB;IAChB,8BAA8B;IAC9B,aAAa;IACb,gBAAgB;IAChB,cAAc;IACd,SAAS;IACT,iBAAiB;IACjB,aAAa;IACb,gBAAgB;IAChB,YAAY;IACZ,eAAe;IAEf,eAAe;IACf,oBAAoB;IACpB,2BAA2B;IAC3B,6BAA6B;IAC7B,yBAAyB;IACzB,qBAAqB;IACrB,WAAW;IACX,cAAc;IACd,wBAAwB;IACxB,2BAA2B;IAC3B,kBAAkB;IAClB,iBAAiB;IACjB,eAAe;IACf,6BAA6B;IAC7B,sCAAsC;IACtC,gBAAgB;IAChB,gBAAgB;IAChB,cAAc;IAEd,SAAS;IACT,cAAc;IACd,mBAAmB;IACnB,sBAAsB;IACtB,uBAAuB;IACvB,iCAAiC;IACjC,iBAAiB;IACjB,WAAW;IACX,kBAAkB;IAClB,gBAAgB;IAChB,iCAAiC;IACjC,6BAA6B;IAC7B,uBAAuB;IACvB,WAAW;IACX,2BAA2B;IAC3B,0BAA0B;IAC1B,cAAc;IACd,cAAc;IACd,yBAAyB;IACzB,UAAU;IACV,aAAa;IACb,mBAAmB;IACnB,iCAAiC;IACjC,aAAa;IACb,gBAAgB;IAChB,QAAQ;IACR,WAAW;IACX,WAAW;IACX,WAAW;IACX,uBAAuB;IACvB,eAAe;IACf,WAAW;IACX,gBAAgB;CACjB,CAAA","sourcesContent":["import { LanguageCode } from '../language'\nimport { getLabelOrDefault } from '../language/labels'\nimport { ValuePropsCoordinate } from '../node/nodeValueProps'\nimport { defaultCycle } from '../survey'\nimport { Objects } from '../utils'\nimport {\n ArenaAnyNodeDef,\n ArenaNodeDef,\n ArenaNodeDefCountExpression,\n NodeDefCountType,\n ArenaNodeDefExpression,\n ArenaNodeDefLayout,\n ArenaNodeDefPropsWithLayout,\n NodeDefType,\n ArenaNodeDefValidations,\n} from './nodeDef'\nimport { ArenaNodeDefBoolean } from './types/boolean'\nimport { ArenaNodeDefCode } from './types/code'\nimport { ArenaNodeDefCoordinate } from './types/coordinate'\nimport { ArenaNodeDefDate } from './types/date'\nimport { ArenaNodeDefDecimal } from './types/decimal'\nimport {\n ArenaNodeDefEntity,\n ArenaNodeDefEntityLayout,\n ArenaNodeDefEntityLayoutChildItem,\n NodeDefEntityRenderType,\n ArenaNodeDefPrintOrientation,\n} from './types/entity'\nimport { ArenaNodeDefFile, NodeDefFileType } from './types/file'\nimport { ArenaNodeDefFormHeader } from './types/formHeader'\nimport { ArenaNodeDefGeo } from './types/geo'\nimport { ArenaNodeDefInteger } from './types/integer'\nimport { ArenaNodeDefTaxon } from './types/taxon'\nimport { ArenaNodeDefText, NodeDefTextRenderType, NodeDefTextInputType } from './types/text'\nimport { ArenaNodeDefTime } from './types/time'\n\nconst isRoot = (nodeDef: ArenaAnyNodeDef): boolean => !nodeDef.parentUuid\n\nconst isAttribute = (nodeDef: ArenaAnyNodeDef): boolean => !isEntity(nodeDef)\n\nconst isEntity = (nodeDef: ArenaAnyNodeDef): nodeDef is ArenaNodeDefEntity => nodeDef.type === NodeDefType.entity\n\nconst isBoolean = (nodeDef: ArenaAnyNodeDef): nodeDef is ArenaNodeDefBoolean => nodeDef.type === NodeDefType.boolean\n\nconst isCode = (nodeDef: ArenaAnyNodeDef): nodeDef is ArenaNodeDefCode => nodeDef.type === NodeDefType.code\n\nconst isCoordinate = (nodeDef: ArenaAnyNodeDef): nodeDef is ArenaNodeDefCoordinate =>\n nodeDef.type === NodeDefType.coordinate\n\nconst isDate = (nodeDef: ArenaAnyNodeDef): nodeDef is ArenaNodeDefDate => nodeDef.type === NodeDefType.date\n\nconst isDecimal = (nodeDef: ArenaAnyNodeDef): nodeDef is ArenaNodeDefDecimal => nodeDef.type === NodeDefType.decimal\n\nconst isFile = (nodeDef: ArenaAnyNodeDef): nodeDef is ArenaNodeDefFile => nodeDef.type === NodeDefType.file\n\nconst isGeo = (nodeDef: ArenaAnyNodeDef): nodeDef is ArenaNodeDefGeo => nodeDef.type === NodeDefType.geo\n\nconst isInteger = (nodeDef: ArenaAnyNodeDef): nodeDef is ArenaNodeDefInteger => nodeDef.type === NodeDefType.integer\n\nconst isTaxon = (nodeDef: ArenaAnyNodeDef): nodeDef is ArenaNodeDefTaxon => nodeDef.type === NodeDefType.taxon\n\nconst isText = (nodeDef: ArenaAnyNodeDef): nodeDef is ArenaNodeDefText => nodeDef.type === NodeDefType.text\n\nconst isTime = (nodeDef: ArenaAnyNodeDef): nodeDef is ArenaNodeDefTime => nodeDef.type === NodeDefType.time\n\nconst isMultiple = (nodeDef: ArenaAnyNodeDef): boolean => nodeDef.props.multiple ?? false\n\nconst isSingle = (nodeDef: ArenaAnyNodeDef): boolean => !isMultiple(nodeDef)\n\nconst isSingleEntity = (nodeDef: ArenaAnyNodeDef): nodeDef is ArenaNodeDefEntity =>\n isEntity(nodeDef) && isSingle(nodeDef)\n\nconst isSingleAttribute = (nodeDef: ArenaAnyNodeDef): boolean => isAttribute(nodeDef) && isSingle(nodeDef)\n\nconst isMultipleEntity = (nodeDef: ArenaAnyNodeDef): nodeDef is ArenaNodeDefEntity =>\n isEntity(nodeDef) && isMultiple(nodeDef)\n\nconst isMultipleAttribute = (nodeDef: ArenaAnyNodeDef): boolean => isAttribute(nodeDef) && isMultiple(nodeDef)\n\nconst isKey = (nodeDef: ArenaAnyNodeDef): boolean => nodeDef.props.key ?? false\n\nconst isAutoIncrementalKey = (nodeDef: ArenaAnyNodeDef): boolean => nodeDef.props.autoIncrementalKey ?? false\n\nconst isAnalysis = (nodeDef: ArenaAnyNodeDef): boolean => nodeDef.analysis ?? false\n\nconst getType = (nodeDef: ArenaAnyNodeDef): NodeDefType => nodeDef.type\n\nconst isLayoutElement = (nodeDef: ArenaAnyNodeDef): nodeDef is ArenaNodeDefFormHeader =>\n nodeDef.type === NodeDefType.formHeader\n\nconst getName = (nodeDef: ArenaAnyNodeDef): string => nodeDef.props.name ?? ''\n\nconst getLabelOrName = (nodeDef: ArenaAnyNodeDef, lang: LanguageCode): string =>\n getLabelOrDefault(nodeDef.props.labels, lang, getName(nodeDef))\n\nconst getDescription = (nodeDef: ArenaAnyNodeDef, lang: LanguageCode): string =>\n getLabelOrDefault(nodeDef.props.descriptions, lang)\n\nconst isQualifier = (nodeDef: ArenaAnyNodeDef): boolean => nodeDef.props.qualifier ?? false\n\nconst isReadOnly = (nodeDef: ArenaNodeDef<any>): boolean => nodeDef.props.readOnly ?? false\n\nconst isHidden = (nodeDef: ArenaNodeDef<any>): boolean => nodeDef.props.hidden ?? false\n\nconst isEnumerate = (nodeDef: ArenaNodeDefEntity): boolean => nodeDef.props.enumerate ?? false\n\nconst getEnumeratingItemsExpression = (nodeDef: ArenaNodeDefEntity): string | undefined =>\n nodeDef.propsAdvanced?.enumeratingItemsExpression\n\nconst isAutoCreateMinCountItems = (nodeDef: ArenaNodeDefEntity): boolean =>\n isMultipleEntity(nodeDef) && (nodeDef.props.autoCreateMinCountItems ?? false)\n\nconst getPrintOrientation = (nodeDef: ArenaNodeDefEntity): ArenaNodeDefPrintOrientation | undefined =>\n nodeDef.props.printOrientation\n\nconst getDefaultValues = (nodeDef: ArenaAnyNodeDef): ArenaNodeDefExpression[] =>\n nodeDef.propsAdvanced?.defaultValues ?? []\n\nconst isDefaultValueEvaluatedOneTime = (nodeDef: ArenaAnyNodeDef): boolean =>\n !!nodeDef.propsAdvanced?.defaultValueEvaluatedOneTime\n\nconst getApplicable = (nodeDef: ArenaAnyNodeDef): ArenaNodeDefExpression[] => nodeDef.propsAdvanced?.applicable ?? []\n\nconst getVisibleFields = (nodeDef: ArenaAnyNodeDef): string[] | undefined => nodeDef.props.visibleFields\n\nconst isFieldVisible = (field: string) => (nodeDef: ArenaNodeDef<any>) => {\n const visibleFields = getVisibleFields(nodeDef)\n return !visibleFields || visibleFields.includes(field)\n}\n\nconst isInCycle =\n (cycle: string) =>\n (nodeDef: ArenaAnyNodeDef): boolean => {\n const cycles = nodeDef.props.cycles ?? [defaultCycle]\n return cycles.includes(cycle)\n }\n\nconst isExcludedInClone = (nodeDef: ArenaAnyNodeDef): boolean => !!nodeDef.propsAdvanced?.excludedInClone\n\nconst getEditableIf = (nodeDef: ArenaAnyNodeDef): ArenaNodeDefExpression[] => nodeDef.propsAdvanced?.editableIf ?? []\n\nconst isAlwaysEditable = (nodeDef: ArenaAnyNodeDef): boolean => getEditableIf(nodeDef).length === 0\n\nconst getVisibleIf = (nodeDef: ArenaAnyNodeDef): ArenaNodeDefExpression[] => nodeDef.propsAdvanced?.visibleIf ?? []\n\nconst isAlwaysVisible = (nodeDef: ArenaAnyNodeDef): boolean => getVisibleIf(nodeDef).length === 0\n\n// code\nconst getCategoryUuid = (nodeDef: ArenaNodeDefCode): string | undefined => nodeDef.props.categoryUuid\nconst getParentCodeDefUuid = (nodeDef: ArenaNodeDefCode): string | undefined => nodeDef.props.parentCodeDefUuid\n\n// coordinate\nconst isAllowOnlyDeviceCoordinate = (nodeDef: ArenaNodeDefCoordinate): boolean =>\n !!nodeDef.props.allowOnlyDeviceCoordinate\n\nconst getCoordinateAdditionalFields = (nodeDef: ArenaNodeDefCoordinate): string[] => {\n const result = []\n if (nodeDef.props.includeAccuracy) result.push(ValuePropsCoordinate[ValuePropsCoordinate.accuracy])\n if (nodeDef.props.includeAltitude) result.push(ValuePropsCoordinate[ValuePropsCoordinate.altitude])\n if (nodeDef.props.includeAltitudeAccuracy) result.push(ValuePropsCoordinate[ValuePropsCoordinate.altitudeAccuracy])\n return result\n}\n\n// decimal\nconst getMaxNumberDecimalDigits = (nodeDef: ArenaNodeDefDecimal) => {\n const decimalDigits = nodeDef.props.maxNumberDecimalDigits\n return Objects.isEmpty(decimalDigits) ? Number.NaN : Number(decimalDigits)\n}\n\n// file\nconst getFileType = (nodeDef: ArenaNodeDefFile): NodeDefFileType | undefined => nodeDef.props.fileType\nconst getFileNameExpression = (nodeDef: ArenaNodeDefFile): string | undefined =>\n nodeDef.propsAdvanced?.fileNameExpression\nconst getFileMaxSize = (nodeDef: ArenaNodeDefFile): number | undefined => nodeDef.props.maxFileSize\nconst isGeotagInformationShown = (nodeDef: ArenaNodeDefFile): boolean => !!nodeDef.props.geotagInformationShown\nconst isScreenCaptureInMapAllowed = (nodeDef: ArenaNodeDefFile): boolean => !!nodeDef.props.screenCaptureInMapAllowed\n\n// geo\nconst isPositionTracking = (nodeDef: ArenaNodeDefGeo): boolean => !!nodeDef.props.positionTracking\n\n// time\nconst isSecondsIncluded = (nodeDef: ArenaNodeDefTime): boolean => !!nodeDef.props.includeSeconds\n\n// taxon\nconst getTaxonomyUuid = (nodeDef: ArenaNodeDefTaxon): string | undefined => nodeDef.props.taxonomyUuid\n\nconst isVernacularNameSelectionKept = (nodeDef: ArenaNodeDefTaxon): boolean =>\n !!nodeDef.props.vernacularNameSelectionKept\n\nconst isVernacularNameAlwaysIncludedIfSingle = (nodeDef: ArenaNodeDefTaxon): boolean =>\n !!nodeDef.props.vernacularNameAlwaysIncludedIfSingle\n\n// text\nconst getTextTransform = (nodeDef: ArenaNodeDefText): string | undefined => nodeDef.props?.textTransform\nconst getTextInputType = (nodeDef: ArenaNodeDefText): NodeDefTextInputType | undefined => nodeDef.props?.textInputType\n\n// code and taxon\nconst getItemsFilter = (nodeDef: ArenaNodeDef<any>): string | undefined => nodeDef.propsAdvanced?.itemsFilter\n\n// Validations\nconst getValidations = (nodeDef: ArenaAnyNodeDef): ArenaNodeDefValidations | undefined =>\n nodeDef.propsAdvanced?.validations\n\nconst getValidationsExpressions = (nodeDef: ArenaAnyNodeDef): ArenaNodeDefExpression[] =>\n getValidations(nodeDef)?.expressions ?? []\n\nconst isRequired = (nodeDef: ArenaAnyNodeDef): boolean => getValidations(nodeDef)?.required ?? false\n\nconst getRequiredIf = (nodeDef: ArenaAnyNodeDef): ArenaNodeDefExpression[] => getValidations(nodeDef)?.requiredIf ?? []\n\nconst isRequiredIfDefined = (nodeDef: ArenaAnyNodeDef): boolean => getRequiredIf(nodeDef).length > 0\n\n/**\n * True if the node def is always required or required when a condition is met (node def level, not record level).\n */\nconst isRequiredOrConditionallyRequired = (nodeDef: ArenaAnyNodeDef): boolean =>\n isRequired(nodeDef) || isRequiredIfDefined(nodeDef)\n\n// // Min/max count\n\nconst getCount = (nodeDef: ArenaAnyNodeDef, countType: NodeDefCountType): ArenaNodeDefCountExpression | undefined => {\n const countValidations = getValidations(nodeDef)?.count\n if (!countValidations) return undefined\n return countType === NodeDefCountType.max ? countValidations.max : countValidations.min\n}\n\nconst getMinCount = (nodeDef: ArenaAnyNodeDef): ArenaNodeDefCountExpression | undefined =>\n getCount(nodeDef, NodeDefCountType.min)\n\nconst getMaxCount = (nodeDef: ArenaAnyNodeDef): ArenaNodeDefCountExpression | undefined =>\n getCount(nodeDef, NodeDefCountType.max)\n\nconst hasMinOrMaxCount = (nodeDef: ArenaAnyNodeDef): boolean =>\n Objects.isNotEmpty(getMinCount(nodeDef)) || Objects.isNotEmpty(getMaxCount(nodeDef))\n\n// layout\nconst getLayoutProps =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDef<any, ArenaNodeDefPropsWithLayout<any>>): any =>\n nodeDef?.props?.layout?.[cycle] ?? {}\n\nconst getLayoutRenderType =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDef<any, ArenaNodeDefPropsWithLayout<any>>): string | undefined =>\n getLayoutProps(cycle)(nodeDef).renderType\n\nconst isLayoutRenderTypeForm =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDefEntity): boolean =>\n getLayoutRenderType(cycle)(nodeDef) === NodeDefEntityRenderType.form\n\nconst isLayoutRenderTypeTable =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDefEntity): boolean =>\n getLayoutRenderType(cycle)(nodeDef) === NodeDefEntityRenderType.table\n\nconst isLayoutRenderTypeHyperlink =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDefText): boolean =>\n getLayoutRenderType(cycle)(nodeDef) === NodeDefTextRenderType.hyperlink\n\nconst isLayoutRenderTypeMarkdown =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDefText): boolean =>\n getLayoutRenderType(cycle)(nodeDef) === NodeDefTextRenderType.markdown\n\nconst getChildrenEntitiesInOwnPageUuids =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDefEntity): string[] =>\n (getLayoutProps(cycle)(nodeDef) as ArenaNodeDefEntityLayout).indexChildren ?? []\n\nconst getLayoutChildren =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDefEntity): ArenaNodeDefEntityLayoutChildItem[] =>\n (getLayoutProps(cycle)(nodeDef) as ArenaNodeDefEntityLayout).layoutChildren ?? []\n\nconst getPageUuid =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDefEntity): string | undefined =>\n (getLayoutProps(cycle)(nodeDef) as ArenaNodeDefEntityLayout).pageUuid\n\nconst isDisplayInOwnPage =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDefEntity): boolean =>\n !!getPageUuid(cycle)(nodeDef)\n\nconst isHiddenInMobile =\n (cycle = defaultCycle) =>\n <L extends ArenaNodeDefLayout>(nodeDef: ArenaNodeDef<any, ArenaNodeDefPropsWithLayout<L>>): boolean =>\n getLayoutProps(cycle)(nodeDef).hiddenInMobile ?? false\n\nconst isIncludedInMultipleEntitySummary =\n (cycle = defaultCycle) =>\n <L extends ArenaNodeDefLayout>(nodeDef: ArenaNodeDef<any, ArenaNodeDefPropsWithLayout<L>>): boolean =>\n getLayoutProps(cycle)(nodeDef).includedInMultipleEntitySummary ?? false\n\nconst isIncludedInPreviousCycleLink =\n (cycle = defaultCycle) =>\n <L extends ArenaNodeDefLayout>(nodeDef: ArenaNodeDef<any, ArenaNodeDefPropsWithLayout<L>>): boolean =>\n getLayoutProps(cycle)(nodeDef).includedInPreviousCycleLink ?? true\n\nconst isHiddenWhenNotRelevant =\n (cycle = defaultCycle) =>\n <L extends ArenaNodeDefLayout>(nodeDef: ArenaNodeDef<any, ArenaNodeDefPropsWithLayout<L>>): boolean =>\n getLayoutProps(cycle)(nodeDef).hiddenWhenNotRelevant ?? false\n\nconst isCodeShown =\n (cycle = defaultCycle) =>\n (nodeDef: ArenaNodeDefCode): boolean =>\n !!(getLayoutProps(cycle)(nodeDef).codeShown ?? true)\n\n// Analysis\nconst getAreaBasedEstimatedOf = (nodeDef: ArenaNodeDef<any>): string | undefined =>\n nodeDef.propsAdvancedDraft?.areaBasedEstimatedOf ?? nodeDef.propsAdvanced?.areaBasedEstimatedOf\n\nconst getIndexInChain = (nodeDef: ArenaNodeDef<any>): number | undefined => nodeDef.propsAdvanced?.index\n\n// Metadata\nconst getMetaHierarchy = (nodeDef: ArenaNodeDef<any>): string[] => nodeDef.meta?.h ?? []\n\nexport const NodeDefs = {\n isEntity,\n isBoolean,\n isCode,\n isCoordinate,\n isDate,\n isDecimal,\n isFile,\n isGeo,\n isInteger,\n isTaxon,\n isText,\n isTime,\n isMultiple,\n isMultipleEntity,\n isSingle,\n isSingleEntity,\n isAttribute,\n isSingleAttribute,\n isMultipleAttribute,\n isKey,\n isAutoIncrementalKey,\n isQualifier,\n isReadOnly,\n isHidden,\n isEnumerate,\n getEnumeratingItemsExpression,\n isAutoCreateMinCountItems,\n getPrintOrientation,\n isAnalysis,\n isRoot,\n getType,\n isLayoutElement,\n getName,\n getLabelOrName,\n getDescription,\n getDefaultValues,\n isDefaultValueEvaluatedOneTime,\n getApplicable,\n getVisibleFields,\n isFieldVisible,\n isInCycle,\n isExcludedInClone,\n getEditableIf,\n isAlwaysEditable,\n getVisibleIf,\n isAlwaysVisible,\n\n getCategoryUuid,\n getParentCodeDefUuid,\n isAllowOnlyDeviceCoordinate,\n getCoordinateAdditionalFields,\n getMaxNumberDecimalDigits,\n getFileNameExpression,\n getFileType,\n getFileMaxSize,\n isGeotagInformationShown,\n isScreenCaptureInMapAllowed,\n isPositionTracking,\n isSecondsIncluded,\n getTaxonomyUuid,\n isVernacularNameSelectionKept,\n isVernacularNameAlwaysIncludedIfSingle,\n getTextTransform,\n getTextInputType,\n getItemsFilter,\n\n // layout\n getLayoutProps,\n getLayoutRenderType,\n isLayoutRenderTypeForm,\n isLayoutRenderTypeTable,\n getChildrenEntitiesInOwnPageUuids,\n getLayoutChildren,\n getPageUuid,\n isDisplayInOwnPage,\n isHiddenInMobile,\n isIncludedInMultipleEntitySummary,\n isIncludedInPreviousCycleLink,\n isHiddenWhenNotRelevant,\n isCodeShown,\n isLayoutRenderTypeHyperlink,\n isLayoutRenderTypeMarkdown,\n // validations\n getValidations,\n getValidationsExpressions,\n isRequired,\n getRequiredIf,\n isRequiredIfDefined,\n isRequiredOrConditionallyRequired,\n // // Min Max\n hasMinOrMaxCount,\n getCount,\n getMaxCount,\n getMinCount,\n // Analysis\n getAreaBasedEstimatedOf,\n getIndexInChain,\n // Metadata\n getMetaHierarchy,\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/nodeDef/service.ts"],"names":[],"mappings":"","sourcesContent":["import { ArenaUser } from '../auth'\nimport { ArenaChainNodeDef } from '../chain'\nimport { ArenaService } from '../common'\nimport { ArenaNodeDef, NodeDefType } from './nodeDef'\n\nexport interface ArenaNodeDefService extends ArenaService {\n // ==== CREATE\n create(options: {\n chainNodeDef?: ArenaChainNodeDef\n cycle: string\n nodeDef: ArenaNodeDef<NodeDefType>\n surveyId: number\n user: ArenaUser\n }): Promise<{ [nodeDefUuid: string]: ArenaNodeDef<NodeDefType> }>\n\n // ==== READ\n getMany(options: {\n advanced?: boolean\n cycle?: string\n deleted?: boolean\n draft?: boolean\n limit?: number\n offset?: number\n surveyId: number\n user: ArenaUser\n validate?: boolean\n }): Promise<{ [nodeDefUuid: string]: ArenaNodeDef<NodeDefType> }>\n\n // ==== UPDATE\n update(options: {\n cycle: string\n nodeDef: ArenaNodeDef<NodeDefType>\n user: ArenaUser\n surveyId: number\n }): Promise<{ [nodeDefUuid: string]: ArenaNodeDef<NodeDefType> }>\n\n // ==== DELETE\n delete(options: {\n cycle: string\n nodeDefUuid: string\n user: ArenaUser\n surveyId: number\n }): Promise<{ [nodeDefUuid: string]: ArenaNodeDef<NodeDefType> }>\n}\n"]}
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/nodeDef/service.ts"],"names":[],"mappings":"","sourcesContent":["import { ArenaUser } from '../auth'\nimport { ArenaChainNodeDef } from '../chain'\nimport { ArenaService } from '../common'\nimport { ArenaAnyNodeDef } from './nodeDef'\n\nexport interface ArenaNodeDefService extends ArenaService {\n // ==== CREATE\n create(options: {\n chainNodeDef?: ArenaChainNodeDef\n cycle: string\n nodeDef: ArenaAnyNodeDef\n surveyId: number\n user: ArenaUser\n }): Promise<{ [nodeDefUuid: string]: ArenaAnyNodeDef }>\n\n // ==== READ\n getMany(options: {\n advanced?: boolean\n cycle?: string\n deleted?: boolean\n draft?: boolean\n limit?: number\n offset?: number\n surveyId: number\n user: ArenaUser\n validate?: boolean\n }): Promise<{ [nodeDefUuid: string]: ArenaAnyNodeDef }>\n\n // ==== UPDATE\n update(options: {\n cycle: string\n nodeDef: ArenaAnyNodeDef\n user: ArenaUser\n surveyId: number\n }): Promise<{ [nodeDefUuid: string]: ArenaAnyNodeDef }>\n\n // ==== DELETE\n delete(options: {\n cycle: string\n nodeDefUuid: string\n user: ArenaUser\n surveyId: number\n }): Promise<{ [nodeDefUuid: string]: ArenaAnyNodeDef }>\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/nodeDefExpressionEvaluator/context.ts"],"names":[],"mappings":"","sourcesContent":["import { ArenaUser } from '../auth'\nimport { ArenaExpressionContext } from '../expression'\nimport { ArenaNodeDef } from '../nodeDef'\nimport { ArenaNodeDefProps, NodeDefType } from '../nodeDef/nodeDef'\nimport { ArenaSurvey } from '../survey'\nimport { ArenaAreaOfInterestProvider } from './areaOfInterestProvider'\nimport { ArenaCategoryItemProvider } from './categoryItemProvider'\nimport { ArenaTaxonProvider } from './taxonProvider'\n\nexport interface NodeDefExpressionContext extends ArenaExpressionContext {\n survey: ArenaSurvey\n user?: ArenaUser\n nodeDefCurrent: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n nodeDefContext?: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n /**\n * Unique UUIDs of node definitions being visited during expression evaluation.\n */\n referencedNodeDefUuids?: Set<string>\n selfReferenceAllowed?: boolean\n // true when the expression is used to filter code or taxon items\n itemsFilter?: boolean\n // true when evaluating the property of a member expression (e.g. \"length\" in \"text_attr.length\")\n memberProperty?: boolean\n\n categoryItemProvider?: ArenaCategoryItemProvider\n taxonProvider?: ArenaTaxonProvider\n areaOfInterestProvider?: ArenaAreaOfInterestProvider\n}\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/nodeDefExpressionEvaluator/context.ts"],"names":[],"mappings":"","sourcesContent":["import { ArenaUser } from '../auth'\nimport { ArenaExpressionContext } from '../expression'\nimport { ArenaAnyNodeDef } from '../nodeDef'\nimport { ArenaSurvey } from '../survey'\nimport { ArenaAreaOfInterestProvider } from './areaOfInterestProvider'\nimport { ArenaCategoryItemProvider } from './categoryItemProvider'\nimport { ArenaTaxonProvider } from './taxonProvider'\n\nexport interface NodeDefExpressionContext extends ArenaExpressionContext {\n survey: ArenaSurvey\n user?: ArenaUser\n nodeDefCurrent: ArenaAnyNodeDef\n nodeDefContext?: ArenaAnyNodeDef\n /**\n * Unique UUIDs of node definitions being visited during expression evaluation.\n */\n referencedNodeDefUuids?: Set<string>\n selfReferenceAllowed?: boolean\n // true when the expression is used to filter code or taxon items\n itemsFilter?: boolean\n // true when evaluating the property of a member expression (e.g. \"length\" in \"text_attr.length\")\n memberProperty?: boolean\n\n categoryItemProvider?: ArenaCategoryItemProvider\n taxonProvider?: ArenaTaxonProvider\n areaOfInterestProvider?: ArenaAreaOfInterestProvider\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file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aNodeDefProps, NodeDefType } from '../../nodeDef/nodeDef'\nimport { getNodeDefChildren, getNodeDefParent, getNodeDefSource } from '../../survey/surveys/nodeDefs'\nimport { NodeDefs } from '../../nodeDef/nodeDefs'\nimport { Objects, Queue } from '../../utils'\nimport { IdentifierEvaluator } from '../../expression/javascript/node/identifier'\nimport { getGlobalObjectProperty, isForbiddenPropertyName } from '../../expression/javascript/global'\nimport { NodeDefExpressionContext } from '../context'\nimport { ExpressionVariable, ArenaIdentifierExpression } from '../../expression'\nimport { SystemError, SystemErrorKeys } from '../../error'\nimport { ValidatorErrorKeys } from '../../validation'\nimport { NodeNativeProperties } from './nodeDefExpressionNativeProperties'\nimport { RecordNodeValues } from '../../node/nodeValues'\n\n/**\n * Determines the actual context node def\n * - attribute def => parent entity def\n * - virtual entity def => source node def\n * - entity def => entity def itself\n */\nconst findActualContextNode = (params: {\n context: NodeDefExpressionContext\n}): ArenaNodeDef<NodeDefType, ArenaNodeDefProps> | undefined => {\n const { context } = params\n const { survey, object: nodeDefObjectContext } = context\n\n if (!nodeDefObjectContext) return undefined\n\n if (NodeDefs.isAttribute(nodeDefObjectContext)) {\n return getNodeDefParent({ survey, nodeDef: nodeDefObjectContext })\n }\n if (nodeDefObjectContext.virtual) {\n return getNodeDefSource({ survey, nodeDef: nodeDefObjectContext })\n }\n return nodeDefObjectContext\n}\n\nexport class NodeDefIdentifierEvaluator extends IdentifierEvaluator<NodeDefExpressionContext> {\n evaluate(expressionNode: ArenaIdentifierExpression): Promise<any> {\n try {\n return Promise.resolve(this.evaluateIdentifier(expressionNode))\n } catch (error) {\n return Promise.reject(error)\n }\n }\n\n private evaluateIdentifier(expressionNode: ArenaIdentifierExpression): any {\n const { context } = this\n const { nodeDefContext, object: objectContext, itemsFilter, memberProperty } = context\n const { name: exprName } = expressionNode\n\n if (isForbiddenPropertyName(exprName)) {\n this.throwIdentifierNotFound(expressionNode)\n }\n\n if (exprName === ExpressionVariable.CONTEXT) {\n if (nodeDefContext) {\n this.addReferencedNodeDefUuid(nodeDefContext.uuid)\n }\n return nodeDefContext\n }\n\n // global objects (e.g. Math, String)\n const globalObjectProperty = getGlobalObjectProperty(exprName, objectContext)\n if (globalObjectProperty !== null) {\n return globalObjectProperty\n }\n\n if (itemsFilter) {\n const prop = objectContext?.props?.[exprName] ?? objectContext?.props?.extra?.[exprName]\n if (!Objects.isEmpty(prop)) {\n return prop\n }\n }\n\n // check if identifier is a composite attribute value prop\n if (\n NodeDefs.isAttribute(objectContext) &&\n RecordNodeValues.isValueProp({ nodeDef: objectContext, prop: exprName })\n ) {\n return objectContext\n }\n\n if (memberProperty) {\n // property of a member expression (e.g. text_attr.length or text_attr.toUpperCase()): native properties first\n const nativeProperty = this.findNativeProperty(expressionNode)\n if (nativeProperty) return nativeProperty.value\n return this.getReferencedNodeDef(expressionNode)\n }\n // identifier not in a member expression: node defs first, so that node defs named like native properties\n // (e.g. \"name\", \"type\", \"trim\") are always found (and registered as dependencies)\n const referencedNodeDef = this.findReferencedNodeDef(expressionNode)\n if (referencedNodeDef) return referencedNodeDef\n\n const nativeProperty = this.findNativeProperty(expressionNode)\n if (nativeProperty) return nativeProperty.value\n\n return this.throwIdentifierNotFound(expressionNode)\n }\n\n /**\n * Finds the identifier among the native properties or functions of the context object\n * (e.g. String.length or String.toUpperCase()).\n */\n private findNativeProperty(expressionNode: ArenaIdentifierExpression): { value: any } | null {\n const { object: objectContext } = this.context\n const { name: exprName } = expressionNode\n\n const globalOrNativeProperty = this.findGlobalOrNativeProperty(expressionNode)\n if (globalOrNativeProperty) {\n return globalOrNativeProperty\n }\n if (NodeNativeProperties.hasNativeProperty({ nodeDefOrValue: objectContext, propName: exprName })) {\n return {\n value: NodeNativeProperties.evalNodeDefProperty({ nodeDefOrValue: objectContext, propName: exprName }),\n }\n }\n return null\n }\n\n private findReferencedNodeDef(\n expressionNode: ArenaIdentifierExpression\n ): ArenaNodeDef<NodeDefType, ArenaNodeDefProps> | undefined {\n const { nodeDefCurrent, selfReferenceAllowed } = this.context\n const referencedNodeDef = this.findIdentifierAmongReachableNodeDefs(expressionNode)\n if (!referencedNodeDef) return undefined\n\n if (!selfReferenceAllowed && referencedNodeDef.uuid === nodeDefCurrent?.uuid) {\n throw new SystemError(ValidatorErrorKeys.expressions.cannotUseCurrentNode, { name: expressionNode.name })\n }\n this.addReferencedNodeDefUuid(referencedNodeDef.uuid)\n return referencedNodeDef\n }\n\n private getReferencedNodeDef(\n expressionNode: ArenaIdentifierExpression\n ): ArenaNodeDef<NodeDefType, ArenaNodeDefProps> {\n return this.findReferencedNodeDef(expressionNode) ?? this.throwIdentifierNotFound(expressionNode)\n }\n\n private throwIdentifierNotFound(expressionNode: ArenaIdentifierExpression): never {\n throw new SystemError(SystemErrorKeys.expression.identifierNotFound, {\n name: expressionNode.name,\n contextObject: this.context.object?.props?.name,\n })\n }\n\n private addReferencedNodeDefUuid(uuid: string) {\n const { context } = this\n const { referencedNodeDefUuids = new Set() } = context\n context.referencedNodeDefUuids = referencedNodeDefUuids.add(uuid)\n }\n\n /**\n * Tries to find the specified identifier among the node defs that can be \"reached\" from the context node def.\n */\n protected findIdentifierAmongReachableNodeDefs(\n expressionNode: ArenaIdentifierExpression\n ): ArenaNodeDef<NodeDefType, ArenaNodeDefProps> | undefined {\n const { object: contextObject } = this.context\n\n if (!contextObject) return undefined\n\n // stop at the first match, without visiting all the reachable node defs\n for (const reachableNodeDef of this.iterateReachableNodeDefs()) {\n if (reachableNodeDef.props.name === expressionNode.name) {\n return reachableNodeDef\n }\n }\n return undefined\n }\n\n /**\n * Iterates over the reachable node defs, i.e. the actual context node def, the children of its ancestors\n * (including the ones inside single entities) and the ancestors themselves, yielding every node def only once.\n */\n private *iterateReachableNodeDefs(): Generator<ArenaNodeDef<NodeDefType, ArenaNodeDefProps>> {\n const { context } = this\n const { survey, includeAnalysis } = context\n\n const reachableNodeDefUuids = new Set<string>()\n const visitedUuids = new Set<string>()\n\n const queue = new Queue<ArenaNodeDef<NodeDefType>>()\n\n const actualContextNode = findActualContextNode({ context })\n if (actualContextNode) {\n queue.enqueue(actualContextNode)\n reachableNodeDefUuids.add(actualContextNode.uuid)\n yield actualContextNode\n }\n\n while (!queue.isEmpty()) {\n const entityDefCurrent = queue.dequeue()!\n const entityDefCurrentChildren = getNodeDefChildren({ survey, nodeDef: entityDefCurrent, includeAnalysis })\n for (const childDef of entityDefCurrentChildren) {\n if (!reachableNodeDefUuids.has(childDef.uuid)) {\n reachableNodeDefUuids.add(childDef.uuid)\n yield childDef\n }\n }\n // visit nodes inside single entities\n queue.enqueueItems(entityDefCurrentChildren.filter(NodeDefs.isSingleEntity))\n\n // avoid visiting 2 times the same entity definition when traversing single entities\n if (!visitedUuids.has(entityDefCurrent.uuid)) {\n const entityDefCurrentParent = getNodeDefParent({ survey, nodeDef: entityDefCurrent })\n if (entityDefCurrentParent) {\n queue.enqueue(entityDefCurrentParent)\n }\n if (!reachableNodeDefUuids.has(entityDefCurrent.uuid)) {\n reachableNodeDefUuids.add(entityDefCurrent.uuid)\n yield entityDefCurrent\n }\n visitedUuids.add(entityDefCurrent.uuid)\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../../src/nodeDefExpressionEvaluator/node/identifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AACtG,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AACjF,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAA;AAErG,OAAO,EAAE,kBAAkB,EAA6B,MAAM,kBAAkB,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAA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rC,KAAK,CAAC,YAAY,CAAC,wBAAwB,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAA;YAE5E,oFAAoF;YACpF,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC7C,MAAM,sBAAsB,GAAG,gBAAgB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAA;gBACtF,IAAI,sBAAsB,EAAE,CAAC;oBAC3B,KAAK,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAA;gBACvC,CAAC;gBACD,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;oBACtD,qBAAqB,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;oBAChD,MAAM,gBAAgB,CAAA;gBACxB,CAAC;gBACD,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;YACzC,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { ArenaAnyNodeDef } from '../../nodeDef/nodeDef'\nimport { getNodeDefChildren, getNodeDefParent, getNodeDefSource } from '../../survey/surveys/nodeDefs'\nimport { NodeDefs } from '../../nodeDef/nodeDefs'\nimport { Objects, Queue } from '../../utils'\nimport { IdentifierEvaluator } from '../../expression/javascript/node/identifier'\nimport { getGlobalObjectProperty, isForbiddenPropertyName } from '../../expression/javascript/global'\nimport { NodeDefExpressionContext } from '../context'\nimport { ExpressionVariable, ArenaIdentifierExpression } from '../../expression'\nimport { SystemError, SystemErrorKeys } from '../../error'\nimport { ValidatorErrorKeys } from '../../validation'\nimport { NodeNativeProperties } from './nodeDefExpressionNativeProperties'\nimport { RecordNodeValues } from '../../node/nodeValues'\n\n/**\n * Determines the actual context node def\n * - attribute def => parent entity def\n * - virtual entity def => source node def\n * - entity def => entity def itself\n */\nconst findActualContextNode = (params: { context: NodeDefExpressionContext }): ArenaAnyNodeDef | undefined => {\n const { context } = params\n const { survey, object: nodeDefObjectContext } = context\n\n if (!nodeDefObjectContext) return undefined\n\n if (NodeDefs.isAttribute(nodeDefObjectContext)) {\n return getNodeDefParent({ survey, nodeDef: nodeDefObjectContext })\n }\n if (nodeDefObjectContext.virtual) {\n return getNodeDefSource({ survey, nodeDef: nodeDefObjectContext })\n }\n return nodeDefObjectContext\n}\n\nexport class NodeDefIdentifierEvaluator extends IdentifierEvaluator<NodeDefExpressionContext> {\n evaluate(expressionNode: ArenaIdentifierExpression): Promise<any> {\n try {\n return Promise.resolve(this.evaluateIdentifier(expressionNode))\n } catch (error) {\n return Promise.reject(error)\n }\n }\n\n private evaluateIdentifier(expressionNode: ArenaIdentifierExpression): any {\n const { context } = this\n const { nodeDefContext, object: objectContext, itemsFilter, memberProperty } = context\n const { name: exprName } = expressionNode\n\n if (isForbiddenPropertyName(exprName)) {\n this.throwIdentifierNotFound(expressionNode)\n }\n\n if (exprName === ExpressionVariable.CONTEXT) {\n if (nodeDefContext) {\n this.addReferencedNodeDefUuid(nodeDefContext.uuid)\n }\n return nodeDefContext\n }\n\n // global objects (e.g. Math, String)\n const globalObjectProperty = getGlobalObjectProperty(exprName, objectContext)\n if (globalObjectProperty !== null) {\n return globalObjectProperty\n }\n\n if (itemsFilter) {\n const prop = objectContext?.props?.[exprName] ?? objectContext?.props?.extra?.[exprName]\n if (!Objects.isEmpty(prop)) {\n return prop\n }\n }\n\n // check if identifier is a composite attribute value prop\n if (\n NodeDefs.isAttribute(objectContext) &&\n RecordNodeValues.isValueProp({ nodeDef: objectContext, prop: exprName })\n ) {\n return objectContext\n }\n\n if (memberProperty) {\n // property of a member expression (e.g. text_attr.length or text_attr.toUpperCase()): native properties first\n const nativeProperty = this.findNativeProperty(expressionNode)\n if (nativeProperty) return nativeProperty.value\n return this.getReferencedNodeDef(expressionNode)\n }\n // identifier not in a member expression: node defs first, so that node defs named like native properties\n // (e.g. \"name\", \"type\", \"trim\") are always found (and registered as dependencies)\n const referencedNodeDef = this.findReferencedNodeDef(expressionNode)\n if (referencedNodeDef) return referencedNodeDef\n\n const nativeProperty = this.findNativeProperty(expressionNode)\n if (nativeProperty) return nativeProperty.value\n\n return this.throwIdentifierNotFound(expressionNode)\n }\n\n /**\n * Finds the identifier among the native properties or functions of the context object\n * (e.g. String.length or String.toUpperCase()).\n */\n private findNativeProperty(expressionNode: ArenaIdentifierExpression): { value: any } | null {\n const { object: objectContext } = this.context\n const { name: exprName } = expressionNode\n\n const globalOrNativeProperty = this.findGlobalOrNativeProperty(expressionNode)\n if (globalOrNativeProperty) {\n return globalOrNativeProperty\n }\n if (NodeNativeProperties.hasNativeProperty({ nodeDefOrValue: objectContext, propName: exprName })) {\n return {\n value: NodeNativeProperties.evalNodeDefProperty({ nodeDefOrValue: objectContext, propName: exprName }),\n }\n }\n return null\n }\n\n private findReferencedNodeDef(expressionNode: ArenaIdentifierExpression): ArenaAnyNodeDef | undefined {\n const { nodeDefCurrent, selfReferenceAllowed } = this.context\n const referencedNodeDef = this.findIdentifierAmongReachableNodeDefs(expressionNode)\n if (!referencedNodeDef) return undefined\n\n if (!selfReferenceAllowed && referencedNodeDef.uuid === nodeDefCurrent?.uuid) {\n throw new SystemError(ValidatorErrorKeys.expressions.cannotUseCurrentNode, { name: expressionNode.name })\n }\n this.addReferencedNodeDefUuid(referencedNodeDef.uuid)\n return referencedNodeDef\n }\n\n private getReferencedNodeDef(expressionNode: ArenaIdentifierExpression): ArenaAnyNodeDef {\n return this.findReferencedNodeDef(expressionNode) ?? this.throwIdentifierNotFound(expressionNode)\n }\n\n private throwIdentifierNotFound(expressionNode: ArenaIdentifierExpression): never {\n throw new SystemError(SystemErrorKeys.expression.identifierNotFound, {\n name: expressionNode.name,\n contextObject: this.context.object?.props?.name,\n })\n }\n\n private addReferencedNodeDefUuid(uuid: string) {\n const { context } = this\n const { referencedNodeDefUuids = new Set() } = context\n context.referencedNodeDefUuids = referencedNodeDefUuids.add(uuid)\n }\n\n /**\n * Tries to find the specified identifier among the node defs that can be \"reached\" from the context node def.\n */\n protected findIdentifierAmongReachableNodeDefs(\n expressionNode: ArenaIdentifierExpression\n ): ArenaAnyNodeDef | undefined {\n const { object: contextObject } = this.context\n\n if (!contextObject) return undefined\n\n // stop at the first match, without visiting all the reachable node defs\n for (const reachableNodeDef of this.iterateReachableNodeDefs()) {\n if (reachableNodeDef.props.name === expressionNode.name) {\n return reachableNodeDef\n }\n }\n return undefined\n }\n\n /**\n * Iterates over the reachable node defs, i.e. the actual context node def, the children of its ancestors\n * (including the ones inside single entities) and the ancestors themselves, yielding every node def only once.\n */\n private *iterateReachableNodeDefs(): Generator<ArenaAnyNodeDef> {\n const { context } = this\n const { survey, includeAnalysis } = context\n\n const reachableNodeDefUuids = new Set<string>()\n const visitedUuids = new Set<string>()\n\n const queue = new Queue<ArenaAnyNodeDef>()\n\n const actualContextNode = findActualContextNode({ context })\n if (actualContextNode) {\n queue.enqueue(actualContextNode)\n reachableNodeDefUuids.add(actualContextNode.uuid)\n yield actualContextNode\n }\n\n while (!queue.isEmpty()) {\n const entityDefCurrent = queue.dequeue()!\n const entityDefCurrentChildren = getNodeDefChildren({ survey, nodeDef: entityDefCurrent, includeAnalysis })\n for (const childDef of entityDefCurrentChildren) {\n if (!reachableNodeDefUuids.has(childDef.uuid)) {\n reachableNodeDefUuids.add(childDef.uuid)\n yield childDef\n }\n }\n // visit nodes inside single entities\n queue.enqueueItems(entityDefCurrentChildren.filter(NodeDefs.isSingleEntity))\n\n // avoid visiting 2 times the same entity definition when traversing single entities\n if (!visitedUuids.has(entityDefCurrent.uuid)) {\n const entityDefCurrentParent = getNodeDefParent({ survey, nodeDef: entityDefCurrent })\n if (entityDefCurrentParent) {\n queue.enqueue(entityDefCurrentParent)\n }\n if (!reachableNodeDefUuids.has(entityDefCurrent.uuid)) {\n reachableNodeDefUuids.add(entityDefCurrent.uuid)\n yield entityDefCurrent\n }\n visitedUuids.add(entityDefCurrent.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;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,oBAAoB;CACrB,CAAA","sourcesContent":["import { ArenaAnyExpressionNode, ExpressionNodeType } from '../../expression'\nimport { parseExpression } from '../../expression/javascript/evaluator'\nimport { ArenaNodeDef, ArenaNodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { SurveyDependencyType } from '../../survey/survey'\n\n/**\n * True if the identifier is used as (or inside) the property of a member expression (e.g. \"dbh\" in\n * \"parent(tree).tree.dbh\" or in \"tree[dbh > 10]\"): there it can refer to nodes outside the context entity.\n */\nconst isReferencedThroughMember = (params: {\n expressionNode: unknown\n name: string\n inMemberProperty: boolean\n}): boolean => {\n const { expressionNode, name, inMemberProperty } = params\n if (!expressionNode || typeof expressionNode !== 'object') return false\n if (Array.isArray(expressionNode)) {\n return expressionNode.some((item) => isReferencedThroughMember({ expressionNode: item, name, inMemberProperty }))\n }\n // parsed expression nodes (or their array or object properties)\n const node = expressionNode as ArenaAnyExpressionNode\n if (node.type === ExpressionNodeType.Identifier) {\n return inMemberProperty && node.name === name\n }\n if (node.type === ExpressionNodeType.Member) {\n const { object, property } = node\n return (\n isReferencedThroughMember({ expressionNode: object, name, inMemberProperty }) ||\n isReferencedThroughMember({ expressionNode: property, name, inMemberProperty: true })\n )\n }\n return Object.values(expressionNode).some((child) =>\n isReferencedThroughMember({ expressionNode: child, name, inMemberProperty })\n )\n}\n\nconst isExpressionSelfReferenceLocal = (params: { expression: string | undefined; name: string }): boolean => {\n const { expression, name } = params\n if (!expression) return true\n try {\n return !isReferencedThroughMember({ expressionNode: parseExpression(expression), name, inMemberProperty: false })\n } catch {\n // invalid expression: be conservative\n return false\n }\n}\n\n/**\n * Returns true if the node def references itself in its expressions of the specified dependency type only\n * as a plain identifier (e.g. \"dbh > 0\" in a validation of \"dbh\"): such a reference is resolved among the\n * children of the node's parent entity, so only the node and its siblings depend on it, not every node with\n * the same node def in the record.\n */\nconst isSelfReferenceLocal = (params: {\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n dependencyType: SurveyDependencyType\n}): boolean => {\n const { nodeDef, dependencyType } = params\n // self references by plain identifier are allowed only in validation expressions (see dependencies.ts)\n if (dependencyType !== SurveyDependencyType.validations) return false\n const name = NodeDefs.getName(nodeDef)\n return NodeDefs.getValidationsExpressions(nodeDef).every(\n ({ expression, applyIf }) =>\n isExpressionSelfReferenceLocal({ expression, name }) &&\n isExpressionSelfReferenceLocal({ expression: applyIf, name })\n )\n}\n\nexport const NodeDefSelfReferences = {\n isSelfReferenceLocal,\n}\n"]}
1
+ {"version":3,"file":"nodeDefSelfReferences.js","sourceRoot":"","sources":["../../../../src/record/_records/nodeDefSelfReferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAA;AACvE,OAAO,EAAmB,QAAQ,EAAE,MAAM,eAAe,CAAA;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE1D;;;GAGG;AACH,MAAM,yBAAyB,GAAG,CAAC,MAIlC,EAAW,EAAE;IACZ,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAAA;IACzD,IAAI,CAAC,cAAc,IAAI,OAAO,cAAc,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IACvE,IAAI,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;QAClC,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,yBAAyB,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAA;IACnH,CAAC;IACD,gEAAgE;IAChE,MAAM,IAAI,GAAG,cAAwC,CAAA;IACrD,IAAI,IAAI,CAAC,IAAI,KAAK,kBAAkB,CAAC,UA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O,KAAK,CAAA;IACrE,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IACtC,OAAO,QAAQ,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC,KAAK,CACtD,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,EAAE,CAC1B,8BAA8B,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QACpD,8BAA8B,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAChE,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,oBAAoB;CACrB,CAAA","sourcesContent":["import { ArenaAnyExpressionNode, ExpressionNodeType } from '../../expression'\nimport { parseExpression } from '../../expression/javascript/evaluator'\nimport { ArenaAnyNodeDef, NodeDefs } from '../../nodeDef'\nimport { SurveyDependencyType } from '../../survey/survey'\n\n/**\n * True if the identifier is used as (or inside) the property of a member expression (e.g. \"dbh\" in\n * \"parent(tree).tree.dbh\" or in \"tree[dbh > 10]\"): there it can refer to nodes outside the context entity.\n */\nconst isReferencedThroughMember = (params: {\n expressionNode: unknown\n name: string\n inMemberProperty: boolean\n}): boolean => {\n const { expressionNode, name, inMemberProperty } = params\n if (!expressionNode || typeof expressionNode !== 'object') return false\n if (Array.isArray(expressionNode)) {\n return expressionNode.some((item) => isReferencedThroughMember({ expressionNode: item, name, inMemberProperty }))\n }\n // parsed expression nodes (or their array or object properties)\n const node = expressionNode as ArenaAnyExpressionNode\n if (node.type === ExpressionNodeType.Identifier) {\n return inMemberProperty && node.name === name\n }\n if (node.type === ExpressionNodeType.Member) {\n const { object, property } = node\n return (\n isReferencedThroughMember({ expressionNode: object, name, inMemberProperty }) ||\n isReferencedThroughMember({ expressionNode: property, name, inMemberProperty: true })\n )\n }\n return Object.values(expressionNode).some((child) =>\n isReferencedThroughMember({ expressionNode: child, name, inMemberProperty })\n )\n}\n\nconst isExpressionSelfReferenceLocal = (params: { expression: string | undefined; name: string }): boolean => {\n const { expression, name } = params\n if (!expression) return true\n try {\n return !isReferencedThroughMember({ expressionNode: parseExpression(expression), name, inMemberProperty: false })\n } catch {\n // invalid expression: be conservative\n return false\n }\n}\n\n/**\n * Returns true if the node def references itself in its expressions of the specified dependency type only\n * as a plain identifier (e.g. \"dbh > 0\" in a validation of \"dbh\"): such a reference is resolved among the\n * children of the node's parent entity, so only the node and its siblings depend on it, not every node with\n * the same node def in the record.\n */\nconst isSelfReferenceLocal = (params: { nodeDef: ArenaAnyNodeDef; dependencyType: SurveyDependencyType }): boolean => {\n const { nodeDef, dependencyType } = params\n // self references by plain identifier are allowed only in validation expressions (see dependencies.ts)\n if (dependencyType !== SurveyDependencyType.validations) return false\n const name = NodeDefs.getName(nodeDef)\n return NodeDefs.getValidationsExpressions(nodeDef).every(\n ({ expression, applyIf }) =>\n isExpressionSelfReferenceLocal({ expression, name }) &&\n isExpressionSelfReferenceLocal({ expression: applyIf, name })\n )\n}\n\nexport const NodeDefSelfReferences = {\n isSelfReferenceLocal,\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"recordCompletion.js","sourceRoot":"","sources":["../../../../src/record/_records/recordCompletion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,WAAW,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,EAAmC,QAAQ,EAAe,MAAM,eAAe,CAAA;AACtF,OAAO,EAAe,OAAO,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAOhE,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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C;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED,MAAM,mBAAmB,GAAG,CAAC,KAA4B,EAAU,EAAE;IACnE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAA;IAC/B,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,GAAG,CAAA;IAC1B,OAAO,OAAO,CAAC,gBAAgB,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAA;AAC5D,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,MAI1C,EAAU,EAAE,CAAC,mBAAmB,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,CAAA;AAEnE;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,MAI7C,EAAU,EAAE,CAAC,mBAAmB,CAAC,wBAAwB,iCAAM,MAAM,KAAE,qBAAqB,EAAE,KAAK,IAAG,CAAC,CAAA;AAExG;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,MAAoD,EAAU,EAAE;IACzG,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IACjC,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAClC,OAAO,UAAU,CAAC,CAAC,CAAC,0BAA0B,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC5F,CAAC,CAAA","sourcesContent":["import { ArenaRecordNode, RecordNodes } from '../../node'\nimport { ArenaNodeDef, ArenaNodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { ArenaSurvey, Surveys } from '../../survey'\nimport { Numbers } from '../../utils'\nimport { ArenaRecord } from '../record'\nimport { getChildren, getCycle, 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 isAttributeRequired = (entity: ArenaRecordNode, nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>): boolean =>\n NodeDefs.isKey(nodeDef) ||\n NodeDefs.isRequired(nodeDef) ||\n (NodeDefs.isRequiredIfDefined(nodeDef) && RecordNodes.isChildRequired(entity, nodeDef.uuid))\n\nconst getAttributeCompletionStats = (params: {\n record: ArenaRecord\n entity: ArenaRecordNode\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n}): EntityCompletionStats => {\n const { record, entity, nodeDef } = params\n\n if (NodeDefs.isMultiple(nodeDef)) {\n const minCount = RecordNodes.getChildrenMinCount({ parentNode: entity, nodeDef })\n if (Number.isNaN(minCount) || minCount <= 0) return emptyStats()\n\n const filledNodesCount = getChildren(entity, nodeDef.uuid)(record).filter(RecordNodes.isValueNotBlank).length\n\n return { total: minCount, filled: Math.min(filledNodesCount, minCount) }\n }\n\n if (!isAttributeRequired(entity, nodeDef)) return emptyStats()\n\n const node = getChildren(entity, nodeDef.uuid)(record)[0]\n return { total: 1, filled: node && RecordNodes.isValueNotBlank(node) ? 1 : 0 }\n}\n\nconst getChildEntityCompletionStats = (params: {\n survey: ArenaSurvey\n record: ArenaRecord\n parentEntity: ArenaRecordNode\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\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 = RecordNodes.getChildrenMinCount({ parentNode: parentEntity, nodeDef })\n const minCount = Number.isNaN(minCountRaw) ? 0 : Math.max(minCountRaw, 0)\n\n const stats = emptyStats()\n // entities added beyond the min count are still expected to be complete\n for (const childEntity of childEntities) {\n addStats(stats, getEntityCompletionStats({ survey, record, entity: childEntity }))\n }\n // a missing repetition (below the min count) counts as a single incomplete unit\n stats.total += Math.max(minCount - childEntities.length, 0)\n return stats\n}\n\nexport const getEntityCompletionStats = (params: {\n survey: ArenaSurvey\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 }).filter(\n NodeDefs.isInCycle(getCycle(record))\n )\n\n const stats = emptyStats()\n for (const childDef of childDefs) {\n if (!RecordNodes.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 RecordNodes.getChildrenMinCount).\n */\nexport const getEntityCompletionPercent = (params: {\n survey: ArenaSurvey\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: ArenaSurvey\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: ArenaSurvey; 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
+ {"version":3,"file":"recordCompletion.js","sourceRoot":"","sources":["../../../../src/record/_records/recordCompletion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,WAAW,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,EAAmB,QAAQ,EAAE,MAAM,eAAe,CAAA;AACzD,OAAO,EAAe,OAAO,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAOhE,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,mBAAmB,GAAG,CAAC,MAAuB,EAAE,OAAwB,EAAW,EAAE,CACzF,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC;IACvB,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC;IAC5B,CAAC,QAAQ,CAAC,mBAAmB,CAAC,OAAO,CAAC,IAAI,WAAW,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;AAE9F,MAAM,2BAA2B,GAAG,CAAC,MA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,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,CAAA;AAEnE;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,MAI7C,EAAU,EAAE,CAAC,mBAAmB,CAAC,wBAAwB,iCAAM,MAAM,KAAE,qBAAqB,EAAE,KAAK,IAAG,CAAC,CAAA;AAExG;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,MAAoD,EAAU,EAAE;IACzG,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IACjC,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAClC,OAAO,UAAU,CAAC,CAAC,CAAC,0BAA0B,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC5F,CAAC,CAAA","sourcesContent":["import { ArenaRecordNode, RecordNodes } from '../../node'\nimport { ArenaAnyNodeDef, NodeDefs } from '../../nodeDef'\nimport { ArenaSurvey, Surveys } from '../../survey'\nimport { Numbers } from '../../utils'\nimport { ArenaRecord } from '../record'\nimport { getChildren, getCycle, 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 isAttributeRequired = (entity: ArenaRecordNode, nodeDef: ArenaAnyNodeDef): boolean =>\n NodeDefs.isKey(nodeDef) ||\n NodeDefs.isRequired(nodeDef) ||\n (NodeDefs.isRequiredIfDefined(nodeDef) && RecordNodes.isChildRequired(entity, nodeDef.uuid))\n\nconst getAttributeCompletionStats = (params: {\n record: ArenaRecord\n entity: ArenaRecordNode\n nodeDef: ArenaAnyNodeDef\n}): EntityCompletionStats => {\n const { record, entity, nodeDef } = params\n\n if (NodeDefs.isMultiple(nodeDef)) {\n const minCount = RecordNodes.getChildrenMinCount({ parentNode: entity, nodeDef })\n if (Number.isNaN(minCount) || minCount <= 0) return emptyStats()\n\n const filledNodesCount = getChildren(entity, nodeDef.uuid)(record).filter(RecordNodes.isValueNotBlank).length\n\n return { total: minCount, filled: Math.min(filledNodesCount, minCount) }\n }\n\n if (!isAttributeRequired(entity, nodeDef)) return emptyStats()\n\n const node = getChildren(entity, nodeDef.uuid)(record)[0]\n return { total: 1, filled: node && RecordNodes.isValueNotBlank(node) ? 1 : 0 }\n}\n\nconst getChildEntityCompletionStats = (params: {\n survey: ArenaSurvey\n record: ArenaRecord\n parentEntity: ArenaRecordNode\n nodeDef: ArenaAnyNodeDef\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 = RecordNodes.getChildrenMinCount({ parentNode: parentEntity, nodeDef })\n const minCount = Number.isNaN(minCountRaw) ? 0 : Math.max(minCountRaw, 0)\n\n const stats = emptyStats()\n // entities added beyond the min count are still expected to be complete\n for (const childEntity of childEntities) {\n addStats(stats, getEntityCompletionStats({ survey, record, entity: childEntity }))\n }\n // a missing repetition (below the min count) counts as a single incomplete unit\n stats.total += Math.max(minCount - childEntities.length, 0)\n return stats\n}\n\nexport const getEntityCompletionStats = (params: {\n survey: ArenaSurvey\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 }).filter(\n NodeDefs.isInCycle(getCycle(record))\n )\n\n const stats = emptyStats()\n for (const childDef of childDefs) {\n if (!RecordNodes.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 RecordNodes.getChildrenMinCount).\n */\nexport const getEntityCompletionPercent = (params: {\n survey: ArenaSurvey\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: ArenaSurvey\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: ArenaSurvey; 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 +1 @@
1
- {"version":3,"file":"recordGetters.js","sourceRoot":"","sources":["../../../../src/record/_records/recordGetters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAE,MAAM,cAAc,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAA2C,WAAW,EAAuB,MAAM,YAAY,CAAA;AACtG,OAAO,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AAC,IAAqB,EAAE,EAAE,CAC1B,CAAC,MAAmB,EAAW,EAAE,CAC/B,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AAErG,MAAM,CAAC,MAAM,WAAW,GACtB,CAAC,IAAqB,EAAE,EAAE,CAC1B,CAAC,MAAmB,EAAW,EAAE,CAC/B,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAA;AAErC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,MAAmB,EAAW,EAAE;IACtD,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAChC,OAAO,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACxD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,MAAmB,EAAU,EAAE,wBAAC,MAAM,CAAC,IAAI,mCAAI,mBAAmB,GAAA,CAAA;AAE1F,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAmB,EAAW,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,sBAAsB,CAAA","sourcesContent":["import { ArenaDictionary, TraverseMethod } from '../../common'\nimport { SystemError, SystemErrorKeys } from '../../error'\nimport { ArenaRecordNode, ArenaRecordNodePointer, RecordNodes, ArenaRecordNodesMap } from '../../node'\nimport { RecordNodeValues } from '../../node/nodeValues'\nimport {\n ArenaNodeDef,\n ArenaNodeDefCode,\n ArenaNodeDefCodeProps,\n ArenaNodeDefProps,\n NodeDefs,\n NodeDefType,\n} from '../../nodeDef'\nimport { defaultCycle, Surveys } from '../../survey'\nimport { ArenaSurvey, SurveyDependencyType } from '../../survey/survey'\nimport { Arrays, Queue } from '../../utils'\nimport { ArenaRecord, RECORD_STEP_DEFAULT, RecordNodesIndex } from '../record'\nimport { RecordStepAnalysisCode } from '../recordStep'\nimport { RecordNodesIndexReader } from './recordNodesIndexReader'\nimport { RecordNodesIndexUpdater } from './recordNodesIndexUpdater'\nimport { NodeDefSelfReferences } from './nodeDefSelfReferences'\n\nexport const getCycle = (record: ArenaRecord): string => record.cycle ?? defaultCycle\n\nexport const getNodes = (record: ArenaRecord): ArenaDictionary<ArenaRecordNode> => record.nodes ?? {}\n\nexport const getNodesArray = (record: ArenaRecord): ArenaRecordNode[] => Object.values(getNodes(record))\n\n/**\n * Returns the nodes index of the record or, if missing, a new index built from all the record nodes (not stored in the record).\n * To be used before updating the index: a partial index would be trusted by the getters.\n */\nexport const getNodesIndexOrBuild = (record: ArenaRecord): RecordNodesIndex =>\n record._nodesIndex ?? RecordNodesIndexUpdater.initializeIndex(record)\n\n/**\n * Returns the node with the specified uuid, or undefined if not found.\n * Like the other node getters, it does not throw an error when the node is not found.\n */\nexport const getNodeByUuid =\n (uuid: string) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n record.nodes?.[uuid]\n\nexport const getNodesByUuids =\n (uuids: string[]) =>\n (record: ArenaRecord): ArenaRecordNode[] =>\n uuids.map((uuid: string) => record.nodes?.[uuid]) as ArenaRecordNode[]\n\n/**\n * Returns the root node, or undefined if the record has no nodes.\n */\nexport const getRoot = (record: ArenaRecord): ArenaRecordNode | undefined => {\n const rootUuid = record._nodesIndex ? RecordNodesIndexReader.getNodeRootUuid(record._nodesIndex) : null\n if (rootUuid) {\n return getNodeByUuid(rootUuid)(record)\n }\n return getNodesArray(record).find((node) => !node.parentUuid)\n}\n\nexport const getChildren =\n (parentNode: ArenaRecordNode, childDefUuid?: string) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const childrenUuids = childDefUuid\n ? RecordNodesIndexReader.getNodeUuidsByParentAndChildDef({\n parentNodeUuid: parentNode.uuid,\n childDefUuid,\n })(record._nodesIndex)\n : RecordNodesIndexReader.getNodeUuidsByParent(parentNode.uuid)(record._nodesIndex)\n return getNodesByUuids(childrenUuids)(record)\n }\n return getNodesArray(record).filter(\n (node) => node.parentUuid === parentNode.uuid && (!childDefUuid || node.nodeDefUuid == childDefUuid)\n )\n }\n\n/**\n * Returns the only child of the parent node with the specified node def, or undefined if not found.\n * Throws an error if more than one child is found.\n */\nexport const getChild =\n (parentNode: ArenaRecordNode, childDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const children = getChildren(parentNode, childDefUuid)(record)\n if (children.length > 1) {\n const errorParams = { childDefUuid, parentNodeUuid: parentNode.uuid, recordUuid: record.uuid }\n throw new SystemError(SystemErrorKeys.record.multipleNodesFound, errorParams)\n }\n return children[0]\n }\n\n// called for every ancestor in the record update loops: keep it a plain lookup\nconst getParentNode = (record: ArenaRecord, node: ArenaRecordNode): ArenaRecordNode | undefined =>\n node.parentUuid ? record.nodes?.[node.parentUuid] : undefined\n\nexport const getParent =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n getParentNode(record, node)\n\nexport const getNodesByDefUuid =\n (nodeDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeUuidsByDef(nodeDefUuid)(record._nodesIndex)\n return getNodesByUuids(nodeUuids)(record)\n }\n return getNodesArray(record).filter((node) => node.nodeDefUuid === nodeDefUuid)\n }\n\nconst isNodeFlagTrue =\n (isChildFlagTrue: (parent: ArenaRecordNode, nodeDefUuid: string) => boolean) =>\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean => {\n let child = node\n let parent = getParentNode(record, child)\n while (parent) {\n if (!isChildFlagTrue(parent, child.nodeDefUuid)) return false\n child = parent\n parent = getParentNode(record, child)\n }\n return true\n }\n\nexport const isNodeApplicable = isNodeFlagTrue((parent, nodeDefUuid) =>\n RecordNodes.isChildApplicable(parent, nodeDefUuid)\n)\nexport const isNodeEditable = isNodeFlagTrue((parent, nodeDefUuid) => RecordNodes.isChildEditable(parent, nodeDefUuid))\nexport const isNodeVisible = isNodeFlagTrue((parent, nodeDefUuid) => RecordNodes.isChildVisible(parent, nodeDefUuid))\n\n/**\n * Whether a value is required for the node: key or always required attribute, or attribute with a \"required if\"\n * condition met in its parent entity (evaluated condition stored in the parent node meta).\n */\nexport const isNodeRequired =\n (nodeDef: ArenaNodeDef<NodeDefType>, node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean => {\n if (NodeDefs.isKey(nodeDef) || NodeDefs.isRequired(nodeDef)) return true\n if (!NodeDefs.isRequiredIfDefined(nodeDef)) return false\n const parent = getParentNode(record, node)\n return !!parent && RecordNodes.isChildRequired(parent, nodeDef.uuid)\n }\n\nexport const getDependentCodeAttributes =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeCodeDependentUuids(node.uuid)(record._nodesIndex)\n return getNodesByUuids(nodeUuids)(record)\n }\n throw new SystemError(SystemErrorKeys.record.nodesIndexNotInitialized)\n }\n\nexport const getParentCodeAttribute =\n (parentNode: ArenaRecordNode, nodeDef: ArenaNodeDefCode) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(nodeDef)\n if (!parentCodeDefUuid) return undefined\n\n const ancestors = getAncestorsAndSelf(parentNode)(record)\n for (const ancestor of ancestors) {\n const children = getChildren(ancestor, parentCodeDefUuid)(record)\n if (children.length === 1) {\n return children[0]\n }\n }\n return undefined\n }\n\n// ancestors\n\n/**\n * Visits the specified node and its ancestors, from the node up to the root: the visit stops when the visitor returns true.\n */\nexport const visitAncestorsAndSelf =\n (node: ArenaRecordNode, visitor: (node: ArenaRecordNode) => boolean | void) =>\n (record: ArenaRecord): void => {\n let currentNode: ArenaRecordNode | undefined = node\n while (currentNode) {\n if (visitor(currentNode)) return\n currentNode = getParentNode(record, currentNode)\n }\n }\n\n/**\n * Returns the first node satisfying the predicate among the specified node and its ancestors (from the node up to the root).\n */\nexport const findAncestor =\n (node: ArenaRecordNode, predicate: (node: ArenaRecordNode) => boolean) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let result: ArenaRecordNode | undefined = undefined\n visitAncestorsAndSelf(node, (visitedNode) => {\n if (predicate(visitedNode)) {\n result = visitedNode\n return true\n }\n return false\n })(record)\n return result\n }\n\n/**\n * Returns the specified node, if it has the specified node def, or its ancestor with that node def; undefined if not found.\n */\nexport const getAncestor =\n (node: ArenaRecordNode, ancestorDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let ancestor: ArenaRecordNode | undefined = node\n while (ancestor && ancestor.nodeDefUuid !== ancestorDefUuid) {\n ancestor = getParentNode(record, ancestor)\n }\n return ancestor\n }\n\n/**\n * Returns the list of ancestors from the given node to the root entity\n */\nexport const getAncestorsAndSelf =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): Array<ArenaRecordNode> => {\n const ancestors: Array<ArenaRecordNode> = []\n let currentNode: ArenaRecordNode | undefined = node\n while (currentNode) {\n ancestors.push(currentNode)\n currentNode = getParentNode(record, currentNode)\n }\n return ancestors\n }\n\n// descendants\n\nexport const getDescendantsOrSelf =\n (node: ArenaRecordNode, nodeDefDescendant: ArenaNodeDef<any>) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (nodeDefDescendant.uuid === node.nodeDefUuid) return [node]\n\n const nodeDefDescendantFullHierarchy = [...nodeDefDescendant.meta.h, nodeDefDescendant.uuid]\n\n // 1. get the descendant node defs uuids starting from node nodeDefUuid (not inclusive) down to the specified nodeDefDescendant uuid\n const descendantNodeDefUuids = nodeDefDescendantFullHierarchy.slice(\n nodeDefDescendantFullHierarchy.indexOf(node.nodeDefUuid) + 1\n )\n // 2. for every level in the hierarchy, find the children having the nodeDefUuid equal to the current one\n let currentAncestors = [node]\n let currentDescendants: ArenaRecordNode[] = []\n for (const currentDescendantDefUuid of descendantNodeDefUuids) {\n for (const currentAncestor of currentAncestors) {\n for (const child of getChildren(currentAncestor, currentDescendantDefUuid)(record)) {\n currentDescendants.push(child)\n }\n }\n currentAncestors = currentDescendants\n currentDescendants = []\n }\n return currentAncestors // currentAncestors is equal to the currentDescendants of the last level\n }\n\n/**\n * Returns the first descendant (or the node itself) with the specified node def, or undefined if not found.\n */\nexport const getDescendant =\n (node: ArenaRecordNode, nodeDefDescendant: ArenaNodeDef<any>) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n getDescendantsOrSelf(node, nodeDefDescendant)(record)[0]\n\nexport const isDescendantOf = (node: ArenaRecordNode, ancestor: ArenaRecordNode): boolean =>\n RecordNodes.getHierarchy(node).includes(ancestor.uuid)\n\nexport const visitDescendantsAndSelf =\n (\n node: ArenaRecordNode,\n visitor: (node: ArenaRecordNode) => boolean | void,\n traverseMethod: TraverseMethod = TraverseMethod.bfs\n ) =>\n (record: ArenaRecord): void => {\n if (traverseMethod === TraverseMethod.bfs) {\n const queue = new Queue<ArenaRecordNode>()\n\n queue.enqueue(node)\n\n while (!queue.isEmpty()) {\n const visitedNode = queue.dequeue()!\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren(visitedNode)(record)\n queue.enqueueItems(children)\n }\n } else {\n const stack = []\n\n stack.push(node)\n\n while (stack.length > 0) {\n const visitedNode = stack.pop() as ArenaRecordNode\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren(visitedNode)(record)\n\n // add children to stack in reverse order\n for (let index = children.length - 1; index >= 0; index--) {\n const child = children[index]\n stack.push(child)\n }\n }\n }\n }\n\nexport const findDescendantOrSelf =\n (node: ArenaRecordNode, predicate: (node: ArenaRecordNode) => boolean) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let found = undefined\n\n visitDescendantsAndSelf(node, (currentNode) => {\n if (predicate(currentNode)) {\n found = currentNode\n return true\n }\n return false\n })(record)\n return found\n }\n\nconst getClosestAncestorNode =\n (\n node: ArenaRecordNode,\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>,\n dependentDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>,\n dependencyType: SurveyDependencyType\n ) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n // 1a if dependent def is the same as node def, potentially all nodes with\n // nodeDefUuid === dependentDef.uuid in record could be dependent of nodeDef;\n // consider the root node as the closest ancestor node,\n // unless the node def references itself only among the children of its parent entity (e.g. validation \"dbh > 0\")\n if (nodeDef.uuid === dependentDef.uuid) {\n return NodeDefSelfReferences.isSelfReferenceLocal({ nodeDef, dependencyType })\n ? getParent(node)(record)\n : getRoot(record)\n }\n // 1 find common ancestor def\n const commonAncestorDefUuid = Arrays.last(Arrays.intersection(nodeDef.meta.h, dependentDef.meta.h))\n if (!commonAncestorDefUuid) return undefined\n\n // 2 get ancestor node with common parent def\n return getAncestor(node, commonAncestorDefUuid)(record)\n }\n\ntype KeyDefs = ArenaNodeDef<NodeDefType, ArenaNodeDefProps>[]\n\n/**\n * Returns the key nodes of the entity, indexed by key def uuid; keyDefs, when specified, are used instead of the\n * entity def keys in the cycle.\n */\nexport const getEntityKeyNodesByDefUuid =\n (survey: ArenaSurvey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): ArenaRecordNodesMap => {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const nodeDefKeys = keyDefs ?? Surveys.getNodeDefKeys({ survey, cycle, nodeDef })\n return nodeDefKeys.reduce((acc: ArenaRecordNodesMap, nodeDefKey) => {\n const nodeKey = getDescendant(entity, nodeDefKey)(record)\n // missing key nodes are kept as undefined entries\n acc[nodeDefKey.uuid] = nodeKey as ArenaRecordNode\n return acc\n }, {})\n }\n\nexport const getEntityKeyNodes =\n (survey: ArenaSurvey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): ArenaRecordNode[] =>\n Object.values(getEntityKeyNodesByDefUuid(survey, entity, cycle, keyDefs)(record))\n\nexport const getEntityKeyValuesByDefUuid =\n (survey: ArenaSurvey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): ArenaDictionary<any> => {\n const keyNodesByDefUuid = getEntityKeyNodesByDefUuid(survey, entity, cycle, keyDefs)(record)\n return Object.entries(keyNodesByDefUuid).reduce((acc: ArenaDictionary<any>, [uuid, keyNode]) => {\n acc[uuid] = keyNode?.value\n return acc\n }, {})\n }\n\nexport const getEntityKeyValues =\n (survey: ArenaSurvey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): any[] =>\n Object.values(getEntityKeyValuesByDefUuid(survey, entity, cycle, keyDefs)(record))\n\nexport const getEntitySiblings =\n (entity: ArenaRecordNode, includeSelf = false) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n const parentEntity = getParent(entity)(record)\n if (!parentEntity) return []\n const siblingEntities = getChildren(parentEntity, entity.nodeDefUuid)(record)\n return includeSelf ? siblingEntities : siblingEntities.filter((sibling) => !RecordNodes.areEqual(sibling, entity))\n }\n\nexport const getAttributeSiblings =\n (node: ArenaRecordNode, nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n const parentEntity = getParent(node)(record)\n if (!parentEntity) return []\n const siblingParentEntities = getEntitySiblings(parentEntity)(record)\n return siblingParentEntities.reduce((siblingsAcc: ArenaRecordNode[], siblingEntity) => {\n for (const sibling of getChildren(siblingEntity, nodeDef.uuid)(record)) {\n siblingsAcc.push(sibling)\n }\n return siblingsAcc\n }, [])\n }\n\nexport const getNodeIndex = (node: ArenaRecordNode) => (record: ArenaRecord) => {\n const parentEntity = getParent(node)(record)\n if (!parentEntity) return 0 // root entity\n const siblings = getChildren(parentEntity, node.nodeDefUuid)(record)\n // compared by uuid: the specified node can be a copy of the one in the record (e.g. an updated version of it)\n return siblings.findIndex((sibling) => sibling.uuid === node.uuid)\n}\n\nexport const findEntityByKeyValues =\n (\n survey: ArenaSurvey,\n cycle: string,\n parentEntity: ArenaRecordNode,\n entityDefUuid: string,\n keyValuesByDefUuid: ArenaDictionary<any>\n ) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entityDefUuid })\n const siblingEntities = getChildren(parentEntity, entityDefUuid)(record)\n if (NodeDefs.isSingle(entityDef)) {\n return siblingEntities[0]\n }\n const keyDefs = Surveys.getNodeDefKeys({ survey, cycle, nodeDef: entityDef })\n\n return siblingEntities.find((siblingEntity) => {\n const siblingEntityKeyValuesByDefUuid = getEntityKeyValuesByDefUuid(\n survey,\n siblingEntity,\n undefined,\n keyDefs\n )(record)\n return keyDefs.every((keyDef) => {\n const keyValue = siblingEntityKeyValuesByDefUuid[keyDef.uuid]\n const keyValueSearch = keyValuesByDefUuid[keyDef.uuid]\n return RecordNodeValues.isValueEqual({\n survey,\n nodeDef: keyDef,\n value: keyValue,\n valueSearch: keyValueSearch,\n })\n })\n })\n }\n\nexport const findEntityWithSameKeysInAnotherRecord =\n (survey: ArenaSurvey, cycle: string, entityUuid: string, recordOther: ArenaRecord) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const entity = getNodeByUuid(entityUuid)(record)\n if (!entity) return undefined\n\n let otherRecordCurrentParentEntity = getRoot(recordOther)\n if (!otherRecordCurrentParentEntity) return undefined\n\n const entityAncestorsAndSelf = getAncestorsAndSelf(entity)(record)\n const ancestorDefUuidsAndKeys = entityAncestorsAndSelf.map((ancestor) => ({\n entityDefUuid: ancestor.nodeDefUuid,\n keyValuesByDefUuid: getEntityKeyValuesByDefUuid(survey, ancestor)(record),\n }))\n\n const ancestorDefUuidsAndKeysToVisit = [...ancestorDefUuidsAndKeys].reverse()\n\n for (let index = 1; otherRecordCurrentParentEntity && index < ancestorDefUuidsAndKeysToVisit.length; index++) {\n const { entityDefUuid, keyValuesByDefUuid } = ancestorDefUuidsAndKeysToVisit[index]\n otherRecordCurrentParentEntity = findEntityByKeyValues(\n survey,\n cycle,\n otherRecordCurrentParentEntity,\n entityDefUuid,\n keyValuesByDefUuid\n )(recordOther)\n }\n return otherRecordCurrentParentEntity\n }\n\nexport const getDependentNodePointers =\n (\n survey: ArenaSurvey,\n node: ArenaRecordNode,\n dependencyType: SurveyDependencyType,\n includeSelf = false,\n filterFn: ((nodePointer: ArenaRecordNodePointer) => boolean) | null = null\n ) =>\n (record: ArenaRecord): ArenaRecordNodePointer[] => {\n const nodeDefUuid = node.nodeDefUuid\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: nodeDefUuid })\n const dependentDefs = Surveys.getNodeDefDependents({ survey, nodeDefUuid, dependencyType })\n const nodePointers: Array<ArenaRecordNodePointer> = []\n\n const addToNodePointers = (nodePointer: ArenaRecordNodePointer): void => {\n if (filterFn === null || filterFn(nodePointer)) {\n nodePointers.push(nodePointer)\n }\n }\n\n for (const dependentDef of dependentDefs) {\n // 1 find common ancestor node\n const commonAncestorNode = getClosestAncestorNode(node, nodeDef, dependentDef, dependencyType)(record)\n if (!commonAncestorNode) continue\n\n const nodeDefDependentParent = Surveys.getNodeDefParent({ survey, nodeDef: dependentDef })\n if (!nodeDefDependentParent) throw new SystemError(SystemErrorKeys.record.dependencyOnRootFound)\n\n // 2 find descendant nodes of common parent node with nodeDefUuid = dependentDef uuid\n const dependentContextNodes = getDescendantsOrSelf(commonAncestorNode, nodeDefDependentParent)(record)\n\n for (const dependentContextNode of dependentContextNodes) {\n addToNodePointers({\n nodeCtx: dependentContextNode,\n nodeDef: dependentDef,\n })\n }\n }\n if (includeSelf) {\n const parentNode = getParent(node)(record)\n if (parentNode) {\n addToNodePointers({\n nodeCtx: parentNode,\n nodeDef,\n })\n }\n }\n\n return nodePointers\n }\n\n/**\n * Returns the code attributes the specified code attribute depends on, from the top level one to the parent one.\n */\nexport const getAncestorCodeAttributes =\n (survey: ArenaSurvey, parentNode: ArenaRecordNode, nodeDef: ArenaNodeDefCode) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n const ancestorCodeAttributes = []\n let currentParentCodeAttribute = getParentCodeAttribute(parentNode, nodeDef)(record)\n while (currentParentCodeAttribute) {\n ancestorCodeAttributes.unshift(currentParentCodeAttribute)\n const ancestorCodeDef = Surveys.getNodeDefByUuid({\n survey,\n uuid: currentParentCodeAttribute.nodeDefUuid,\n }) as ArenaNodeDefCode\n currentParentCodeAttribute = getParentCodeAttribute(parentNode, ancestorCodeDef)(record)\n }\n return ancestorCodeAttributes\n }\n\nexport const getAncestorCodePath =\n (survey: ArenaSurvey, parentNode: ArenaRecordNode, nodeDef: ArenaNodeDef<NodeDefType.code, ArenaNodeDefCodeProps>) =>\n (record: ArenaRecord): string[] =>\n getAncestorCodeAttributes(\n survey,\n parentNode,\n nodeDef\n )(record).map((codeAttribute) => {\n const codeItemUuid = RecordNodeValues.getItemUuid(codeAttribute)\n if (!codeItemUuid) return ''\n // items of big categories are not in the survey ref data: they can be in the node ref data\n const item =\n codeAttribute.refData?.categoryItem ?? Surveys.getCategoryItemByUuid({ survey, itemUuid: codeItemUuid })\n return item?.props.code ?? ''\n })\n\nexport const getCategoryItemUuid =\n (\n survey: ArenaSurvey,\n nodeDef: ArenaNodeDef<NodeDefType.code, ArenaNodeDefCodeProps>,\n parentNode: ArenaRecordNode,\n code: string\n ) =>\n (record: ArenaRecord): string | undefined => {\n const categoryUuid = nodeDef.props.categoryUuid\n\n const codePaths = [...getAncestorCodePath(survey, parentNode, nodeDef)(record), code]\n\n const item = Surveys.getCategoryItemByCodePaths({ survey, categoryUuid, codePaths })\n\n return item?.uuid\n }\n\nexport const isNodeFilledByUser =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean =>\n !!findDescendantOrSelf(node, (visitedNode) => RecordNodes.hasUserInputValue(visitedNode))(record)\n\nexport const isNodeEmpty =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean =>\n !isNodeFilledByUser(node)(record)\n\nexport const isEmpty = (record: ArenaRecord): boolean => {\n const rootNode = getRoot(record)\n return rootNode ? isNodeEmpty(rootNode)(record) : true\n}\n\nexport const getStep = (record: ArenaRecord): string => record.step ?? RECORD_STEP_DEFAULT\n\nexport const isInAnalysisStep = (record: ArenaRecord): boolean => getStep(record) === RecordStepAnalysisCode\n"]}
1
+ {"version":3,"file":"recordGetters.js","sourceRoot":"","sources":["../../../../src/record/_records/recordGetters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAE,MAAM,cAAc,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAA2C,WAAW,EAAuB,MAAM,YAAY,CAAA;AACtG,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAKL,QAAQ,GAET,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEpD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAe,mBAAmB,EAAoB,MAAM,WAAW,CAAA;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAE/D,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAmB,EAAU,EAAE,wBAAC,MAAM,CAAC,KAAK,mCAAI,YAAY,GAAA,CAAA;AAErF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAmB,EAAoC,EAAE,wBAAC,MAAM,CAAC,KAAK,mCAAI,EAAE,GAAA,CAAA;AAErG,MAAM,CAA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E1F,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAmB,EAAW,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,sBAAsB,CAAA","sourcesContent":["import { ArenaDictionary, TraverseMethod } from '../../common'\nimport { SystemError, SystemErrorKeys } from '../../error'\nimport { ArenaRecordNode, ArenaRecordNodePointer, RecordNodes, ArenaRecordNodesMap } from '../../node'\nimport { RecordNodeValues } from '../../node/nodeValues'\nimport {\n ArenaAnyNodeDef,\n ArenaNodeDef,\n ArenaNodeDefCode,\n ArenaNodeDefCodeProps,\n NodeDefs,\n NodeDefType,\n} from '../../nodeDef'\nimport { defaultCycle, Surveys } from '../../survey'\nimport { ArenaSurvey, SurveyDependencyType } from '../../survey/survey'\nimport { Arrays, Queue } from '../../utils'\nimport { ArenaRecord, RECORD_STEP_DEFAULT, RecordNodesIndex } from '../record'\nimport { RecordStepAnalysisCode } from '../recordStep'\nimport { RecordNodesIndexReader } from './recordNodesIndexReader'\nimport { RecordNodesIndexUpdater } from './recordNodesIndexUpdater'\nimport { NodeDefSelfReferences } from './nodeDefSelfReferences'\n\nexport const getCycle = (record: ArenaRecord): string => record.cycle ?? defaultCycle\n\nexport const getNodes = (record: ArenaRecord): ArenaDictionary<ArenaRecordNode> => record.nodes ?? {}\n\nexport const getNodesArray = (record: ArenaRecord): ArenaRecordNode[] => Object.values(getNodes(record))\n\n/**\n * Returns the nodes index of the record or, if missing, a new index built from all the record nodes (not stored in the record).\n * To be used before updating the index: a partial index would be trusted by the getters.\n */\nexport const getNodesIndexOrBuild = (record: ArenaRecord): RecordNodesIndex =>\n record._nodesIndex ?? RecordNodesIndexUpdater.initializeIndex(record)\n\n/**\n * Returns the node with the specified uuid, or undefined if not found.\n * Like the other node getters, it does not throw an error when the node is not found.\n */\nexport const getNodeByUuid =\n (uuid: string) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n record.nodes?.[uuid]\n\nexport const getNodesByUuids =\n (uuids: string[]) =>\n (record: ArenaRecord): ArenaRecordNode[] =>\n uuids.map((uuid: string) => record.nodes?.[uuid]) as ArenaRecordNode[]\n\n/**\n * Returns the root node, or undefined if the record has no nodes.\n */\nexport const getRoot = (record: ArenaRecord): ArenaRecordNode | undefined => {\n const rootUuid = record._nodesIndex ? RecordNodesIndexReader.getNodeRootUuid(record._nodesIndex) : null\n if (rootUuid) {\n return getNodeByUuid(rootUuid)(record)\n }\n return getNodesArray(record).find((node) => !node.parentUuid)\n}\n\nexport const getChildren =\n (parentNode: ArenaRecordNode, childDefUuid?: string) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const childrenUuids = childDefUuid\n ? RecordNodesIndexReader.getNodeUuidsByParentAndChildDef({\n parentNodeUuid: parentNode.uuid,\n childDefUuid,\n })(record._nodesIndex)\n : RecordNodesIndexReader.getNodeUuidsByParent(parentNode.uuid)(record._nodesIndex)\n return getNodesByUuids(childrenUuids)(record)\n }\n return getNodesArray(record).filter(\n (node) => node.parentUuid === parentNode.uuid && (!childDefUuid || node.nodeDefUuid == childDefUuid)\n )\n }\n\n/**\n * Returns the only child of the parent node with the specified node def, or undefined if not found.\n * Throws an error if more than one child is found.\n */\nexport const getChild =\n (parentNode: ArenaRecordNode, childDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const children = getChildren(parentNode, childDefUuid)(record)\n if (children.length > 1) {\n const errorParams = { childDefUuid, parentNodeUuid: parentNode.uuid, recordUuid: record.uuid }\n throw new SystemError(SystemErrorKeys.record.multipleNodesFound, errorParams)\n }\n return children[0]\n }\n\n// called for every ancestor in the record update loops: keep it a plain lookup\nconst getParentNode = (record: ArenaRecord, node: ArenaRecordNode): ArenaRecordNode | undefined =>\n node.parentUuid ? record.nodes?.[node.parentUuid] : undefined\n\nexport const getParent =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n getParentNode(record, node)\n\nexport const getNodesByDefUuid =\n (nodeDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeUuidsByDef(nodeDefUuid)(record._nodesIndex)\n return getNodesByUuids(nodeUuids)(record)\n }\n return getNodesArray(record).filter((node) => node.nodeDefUuid === nodeDefUuid)\n }\n\nconst isNodeFlagTrue =\n (isChildFlagTrue: (parent: ArenaRecordNode, nodeDefUuid: string) => boolean) =>\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean => {\n let child = node\n let parent = getParentNode(record, child)\n while (parent) {\n if (!isChildFlagTrue(parent, child.nodeDefUuid)) return false\n child = parent\n parent = getParentNode(record, child)\n }\n return true\n }\n\nexport const isNodeApplicable = isNodeFlagTrue((parent, nodeDefUuid) =>\n RecordNodes.isChildApplicable(parent, nodeDefUuid)\n)\nexport const isNodeEditable = isNodeFlagTrue((parent, nodeDefUuid) => RecordNodes.isChildEditable(parent, nodeDefUuid))\nexport const isNodeVisible = isNodeFlagTrue((parent, nodeDefUuid) => RecordNodes.isChildVisible(parent, nodeDefUuid))\n\n/**\n * Whether a value is required for the node: key or always required attribute, or attribute with a \"required if\"\n * condition met in its parent entity (evaluated condition stored in the parent node meta).\n */\nexport const isNodeRequired =\n (nodeDef: ArenaAnyNodeDef, node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean => {\n if (NodeDefs.isKey(nodeDef) || NodeDefs.isRequired(nodeDef)) return true\n if (!NodeDefs.isRequiredIfDefined(nodeDef)) return false\n const parent = getParentNode(record, node)\n return !!parent && RecordNodes.isChildRequired(parent, nodeDef.uuid)\n }\n\nexport const getDependentCodeAttributes =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeCodeDependentUuids(node.uuid)(record._nodesIndex)\n return getNodesByUuids(nodeUuids)(record)\n }\n throw new SystemError(SystemErrorKeys.record.nodesIndexNotInitialized)\n }\n\nexport const getParentCodeAttribute =\n (parentNode: ArenaRecordNode, nodeDef: ArenaNodeDefCode) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(nodeDef)\n if (!parentCodeDefUuid) return undefined\n\n const ancestors = getAncestorsAndSelf(parentNode)(record)\n for (const ancestor of ancestors) {\n const children = getChildren(ancestor, parentCodeDefUuid)(record)\n if (children.length === 1) {\n return children[0]\n }\n }\n return undefined\n }\n\n// ancestors\n\n/**\n * Visits the specified node and its ancestors, from the node up to the root: the visit stops when the visitor returns true.\n */\nexport const visitAncestorsAndSelf =\n (node: ArenaRecordNode, visitor: (node: ArenaRecordNode) => boolean | void) =>\n (record: ArenaRecord): void => {\n let currentNode: ArenaRecordNode | undefined = node\n while (currentNode) {\n if (visitor(currentNode)) return\n currentNode = getParentNode(record, currentNode)\n }\n }\n\n/**\n * Returns the first node satisfying the predicate among the specified node and its ancestors (from the node up to the root).\n */\nexport const findAncestor =\n (node: ArenaRecordNode, predicate: (node: ArenaRecordNode) => boolean) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let result: ArenaRecordNode | undefined = undefined\n visitAncestorsAndSelf(node, (visitedNode) => {\n if (predicate(visitedNode)) {\n result = visitedNode\n return true\n }\n return false\n })(record)\n return result\n }\n\n/**\n * Returns the specified node, if it has the specified node def, or its ancestor with that node def; undefined if not found.\n */\nexport const getAncestor =\n (node: ArenaRecordNode, ancestorDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let ancestor: ArenaRecordNode | undefined = node\n while (ancestor && ancestor.nodeDefUuid !== ancestorDefUuid) {\n ancestor = getParentNode(record, ancestor)\n }\n return ancestor\n }\n\n/**\n * Returns the list of ancestors from the given node to the root entity\n */\nexport const getAncestorsAndSelf =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): Array<ArenaRecordNode> => {\n const ancestors: Array<ArenaRecordNode> = []\n let currentNode: ArenaRecordNode | undefined = node\n while (currentNode) {\n ancestors.push(currentNode)\n currentNode = getParentNode(record, currentNode)\n }\n return ancestors\n }\n\n// descendants\n\nexport const getDescendantsOrSelf =\n (node: ArenaRecordNode, nodeDefDescendant: ArenaNodeDef<any>) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (nodeDefDescendant.uuid === node.nodeDefUuid) return [node]\n\n const nodeDefDescendantFullHierarchy = [...nodeDefDescendant.meta.h, nodeDefDescendant.uuid]\n\n // 1. get the descendant node defs uuids starting from node nodeDefUuid (not inclusive) down to the specified nodeDefDescendant uuid\n const descendantNodeDefUuids = nodeDefDescendantFullHierarchy.slice(\n nodeDefDescendantFullHierarchy.indexOf(node.nodeDefUuid) + 1\n )\n // 2. for every level in the hierarchy, find the children having the nodeDefUuid equal to the current one\n let currentAncestors = [node]\n let currentDescendants: ArenaRecordNode[] = []\n for (const currentDescendantDefUuid of descendantNodeDefUuids) {\n for (const currentAncestor of currentAncestors) {\n for (const child of getChildren(currentAncestor, currentDescendantDefUuid)(record)) {\n currentDescendants.push(child)\n }\n }\n currentAncestors = currentDescendants\n currentDescendants = []\n }\n return currentAncestors // currentAncestors is equal to the currentDescendants of the last level\n }\n\n/**\n * Returns the first descendant (or the node itself) with the specified node def, or undefined if not found.\n */\nexport const getDescendant =\n (node: ArenaRecordNode, nodeDefDescendant: ArenaNodeDef<any>) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n getDescendantsOrSelf(node, nodeDefDescendant)(record)[0]\n\nexport const isDescendantOf = (node: ArenaRecordNode, ancestor: ArenaRecordNode): boolean =>\n RecordNodes.getHierarchy(node).includes(ancestor.uuid)\n\nexport const visitDescendantsAndSelf =\n (\n node: ArenaRecordNode,\n visitor: (node: ArenaRecordNode) => boolean | void,\n traverseMethod: TraverseMethod = TraverseMethod.bfs\n ) =>\n (record: ArenaRecord): void => {\n if (traverseMethod === TraverseMethod.bfs) {\n const queue = new Queue<ArenaRecordNode>()\n\n queue.enqueue(node)\n\n while (!queue.isEmpty()) {\n const visitedNode = queue.dequeue()!\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren(visitedNode)(record)\n queue.enqueueItems(children)\n }\n } else {\n const stack = []\n\n stack.push(node)\n\n while (stack.length > 0) {\n const visitedNode = stack.pop() as ArenaRecordNode\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren(visitedNode)(record)\n\n // add children to stack in reverse order\n for (let index = children.length - 1; index >= 0; index--) {\n const child = children[index]\n stack.push(child)\n }\n }\n }\n }\n\nexport const findDescendantOrSelf =\n (node: ArenaRecordNode, predicate: (node: ArenaRecordNode) => boolean) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let found = undefined\n\n visitDescendantsAndSelf(node, (currentNode) => {\n if (predicate(currentNode)) {\n found = currentNode\n return true\n }\n return false\n })(record)\n return found\n }\n\nconst getClosestAncestorNode =\n (\n node: ArenaRecordNode,\n nodeDef: ArenaAnyNodeDef,\n dependentDef: ArenaAnyNodeDef,\n dependencyType: SurveyDependencyType\n ) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n // 1a if dependent def is the same as node def, potentially all nodes with\n // nodeDefUuid === dependentDef.uuid in record could be dependent of nodeDef;\n // consider the root node as the closest ancestor node,\n // unless the node def references itself only among the children of its parent entity (e.g. validation \"dbh > 0\")\n if (nodeDef.uuid === dependentDef.uuid) {\n return NodeDefSelfReferences.isSelfReferenceLocal({ nodeDef, dependencyType })\n ? getParent(node)(record)\n : getRoot(record)\n }\n // 1 find common ancestor def\n const commonAncestorDefUuid = Arrays.last(Arrays.intersection(nodeDef.meta.h, dependentDef.meta.h))\n if (!commonAncestorDefUuid) return undefined\n\n // 2 get ancestor node with common parent def\n return getAncestor(node, commonAncestorDefUuid)(record)\n }\n\ntype KeyDefs = ArenaAnyNodeDef[]\n\n/**\n * Returns the key nodes of the entity, indexed by key def uuid; keyDefs, when specified, are used instead of the\n * entity def keys in the cycle.\n */\nexport const getEntityKeyNodesByDefUuid =\n (survey: ArenaSurvey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): ArenaRecordNodesMap => {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const nodeDefKeys = keyDefs ?? Surveys.getNodeDefKeys({ survey, cycle, nodeDef })\n return nodeDefKeys.reduce((acc: ArenaRecordNodesMap, nodeDefKey) => {\n const nodeKey = getDescendant(entity, nodeDefKey)(record)\n // missing key nodes are kept as undefined entries\n acc[nodeDefKey.uuid] = nodeKey as ArenaRecordNode\n return acc\n }, {})\n }\n\nexport const getEntityKeyNodes =\n (survey: ArenaSurvey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): ArenaRecordNode[] =>\n Object.values(getEntityKeyNodesByDefUuid(survey, entity, cycle, keyDefs)(record))\n\nexport const getEntityKeyValuesByDefUuid =\n (survey: ArenaSurvey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): ArenaDictionary<any> => {\n const keyNodesByDefUuid = getEntityKeyNodesByDefUuid(survey, entity, cycle, keyDefs)(record)\n return Object.entries(keyNodesByDefUuid).reduce((acc: ArenaDictionary<any>, [uuid, keyNode]) => {\n acc[uuid] = keyNode?.value\n return acc\n }, {})\n }\n\nexport const getEntityKeyValues =\n (survey: ArenaSurvey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): any[] =>\n Object.values(getEntityKeyValuesByDefUuid(survey, entity, cycle, keyDefs)(record))\n\nexport const getEntitySiblings =\n (entity: ArenaRecordNode, includeSelf = false) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n const parentEntity = getParent(entity)(record)\n if (!parentEntity) return []\n const siblingEntities = getChildren(parentEntity, entity.nodeDefUuid)(record)\n return includeSelf ? siblingEntities : siblingEntities.filter((sibling) => !RecordNodes.areEqual(sibling, entity))\n }\n\nexport const getAttributeSiblings =\n (node: ArenaRecordNode, nodeDef: ArenaAnyNodeDef) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n const parentEntity = getParent(node)(record)\n if (!parentEntity) return []\n const siblingParentEntities = getEntitySiblings(parentEntity)(record)\n return siblingParentEntities.reduce((siblingsAcc: ArenaRecordNode[], siblingEntity) => {\n for (const sibling of getChildren(siblingEntity, nodeDef.uuid)(record)) {\n siblingsAcc.push(sibling)\n }\n return siblingsAcc\n }, [])\n }\n\nexport const getNodeIndex = (node: ArenaRecordNode) => (record: ArenaRecord) => {\n const parentEntity = getParent(node)(record)\n if (!parentEntity) return 0 // root entity\n const siblings = getChildren(parentEntity, node.nodeDefUuid)(record)\n // compared by uuid: the specified node can be a copy of the one in the record (e.g. an updated version of it)\n return siblings.findIndex((sibling) => sibling.uuid === node.uuid)\n}\n\nexport const findEntityByKeyValues =\n (\n survey: ArenaSurvey,\n cycle: string,\n parentEntity: ArenaRecordNode,\n entityDefUuid: string,\n keyValuesByDefUuid: ArenaDictionary<any>\n ) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entityDefUuid })\n const siblingEntities = getChildren(parentEntity, entityDefUuid)(record)\n if (NodeDefs.isSingle(entityDef)) {\n return siblingEntities[0]\n }\n const keyDefs = Surveys.getNodeDefKeys({ survey, cycle, nodeDef: entityDef })\n\n return siblingEntities.find((siblingEntity) => {\n const siblingEntityKeyValuesByDefUuid = getEntityKeyValuesByDefUuid(\n survey,\n siblingEntity,\n undefined,\n keyDefs\n )(record)\n return keyDefs.every((keyDef) => {\n const keyValue = siblingEntityKeyValuesByDefUuid[keyDef.uuid]\n const keyValueSearch = keyValuesByDefUuid[keyDef.uuid]\n return RecordNodeValues.isValueEqual({\n survey,\n nodeDef: keyDef,\n value: keyValue,\n valueSearch: keyValueSearch,\n })\n })\n })\n }\n\nexport const findEntityWithSameKeysInAnotherRecord =\n (survey: ArenaSurvey, cycle: string, entityUuid: string, recordOther: ArenaRecord) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const entity = getNodeByUuid(entityUuid)(record)\n if (!entity) return undefined\n\n let otherRecordCurrentParentEntity = getRoot(recordOther)\n if (!otherRecordCurrentParentEntity) return undefined\n\n const entityAncestorsAndSelf = getAncestorsAndSelf(entity)(record)\n const ancestorDefUuidsAndKeys = entityAncestorsAndSelf.map((ancestor) => ({\n entityDefUuid: ancestor.nodeDefUuid,\n keyValuesByDefUuid: getEntityKeyValuesByDefUuid(survey, ancestor)(record),\n }))\n\n const ancestorDefUuidsAndKeysToVisit = [...ancestorDefUuidsAndKeys].reverse()\n\n for (let index = 1; otherRecordCurrentParentEntity && index < ancestorDefUuidsAndKeysToVisit.length; index++) {\n const { entityDefUuid, keyValuesByDefUuid } = ancestorDefUuidsAndKeysToVisit[index]\n otherRecordCurrentParentEntity = findEntityByKeyValues(\n survey,\n cycle,\n otherRecordCurrentParentEntity,\n entityDefUuid,\n keyValuesByDefUuid\n )(recordOther)\n }\n return otherRecordCurrentParentEntity\n }\n\nexport const getDependentNodePointers =\n (\n survey: ArenaSurvey,\n node: ArenaRecordNode,\n dependencyType: SurveyDependencyType,\n includeSelf = false,\n filterFn: ((nodePointer: ArenaRecordNodePointer) => boolean) | null = null\n ) =>\n (record: ArenaRecord): ArenaRecordNodePointer[] => {\n const nodeDefUuid = node.nodeDefUuid\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: nodeDefUuid })\n const dependentDefs = Surveys.getNodeDefDependents({ survey, nodeDefUuid, dependencyType })\n const nodePointers: Array<ArenaRecordNodePointer> = []\n\n const addToNodePointers = (nodePointer: ArenaRecordNodePointer): void => {\n if (filterFn === null || filterFn(nodePointer)) {\n nodePointers.push(nodePointer)\n }\n }\n\n for (const dependentDef of dependentDefs) {\n // 1 find common ancestor node\n const commonAncestorNode = getClosestAncestorNode(node, nodeDef, dependentDef, dependencyType)(record)\n if (!commonAncestorNode) continue\n\n const nodeDefDependentParent = Surveys.getNodeDefParent({ survey, nodeDef: dependentDef })\n if (!nodeDefDependentParent) throw new SystemError(SystemErrorKeys.record.dependencyOnRootFound)\n\n // 2 find descendant nodes of common parent node with nodeDefUuid = dependentDef uuid\n const dependentContextNodes = getDescendantsOrSelf(commonAncestorNode, nodeDefDependentParent)(record)\n\n for (const dependentContextNode of dependentContextNodes) {\n addToNodePointers({\n nodeCtx: dependentContextNode,\n nodeDef: dependentDef,\n })\n }\n }\n if (includeSelf) {\n const parentNode = getParent(node)(record)\n if (parentNode) {\n addToNodePointers({\n nodeCtx: parentNode,\n nodeDef,\n })\n }\n }\n\n return nodePointers\n }\n\n/**\n * Returns the code attributes the specified code attribute depends on, from the top level one to the parent one.\n */\nexport const getAncestorCodeAttributes =\n (survey: ArenaSurvey, parentNode: ArenaRecordNode, nodeDef: ArenaNodeDefCode) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n const ancestorCodeAttributes = []\n let currentParentCodeAttribute = getParentCodeAttribute(parentNode, nodeDef)(record)\n while (currentParentCodeAttribute) {\n ancestorCodeAttributes.unshift(currentParentCodeAttribute)\n const ancestorCodeDef = Surveys.getNodeDefByUuid({\n survey,\n uuid: currentParentCodeAttribute.nodeDefUuid,\n }) as ArenaNodeDefCode\n currentParentCodeAttribute = getParentCodeAttribute(parentNode, ancestorCodeDef)(record)\n }\n return ancestorCodeAttributes\n }\n\nexport const getAncestorCodePath =\n (survey: ArenaSurvey, parentNode: ArenaRecordNode, nodeDef: ArenaNodeDef<NodeDefType.code, ArenaNodeDefCodeProps>) =>\n (record: ArenaRecord): string[] =>\n getAncestorCodeAttributes(\n survey,\n parentNode,\n nodeDef\n )(record).map((codeAttribute) => {\n const codeItemUuid = RecordNodeValues.getItemUuid(codeAttribute)\n if (!codeItemUuid) return ''\n // items of big categories are not in the survey ref data: they can be in the node ref data\n const item =\n codeAttribute.refData?.categoryItem ?? Surveys.getCategoryItemByUuid({ survey, itemUuid: codeItemUuid })\n return item?.props.code ?? ''\n })\n\nexport const getCategoryItemUuid =\n (\n survey: ArenaSurvey,\n nodeDef: ArenaNodeDef<NodeDefType.code, ArenaNodeDefCodeProps>,\n parentNode: ArenaRecordNode,\n code: string\n ) =>\n (record: ArenaRecord): string | undefined => {\n const categoryUuid = nodeDef.props.categoryUuid\n\n const codePaths = [...getAncestorCodePath(survey, parentNode, nodeDef)(record), code]\n\n const item = Surveys.getCategoryItemByCodePaths({ survey, categoryUuid, codePaths })\n\n return item?.uuid\n }\n\nexport const isNodeFilledByUser =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean =>\n !!findDescendantOrSelf(node, (visitedNode) => RecordNodes.hasUserInputValue(visitedNode))(record)\n\nexport const isNodeEmpty =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean =>\n !isNodeFilledByUser(node)(record)\n\nexport const isEmpty = (record: ArenaRecord): boolean => {\n const rootNode = getRoot(record)\n return rootNode ? isNodeEmpty(rootNode)(record) : true\n}\n\nexport const getStep = (record: ArenaRecord): string => record.step ?? RECORD_STEP_DEFAULT\n\nexport const isInAnalysisStep = (record: ArenaRecord): boolean => getStep(record) === RecordStepAnalysisCode\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"recordNodeDependentsRequiredUpdater.js","sourceRoot":"","sources":["../../../../src/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAmB,WAAW,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,EAAgB,QAAQ,EAAe,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAA;AAExE,OAAO,EAAE,8BAA8B,EAAE,MAAM,uCAAuC,CAAA;AAEtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAA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E,CAAC;YACxB,MAAM,cAAc,GAAG,WAAW,CAAC,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,CAAC,CAAA;YACnG,YAAY,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,UAAU,EAAE,CAAC,CAAA;QACtD,CAAC;IACH,CAAC;AACH,CAAC,CAAA,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,MAA2E,EAC9C,EAAE;IAC/B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,CAAA;IAC/C,MAAM,YAAY,GAAG,IAAI,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IAEvD,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAA;QACxE,IAAI,EAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,CAAA;YAAE,SAAQ;QAClC,mFAAmF;QACnF,MAAM,0BAA0B,iCAAM,MAAM,KAAE,OAAO,EAAE,YAAY,IAAG,CAAA,CAAC,UAAU;IACnF,CAAC;IACD,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA,CAAA","sourcesContent":["import { ArenaRecordNode, RecordNodes } from '../../node'\nimport { ArenaNodeDef, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { Surveys } from '../../survey'\nimport { SurveyDependencyType } from '../../survey/survey'\nimport { getNodesByDefUuid } from '../_records/recordGetters'\nimport { RecordExpressionEvaluator } from '../recordExpressionEvaluator'\nimport { ArenaRecordExpressionEvaluationContext } from './recordExpressionEvaluationContext'\nimport { getDependentNodePointersByType } from './recordNodesDependentsUpdaterCommons'\nimport { RecordNodeDependentsUpdateParams } from './recordNodeDependentsUpdateParams'\nimport { RecordUpdateResult } from './recordUpdateResult'\n\nconst expressionEvaluator = new RecordExpressionEvaluator()\n\n/**\n * Evaluates the \"required if\" condition of the specified child def in the context of the specified parent entity.\n */\nexport const evaluateRequiredIf = async (\n params: ArenaRecordExpressionEvaluationContext & {\n nodeCtx: ArenaRecordNode\n nodeDef: ArenaNodeDef<NodeDefType>\n }\n): Promise<boolean> => {\n const { nodeCtx, nodeDef } = params\n const exprEval = await expressionEvaluator.evalApplicableExpression({\n ...params,\n nodeCtx,\n expressions: NodeDefs.getRequiredIf(nodeDef),\n })\n return !!exprEval?.value\n}\n\n/**\n * Updates the \"required if\" flags (parent node meta `cReq`) of the node itself (if attribute) and of its dependents.\n */\nexport const updateSelfAndDependentsRequired = async (\n params: RecordNodeDependentsUpdateParams\n): Promise<RecordUpdateResult> => {\n const { survey, record, node, sideEffect = false } = params\n const updateResult = new RecordUpdateResult({ record })\n\n const nodePointersToUpdate = getDependentNodePointersByType({\n survey,\n record,\n node,\n dependencyType: SurveyDependencyType.required,\n includeSelfWhenSourceIsAttribute: true,\n filterFn: (nodePointer) => NodeDefs.isRequiredIfDefined(nodePointer.nodeDef),\n })\n\n // NOTE: don't do it in parallel, same nodeCtx metadata could be overwritten\n for (const { nodeCtx: nodeCtxNodePointer, nodeDef } of nodePointersToUpdate) {\n const nodeCtx = updateResult.getNodeByUuid(nodeCtxNodePointer.uuid) ?? nodeCtxNodePointer\n const valuePrev = RecordNodes.isChildRequired(nodeCtx, nodeDef.uuid)\n // NOSONAR: sequential evaluation needed (see note above)\n const value = await evaluateRequiredIf({ ...params, record: updateResult.record, nodeCtx, nodeDef }) // NOSONAR\n if (valuePrev === value) continue\n\n const nodeCtxUpdated = RecordNodes.assocChildRequired(nodeCtx, nodeDef.uuid, value, { sideEffect })\n updateResult.addNode(nodeCtxUpdated, { sideEffect })\n }\n return updateResult\n}\n\nconst updateNodeDefRequiredFlags = async (\n params: ArenaRecordExpressionEvaluationContext & {\n nodeDef: ArenaNodeDef<NodeDefType>\n updateResult: RecordUpdateResult\n }\n): Promise<void> => {\n const { nodeDef, updateResult, sideEffect = false } = params\n const requiredIfDefined = NodeDefs.isRequiredIfDefined(nodeDef)\n const parentNodes = getNodesByDefUuid(nodeDef.parentUuid!)(updateResult.record)\n\n for (const parentNode of parentNodes) {\n const nodeCtx = updateResult.getNodeByUuid(parentNode.uuid) ?? parentNode\n const valuePrev = RecordNodes.isChildRequired(nodeCtx, nodeDef.uuid)\n // sequential evaluation: the same parent node can be updated for different child defs\n const value =\n requiredIfDefined && (await evaluateRequiredIf({ ...params, record: updateResult.record, nodeCtx, nodeDef })) // NOSONAR\n if (value !== valuePrev) {\n const nodeCtxUpdated = RecordNodes.assocChildRequired(nodeCtx, nodeDef.uuid, value, { sideEffect })\n updateResult.addNode(nodeCtxUpdated, { sideEffect })\n }\n }\n}\n\n/**\n * Recomputes the \"required if\" flags (parent node meta `cReq`) of the specified node defs in the whole record,\n * e.g. after their \"required if\" condition has been added, changed or removed. Validation is not updated.\n */\nexport const updateRequiredFlags = async (\n params: ArenaRecordExpressionEvaluationContext & { nodeDefUuids: string[] }\n): Promise<RecordUpdateResult> => {\n const { survey, record, nodeDefUuids } = params\n const updateResult = new RecordUpdateResult({ record })\n\n for (const nodeDefUuid of nodeDefUuids) {\n const nodeDef = Surveys.findNodeDefByUuid({ survey, uuid: nodeDefUuid })\n if (!nodeDef?.parentUuid) continue\n // sequential: each node def update works on the record updated by the previous one\n await updateNodeDefRequiredFlags({ ...params, nodeDef, updateResult }) // NOSONAR\n }\n return updateResult\n}\n"]}
1
+ {"version":3,"file":"recordNodeDependentsRequiredUpdater.js","sourceRoot":"","sources":["../../../../src/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAmB,WAAW,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,EAAmB,QAAQ,EAAE,MAAM,eAAe,CAAA;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAA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e,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;QACpE,sFAAsF;QACtF,MAAM,KAAK,GACT,iBAAiB,IAAI,CAAC,MAAM,kBAAkB,iCAAM,MAAM,KAAE,MAAM,EAAE,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,IAAG,CAAC,CAAA,CAAC,UAAU;QAC1H,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,cAAc,GAAG,WAAW,CAAC,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,CAAC,CAAA;YACnG,YAAY,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,UAAU,EAAE,CAAC,CAAA;QACtD,CAAC;IACH,CAAC;AACH,CAAC,CAAA,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,MAA2E,EAC9C,EAAE;IAC/B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,CAAA;IAC/C,MAAM,YAAY,GAAG,IAAI,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IAEvD,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAA;QACxE,IAAI,EAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,CAAA;YAAE,SAAQ;QAClC,mFAAmF;QACnF,MAAM,0BAA0B,iCAAM,MAAM,KAAE,OAAO,EAAE,YAAY,IAAG,CAAA,CAAC,UAAU;IACnF,CAAC;IACD,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA,CAAA","sourcesContent":["import { ArenaRecordNode, RecordNodes } from '../../node'\nimport { ArenaAnyNodeDef, NodeDefs } from '../../nodeDef'\nimport { Surveys } from '../../survey'\nimport { SurveyDependencyType } from '../../survey/survey'\nimport { getNodesByDefUuid } from '../_records/recordGetters'\nimport { RecordExpressionEvaluator } from '../recordExpressionEvaluator'\nimport { ArenaRecordExpressionEvaluationContext } from './recordExpressionEvaluationContext'\nimport { getDependentNodePointersByType } from './recordNodesDependentsUpdaterCommons'\nimport { RecordNodeDependentsUpdateParams } from './recordNodeDependentsUpdateParams'\nimport { RecordUpdateResult } from './recordUpdateResult'\n\nconst expressionEvaluator = new RecordExpressionEvaluator()\n\n/**\n * Evaluates the \"required if\" condition of the specified child def in the context of the specified parent entity.\n */\nexport const evaluateRequiredIf = async (\n params: ArenaRecordExpressionEvaluationContext & {\n nodeCtx: ArenaRecordNode\n nodeDef: ArenaAnyNodeDef\n }\n): Promise<boolean> => {\n const { nodeCtx, nodeDef } = params\n const exprEval = await expressionEvaluator.evalApplicableExpression({\n ...params,\n nodeCtx,\n expressions: NodeDefs.getRequiredIf(nodeDef),\n })\n return !!exprEval?.value\n}\n\n/**\n * Updates the \"required if\" flags (parent node meta `cReq`) of the node itself (if attribute) and of its dependents.\n */\nexport const updateSelfAndDependentsRequired = async (\n params: RecordNodeDependentsUpdateParams\n): Promise<RecordUpdateResult> => {\n const { survey, record, node, sideEffect = false } = params\n const updateResult = new RecordUpdateResult({ record })\n\n const nodePointersToUpdate = getDependentNodePointersByType({\n survey,\n record,\n node,\n dependencyType: SurveyDependencyType.required,\n includeSelfWhenSourceIsAttribute: true,\n filterFn: (nodePointer) => NodeDefs.isRequiredIfDefined(nodePointer.nodeDef),\n })\n\n // NOTE: don't do it in parallel, same nodeCtx metadata could be overwritten\n for (const { nodeCtx: nodeCtxNodePointer, nodeDef } of nodePointersToUpdate) {\n const nodeCtx = updateResult.getNodeByUuid(nodeCtxNodePointer.uuid) ?? nodeCtxNodePointer\n const valuePrev = RecordNodes.isChildRequired(nodeCtx, nodeDef.uuid)\n // NOSONAR: sequential evaluation needed (see note above)\n const value = await evaluateRequiredIf({ ...params, record: updateResult.record, nodeCtx, nodeDef }) // NOSONAR\n if (valuePrev === value) continue\n\n const nodeCtxUpdated = RecordNodes.assocChildRequired(nodeCtx, nodeDef.uuid, value, { sideEffect })\n updateResult.addNode(nodeCtxUpdated, { sideEffect })\n }\n return updateResult\n}\n\nconst updateNodeDefRequiredFlags = async (\n params: ArenaRecordExpressionEvaluationContext & {\n nodeDef: ArenaAnyNodeDef\n updateResult: RecordUpdateResult\n }\n): Promise<void> => {\n const { nodeDef, updateResult, sideEffect = false } = params\n const requiredIfDefined = NodeDefs.isRequiredIfDefined(nodeDef)\n const parentNodes = getNodesByDefUuid(nodeDef.parentUuid!)(updateResult.record)\n\n for (const parentNode of parentNodes) {\n const nodeCtx = updateResult.getNodeByUuid(parentNode.uuid) ?? parentNode\n const valuePrev = RecordNodes.isChildRequired(nodeCtx, nodeDef.uuid)\n // sequential evaluation: the same parent node can be updated for different child defs\n const value =\n requiredIfDefined && (await evaluateRequiredIf({ ...params, record: updateResult.record, nodeCtx, nodeDef })) // NOSONAR\n if (value !== valuePrev) {\n const nodeCtxUpdated = RecordNodes.assocChildRequired(nodeCtx, nodeDef.uuid, value, { sideEffect })\n updateResult.addNode(nodeCtxUpdated, { sideEffect })\n }\n }\n}\n\n/**\n * Recomputes the \"required if\" flags (parent node meta `cReq`) of the specified node defs in the whole record,\n * e.g. after their \"required if\" condition has been added, changed or removed. Validation is not updated.\n */\nexport const updateRequiredFlags = async (\n params: ArenaRecordExpressionEvaluationContext & { nodeDefUuids: string[] }\n): Promise<RecordUpdateResult> => {\n const { survey, record, nodeDefUuids } = params\n const updateResult = new RecordUpdateResult({ record })\n\n for (const nodeDefUuid of nodeDefUuids) {\n const nodeDef = Surveys.findNodeDefByUuid({ survey, uuid: nodeDefUuid })\n if (!nodeDef?.parentUuid) continue\n // sequential: each node def update works on the record updated by the previous one\n await updateNodeDefRequiredFlags({ ...params, nodeDef, updateResult }) // NOSONAR\n }\n return updateResult\n}\n"]}