@openforis/arena-core 2.3.36 → 2.3.39
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.
- package/dist/auth/authGroup.js.map +1 -1
- package/dist/auth/authGroups.d.ts +21 -11
- package/dist/auth/authGroups.js.map +1 -1
- package/dist/auth/authorizer.d.ts +64 -38
- package/dist/auth/authorizer.js.map +1 -1
- package/dist/auth/permission.js.map +1 -1
- package/dist/auth/user.js.map +1 -1
- package/dist/auth/users.d.ts +19 -9
- package/dist/auth/users.js +3 -2
- package/dist/auth/users.js.map +1 -1
- package/dist/category/categories.d.ts +7 -3
- package/dist/category/categories.js.map +1 -1
- package/dist/category/categoryImportSummary.js.map +1 -1
- package/dist/category/categoryItemGenerator.d.ts +6 -4
- package/dist/category/categoryItems.d.ts +9 -4
- package/dist/category/categoryItems.js +2 -1
- package/dist/category/categoryItems.js.map +1 -1
- package/dist/category/factory.js.map +1 -1
- package/dist/chain/chain.js.map +1 -1
- package/dist/common/index.js.map +1 -1
- package/dist/dataExport/FlatDataExportModel.js.map +1 -1
- package/dist/dataExport/FlatDataExportOptions.js.map +1 -1
- package/dist/dataExport/FlatDataFiles.d.ts +7 -5
- package/dist/dataExport/UniqueFileNamesGenerator.js.map +1 -1
- package/dist/dataQuery/dataQuery.js.map +1 -1
- package/dist/dataQuery/dataQuerySummaries.d.ts +28 -15
- package/dist/dataQuery/dataQuerySummaries.js +3 -3
- package/dist/dataQuery/dataQuerySummaries.js.map +1 -1
- package/dist/error/SystemError.js.map +1 -1
- package/dist/esm/auth/authGroups.js.map +1 -1
- package/dist/esm/auth/users.js +3 -2
- package/dist/esm/auth/users.js.map +1 -1
- package/dist/esm/category/categories.js.map +1 -1
- package/dist/esm/category/categoryItems.js +2 -1
- package/dist/esm/category/categoryItems.js.map +1 -1
- package/dist/esm/dataExport/FlatDataExportModel.js.map +1 -1
- package/dist/esm/dataQuery/dataQuerySummaries.js +3 -3
- package/dist/esm/dataQuery/dataQuerySummaries.js.map +1 -1
- package/dist/esm/expression/javascript/evaluator.js.map +1 -1
- package/dist/esm/extraProp/extraProps.js.map +1 -1
- package/dist/esm/geo/pointFactory.js.map +1 -1
- package/dist/esm/geo/points/bearing.js +1 -1
- package/dist/esm/geo/points/bearing.js.map +1 -1
- package/dist/esm/geo/points/distance.js +1 -1
- package/dist/esm/geo/points/distance.js.map +1 -1
- package/dist/esm/geo/points/isValid.js.map +1 -1
- package/dist/esm/geo/points/transform.js.map +1 -1
- package/dist/esm/job/JobBase.js +4 -3
- package/dist/esm/job/JobBase.js.map +1 -1
- package/dist/esm/message/messages.js +9 -8
- package/dist/esm/message/messages.js.map +1 -1
- package/dist/esm/node/factory.js +2 -1
- package/dist/esm/node/factory.js.map +1 -1
- package/dist/esm/node/nodeValueFormatter.js +2 -1
- package/dist/esm/node/nodeValueFormatter.js.map +1 -1
- package/dist/esm/node/nodeValues.js +3 -2
- package/dist/esm/node/nodeValues.js.map +1 -1
- package/dist/esm/node/nodes.js +4 -4
- package/dist/esm/node/nodes.js.map +1 -1
- package/dist/esm/nodeDef/nodeDefs.js +10 -10
- package/dist/esm/nodeDef/nodeDefs.js.map +1 -1
- package/dist/esm/nodeDefExpressionEvaluator/evaluator.js.map +1 -1
- package/dist/esm/nodeDefExpressionEvaluator/functions.js.map +1 -1
- package/dist/esm/nodeDefExpressionEvaluator/node/identifier.js +3 -2
- package/dist/esm/nodeDefExpressionEvaluator/node/identifier.js.map +1 -1
- package/dist/esm/nodeDefExpressionEvaluator/node/member.js.map +1 -1
- package/dist/esm/nodeDefExpressionEvaluator/validator.js.map +1 -1
- package/dist/esm/record/_records/nodeDefSelfReferences.js.map +1 -1
- package/dist/esm/record/_records/recordGetters.js.map +1 -1
- package/dist/esm/record/_records/recordNodesIndexReader.js +6 -4
- package/dist/esm/record/_records/recordNodesIndexReader.js.map +1 -1
- package/dist/esm/record/_records/recordNodesIndexUpdater.js +10 -7
- package/dist/esm/record/_records/recordNodesIndexUpdater.js.map +1 -1
- package/dist/esm/record/_records/recordPagesValidation.js.map +1 -1
- package/dist/esm/record/_records/recordUpdater.js.map +1 -1
- package/dist/esm/record/factory.js +2 -1
- package/dist/esm/record/factory.js.map +1 -1
- package/dist/esm/record/recordCloner.js +2 -1
- package/dist/esm/record/recordCloner.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/functions.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/node/identifier/identifier.js +3 -2
- package/dist/esm/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/recordExpressionEvaluator.js +4 -7
- package/dist/esm/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsCountUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesDeleter.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordUpdateResult.js.map +1 -1
- package/dist/esm/record/recordUpdater.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeTypeValidator.js +2 -2
- package/dist/esm/record/recordValidator/attributeTypeValidator.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeUniqueValidator.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeValidator.js.map +1 -1
- package/dist/esm/record/recordValidator/recordValidator.js.map +1 -1
- package/dist/esm/survey/nodeDefsFixer.js.map +1 -1
- package/dist/esm/survey/refData/factory.js +3 -2
- package/dist/esm/survey/refData/factory.js.map +1 -1
- package/dist/esm/survey/surveyDocImageFactory.js.map +1 -1
- package/dist/esm/survey/surveyDocImages.js.map +1 -1
- package/dist/esm/survey/surveyFileFactory.js.map +1 -1
- package/dist/esm/survey/surveys/_nodeDefs/nodeDefsIndex.js.map +1 -1
- package/dist/esm/survey/surveys/_nodeDefs/nodeDefsReader.js.map +1 -1
- package/dist/esm/survey/surveys/dependencies.js +2 -1
- package/dist/esm/survey/surveys/dependencies.js.map +1 -1
- package/dist/esm/survey/surveys/nodeDefs.js +4 -2
- package/dist/esm/survey/surveys/nodeDefs.js.map +1 -1
- package/dist/esm/survey/surveys/refsData.js +2 -1
- package/dist/esm/survey/surveys/refsData.js.map +1 -1
- package/dist/esm/survey/surveys/surveyGettersSecurity.js +1 -4
- package/dist/esm/survey/surveys/surveyGettersSecurity.js.map +1 -1
- package/dist/esm/survey/surveys/surveysGetters.js +5 -7
- package/dist/esm/survey/surveys/surveysGetters.js.map +1 -1
- package/dist/esm/taxonomy/taxa.js.map +1 -1
- package/dist/esm/taxonomy/taxonomies.js.map +1 -1
- package/dist/esm/tests/builder/recordBuilder/attributeBuilder.js.map +1 -1
- package/dist/esm/tests/builder/recordBuilder/index.js.map +1 -1
- package/dist/esm/tests/builder/recordBuilder/nodeBuilder.js.map +1 -1
- package/dist/esm/tests/builder/surveyBuilder/categoryItemBuilder.js.map +1 -1
- package/dist/esm/tests/builder/surveyBuilder/nodeDefAttributeBuilder.js.map +1 -1
- package/dist/esm/tests/builder/surveyBuilder/nodeDefBuilder.js.map +1 -1
- package/dist/esm/utils/_objects/camelize.js.map +1 -1
- package/dist/esm/utils/arrays.js.map +1 -1
- package/dist/esm/utils/dates.js.map +1 -1
- package/dist/esm/utils/fileNames.js.map +1 -1
- package/dist/esm/utils/fileProcessor.js +2 -1
- package/dist/esm/utils/fileProcessor.js.map +1 -1
- package/dist/esm/utils/numbers.js.map +1 -1
- package/dist/esm/utils/queue.js.map +1 -1
- package/dist/esm/utils/versions.js.map +1 -1
- package/dist/esm/validation/factory.js.map +1 -1
- package/dist/esm/validation/fieldValidators/numeric.js.map +1 -1
- package/dist/esm/validation/fieldValidators/numericPositive.js.map +1 -1
- package/dist/esm/validation/validationResults.js +1 -1
- package/dist/esm/validation/validationResults.js.map +1 -1
- package/dist/esm/validation/validations.js +2 -2
- package/dist/esm/validation/validations.js.map +1 -1
- package/dist/esm/validation/validator.js.map +1 -1
- package/dist/expression/javascript/evaluator.js.map +1 -1
- package/dist/expression/javascript/global.js.map +1 -1
- package/dist/expression/javascript/node/array.js.map +1 -1
- package/dist/expression/javascript/node/binary.js.map +1 -1
- package/dist/expression/javascript/node/call.js.map +1 -1
- package/dist/expression/javascript/node/compound.js.map +1 -1
- package/dist/expression/javascript/node/conditional.js.map +1 -1
- package/dist/expression/javascript/node/identifier.js.map +1 -1
- package/dist/expression/javascript/node/literal.js.map +1 -1
- package/dist/expression/javascript/node/member.js.map +1 -1
- package/dist/expression/javascript/node/sequence.js.map +1 -1
- package/dist/expression/javascript/node/this.js.map +1 -1
- package/dist/expression/javascript/node/unary.js.map +1 -1
- package/dist/expression/javascript/parser/jsep.js.map +1 -1
- package/dist/expression/javascript/parser/parser.js.map +1 -1
- package/dist/expression/node.js.map +1 -1
- package/dist/expression/variable.js.map +1 -1
- package/dist/extraProp/extraProp.js.map +1 -1
- package/dist/extraProp/extraProps.d.ts +9 -6
- package/dist/extraProp/extraProps.js.map +1 -1
- package/dist/extraProp/extraPropsDataGenerator.d.ts +7 -5
- package/dist/geo/pointFactory.js.map +1 -1
- package/dist/geo/points/bearing.js +5 -2
- package/dist/geo/points/bearing.js.map +1 -1
- package/dist/geo/points/distance.js +5 -2
- package/dist/geo/points/distance.js.map +1 -1
- package/dist/geo/points/equals.js.map +1 -1
- package/dist/geo/points/getSrs.js.map +1 -1
- package/dist/geo/points/index.d.ts +18 -14
- package/dist/geo/points/isFilled.js.map +1 -1
- package/dist/geo/points/isValid.js.map +1 -1
- package/dist/geo/points/parse.js.map +1 -1
- package/dist/geo/points/pointAtDistance.js.map +1 -1
- package/dist/geo/points/toLatLong.js.map +1 -1
- package/dist/geo/points/toString.js.map +1 -1
- package/dist/geo/points/transform.js.map +1 -1
- package/dist/job/JobBase.js +4 -3
- package/dist/job/JobBase.js.map +1 -1
- package/dist/job/jobEvent.js.map +1 -1
- package/dist/job/status.js.map +1 -1
- package/dist/language/languageCode.js.map +1 -1
- package/dist/language/languages.js.map +1 -1
- package/dist/message/message.js.map +1 -1
- package/dist/message/messages.d.ts +54 -28
- package/dist/message/messages.js +9 -8
- package/dist/message/messages.js.map +1 -1
- package/dist/node/factory.js +2 -1
- package/dist/node/factory.js.map +1 -1
- package/dist/node/node.js.map +1 -1
- package/dist/node/nodeValueFormatter.d.ts +2 -1
- package/dist/node/nodeValueFormatter.js +2 -1
- package/dist/node/nodeValueFormatter.js.map +1 -1
- package/dist/node/nodeValueProps.js.map +1 -1
- package/dist/node/nodeValues.d.ts +62 -41
- package/dist/node/nodeValues.js +3 -2
- package/dist/node/nodeValues.js.map +1 -1
- package/dist/node/nodes.d.ts +112 -86
- package/dist/node/nodes.js +4 -4
- package/dist/node/nodes.js.map +1 -1
- package/dist/nodeDef/nodeDef.js.map +1 -1
- package/dist/nodeDef/nodeDefs.d.ts +173 -86
- package/dist/nodeDef/nodeDefs.js +10 -10
- package/dist/nodeDef/nodeDefs.js.map +1 -1
- package/dist/nodeDef/types/entity.js.map +1 -1
- package/dist/nodeDef/types/file.js.map +1 -1
- package/dist/nodeDef/types/formHeader.js.map +1 -1
- package/dist/nodeDef/types/text.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/evaluator.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/functions.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/node/identifier.js +3 -2
- package/dist/nodeDefExpressionEvaluator/node/identifier.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/node/member.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/node/nodeDefExpressionNativeProperties.d.ts +11 -8
- package/dist/nodeDefExpressionEvaluator/node/thisEvaluator.d.ts +1 -1
- package/dist/nodeDefExpressionEvaluator/node/thisEvaluator.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/validator.js.map +1 -1
- package/dist/record/_records/nodeDefSelfReferences.d.ts +12 -4
- package/dist/record/_records/nodeDefSelfReferences.js.map +1 -1
- package/dist/record/_records/recordCompletion.js.map +1 -1
- package/dist/record/_records/recordGetters.js.map +1 -1
- package/dist/record/_records/recordNodesIndexReader.d.ts +14 -8
- package/dist/record/_records/recordNodesIndexReader.js +6 -4
- package/dist/record/_records/recordNodesIndexReader.js.map +1 -1
- package/dist/record/_records/recordNodesIndexUpdater.d.ts +22 -12
- package/dist/record/_records/recordNodesIndexUpdater.js +10 -7
- package/dist/record/_records/recordNodesIndexUpdater.js.map +1 -1
- package/dist/record/_records/recordPagesValidation.js.map +1 -1
- package/dist/record/_records/recordUpdater.js.map +1 -1
- package/dist/record/_records/recordUtils.js.map +1 -1
- package/dist/record/factory.js +2 -1
- package/dist/record/factory.js.map +1 -1
- package/dist/record/nodePointers.d.ts +13 -10
- package/dist/record/recordCloner.d.ts +11 -10
- package/dist/record/recordCloner.js +2 -1
- package/dist/record/recordCloner.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/functions.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/node/identifier/identifier.js +3 -2
- package/dist/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/node/identifier/nodesFinder.d.ts +8 -6
- package/dist/record/recordExpressionEvaluator/node/thisEvaluator.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/nodeValueExtractor.d.ts +7 -5
- package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.js +4 -7
- package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
- package/dist/record/recordFixer.d.ts +19 -10
- package/dist/record/recordNodesUpdater/index.d.ts +8 -7
- package/dist/record/recordNodesUpdater/recordEnumeratingItemsExpressionEvaluator.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordExpressionValueConverter.d.ts +2 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsCountUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsEditableUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsVisibleUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesCreator.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesDeleter.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordUpdateResult.js.map +1 -1
- package/dist/record/recordPrettyPrinter.d.ts +18 -15
- package/dist/record/recordPrettyPrinter.js.map +1 -1
- package/dist/record/recordStep.d.ts +5 -2
- package/dist/record/recordStep.js.map +1 -1
- package/dist/record/recordUpdater.d.ts +22 -15
- package/dist/record/recordUpdater.js.map +1 -1
- package/dist/record/recordValidations.d.ts +21 -14
- package/dist/record/recordValidator/attributeKeyValidator.d.ts +8 -6
- package/dist/record/recordValidator/attributeKeyValidator.js.map +1 -1
- package/dist/record/recordValidator/attributeTypeValidator.d.ts +2 -1
- package/dist/record/recordValidator/attributeTypeValidator.js +2 -2
- package/dist/record/recordValidator/attributeTypeValidator.js.map +1 -1
- package/dist/record/recordValidator/attributeUniqueValidator.d.ts +1 -5
- package/dist/record/recordValidator/attributeUniqueValidator.js.map +1 -1
- package/dist/record/recordValidator/attributeValidator.d.ts +3 -1
- package/dist/record/recordValidator/attributeValidator.js.map +1 -1
- package/dist/record/recordValidator/countVaildator.d.ts +21 -17
- package/dist/record/recordValidator/index.d.ts +4 -3
- package/dist/record/recordValidator/recordValidator.js.map +1 -1
- package/dist/record/records.d.ts +62 -220
- package/dist/registry/serviceRegistry.js.map +1 -1
- package/dist/registry/serviceType.js.map +1 -1
- package/dist/srs/srs.js.map +1 -1
- package/dist/survey/nodeDefsFixer.d.ts +5 -4
- package/dist/survey/nodeDefsFixer.js.map +1 -1
- package/dist/survey/refData/factory.js +3 -2
- package/dist/survey/refData/factory.js.map +1 -1
- package/dist/survey/survey.d.ts +2 -2
- package/dist/survey/survey.js.map +1 -1
- package/dist/survey/surveyDocImageFactory.js.map +1 -1
- package/dist/survey/surveyDocImages.d.ts +11 -5
- package/dist/survey/surveyDocImages.js.map +1 -1
- package/dist/survey/surveyFileFactory.js.map +1 -1
- package/dist/survey/surveys/_nodeDefs/nodeDefsIndex.js.map +1 -1
- package/dist/survey/surveys/_nodeDefs/nodeDefsReader.js.map +1 -1
- package/dist/survey/surveys/dependencies.js +2 -1
- package/dist/survey/surveys/dependencies.js.map +1 -1
- package/dist/survey/surveys/index.d.ts +82 -255
- package/dist/survey/surveys/nodeDefs.d.ts +4 -6
- package/dist/survey/surveys/nodeDefs.js +4 -2
- package/dist/survey/surveys/nodeDefs.js.map +1 -1
- package/dist/survey/surveys/refsData.js +2 -1
- package/dist/survey/surveys/refsData.js.map +1 -1
- package/dist/survey/surveys/surveyGettersSecurity.js +1 -4
- package/dist/survey/surveys/surveyGettersSecurity.js.map +1 -1
- package/dist/survey/surveys/surveysGetters.js +5 -7
- package/dist/survey/surveys/surveysGetters.js.map +1 -1
- package/dist/survey/surveys/surveysUtils.js.map +1 -1
- package/dist/taxonomy/taxa.d.ts +17 -11
- package/dist/taxonomy/taxa.js.map +1 -1
- package/dist/taxonomy/taxonGenerator.d.ts +6 -4
- package/dist/taxonomy/taxonomies.d.ts +7 -3
- package/dist/taxonomy/taxonomies.js.map +1 -1
- package/dist/tests/builder/recordBuilder/attributeBuilder.js.map +1 -1
- package/dist/tests/builder/recordBuilder/entityBuilder.js.map +1 -1
- package/dist/tests/builder/recordBuilder/index.d.ts +4 -2
- package/dist/tests/builder/recordBuilder/index.js.map +1 -1
- package/dist/tests/builder/recordBuilder/nodeBuilder.js.map +1 -1
- package/dist/tests/builder/recordBuilder/recordBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/categoryBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/categoryItemBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/index.d.ts +30 -15
- package/dist/tests/builder/surveyBuilder/nodeDefAttributeBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/nodeDefBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/nodeDefCodeBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/nodeDefEntityBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/nodeDefTaxonBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/surveyBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/taxonBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/taxonomyBuilder.js.map +1 -1
- package/dist/utils/_objects/assoc.js.map +1 -1
- package/dist/utils/_objects/assocPath.js.map +1 -1
- package/dist/utils/_objects/camelize.js.map +1 -1
- package/dist/utils/_objects/deepMerge.js.map +1 -1
- package/dist/utils/_objects/deleteEmptyProps.js.map +1 -1
- package/dist/utils/_objects/difference.js.map +1 -1
- package/dist/utils/_objects/dissoc.js.map +1 -1
- package/dist/utils/_objects/dissocPath.js.map +1 -1
- package/dist/utils/_objects/dissocPathIfEmpty.js.map +1 -1
- package/dist/utils/_objects/index.d.ts +34 -48
- package/dist/utils/_objects/isEmpty.js.map +1 -1
- package/dist/utils/_objects/isNil.js.map +1 -1
- package/dist/utils/_objects/isNotEmpty.js.map +1 -1
- package/dist/utils/_objects/parse.js.map +1 -1
- package/dist/utils/_objects/path.js.map +1 -1
- package/dist/utils/_objects/propertyOf.js.map +1 -1
- package/dist/utils/_objects/setInPath.js.map +1 -1
- package/dist/utils/_objects/stringify.js.map +1 -1
- package/dist/utils/arrays.d.ts +25 -15
- package/dist/utils/arrays.js.map +1 -1
- package/dist/utils/dates.d.ts +101 -48
- package/dist/utils/dates.js.map +1 -1
- package/dist/utils/fileNames.d.ts +7 -3
- package/dist/utils/fileNames.js.map +1 -1
- package/dist/utils/fileProcessor.js +2 -1
- package/dist/utils/fileProcessor.js.map +1 -1
- package/dist/utils/numbers.d.ts +42 -13
- package/dist/utils/numbers.js.map +1 -1
- package/dist/utils/promises.d.ts +12 -1
- package/dist/utils/queue.js.map +1 -1
- package/dist/utils/retryProcessor.js.map +1 -1
- package/dist/utils/strings.d.ts +22 -11
- package/dist/utils/uuids.d.ts +3 -1
- package/dist/utils/versions.d.ts +19 -7
- package/dist/utils/versions.js.map +1 -1
- package/dist/validation/factory.js.map +1 -1
- package/dist/validation/fieldValidators/email.js.map +1 -1
- package/dist/validation/fieldValidators/index.d.ts +12 -6
- package/dist/validation/fieldValidators/name.js.map +1 -1
- package/dist/validation/fieldValidators/notKeyword.js.map +1 -1
- package/dist/validation/fieldValidators/numeric.js.map +1 -1
- package/dist/validation/fieldValidators/numericPositive.js.map +1 -1
- package/dist/validation/fieldValidators/required.js.map +1 -1
- package/dist/validation/validation.js.map +1 -1
- package/dist/validation/validationResults.d.ts +17 -9
- package/dist/validation/validationResults.js +1 -1
- package/dist/validation/validationResults.js.map +1 -1
- package/dist/validation/validations.d.ts +71 -35
- package/dist/validation/validations.js +2 -2
- package/dist/validation/validations.js.map +1 -1
- package/dist/validation/validator.js.map +1 -1
- package/package.json +11 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeDefSelfReferences.js","sourceRoot":"","sources":["../../../src/record/_records/nodeDefSelfReferences.ts"],"names":[],"mappings":";;;AAAA,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CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QACpD,8BAA8B,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAChE,CAAA;AACH,CAAC,CAAA;AAEY,QAAA,qBAAqB,GAAG;IACnC,oBAAoB;CACrB,CAAA","sourcesContent":["import { ExpressionNode, ExpressionNodeType, IdentifierExpression, MemberExpression } from '../../expression'\nimport { parseExpression } from '../../expression/javascript/evaluator'\nimport { NodeDef, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { SurveyDependencyType } from '../../survey/survey'\n\n/**\n * True if the identifier is used as (or inside) the property of a member expression (e.g. \"dbh\" in\n * \"parent(tree).tree.dbh\" or in \"tree[dbh > 10]\"): there it can refer to nodes outside the context entity.\n */\nconst isReferencedThroughMember = (params: {\n expressionNode: unknown\n name: string\n inMemberProperty: boolean\n}): boolean => {\n const { expressionNode, name, inMemberProperty } = params\n if (!expressionNode || typeof expressionNode !== 'object') return false\n if (Array.isArray(expressionNode)) {\n return expressionNode.some((item) => isReferencedThroughMember({ expressionNode: item, name, inMemberProperty }))\n }\n const { type } = expressionNode as ExpressionNode<ExpressionNodeType>\n if (type === ExpressionNodeType.Identifier) {\n return inMemberProperty && (expressionNode as IdentifierExpression).name === name\n }\n if (type === ExpressionNodeType.Member) {\n const { object, property } = expressionNode as MemberExpression\n return (\n isReferencedThroughMember({ expressionNode: object, name, inMemberProperty }) ||\n isReferencedThroughMember({ expressionNode: property, name, inMemberProperty: true })\n )\n }\n return Object.values(expressionNode).some((child) =>\n isReferencedThroughMember({ expressionNode: child, name, inMemberProperty })\n )\n}\n\nconst isExpressionSelfReferenceLocal = (params: { expression: string | undefined; name: string }): boolean => {\n const { expression, name } = params\n if (!expression) return true\n try {\n return !isReferencedThroughMember({ expressionNode: parseExpression(expression), name, inMemberProperty: false })\n } catch {\n // invalid expression: be conservative\n return false\n }\n}\n\n/**\n * Returns true if the node def references itself in its expressions of the specified dependency type only\n * as a plain identifier (e.g. \"dbh > 0\" in a validation of \"dbh\"): such a reference is resolved among the\n * children of the node's parent entity, so only the node and its siblings depend on it, not every node with\n * the same node def in the record.\n */\nconst isSelfReferenceLocal = (params: {\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n dependencyType: SurveyDependencyType\n}): boolean => {\n const { nodeDef, dependencyType } = params\n // self references by plain identifier are allowed only in validation expressions (see dependencies.ts)\n if (dependencyType !== SurveyDependencyType.validations) return false\n const name = NodeDefs.getName(nodeDef)\n return NodeDefs.getValidationsExpressions(nodeDef).every(\n ({ expression, applyIf }) =>\n isExpressionSelfReferenceLocal({ expression, name }) &&\n isExpressionSelfReferenceLocal({ expression: applyIf, name })\n )\n}\n\nexport const NodeDefSelfReferences = {\n isSelfReferenceLocal,\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordCompletion.js","sourceRoot":"","sources":["../../../src/record/_records/recordCompletion.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AACxC,2CAA4E;AAC5E,yCAA8C;AAC9C,uCAAqC;AAErC,mDAAsD;AAOtD,MAAM,UAAU,GAAG,GAA0B,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAA;AAEzE,MAAM,QAAQ,GAAG,CAAC,QAA+B,EAAE,UAAiC,EAAQ,EAAE;IAC5F,QAAQ,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAA;IAClC,QAAQ,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,CAAA;AACtC,CAAC,CAAA;AAED,MAAM,2BAA2B,GAAG,CAAC,MAIpC,EAAyB,EAAE;IAC1B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IAE1C,IAAI,kBAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,YAAK,CAAC,mBAAmB,CAAC,E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AC/F,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IACjC,MAAM,UAAU,GAAG,IAAA,uBAAO,EAAC,MAAM,CAAC,CAAA;IAClC,OAAO,UAAU,CAAC,CAAC,CAAC,IAAA,QAAA,0BAA0B,EAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC5F,CAAC,CAAA;AAJY,QAAA,0BAA0B,GAA1B,0BAA0B,CAItC","sourcesContent":["import { Node, Nodes } from '../../node'\nimport { NodeDef, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { Survey, Surveys } from '../../survey'\nimport { Numbers } from '../../utils'\nimport { Record } from '../record'\nimport { getChildren, getRoot } from './recordGetters'\n\nexport interface EntityCompletionStats {\n total: number\n filled: number\n}\n\nconst emptyStats = (): EntityCompletionStats => ({ total: 0, filled: 0 })\n\nconst addStats = (statsAcc: EntityCompletionStats, statsToAdd: EntityCompletionStats): void => {\n statsAcc.total += statsToAdd.total\n statsAcc.filled += statsToAdd.filled\n}\n\nconst getAttributeCompletionStats = (params: {\n record: Record\n entity: Node\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): EntityCompletionStats => {\n const { record, entity, nodeDef } = params\n\n if (NodeDefs.isMultiple(nodeDef)) {\n const minCount = Nodes.getChildrenMinCount({ parentNode: entity, nodeDef })\n if (Number.isNaN(minCount) || minCount <= 0) return emptyStats()\n\n const filledNodesCount = getChildren(entity, nodeDef.uuid)(record).filter(Nodes.isValueNotBlank).length\n\n return { total: minCount, filled: Math.min(filledNodesCount, minCount) }\n }\n\n if (!NodeDefs.isRequired(nodeDef) && !NodeDefs.isKey(nodeDef)) return emptyStats()\n\n const node = getChildren(entity, nodeDef.uuid)(record)[0]\n return { total: 1, filled: node && Nodes.isValueNotBlank(node) ? 1 : 0 }\n}\n\nconst getChildEntityCompletionStats = (params: {\n survey: Survey\n record: Record\n parentEntity: Node\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): EntityCompletionStats => {\n const { survey, record, parentEntity, nodeDef } = params\n const childEntities = getChildren(parentEntity, nodeDef.uuid)(record)\n\n if (NodeDefs.isSingle(nodeDef)) {\n const childEntity = childEntities[0]\n return childEntity ? getEntityCompletionStats({ survey, record, entity: childEntity }) : emptyStats()\n }\n\n const minCountRaw = Nodes.getChildrenMinCount({ parentNode: parentEntity, nodeDef })\n const minCount = Number.isNaN(minCountRaw) ? 0 : Math.max(minCountRaw, 0)\n // entities added beyond the min count are still expected to be complete\n const expectedCount = Math.max(minCount, childEntities.length)\n if (expectedCount === 0) return emptyStats()\n\n const stats = emptyStats()\n for (let index = 0; index < expectedCount; index++) {\n const childEntity = childEntities[index]\n // a missing repetition (below the min count) counts as a single incomplete unit\n addStats(\n stats,\n childEntity ? getEntityCompletionStats({ survey, record, entity: childEntity }) : { total: 1, filled: 0 }\n )\n }\n return stats\n}\n\nexport const getEntityCompletionStats = (params: {\n survey: Survey\n record: Record\n entity: Node\n includeNestedEntities?: boolean\n}): EntityCompletionStats => {\n const { survey, record, entity, includeNestedEntities = true } = params\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const childDefs = Surveys.getNodeDefChildren({ survey, nodeDef: entityDef })\n\n const stats = emptyStats()\n for (const childDef of childDefs) {\n if (!Nodes.isChildApplicable(entity, childDef.uuid)) continue\n\n if (NodeDefs.isEntity(childDef)) {\n if (!includeNestedEntities) continue\n addStats(stats, getChildEntityCompletionStats({ survey, record, parentEntity: entity, nodeDef: childDef }))\n } else {\n addStats(stats, getAttributeCompletionStats({ record, entity, nodeDef: childDef }))\n }\n }\n return stats\n}\n\nconst toCompletionPercent = (stats: EntityCompletionStats): number => {\n const { total, filled } = stats\n if (total <= 0) return 100\n return Numbers.roundToPrecision((filled / total) * 100, 2)\n}\n\n/**\n * Returns the percentage of completion of the given entity (0-100), considering every descendant recursively.\n * A required or key attribute is considered filled when it has a non empty value; multiple attributes and\n * entities are considered filled based on their min count (see Nodes.getChildrenMinCount).\n */\nexport const getEntityCompletionPercent = (params: { survey: Survey; record: Record; entity: Node }): number =>\n toCompletionPercent(getEntityCompletionStats(params))\n\n/**\n * Returns the percentage of completion of the given entity (0-100), considering only its own attributes\n * (nested entities are ignored).\n */\nexport const getEntityOwnCompletionPercent = (params: { survey: Survey; record: Record; entity: Node }): number =>\n toCompletionPercent(getEntityCompletionStats({ ...params, includeNestedEntities: false }))\n\n/**\n * Returns the percentage of completion of the given record (0-100), i.e. the completion of its root entity.\n */\nexport const getRecordCompletionPercent = (params: { survey: Survey; record: Record }): number => {\n const { survey, record } = params\n const rootEntity = getRoot(record)\n return rootEntity ? getEntityCompletionPercent({ survey, record, entity: rootEntity }) : 0\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordGetters.js","sourceRoot":"","sources":["../../../src/record/_records/recordGetters.ts"],"names":[],"mappings":";;;AAAA,yCAAyD;AACzD,uCAAyC;AACzC,qCAA+D;AAC/D,sDAAkD;AAClD,2CAA2G;AAC3G,yCAAoD;AAEpD,uCAA2C;AAC3C,sCAAuD;AACvD,8CAAsD;AACtD,qEAAiE;AACjE,mEAA+D;AAExD,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAU,EAAE,WAAC,OAAA,MAAA,MAAM,CAAC,KAAK,mCAAI,qBAAY,CAAA,EAAA,CAAA;AAAnE,QAAA,QAAQ,YAA2D;AAEzE,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAoB,EAAE,WAAC,OAAA,MAAA,MAAM,CAAC,KAAK,mCAAI,EAAE,CAAA,EAAA,CAAA;AAAnE,QAAA,QAAQ,YAA2D;AAEzE,MAAM,aAAa,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAA,gBAAQ,EAAC,MAAM,CAAC,CAAC,CAAA;AAA3E,QAAA,aAAa,iBAA8D;AAEjF,MAAM,aA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AACxD,CAAC,CAAA;AAHY,QAAA,OAAO,WAGnB;AAEM,MAAM,OAAO,GAAG,CAAC,MAAc,EAAU,EAAE,WAAC,OAAA,MAAA,MAAM,CAAC,IAAI,mCAAI,4BAAmB,CAAA,EAAA,CAAA;AAAxE,QAAA,OAAO,WAAiE;AAE9E,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAW,EAAE,CAAC,IAAA,eAAO,EAAC,MAAM,CAAC,KAAK,mCAAsB,CAAA;AAA1F,QAAA,gBAAgB,oBAA0E","sourcesContent":["import { Dictionary, TraverseMethod } from '../../common'\nimport { SystemError } from '../../error'\nimport { Node, NodePointer, Nodes, NodesMap } from '../../node'\nimport { NodeValues } from '../../node/nodeValues'\nimport { NodeDef, NodeDefCode, NodeDefCodeProps, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { defaultCycle, Surveys } from '../../survey'\nimport { Survey, SurveyDependencyType } from '../../survey/survey'\nimport { Arrays, Queue } from '../../utils'\nimport { Record, RECORD_STEP_DEFAULT } from '../record'\nimport { RecordStepAnalysisCode } from '../recordStep'\nimport { RecordNodesIndexReader } from './recordNodesIndexReader'\nimport { NodeDefSelfReferences } from './nodeDefSelfReferences'\n\nexport const getCycle = (record: Record): string => record.cycle ?? defaultCycle\n\nexport const getNodes = (record: Record): Dictionary<Node> => record.nodes ?? {}\n\nexport const getNodesArray = (record: Record): Node[] => Object.values(getNodes(record))\n\nexport const getNodeByUuid =\n (uuid: string) =>\n (record: Record): Node | undefined =>\n record.nodes?.[uuid]\n\nexport const getNodesByUuids =\n (uuids: string[]) =>\n (record: Record): Node[] =>\n uuids.map((uuid: string) => getNodeByUuid(uuid)(record)) as Node[]\n\nexport const getRoot = (record: Record): Node | undefined => {\n const rootUuid = record._nodesIndex ? RecordNodesIndexReader.getNodeRootUuid(record._nodesIndex) : null\n if (rootUuid) {\n return getNodeByUuid(rootUuid)(record)\n }\n return getNodesArray(record).find((node) => !node.parentUuid)\n}\n\nexport const getChildren =\n (parentNode: Node, childDefUuid?: string) =>\n (record: Record): Node[] => {\n if (record._nodesIndex) {\n const childrenUuids = childDefUuid\n ? RecordNodesIndexReader.getNodeUuidsByParentAndChildDef({\n parentNodeUuid: parentNode.uuid,\n childDefUuid,\n })(record._nodesIndex)\n : RecordNodesIndexReader.getNodeUuidsByParent(parentNode.uuid)(record._nodesIndex)\n return getNodesByUuids(childrenUuids)(record)\n }\n return getNodesArray(record).filter(\n (node) => node.parentUuid === parentNode.uuid && (!childDefUuid || node.nodeDefUuid == childDefUuid)\n )\n }\n\nexport const getChild =\n (parentNode: Node, childDefUuid: string) =>\n (record: Record): Node => {\n const children = getChildren(parentNode, childDefUuid)(record)\n const errorParams = { childDefUuid, parentNodeUuid: parentNode.uuid, recordUuid: record.uuid }\n if (children.length === 1) {\n return children[0]\n }\n if (children.length > 1) {\n throw new SystemError('systemError.record.multipleNodesFound', errorParams)\n }\n throw new SystemError('systemError.record.childNotFound', errorParams)\n }\n\nexport const getParent =\n (node: Node) =>\n (record: Record): Node | undefined =>\n node.parentUuid ? getNodeByUuid(node.parentUuid)(record) : undefined\n\nexport const getNodesByDefUuid =\n (nodeDefUuid: string) =>\n (record: Record): Node[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeUuidsByDef(nodeDefUuid)(record._nodesIndex)\n return getNodesByUuids(nodeUuids)(record)\n }\n return getNodesArray(record).filter((node) => node.nodeDefUuid === nodeDefUuid)\n }\n\nconst isNodeFlagTrue =\n (isChildFlagTrue: (parent: Node, nodeDefUuid: string) => boolean) =>\n (params: { record: Record; node: Node }): boolean => {\n const { record, node } = params\n const ancestorsAndSelf = getAncestorsAndSelf({ record, node })\n for (let i = 0; i < ancestorsAndSelf.length - 1; i++) {\n const child = ancestorsAndSelf[i]\n const parent = ancestorsAndSelf[i + 1]\n if (!isChildFlagTrue(parent, child.nodeDefUuid)) return false\n }\n return true\n }\n\nexport const isNodeApplicable = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildApplicable(parent, nodeDefUuid))\nexport const isNodeEditable = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildEditable(parent, nodeDefUuid))\nexport const isNodeVisible = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildVisible(parent, nodeDefUuid))\n\nexport const getDependentCodeAttributes =\n (node: Node) =>\n (record: Record): Node[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeCodeDependentUuids(node.uuid)(record._nodesIndex)\n return getNodesByUuids(nodeUuids)(record)\n }\n throw new SystemError('record.nodesIndexNotInitialized')\n }\n\nexport const getParentCodeAttribute =\n (params: { parentNode: Node; nodeDef: NodeDefCode }) =>\n (record: Record): Node | undefined => {\n const { parentNode, nodeDef } = params\n\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(nodeDef)\n if (!parentCodeDefUuid) return undefined\n\n const ancestors = getAncestorsAndSelf({ record, node: parentNode })\n for (const ancestor of ancestors) {\n const children = getChildren(ancestor, parentCodeDefUuid)(record)\n if (children.length === 1) {\n return children[0]\n }\n }\n return undefined\n }\n\n// ancestors\nexport const visitAncestorsAndSelf =\n (node: Node, visitor: (node: Node) => void, stopIfFn?: () => boolean) =>\n (record: Record): void => {\n let currentNode: Node | undefined = node\n while (currentNode) {\n visitor(currentNode)\n if (stopIfFn?.()) break\n currentNode = getParent(currentNode)(record)\n }\n }\n\nexport const findAncestor =\n (node: Node, predicate: (node: Node) => boolean) =>\n (record: Record): Node | undefined => {\n let result: Node | undefined = undefined\n visitAncestorsAndSelf(\n node,\n (visitedNode) => {\n if (predicate(visitedNode)) {\n result = visitedNode\n }\n },\n () => !!result\n )(record)\n return result\n }\n\nexport const getAncestor = (params: { record: Record; node: Node; ancestorDefUuid: string }): Node | undefined => {\n const { record, node, ancestorDefUuid } = params\n if (node.nodeDefUuid === ancestorDefUuid) return node\n\n let ancestor = getParent(node)(record)\n while (ancestor && ancestor.nodeDefUuid !== ancestorDefUuid) {\n ancestor = getParent(ancestor)(record)\n }\n return ancestor\n}\n\n/**\n * Returns the list of ancestors from the given node to the root entity\n */\nexport const getAncestorsAndSelf = (params: { record: Record; node: Node }): Array<Node> => {\n const { record, node } = params\n const ancestors: Array<Node> = []\n visitAncestorsAndSelf(node, (currentNode) => {\n ancestors.push(currentNode)\n })(record)\n return ancestors\n}\n\n// descendants\n\nexport const getDescendantsOrSelf = (params: {\n record: Record\n node: Node\n nodeDefDescendant: NodeDef<any>\n}): Node[] => {\n const { record, node, nodeDefDescendant } = params\n\n if (nodeDefDescendant.uuid === node.nodeDefUuid) return [node]\n\n const nodeDefDescendantFullHierarchy = [...nodeDefDescendant.meta.h, nodeDefDescendant.uuid]\n\n // 1. get the descendant node defs uuids starting from node nodeDefUuid (not inclusive) down to the specified nodeDefDescendant uuid\n const descendantNodeDefUuids = nodeDefDescendantFullHierarchy.slice(\n nodeDefDescendantFullHierarchy.indexOf(node.nodeDefUuid) + 1\n )\n // 2. for every level in the hierarchy, find the children having the nodeDefUuid equal to the current one\n let currentAncestors = [node]\n let currentDescendants: Node[] = []\n for (const currentDescendantDefUuid of descendantNodeDefUuids) {\n for (const currentAncestor of currentAncestors) {\n currentDescendants.push(...getChildren(currentAncestor, currentDescendantDefUuid)(record))\n }\n currentAncestors = currentDescendants\n currentDescendants = []\n }\n return currentAncestors // currentAncestors is equal to the currentDescendants of the last level\n}\n\nexport const getDescendant = (params: { record: Record; node: Node; nodeDefDescendant: NodeDef<any> }): Node => {\n const { record, node, nodeDefDescendant } = params\n\n return getDescendantsOrSelf({ record, node, nodeDefDescendant })[0]\n}\n\nexport const isDescendantOf = (params: { node: Node; ancestor: Node }): boolean => {\n const { node, ancestor } = params\n return Nodes.getHierarchy(node).includes(ancestor.uuid)\n}\n\nexport const visitDescendantsAndSelf = (params: {\n record: Record\n node: Node\n visitor: (node: Node) => boolean | void\n traverseMethod?: TraverseMethod\n}): void => {\n const { record, node, visitor, traverseMethod = TraverseMethod.bfs } = params\n\n if (traverseMethod === TraverseMethod.bfs) {\n const queue = new Queue()\n\n queue.enqueue(node)\n\n while (!queue.isEmpty()) {\n const visitedNode = queue.dequeue()\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren(visitedNode)(record)\n queue.enqueueItems(children)\n }\n } else {\n const stack = []\n\n stack.push(node)\n\n while (stack.length > 0) {\n const visitedNode = stack.pop() as Node\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren(visitedNode)(record)\n\n // add children to stack in reverse order\n for (let index = children.length - 1; index >= 0; index--) {\n const child = children[index]\n stack.push(child)\n }\n }\n }\n}\n\nexport const findDescendantOrSelf =\n (node: Node, predicate: (node: Node) => boolean) =>\n (record: Record): Node | undefined => {\n let found = undefined\n\n visitDescendantsAndSelf({\n record,\n node,\n visitor: (currentNode) => {\n if (predicate(currentNode)) {\n found = currentNode\n return true\n }\n return false\n },\n })\n return found\n }\n\nconst getClosestAncestorNode = (params: {\n record: Record\n node: Node\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n dependentDef: NodeDef<NodeDefType, NodeDefProps>\n dependencyType: SurveyDependencyType\n}): Node | undefined => {\n const { record, node, nodeDef, dependentDef, dependencyType } = params\n\n // 1a if dependent def is the same as node def, potentially all nodes with\n // nodeDefUuid === dependentDef.uuid in record could be dependent of nodeDef;\n // consider the root node as the closest ancestor node,\n // unless the node def references itself only among the children of its parent entity (e.g. validation \"dbh > 0\")\n if (nodeDef.uuid === dependentDef.uuid) {\n return NodeDefSelfReferences.isSelfReferenceLocal({ nodeDef, dependencyType })\n ? getParent(node)(record)\n : getRoot(record)\n }\n // 1 find common ancestor def\n const commonAncestorDefUuid = Arrays.last(Arrays.intersection(nodeDef.meta.h, dependentDef.meta.h))\n if (!commonAncestorDefUuid) return undefined\n\n // 2 get ancestor node with common parent def\n return getAncestor({ record, node, ancestorDefUuid: commonAncestorDefUuid })\n}\n\ntype EntityKeyNodesGetterParams = {\n survey: Survey\n cycle?: string\n record: Record\n entity: Node\n keyDefs?: NodeDef<NodeDefType, NodeDefProps>[]\n}\n\nexport const getEntityKeyNodesByDefUuid = (params: EntityKeyNodesGetterParams): NodesMap => {\n const { survey, cycle, record, entity, keyDefs } = params\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const nodeDefKeys = keyDefs ?? Surveys.getNodeDefKeys({ survey, cycle, nodeDef })\n return nodeDefKeys.reduce((acc: NodesMap, nodeDefKey) => {\n const nodeKey = getDescendant({ record, node: entity, nodeDefDescendant: nodeDefKey })\n acc[nodeDefKey.uuid] = nodeKey\n return acc\n }, {})\n}\n\nexport const getEntityKeyNodes = (params: EntityKeyNodesGetterParams): Node[] =>\n Object.values(getEntityKeyNodesByDefUuid(params))\n\nexport const getEntityKeyValuesByDefUuid = (params: EntityKeyNodesGetterParams): Dictionary<any> => {\n const keyNodesByDefUuid = getEntityKeyNodesByDefUuid(params)\n return Object.entries(keyNodesByDefUuid).reduce((acc: Dictionary<any>, [uuid, keyNode]) => {\n acc[uuid] = keyNode?.value\n return acc\n }, {})\n}\n\nexport const getEntityKeyValues = (params: EntityKeyNodesGetterParams): any[] =>\n Object.values(getEntityKeyValuesByDefUuid(params))\n\nexport const getEntitySiblings = (params: { record: Record; entity: Node; includeSelf?: boolean }) => {\n const { record, entity, includeSelf = false } = params\n const parentEntity = getParent(entity)(record)\n if (!parentEntity) return []\n const siblingEntities = getChildren(parentEntity, entity.nodeDefUuid)(record)\n return includeSelf ? siblingEntities : siblingEntities.filter((sibling) => !Nodes.areEqual(sibling, entity))\n}\n\nexport const getAttributeSiblings = (params: {\n record: Record\n node: Node\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}) => {\n const { record, node, nodeDef } = params\n const parentEntity = getParent(node)(record)\n if (!parentEntity) return []\n const siblingParentEntities = getEntitySiblings({ record, entity: parentEntity })\n return siblingParentEntities.reduce((siblingsAcc: Node[], siblingEntity) => {\n siblingsAcc.push(...getChildren(siblingEntity, nodeDef.uuid)(record))\n return siblingsAcc\n }, [])\n}\n\nexport const getNodeIndex = (params: { record: Record; node: Node }) => {\n const { record, node } = params\n const parentEntity = getParent(node)(record)\n if (!parentEntity) return 0 // root entity\n const siblings = getChildren(parentEntity, node.nodeDefUuid)(record)\n return siblings.indexOf(node)\n}\n\nexport const findEntityByKeyValues = (params: {\n survey: Survey\n cycle: string\n record: Record\n parentEntity: Node\n entityDefUuid: string\n keyValuesByDefUuid: Dictionary<any>\n}): Node | undefined => {\n const { survey, cycle, record, parentEntity, entityDefUuid, keyValuesByDefUuid } = params\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entityDefUuid })\n const siblingEntities = getChildren(parentEntity, entityDefUuid)(record)\n if (NodeDefs.isSingle(entityDef)) {\n return siblingEntities[0]\n }\n const keyDefs = Surveys.getNodeDefKeys({ survey, cycle, nodeDef: entityDef })\n\n return siblingEntities.find((siblingEntity) => {\n const siblingEntityKeyValuesByDefUuid = getEntityKeyValuesByDefUuid({\n survey,\n record,\n entity: siblingEntity,\n keyDefs,\n })\n return keyDefs.every((keyDef) => {\n const keyValue = siblingEntityKeyValuesByDefUuid[keyDef.uuid]\n const keyValueSearch = keyValuesByDefUuid[keyDef.uuid]\n return NodeValues.isValueEqual({\n survey,\n nodeDef: keyDef,\n value: keyValue,\n valueSearch: keyValueSearch,\n })\n })\n })\n}\n\nexport const findEntityWithSameKeysInAnotherRecord = (params: {\n survey: Survey\n cycle: string\n entityUuid: string\n record: Record\n recordOther: Record\n}): Node | undefined => {\n const { survey, cycle, entityUuid, record, recordOther } = params\n const entity = getNodeByUuid(entityUuid)(record)\n if (!entity) return undefined\n\n let otherRecordCurrentParentEntity = getRoot(recordOther)\n if (!otherRecordCurrentParentEntity) return undefined\n\n const entityAncestorsAndSelf = getAncestorsAndSelf({\n record,\n node: entity,\n })\n const ancestorDefUuidsAndKeys = entityAncestorsAndSelf.map((ancestor) => ({\n entityDefUuid: ancestor.nodeDefUuid,\n keyValuesByDefUuid: getEntityKeyValuesByDefUuid({\n survey,\n record,\n entity: ancestor,\n }),\n }))\n\n const ancestorDefUuidsAndKeysToVisit = [...ancestorDefUuidsAndKeys].reverse()\n\n for (let index = 1; otherRecordCurrentParentEntity && index < ancestorDefUuidsAndKeysToVisit.length; index++) {\n const { entityDefUuid, keyValuesByDefUuid } = ancestorDefUuidsAndKeysToVisit[index]\n otherRecordCurrentParentEntity = findEntityByKeyValues({\n survey,\n cycle,\n record: recordOther,\n parentEntity: otherRecordCurrentParentEntity,\n entityDefUuid,\n keyValuesByDefUuid,\n })\n }\n return otherRecordCurrentParentEntity\n}\n\nexport const getDependentNodePointers = (params: {\n survey: Survey\n record: Record\n node: Node\n dependencyType: SurveyDependencyType\n includeSelf?: boolean\n filterFn?: (nodePointer: NodePointer) => boolean\n}) => {\n const { survey, record, node, dependencyType, includeSelf = false, filterFn = null } = params\n const nodeDefUuid = node.nodeDefUuid\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: nodeDefUuid })\n const dependentDefs = Surveys.getNodeDefDependents({ survey, nodeDefUuid, dependencyType })\n const nodePointers: Array<NodePointer> = []\n\n const addToNodePointers = (nodePointer: NodePointer): void => {\n if (filterFn === null || filterFn(nodePointer)) {\n nodePointers.push(nodePointer)\n }\n }\n\n for (const dependentDef of dependentDefs) {\n // 1 find common ancestor node\n const commonAncestorNode = getClosestAncestorNode({ record, node, nodeDef, dependentDef, dependencyType })\n if (!commonAncestorNode) continue\n\n const nodeDefDependentParent = Surveys.getNodeDefParent({ survey, nodeDef: dependentDef })\n if (!nodeDefDependentParent) throw new SystemError('record.nodes.dependents.dependencyOnRootFound')\n\n // 2 find descendant nodes of common parent node with nodeDefUuid = dependentDef uuid\n const dependentContextNodes = getDescendantsOrSelf({\n record,\n node: commonAncestorNode,\n nodeDefDescendant: nodeDefDependentParent,\n })\n\n for (const dependentContextNode of dependentContextNodes) {\n addToNodePointers({\n nodeCtx: dependentContextNode,\n nodeDef: dependentDef,\n })\n }\n }\n if (includeSelf) {\n const parentNode = getParent(node)(record)\n if (parentNode) {\n addToNodePointers({\n nodeCtx: parentNode,\n nodeDef,\n })\n }\n }\n\n return nodePointers\n}\n\nexport const getAncestorCodePath = (params: {\n survey: Survey\n record: Record\n parentNode: Node\n nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>\n}): string[] => {\n const { record, parentNode, nodeDef, survey } = params\n\n const getCodeAttributeItemCode = (codeAttribute: Node | undefined): string => {\n const codeItemUuid = codeAttribute ? NodeValues.getItemUuid(codeAttribute) : undefined\n if (!codeItemUuid) return ''\n const item = Surveys.getCategoryItemByUuid({ survey, itemUuid: codeItemUuid })\n return item?.props.code ?? ''\n }\n\n const codePaths = []\n let currentParentCodeAttribute = getParentCodeAttribute({ parentNode, nodeDef })(record)\n\n while (currentParentCodeAttribute) {\n const ancestorItemCode = getCodeAttributeItemCode(currentParentCodeAttribute)\n codePaths.unshift(ancestorItemCode)\n const ancestorCodeDef = Surveys.getNodeDefByUuid({\n survey,\n uuid: currentParentCodeAttribute.nodeDefUuid,\n }) as NodeDefCode\n currentParentCodeAttribute = getParentCodeAttribute({ parentNode, nodeDef: ancestorCodeDef })(record)\n }\n return codePaths\n}\n\nexport const getCategoryItemUuid = (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>\n record: Record\n parentNode: Node\n code: string\n}): string | undefined => {\n const { survey, nodeDef, record, parentNode, code } = params\n const categoryUuid = nodeDef.props.categoryUuid\n\n const codePaths = [...getAncestorCodePath({ survey, record, parentNode, nodeDef }), code]\n\n const item = Surveys.getCategoryItemByCodePaths({ survey, categoryUuid, codePaths })\n\n return item?.uuid\n}\n\nexport const isNodeFilledByUser =\n (node: Node) =>\n (record: Record): boolean =>\n !!findDescendantOrSelf(node, (visitedNode) => Nodes.hasUserInputValue(visitedNode))(record)\n\nexport const isNodeEmpty =\n (node: Node) =>\n (record: Record): boolean =>\n !isNodeFilledByUser(node)(record)\n\nexport const isEmpty = (record: Record): boolean => {\n const rootNode = getRoot(record)\n return rootNode ? isNodeEmpty(rootNode)(record) : true\n}\n\nexport const getStep = (record: Record): string => record.step ?? RECORD_STEP_DEFAULT\n\nexport const isInAnalysisStep = (record: Record): boolean => getStep(record) === RecordStepAnalysisCode\n"]}
|
|
1
|
+
{"version":3,"file":"recordGetters.js","sourceRoot":"","sources":["../../../src/record/_records/recordGetters.ts"],"names":[],"mappings":";;;AAAA,yCAAyD;AACzD,uCAAyC;AACzC,qCAA+D;AAC/D,sDAAkD;AAClD,2CAA2G;AAC3G,yCAAoD;AAEpD,uCAA2C;AAC3C,sCAAuD;AACvD,8CAAsD;AACtD,qEAAiE;AACjE,mEAA+D;AAExD,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAU,EAAE,wBAAC,MAAM,CAAC,KAAK,mCAAI,qBAAY,GAAA,CAAA;AAAnE,QAAA,QAAQ,GAAR,QAAQ,CAA2D;AAEzE,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAoB,EAAE,wBAAC,MAAM,CAAC,KAAK,mCAAI,EAAE,GAAA,CAAA;AAAnE,QAAA,QAAQ,GAAR,QAAQ,CAA2D;AAEzE,MAAM,aAAa,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAA,QAAA,QAAQ,EAAC,MAAM,CAAC,CAAC,CAAA;AAA3E,QAAA,aAAa,GAAb,aAAa,CAA8D;AAEjF,MAAM,aAAa,GACxB,CAAC,IAAY,EAAE,EAAE,CACjB,CAAC,MAAc,EAAoB,EAAE,kBACnC,MAAA,MAAM,CAAC,KAAK,0CAAG,IAAI,CAAC,GAAA,CAAA;AAHX,QAAA,aAAa,GAAb,aAAa,CAGF;AAEjB,MAAM,eAAe,GAC1B,CAAC,KAAe,EAAE,EAAE,CACpB,CAAC,MAAc,EAAU,EAAE,CACzB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,IAAA,QAAA,aAAa,EAAC,IAAI,CAAC,CAAC,MAAM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AA,QAAA,kBAAkB,EAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAA;AAHxB,QAAA,WAAW,GAAX,WAAW,CAGa;AAE9B,MAAM,OAAO,GAAG,CAAC,MAAc,EAAW,EAAE;IACjD,MAAM,QAAQ,GAAG,IAAA,QAAA,OAAO,EAAC,MAAM,CAAC,CAAA;IAChC,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAA,QAAA,WAAW,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACxD,CAAC,CAAA;AAHY,QAAA,OAAO,GAAP,OAAO,CAGnB;AAEM,MAAM,OAAO,GAAG,CAAC,MAAc,EAAU,EAAE,wBAAC,MAAM,CAAC,IAAI,mCAAI,4BAAmB,GAAA,CAAA;AAAxE,QAAA,OAAO,GAAP,OAAO,CAAiE;AAE9E,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAW,EAAE,CAAC,IAAA,QAAA,OAAO,EAAC,MAAM,CAAC,KAAK,mCAAsB,CAAA;AAA1F,QAAA,gBAAgB,GAAhB,gBAAgB,CAA0E","sourcesContent":["import { Dictionary, TraverseMethod } from '../../common'\nimport { SystemError } from '../../error'\nimport { Node, NodePointer, Nodes, NodesMap } from '../../node'\nimport { NodeValues } from '../../node/nodeValues'\nimport { NodeDef, NodeDefCode, NodeDefCodeProps, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { defaultCycle, Surveys } from '../../survey'\nimport { Survey, SurveyDependencyType } from '../../survey/survey'\nimport { Arrays, Queue } from '../../utils'\nimport { Record, RECORD_STEP_DEFAULT } from '../record'\nimport { RecordStepAnalysisCode } from '../recordStep'\nimport { RecordNodesIndexReader } from './recordNodesIndexReader'\nimport { NodeDefSelfReferences } from './nodeDefSelfReferences'\n\nexport const getCycle = (record: Record): string => record.cycle ?? defaultCycle\n\nexport const getNodes = (record: Record): Dictionary<Node> => record.nodes ?? {}\n\nexport const getNodesArray = (record: Record): Node[] => Object.values(getNodes(record))\n\nexport const getNodeByUuid =\n (uuid: string) =>\n (record: Record): Node | undefined =>\n record.nodes?.[uuid]\n\nexport const getNodesByUuids =\n (uuids: string[]) =>\n (record: Record): Node[] =>\n uuids.map((uuid: string) => getNodeByUuid(uuid)(record)) as Node[]\n\nexport const getRoot = (record: Record): Node | undefined => {\n const rootUuid = record._nodesIndex ? RecordNodesIndexReader.getNodeRootUuid(record._nodesIndex) : null\n if (rootUuid) {\n return getNodeByUuid(rootUuid)(record)\n }\n return getNodesArray(record).find((node) => !node.parentUuid)\n}\n\nexport const getChildren =\n (parentNode: Node, childDefUuid?: string) =>\n (record: Record): Node[] => {\n if (record._nodesIndex) {\n const childrenUuids = childDefUuid\n ? RecordNodesIndexReader.getNodeUuidsByParentAndChildDef({\n parentNodeUuid: parentNode.uuid,\n childDefUuid,\n })(record._nodesIndex)\n : RecordNodesIndexReader.getNodeUuidsByParent(parentNode.uuid)(record._nodesIndex)\n return getNodesByUuids(childrenUuids)(record)\n }\n return getNodesArray(record).filter(\n (node) => node.parentUuid === parentNode.uuid && (!childDefUuid || node.nodeDefUuid == childDefUuid)\n )\n }\n\nexport const getChild =\n (parentNode: Node, childDefUuid: string) =>\n (record: Record): Node => {\n const children = getChildren(parentNode, childDefUuid)(record)\n const errorParams = { childDefUuid, parentNodeUuid: parentNode.uuid, recordUuid: record.uuid }\n if (children.length === 1) {\n return children[0]\n }\n if (children.length > 1) {\n throw new SystemError('systemError.record.multipleNodesFound', errorParams)\n }\n throw new SystemError('systemError.record.childNotFound', errorParams)\n }\n\nexport const getParent =\n (node: Node) =>\n (record: Record): Node | undefined =>\n node.parentUuid ? getNodeByUuid(node.parentUuid)(record) : undefined\n\nexport const getNodesByDefUuid =\n (nodeDefUuid: string) =>\n (record: Record): Node[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeUuidsByDef(nodeDefUuid)(record._nodesIndex)\n return getNodesByUuids(nodeUuids)(record)\n }\n return getNodesArray(record).filter((node) => node.nodeDefUuid === nodeDefUuid)\n }\n\nconst isNodeFlagTrue =\n (isChildFlagTrue: (parent: Node, nodeDefUuid: string) => boolean) =>\n (params: { record: Record; node: Node }): boolean => {\n const { record, node } = params\n const ancestorsAndSelf = getAncestorsAndSelf({ record, node })\n for (let i = 0; i < ancestorsAndSelf.length - 1; i++) {\n const child = ancestorsAndSelf[i]\n const parent = ancestorsAndSelf[i + 1]\n if (!isChildFlagTrue(parent, child.nodeDefUuid)) return false\n }\n return true\n }\n\nexport const isNodeApplicable = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildApplicable(parent, nodeDefUuid))\nexport const isNodeEditable = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildEditable(parent, nodeDefUuid))\nexport const isNodeVisible = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildVisible(parent, nodeDefUuid))\n\nexport const getDependentCodeAttributes =\n (node: Node) =>\n (record: Record): Node[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeCodeDependentUuids(node.uuid)(record._nodesIndex)\n return getNodesByUuids(nodeUuids)(record)\n }\n throw new SystemError('record.nodesIndexNotInitialized')\n }\n\nexport const getParentCodeAttribute =\n (params: { parentNode: Node; nodeDef: NodeDefCode }) =>\n (record: Record): Node | undefined => {\n const { parentNode, nodeDef } = params\n\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(nodeDef)\n if (!parentCodeDefUuid) return undefined\n\n const ancestors = getAncestorsAndSelf({ record, node: parentNode })\n for (const ancestor of ancestors) {\n const children = getChildren(ancestor, parentCodeDefUuid)(record)\n if (children.length === 1) {\n return children[0]\n }\n }\n return undefined\n }\n\n// ancestors\nexport const visitAncestorsAndSelf =\n (node: Node, visitor: (node: Node) => void, stopIfFn?: () => boolean) =>\n (record: Record): void => {\n let currentNode: Node | undefined = node\n while (currentNode) {\n visitor(currentNode)\n if (stopIfFn?.()) break\n currentNode = getParent(currentNode)(record)\n }\n }\n\nexport const findAncestor =\n (node: Node, predicate: (node: Node) => boolean) =>\n (record: Record): Node | undefined => {\n let result: Node | undefined = undefined\n visitAncestorsAndSelf(\n node,\n (visitedNode) => {\n if (predicate(visitedNode)) {\n result = visitedNode\n }\n },\n () => !!result\n )(record)\n return result\n }\n\nexport const getAncestor = (params: { record: Record; node: Node; ancestorDefUuid: string }): Node | undefined => {\n const { record, node, ancestorDefUuid } = params\n if (node.nodeDefUuid === ancestorDefUuid) return node\n\n let ancestor = getParent(node)(record)\n while (ancestor && ancestor.nodeDefUuid !== ancestorDefUuid) {\n ancestor = getParent(ancestor)(record)\n }\n return ancestor\n}\n\n/**\n * Returns the list of ancestors from the given node to the root entity\n */\nexport const getAncestorsAndSelf = (params: { record: Record; node: Node }): Array<Node> => {\n const { record, node } = params\n const ancestors: Array<Node> = []\n visitAncestorsAndSelf(node, (currentNode) => {\n ancestors.push(currentNode)\n })(record)\n return ancestors\n}\n\n// descendants\n\nexport const getDescendantsOrSelf = (params: {\n record: Record\n node: Node\n nodeDefDescendant: NodeDef<any>\n}): Node[] => {\n const { record, node, nodeDefDescendant } = params\n\n if (nodeDefDescendant.uuid === node.nodeDefUuid) return [node]\n\n const nodeDefDescendantFullHierarchy = [...nodeDefDescendant.meta.h, nodeDefDescendant.uuid]\n\n // 1. get the descendant node defs uuids starting from node nodeDefUuid (not inclusive) down to the specified nodeDefDescendant uuid\n const descendantNodeDefUuids = nodeDefDescendantFullHierarchy.slice(\n nodeDefDescendantFullHierarchy.indexOf(node.nodeDefUuid) + 1\n )\n // 2. for every level in the hierarchy, find the children having the nodeDefUuid equal to the current one\n let currentAncestors = [node]\n let currentDescendants: Node[] = []\n for (const currentDescendantDefUuid of descendantNodeDefUuids) {\n for (const currentAncestor of currentAncestors) {\n currentDescendants.push(...getChildren(currentAncestor, currentDescendantDefUuid)(record))\n }\n currentAncestors = currentDescendants\n currentDescendants = []\n }\n return currentAncestors // currentAncestors is equal to the currentDescendants of the last level\n}\n\nexport const getDescendant = (params: { record: Record; node: Node; nodeDefDescendant: NodeDef<any> }): Node => {\n const { record, node, nodeDefDescendant } = params\n\n return getDescendantsOrSelf({ record, node, nodeDefDescendant })[0]\n}\n\nexport const isDescendantOf = (params: { node: Node; ancestor: Node }): boolean => {\n const { node, ancestor } = params\n return Nodes.getHierarchy(node).includes(ancestor.uuid)\n}\n\nexport const visitDescendantsAndSelf = (params: {\n record: Record\n node: Node\n visitor: (node: Node) => boolean | void\n traverseMethod?: TraverseMethod\n}): void => {\n const { record, node, visitor, traverseMethod = TraverseMethod.bfs } = params\n\n if (traverseMethod === TraverseMethod.bfs) {\n const queue = new Queue()\n\n queue.enqueue(node)\n\n while (!queue.isEmpty()) {\n const visitedNode = queue.dequeue()\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren(visitedNode)(record)\n queue.enqueueItems(children)\n }\n } else {\n const stack = []\n\n stack.push(node)\n\n while (stack.length > 0) {\n const visitedNode = stack.pop() as Node\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren(visitedNode)(record)\n\n // add children to stack in reverse order\n for (let index = children.length - 1; index >= 0; index--) {\n const child = children[index]\n stack.push(child)\n }\n }\n }\n}\n\nexport const findDescendantOrSelf =\n (node: Node, predicate: (node: Node) => boolean) =>\n (record: Record): Node | undefined => {\n let found = undefined\n\n visitDescendantsAndSelf({\n record,\n node,\n visitor: (currentNode) => {\n if (predicate(currentNode)) {\n found = currentNode\n return true\n }\n return false\n },\n })\n return found\n }\n\nconst getClosestAncestorNode = (params: {\n record: Record\n node: Node\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n dependentDef: NodeDef<NodeDefType, NodeDefProps>\n dependencyType: SurveyDependencyType\n}): Node | undefined => {\n const { record, node, nodeDef, dependentDef, dependencyType } = params\n\n // 1a if dependent def is the same as node def, potentially all nodes with\n // nodeDefUuid === dependentDef.uuid in record could be dependent of nodeDef;\n // consider the root node as the closest ancestor node,\n // unless the node def references itself only among the children of its parent entity (e.g. validation \"dbh > 0\")\n if (nodeDef.uuid === dependentDef.uuid) {\n return NodeDefSelfReferences.isSelfReferenceLocal({ nodeDef, dependencyType })\n ? getParent(node)(record)\n : getRoot(record)\n }\n // 1 find common ancestor def\n const commonAncestorDefUuid = Arrays.last(Arrays.intersection(nodeDef.meta.h, dependentDef.meta.h))\n if (!commonAncestorDefUuid) return undefined\n\n // 2 get ancestor node with common parent def\n return getAncestor({ record, node, ancestorDefUuid: commonAncestorDefUuid })\n}\n\ntype EntityKeyNodesGetterParams = {\n survey: Survey\n cycle?: string\n record: Record\n entity: Node\n keyDefs?: NodeDef<NodeDefType, NodeDefProps>[]\n}\n\nexport const getEntityKeyNodesByDefUuid = (params: EntityKeyNodesGetterParams): NodesMap => {\n const { survey, cycle, record, entity, keyDefs } = params\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const nodeDefKeys = keyDefs ?? Surveys.getNodeDefKeys({ survey, cycle, nodeDef })\n return nodeDefKeys.reduce((acc: NodesMap, nodeDefKey) => {\n const nodeKey = getDescendant({ record, node: entity, nodeDefDescendant: nodeDefKey })\n acc[nodeDefKey.uuid] = nodeKey\n return acc\n }, {})\n}\n\nexport const getEntityKeyNodes = (params: EntityKeyNodesGetterParams): Node[] =>\n Object.values(getEntityKeyNodesByDefUuid(params))\n\nexport const getEntityKeyValuesByDefUuid = (params: EntityKeyNodesGetterParams): Dictionary<any> => {\n const keyNodesByDefUuid = getEntityKeyNodesByDefUuid(params)\n return Object.entries(keyNodesByDefUuid).reduce((acc: Dictionary<any>, [uuid, keyNode]) => {\n acc[uuid] = keyNode?.value\n return acc\n }, {})\n}\n\nexport const getEntityKeyValues = (params: EntityKeyNodesGetterParams): any[] =>\n Object.values(getEntityKeyValuesByDefUuid(params))\n\nexport const getEntitySiblings = (params: { record: Record; entity: Node; includeSelf?: boolean }) => {\n const { record, entity, includeSelf = false } = params\n const parentEntity = getParent(entity)(record)\n if (!parentEntity) return []\n const siblingEntities = getChildren(parentEntity, entity.nodeDefUuid)(record)\n return includeSelf ? siblingEntities : siblingEntities.filter((sibling) => !Nodes.areEqual(sibling, entity))\n}\n\nexport const getAttributeSiblings = (params: {\n record: Record\n node: Node\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}) => {\n const { record, node, nodeDef } = params\n const parentEntity = getParent(node)(record)\n if (!parentEntity) return []\n const siblingParentEntities = getEntitySiblings({ record, entity: parentEntity })\n return siblingParentEntities.reduce((siblingsAcc: Node[], siblingEntity) => {\n siblingsAcc.push(...getChildren(siblingEntity, nodeDef.uuid)(record))\n return siblingsAcc\n }, [])\n}\n\nexport const getNodeIndex = (params: { record: Record; node: Node }) => {\n const { record, node } = params\n const parentEntity = getParent(node)(record)\n if (!parentEntity) return 0 // root entity\n const siblings = getChildren(parentEntity, node.nodeDefUuid)(record)\n return siblings.indexOf(node)\n}\n\nexport const findEntityByKeyValues = (params: {\n survey: Survey\n cycle: string\n record: Record\n parentEntity: Node\n entityDefUuid: string\n keyValuesByDefUuid: Dictionary<any>\n}): Node | undefined => {\n const { survey, cycle, record, parentEntity, entityDefUuid, keyValuesByDefUuid } = params\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entityDefUuid })\n const siblingEntities = getChildren(parentEntity, entityDefUuid)(record)\n if (NodeDefs.isSingle(entityDef)) {\n return siblingEntities[0]\n }\n const keyDefs = Surveys.getNodeDefKeys({ survey, cycle, nodeDef: entityDef })\n\n return siblingEntities.find((siblingEntity) => {\n const siblingEntityKeyValuesByDefUuid = getEntityKeyValuesByDefUuid({\n survey,\n record,\n entity: siblingEntity,\n keyDefs,\n })\n return keyDefs.every((keyDef) => {\n const keyValue = siblingEntityKeyValuesByDefUuid[keyDef.uuid]\n const keyValueSearch = keyValuesByDefUuid[keyDef.uuid]\n return NodeValues.isValueEqual({\n survey,\n nodeDef: keyDef,\n value: keyValue,\n valueSearch: keyValueSearch,\n })\n })\n })\n}\n\nexport const findEntityWithSameKeysInAnotherRecord = (params: {\n survey: Survey\n cycle: string\n entityUuid: string\n record: Record\n recordOther: Record\n}): Node | undefined => {\n const { survey, cycle, entityUuid, record, recordOther } = params\n const entity = getNodeByUuid(entityUuid)(record)\n if (!entity) return undefined\n\n let otherRecordCurrentParentEntity = getRoot(recordOther)\n if (!otherRecordCurrentParentEntity) return undefined\n\n const entityAncestorsAndSelf = getAncestorsAndSelf({\n record,\n node: entity,\n })\n const ancestorDefUuidsAndKeys = entityAncestorsAndSelf.map((ancestor) => ({\n entityDefUuid: ancestor.nodeDefUuid,\n keyValuesByDefUuid: getEntityKeyValuesByDefUuid({\n survey,\n record,\n entity: ancestor,\n }),\n }))\n\n const ancestorDefUuidsAndKeysToVisit = [...ancestorDefUuidsAndKeys].reverse()\n\n for (let index = 1; otherRecordCurrentParentEntity && index < ancestorDefUuidsAndKeysToVisit.length; index++) {\n const { entityDefUuid, keyValuesByDefUuid } = ancestorDefUuidsAndKeysToVisit[index]\n otherRecordCurrentParentEntity = findEntityByKeyValues({\n survey,\n cycle,\n record: recordOther,\n parentEntity: otherRecordCurrentParentEntity,\n entityDefUuid,\n keyValuesByDefUuid,\n })\n }\n return otherRecordCurrentParentEntity\n}\n\nexport const getDependentNodePointers = (params: {\n survey: Survey\n record: Record\n node: Node\n dependencyType: SurveyDependencyType\n includeSelf?: boolean\n filterFn?: (nodePointer: NodePointer) => boolean\n}) => {\n const { survey, record, node, dependencyType, includeSelf = false, filterFn = null } = params\n const nodeDefUuid = node.nodeDefUuid\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: nodeDefUuid })\n const dependentDefs = Surveys.getNodeDefDependents({ survey, nodeDefUuid, dependencyType })\n const nodePointers: Array<NodePointer> = []\n\n const addToNodePointers = (nodePointer: NodePointer): void => {\n if (filterFn === null || filterFn(nodePointer)) {\n nodePointers.push(nodePointer)\n }\n }\n\n for (const dependentDef of dependentDefs) {\n // 1 find common ancestor node\n const commonAncestorNode = getClosestAncestorNode({ record, node, nodeDef, dependentDef, dependencyType })\n if (!commonAncestorNode) continue\n\n const nodeDefDependentParent = Surveys.getNodeDefParent({ survey, nodeDef: dependentDef })\n if (!nodeDefDependentParent) throw new SystemError('record.nodes.dependents.dependencyOnRootFound')\n\n // 2 find descendant nodes of common parent node with nodeDefUuid = dependentDef uuid\n const dependentContextNodes = getDescendantsOrSelf({\n record,\n node: commonAncestorNode,\n nodeDefDescendant: nodeDefDependentParent,\n })\n\n for (const dependentContextNode of dependentContextNodes) {\n addToNodePointers({\n nodeCtx: dependentContextNode,\n nodeDef: dependentDef,\n })\n }\n }\n if (includeSelf) {\n const parentNode = getParent(node)(record)\n if (parentNode) {\n addToNodePointers({\n nodeCtx: parentNode,\n nodeDef,\n })\n }\n }\n\n return nodePointers\n}\n\nexport const getAncestorCodePath = (params: {\n survey: Survey\n record: Record\n parentNode: Node\n nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>\n}): string[] => {\n const { record, parentNode, nodeDef, survey } = params\n\n const getCodeAttributeItemCode = (codeAttribute: Node | undefined): string => {\n const codeItemUuid = codeAttribute ? NodeValues.getItemUuid(codeAttribute) : undefined\n if (!codeItemUuid) return ''\n const item = Surveys.getCategoryItemByUuid({ survey, itemUuid: codeItemUuid })\n return item?.props.code ?? ''\n }\n\n const codePaths = []\n let currentParentCodeAttribute = getParentCodeAttribute({ parentNode, nodeDef })(record)\n\n while (currentParentCodeAttribute) {\n const ancestorItemCode = getCodeAttributeItemCode(currentParentCodeAttribute)\n codePaths.unshift(ancestorItemCode)\n const ancestorCodeDef = Surveys.getNodeDefByUuid({\n survey,\n uuid: currentParentCodeAttribute.nodeDefUuid,\n }) as NodeDefCode\n currentParentCodeAttribute = getParentCodeAttribute({ parentNode, nodeDef: ancestorCodeDef })(record)\n }\n return codePaths\n}\n\nexport const getCategoryItemUuid = (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>\n record: Record\n parentNode: Node\n code: string\n}): string | undefined => {\n const { survey, nodeDef, record, parentNode, code } = params\n const categoryUuid = nodeDef.props.categoryUuid\n\n const codePaths = [...getAncestorCodePath({ survey, record, parentNode, nodeDef }), code]\n\n const item = Surveys.getCategoryItemByCodePaths({ survey, categoryUuid, codePaths })\n\n return item?.uuid\n}\n\nexport const isNodeFilledByUser =\n (node: Node) =>\n (record: Record): boolean =>\n !!findDescendantOrSelf(node, (visitedNode) => Nodes.hasUserInputValue(visitedNode))(record)\n\nexport const isNodeEmpty =\n (node: Node) =>\n (record: Record): boolean =>\n !isNodeFilledByUser(node)(record)\n\nexport const isEmpty = (record: Record): boolean => {\n const rootNode = getRoot(record)\n return rootNode ? isNodeEmpty(rootNode)(record) : true\n}\n\nexport const getStep = (record: Record): string => record.step ?? RECORD_STEP_DEFAULT\n\nexport const isInAnalysisStep = (record: Record): boolean => getStep(record) === RecordStepAnalysisCode\n"]}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { RecordNodesIndex } from '../record';
|
|
2
|
+
declare const getNodeRootUuid: (index: RecordNodesIndex) => string | undefined;
|
|
3
|
+
declare const getNodeUuidsByDef: (nodeDefUuid: string) => (index: RecordNodesIndex) => string[];
|
|
4
|
+
declare const getNodeUuidsByParentAndChildDef: (params: {
|
|
5
|
+
parentNodeUuid: string;
|
|
6
|
+
childDefUuid: string;
|
|
7
|
+
}) => (index: RecordNodesIndex) => string[];
|
|
8
|
+
declare const getNodeUuidsByParent: (parentNodeUuid: string) => (index: RecordNodesIndex) => string[];
|
|
9
|
+
declare const getNodeCodeDependentUuids: (nodeUuid: string) => (index: RecordNodesIndex) => string[];
|
|
2
10
|
export declare const RecordNodesIndexReader: {
|
|
3
|
-
getNodeRootUuid:
|
|
4
|
-
getNodeUuidsByDef:
|
|
5
|
-
getNodeUuidsByParentAndChildDef:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}) => (index: RecordNodesIndex) => string[];
|
|
9
|
-
getNodeUuidsByParent: (parentNodeUuid: string) => (index: RecordNodesIndex) => string[];
|
|
10
|
-
getNodeCodeDependentUuids: (nodeUuid: string) => (index: RecordNodesIndex) => string[];
|
|
11
|
+
getNodeRootUuid: typeof getNodeRootUuid;
|
|
12
|
+
getNodeUuidsByDef: typeof getNodeUuidsByDef;
|
|
13
|
+
getNodeUuidsByParentAndChildDef: typeof getNodeUuidsByParentAndChildDef;
|
|
14
|
+
getNodeUuidsByParent: typeof getNodeUuidsByParent;
|
|
15
|
+
getNodeCodeDependentUuids: typeof getNodeCodeDependentUuids;
|
|
11
16
|
};
|
|
17
|
+
export {};
|
|
@@ -2,18 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RecordNodesIndexReader = void 0;
|
|
4
4
|
const getNodeRootUuid = (index) => index.nodeRootUuid;
|
|
5
|
-
const getNodeUuidsByDef = (nodeDefUuid) => (index) => { var _a
|
|
5
|
+
const getNodeUuidsByDef = (nodeDefUuid) => (index) => { var _a; var _b; return Object.keys((_b = (_a = index.nodesByDef) === null || _a === void 0 ? void 0 : _a[nodeDefUuid]) !== null && _b !== void 0 ? _b : {}); };
|
|
6
6
|
const getNodeUuidsByParentAndChildDef = (params) => (index) => {
|
|
7
|
-
var _a, _b
|
|
7
|
+
var _a, _b;
|
|
8
|
+
var _c;
|
|
8
9
|
const { parentNodeUuid, childDefUuid } = params;
|
|
9
10
|
return Object.keys((_c = (_b = (_a = index.nodesByParentAndChildDef) === null || _a === void 0 ? void 0 : _a[parentNodeUuid]) === null || _b === void 0 ? void 0 : _b[childDefUuid]) !== null && _c !== void 0 ? _c : {});
|
|
10
11
|
};
|
|
11
12
|
const getNodeUuidsByParent = (parentNodeUuid) => (index) => {
|
|
12
|
-
var _a
|
|
13
|
+
var _a;
|
|
14
|
+
var _b;
|
|
13
15
|
const nodesPresenceByChildDefUuid = (_b = (_a = index.nodesByParentAndChildDef) === null || _a === void 0 ? void 0 : _a[parentNodeUuid]) !== null && _b !== void 0 ? _b : {};
|
|
14
16
|
return Object.values(nodesPresenceByChildDefUuid).flatMap((nodesPresence) => Object.keys(nodesPresence));
|
|
15
17
|
};
|
|
16
|
-
const getNodeCodeDependentUuids = (nodeUuid) => (index) => { var _a
|
|
18
|
+
const getNodeCodeDependentUuids = (nodeUuid) => (index) => { var _a; var _b; return Object.keys((_b = (_a = index.nodeCodeDependents) === null || _a === void 0 ? void 0 : _a[nodeUuid]) !== null && _b !== void 0 ? _b : {}); };
|
|
17
19
|
exports.RecordNodesIndexReader = {
|
|
18
20
|
getNodeRootUuid,
|
|
19
21
|
getNodeUuidsByDef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordNodesIndexReader.js","sourceRoot":"","sources":["../../../src/record/_records/recordNodesIndexReader.ts"],"names":[],"mappings":";;;AAEA,MAAM,eAAe,GAAG,CAAC,KAAuB,EAAsB,EAAE,CAAC,KAAK,CAAC,YAAY,CAAA;AAE3F,MAAM,iBAAiB,GACrB,CAAC,WAAmB,EAAE,EAAE,CACxB,CAAC,KAAuB,EAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"recordNodesIndexReader.js","sourceRoot":"","sources":["../../../src/record/_records/recordNodesIndexReader.ts"],"names":[],"mappings":";;;AAEA,MAAM,eAAe,GAAG,CAAC,KAAuB,EAAsB,EAAE,CAAC,KAAK,CAAC,YAAY,CAAA;AAE3F,MAAM,iBAAiB,GACrB,CAAC,WAAmB,EAAE,EAAE,CACxB,CAAC,KAAuB,EAAY,EAAE,0BACpC,MAAM,CAAC,IAAI,OAAC,MAAA,KAAK,CAAC,UAAU,0CAAG,WAAW,CAAC,mCAAI,EAAE,CAAC,GAAA,CAAA;AAEtD,MAAM,+BAA+B,GACnC,CAAC,MAAwD,EAAE,EAAE,CAC7D,CAAC,KAAuB,EAAY,EAAE;;;IACpC,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,MAAM,CAAA;IAC/C,OAAO,MAAM,CAAC,IAAI,OAAC,MAAA,MAAA,KAAK,CAAC,wBAAwB,0CAAG,cAAc,CAAC,0CAAG,YAAY,CAAC,mCAAI,EAAE,CAAC,CAAA;AAC5F,CAAC,CAAA;AAEH,MAAM,oBAAoB,GACxB,CAAC,cAAsB,EAAE,EAAE,CAC3B,CAAC,KAAuB,EAAY,EAAE;;;IACpC,MAAM,2BAA2B,SAAG,MAAA,KAAK,CAAC,wBAAwB,0CAAG,cAAc,CAAC,mCAAI,EAAE,CAAA;IAC1F,OAAO,MAAM,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAA;AAC1G,CAAC,CAAA;AAEH,MAAM,yBAAyB,GAC7B,CAAC,QAAgB,EAAE,EAAE,CACrB,CAAC,KAAuB,EAAY,EAAE,0BACpC,MAAM,CAAC,IAAI,OAAC,MAAA,KAAK,CAAC,kBAAkB,0CAAG,QAAQ,CAAC,mCAAI,EAAE,CAAC,GAAA,CAAA;AAE9C,QAAA,sBAAsB,GAAG;IACpC,eAAe;IACf,iBAAiB;IACjB,+BAA+B;IAC/B,oBAAoB;IACpB,yBAAyB;CAC1B,CAAA","sourcesContent":["import { RecordNodesIndex } from '../record'\n\nconst getNodeRootUuid = (index: RecordNodesIndex): string | undefined => index.nodeRootUuid\n\nconst getNodeUuidsByDef =\n (nodeDefUuid: string) =>\n (index: RecordNodesIndex): string[] =>\n Object.keys(index.nodesByDef?.[nodeDefUuid] ?? {})\n\nconst getNodeUuidsByParentAndChildDef =\n (params: { parentNodeUuid: string; childDefUuid: string }) =>\n (index: RecordNodesIndex): string[] => {\n const { parentNodeUuid, childDefUuid } = params\n return Object.keys(index.nodesByParentAndChildDef?.[parentNodeUuid]?.[childDefUuid] ?? {})\n }\n\nconst getNodeUuidsByParent =\n (parentNodeUuid: string) =>\n (index: RecordNodesIndex): string[] => {\n const nodesPresenceByChildDefUuid = index.nodesByParentAndChildDef?.[parentNodeUuid] ?? {}\n return Object.values(nodesPresenceByChildDefUuid).flatMap((nodesPresence) => Object.keys(nodesPresence))\n }\n\nconst getNodeCodeDependentUuids =\n (nodeUuid: string) =>\n (index: RecordNodesIndex): string[] =>\n Object.keys(index.nodeCodeDependents?.[nodeUuid] ?? {})\n\nexport const RecordNodesIndexReader = {\n getNodeRootUuid,\n getNodeUuidsByDef,\n getNodeUuidsByParentAndChildDef,\n getNodeUuidsByParent,\n getNodeCodeDependentUuids,\n}\n"]}
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import { Node } from '../../node';
|
|
2
2
|
import { Record, RecordNodesIndex } from '../record';
|
|
3
|
+
declare const addNodes: (nodes: {
|
|
4
|
+
[key: string]: Node;
|
|
5
|
+
}, sideEffect?: boolean, sortNodes?: boolean) => (index: RecordNodesIndex) => RecordNodesIndex;
|
|
6
|
+
declare const addNode: (node: Node) => (index: RecordNodesIndex) => RecordNodesIndex;
|
|
7
|
+
declare const initializeIndex: (record: Record) => RecordNodesIndex;
|
|
8
|
+
declare const removeNodes: (nodes: Node[], sideEffect?: boolean) => (index: RecordNodesIndex) => RecordNodesIndex;
|
|
9
|
+
declare const removeNode: (node: Node, sideEffect?: boolean) => (index: RecordNodesIndex) => RecordNodesIndex;
|
|
10
|
+
/**
|
|
11
|
+
* Returns true if the index entries of the specified node would not change when the node replaces the previous version of it.
|
|
12
|
+
*/
|
|
13
|
+
declare const isNodeIndexUnchanged: (params: {
|
|
14
|
+
index: RecordNodesIndex;
|
|
15
|
+
node: Node;
|
|
16
|
+
nodePrev?: Node;
|
|
17
|
+
}) => boolean;
|
|
3
18
|
export declare const RecordNodesIndexUpdater: {
|
|
4
|
-
addNode:
|
|
5
|
-
addNodes:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
index: RecordNodesIndex;
|
|
11
|
-
node: Node;
|
|
12
|
-
nodePrev?: Node;
|
|
13
|
-
}) => boolean;
|
|
14
|
-
removeNode: (node: Node, sideEffect?: boolean) => (index: RecordNodesIndex) => RecordNodesIndex;
|
|
15
|
-
removeNodes: (nodes: Node[], sideEffect?: boolean) => (index: RecordNodesIndex) => RecordNodesIndex;
|
|
19
|
+
addNode: typeof addNode;
|
|
20
|
+
addNodes: typeof addNodes;
|
|
21
|
+
initializeIndex: typeof initializeIndex;
|
|
22
|
+
isNodeIndexUnchanged: typeof isNodeIndexUnchanged;
|
|
23
|
+
removeNode: typeof removeNode;
|
|
24
|
+
removeNodes: typeof removeNodes;
|
|
16
25
|
};
|
|
26
|
+
export {};
|
|
@@ -10,14 +10,15 @@ const keys = {
|
|
|
10
10
|
nodeCodeDependents: 'nodeCodeDependents',
|
|
11
11
|
};
|
|
12
12
|
const sortNodesByIdOrCreationDate = (nodeA, nodeB) => {
|
|
13
|
-
var _a, _b, _c, _d
|
|
13
|
+
var _a, _b, _c, _d;
|
|
14
|
+
var _e, _f;
|
|
14
15
|
if (!nodeA.parentUuid)
|
|
15
16
|
return -1;
|
|
16
17
|
if (!nodeB.parentUuid)
|
|
17
18
|
return 1;
|
|
18
19
|
// read the hierarchy length directly: Nodes.getHierarchy copies the array on every comparison
|
|
19
|
-
const hierarchyDepthA = (
|
|
20
|
-
const hierarchyDepthB = (_f = (
|
|
20
|
+
const hierarchyDepthA = (_e = (_b = (_a = nodeA.meta) === null || _a === void 0 ? void 0 : _a.h) === null || _b === void 0 ? void 0 : _b.length) !== null && _e !== void 0 ? _e : 0;
|
|
21
|
+
const hierarchyDepthB = (_f = (_d = (_c = nodeB.meta) === null || _c === void 0 ? void 0 : _c.h) === null || _d === void 0 ? void 0 : _d.length) !== null && _f !== void 0 ? _f : 0;
|
|
21
22
|
const depthDiff = hierarchyDepthA - hierarchyDepthB;
|
|
22
23
|
if (depthDiff !== 0)
|
|
23
24
|
return depthDiff;
|
|
@@ -84,7 +85,8 @@ class NodesIndexDraft {
|
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
addNode(node) {
|
|
87
|
-
var _a
|
|
88
|
+
var _a;
|
|
89
|
+
var _b;
|
|
88
90
|
const { uuid: nodeUuid, nodeDefUuid, parentUuid } = node;
|
|
89
91
|
if (parentUuid) {
|
|
90
92
|
// nodes by parent and child def uuid
|
|
@@ -139,9 +141,10 @@ const removeNodes = (nodes, sideEffect = false) => (index) => {
|
|
|
139
141
|
};
|
|
140
142
|
const removeNode = (node, sideEffect = false) => (index) => removeNodes([node], sideEffect)(index);
|
|
141
143
|
const _isSameHierarchyCode = (nodeA, nodeB) => {
|
|
142
|
-
var _a, _b
|
|
143
|
-
|
|
144
|
-
const
|
|
144
|
+
var _a, _b;
|
|
145
|
+
var _c, _d;
|
|
146
|
+
const hCodeA = (_c = (_a = nodeA.meta) === null || _a === void 0 ? void 0 : _a.hCode) !== null && _c !== void 0 ? _c : [];
|
|
147
|
+
const hCodeB = (_d = (_b = nodeB.meta) === null || _b === void 0 ? void 0 : _b.hCode) !== null && _d !== void 0 ? _d : [];
|
|
145
148
|
return hCodeA.length === hCodeB.length && hCodeA.every((uuid, index) => uuid === hCodeB[index]);
|
|
146
149
|
};
|
|
147
150
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordNodesIndexUpdater.js","sourceRoot":"","sources":["../../../src/record/_records/recordNodesIndexUpdater.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AACxC,uCAAqC;AAGrC,MAAM,IAAI,GAAG;IACX,YAAY,EAAE,cAAc;IAC5B,wBAAwB,EAAE,0BAA0B;IACpD,UAAU,EAAE,YAAY;IACxB,kBAAkB,EAAE,oBAAoB;CACzC,CAAA;AAED,MAAM,2BAA2B,GAAG,CAAC,KAAW,EAAE,KAAW,EAAU,EAAE;;IACvE,IAAI,CAAC,KAAK,CAAC,UAAU;QAAE,OAAO,CAAC,CAAC,CAAA;IAChC,IAAI,CAAC,KAAK,CAAC,UAAU;QAAE,OAAO,CAAC,CAAA;IAC/B,8FAA8F;IAC9F,MAAM,eAAe,GAAG,MAAA,MAAA,MAAA,KAAK,CAAC,IAAI,0CAAE,CAAC,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AC,IAAI,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;AACjG,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,oBAAoB,GAAG,CAAC,MAAgE,EAAW,EAAE;;IACzG,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;IACxC,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3B,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAC9C,IAAI,UAAU,KAAK,QAAQ,CAAC,UAAU,IAAI,WAAW,KAAK,QAAQ,CAAC,WAAW;QAAE,OAAO,KAAK,CAAA;IAC5F,IAAI,CAAC,oBAAoB,CAAC,IAAI,EAAE,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAA;IACvD,IAAI,CAAC,CAAA,MAAA,MAAA,KAAK,CAAC,UAAU,0CAAG,WAAW,CAAC,0CAAG,IAAI,CAAC,CAAA;QAAE,OAAO,KAAK,CAAA;IAC1D,OAAO,UAAU;QACf,CAAC,CAAC,CAAC,CAAC,CAAA,MAAA,MAAA,MAAA,KAAK,CAAC,wBAAwB,0CAAG,UAAU,CAAC,0CAAG,WAAW,CAAC,0CAAG,IAAI,CAAC,CAAA;QACvE,CAAC,CAAC,KAAK,CAAC,YAAY,KAAK,IAAI,CAAA;AACjC,CAAC,CAAA;AAEY,QAAA,uBAAuB,GAAG;IACrC,OAAO;IACP,QAAQ;IACR,eAAe;IACf,oBAAoB;IACpB,UAAU;IACV,WAAW;CACZ,CAAA","sourcesContent":["import { Node, Nodes } from '../../node'\nimport { Objects } from '../../utils'\nimport { Record, RecordNodesIndex } from '../record'\n\nconst keys = {\n nodeRootUuid: 'nodeRootUuid',\n nodesByParentAndChildDef: 'nodesByParentAndChildDef',\n nodesByDef: 'nodesByDef',\n nodeCodeDependents: 'nodeCodeDependents',\n}\n\nconst sortNodesByIdOrCreationDate = (nodeA: Node, nodeB: Node): number => {\n if (!nodeA.parentUuid) return -1\n if (!nodeB.parentUuid) return 1\n // read the hierarchy length directly: Nodes.getHierarchy copies the array on every comparison\n const hierarchyDepthA = nodeA.meta?.h?.length ?? 0\n const hierarchyDepthB = nodeB.meta?.h?.length ?? 0\n const depthDiff = hierarchyDepthA - hierarchyDepthB\n if (depthDiff !== 0) return depthDiff\n if (nodeA.id && nodeB.id) return nodeA.id - nodeB.id\n if (nodeA.dateCreated && nodeB.dateCreated) return nodeA.dateCreated.localeCompare(nodeB.dateCreated)\n return 0\n}\n\n/**\n * Mutable copy of a nodes index, used to apply many changes to it at once.\n * When sideEffect is false, every object along a modified path is copied only the first time it is modified\n * (copy on write): applying N changes costs one copy of each touched object instead of N copies.\n */\nclass NodesIndexDraft {\n readonly index: RecordNodesIndex\n private readonly sideEffect: boolean\n private readonly copiedObjects = new Set<object>()\n\n constructor(index: RecordNodesIndex, sideEffect: boolean) {\n this.sideEffect = sideEffect\n this.index = sideEffect ? index : this.markCopied({ ...index })\n }\n\n private markCopied<T extends object>(obj: T): T {\n this.copiedObjects.add(obj)\n return obj\n }\n\n private getWritableChild(parent: any, key: string, createIfMissing: boolean): any {\n const child = parent[key]\n if (child === undefined || child === null) {\n if (!createIfMissing) return undefined\n const childCreated = this.markCopied({})\n parent[key] = childCreated\n return childCreated\n }\n if (this.sideEffect || this.copiedObjects.has(child)) return child\n const childCopy = this.markCopied({ ...child })\n parent[key] = childCopy\n return childCopy\n }\n\n set(path: string[], value: any): void {\n let current: any = this.index\n for (let i = 0; i < path.length - 1; i++) {\n current = this.getWritableChild(current, path[i], true)\n }\n current[path.at(-1)!] = value\n }\n\n /**\n * Deletes the value at the specified path, then removes the objects along the path left empty.\n */\n delete(path: string[]): void {\n const containers: any[] = [this.index]\n let current: any = this.index\n for (let i = 0; i < path.length - 1; i++) {\n if (current[path[i]] === undefined) return\n current = this.getWritableChild(current, path[i], false)\n containers.push(current)\n }\n delete current[path.at(-1)!]\n for (let i = path.length - 2; i >= 0; i--) {\n if (!Objects.isEmpty(containers[i + 1])) break\n delete containers[i][path[i]]\n }\n }\n\n addNode(node: Node): void {\n const { uuid: nodeUuid, nodeDefUuid, parentUuid } = node\n if (parentUuid) {\n // nodes by parent and child def uuid\n this.set([keys.nodesByParentAndChildDef, parentUuid, nodeDefUuid, nodeUuid], true)\n } else {\n // root entity index\n this.index.nodeRootUuid = nodeUuid\n }\n // nodes by def uuid\n this.set([keys.nodesByDef, nodeDefUuid, nodeUuid], true)\n // code dependents\n for (const ancestorCodeAttributeUuid of node.meta?.hCode ?? []) {\n this.set([keys.nodeCodeDependents, ancestorCodeAttributeUuid, nodeUuid], true)\n }\n }\n\n removeNode(node: Node): void {\n const { uuid: nodeUuid, parentUuid, nodeDefUuid } = node\n if (parentUuid) {\n this.delete([keys.nodesByParentAndChildDef, parentUuid, nodeDefUuid, nodeUuid])\n } else {\n delete this.index.nodeRootUuid\n }\n this.delete([keys.nodesByDef, nodeDefUuid, nodeUuid])\n // code dependents\n for (const ancestorCodeAttributeUuid of Nodes.getHierarchyCode(node)) {\n this.delete([keys.nodeCodeDependents, ancestorCodeAttributeUuid, nodeUuid])\n }\n this.delete([keys.nodeCodeDependents, nodeUuid])\n }\n}\n\nconst addNodes =\n (nodes: { [key: string]: Node }, sideEffect = false, sortNodes = false) =>\n (index: RecordNodesIndex): RecordNodesIndex => {\n const draft = new NodesIndexDraft(index, sideEffect)\n const nodesArray = Object.values(nodes)\n if (sortNodes) {\n nodesArray.sort(sortNodesByIdOrCreationDate)\n }\n for (const node of nodesArray) {\n draft.addNode(node)\n }\n return draft.index\n }\n\nconst addNode =\n (node: Node) =>\n (index: RecordNodesIndex): RecordNodesIndex =>\n addNodes({ [node.uuid]: node })(index)\n\nconst initializeIndex = (record: Record): RecordNodesIndex => addNodes(record.nodes ?? {}, true, true)({})\n\nconst removeNodes =\n (nodes: Node[], sideEffect = false) =>\n (index: RecordNodesIndex): RecordNodesIndex => {\n const draft = new NodesIndexDraft(index, sideEffect)\n for (const node of nodes) {\n draft.removeNode(node)\n }\n return draft.index\n }\n\nconst removeNode =\n (node: Node, sideEffect = false) =>\n (index: RecordNodesIndex): RecordNodesIndex =>\n removeNodes([node], sideEffect)(index)\n\nconst _isSameHierarchyCode = (nodeA: Node, nodeB: Node): boolean => {\n const hCodeA = nodeA.meta?.hCode ?? []\n const hCodeB = nodeB.meta?.hCode ?? []\n return hCodeA.length === hCodeB.length && hCodeA.every((uuid, index) => uuid === hCodeB[index])\n}\n\n/**\n * Returns true if the index entries of the specified node would not change when the node replaces the previous version of it.\n */\nconst isNodeIndexUnchanged = (params: { index: RecordNodesIndex; node: Node; nodePrev?: Node }): boolean => {\n const { index, node, nodePrev } = params\n if (!nodePrev) return false\n const { uuid, parentUuid, nodeDefUuid } = node\n if (parentUuid !== nodePrev.parentUuid || nodeDefUuid !== nodePrev.nodeDefUuid) return false\n if (!_isSameHierarchyCode(node, nodePrev)) return false\n if (!index.nodesByDef?.[nodeDefUuid]?.[uuid]) return false\n return parentUuid\n ? !!index.nodesByParentAndChildDef?.[parentUuid]?.[nodeDefUuid]?.[uuid]\n : index.nodeRootUuid === uuid\n}\n\nexport const RecordNodesIndexUpdater = {\n addNode,\n addNodes,\n initializeIndex,\n isNodeIndexUnchanged,\n removeNode,\n removeNodes,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"recordNodesIndexUpdater.js","sourceRoot":"","sources":["../../../src/record/_records/recordNodesIndexUpdater.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AACxC,uCAAqC;AAGrC,MAAM,IAAI,GAAG;IACX,YAAY,EAAE,cAAc;IAC5B,wBAAwB,EAAE,0BAA0B;IACpD,UAAU,EAAE,YAAY;IACxB,kBAAkB,EAAE,oBAAoB;CACzC,CAAA;AAED,MAAM,2BAA2B,GAAG,CAAC,KAAW,EAAE,KAAW,EAAU,EAAE;;;IACvE,IAAI,CAAC,KAAK,CAAC,UAAU;QAAE,OAAO,CAAC,CAAC,CAAA;IAChC,IAAI,CAAC,KA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AAM,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;AACjG,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,oBAAoB,GAAG,CAAC,MAAgE,EAAW,EAAE;;IACzG,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;IACxC,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3B,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAC9C,IAAI,UAAU,KAAK,QAAQ,CAAC,UAAU,IAAI,WAAW,KAAK,QAAQ,CAAC,WAAW;QAAE,OAAO,KAAK,CAAA;IAC5F,IAAI,CAAC,oBAAoB,CAAC,IAAI,EAAE,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAA;IACvD,IAAI,EAAC,MAAA,MAAA,KAAK,CAAC,UAAU,0CAAG,WAAW,CAAC,0CAAG,IAAI,CAAC,CAAA;QAAE,OAAO,KAAK,CAAA;IAC1D,OAAO,UAAU;QACf,CAAC,CAAC,CAAC,EAAC,MAAA,MAAA,MAAA,KAAK,CAAC,wBAAwB,0CAAG,UAAU,CAAC,0CAAG,WAAW,CAAC,0CAAG,IAAI,CAAC,CAAA;QACvE,CAAC,CAAC,KAAK,CAAC,YAAY,KAAK,IAAI,CAAA;AACjC,CAAC,CAAA;AAEY,QAAA,uBAAuB,GAAG;IACrC,OAAO;IACP,QAAQ;IACR,eAAe;IACf,oBAAoB;IACpB,UAAU;IACV,WAAW;CACZ,CAAA","sourcesContent":["import { Node, Nodes } from '../../node'\nimport { Objects } from '../../utils'\nimport { Record, RecordNodesIndex } from '../record'\n\nconst keys = {\n nodeRootUuid: 'nodeRootUuid',\n nodesByParentAndChildDef: 'nodesByParentAndChildDef',\n nodesByDef: 'nodesByDef',\n nodeCodeDependents: 'nodeCodeDependents',\n}\n\nconst sortNodesByIdOrCreationDate = (nodeA: Node, nodeB: Node): number => {\n if (!nodeA.parentUuid) return -1\n if (!nodeB.parentUuid) return 1\n // read the hierarchy length directly: Nodes.getHierarchy copies the array on every comparison\n const hierarchyDepthA = nodeA.meta?.h?.length ?? 0\n const hierarchyDepthB = nodeB.meta?.h?.length ?? 0\n const depthDiff = hierarchyDepthA - hierarchyDepthB\n if (depthDiff !== 0) return depthDiff\n if (nodeA.id && nodeB.id) return nodeA.id - nodeB.id\n if (nodeA.dateCreated && nodeB.dateCreated) return nodeA.dateCreated.localeCompare(nodeB.dateCreated)\n return 0\n}\n\n/**\n * Mutable copy of a nodes index, used to apply many changes to it at once.\n * When sideEffect is false, every object along a modified path is copied only the first time it is modified\n * (copy on write): applying N changes costs one copy of each touched object instead of N copies.\n */\nclass NodesIndexDraft {\n readonly index: RecordNodesIndex\n private readonly sideEffect: boolean\n private readonly copiedObjects = new Set<object>()\n\n constructor(index: RecordNodesIndex, sideEffect: boolean) {\n this.sideEffect = sideEffect\n this.index = sideEffect ? index : this.markCopied({ ...index })\n }\n\n private markCopied<T extends object>(obj: T): T {\n this.copiedObjects.add(obj)\n return obj\n }\n\n private getWritableChild(parent: any, key: string, createIfMissing: boolean): any {\n const child = parent[key]\n if (child === undefined || child === null) {\n if (!createIfMissing) return undefined\n const childCreated = this.markCopied({})\n parent[key] = childCreated\n return childCreated\n }\n if (this.sideEffect || this.copiedObjects.has(child)) return child\n const childCopy = this.markCopied({ ...child })\n parent[key] = childCopy\n return childCopy\n }\n\n set(path: string[], value: any): void {\n let current: any = this.index\n for (let i = 0; i < path.length - 1; i++) {\n current = this.getWritableChild(current, path[i], true)\n }\n current[path.at(-1)!] = value\n }\n\n /**\n * Deletes the value at the specified path, then removes the objects along the path left empty.\n */\n delete(path: string[]): void {\n const containers: any[] = [this.index]\n let current: any = this.index\n for (let i = 0; i < path.length - 1; i++) {\n if (current[path[i]] === undefined) return\n current = this.getWritableChild(current, path[i], false)\n containers.push(current)\n }\n delete current[path.at(-1)!]\n for (let i = path.length - 2; i >= 0; i--) {\n if (!Objects.isEmpty(containers[i + 1])) break\n delete containers[i][path[i]]\n }\n }\n\n addNode(node: Node): void {\n const { uuid: nodeUuid, nodeDefUuid, parentUuid } = node\n if (parentUuid) {\n // nodes by parent and child def uuid\n this.set([keys.nodesByParentAndChildDef, parentUuid, nodeDefUuid, nodeUuid], true)\n } else {\n // root entity index\n this.index.nodeRootUuid = nodeUuid\n }\n // nodes by def uuid\n this.set([keys.nodesByDef, nodeDefUuid, nodeUuid], true)\n // code dependents\n for (const ancestorCodeAttributeUuid of node.meta?.hCode ?? []) {\n this.set([keys.nodeCodeDependents, ancestorCodeAttributeUuid, nodeUuid], true)\n }\n }\n\n removeNode(node: Node): void {\n const { uuid: nodeUuid, parentUuid, nodeDefUuid } = node\n if (parentUuid) {\n this.delete([keys.nodesByParentAndChildDef, parentUuid, nodeDefUuid, nodeUuid])\n } else {\n delete this.index.nodeRootUuid\n }\n this.delete([keys.nodesByDef, nodeDefUuid, nodeUuid])\n // code dependents\n for (const ancestorCodeAttributeUuid of Nodes.getHierarchyCode(node)) {\n this.delete([keys.nodeCodeDependents, ancestorCodeAttributeUuid, nodeUuid])\n }\n this.delete([keys.nodeCodeDependents, nodeUuid])\n }\n}\n\nconst addNodes =\n (nodes: { [key: string]: Node }, sideEffect = false, sortNodes = false) =>\n (index: RecordNodesIndex): RecordNodesIndex => {\n const draft = new NodesIndexDraft(index, sideEffect)\n const nodesArray = Object.values(nodes)\n if (sortNodes) {\n nodesArray.sort(sortNodesByIdOrCreationDate)\n }\n for (const node of nodesArray) {\n draft.addNode(node)\n }\n return draft.index\n }\n\nconst addNode =\n (node: Node) =>\n (index: RecordNodesIndex): RecordNodesIndex =>\n addNodes({ [node.uuid]: node })(index)\n\nconst initializeIndex = (record: Record): RecordNodesIndex => addNodes(record.nodes ?? {}, true, true)({})\n\nconst removeNodes =\n (nodes: Node[], sideEffect = false) =>\n (index: RecordNodesIndex): RecordNodesIndex => {\n const draft = new NodesIndexDraft(index, sideEffect)\n for (const node of nodes) {\n draft.removeNode(node)\n }\n return draft.index\n }\n\nconst removeNode =\n (node: Node, sideEffect = false) =>\n (index: RecordNodesIndex): RecordNodesIndex =>\n removeNodes([node], sideEffect)(index)\n\nconst _isSameHierarchyCode = (nodeA: Node, nodeB: Node): boolean => {\n const hCodeA = nodeA.meta?.hCode ?? []\n const hCodeB = nodeB.meta?.hCode ?? []\n return hCodeA.length === hCodeB.length && hCodeA.every((uuid, index) => uuid === hCodeB[index])\n}\n\n/**\n * Returns true if the index entries of the specified node would not change when the node replaces the previous version of it.\n */\nconst isNodeIndexUnchanged = (params: { index: RecordNodesIndex; node: Node; nodePrev?: Node }): boolean => {\n const { index, node, nodePrev } = params\n if (!nodePrev) return false\n const { uuid, parentUuid, nodeDefUuid } = node\n if (parentUuid !== nodePrev.parentUuid || nodeDefUuid !== nodePrev.nodeDefUuid) return false\n if (!_isSameHierarchyCode(node, nodePrev)) return false\n if (!index.nodesByDef?.[nodeDefUuid]?.[uuid]) return false\n return parentUuid\n ? !!index.nodesByParentAndChildDef?.[parentUuid]?.[nodeDefUuid]?.[uuid]\n : index.nodeRootUuid === uuid\n}\n\nexport const RecordNodesIndexUpdater = {\n addNode,\n addNodes,\n initializeIndex,\n isNodeIndexUnchanged,\n removeNode,\n removeNodes,\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordPagesValidation.js","sourceRoot":"","sources":["../../../src/record/_records/recordPagesValidation.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AACxC,2CAAuD;AACvD,yCAA8C;AAC9C,iDAA8C;AAE9C,4DAAwD;AACxD,yDAA6D;AAC7D,mDAAqF;AAmBrF;;GAEG;AACI,MAAM,iBAAiB,GAAG,CAAC,MAA+D,EAAW,EAAE;IAC5G,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,MAAM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CAAA;IAC9C,MAAM,YAAY,GAAG,IAAA,uBAAe,EAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;IACvD,MAAM,UAAU,GAAG,YAAY,CAAC,MAAM,CAAA;IACtC,IAAI,UAAU,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAEjC,IAAI,UAAU,GAAG,CAAC,CAAA;IAClB,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,eAAe,GAAG,WAAW,CAAC,IAAI,CAAA;QACxC,MAAM,mBAAmB,GAAG,IAAA,qCAA6B,EAAC,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAA;QACzF,IAAI,CAAC,IAAA,wBAAgB,EAAC,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;YACxE,UAAU,IAAI,CAAC,CAAA;QACjB,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,UAAU,GAAG,UAAU,CAAC,GAAG,GAAG,CAAC,CAAA;IAC3D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAA;AAC5C,CAAC,CAAA;AAxBY,QAAA,gCAAgC,oCAwB5C","sourcesContent":["import { Node, Nodes } from '../../node'\nimport { NodeDefEntity, NodeDefs } from '../../nodeDef'\nimport { Survey, Surveys } from '../../survey'\nimport { Validations } from '../../validation'\nimport { Record } from '../record'\nimport { RecordValidations } from '../recordValidations'\nimport { getEntityCompletionStats } from './recordCompletion'\nimport { getCycle, getNodeByUuid, getNodesByDefUuid, getRoot } from './recordGetters'\n\nexport type PageValidationStatus = {\n hasErrors: boolean\n hasWarnings: boolean\n}\n\nexport type EntitySubtreeStatus = {\n hasErrors: boolean\n hasWarnings: boolean\n isComplete: boolean\n}\n\nexport type PagesValidationProgress = {\n percent: number\n validCount: number\n totalCount: number\n}\n\n/**\n * Whether a node belongs under a page entity (itself or any descendant of that page).\n */\nexport const nodeBelongsToPage = (params: { node: Node; pageNodeDefUuid: string; record: Record }): boolean => {\n const { node, pageNodeDefUuid, record } = params\n if (node.nodeDefUuid === pageNodeDefUuid) return true\n return Nodes.getHierarchy(node).some((ancestorUuid) => {\n const ancestor = getNodeByUuid(ancestorUuid)(record)\n return ancestor?.nodeDefUuid === pageNodeDefUuid\n })\n}\n\n/**\n * Whether a node belongs to this page only — not to a nested descendant page entity.\n * When descendantPageUuids is empty, all nodes under the page hierarchy are included.\n */\nexport const nodeBelongsToOwnPage = (params: {\n node: Node\n pageNodeDefUuid: string\n descendantPageUuids: string[]\n record: Record\n}): boolean => {\n const { node, pageNodeDefUuid, descendantPageUuids, record } = params\n if (!nodeBelongsToPage({ node, pageNodeDefUuid, record })) return false\n if (descendantPageUuids.includes(node.nodeDefUuid)) return false\n return !descendantPageUuids.some((descendantUuid) =>\n nodeBelongsToPage({ node, pageNodeDefUuid: descendantUuid, record })\n )\n}\n\n/**\n * Child page-entity defs displayed in their own page under the given entity.\n */\nexport const getNodeDefChildrenInOwnPage = (params: {\n survey: Survey\n nodeDef: NodeDefEntity\n cycle: string\n}): NodeDefEntity[] => {\n const { survey, nodeDef, cycle } = params\n return Surveys.getNodeDefChildren({ survey, nodeDef, includeAnalysis: true }).filter(\n (child): child is NodeDefEntity => {\n if (!NodeDefs.isEntity(child)) return false\n return NodeDefs.isDisplayInOwnPage(cycle)(child as NodeDefEntity)\n }\n )\n}\n\n/**\n * Collects all page-entity node defs in the survey cycle (root + nested own-pages).\n */\nexport const getPageNodeDefs = (params: { survey: Survey; cycle: string }): NodeDefEntity[] => {\n const { survey, cycle } = params\n const root = Surveys.getNodeDefRoot({ survey }) as NodeDefEntity | undefined\n if (!root) return []\n\n const pages: NodeDefEntity[] = []\n const stack: NodeDefEntity[] = [root]\n while (stack.length > 0) {\n const current = stack.pop()\n if (!current) continue\n pages.push(current)\n stack.push(...getNodeDefChildrenInOwnPage({ survey, nodeDef: current, cycle }))\n }\n return pages\n}\n\n/**\n * Collects descendant page node def UUIDs under a page (not including the page itself).\n */\nexport const getDescendantPageNodeDefUuids = (params: {\n survey: Survey\n cycle: string\n pageNodeDef: NodeDefEntity\n}): string[] => {\n const { survey, cycle, pageNodeDef } = params\n const uuids: string[] = []\n const visit = (nodeDef: NodeDefEntity) => {\n const children = getNodeDefChildrenInOwnPage({ survey, nodeDef, cycle })\n for (const child of children) {\n uuids.push(child.uuid)\n visit(child)\n }\n }\n visit(pageNodeDef)\n return uuids\n}\n\nconst nodeIsUnderEntity = (params: { node: Node; entityUuid: string }): boolean => {\n const { node, entityUuid } = params\n if (node.uuid === entityUuid) return true\n return Nodes.getHierarchy(node).includes(entityUuid)\n}\n\nconst getOwnPageFieldValidationFlags = (params: {\n nodeUuid: string\n pageNodeDefUuid: string\n descendantPageUuids: string[]\n scopeEntityUuid?: string\n record: Record\n recordValidation: ReturnType<typeof Validations.getValidation>\n}): PageValidationStatus | null => {\n const { nodeUuid, pageNodeDefUuid, descendantPageUuids, scopeEntityUuid, record, recordValidation } = params\n\n if (RecordValidations.isValidationChildrenCountKey(nodeUuid)) {\n return getOwnPageChildrenCountValidationFlags({\n childrenCountKey: nodeUuid,\n pageNodeDefUuid,\n descendantPageUuids,\n scopeEntityUuid,\n record,\n recordValidation,\n })\n }\n\n const node = getNodeByUuid(nodeUuid)(record)\n if (!node || !nodeBelongsToOwnPage({ node, pageNodeDefUuid, descendantPageUuids, record })) return null\n if (scopeEntityUuid && !nodeIsUnderEntity({ node, entityUuid: scopeEntityUuid })) return null\n\n const nodeValidation = RecordValidations.getValidationNode({ nodeUuid })(recordValidation)\n if (!nodeValidation) return null\n\n return {\n hasErrors: Validations.hasErrors(nodeValidation),\n hasWarnings: Validations.hasWarnings(nodeValidation),\n }\n}\n\n/**\n * Children-count validations (file min count, inline multiple min/max, etc.) are keyed as\n * `childrenCount_{parentUuid}_{childDefUuid}`, not as node UUIDs.\n * Include them when the parent is on this page, but skip counts that refer to descendant\n * page entities (missing sub-page instances should not paint the parent page red).\n */\nconst getOwnPageChildrenCountValidationFlags = (params: {\n childrenCountKey: string\n pageNodeDefUuid: string\n descendantPageUuids: string[]\n scopeEntityUuid?: string\n record: Record\n recordValidation: ReturnType<typeof Validations.getValidation>\n}): PageValidationStatus | null => {\n const { childrenCountKey, pageNodeDefUuid, descendantPageUuids, scopeEntityUuid, record, recordValidation } = params\n const parentUuid = RecordValidations.extractValidationChildrenCountKeyParentUuid(childrenCountKey)\n const childDefUuid = RecordValidations.extractValidationChildrenCountKeyNodeDefUuid(childrenCountKey)\n if (!parentUuid || !childDefUuid) return null\n\n // Sub-page entity min/max counts belong to navigation of nested pages, not this page's fields.\n if (descendantPageUuids.includes(childDefUuid)) return null\n\n const parentNode = getNodeByUuid(parentUuid)(record)\n if (!parentNode || !nodeBelongsToOwnPage({ node: parentNode, pageNodeDefUuid, descendantPageUuids, record })) {\n return null\n }\n if (scopeEntityUuid && !nodeIsUnderEntity({ node: parentNode, entityUuid: scopeEntityUuid })) return null\n\n const fieldValidation = Validations.getFieldValidation(childrenCountKey)(recordValidation)\n if (!fieldValidation) return null\n\n return {\n hasErrors: Validations.hasErrors(fieldValidation),\n hasWarnings: Validations.hasWarnings(fieldValidation),\n }\n}\n\n/**\n * Aggregates error/warning flags for a page.\n * When descendantPageUuids is non-empty, nested page entities are excluded (own-page scope).\n * When scopeEntityUuid is set, only validations for nodes under that entity instance are included.\n */\nexport const getPageValidationStatus = (params: {\n pageNodeDefUuid: string\n descendantPageUuids?: string[]\n record: Record\n scopeEntityUuid?: string\n}): PageValidationStatus => {\n const { pageNodeDefUuid, descendantPageUuids = [], record, scopeEntityUuid } = params\n const recordValidation = Validations.getValidation(record)\n const fields = Validations.getFieldValidations(recordValidation)\n let hasErrors = false\n let hasWarnings = false\n\n for (const nodeUuid of Object.keys(fields)) {\n const flags = getOwnPageFieldValidationFlags({\n nodeUuid,\n pageNodeDefUuid,\n descendantPageUuids,\n scopeEntityUuid,\n record,\n recordValidation,\n })\n if (!flags) continue\n if (flags.hasErrors) hasErrors = true\n if (flags.hasWarnings) hasWarnings = true\n if (hasErrors && hasWarnings) break\n }\n\n return { hasErrors, hasWarnings }\n}\n\nconst aggregatePageValidationStatuses = (statuses: PageValidationStatus[]): PageValidationStatus => ({\n hasErrors: statuses.some((status) => status.hasErrors),\n hasWarnings: statuses.some((status) => status.hasWarnings),\n})\n\n/**\n * Validation and completion status for one entity instance and its descendant pages.\n * Returns null when the node is missing or is not an entity.\n */\nexport const getEntitySubtreeStatus = (params: {\n survey: Survey\n record: Record\n entityUuid: string\n cycle?: string\n}): EntitySubtreeStatus | null => {\n const { survey, record, entityUuid } = params\n const entity = getNodeByUuid(entityUuid)(record)\n if (!entity) return null\n\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n if (!NodeDefs.isEntity(entityDef)) return null\n\n const cycle = params.cycle ?? getCycle(record)\n const entityPageDef = entityDef as NodeDefEntity\n const descendantPageUuids = getDescendantPageNodeDefUuids({ survey, cycle, pageNodeDef: entityPageDef })\n const pageUuidsToCheck = [entity.nodeDefUuid, ...descendantPageUuids]\n\n const validationStatuses = pageUuidsToCheck.map((pageNodeDefUuid) => {\n const pageNodeDef = Surveys.getNodeDefByUuid({ survey, uuid: pageNodeDefUuid }) as NodeDefEntity\n const pageDescendantUuids = getDescendantPageNodeDefUuids({ survey, cycle, pageNodeDef })\n return getPageValidationStatus({\n pageNodeDefUuid,\n descendantPageUuids: pageDescendantUuids,\n record,\n scopeEntityUuid: entityUuid,\n })\n })\n\n const { hasErrors, hasWarnings } = aggregatePageValidationStatuses(validationStatuses)\n const { total, filled } = getEntityCompletionStats({ survey, record, entity })\n const isComplete = total > 0 && filled === total && !hasErrors && !hasWarnings\n\n return { hasErrors, hasWarnings, isComplete }\n}\n\n/**\n * Aggregates subtree status across instances of a multiple page entity.\n * When `scopeEntityUuid` is set, only instances under that ancestor entity are included\n * (needed for nested multiples, e.g. Tree under the currently selected Plot).\n * Empty instance lists return a non-complete status with no validation flags.\n */\nexport const getMultiplePageEntitiesStatus = (params: {\n survey: Survey\n record: Record\n pageNodeDefUuid: string\n cycle?: string\n /** When set, only instances under this ancestor entity are aggregated. */\n scopeEntityUuid?: string\n}): EntitySubtreeStatus => {\n const { survey, record, pageNodeDefUuid, scopeEntityUuid } = params\n const instances = getNodesByDefUuid(pageNodeDefUuid)(record).filter((instance) =>\n scopeEntityUuid ? nodeIsUnderEntity({ node: instance, entityUuid: scopeEntityUuid }) : true\n )\n\n if (instances.length === 0) {\n return { hasErrors: false, hasWarnings: false, isComplete: false }\n }\n\n const instanceStatuses = instances\n .map((instance) => getEntitySubtreeStatus({ survey, record, entityUuid: instance.uuid, cycle: params.cycle }))\n .filter((status): status is EntitySubtreeStatus => status !== null)\n\n return {\n hasErrors: instanceStatuses.some((status) => status.hasErrors),\n hasWarnings: instanceStatuses.some((status) => status.hasWarnings),\n isComplete: instanceStatuses.length > 0 && instanceStatuses.every((status) => status.isComplete),\n }\n}\n\n/**\n * Whether the page has validation errors on its own fields (excluding nested page entities).\n */\nexport const pageHasOwnErrors = (params: {\n pageNodeDefUuid: string\n descendantPageUuids: string[]\n record: Record\n}): boolean => getPageValidationStatus(params).hasErrors\n\n/**\n * Progress of pages without own-field validation errors over all survey pages.\n * Warnings do not reduce the score (matches Arena sidebar red-icon signal).\n */\nexport const getRecordPagesValidationProgress = (params: {\n survey: Survey\n record: Record\n cycle?: string\n}): PagesValidationProgress | null => {\n const { survey, record } = params\n if (!getRoot(record)) return null\n\n const cycle = params.cycle ?? getCycle(record)\n const pageNodeDefs = getPageNodeDefs({ survey, cycle })\n const totalCount = pageNodeDefs.length\n if (totalCount === 0) return null\n\n let validCount = 0\n for (const pageNodeDef of pageNodeDefs) {\n const pageNodeDefUuid = pageNodeDef.uuid\n const descendantPageUuids = getDescendantPageNodeDefUuids({ survey, cycle, pageNodeDef })\n if (!pageHasOwnErrors({ pageNodeDefUuid, descendantPageUuids, record })) {\n validCount += 1\n }\n }\n\n const percent = Math.round((validCount / totalCount) * 100)\n return { percent, validCount, totalCount }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"recordPagesValidation.js","sourceRoot":"","sources":["../../../src/record/_records/recordPagesValidation.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AACxC,2CAAuD;AACvD,yCAA8C;AAC9C,iDAA8C;AAE9C,4DAAwD;AACxD,yDAA6D;AAC7D,mDAAqF;AAmBrF;;GAEG;AACI,MAAM,iBAAiB,GAAG,CAAC,MAA+D,EAAW,EAAE;IAC5G,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IAChD,IAAI,IAAI,CAAC,WAAW,KAAK,eAAe;QAAE,OAAO,IAAI,CAAA;IACrD,OAAO,YAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,EAAE;QACpD,MAAM,QAAQ,GAAG,IAAA,6BAAa,EAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;QACpD,OAAO,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,WAAW,MAAK,eAAe,CAAA;IAClD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAPY,QAAA,iBAAiB,GAAjB,iBAAiB,CAO7B;AAED;;;GAGG;AACI,MAAM,oBAAoB,GAAG,CAAC,MAKpC,EAAW,EAAE;IACZ,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IACrE,IAAI,CAAC,IAAA,QAAA,iBAAiB,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC;QAAE,OAAO,KAAK,CAAA;IACvE,IAAI,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC;QAAE,OAAO,KAAK,CAAA;IAChE,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,EA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UAAU,GAAG,UAAU,CAAC,GAAG,GAAG,CAAC,CAAA;IAC3D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAA;AAC5C,CAAC,CAAA;AAxBY,QAAA,gCAAgC,GAAhC,gCAAgC,CAwB5C","sourcesContent":["import { Node, Nodes } from '../../node'\nimport { NodeDefEntity, NodeDefs } from '../../nodeDef'\nimport { Survey, Surveys } from '../../survey'\nimport { Validations } from '../../validation'\nimport { Record } from '../record'\nimport { RecordValidations } from '../recordValidations'\nimport { getEntityCompletionStats } from './recordCompletion'\nimport { getCycle, getNodeByUuid, getNodesByDefUuid, getRoot } from './recordGetters'\n\nexport type PageValidationStatus = {\n hasErrors: boolean\n hasWarnings: boolean\n}\n\nexport type EntitySubtreeStatus = {\n hasErrors: boolean\n hasWarnings: boolean\n isComplete: boolean\n}\n\nexport type PagesValidationProgress = {\n percent: number\n validCount: number\n totalCount: number\n}\n\n/**\n * Whether a node belongs under a page entity (itself or any descendant of that page).\n */\nexport const nodeBelongsToPage = (params: { node: Node; pageNodeDefUuid: string; record: Record }): boolean => {\n const { node, pageNodeDefUuid, record } = params\n if (node.nodeDefUuid === pageNodeDefUuid) return true\n return Nodes.getHierarchy(node).some((ancestorUuid) => {\n const ancestor = getNodeByUuid(ancestorUuid)(record)\n return ancestor?.nodeDefUuid === pageNodeDefUuid\n })\n}\n\n/**\n * Whether a node belongs to this page only — not to a nested descendant page entity.\n * When descendantPageUuids is empty, all nodes under the page hierarchy are included.\n */\nexport const nodeBelongsToOwnPage = (params: {\n node: Node\n pageNodeDefUuid: string\n descendantPageUuids: string[]\n record: Record\n}): boolean => {\n const { node, pageNodeDefUuid, descendantPageUuids, record } = params\n if (!nodeBelongsToPage({ node, pageNodeDefUuid, record })) return false\n if (descendantPageUuids.includes(node.nodeDefUuid)) return false\n return !descendantPageUuids.some((descendantUuid) =>\n nodeBelongsToPage({ node, pageNodeDefUuid: descendantUuid, record })\n )\n}\n\n/**\n * Child page-entity defs displayed in their own page under the given entity.\n */\nexport const getNodeDefChildrenInOwnPage = (params: {\n survey: Survey\n nodeDef: NodeDefEntity\n cycle: string\n}): NodeDefEntity[] => {\n const { survey, nodeDef, cycle } = params\n return Surveys.getNodeDefChildren({ survey, nodeDef, includeAnalysis: true }).filter(\n (child): child is NodeDefEntity => {\n if (!NodeDefs.isEntity(child)) return false\n return NodeDefs.isDisplayInOwnPage(cycle)(child as NodeDefEntity)\n }\n )\n}\n\n/**\n * Collects all page-entity node defs in the survey cycle (root + nested own-pages).\n */\nexport const getPageNodeDefs = (params: { survey: Survey; cycle: string }): NodeDefEntity[] => {\n const { survey, cycle } = params\n const root = Surveys.getNodeDefRoot({ survey }) as NodeDefEntity | undefined\n if (!root) return []\n\n const pages: NodeDefEntity[] = []\n const stack: NodeDefEntity[] = [root]\n while (stack.length > 0) {\n const current = stack.pop()\n if (!current) continue\n pages.push(current)\n stack.push(...getNodeDefChildrenInOwnPage({ survey, nodeDef: current, cycle }))\n }\n return pages\n}\n\n/**\n * Collects descendant page node def UUIDs under a page (not including the page itself).\n */\nexport const getDescendantPageNodeDefUuids = (params: {\n survey: Survey\n cycle: string\n pageNodeDef: NodeDefEntity\n}): string[] => {\n const { survey, cycle, pageNodeDef } = params\n const uuids: string[] = []\n const visit = (nodeDef: NodeDefEntity) => {\n const children = getNodeDefChildrenInOwnPage({ survey, nodeDef, cycle })\n for (const child of children) {\n uuids.push(child.uuid)\n visit(child)\n }\n }\n visit(pageNodeDef)\n return uuids\n}\n\nconst nodeIsUnderEntity = (params: { node: Node; entityUuid: string }): boolean => {\n const { node, entityUuid } = params\n if (node.uuid === entityUuid) return true\n return Nodes.getHierarchy(node).includes(entityUuid)\n}\n\nconst getOwnPageFieldValidationFlags = (params: {\n nodeUuid: string\n pageNodeDefUuid: string\n descendantPageUuids: string[]\n scopeEntityUuid?: string\n record: Record\n recordValidation: ReturnType<typeof Validations.getValidation>\n}): PageValidationStatus | null => {\n const { nodeUuid, pageNodeDefUuid, descendantPageUuids, scopeEntityUuid, record, recordValidation } = params\n\n if (RecordValidations.isValidationChildrenCountKey(nodeUuid)) {\n return getOwnPageChildrenCountValidationFlags({\n childrenCountKey: nodeUuid,\n pageNodeDefUuid,\n descendantPageUuids,\n scopeEntityUuid,\n record,\n recordValidation,\n })\n }\n\n const node = getNodeByUuid(nodeUuid)(record)\n if (!node || !nodeBelongsToOwnPage({ node, pageNodeDefUuid, descendantPageUuids, record })) return null\n if (scopeEntityUuid && !nodeIsUnderEntity({ node, entityUuid: scopeEntityUuid })) return null\n\n const nodeValidation = RecordValidations.getValidationNode({ nodeUuid })(recordValidation)\n if (!nodeValidation) return null\n\n return {\n hasErrors: Validations.hasErrors(nodeValidation),\n hasWarnings: Validations.hasWarnings(nodeValidation),\n }\n}\n\n/**\n * Children-count validations (file min count, inline multiple min/max, etc.) are keyed as\n * `childrenCount_{parentUuid}_{childDefUuid}`, not as node UUIDs.\n * Include them when the parent is on this page, but skip counts that refer to descendant\n * page entities (missing sub-page instances should not paint the parent page red).\n */\nconst getOwnPageChildrenCountValidationFlags = (params: {\n childrenCountKey: string\n pageNodeDefUuid: string\n descendantPageUuids: string[]\n scopeEntityUuid?: string\n record: Record\n recordValidation: ReturnType<typeof Validations.getValidation>\n}): PageValidationStatus | null => {\n const { childrenCountKey, pageNodeDefUuid, descendantPageUuids, scopeEntityUuid, record, recordValidation } = params\n const parentUuid = RecordValidations.extractValidationChildrenCountKeyParentUuid(childrenCountKey)\n const childDefUuid = RecordValidations.extractValidationChildrenCountKeyNodeDefUuid(childrenCountKey)\n if (!parentUuid || !childDefUuid) return null\n\n // Sub-page entity min/max counts belong to navigation of nested pages, not this page's fields.\n if (descendantPageUuids.includes(childDefUuid)) return null\n\n const parentNode = getNodeByUuid(parentUuid)(record)\n if (!parentNode || !nodeBelongsToOwnPage({ node: parentNode, pageNodeDefUuid, descendantPageUuids, record })) {\n return null\n }\n if (scopeEntityUuid && !nodeIsUnderEntity({ node: parentNode, entityUuid: scopeEntityUuid })) return null\n\n const fieldValidation = Validations.getFieldValidation(childrenCountKey)(recordValidation)\n if (!fieldValidation) return null\n\n return {\n hasErrors: Validations.hasErrors(fieldValidation),\n hasWarnings: Validations.hasWarnings(fieldValidation),\n }\n}\n\n/**\n * Aggregates error/warning flags for a page.\n * When descendantPageUuids is non-empty, nested page entities are excluded (own-page scope).\n * When scopeEntityUuid is set, only validations for nodes under that entity instance are included.\n */\nexport const getPageValidationStatus = (params: {\n pageNodeDefUuid: string\n descendantPageUuids?: string[]\n record: Record\n scopeEntityUuid?: string\n}): PageValidationStatus => {\n const { pageNodeDefUuid, descendantPageUuids = [], record, scopeEntityUuid } = params\n const recordValidation = Validations.getValidation(record)\n const fields = Validations.getFieldValidations(recordValidation)\n let hasErrors = false\n let hasWarnings = false\n\n for (const nodeUuid of Object.keys(fields)) {\n const flags = getOwnPageFieldValidationFlags({\n nodeUuid,\n pageNodeDefUuid,\n descendantPageUuids,\n scopeEntityUuid,\n record,\n recordValidation,\n })\n if (!flags) continue\n if (flags.hasErrors) hasErrors = true\n if (flags.hasWarnings) hasWarnings = true\n if (hasErrors && hasWarnings) break\n }\n\n return { hasErrors, hasWarnings }\n}\n\nconst aggregatePageValidationStatuses = (statuses: PageValidationStatus[]): PageValidationStatus => ({\n hasErrors: statuses.some((status) => status.hasErrors),\n hasWarnings: statuses.some((status) => status.hasWarnings),\n})\n\n/**\n * Validation and completion status for one entity instance and its descendant pages.\n * Returns null when the node is missing or is not an entity.\n */\nexport const getEntitySubtreeStatus = (params: {\n survey: Survey\n record: Record\n entityUuid: string\n cycle?: string\n}): EntitySubtreeStatus | null => {\n const { survey, record, entityUuid } = params\n const entity = getNodeByUuid(entityUuid)(record)\n if (!entity) return null\n\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n if (!NodeDefs.isEntity(entityDef)) return null\n\n const cycle = params.cycle ?? getCycle(record)\n const entityPageDef = entityDef as NodeDefEntity\n const descendantPageUuids = getDescendantPageNodeDefUuids({ survey, cycle, pageNodeDef: entityPageDef })\n const pageUuidsToCheck = [entity.nodeDefUuid, ...descendantPageUuids]\n\n const validationStatuses = pageUuidsToCheck.map((pageNodeDefUuid) => {\n const pageNodeDef = Surveys.getNodeDefByUuid({ survey, uuid: pageNodeDefUuid }) as NodeDefEntity\n const pageDescendantUuids = getDescendantPageNodeDefUuids({ survey, cycle, pageNodeDef })\n return getPageValidationStatus({\n pageNodeDefUuid,\n descendantPageUuids: pageDescendantUuids,\n record,\n scopeEntityUuid: entityUuid,\n })\n })\n\n const { hasErrors, hasWarnings } = aggregatePageValidationStatuses(validationStatuses)\n const { total, filled } = getEntityCompletionStats({ survey, record, entity })\n const isComplete = total > 0 && filled === total && !hasErrors && !hasWarnings\n\n return { hasErrors, hasWarnings, isComplete }\n}\n\n/**\n * Aggregates subtree status across instances of a multiple page entity.\n * When `scopeEntityUuid` is set, only instances under that ancestor entity are included\n * (needed for nested multiples, e.g. Tree under the currently selected Plot).\n * Empty instance lists return a non-complete status with no validation flags.\n */\nexport const getMultiplePageEntitiesStatus = (params: {\n survey: Survey\n record: Record\n pageNodeDefUuid: string\n cycle?: string\n /** When set, only instances under this ancestor entity are aggregated. */\n scopeEntityUuid?: string\n}): EntitySubtreeStatus => {\n const { survey, record, pageNodeDefUuid, scopeEntityUuid } = params\n const instances = getNodesByDefUuid(pageNodeDefUuid)(record).filter((instance) =>\n scopeEntityUuid ? nodeIsUnderEntity({ node: instance, entityUuid: scopeEntityUuid }) : true\n )\n\n if (instances.length === 0) {\n return { hasErrors: false, hasWarnings: false, isComplete: false }\n }\n\n const instanceStatuses = instances\n .map((instance) => getEntitySubtreeStatus({ survey, record, entityUuid: instance.uuid, cycle: params.cycle }))\n .filter((status): status is EntitySubtreeStatus => status !== null)\n\n return {\n hasErrors: instanceStatuses.some((status) => status.hasErrors),\n hasWarnings: instanceStatuses.some((status) => status.hasWarnings),\n isComplete: instanceStatuses.length > 0 && instanceStatuses.every((status) => status.isComplete),\n }\n}\n\n/**\n * Whether the page has validation errors on its own fields (excluding nested page entities).\n */\nexport const pageHasOwnErrors = (params: {\n pageNodeDefUuid: string\n descendantPageUuids: string[]\n record: Record\n}): boolean => getPageValidationStatus(params).hasErrors\n\n/**\n * Progress of pages without own-field validation errors over all survey pages.\n * Warnings do not reduce the score (matches Arena sidebar red-icon signal).\n */\nexport const getRecordPagesValidationProgress = (params: {\n survey: Survey\n record: Record\n cycle?: string\n}): PagesValidationProgress | null => {\n const { survey, record } = params\n if (!getRoot(record)) return null\n\n const cycle = params.cycle ?? getCycle(record)\n const pageNodeDefs = getPageNodeDefs({ survey, cycle })\n const totalCount = pageNodeDefs.length\n if (totalCount === 0) return null\n\n let validCount = 0\n for (const pageNodeDef of pageNodeDefs) {\n const pageNodeDefUuid = pageNodeDef.uuid\n const descendantPageUuids = getDescendantPageNodeDefUuids({ survey, cycle, pageNodeDef })\n if (!pageHasOwnErrors({ pageNodeDefUuid, descendantPageUuids, record })) {\n validCount += 1\n }\n }\n\n const percent = Math.round((validCount / totalCount) * 100)\n return { percent, validCount, totalCount }\n}\n"]}
|