@openforis/arena-core 2.3.39 → 2.3.41

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 (163) hide show
  1. package/dist/auth/authorizer.d.ts +3 -3
  2. package/dist/auth/authorizer.js.map +1 -1
  3. package/dist/esm/auth/authorizer.js.map +1 -1
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/esm/node/factory.js.map +1 -1
  6. package/dist/esm/node/index.js.map +1 -1
  7. package/dist/esm/node/node.js.map +1 -1
  8. package/dist/esm/node/nodePointer.js.map +1 -1
  9. package/dist/esm/node/nodeValueFormatter.js.map +1 -1
  10. package/dist/esm/node/nodeValues.js.map +1 -1
  11. package/dist/esm/node/nodes.js +1 -1
  12. package/dist/esm/node/nodes.js.map +1 -1
  13. package/dist/esm/node/service.js.map +1 -1
  14. package/dist/esm/nodeDefExpressionEvaluator/functions.js.map +1 -1
  15. package/dist/esm/record/_records/recordCompletion.js.map +1 -1
  16. package/dist/esm/record/_records/recordGetters.js.map +1 -1
  17. package/dist/esm/record/_records/recordNodesIndexUpdater.js.map +1 -1
  18. package/dist/esm/record/_records/recordPagesValidation.js.map +1 -1
  19. package/dist/esm/record/_records/recordUpdater.js.map +1 -1
  20. package/dist/esm/record/_records/recordUtils.js.map +1 -1
  21. package/dist/esm/record/factory.js.map +1 -1
  22. package/dist/esm/record/index.js.map +1 -1
  23. package/dist/esm/record/nodePointers.js.map +1 -1
  24. package/dist/esm/record/record.js.map +1 -1
  25. package/dist/esm/record/recordCloner.js.map +1 -1
  26. package/dist/esm/record/recordExpressionEvaluator/context.js.map +1 -1
  27. package/dist/esm/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
  28. package/dist/esm/record/recordExpressionEvaluator/node/identifier/nodesFinder.js.map +1 -1
  29. package/dist/esm/record/recordExpressionEvaluator/nodeValueExtractor.js.map +1 -1
  30. package/dist/esm/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
  31. package/dist/esm/record/recordFixer.js.map +1 -1
  32. package/dist/esm/record/recordNodesUpdater/recordEnumeratingItemsExpressionEvaluator.js.map +1 -1
  33. package/dist/esm/record/recordNodesUpdater/recordExpressionValueConverter.js.map +1 -1
  34. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js.map +1 -1
  35. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js.map +1 -1
  36. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js.map +1 -1
  37. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js.map +1 -1
  38. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js.map +1 -1
  39. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js.map +1 -1
  40. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
  41. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsUpdateParams.js.map +1 -1
  42. package/dist/esm/record/recordNodesUpdater/recordNodesCreator.js.map +1 -1
  43. package/dist/esm/record/recordNodesUpdater/recordNodesDeleter.js.map +1 -1
  44. package/dist/esm/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
  45. package/dist/esm/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
  46. package/dist/esm/record/recordNodesUpdater/recordUpdateResult.js.map +1 -1
  47. package/dist/esm/record/recordPrettyPrinter.js.map +1 -1
  48. package/dist/esm/record/recordUpdater.js.map +1 -1
  49. package/dist/esm/record/recordValidator/attributeKeyValidator.js.map +1 -1
  50. package/dist/esm/record/recordValidator/attributeTypeValidator.js.map +1 -1
  51. package/dist/esm/record/recordValidator/attributeUniqueValidator.js.map +1 -1
  52. package/dist/esm/record/recordValidator/attributeValidator.js.map +1 -1
  53. package/dist/esm/record/recordValidator/countVaildator.js.map +1 -1
  54. package/dist/esm/record/recordValidator/recordValidator.js.map +1 -1
  55. package/dist/esm/record/service.js.map +1 -1
  56. package/dist/esm/tests/builder/recordBuilder/attributeBuilder.js.map +1 -1
  57. package/dist/esm/tests/builder/recordBuilder/entityBuilder.js.map +1 -1
  58. package/dist/esm/tests/builder/recordBuilder/nodeBuilder.js.map +1 -1
  59. package/dist/esm/tests/builder/recordBuilder/recordBuilder.js.map +1 -1
  60. package/dist/index.d.ts +2 -2
  61. package/dist/index.js.map +1 -1
  62. package/dist/node/factory.d.ts +4 -4
  63. package/dist/node/factory.js.map +1 -1
  64. package/dist/node/index.d.ts +1 -2
  65. package/dist/node/index.js.map +1 -1
  66. package/dist/node/node.d.ts +7 -2
  67. package/dist/node/node.js.map +1 -1
  68. package/dist/node/nodePointer.d.ts +2 -2
  69. package/dist/node/nodePointer.js.map +1 -1
  70. package/dist/node/nodeValueFormatter.d.ts +2 -2
  71. package/dist/node/nodeValueFormatter.js.map +1 -1
  72. package/dist/node/nodeValues.d.ts +21 -21
  73. package/dist/node/nodeValues.js.map +1 -1
  74. package/dist/node/nodes.d.ts +31 -31
  75. package/dist/node/nodes.js +1 -1
  76. package/dist/node/nodes.js.map +1 -1
  77. package/dist/node/service.d.ts +6 -6
  78. package/dist/node/service.js.map +1 -1
  79. package/dist/nodeDefExpressionEvaluator/functions.js.map +1 -1
  80. package/dist/record/_records/recordCompletion.d.ts +9 -9
  81. package/dist/record/_records/recordCompletion.js.map +1 -1
  82. package/dist/record/_records/recordGetters.d.ts +69 -69
  83. package/dist/record/_records/recordGetters.js.map +1 -1
  84. package/dist/record/_records/recordNodesIndexUpdater.d.ts +9 -9
  85. package/dist/record/_records/recordNodesIndexUpdater.js.map +1 -1
  86. package/dist/record/_records/recordPagesValidation.d.ts +11 -11
  87. package/dist/record/_records/recordPagesValidation.js.map +1 -1
  88. package/dist/record/_records/recordUpdater.d.ts +5 -5
  89. package/dist/record/_records/recordUpdater.js.map +1 -1
  90. package/dist/record/_records/recordUtils.d.ts +6 -6
  91. package/dist/record/_records/recordUtils.js.map +1 -1
  92. package/dist/record/factory.d.ts +2 -2
  93. package/dist/record/factory.js.map +1 -1
  94. package/dist/record/index.d.ts +1 -2
  95. package/dist/record/index.js.map +1 -1
  96. package/dist/record/nodePointers.d.ts +6 -6
  97. package/dist/record/nodePointers.js.map +1 -1
  98. package/dist/record/record.d.ts +8 -5
  99. package/dist/record/record.js.map +1 -1
  100. package/dist/record/recordCloner.d.ts +3 -3
  101. package/dist/record/recordCloner.js.map +1 -1
  102. package/dist/record/recordExpressionEvaluator/context.d.ts +6 -6
  103. package/dist/record/recordExpressionEvaluator/context.js.map +1 -1
  104. package/dist/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
  105. package/dist/record/recordExpressionEvaluator/node/identifier/nodesFinder.d.ts +5 -5
  106. package/dist/record/recordExpressionEvaluator/node/identifier/nodesFinder.js.map +1 -1
  107. package/dist/record/recordExpressionEvaluator/nodeValueExtractor.d.ts +2 -2
  108. package/dist/record/recordExpressionEvaluator/nodeValueExtractor.js.map +1 -1
  109. package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.d.ts +4 -4
  110. package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
  111. package/dist/record/recordFixer.js.map +1 -1
  112. package/dist/record/recordNodesUpdater/recordEnumeratingItemsExpressionEvaluator.d.ts +4 -4
  113. package/dist/record/recordNodesUpdater/recordEnumeratingItemsExpressionEvaluator.js.map +1 -1
  114. package/dist/record/recordNodesUpdater/recordExpressionValueConverter.d.ts +4 -4
  115. package/dist/record/recordNodesUpdater/recordExpressionValueConverter.js.map +1 -1
  116. package/dist/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js.map +1 -1
  117. package/dist/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.d.ts +3 -3
  118. package/dist/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js.map +1 -1
  119. package/dist/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js.map +1 -1
  120. package/dist/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js.map +1 -1
  121. package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.d.ts +2 -2
  122. package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js.map +1 -1
  123. package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.d.ts +2 -2
  124. package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js.map +1 -1
  125. package/dist/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
  126. package/dist/record/recordNodesUpdater/recordNodeDependentsUpdateParams.d.ts +2 -2
  127. package/dist/record/recordNodesUpdater/recordNodeDependentsUpdateParams.js.map +1 -1
  128. package/dist/record/recordNodesUpdater/recordNodesCreator.d.ts +4 -4
  129. package/dist/record/recordNodesUpdater/recordNodesCreator.js.map +1 -1
  130. package/dist/record/recordNodesUpdater/recordNodesDeleter.d.ts +3 -3
  131. package/dist/record/recordNodesUpdater/recordNodesDeleter.js.map +1 -1
  132. package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.d.ts +4 -4
  133. package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
  134. package/dist/record/recordNodesUpdater/recordNodesUpdater.d.ts +2 -2
  135. package/dist/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
  136. package/dist/record/recordNodesUpdater/recordUpdateResult.d.ts +6 -6
  137. package/dist/record/recordNodesUpdater/recordUpdateResult.js.map +1 -1
  138. package/dist/record/recordPrettyPrinter.d.ts +7 -7
  139. package/dist/record/recordPrettyPrinter.js.map +1 -1
  140. package/dist/record/recordUpdater.js.map +1 -1
  141. package/dist/record/recordValidator/attributeKeyValidator.d.ts +4 -4
  142. package/dist/record/recordValidator/attributeKeyValidator.js.map +1 -1
  143. package/dist/record/recordValidator/attributeTypeValidator.d.ts +4 -4
  144. package/dist/record/recordValidator/attributeTypeValidator.js.map +1 -1
  145. package/dist/record/recordValidator/attributeUniqueValidator.d.ts +4 -4
  146. package/dist/record/recordValidator/attributeUniqueValidator.js.map +1 -1
  147. package/dist/record/recordValidator/attributeValidator.d.ts +6 -6
  148. package/dist/record/recordValidator/attributeValidator.js.map +1 -1
  149. package/dist/record/recordValidator/countVaildator.d.ts +7 -7
  150. package/dist/record/recordValidator/countVaildator.js.map +1 -1
  151. package/dist/record/recordValidator/recordValidator.js.map +1 -1
  152. package/dist/record/records.d.ts +6 -6
  153. package/dist/record/service.d.ts +8 -8
  154. package/dist/record/service.js.map +1 -1
  155. package/dist/tests/builder/recordBuilder/attributeBuilder.d.ts +5 -5
  156. package/dist/tests/builder/recordBuilder/attributeBuilder.js.map +1 -1
  157. package/dist/tests/builder/recordBuilder/entityBuilder.d.ts +5 -5
  158. package/dist/tests/builder/recordBuilder/entityBuilder.js.map +1 -1
  159. package/dist/tests/builder/recordBuilder/nodeBuilder.d.ts +5 -5
  160. package/dist/tests/builder/recordBuilder/nodeBuilder.js.map +1 -1
  161. package/dist/tests/builder/recordBuilder/recordBuilder.d.ts +2 -2
  162. package/dist/tests/builder/recordBuilder/recordBuilder.js.map +1 -1
  163. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"attributeKeyValidator.js","sourceRoot":"","sources":["../../../../src/record/recordValidator/attributeKeyValidator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAW,QAAQ,EAA6B,MAAM,eAAe,CAAA;AAC5E,OAAO,EAAQ,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EAAoB,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAChG,OAAO,EAAU,OAAO,EAAE,MAAM,cAAc,CAAA;AAG9C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAWrC,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAoB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,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC,EAAE,CAAC;YAC9E,OAAO,OAAO,CAAC,OAAO,CACpB,uBAAuB,CAAC,cAAc,CAAC;gBACrC,KAAK,EAAE,KAAK;gBACZ,QAAQ,EAAE,kBAAkB,CAAC,KAAK;gBAClC,GAAG,EAAE,4BAA4B;aAClC,CAAC,CACH,CAAA;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,uBAAuB,CAAC,cAAc,EAAE,CAAC,CAAA;AAClE,CAAC,CAAA;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,oBAAoB;CACrB,CAAA","sourcesContent":["import { Record } from '../record'\nimport { Records } from '../records'\nimport { NodeDef, NodeDefs, NodeDefProps, NodeDefType } from '../../nodeDef'\nimport { Node, Nodes, NodeValues } from '../../node'\nimport { ValidationResult, ValidationResultFactory, ValidationSeverity } from '../../validation'\nimport { Survey, Surveys } from '../../survey'\n\nimport { Dictionary } from '../../common'\nimport { Objects } from '../../utils'\n\n/**\n * Cache of entity key values (and key defs by entity def) used during a single validation run (the record doesn't change):\n * without it, validating the keys of S sibling entities would compute the key values of every sibling S times.\n */\nexport type EntityKeysCache = {\n keyDefsByEntityDefUuid: Map<string, NodeDef<NodeDefType, NodeDefProps>[]>\n keyValuesByEntityUuid: Map<string, Dictionary<any>>\n}\n\nexport const createEntityKeysCache = (): EntityKeysCache => ({\n keyDefsByEntityDefUuid: new Map(),\n keyValuesByEntityUuid: new Map(),\n})\n\nconst _getKeyDefs = (params: {\n survey: Survey\n entityDef: NodeDef<NodeDefType, NodeDefProps>\n cache?: EntityKeysCache\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey, entityDef, cache } = params\n let keyDefs = cache?.keyDefsByEntityDefUuid.get(entityDef.uuid)\n if (!keyDefs) {\n keyDefs = Surveys.getNodeDefKeys({ survey, nodeDef: entityDef })\n cache?.keyDefsByEntityDefUuid.set(entityDef.uuid, keyDefs)\n }\n return keyDefs\n}\n\nconst _getKeyValuesByDefUuid = (params: {\n survey: Survey\n record: Record\n entity: Node\n keyDefs: NodeDef<NodeDefType, NodeDefProps>[]\n cache?: EntityKeysCache\n}): Dictionary<any> => {\n const { survey, record, entity, keyDefs, cache } = params\n let keyValues = cache?.keyValuesByEntityUuid.get(entity.uuid)\n if (!keyValues) {\n keyValues = Records.getEntityKeyValuesByDefUuid({ survey, record, entity, keyDefs })\n cache?.keyValuesByEntityUuid.set(entity.uuid, keyValues)\n }\n return keyValues\n}\n\nconst _isEntityDuplicate = (params: {\n survey: Survey\n record: Record\n entity: Node\n entityKeysCache?: EntityKeysCache\n}): boolean => {\n const { survey, entity, record, entityKeysCache: cache } = params\n // 1. get sibling entities\n const nodeParent = Records.getParent(entity)(record)\n if (!nodeParent) return false\n\n const siblingEntities = Records.getChildren(\n nodeParent,\n entity.nodeDefUuid\n )(record).filter((node) => !Nodes.areEqual(entity, node))\n\n // 2. get key values\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const keyDefs = _getKeyDefs({ survey, entityDef, cache })\n\n if (Objects.isEmpty(siblingEntities) || Objects.isEmpty(keyDefs)) {\n return false\n }\n const keyValuesByDefUuid = _getKeyValuesByDefUuid({ survey, record, entity, keyDefs, cache })\n return (\n !Objects.isEmpty(keyValuesByDefUuid) &&\n siblingEntities.some((sibilingEntity) => {\n const siblingKeyValuesByDefUuid = _getKeyValuesByDefUuid({\n survey,\n record,\n entity: sibilingEntity,\n keyDefs,\n cache,\n })\n return keyDefs.every((keyDef) => {\n const keyValue = keyValuesByDefUuid[keyDef.uuid]\n const siblingKeyValue = siblingKeyValuesByDefUuid[keyDef.uuid]\n return NodeValues.isValueEqual({\n survey,\n nodeDef: keyDef,\n value: keyValue,\n valueSearch: siblingKeyValue,\n })\n })\n })\n )\n}\n\nconst isNodeDefToBeValidated = (params: { survey: Survey; nodeDef: NodeDef<NodeDefType, NodeDefProps> }): boolean => {\n const { survey, nodeDef } = params\n if (!NodeDefs.isKey(nodeDef)) return false\n\n const nodeDefParent = Surveys.getNodeDefParent({ survey, nodeDef })\n // root entity key attributes will be validated by another validator\n return !!nodeDefParent && !NodeDefs.isRoot(nodeDefParent)\n}\n\nconst validateAttributeKey =\n (params: {\n survey: Survey\n record: Record\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n entityKeysCache?: EntityKeysCache\n }) =>\n (_propName: string, node: Node): Promise<ValidationResult> => {\n const { survey, nodeDef, record, entityKeysCache } = params\n\n if (isNodeDefToBeValidated({ survey, nodeDef })) {\n const entity = Records.getParent(node)(record)\n if (entity && _isEntityDuplicate({ survey, record, entity, entityKeysCache })) {\n return Promise.resolve(\n ValidationResultFactory.createInstance({\n valid: false,\n severity: ValidationSeverity.error,\n key: 'record.entity.keyDuplicate',\n })\n )\n }\n }\n\n return Promise.resolve(ValidationResultFactory.createInstance())\n }\n\nexport const AttributeKeyValidator = {\n validateAttributeKey,\n}\n"]}
1
+ {"version":3,"file":"attributeKeyValidator.js","sourceRoot":"","sources":["../../../../src/record/recordValidator/attributeKeyValidator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAW,QAAQ,EAA6B,MAAM,eAAe,CAAA;AAC5E,OAAO,EAAmB,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC/D,OAAO,EAAoB,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAChG,OAAO,EAAU,OAAO,EAAE,MAAM,cAAc,CAAA;AAG9C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAWrC,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAoB,EAAE,CAAC,CAAC;IAC3D,sBAAsB,EAAE,IAAI,GAAG,EAAE;IACjC,qBAAqB,EAAE,IAAI,GAAG,EAAE;CACjC,CAAC,CAAA;AAEF,MAAM,WAAW,GAAG,CAAC,MAIpB,EAAwC,EAAE;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,CAAC,KAAK;gBAClC,GAAG,EAAE,4BAA4B;aAClC,CAAC,CACH,CAAA;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,uBAAuB,CAAC,cAAc,EAAE,CAAC,CAAA;AAClE,CAAC,CAAA;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,oBAAoB;CACrB,CAAA","sourcesContent":["import { ArenaRecord } from '../record'\nimport { Records } from '../records'\nimport { NodeDef, NodeDefs, NodeDefProps, NodeDefType } from '../../nodeDef'\nimport { ArenaRecordNode, Nodes, NodeValues } from '../../node'\nimport { ValidationResult, ValidationResultFactory, ValidationSeverity } from '../../validation'\nimport { Survey, Surveys } from '../../survey'\n\nimport { Dictionary } from '../../common'\nimport { Objects } from '../../utils'\n\n/**\n * Cache of entity key values (and key defs by entity def) used during a single validation run (the record doesn't change):\n * without it, validating the keys of S sibling entities would compute the key values of every sibling S times.\n */\nexport type EntityKeysCache = {\n keyDefsByEntityDefUuid: Map<string, NodeDef<NodeDefType, NodeDefProps>[]>\n keyValuesByEntityUuid: Map<string, Dictionary<any>>\n}\n\nexport const createEntityKeysCache = (): EntityKeysCache => ({\n keyDefsByEntityDefUuid: new Map(),\n keyValuesByEntityUuid: new Map(),\n})\n\nconst _getKeyDefs = (params: {\n survey: Survey\n entityDef: NodeDef<NodeDefType, NodeDefProps>\n cache?: EntityKeysCache\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey, entityDef, cache } = params\n let keyDefs = cache?.keyDefsByEntityDefUuid.get(entityDef.uuid)\n if (!keyDefs) {\n keyDefs = Surveys.getNodeDefKeys({ survey, nodeDef: entityDef })\n cache?.keyDefsByEntityDefUuid.set(entityDef.uuid, keyDefs)\n }\n return keyDefs\n}\n\nconst _getKeyValuesByDefUuid = (params: {\n survey: Survey\n record: ArenaRecord\n entity: ArenaRecordNode\n keyDefs: NodeDef<NodeDefType, NodeDefProps>[]\n cache?: EntityKeysCache\n}): Dictionary<any> => {\n const { survey, record, entity, keyDefs, cache } = params\n let keyValues = cache?.keyValuesByEntityUuid.get(entity.uuid)\n if (!keyValues) {\n keyValues = Records.getEntityKeyValuesByDefUuid({ survey, record, entity, keyDefs })\n cache?.keyValuesByEntityUuid.set(entity.uuid, keyValues)\n }\n return keyValues\n}\n\nconst _isEntityDuplicate = (params: {\n survey: Survey\n record: ArenaRecord\n entity: ArenaRecordNode\n entityKeysCache?: EntityKeysCache\n}): boolean => {\n const { survey, entity, record, entityKeysCache: cache } = params\n // 1. get sibling entities\n const nodeParent = Records.getParent(entity)(record)\n if (!nodeParent) return false\n\n const siblingEntities = Records.getChildren(\n nodeParent,\n entity.nodeDefUuid\n )(record).filter((node) => !Nodes.areEqual(entity, node))\n\n // 2. get key values\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const keyDefs = _getKeyDefs({ survey, entityDef, cache })\n\n if (Objects.isEmpty(siblingEntities) || Objects.isEmpty(keyDefs)) {\n return false\n }\n const keyValuesByDefUuid = _getKeyValuesByDefUuid({ survey, record, entity, keyDefs, cache })\n return (\n !Objects.isEmpty(keyValuesByDefUuid) &&\n siblingEntities.some((sibilingEntity) => {\n const siblingKeyValuesByDefUuid = _getKeyValuesByDefUuid({\n survey,\n record,\n entity: sibilingEntity,\n keyDefs,\n cache,\n })\n return keyDefs.every((keyDef) => {\n const keyValue = keyValuesByDefUuid[keyDef.uuid]\n const siblingKeyValue = siblingKeyValuesByDefUuid[keyDef.uuid]\n return NodeValues.isValueEqual({\n survey,\n nodeDef: keyDef,\n value: keyValue,\n valueSearch: siblingKeyValue,\n })\n })\n })\n )\n}\n\nconst isNodeDefToBeValidated = (params: { survey: Survey; nodeDef: NodeDef<NodeDefType, NodeDefProps> }): boolean => {\n const { survey, nodeDef } = params\n if (!NodeDefs.isKey(nodeDef)) return false\n\n const nodeDefParent = Surveys.getNodeDefParent({ survey, nodeDef })\n // root entity key attributes will be validated by another validator\n return !!nodeDefParent && !NodeDefs.isRoot(nodeDefParent)\n}\n\nconst validateAttributeKey =\n (params: {\n survey: Survey\n record: ArenaRecord\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n entityKeysCache?: EntityKeysCache\n }) =>\n (_propName: string, node: ArenaRecordNode): Promise<ValidationResult> => {\n const { survey, nodeDef, record, entityKeysCache } = params\n\n if (isNodeDefToBeValidated({ survey, nodeDef })) {\n const entity = Records.getParent(node)(record)\n if (entity && _isEntityDuplicate({ survey, record, entity, entityKeysCache })) {\n return Promise.resolve(\n ValidationResultFactory.createInstance({\n valid: false,\n severity: ValidationSeverity.error,\n key: 'record.entity.keyDuplicate',\n })\n )\n }\n }\n\n return Promise.resolve(ValidationResultFactory.createInstance())\n }\n\nexport const AttributeKeyValidator = {\n validateAttributeKey,\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"attributeTypeValidator.js","sourceRoot":"","sources":["../../../../src/record/recordValidator/attributeTypeValidator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAsC,QAAQ,EAAgB,WAAW,EAAE,MAAM,eAAe,CAAA;AACvG,OAAO,EAAQ,KAAK,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAoB,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC5E,OAAO,EAAU,OAAO,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAG5C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAgBrC,MAAM,eAAe,GAAG,CAAC,MAA4C,EAAW,EAAE;IAChF,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IACxB,sHAAsH;IACtH,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC/B,CAAC,CAAA;AAED,MAA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vB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG;YAC9B,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC;YAC5B,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC;YAC9B,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC;SAChC,CAAA;QACD,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC;CACF,CAAA;AAED,MAAM,iBAAiB,GACrB,CAAC,MAAoC,EAAE,EAAE,CACzC,CAAO,SAAiB,EAAE,IAAU,EAA6B,EAAE;;IACjE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,aAAa,EAAE,GAAG,MAAM,CAAA;IAE/E,IAAI,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC;QAAE,OAAO,uBAAuB,CAAC,cAAc,EAAE,CAAA;IAE7E,MAAM,eAAe,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACtD,MAAM,KAAK,SACT,CAAC,MAAM,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAG;QACvB,MAAM;QACN,oBAAoB;QACpB,aAAa;QACb,MAAM;QACN,OAAO;QACP,IAAI;QACJ,KAAK,EAAE,IAAI,CAAC,KAAK;KAClB,CAAC,CAAC,mCAAI,IAAI,CAAA;IACb,OAAO,uBAAuB,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,+BAA+B,EAAE,KAAK,EAAE,CAAC,CAAA;AAChG,CAAC,CAAA,CAAA;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,iBAAiB;CAClB,CAAA","sourcesContent":["import { NodeDef, NodeDefCode, NodeDefProps, NodeDefs, NodeDefTaxon, NodeDefType } from '../../nodeDef'\nimport { Node, Nodes } from '../../node'\nimport { ValidationResult, ValidationResultFactory } from '../../validation'\nimport { Survey, Surveys } from '../../survey'\nimport { NodeValues } from '../../node/nodeValues'\nimport { Points } from '../../geo'\nimport { Numbers, Dates } from '../../utils'\nimport { CategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider'\nimport { TaxonProvider } from '../../nodeDefExpressionEvaluator/taxonProvider'\nimport { Taxa } from '../../taxonomy'\nimport { Record } from '../record'\n\ninterface AttributeTypeValidatorParams {\n survey: Survey\n categoryItemProvider?: CategoryItemProvider\n taxonProvider?: TaxonProvider\n record: Record\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}\n\ninterface AttributeTypeValidatorInternalParams extends AttributeTypeValidatorParams {\n node: Node\n value: any\n}\n\nconst validateDecimal = (params: AttributeTypeValidatorInternalParams): boolean => {\n const { value } = params\n // the max number of decimal digits is not validated: it is applied when formatting the value (see nodeValueFormatter)\n return Numbers.isFloat(value)\n}\n\nconst validateCode = async (params: AttributeTypeValidatorInternalParams) => {\n const { survey, record, node, categoryItemProvider } = params\n const itemUuid = NodeValues.getItemUuid(node)\n if (!itemUuid) return true\n\n let item = Surveys.getCategoryItemByUuid({ survey, itemUuid })\n if (item) return true\n\n if (!categoryItemProvider) return false\n\n // loookup item with categoryItemProvider\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid }) as NodeDefCode\n const categoryUuid = NodeDefs.getCategoryUuid(nodeDef)\n if (!categoryUuid) return false\n const draft = !!record.preview\n item = await categoryItemProvider.getItemByUuid({ survey, categoryUuid, itemUuid, draft })\n return Boolean(item)\n}\n\nconst validateTaxon = async (params: AttributeTypeValidatorInternalParams): Promise<boolean> => {\n const { survey, record, node, taxonProvider } = params\n const taxonUuid = NodeValues.getTaxonUuid(node)\n if (!taxonUuid) return true\n\n let taxon = Surveys.getTaxonByUuid({ survey, taxonUuid })\n if (!taxon && taxonProvider) {\n // lookup taxon with taxonProvider\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid }) as NodeDefTaxon\n const taxonomyUuid = NodeDefs.getTaxonomyUuid(nodeDef)\n if (!taxonomyUuid) return false\n const draft = !!record.preview\n taxon = await taxonProvider.getTaxonByUuid({ survey, taxonomyUuid, taxonUuid, draft })\n }\n if (!taxon) return false\n\n const vernacularNameUuid = NodeValues.getVernacularNameUuid(node)\n if (!vernacularNameUuid) return true\n\n const vernacularName = Taxa.getVernacularNameByUuid(vernacularNameUuid)(taxon)\n return !!vernacularName\n}\n\nconst typeValidatorFns: {\n [key in NodeDefType]?: (params: AttributeTypeValidatorInternalParams) => boolean | Promise<boolean>\n} = {\n [NodeDefType.boolean]: (params: AttributeTypeValidatorInternalParams): boolean =>\n ['true', 'false'].includes(params.value),\n [NodeDefType.code]: validateCode,\n [NodeDefType.coordinate]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { survey, node } = params\n\n const point = NodeValues.getValueAsPoint({ survey, node })\n if (!point) return false\n\n const srsIndex = Surveys.getSRSIndex(survey)\n\n return Points.isValid(point, srsIndex)\n },\n\n [NodeDefType.date]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { node } = params\n const [year, month, day] = [\n NodeValues.getDateYear(node),\n NodeValues.getDateMonth(node),\n NodeValues.getDateDay(node),\n ]\n return Dates.isValidDate(year, month, day)\n },\n\n [NodeDefType.decimal]: validateDecimal,\n\n [NodeDefType.integer]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { value } = params\n return Numbers.isInteger(value)\n },\n\n [NodeDefType.taxon]: validateTaxon,\n\n [NodeDefType.text]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { value } = params\n return typeof value === 'string'\n },\n\n [NodeDefType.time]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { node } = params\n const [hour, minute, seconds] = [\n NodeValues.getTimeHour(node),\n NodeValues.getTimeMinute(node),\n NodeValues.getTimeSeconds(node),\n ]\n return Dates.isValidTime(hour, minute, seconds)\n },\n}\n\nconst validateValueType =\n (params: AttributeTypeValidatorParams) =>\n async (_propName: string, node: Node): Promise<ValidationResult> => {\n const { survey, nodeDef, record, categoryItemProvider, taxonProvider } = params\n\n if (Nodes.isValueBlank(node)) return ValidationResultFactory.createInstance()\n\n const typeValidatorFn = typeValidatorFns[nodeDef.type]\n const valid =\n (await typeValidatorFn?.({\n survey,\n categoryItemProvider,\n taxonProvider,\n record,\n nodeDef,\n node,\n value: node.value,\n })) ?? true\n return ValidationResultFactory.createInstance({ key: 'record.attribute.valueInvalid', valid })\n }\n\nexport const AttributeTypeValidator = {\n validateValueType,\n}\n"]}
1
+ {"version":3,"file":"attributeTypeValidator.js","sourceRoot":"","sources":["../../../../src/record/recordValidator/attributeTypeValidator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAsC,QAAQ,EAAgB,WAAW,EAAE,MAAM,eAAe,CAAA;AACvG,OAAO,EAAmB,KAAK,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAoB,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC5E,OAAO,EAAU,OAAO,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAG5C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAgBrC,MAAM,eAAe,GAAG,CAAC,MAA4C,EAAW,EAAE;IAChF,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IACxB,sHAAsH;IACtH,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC/B,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,CAAO,MAA4C,EAAE,EAAE;IAC1E,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAA;IAC7D,MAAM,QAAQ,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IAC7C,IAAI,CAAC,QA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AAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC;CACF,CAAA;AAED,MAAM,iBAAiB,GACrB,CAAC,MAAoC,EAAE,EAAE,CACzC,CAAO,SAAiB,EAAE,IAAqB,EAA6B,EAAE;;IAC5E,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,aAAa,EAAE,GAAG,MAAM,CAAA;IAE/E,IAAI,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC;QAAE,OAAO,uBAAuB,CAAC,cAAc,EAAE,CAAA;IAE7E,MAAM,eAAe,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACtD,MAAM,KAAK,SACT,CAAC,MAAM,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAG;QACvB,MAAM;QACN,oBAAoB;QACpB,aAAa;QACb,MAAM;QACN,OAAO;QACP,IAAI;QACJ,KAAK,EAAE,IAAI,CAAC,KAAK;KAClB,CAAC,CAAC,mCAAI,IAAI,CAAA;IACb,OAAO,uBAAuB,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,+BAA+B,EAAE,KAAK,EAAE,CAAC,CAAA;AAChG,CAAC,CAAA,CAAA;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,iBAAiB;CAClB,CAAA","sourcesContent":["import { NodeDef, NodeDefCode, NodeDefProps, NodeDefs, NodeDefTaxon, NodeDefType } from '../../nodeDef'\nimport { ArenaRecordNode, Nodes } from '../../node'\nimport { ValidationResult, ValidationResultFactory } from '../../validation'\nimport { Survey, Surveys } from '../../survey'\nimport { NodeValues } from '../../node/nodeValues'\nimport { Points } from '../../geo'\nimport { Numbers, Dates } from '../../utils'\nimport { CategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider'\nimport { TaxonProvider } from '../../nodeDefExpressionEvaluator/taxonProvider'\nimport { Taxa } from '../../taxonomy'\nimport { ArenaRecord } from '../record'\n\ninterface AttributeTypeValidatorParams {\n survey: Survey\n categoryItemProvider?: CategoryItemProvider\n taxonProvider?: TaxonProvider\n record: ArenaRecord\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}\n\ninterface AttributeTypeValidatorInternalParams extends AttributeTypeValidatorParams {\n node: ArenaRecordNode\n value: any\n}\n\nconst validateDecimal = (params: AttributeTypeValidatorInternalParams): boolean => {\n const { value } = params\n // the max number of decimal digits is not validated: it is applied when formatting the value (see nodeValueFormatter)\n return Numbers.isFloat(value)\n}\n\nconst validateCode = async (params: AttributeTypeValidatorInternalParams) => {\n const { survey, record, node, categoryItemProvider } = params\n const itemUuid = NodeValues.getItemUuid(node)\n if (!itemUuid) return true\n\n let item = Surveys.getCategoryItemByUuid({ survey, itemUuid })\n if (item) return true\n\n if (!categoryItemProvider) return false\n\n // loookup item with categoryItemProvider\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid }) as NodeDefCode\n const categoryUuid = NodeDefs.getCategoryUuid(nodeDef)\n if (!categoryUuid) return false\n const draft = !!record.preview\n item = await categoryItemProvider.getItemByUuid({ survey, categoryUuid, itemUuid, draft })\n return Boolean(item)\n}\n\nconst validateTaxon = async (params: AttributeTypeValidatorInternalParams): Promise<boolean> => {\n const { survey, record, node, taxonProvider } = params\n const taxonUuid = NodeValues.getTaxonUuid(node)\n if (!taxonUuid) return true\n\n let taxon = Surveys.getTaxonByUuid({ survey, taxonUuid })\n if (!taxon && taxonProvider) {\n // lookup taxon with taxonProvider\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid }) as NodeDefTaxon\n const taxonomyUuid = NodeDefs.getTaxonomyUuid(nodeDef)\n if (!taxonomyUuid) return false\n const draft = !!record.preview\n taxon = await taxonProvider.getTaxonByUuid({ survey, taxonomyUuid, taxonUuid, draft })\n }\n if (!taxon) return false\n\n const vernacularNameUuid = NodeValues.getVernacularNameUuid(node)\n if (!vernacularNameUuid) return true\n\n const vernacularName = Taxa.getVernacularNameByUuid(vernacularNameUuid)(taxon)\n return !!vernacularName\n}\n\nconst typeValidatorFns: {\n [key in NodeDefType]?: (params: AttributeTypeValidatorInternalParams) => boolean | Promise<boolean>\n} = {\n [NodeDefType.boolean]: (params: AttributeTypeValidatorInternalParams): boolean =>\n ['true', 'false'].includes(params.value),\n [NodeDefType.code]: validateCode,\n [NodeDefType.coordinate]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { survey, node } = params\n\n const point = NodeValues.getValueAsPoint({ survey, node })\n if (!point) return false\n\n const srsIndex = Surveys.getSRSIndex(survey)\n\n return Points.isValid(point, srsIndex)\n },\n\n [NodeDefType.date]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { node } = params\n const [year, month, day] = [\n NodeValues.getDateYear(node),\n NodeValues.getDateMonth(node),\n NodeValues.getDateDay(node),\n ]\n return Dates.isValidDate(year, month, day)\n },\n\n [NodeDefType.decimal]: validateDecimal,\n\n [NodeDefType.integer]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { value } = params\n return Numbers.isInteger(value)\n },\n\n [NodeDefType.taxon]: validateTaxon,\n\n [NodeDefType.text]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { value } = params\n return typeof value === 'string'\n },\n\n [NodeDefType.time]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { node } = params\n const [hour, minute, seconds] = [\n NodeValues.getTimeHour(node),\n NodeValues.getTimeMinute(node),\n NodeValues.getTimeSeconds(node),\n ]\n return Dates.isValidTime(hour, minute, seconds)\n },\n}\n\nconst validateValueType =\n (params: AttributeTypeValidatorParams) =>\n async (_propName: string, node: ArenaRecordNode): Promise<ValidationResult> => {\n const { survey, nodeDef, record, categoryItemProvider, taxonProvider } = params\n\n if (Nodes.isValueBlank(node)) return ValidationResultFactory.createInstance()\n\n const typeValidatorFn = typeValidatorFns[nodeDef.type]\n const valid =\n (await typeValidatorFn?.({\n survey,\n categoryItemProvider,\n taxonProvider,\n record,\n nodeDef,\n node,\n value: node.value,\n })) ?? true\n return ValidationResultFactory.createInstance({ key: 'record.attribute.valueInvalid', valid })\n }\n\nexport const AttributeTypeValidator = {\n validateValueType,\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"attributeUniqueValidator.js","sourceRoot":"","sources":["../../../../src/record/recordValidator/attributeUniqueValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EAAyB,QAAQ,EAAe,MAAM,eAAe,CAAA;AAC5E,OAAO,EAAU,OAAO,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAoB,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,MAAM,qBAAqB,GAAG,CAAC,MAK9B,EAAW,EAAE;IACZ,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IACrD,+CAA+C;IAC/C,IAAI,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC;QAAE,OAAO,KAAK,CAAA;IAC/C,MAAM,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAA;IACvF,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CACnC,UAAU,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CACjG,CAAA;AACH,CAAC,CAAA;AAED,MAAM,sBAAsB,GAAG,CAAC,MAAuE,EAAW,EAAE;IAClH,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IAClC,MAAM,kBAAkB,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;IAC3D,IAAI,EAAC,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,MAAM,CAAA;QAAE,OAAO,KAAK,CAAA;IAE7C,MAAM,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAA;IACnE,IAAI,CAAC,aAAa,IAAI,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;QACrD,iDAAiD;QACjD,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAClC,CAAC,MAAuF,EAAE,EAAE,CAC5F,CAAC,SAAiB,EAAE,IAAU,EAA6B,EAAE;IAC3D,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IAE1C,IACE,sBAAsB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;QAC3C,qBAAqB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EACnE,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CACpB,uBAAuB,CAAC,cAAc,CAAC;YACrC,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,kBAAkB,CAAC,KAAK;YAClC,GAAG,EAAE,kCAAkC;SACxC,CAAC,CACH,CAAA;IACH,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,uBAAuB,CAAC,cAAc,EAAE,CAAC,CAAA;AAClE,CAAC,CAAA;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,uBAAuB;CACxB,CAAA","sourcesContent":["import { Node, Nodes, NodeValues } from '../../node'\nimport { NodeDef, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { Survey, Surveys } from '../../survey'\nimport { ValidationResult, ValidationResultFactory, ValidationSeverity } from '../../validation'\nimport { Record } from '../record'\nimport { Records } from '../records'\n\nconst _isAttributeDuplicate = (params: {\n survey: Survey\n record: Record\n attribute: Node\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): boolean => {\n const { survey, attribute, record, nodeDef } = params\n // blank values are never considered duplicates\n if (Nodes.isValueBlank(attribute)) return false\n const nodeSiblings = Records.getAttributeSiblings({ record, node: attribute, nodeDef })\n return nodeSiblings.some((sibling) =>\n NodeValues.isValueEqual({ survey, nodeDef, value: sibling.value, valueSearch: attribute.value })\n )\n}\n\nconst isNodeDefToBeValidated = (params: { survey: Survey; nodeDef: NodeDef<NodeDefType, NodeDefProps> }): boolean => {\n const { survey, nodeDef } = params\n const nodeDefValidations = NodeDefs.getValidations(nodeDef)\n if (!nodeDefValidations?.unique) return false\n\n const nodeDefParent = Surveys.getNodeDefParent({ survey, nodeDef })\n if (!nodeDefParent || NodeDefs.isRoot(nodeDefParent)) {\n // uniqueness at record level evaluated elsewhere\n return false\n }\n return true\n}\n\nexport const validateAttributeUnique =\n (params: { survey: Survey; record: Record; nodeDef: NodeDef<NodeDefType, NodeDefProps> }) =>\n (_propName: string, node: Node): Promise<ValidationResult> => {\n const { survey, record, nodeDef } = params\n\n if (\n isNodeDefToBeValidated({ survey, nodeDef }) &&\n _isAttributeDuplicate({ survey, record, attribute: node, nodeDef })\n ) {\n return Promise.resolve(\n ValidationResultFactory.createInstance({\n valid: false,\n severity: ValidationSeverity.error,\n key: 'record.attribute.uniqueDuplicate',\n })\n )\n }\n\n return Promise.resolve(ValidationResultFactory.createInstance())\n }\n\nexport const AttributeUniqueValidator = {\n validateAttributeUnique,\n}\n"]}
1
+ {"version":3,"file":"attributeUniqueValidator.js","sourceRoot":"","sources":["../../../../src/record/recordValidator/attributeUniqueValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC/D,OAAO,EAAyB,QAAQ,EAAe,MAAM,eAAe,CAAA;AAC5E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CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAClC,CAAC,MAA4F,EAAE,EAAE,CACjG,CAAC,SAAiB,EAAE,IAAqB,EAA6B,EAAE;IACtE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IAE1C,IACE,sBAAsB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;QAC3C,qBAAqB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EACnE,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CACpB,uBAAuB,CAAC,cAAc,CAAC;YACrC,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,kBAAkB,CAAC,KAAK;YAClC,GAAG,EAAE,kCAAkC;SACxC,CAAC,CACH,CAAA;IACH,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,uBAAuB,CAAC,cAAc,EAAE,CAAC,CAAA;AAClE,CAAC,CAAA;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,uBAAuB;CACxB,CAAA","sourcesContent":["import { ArenaRecordNode, Nodes, NodeValues } from '../../node'\nimport { NodeDef, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { Survey, Surveys } from '../../survey'\nimport { ValidationResult, ValidationResultFactory, ValidationSeverity } from '../../validation'\nimport { ArenaRecord } from '../record'\nimport { Records } from '../records'\n\nconst _isAttributeDuplicate = (params: {\n survey: Survey\n record: ArenaRecord\n attribute: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): boolean => {\n const { survey, attribute, record, nodeDef } = params\n // blank values are never considered duplicates\n if (Nodes.isValueBlank(attribute)) return false\n const nodeSiblings = Records.getAttributeSiblings({ record, node: attribute, nodeDef })\n return nodeSiblings.some((sibling) =>\n NodeValues.isValueEqual({ survey, nodeDef, value: sibling.value, valueSearch: attribute.value })\n )\n}\n\nconst isNodeDefToBeValidated = (params: { survey: Survey; nodeDef: NodeDef<NodeDefType, NodeDefProps> }): boolean => {\n const { survey, nodeDef } = params\n const nodeDefValidations = NodeDefs.getValidations(nodeDef)\n if (!nodeDefValidations?.unique) return false\n\n const nodeDefParent = Surveys.getNodeDefParent({ survey, nodeDef })\n if (!nodeDefParent || NodeDefs.isRoot(nodeDefParent)) {\n // uniqueness at record level evaluated elsewhere\n return false\n }\n return true\n}\n\nexport const validateAttributeUnique =\n (params: { survey: Survey; record: ArenaRecord; nodeDef: NodeDef<NodeDefType, NodeDefProps> }) =>\n (_propName: string, node: ArenaRecordNode): Promise<ValidationResult> => {\n const { survey, record, nodeDef } = params\n\n if (\n isNodeDefToBeValidated({ survey, nodeDef }) &&\n _isAttributeDuplicate({ survey, record, attribute: node, nodeDef })\n ) {\n return Promise.resolve(\n ValidationResultFactory.createInstance({\n valid: false,\n severity: ValidationSeverity.error,\n key: 'record.attribute.uniqueDuplicate',\n })\n )\n }\n\n return Promise.resolve(ValidationResultFactory.createInstance())\n }\n\nexport const AttributeUniqueValidator = {\n validateAttributeUnique,\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"attributeValidator.js","sourceRoot":"","sources":["../../../../src/record/recordValidator/attributeValidator.ts"],"names":[],"mappings":";;;;;;;;;AAGA,OAAO,EAAQ,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC9D,OAAO,EAA4C,QAAQ,EAAe,MAAM,eAAe,CAAA;AAG/F,OAAO,EAAU,OAAO,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrC,OAAO,EACL,iBAAiB,EAEjB,uBAAuB,EACvB,kBAAkB,EAClB,SAAS,GACV,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,YAAY,EA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F,qBAAqB,CAAC,QAAQ,CAAC,GAAG,MAAM,iBAAiB,CAAC,wBAAwB,CAAC,CAAA,CAAC,UAAU;QAChG,CAAC;IACH,CAAC;IACD,OAAO,qBAAqB,CAAA;AAC9B,CAAC,CAAA,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,wCAAwC;CACzC,CAAA","sourcesContent":["import { User } from '../../auth'\nimport { Dictionary } from '../../common'\nimport { Labels } from '../../language'\nimport { Node, NodeKeys, Nodes, NodeValues } from '../../node'\nimport { NodeDef, NodeDefExpression, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { CategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider'\nimport { TaxonProvider } from '../../nodeDefExpressionEvaluator/taxonProvider'\nimport { Survey, Surveys } from '../../survey'\nimport { SurveyDependencyType } from '../../survey/survey'\nimport { Objects } from '../../utils'\nimport {\n ValidationFactory,\n ValidationResult,\n ValidationResultFactory,\n ValidationSeverity,\n Validator,\n} from '../../validation'\nimport { ValidationFields } from '../../validation/validation'\nimport { NodePointers } from '../nodePointers'\nimport { Record } from '../record'\nimport { RecordExpressionEvaluator } from '../recordExpressionEvaluator'\nimport { Records } from '../records'\nimport { RecordValidations } from '../recordValidations'\nimport { AttributeKeyValidator, createEntityKeysCache, EntityKeysCache } from './attributeKeyValidator'\nimport { AttributeTypeValidator } from './attributeTypeValidator'\nimport { AttributeUniqueValidator } from './attributeUniqueValidator'\n\nconst expressionEvaluator = new RecordExpressionEvaluator()\n\nexport interface RecordValidatorParams {\n user: User\n survey: Survey\n categoryItemProvider?: CategoryItemProvider\n taxonProvider?: TaxonProvider\n record: Record\n}\n\nexport interface AttributeValidatorParams extends RecordValidatorParams {\n attribute: Node\n}\n\nexport interface AttributesValidatorParams extends RecordValidatorParams {\n nodes: Dictionary<Node>\n}\n\nexport interface SortedAttributesValidatorParams extends RecordValidatorParams {\n nodesArray: Node[]\n}\n\ntype SiblingKeyNodeItem = { entityUuid: string; keyNode: Node; hasErrors: boolean }\n\n// sibling key nodes are cached by ancestor multiple entity parent and def uuid during the same validation call:\n// when many entities are added to the same parent entity (e.g. data import), computing them for every updated\n// key attribute would take a time that grows quadratically with the number of entities\ntype SiblingKeyNodesCache = Map<string, SiblingKeyNodeItem[]>\n\nconst _getSiblingNodeKeys = (\n params: AttributeValidatorParams & { siblingKeyNodesCache?: SiblingKeyNodesCache }\n): SiblingKeyNodeItem[] => {\n const { survey, record, attribute, siblingKeyNodesCache } = params\n\n const attributeDef = Surveys.getNodeDefByUuid({ survey, uuid: attribute.nodeDefUuid })\n const ancestorMultipleEntityDef = Surveys.getNodeDefAncestorMultipleEntity({ survey, nodeDef: attributeDef })\n if (!ancestorMultipleEntityDef) {\n return []\n }\n const ancestorMultipleEntity = Records.getAncestor({\n record,\n node: attribute,\n ancestorDefUuid: ancestorMultipleEntityDef.uuid,\n })\n if (!ancestorMultipleEntity) return []\n\n const ancestorMultipleEntityParent = Records.getParent(ancestorMultipleEntity)(record)\n if (!ancestorMultipleEntityParent) return []\n\n const cacheKey = `${ancestorMultipleEntityParent.uuid}_${ancestorMultipleEntityDef.uuid}`\n let items = siblingKeyNodesCache?.get(cacheKey)\n if (!items) {\n const keyDefs = Surveys.getNodeDefKeys({ survey, nodeDef: ancestorMultipleEntityDef })\n const entities = Records.getEntitySiblings({ record, entity: ancestorMultipleEntity, includeSelf: true })\n items = []\n for (const entity of entities) {\n const keyNodes = Records.getEntityKeyNodes({ survey, record, entity, keyDefs })\n for (const keyNode of keyNodes) {\n if (!keyNode) continue\n const nodeValidation =\n record.validation && RecordValidations.getValidationNode({ nodeUuid: keyNode.uuid })(record.validation)\n items.push({ entityUuid: entity.uuid, keyNode, hasErrors: !!nodeValidation && !nodeValidation.valid })\n }\n }\n siblingKeyNodesCache?.set(cacheKey, items)\n }\n return items.filter((item) => item.entityUuid !== ancestorMultipleEntity.uuid)\n}\n\nconst _getValidationMessagesWithDefault = (params: {\n survey: Survey\n expression: NodeDefExpression\n defaultMessage?: string\n}): Labels => {\n const { survey, expression, defaultMessage } = params\n const messages: Labels = { ...expression.messages }\n\n const languages = Surveys.getLanguages(survey)\n const defaultMessageDefined = Objects.isNotEmpty(defaultMessage)\n\n for (const lang of languages) {\n const customMessage = messages[lang]\n if (Objects.isEmpty(customMessage) && defaultMessageDefined) {\n messages[lang] = defaultMessage\n }\n }\n\n return messages\n}\n\nconst _validateRequired =\n (params: { nodeDef: NodeDef<NodeDefType, NodeDefProps> }) =>\n (_field: string, node: any): Promise<ValidationResult> => {\n const { nodeDef } = params\n const valid = (!NodeDefs.isKey(nodeDef) && !NodeDefs.isRequired(nodeDef)) || !Nodes.isValueBlank(node)\n return Promise.resolve(\n valid\n ? ValidationResultFactory.createInstance()\n : ValidationResultFactory.createInstance({\n key: 'record.attribute.valueRequired',\n severity: ValidationSeverity.error,\n valid,\n })\n )\n }\n\n/**\n * Evaluates the validation expressions.\n */\nconst _validateNodeValidations =\n (params: { user: User; survey: Survey; record: Record; nodeDef: NodeDef<NodeDefType, NodeDefProps> }) =>\n async (_propName: string, node: Node): Promise<ValidationResult> => {\n const { user, survey, record, nodeDef } = params\n if (Nodes.isValueBlank(node)) return ValidationResultFactory.createInstance()\n\n const validations = NodeDefs.getValidations(nodeDef)\n if (!validations?.expressions?.length) return ValidationResultFactory.createInstance()\n\n const applicableExpressionsEval = await expressionEvaluator.evalApplicableExpressions({\n user,\n survey,\n record,\n nodeCtx: node,\n expressions: validations.expressions,\n stopAtFirstFound: false,\n })\n\n let validationResult = ValidationResultFactory.createInstance()\n\n for (const { expression, value: valid } of applicableExpressionsEval) {\n if (!valid) {\n const messages = _getValidationMessagesWithDefault({\n survey,\n expression,\n defaultMessage: expression.expression,\n })\n\n validationResult = ValidationResultFactory.createInstance({\n valid: false,\n key: 'record.attribute.customValidation',\n severity: expression.severity,\n messages,\n })\n break\n }\n }\n\n return validationResult\n }\n\nconst validateAttribute = async (params: AttributeValidatorParams & { entityKeysCache?: EntityKeysCache }) => {\n const { survey, record, attribute } = params\n if (Records.isNodeApplicable({ record, node: attribute })) {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: attribute.nodeDefUuid })\n const validatorParams = { ...params, nodeDef }\n return new Validator().validate(attribute, {\n [NodeKeys.value]: [\n _validateRequired({ nodeDef }),\n AttributeTypeValidator.validateValueType(validatorParams),\n _validateNodeValidations(validatorParams),\n AttributeKeyValidator.validateAttributeKey(validatorParams),\n AttributeUniqueValidator.validateAttributeUnique(validatorParams),\n ],\n })\n }\n return ValidationFactory.createInstance()\n}\n\nconst findSiblingKeyNodesToValidate = (\n params: AttributeValidatorParams & {\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n nodeParent?: Node\n siblingKeyNodesCache?: SiblingKeyNodesCache\n }\n) => {\n const { survey, nodeDef, nodeParent: parentNode, attribute } = params\n if (\n !NodeDefs.isKey(nodeDef) ||\n !parentNode ||\n (NodeDefs.isAutoIncrementalKey(nodeDef) && attribute.created && Nodes.isDefaultValueApplied(attribute))\n ) {\n // when a new node is created and the key is autoincremental, its value will be unique\n // and the validation of sibling key attributes is not necessary\n return []\n }\n // when a key attribute is updated, a sibling key attribute with the same value\n // or a sibling attribute with a validation error (duplicate key) should be re-validated\n const siblingNodeKeys = _getSiblingNodeKeys(params)\n const siblingNodeKeysWithSameValue: Node[] = []\n const siblingNodeKeysWithErrors: Node[] = []\n siblingNodeKeys.forEach(({ keyNode, hasErrors }) => {\n if (NodeValues.isValueEqual({ survey, nodeDef, parentNode, value: keyNode.value, valueSearch: attribute.value })) {\n siblingNodeKeysWithSameValue.push(keyNode)\n }\n if (hasErrors) {\n siblingNodeKeysWithErrors.push(keyNode)\n }\n })\n return [...siblingNodeKeysWithSameValue, ...siblingNodeKeysWithErrors]\n}\n\nconst findSortedNodesToValidate = (params: SortedAttributesValidatorParams): Node[] => {\n const { survey, record, nodesArray } = params\n\n const result = []\n const siblingKeyNodesCache: SiblingKeyNodesCache = new Map()\n for (const node of nodesArray) {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid })\n if (!NodeDefs.isAttribute(nodeDef)) {\n continue\n }\n // Get dependents and attribute itself\n const nodePointersAttributeAndDependents = Records.getDependentNodePointers({\n survey,\n record,\n node,\n dependencyType: SurveyDependencyType.validations,\n includeSelf: true,\n })\n\n const nodeParent = Records.getParent(node)(record)\n\n result.push(\n ...NodePointers.getNodesFromNodePointers({ record, nodePointers: nodePointersAttributeAndDependents }),\n ...findSiblingKeyNodesToValidate({ ...params, nodeDef, nodeParent, attribute: node, siblingKeyNodesCache })\n )\n\n if (NodeDefs.getValidations(nodeDef)?.unique) {\n result.push(...Records.getAttributeSiblings({ record, node, nodeDef }))\n }\n }\n\n return result\n}\n\nconst validateSelfAndDependentSortedAttributes = async (\n params: SortedAttributesValidatorParams\n): Promise<ValidationFields> => {\n const nodesToValidate: Node[] = findSortedNodesToValidate(params)\n const validationsByNodeUuid: ValidationFields = {}\n // the record doesn't change during the validation: entity keys can be cached\n const entityKeysCache = createEntityKeysCache()\n\n for (const nodeToValidate of nodesToValidate) {\n const nodeUuid = nodeToValidate.uuid\n // Validate only attributes not deleted and not validated already\n if (!nodeToValidate.deleted && !validationsByNodeUuid[nodeUuid]) {\n // sequential: avoid concurrent item/taxon lookups on large node sets\n const attributeValidatorParams = { ...params, attribute: nodeToValidate, entityKeysCache }\n validationsByNodeUuid[nodeUuid] = await validateAttribute(attributeValidatorParams) // NOSONAR\n }\n }\n return validationsByNodeUuid\n}\n\nexport const AttributeValidator = {\n validateSelfAndDependentSortedAttributes,\n}\n"]}
1
+ {"version":3,"file":"attributeValidator.js","sourceRoot":"","sources":["../../../../src/record/recordValidator/attributeValidator.ts"],"names":[],"mappings":";;;;;;;;;AAGA,OAAO,EAAmB,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACzE,OAAO,EAA4C,QAAQ,EAAe,MAAM,eAAe,CAAA;AAG/F,OAAO,EAAU,OAAO,EAAE,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7C,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAA;QACpC,iEAAiE;QACjE,IAAI,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAChE,qEAAqE;YACrE,MAAM,wBAAwB,mCAAQ,MAAM,KAAE,SAAS,EAAE,cAAc,EAAE,eAAe,GAAE,CAAA;YAC1F,qBAAqB,CAAC,QAAQ,CAAC,GAAG,MAAM,iBAAiB,CAAC,wBAAwB,CAAC,CAAA,CAAC,UAAU;QAChG,CAAC;IACH,CAAC;IACD,OAAO,qBAAqB,CAAA;AAC9B,CAAC,CAAA,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,wCAAwC;CACzC,CAAA","sourcesContent":["import { User } from '../../auth'\nimport { Dictionary } from '../../common'\nimport { Labels } from '../../language'\nimport { ArenaRecordNode, NodeKeys, Nodes, NodeValues } from '../../node'\nimport { NodeDef, NodeDefExpression, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { CategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider'\nimport { TaxonProvider } from '../../nodeDefExpressionEvaluator/taxonProvider'\nimport { Survey, Surveys } from '../../survey'\nimport { SurveyDependencyType } from '../../survey/survey'\nimport { Objects } from '../../utils'\nimport {\n ValidationFactory,\n ValidationResult,\n ValidationResultFactory,\n ValidationSeverity,\n Validator,\n} from '../../validation'\nimport { ValidationFields } from '../../validation/validation'\nimport { NodePointers } from '../nodePointers'\nimport { ArenaRecord } from '../record'\nimport { RecordExpressionEvaluator } from '../recordExpressionEvaluator'\nimport { Records } from '../records'\nimport { RecordValidations } from '../recordValidations'\nimport { AttributeKeyValidator, createEntityKeysCache, EntityKeysCache } from './attributeKeyValidator'\nimport { AttributeTypeValidator } from './attributeTypeValidator'\nimport { AttributeUniqueValidator } from './attributeUniqueValidator'\n\nconst expressionEvaluator = new RecordExpressionEvaluator()\n\nexport interface RecordValidatorParams {\n user: User\n survey: Survey\n categoryItemProvider?: CategoryItemProvider\n taxonProvider?: TaxonProvider\n record: ArenaRecord\n}\n\nexport interface AttributeValidatorParams extends RecordValidatorParams {\n attribute: ArenaRecordNode\n}\n\nexport interface AttributesValidatorParams extends RecordValidatorParams {\n nodes: Dictionary<ArenaRecordNode>\n}\n\nexport interface SortedAttributesValidatorParams extends RecordValidatorParams {\n nodesArray: ArenaRecordNode[]\n}\n\ntype SiblingKeyNodeItem = { entityUuid: string; keyNode: ArenaRecordNode; hasErrors: boolean }\n\n// sibling key nodes are cached by ancestor multiple entity parent and def uuid during the same validation call:\n// when many entities are added to the same parent entity (e.g. data import), computing them for every updated\n// key attribute would take a time that grows quadratically with the number of entities\ntype SiblingKeyNodesCache = Map<string, SiblingKeyNodeItem[]>\n\nconst _getSiblingNodeKeys = (\n params: AttributeValidatorParams & { siblingKeyNodesCache?: SiblingKeyNodesCache }\n): SiblingKeyNodeItem[] => {\n const { survey, record, attribute, siblingKeyNodesCache } = params\n\n const attributeDef = Surveys.getNodeDefByUuid({ survey, uuid: attribute.nodeDefUuid })\n const ancestorMultipleEntityDef = Surveys.getNodeDefAncestorMultipleEntity({ survey, nodeDef: attributeDef })\n if (!ancestorMultipleEntityDef) {\n return []\n }\n const ancestorMultipleEntity = Records.getAncestor({\n record,\n node: attribute,\n ancestorDefUuid: ancestorMultipleEntityDef.uuid,\n })\n if (!ancestorMultipleEntity) return []\n\n const ancestorMultipleEntityParent = Records.getParent(ancestorMultipleEntity)(record)\n if (!ancestorMultipleEntityParent) return []\n\n const cacheKey = `${ancestorMultipleEntityParent.uuid}_${ancestorMultipleEntityDef.uuid}`\n let items = siblingKeyNodesCache?.get(cacheKey)\n if (!items) {\n const keyDefs = Surveys.getNodeDefKeys({ survey, nodeDef: ancestorMultipleEntityDef })\n const entities = Records.getEntitySiblings({ record, entity: ancestorMultipleEntity, includeSelf: true })\n items = []\n for (const entity of entities) {\n const keyNodes = Records.getEntityKeyNodes({ survey, record, entity, keyDefs })\n for (const keyNode of keyNodes) {\n if (!keyNode) continue\n const nodeValidation =\n record.validation && RecordValidations.getValidationNode({ nodeUuid: keyNode.uuid })(record.validation)\n items.push({ entityUuid: entity.uuid, keyNode, hasErrors: !!nodeValidation && !nodeValidation.valid })\n }\n }\n siblingKeyNodesCache?.set(cacheKey, items)\n }\n return items.filter((item) => item.entityUuid !== ancestorMultipleEntity.uuid)\n}\n\nconst _getValidationMessagesWithDefault = (params: {\n survey: Survey\n expression: NodeDefExpression\n defaultMessage?: string\n}): Labels => {\n const { survey, expression, defaultMessage } = params\n const messages: Labels = { ...expression.messages }\n\n const languages = Surveys.getLanguages(survey)\n const defaultMessageDefined = Objects.isNotEmpty(defaultMessage)\n\n for (const lang of languages) {\n const customMessage = messages[lang]\n if (Objects.isEmpty(customMessage) && defaultMessageDefined) {\n messages[lang] = defaultMessage\n }\n }\n\n return messages\n}\n\nconst _validateRequired =\n (params: { nodeDef: NodeDef<NodeDefType, NodeDefProps> }) =>\n (_field: string, node: any): Promise<ValidationResult> => {\n const { nodeDef } = params\n const valid = (!NodeDefs.isKey(nodeDef) && !NodeDefs.isRequired(nodeDef)) || !Nodes.isValueBlank(node)\n return Promise.resolve(\n valid\n ? ValidationResultFactory.createInstance()\n : ValidationResultFactory.createInstance({\n key: 'record.attribute.valueRequired',\n severity: ValidationSeverity.error,\n valid,\n })\n )\n }\n\n/**\n * Evaluates the validation expressions.\n */\nconst _validateNodeValidations =\n (params: { user: User; survey: Survey; record: ArenaRecord; nodeDef: NodeDef<NodeDefType, NodeDefProps> }) =>\n async (_propName: string, node: ArenaRecordNode): Promise<ValidationResult> => {\n const { user, survey, record, nodeDef } = params\n if (Nodes.isValueBlank(node)) return ValidationResultFactory.createInstance()\n\n const validations = NodeDefs.getValidations(nodeDef)\n if (!validations?.expressions?.length) return ValidationResultFactory.createInstance()\n\n const applicableExpressionsEval = await expressionEvaluator.evalApplicableExpressions({\n user,\n survey,\n record,\n nodeCtx: node,\n expressions: validations.expressions,\n stopAtFirstFound: false,\n })\n\n let validationResult = ValidationResultFactory.createInstance()\n\n for (const { expression, value: valid } of applicableExpressionsEval) {\n if (!valid) {\n const messages = _getValidationMessagesWithDefault({\n survey,\n expression,\n defaultMessage: expression.expression,\n })\n\n validationResult = ValidationResultFactory.createInstance({\n valid: false,\n key: 'record.attribute.customValidation',\n severity: expression.severity,\n messages,\n })\n break\n }\n }\n\n return validationResult\n }\n\nconst validateAttribute = async (params: AttributeValidatorParams & { entityKeysCache?: EntityKeysCache }) => {\n const { survey, record, attribute } = params\n if (Records.isNodeApplicable({ record, node: attribute })) {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: attribute.nodeDefUuid })\n const validatorParams = { ...params, nodeDef }\n return new Validator().validate(attribute, {\n [NodeKeys.value]: [\n _validateRequired({ nodeDef }),\n AttributeTypeValidator.validateValueType(validatorParams),\n _validateNodeValidations(validatorParams),\n AttributeKeyValidator.validateAttributeKey(validatorParams),\n AttributeUniqueValidator.validateAttributeUnique(validatorParams),\n ],\n })\n }\n return ValidationFactory.createInstance()\n}\n\nconst findSiblingKeyNodesToValidate = (\n params: AttributeValidatorParams & {\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n nodeParent?: ArenaRecordNode\n siblingKeyNodesCache?: SiblingKeyNodesCache\n }\n) => {\n const { survey, nodeDef, nodeParent: parentNode, attribute } = params\n if (\n !NodeDefs.isKey(nodeDef) ||\n !parentNode ||\n (NodeDefs.isAutoIncrementalKey(nodeDef) && attribute.created && Nodes.isDefaultValueApplied(attribute))\n ) {\n // when a new node is created and the key is autoincremental, its value will be unique\n // and the validation of sibling key attributes is not necessary\n return []\n }\n // when a key attribute is updated, a sibling key attribute with the same value\n // or a sibling attribute with a validation error (duplicate key) should be re-validated\n const siblingNodeKeys = _getSiblingNodeKeys(params)\n const siblingNodeKeysWithSameValue: ArenaRecordNode[] = []\n const siblingNodeKeysWithErrors: ArenaRecordNode[] = []\n siblingNodeKeys.forEach(({ keyNode, hasErrors }) => {\n if (NodeValues.isValueEqual({ survey, nodeDef, parentNode, value: keyNode.value, valueSearch: attribute.value })) {\n siblingNodeKeysWithSameValue.push(keyNode)\n }\n if (hasErrors) {\n siblingNodeKeysWithErrors.push(keyNode)\n }\n })\n return [...siblingNodeKeysWithSameValue, ...siblingNodeKeysWithErrors]\n}\n\nconst findSortedNodesToValidate = (params: SortedAttributesValidatorParams): ArenaRecordNode[] => {\n const { survey, record, nodesArray } = params\n\n const result = []\n const siblingKeyNodesCache: SiblingKeyNodesCache = new Map()\n for (const node of nodesArray) {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid })\n if (!NodeDefs.isAttribute(nodeDef)) {\n continue\n }\n // Get dependents and attribute itself\n const nodePointersAttributeAndDependents = Records.getDependentNodePointers({\n survey,\n record,\n node,\n dependencyType: SurveyDependencyType.validations,\n includeSelf: true,\n })\n\n const nodeParent = Records.getParent(node)(record)\n\n result.push(\n ...NodePointers.getNodesFromNodePointers({ record, nodePointers: nodePointersAttributeAndDependents }),\n ...findSiblingKeyNodesToValidate({ ...params, nodeDef, nodeParent, attribute: node, siblingKeyNodesCache })\n )\n\n if (NodeDefs.getValidations(nodeDef)?.unique) {\n result.push(...Records.getAttributeSiblings({ record, node, nodeDef }))\n }\n }\n\n return result\n}\n\nconst validateSelfAndDependentSortedAttributes = async (\n params: SortedAttributesValidatorParams\n): Promise<ValidationFields> => {\n const nodesToValidate: ArenaRecordNode[] = findSortedNodesToValidate(params)\n const validationsByNodeUuid: ValidationFields = {}\n // the record doesn't change during the validation: entity keys can be cached\n const entityKeysCache = createEntityKeysCache()\n\n for (const nodeToValidate of nodesToValidate) {\n const nodeUuid = nodeToValidate.uuid\n // Validate only attributes not deleted and not validated already\n if (!nodeToValidate.deleted && !validationsByNodeUuid[nodeUuid]) {\n // sequential: avoid concurrent item/taxon lookups on large node sets\n const attributeValidatorParams = { ...params, attribute: nodeToValidate, entityKeysCache }\n validationsByNodeUuid[nodeUuid] = await validateAttribute(attributeValidatorParams) // NOSONAR\n }\n }\n return validationsByNodeUuid\n}\n\nexport const AttributeValidator = {\n validateSelfAndDependentSortedAttributes,\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"countVaildator.js","sourceRoot":"","sources":["../../../../src/record/recordValidator/countVaildator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,EAAE,MAAM,YAAY,CAAA;AACrD,OAAO,EAAyB,QAAQ,EAAe,MAAM,eAAe,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAc,iBAAiB,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAE7G,OAAO,EAAU,OAAO,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAGxD,MAAM,sBAAsB,GAAG,CAAC,MAK/B,EAAc,EAAE;IACf,MAAM,EAAE,WAAW,EAAE,oBAAoB,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;IAExE,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,iBAAiB,CAAC,cAAc,CAAC;YACtC,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE;gBACN,uBAAuB,CAAC,cAAc,CAAC;oBACrC,GAAG,EAAE,4BAA4B;oBACjC,MAAM,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE;oBACxC,QAAQ,EAAE,kBAAkB,CAAC,KAAK;iBACnC,CAAC;aACH;SACF,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,iBAAiB,CAAC,cAAc,CAAC;QACtC,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE;YACN,uBAAuB,CAAC,cAAc,CAAC;gBACrC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,gCAAgC;gBACjG,MAAM,kBAAI,W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iB,CAAC,6BAA6B,CAAC;gBACjF,cAAc,EAAE,OAAO,CAAC,IAAI;gBAC5B,gBAAgB,EAAE,OAAO,CAAC,IAAI;aAC/B,CAAC,CAAA;YACF,IAAI,CAAC,CAAC,0BAA0B,IAAI,cAAc,CAAC,EAAE,CAAC;gBACpD,mDAAmD;gBACnD,MAAM,qBAAqB,GAAG,mBAAmB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAA;gBAC/E,cAAc,CAAC,0BAA0B,CAAC,GAAG,qBAAqB,CAAA;YACpE,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,cAAc,CAAA;AACvB,CAAC,CAAA;AAED,MAAM,0BAA0B,GAAG,CAAC,MAInC,EAAoB,EAAE,CAAC,+BAA+B,iCAAM,MAAM,KAAE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAG,CAAA;AAE/G,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,qBAAqB;IACrB,+BAA+B;IAC/B,0BAA0B;CAC3B,CAAA","sourcesContent":["import { Node, NodePointer, Nodes } from '../../node'\nimport { NodeDef, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { Records } from '../records'\nimport { Validation, ValidationFactory, ValidationResultFactory, ValidationSeverity } from '../../validation'\nimport { Record } from '../record'\nimport { Survey, Surveys } from '../../survey'\nimport { RecordValidations } from '../recordValidations'\nimport { ValidationFields } from '../../validation/validation'\n\nconst createValidationResult = (params: {\n nodeDefUuid: string\n isMinCountValidation: boolean\n minCount: number\n maxCount: number\n}): Validation => {\n const { nodeDefUuid, isMinCountValidation, minCount, maxCount } = params\n\n if (minCount === maxCount) {\n return ValidationFactory.createInstance({\n valid: false,\n errors: [\n ValidationResultFactory.createInstance({\n key: 'record.nodes.count.invalid',\n params: { nodeDefUuid, count: minCount },\n severity: ValidationSeverity.error,\n }),\n ],\n })\n }\n return ValidationFactory.createInstance({\n valid: false,\n errors: [\n ValidationResultFactory.createInstance({\n key: isMinCountValidation ? 'record.nodes.count.minNotReached' : 'record.nodes.count.maxExceeded',\n params: { nodeDefUuid, ...(isMinCountValidation ? { minCount } : { maxCount }) },\n severity: ValidationSeverity.error,\n }),\n ],\n })\n}\n\nconst validateChildrenCount = (params: {\n parentNode: Node\n nodeDefChild: NodeDef<NodeDefType, NodeDefProps>\n count: number\n}): Validation => {\n const { parentNode, nodeDefChild, count } = params\n\n const minCount = Nodes.getChildrenMinCount({ parentNode, nodeDef: nodeDefChild })\n const maxCount = Nodes.getChildrenMaxCount({ parentNode, nodeDef: nodeDefChild })\n\n const minCountValid = Number.isNaN(minCount) || count >= minCount\n const maxCountValid = Number.isNaN(maxCount) || count <= maxCount\n\n return minCountValid && maxCountValid\n ? ValidationFactory.createInstance()\n : createValidationResult({\n nodeDefUuid: nodeDefChild.uuid,\n isMinCountValidation: !minCountValid,\n minCount,\n maxCount,\n })\n}\n\nconst _countChildren = (params: { record: Record; parentNode: Node; childDef: NodeDef<NodeDefType, NodeDefProps> }) => {\n const { record, parentNode, childDef } = params\n const children = Records.getChildren(parentNode, childDef.uuid)(record)\n const nonEmptyChildren = NodeDefs.isAttribute(childDef)\n ? children.filter((child) => !Nodes.isValueBlank(child))\n : children\n return nonEmptyChildren.length\n}\n\nconst isNodePointerToBeValidated = (nodePointer: NodePointer) => NodeDefs.hasMinOrMaxCount(nodePointer.nodeDef)\n\nconst validateNodePointer = (params: {\n record: Record\n nodeCtx: Node\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}) => {\n const { record, nodeCtx, nodeDef } = params\n // Check children count only for applicable nodes\n if (Nodes.isChildApplicable(nodeCtx, nodeDef.uuid)) {\n const count = _countChildren({ record, parentNode: nodeCtx, childDef: nodeDef })\n return validateChildrenCount({ parentNode: nodeCtx, nodeDefChild: nodeDef, count })\n }\n return ValidationFactory.createInstance()\n}\n\nconst getNodePointersToValidate = (params: { survey: Survey; record: Record; node: Node }): NodePointer[] => {\n const { survey, record, node } = params\n const nodePointersToValidate: NodePointer[] = []\n\n const nodeDef = Surveys.getNodeDefByUuid({ uuid: node.nodeDefUuid, survey })\n\n const nodeParent = Records.getParent(node)(record)\n if (nodeParent) {\n // always validate the node itself\n const nodePointer = { nodeCtx: nodeParent, nodeDef }\n if (isNodePointerToBeValidated(nodePointer)) {\n nodePointersToValidate.push(nodePointer)\n }\n }\n if (NodeDefs.isEntity(nodeDef) && !node.deleted) {\n // validate the count of every node def children\n const childDefs = Surveys.getNodeDefChildren({ survey, nodeDef })\n for (const childDef of childDefs) {\n const nodePointer = { nodeCtx: node, nodeDef: childDef }\n if (isNodePointerToBeValidated(nodePointer)) {\n nodePointersToValidate.push(nodePointer)\n }\n }\n }\n return nodePointersToValidate\n}\n\nconst validateChildrenCountNodesArray = (params: {\n survey: Survey\n record: Record\n nodesArray: Node[]\n}): ValidationFields => {\n const { survey, record, nodesArray } = params\n const validationsAcc: ValidationFields = {}\n for (const node of nodesArray) {\n const nodePointersToValidate = getNodePointersToValidate({ survey, record, node })\n\n for (const nodePointer of nodePointersToValidate) {\n const { nodeCtx, nodeDef } = nodePointer\n // check if validated already\n const validationChildrenCountKey = RecordValidations.getValidationChildrenCountKey({\n nodeParentUuid: nodeCtx.uuid,\n nodeDefChildUuid: nodeDef.uuid,\n })\n if (!(validationChildrenCountKey in validationsAcc)) {\n // validate the children count of this node pointer\n const validationNodePointer = validateNodePointer({ record, nodeCtx, nodeDef })\n validationsAcc[validationChildrenCountKey] = validationNodePointer\n }\n }\n }\n return validationsAcc\n}\n\nconst validateChildrenCountNodes = (params: {\n survey: Survey\n record: Record\n nodes: { [key: string]: Node }\n}): ValidationFields => validateChildrenCountNodesArray({ ...params, nodesArray: Object.values(params.nodes) })\n\nexport const CountValidator = {\n validateChildrenCount,\n validateChildrenCountNodesArray,\n validateChildrenCountNodes,\n}\n"]}
1
+ {"version":3,"file":"countVaildator.js","sourceRoot":"","sources":["../../../../src/record/recordValidator/countVaildator.ts"],"names":[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ACnD,MAAM,qBAAqB,GAAG,mBAAmB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAA;gBAC/E,cAAc,CAAC,0BAA0B,CAAC,GAAG,qBAAqB,CAAA;YACpE,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,cAAc,CAAA;AACvB,CAAC,CAAA;AAED,MAAM,0BAA0B,GAAG,CAAC,MAInC,EAAoB,EAAE,CAAC,+BAA+B,iCAAM,MAAM,KAAE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAG,CAAA;AAE/G,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,qBAAqB;IACrB,+BAA+B;IAC/B,0BAA0B;CAC3B,CAAA","sourcesContent":["import { ArenaRecordNode, NodePointer, Nodes } from '../../node'\nimport { NodeDef, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { Records } from '../records'\nimport { Validation, ValidationFactory, ValidationResultFactory, ValidationSeverity } from '../../validation'\nimport { ArenaRecord } from '../record'\nimport { Survey, Surveys } from '../../survey'\nimport { RecordValidations } from '../recordValidations'\nimport { ValidationFields } from '../../validation/validation'\n\nconst createValidationResult = (params: {\n nodeDefUuid: string\n isMinCountValidation: boolean\n minCount: number\n maxCount: number\n}): Validation => {\n const { nodeDefUuid, isMinCountValidation, minCount, maxCount } = params\n\n if (minCount === maxCount) {\n return ValidationFactory.createInstance({\n valid: false,\n errors: [\n ValidationResultFactory.createInstance({\n key: 'record.nodes.count.invalid',\n params: { nodeDefUuid, count: minCount },\n severity: ValidationSeverity.error,\n }),\n ],\n })\n }\n return ValidationFactory.createInstance({\n valid: false,\n errors: [\n ValidationResultFactory.createInstance({\n key: isMinCountValidation ? 'record.nodes.count.minNotReached' : 'record.nodes.count.maxExceeded',\n params: { nodeDefUuid, ...(isMinCountValidation ? { minCount } : { maxCount }) },\n severity: ValidationSeverity.error,\n }),\n ],\n })\n}\n\nconst validateChildrenCount = (params: {\n parentNode: ArenaRecordNode\n nodeDefChild: NodeDef<NodeDefType, NodeDefProps>\n count: number\n}): Validation => {\n const { parentNode, nodeDefChild, count } = params\n\n const minCount = Nodes.getChildrenMinCount({ parentNode, nodeDef: nodeDefChild })\n const maxCount = Nodes.getChildrenMaxCount({ parentNode, nodeDef: nodeDefChild })\n\n const minCountValid = Number.isNaN(minCount) || count >= minCount\n const maxCountValid = Number.isNaN(maxCount) || count <= maxCount\n\n return minCountValid && maxCountValid\n ? ValidationFactory.createInstance()\n : createValidationResult({\n nodeDefUuid: nodeDefChild.uuid,\n isMinCountValidation: !minCountValid,\n minCount,\n maxCount,\n })\n}\n\nconst _countChildren = (params: {\n record: ArenaRecord\n parentNode: ArenaRecordNode\n childDef: NodeDef<NodeDefType, NodeDefProps>\n}) => {\n const { record, parentNode, childDef } = params\n const children = Records.getChildren(parentNode, childDef.uuid)(record)\n const nonEmptyChildren = NodeDefs.isAttribute(childDef)\n ? children.filter((child) => !Nodes.isValueBlank(child))\n : children\n return nonEmptyChildren.length\n}\n\nconst isNodePointerToBeValidated = (nodePointer: NodePointer) => NodeDefs.hasMinOrMaxCount(nodePointer.nodeDef)\n\nconst validateNodePointer = (params: {\n record: ArenaRecord\n nodeCtx: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}) => {\n const { record, nodeCtx, nodeDef } = params\n // Check children count only for applicable nodes\n if (Nodes.isChildApplicable(nodeCtx, nodeDef.uuid)) {\n const count = _countChildren({ record, parentNode: nodeCtx, childDef: nodeDef })\n return validateChildrenCount({ parentNode: nodeCtx, nodeDefChild: nodeDef, count })\n }\n return ValidationFactory.createInstance()\n}\n\nconst getNodePointersToValidate = (params: {\n survey: Survey\n record: ArenaRecord\n node: ArenaRecordNode\n}): NodePointer[] => {\n const { survey, record, node } = params\n const nodePointersToValidate: NodePointer[] = []\n\n const nodeDef = Surveys.getNodeDefByUuid({ uuid: node.nodeDefUuid, survey })\n\n const nodeParent = Records.getParent(node)(record)\n if (nodeParent) {\n // always validate the node itself\n const nodePointer = { nodeCtx: nodeParent, nodeDef }\n if (isNodePointerToBeValidated(nodePointer)) {\n nodePointersToValidate.push(nodePointer)\n }\n }\n if (NodeDefs.isEntity(nodeDef) && !node.deleted) {\n // validate the count of every node def children\n const childDefs = Surveys.getNodeDefChildren({ survey, nodeDef })\n for (const childDef of childDefs) {\n const nodePointer = { nodeCtx: node, nodeDef: childDef }\n if (isNodePointerToBeValidated(nodePointer)) {\n nodePointersToValidate.push(nodePointer)\n }\n }\n }\n return nodePointersToValidate\n}\n\nconst validateChildrenCountNodesArray = (params: {\n survey: Survey\n record: ArenaRecord\n nodesArray: ArenaRecordNode[]\n}): ValidationFields => {\n const { survey, record, nodesArray } = params\n const validationsAcc: ValidationFields = {}\n for (const node of nodesArray) {\n const nodePointersToValidate = getNodePointersToValidate({ survey, record, node })\n\n for (const nodePointer of nodePointersToValidate) {\n const { nodeCtx, nodeDef } = nodePointer\n // check if validated already\n const validationChildrenCountKey = RecordValidations.getValidationChildrenCountKey({\n nodeParentUuid: nodeCtx.uuid,\n nodeDefChildUuid: nodeDef.uuid,\n })\n if (!(validationChildrenCountKey in validationsAcc)) {\n // validate the children count of this node pointer\n const validationNodePointer = validateNodePointer({ record, nodeCtx, nodeDef })\n validationsAcc[validationChildrenCountKey] = validationNodePointer\n }\n }\n }\n return validationsAcc\n}\n\nconst validateChildrenCountNodes = (params: {\n survey: Survey\n record: ArenaRecord\n nodes: { [key: string]: ArenaRecordNode }\n}): ValidationFields => validateChildrenCountNodesArray({ ...params, nodesArray: Object.values(params.nodes) })\n\nexport const CountValidator = {\n validateChildrenCount,\n validateChildrenCountNodesArray,\n validateChildrenCountNodes,\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"recordValidator.js","sourceRoot":"","sources":["../../../../src/record/recordValidator/recordValidator.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAc,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAChE,OA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AC,MAAM,CAAE;QAC9B,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YAChB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACrB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;QACzB,CAAC;KACF,CAAC,CAAA;IAEF,OAAO,mBAAmB,iCAAM,MAAM,KAAE,UAAU,IAAG,CAAA;AACvD,CAAC,CAAA,CAAA","sourcesContent":["import { Node, NodesMap } from '../../node'\nimport { Validation, ValidationFactory } from '../../validation'\nimport { Validations } from '../../validation/validations'\nimport { Records } from '../records'\nimport {\n AttributesValidatorParams,\n AttributeValidator,\n RecordValidatorParams,\n SortedAttributesValidatorParams,\n} from './attributeValidator'\nimport { CountValidator } from './countVaildator'\n\nexport const validateSortedNodes = async (params: SortedAttributesValidatorParams): Promise<Validation> => {\n const { survey, record, nodesArray } = params\n\n // 1. validate attributes\n const attributeValidations = await AttributeValidator.validateSelfAndDependentSortedAttributes({\n ...params,\n nodesArray,\n })\n\n // 2. validate min/max count\n const nodeCountValidations = CountValidator.validateChildrenCountNodesArray({ survey, record, nodesArray })\n\n // 3. merge validations\n return Validations.recalculateValidity(\n ValidationFactory.createInstance({\n valid: true,\n fields: {\n ...attributeValidations,\n ...nodeCountValidations,\n },\n })\n )\n}\n\nexport const validateNodes = async (params: AttributesValidatorParams): Promise<Validation> =>\n validateSortedNodes({ ...params, nodesArray: Object.values(params.nodes) })\n\nexport const validateRecord = async (params: RecordValidatorParams): Promise<Validation> => {\n const { record } = params\n const nodesArray: Node[] = []\n const nodes: NodesMap = {}\n Records.visitDescendantsAndSelf({\n record,\n node: Records.getRoot(record)!,\n visitor: (node) => {\n nodesArray.push(node)\n nodes[node.uuid] = node\n },\n })\n\n return validateSortedNodes({ ...params, nodesArray })\n}\n"]}
1
+ {"version":3,"file":"recordValidator.js","sourceRoot":"","sources":["../../../../src/record/recordValidator/recordValidator.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO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QAC9B,MAAM;QACN,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAE;QAC9B,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YAChB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACrB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;QACzB,CAAC;KACF,CAAC,CAAA;IAEF,OAAO,mBAAmB,iCAAM,MAAM,KAAE,UAAU,IAAG,CAAA;AACvD,CAAC,CAAA,CAAA","sourcesContent":["import { ArenaRecordNode, NodesMap } from '../../node'\nimport { Validation, ValidationFactory } from '../../validation'\nimport { Validations } from '../../validation/validations'\nimport { Records } from '../records'\nimport {\n AttributesValidatorParams,\n AttributeValidator,\n RecordValidatorParams,\n SortedAttributesValidatorParams,\n} from './attributeValidator'\nimport { CountValidator } from './countVaildator'\n\nexport const validateSortedNodes = async (params: SortedAttributesValidatorParams): Promise<Validation> => {\n const { survey, record, nodesArray } = params\n\n // 1. validate attributes\n const attributeValidations = await AttributeValidator.validateSelfAndDependentSortedAttributes({\n ...params,\n nodesArray,\n })\n\n // 2. validate min/max count\n const nodeCountValidations = CountValidator.validateChildrenCountNodesArray({ survey, record, nodesArray })\n\n // 3. merge validations\n return Validations.recalculateValidity(\n ValidationFactory.createInstance({\n valid: true,\n fields: {\n ...attributeValidations,\n ...nodeCountValidations,\n },\n })\n )\n}\n\nexport const validateNodes = async (params: AttributesValidatorParams): Promise<Validation> =>\n validateSortedNodes({ ...params, nodesArray: Object.values(params.nodes) })\n\nexport const validateRecord = async (params: RecordValidatorParams): Promise<Validation> => {\n const { record } = params\n const nodesArray: ArenaRecordNode[] = []\n const nodes: NodesMap = {}\n Records.visitDescendantsAndSelf({\n record,\n node: Records.getRoot(record)!,\n visitor: (node) => {\n nodesArray.push(node)\n nodes[node.uuid] = node\n },\n })\n\n return validateSortedNodes({ ...params, nodesArray })\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/record/service.ts"],"names":[],"mappings":"","sourcesContent":["import { User } from '../auth'\nimport { ArenaService } from '../common'\nimport { Record } from './record'\n\nexport interface RecordService extends ArenaService {\n // ==== CREATE\n create(options: { socketId: string; record: Record; surveyId: number; user: User }): Promise<Record>\n\n // ==== READ\n count(options: { cycle: string; surveyId: number }): Promise<number>\n\n get(options: { recordUuid: string; surveyId: number }): Promise<Record>\n\n getMany(options: { cycle: string; limit: number; offset: number; surveyId: number }): Promise<Record[]>\n\n getManyByUuids(options: { surveyId: number; uuids: string[] }): Promise<Record[]>\n\n // ==== UPDATE\n update(options: { recordUuid: string; step: string; surveyId: number; user: User }): Promise<Record>\n\n checkIn(options: {\n draft?: boolean\n recordUuid: string\n socketId: string\n surveyId: number\n user: User\n }): Promise<Record>\n\n checkOut(options: { recordUuid: string; socketId: string; surveyId: number; user: User }): void\n\n // ==== DELETE\n delete(options: { recordUuid: string; socketId: string; surveyId: number; user: User }): void\n}\n"]}
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/record/service.ts"],"names":[],"mappings":"","sourcesContent":["import { User } from '../auth'\nimport { ArenaService } from '../common'\nimport { ArenaRecord } from './record'\n\nexport interface RecordService extends ArenaService {\n // ==== CREATE\n create(options: { socketId: string; record: ArenaRecord; surveyId: number; user: User }): Promise<ArenaRecord>\n\n // ==== READ\n count(options: { cycle: string; surveyId: number }): Promise<number>\n\n get(options: { recordUuid: string; surveyId: number }): Promise<ArenaRecord>\n\n getMany(options: { cycle: string; limit: number; offset: number; surveyId: number }): Promise<ArenaRecord[]>\n\n getManyByUuids(options: { surveyId: number; uuids: string[] }): Promise<ArenaRecord[]>\n\n // ==== UPDATE\n update(options: { recordUuid: string; step: string; surveyId: number; user: User }): Promise<ArenaRecord>\n\n checkIn(options: {\n draft?: boolean\n recordUuid: string\n socketId: string\n surveyId: number\n user: User\n }): Promise<ArenaRecord>\n\n checkOut(options: { recordUuid: string; socketId: string; surveyId: number; user: User }): void\n\n // ==== DELETE\n delete(options: { recordUuid: string; socketId: string; surveyId: number; user: User }): void\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"attributeBuilder.js","sourceRoot":"","sources":["../../../../../src/tests/builder/recordBuilder/attributeBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,WAAW,EAAiC,MAAM,eAAe,CAAA;AAEhF,OAAO,EAAsC,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAClF,OAAO,EAAU,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAU,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,OAAO,gBAAiB,SAAQ,WAAW;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,OAAO,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;YACL,QAAQ,EAAE,IAAI,CAAC,IAAI;YACnB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;SACL,CA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;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,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAA;IAC3C,CAAC;CACF","sourcesContent":["import { Node, NodeFactory, NodeValueCode, NodeValueTaxon } from '../../../node'\nimport { NodeMeta } from '../../../node/node'\nimport { NodeDef, NodeDefCode, NodeDefTaxon, NodeDefType } from '../../../nodeDef'\nimport { Record, 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: Record; parentNode?: Node }): 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: Record; parentNode?: Node }): Record {\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,OAAO,EAAmB,WAAW,EAAiC,MAAM,eAAe,CAAA;AAE3F,OAAO,EAAsC,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAClF,OAAO,EAAe,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAU,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,eAA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AA;YAC1C,IAAI,WAAW,CAAC,KAAK,CAAC,iBAAiB,IAAI,UAAU,EAAE,CAAC;gBACtD,MAAM,mBAAmB,GAAG,OAAO,CAAC,sBAAsB,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,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,WAAW,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,OAAO,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 +1 @@
1
- {"version":3,"file":"entityBuilder.js","sourceRoot":"","sources":["../../../../../src/tests/builder/recordBuilder/entityBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,WAAW,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAU,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,OAAO,aAAc,SAAQ,WAAW;IAG5C,YAAY,WAAmB,EAAE,GAAG,aAA4B;QAC9D,KAAK,CAAC,WAAW,CAAC,CAAA;QAHH,kBAAa,GAAkB,EAAE,CAAA;QAIhD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;IACpC,CAAC;IAED,KAAK,CAAC,MAA6D;QACjE,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,MAAM,GAAG,WAAW,CAAC,cAAc,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,CAAA;QAE7G,IAAI,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;QAEnD,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;YAC1C,aAAa,GAAG,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAA;QAC3F,CAAC,CAAC,CAAA;QAEF,OAAO,aAAa,CAAA;IACtB,CAAC;CACF","sourcesContent":["import { Node, NodeFactory } from '../../../node'\nimport { Record, Records } from '../../../record'\nimport { Survey } from '../../../survey'\nimport { NodeBuilder } from './nodeBuilder'\n\nexport class EntityBuilder extends NodeBuilder {\n private readonly childBuilders: NodeBuilder[] = []\n\n constructor(nodeDefName: string, ...childBuilders: NodeBuilder[]) {\n super(nodeDefName)\n this.childBuilders = childBuilders\n }\n\n build(params: { survey: Survey; record: Record; parentNode?: Node }): Record {\n const { survey, record, parentNode } = params\n\n const nodeDef = this.getNodeDef({ survey })\n\n const entity = NodeFactory.createInstance({ nodeDefUuid: nodeDef.uuid, recordUuid: record.uuid, parentNode })\n\n let recordUpdated = Records.addNode(entity)(record)\n\n this.childBuilders.forEach((childBuilder) => {\n recordUpdated = childBuilder.build({ survey, record: recordUpdated, parentNode: entity })\n })\n\n return recordUpdated\n }\n}\n"]}
1
+ {"version":3,"file":"entityBuilder.js","sourceRoot":"","sources":["../../../../../src/tests/builder/recordBuilder/entityBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,WAAW,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAe,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,OAAO,aAAc,SAAQ,WAAW;IAG5C,YAAY,WAAmB,EAAE,GAAG,aAA4B;QAC9D,KAAK,CAAC,WAAW,CAAC,CAAA;QAHH,kBAAa,GAAkB,EAAE,CAAA;QAIhD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;IACpC,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,MAAM,GAAG,WAAW,CAAC,cAAc,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,CAAA;QAE7G,IAAI,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;QAEnD,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;YAC1C,aAAa,GAAG,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAA;QAC3F,CAAC,CAAC,CAAA;QAEF,OAAO,aAAa,CAAA;IACtB,CAAC;CACF","sourcesContent":["import { ArenaRecordNode, NodeFactory } from '../../../node'\nimport { ArenaRecord, Records } from '../../../record'\nimport { Survey } from '../../../survey'\nimport { NodeBuilder } from './nodeBuilder'\n\nexport class EntityBuilder extends NodeBuilder {\n private readonly childBuilders: NodeBuilder[] = []\n\n constructor(nodeDefName: string, ...childBuilders: NodeBuilder[]) {\n super(nodeDefName)\n this.childBuilders = childBuilders\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 entity = NodeFactory.createInstance({ nodeDefUuid: nodeDef.uuid, recordUuid: record.uuid, parentNode })\n\n let recordUpdated = Records.addNode(entity)(record)\n\n this.childBuilders.forEach((childBuilder) => {\n recordUpdated = childBuilder.build({ survey, record: recordUpdated, parentNode: entity })\n })\n\n return recordUpdated\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"nodeBuilder.js","sourceRoot":"","sources":["../../../../../src/tests/builder/recordBuilder/nodeBuilder.ts"],"names":[],"mappings":"AAKA,MAAM,OAAgB,WAAW;IAG/B,YAAY,WAAmB;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAES,UAAU,CAAC,MAA0B;;QAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,OAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,mCAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,WAAW,CAAC,CAAA;QAE1G,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,CAAC,WAAW,sBAAsB,CAAC,CAAA;QAC/E,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CAGF","sourcesContent":["import { Node } from '../../../node'\nimport { NodeDef, NodeDefProps, NodeDefType } from '../../../nodeDef'\nimport { Record } from '../../../record'\nimport { Survey } from '../../../survey'\n\nexport abstract class NodeBuilder {\n protected nodeDefName: string\n\n constructor(nodeDefName: string) {\n this.nodeDefName = nodeDefName\n }\n\n protected getNodeDef(params: { survey: Survey }): NodeDef<NodeDefType, NodeDefProps> {\n const nodeDef = Object.values(params.survey.nodeDefs ?? {}).find((n) => n.props.name === this.nodeDefName)\n\n if (!nodeDef) {\n throw new Error(`Node def with name ${this.nodeDefName} not found in survey`)\n }\n\n return nodeDef\n }\n\n abstract build(params: { survey: Survey; record: Record; parentNode?: Node }): Record\n}\n"]}
1
+ {"version":3,"file":"nodeBuilder.js","sourceRoot":"","sources":["../../../../../src/tests/builder/recordBuilder/nodeBuilder.ts"],"names":[],"mappings":"AAKA,MAAM,OAAgB,WAAW;IAG/B,YAAY,WAAmB;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAES,UAAU,CAAC,MAA0B;;QAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,OAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,mCAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,WAAW,CAAC,CAAA;QAE1G,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,CAAC,WAAW,sBAAsB,CAAC,CAAA;QAC/E,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CAGF","sourcesContent":["import { ArenaRecordNode } from '../../../node'\nimport { NodeDef, NodeDefProps, NodeDefType } from '../../../nodeDef'\nimport { ArenaRecord } from '../../../record'\nimport { Survey } from '../../../survey'\n\nexport abstract class NodeBuilder {\n protected nodeDefName: string\n\n constructor(nodeDefName: string) {\n this.nodeDefName = nodeDefName\n }\n\n protected getNodeDef(params: { survey: Survey }): NodeDef<NodeDefType, NodeDefProps> {\n const nodeDef = Object.values(params.survey.nodeDefs ?? {}).find((n) => n.props.name === this.nodeDefName)\n\n if (!nodeDef) {\n throw new Error(`Node def with name ${this.nodeDefName} not found in survey`)\n }\n\n return nodeDef\n }\n\n abstract build(params: { survey: Survey; record: ArenaRecord; parentNode?: ArenaRecordNode }): ArenaRecord\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"recordBuilder.js","sourceRoot":"","sources":["../../../../../src/tests/builder/recordBuilder/recordBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAKvD,MAAM,OAAO,aAAa;IAKxB,YAAY,IAAU,EAAE,MAAc,EAAE,iBAAgC;QACtE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;IAC5C,CAAC;IAED,KAAK;QACH,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;QAC7B,MAAM,MAAM,GAAG,aAAa,CAAC,cAAc,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QAC9E,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IACzD,CAAC;CACF","sourcesContent":["import { Record, RecordFactory } from '../../../record'\nimport { User } from '../../../auth'\nimport { Survey } from '../../../survey'\nimport { EntityBuilder } from './entityBuilder'\n\nexport class RecordBuilder {\n private readonly survey: Survey\n private readonly user: User\n private readonly rootEntityBuilder: EntityBuilder\n\n constructor(user: User, survey: Survey, rootEntityBuilder: EntityBuilder) {\n this.survey = survey\n this.user = user\n this.rootEntityBuilder = rootEntityBuilder\n }\n\n build(): Record {\n const { survey, user } = this\n const record = RecordFactory.createInstance({ surveyUuid: survey.uuid, user })\n return this.rootEntityBuilder.build({ survey, record })\n }\n}\n"]}
1
+ {"version":3,"file":"recordBuilder.js","sourceRoot":"","sources":["../../../../../src/tests/builder/recordBuilder/recordBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAK5D,MAAM,OAAO,aAAa;IAKxB,YAAY,IAAU,EAAE,MAAc,EAAE,iBAAgC;QACtE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;IAC5C,CAAC;IAED,KAAK;QACH,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;QAC7B,MAAM,MAAM,GAAG,aAAa,CAAC,cAAc,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QAC9E,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IACzD,CAAC;CACF","sourcesContent":["import { ArenaRecord, RecordFactory } from '../../../record'\nimport { User } from '../../../auth'\nimport { Survey } from '../../../survey'\nimport { EntityBuilder } from './entityBuilder'\n\nexport class RecordBuilder {\n private readonly survey: Survey\n private readonly user: User\n private readonly rootEntityBuilder: EntityBuilder\n\n constructor(user: User, survey: Survey, rootEntityBuilder: EntityBuilder) {\n this.survey = survey\n this.user = user\n this.rootEntityBuilder = rootEntityBuilder\n }\n\n build(): ArenaRecord {\n const { survey, user } = this\n const record = RecordFactory.createInstance({ surveyUuid: survey.uuid, user })\n return this.rootEntityBuilder.build({ survey, record })\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -27,13 +27,13 @@ export type { Logger } from './logger';
27
27
  export type { Message } from './message';
28
28
  export { MessageNotificationType, MessagePropsKey, MessageStatus, MessageTargetUserType, Messages } from './message';
29
29
  export { NodeFactory, NodeKeys, NodeMetaKeys, Nodes, NodeValueFormatter, NodeValues } from './node';
30
- export type { Node, Node as ArenaRecordNode, NodeMeta, NodePointer, NodeRefData, NodeService, NodesMap, NodeValueCode, NodeValueCoordinate, NodeValueFile, NodeValueTaxon, } from './node';
30
+ export type { ArenaRecordNode, Node, NodeMeta, NodePointer, NodeRefData, NodeService, NodesMap, NodeValueCode, NodeValueCoordinate, NodeValueFile, NodeValueTaxon, } from './node';
31
31
  export { NodeDefCountType, NodeDefType, NodeDefFactory, NodeDefs, NodeDefEntityRenderType, NodeDefFileType, NodeDefTextInputType, NodeDefTextRenderType, FormHeaderColor, } from './nodeDef';
32
32
  export { NodeDefExpressionEvaluator, NodeDefExpressionValidator } from './nodeDefExpressionEvaluator';
33
33
  export type { CategoryItemProvider, TaxonProvider } from './nodeDefExpressionEvaluator';
34
34
  export type { NodeDef, NodeDefLayout, NodeDefMeta, NodeDefProps, NodeDefPropsWithLayout, NodeDefBoolean, NodeDefBooleanProps, NodeDefCode, NodeDefCodeLayout, NodeDefCodeProps, NodeDefCoordinate, NodeDefCoordinateProps, NodeDefDate, NodeDefDecimal, NodeDefDecimalProps, NodeDefEntity, NodeDefEntityChildPosition, NodeDefEntityLayout, NodeDefEntityProps, NodeDefPrintOrientation, NodeDefFile, NodeDefFileProps, NodeDefFormHeader, NodeDefFormHeaderProps, NodeDefInteger, NodeDefPropsAdvanced, NodeDefTaxon, NodeDefTaxonProps, NodeDefText, NodeDefTextProps, NodeDefTextLayout, NodeDefTime, NodeDefTimeProps, NodeDefExpression, NodeDefMap, NodeDefService, NodeDefValidations, } from './nodeDef';
35
35
  export { NodePointers, RecordCloner, RecordFactory, RecordFixer, Records, RECORD_STEP_DEFAULT, RecordExpressionEvaluator, RecordNodesUpdater, RecordPrettyPrinter, RecordUpdater, RecordUpdateResult, RecordValidator, RecordValidations, } from './record';
36
- export type { AttributeValidatorParams, AttributesValidatorParams, NodeCreateParams, NodesUpdateParams, Record, Record as ArenaRecord, RecordExpressionContext, RecordExpressionEvaluationContext, RecordService, RecordUpdateOptions, RecordValidatorParams, SortedAttributesValidatorParams, } from './record';
36
+ export type { AttributeValidatorParams, AttributesValidatorParams, NodeCreateParams, NodesUpdateParams, ArenaRecord, Record, RecordExpressionContext, RecordExpressionEvaluationContext, RecordService, RecordUpdateOptions, RecordValidatorParams, SortedAttributesValidatorParams, } from './record';
37
37
  export { ServiceRegistry, ServiceType } from './registry';
38
38
  export { DEFAULT_SRS, DEFAULT_SRS_INDEX, SRSFactory } from './srs';
39
39
  export type { SRS, SRSIndex } from './srs';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":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A;AACjB,yGAAA,WAAW,OAAA;AACX,gHAAA,kBAAkB,OAAA;AAClB,uGAAA,SAAS,OAAA;AACT,gHAAA,kBAAkB,OAAA","sourcesContent":["export type { AppInfo } from './app'\n\nexport { Authorizer, AuthGroupName, UserStatus, Permission, UserTitle, UserFactory, Users } from './auth'\nexport type {\n AuthGroup,\n User,\n UserAuthGroup,\n UserAuthGroupProps,\n AuthToken,\n UserAuthTokenPayload,\n UserAuthTokenService,\n UserPrefs,\n UserPrefSurveys,\n UserProps,\n UserAuthRefreshToken,\n UserAuthRefreshTokenProps,\n UserAuthRefreshTokenPayload,\n UserService,\n UserTokenPayload,\n DownloadAuthTokenPayload,\n UserGroup,\n UserGroupProps,\n UserGroupQualifier,\n UserInvitation,\n} from './auth'\n\nexport { CategoryFactory, CategoryImportColumnType, CategoryItemFactory, CategoryLevelFactory } from './category'\nexport type {\n CategoryItemProps,\n Category,\n CategoryItem,\n CategoryLevel,\n CategoryLevelProps,\n CategoryImportSummary,\n CategoryImportSummaryColumn,\n CategoryItemService,\n CategoryLevelService,\n CategoryProps,\n CategoryService,\n} from './category'\n\nexport { Categories, CategoryItems } from './category'\n\nexport { ChainFactory, ChainStatusExec, ChainNodeDefFactory } from './chain'\nexport type {\n Chain,\n ChainProps,\n ChainService,\n ChainNodeDef,\n ChainNodeDefProps,\n ChainNodeDefService,\n ChainNodeDefAggregate,\n ChainNodeDefAggregateProps,\n} from './chain'\n\nexport { TraverseMethod } from './common'\nexport type { ArenaObject, ArenaService, Dictionary, Factory, I18n } from './common'\n\nexport type { FlatDataExportOptions, ArenaExportInfoFactoryParams, ArenaExportInfo } from './dataExport'\nexport {\n FlatDataExportDefaultOptions,\n FlatDataExportOption,\n FlatDataFiles,\n FlatDataExportModel,\n FlatDataExportColumnDataType,\n ArenaExportInfoFactory,\n UniqueFileNamesGenerator,\n} from './dataExport'\n\nexport { DataQueryMode, DataQuerySummaries } from './dataQuery'\nexport type { DataQuery, DataQuerySummary, DataQuerySummaryProps } from './dataQuery'\n\nexport { SystemError } from './error'\n\nexport {\n ExpressionNodeType,\n ExpressionNodeEvaluator,\n ExpressionVariable,\n JavascriptExpressionEvaluator,\n JavascriptExpressionParser,\n} from './expression'\nexport type {\n ArrayExpression,\n BinaryExpression,\n CallExpression,\n CompoundExpression,\n ConditionalExpression,\n ExpressionContext,\n ExpressionEvaluator,\n ExpressionFunction,\n ExpressionFunctions,\n ExpressionNode,\n ExpressionNodeEvaluatorConstructor,\n MemberExpression,\n IdentifierExpression,\n LiteralExpression,\n SequenceExpression,\n ThisExpression,\n UnaryExpression,\n} from './expression'\n\nexport { ExtraPropDataType, ExtraPropsDataGenerator } from './extraProp'\nexport type { ExtraPropDef, ExtraPropDefs } from './extraProp'\n\nexport { PointFactory, Points } from './geo'\nexport type { Point } from './geo'\n\nexport { JobBase, JobEventType, JobStatus } from './job'\nexport type { Job, JobContext, JobEvent, JobSerialized } from './job'\n\nexport { LanguageCode, Languages, LanguagesISO639part2 } from './language'\nexport type { Labels } from './language'\n\nexport type { Logger } from './logger'\n\nexport type { Message } from './message'\nexport { MessageNotificationType, MessagePropsKey, MessageStatus, MessageTargetUserType, Messages } from './message'\n\nexport { NodeFactory, NodeKeys, NodeMetaKeys, Nodes, NodeValueFormatter, NodeValues } from './node'\nexport type {\n Node,\n Node as ArenaRecordNode,\n NodeMeta,\n NodePointer,\n NodeRefData,\n NodeService,\n NodesMap,\n NodeValueCode,\n NodeValueCoordinate,\n NodeValueFile,\n NodeValueTaxon,\n} from './node'\n\nexport {\n NodeDefCountType,\n NodeDefType,\n NodeDefFactory,\n NodeDefs,\n NodeDefEntityRenderType,\n NodeDefFileType,\n NodeDefTextInputType,\n NodeDefTextRenderType,\n FormHeaderColor,\n} from './nodeDef'\n\nexport { NodeDefExpressionEvaluator, NodeDefExpressionValidator } from './nodeDefExpressionEvaluator'\nexport type { CategoryItemProvider, TaxonProvider } from './nodeDefExpressionEvaluator'\n\nexport type {\n NodeDef,\n NodeDefLayout,\n NodeDefMeta,\n NodeDefProps,\n NodeDefPropsWithLayout,\n NodeDefBoolean,\n NodeDefBooleanProps,\n NodeDefCode,\n NodeDefCodeLayout,\n NodeDefCodeProps,\n NodeDefCoordinate,\n NodeDefCoordinateProps,\n NodeDefDate,\n NodeDefDecimal,\n NodeDefDecimalProps,\n NodeDefEntity,\n NodeDefEntityChildPosition,\n NodeDefEntityLayout,\n NodeDefEntityProps,\n NodeDefPrintOrientation,\n NodeDefFile,\n NodeDefFileProps,\n NodeDefFormHeader,\n NodeDefFormHeaderProps,\n NodeDefInteger,\n NodeDefPropsAdvanced,\n NodeDefTaxon,\n NodeDefTaxonProps,\n NodeDefText,\n NodeDefTextProps,\n NodeDefTextLayout,\n NodeDefTime,\n NodeDefTimeProps,\n NodeDefExpression,\n NodeDefMap,\n NodeDefService,\n NodeDefValidations,\n} from './nodeDef'\n\nexport {\n NodePointers,\n RecordCloner,\n RecordFactory,\n RecordFixer,\n Records,\n RECORD_STEP_DEFAULT,\n RecordExpressionEvaluator,\n RecordNodesUpdater,\n RecordPrettyPrinter,\n RecordUpdater,\n RecordUpdateResult,\n RecordValidator,\n RecordValidations,\n} from './record'\nexport type {\n AttributeValidatorParams,\n AttributesValidatorParams,\n NodeCreateParams,\n NodesUpdateParams,\n Record,\n Record as ArenaRecord,\n RecordExpressionContext,\n RecordExpressionEvaluationContext,\n RecordService,\n RecordUpdateOptions,\n RecordValidatorParams,\n SortedAttributesValidatorParams,\n} from './record'\n\nexport { ServiceRegistry, ServiceType } from './registry'\n\nexport { DEFAULT_SRS, DEFAULT_SRS_INDEX, SRSFactory } from './srs'\nexport type { SRS, SRSIndex } from './srs'\n\nexport {\n NodeDefsFixer,\n SurveyDocImages,\n SurveyDocImageFactory,\n SurveyDocPlace,\n SurveyDependencyType,\n SurveyFactory,\n SurveyFileFactory,\n SurveyFileType,\n SurveyRefDataFactory,\n SurveySecurityProp,\n Surveys,\n surveyDocImagePropKeys,\n surveySecurityDefaults,\n defaultCycle,\n} from './survey'\nexport type {\n Survey,\n SurveyCycle,\n SurveyDependency,\n SurveyDependencyGraph,\n SurveyDocImage,\n SurveyDocImageFactoryParams,\n SurveyDocImageProps,\n SurveyFile,\n SurveyFileFactoryParams,\n SurveyFileProps,\n SurveyProps,\n SurveyRefData,\n SurveySecurity,\n SurveyService,\n} from './survey'\n\nexport { Taxa, Taxonomies, TaxonomyFactory, TaxonFactory, TaxonGenerator, VernacularNameFactory } from './taxonomy'\nexport type {\n VernacularNameParams,\n TaxonomyFactoryParams,\n TaxonFactoryParams,\n Taxonomy,\n TaxonomyService,\n VernacularNameProps,\n VernacularName,\n TaxonProps,\n Taxon,\n TaxonomyProps,\n TaxonService,\n} from './taxonomy'\n\nexport { SurveyBuilder, SurveyObjectBuilders } from './tests/builder/surveyBuilder'\nexport { RecordBuilder, RecordNodeBuilders } from './tests/builder/recordBuilder'\n\nexport {\n Arrays,\n DateFormats,\n Dates,\n FileNames,\n FileProcessor,\n Numbers,\n Objects,\n Promises,\n Queue,\n RetryProcessor,\n Strings,\n UnitOfTime,\n UUIDs,\n Versions,\n} from './utils'\n\nexport type { FileProcessorConstructorArgs, ParsedVersion } from './utils'\n\nexport {\n FieldValidators,\n ValidationFactory,\n ValidationResultFactory,\n ValidationResults,\n Validations,\n ValidationSeverity,\n Validator,\n ValidatorErrorKeys,\n} from './validation'\nexport type { FieldValidator, Validation, ValidationFields, ValidationResult, ValidationCounts } from './validation'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAEA,+BAAyG;AAAhG,kGAAA,UAAU,OAAA;AAAE,qGAAA,aAAa,OAAA;AAAE,kGAAA,UAAU,OAAA;AAAE,kGAAA,UAAU,OAAA;AAAE,iGAAA,SAAS,OAAA;AAAE,mGAAA,WAAW,OAAA;AAAE,6FAAA,KAAK,OAAA;AAwBzF,uCAAiH;AAAxG,2GAAA,eAAe,OAAA;AAAE,oHAAA,wBAAwB,OAAA;AAAE,+GAAA,mBA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BAAkB,OAAA;AAClB,iGAAA,OAAO,OAAA;AACP,gHAAA,sBAAsB,OAAA;AACtB,gHAAA,sBAAsB,OAAA;AACtB,sGAAA,YAAY,OAAA;AAmBd,uCAAmH;AAA1G,gGAAA,IAAI,OAAA;AAAE,sGAAA,UAAU,OAAA;AAAE,2GAAA,eAAe,OAAA;AAAE,wGAAA,YAAY,OAAA;AAAE,0GAAA,cAAc,OAAA;AAAE,iHAAA,qBAAqB,OAAA;AAe/F,+DAAmF;AAA1E,8GAAA,aAAa,OAAA;AAAE,qHAAA,oBAAoB,OAAA;AAC5C,+DAAiF;AAAxE,8GAAA,aAAa,OAAA;AAAE,mHAAA,kBAAkB,OAAA;AAE1C,iCAegB;AAdd,+FAAA,MAAM,OAAA;AACN,oGAAA,WAAW,OAAA;AACX,8FAAA,KAAK,OAAA;AACL,kGAAA,SAAS,OAAA;AACT,sGAAA,aAAa,OAAA;AACb,gGAAA,OAAO,OAAA;AACP,gGAAA,OAAO,OAAA;AACP,iGAAA,QAAQ,OAAA;AACR,8FAAA,KAAK,OAAA;AACL,uGAAA,cAAc,OAAA;AACd,gGAAA,OAAO,OAAA;AACP,mGAAA,UAAU,OAAA;AACV,8FAAA,KAAK,OAAA;AACL,iGAAA,QAAQ,OAAA;AAKV,2CASqB;AARnB,6GAAA,eAAe,OAAA;AACf,+GAAA,iBAAiB,OAAA;AACjB,qHAAA,uBAAuB,OAAA;AACvB,+GAAA,iBAAiB,OAAA;AACjB,yGAAA,WAAW,OAAA;AACX,gHAAA,kBAAkB,OAAA;AAClB,uGAAA,SAAS,OAAA;AACT,gHAAA,kBAAkB,OAAA","sourcesContent":["export type { AppInfo } from './app'\n\nexport { Authorizer, AuthGroupName, UserStatus, Permission, UserTitle, UserFactory, Users } from './auth'\nexport type {\n AuthGroup,\n User,\n UserAuthGroup,\n UserAuthGroupProps,\n AuthToken,\n UserAuthTokenPayload,\n UserAuthTokenService,\n UserPrefs,\n UserPrefSurveys,\n UserProps,\n UserAuthRefreshToken,\n UserAuthRefreshTokenProps,\n UserAuthRefreshTokenPayload,\n UserService,\n UserTokenPayload,\n DownloadAuthTokenPayload,\n UserGroup,\n UserGroupProps,\n UserGroupQualifier,\n UserInvitation,\n} from './auth'\n\nexport { CategoryFactory, CategoryImportColumnType, CategoryItemFactory, CategoryLevelFactory } from './category'\nexport type {\n CategoryItemProps,\n Category,\n CategoryItem,\n CategoryLevel,\n CategoryLevelProps,\n CategoryImportSummary,\n CategoryImportSummaryColumn,\n CategoryItemService,\n CategoryLevelService,\n CategoryProps,\n CategoryService,\n} from './category'\n\nexport { Categories, CategoryItems } from './category'\n\nexport { ChainFactory, ChainStatusExec, ChainNodeDefFactory } from './chain'\nexport type {\n Chain,\n ChainProps,\n ChainService,\n ChainNodeDef,\n ChainNodeDefProps,\n ChainNodeDefService,\n ChainNodeDefAggregate,\n ChainNodeDefAggregateProps,\n} from './chain'\n\nexport { TraverseMethod } from './common'\nexport type { ArenaObject, ArenaService, Dictionary, Factory, I18n } from './common'\n\nexport type { FlatDataExportOptions, ArenaExportInfoFactoryParams, ArenaExportInfo } from './dataExport'\nexport {\n FlatDataExportDefaultOptions,\n FlatDataExportOption,\n FlatDataFiles,\n FlatDataExportModel,\n FlatDataExportColumnDataType,\n ArenaExportInfoFactory,\n UniqueFileNamesGenerator,\n} from './dataExport'\n\nexport { DataQueryMode, DataQuerySummaries } from './dataQuery'\nexport type { DataQuery, DataQuerySummary, DataQuerySummaryProps } from './dataQuery'\n\nexport { SystemError } from './error'\n\nexport {\n ExpressionNodeType,\n ExpressionNodeEvaluator,\n ExpressionVariable,\n JavascriptExpressionEvaluator,\n JavascriptExpressionParser,\n} from './expression'\nexport type {\n ArrayExpression,\n BinaryExpression,\n CallExpression,\n CompoundExpression,\n ConditionalExpression,\n ExpressionContext,\n ExpressionEvaluator,\n ExpressionFunction,\n ExpressionFunctions,\n ExpressionNode,\n ExpressionNodeEvaluatorConstructor,\n MemberExpression,\n IdentifierExpression,\n LiteralExpression,\n SequenceExpression,\n ThisExpression,\n UnaryExpression,\n} from './expression'\n\nexport { ExtraPropDataType, ExtraPropsDataGenerator } from './extraProp'\nexport type { ExtraPropDef, ExtraPropDefs } from './extraProp'\n\nexport { PointFactory, Points } from './geo'\nexport type { Point } from './geo'\n\nexport { JobBase, JobEventType, JobStatus } from './job'\nexport type { Job, JobContext, JobEvent, JobSerialized } from './job'\n\nexport { LanguageCode, Languages, LanguagesISO639part2 } from './language'\nexport type { Labels } from './language'\n\nexport type { Logger } from './logger'\n\nexport type { Message } from './message'\nexport { MessageNotificationType, MessagePropsKey, MessageStatus, MessageTargetUserType, Messages } from './message'\n\nexport { NodeFactory, NodeKeys, NodeMetaKeys, Nodes, NodeValueFormatter, NodeValues } from './node'\nexport type {\n ArenaRecordNode,\n Node,\n NodeMeta,\n NodePointer,\n NodeRefData,\n NodeService,\n NodesMap,\n NodeValueCode,\n NodeValueCoordinate,\n NodeValueFile,\n NodeValueTaxon,\n} from './node'\n\nexport {\n NodeDefCountType,\n NodeDefType,\n NodeDefFactory,\n NodeDefs,\n NodeDefEntityRenderType,\n NodeDefFileType,\n NodeDefTextInputType,\n NodeDefTextRenderType,\n FormHeaderColor,\n} from './nodeDef'\n\nexport { NodeDefExpressionEvaluator, NodeDefExpressionValidator } from './nodeDefExpressionEvaluator'\nexport type { CategoryItemProvider, TaxonProvider } from './nodeDefExpressionEvaluator'\n\nexport type {\n NodeDef,\n NodeDefLayout,\n NodeDefMeta,\n NodeDefProps,\n NodeDefPropsWithLayout,\n NodeDefBoolean,\n NodeDefBooleanProps,\n NodeDefCode,\n NodeDefCodeLayout,\n NodeDefCodeProps,\n NodeDefCoordinate,\n NodeDefCoordinateProps,\n NodeDefDate,\n NodeDefDecimal,\n NodeDefDecimalProps,\n NodeDefEntity,\n NodeDefEntityChildPosition,\n NodeDefEntityLayout,\n NodeDefEntityProps,\n NodeDefPrintOrientation,\n NodeDefFile,\n NodeDefFileProps,\n NodeDefFormHeader,\n NodeDefFormHeaderProps,\n NodeDefInteger,\n NodeDefPropsAdvanced,\n NodeDefTaxon,\n NodeDefTaxonProps,\n NodeDefText,\n NodeDefTextProps,\n NodeDefTextLayout,\n NodeDefTime,\n NodeDefTimeProps,\n NodeDefExpression,\n NodeDefMap,\n NodeDefService,\n NodeDefValidations,\n} from './nodeDef'\n\nexport {\n NodePointers,\n RecordCloner,\n RecordFactory,\n RecordFixer,\n Records,\n RECORD_STEP_DEFAULT,\n RecordExpressionEvaluator,\n RecordNodesUpdater,\n RecordPrettyPrinter,\n RecordUpdater,\n RecordUpdateResult,\n RecordValidator,\n RecordValidations,\n} from './record'\nexport type {\n AttributeValidatorParams,\n AttributesValidatorParams,\n NodeCreateParams,\n NodesUpdateParams,\n ArenaRecord,\n Record,\n RecordExpressionContext,\n RecordExpressionEvaluationContext,\n RecordService,\n RecordUpdateOptions,\n RecordValidatorParams,\n SortedAttributesValidatorParams,\n} from './record'\n\nexport { ServiceRegistry, ServiceType } from './registry'\n\nexport { DEFAULT_SRS, DEFAULT_SRS_INDEX, SRSFactory } from './srs'\nexport type { SRS, SRSIndex } from './srs'\n\nexport {\n NodeDefsFixer,\n SurveyDocImages,\n SurveyDocImageFactory,\n SurveyDocPlace,\n SurveyDependencyType,\n SurveyFactory,\n SurveyFileFactory,\n SurveyFileType,\n SurveyRefDataFactory,\n SurveySecurityProp,\n Surveys,\n surveyDocImagePropKeys,\n surveySecurityDefaults,\n defaultCycle,\n} from './survey'\nexport type {\n Survey,\n SurveyCycle,\n SurveyDependency,\n SurveyDependencyGraph,\n SurveyDocImage,\n SurveyDocImageFactoryParams,\n SurveyDocImageProps,\n SurveyFile,\n SurveyFileFactoryParams,\n SurveyFileProps,\n SurveyProps,\n SurveyRefData,\n SurveySecurity,\n SurveyService,\n} from './survey'\n\nexport { Taxa, Taxonomies, TaxonomyFactory, TaxonFactory, TaxonGenerator, VernacularNameFactory } from './taxonomy'\nexport type {\n VernacularNameParams,\n TaxonomyFactoryParams,\n TaxonFactoryParams,\n Taxonomy,\n TaxonomyService,\n VernacularNameProps,\n VernacularName,\n TaxonProps,\n Taxon,\n TaxonomyProps,\n TaxonService,\n} from './taxonomy'\n\nexport { SurveyBuilder, SurveyObjectBuilders } from './tests/builder/surveyBuilder'\nexport { RecordBuilder, RecordNodeBuilders } from './tests/builder/recordBuilder'\n\nexport {\n Arrays,\n DateFormats,\n Dates,\n FileNames,\n FileProcessor,\n Numbers,\n Objects,\n Promises,\n Queue,\n RetryProcessor,\n Strings,\n UnitOfTime,\n UUIDs,\n Versions,\n} from './utils'\n\nexport type { FileProcessorConstructorArgs, ParsedVersion } from './utils'\n\nexport {\n FieldValidators,\n ValidationFactory,\n ValidationResultFactory,\n ValidationResults,\n Validations,\n ValidationSeverity,\n Validator,\n ValidatorErrorKeys,\n} from './validation'\nexport type { FieldValidator, Validation, ValidationFields, ValidationResult, ValidationCounts } from './validation'\n"]}
@@ -1,11 +1,11 @@
1
1
  import { Factory } from '../common';
2
- import { Node } from './node';
2
+ import { ArenaRecordNode } from './node';
3
3
  export type NodeFactoryParams = {
4
4
  nodeDefUuid: string;
5
5
  recordUuid: string;
6
- parentNode?: Node;
6
+ parentNode?: ArenaRecordNode;
7
7
  surveyUuid?: string;
8
8
  value?: any;
9
9
  };
10
- export declare const NodeFactory: Factory<Node, NodeFactoryParams>;
11
- export declare const NodePlaceholderFactory: Factory<Node, NodeFactoryParams>;
10
+ export declare const NodeFactory: Factory<ArenaRecordNode, NodeFactoryParams>;
11
+ export declare const NodePlaceholderFactory: Factory<ArenaRecordNode, NodeFactoryParams>;
@@ -1 +1 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/node/factory.ts"],"names":[],"mappings":";;;AACA,oCAAuC;AAW1B,QAAA,WAAW,GAAqC;IAC3D,cAAc,EAAE,CAAC,MAAyB,EAAQ,EAAE;;;QAClD,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;QACzE,MAAM,GAAG,GAAG,aAAK,CAAC,sBAAsB,EAAE,CAAA;QAE1C,OAAO;YACL,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,GAAG;YAChB,YAAY,EAAE,GAAG;YACjB,IAAI,EAAE;gBACJ,CAAC,EAAE,CAAC,GAAG,OAAC,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,0CAAE,CAAC,mCAAI,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,EAAC,CAAC,CAAC,CAAC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;aACrF;YACD,WAAW;YACX,UAAU,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI;YAC5B,UAAU;YACV,UAAU;YACV,KAAK;YACL,IAAI,EAAE,aAAK,CAAC,EAAE,EAAE;SACjB,CAAA;IACH,CAAC;CACF,CAAA;AAEY,QAAA,sBAAsB,GAAqC;IACtE,cAAc,EAAE,CAAC,MAAyB,EAAQ,EAAE;QAClD,uCACK,QAAA,WAAW,CAAC,cAAc,CAAC,MAAM,CAAC,KACrC,WAAW,EAAE,IAAI,IAClB;IACH,CAAC;CACF,CAAA","sourcesContent":["import { Factory } from '../common'\nimport { Dates, UUIDs } from '../utils'\nimport { Node } from './node'\n\nexport type NodeFactoryParams = {\n nodeDefUuid: string\n recordUuid: string\n parentNode?: Node\n surveyUuid?: string\n value?: any\n}\n\nexport const NodeFactory: Factory<Node, NodeFactoryParams> = {\n createInstance: (params: NodeFactoryParams): Node => {\n const { nodeDefUuid, recordUuid, parentNode, surveyUuid, value } = params\n const now = Dates.nowFormattedForStorage()\n\n return {\n created: true,\n dateCreated: now,\n dateModified: now,\n meta: {\n h: [...(parentNode?.meta?.h ?? []), ...(parentNode?.uuid ? [parentNode?.uuid] : [])],\n },\n nodeDefUuid,\n parentUuid: parentNode?.uuid,\n recordUuid,\n surveyUuid,\n value,\n uuid: UUIDs.v4(),\n }\n },\n}\n\nexport const NodePlaceholderFactory: Factory<Node, NodeFactoryParams> = {\n createInstance: (params: NodeFactoryParams): Node => {\n return {\n ...NodeFactory.createInstance(params),\n placeholder: true,\n }\n },\n}\n"]}
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/node/factory.ts"],"names":[],"mappings":";;;AACA,oCAAuC;AAW1B,QAAA,WAAW,GAAgD;IACtE,cAAc,EAAE,CAAC,MAAyB,EAAmB,EAAE;;;QAC7D,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;QACzE,MAAM,GAAG,GAAG,aAAK,CAAC,sBAAsB,EAAE,CAAA;QAE1C,OAAO;YACL,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,GAAG;YAChB,YAAY,EAAE,GAAG;YACjB,IAAI,EAAE;gBACJ,CAAC,EAAE,CAAC,GAAG,OAAC,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,0CAAE,CAAC,mCAAI,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,EAAC,CAAC,CAAC,CAAC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;aACrF;YACD,WAAW;YACX,UAAU,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI;YAC5B,UAAU;YACV,UAAU;YACV,KAAK;YACL,IAAI,EAAE,aAAK,CAAC,EAAE,EAAE;SACjB,CAAA;IACH,CAAC;CACF,CAAA;AAEY,QAAA,sBAAsB,GAAgD;IACjF,cAAc,EAAE,CAAC,MAAyB,EAAmB,EAAE;QAC7D,uCACK,QAAA,WAAW,CAAC,cAAc,CAAC,MAAM,CAAC,KACrC,WAAW,EAAE,IAAI,IAClB;IACH,CAAC;CACF,CAAA","sourcesContent":["import { Factory } from '../common'\nimport { Dates, UUIDs } from '../utils'\nimport { ArenaRecordNode } from './node'\n\nexport type NodeFactoryParams = {\n nodeDefUuid: string\n recordUuid: string\n parentNode?: ArenaRecordNode\n surveyUuid?: string\n value?: any\n}\n\nexport const NodeFactory: Factory<ArenaRecordNode, NodeFactoryParams> = {\n createInstance: (params: NodeFactoryParams): ArenaRecordNode => {\n const { nodeDefUuid, recordUuid, parentNode, surveyUuid, value } = params\n const now = Dates.nowFormattedForStorage()\n\n return {\n created: true,\n dateCreated: now,\n dateModified: now,\n meta: {\n h: [...(parentNode?.meta?.h ?? []), ...(parentNode?.uuid ? [parentNode?.uuid] : [])],\n },\n nodeDefUuid,\n parentUuid: parentNode?.uuid,\n recordUuid,\n surveyUuid,\n value,\n uuid: UUIDs.v4(),\n }\n },\n}\n\nexport const NodePlaceholderFactory: Factory<ArenaRecordNode, NodeFactoryParams> = {\n createInstance: (params: NodeFactoryParams): ArenaRecordNode => {\n return {\n ...NodeFactory.createInstance(params),\n placeholder: true,\n }\n },\n}\n"]}
@@ -1,5 +1,4 @@
1
- export type { Node, NodeMeta, NodeRefData, NodesMap } from './node';
2
- export type { Node as ArenaRecordNode } from './node';
1
+ export type { ArenaRecordNode, Node, NodeMeta, NodeRefData, NodesMap } from './node';
3
2
  export { NodeKeys, NodeMetaKeys } from './node';
4
3
  export type { NodePointer } from './nodePointer';
5
4
  export type { NodeValueCode, NodeValueCoordinate, NodeValueFile, NodeValueTaxon } from './nodeValue';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";;;AAGA,+BAA+C;AAAtC,gGAAA,QAAQ,OAAA;AAAE,oGAAA,YAAY,OAAA;AAM/B,qCAAuC;AAA9B,sGAAA,WAAW,OAAA;AAEpB,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AAEd,2DAAyD;AAAhD,wHAAA,kBAAkB,OAAA;AAE3B,2CAAyC;AAAhC,wGAAA,UAAU,OAAA","sourcesContent":["export type { Node, NodeMeta, NodeRefData, NodesMap } from './node'\nexport type { Node as ArenaRecordNode } from './node'\n\nexport { NodeKeys, NodeMetaKeys } from './node'\n\nexport type { NodePointer } from './nodePointer'\n\nexport type { NodeValueCode, NodeValueCoordinate, NodeValueFile, NodeValueTaxon } from './nodeValue'\n\nexport { NodeFactory } from './factory'\n\nexport { Nodes } from './nodes'\n\nexport { NodeValueFormatter } from './nodeValueFormatter'\n\nexport { NodeValues } from './nodeValues'\n\nexport type { NodeService } from './service'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";;;AAEA,+BAA+C;AAAtC,gGAAA,QAAQ,OAAA;AAAE,oGAAA,YAAY,OAAA;AAM/B,qCAAuC;AAA9B,sGAAA,WAAW,OAAA;AAEpB,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AAEd,2DAAyD;AAAhD,wHAAA,kBAAkB,OAAA;AAE3B,2CAAyC;AAAhC,wGAAA,UAAU,OAAA","sourcesContent":["export type { ArenaRecordNode, Node, NodeMeta, NodeRefData, NodesMap } from './node'\n\nexport { NodeKeys, NodeMetaKeys } from './node'\n\nexport type { NodePointer } from './nodePointer'\n\nexport type { NodeValueCode, NodeValueCoordinate, NodeValueFile, NodeValueTaxon } from './nodeValue'\n\nexport { NodeFactory } from './factory'\n\nexport { Nodes } from './nodes'\n\nexport { NodeValueFormatter } from './nodeValueFormatter'\n\nexport { NodeValues } from './nodeValues'\n\nexport type { NodeService } from './service'\n"]}
@@ -61,7 +61,7 @@ export interface NodeRefData {
61
61
  categoryItem?: CategoryItem;
62
62
  taxon?: Taxon;
63
63
  }
64
- export interface Node {
64
+ export interface ArenaRecordNode {
65
65
  dateCreated?: string;
66
66
  dateModified?: string;
67
67
  id?: number;
@@ -87,6 +87,11 @@ export interface Node {
87
87
  */
88
88
  updated?: boolean;
89
89
  }
90
+ /**
91
+ * @deprecated Use ArenaRecordNode: this name shadows the DOM Node type.
92
+ * It will be removed in the next major version.
93
+ */
94
+ export type Node = ArenaRecordNode;
90
95
  export interface NodesMap {
91
- [key: string]: Node;
96
+ [key: string]: ArenaRecordNode;
92
97
  }
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node/node.ts"],"names":[],"mappings":";;;AAGA,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,2BAAe,CAAA;AACjB,CAAC,EAHW,QAAQ,aAAR,QAAQ,GAAR,QAAQ,QAGnB;AAED,IAAY,YAEX;AAFD,WAAY,YAAY;IACtB,uBAAO,CAAA;AACT,CAAC,EAFW,YAAY,aAAZ,YAAY,GAAZ,YAAY,QAEvB","sourcesContent":["import { CategoryItem } from '../category'\nimport { Taxon } from '../taxonomy'\n\nexport enum NodeKeys {\n meta = 'meta',\n value = 'value',\n}\n\nexport enum NodeMetaKeys {\n h = 'h',\n}\n\nexport interface NodeMeta {\n /**\n * Applicability of the node children (by definition UUID). If not defined, the children are applicable by default.\n */\n childApplicability?: { [uuid: string]: boolean }\n /**\n * Whether the node children (by definition UUID) are editable (true) or read-only (false).\n * If not defined, the children are editable by default.\n */\n cEdit?: { [uuid: string]: boolean }\n /**\n * Maximum number of children (by definition UUID) for the node.\n */\n childrenMaxCount?: { [uuid: string]: number }\n /**\n * Minimum number of children (by definition UUID) for the node.\n */\n childrenMinCount?: { [uuid: string]: number }\n /**\n * Whether the node children (by definition UUID) are visible (true) or hidden (false).\n * If not defined, the children are visible by default.\n */\n cVis?: { [uuid: string]: boolean }\n /**\n * Hierarchy of ancestor node UUIDs.\n */\n h?: string[]\n /**\n * Hierarchy of code attribute ancestor UUIDs (according to the parent code defs specified).\n */\n hCode?: string[]\n /**\n * True if the value has been auto-filled from the node default value\n */\n defaultValueApplied?: boolean\n /**\n * True if the value has been auto-filled from the user group qualifier\n */\n qualifierValueApplied?: boolean\n}\n\nexport interface NodeRefData {\n categoryItem?: CategoryItem\n taxon?: Taxon\n}\n\nexport interface Node {\n dateCreated?: string\n dateModified?: string\n id?: number\n meta?: NodeMeta\n nodeDefUuid: string\n parentUuid?: string\n recordUuid: string\n refData?: NodeRefData\n uuid: string\n value?: any\n placeholder?: boolean\n surveyUuid?: string\n\n // transient status variables\n /**\n * Record node has been created but not persisted yet.\n */\n created?: boolean\n /**\n * Record node has been deleted.\n */\n deleted?: boolean\n /**\n * Record node has been modified but not persisted yet.\n */\n updated?: boolean\n}\n\nexport interface NodesMap {\n [key: string]: Node\n}\n"]}
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node/node.ts"],"names":[],"mappings":";;;AAGA,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,2BAAe,CAAA;AACjB,CAAC,EAHW,QAAQ,aAAR,QAAQ,GAAR,QAAQ,QAGnB;AAED,IAAY,YAEX;AAFD,WAAY,YAAY;IACtB,uBAAO,CAAA;AACT,CAAC,EAFW,YAAY,aAAZ,YAAY,GAAZ,YAAY,QAEvB","sourcesContent":["import { CategoryItem } from '../category'\nimport { Taxon } from '../taxonomy'\n\nexport enum NodeKeys {\n meta = 'meta',\n value = 'value',\n}\n\nexport enum NodeMetaKeys {\n h = 'h',\n}\n\nexport interface NodeMeta {\n /**\n * Applicability of the node children (by definition UUID). If not defined, the children are applicable by default.\n */\n childApplicability?: { [uuid: string]: boolean }\n /**\n * Whether the node children (by definition UUID) are editable (true) or read-only (false).\n * If not defined, the children are editable by default.\n */\n cEdit?: { [uuid: string]: boolean }\n /**\n * Maximum number of children (by definition UUID) for the node.\n */\n childrenMaxCount?: { [uuid: string]: number }\n /**\n * Minimum number of children (by definition UUID) for the node.\n */\n childrenMinCount?: { [uuid: string]: number }\n /**\n * Whether the node children (by definition UUID) are visible (true) or hidden (false).\n * If not defined, the children are visible by default.\n */\n cVis?: { [uuid: string]: boolean }\n /**\n * Hierarchy of ancestor node UUIDs.\n */\n h?: string[]\n /**\n * Hierarchy of code attribute ancestor UUIDs (according to the parent code defs specified).\n */\n hCode?: string[]\n /**\n * True if the value has been auto-filled from the node default value\n */\n defaultValueApplied?: boolean\n /**\n * True if the value has been auto-filled from the user group qualifier\n */\n qualifierValueApplied?: boolean\n}\n\nexport interface NodeRefData {\n categoryItem?: CategoryItem\n taxon?: Taxon\n}\n\nexport interface ArenaRecordNode {\n dateCreated?: string\n dateModified?: string\n id?: number\n meta?: NodeMeta\n nodeDefUuid: string\n parentUuid?: string\n recordUuid: string\n refData?: NodeRefData\n uuid: string\n value?: any\n placeholder?: boolean\n surveyUuid?: string\n\n // transient status variables\n /**\n * Record node has been created but not persisted yet.\n */\n created?: boolean\n /**\n * Record node has been deleted.\n */\n deleted?: boolean\n /**\n * Record node has been modified but not persisted yet.\n */\n updated?: boolean\n}\n\n/**\n * @deprecated Use ArenaRecordNode: this name shadows the DOM Node type.\n * It will be removed in the next major version.\n */\nexport type Node = ArenaRecordNode\n\nexport interface NodesMap {\n [key: string]: ArenaRecordNode\n}\n"]}
@@ -1,6 +1,6 @@
1
- import { Node } from './node';
1
+ import { ArenaRecordNode } from './node';
2
2
  import { NodeDef, NodeDefProps, NodeDefType } from '../nodeDef';
3
3
  export interface NodePointer {
4
- nodeCtx: Node;
4
+ nodeCtx: ArenaRecordNode;
5
5
  nodeDef: NodeDef<NodeDefType, NodeDefProps>;
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"nodePointer.js","sourceRoot":"","sources":["../../src/node/nodePointer.ts"],"names":[],"mappings":"","sourcesContent":["import { Node } from './node'\nimport { NodeDef, NodeDefProps, NodeDefType } from '../nodeDef'\n\nexport interface NodePointer {\n nodeCtx: Node\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}\n"]}
1
+ {"version":3,"file":"nodePointer.js","sourceRoot":"","sources":["../../src/node/nodePointer.ts"],"names":[],"mappings":"","sourcesContent":["import { ArenaRecordNode } from './node'\nimport { NodeDef, NodeDefProps, NodeDefType } from '../nodeDef'\n\nexport interface NodePointer {\n nodeCtx: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}\n"]}
@@ -1,12 +1,12 @@
1
1
  import { LanguageCode } from '../language';
2
2
  import { NodeDef, NodeDefType } from '../nodeDef';
3
3
  import { Survey } from '../survey';
4
- import { Node } from './node';
4
+ import { ArenaRecordNode } from './node';
5
5
  type FormatParams = {
6
6
  survey: Survey;
7
7
  cycle: string;
8
8
  nodeDef: NodeDef<NodeDefType>;
9
- node?: Node;
9
+ node?: ArenaRecordNode;
10
10
  value: any;
11
11
  showLabel?: boolean;
12
12
  quoteLabels?: boolean;