@openforis/arena-core 2.5.15 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/dist/esm/node/node.js.map +1 -1
  2. package/dist/esm/node/nodeValues.js +1 -1
  3. package/dist/esm/node/nodeValues.js.map +1 -1
  4. package/dist/esm/node/nodes.js +21 -2
  5. package/dist/esm/node/nodes.js.map +1 -1
  6. package/dist/esm/nodeDef/nodeDef.js.map +1 -1
  7. package/dist/esm/nodeDef/nodeDefs.js +9 -0
  8. package/dist/esm/nodeDef/nodeDefs.js.map +1 -1
  9. package/dist/esm/record/_records/recordCompletion.js +7 -4
  10. package/dist/esm/record/_records/recordCompletion.js.map +1 -1
  11. package/dist/esm/record/_records/recordGetters.js +158 -259
  12. package/dist/esm/record/_records/recordGetters.js.map +1 -1
  13. package/dist/esm/record/_records/recordPagesValidation.js +5 -5
  14. package/dist/esm/record/_records/recordPagesValidation.js.map +1 -1
  15. package/dist/esm/record/_records/recordUtils.js +4 -4
  16. package/dist/esm/record/_records/recordUtils.js.map +1 -1
  17. package/dist/esm/record/nodePointers.js +1 -1
  18. package/dist/esm/record/nodePointers.js.map +1 -1
  19. package/dist/esm/record/recordCloner.js +1 -1
  20. package/dist/esm/record/recordCloner.js.map +1 -1
  21. package/dist/esm/record/recordExpressionEvaluator/functions.js +4 -9
  22. package/dist/esm/record/recordExpressionEvaluator/functions.js.map +1 -1
  23. package/dist/esm/record/recordExpressionEvaluator/node/identifier/identifier.js +1 -1
  24. package/dist/esm/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
  25. package/dist/esm/record/recordExpressionEvaluator/node/identifier/nodesFinder.js +2 -2
  26. package/dist/esm/record/recordExpressionEvaluator/node/identifier/nodesFinder.js.map +1 -1
  27. package/dist/esm/record/recordExpressionEvaluator/recordExpressionEvaluator.js +1 -1
  28. package/dist/esm/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
  29. package/dist/esm/record/recordFixer.js +7 -7
  30. package/dist/esm/record/recordFixer.js.map +1 -1
  31. package/dist/esm/record/recordNodesUpdater/index.js +3 -0
  32. package/dist/esm/record/recordNodesUpdater/index.js.map +1 -1
  33. package/dist/esm/record/recordNodesUpdater/recordExpressionValueConverter.js +2 -2
  34. package/dist/esm/record/recordNodesUpdater/recordExpressionValueConverter.js.map +1 -1
  35. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js +20 -24
  36. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js.map +1 -1
  37. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js +1 -1
  38. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js.map +1 -1
  39. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsCountUpdater.js +1 -1
  40. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsCountUpdater.js.map +1 -1
  41. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js +3 -9
  42. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js.map +1 -1
  43. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js +3 -3
  44. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js.map +1 -1
  45. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js +4 -8
  46. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js.map +1 -1
  47. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js +2 -7
  48. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
  49. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.js +87 -0
  50. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.js.map +1 -0
  51. package/dist/esm/record/recordNodesUpdater/recordNodesDeleter.js +1 -1
  52. package/dist/esm/record/recordNodesUpdater/recordNodesDeleter.js.map +1 -1
  53. package/dist/esm/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js +2 -2
  54. package/dist/esm/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
  55. package/dist/esm/record/recordNodesUpdater/recordNodesUpdater.js +3 -1
  56. package/dist/esm/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
  57. package/dist/esm/record/recordPrettyPrinter.js +19 -26
  58. package/dist/esm/record/recordPrettyPrinter.js.map +1 -1
  59. package/dist/esm/record/recordUpdater.js +3 -2
  60. package/dist/esm/record/recordUpdater.js.map +1 -1
  61. package/dist/esm/record/recordValidator/attributeKeyValidator.js +4 -4
  62. package/dist/esm/record/recordValidator/attributeKeyValidator.js.map +1 -1
  63. package/dist/esm/record/recordValidator/attributeUniqueValidator.js +1 -1
  64. package/dist/esm/record/recordValidator/attributeUniqueValidator.js.map +1 -1
  65. package/dist/esm/record/recordValidator/attributeValidator.js +31 -23
  66. package/dist/esm/record/recordValidator/attributeValidator.js.map +1 -1
  67. package/dist/esm/record/recordValidator/countValidator.js +2 -2
  68. package/dist/esm/record/recordValidator/countValidator.js.map +1 -1
  69. package/dist/esm/record/recordValidator/recordValidator.js +2 -5
  70. package/dist/esm/record/recordValidator/recordValidator.js.map +1 -1
  71. package/dist/esm/record/records.js +2 -1
  72. package/dist/esm/record/records.js.map +1 -1
  73. package/dist/esm/survey/survey.js +1 -0
  74. package/dist/esm/survey/survey.js.map +1 -1
  75. package/dist/esm/survey/surveys/dependencies.js +4 -0
  76. package/dist/esm/survey/surveys/dependencies.js.map +1 -1
  77. package/dist/esm/tests/builder/recordBuilder/attributeBuilder.js +1 -1
  78. package/dist/esm/tests/builder/recordBuilder/attributeBuilder.js.map +1 -1
  79. package/dist/esm/tests/builder/surveyBuilder/nodeDefBuilder.js +8 -0
  80. package/dist/esm/tests/builder/surveyBuilder/nodeDefBuilder.js.map +1 -1
  81. package/dist/node/node.d.ts +7 -0
  82. package/dist/node/node.js.map +1 -1
  83. package/dist/node/nodeValues.js +1 -1
  84. package/dist/node/nodeValues.js.map +1 -1
  85. package/dist/node/nodes.d.ts +7 -0
  86. package/dist/node/nodes.js +21 -2
  87. package/dist/node/nodes.js.map +1 -1
  88. package/dist/nodeDef/nodeDef.d.ts +4 -0
  89. package/dist/nodeDef/nodeDef.js.map +1 -1
  90. package/dist/nodeDef/nodeDefs.d.ts +9 -0
  91. package/dist/nodeDef/nodeDefs.js +9 -0
  92. package/dist/nodeDef/nodeDefs.js.map +1 -1
  93. package/dist/record/_records/recordCompletion.js +7 -4
  94. package/dist/record/_records/recordCompletion.js.map +1 -1
  95. package/dist/record/_records/recordGetters.d.ts +44 -165
  96. package/dist/record/_records/recordGetters.js +187 -260
  97. package/dist/record/_records/recordGetters.js.map +1 -1
  98. package/dist/record/_records/recordPagesValidation.js +5 -5
  99. package/dist/record/_records/recordPagesValidation.js.map +1 -1
  100. package/dist/record/_records/recordUtils.js +4 -4
  101. package/dist/record/_records/recordUtils.js.map +1 -1
  102. package/dist/record/nodePointers.js +1 -1
  103. package/dist/record/nodePointers.js.map +1 -1
  104. package/dist/record/recordCloner.js +1 -1
  105. package/dist/record/recordCloner.js.map +1 -1
  106. package/dist/record/recordExpressionEvaluator/functions.js +4 -9
  107. package/dist/record/recordExpressionEvaluator/functions.js.map +1 -1
  108. package/dist/record/recordExpressionEvaluator/node/identifier/identifier.js +1 -1
  109. package/dist/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
  110. package/dist/record/recordExpressionEvaluator/node/identifier/nodesFinder.js +2 -2
  111. package/dist/record/recordExpressionEvaluator/node/identifier/nodesFinder.js.map +1 -1
  112. package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.js +1 -1
  113. package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
  114. package/dist/record/recordFixer.js +7 -7
  115. package/dist/record/recordFixer.js.map +1 -1
  116. package/dist/record/recordNodesUpdater/index.d.ts +3 -0
  117. package/dist/record/recordNodesUpdater/index.js +3 -0
  118. package/dist/record/recordNodesUpdater/index.js.map +1 -1
  119. package/dist/record/recordNodesUpdater/recordExpressionValueConverter.js +2 -2
  120. package/dist/record/recordNodesUpdater/recordExpressionValueConverter.js.map +1 -1
  121. package/dist/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js +20 -24
  122. package/dist/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js.map +1 -1
  123. package/dist/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js +1 -1
  124. package/dist/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js.map +1 -1
  125. package/dist/record/recordNodesUpdater/recordNodeDependentsCountUpdater.js +1 -1
  126. package/dist/record/recordNodesUpdater/recordNodeDependentsCountUpdater.js.map +1 -1
  127. package/dist/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js +3 -9
  128. package/dist/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js.map +1 -1
  129. package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js +3 -3
  130. package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js.map +1 -1
  131. package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js +4 -8
  132. package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js.map +1 -1
  133. package/dist/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js +2 -7
  134. package/dist/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
  135. package/dist/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.d.ts +23 -0
  136. package/dist/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.js +93 -0
  137. package/dist/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.js.map +1 -0
  138. package/dist/record/recordNodesUpdater/recordNodesDeleter.js +1 -1
  139. package/dist/record/recordNodesUpdater/recordNodesDeleter.js.map +1 -1
  140. package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js +2 -2
  141. package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
  142. package/dist/record/recordNodesUpdater/recordNodesUpdater.js +3 -1
  143. package/dist/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
  144. package/dist/record/recordPrettyPrinter.js +19 -26
  145. package/dist/record/recordPrettyPrinter.js.map +1 -1
  146. package/dist/record/recordUpdater.js +3 -2
  147. package/dist/record/recordUpdater.js.map +1 -1
  148. package/dist/record/recordValidator/attributeKeyValidator.js +4 -4
  149. package/dist/record/recordValidator/attributeKeyValidator.js.map +1 -1
  150. package/dist/record/recordValidator/attributeUniqueValidator.js +1 -1
  151. package/dist/record/recordValidator/attributeUniqueValidator.js.map +1 -1
  152. package/dist/record/recordValidator/attributeValidator.js +31 -23
  153. package/dist/record/recordValidator/attributeValidator.js.map +1 -1
  154. package/dist/record/recordValidator/countValidator.js +2 -2
  155. package/dist/record/recordValidator/countValidator.js.map +1 -1
  156. package/dist/record/recordValidator/recordValidator.js +2 -5
  157. package/dist/record/recordValidator/recordValidator.js.map +1 -1
  158. package/dist/record/records.d.ts +32 -146
  159. package/dist/record/records.js +1 -0
  160. package/dist/record/records.js.map +1 -1
  161. package/dist/survey/survey.d.ts +1 -0
  162. package/dist/survey/survey.js +1 -0
  163. package/dist/survey/survey.js.map +1 -1
  164. package/dist/survey/surveys/dependencies.js +4 -0
  165. package/dist/survey/surveys/dependencies.js.map +1 -1
  166. package/dist/tests/builder/recordBuilder/attributeBuilder.js +1 -1
  167. package/dist/tests/builder/recordBuilder/attributeBuilder.js.map +1 -1
  168. package/dist/tests/builder/surveyBuilder/nodeDefBuilder.d.ts +1 -0
  169. package/dist/tests/builder/surveyBuilder/nodeDefBuilder.js +8 -0
  170. package/dist/tests/builder/surveyBuilder/nodeDefBuilder.js.map +1 -1
  171. package/package.json +1 -1
@@ -61,6 +61,7 @@ const isContextParentByDependencyType = {
61
61
  [survey_1.SurveyDependencyType.minCount]: true,
62
62
  [survey_1.SurveyDependencyType.onUpdate]: true,
63
63
  [survey_1.SurveyDependencyType.parentCode]: false,
64
+ [survey_1.SurveyDependencyType.required]: true,
64
65
  [survey_1.SurveyDependencyType.validations]: true,
65
66
  [survey_1.SurveyDependencyType.visible]: true,
66
67
  };
@@ -75,6 +76,7 @@ const selfReferenceAllowedByDependencyType = {
75
76
  [survey_1.SurveyDependencyType.minCount]: false,
76
77
  [survey_1.SurveyDependencyType.onUpdate]: false,
77
78
  [survey_1.SurveyDependencyType.parentCode]: false,
79
+ [survey_1.SurveyDependencyType.required]: false,
78
80
  [survey_1.SurveyDependencyType.validations]: true,
79
81
  [survey_1.SurveyDependencyType.visible]: false,
80
82
  };
@@ -89,6 +91,7 @@ const newDependencyGraph = () => ({
89
91
  [survey_1.SurveyDependencyType.minCount]: {},
90
92
  [survey_1.SurveyDependencyType.onUpdate]: {},
91
93
  [survey_1.SurveyDependencyType.parentCode]: {},
94
+ [survey_1.SurveyDependencyType.required]: {},
92
95
  [survey_1.SurveyDependencyType.validations]: {},
93
96
  [survey_1.SurveyDependencyType.visible]: {},
94
97
  });
@@ -196,6 +199,7 @@ const addNodeDefDependencies = (params) => __awaiter(void 0, void 0, void 0, fun
196
199
  graphsUpdated = yield _addDependencies(survey_1.SurveyDependencyType.applicable, nodeDef_1.NodeDefs.getApplicable(nodeDef));
197
200
  graphsUpdated = yield _addDependencies(survey_1.SurveyDependencyType.defaultValues, nodeDef_1.NodeDefs.getDefaultValues(nodeDef));
198
201
  graphsUpdated = yield _addDependencies(survey_1.SurveyDependencyType.editable, nodeDef_1.NodeDefs.getEditableIf(nodeDef));
202
+ graphsUpdated = yield _addDependencies(survey_1.SurveyDependencyType.required, nodeDef_1.NodeDefs.getRequiredIf(nodeDef));
199
203
  graphsUpdated = yield _addDependencies(survey_1.SurveyDependencyType.validations, nodeDef_1.NodeDefs.getValidationsExpressions(nodeDef));
200
204
  graphsUpdated = yield _addDependencies(survey_1.SurveyDependencyType.visible, nodeDef_1.NodeDefs.getVisibleIf(nodeDef));
201
205
  const maxCount = nodeDef_1.NodeDefs.getMaxCount(nodeDef);
@@ -1 +1 @@
1
- {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../src/survey/surveys/dependencies.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,cAAc,uCAAkB;AAC5C,2CASsB;AACtB,iFAA6E;AAE7E,sCAA+E;AAC/E,uCAA6C;AAC7C,mDAAgE;AAGhE,MAAM,oCAAoC,GAAG,CAAC,wBAAwB,CAAC,CAAA;AAEvE,MAAM,+BAA+B,GAAG;IACtC,CAAC,6BAAoB,CAAC,UAAU,CAAC,EAAE,IAAI;IACvC,CAAC,6BAAoB,CAAC,aAAa,CAAC,EAAE,IAAI;IAC1C,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,gBAAgB,CAAC,EAAE,IAAI;IAC7C,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,OAAO,CAAC,EAAE,KAAK;IACrC,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,UAAU,CAAC,EAAE,KAAK;IACxC,CAAC,6BAAoB,CAAC,WAAW,CAAC,EAAE,IAAI;IACxC,CAAC,6BAAoB,CAAC,OAAO,CAAC,EAAE,IAAI;CACrC,CAAA;AAED,MAAM,oCAAoC,GAAG;IAC3C,CAAC,6BAAoB,CAAC,UAAU,CAAC,EAAE,KAAK;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C,MAAM,CAC1C,CAAC,kBAAkB,EAAE,IAAI,EAAE,EAAE,CAC3B,gCAAgC,CAAC,EAAE,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,EACrG,MAAM,CACP,CAAA;IACD,uCAAY,MAAM,KAAE,eAAe,EAAE,aAAa,IAAE;AACtD,CAAC,CAAA;AAdY,QAAA,yBAAyB,GAAzB,yBAAyB,CAcrC;AAED;;;;;GAKG;AACI,MAAM,4BAA4B,GAAG,CAAO,MAAc,EAAmB,EAAE;IACpF,iIAAiI;IACjI,MAAM,UAAU,GAAG,IAAI,CAAA;IAEvB,sCAAsC;IACtC,IAAI,aAAa,mCAAgB,MAAM,KAAE,eAAe,EAAE,kBAAkB,EAAE,GAAE,CAAA;IAChF,KAAK,MAAM,OAAO,IAAI,cAAc,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9D,gDAAgD;QAChD,aAAa,GAAG,MAAM,IAAA,QAAA,sBAAsB,EAAC,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAA,CAAC,UAAU;IACzG,CAAC;IACD,OAAO,aAAa,CAAA;AACtB,CAAC,CAAA,CAAA;AAXY,QAAA,4BAA4B,GAA5B,4BAA4B,CAWxC","sourcesContent":["import * as SurveyNodeDefs from './nodeDefs'\nimport {\n NodeDef,\n NodeDefCode,\n NodeDefEntity,\n NodeDefExpression,\n NodeDefFile,\n NodeDefProps,\n NodeDefs,\n NodeDefType,\n} from '../../nodeDef'\nimport { NodeDefExpressionEvaluator } from '../../nodeDefExpressionEvaluator'\n\nimport { Survey, SurveyDependencyGraph, SurveyDependencyType } from '../survey'\nimport { Arrays, Objects } from '../../utils'\nimport { NodeDefExpressionFactory } from '../../nodeDef/nodeDef'\nimport { Dictionary } from '../../common'\n\nconst functionsRequiringOnUpdateDependency = ['recordDateLastModified']\n\nconst isContextParentByDependencyType = {\n [SurveyDependencyType.applicable]: true,\n [SurveyDependencyType.defaultValues]: true,\n [SurveyDependencyType.editable]: true,\n [SurveyDependencyType.enumeratingItems]: true,\n [SurveyDependencyType.fileName]: true,\n [SurveyDependencyType.formula]: false,\n [SurveyDependencyType.maxCount]: true,\n [SurveyDependencyType.minCount]: true,\n [SurveyDependencyType.onUpdate]: true,\n [SurveyDependencyType.parentCode]: false,\n [SurveyDependencyType.validations]: true,\n [SurveyDependencyType.visible]: true,\n}\n\nconst selfReferenceAllowedByDependencyType = {\n [SurveyDependencyType.applicable]: false,\n [SurveyDependencyType.defaultValues]: false,\n [SurveyDependencyType.editable]: false,\n [SurveyDependencyType.enumeratingItems]: false,\n [SurveyDependencyType.fileName]: false,\n [SurveyDependencyType.formula]: false,\n [SurveyDependencyType.maxCount]: false,\n [SurveyDependencyType.minCount]: false,\n [SurveyDependencyType.onUpdate]: false,\n [SurveyDependencyType.parentCode]: false,\n [SurveyDependencyType.validations]: true,\n [SurveyDependencyType.visible]: false,\n}\n\nconst newDependencyGraph = () => ({\n [SurveyDependencyType.applicable]: {},\n [SurveyDependencyType.defaultValues]: {},\n [SurveyDependencyType.editable]: {},\n [SurveyDependencyType.enumeratingItems]: {},\n [SurveyDependencyType.fileName]: {},\n [SurveyDependencyType.formula]: {},\n [SurveyDependencyType.maxCount]: {},\n [SurveyDependencyType.minCount]: {},\n [SurveyDependencyType.onUpdate]: {},\n [SurveyDependencyType.parentCode]: {},\n [SurveyDependencyType.validations]: {},\n [SurveyDependencyType.visible]: {},\n})\n\nconst getDependencyGraph = (survey: Survey): SurveyDependencyGraph => survey.dependencyGraph ?? newDependencyGraph()\n\nconst getDependencies = (params: {\n graphs: SurveyDependencyGraph\n type: SurveyDependencyType\n nodeDefUuid: string\n}): Array<string> => {\n const { graphs, type, nodeDefUuid } = params\n return type === SurveyDependencyType.onUpdate ? [] : ((graphs?.[type]?.[nodeDefUuid] ?? []) as string[])\n}\n\nexport const getNodeDefDependents = (params: {\n survey: Survey\n nodeDefUuid: string\n dependencyType?: SurveyDependencyType\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey, nodeDefUuid, dependencyType } = params\n const dependencyGraph = getDependencyGraph(survey)\n\n const dependentUuids = new Set<string>()\n\n const dependencyTypes: SurveyDependencyType[] = dependencyType\n ? [dependencyType]\n : Object.values(SurveyDependencyType)\n\n for (const depType of dependencyTypes) {\n const dependentUuidsTemp = getDependencies({ graphs: dependencyGraph, type: depType, nodeDefUuid })\n for (const dependentUuid of dependentUuidsTemp) {\n dependentUuids.add(dependentUuid)\n }\n }\n return dependentUuids.size > 0 ? SurveyNodeDefs.findNodeDefsByUuids({ survey, uuids: [...dependentUuids] }) : []\n}\n\nexport const getOnUpdateDependents = (params: { survey: Survey }) => {\n const { survey } = params\n const dependencyGraph = getDependencyGraph(survey)\n const sourceDefUuids = Object.keys(dependencyGraph[SurveyDependencyType.onUpdate] ?? {})\n return sourceDefUuids.length > 0 ? SurveyNodeDefs.findNodeDefsByUuids({ survey, uuids: sourceDefUuids }) : []\n}\n\n// UPDATE\n\nconst addDependency = (params: {\n graphs: SurveyDependencyGraph\n type: SurveyDependencyType\n nodeDefUuid: string\n nodeDefDepUuid: string\n sideEffect: boolean\n}): SurveyDependencyGraph => {\n const { graphs, type, nodeDefUuid, nodeDefDepUuid, sideEffect = false } = params\n const deps = getDependencies({ graphs, type, nodeDefUuid })\n const depsUpdated = Arrays.addItem(nodeDefDepUuid, { sideEffect })(deps)\n return Objects.assocPath({ obj: graphs, path: [type, nodeDefUuid], value: depsUpdated, sideEffect })\n}\n\nconst addDependencies = async (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType>\n type: SurveyDependencyType\n graphs: SurveyDependencyGraph\n expressions: NodeDefExpression[]\n sideEffect?: boolean\n}): Promise<SurveyDependencyGraph> => {\n const { survey, nodeDef, type, expressions, graphs: graphsParam, sideEffect = false } = params\n\n if (!expressions || expressions.length === 0) return graphsParam\n\n let graphsUpdated = sideEffect ? graphsParam : { ...graphsParam }\n\n const isContextParent = isContextParentByDependencyType[type]\n const selfReferenceAllowed = selfReferenceAllowedByDependencyType[type]\n\n const findReferencedNodeDefs = async (\n expression: string | undefined\n ): Promise<{ [key: string]: NodeDef<NodeDefType> }> => {\n if (!expression) return {}\n\n const referencedNodeDefUuids = await new NodeDefExpressionEvaluator().findReferencedNodeDefUuids({\n expression,\n survey,\n nodeDef,\n isContextParent,\n selfReferenceAllowed,\n })\n const referencedNodeDefsByUuid: Dictionary<NodeDef<any>> = {}\n for (const uuid of referencedNodeDefUuids) {\n referencedNodeDefsByUuid[uuid] = SurveyNodeDefs.getNodeDefByUuid({ survey, uuid })\n }\n return referencedNodeDefsByUuid\n }\n\n const referencedNodeDefsArray = await Promise.all(\n expressions.flatMap((nodeDefExpr) => [\n findReferencedNodeDefs(nodeDefExpr.expression),\n findReferencedNodeDefs(nodeDefExpr.applyIf),\n ])\n )\n const referencedNodeDefs: Dictionary<NodeDef<any>> = Object.assign({}, ...referencedNodeDefsArray)\n\n for (const nodeDefRef of Object.values(referencedNodeDefs)) {\n graphsUpdated = addDependency({\n graphs: graphsUpdated,\n type,\n nodeDefUuid: nodeDefRef.uuid,\n nodeDefDepUuid: nodeDef.uuid,\n sideEffect,\n })\n }\n\n return graphsUpdated\n}\n\nexport const addNodeDefDependencies = async (params: {\n nodeDef: NodeDef<NodeDefType>\n survey: Survey\n sideEffect?: boolean\n}): Promise<Survey> => {\n const { nodeDef, survey, sideEffect = false } = params\n const graphs = getDependencyGraph(survey)\n let graphsUpdated = sideEffect ? graphs : { ...graphs }\n\n const _addDependencies = async (type: SurveyDependencyType, expressions: NodeDefExpression[]) => {\n let _graphUpdated = await addDependencies({\n survey,\n nodeDef,\n type,\n expressions,\n graphs: graphsUpdated,\n sideEffect,\n })\n // add onUpdate dependencies\n if (\n expressions.some((expression) =>\n functionsRequiringOnUpdateDependency.some(\n (functionName) => expression.applyIf?.includes(functionName) || expression.expression?.includes(functionName)\n )\n )\n ) {\n _graphUpdated = Objects.assocPath({\n obj: _graphUpdated,\n path: [SurveyDependencyType.onUpdate, nodeDef.uuid],\n value: true,\n sideEffect,\n })\n }\n return _graphUpdated\n }\n graphsUpdated = await _addDependencies(SurveyDependencyType.applicable, NodeDefs.getApplicable(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.defaultValues, NodeDefs.getDefaultValues(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.editable, NodeDefs.getEditableIf(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.validations, NodeDefs.getValidationsExpressions(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.visible, NodeDefs.getVisibleIf(nodeDef))\n const maxCount = NodeDefs.getMaxCount(nodeDef)\n if (Array.isArray(maxCount)) {\n graphsUpdated = await _addDependencies(SurveyDependencyType.maxCount, maxCount)\n }\n const minCount = NodeDefs.getMinCount(nodeDef)\n if (Array.isArray(minCount)) {\n graphsUpdated = await _addDependencies(SurveyDependencyType.minCount, minCount)\n }\n // file name expression\n if (NodeDefs.getType(nodeDef) === NodeDefType.file) {\n const fileNameExpression = NodeDefs.getFileNameExpression(nodeDef as NodeDefFile)\n if (fileNameExpression) {\n graphsUpdated = await _addDependencies(SurveyDependencyType.fileName, [\n NodeDefExpressionFactory.createInstance({ expression: fileNameExpression }),\n ])\n }\n }\n if (NodeDefs.isEntity(nodeDef)) {\n const enumeratingItemsExpression = NodeDefs.getEnumeratingItemsExpression(nodeDef as NodeDefEntity)\n if (enumeratingItemsExpression) {\n graphsUpdated = await _addDependencies(SurveyDependencyType.enumeratingItems, [\n NodeDefExpressionFactory.createInstance({ expression: enumeratingItemsExpression }),\n ])\n }\n }\n // parent code\n if (NodeDefs.getType(nodeDef) === NodeDefType.code) {\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(nodeDef as NodeDefCode)\n if (parentCodeDefUuid) {\n graphsUpdated = addDependency({\n graphs: graphsUpdated,\n type: SurveyDependencyType.parentCode,\n nodeDefUuid: parentCodeDefUuid,\n nodeDefDepUuid: nodeDef.uuid,\n sideEffect,\n })\n }\n }\n if (sideEffect) {\n survey.dependencyGraph = graphsUpdated\n return survey\n }\n return { ...survey, dependencyGraph: graphsUpdated }\n}\n\n// DELETE\n\nconst _removeNodeDefDependenciesOfType = (params: {\n graphs: SurveyDependencyGraph\n dependencyType: SurveyDependencyType\n nodeDefUuid: string\n}): SurveyDependencyGraph => {\n const { graphs, nodeDefUuid, dependencyType } = params\n\n const graphsUpdated = { ...graphs }\n let graphUpdated = { ...graphsUpdated[dependencyType] }\n // dissoc nodeDefUuid dependency as dependent\n graphUpdated = Objects.dissoc({ obj: graphUpdated, prop: nodeDefUuid })\n\n if (dependencyType !== SurveyDependencyType.onUpdate) {\n // dissoc nodeDefUuid dependency from sources (if any)\n for (const [key, dependentUuids] of Object.entries(graphUpdated)) {\n graphUpdated[key] = Arrays.removeItem(nodeDefUuid)(dependentUuids as string[])\n }\n }\n\n graphsUpdated[dependencyType] = graphUpdated\n return graphsUpdated\n}\n\nexport const removeNodeDefDependencies = (params: {\n survey: Survey\n nodeDefUuid: string\n dependencyType?: SurveyDependencyType\n}): Survey => {\n const { survey, nodeDefUuid, dependencyType = null } = params\n const graphs = getDependencyGraph(survey)\n const dependencyTypes = dependencyType ? [dependencyType] : (Object.keys(graphs) as SurveyDependencyType[])\n const graphsUpdated = dependencyTypes.reduce(\n (dependencyGraphAcc, type) =>\n _removeNodeDefDependenciesOfType({ graphs: dependencyGraphAcc, dependencyType: type, nodeDefUuid }),\n graphs\n )\n return { ...survey, dependencyGraph: graphsUpdated }\n}\n\n/**\n * Builds the dependency graph of the survey.\n *\n * @param survey - The survey.\n * @returns A copy of the survey with the dependency graph (the survey passed in is not modified).\n */\nexport const buildAndAssocDependencyGraph = async (survey: Survey): Promise<Survey> => {\n // the new graph is built from scratch with side effect (to avoid re-creating objects): it belongs only to the copy of the survey\n const sideEffect = true\n\n // add dependencies for every node def\n let surveyUpdated: Survey = { ...survey, dependencyGraph: newDependencyGraph() }\n for (const nodeDef of SurveyNodeDefs.getNodeDefsArray(survey)) {\n // sequential: each iteration updates the survey\n surveyUpdated = await addNodeDefDependencies({ nodeDef, survey: surveyUpdated, sideEffect }) // NOSONAR\n }\n return surveyUpdated\n}\n"]}
1
+ {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../src/survey/surveys/dependencies.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,cAAc,uCAAkB;AAC5C,2CASsB;AACtB,iFAA6E;AAE7E,sCAA+E;AAC/E,uCAA6C;AAC7C,mDAAgE;AAGhE,MAAM,oCAAoC,GAAG,CAAC,wBAAwB,CAAC,CAAA;AAEvE,MAAM,+BAA+B,GAAG;IACtC,CAAC,6BAAoB,CAAC,UAAU,CAAC,EAAE,IAAI;IACvC,CAAC,6BAAoB,CAAC,aAAa,CAAC,EAAE,IAAI;IAC1C,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,gBAAgB,CAAC,EAAE,IAAI;IAC7C,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,OAAO,CAAC,EAAE,KAAK;IACrC,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,UAAU,CAAC,EAAE,KAAK;IACxC,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,WAAW,CAAC,EAAE,IAAI;IACxC,CAAC,6BAAoB,CAAC,OAAO,CAAC,EAAE,IAAI;CACrC,CAAA;AAED,MAAM,oCAAoC,GAAG;IAC3C,CAAC,6BAAoB,CAAC,UAAU,CAAC,EAAE,KAAK;IAC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7D,MAAM,MAAM,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAA;IACzC,MAAM,eAAe,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAA4B,CAAA;IAC3G,MAAM,aAAa,GAAG,eAAe,CAAC,MAAM,CAC1C,CAAC,kBAAkB,EAAE,IAAI,EAAE,EAAE,CAC3B,gCAAgC,CAAC,EAAE,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,EACrG,MAAM,CACP,CAAA;IACD,uCAAY,MAAM,KAAE,eAAe,EAAE,aAAa,IAAE;AACtD,CAAC,CAAA;AAdY,QAAA,yBAAyB,GAAzB,yBAAyB,CAcrC;AAED;;;;;GAKG;AACI,MAAM,4BAA4B,GAAG,CAAO,MAAc,EAAmB,EAAE;IACpF,iIAAiI;IACjI,MAAM,UAAU,GAAG,IAAI,CAAA;IAEvB,sCAAsC;IACtC,IAAI,aAAa,mCAAgB,MAAM,KAAE,eAAe,EAAE,kBAAkB,EAAE,GAAE,CAAA;IAChF,KAAK,MAAM,OAAO,IAAI,cAAc,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9D,gDAAgD;QAChD,aAAa,GAAG,MAAM,IAAA,QAAA,sBAAsB,EAAC,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAA,CAAC,UAAU;IACzG,CAAC;IACD,OAAO,aAAa,CAAA;AACtB,CAAC,CAAA,CAAA;AAXY,QAAA,4BAA4B,GAA5B,4BAA4B,CAWxC","sourcesContent":["import * as SurveyNodeDefs from './nodeDefs'\nimport {\n NodeDef,\n NodeDefCode,\n NodeDefEntity,\n NodeDefExpression,\n NodeDefFile,\n NodeDefProps,\n NodeDefs,\n NodeDefType,\n} from '../../nodeDef'\nimport { NodeDefExpressionEvaluator } from '../../nodeDefExpressionEvaluator'\n\nimport { Survey, SurveyDependencyGraph, SurveyDependencyType } from '../survey'\nimport { Arrays, Objects } from '../../utils'\nimport { NodeDefExpressionFactory } from '../../nodeDef/nodeDef'\nimport { Dictionary } from '../../common'\n\nconst functionsRequiringOnUpdateDependency = ['recordDateLastModified']\n\nconst isContextParentByDependencyType = {\n [SurveyDependencyType.applicable]: true,\n [SurveyDependencyType.defaultValues]: true,\n [SurveyDependencyType.editable]: true,\n [SurveyDependencyType.enumeratingItems]: true,\n [SurveyDependencyType.fileName]: true,\n [SurveyDependencyType.formula]: false,\n [SurveyDependencyType.maxCount]: true,\n [SurveyDependencyType.minCount]: true,\n [SurveyDependencyType.onUpdate]: true,\n [SurveyDependencyType.parentCode]: false,\n [SurveyDependencyType.required]: true,\n [SurveyDependencyType.validations]: true,\n [SurveyDependencyType.visible]: true,\n}\n\nconst selfReferenceAllowedByDependencyType = {\n [SurveyDependencyType.applicable]: false,\n [SurveyDependencyType.defaultValues]: false,\n [SurveyDependencyType.editable]: false,\n [SurveyDependencyType.enumeratingItems]: false,\n [SurveyDependencyType.fileName]: false,\n [SurveyDependencyType.formula]: false,\n [SurveyDependencyType.maxCount]: false,\n [SurveyDependencyType.minCount]: false,\n [SurveyDependencyType.onUpdate]: false,\n [SurveyDependencyType.parentCode]: false,\n [SurveyDependencyType.required]: false,\n [SurveyDependencyType.validations]: true,\n [SurveyDependencyType.visible]: false,\n}\n\nconst newDependencyGraph = () => ({\n [SurveyDependencyType.applicable]: {},\n [SurveyDependencyType.defaultValues]: {},\n [SurveyDependencyType.editable]: {},\n [SurveyDependencyType.enumeratingItems]: {},\n [SurveyDependencyType.fileName]: {},\n [SurveyDependencyType.formula]: {},\n [SurveyDependencyType.maxCount]: {},\n [SurveyDependencyType.minCount]: {},\n [SurveyDependencyType.onUpdate]: {},\n [SurveyDependencyType.parentCode]: {},\n [SurveyDependencyType.required]: {},\n [SurveyDependencyType.validations]: {},\n [SurveyDependencyType.visible]: {},\n})\n\nconst getDependencyGraph = (survey: Survey): SurveyDependencyGraph => survey.dependencyGraph ?? newDependencyGraph()\n\nconst getDependencies = (params: {\n graphs: SurveyDependencyGraph\n type: SurveyDependencyType\n nodeDefUuid: string\n}): Array<string> => {\n const { graphs, type, nodeDefUuid } = params\n return type === SurveyDependencyType.onUpdate ? [] : ((graphs?.[type]?.[nodeDefUuid] ?? []) as string[])\n}\n\nexport const getNodeDefDependents = (params: {\n survey: Survey\n nodeDefUuid: string\n dependencyType?: SurveyDependencyType\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey, nodeDefUuid, dependencyType } = params\n const dependencyGraph = getDependencyGraph(survey)\n\n const dependentUuids = new Set<string>()\n\n const dependencyTypes: SurveyDependencyType[] = dependencyType\n ? [dependencyType]\n : Object.values(SurveyDependencyType)\n\n for (const depType of dependencyTypes) {\n const dependentUuidsTemp = getDependencies({ graphs: dependencyGraph, type: depType, nodeDefUuid })\n for (const dependentUuid of dependentUuidsTemp) {\n dependentUuids.add(dependentUuid)\n }\n }\n return dependentUuids.size > 0 ? SurveyNodeDefs.findNodeDefsByUuids({ survey, uuids: [...dependentUuids] }) : []\n}\n\nexport const getOnUpdateDependents = (params: { survey: Survey }) => {\n const { survey } = params\n const dependencyGraph = getDependencyGraph(survey)\n const sourceDefUuids = Object.keys(dependencyGraph[SurveyDependencyType.onUpdate] ?? {})\n return sourceDefUuids.length > 0 ? SurveyNodeDefs.findNodeDefsByUuids({ survey, uuids: sourceDefUuids }) : []\n}\n\n// UPDATE\n\nconst addDependency = (params: {\n graphs: SurveyDependencyGraph\n type: SurveyDependencyType\n nodeDefUuid: string\n nodeDefDepUuid: string\n sideEffect: boolean\n}): SurveyDependencyGraph => {\n const { graphs, type, nodeDefUuid, nodeDefDepUuid, sideEffect = false } = params\n const deps = getDependencies({ graphs, type, nodeDefUuid })\n const depsUpdated = Arrays.addItem(nodeDefDepUuid, { sideEffect })(deps)\n return Objects.assocPath({ obj: graphs, path: [type, nodeDefUuid], value: depsUpdated, sideEffect })\n}\n\nconst addDependencies = async (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType>\n type: SurveyDependencyType\n graphs: SurveyDependencyGraph\n expressions: NodeDefExpression[]\n sideEffect?: boolean\n}): Promise<SurveyDependencyGraph> => {\n const { survey, nodeDef, type, expressions, graphs: graphsParam, sideEffect = false } = params\n\n if (!expressions || expressions.length === 0) return graphsParam\n\n let graphsUpdated = sideEffect ? graphsParam : { ...graphsParam }\n\n const isContextParent = isContextParentByDependencyType[type]\n const selfReferenceAllowed = selfReferenceAllowedByDependencyType[type]\n\n const findReferencedNodeDefs = async (\n expression: string | undefined\n ): Promise<{ [key: string]: NodeDef<NodeDefType> }> => {\n if (!expression) return {}\n\n const referencedNodeDefUuids = await new NodeDefExpressionEvaluator().findReferencedNodeDefUuids({\n expression,\n survey,\n nodeDef,\n isContextParent,\n selfReferenceAllowed,\n })\n const referencedNodeDefsByUuid: Dictionary<NodeDef<any>> = {}\n for (const uuid of referencedNodeDefUuids) {\n referencedNodeDefsByUuid[uuid] = SurveyNodeDefs.getNodeDefByUuid({ survey, uuid })\n }\n return referencedNodeDefsByUuid\n }\n\n const referencedNodeDefsArray = await Promise.all(\n expressions.flatMap((nodeDefExpr) => [\n findReferencedNodeDefs(nodeDefExpr.expression),\n findReferencedNodeDefs(nodeDefExpr.applyIf),\n ])\n )\n const referencedNodeDefs: Dictionary<NodeDef<any>> = Object.assign({}, ...referencedNodeDefsArray)\n\n for (const nodeDefRef of Object.values(referencedNodeDefs)) {\n graphsUpdated = addDependency({\n graphs: graphsUpdated,\n type,\n nodeDefUuid: nodeDefRef.uuid,\n nodeDefDepUuid: nodeDef.uuid,\n sideEffect,\n })\n }\n\n return graphsUpdated\n}\n\nexport const addNodeDefDependencies = async (params: {\n nodeDef: NodeDef<NodeDefType>\n survey: Survey\n sideEffect?: boolean\n}): Promise<Survey> => {\n const { nodeDef, survey, sideEffect = false } = params\n const graphs = getDependencyGraph(survey)\n let graphsUpdated = sideEffect ? graphs : { ...graphs }\n\n const _addDependencies = async (type: SurveyDependencyType, expressions: NodeDefExpression[]) => {\n let _graphUpdated = await addDependencies({\n survey,\n nodeDef,\n type,\n expressions,\n graphs: graphsUpdated,\n sideEffect,\n })\n // add onUpdate dependencies\n if (\n expressions.some((expression) =>\n functionsRequiringOnUpdateDependency.some(\n (functionName) => expression.applyIf?.includes(functionName) || expression.expression?.includes(functionName)\n )\n )\n ) {\n _graphUpdated = Objects.assocPath({\n obj: _graphUpdated,\n path: [SurveyDependencyType.onUpdate, nodeDef.uuid],\n value: true,\n sideEffect,\n })\n }\n return _graphUpdated\n }\n graphsUpdated = await _addDependencies(SurveyDependencyType.applicable, NodeDefs.getApplicable(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.defaultValues, NodeDefs.getDefaultValues(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.editable, NodeDefs.getEditableIf(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.required, NodeDefs.getRequiredIf(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.validations, NodeDefs.getValidationsExpressions(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.visible, NodeDefs.getVisibleIf(nodeDef))\n const maxCount = NodeDefs.getMaxCount(nodeDef)\n if (Array.isArray(maxCount)) {\n graphsUpdated = await _addDependencies(SurveyDependencyType.maxCount, maxCount)\n }\n const minCount = NodeDefs.getMinCount(nodeDef)\n if (Array.isArray(minCount)) {\n graphsUpdated = await _addDependencies(SurveyDependencyType.minCount, minCount)\n }\n // file name expression\n if (NodeDefs.getType(nodeDef) === NodeDefType.file) {\n const fileNameExpression = NodeDefs.getFileNameExpression(nodeDef as NodeDefFile)\n if (fileNameExpression) {\n graphsUpdated = await _addDependencies(SurveyDependencyType.fileName, [\n NodeDefExpressionFactory.createInstance({ expression: fileNameExpression }),\n ])\n }\n }\n if (NodeDefs.isEntity(nodeDef)) {\n const enumeratingItemsExpression = NodeDefs.getEnumeratingItemsExpression(nodeDef as NodeDefEntity)\n if (enumeratingItemsExpression) {\n graphsUpdated = await _addDependencies(SurveyDependencyType.enumeratingItems, [\n NodeDefExpressionFactory.createInstance({ expression: enumeratingItemsExpression }),\n ])\n }\n }\n // parent code\n if (NodeDefs.getType(nodeDef) === NodeDefType.code) {\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(nodeDef as NodeDefCode)\n if (parentCodeDefUuid) {\n graphsUpdated = addDependency({\n graphs: graphsUpdated,\n type: SurveyDependencyType.parentCode,\n nodeDefUuid: parentCodeDefUuid,\n nodeDefDepUuid: nodeDef.uuid,\n sideEffect,\n })\n }\n }\n if (sideEffect) {\n survey.dependencyGraph = graphsUpdated\n return survey\n }\n return { ...survey, dependencyGraph: graphsUpdated }\n}\n\n// DELETE\n\nconst _removeNodeDefDependenciesOfType = (params: {\n graphs: SurveyDependencyGraph\n dependencyType: SurveyDependencyType\n nodeDefUuid: string\n}): SurveyDependencyGraph => {\n const { graphs, nodeDefUuid, dependencyType } = params\n\n const graphsUpdated = { ...graphs }\n let graphUpdated = { ...graphsUpdated[dependencyType] }\n // dissoc nodeDefUuid dependency as dependent\n graphUpdated = Objects.dissoc({ obj: graphUpdated, prop: nodeDefUuid })\n\n if (dependencyType !== SurveyDependencyType.onUpdate) {\n // dissoc nodeDefUuid dependency from sources (if any)\n for (const [key, dependentUuids] of Object.entries(graphUpdated)) {\n graphUpdated[key] = Arrays.removeItem(nodeDefUuid)(dependentUuids as string[])\n }\n }\n\n graphsUpdated[dependencyType] = graphUpdated\n return graphsUpdated\n}\n\nexport const removeNodeDefDependencies = (params: {\n survey: Survey\n nodeDefUuid: string\n dependencyType?: SurveyDependencyType\n}): Survey => {\n const { survey, nodeDefUuid, dependencyType = null } = params\n const graphs = getDependencyGraph(survey)\n const dependencyTypes = dependencyType ? [dependencyType] : (Object.keys(graphs) as SurveyDependencyType[])\n const graphsUpdated = dependencyTypes.reduce(\n (dependencyGraphAcc, type) =>\n _removeNodeDefDependenciesOfType({ graphs: dependencyGraphAcc, dependencyType: type, nodeDefUuid }),\n graphs\n )\n return { ...survey, dependencyGraph: graphsUpdated }\n}\n\n/**\n * Builds the dependency graph of the survey.\n *\n * @param survey - The survey.\n * @returns A copy of the survey with the dependency graph (the survey passed in is not modified).\n */\nexport const buildAndAssocDependencyGraph = async (survey: Survey): Promise<Survey> => {\n // the new graph is built from scratch with side effect (to avoid re-creating objects): it belongs only to the copy of the survey\n const sideEffect = true\n\n // add dependencies for every node def\n let surveyUpdated: Survey = { ...survey, dependencyGraph: newDependencyGraph() }\n for (const nodeDef of SurveyNodeDefs.getNodeDefsArray(survey)) {\n // sequential: each iteration updates the survey\n surveyUpdated = await addNodeDefDependencies({ nodeDef, survey: surveyUpdated, sideEffect }) // NOSONAR\n }\n return surveyUpdated\n}\n"]}
@@ -68,7 +68,7 @@ class AttributeBuilder extends nodeBuilder_1.NodeBuilder {
68
68
  if (nodeDef.type === nodeDef_1.NodeDefType.code) {
69
69
  const nodeDefCode = nodeDef;
70
70
  if (nodeDefCode.props.parentCodeDefUuid && parentNode) {
71
- const parentCodeAttribute = record_1.Records.getParentCodeAttribute({ parentNode, nodeDef: nodeDefCode })(record);
71
+ const parentCodeAttribute = record_1.Records.getParentCodeAttribute(parentNode, nodeDefCode)(record);
72
72
  if (!parentCodeAttribute)
73
73
  throw new Error('Could not find the parent code attibute');
74
74
  return Object.assign(Object.assign({}, meta), { hCode: [parentCodeAttribute.uuid] });
@@ -1 +1 @@
1
- {"version":3,"file":"attributeBuilder.js","sourceRoot":"","sources":["../../../../src/tests/builder/recordBuilder/attributeBuilder.ts"],"names":[],"mappings":";;;AAAA,wCAA2F;AAE3F,8CAAkF;AAClF,4CAAsD;AACtD,4CAAiD;AACjD,+CAA2C;AAE3C,sBAA8B,SAAQ,yBAAW;IAG/C,YAAY,WAAmB,EAAE,KAAK,GAAQ,IAAI;QAChD,KAAK,CAAC,WAAW,CAAC,CAAA;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA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AAE,CAAC,CAAC,MAAM,CAAC,CAAA;gBACxG,IAAI,CAAC,mBAAmB;oBAAE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAA;gBACpF,uCAAY,IAAI,KAAE,KAAK,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAE;YACvD,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;IAED,KAAK,CAAC,MAA6E;QACjF,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAA;QAE7C,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;QAE3C,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;QAEzC,MAAM,SAAS,GAAG,kBAAW,CAAC,cAAc,CAAC;YAC3C,WAAW,EAAE,OAAO,CAAC,IAAI;YACzB,UAAU;YACV,UAAU,EAAE,MAAM,CAAC,IAAI;YACvB,KAAK;SACN,CAAC,CAAA;QACF,SAAS,CAAC,IAAI,mCACT,SAAS,CAAC,IAAI,GACd,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CACnD,CAAA;QACD,OAAO,gBAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAA;IAC3C,CAAC;CACF","sourcesContent":["import { ArenaRecordNode, NodeFactory, NodeValueCode, NodeValueTaxon } from '../../../node'\nimport { NodeMeta } from '../../../node/node'\nimport { NodeDef, NodeDefCode, NodeDefTaxon, NodeDefType } from '../../../nodeDef'\nimport { ArenaRecord, Records } from '../../../record'\nimport { Survey, Surveys } from '../../../survey'\nimport { NodeBuilder } from './nodeBuilder'\n\nexport class AttributeBuilder extends NodeBuilder {\n private readonly value: any\n\n constructor(nodeDefName: string, value: any = null) {\n super(nodeDefName)\n this.value = value\n }\n\n private buildCodeValue(params: { survey: Survey; nodeDef: NodeDefCode }) {\n const { survey, nodeDef } = params\n\n if (this.value.itemUuid) {\n // value is already a NodeValueCode object\n return this.value\n }\n\n const code = this.value\n const item = Surveys.getCategoryItemByCodePaths({\n survey,\n categoryUuid: nodeDef.props.categoryUuid,\n codePaths: [code],\n })\n if (!item) {\n throw new Error(`could not find category item with code: ${code}`)\n }\n\n return {\n itemUuid: item.uuid,\n code: item.props.code,\n } as NodeValueCode\n }\n\n private buildTaxonValue(params: { survey: Survey; nodeDef: NodeDefTaxon }) {\n const { survey, nodeDef } = params\n\n if (this.value.taxonUuid) {\n // value is already a NodeValueTaxon object\n return this.value\n }\n const taxonCode = this.value.code || this.value\n const taxonomyUuid = nodeDef.props.taxonomyUuid\n\n const taxon = Surveys.getTaxonByCode({ survey, taxonomyUuid, taxonCode })\n if (!taxon) {\n throw new Error(`could not find taxon with code: ${JSON.stringify(taxonCode)}`)\n }\n\n return {\n taxonUuid: taxon.uuid,\n code: taxon.props.code,\n scientificName: taxon.props.scientificName,\n } as NodeValueTaxon\n }\n\n private buildValue(params: { survey: Survey }) {\n const { survey } = params\n const nodeDef = this.getNodeDef({ survey })\n\n if (this.value === null || this.value === undefined) return null\n\n if (nodeDef.type === NodeDefType.code) {\n return this.buildCodeValue({ survey, nodeDef: nodeDef as NodeDefCode })\n }\n if (nodeDef.type === NodeDefType.taxon) {\n return this.buildTaxonValue({ survey, nodeDef: nodeDef as NodeDefTaxon })\n }\n return this.value\n }\n\n private buildMeta(params: { nodeDef: NodeDef<any>; record: ArenaRecord; parentNode?: ArenaRecordNode }): NodeMeta {\n const { nodeDef, record, parentNode } = params\n\n const meta: NodeMeta = {}\n\n if (nodeDef.type === NodeDefType.code) {\n const nodeDefCode = nodeDef as NodeDefCode\n if (nodeDefCode.props.parentCodeDefUuid && parentNode) {\n const parentCodeAttribute = Records.getParentCodeAttribute({ parentNode, nodeDef: nodeDefCode })(record)\n if (!parentCodeAttribute) throw new Error('Could not find the parent code attibute')\n return { ...meta, hCode: [parentCodeAttribute.uuid] }\n }\n }\n\n return meta\n }\n\n build(params: { survey: Survey; record: ArenaRecord; parentNode?: ArenaRecordNode }): ArenaRecord {\n const { survey, record, parentNode } = params\n\n const nodeDef = this.getNodeDef({ survey })\n\n const value = this.buildValue({ survey })\n\n const attribute = NodeFactory.createInstance({\n nodeDefUuid: nodeDef.uuid,\n parentNode,\n recordUuid: record.uuid,\n value,\n })\n attribute.meta = {\n ...attribute.meta,\n ...this.buildMeta({ nodeDef, parentNode, record }),\n }\n return Records.addNode(attribute)(record)\n }\n}\n"]}
1
+ {"version":3,"file":"attributeBuilder.js","sourceRoot":"","sources":["../../../../src/tests/builder/recordBuilder/attributeBuilder.ts"],"names":[],"mappings":";;;AAAA,wCAA2F;AAE3F,8CAAkF;AAClF,4CAAsD;AACtD,4CAAiD;AACjD,+CAA2C;AAE3C,sBAA8B,SAAQ,yBAAW;IAG/C,YAAY,WAAmB,EAAE,KAAK,GAAQ,IAAI;QAChD,KAAK,CAAC,WAAW,CAAC,CAAA;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAEO,cAAc,CAAC,MAAgD;QACrE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;QAElC,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACxB,0CAA0C;YAC1C,OAAO,IAAI,CAAC,KAAK,CAAA;QACnB,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAA;QACvB,MAAM,IAAI,GAAG,gBAAO,CAAC,0BAA0B,CAAC;YAC9C,MAAM;YACN,YAAY,EAAE,OAAO,CAAC,KAAK,CAAC,YAAY;YACxC,SAAS,EAAE,CAAC,IAAI,CAAC;SAClB,CAAC,CAAA;QACF,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,2CAA2C,IAAI,EAAE,CAAC,CAAA;QACpE,CAAC;QAED,OAAO;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OAAO,CAAC,IAAI;YACzB,UAAU;YACV,UAAU,EAAE,MAAM,CAAC,IAAI;YACvB,KAAK;SACN,CAAC,CAAA;QACF,SAAS,CAAC,IAAI,mCACT,SAAS,CAAC,IAAI,GACd,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CACnD,CAAA;QACD,OAAO,gBAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAA;IAC3C,CAAC;CACF","sourcesContent":["import { ArenaRecordNode, NodeFactory, NodeValueCode, NodeValueTaxon } from '../../../node'\nimport { NodeMeta } from '../../../node/node'\nimport { NodeDef, NodeDefCode, NodeDefTaxon, NodeDefType } from '../../../nodeDef'\nimport { ArenaRecord, Records } from '../../../record'\nimport { Survey, Surveys } from '../../../survey'\nimport { NodeBuilder } from './nodeBuilder'\n\nexport class AttributeBuilder extends NodeBuilder {\n private readonly value: any\n\n constructor(nodeDefName: string, value: any = null) {\n super(nodeDefName)\n this.value = value\n }\n\n private buildCodeValue(params: { survey: Survey; nodeDef: NodeDefCode }) {\n const { survey, nodeDef } = params\n\n if (this.value.itemUuid) {\n // value is already a NodeValueCode object\n return this.value\n }\n\n const code = this.value\n const item = Surveys.getCategoryItemByCodePaths({\n survey,\n categoryUuid: nodeDef.props.categoryUuid,\n codePaths: [code],\n })\n if (!item) {\n throw new Error(`could not find category item with code: ${code}`)\n }\n\n return {\n itemUuid: item.uuid,\n code: item.props.code,\n } as NodeValueCode\n }\n\n private buildTaxonValue(params: { survey: Survey; nodeDef: NodeDefTaxon }) {\n const { survey, nodeDef } = params\n\n if (this.value.taxonUuid) {\n // value is already a NodeValueTaxon object\n return this.value\n }\n const taxonCode = this.value.code || this.value\n const taxonomyUuid = nodeDef.props.taxonomyUuid\n\n const taxon = Surveys.getTaxonByCode({ survey, taxonomyUuid, taxonCode })\n if (!taxon) {\n throw new Error(`could not find taxon with code: ${JSON.stringify(taxonCode)}`)\n }\n\n return {\n taxonUuid: taxon.uuid,\n code: taxon.props.code,\n scientificName: taxon.props.scientificName,\n } as NodeValueTaxon\n }\n\n private buildValue(params: { survey: Survey }) {\n const { survey } = params\n const nodeDef = this.getNodeDef({ survey })\n\n if (this.value === null || this.value === undefined) return null\n\n if (nodeDef.type === NodeDefType.code) {\n return this.buildCodeValue({ survey, nodeDef: nodeDef as NodeDefCode })\n }\n if (nodeDef.type === NodeDefType.taxon) {\n return this.buildTaxonValue({ survey, nodeDef: nodeDef as NodeDefTaxon })\n }\n return this.value\n }\n\n private buildMeta(params: { nodeDef: NodeDef<any>; record: ArenaRecord; parentNode?: ArenaRecordNode }): NodeMeta {\n const { nodeDef, record, parentNode } = params\n\n const meta: NodeMeta = {}\n\n if (nodeDef.type === NodeDefType.code) {\n const nodeDefCode = nodeDef as NodeDefCode\n if (nodeDefCode.props.parentCodeDefUuid && parentNode) {\n const parentCodeAttribute = Records.getParentCodeAttribute(parentNode, nodeDefCode)(record)\n if (!parentCodeAttribute) throw new Error('Could not find the parent code attibute')\n return { ...meta, hCode: [parentCodeAttribute.uuid] }\n }\n }\n\n return meta\n }\n\n build(params: { survey: Survey; record: ArenaRecord; parentNode?: ArenaRecordNode }): ArenaRecord {\n const { survey, record, parentNode } = params\n\n const nodeDef = this.getNodeDef({ survey })\n\n const value = this.buildValue({ survey })\n\n const attribute = NodeFactory.createInstance({\n nodeDefUuid: nodeDef.uuid,\n parentNode,\n recordUuid: record.uuid,\n value,\n })\n attribute.meta = {\n ...attribute.meta,\n ...this.buildMeta({ nodeDef, parentNode, record }),\n }\n return Records.addNode(attribute)(record)\n }\n}\n"]}
@@ -21,5 +21,6 @@ export declare abstract class NodeDefBuilder {
21
21
  visibleIf(...expressions: (string | NodeDefExpression)[]): this;
22
22
  maxCount(countExpr: NodeDefCountExpression): this;
23
23
  minCount(countExpr: NodeDefCountExpression): this;
24
+ requiredIf(...expressions: (string | NodeDefExpression)[]): this;
24
25
  required(): this;
25
26
  }
@@ -54,6 +54,14 @@ class NodeDefBuilder {
54
54
  sideEffect: true,
55
55
  });
56
56
  }
57
+ requiredIf(...expressions) {
58
+ return utils_1.Objects.assocPath({
59
+ obj: this,
60
+ path: ['propsAdvanced', 'validations', 'requiredIf'],
61
+ value: expressions.map((expression) => typeof expression === 'string' ? nodeDef_2.NodeDefExpressionFactory.createInstance({ expression }) : expression),
62
+ sideEffect: true,
63
+ });
64
+ }
57
65
  required() {
58
66
  return utils_1.Objects.assocPath({
59
67
  obj: this,
@@ -1 +1 @@
1
- {"version":3,"file":"nodeDefBuilder.js","sourceRoot":"","sources":["../../../../src/tests/builder/surveyBuilder/nodeDefBuilder.ts"],"names":[],"mappings":";;;AACA,8CAOyB;AACzB,sDAA8G;AAC9G,0CAAwC;AAExC;IAKE,YAAY,IAAY,EAAE,IAAiB;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,KAAK,GAAG;YACX,IAAI;SACL,CAAA;QACD,IAAI,CAAC,aAAa,GAAG,EAAE,CAAA;IACzB,CAAC;IAES,aAAa,CAAC,MAAM,GAAsC,EAAE;QACpE,MAAM,OAAO,GAAG,wBAAc,CAAC,cAAc,CAAC;YAC5C,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,aAAa,EAAE,IAAI,CAAC,aAAa;SAClC,CAAC,CAAA;QACF,OAAO,CAAC,SAAS,GAAG,KAAK,CAAA;QACzB,OAAO,OAAO,CAAA;IAChB,CAAC;IAID,QAAQ;QACN,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAA;QAC1B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,CAAC,UAAkB;QACxB,IAAI,CAAC,aAAa,CAAC,UAAU,GAAG,CAAC,kCAAwB,CAAC,cAAc,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAA;QACzF,OAAO,IAAI,C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EAAE,IAAI;SACjB,CAAC,CAAA;IACJ,CAAC;CACF","sourcesContent":["import { Survey } from '../../../survey'\nimport {\n NodeDef,\n NodeDefFactory,\n NodeDefEntity,\n NodeDefProps,\n NodeDefPropsAdvanced,\n NodeDefType,\n} from '../../../nodeDef'\nimport { NodeDefCountExpression, NodeDefExpression, NodeDefExpressionFactory } from '../../../nodeDef/nodeDef'\nimport { Objects } from '../../../utils'\n\nexport abstract class NodeDefBuilder {\n protected props: NodeDefProps\n protected propsAdvanced: NodeDefPropsAdvanced\n protected type: NodeDefType\n\n constructor(name: string, type: NodeDefType) {\n this.type = type\n this.props = {\n name,\n }\n this.propsAdvanced = {}\n }\n\n protected createNodeDef(params: { nodeDefParent?: NodeDefEntity } = {}): NodeDef<NodeDefType, NodeDefProps> {\n const nodeDef = NodeDefFactory.createInstance({\n nodeDefParent: params.nodeDefParent,\n type: this.type,\n props: this.props,\n propsAdvanced: this.propsAdvanced,\n })\n nodeDef.temporary = false\n return nodeDef\n }\n\n abstract build(params: { survey: Survey; nodeDefParent?: NodeDefEntity }): { [uuid: string]: NodeDef<NodeDefType> }\n\n multiple(): this {\n this.props.multiple = true\n return this\n }\n\n applyIf(expression: string): this {\n this.propsAdvanced.applicable = [NodeDefExpressionFactory.createInstance({ expression })]\n return this\n }\n\n editableIf(...expressions: (string | NodeDefExpression)[]): this {\n this.propsAdvanced.editableIf = expressions.map((expression) =>\n typeof expression === 'string' ? NodeDefExpressionFactory.createInstance({ expression }) : expression\n )\n return this\n }\n\n visibleIf(...expressions: (string | NodeDefExpression)[]): this {\n this.propsAdvanced.visibleIf = expressions.map((expression) =>\n typeof expression === 'string' ? NodeDefExpressionFactory.createInstance({ expression }) : expression\n )\n return this\n }\n\n maxCount(countExpr: NodeDefCountExpression): this {\n return Objects.assocPath({\n obj: this,\n path: ['propsAdvanced', 'validations', 'count', 'max'],\n value: countExpr,\n sideEffect: true,\n })\n }\n\n minCount(countExpr: NodeDefCountExpression): this {\n return Objects.assocPath({\n obj: this,\n path: ['propsAdvanced', 'validations', 'count', 'min'],\n value: countExpr,\n sideEffect: true,\n })\n }\n\n required(): this {\n return Objects.assocPath({\n obj: this,\n path: ['propsAdvanced', 'validations', 'required'],\n value: true,\n sideEffect: true,\n })\n }\n}\n"]}
1
+ {"version":3,"file":"nodeDefBuilder.js","sourceRoot":"","sources":["../../../../src/tests/builder/surveyBuilder/nodeDefBuilder.ts"],"names":[],"mappings":";;;AACA,8CAOyB;AACzB,sDAA8G;AAC9G,0CAAwC;AAExC;IAKE,YAAY,IAAY,EAAE,IAAiB;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,KAAK,GAAG;YACX,IAAI;SACL,CAAA;QACD,IAAI,CAAC,aAAa,GAAG,EAAE,CAAA;IACzB,CAAC;IAES,aAAa,CAAC,MAAM,GAAsC,EAAE;QACpE,MAAM,OAAO,GAAG,wBAAc,CAAC,cAAc,CAAC;YAC5C,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,aAAa,EAAE,IAAI,CAAC,aAAa;SAClC,CAAC,CAAA;QACF,OAAO,CAAC,SAAS,GAAG,KAAK,CAAA;QACzB,OAAO,OAAO,CAAA;IAChB,CAAC;IAID,QAAQ;QACN,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAA;QAC1B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,CAAC,UAAkB;QACxB,IAAI,CAAC,aAAa,CAAC,UAAU,GAAG,CAAC,kCAAwB,CAAC,cAAc,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAA;QACzF,OAAO,IAAI,CAAA;IACb,CAAC;IAED,UAAU,CAAC,GAAG,WAA2C;QACvD,IAAI,CAAC,aAAa,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAC7D,OAAO,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,CAAC,CAAC,CAAC,UAAU,CACtG;YACD,UAAU,EAAE,IAAI;SACjB,CAAC,CAAA;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,eAAO,CAAC,SAAS,CAAC;YACvB,GAAG,EAAE,IAAI;YACT,IAAI,EAAE,CAAC,eAAe,EAAE,aAAa,EAAE,UAAU,CAAC;YAClD,KAAK,EAAE,IAAI;YACX,UAAU,EAAE,IAAI;SACjB,CAAC,CAAA;IACJ,CAAC;CACF","sourcesContent":["import { Survey } from '../../../survey'\nimport {\n NodeDef,\n NodeDefFactory,\n NodeDefEntity,\n NodeDefProps,\n NodeDefPropsAdvanced,\n NodeDefType,\n} from '../../../nodeDef'\nimport { NodeDefCountExpression, NodeDefExpression, NodeDefExpressionFactory } from '../../../nodeDef/nodeDef'\nimport { Objects } from '../../../utils'\n\nexport abstract class NodeDefBuilder {\n protected props: NodeDefProps\n protected propsAdvanced: NodeDefPropsAdvanced\n protected type: NodeDefType\n\n constructor(name: string, type: NodeDefType) {\n this.type = type\n this.props = {\n name,\n }\n this.propsAdvanced = {}\n }\n\n protected createNodeDef(params: { nodeDefParent?: NodeDefEntity } = {}): NodeDef<NodeDefType, NodeDefProps> {\n const nodeDef = NodeDefFactory.createInstance({\n nodeDefParent: params.nodeDefParent,\n type: this.type,\n props: this.props,\n propsAdvanced: this.propsAdvanced,\n })\n nodeDef.temporary = false\n return nodeDef\n }\n\n abstract build(params: { survey: Survey; nodeDefParent?: NodeDefEntity }): { [uuid: string]: NodeDef<NodeDefType> }\n\n multiple(): this {\n this.props.multiple = true\n return this\n }\n\n applyIf(expression: string): this {\n this.propsAdvanced.applicable = [NodeDefExpressionFactory.createInstance({ expression })]\n return this\n }\n\n editableIf(...expressions: (string | NodeDefExpression)[]): this {\n this.propsAdvanced.editableIf = expressions.map((expression) =>\n typeof expression === 'string' ? NodeDefExpressionFactory.createInstance({ expression }) : expression\n )\n return this\n }\n\n visibleIf(...expressions: (string | NodeDefExpression)[]): this {\n this.propsAdvanced.visibleIf = expressions.map((expression) =>\n typeof expression === 'string' ? NodeDefExpressionFactory.createInstance({ expression }) : expression\n )\n return this\n }\n\n maxCount(countExpr: NodeDefCountExpression): this {\n return Objects.assocPath({\n obj: this,\n path: ['propsAdvanced', 'validations', 'count', 'max'],\n value: countExpr,\n sideEffect: true,\n })\n }\n\n minCount(countExpr: NodeDefCountExpression): this {\n return Objects.assocPath({\n obj: this,\n path: ['propsAdvanced', 'validations', 'count', 'min'],\n value: countExpr,\n sideEffect: true,\n })\n }\n\n requiredIf(...expressions: (string | NodeDefExpression)[]): this {\n return Objects.assocPath({\n obj: this,\n path: ['propsAdvanced', 'validations', 'requiredIf'],\n value: expressions.map((expression) =>\n typeof expression === 'string' ? NodeDefExpressionFactory.createInstance({ expression }) : expression\n ),\n sideEffect: true,\n })\n }\n\n required(): this {\n return Objects.assocPath({\n obj: this,\n path: ['propsAdvanced', 'validations', 'required'],\n value: true,\n sideEffect: true,\n })\n }\n}\n"]}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "OpenForis",
5
5
  "email": "openforis.arena@gmail.com"
6
6
  },
7
- "version": "2.5.15",
7
+ "version": "2.7.0",
8
8
  "description": "Arena core module",
9
9
  "repository": {
10
10
  "type": "git",