@openforis/arena-core 2.15.0 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/error/systemErrorKeys.d.ts +1 -0
- package/dist/error/systemErrorKeys.js +1 -0
- package/dist/error/systemErrorKeys.js.map +1 -1
- package/dist/esm/error/systemErrorKeys.js +1 -0
- package/dist/esm/error/systemErrorKeys.js.map +1 -1
- package/dist/esm/geo/areaOfInterest.js.map +1 -1
- package/dist/esm/geo/index.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/nodeDefExpressionEvaluator/areaOfInterestProvider.js +2 -0
- package/dist/esm/nodeDefExpressionEvaluator/areaOfInterestProvider.js.map +1 -0
- package/dist/esm/nodeDefExpressionEvaluator/context.js.map +1 -1
- package/dist/esm/nodeDefExpressionEvaluator/functions.js +45 -8
- package/dist/esm/nodeDefExpressionEvaluator/functions.js.map +1 -1
- package/dist/esm/nodeDefExpressionEvaluator/index.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/context.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordExpressionEvaluationContext.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeValidator.js +2 -1
- package/dist/esm/record/recordValidator/attributeValidator.js.map +1 -1
- package/dist/esm/survey/survey.js.map +1 -1
- package/dist/esm/survey/surveys/index.js +3 -2
- package/dist/esm/survey/surveys/index.js.map +1 -1
- package/dist/esm/survey/surveys/surveysGetters.js +3 -2
- package/dist/esm/survey/surveys/surveysGetters.js.map +1 -1
- package/dist/geo/areaOfInterest.d.ts +14 -1
- package/dist/geo/areaOfInterest.js.map +1 -1
- package/dist/geo/index.d.ts +1 -1
- package/dist/geo/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/areaOfInterestProvider.d.ts +11 -0
- package/dist/nodeDefExpressionEvaluator/areaOfInterestProvider.js +3 -0
- package/dist/nodeDefExpressionEvaluator/areaOfInterestProvider.js.map +1 -0
- package/dist/nodeDefExpressionEvaluator/context.d.ts +2 -0
- package/dist/nodeDefExpressionEvaluator/context.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/functions.js +44 -7
- package/dist/nodeDefExpressionEvaluator/functions.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/index.d.ts +1 -0
- package/dist/nodeDefExpressionEvaluator/index.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/context.d.ts +2 -0
- package/dist/record/recordExpressionEvaluator/context.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.d.ts +2 -0
- package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordExpressionEvaluationContext.d.ts +2 -0
- package/dist/record/recordNodesUpdater/recordExpressionEvaluationContext.js.map +1 -1
- package/dist/record/recordValidator/attributeValidator.d.ts +2 -0
- package/dist/record/recordValidator/attributeValidator.js +2 -1
- package/dist/record/recordValidator/attributeValidator.js.map +1 -1
- package/dist/survey/survey.d.ts +2 -2
- package/dist/survey/survey.js.map +1 -1
- package/dist/survey/surveys/index.d.ts +3 -2
- package/dist/survey/surveys/index.js +2 -1
- package/dist/survey/surveys/index.js.map +1 -1
- package/dist/survey/surveys/surveysGetters.d.ts +6 -2
- package/dist/survey/surveys/surveysGetters.js +6 -4
- package/dist/survey/surveys/surveysGetters.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { User } from '../../auth';
|
|
2
2
|
import { Dictionary } from '../../common';
|
|
3
3
|
import { ArenaRecordNode } from '../../node';
|
|
4
|
+
import { AreaOfInterestProvider } from '../../nodeDefExpressionEvaluator/areaOfInterestProvider';
|
|
4
5
|
import { CategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider';
|
|
5
6
|
import { TaxonProvider } from '../../nodeDefExpressionEvaluator/taxonProvider';
|
|
6
7
|
import { Survey } from '../../survey';
|
|
@@ -11,6 +12,7 @@ export interface RecordValidatorParams {
|
|
|
11
12
|
survey: Survey;
|
|
12
13
|
categoryItemProvider?: CategoryItemProvider;
|
|
13
14
|
taxonProvider?: TaxonProvider;
|
|
15
|
+
areaOfInterestProvider?: AreaOfInterestProvider;
|
|
14
16
|
record: ArenaRecord;
|
|
15
17
|
}
|
|
16
18
|
export interface AttributeValidatorParams extends RecordValidatorParams {
|
|
@@ -98,7 +98,7 @@ const _validateRequired = (params) => (_field, node) => __awaiter(void 0, void 0
|
|
|
98
98
|
*/
|
|
99
99
|
const _validateNodeValidations = (params) => (_propName, node) => __awaiter(void 0, void 0, void 0, function* () {
|
|
100
100
|
var _a;
|
|
101
|
-
const { user, survey, record, nodeDef } = params;
|
|
101
|
+
const { user, survey, record, nodeDef, areaOfInterestProvider } = params;
|
|
102
102
|
if (node_1.Nodes.isValueBlank(node))
|
|
103
103
|
return validation_1.ValidationResultFactory.createInstance();
|
|
104
104
|
const validations = nodeDef_1.NodeDefs.getValidations(nodeDef);
|
|
@@ -108,6 +108,7 @@ const _validateNodeValidations = (params) => (_propName, node) => __awaiter(void
|
|
|
108
108
|
user,
|
|
109
109
|
survey,
|
|
110
110
|
record,
|
|
111
|
+
areaOfInterestProvider,
|
|
111
112
|
nodeCtx: node,
|
|
112
113
|
expressions: validations.expressions,
|
|
113
114
|
stopAtFirstFound: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributeValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/attributeValidator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,qCAAyE;AACzE,2CAA+F;AAG/F,yCAA8C;AAC9C,gDAA0D;AAC1D,uCAAqC;AACrC,iDAMyB;AAEzB,kDAA8C;AAE9C,4EAAwE;AACxE,mHAA8F;AAC9F,wCAAoC;AACpC,4DAAwD;AACxD,mEAAuG;AACvG,qEAAiE;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E,IAAI,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAChE,qEAAqE;YACrE,MAAM,wBAAwB,mCAAQ,MAAM,KAAE,SAAS,EAAE,cAAc,EAAE,eAAe,GAAE,CAAA;YAC1F,qBAAqB,CAAC,QAAQ,CAAC,GAAG,MAAM,iBAAiB,CAAC,wBAAwB,CAAC,CAAA,CAAC,UAAU;QAChG,CAAC;IACH,CAAC;IACD,OAAO,qBAAqB,CAAA;AAC9B,CAAC,CAAA,CAAA;AAEY,QAAA,kBAAkB,GAAG;IAChC,wCAAwC;CACzC,CAAA","sourcesContent":["import { User } from '../../auth'\nimport { Dictionary } from '../../common'\nimport { Labels } from '../../language'\nimport { ArenaRecordNode, NodeKeys, Nodes, NodeValues } from '../../node'\nimport { NodeDef, NodeDefExpression, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { CategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider'\nimport { TaxonProvider } from '../../nodeDefExpressionEvaluator/taxonProvider'\nimport { Survey, Surveys } from '../../survey'\nimport { SurveyDependencyType } from '../../survey/survey'\nimport { Objects } from '../../utils'\nimport {\n ValidationFactory,\n ValidationResult,\n ValidationResultFactory,\n ValidationSeverity,\n Validator,\n} from '../../validation'\nimport { ValidationFields } from '../../validation/validation'\nimport { NodePointers } from '../nodePointers'\nimport { ArenaRecord } from '../record'\nimport { RecordExpressionEvaluator } from '../recordExpressionEvaluator'\nimport { evaluateRequiredIf } from '../recordNodesUpdater/recordNodeDependentsRequiredUpdater'\nimport { Records } from '../records'\nimport { RecordValidations } from '../recordValidations'\nimport { AttributeKeyValidator, createEntityKeysCache, EntityKeysCache } from './attributeKeyValidator'\nimport { AttributeTypeValidator } from './attributeTypeValidator'\nimport { AttributeUniqueValidator } from './attributeUniqueValidator'\n\nconst expressionEvaluator = new RecordExpressionEvaluator()\n\nexport interface RecordValidatorParams {\n user: User\n survey: Survey\n categoryItemProvider?: CategoryItemProvider\n taxonProvider?: TaxonProvider\n record: ArenaRecord\n}\n\nexport interface AttributeValidatorParams extends RecordValidatorParams {\n attribute: ArenaRecordNode\n}\n\nexport interface AttributesValidatorParams extends RecordValidatorParams {\n nodes: Dictionary<ArenaRecordNode>\n}\n\nexport interface SortedAttributesValidatorParams extends RecordValidatorParams {\n nodesArray: ArenaRecordNode[]\n}\n\ntype SiblingKeyNodeItem = { entityUuid: string; keyNode: ArenaRecordNode; hasErrors: boolean }\n\n// sibling key nodes are cached by ancestor multiple entity parent and def uuid during the same validation call:\n// when many entities are added to the same parent entity (e.g. data import), computing them for every updated\n// key attribute would take a time that grows quadratically with the number of entities\ntype SiblingKeyNodesCache = Map<string, SiblingKeyNodeItem[]>\n\nconst _getSiblingNodeKeys = (\n params: AttributeValidatorParams & { siblingKeyNodesCache?: SiblingKeyNodesCache }\n): SiblingKeyNodeItem[] => {\n const { survey, record, attribute, siblingKeyNodesCache } = params\n\n const attributeDef = Surveys.getNodeDefByUuid({ survey, uuid: attribute.nodeDefUuid })\n const ancestorMultipleEntityDef = Surveys.getNodeDefAncestorMultipleEntity({ survey, nodeDef: attributeDef })\n if (!ancestorMultipleEntityDef) {\n return []\n }\n const ancestorMultipleEntity = Records.getAncestor(attribute, ancestorMultipleEntityDef.uuid)(record)\n if (!ancestorMultipleEntity) return []\n\n const ancestorMultipleEntityParent = Records.getParent(ancestorMultipleEntity)(record)\n if (!ancestorMultipleEntityParent) return []\n\n const cacheKey = `${ancestorMultipleEntityParent.uuid}_${ancestorMultipleEntityDef.uuid}`\n let items = siblingKeyNodesCache?.get(cacheKey)\n if (!items) {\n const keyDefs = Surveys.getNodeDefKeys({ survey, nodeDef: ancestorMultipleEntityDef })\n const entities = Records.getEntitySiblings(ancestorMultipleEntity, true)(record)\n items = []\n for (const entity of entities) {\n const keyNodes = Records.getEntityKeyNodes(survey, entity, undefined, keyDefs)(record)\n for (const keyNode of keyNodes) {\n if (!keyNode) continue\n const nodeValidation =\n record.validation && RecordValidations.getValidationNode({ nodeUuid: keyNode.uuid })(record.validation)\n items.push({ entityUuid: entity.uuid, keyNode, hasErrors: !!nodeValidation && !nodeValidation.valid })\n }\n }\n siblingKeyNodesCache?.set(cacheKey, items)\n }\n return items.filter((item) => item.entityUuid !== ancestorMultipleEntity.uuid)\n}\n\nconst _getValidationMessagesWithDefault = (params: {\n survey: Survey\n expression: NodeDefExpression\n defaultMessage?: string\n}): Labels => {\n const { survey, expression, defaultMessage } = params\n const messages: Labels = { ...expression.messages }\n\n const languages = Surveys.getLanguages(survey)\n const defaultMessageDefined = Objects.isNotEmpty(defaultMessage)\n\n for (const lang of languages) {\n const customMessage = messages[lang]\n if (Objects.isEmpty(customMessage) && defaultMessageDefined) {\n messages[lang] = defaultMessage\n }\n }\n\n return messages\n}\n\nconst _isValueRequired = async (\n params: AttributeValidatorParams & { nodeDef: NodeDef<NodeDefType, NodeDefProps> }\n): Promise<boolean> => {\n const { record, attribute, nodeDef } = params\n if (NodeDefs.isKey(nodeDef) || NodeDefs.isRequired(nodeDef)) return true\n if (!NodeDefs.isRequiredIfDefined(nodeDef)) return false\n const parentNode = Records.getParent(attribute)(record)\n if (!parentNode) return false\n // evaluated here (not read from the parent node meta flag) so validation doesn't depend on up to date node meta\n // (e.g. records created before the \"required if\" condition was defined)\n return evaluateRequiredIf({ ...params, nodeCtx: parentNode, nodeDef })\n}\n\nconst _validateRequired =\n (params: AttributeValidatorParams & { nodeDef: NodeDef<NodeDefType, NodeDefProps> }) =>\n async (_field: string, node: any): Promise<ValidationResult> => {\n const valid = !Nodes.isValueBlank(node) || !(await _isValueRequired(params))\n return valid\n ? ValidationResultFactory.createInstance()\n : ValidationResultFactory.createInstance({\n key: 'record.attribute.valueRequired',\n severity: ValidationSeverity.error,\n valid,\n })\n }\n\n/**\n * Evaluates the validation expressions.\n */\nconst _validateNodeValidations =\n (params: { user: User; survey: Survey; record: ArenaRecord; nodeDef: NodeDef<NodeDefType, NodeDefProps> }) =>\n async (_propName: string, node: ArenaRecordNode): Promise<ValidationResult> => {\n const { user, survey, record, nodeDef } = params\n if (Nodes.isValueBlank(node)) return ValidationResultFactory.createInstance()\n\n const validations = NodeDefs.getValidations(nodeDef)\n if (!validations?.expressions?.length) return ValidationResultFactory.createInstance()\n\n const applicableExpressionsEval = await expressionEvaluator.evalApplicableExpressions({\n user,\n survey,\n record,\n nodeCtx: node,\n expressions: validations.expressions,\n stopAtFirstFound: false,\n })\n\n let validationResult = ValidationResultFactory.createInstance()\n\n for (const { expression, value: valid } of applicableExpressionsEval) {\n if (!valid) {\n const messages = _getValidationMessagesWithDefault({\n survey,\n expression,\n defaultMessage: expression.expression,\n })\n\n validationResult = ValidationResultFactory.createInstance({\n valid: false,\n key: 'record.attribute.customValidation',\n severity: expression.severity,\n messages,\n })\n break\n }\n }\n\n return validationResult\n }\n\nconst validateAttribute = async (params: AttributeValidatorParams & { entityKeysCache?: EntityKeysCache }) => {\n const { survey, record, attribute } = params\n if (Records.isNodeApplicable(attribute)(record)) {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: attribute.nodeDefUuid })\n const validatorParams = { ...params, nodeDef }\n return new Validator().validate(attribute, {\n [NodeKeys.value]: [\n _validateRequired(validatorParams),\n AttributeTypeValidator.validateValueType(validatorParams),\n _validateNodeValidations(validatorParams),\n AttributeKeyValidator.validateAttributeKey(validatorParams),\n AttributeUniqueValidator.validateAttributeUnique(validatorParams),\n ],\n })\n }\n return ValidationFactory.createInstance()\n}\n\nconst findSiblingKeyNodesToValidate = (\n params: AttributeValidatorParams & {\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n nodeParent?: ArenaRecordNode\n siblingKeyNodesCache?: SiblingKeyNodesCache\n }\n) => {\n const { survey, nodeDef, nodeParent: parentNode, attribute } = params\n if (\n !NodeDefs.isKey(nodeDef) ||\n !parentNode ||\n (NodeDefs.isAutoIncrementalKey(nodeDef) && attribute.created && Nodes.isDefaultValueApplied(attribute))\n ) {\n // when a new node is created and the key is autoincremental, its value will be unique\n // and the validation of sibling key attributes is not necessary\n return []\n }\n // when a key attribute is updated, a sibling key attribute with the same value\n // or a sibling attribute with a validation error (duplicate key) should be re-validated\n const siblingNodeKeys = _getSiblingNodeKeys(params)\n const siblingNodeKeysWithSameValue: ArenaRecordNode[] = []\n const siblingNodeKeysWithErrors: ArenaRecordNode[] = []\n siblingNodeKeys.forEach(({ keyNode, hasErrors }) => {\n if (NodeValues.isValueEqual({ survey, nodeDef, parentNode, value: keyNode.value, valueSearch: attribute.value })) {\n siblingNodeKeysWithSameValue.push(keyNode)\n }\n if (hasErrors) {\n siblingNodeKeysWithErrors.push(keyNode)\n }\n })\n return [...siblingNodeKeysWithSameValue, ...siblingNodeKeysWithErrors]\n}\n\nconst findSortedNodesToValidate = (params: SortedAttributesValidatorParams): ArenaRecordNode[] => {\n const { survey, record, nodesArray } = params\n\n const result = []\n const siblingKeyNodesCache: SiblingKeyNodesCache = new Map()\n for (const node of nodesArray) {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid })\n if (!NodeDefs.isAttribute(nodeDef)) {\n continue\n }\n // Get dependents and attribute itself\n const nodePointersAttributeAndDependents = [\n ...Records.getDependentNodePointers(survey, node, SurveyDependencyType.validations, true)(record),\n ...Records.getDependentNodePointers(survey, node, SurveyDependencyType.required)(record),\n ]\n\n const nodeParent = Records.getParent(node)(record)\n\n result.push(\n ...NodePointers.getNodesFromNodePointers({ record, nodePointers: nodePointersAttributeAndDependents }),\n ...findSiblingKeyNodesToValidate({ ...params, nodeDef, nodeParent, attribute: node, siblingKeyNodesCache })\n )\n\n if (NodeDefs.getValidations(nodeDef)?.unique) {\n result.push(...Records.getAttributeSiblings(node, nodeDef)(record))\n }\n }\n\n return result\n}\n\nconst validateSelfAndDependentSortedAttributes = async (\n params: SortedAttributesValidatorParams\n): Promise<ValidationFields> => {\n const nodesToValidate: ArenaRecordNode[] = findSortedNodesToValidate(params)\n const validationsByNodeUuid: ValidationFields = {}\n // the record doesn't change during the validation: entity keys can be cached\n const entityKeysCache = createEntityKeysCache()\n\n for (const nodeToValidate of nodesToValidate) {\n const nodeUuid = nodeToValidate.uuid\n // Validate only attributes not deleted and not validated already\n if (!nodeToValidate.deleted && !validationsByNodeUuid[nodeUuid]) {\n // sequential: avoid concurrent item/taxon lookups on large node sets\n const attributeValidatorParams = { ...params, attribute: nodeToValidate, entityKeysCache }\n validationsByNodeUuid[nodeUuid] = await validateAttribute(attributeValidatorParams) // NOSONAR\n }\n }\n return validationsByNodeUuid\n}\n\nexport const AttributeValidator = {\n validateSelfAndDependentSortedAttributes,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"attributeValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/attributeValidator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,qCAAyE;AACzE,2CAA+F;AAI/F,yCAA8C;AAC9C,gDAA0D;AAC1D,uCAAqC;AACrC,iDAMyB;AAEzB,kDAA8C;AAE9C,4EAAwE;AACxE,mHAA8F;AAC9F,wCAAoC;AACpC,4DAAwD;AACxD,mEAAuG;AACvG,qEAAiE;AACjE,yEAAqE;AAErE,MAAM,mBAAmB,GAAG,IAAI,qDAAyB,EAAE,CAAA;AA8B3D,MAAM,mBAAmB,GAAG,CAC1B,MAAkF,EAC5D,EAAE;IACxB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAA;IAElE,MAAM,YAAY,GAAG,gBAAO,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,WAAW,EAAE,CAAC,CAAA;IACtF,MAAM,yBAAyB,GAAG,gBAAO,CAAC,gCAAgC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAA;IAC7G,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAC/B,OAAO,EAAE,CAAA;IACX,CAAC;IACD,MAAM,sBAAsB,GAAG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,CAAC,EACtG,GAAG,6BAA6B,iCAAM,MAAM,KAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,oBAAoB,IAAG,CAC5G,CAAA;QAED,IAAI,MAAA,kBAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,0CAAE,MAAM,EAAE,CAAC;YAC7C,MAAM,CAAC,IAAI,CAAC,GAAG,iBAAO,CAAC,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;QACrE,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,MAAM,wCAAwC,GAAG,CAC/C,MAAuC,EACZ,EAAE;IAC7B,MAAM,eAAe,GAAsB,yBAAyB,CAAC,MAAM,CAAC,CAAA;IAC5E,MAAM,qBAAqB,GAAqB,EAAE,CAAA;IAClD,6EAA6E;IAC7E,MAAM,eAAe,GAAG,IAAA,6CAAqB,GAAE,CAAA;IAE/C,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE,CAAC;QAC7C,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAA;QACpC,iEAAiE;QACjE,IAAI,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAChE,qEAAqE;YACrE,MAAM,wBAAwB,mCAAQ,MAAM,KAAE,SAAS,EAAE,cAAc,EAAE,eAAe,GAAE,CAAA;YAC1F,qBAAqB,CAAC,QAAQ,CAAC,GAAG,MAAM,iBAAiB,CAAC,wBAAwB,CAAC,CAAA,CAAC,UAAU;QAChG,CAAC;IACH,CAAC;IACD,OAAO,qBAAqB,CAAA;AAC9B,CAAC,CAAA,CAAA;AAEY,QAAA,kBAAkB,GAAG;IAChC,wCAAwC;CACzC,CAAA","sourcesContent":["import { User } from '../../auth'\nimport { Dictionary } from '../../common'\nimport { Labels } from '../../language'\nimport { ArenaRecordNode, NodeKeys, Nodes, NodeValues } from '../../node'\nimport { NodeDef, NodeDefExpression, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { AreaOfInterestProvider } from '../../nodeDefExpressionEvaluator/areaOfInterestProvider'\nimport { CategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider'\nimport { TaxonProvider } from '../../nodeDefExpressionEvaluator/taxonProvider'\nimport { Survey, Surveys } from '../../survey'\nimport { SurveyDependencyType } from '../../survey/survey'\nimport { Objects } from '../../utils'\nimport {\n ValidationFactory,\n ValidationResult,\n ValidationResultFactory,\n ValidationSeverity,\n Validator,\n} from '../../validation'\nimport { ValidationFields } from '../../validation/validation'\nimport { NodePointers } from '../nodePointers'\nimport { ArenaRecord } from '../record'\nimport { RecordExpressionEvaluator } from '../recordExpressionEvaluator'\nimport { evaluateRequiredIf } from '../recordNodesUpdater/recordNodeDependentsRequiredUpdater'\nimport { Records } from '../records'\nimport { RecordValidations } from '../recordValidations'\nimport { AttributeKeyValidator, createEntityKeysCache, EntityKeysCache } from './attributeKeyValidator'\nimport { AttributeTypeValidator } from './attributeTypeValidator'\nimport { AttributeUniqueValidator } from './attributeUniqueValidator'\n\nconst expressionEvaluator = new RecordExpressionEvaluator()\n\nexport interface RecordValidatorParams {\n user: User\n survey: Survey\n categoryItemProvider?: CategoryItemProvider\n taxonProvider?: TaxonProvider\n areaOfInterestProvider?: AreaOfInterestProvider\n record: ArenaRecord\n}\n\nexport interface AttributeValidatorParams extends RecordValidatorParams {\n attribute: ArenaRecordNode\n}\n\nexport interface AttributesValidatorParams extends RecordValidatorParams {\n nodes: Dictionary<ArenaRecordNode>\n}\n\nexport interface SortedAttributesValidatorParams extends RecordValidatorParams {\n nodesArray: ArenaRecordNode[]\n}\n\ntype SiblingKeyNodeItem = { entityUuid: string; keyNode: ArenaRecordNode; hasErrors: boolean }\n\n// sibling key nodes are cached by ancestor multiple entity parent and def uuid during the same validation call:\n// when many entities are added to the same parent entity (e.g. data import), computing them for every updated\n// key attribute would take a time that grows quadratically with the number of entities\ntype SiblingKeyNodesCache = Map<string, SiblingKeyNodeItem[]>\n\nconst _getSiblingNodeKeys = (\n params: AttributeValidatorParams & { siblingKeyNodesCache?: SiblingKeyNodesCache }\n): SiblingKeyNodeItem[] => {\n const { survey, record, attribute, siblingKeyNodesCache } = params\n\n const attributeDef = Surveys.getNodeDefByUuid({ survey, uuid: attribute.nodeDefUuid })\n const ancestorMultipleEntityDef = Surveys.getNodeDefAncestorMultipleEntity({ survey, nodeDef: attributeDef })\n if (!ancestorMultipleEntityDef) {\n return []\n }\n const ancestorMultipleEntity = Records.getAncestor(attribute, ancestorMultipleEntityDef.uuid)(record)\n if (!ancestorMultipleEntity) return []\n\n const ancestorMultipleEntityParent = Records.getParent(ancestorMultipleEntity)(record)\n if (!ancestorMultipleEntityParent) return []\n\n const cacheKey = `${ancestorMultipleEntityParent.uuid}_${ancestorMultipleEntityDef.uuid}`\n let items = siblingKeyNodesCache?.get(cacheKey)\n if (!items) {\n const keyDefs = Surveys.getNodeDefKeys({ survey, nodeDef: ancestorMultipleEntityDef })\n const entities = Records.getEntitySiblings(ancestorMultipleEntity, true)(record)\n items = []\n for (const entity of entities) {\n const keyNodes = Records.getEntityKeyNodes(survey, entity, undefined, keyDefs)(record)\n for (const keyNode of keyNodes) {\n if (!keyNode) continue\n const nodeValidation =\n record.validation && RecordValidations.getValidationNode({ nodeUuid: keyNode.uuid })(record.validation)\n items.push({ entityUuid: entity.uuid, keyNode, hasErrors: !!nodeValidation && !nodeValidation.valid })\n }\n }\n siblingKeyNodesCache?.set(cacheKey, items)\n }\n return items.filter((item) => item.entityUuid !== ancestorMultipleEntity.uuid)\n}\n\nconst _getValidationMessagesWithDefault = (params: {\n survey: Survey\n expression: NodeDefExpression\n defaultMessage?: string\n}): Labels => {\n const { survey, expression, defaultMessage } = params\n const messages: Labels = { ...expression.messages }\n\n const languages = Surveys.getLanguages(survey)\n const defaultMessageDefined = Objects.isNotEmpty(defaultMessage)\n\n for (const lang of languages) {\n const customMessage = messages[lang]\n if (Objects.isEmpty(customMessage) && defaultMessageDefined) {\n messages[lang] = defaultMessage\n }\n }\n\n return messages\n}\n\nconst _isValueRequired = async (\n params: AttributeValidatorParams & { nodeDef: NodeDef<NodeDefType, NodeDefProps> }\n): Promise<boolean> => {\n const { record, attribute, nodeDef } = params\n if (NodeDefs.isKey(nodeDef) || NodeDefs.isRequired(nodeDef)) return true\n if (!NodeDefs.isRequiredIfDefined(nodeDef)) return false\n const parentNode = Records.getParent(attribute)(record)\n if (!parentNode) return false\n // evaluated here (not read from the parent node meta flag) so validation doesn't depend on up to date node meta\n // (e.g. records created before the \"required if\" condition was defined)\n return evaluateRequiredIf({ ...params, nodeCtx: parentNode, nodeDef })\n}\n\nconst _validateRequired =\n (params: AttributeValidatorParams & { nodeDef: NodeDef<NodeDefType, NodeDefProps> }) =>\n async (_field: string, node: any): Promise<ValidationResult> => {\n const valid = !Nodes.isValueBlank(node) || !(await _isValueRequired(params))\n return valid\n ? ValidationResultFactory.createInstance()\n : ValidationResultFactory.createInstance({\n key: 'record.attribute.valueRequired',\n severity: ValidationSeverity.error,\n valid,\n })\n }\n\n/**\n * Evaluates the validation expressions.\n */\nconst _validateNodeValidations =\n (params: {\n user: User\n survey: Survey\n record: ArenaRecord\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n areaOfInterestProvider?: AreaOfInterestProvider\n }) =>\n async (_propName: string, node: ArenaRecordNode): Promise<ValidationResult> => {\n const { user, survey, record, nodeDef, areaOfInterestProvider } = params\n if (Nodes.isValueBlank(node)) return ValidationResultFactory.createInstance()\n\n const validations = NodeDefs.getValidations(nodeDef)\n if (!validations?.expressions?.length) return ValidationResultFactory.createInstance()\n\n const applicableExpressionsEval = await expressionEvaluator.evalApplicableExpressions({\n user,\n survey,\n record,\n areaOfInterestProvider,\n nodeCtx: node,\n expressions: validations.expressions,\n stopAtFirstFound: false,\n })\n\n let validationResult = ValidationResultFactory.createInstance()\n\n for (const { expression, value: valid } of applicableExpressionsEval) {\n if (!valid) {\n const messages = _getValidationMessagesWithDefault({\n survey,\n expression,\n defaultMessage: expression.expression,\n })\n\n validationResult = ValidationResultFactory.createInstance({\n valid: false,\n key: 'record.attribute.customValidation',\n severity: expression.severity,\n messages,\n })\n break\n }\n }\n\n return validationResult\n }\n\nconst validateAttribute = async (params: AttributeValidatorParams & { entityKeysCache?: EntityKeysCache }) => {\n const { survey, record, attribute } = params\n if (Records.isNodeApplicable(attribute)(record)) {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: attribute.nodeDefUuid })\n const validatorParams = { ...params, nodeDef }\n return new Validator().validate(attribute, {\n [NodeKeys.value]: [\n _validateRequired(validatorParams),\n AttributeTypeValidator.validateValueType(validatorParams),\n _validateNodeValidations(validatorParams),\n AttributeKeyValidator.validateAttributeKey(validatorParams),\n AttributeUniqueValidator.validateAttributeUnique(validatorParams),\n ],\n })\n }\n return ValidationFactory.createInstance()\n}\n\nconst findSiblingKeyNodesToValidate = (\n params: AttributeValidatorParams & {\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n nodeParent?: ArenaRecordNode\n siblingKeyNodesCache?: SiblingKeyNodesCache\n }\n) => {\n const { survey, nodeDef, nodeParent: parentNode, attribute } = params\n if (\n !NodeDefs.isKey(nodeDef) ||\n !parentNode ||\n (NodeDefs.isAutoIncrementalKey(nodeDef) && attribute.created && Nodes.isDefaultValueApplied(attribute))\n ) {\n // when a new node is created and the key is autoincremental, its value will be unique\n // and the validation of sibling key attributes is not necessary\n return []\n }\n // when a key attribute is updated, a sibling key attribute with the same value\n // or a sibling attribute with a validation error (duplicate key) should be re-validated\n const siblingNodeKeys = _getSiblingNodeKeys(params)\n const siblingNodeKeysWithSameValue: ArenaRecordNode[] = []\n const siblingNodeKeysWithErrors: ArenaRecordNode[] = []\n siblingNodeKeys.forEach(({ keyNode, hasErrors }) => {\n if (NodeValues.isValueEqual({ survey, nodeDef, parentNode, value: keyNode.value, valueSearch: attribute.value })) {\n siblingNodeKeysWithSameValue.push(keyNode)\n }\n if (hasErrors) {\n siblingNodeKeysWithErrors.push(keyNode)\n }\n })\n return [...siblingNodeKeysWithSameValue, ...siblingNodeKeysWithErrors]\n}\n\nconst findSortedNodesToValidate = (params: SortedAttributesValidatorParams): ArenaRecordNode[] => {\n const { survey, record, nodesArray } = params\n\n const result = []\n const siblingKeyNodesCache: SiblingKeyNodesCache = new Map()\n for (const node of nodesArray) {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid })\n if (!NodeDefs.isAttribute(nodeDef)) {\n continue\n }\n // Get dependents and attribute itself\n const nodePointersAttributeAndDependents = [\n ...Records.getDependentNodePointers(survey, node, SurveyDependencyType.validations, true)(record),\n ...Records.getDependentNodePointers(survey, node, SurveyDependencyType.required)(record),\n ]\n\n const nodeParent = Records.getParent(node)(record)\n\n result.push(\n ...NodePointers.getNodesFromNodePointers({ record, nodePointers: nodePointersAttributeAndDependents }),\n ...findSiblingKeyNodesToValidate({ ...params, nodeDef, nodeParent, attribute: node, siblingKeyNodesCache })\n )\n\n if (NodeDefs.getValidations(nodeDef)?.unique) {\n result.push(...Records.getAttributeSiblings(node, nodeDef)(record))\n }\n }\n\n return result\n}\n\nconst validateSelfAndDependentSortedAttributes = async (\n params: SortedAttributesValidatorParams\n): Promise<ValidationFields> => {\n const nodesToValidate: ArenaRecordNode[] = findSortedNodesToValidate(params)\n const validationsByNodeUuid: ValidationFields = {}\n // the record doesn't change during the validation: entity keys can be cached\n const entityKeysCache = createEntityKeysCache()\n\n for (const nodeToValidate of nodesToValidate) {\n const nodeUuid = nodeToValidate.uuid\n // Validate only attributes not deleted and not validated already\n if (!nodeToValidate.deleted && !validationsByNodeUuid[nodeUuid]) {\n // sequential: avoid concurrent item/taxon lookups on large node sets\n const attributeValidatorParams = { ...params, attribute: nodeToValidate, entityKeysCache }\n validationsByNodeUuid[nodeUuid] = await validateAttribute(attributeValidatorParams) // NOSONAR\n }\n }\n return validationsByNodeUuid\n}\n\nexport const AttributeValidator = {\n validateSelfAndDependentSortedAttributes,\n}\n"]}
|
package/dist/survey/survey.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ArenaObject, Dictionary } from '../common';
|
|
2
2
|
import { AuthGroup } from '../auth';
|
|
3
3
|
import { Labels, LanguageCode } from '../language';
|
|
4
|
-
import type {
|
|
4
|
+
import type { AreaOfInterestDescriptor } from '../geo';
|
|
5
5
|
import { SRS } from '../srs';
|
|
6
6
|
import { NodeDef, NodeDefType } from '../nodeDef';
|
|
7
7
|
import { Category } from '../category';
|
|
@@ -81,7 +81,7 @@ export type SurveyDocOptions = {
|
|
|
81
81
|
headerOnFirstPageOnly?: boolean;
|
|
82
82
|
};
|
|
83
83
|
export interface SurveyProps {
|
|
84
|
-
|
|
84
|
+
areasOfInterest?: AreaOfInterestDescriptor[];
|
|
85
85
|
collectUri?: string;
|
|
86
86
|
cycles: {
|
|
87
87
|
[key: string]: SurveyCycle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"survey.js","sourceRoot":"","sources":["../../src/survey/survey.ts"],"names":[],"mappings":";;;AAWa,QAAA,YAAY,GAAG,GAAG,CAAA;AAM/B,IAAY,oBAcX;AAdD,WAAY,oBAAoB;IAC9B,iDAAyB,CAAA;IACzB,uDAA+B,CAAA;IAC/B,6CAAqB,CAAA;IACrB,6DAAqC,CAAA;IACrC,6CAAqB,CAAA;IACrB,2CAAmB,CAAA;IACnB,6CAAqB,CAAA;IACrB,6CAAqB,CAAA;IACrB,iDAAyB,CAAA;IACzB,6CAAqB,CAAA;IACrB,mDAA2B,CAAA;IAC3B,2CAAmB,CAAA;IACnB,6CAAqB,CAAA;AACvB,CAAC,EAdW,oBAAoB,aAApB,oBAAoB,GAApB,oBAAoB,QAc/B;AAWD,IAAY,kBAQX;AARD,WAAY,kBAAkB;IAC5B,mGAA6E,CAAA;IAC7E,qGAA+E,CAAA;IAC/E,yDAAmC,CAAA;IACnC,mFAA6D,CAAA;IAC7D,mFAA6D,CAAA;IAC7D,uGAAiF,CAAA;IACjF,qFAA+D,CAAA;AACjE,CAAC,EARW,kBAAkB,aAAlB,kBAAkB,GAAlB,kBAAkB,QAQ7B;AAMY,QAAA,sBAAsB,GAAmB;IACpD,CAAC,kBAAkB,CAAC,oCAAoC,CAAC,EAAE,IAAI;IAC/D,CAAC,kBAAkB,CAAC,qCAAqC,CAAC,EAAE,IAAI;IAChE,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,IAAI;IAC1C,CAAC,kBAAkB,CAAC,4BAA4B,CAAC,EAAE,IAAI;IACvD,CAAC,kBAAkB,CAAC,4BAA4B,CAAC,EAAE,IAAI;IACvD,CAAC,kBAAkB,CAAC,sCAAsC,CAAC,EAAE,IAAI;IACjE,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,EAAE,IAAI;CACzD,CAAA;AAED,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;AACnB,CAAC,EAHW,cAAc,aAAd,cAAc,GAAd,cAAc,QAGzB;AAEY,QAAA,sBAAsB,GAAG;IACpC,aAAa,EAAE,eAAe;IAC9B,OAAO,EAAE,SAAS;CACV,CAAA","sourcesContent":["import { ArenaObject, Dictionary } from '../common'\nimport { AuthGroup } from '../auth'\nimport { Labels, LanguageCode } from '../language'\nimport type {
|
|
1
|
+
{"version":3,"file":"survey.js","sourceRoot":"","sources":["../../src/survey/survey.ts"],"names":[],"mappings":";;;AAWa,QAAA,YAAY,GAAG,GAAG,CAAA;AAM/B,IAAY,oBAcX;AAdD,WAAY,oBAAoB;IAC9B,iDAAyB,CAAA;IACzB,uDAA+B,CAAA;IAC/B,6CAAqB,CAAA;IACrB,6DAAqC,CAAA;IACrC,6CAAqB,CAAA;IACrB,2CAAmB,CAAA;IACnB,6CAAqB,CAAA;IACrB,6CAAqB,CAAA;IACrB,iDAAyB,CAAA;IACzB,6CAAqB,CAAA;IACrB,mDAA2B,CAAA;IAC3B,2CAAmB,CAAA;IACnB,6CAAqB,CAAA;AACvB,CAAC,EAdW,oBAAoB,aAApB,oBAAoB,GAApB,oBAAoB,QAc/B;AAWD,IAAY,kBAQX;AARD,WAAY,kBAAkB;IAC5B,mGAA6E,CAAA;IAC7E,qGAA+E,CAAA;IAC/E,yDAAmC,CAAA;IACnC,mFAA6D,CAAA;IAC7D,mFAA6D,CAAA;IAC7D,uGAAiF,CAAA;IACjF,qFAA+D,CAAA;AACjE,CAAC,EARW,kBAAkB,aAAlB,kBAAkB,GAAlB,kBAAkB,QAQ7B;AAMY,QAAA,sBAAsB,GAAmB;IACpD,CAAC,kBAAkB,CAAC,oCAAoC,CAAC,EAAE,IAAI;IAC/D,CAAC,kBAAkB,CAAC,qCAAqC,CAAC,EAAE,IAAI;IAChE,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,IAAI;IAC1C,CAAC,kBAAkB,CAAC,4BAA4B,CAAC,EAAE,IAAI;IACvD,CAAC,kBAAkB,CAAC,4BAA4B,CAAC,EAAE,IAAI;IACvD,CAAC,kBAAkB,CAAC,sCAAsC,CAAC,EAAE,IAAI;IACjE,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,EAAE,IAAI;CACzD,CAAA;AAED,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;AACnB,CAAC,EAHW,cAAc,aAAd,cAAc,GAAd,cAAc,QAGzB;AAEY,QAAA,sBAAsB,GAAG;IACpC,aAAa,EAAE,eAAe;IAC9B,OAAO,EAAE,SAAS;CACV,CAAA","sourcesContent":["import { ArenaObject, Dictionary } from '../common'\nimport { AuthGroup } from '../auth'\nimport { Labels, LanguageCode } from '../language'\nimport type { AreaOfInterestDescriptor } from '../geo'\nimport { SRS } from '../srs'\n\nimport { NodeDef, NodeDefType } from '../nodeDef'\nimport { Category } from '../category'\nimport { Taxonomy } from '../taxonomy'\nimport { SurveyRefData } from './refData/refData'\n\nexport const defaultCycle = '0'\n\nexport interface SurveyDependency {\n [nodeDefUuid: string]: string[] | boolean\n}\n\nexport enum SurveyDependencyType {\n applicable = 'applicable',\n defaultValues = 'defaultValues',\n editable = 'editable',\n enumeratingItems = 'enumeratingItems',\n fileName = 'fileName',\n formula = 'formula',\n maxCount = 'maxCount',\n minCount = 'minCount',\n parentCode = 'parentCode',\n required = 'required',\n validations = 'validations',\n visible = 'visible',\n onUpdate = 'onUpdate', // dependencies updated on every record update, stored as dictionary of booleans\n}\n\nexport type SurveyDependencyGraph = {\n [key in SurveyDependencyType]: SurveyDependency\n}\n\nexport interface SurveyCycle {\n dateEnd?: string\n dateStart: string\n}\n\nexport enum SurveySecurityProp {\n dataEditorViewNotOwnedRecordsAllowed = 'dataEditorViewNotOwnedRecordsAllowed',\n dataAnalystViewNotOwnedRecordsAllowed = 'dataAnalystViewNotOwnedRecordsAllowed',\n visibleInMobile = 'visibleInMobile',\n allowRecordsDownloadInMobile = 'allowRecordsDownloadInMobile',\n allowRecordsUploadFromMobile = 'allowRecordsUploadFromMobile',\n allowRecordsWithErrorsUploadFromMobile = 'allowRecordsWithErrorsUploadFromMobile',\n allowRecordsMergeWithSameKeys = 'allowRecordsMergeWithSameKeys',\n}\n\nexport type SurveySecurity = {\n [key in SurveySecurityProp]?: boolean\n}\n\nexport const surveySecurityDefaults: SurveySecurity = {\n [SurveySecurityProp.dataEditorViewNotOwnedRecordsAllowed]: true,\n [SurveySecurityProp.dataAnalystViewNotOwnedRecordsAllowed]: true,\n [SurveySecurityProp.visibleInMobile]: true,\n [SurveySecurityProp.allowRecordsDownloadInMobile]: true,\n [SurveySecurityProp.allowRecordsUploadFromMobile]: true,\n [SurveySecurityProp.allowRecordsWithErrorsUploadFromMobile]: true,\n [SurveySecurityProp.allowRecordsMergeWithSameKeys]: true,\n}\n\nexport enum SurveyDocPlace {\n header = 'header',\n footer = 'footer',\n}\n\nexport const surveyDocImagePropKeys = {\n documentPlace: 'documentPlace',\n applyIf: 'applyIf',\n} as const\n\nexport type SurveyDocImageProps = SurveyFileProps & {\n documentPlace?: SurveyDocPlace\n applyIf?: string\n}\n\nexport type SurveyFileProps = {\n deleted?: boolean\n labels?: Labels\n name?: string\n nodeUuid?: string\n recordUuid?: string\n size?: number | null\n temporary?: boolean\n type?: string\n}\n\nexport type SurveyFile = {\n uuid: string\n props: SurveyFileProps\n content?: Buffer | null\n dateCreated: string\n}\n\nexport type SurveyDocImage = SurveyFile & {\n props: SurveyDocImageProps\n}\n\nexport type SurveyDocOptions = {\n headerOnFirstPageOnly?: boolean // default: true\n}\n\nexport interface SurveyProps {\n areasOfInterest?: AreaOfInterestDescriptor[]\n collectUri?: string\n cycles: {\n [key: string]: SurveyCycle\n }\n defaultCycleKey?: string\n descriptions?: Labels\n fieldManualLinks?: Labels\n // when true, values of attributes becoming non-applicable are kept during data entry (default: cleared)\n keepNonApplicableValues?: boolean\n labels?: Labels\n languages: LanguageCode[]\n name: string\n preloadedMapLayers?: SurveyFile[]\n preloadedMapLayersEnabled?: boolean\n security?: SurveySecurity\n srs: SRS[]\n surveyDocImages?: SurveyDocImage[]\n surveyDocOptions?: SurveyDocOptions\n}\n\nexport interface SurveyNodeDefsIndex {\n rootDefUuid?: string\n childDefUuidPresenceByParentUuid?: { [parentUuid: string]: { [nodeDefUuid: string]: boolean } }\n nodeDefUuidByName?: Dictionary<string>\n qualifierPresenceByUuid?: { [nodeDefUuid: string]: boolean }\n}\n\nexport interface Survey extends ArenaObject<SurveyProps> {\n authGroups: Array<AuthGroup>\n dateCreated?: string\n dateModified?: string\n datePublished?: string\n dependencyGraph?: SurveyDependencyGraph\n draft: boolean\n nodeDefs?: { [nodeDefUuid: string]: NodeDef<NodeDefType> }\n ownerUuid: string\n published: boolean\n readonly id?: number\n template: boolean\n uuid: string\n /**\n * Categories indexed by uuid.\n */\n categories?: { [categoryUuid: string]: Category }\n /**\n * Taxonomies indexed by uuid.\n */\n taxonomies?: { [taxonomyUuid: string]: Taxonomy }\n /**\n * Reference data cache (category items and taxa).\n */\n refData?: SurveyRefData\n\n nodeDefsIndex?: SurveyNodeDefsIndex\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { addNodeDefDependencies, buildAndAssocDependencyGraph, getNodeDefDependents, getOnUpdateDependents, removeNodeDefDependencies } from './dependencies';
|
|
2
2
|
import { findNodeDefByName, findNodeDefByUuid, findNodeDefsByUuids, getDependentCodeAttributeDefs, getDependentEnumeratedEntityDefs, getDescendantsInSingleEntities, getNodeDefAncestorCodes, getNodeDefAncestorMultipleEntity, getNodeDefByName, getNodeDefByUuid, getNodeDefCategoryLevelIndex, getNodeDefChildren, getNodeDefChildrenSorted, getNodeDefEnumerator, getNodeDefKeys, getNodeDefParent, getNodeDefParentCode, getNodeDefRoot, getNodeDefSource, getNodeDefsByUuids, getNodeDefsIncludedInMultipleEntitySummary, getQualifierDefs, getRootKeys, isNodeDefAncestor, isNodeDefEnumerator, isNodeDefParentCode, visitAncestorsAndSelfNodeDef, visitDescendantsAndSelfNodeDef, visitNodeDefs } from './nodeDefs';
|
|
3
3
|
import { getCategoryItemByCodePaths, getCategoryItemByUuid, getCategoryItemUuidByCode, getCategoryItems, getCategoryItemsByNodeDef, getCategoryItemsInLevel, getTaxonByCode, getTaxonByUuid, getTaxonVernacularNameUuid, includesTaxonVernacularName } from './refsData';
|
|
4
|
-
import { getCategoryByName, getCategoryByUuid, getCycleKeys, getDefaultCycleKey, getDefaultLanguage, getLabelOrName, getLanguages, getLastCycleKey, getName, getSRSByCode, getSRSIndex,
|
|
4
|
+
import { getCategoryByName, getCategoryByUuid, getCycleKeys, getDefaultCycleKey, getDefaultLanguage, getLabelOrName, getLanguages, getLastCycleKey, getName, getSRSByCode, getSRSIndex, getAreasOfInterest, getAreaOfInterestByName, getSRSs, getTaxonomyByName, getTaxonomyByUuid, getAuthGroups, getAuthGroupAdmin, isKeepNonApplicableValues } from './surveysGetters';
|
|
5
5
|
import { getSecurity, isDataAnalystViewNotOwnedRecordsAllowed, isDataEditorViewNotOwnedRecordsAllowed, isRecordsDownloadInMobileAllowed, isRecordsMergeWithSameKeysAllowed, isRecordsUploadFromMobileAllowed, isRecordsWithErrorsUploadFromMobileAllowed, isVisibleInMobile } from './surveyGettersSecurity';
|
|
6
6
|
import { findApplicableDependentEnumeratedEntityDefs, getEnumeratingCategoryItems } from './surveysUtils';
|
|
7
7
|
export declare const Surveys: {
|
|
@@ -18,7 +18,8 @@ export declare const Surveys: {
|
|
|
18
18
|
getSRSs: typeof getSRSs;
|
|
19
19
|
getSRSByCode: typeof getSRSByCode;
|
|
20
20
|
getSRSIndex: typeof getSRSIndex;
|
|
21
|
-
|
|
21
|
+
getAreasOfInterest: typeof getAreasOfInterest;
|
|
22
|
+
getAreaOfInterestByName: typeof getAreaOfInterestByName;
|
|
22
23
|
getCategoryByName: typeof getCategoryByName;
|
|
23
24
|
getCategoryByUuid: typeof getCategoryByUuid;
|
|
24
25
|
getTaxonomyByName: typeof getTaxonomyByName;
|
|
@@ -21,7 +21,8 @@ exports.Surveys = {
|
|
|
21
21
|
getSRSs: surveysGetters_1.getSRSs,
|
|
22
22
|
getSRSByCode: surveysGetters_1.getSRSByCode,
|
|
23
23
|
getSRSIndex: surveysGetters_1.getSRSIndex,
|
|
24
|
-
|
|
24
|
+
getAreasOfInterest: surveysGetters_1.getAreasOfInterest,
|
|
25
|
+
getAreaOfInterestByName: surveysGetters_1.getAreaOfInterestByName,
|
|
25
26
|
getCategoryByName: surveysGetters_1.getCategoryByName,
|
|
26
27
|
getCategoryByUuid: surveysGetters_1.getCategoryByUuid,
|
|
27
28
|
getTaxonomyByName: surveysGetters_1.getTaxonomyByName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/survey/surveys/index.ts"],"names":[],"mappings":";;;AAAA,iDAMuB;AAEvB,yCAmCmB;AAEnB,yCAWmB;AAEnB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/survey/surveys/index.ts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AAiC,EAAjC,yDAAiC;IAEjC,QAAQ;IACR,2BAA2B,EAA3B,0CAA2B;IAC3B,2CAA2C,EAA3C,0DAA2C;CAC5C,CAAA","sourcesContent":["import {\n addNodeDefDependencies,\n buildAndAssocDependencyGraph,\n getNodeDefDependents,\n getOnUpdateDependents,\n removeNodeDefDependencies,\n} from './dependencies'\n\nimport {\n addNodeDefToIndex,\n buildAndAssocNodeDefsIndex,\n deleteNodeDefIndex,\n findNodeDefByName,\n findNodeDefByUuid,\n findNodeDefsByUuids,\n getDependentCodeAttributeDefs,\n getDependentEnumeratedEntityDefs,\n getDescendantsInSingleEntities,\n getNodeDefsArray,\n getNodeDefAncestorCodes,\n getNodeDefAncestorMultipleEntity,\n getNodeDefByName,\n getNodeDefByUuid,\n getNodeDefCategoryLevelIndex,\n getNodeDefChildren,\n getNodeDefChildrenSorted,\n getNodeDefEnumerator,\n getNodeDefKeys,\n getNodeDefParent,\n getNodeDefParentCode,\n getNodeDefRoot,\n getNodeDefSource,\n getNodeDefsByUuids,\n getNodeDefsIncludedInMultipleEntitySummary,\n getQualifierDefs,\n getRootKeys,\n isNodeDefAncestor,\n isNodeDefEnumerator,\n isNodeDefParentCode,\n updateNodeDefUuidByNameIndex,\n visitAncestorsAndSelfNodeDef,\n visitDescendantsAndSelfNodeDef,\n visitNodeDefs,\n} from './nodeDefs'\n\nimport {\n getCategoryItemByCodePaths,\n getCategoryItemByUuid,\n getCategoryItemUuidByCode,\n getCategoryItems,\n getCategoryItemsByNodeDef,\n getCategoryItemsInLevel,\n getTaxonByCode,\n getTaxonByUuid,\n getTaxonVernacularNameUuid,\n includesTaxonVernacularName,\n} from './refsData'\n\nimport {\n getCategoryByName,\n getCategoryByUuid,\n getCycleKeys,\n getDefaultCycleKey,\n getDefaultLanguage,\n getDescription,\n getFieldManualLink,\n getLabel,\n getLabelOrName,\n getLanguages,\n getLastCycleKey,\n getName,\n getSRSByCode,\n getSRSIndex,\n getAreasOfInterest,\n getAreaOfInterestByName,\n getSRSs,\n getTaxonomyByName,\n getTaxonomyByUuid,\n getAuthGroups,\n getAuthGroupAdmin,\n isKeepNonApplicableValues,\n} from './surveysGetters'\n\nimport {\n getSecurity,\n isDataAnalystViewNotOwnedRecordsAllowed,\n isDataEditorViewNotOwnedRecordsAllowed,\n isRecordsDownloadInMobileAllowed,\n isRecordsMergeWithSameKeysAllowed,\n isRecordsUploadFromMobileAllowed,\n isRecordsWithErrorsUploadFromMobileAllowed,\n isVisibleInMobile,\n} from './surveyGettersSecurity'\n\nimport { findApplicableDependentEnumeratedEntityDefs, getEnumeratingCategoryItems } from './surveysUtils'\n\nexport const Surveys = {\n getName,\n getLanguages,\n getDefaultLanguage,\n getLabel,\n getLabelOrName,\n getDescription,\n getFieldManualLink,\n getCycleKeys,\n getLastCycleKey,\n getDefaultCycleKey,\n getSRSs,\n getSRSByCode,\n getSRSIndex,\n getAreasOfInterest,\n getAreaOfInterestByName,\n getCategoryByName,\n getCategoryByUuid,\n getTaxonomyByName,\n getTaxonomyByUuid,\n getAuthGroups,\n getAuthGroupAdmin,\n isKeepNonApplicableValues,\n\n findNodeDefByName,\n findNodeDefByUuid,\n findNodeDefsByUuids,\n getNodeDefsArray,\n getNodeDefByName,\n getNodeDefsByUuids,\n getNodeDefByUuid,\n getNodeDefChildren,\n getNodeDefChildrenSorted,\n getNodeDefParent,\n getNodeDefAncestorMultipleEntity,\n getNodeDefRoot,\n getNodeDefSource,\n isNodeDefAncestor,\n getNodeDefKeys,\n getRootKeys,\n getNodeDefsIncludedInMultipleEntitySummary,\n getQualifierDefs,\n isNodeDefEnumerator,\n getNodeDefEnumerator,\n visitAncestorsAndSelfNodeDef,\n visitDescendantsAndSelfNodeDef,\n visitNodeDefs,\n getDescendantsInSingleEntities,\n\n // ref data\n getCategoryItemByCodePaths,\n getCategoryItemByUuid,\n getCategoryItemUuidByCode,\n getCategoryItems,\n getCategoryItemsByNodeDef,\n getCategoryItemsInLevel,\n getTaxonByCode,\n getTaxonByUuid,\n getTaxonVernacularNameUuid,\n includesTaxonVernacularName,\n\n // node def code\n getNodeDefParentCode,\n getNodeDefAncestorCodes,\n isNodeDefParentCode,\n getNodeDefCategoryLevelIndex,\n getDependentCodeAttributeDefs,\n getDependentEnumeratedEntityDefs,\n\n // dependencies\n buildAndAssocDependencyGraph,\n addNodeDefDependencies,\n getNodeDefDependents,\n getOnUpdateDependents,\n removeNodeDefDependencies,\n\n // index\n buildAndAssocNodeDefsIndex,\n addNodeDefToIndex,\n updateNodeDefUuidByNameIndex,\n deleteNodeDefIndex,\n\n // security\n getSecurity,\n isDataAnalystViewNotOwnedRecordsAllowed,\n isDataEditorViewNotOwnedRecordsAllowed,\n isVisibleInMobile,\n isRecordsDownloadInMobileAllowed,\n isRecordsUploadFromMobileAllowed,\n isRecordsWithErrorsUploadFromMobileAllowed,\n isRecordsMergeWithSameKeysAllowed,\n\n // utils\n getEnumeratingCategoryItems,\n findApplicableDependentEnumeratedEntityDefs,\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UserAuthGroup } from '../../auth';
|
|
2
2
|
import { Category } from '../../category';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AreaOfInterestDescriptor } from '../../geo';
|
|
4
4
|
import { LanguageCode } from '../../language';
|
|
5
5
|
import { SRS, SRSIndex } from '../../srs';
|
|
6
6
|
import { Taxonomy } from '../../taxonomy';
|
|
@@ -39,6 +39,10 @@ export declare const getDefaultCycleKey: (survey: Survey) => string | undefined;
|
|
|
39
39
|
export declare const getSRSs: (survey: Survey) => SRS[];
|
|
40
40
|
export declare const getSRSIndex: (survey: Survey) => SRSIndex;
|
|
41
41
|
export declare const getSRSByCode: (code: string) => (survey: Survey) => SRS | undefined;
|
|
42
|
-
export declare const
|
|
42
|
+
export declare const getAreasOfInterest: (survey: Survey) => AreaOfInterestDescriptor[];
|
|
43
|
+
export declare const getAreaOfInterestByName: (params: {
|
|
44
|
+
survey: Survey;
|
|
45
|
+
name: string;
|
|
46
|
+
}) => AreaOfInterestDescriptor | undefined;
|
|
43
47
|
export declare const getAuthGroups: (survey: Survey) => UserAuthGroup[];
|
|
44
48
|
export declare const getAuthGroupAdmin: (survey: Survey) => UserAuthGroup | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAuthGroupAdmin = exports.getAuthGroups = exports.
|
|
3
|
+
exports.getAuthGroupAdmin = exports.getAuthGroups = exports.getAreaOfInterestByName = exports.getAreasOfInterest = exports.getSRSByCode = exports.getSRSIndex = exports.getSRSs = exports.getDefaultCycleKey = exports.isKeepNonApplicableValues = exports.getLastCycleKey = exports.getCycleKeys = exports.getTaxonomyByUuid = exports.getTaxonomyByName = exports.getCategoryByUuid = exports.getCategoryByName = exports.getLabelOrName = exports.getFieldManualLink = exports.getDescription = exports.getLabel = exports.getDefaultLanguage = exports.getLanguages = exports.getName = void 0;
|
|
4
4
|
const auth_1 = require("../../auth");
|
|
5
5
|
const labels_1 = require("../../language/labels");
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
@@ -81,10 +81,12 @@ const getSRSIndex = (survey) => (0, exports.getSRSs)(survey).reduce((acc, srs) =
|
|
|
81
81
|
exports.getSRSIndex = getSRSIndex;
|
|
82
82
|
const getSRSByCode = (code) => (survey) => (0, exports.getSRSIndex)(survey)[code];
|
|
83
83
|
exports.getSRSByCode = getSRSByCode;
|
|
84
|
-
const
|
|
84
|
+
const getAreasOfInterest = (survey) => { var _a, _b, _c; var _d, _e; return (_e = (_d = (_a = survey === null || survey === void 0 ? void 0 : survey.props) === null || _a === void 0 ? void 0 : _a.areasOfInterest) !== null && _d !== void 0 ? _d :
|
|
85
85
|
// backwards compatibility with Arena: survey info props stored in info
|
|
86
|
-
(_c = (_b = survey === null || survey === void 0 ? void 0 : survey.info) === null || _b === void 0 ? void 0 : _b.props) === null || _c === void 0 ? void 0 : _c.
|
|
87
|
-
exports.
|
|
86
|
+
(_c = (_b = survey === null || survey === void 0 ? void 0 : survey.info) === null || _b === void 0 ? void 0 : _b.props) === null || _c === void 0 ? void 0 : _c.areasOfInterest) !== null && _e !== void 0 ? _e : []; };
|
|
87
|
+
exports.getAreasOfInterest = getAreasOfInterest;
|
|
88
|
+
const getAreaOfInterestByName = (params) => (0, exports.getAreasOfInterest)(params.survey).find((areaOfInterest) => areaOfInterest.name === params.name);
|
|
89
|
+
exports.getAreaOfInterestByName = getAreaOfInterestByName;
|
|
88
90
|
const getAuthGroups = (survey) => { var _a; return (_a = survey === null || survey === void 0 ? void 0 : survey.authGroups) !== null && _a !== void 0 ? _a : []; };
|
|
89
91
|
exports.getAuthGroups = getAuthGroups;
|
|
90
92
|
const getAuthGroupAdmin = (survey) => (0, exports.getAuthGroups)(survey).find((authGroup) => authGroup.name === auth_1.AuthGroupName.surveyAdmin);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surveysGetters.js","sourceRoot":"","sources":["../../../src/survey/surveys/surveysGetters.ts"],"names":[],"mappings":";;;AAAA,qCAAyD;AAIzD,kDAAyD;AAGzD,uCAA6C;AAGtC,MAAM,OAAO,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAA;AAAvD,QAAA,OAAO,GAAP,OAAO,CAAgD;AAE7D,MAAM,YAAY,GAAG,CAAC,MAAc,EAAkB,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAA;AAAzE,QAAA,YAAY,GAAZ,YAAY,CAA6D;AAE/E,MAAM,kBAAkB,GAAG,CAAC,MAAc,EAAgB,EAAE,CAAC,IAAA,QAAA,YAAY,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AAA9E,QAAA,kBAAkB,GAAlB,kBAAkB,CAA4D;AAE3F,MAAM,qBAAqB,GACzB,CAAC,IAAoD,EAAE,EAAE,CACzD,CAAC,QAAuB,EAAE,EAAE,CAC5B,CAAC,MAAc,EAA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c,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,CAAA;AAJpF,QAAA,uBAAuB,GAAvB,uBAAuB,CAI6D;AAE1F,MAAM,aAAa,GAAG,CAAC,MAAc,EAAmB,EAAE,wBAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,UAAU,mCAAI,EAAE,GAAA,CAAA;AAA7E,QAAA,aAAa,GAAb,aAAa,CAAgE;AAEnF,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAA6B,EAAE,CAC7E,IAAA,QAAA,aAAa,EAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,oBAAa,CAAC,WAAW,CAAC,CAAA;AAD5E,QAAA,iBAAiB,GAAjB,iBAAiB,CAC2D","sourcesContent":["import { AuthGroupName, UserAuthGroup } from '../../auth'\nimport { Category } from '../../category'\nimport type { AreaOfInterestDescriptor } from '../../geo'\nimport { LanguageCode } from '../../language'\nimport { getLabelOrDefault } from '../../language/labels'\nimport { SRS, SRSIndex } from '../../srs'\nimport { Taxonomy } from '../../taxonomy'\nimport { Arrays, Objects } from '../../utils'\nimport { Survey } from '../survey'\n\nexport const getName = (survey: Survey): string => survey.props.name\n\nexport const getLanguages = (survey: Survey): LanguageCode[] => survey.props.languages\n\nexport const getDefaultLanguage = (survey: Survey): LanguageCode => getLanguages(survey)[0]\n\nconst getMultilangPropValue =\n (prop: 'labels' | 'descriptions' | 'fieldManualLinks') =>\n (langCode?: LanguageCode) =>\n (survey: Survey): string | undefined => {\n const languageCode = langCode ?? getDefaultLanguage(survey)\n return survey.props[prop]?.[languageCode]\n }\nexport const getLabel = getMultilangPropValue('labels')\nexport const getDescription = getMultilangPropValue('descriptions')\nexport const getFieldManualLink = getMultilangPropValue('fieldManualLinks')\n\n/**\n * Returns the survey label in the specified language (the default language if not specified), or the survey name\n * when the label is missing or empty.\n */\nexport const getLabelOrName =\n (langCode?: LanguageCode) =>\n (survey: Survey): string =>\n getLabelOrDefault(survey.props.labels, langCode ?? getDefaultLanguage(survey), getName(survey))\n\nexport const getCategoryByName = (params: { survey: Survey; categoryName: string }): Category | undefined => {\n const { survey, categoryName } = params\n return survey.categories\n ? Object.values(survey.categories).find((category) => category.props.name === categoryName)\n : undefined\n}\n\nexport const getCategoryByUuid = (params: { survey: Survey; categoryUuid: string }): Category | undefined => {\n const { survey, categoryUuid } = params\n return survey.categories?.[categoryUuid]\n}\n\nexport const getTaxonomyByName = (params: { survey: Survey; taxonomyName: string }): Taxonomy | undefined => {\n const { survey, taxonomyName } = params\n return survey.taxonomies\n ? Object.values(survey.taxonomies).find((taxonomy) => taxonomy.props.name === taxonomyName)\n : undefined\n}\n\nexport const getTaxonomyByUuid = (params: { survey: Survey; taxonomyUuid: string }): Taxonomy | undefined => {\n const { survey, taxonomyUuid } = params\n return survey.taxonomies?.[taxonomyUuid]\n}\n\nexport const getCycleKeys = (survey: Survey): string[] => {\n const cycles = survey.props?.cycles ?? {}\n return Object.keys(cycles)\n}\n\nexport const getLastCycleKey = (survey: Survey): string => Arrays.last(getCycleKeys(survey)) as string\n\nexport const isKeepNonApplicableValues = (survey: Survey): boolean => survey?.props?.keepNonApplicableValues === true\n\nexport const getDefaultCycleKey = (survey: Survey) => {\n const defaultCycleKey = survey.props?.defaultCycleKey\n const lastCycleKey = getLastCycleKey(survey)\n return Objects.isEmpty(defaultCycleKey) || Number(defaultCycleKey) > Number(lastCycleKey)\n ? lastCycleKey\n : defaultCycleKey\n}\n\nexport const getSRSs = (survey: Survey): SRS[] =>\n survey.props?.srs ??\n // backwards compatibility with Arena: srs stored in info in UI\n (survey as any).info?.props?.srs ??\n []\n\nexport const getSRSIndex = (survey: Survey): SRSIndex =>\n getSRSs(survey).reduce((acc: SRSIndex, srs) => {\n acc[srs.code] = srs\n return acc\n }, {})\n\nexport const getSRSByCode =\n (code: string) =>\n (survey: Survey): SRS | undefined =>\n getSRSIndex(survey)[code]\n\nexport const getAreasOfInterest = (survey: Survey): AreaOfInterestDescriptor[] =>\n survey?.props?.areasOfInterest ??\n // backwards compatibility with Arena: survey info props stored in info\n (survey as any)?.info?.props?.areasOfInterest ??\n []\n\nexport const getAreaOfInterestByName = (params: {\n survey: Survey\n name: string\n}): AreaOfInterestDescriptor | undefined =>\n getAreasOfInterest(params.survey).find((areaOfInterest) => areaOfInterest.name === params.name)\n\nexport const getAuthGroups = (survey: Survey): UserAuthGroup[] => survey?.authGroups ?? []\n\nexport const getAuthGroupAdmin = (survey: Survey): UserAuthGroup | undefined =>\n getAuthGroups(survey).find((authGroup) => authGroup.name === AuthGroupName.surveyAdmin)\n"]}
|