@openforis/arena-core 2.3.40 → 2.3.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/authorizer.d.ts +3 -3
- package/dist/auth/authorizer.js.map +1 -1
- package/dist/esm/auth/authorizer.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node/factory.js.map +1 -1
- package/dist/esm/node/index.js.map +1 -1
- package/dist/esm/node/node.js.map +1 -1
- package/dist/esm/node/nodePointer.js.map +1 -1
- package/dist/esm/node/nodeValueFormatter.js.map +1 -1
- package/dist/esm/node/nodeValues.js.map +1 -1
- package/dist/esm/node/nodes.js +13 -5
- package/dist/esm/node/nodes.js.map +1 -1
- package/dist/esm/node/service.js.map +1 -1
- package/dist/esm/nodeDefExpressionEvaluator/functions.js.map +1 -1
- package/dist/esm/record/_records/recordCompletion.js.map +1 -1
- package/dist/esm/record/_records/recordGetters.js.map +1 -1
- package/dist/esm/record/_records/recordNodesIndexUpdater.js +6 -4
- 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/recordUpdateOptions.js.map +1 -1
- package/dist/esm/record/_records/recordUpdater.js +1 -1
- package/dist/esm/record/_records/recordUpdater.js.map +1 -1
- package/dist/esm/record/_records/recordUtils.js.map +1 -1
- package/dist/esm/record/factory.js.map +1 -1
- package/dist/esm/record/index.js.map +1 -1
- package/dist/esm/record/nodePointers.js.map +1 -1
- package/dist/esm/record/record.js.map +1 -1
- package/dist/esm/record/recordCloner.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/context.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/node/identifier/nodesFinder.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/nodeValueExtractor.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
- package/dist/esm/record/recordFixer.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordEnumeratingItemsExpressionEvaluator.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordExpressionValueConverter.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEditableUpdater.js +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEditableUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsUpdateParams.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsVisibleUpdater.js +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsVisibleUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesCreator.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesDeleter.js +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesDeleter.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.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/recordPrettyPrinter.js.map +1 -1
- package/dist/esm/record/recordUpdater.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeKeyValidator.js.map +1 -1
- 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/countVaildator.js.map +1 -1
- package/dist/esm/record/recordValidator/recordValidator.js.map +1 -1
- package/dist/esm/record/service.js.map +1 -1
- package/dist/esm/survey/nodeDefsFixer.js.map +1 -1
- package/dist/esm/survey/surveys/_nodeDefs/nodeDefsIndex.js +2 -2
- package/dist/esm/survey/surveys/_nodeDefs/nodeDefsIndex.js.map +1 -1
- package/dist/esm/tests/builder/recordBuilder/attributeBuilder.js.map +1 -1
- package/dist/esm/tests/builder/recordBuilder/entityBuilder.js.map +1 -1
- package/dist/esm/tests/builder/recordBuilder/nodeBuilder.js.map +1 -1
- package/dist/esm/tests/builder/recordBuilder/recordBuilder.js.map +1 -1
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/mutationOptions.js +5 -0
- package/dist/esm/utils/mutationOptions.js.map +1 -0
- package/dist/esm/validation/index.js.map +1 -1
- package/dist/esm/validation/validations.js +26 -19
- package/dist/esm/validation/validations.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js.map +1 -1
- package/dist/node/factory.d.ts +4 -4
- package/dist/node/factory.js.map +1 -1
- package/dist/node/index.d.ts +1 -2
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +7 -2
- package/dist/node/node.js.map +1 -1
- package/dist/node/nodePointer.d.ts +2 -2
- package/dist/node/nodePointer.js.map +1 -1
- package/dist/node/nodeValueFormatter.d.ts +2 -2
- package/dist/node/nodeValueFormatter.js.map +1 -1
- package/dist/node/nodeValues.d.ts +21 -21
- package/dist/node/nodeValues.js.map +1 -1
- package/dist/node/nodes.d.ts +38 -31
- package/dist/node/nodes.js +13 -5
- package/dist/node/nodes.js.map +1 -1
- package/dist/node/service.d.ts +6 -6
- package/dist/node/service.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/functions.js.map +1 -1
- package/dist/record/_records/recordCompletion.d.ts +9 -9
- package/dist/record/_records/recordCompletion.js.map +1 -1
- package/dist/record/_records/recordGetters.d.ts +69 -69
- package/dist/record/_records/recordGetters.js.map +1 -1
- package/dist/record/_records/recordNodesIndexUpdater.d.ts +13 -10
- package/dist/record/_records/recordNodesIndexUpdater.js +6 -4
- package/dist/record/_records/recordNodesIndexUpdater.js.map +1 -1
- package/dist/record/_records/recordPagesValidation.d.ts +11 -11
- package/dist/record/_records/recordPagesValidation.js.map +1 -1
- package/dist/record/_records/recordUpdateOptions.d.ts +2 -2
- package/dist/record/_records/recordUpdateOptions.js.map +1 -1
- package/dist/record/_records/recordUpdater.d.ts +5 -5
- package/dist/record/_records/recordUpdater.js +1 -1
- package/dist/record/_records/recordUpdater.js.map +1 -1
- package/dist/record/_records/recordUtils.d.ts +6 -6
- package/dist/record/_records/recordUtils.js.map +1 -1
- package/dist/record/factory.d.ts +2 -2
- package/dist/record/factory.js.map +1 -1
- package/dist/record/index.d.ts +1 -2
- package/dist/record/index.js.map +1 -1
- package/dist/record/nodePointers.d.ts +6 -6
- package/dist/record/nodePointers.js.map +1 -1
- package/dist/record/record.d.ts +8 -5
- package/dist/record/record.js.map +1 -1
- package/dist/record/recordCloner.d.ts +3 -3
- package/dist/record/recordCloner.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/context.d.ts +6 -6
- package/dist/record/recordExpressionEvaluator/context.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/node/identifier/nodesFinder.d.ts +5 -5
- package/dist/record/recordExpressionEvaluator/node/identifier/nodesFinder.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/nodeValueExtractor.d.ts +2 -2
- package/dist/record/recordExpressionEvaluator/nodeValueExtractor.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.d.ts +4 -4
- package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
- package/dist/record/recordFixer.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordEnumeratingItemsExpressionEvaluator.d.ts +4 -4
- package/dist/record/recordNodesUpdater/recordEnumeratingItemsExpressionEvaluator.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordExpressionValueConverter.d.ts +4 -4
- package/dist/record/recordNodesUpdater/recordExpressionValueConverter.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.d.ts +4 -3
- package/dist/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsEditableUpdater.js +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsEditableUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.d.ts +2 -2
- package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.d.ts +2 -2
- package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsUpdateParams.d.ts +2 -2
- package/dist/record/recordNodesUpdater/recordNodeDependentsUpdateParams.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsVisibleUpdater.js +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsVisibleUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesCreator.d.ts +4 -4
- package/dist/record/recordNodesUpdater/recordNodesCreator.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesDeleter.d.ts +3 -3
- package/dist/record/recordNodesUpdater/recordNodesDeleter.js +1 -1
- package/dist/record/recordNodesUpdater/recordNodesDeleter.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.d.ts +4 -4
- package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesUpdater.d.ts +2 -2
- package/dist/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordUpdateResult.d.ts +6 -6
- package/dist/record/recordNodesUpdater/recordUpdateResult.js.map +1 -1
- package/dist/record/recordPrettyPrinter.d.ts +7 -7
- package/dist/record/recordPrettyPrinter.js.map +1 -1
- package/dist/record/recordUpdater.js.map +1 -1
- package/dist/record/recordValidator/attributeKeyValidator.d.ts +4 -4
- package/dist/record/recordValidator/attributeKeyValidator.js.map +1 -1
- package/dist/record/recordValidator/attributeTypeValidator.d.ts +4 -4
- package/dist/record/recordValidator/attributeTypeValidator.js.map +1 -1
- package/dist/record/recordValidator/attributeUniqueValidator.d.ts +4 -4
- package/dist/record/recordValidator/attributeUniqueValidator.js.map +1 -1
- package/dist/record/recordValidator/attributeValidator.d.ts +6 -6
- package/dist/record/recordValidator/attributeValidator.js.map +1 -1
- package/dist/record/recordValidator/countVaildator.d.ts +7 -7
- package/dist/record/recordValidator/countVaildator.js.map +1 -1
- package/dist/record/recordValidator/recordValidator.js.map +1 -1
- package/dist/record/records.d.ts +6 -6
- package/dist/record/service.d.ts +8 -8
- package/dist/record/service.js.map +1 -1
- package/dist/survey/nodeDefsFixer.d.ts +2 -2
- package/dist/survey/nodeDefsFixer.js.map +1 -1
- package/dist/survey/surveys/_nodeDefs/nodeDefsIndex.d.ts +3 -6
- package/dist/survey/surveys/_nodeDefs/nodeDefsIndex.js +2 -2
- package/dist/survey/surveys/_nodeDefs/nodeDefsIndex.js.map +1 -1
- package/dist/tests/builder/recordBuilder/attributeBuilder.d.ts +5 -5
- package/dist/tests/builder/recordBuilder/attributeBuilder.js.map +1 -1
- package/dist/tests/builder/recordBuilder/entityBuilder.d.ts +5 -5
- package/dist/tests/builder/recordBuilder/entityBuilder.js.map +1 -1
- package/dist/tests/builder/recordBuilder/nodeBuilder.d.ts +5 -5
- package/dist/tests/builder/recordBuilder/nodeBuilder.js.map +1 -1
- package/dist/tests/builder/recordBuilder/recordBuilder.d.ts +2 -2
- package/dist/tests/builder/recordBuilder/recordBuilder.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/mutationOptions.d.ts +14 -0
- package/dist/utils/mutationOptions.js +9 -0
- package/dist/utils/mutationOptions.js.map +1 -0
- package/dist/validation/index.d.ts +1 -0
- package/dist/validation/index.js.map +1 -1
- package/dist/validation/validations.d.ts +17 -2
- package/dist/validation/validations.js +26 -19
- package/dist/validation/validations.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordNodesDeleter.js","sourceRoot":"","sources":["../../../src/record/recordNodesUpdater/recordNodesDeleter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAA0D;AAC1D,MAAY,aAAa,sDAAiC;AAC1D,iFAA6E;AAC7E,yEAAkG;AAElG,4DAAwD;AACxD,6DAAyD;AAEzD,MAAM,qCAAqC,GAAG,CAAC,QAAgB,EAAsB,EAAE;IACrF,IAAI,CAAC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Q,CAAC,CAAA;QACzC,IAAI,CAAC,IAAI;YAAE,OAAM;QAEjB,aAAa,CAAC,uBAAuB,CAAC;YACpC,MAAM;YACN,IAAI;YACJ,OAAO,EAAE,oBAAoB;SAC9B,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,6EAA6E;IAC7E,aAAa,CAAC,UAAU,GAAG,wBAAW,CAAC,OAAO,CAC5C,qCAAqC,CAAC;QACpC,UAAU,EAAE,wBAAW,CAAC,aAAa,CAAC,MAAM,CAAC;QAC7C,YAAY;QACZ,UAAU,EAAE,CAAC,CAAC,UAAU;KACzB,CAAC,CACH,CAAA;IAED,aAAa,CAAC,KAAK,GAAG,kBAAkB,CAAA;IACxC,0DAA0D;IAC1D,IAAI,gBAAgB,EAAE,CAAC;QACrB,aAAa,CAAC,WAAW,GAAG,iDAAuB,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,EAAE,UAAU,EAAE,CAAC,OAC1G,MAAM,CAAC,WAAW,mCAAI,EAAE,CACzB,CAAA;IACH,CAAC;IACD,OAAO,IAAI,uCAAkB,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC,CAAA;AAC7F,CAAC,CAAA;AApDU,QAAA,WAAW,GAAX,WAAW,CAoDrB;AAEI,MAAM,UAAU,GACrB,CAAC,QAAgB,EAAE,OAAO,GAAwB,iDAA2B,EAAE,EAAE,CACjF,CAAC,MAAmB,EAAsB,EAAE,CAC1C,IAAA,QAAA,WAAW,EAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,CAAA;AAH/B,QAAA,UAAU,GAAV,UAAU,CAGqB","sourcesContent":["import { ArenaRecordNode, NodesMap } from '../../node'\nimport { Validation, Validations } from '../../validation'\nimport * as RecordGetters from '../_records/recordGetters'\nimport { RecordNodesIndexUpdater } from '../_records/recordNodesIndexUpdater'\nimport { RecordUpdateOptions, RecordUpdateOptionsDefaults } from '../_records/recordUpdateOptions'\nimport { ArenaRecord } from '../record'\nimport { RecordValidations } from '../recordValidations'\nimport { RecordUpdateResult } from './recordUpdateResult'\n\nconst _getChildrenCountValidationParentUuid = (fieldKey: string): string | undefined => {\n if (!RecordValidations.isValidationChildrenCountKey(fieldKey)) return undefined\n // children count field key format: {prefix}{parentUuid}_{childDefUuid}\n const keyWithoutPrefix = fieldKey.substring(RecordValidations.prefixValidationFieldChildrenCount.length)\n const separatorIndex = keyWithoutPrefix.indexOf('_')\n return separatorIndex >= 0 ? keyWithoutPrefix.substring(0, separatorIndex) : keyWithoutPrefix\n}\n\n/**\n * Removes the validation of the deleted nodes and the validation of their children count.\n */\nconst _dissocValidationFieldsOfDeletedNodes = (params: {\n validation: Validation\n nodesDeleted: NodesMap\n sideEffect: boolean\n}): Validation => {\n const { validation, nodesDeleted, sideEffect } = params\n const fields = Validations.getFieldValidations(validation)\n const fieldsUpdated = sideEffect ? fields : { ...fields }\n for (const fieldKey of Object.keys(fieldsUpdated)) {\n const nodeUuid = _getChildrenCountValidationParentUuid(fieldKey) ?? fieldKey\n if (nodesDeleted[nodeUuid]) {\n delete fieldsUpdated[fieldKey]\n }\n }\n if (sideEffect) {\n validation.fields = fieldsUpdated\n return validation\n }\n return { ...validation, fields: fieldsUpdated }\n}\n\nexport const deleteNodes =\n (nodeUuids: string[], options: RecordUpdateOptions = RecordUpdateOptionsDefaults) =>\n (record: ArenaRecord): RecordUpdateResult => {\n const { sideEffect, updateNodesIndex } = { ...RecordUpdateOptionsDefaults, ...options }\n\n const recordUpdated = sideEffect ? record : { ...record }\n\n const recordNodes = RecordGetters.getNodes(recordUpdated)\n\n const nodesDeleted: NodesMap = {}\n const recordNodesUpdated = sideEffect ? recordNodes : { ...recordNodes }\n\n const deleteDescendantNode = (visitedNode: ArenaRecordNode) => {\n const visitedNodeUuid = visitedNode.uuid\n if (nodesDeleted[visitedNodeUuid]) return\n\n // delete node from 'nodes'\n delete recordNodesUpdated[visitedNodeUuid]\n\n const visitedNodeUpdated = sideEffect ? visitedNode : { ...visitedNode }\n visitedNodeUpdated.deleted = true\n nodesDeleted[visitedNodeUuid] = visitedNodeUpdated\n }\n\n nodeUuids.forEach((nodeUuid) => {\n const node = recordNodesUpdated[nodeUuid]\n if (!node) return\n\n RecordGetters.visitDescendantsAndSelf({\n record,\n node,\n visitor: deleteDescendantNode,\n })\n })\n\n // delete nodes from validation (in a single pass over the validation fields)\n recordUpdated.validation = Validations.cleanup(\n _dissocValidationFieldsOfDeletedNodes({\n validation: Validations.getValidation(record),\n nodesDeleted,\n sideEffect: !!sideEffect,\n })\n )\n\n recordUpdated.nodes = recordNodesUpdated\n // update nodes index (copying every index part only once)\n if (updateNodesIndex) {\n recordUpdated._nodesIndex = RecordNodesIndexUpdater.removeNodes(Object.values(nodesDeleted), { sideEffect })(\n record._nodesIndex ?? {}\n )\n }\n return new RecordUpdateResult({ record: recordUpdated, nodes: nodesDeleted, nodesDeleted })\n }\n\nexport const deleteNode =\n (nodeUuid: string, options: RecordUpdateOptions = RecordUpdateOptionsDefaults) =>\n (record: ArenaRecord): RecordUpdateResult =>\n deleteNodes([nodeUuid], options)(record)\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArenaRecordNode, NodePointer } from '../../node';
|
|
2
2
|
import { NodeDef, NodeDefExpression, NodeDefProps, NodeDefType } from '../../nodeDef';
|
|
3
3
|
import { Survey, SurveyDependencyType } from '../../survey';
|
|
4
|
-
import {
|
|
4
|
+
import { ArenaRecord } from '../record';
|
|
5
5
|
export declare const throwError: (params: {
|
|
6
6
|
error: any;
|
|
7
7
|
errorKey: string;
|
|
@@ -12,8 +12,8 @@ export declare const throwError: (params: {
|
|
|
12
12
|
}) => never;
|
|
13
13
|
export declare const getDependentNodePointersByType: (params: {
|
|
14
14
|
survey: Survey;
|
|
15
|
-
record:
|
|
16
|
-
node:
|
|
15
|
+
record: ArenaRecord;
|
|
16
|
+
node: ArenaRecordNode;
|
|
17
17
|
dependencyType: SurveyDependencyType;
|
|
18
18
|
includeSelfWhenSourceIsAttribute?: boolean;
|
|
19
19
|
includeNewEntitySelf?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordNodesDependentsUpdaterCommons.js","sourceRoot":"","sources":["../../../src/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.ts"],"names":[],"mappings":";;;AAAA,uCAAyC;AAEzC,2CAA+F;AAC/F,yCAAoE;AAEpE,wCAAoC;AAE7B,MAAM,UAAU,GAAG,CAAC,MAO1B,EAAE,EAAE;IACH,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,EAAE,GAAG,MAAM,CAAA;IAC1F,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAA;IACtC,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAA;IAE/D,MAAM,IAAI,mBAAW,CAAC,QAAQ,EAAE;QAC9B,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI;QAC7B,WAAW;QACX,cAAc;QACd,iBAAiB;QACjB,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE;QACvB,SAAS,EAAE,KAAK,YAAY,mBAAW,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI;KAChE,CAAC,CAAA;AACJ,CAAC,CAAA;AApBY,QAAA,UAAU,GAAV,UAAU,CAoBtB;AAED,MAAM,oBAAoB,GAAG,CAAC,MAI7B,EAAE,EAAE;IACH,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;IAClD,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACnC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC5B,CA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,6BAA6B,GAAG,KAAK,EACrC,QAAQ,GACT,GAAG,MAAM,CAAA;IAEV,MAAM,aAAa,GAAG,gBAAO,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAA;IAClF,MAAM,WAAW,GAAG,gCAAgC,IAAI,CAAC,kBAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA;IAEzF,MAAM,YAAY,GAAG,iBAAO,CAAC,wBAAwB,CAAC;QACpD,MAAM;QACN,MAAM;QACN,IAAI;QACJ,cAAc;QACd,WAAW;QACX,QAAQ;KACT,CAAC,CAAA;IAEF,IAAI,CAAC,kBAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACvD,OAAO,YAAY,CAAA;IACrB,CAAC;IAED,0EAA0E;IAC1E,IAAI,oBAAoB,EAAE,CAAC;QACzB,uBAAuB,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC1F,CAAC;IAED,uGAAuG;IACvG,IAAI,6BAA6B,EAAE,CAAC;QAClC,iCAAiC,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC5F,CAAC;IAED,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA;AAhDY,QAAA,8BAA8B,GAA9B,8BAA8B,CAgD1C","sourcesContent":["import { SystemError } from '../../error'\nimport {
|
|
1
|
+
{"version":3,"file":"recordNodesDependentsUpdaterCommons.js","sourceRoot":"","sources":["../../../src/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.ts"],"names":[],"mappings":";;;AAAA,uCAAyC;AAEzC,2CAA+F;AAC/F,yCAAoE;AAEpE,wCAAoC;AAE7B,MAAM,UAAU,GAAG,CAAC,MAO1B,EAAE,EAAE;IACH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T,CAAC,CAAA;IAEF,IAAI,CAAC,kBAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACvD,OAAO,YAAY,CAAA;IACrB,CAAC;IAED,0EAA0E;IAC1E,IAAI,oBAAoB,EAAE,CAAC;QACzB,uBAAuB,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC1F,CAAC;IAED,uGAAuG;IACvG,IAAI,6BAA6B,EAAE,CAAC;QAClC,iCAAiC,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC5F,CAAC;IAED,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA;AAhDY,QAAA,8BAA8B,GAA9B,8BAA8B,CAgD1C","sourcesContent":["import { SystemError } from '../../error'\nimport { ArenaRecordNode, NodePointer } from '../../node'\nimport { NodeDef, NodeDefExpression, NodeDefProps, NodeDefType, NodeDefs } from '../../nodeDef'\nimport { Survey, SurveyDependencyType, Surveys } from '../../survey'\nimport { ArenaRecord } from '../record'\nimport { Records } from '../records'\n\nexport const throwError = (params: {\n error: any\n errorKey: string\n expressionType: SurveyDependencyType\n survey: Survey\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n expressionsToEvaluate: NodeDefExpression[]\n}) => {\n const { error, errorKey, expressionType, survey, nodeDef, expressionsToEvaluate } = params\n const nodeDefName = nodeDef.props.name\n const expressionsString = JSON.stringify(expressionsToEvaluate)\n\n throw new SystemError(errorKey, {\n surveyName: survey.props.name,\n nodeDefName,\n expressionType,\n expressionsString,\n error: error.toString(),\n errorJson: error instanceof SystemError ? error.toJSON() : null,\n })\n}\n\nconst addPointerIfAccepted = (params: {\n nodePointers: NodePointer[]\n pointer: NodePointer\n filterFn?: (nodePointer: NodePointer) => boolean\n}) => {\n const { nodePointers, pointer, filterFn } = params\n if (!filterFn || filterFn(pointer)) {\n nodePointers.push(pointer)\n }\n}\n\nconst addNewEntitySelfPointer = (params: {\n nodePointers: NodePointer[]\n survey: Survey\n record: ArenaRecord\n node: ArenaRecordNode\n sourceNodeDef: NodeDef<NodeDefType, NodeDefProps>\n filterFn?: (nodePointer: NodePointer) => boolean\n}) => {\n const { nodePointers, record, node, sourceNodeDef, filterFn } = params\n if (!node.parentUuid) {\n return\n }\n const parentNode = Records.getNodeByUuid(node.parentUuid)(record)\n if (!parentNode) {\n return\n }\n addPointerIfAccepted({\n nodePointers,\n pointer: { nodeCtx: parentNode, nodeDef: sourceNodeDef },\n filterFn,\n })\n}\n\nconst addNewEntityChildMultiplePointers = (params: {\n nodePointers: NodePointer[]\n survey: Survey\n node: ArenaRecordNode\n sourceNodeDef: NodeDef<NodeDefType, NodeDefProps>\n filterFn?: (nodePointer: NodePointer) => boolean\n}) => {\n const { nodePointers, survey, node, sourceNodeDef, filterFn } = params\n const multipleNodeDefs = Surveys.getNodeDefChildren({ survey, nodeDef: sourceNodeDef }).filter(NodeDefs.isMultiple)\n\n for (const childDef of multipleNodeDefs) {\n addPointerIfAccepted({\n nodePointers,\n pointer: { nodeCtx: node, nodeDef: childDef },\n filterFn,\n })\n }\n}\n\nexport const getDependentNodePointersByType = (params: {\n survey: Survey\n record: ArenaRecord\n node: ArenaRecordNode\n dependencyType: SurveyDependencyType\n includeSelfWhenSourceIsAttribute?: boolean\n includeNewEntitySelf?: boolean\n includeNewEntityChildPointers?: boolean\n filterFn?: (nodePointer: NodePointer) => boolean\n}): NodePointer[] => {\n const {\n survey,\n record,\n node,\n dependencyType,\n includeSelfWhenSourceIsAttribute = false,\n includeNewEntitySelf = false,\n includeNewEntityChildPointers = false,\n filterFn,\n } = params\n\n const sourceNodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid })\n const includeSelf = includeSelfWhenSourceIsAttribute && !NodeDefs.isEntity(sourceNodeDef)\n\n const nodePointers = Records.getDependentNodePointers({\n survey,\n record,\n node,\n dependencyType,\n includeSelf,\n filterFn,\n })\n\n if (!NodeDefs.isEntity(sourceNodeDef) || !node.created) {\n return nodePointers\n }\n\n // For newly created entities, include a self-pointer for the source node.\n if (includeNewEntitySelf) {\n addNewEntitySelfPointer({ nodePointers, survey, record, node, sourceNodeDef, filterFn })\n }\n\n // For new entities, include child multiple nodes so their dependency metadata/status gets updated too.\n if (includeNewEntityChildPointers) {\n addNewEntityChildMultiplePointers({ nodePointers, survey, node, sourceNodeDef, filterFn })\n }\n\n return nodePointers\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Dictionary } from '../../common';
|
|
2
|
-
import {
|
|
2
|
+
import { ArenaRecordNode } from '../../node';
|
|
3
3
|
import { NodesUpdateParams } from './recordNodesCreator';
|
|
4
4
|
import { RecordUpdateResult } from './recordUpdateResult';
|
|
5
5
|
export declare const updateNodesDependents: (params: NodesUpdateParams & {
|
|
6
|
-
nodes: Dictionary<
|
|
6
|
+
nodes: Dictionary<ArenaRecordNode>;
|
|
7
7
|
}) => Promise<RecordUpdateResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordNodesUpdater.js","sourceRoot":"","sources":["../../../src/record/recordNodesUpdater/recordNodesUpdater.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAmC;AAInC,2CAAgD;AAChD,yCAAsC;AACtC,6DAA6D;AAC7D,mGAA2F;AAC3F,2GAA2F;AAC3F,yFAA0E;AAC1E,yGAAiG;AACjG,+FAAuF;AACvF,mHAAmG;AACnG,+GAAuG;AACvG,qGAA2F;AAE3F,6FAAqF;AAErF,6DAAyD;AAEzD;;;;GAIG;AACH,MAAM,6BAA6B,GAAG,CAAC,CAAA;AAIvC;;GAEG;AACH,MAAM,kBAAkB,GAAkC;IACxD,CAAC,MAAM,EAAE,EAAE,CAAC,IAAA,wDAAqB,kCAAM,MAAM,KAAE,SAAS,EAAE,0BAAgB,CAAC,GAAG,IAAG;IACjF,CAAC,MAAM,EAAE,EAAE,CAAC,IAAA,wDAAqB,kCAAM,MAAM,KAAE,SAAS,EAAE,0BAAgB,CAAC,GAAG,IAAG;IACjF,yEAAiC;IACjC,+EAAoC;IACpC,qEAA+B;IAC/B,mEAA8B;IAC9B,yEAA6B;IAC7B,iFAAiC;IACjC,qFAAuC;IACvC,yEAAgC;CACjC,CAAA;AAEM,MAAM,qBAAqB,GAAG,CACnC,
|
|
1
|
+
{"version":3,"file":"recordNodesUpdater.js","sourceRoot":"","sources":["../../../src/record/recordNodesUpdater/recordNodesUpdater.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAmC;AAInC,2CAAgD;AAChD,yCAAsC;AACtC,6DAA6D;AAC7D,mGAA2F;AAC3F,2GAA2F;AAC3F,yFAA0E;AAC1E,yGAAiG;AACjG,+FAAuF;AACvF,mHAAmG;AACnG,+GAAuG;AACvG,qGAA2F;AAE3F,6FAAqF;AAErF,6DAAyD;AAEzD;;;;GAIG;AACH,MAAM,6BAA6B,GAAG,CAAC,CAAA;AAIvC;;GAEG;AACH,MAAM,kBAAkB,GAAkC;IACxD,CAAC,MAAM,EAAE,EAAE,CAAC,IAAA,wDAAqB,kCAAM,MAAM,KAAE,SAAS,EAAE,0BAAgB,CAAC,GAAG,IAAG;IACjF,CAAC,MAAM,EAAE,EAAE,CAAC,IAAA,wDAAqB,kCAAM,MAAM,KAAE,SAAS,EAAE,0BAAgB,CAAC,GAAG,IAAG;IACjF,yEAAiC;IACjC,+EAAoC;IACpC,qEAA+B;IAC/B,mEAA8B;IAC9B,yEAA6B;IAC7B,iFAAiC;IACjC,qFAAuC;IACvC,yEAAgC;CACjC,CAAA;AAEM,MAAM,qBAAqB,GAAG,CACnC,MAAkE,EACrC,EAAE;;IAC/B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,MAAM,CAAA;IAC5D,MAAM,mBAAmB,GAAG,UA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AC;gBACnD,uGAAuG;gBACvG,MAAM,IAAI,GAAG,YAAY,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;gBACjD,MAAM,sBAAsB,GAAG,MAAM,iBAAiB,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAA,CAAC,UAAU;gBAC/F,YAAY,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAA;gBAC1C,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAA;YAClE,CAAC;YAED,8BAA8B;YAC9B,gBAAgB,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAA;YAE/D,uBAAuB;YACvB,kBAAkB,CAAC,QAAQ,CAAC,GAAG,YAAY,GAAG,CAAC,CAAA;QACjD,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA,CAAA;AAtDY,QAAA,qBAAqB,GAArB,qBAAqB,CAsDjC","sourcesContent":["import { Queue } from '../../utils'\n\nimport { Dictionary } from '../../common'\nimport { ArenaRecordNode } from '../../node'\nimport { NodeDefCountType } from '../../nodeDef'\nimport { Surveys } from '../../survey'\nimport { getNodesByDefUuid } from '../_records/recordGetters'\nimport { updateSelfAndDependentsApplicable } from './recordNodeDependentsApplicableUpdater'\nimport { updateDependentCodeAttributes } from './recordNodeDependentsCodeAttributesUpdater'\nimport { updateDependentsCount } from './recordNodeDependentsCountUpdater'\nimport { updateSelfAndDependentsDefaultValues } from './recordNodeDependentsDefaultValuesUpdater'\nimport { updateSelfAndDependentsEditable } from './recordNodeDependentsEditableUpdater'\nimport { updateDependentEnumeratedEntities } from './recordNodeDependentsEnumeratedEntitiesUpdater'\nimport { updateDependentEnumeratingItemsEntities } from './recordNodeDependentsEnumeratingItemsUpdater'\nimport { updateSelfAndDependentsFileNames } from './recordNodeDependentsFileNamesEvaluator'\nimport { RecordNodeDependentsUpdateParams } from './recordNodeDependentsUpdateParams'\nimport { updateSelfAndDependentsVisible } from './recordNodeDependentsVisibleUpdater'\nimport { NodesUpdateParams } from './recordNodesCreator'\nimport { RecordUpdateResult } from './recordUpdateResult'\n\n/**\n * Nodes can be visited maximum 2 times during the update of the dependent nodes, to avoid loops in the evaluation.\n * The first time the applicability can depend on attributes with default values not applied yet.\n * The second time the applicability expression can be evaluated correctly.\n */\nconst MAX_DEPENDENTS_VISITING_TIMES = 2\n\ntype RecordNodeDependentsUpdater = (params: RecordNodeDependentsUpdateParams) => Promise<RecordUpdateResult>\n\n/**\n * Updaters applied (in this order) to every visited node and to its dependents.\n */\nconst dependentsUpdaters: RecordNodeDependentsUpdater[] = [\n (params) => updateDependentsCount({ ...params, countType: NodeDefCountType.min }),\n (params) => updateDependentsCount({ ...params, countType: NodeDefCountType.max }),\n updateSelfAndDependentsApplicable,\n updateSelfAndDependentsDefaultValues,\n updateSelfAndDependentsEditable,\n updateSelfAndDependentsVisible,\n updateDependentCodeAttributes,\n updateDependentEnumeratedEntities,\n updateDependentEnumeratingItemsEntities,\n updateSelfAndDependentsFileNames,\n]\n\nexport const updateNodesDependents = async (\n params: NodesUpdateParams & { nodes: Dictionary<ArenaRecordNode> }\n): Promise<RecordUpdateResult> => {\n const { survey, record, nodes, sideEffect = false } = params\n const initialNodesToVisit = sideEffect ? nodes : { ...nodes }\n\n // include onUpdate dependents (always included in every record update)\n const onUpdateDependentDefs = Surveys.getOnUpdateDependents({ survey })\n if (onUpdateDependentDefs.length > 0) {\n for (const dependentDef of onUpdateDependentDefs) {\n const dependentNodes = getNodesByDefUuid(dependentDef.uuid)(record)\n for (const node of dependentNodes) {\n initialNodesToVisit[node.uuid] = node\n }\n }\n }\n\n const updateResult = new RecordUpdateResult({ record, nodes: initialNodesToVisit })\n\n const createNodeUpdateParams = (node: ArenaRecordNode): RecordNodeDependentsUpdateParams => ({\n ...params,\n record: updateResult.record, // updateResult.record changes at every step (when sideEffect=false)\n node,\n })\n\n const nodeUuidsToVisit = new Queue(Object.keys(initialNodesToVisit))\n\n // Avoid loops: visit the same node maximum 2 times (the second time the applicability could have been changed)\n const visitedCountByUuid: Dictionary<number> = {}\n\n while (!nodeUuidsToVisit.isEmpty()) {\n const nodeUuid = nodeUuidsToVisit.dequeue()\n\n const visitedCount = visitedCountByUuid[nodeUuid] ?? 0\n\n if (visitedCount < MAX_DEPENDENTS_VISITING_TIMES) {\n const nodesUpdatedCurrent: Dictionary<ArenaRecordNode> = {}\n for (const dependentsUpdater of dependentsUpdaters) {\n // updaters must run sequentially: each one works on the record (and node) updated by the previous ones\n const node = updateResult.getNodeByUuid(nodeUuid)\n const dependentsUpdateResult = await dependentsUpdater(createNodeUpdateParams(node)) // NOSONAR\n updateResult.merge(dependentsUpdateResult)\n Object.assign(nodesUpdatedCurrent, dependentsUpdateResult.nodes)\n }\n\n // Mark updated nodes to visit\n nodeUuidsToVisit.enqueueItems(Object.keys(nodesUpdatedCurrent))\n\n // Mark node as visited\n visitedCountByUuid[nodeUuid] = visitedCount + 1\n }\n }\n\n return updateResult\n}\n"]}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArenaRecordNode, NodesMap } from '../../node';
|
|
2
2
|
import { Validation } from '../../validation';
|
|
3
|
-
import {
|
|
3
|
+
import { ArenaRecord } from '../record';
|
|
4
4
|
import { RecordUpdateOptions } from '../records';
|
|
5
5
|
export declare class RecordUpdateResult {
|
|
6
|
-
record:
|
|
6
|
+
record: ArenaRecord;
|
|
7
7
|
nodes: NodesMap;
|
|
8
8
|
nodesDeleted: NodesMap;
|
|
9
9
|
clearedDefUuids: Set<string>;
|
|
10
10
|
validation?: Validation;
|
|
11
11
|
constructor(params: {
|
|
12
|
-
record:
|
|
12
|
+
record: ArenaRecord;
|
|
13
13
|
nodes?: NodesMap;
|
|
14
14
|
nodesDeleted?: NodesMap;
|
|
15
15
|
clearedDefUuids?: Set<string>;
|
|
16
16
|
validation?: Validation;
|
|
17
17
|
});
|
|
18
|
-
getNodeByUuid(uuid: string):
|
|
19
|
-
addNode(node:
|
|
18
|
+
getNodeByUuid(uuid: string): ArenaRecordNode;
|
|
19
|
+
addNode(node: ArenaRecordNode, options?: RecordUpdateOptions): void;
|
|
20
20
|
addClearedDefUuid(nodeDefUuid: string): void;
|
|
21
21
|
/**
|
|
22
22
|
* Merges this record update result with the specified one.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordUpdateResult.js","sourceRoot":"","sources":["../../../src/record/recordNodesUpdater/recordUpdateResult.ts"],"names":[],"mappings":";;;AAGA,6DAAmD;AAGnD;IAOE,YAAY,MAMX;;QACC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;QAC3B,IAAI,CAAC,KAAK,SAAG,MAAM,CAAC,KAAK,mCAAI,EAAE,CAAA;QAC/B,IAAI,CAAC,YAAY,SAAG,MAAM,CAAC,YAAY,mCAAI,EAAE,CAAA;QAC7C,IAAI,CAAC,eAAe,SAAG,MAAM,CAAC,eAAe,mCAAI,IAAI,GAAG,EAAU,CAAA;QAClE,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAA;IACrC,CAAC;IAED,aAAa,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IAED,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"recordUpdateResult.js","sourceRoot":"","sources":["../../../src/record/recordNodesUpdater/recordUpdateResult.ts"],"names":[],"mappings":";;;AAGA,6DAAmD;AAGnD;IAOE,YAAY,MAMX;;QACC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;QAC3B,IAAI,CAAC,KAAK,SAAG,MAAM,CAAC,KAAK,mCAAI,EAAE,CAAA;QAC/B,IAAI,CAAC,YAAY,SAAG,MAAM,CAAC,YAAY,mCAAI,EAAE,CAAA;QAC7C,IAAI,CAAC,eAAe,SAAG,MAAM,CAAC,eAAe,mCAAI,IAAI,GAAG,EAAU,CAAA;QAClE,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAA;IACrC,CAAC;IAED,aAAa,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IAED,OAAO,CAAC,IAAqB,EAAE,OAA6B;QAC1D,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;QAC5B,IAAI,CAAC,MAAM,GAAG,IAAA,uBAAO,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACnD,CAAC;IAED,iBAAiB,CAAC,WAAmB;QACnC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;IACvC,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,kBAAsC;QAC1C,IAAI,CAAC,MAAM,GAAG,kBAAkB,CAAC,MAAM,CAAA;QACvC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAA;QACnD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAA;QACjE,KAAK,MAAM,WAAW,IAAI,kBAAkB,CAAC,eAAe,EAAE,CAAC;YAC7D,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAA;QACrC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF","sourcesContent":["import { ArenaRecordNode, NodesMap } from '../../node'\nimport { Validation } from '../../validation'\nimport { ArenaRecord } from '../record'\nimport { addNode } from '../_records/recordUpdater'\nimport { RecordUpdateOptions } from '../records'\n\nexport class RecordUpdateResult {\n record: ArenaRecord\n nodes: NodesMap\n nodesDeleted: NodesMap\n clearedDefUuids: Set<string>\n validation?: Validation\n\n constructor(params: {\n record: ArenaRecord\n nodes?: NodesMap\n nodesDeleted?: NodesMap\n clearedDefUuids?: Set<string>\n validation?: Validation\n }) {\n this.record = params.record\n this.nodes = params.nodes ?? {}\n this.nodesDeleted = params.nodesDeleted ?? {}\n this.clearedDefUuids = params.clearedDefUuids ?? new Set<string>()\n this.validation = params.validation\n }\n\n getNodeByUuid(uuid: string) {\n return this.nodes[uuid]\n }\n\n addNode(node: ArenaRecordNode, options?: RecordUpdateOptions) {\n this.nodes[node.uuid] = node\n this.record = addNode(node, options)(this.record)\n }\n\n addClearedDefUuid(nodeDefUuid: string) {\n this.clearedDefUuids.add(nodeDefUuid)\n }\n\n /**\n * Merges this record update result with the specified one.\n * The record of this record update result will be the one of the specified record update result\n * and the nodes of the specified one will be added to the nodes of this one.\n *\n * @param {!RecordUpdateResult} recordUpdateResult - The record update result to merge with.\n * @returns {RecordUpdateResult} - The updated object.\n */\n merge(recordUpdateResult: RecordUpdateResult): this {\n this.record = recordUpdateResult.record\n Object.assign(this.nodes, recordUpdateResult.nodes)\n Object.assign(this.nodesDeleted, recordUpdateResult.nodesDeleted)\n for (const nodeDefUuid of recordUpdateResult.clearedDefUuids) {\n this.addClearedDefUuid(nodeDefUuid)\n }\n return this\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Dictionary } from '../common';
|
|
2
|
-
import {
|
|
2
|
+
import { ArenaRecordNode } from '../node';
|
|
3
3
|
import { Survey } from '../survey';
|
|
4
|
-
import {
|
|
4
|
+
import { ArenaRecord } from './record';
|
|
5
5
|
type PrintOptions = {
|
|
6
6
|
includeEmptyNodes?: boolean;
|
|
7
7
|
showNotApplicable?: boolean;
|
|
@@ -10,18 +10,18 @@ type PrintOptions = {
|
|
|
10
10
|
};
|
|
11
11
|
declare const print: (params: {
|
|
12
12
|
survey: Survey;
|
|
13
|
-
record:
|
|
13
|
+
record: ArenaRecord;
|
|
14
14
|
options?: PrintOptions;
|
|
15
15
|
}) => string;
|
|
16
16
|
declare const printNodePath: (params: {
|
|
17
17
|
survey: Survey;
|
|
18
|
-
record:
|
|
19
|
-
node:
|
|
18
|
+
record: ArenaRecord;
|
|
19
|
+
node: ArenaRecordNode;
|
|
20
20
|
}) => string;
|
|
21
21
|
declare const printNodesPaths: (params: {
|
|
22
22
|
survey: Survey;
|
|
23
|
-
record:
|
|
24
|
-
nodes: Dictionary<
|
|
23
|
+
record: ArenaRecord;
|
|
24
|
+
nodes: Dictionary<ArenaRecordNode>;
|
|
25
25
|
}) => string[];
|
|
26
26
|
export declare const RecordPrettyPrinter: {
|
|
27
27
|
print: typeof print;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordPrettyPrinter.js","sourceRoot":"","sources":["../../src/record/recordPrettyPrinter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAsD;AACtD,kCAAyD;AACzD,wCAAqC;AACrC,sCAA2C;AAC3C,oCAAkC;AAElC,MAAY,aAAa,qDAAgC;AASzD,MAAM,mBAAmB,GAAiB;IACxC,iBAAiB,EAAE,KAAK;IACxB,iBAAiB,EAAE,KAAK;IACxB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,KAAK;CACtB,CAAA;AAED,MAAM,KAAK,GAAG,CAAC,MAAkE,EAAU,EAAE;IAC3F,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,mBAAmB,EAAE,GAAG,MAAM,CAAA;IAChE,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,OAAO,CAAA;IAEzF,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC5C,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAC9C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,EAAE,CAAA;IACX,CAAC;IAED,MAAM,YAAY,GAAG,CAAC,MAA0D,EAAY,EAAE;QAC5F,MAAM,EAAE,UAAU,EAAE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MAAM,CAAA;IACxC,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAA,mBAAmB,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AACxG,CAAC,CAAA;AAEY,QAAA,mBAAmB,GAAG;IACjC,KAAK;IACL,aAAa;IACb,eAAe;CAChB,CAAA","sourcesContent":["import { Dictionary, TraverseMethod } from '../common'\nimport { Node, NodeValueFormatter, Nodes } from '../node'\nimport { NodeDefs } from '../nodeDef'\nimport { Survey, Surveys } from '../survey'\nimport { Strings } from '../utils'\nimport { Record } from './record'\nimport * as RecordGetters from './_records/recordGetters'\n\ntype PrintOptions = {\n includeEmptyNodes?: boolean\n showNotApplicable?: boolean\n showNotEditable?: boolean\n showNotVisible?: boolean\n}\n\nconst DefaultPrintOptions: PrintOptions = {\n includeEmptyNodes: false,\n showNotApplicable: false,\n showNotEditable: false,\n showNotVisible: false,\n}\n\nconst print = (params: { survey: Survey; record: Record; options?: PrintOptions }): string => {\n const { survey, record, options = DefaultPrintOptions } = params\n const { includeEmptyNodes, showNotApplicable, showNotEditable, showNotVisible } = options\n\n const cycle = RecordGetters.getCycle(record)\n const rootNode = RecordGetters.getRoot(record)\n if (!rootNode) {\n return ''\n }\n\n const getInfoParts = (params: { parentNode?: Node | null; childDefUuid: string }): string[] => {\n const { parentNode, childDefUuid } = params\n if (!parentNode) {\n return []\n }\n const infoParts: string[] = []\n if (showNotApplicable && !Nodes.isChildApplicable(parentNode, childDefUuid)) {\n infoParts.push('not applicable')\n }\n if (showNotEditable && !Nodes.isChildEditable(parentNode, childDefUuid)) {\n infoParts.push('not editable')\n }\n if (showNotVisible && !Nodes.isChildVisible(parentNode, childDefUuid)) {\n infoParts.push('not visible')\n }\n return infoParts\n }\n\n const toPart = (params: { depth: number; name: string; value: string; infoParts?: string[] }): string => {\n const { depth, name, value, infoParts = [] } = params\n const indentation = Strings.repeat(' ', depth)\n let part = `${indentation}${name}: ${value}`\n if (infoParts.length > 0) {\n part += ` (${infoParts.join(', ')})`\n }\n return part\n }\n\n const parts: string[] = []\n\n if (includeEmptyNodes) {\n const printNodeAndChildren = (params: { node: Node; parentNode: Node | null }): void => {\n const { node, parentNode } = params\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid })\n const value = NodeValueFormatter.format({ survey, cycle, nodeDef, node, value: node.value })\n const depth = Nodes.getHierarchy(node).length\n const infoParts = getInfoParts({ parentNode, childDefUuid: node.nodeDefUuid })\n parts.push(toPart({ depth, name: NodeDefs.getName(nodeDef), value, infoParts }))\n\n const childDefs = Surveys.getNodeDefChildrenSorted({ survey, nodeDef, cycle })\n childDefs.forEach((childDef) => {\n const children = RecordGetters.getChildren(node, childDef.uuid)(record)\n if (children.length === 0) {\n const childInfoParts = getInfoParts({ parentNode: node, childDefUuid: childDef.uuid })\n parts.push(\n toPart({\n depth: depth + 1,\n name: NodeDefs.getName(childDef),\n value: '<empty>',\n infoParts: childInfoParts,\n })\n )\n return\n }\n children.forEach((child) => printNodeAndChildren({ node: child, parentNode: node }))\n })\n }\n\n printNodeAndChildren({ node: rootNode, parentNode: null })\n return parts.join('\\n')\n }\n\n RecordGetters.visitDescendantsAndSelf({\n record,\n node: rootNode,\n visitor: (node) => {\n const { nodeDefUuid } = node\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: nodeDefUuid })\n const value = NodeValueFormatter.format({ survey, cycle, nodeDef, node, value: node.value })\n const depth = Nodes.getHierarchy(node).length\n const parentNode = NodeDefs.isRoot(nodeDef) ? null : RecordGetters.getParent(node)(record)\n const infoParts = getInfoParts({ parentNode, childDefUuid: nodeDefUuid })\n parts.push(toPart({ depth, name: NodeDefs.getName(nodeDef), value, infoParts }))\n return false\n },\n traverseMethod: TraverseMethod.dfs,\n })\n return parts.join('\\n')\n}\n\nconst printNodePath = (params: { survey: Survey; record: Record; node: Node }): string => {\n const { survey, record, node } = params\n const parts: string[] = []\n RecordGetters.visitAncestorsAndSelf(node, (visitedNode) => {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: visitedNode.nodeDefUuid })\n let part = NodeDefs.getName(nodeDef)\n if (NodeDefs.isMultiple(nodeDef)) {\n const index = RecordGetters.getNodeIndex({ record, node: visitedNode })\n part = `${part}[${index}]`\n }\n parts.unshift(part)\n })(record)\n return parts.join('.')\n}\n\nconst printNodesPaths = (params: { survey: Survey; record: Record; nodes: Dictionary<Node> }): string[] => {\n const { survey, record, nodes } = params\n return Object.values(nodes).map((node) => RecordPrettyPrinter.printNodePath({ survey, record, node }))\n}\n\nexport const RecordPrettyPrinter = {\n print,\n printNodePath,\n printNodesPaths,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"recordPrettyPrinter.js","sourceRoot":"","sources":["../../src/record/recordPrettyPrinter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAsD;AACtD,kCAAoE;AACpE,wCAAqC;AACrC,sCAA2C;AAC3C,oCAAkC;AAElC,MAAY,aAAa,qDAAgC;AASzD,MAAM,mBAAmB,GAAiB;IACxC,iBAAiB,EAAE,KAAK;IACxB,iBAAiB,EAAE,KAAK;IACxB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,KAAK;CACtB,CAAA;AAED,MAAM,KAAK,GAAG,CAAC,MAAuE,EAAU,EAAE;IAChG,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,mBAAmB,EAAE,GAAG,MAAM,CAAA;IAChE,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,OAAO,CAAA;IAEzF,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC5C,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAC9C,IAAI,C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AC,CAAA;AACxB,CAAC,CAAA;AAED,MAAM,eAAe,GAAG,CAAC,MAIxB,EAAY,EAAE;IACb,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IACxC,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAA,mBAAmB,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AACxG,CAAC,CAAA;AAEY,QAAA,mBAAmB,GAAG;IACjC,KAAK;IACL,aAAa;IACb,eAAe;CAChB,CAAA","sourcesContent":["import { Dictionary, TraverseMethod } from '../common'\nimport { ArenaRecordNode, NodeValueFormatter, Nodes } from '../node'\nimport { NodeDefs } from '../nodeDef'\nimport { Survey, Surveys } from '../survey'\nimport { Strings } from '../utils'\nimport { ArenaRecord } from './record'\nimport * as RecordGetters from './_records/recordGetters'\n\ntype PrintOptions = {\n includeEmptyNodes?: boolean\n showNotApplicable?: boolean\n showNotEditable?: boolean\n showNotVisible?: boolean\n}\n\nconst DefaultPrintOptions: PrintOptions = {\n includeEmptyNodes: false,\n showNotApplicable: false,\n showNotEditable: false,\n showNotVisible: false,\n}\n\nconst print = (params: { survey: Survey; record: ArenaRecord; options?: PrintOptions }): string => {\n const { survey, record, options = DefaultPrintOptions } = params\n const { includeEmptyNodes, showNotApplicable, showNotEditable, showNotVisible } = options\n\n const cycle = RecordGetters.getCycle(record)\n const rootNode = RecordGetters.getRoot(record)\n if (!rootNode) {\n return ''\n }\n\n const getInfoParts = (params: { parentNode?: ArenaRecordNode | null; childDefUuid: string }): string[] => {\n const { parentNode, childDefUuid } = params\n if (!parentNode) {\n return []\n }\n const infoParts: string[] = []\n if (showNotApplicable && !Nodes.isChildApplicable(parentNode, childDefUuid)) {\n infoParts.push('not applicable')\n }\n if (showNotEditable && !Nodes.isChildEditable(parentNode, childDefUuid)) {\n infoParts.push('not editable')\n }\n if (showNotVisible && !Nodes.isChildVisible(parentNode, childDefUuid)) {\n infoParts.push('not visible')\n }\n return infoParts\n }\n\n const toPart = (params: { depth: number; name: string; value: string; infoParts?: string[] }): string => {\n const { depth, name, value, infoParts = [] } = params\n const indentation = Strings.repeat(' ', depth)\n let part = `${indentation}${name}: ${value}`\n if (infoParts.length > 0) {\n part += ` (${infoParts.join(', ')})`\n }\n return part\n }\n\n const parts: string[] = []\n\n if (includeEmptyNodes) {\n const printNodeAndChildren = (params: { node: ArenaRecordNode; parentNode: ArenaRecordNode | null }): void => {\n const { node, parentNode } = params\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid })\n const value = NodeValueFormatter.format({ survey, cycle, nodeDef, node, value: node.value })\n const depth = Nodes.getHierarchy(node).length\n const infoParts = getInfoParts({ parentNode, childDefUuid: node.nodeDefUuid })\n parts.push(toPart({ depth, name: NodeDefs.getName(nodeDef), value, infoParts }))\n\n const childDefs = Surveys.getNodeDefChildrenSorted({ survey, nodeDef, cycle })\n childDefs.forEach((childDef) => {\n const children = RecordGetters.getChildren(node, childDef.uuid)(record)\n if (children.length === 0) {\n const childInfoParts = getInfoParts({ parentNode: node, childDefUuid: childDef.uuid })\n parts.push(\n toPart({\n depth: depth + 1,\n name: NodeDefs.getName(childDef),\n value: '<empty>',\n infoParts: childInfoParts,\n })\n )\n return\n }\n children.forEach((child) => printNodeAndChildren({ node: child, parentNode: node }))\n })\n }\n\n printNodeAndChildren({ node: rootNode, parentNode: null })\n return parts.join('\\n')\n }\n\n RecordGetters.visitDescendantsAndSelf({\n record,\n node: rootNode,\n visitor: (node) => {\n const { nodeDefUuid } = node\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: nodeDefUuid })\n const value = NodeValueFormatter.format({ survey, cycle, nodeDef, node, value: node.value })\n const depth = Nodes.getHierarchy(node).length\n const parentNode = NodeDefs.isRoot(nodeDef) ? null : RecordGetters.getParent(node)(record)\n const infoParts = getInfoParts({ parentNode, childDefUuid: nodeDefUuid })\n parts.push(toPart({ depth, name: NodeDefs.getName(nodeDef), value, infoParts }))\n return false\n },\n traverseMethod: TraverseMethod.dfs,\n })\n return parts.join('\\n')\n}\n\nconst printNodePath = (params: { survey: Survey; record: ArenaRecord; node: ArenaRecordNode }): string => {\n const { survey, record, node } = params\n const parts: string[] = []\n RecordGetters.visitAncestorsAndSelf(node, (visitedNode) => {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: visitedNode.nodeDefUuid })\n let part = NodeDefs.getName(nodeDef)\n if (NodeDefs.isMultiple(nodeDef)) {\n const index = RecordGetters.getNodeIndex({ record, node: visitedNode })\n part = `${part}[${index}]`\n }\n parts.unshift(part)\n })(record)\n return parts.join('.')\n}\n\nconst printNodesPaths = (params: {\n survey: Survey\n record: ArenaRecord\n nodes: Dictionary<ArenaRecordNode>\n}): string[] => {\n const { survey, record, nodes } = params\n return Object.values(nodes).map((node) => RecordPrettyPrinter.printNodePath({ survey, record, node }))\n}\n\nexport const RecordPrettyPrinter = {\n print,\n printNodePath,\n printNodesPaths,\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordUpdater.js","sourceRoot":"","sources":["../../src/record/recordUpdater.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,oCAAsC;AAEtC,sCAAiE;AACjE,oCAAyC;AACzC,2DAAuD;AACvD,iDAA6C;AAE7C,6DAA6E;AAE7E,uCAAmC;AACnC,uDAAmD;AAEnD,MAAM,yBAAyB,GAAG;IAChC,6BAAoB,CAAC,WAAW;IAChC,6BAAoB,CAAC,QAAQ;IAC7B,6BAAoB,CAAC,QAAQ;CAC9B,CAAA;AAED,MAAM,kCAAkC,GAAG,CAAC,MAI3C,EAAiB,EAAE;IAClB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IACxC,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAuB,CAAA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AAG,iBAAO,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,CAAA;IAEzE,OAAO,4BAA4B,iCAAM,MAAM,KAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,IAAG,CAAA;AAC1F,CAAC,CAAA,CAAA;AAED,MAAM,WAAW,GAAG,CAClB,MAEC,EAC4B,EAAE;IAC/B,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,MAAM,CAAA;IAEjE,MAAM,YAAY,GAAG,iBAAO,CAAC,WAAW,CAAC,SAAS,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,CAAA;IAC5E,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,YAAY,CAAA;IAE7C,MAAM,MAAM,GAAG,MAAM,4BAA4B,iCAAM,MAAM,KAAE,MAAM,EAAE,KAAK,EAAE,YAAY,IAAG,CAAA;IAC7F,MAAM,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,OAAO,MAAM,CAAA;AACf,CAAC,CAAA,CAAA;AAED,MAAM,UAAU,GAAG,CAAO,MAAgD,EAA+B,EAAE;IACzG,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;IAC3B,OAAO,WAAW,iCAAM,MAAM,KAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,IAAG,CAAA;AAC1D,CAAC,CAAA,CAAA;AAEY,QAAA,aAAa,GAAG;IAC3B,iBAAiB;IACjB,wBAAwB;IACxB,gBAAgB;IAChB,oBAAoB;IACpB,UAAU;IACV,WAAW;CACZ,CAAA","sourcesContent":["import { Dictionary } from '../common'\nimport { SystemError } from '../error'\nimport { Node, NodePointer, NodesMap } from '../node'\nimport { Survey, SurveyDependencyType, Surveys } from '../survey'\nimport { Dates, Objects } from '../utils'\nimport { Validations } from '../validation/validations'\nimport { NodePointers } from './nodePointers'\nimport { Record } from './record'\nimport { RecordNodesUpdater, RecordUpdateResult } from './recordNodesUpdater'\nimport { NodeCreateParams, NodesUpdateParams } from './recordNodesUpdater/recordNodesCreator'\nimport { Records } from './records'\nimport { RecordValidator } from './recordValidator'\n\nconst validationDependencyTypes = [\n SurveyDependencyType.validations,\n SurveyDependencyType.minCount,\n SurveyDependencyType.maxCount,\n]\n\nconst getDependentValidationNodePointers = (params: {\n survey: Survey\n record: Record\n nodes: NodesMap\n}): NodePointer[] => {\n const { survey, record, nodes } = params\n const uniquePointersByKey = new Map<string, NodePointer>()\n for (const node of Object.values(nodes)) {\n for (const dependencyType of validationDependencyTypes) {\n const nodePointers = Records.getDependentNodePointers({ survey, record, node, dependencyType })\n for (const pointer of nodePointers) {\n const nodeCtxUuid = pointer.nodeCtx.uuid\n const nodeDefUuid = pointer.nodeDef.uuid\n const key = `${nodeCtxUuid ?? ''}:${nodeDefUuid ?? ''}`\n if (!uniquePointersByKey.has(key)) {\n uniquePointersByKey.set(key, pointer)\n }\n }\n }\n }\n return Array.from(uniquePointersByKey.values())\n}\n\nconst _onRecordNodesCreateOrUpdate = async (\n params: NodesUpdateParams & { nodes: Dictionary<Node> }\n): Promise<RecordUpdateResult> => {\n const { user, survey, dateModified = Dates.nowFormattedForStorage() } = params\n\n const updateResult = await RecordNodesUpdater.updateNodesDependents(params)\n const { nodes: updatedNodes, record: updatedRecord } = updateResult\n\n const dependentValidationNodePointers = getDependentValidationNodePointers({\n survey,\n record: updatedRecord,\n nodes: updatedNodes,\n })\n\n const dependentValidationNodes = NodePointers.getNodesMapFromNodePointers({\n record: updatedRecord,\n nodePointers: dependentValidationNodePointers,\n })\n\n const nodesToValidate = { ...updatedNodes, ...dependentValidationNodes }\n\n const validationUpdatedNodes = await RecordValidator.validateNodes({\n user,\n survey,\n record: updatedRecord,\n nodes: nodesToValidate,\n })\n\n const validation = Validations.mergeValidations(validationUpdatedNodes)(Validations.getValidation(updatedRecord))\n updatedRecord.validation = validation\n updatedRecord.dateModified = dateModified\n\n updateResult.validation = validation\n\n return updateResult\n}\n\nconst createDescendants = async (params: NodeCreateParams): Promise<RecordUpdateResult> => {\n const { record: updatedRecord, nodes: createdNodes } = await RecordNodesUpdater.createDescendants(params)\n\n return _onRecordNodesCreateOrUpdate({ ...params, record: updatedRecord, nodes: createdNodes })\n}\n\nconst _createNodeAndDescendants = async (params: NodeCreateParams): Promise<RecordUpdateResult> => {\n const { record: updatedRecord, nodes: createdNodes } = await RecordNodesUpdater.createNodeAndDescendants(params)\n\n return _onRecordNodesCreateOrUpdate({ ...params, record: updatedRecord, nodes: createdNodes })\n}\n\nconst createNodeAndDescendants = async (params: NodeCreateParams): Promise<RecordUpdateResult> =>\n _createNodeAndDescendants(params)\n\nconst createRootEntity = async (\n params: NodesUpdateParams & {\n createMultipleEntities?: boolean\n }\n): Promise<RecordUpdateResult> => {\n const { survey, createMultipleEntities = true } = params\n\n return _createNodeAndDescendants({ ...params, nodeDef: Surveys.getNodeDefRoot({ survey }), createMultipleEntities })\n}\n\nconst updateAttributeValue = async (\n params: NodesUpdateParams & {\n attributeUuid: string\n value: any\n }\n): Promise<RecordUpdateResult> => {\n const { attributeUuid, record, value, dateModified = Dates.nowFormattedForStorage(), sideEffect = false } = params\n const attribute = Records.getNodeByUuid(attributeUuid)(record)\n if (!attribute) throw new SystemError('record.nodeNotFound')\n\n let attributeUpdated = sideEffect ? attribute : { ...attribute }\n attributeUpdated.value = value\n attributeUpdated.dateModified = dateModified\n // reset defaultValueApplied flag\n attributeUpdated = Objects.dissocPath({ obj: attributeUpdated, path: ['meta', 'defaultValueApplied'], sideEffect })\n\n const nodesUpdated = { [attributeUuid]: attributeUpdated }\n\n const _record = Records.addNode(attributeUpdated, { sideEffect })(record)\n\n return _onRecordNodesCreateOrUpdate({ ...params, record: _record, nodes: nodesUpdated })\n}\n\nconst deleteNodes = async (\n params: NodesUpdateParams & {\n nodeUuids: string[]\n }\n): Promise<RecordUpdateResult> => {\n const { nodeUuids, record: _record, sideEffect = false } = params\n\n const updateResult = Records.deleteNodes(nodeUuids, { sideEffect })(_record)\n const { record, nodesDeleted } = updateResult\n\n const result = await _onRecordNodesCreateOrUpdate({ ...params, record, nodes: nodesDeleted })\n result.nodesDeleted = nodesDeleted\n return result\n}\n\nconst deleteNode = async (params: NodesUpdateParams & { nodeUuid: string }): Promise<RecordUpdateResult> => {\n const { nodeUuid } = params\n return deleteNodes({ ...params, nodeUuids: [nodeUuid] })\n}\n\nexport const RecordUpdater = {\n createDescendants,\n createNodeAndDescendants,\n createRootEntity,\n updateAttributeValue,\n deleteNode,\n deleteNodes,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"recordUpdater.js","sourceRoot":"","sources":["../../src/record/recordUpdater.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,oCAAsC;AAEtC,sCAAiE;AACjE,oCAAyC;AACzC,2DAAuD;AACvD,iDAA6C;AAE7C,6DAA6E;AAE7E,uCAAmC;AACnC,uDAAmD;AAEnD,MAAM,yBAAyB,GAAG;IAChC,6BAAoB,CAAC,WAAW;IAChC,6BAAoB,CAAC,QAAQ;IAC7B,6BAAoB,CAAC,QAAQ;CAC9B,CAAA;AAED,MAAM,kCAAkC,GAAG,CAAC,MAI3C,EAAiB,EAAE;IAClB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IACxC,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAuB,CAAA;IAC1D,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACxC,KAAK,MAAM,cAAc,IAAI,yBAAyB,EAAE,CAAC;YACvD,MAAM,YAAY,GAAG,iBAAO,CAAC,wBAAwB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAA;YAC/F,KAAK,MAAM,OAAO,IAAI,YAAY,EAAE,CAAC;gBACnC,MAAM,WAAW,GAAG,OAAO,CAAC,OAA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GAAG,MAAM,CAAA;IAEjE,MAAM,YAAY,GAAG,iBAAO,CAAC,WAAW,CAAC,SAAS,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,CAAA;IAC5E,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,YAAY,CAAA;IAE7C,MAAM,MAAM,GAAG,MAAM,4BAA4B,iCAAM,MAAM,KAAE,MAAM,EAAE,KAAK,EAAE,YAAY,IAAG,CAAA;IAC7F,MAAM,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,OAAO,MAAM,CAAA;AACf,CAAC,CAAA,CAAA;AAED,MAAM,UAAU,GAAG,CAAO,MAAgD,EAA+B,EAAE;IACzG,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;IAC3B,OAAO,WAAW,iCAAM,MAAM,KAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,IAAG,CAAA;AAC1D,CAAC,CAAA,CAAA;AAEY,QAAA,aAAa,GAAG;IAC3B,iBAAiB;IACjB,wBAAwB;IACxB,gBAAgB;IAChB,oBAAoB;IACpB,UAAU;IACV,WAAW;CACZ,CAAA","sourcesContent":["import { Dictionary } from '../common'\nimport { SystemError } from '../error'\nimport { ArenaRecordNode, NodePointer, NodesMap } from '../node'\nimport { Survey, SurveyDependencyType, Surveys } from '../survey'\nimport { Dates, Objects } from '../utils'\nimport { Validations } from '../validation/validations'\nimport { NodePointers } from './nodePointers'\nimport { ArenaRecord } from './record'\nimport { RecordNodesUpdater, RecordUpdateResult } from './recordNodesUpdater'\nimport { NodeCreateParams, NodesUpdateParams } from './recordNodesUpdater/recordNodesCreator'\nimport { Records } from './records'\nimport { RecordValidator } from './recordValidator'\n\nconst validationDependencyTypes = [\n SurveyDependencyType.validations,\n SurveyDependencyType.minCount,\n SurveyDependencyType.maxCount,\n]\n\nconst getDependentValidationNodePointers = (params: {\n survey: Survey\n record: ArenaRecord\n nodes: NodesMap\n}): NodePointer[] => {\n const { survey, record, nodes } = params\n const uniquePointersByKey = new Map<string, NodePointer>()\n for (const node of Object.values(nodes)) {\n for (const dependencyType of validationDependencyTypes) {\n const nodePointers = Records.getDependentNodePointers({ survey, record, node, dependencyType })\n for (const pointer of nodePointers) {\n const nodeCtxUuid = pointer.nodeCtx.uuid\n const nodeDefUuid = pointer.nodeDef.uuid\n const key = `${nodeCtxUuid ?? ''}:${nodeDefUuid ?? ''}`\n if (!uniquePointersByKey.has(key)) {\n uniquePointersByKey.set(key, pointer)\n }\n }\n }\n }\n return Array.from(uniquePointersByKey.values())\n}\n\nconst _onRecordNodesCreateOrUpdate = async (\n params: NodesUpdateParams & { nodes: Dictionary<ArenaRecordNode> }\n): Promise<RecordUpdateResult> => {\n const { user, survey, dateModified = Dates.nowFormattedForStorage() } = params\n\n const updateResult = await RecordNodesUpdater.updateNodesDependents(params)\n const { nodes: updatedNodes, record: updatedRecord } = updateResult\n\n const dependentValidationNodePointers = getDependentValidationNodePointers({\n survey,\n record: updatedRecord,\n nodes: updatedNodes,\n })\n\n const dependentValidationNodes = NodePointers.getNodesMapFromNodePointers({\n record: updatedRecord,\n nodePointers: dependentValidationNodePointers,\n })\n\n const nodesToValidate = { ...updatedNodes, ...dependentValidationNodes }\n\n const validationUpdatedNodes = await RecordValidator.validateNodes({\n user,\n survey,\n record: updatedRecord,\n nodes: nodesToValidate,\n })\n\n const validation = Validations.mergeValidations(validationUpdatedNodes)(Validations.getValidation(updatedRecord))\n updatedRecord.validation = validation\n updatedRecord.dateModified = dateModified\n\n updateResult.validation = validation\n\n return updateResult\n}\n\nconst createDescendants = async (params: NodeCreateParams): Promise<RecordUpdateResult> => {\n const { record: updatedRecord, nodes: createdNodes } = await RecordNodesUpdater.createDescendants(params)\n\n return _onRecordNodesCreateOrUpdate({ ...params, record: updatedRecord, nodes: createdNodes })\n}\n\nconst _createNodeAndDescendants = async (params: NodeCreateParams): Promise<RecordUpdateResult> => {\n const { record: updatedRecord, nodes: createdNodes } = await RecordNodesUpdater.createNodeAndDescendants(params)\n\n return _onRecordNodesCreateOrUpdate({ ...params, record: updatedRecord, nodes: createdNodes })\n}\n\nconst createNodeAndDescendants = async (params: NodeCreateParams): Promise<RecordUpdateResult> =>\n _createNodeAndDescendants(params)\n\nconst createRootEntity = async (\n params: NodesUpdateParams & {\n createMultipleEntities?: boolean\n }\n): Promise<RecordUpdateResult> => {\n const { survey, createMultipleEntities = true } = params\n\n return _createNodeAndDescendants({ ...params, nodeDef: Surveys.getNodeDefRoot({ survey }), createMultipleEntities })\n}\n\nconst updateAttributeValue = async (\n params: NodesUpdateParams & {\n attributeUuid: string\n value: any\n }\n): Promise<RecordUpdateResult> => {\n const { attributeUuid, record, value, dateModified = Dates.nowFormattedForStorage(), sideEffect = false } = params\n const attribute = Records.getNodeByUuid(attributeUuid)(record)\n if (!attribute) throw new SystemError('record.nodeNotFound')\n\n let attributeUpdated = sideEffect ? attribute : { ...attribute }\n attributeUpdated.value = value\n attributeUpdated.dateModified = dateModified\n // reset defaultValueApplied flag\n attributeUpdated = Objects.dissocPath({ obj: attributeUpdated, path: ['meta', 'defaultValueApplied'], sideEffect })\n\n const nodesUpdated = { [attributeUuid]: attributeUpdated }\n\n const _record = Records.addNode(attributeUpdated, { sideEffect })(record)\n\n return _onRecordNodesCreateOrUpdate({ ...params, record: _record, nodes: nodesUpdated })\n}\n\nconst deleteNodes = async (\n params: NodesUpdateParams & {\n nodeUuids: string[]\n }\n): Promise<RecordUpdateResult> => {\n const { nodeUuids, record: _record, sideEffect = false } = params\n\n const updateResult = Records.deleteNodes(nodeUuids, { sideEffect })(_record)\n const { record, nodesDeleted } = updateResult\n\n const result = await _onRecordNodesCreateOrUpdate({ ...params, record, nodes: nodesDeleted })\n result.nodesDeleted = nodesDeleted\n return result\n}\n\nconst deleteNode = async (params: NodesUpdateParams & { nodeUuid: string }): Promise<RecordUpdateResult> => {\n const { nodeUuid } = params\n return deleteNodes({ ...params, nodeUuids: [nodeUuid] })\n}\n\nexport const RecordUpdater = {\n createDescendants,\n createNodeAndDescendants,\n createRootEntity,\n updateAttributeValue,\n deleteNode,\n deleteNodes,\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArenaRecord } from '../record';
|
|
2
2
|
import { NodeDef, NodeDefProps, NodeDefType } from '../../nodeDef';
|
|
3
|
-
import {
|
|
3
|
+
import { ArenaRecordNode } from '../../node';
|
|
4
4
|
import { ValidationResult } from '../../validation';
|
|
5
5
|
import { Survey } from '../../survey';
|
|
6
6
|
import { Dictionary } from '../../common';
|
|
@@ -15,10 +15,10 @@ export type EntityKeysCache = {
|
|
|
15
15
|
export declare const createEntityKeysCache: () => EntityKeysCache;
|
|
16
16
|
declare const validateAttributeKey: (params: {
|
|
17
17
|
survey: Survey;
|
|
18
|
-
record:
|
|
18
|
+
record: ArenaRecord;
|
|
19
19
|
nodeDef: NodeDef<NodeDefType, NodeDefProps>;
|
|
20
20
|
entityKeysCache?: EntityKeysCache;
|
|
21
|
-
}) => (_propName: string, node:
|
|
21
|
+
}) => (_propName: string, node: ArenaRecordNode) => Promise<ValidationResult>;
|
|
22
22
|
export declare const AttributeKeyValidator: {
|
|
23
23
|
validateAttributeKey: typeof validateAttributeKey;
|
|
24
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributeKeyValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/attributeKeyValidator.ts"],"names":[],"mappings":";;;AACA,wCAAoC;AACpC,2CAA4E;AAC5E,
|
|
1
|
+
{"version":3,"file":"attributeKeyValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/attributeKeyValidator.ts"],"names":[],"mappings":";;;AACA,wCAAoC;AACpC,2CAA4E;AAC5E,qCAA+D;AAC/D,iDAAgG;AAChG,yCAA8C;AAG9C,uCAAqC;AAW9B,MAAM,qBAAqB,GAAG,GAAoB,EAAE,CAAC,CAAC;IAC3D,sBAAsB,EAAE,IAAI,GAAG,EAAE;IACjC,qBAAqB,EAAE,I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AAE,CAAC,EAAE,CAAC;YAC9E,OAAO,OAAO,CAAC,OAAO,CACpB,oCAAuB,CAAC,cAAc,CAAC;gBACrC,KAAK,EAAE,KAAK;gBACZ,QAAQ,EAAE,+BAAkB,CAAC,KAAK;gBAClC,GAAG,EAAE,4BAA4B;aAClC,CAAC,CACH,CAAA;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,oCAAuB,CAAC,cAAc,EAAE,CAAC,CAAA;AAClE,CAAC,CAAA;AAEU,QAAA,qBAAqB,GAAG;IACnC,oBAAoB;CACrB,CAAA","sourcesContent":["import { ArenaRecord } from '../record'\nimport { Records } from '../records'\nimport { NodeDef, NodeDefs, NodeDefProps, NodeDefType } from '../../nodeDef'\nimport { ArenaRecordNode, Nodes, NodeValues } from '../../node'\nimport { ValidationResult, ValidationResultFactory, ValidationSeverity } from '../../validation'\nimport { Survey, Surveys } from '../../survey'\n\nimport { Dictionary } from '../../common'\nimport { Objects } from '../../utils'\n\n/**\n * Cache of entity key values (and key defs by entity def) used during a single validation run (the record doesn't change):\n * without it, validating the keys of S sibling entities would compute the key values of every sibling S times.\n */\nexport type EntityKeysCache = {\n keyDefsByEntityDefUuid: Map<string, NodeDef<NodeDefType, NodeDefProps>[]>\n keyValuesByEntityUuid: Map<string, Dictionary<any>>\n}\n\nexport const createEntityKeysCache = (): EntityKeysCache => ({\n keyDefsByEntityDefUuid: new Map(),\n keyValuesByEntityUuid: new Map(),\n})\n\nconst _getKeyDefs = (params: {\n survey: Survey\n entityDef: NodeDef<NodeDefType, NodeDefProps>\n cache?: EntityKeysCache\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey, entityDef, cache } = params\n let keyDefs = cache?.keyDefsByEntityDefUuid.get(entityDef.uuid)\n if (!keyDefs) {\n keyDefs = Surveys.getNodeDefKeys({ survey, nodeDef: entityDef })\n cache?.keyDefsByEntityDefUuid.set(entityDef.uuid, keyDefs)\n }\n return keyDefs\n}\n\nconst _getKeyValuesByDefUuid = (params: {\n survey: Survey\n record: ArenaRecord\n entity: ArenaRecordNode\n keyDefs: NodeDef<NodeDefType, NodeDefProps>[]\n cache?: EntityKeysCache\n}): Dictionary<any> => {\n const { survey, record, entity, keyDefs, cache } = params\n let keyValues = cache?.keyValuesByEntityUuid.get(entity.uuid)\n if (!keyValues) {\n keyValues = Records.getEntityKeyValuesByDefUuid({ survey, record, entity, keyDefs })\n cache?.keyValuesByEntityUuid.set(entity.uuid, keyValues)\n }\n return keyValues\n}\n\nconst _isEntityDuplicate = (params: {\n survey: Survey\n record: ArenaRecord\n entity: ArenaRecordNode\n entityKeysCache?: EntityKeysCache\n}): boolean => {\n const { survey, entity, record, entityKeysCache: cache } = params\n // 1. get sibling entities\n const nodeParent = Records.getParent(entity)(record)\n if (!nodeParent) return false\n\n const siblingEntities = Records.getChildren(\n nodeParent,\n entity.nodeDefUuid\n )(record).filter((node) => !Nodes.areEqual(entity, node))\n\n // 2. get key values\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const keyDefs = _getKeyDefs({ survey, entityDef, cache })\n\n if (Objects.isEmpty(siblingEntities) || Objects.isEmpty(keyDefs)) {\n return false\n }\n const keyValuesByDefUuid = _getKeyValuesByDefUuid({ survey, record, entity, keyDefs, cache })\n return (\n !Objects.isEmpty(keyValuesByDefUuid) &&\n siblingEntities.some((sibilingEntity) => {\n const siblingKeyValuesByDefUuid = _getKeyValuesByDefUuid({\n survey,\n record,\n entity: sibilingEntity,\n keyDefs,\n cache,\n })\n return keyDefs.every((keyDef) => {\n const keyValue = keyValuesByDefUuid[keyDef.uuid]\n const siblingKeyValue = siblingKeyValuesByDefUuid[keyDef.uuid]\n return NodeValues.isValueEqual({\n survey,\n nodeDef: keyDef,\n value: keyValue,\n valueSearch: siblingKeyValue,\n })\n })\n })\n )\n}\n\nconst isNodeDefToBeValidated = (params: { survey: Survey; nodeDef: NodeDef<NodeDefType, NodeDefProps> }): boolean => {\n const { survey, nodeDef } = params\n if (!NodeDefs.isKey(nodeDef)) return false\n\n const nodeDefParent = Surveys.getNodeDefParent({ survey, nodeDef })\n // root entity key attributes will be validated by another validator\n return !!nodeDefParent && !NodeDefs.isRoot(nodeDefParent)\n}\n\nconst validateAttributeKey =\n (params: {\n survey: Survey\n record: ArenaRecord\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n entityKeysCache?: EntityKeysCache\n }) =>\n (_propName: string, node: ArenaRecordNode): Promise<ValidationResult> => {\n const { survey, nodeDef, record, entityKeysCache } = params\n\n if (isNodeDefToBeValidated({ survey, nodeDef })) {\n const entity = Records.getParent(node)(record)\n if (entity && _isEntityDuplicate({ survey, record, entity, entityKeysCache })) {\n return Promise.resolve(\n ValidationResultFactory.createInstance({\n valid: false,\n severity: ValidationSeverity.error,\n key: 'record.entity.keyDuplicate',\n })\n )\n }\n }\n\n return Promise.resolve(ValidationResultFactory.createInstance())\n }\n\nexport const AttributeKeyValidator = {\n validateAttributeKey,\n}\n"]}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { NodeDef, NodeDefProps, NodeDefType } from '../../nodeDef';
|
|
2
|
-
import {
|
|
2
|
+
import { ArenaRecordNode } from '../../node';
|
|
3
3
|
import { ValidationResult } from '../../validation';
|
|
4
4
|
import { Survey } from '../../survey';
|
|
5
5
|
import { CategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider';
|
|
6
6
|
import { TaxonProvider } from '../../nodeDefExpressionEvaluator/taxonProvider';
|
|
7
|
-
import {
|
|
7
|
+
import { ArenaRecord } from '../record';
|
|
8
8
|
interface AttributeTypeValidatorParams {
|
|
9
9
|
survey: Survey;
|
|
10
10
|
categoryItemProvider?: CategoryItemProvider;
|
|
11
11
|
taxonProvider?: TaxonProvider;
|
|
12
|
-
record:
|
|
12
|
+
record: ArenaRecord;
|
|
13
13
|
nodeDef: NodeDef<NodeDefType, NodeDefProps>;
|
|
14
14
|
}
|
|
15
|
-
declare const validateValueType: (params: AttributeTypeValidatorParams) => (_propName: string, node:
|
|
15
|
+
declare const validateValueType: (params: AttributeTypeValidatorParams) => (_propName: string, node: ArenaRecordNode) => Promise<ValidationResult>;
|
|
16
16
|
export declare const AttributeTypeValidator: {
|
|
17
17
|
validateValueType: typeof validateValueType;
|
|
18
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributeTypeValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/attributeTypeValidator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAuG;AACvG,
|
|
1
|
+
{"version":3,"file":"attributeTypeValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/attributeTypeValidator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAuG;AACvG,qCAAmD;AACnD,iDAA4E;AAC5E,yCAA8C;AAC9C,sDAAkD;AAClD,mCAAkC;AAClC,uCAA4C;AAG5C,6CAAqC;AAgBrC,MAAM,eAAe,GAAG,CAAC,MAA4C,EAAW,EAAE;IAChF,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IACxB,sHAAsH;IACtH,OAAO,eAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC/B,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,CAAO,MAA4C,EAAE,EAAE;IAC1E,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAA;IAC7D,MAAM,QAAQ,GAAG,uBAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IAC7C,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAA;IAE1B,IAAI,IAAI,GAAG,gBAAO,CAAC,qBAAqB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC9D,IAAI,IAAI;QAAE,OAAO,IAAI,CAAA;IAErB,IAAI,CAAC,oBAAoB;QAAE,OAAO,KAAK,CAAA;IAEvC,yCAAyC;IACzC,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OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,aAAa,EAAE,GAAG,MAAM,CAAA;IAE/E,IAAI,YAAK,CAAC,YAAY,CAAC,IAAI,CAAC;QAAE,OAAO,oCAAuB,CAAC,cAAc,EAAE,CAAA;IAE7E,MAAM,eAAe,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACtD,MAAM,KAAK,SACT,CAAC,MAAM,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAG;QACvB,MAAM;QACN,oBAAoB;QACpB,aAAa;QACb,MAAM;QACN,OAAO;QACP,IAAI;QACJ,KAAK,EAAE,IAAI,CAAC,KAAK;KAClB,CAAC,CAAC,mCAAI,IAAI,CAAA;IACb,OAAO,oCAAuB,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,+BAA+B,EAAE,KAAK,EAAE,CAAC,CAAA;AAChG,CAAC,CAAA,CAAA;AAEU,QAAA,sBAAsB,GAAG;IACpC,iBAAiB;CAClB,CAAA","sourcesContent":["import { NodeDef, NodeDefCode, NodeDefProps, NodeDefs, NodeDefTaxon, NodeDefType } from '../../nodeDef'\nimport { ArenaRecordNode, Nodes } from '../../node'\nimport { ValidationResult, ValidationResultFactory } from '../../validation'\nimport { Survey, Surveys } from '../../survey'\nimport { NodeValues } from '../../node/nodeValues'\nimport { Points } from '../../geo'\nimport { Numbers, Dates } from '../../utils'\nimport { CategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider'\nimport { TaxonProvider } from '../../nodeDefExpressionEvaluator/taxonProvider'\nimport { Taxa } from '../../taxonomy'\nimport { ArenaRecord } from '../record'\n\ninterface AttributeTypeValidatorParams {\n survey: Survey\n categoryItemProvider?: CategoryItemProvider\n taxonProvider?: TaxonProvider\n record: ArenaRecord\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}\n\ninterface AttributeTypeValidatorInternalParams extends AttributeTypeValidatorParams {\n node: ArenaRecordNode\n value: any\n}\n\nconst validateDecimal = (params: AttributeTypeValidatorInternalParams): boolean => {\n const { value } = params\n // the max number of decimal digits is not validated: it is applied when formatting the value (see nodeValueFormatter)\n return Numbers.isFloat(value)\n}\n\nconst validateCode = async (params: AttributeTypeValidatorInternalParams) => {\n const { survey, record, node, categoryItemProvider } = params\n const itemUuid = NodeValues.getItemUuid(node)\n if (!itemUuid) return true\n\n let item = Surveys.getCategoryItemByUuid({ survey, itemUuid })\n if (item) return true\n\n if (!categoryItemProvider) return false\n\n // loookup item with categoryItemProvider\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid }) as NodeDefCode\n const categoryUuid = NodeDefs.getCategoryUuid(nodeDef)\n if (!categoryUuid) return false\n const draft = !!record.preview\n item = await categoryItemProvider.getItemByUuid({ survey, categoryUuid, itemUuid, draft })\n return Boolean(item)\n}\n\nconst validateTaxon = async (params: AttributeTypeValidatorInternalParams): Promise<boolean> => {\n const { survey, record, node, taxonProvider } = params\n const taxonUuid = NodeValues.getTaxonUuid(node)\n if (!taxonUuid) return true\n\n let taxon = Surveys.getTaxonByUuid({ survey, taxonUuid })\n if (!taxon && taxonProvider) {\n // lookup taxon with taxonProvider\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid }) as NodeDefTaxon\n const taxonomyUuid = NodeDefs.getTaxonomyUuid(nodeDef)\n if (!taxonomyUuid) return false\n const draft = !!record.preview\n taxon = await taxonProvider.getTaxonByUuid({ survey, taxonomyUuid, taxonUuid, draft })\n }\n if (!taxon) return false\n\n const vernacularNameUuid = NodeValues.getVernacularNameUuid(node)\n if (!vernacularNameUuid) return true\n\n const vernacularName = Taxa.getVernacularNameByUuid(vernacularNameUuid)(taxon)\n return !!vernacularName\n}\n\nconst typeValidatorFns: {\n [key in NodeDefType]?: (params: AttributeTypeValidatorInternalParams) => boolean | Promise<boolean>\n} = {\n [NodeDefType.boolean]: (params: AttributeTypeValidatorInternalParams): boolean =>\n ['true', 'false'].includes(params.value),\n [NodeDefType.code]: validateCode,\n [NodeDefType.coordinate]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { survey, node } = params\n\n const point = NodeValues.getValueAsPoint({ survey, node })\n if (!point) return false\n\n const srsIndex = Surveys.getSRSIndex(survey)\n\n return Points.isValid(point, srsIndex)\n },\n\n [NodeDefType.date]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { node } = params\n const [year, month, day] = [\n NodeValues.getDateYear(node),\n NodeValues.getDateMonth(node),\n NodeValues.getDateDay(node),\n ]\n return Dates.isValidDate(year, month, day)\n },\n\n [NodeDefType.decimal]: validateDecimal,\n\n [NodeDefType.integer]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { value } = params\n return Numbers.isInteger(value)\n },\n\n [NodeDefType.taxon]: validateTaxon,\n\n [NodeDefType.text]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { value } = params\n return typeof value === 'string'\n },\n\n [NodeDefType.time]: (params: AttributeTypeValidatorInternalParams): boolean => {\n const { node } = params\n const [hour, minute, seconds] = [\n NodeValues.getTimeHour(node),\n NodeValues.getTimeMinute(node),\n NodeValues.getTimeSeconds(node),\n ]\n return Dates.isValidTime(hour, minute, seconds)\n },\n}\n\nconst validateValueType =\n (params: AttributeTypeValidatorParams) =>\n async (_propName: string, node: ArenaRecordNode): Promise<ValidationResult> => {\n const { survey, nodeDef, record, categoryItemProvider, taxonProvider } = params\n\n if (Nodes.isValueBlank(node)) return ValidationResultFactory.createInstance()\n\n const typeValidatorFn = typeValidatorFns[nodeDef.type]\n const valid =\n (await typeValidatorFn?.({\n survey,\n categoryItemProvider,\n taxonProvider,\n record,\n nodeDef,\n node,\n value: node.value,\n })) ?? true\n return ValidationResultFactory.createInstance({ key: 'record.attribute.valueInvalid', valid })\n }\n\nexport const AttributeTypeValidator = {\n validateValueType,\n}\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArenaRecordNode } from '../../node';
|
|
2
2
|
import { NodeDef, NodeDefProps, NodeDefType } from '../../nodeDef';
|
|
3
3
|
import { Survey } from '../../survey';
|
|
4
4
|
import { ValidationResult } from '../../validation';
|
|
5
|
-
import {
|
|
5
|
+
import { ArenaRecord } from '../record';
|
|
6
6
|
export declare const validateAttributeUnique: (params: {
|
|
7
7
|
survey: Survey;
|
|
8
|
-
record:
|
|
8
|
+
record: ArenaRecord;
|
|
9
9
|
nodeDef: NodeDef<NodeDefType, NodeDefProps>;
|
|
10
|
-
}) => (_propName: string, node:
|
|
10
|
+
}) => (_propName: string, node: ArenaRecordNode) => Promise<ValidationResult>;
|
|
11
11
|
export declare const AttributeUniqueValidator: {
|
|
12
12
|
validateAttributeUnique: typeof validateAttributeUnique;
|
|
13
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributeUniqueValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/attributeUniqueValidator.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"attributeUniqueValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/attributeUniqueValidator.ts"],"names":[],"mappings":";;;AAAA,qCAA+D;AAC/D,2CAA4E;AAC5E,yCAA8C;AAC9C,iDAAgG;AAEhG,wCAAoC;AAEpC,MAAM,qBAAqB,GAAG,CAAC,MAK9B,EAAW,EAAE;IACZ,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IACrD,+CAA+C;IAC/C,IAAI,YAAK,CAAC,YAAY,CAAC,SAAS,CAAC;QAAE,OAAO,KAAK,CAAA;IAC/C,MAAM,YAAY,GAAG,iBAAO,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAA;IACvF,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CACnC,iBAAU,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE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AC,CAAA;AAClE,CAAC,CAAA;AAnBU,QAAA,uBAAuB,GAAvB,uBAAuB,CAmBjC;AAEU,QAAA,wBAAwB,GAAG;IACtC,uBAAuB,EAAvB,QAAA,uBAAuB;CACxB,CAAA","sourcesContent":["import { ArenaRecordNode, Nodes, NodeValues } from '../../node'\nimport { NodeDef, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { Survey, Surveys } from '../../survey'\nimport { ValidationResult, ValidationResultFactory, ValidationSeverity } from '../../validation'\nimport { ArenaRecord } from '../record'\nimport { Records } from '../records'\n\nconst _isAttributeDuplicate = (params: {\n survey: Survey\n record: ArenaRecord\n attribute: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): boolean => {\n const { survey, attribute, record, nodeDef } = params\n // blank values are never considered duplicates\n if (Nodes.isValueBlank(attribute)) return false\n const nodeSiblings = Records.getAttributeSiblings({ record, node: attribute, nodeDef })\n return nodeSiblings.some((sibling) =>\n NodeValues.isValueEqual({ survey, nodeDef, value: sibling.value, valueSearch: attribute.value })\n )\n}\n\nconst isNodeDefToBeValidated = (params: { survey: Survey; nodeDef: NodeDef<NodeDefType, NodeDefProps> }): boolean => {\n const { survey, nodeDef } = params\n const nodeDefValidations = NodeDefs.getValidations(nodeDef)\n if (!nodeDefValidations?.unique) return false\n\n const nodeDefParent = Surveys.getNodeDefParent({ survey, nodeDef })\n if (!nodeDefParent || NodeDefs.isRoot(nodeDefParent)) {\n // uniqueness at record level evaluated elsewhere\n return false\n }\n return true\n}\n\nexport const validateAttributeUnique =\n (params: { survey: Survey; record: ArenaRecord; nodeDef: NodeDef<NodeDefType, NodeDefProps> }) =>\n (_propName: string, node: ArenaRecordNode): Promise<ValidationResult> => {\n const { survey, record, nodeDef } = params\n\n if (\n isNodeDefToBeValidated({ survey, nodeDef }) &&\n _isAttributeDuplicate({ survey, record, attribute: node, nodeDef })\n ) {\n return Promise.resolve(\n ValidationResultFactory.createInstance({\n valid: false,\n severity: ValidationSeverity.error,\n key: 'record.attribute.uniqueDuplicate',\n })\n )\n }\n\n return Promise.resolve(ValidationResultFactory.createInstance())\n }\n\nexport const AttributeUniqueValidator = {\n validateAttributeUnique,\n}\n"]}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { User } from '../../auth';
|
|
2
2
|
import { Dictionary } from '../../common';
|
|
3
|
-
import {
|
|
3
|
+
import { ArenaRecordNode } from '../../node';
|
|
4
4
|
import { CategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider';
|
|
5
5
|
import { TaxonProvider } from '../../nodeDefExpressionEvaluator/taxonProvider';
|
|
6
6
|
import { Survey } from '../../survey';
|
|
7
7
|
import { ValidationFields } from '../../validation/validation';
|
|
8
|
-
import {
|
|
8
|
+
import { ArenaRecord } from '../record';
|
|
9
9
|
export interface RecordValidatorParams {
|
|
10
10
|
user: User;
|
|
11
11
|
survey: Survey;
|
|
12
12
|
categoryItemProvider?: CategoryItemProvider;
|
|
13
13
|
taxonProvider?: TaxonProvider;
|
|
14
|
-
record:
|
|
14
|
+
record: ArenaRecord;
|
|
15
15
|
}
|
|
16
16
|
export interface AttributeValidatorParams extends RecordValidatorParams {
|
|
17
|
-
attribute:
|
|
17
|
+
attribute: ArenaRecordNode;
|
|
18
18
|
}
|
|
19
19
|
export interface AttributesValidatorParams extends RecordValidatorParams {
|
|
20
|
-
nodes: Dictionary<
|
|
20
|
+
nodes: Dictionary<ArenaRecordNode>;
|
|
21
21
|
}
|
|
22
22
|
export interface SortedAttributesValidatorParams extends RecordValidatorParams {
|
|
23
|
-
nodesArray:
|
|
23
|
+
nodesArray: ArenaRecordNode[];
|
|
24
24
|
}
|
|
25
25
|
declare const validateSelfAndDependentSortedAttributes: (params: SortedAttributesValidatorParams) => Promise<ValidationFields>;
|
|
26
26
|
export declare const AttributeValidator: {
|