@openforis/arena-core 3.0.0 → 3.1.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/esm/index.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/nodeDef/factory.js.map +1 -1
- package/dist/esm/nodeDef/index.js.map +1 -1
- package/dist/esm/nodeDef/nodeDef.js.map +1 -1
- package/dist/esm/nodeDef/nodeDefs.js.map +1 -1
- package/dist/esm/nodeDef/service.js.map +1 -1
- package/dist/esm/nodeDefExpressionEvaluator/context.js.map +1 -1
- package/dist/esm/nodeDefExpressionEvaluator/node/identifier.js.map +1 -1
- package/dist/esm/record/_records/nodeDefSelfReferences.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/recordNodesUpdater/recordNodeDependentsRequiredUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeKeyValidator.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeTypeValidator.js +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/countValidator.js.map +1 -1
- package/dist/esm/survey/survey.js.map +1 -1
- package/dist/esm/survey/surveys/_nodeDefs/nodeDefsReader.js.map +1 -1
- package/dist/esm/survey/surveys/dependencies.js.map +1 -1
- package/dist/esm/survey/surveys/nodeDefs.js.map +1 -1
- package/dist/esm/tests/builder/recordBuilder/nodeBuilder.js.map +1 -1
- package/dist/esm/tests/builder/surveyBuilder/nodeDefAttributeBuilder.js.map +1 -1
- package/dist/esm/tests/builder/surveyBuilder/nodeDefBuilder.js.map +1 -1
- package/dist/esm/tests/builder/surveyBuilder/nodeDefCodeBuilder.js.map +1 -1
- package/dist/esm/tests/builder/surveyBuilder/nodeDefEntityBuilder.js.map +1 -1
- package/dist/esm/tests/builder/surveyBuilder/nodeDefTaxonBuilder.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.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 +3 -3
- package/dist/node/nodeValues.js.map +1 -1
- package/dist/nodeDef/factory.d.ts +3 -3
- package/dist/nodeDef/factory.js.map +1 -1
- package/dist/nodeDef/index.d.ts +1 -1
- package/dist/nodeDef/index.js.map +1 -1
- package/dist/nodeDef/nodeDef.d.ts +2 -0
- package/dist/nodeDef/nodeDef.js.map +1 -1
- package/dist/nodeDef/nodeDefs.d.ts +50 -50
- package/dist/nodeDef/nodeDefs.js.map +1 -1
- package/dist/nodeDef/service.d.ts +7 -7
- package/dist/nodeDef/service.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/context.d.ts +3 -4
- package/dist/nodeDefExpressionEvaluator/context.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/node/identifier.d.ts +2 -2
- package/dist/nodeDefExpressionEvaluator/node/identifier.js.map +1 -1
- package/dist/record/_records/nodeDefSelfReferences.d.ts +2 -2
- package/dist/record/_records/nodeDefSelfReferences.js.map +1 -1
- package/dist/record/_records/recordCompletion.js.map +1 -1
- package/dist/record/_records/recordGetters.d.ts +4 -4
- package/dist/record/_records/recordGetters.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.d.ts +2 -2
- package/dist/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.d.ts +2 -2
- package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
- package/dist/record/recordValidator/attributeKeyValidator.d.ts +3 -3
- package/dist/record/recordValidator/attributeKeyValidator.js.map +1 -1
- package/dist/record/recordValidator/attributeTypeValidator.d.ts +2 -2
- package/dist/record/recordValidator/attributeTypeValidator.js.map +1 -1
- package/dist/record/recordValidator/attributeUniqueValidator.d.ts +2 -2
- package/dist/record/recordValidator/attributeUniqueValidator.js.map +1 -1
- package/dist/record/recordValidator/attributeValidator.js.map +1 -1
- package/dist/record/recordValidator/countValidator.d.ts +2 -2
- package/dist/record/recordValidator/countValidator.js.map +1 -1
- package/dist/survey/survey.d.ts +2 -2
- package/dist/survey/survey.js.map +1 -1
- package/dist/survey/surveys/_nodeDefs/nodeDefsReader.d.ts +3 -3
- package/dist/survey/surveys/_nodeDefs/nodeDefsReader.js.map +1 -1
- package/dist/survey/surveys/dependencies.d.ts +4 -4
- package/dist/survey/surveys/dependencies.js.map +1 -1
- package/dist/survey/surveys/nodeDefs.d.ts +28 -28
- package/dist/survey/surveys/nodeDefs.js.map +1 -1
- package/dist/tests/builder/recordBuilder/nodeBuilder.d.ts +2 -2
- package/dist/tests/builder/recordBuilder/nodeBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/nodeDefAttributeBuilder.d.ts +2 -2
- package/dist/tests/builder/surveyBuilder/nodeDefAttributeBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/nodeDefBuilder.d.ts +3 -3
- package/dist/tests/builder/surveyBuilder/nodeDefBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/nodeDefCodeBuilder.d.ts +2 -2
- package/dist/tests/builder/surveyBuilder/nodeDefCodeBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/nodeDefEntityBuilder.d.ts +2 -2
- package/dist/tests/builder/surveyBuilder/nodeDefEntityBuilder.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/nodeDefTaxonBuilder.d.ts +2 -2
- package/dist/tests/builder/surveyBuilder/nodeDefTaxonBuilder.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributeValidator.js","sourceRoot":"","sources":["../../../../src/record/recordValidator/attributeValidator.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAmB,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC3F,OAAO,EAA2D,QAAQ,EAAe,MAAM,eAAe,CAAA;AAC9G,OAAO,EAAe,OAAO,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrC,OAAO,EACL,iBAAiB,EAEjB,uBAAuB,EACvB,kBAAkB,EAClB,SAAS,GACV,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAA;AACxE,OAAO,EACL,kCAAkC,GAEnC,MAAM,yDAAyD,CAAA;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2DAA2D,CAAA;AAC9F,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAmB,MAAM,yBAAyB,CAAA;AACvG,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAErE,MAAM,mBAAmB,GAAG,IAAI,yBAAyB,EAAE,CAAA;AAkC3D,MAAM,wBAAwB,GAAG,CAC/B,MAAsF,EACrB,EAAE;IACnE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB,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;QACpC,iEAAiE;QACjE,IAAI,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAChE,qEAAqE;YACrE,MAAM,wBAAwB,mCAAQ,MAAM,KAAE,SAAS,EAAE,cAAc,EAAE,eAAe,GAAE,CAAA;YAC1F,qBAAqB,CAAC,QAAQ,CAAC,GAAG,MAAM,iBAAiB,CAAC,wBAAwB,CAAC,CAAA,CAAC,UAAU;QAChG,CAAC;IACH,CAAC;IACD,OAAO,qBAAqB,CAAA;AAC9B,CAAC,CAAA,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,wCAAwC;CACzC,CAAA","sourcesContent":["import { ArenaDictionary } from '../../common'\nimport { ArenaLabels } from '../../language'\nimport { ArenaRecordNode, RecordNodeKeys, RecordNodes, RecordNodeValues } from '../../node'\nimport { ArenaNodeDef, ArenaNodeDefExpression, ArenaNodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { ArenaSurvey, Surveys } from '../../survey'\nimport { SurveyDependencyType } from '../../survey/survey'\nimport { Objects } from '../../utils'\nimport {\n ValidationFactory,\n ArenaValidationResult,\n ValidationResultFactory,\n ValidationSeverity,\n Validator,\n} from '../../validation'\nimport { ArenaValidationFields } from '../../validation/validation'\nimport { RecordNodePointers } from '../nodePointers'\nimport { ArenaRecord } from '../record'\nimport { RecordExpressionEvaluator } from '../recordExpressionEvaluator'\nimport {\n RecordExpressionEvaluationContexts,\n RecordExpressionEvaluationParams,\n} from '../recordNodesUpdater/recordExpressionEvaluationContext'\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\n// the params of the record expression evaluator (validation expressions, required if)\nexport type ArenaRecordValidatorParams = RecordExpressionEvaluationParams\n\nexport interface ArenaAttributeValidatorParams extends ArenaRecordValidatorParams {\n attribute: ArenaRecordNode\n}\n\nexport interface ArenaAttributesValidatorParams extends ArenaRecordValidatorParams {\n nodes: ArenaDictionary<ArenaRecordNode>\n}\n\nexport interface ArenaSortedAttributesValidatorParams extends ArenaRecordValidatorParams {\n nodesArray: ArenaRecordNode[]\n}\n\ntype SiblingKeyNodeItem = { entityUuid: string; keyNode: ArenaRecordNode; hasErrors: boolean }\n\ntype SiblingKeyNodesGroup = {\n items: SiblingKeyNodeItem[]\n // items whose key node is not validated anyway (not in the nodes to validate): only these are compared by value\n itemsToCompare?: SiblingKeyNodeItem[]\n // entity of the first key attribute validated in this group: its key nodes with errors are not added\n // until a key attribute of another entity is validated\n firstEntityUuid?: string\n allItemsWithErrorsAdded?: boolean\n}\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, SiblingKeyNodesGroup>\n\nconst _getSiblingNodeKeysGroup = (\n params: ArenaAttributeValidatorParams & { siblingKeyNodesCache: SiblingKeyNodesCache }\n): { entityUuid: string; group: SiblingKeyNodesGroup } | undefined => {\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) return undefined\n\n const ancestorMultipleEntity = Records.getAncestor(attribute, ancestorMultipleEntityDef.uuid)(record)\n if (!ancestorMultipleEntity) return undefined\n\n const ancestorMultipleEntityParent = Records.getParent(ancestorMultipleEntity)(record)\n if (!ancestorMultipleEntityParent) return undefined\n\n const cacheKey = `${ancestorMultipleEntityParent.uuid}_${ancestorMultipleEntityDef.uuid}`\n let group = siblingKeyNodesCache.get(cacheKey)\n if (!group) {\n const keyDefs = Surveys.getNodeDefKeys({ survey, nodeDef: ancestorMultipleEntityDef })\n const entities = Records.getEntitySiblings(ancestorMultipleEntity, true)(record)\n const items: SiblingKeyNodeItem[] = []\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 group = { items }\n siblingKeyNodesCache.set(cacheKey, group)\n }\n return { entityUuid: ancestorMultipleEntity.uuid, group }\n}\n\nconst _getValidationMessagesWithDefault = (params: {\n survey: ArenaSurvey\n expression: ArenaNodeDefExpression\n defaultMessage?: string\n}): ArenaLabels => {\n const { survey, expression, defaultMessage } = params\n const messages: ArenaLabels = { ...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: ArenaAttributeValidatorParams & { nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps> }\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: ArenaAttributeValidatorParams & { nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps> }) =>\n async (_field: string, node: any): Promise<ArenaValidationResult> => {\n const valid = !RecordNodes.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: ArenaRecordValidatorParams & { nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps> }) =>\n async (_propName: string, node: ArenaRecordNode): Promise<ArenaValidationResult> => {\n const { survey, nodeDef } = params\n if (RecordNodes.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 ...RecordExpressionEvaluationContexts.extractEvaluationParams(params),\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: ArenaAttributeValidatorParams & { 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 [RecordNodeKeys.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: ArenaAttributeValidatorParams & {\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n nodeParent?: ArenaRecordNode\n siblingKeyNodesCache: SiblingKeyNodesCache\n nodeUuidsToValidate: Set<string>\n }\n): ArenaRecordNode[] => {\n const { survey, nodeDef, nodeParent: parentNode, attribute, nodeUuidsToValidate } = params\n if (\n !NodeDefs.isKey(nodeDef) ||\n !parentNode ||\n (NodeDefs.isAutoIncrementalKey(nodeDef) && attribute.created && RecordNodes.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 siblingNodeKeysGroup = _getSiblingNodeKeysGroup(params)\n if (!siblingNodeKeysGroup) return []\n\n const { entityUuid, group } = siblingNodeKeysGroup\n // key nodes in the nodes to validate are validated anyway: no need to compare their value\n group.itemsToCompare ??= group.items.filter((item) => !nodeUuidsToValidate.has(item.keyNode.uuid))\n\n const result: ArenaRecordNode[] = []\n for (const { entityUuid: itemEntityUuid, keyNode } of group.itemsToCompare) {\n if (\n itemEntityUuid !== entityUuid &&\n RecordNodeValues.isValueEqual({ survey, nodeDef, parentNode, value: keyNode.value, valueSearch: attribute.value })\n ) {\n result.push(keyNode)\n }\n }\n return result.concat(_findSiblingKeyNodesWithErrorsNotAdded({ group, entityUuid }))\n}\n\n// key nodes with errors (in entities other than the attribute's one) are added only once per group\nconst _findSiblingKeyNodesWithErrorsNotAdded = (params: {\n group: SiblingKeyNodesGroup\n entityUuid: string\n}): ArenaRecordNode[] => {\n const { group, entityUuid } = params\n if (group.firstEntityUuid === undefined) {\n group.firstEntityUuid = entityUuid\n return group.items.filter((item) => item.hasErrors && item.entityUuid !== entityUuid).map((item) => item.keyNode)\n }\n if (group.allItemsWithErrorsAdded || group.firstEntityUuid === entityUuid) return []\n group.allItemsWithErrorsAdded = true\n const { firstEntityUuid } = group\n return group.items.filter((item) => item.hasErrors && item.entityUuid === firstEntityUuid).map((item) => item.keyNode)\n}\n\n// attribute siblings (same attribute def in the sibling entities) added to the nodes to validate,\n// by parent entity def and parent of the parent entity\ntype AttributeSiblingsAddedCache = Map<string, { firstParentEntity: ArenaRecordNode; allSiblingsAdded?: boolean }>\n\nconst findUniqueAttributeSiblingsToValidate = (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n nodeParent?: ArenaRecordNode\n attributeSiblingsAddedCache: AttributeSiblingsAddedCache\n}): ArenaRecordNode[] => {\n const { record, node, nodeDef, nodeParent, attributeSiblingsAddedCache } = params\n if (!nodeParent) return []\n const nodeParentParent = Records.getParent(nodeParent)(record)\n if (!nodeParentParent) return []\n // the siblings of the attribute are the attributes in the other parent entities:\n // after visiting attributes in 2 different parent entities, all the attributes of the group have been added\n const cacheKey = `${nodeParentParent.uuid}_${nodeParent.nodeDefUuid}_${nodeDef.uuid}`\n const cached = attributeSiblingsAddedCache.get(cacheKey)\n if (!cached) {\n attributeSiblingsAddedCache.set(cacheKey, { firstParentEntity: nodeParent })\n return Records.getAttributeSiblings(node, nodeDef)(record)\n }\n if (cached.allSiblingsAdded || cached.firstParentEntity.uuid === nodeParent.uuid) return []\n cached.allSiblingsAdded = true\n return Records.getChildren(cached.firstParentEntity, nodeDef.uuid)(record)\n}\n\nconst findSortedNodesToValidate = (params: ArenaSortedAttributesValidatorParams): ArenaRecordNode[] => {\n const { survey, record, nodesArray } = params\n\n const result: ArenaRecordNode[] = []\n const resultUuids = new Set<string>()\n const addToResult = (nodes: ArenaRecordNode[]) => {\n for (const node of nodes) {\n if (!resultUuids.has(node.uuid)) {\n resultUuids.add(node.uuid)\n result.push(node)\n }\n }\n }\n // every attribute in nodesArray is validated (it's included in its own dependents)\n const nodeUuidsToValidate = new Set(nodesArray.map((node) => node.uuid))\n const siblingKeyNodesCache: SiblingKeyNodesCache = new Map()\n const attributeSiblingsAddedCache: AttributeSiblingsAddedCache = 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 addToResult(\n RecordNodePointers.getNodesFromNodePointers({ record, nodePointers: nodePointersAttributeAndDependents })\n )\n addToResult(\n findSiblingKeyNodesToValidate({\n ...params,\n nodeDef,\n nodeParent,\n attribute: node,\n siblingKeyNodesCache,\n nodeUuidsToValidate,\n })\n )\n\n if (NodeDefs.getValidations(nodeDef)?.unique) {\n addToResult(\n findUniqueAttributeSiblingsToValidate({ record, node, nodeDef, nodeParent, attributeSiblingsAddedCache })\n )\n }\n }\n\n return result\n}\n\nconst validateSelfAndDependentSortedAttributes = async (\n params: ArenaSortedAttributesValidatorParams\n): Promise<ArenaValidationFields> => {\n const nodesToValidate: ArenaRecordNode[] = findSortedNodesToValidate(params)\n const validationsByNodeUuid: ArenaValidationFields = {}\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":";;;;;;;;;AAEA,OAAO,EAAmB,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC3F,OAAO,EAA2C,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjF,OAAO,EAAe,OAAO,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrC,OAAO,EACL,iBAAiB,EAEjB,uBAAuB,EACvB,kBAAkB,EAClB,SAAS,GACV,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAA;AACxE,OAAO,EACL,kCAAkC,GAEnC,MAAM,yDAAyD,CAAA;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2DAA2D,CAAA;AAC9F,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAmB,MAAM,yBAAyB,CAAA;AACvG,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAErE,MAAM,mBAAmB,GAAG,IAAI,yBAAyB,EAAE,CAAA;AAkC3D,MAAM,wBAAwB,GAAG,CAC/B,MAAsF,EACrB,EAAE;IACnE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAA;IAElE,MAAM,YAAY,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C,OAAO,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAChE,qEAAqE;YACrE,MAAM,wBAAwB,mCAAQ,MAAM,KAAE,SAAS,EAAE,cAAc,EAAE,eAAe,GAAE,CAAA;YAC1F,qBAAqB,CAAC,QAAQ,CAAC,GAAG,MAAM,iBAAiB,CAAC,wBAAwB,CAAC,CAAA,CAAC,UAAU;QAChG,CAAC;IACH,CAAC;IACD,OAAO,qBAAqB,CAAA;AAC9B,CAAC,CAAA,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,wCAAwC;CACzC,CAAA","sourcesContent":["import { ArenaDictionary } from '../../common'\nimport { ArenaLabels } from '../../language'\nimport { ArenaRecordNode, RecordNodeKeys, RecordNodes, RecordNodeValues } from '../../node'\nimport { ArenaAnyNodeDef, ArenaNodeDefExpression, NodeDefs } from '../../nodeDef'\nimport { ArenaSurvey, Surveys } from '../../survey'\nimport { SurveyDependencyType } from '../../survey/survey'\nimport { Objects } from '../../utils'\nimport {\n ValidationFactory,\n ArenaValidationResult,\n ValidationResultFactory,\n ValidationSeverity,\n Validator,\n} from '../../validation'\nimport { ArenaValidationFields } from '../../validation/validation'\nimport { RecordNodePointers } from '../nodePointers'\nimport { ArenaRecord } from '../record'\nimport { RecordExpressionEvaluator } from '../recordExpressionEvaluator'\nimport {\n RecordExpressionEvaluationContexts,\n RecordExpressionEvaluationParams,\n} from '../recordNodesUpdater/recordExpressionEvaluationContext'\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\n// the params of the record expression evaluator (validation expressions, required if)\nexport type ArenaRecordValidatorParams = RecordExpressionEvaluationParams\n\nexport interface ArenaAttributeValidatorParams extends ArenaRecordValidatorParams {\n attribute: ArenaRecordNode\n}\n\nexport interface ArenaAttributesValidatorParams extends ArenaRecordValidatorParams {\n nodes: ArenaDictionary<ArenaRecordNode>\n}\n\nexport interface ArenaSortedAttributesValidatorParams extends ArenaRecordValidatorParams {\n nodesArray: ArenaRecordNode[]\n}\n\ntype SiblingKeyNodeItem = { entityUuid: string; keyNode: ArenaRecordNode; hasErrors: boolean }\n\ntype SiblingKeyNodesGroup = {\n items: SiblingKeyNodeItem[]\n // items whose key node is not validated anyway (not in the nodes to validate): only these are compared by value\n itemsToCompare?: SiblingKeyNodeItem[]\n // entity of the first key attribute validated in this group: its key nodes with errors are not added\n // until a key attribute of another entity is validated\n firstEntityUuid?: string\n allItemsWithErrorsAdded?: boolean\n}\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, SiblingKeyNodesGroup>\n\nconst _getSiblingNodeKeysGroup = (\n params: ArenaAttributeValidatorParams & { siblingKeyNodesCache: SiblingKeyNodesCache }\n): { entityUuid: string; group: SiblingKeyNodesGroup } | undefined => {\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) return undefined\n\n const ancestorMultipleEntity = Records.getAncestor(attribute, ancestorMultipleEntityDef.uuid)(record)\n if (!ancestorMultipleEntity) return undefined\n\n const ancestorMultipleEntityParent = Records.getParent(ancestorMultipleEntity)(record)\n if (!ancestorMultipleEntityParent) return undefined\n\n const cacheKey = `${ancestorMultipleEntityParent.uuid}_${ancestorMultipleEntityDef.uuid}`\n let group = siblingKeyNodesCache.get(cacheKey)\n if (!group) {\n const keyDefs = Surveys.getNodeDefKeys({ survey, nodeDef: ancestorMultipleEntityDef })\n const entities = Records.getEntitySiblings(ancestorMultipleEntity, true)(record)\n const items: SiblingKeyNodeItem[] = []\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 group = { items }\n siblingKeyNodesCache.set(cacheKey, group)\n }\n return { entityUuid: ancestorMultipleEntity.uuid, group }\n}\n\nconst _getValidationMessagesWithDefault = (params: {\n survey: ArenaSurvey\n expression: ArenaNodeDefExpression\n defaultMessage?: string\n}): ArenaLabels => {\n const { survey, expression, defaultMessage } = params\n const messages: ArenaLabels = { ...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: ArenaAttributeValidatorParams & { nodeDef: ArenaAnyNodeDef }\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: ArenaAttributeValidatorParams & { nodeDef: ArenaAnyNodeDef }) =>\n async (_field: string, node: any): Promise<ArenaValidationResult> => {\n const valid = !RecordNodes.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: ArenaRecordValidatorParams & { nodeDef: ArenaAnyNodeDef }) =>\n async (_propName: string, node: ArenaRecordNode): Promise<ArenaValidationResult> => {\n const { survey, nodeDef } = params\n if (RecordNodes.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 ...RecordExpressionEvaluationContexts.extractEvaluationParams(params),\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: ArenaAttributeValidatorParams & { 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 [RecordNodeKeys.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: ArenaAttributeValidatorParams & {\n nodeDef: ArenaAnyNodeDef\n nodeParent?: ArenaRecordNode\n siblingKeyNodesCache: SiblingKeyNodesCache\n nodeUuidsToValidate: Set<string>\n }\n): ArenaRecordNode[] => {\n const { survey, nodeDef, nodeParent: parentNode, attribute, nodeUuidsToValidate } = params\n if (\n !NodeDefs.isKey(nodeDef) ||\n !parentNode ||\n (NodeDefs.isAutoIncrementalKey(nodeDef) && attribute.created && RecordNodes.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 siblingNodeKeysGroup = _getSiblingNodeKeysGroup(params)\n if (!siblingNodeKeysGroup) return []\n\n const { entityUuid, group } = siblingNodeKeysGroup\n // key nodes in the nodes to validate are validated anyway: no need to compare their value\n group.itemsToCompare ??= group.items.filter((item) => !nodeUuidsToValidate.has(item.keyNode.uuid))\n\n const result: ArenaRecordNode[] = []\n for (const { entityUuid: itemEntityUuid, keyNode } of group.itemsToCompare) {\n if (\n itemEntityUuid !== entityUuid &&\n RecordNodeValues.isValueEqual({ survey, nodeDef, parentNode, value: keyNode.value, valueSearch: attribute.value })\n ) {\n result.push(keyNode)\n }\n }\n return result.concat(_findSiblingKeyNodesWithErrorsNotAdded({ group, entityUuid }))\n}\n\n// key nodes with errors (in entities other than the attribute's one) are added only once per group\nconst _findSiblingKeyNodesWithErrorsNotAdded = (params: {\n group: SiblingKeyNodesGroup\n entityUuid: string\n}): ArenaRecordNode[] => {\n const { group, entityUuid } = params\n if (group.firstEntityUuid === undefined) {\n group.firstEntityUuid = entityUuid\n return group.items.filter((item) => item.hasErrors && item.entityUuid !== entityUuid).map((item) => item.keyNode)\n }\n if (group.allItemsWithErrorsAdded || group.firstEntityUuid === entityUuid) return []\n group.allItemsWithErrorsAdded = true\n const { firstEntityUuid } = group\n return group.items.filter((item) => item.hasErrors && item.entityUuid === firstEntityUuid).map((item) => item.keyNode)\n}\n\n// attribute siblings (same attribute def in the sibling entities) added to the nodes to validate,\n// by parent entity def and parent of the parent entity\ntype AttributeSiblingsAddedCache = Map<string, { firstParentEntity: ArenaRecordNode; allSiblingsAdded?: boolean }>\n\nconst findUniqueAttributeSiblingsToValidate = (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n nodeDef: ArenaAnyNodeDef\n nodeParent?: ArenaRecordNode\n attributeSiblingsAddedCache: AttributeSiblingsAddedCache\n}): ArenaRecordNode[] => {\n const { record, node, nodeDef, nodeParent, attributeSiblingsAddedCache } = params\n if (!nodeParent) return []\n const nodeParentParent = Records.getParent(nodeParent)(record)\n if (!nodeParentParent) return []\n // the siblings of the attribute are the attributes in the other parent entities:\n // after visiting attributes in 2 different parent entities, all the attributes of the group have been added\n const cacheKey = `${nodeParentParent.uuid}_${nodeParent.nodeDefUuid}_${nodeDef.uuid}`\n const cached = attributeSiblingsAddedCache.get(cacheKey)\n if (!cached) {\n attributeSiblingsAddedCache.set(cacheKey, { firstParentEntity: nodeParent })\n return Records.getAttributeSiblings(node, nodeDef)(record)\n }\n if (cached.allSiblingsAdded || cached.firstParentEntity.uuid === nodeParent.uuid) return []\n cached.allSiblingsAdded = true\n return Records.getChildren(cached.firstParentEntity, nodeDef.uuid)(record)\n}\n\nconst findSortedNodesToValidate = (params: ArenaSortedAttributesValidatorParams): ArenaRecordNode[] => {\n const { survey, record, nodesArray } = params\n\n const result: ArenaRecordNode[] = []\n const resultUuids = new Set<string>()\n const addToResult = (nodes: ArenaRecordNode[]) => {\n for (const node of nodes) {\n if (!resultUuids.has(node.uuid)) {\n resultUuids.add(node.uuid)\n result.push(node)\n }\n }\n }\n // every attribute in nodesArray is validated (it's included in its own dependents)\n const nodeUuidsToValidate = new Set(nodesArray.map((node) => node.uuid))\n const siblingKeyNodesCache: SiblingKeyNodesCache = new Map()\n const attributeSiblingsAddedCache: AttributeSiblingsAddedCache = 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 addToResult(\n RecordNodePointers.getNodesFromNodePointers({ record, nodePointers: nodePointersAttributeAndDependents })\n )\n addToResult(\n findSiblingKeyNodesToValidate({\n ...params,\n nodeDef,\n nodeParent,\n attribute: node,\n siblingKeyNodesCache,\n nodeUuidsToValidate,\n })\n )\n\n if (NodeDefs.getValidations(nodeDef)?.unique) {\n addToResult(\n findUniqueAttributeSiblingsToValidate({ record, node, nodeDef, nodeParent, attributeSiblingsAddedCache })\n )\n }\n }\n\n return result\n}\n\nconst validateSelfAndDependentSortedAttributes = async (\n params: ArenaSortedAttributesValidatorParams\n): Promise<ArenaValidationFields> => {\n const nodesToValidate: ArenaRecordNode[] = findSortedNodesToValidate(params)\n const validationsByNodeUuid: ArenaValidationFields = {}\n // the record doesn't change during the validation: entity keys can be cached\n const entityKeysCache = createEntityKeysCache()\n\n for (const nodeToValidate of nodesToValidate) {\n const nodeUuid = nodeToValidate.uuid\n // Validate only attributes not deleted and not validated already\n if (!nodeToValidate.deleted && !validationsByNodeUuid[nodeUuid]) {\n // sequential: avoid concurrent item/taxon lookups on large node sets\n const attributeValidatorParams = { ...params, attribute: nodeToValidate, entityKeysCache }\n validationsByNodeUuid[nodeUuid] = await validateAttribute(attributeValidatorParams) // NOSONAR\n }\n }\n return validationsByNodeUuid\n}\n\nexport const AttributeValidator = {\n validateSelfAndDependentSortedAttributes,\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"countValidator.js","sourceRoot":"","sources":["../../../../src/record/recordValidator/countValidator.ts"],"names":[],"mappings":"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,MAAM,qBAAqB,GAAG,mBAAmB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAA;gBAC/E,cAAc,CAAC,0BAA0B,CAAC,GAAG,qBAAqB,CAAA;YACpE,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,cAAc,CAAA;AACvB,CAAC,CAAA;AAED,MAAM,0BAA0B,GAAG,CAAC,MAInC,EAAyB,EAAE,CAAC,+BAA+B,iCAAM,MAAM,KAAE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAG,CAAA;AAEpH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,qBAAqB;IACrB,+BAA+B;IAC/B,0BAA0B;CAC3B,CAAA","sourcesContent":["import { ArenaRecordNode, ArenaRecordNodePointer, RecordNodes } from '../../node'\nimport { ArenaNodeDef, ArenaNodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { Records } from '../records'\nimport { ArenaValidation, ValidationFactory, ValidationResultFactory, ValidationSeverity } from '../../validation'\nimport { ArenaRecord } from '../record'\nimport { ArenaSurvey, Surveys } from '../../survey'\nimport { RecordValidations } from '../recordValidations'\nimport { ArenaValidationFields } from '../../validation/validation'\n\nconst createValidationResult = (params: {\n nodeDefUuid: string\n isMinCountValidation: boolean\n minCount: number\n maxCount: number\n}): ArenaValidation => {\n const { nodeDefUuid, isMinCountValidation, minCount, maxCount } = params\n\n if (minCount === maxCount) {\n return ValidationFactory.createInstance({\n valid: false,\n errors: [\n ValidationResultFactory.createInstance({\n key: 'record.nodes.count.invalid',\n params: { nodeDefUuid, count: minCount },\n severity: ValidationSeverity.error,\n }),\n ],\n })\n }\n return ValidationFactory.createInstance({\n valid: false,\n errors: [\n ValidationResultFactory.createInstance({\n key: isMinCountValidation ? 'record.nodes.count.minNotReached' : 'record.nodes.count.maxExceeded',\n params: { nodeDefUuid, ...(isMinCountValidation ? { minCount } : { maxCount }) },\n severity: ValidationSeverity.error,\n }),\n ],\n })\n}\n\nconst validateChildrenCount = (params: {\n parentNode: ArenaRecordNode\n nodeDefChild: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n count: number\n}): ArenaValidation => {\n const { parentNode, nodeDefChild, count } = params\n\n const minCount = RecordNodes.getChildrenMinCount({ parentNode, nodeDef: nodeDefChild })\n const maxCount = RecordNodes.getChildrenMaxCount({ parentNode, nodeDef: nodeDefChild })\n\n const minCountValid = Number.isNaN(minCount) || count >= minCount\n const maxCountValid = Number.isNaN(maxCount) || count <= maxCount\n\n return minCountValid && maxCountValid\n ? ValidationFactory.createInstance()\n : createValidationResult({\n nodeDefUuid: nodeDefChild.uuid,\n isMinCountValidation: !minCountValid,\n minCount,\n maxCount,\n })\n}\n\nconst _countChildren = (params: {\n record: ArenaRecord\n parentNode: ArenaRecordNode\n childDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n}) => {\n const { record, parentNode, childDef } = params\n const children = Records.getChildren(parentNode, childDef.uuid)(record)\n const nonEmptyChildren = NodeDefs.isAttribute(childDef)\n ? children.filter((child) => !RecordNodes.isValueBlank(child))\n : children\n return nonEmptyChildren.length\n}\n\nconst isNodePointerToBeValidated = (nodePointer: ArenaRecordNodePointer) =>\n NodeDefs.hasMinOrMaxCount(nodePointer.nodeDef)\n\nconst validateNodePointer = (params: {\n record: ArenaRecord\n nodeCtx: ArenaRecordNode\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n}) => {\n const { record, nodeCtx, nodeDef } = params\n // Check children count only for applicable nodes\n if (RecordNodes.isChildApplicable(nodeCtx, nodeDef.uuid)) {\n const count = _countChildren({ record, parentNode: nodeCtx, childDef: nodeDef })\n return validateChildrenCount({ parentNode: nodeCtx, nodeDefChild: nodeDef, count })\n }\n return ValidationFactory.createInstance()\n}\n\nconst getNodePointersToValidate = (params: {\n survey: ArenaSurvey\n record: ArenaRecord\n node: ArenaRecordNode\n}): ArenaRecordNodePointer[] => {\n const { survey, record, node } = params\n const nodePointersToValidate: ArenaRecordNodePointer[] = []\n\n const nodeDef = Surveys.getNodeDefByUuid({ uuid: node.nodeDefUuid, survey })\n\n const nodeParent = Records.getParent(node)(record)\n if (nodeParent) {\n // always validate the node itself\n const nodePointer = { nodeCtx: nodeParent, nodeDef }\n if (isNodePointerToBeValidated(nodePointer)) {\n nodePointersToValidate.push(nodePointer)\n }\n }\n if (NodeDefs.isEntity(nodeDef) && !node.deleted) {\n // validate the count of every node def children\n const childDefs = Surveys.getNodeDefChildren({ survey, nodeDef })\n for (const childDef of childDefs) {\n const nodePointer = { nodeCtx: node, nodeDef: childDef }\n if (isNodePointerToBeValidated(nodePointer)) {\n nodePointersToValidate.push(nodePointer)\n }\n }\n }\n return nodePointersToValidate\n}\n\nconst validateChildrenCountNodesArray = (params: {\n survey: ArenaSurvey\n record: ArenaRecord\n nodesArray: ArenaRecordNode[]\n}): ArenaValidationFields => {\n const { survey, record, nodesArray } = params\n const validationsAcc: ArenaValidationFields = {}\n for (const node of nodesArray) {\n const nodePointersToValidate = getNodePointersToValidate({ survey, record, node })\n\n for (const nodePointer of nodePointersToValidate) {\n const { nodeCtx, nodeDef } = nodePointer\n // check if validated already\n const validationChildrenCountKey = RecordValidations.getValidationChildrenCountKey({\n nodeParentUuid: nodeCtx.uuid,\n nodeDefChildUuid: nodeDef.uuid,\n })\n if (!(validationChildrenCountKey in validationsAcc)) {\n // validate the children count of this node pointer\n const validationNodePointer = validateNodePointer({ record, nodeCtx, nodeDef })\n validationsAcc[validationChildrenCountKey] = validationNodePointer\n }\n }\n }\n return validationsAcc\n}\n\nconst validateChildrenCountNodes = (params: {\n survey: ArenaSurvey\n record: ArenaRecord\n nodes: { [key: string]: ArenaRecordNode }\n}): ArenaValidationFields => validateChildrenCountNodesArray({ ...params, nodesArray: Object.values(params.nodes) })\n\nexport const CountValidator = {\n validateChildrenCount,\n validateChildrenCountNodesArray,\n validateChildrenCountNodes,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"countValidator.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,0BAA0B,IAAI,cAAc,CAAC,EAAE,CAAC;gBACpD,mDAAmD;gBACnD,MAAM,qBAAqB,GAAG,mBAAmB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAA;gBAC/E,cAAc,CAAC,0BAA0B,CAAC,GAAG,qBAAqB,CAAA;YACpE,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,cAAc,CAAA;AACvB,CAAC,CAAA;AAED,MAAM,0BAA0B,GAAG,CAAC,MAInC,EAAyB,EAAE,CAAC,+BAA+B,iCAAM,MAAM,KAAE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAG,CAAA;AAEpH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,qBAAqB;IACrB,+BAA+B;IAC/B,0BAA0B;CAC3B,CAAA","sourcesContent":["import { ArenaRecordNode, ArenaRecordNodePointer, RecordNodes } from '../../node'\nimport { ArenaAnyNodeDef, NodeDefs } from '../../nodeDef'\nimport { Records } from '../records'\nimport { ArenaValidation, ValidationFactory, ValidationResultFactory, ValidationSeverity } from '../../validation'\nimport { ArenaRecord } from '../record'\nimport { ArenaSurvey, Surveys } from '../../survey'\nimport { RecordValidations } from '../recordValidations'\nimport { ArenaValidationFields } from '../../validation/validation'\n\nconst createValidationResult = (params: {\n nodeDefUuid: string\n isMinCountValidation: boolean\n minCount: number\n maxCount: number\n}): ArenaValidation => {\n const { nodeDefUuid, isMinCountValidation, minCount, maxCount } = params\n\n if (minCount === maxCount) {\n return ValidationFactory.createInstance({\n valid: false,\n errors: [\n ValidationResultFactory.createInstance({\n key: 'record.nodes.count.invalid',\n params: { nodeDefUuid, count: minCount },\n severity: ValidationSeverity.error,\n }),\n ],\n })\n }\n return ValidationFactory.createInstance({\n valid: false,\n errors: [\n ValidationResultFactory.createInstance({\n key: isMinCountValidation ? 'record.nodes.count.minNotReached' : 'record.nodes.count.maxExceeded',\n params: { nodeDefUuid, ...(isMinCountValidation ? { minCount } : { maxCount }) },\n severity: ValidationSeverity.error,\n }),\n ],\n })\n}\n\nconst validateChildrenCount = (params: {\n parentNode: ArenaRecordNode\n nodeDefChild: ArenaAnyNodeDef\n count: number\n}): ArenaValidation => {\n const { parentNode, nodeDefChild, count } = params\n\n const minCount = RecordNodes.getChildrenMinCount({ parentNode, nodeDef: nodeDefChild })\n const maxCount = RecordNodes.getChildrenMaxCount({ parentNode, nodeDef: nodeDefChild })\n\n const minCountValid = Number.isNaN(minCount) || count >= minCount\n const maxCountValid = Number.isNaN(maxCount) || count <= maxCount\n\n return minCountValid && maxCountValid\n ? ValidationFactory.createInstance()\n : createValidationResult({\n nodeDefUuid: nodeDefChild.uuid,\n isMinCountValidation: !minCountValid,\n minCount,\n maxCount,\n })\n}\n\nconst _countChildren = (params: { record: ArenaRecord; parentNode: ArenaRecordNode; childDef: ArenaAnyNodeDef }) => {\n const { record, parentNode, childDef } = params\n const children = Records.getChildren(parentNode, childDef.uuid)(record)\n const nonEmptyChildren = NodeDefs.isAttribute(childDef)\n ? children.filter((child) => !RecordNodes.isValueBlank(child))\n : children\n return nonEmptyChildren.length\n}\n\nconst isNodePointerToBeValidated = (nodePointer: ArenaRecordNodePointer) =>\n NodeDefs.hasMinOrMaxCount(nodePointer.nodeDef)\n\nconst validateNodePointer = (params: { record: ArenaRecord; nodeCtx: ArenaRecordNode; nodeDef: ArenaAnyNodeDef }) => {\n const { record, nodeCtx, nodeDef } = params\n // Check children count only for applicable nodes\n if (RecordNodes.isChildApplicable(nodeCtx, nodeDef.uuid)) {\n const count = _countChildren({ record, parentNode: nodeCtx, childDef: nodeDef })\n return validateChildrenCount({ parentNode: nodeCtx, nodeDefChild: nodeDef, count })\n }\n return ValidationFactory.createInstance()\n}\n\nconst getNodePointersToValidate = (params: {\n survey: ArenaSurvey\n record: ArenaRecord\n node: ArenaRecordNode\n}): ArenaRecordNodePointer[] => {\n const { survey, record, node } = params\n const nodePointersToValidate: ArenaRecordNodePointer[] = []\n\n const nodeDef = Surveys.getNodeDefByUuid({ uuid: node.nodeDefUuid, survey })\n\n const nodeParent = Records.getParent(node)(record)\n if (nodeParent) {\n // always validate the node itself\n const nodePointer = { nodeCtx: nodeParent, nodeDef }\n if (isNodePointerToBeValidated(nodePointer)) {\n nodePointersToValidate.push(nodePointer)\n }\n }\n if (NodeDefs.isEntity(nodeDef) && !node.deleted) {\n // validate the count of every node def children\n const childDefs = Surveys.getNodeDefChildren({ survey, nodeDef })\n for (const childDef of childDefs) {\n const nodePointer = { nodeCtx: node, nodeDef: childDef }\n if (isNodePointerToBeValidated(nodePointer)) {\n nodePointersToValidate.push(nodePointer)\n }\n }\n }\n return nodePointersToValidate\n}\n\nconst validateChildrenCountNodesArray = (params: {\n survey: ArenaSurvey\n record: ArenaRecord\n nodesArray: ArenaRecordNode[]\n}): ArenaValidationFields => {\n const { survey, record, nodesArray } = params\n const validationsAcc: ArenaValidationFields = {}\n for (const node of nodesArray) {\n const nodePointersToValidate = getNodePointersToValidate({ survey, record, node })\n\n for (const nodePointer of nodePointersToValidate) {\n const { nodeCtx, nodeDef } = nodePointer\n // check if validated already\n const validationChildrenCountKey = RecordValidations.getValidationChildrenCountKey({\n nodeParentUuid: nodeCtx.uuid,\n nodeDefChildUuid: nodeDef.uuid,\n })\n if (!(validationChildrenCountKey in validationsAcc)) {\n // validate the children count of this node pointer\n const validationNodePointer = validateNodePointer({ record, nodeCtx, nodeDef })\n validationsAcc[validationChildrenCountKey] = validationNodePointer\n }\n }\n }\n return validationsAcc\n}\n\nconst validateChildrenCountNodes = (params: {\n survey: ArenaSurvey\n record: ArenaRecord\n nodes: { [key: string]: ArenaRecordNode }\n}): ArenaValidationFields => validateChildrenCountNodesArray({ ...params, nodesArray: Object.values(params.nodes) })\n\nexport const CountValidator = {\n validateChildrenCount,\n validateChildrenCountNodesArray,\n validateChildrenCountNodes,\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"survey.js","sourceRoot":"","s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AAc,KAAd,cAAc,QAGzB;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,aAAa,EAAE,eAAe;IAC9B,OAAO,EAAE,SAAS;CACV,CAAA","sourcesContent":["import { ArenaObject, ArenaDictionary } from '../common'\nimport { ArenaAuthGroup } from '../auth'\nimport { ArenaLabels, LanguageCode } from '../language'\nimport type { ArenaAreaOfInterestDescriptor } from '../geo'\nimport { ArenaSRS } from '../srs'\n\nimport {
|
|
1
|
+
{"version":3,"file":"survey.js","sourceRoot":"","sources":["../../../src/survey/survey.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;AAM/B,MAAM,CAAN,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,KAApB,oBAAoB,QAc/B;AAWD,MAAM,CAAN,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,KAAlB,kBAAkB,QAQ7B;AAMD,MAAM,CAAC,MAAM,sBAAsB,GAAwB;IACzD,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,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;AACnB,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,aAAa,EAAE,eAAe;IAC9B,OAAO,EAAE,SAAS;CACV,CAAA","sourcesContent":["import { ArenaObject, ArenaDictionary } from '../common'\nimport { ArenaAuthGroup } from '../auth'\nimport { ArenaLabels, LanguageCode } from '../language'\nimport type { ArenaAreaOfInterestDescriptor } from '../geo'\nimport { ArenaSRS } from '../srs'\n\nimport { ArenaAnyNodeDef } from '../nodeDef'\nimport { ArenaCategory } from '../category'\nimport { ArenaTaxonomy } from '../taxonomy'\nimport { ArenaSurveyRefData } from './refData/refData'\n\nexport const defaultCycle = '0'\n\nexport interface ArenaSurveyDependency {\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 ArenaSurveyDependencyGraph = {\n [key in SurveyDependencyType]: ArenaSurveyDependency\n}\n\nexport interface ArenaSurveyCycle {\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 ArenaSurveySecurity = {\n [key in SurveySecurityProp]?: boolean\n}\n\nexport const surveySecurityDefaults: ArenaSurveySecurity = {\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 ArenaSurveyDocImageProps = ArenaSurveyFileProps & {\n documentPlace?: SurveyDocPlace\n applyIf?: string\n}\n\nexport type ArenaSurveyFileProps = {\n deleted?: boolean\n labels?: ArenaLabels\n name?: string\n nodeUuid?: string\n recordUuid?: string\n size?: number | null\n temporary?: boolean\n type?: string\n}\n\nexport type ArenaSurveyFile = {\n uuid: string\n props: ArenaSurveyFileProps\n content?: Buffer | null\n dateCreated: string\n}\n\nexport type ArenaSurveyDocImage = ArenaSurveyFile & {\n props: ArenaSurveyDocImageProps\n}\n\nexport type SurveyDocOptions = {\n headerOnFirstPageOnly?: boolean // default: true\n}\n\nexport interface ArenaSurveyProps {\n areasOfInterest?: ArenaAreaOfInterestDescriptor[]\n collectUri?: string\n cycles: {\n [key: string]: ArenaSurveyCycle\n }\n defaultCycleKey?: string\n descriptions?: ArenaLabels\n fieldManualLinks?: ArenaLabels\n // when true, values of attributes becoming non-applicable are kept during data entry (default: cleared)\n keepNonApplicableValues?: boolean\n labels?: ArenaLabels\n languages: LanguageCode[]\n name: string\n preloadedMapLayers?: ArenaSurveyFile[]\n preloadedMapLayersEnabled?: boolean\n security?: ArenaSurveySecurity\n srs: ArenaSRS[]\n surveyDocImages?: ArenaSurveyDocImage[]\n surveyDocOptions?: SurveyDocOptions\n}\n\nexport interface ArenaSurveyNodeDefsIndex {\n rootDefUuid?: string\n childDefUuidPresenceByParentUuid?: { [parentUuid: string]: { [nodeDefUuid: string]: boolean } }\n nodeDefUuidByName?: ArenaDictionary<string>\n qualifierPresenceByUuid?: { [nodeDefUuid: string]: boolean }\n}\n\nexport interface ArenaSurvey extends ArenaObject<ArenaSurveyProps> {\n authGroups: Array<ArenaAuthGroup>\n dateCreated?: string\n dateModified?: string\n datePublished?: string\n dependencyGraph?: ArenaSurveyDependencyGraph\n draft: boolean\n nodeDefs?: { [nodeDefUuid: string]: ArenaAnyNodeDef }\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]: ArenaCategory }\n /**\n * Taxonomies indexed by uuid.\n */\n taxonomies?: { [taxonomyUuid: string]: ArenaTaxonomy }\n /**\n * Reference data cache (category items and taxa).\n */\n refData?: ArenaSurveyRefData\n\n nodeDefsIndex?: ArenaSurveyNodeDefsIndex\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeDefsReader.js","sourceRoot":"","sources":["../../../../../src/survey/surveys/_nodeDefs/nodeDefsReader.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAmB,
|
|
1
|
+
{"version":3,"file":"nodeDefsReader.js","sourceRoot":"","sources":["../../../../../src/survey/surveys/_nodeDefs/nodeDefsReader.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAmB,EAA0B,EAAE,kBAAC,MAAM,CAAC,MAAM,OAAC,MAAM,CAAC,QAAQ,mCAAI,EAAE,CAAC,GAAA,CAAA;AAErH,MAAM,CAAC,MAAM,wBAAwB,GACnC,CAAC,OAAwB,EAAE,EAAE,CAC7B,CAAC,MAAmB,EAAuB,EAAE,CAC3C,gBAAgB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,cAAc,CAAC,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA","sourcesContent":["import { ArenaAnyNodeDef, ArenaNodeDef } from '../../../nodeDef'\nimport { ArenaSurvey } from '../../survey'\n\nexport const getNodeDefsArray = (survey: ArenaSurvey): Array<ArenaAnyNodeDef> => Object.values(survey.nodeDefs ?? {})\n\nexport const calculateNodeDefChildren =\n (nodeDef: ArenaAnyNodeDef) =>\n (survey: ArenaSurvey): ArenaNodeDef<any>[] =>\n getNodeDefsArray(survey).filter((nodeDefCurrent) => nodeDefCurrent.parentUuid === nodeDef.uuid)\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../../src/survey/surveys/dependencies.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,cAAc,MAAM,YAAY,CAAA;AAC5C,OAAO,EAOL,QAAQ,EACR,WAAW,GACZ,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAA;AAE7E,OAAO,EAA2C,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACzF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAGhE,MAAM,oCAAoC,GAAG,CAAC,wBAAwB,CAAC,CAAA;AAE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;;GAKG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAO,MAAmB,EAAwB,EAAE;IAC9F,iIAAiI;IACjI,MAAM,UAAU,GAAG,IAAI,CAAA;IAEvB,sCAAsC;IACtC,IAAI,aAAa,mCAAqB,MAAM,KAAE,eAAe,EAAE,kBAAkB,EAAE,GAAE,CAAA;IACrF,KAAK,MAAM,OAAO,IAAI,cAAc,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9D,gDAAgD;QAChD,aAAa,GAAG,MAAM,sBAAsB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAA,CAAC,UAAU;IACzG,CAAC;IACD,OAAO,aAAa,CAAA;AACtB,CAAC,CAAA,CAAA","sourcesContent":["import * as SurveyNodeDefs from './nodeDefs'\nimport {\n ArenaNodeDef,\n ArenaNodeDefCode,\n ArenaNodeDefEntity,\n ArenaNodeDefExpression,\n ArenaNodeDefFile,\n ArenaNodeDefProps,\n NodeDefs,\n NodeDefType,\n} from '../../nodeDef'\nimport { NodeDefExpressionEvaluator } from '../../nodeDefExpressionEvaluator'\n\nimport { ArenaSurvey, ArenaSurveyDependencyGraph, SurveyDependencyType } from '../survey'\nimport { Arrays, Objects } from '../../utils'\nimport { NodeDefExpressionFactory } from '../../nodeDef/nodeDef'\nimport { ArenaDictionary } from '../../common'\n\nconst functionsRequiringOnUpdateDependency = ['recordDateLastModified']\n\nconst isContextParentByDependencyType = {\n [SurveyDependencyType.applicable]: true,\n [SurveyDependencyType.defaultValues]: true,\n [SurveyDependencyType.editable]: true,\n [SurveyDependencyType.enumeratingItems]: true,\n [SurveyDependencyType.fileName]: true,\n [SurveyDependencyType.formula]: false,\n [SurveyDependencyType.maxCount]: true,\n [SurveyDependencyType.minCount]: true,\n [SurveyDependencyType.onUpdate]: true,\n [SurveyDependencyType.parentCode]: false,\n [SurveyDependencyType.required]: true,\n [SurveyDependencyType.validations]: true,\n [SurveyDependencyType.visible]: true,\n}\n\nconst selfReferenceAllowedByDependencyType = {\n [SurveyDependencyType.applicable]: false,\n [SurveyDependencyType.defaultValues]: false,\n [SurveyDependencyType.editable]: false,\n [SurveyDependencyType.enumeratingItems]: false,\n [SurveyDependencyType.fileName]: false,\n [SurveyDependencyType.formula]: false,\n [SurveyDependencyType.maxCount]: false,\n [SurveyDependencyType.minCount]: false,\n [SurveyDependencyType.onUpdate]: false,\n [SurveyDependencyType.parentCode]: false,\n [SurveyDependencyType.required]: false,\n [SurveyDependencyType.validations]: true,\n [SurveyDependencyType.visible]: false,\n}\n\nconst newDependencyGraph = () => ({\n [SurveyDependencyType.applicable]: {},\n [SurveyDependencyType.defaultValues]: {},\n [SurveyDependencyType.editable]: {},\n [SurveyDependencyType.enumeratingItems]: {},\n [SurveyDependencyType.fileName]: {},\n [SurveyDependencyType.formula]: {},\n [SurveyDependencyType.maxCount]: {},\n [SurveyDependencyType.minCount]: {},\n [SurveyDependencyType.onUpdate]: {},\n [SurveyDependencyType.parentCode]: {},\n [SurveyDependencyType.required]: {},\n [SurveyDependencyType.validations]: {},\n [SurveyDependencyType.visible]: {},\n})\n\nconst getDependencyGraph = (survey: ArenaSurvey): ArenaSurveyDependencyGraph =>\n survey.dependencyGraph ?? newDependencyGraph()\n\nconst getDependencies = (params: {\n graphs: ArenaSurveyDependencyGraph\n type: SurveyDependencyType\n nodeDefUuid: string\n}): Array<string> => {\n const { graphs, type, nodeDefUuid } = params\n return type === SurveyDependencyType.onUpdate ? [] : ((graphs?.[type]?.[nodeDefUuid] ?? []) as string[])\n}\n\nexport const getNodeDefDependents = (params: {\n survey: ArenaSurvey\n nodeDefUuid: string\n dependencyType?: SurveyDependencyType\n}): ArenaNodeDef<NodeDefType, ArenaNodeDefProps>[] => {\n const { survey, nodeDefUuid, dependencyType } = params\n const dependencyGraph = getDependencyGraph(survey)\n\n const dependentUuids = new Set<string>()\n\n const dependencyTypes: SurveyDependencyType[] = dependencyType\n ? [dependencyType]\n : Object.values(SurveyDependencyType)\n\n for (const depType of dependencyTypes) {\n const dependentUuidsTemp = getDependencies({ graphs: dependencyGraph, type: depType, nodeDefUuid })\n for (const dependentUuid of dependentUuidsTemp) {\n dependentUuids.add(dependentUuid)\n }\n }\n return dependentUuids.size > 0 ? SurveyNodeDefs.findNodeDefsByUuids({ survey, uuids: [...dependentUuids] }) : []\n}\n\nexport const getOnUpdateDependents = (params: { survey: ArenaSurvey }) => {\n const { survey } = params\n const dependencyGraph = getDependencyGraph(survey)\n const sourceDefUuids = Object.keys(dependencyGraph[SurveyDependencyType.onUpdate] ?? {})\n return sourceDefUuids.length > 0 ? SurveyNodeDefs.findNodeDefsByUuids({ survey, uuids: sourceDefUuids }) : []\n}\n\n// UPDATE\n\nconst addDependency = (params: {\n graphs: ArenaSurveyDependencyGraph\n type: SurveyDependencyType\n nodeDefUuid: string\n nodeDefDepUuid: string\n sideEffect: boolean\n}): ArenaSurveyDependencyGraph => {\n const { graphs, type, nodeDefUuid, nodeDefDepUuid, sideEffect = false } = params\n const deps = getDependencies({ graphs, type, nodeDefUuid })\n // dependencies of a node def can be added again (e.g. when it is updated): keep each dependent only once\n if (deps.includes(nodeDefDepUuid)) return graphs\n const depsUpdated = Arrays.addItem(nodeDefDepUuid, { sideEffect })(deps)\n return Objects.assocPath({ obj: graphs, path: [type, nodeDefUuid], value: depsUpdated, sideEffect })\n}\n\nconst addDependencies = async (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDef<NodeDefType>\n type: SurveyDependencyType\n graphs: ArenaSurveyDependencyGraph\n expressions: ArenaNodeDefExpression[]\n sideEffect?: boolean\n}): Promise<ArenaSurveyDependencyGraph> => {\n const { survey, nodeDef, type, expressions, graphs: graphsParam, sideEffect = false } = params\n\n if (!expressions || expressions.length === 0) return graphsParam\n\n let graphsUpdated = sideEffect ? graphsParam : { ...graphsParam }\n\n const isContextParent = isContextParentByDependencyType[type]\n const selfReferenceAllowed = selfReferenceAllowedByDependencyType[type]\n\n const findReferencedNodeDefs = async (\n expression: string | undefined\n ): Promise<{ [key: string]: ArenaNodeDef<NodeDefType> }> => {\n if (!expression) return {}\n\n const referencedNodeDefUuids = await new NodeDefExpressionEvaluator().findReferencedNodeDefUuids({\n expression,\n survey,\n nodeDef,\n isContextParent,\n selfReferenceAllowed,\n })\n const referencedNodeDefsByUuid: ArenaDictionary<ArenaNodeDef<any>> = {}\n for (const uuid of referencedNodeDefUuids) {\n referencedNodeDefsByUuid[uuid] = SurveyNodeDefs.getNodeDefByUuid({ survey, uuid })\n }\n return referencedNodeDefsByUuid\n }\n\n const referencedNodeDefsArray = await Promise.all(\n expressions.flatMap((nodeDefExpr) => [\n findReferencedNodeDefs(nodeDefExpr.expression),\n findReferencedNodeDefs(nodeDefExpr.applyIf),\n ])\n )\n const referencedNodeDefs: ArenaDictionary<ArenaNodeDef<any>> = Object.assign({}, ...referencedNodeDefsArray)\n\n for (const nodeDefRef of Object.values(referencedNodeDefs)) {\n graphsUpdated = addDependency({\n graphs: graphsUpdated,\n type,\n nodeDefUuid: nodeDefRef.uuid,\n nodeDefDepUuid: nodeDef.uuid,\n sideEffect,\n })\n }\n\n return graphsUpdated\n}\n\nexport const addNodeDefDependencies = async (params: {\n nodeDef: ArenaNodeDef<NodeDefType>\n survey: ArenaSurvey\n sideEffect?: boolean\n}): Promise<ArenaSurvey> => {\n const { nodeDef, survey, sideEffect = false } = params\n const graphs = getDependencyGraph(survey)\n let graphsUpdated = sideEffect ? graphs : { ...graphs }\n\n const _addDependencies = async (type: SurveyDependencyType, expressions: ArenaNodeDefExpression[]) => {\n let _graphUpdated = await addDependencies({\n survey,\n nodeDef,\n type,\n expressions,\n graphs: graphsUpdated,\n sideEffect,\n })\n // add onUpdate dependencies\n if (\n expressions.some((expression) =>\n functionsRequiringOnUpdateDependency.some(\n (functionName) => expression.applyIf?.includes(functionName) || expression.expression?.includes(functionName)\n )\n )\n ) {\n _graphUpdated = Objects.assocPath({\n obj: _graphUpdated,\n path: [SurveyDependencyType.onUpdate, nodeDef.uuid],\n value: true,\n sideEffect,\n })\n }\n return _graphUpdated\n }\n graphsUpdated = await _addDependencies(SurveyDependencyType.applicable, NodeDefs.getApplicable(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.defaultValues, NodeDefs.getDefaultValues(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.editable, NodeDefs.getEditableIf(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.required, NodeDefs.getRequiredIf(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.validations, NodeDefs.getValidationsExpressions(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.visible, NodeDefs.getVisibleIf(nodeDef))\n const maxCount = NodeDefs.getMaxCount(nodeDef)\n if (Array.isArray(maxCount)) {\n graphsUpdated = await _addDependencies(SurveyDependencyType.maxCount, maxCount)\n }\n const minCount = NodeDefs.getMinCount(nodeDef)\n if (Array.isArray(minCount)) {\n graphsUpdated = await _addDependencies(SurveyDependencyType.minCount, minCount)\n }\n // file name expression\n if (NodeDefs.getType(nodeDef) === NodeDefType.file) {\n const fileNameExpression = NodeDefs.getFileNameExpression(nodeDef as ArenaNodeDefFile)\n if (fileNameExpression) {\n graphsUpdated = await _addDependencies(SurveyDependencyType.fileName, [\n NodeDefExpressionFactory.createInstance({ expression: fileNameExpression }),\n ])\n }\n }\n if (NodeDefs.isEntity(nodeDef)) {\n const enumeratingItemsExpression = NodeDefs.getEnumeratingItemsExpression(nodeDef as ArenaNodeDefEntity)\n if (enumeratingItemsExpression) {\n graphsUpdated = await _addDependencies(SurveyDependencyType.enumeratingItems, [\n NodeDefExpressionFactory.createInstance({ expression: enumeratingItemsExpression }),\n ])\n }\n }\n // parent code\n if (NodeDefs.getType(nodeDef) === NodeDefType.code) {\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(nodeDef as ArenaNodeDefCode)\n if (parentCodeDefUuid) {\n graphsUpdated = addDependency({\n graphs: graphsUpdated,\n type: SurveyDependencyType.parentCode,\n nodeDefUuid: parentCodeDefUuid,\n nodeDefDepUuid: nodeDef.uuid,\n sideEffect,\n })\n }\n }\n if (sideEffect) {\n survey.dependencyGraph = graphsUpdated\n return survey\n }\n return { ...survey, dependencyGraph: graphsUpdated }\n}\n\n// DELETE\n\nconst _removeNodeDefDependenciesOfType = (params: {\n graphs: ArenaSurveyDependencyGraph\n dependencyType: SurveyDependencyType\n nodeDefUuid: string\n}): ArenaSurveyDependencyGraph => {\n const { graphs, nodeDefUuid, dependencyType } = params\n\n const graphsUpdated = { ...graphs }\n let graphUpdated = { ...graphsUpdated[dependencyType] }\n // dissoc nodeDefUuid dependency as dependent\n graphUpdated = Objects.dissoc({ obj: graphUpdated, prop: nodeDefUuid })\n\n if (dependencyType !== SurveyDependencyType.onUpdate) {\n // dissoc nodeDefUuid dependency from sources (if any)\n for (const [key, dependentUuids] of Object.entries(graphUpdated)) {\n graphUpdated[key] = Arrays.removeItem(nodeDefUuid)(dependentUuids as string[])\n }\n }\n\n graphsUpdated[dependencyType] = graphUpdated\n return graphsUpdated\n}\n\nexport const removeNodeDefDependencies = (params: {\n survey: ArenaSurvey\n nodeDefUuid: string\n dependencyType?: SurveyDependencyType\n}): ArenaSurvey => {\n const { survey, nodeDefUuid, dependencyType = null } = params\n const graphs = getDependencyGraph(survey)\n const dependencyTypes = dependencyType ? [dependencyType] : (Object.keys(graphs) as SurveyDependencyType[])\n const graphsUpdated = dependencyTypes.reduce(\n (dependencyGraphAcc, type) =>\n _removeNodeDefDependenciesOfType({ graphs: dependencyGraphAcc, dependencyType: type, nodeDefUuid }),\n graphs\n )\n return { ...survey, dependencyGraph: graphsUpdated }\n}\n\n/**\n * Builds the dependency graph of the survey.\n *\n * @param survey - The survey.\n * @returns A copy of the survey with the dependency graph (the survey passed in is not modified).\n */\nexport const buildAndAssocDependencyGraph = async (survey: ArenaSurvey): Promise<ArenaSurvey> => {\n // the new graph is built from scratch with side effect (to avoid re-creating objects): it belongs only to the copy of the survey\n const sideEffect = true\n\n // add dependencies for every node def\n let surveyUpdated: ArenaSurvey = { ...survey, dependencyGraph: newDependencyGraph() }\n for (const nodeDef of SurveyNodeDefs.getNodeDefsArray(survey)) {\n // sequential: each iteration updates the survey\n surveyUpdated = await addNodeDefDependencies({ nodeDef, survey: surveyUpdated, sideEffect }) // NOSONAR\n }\n return surveyUpdated\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../../src/survey/surveys/dependencies.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,cAAc,MAAM,YAAY,CAAA;AAC5C,OAAO,EAOL,QAAQ,EACR,WAAW,GACZ,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAA;AAE7E,OAAO,EAA2C,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACzF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAGhE,MAAM,oCAAoC,GAAG,CAAC,wBAAwB,CAAC,CAAA;AAEvE,MAAM,+BAA+B,GAAG;IACtC,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE,IAAI;IACvC,CAAC,oBAAoB,CAAC,aAAa,CAAC,EAAE,IAAI;IAC1C,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,EAAE,IAAI;IAC7C,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,KAAK;IACrC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,oBAAoB,CAA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from './nodeDefs'\nimport {\n ArenaAnyNodeDef,\n ArenaNodeDef,\n ArenaNodeDefCode,\n ArenaNodeDefEntity,\n ArenaNodeDefExpression,\n ArenaNodeDefFile,\n NodeDefs,\n NodeDefType,\n} from '../../nodeDef'\nimport { NodeDefExpressionEvaluator } from '../../nodeDefExpressionEvaluator'\n\nimport { ArenaSurvey, ArenaSurveyDependencyGraph, SurveyDependencyType } from '../survey'\nimport { Arrays, Objects } from '../../utils'\nimport { NodeDefExpressionFactory } from '../../nodeDef/nodeDef'\nimport { ArenaDictionary } from '../../common'\n\nconst functionsRequiringOnUpdateDependency = ['recordDateLastModified']\n\nconst isContextParentByDependencyType = {\n [SurveyDependencyType.applicable]: true,\n [SurveyDependencyType.defaultValues]: true,\n [SurveyDependencyType.editable]: true,\n [SurveyDependencyType.enumeratingItems]: true,\n [SurveyDependencyType.fileName]: true,\n [SurveyDependencyType.formula]: false,\n [SurveyDependencyType.maxCount]: true,\n [SurveyDependencyType.minCount]: true,\n [SurveyDependencyType.onUpdate]: true,\n [SurveyDependencyType.parentCode]: false,\n [SurveyDependencyType.required]: true,\n [SurveyDependencyType.validations]: true,\n [SurveyDependencyType.visible]: true,\n}\n\nconst selfReferenceAllowedByDependencyType = {\n [SurveyDependencyType.applicable]: false,\n [SurveyDependencyType.defaultValues]: false,\n [SurveyDependencyType.editable]: false,\n [SurveyDependencyType.enumeratingItems]: false,\n [SurveyDependencyType.fileName]: false,\n [SurveyDependencyType.formula]: false,\n [SurveyDependencyType.maxCount]: false,\n [SurveyDependencyType.minCount]: false,\n [SurveyDependencyType.onUpdate]: false,\n [SurveyDependencyType.parentCode]: false,\n [SurveyDependencyType.required]: false,\n [SurveyDependencyType.validations]: true,\n [SurveyDependencyType.visible]: false,\n}\n\nconst newDependencyGraph = () => ({\n [SurveyDependencyType.applicable]: {},\n [SurveyDependencyType.defaultValues]: {},\n [SurveyDependencyType.editable]: {},\n [SurveyDependencyType.enumeratingItems]: {},\n [SurveyDependencyType.fileName]: {},\n [SurveyDependencyType.formula]: {},\n [SurveyDependencyType.maxCount]: {},\n [SurveyDependencyType.minCount]: {},\n [SurveyDependencyType.onUpdate]: {},\n [SurveyDependencyType.parentCode]: {},\n [SurveyDependencyType.required]: {},\n [SurveyDependencyType.validations]: {},\n [SurveyDependencyType.visible]: {},\n})\n\nconst getDependencyGraph = (survey: ArenaSurvey): ArenaSurveyDependencyGraph =>\n survey.dependencyGraph ?? newDependencyGraph()\n\nconst getDependencies = (params: {\n graphs: ArenaSurveyDependencyGraph\n type: SurveyDependencyType\n nodeDefUuid: string\n}): Array<string> => {\n const { graphs, type, nodeDefUuid } = params\n return type === SurveyDependencyType.onUpdate ? [] : ((graphs?.[type]?.[nodeDefUuid] ?? []) as string[])\n}\n\nexport const getNodeDefDependents = (params: {\n survey: ArenaSurvey\n nodeDefUuid: string\n dependencyType?: SurveyDependencyType\n}): ArenaAnyNodeDef[] => {\n const { survey, nodeDefUuid, dependencyType } = params\n const dependencyGraph = getDependencyGraph(survey)\n\n const dependentUuids = new Set<string>()\n\n const dependencyTypes: SurveyDependencyType[] = dependencyType\n ? [dependencyType]\n : Object.values(SurveyDependencyType)\n\n for (const depType of dependencyTypes) {\n const dependentUuidsTemp = getDependencies({ graphs: dependencyGraph, type: depType, nodeDefUuid })\n for (const dependentUuid of dependentUuidsTemp) {\n dependentUuids.add(dependentUuid)\n }\n }\n return dependentUuids.size > 0 ? SurveyNodeDefs.findNodeDefsByUuids({ survey, uuids: [...dependentUuids] }) : []\n}\n\nexport const getOnUpdateDependents = (params: { survey: ArenaSurvey }) => {\n const { survey } = params\n const dependencyGraph = getDependencyGraph(survey)\n const sourceDefUuids = Object.keys(dependencyGraph[SurveyDependencyType.onUpdate] ?? {})\n return sourceDefUuids.length > 0 ? SurveyNodeDefs.findNodeDefsByUuids({ survey, uuids: sourceDefUuids }) : []\n}\n\n// UPDATE\n\nconst addDependency = (params: {\n graphs: ArenaSurveyDependencyGraph\n type: SurveyDependencyType\n nodeDefUuid: string\n nodeDefDepUuid: string\n sideEffect: boolean\n}): ArenaSurveyDependencyGraph => {\n const { graphs, type, nodeDefUuid, nodeDefDepUuid, sideEffect = false } = params\n const deps = getDependencies({ graphs, type, nodeDefUuid })\n // dependencies of a node def can be added again (e.g. when it is updated): keep each dependent only once\n if (deps.includes(nodeDefDepUuid)) return graphs\n const depsUpdated = Arrays.addItem(nodeDefDepUuid, { sideEffect })(deps)\n return Objects.assocPath({ obj: graphs, path: [type, nodeDefUuid], value: depsUpdated, sideEffect })\n}\n\nconst addDependencies = async (params: {\n survey: ArenaSurvey\n nodeDef: ArenaAnyNodeDef\n type: SurveyDependencyType\n graphs: ArenaSurveyDependencyGraph\n expressions: ArenaNodeDefExpression[]\n sideEffect?: boolean\n}): Promise<ArenaSurveyDependencyGraph> => {\n const { survey, nodeDef, type, expressions, graphs: graphsParam, sideEffect = false } = params\n\n if (!expressions || expressions.length === 0) return graphsParam\n\n let graphsUpdated = sideEffect ? graphsParam : { ...graphsParam }\n\n const isContextParent = isContextParentByDependencyType[type]\n const selfReferenceAllowed = selfReferenceAllowedByDependencyType[type]\n\n const findReferencedNodeDefs = async (\n expression: string | undefined\n ): Promise<{ [key: string]: ArenaAnyNodeDef }> => {\n if (!expression) return {}\n\n const referencedNodeDefUuids = await new NodeDefExpressionEvaluator().findReferencedNodeDefUuids({\n expression,\n survey,\n nodeDef,\n isContextParent,\n selfReferenceAllowed,\n })\n const referencedNodeDefsByUuid: ArenaDictionary<ArenaNodeDef<any>> = {}\n for (const uuid of referencedNodeDefUuids) {\n referencedNodeDefsByUuid[uuid] = SurveyNodeDefs.getNodeDefByUuid({ survey, uuid })\n }\n return referencedNodeDefsByUuid\n }\n\n const referencedNodeDefsArray = await Promise.all(\n expressions.flatMap((nodeDefExpr) => [\n findReferencedNodeDefs(nodeDefExpr.expression),\n findReferencedNodeDefs(nodeDefExpr.applyIf),\n ])\n )\n const referencedNodeDefs: ArenaDictionary<ArenaNodeDef<any>> = Object.assign({}, ...referencedNodeDefsArray)\n\n for (const nodeDefRef of Object.values(referencedNodeDefs)) {\n graphsUpdated = addDependency({\n graphs: graphsUpdated,\n type,\n nodeDefUuid: nodeDefRef.uuid,\n nodeDefDepUuid: nodeDef.uuid,\n sideEffect,\n })\n }\n\n return graphsUpdated\n}\n\nexport const addNodeDefDependencies = async (params: {\n nodeDef: ArenaAnyNodeDef\n survey: ArenaSurvey\n sideEffect?: boolean\n}): Promise<ArenaSurvey> => {\n const { nodeDef, survey, sideEffect = false } = params\n const graphs = getDependencyGraph(survey)\n let graphsUpdated = sideEffect ? graphs : { ...graphs }\n\n const _addDependencies = async (type: SurveyDependencyType, expressions: ArenaNodeDefExpression[]) => {\n let _graphUpdated = await addDependencies({\n survey,\n nodeDef,\n type,\n expressions,\n graphs: graphsUpdated,\n sideEffect,\n })\n // add onUpdate dependencies\n if (\n expressions.some((expression) =>\n functionsRequiringOnUpdateDependency.some(\n (functionName) => expression.applyIf?.includes(functionName) || expression.expression?.includes(functionName)\n )\n )\n ) {\n _graphUpdated = Objects.assocPath({\n obj: _graphUpdated,\n path: [SurveyDependencyType.onUpdate, nodeDef.uuid],\n value: true,\n sideEffect,\n })\n }\n return _graphUpdated\n }\n graphsUpdated = await _addDependencies(SurveyDependencyType.applicable, NodeDefs.getApplicable(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.defaultValues, NodeDefs.getDefaultValues(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.editable, NodeDefs.getEditableIf(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.required, NodeDefs.getRequiredIf(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.validations, NodeDefs.getValidationsExpressions(nodeDef))\n graphsUpdated = await _addDependencies(SurveyDependencyType.visible, NodeDefs.getVisibleIf(nodeDef))\n const maxCount = NodeDefs.getMaxCount(nodeDef)\n if (Array.isArray(maxCount)) {\n graphsUpdated = await _addDependencies(SurveyDependencyType.maxCount, maxCount)\n }\n const minCount = NodeDefs.getMinCount(nodeDef)\n if (Array.isArray(minCount)) {\n graphsUpdated = await _addDependencies(SurveyDependencyType.minCount, minCount)\n }\n // file name expression\n if (NodeDefs.getType(nodeDef) === NodeDefType.file) {\n const fileNameExpression = NodeDefs.getFileNameExpression(nodeDef as ArenaNodeDefFile)\n if (fileNameExpression) {\n graphsUpdated = await _addDependencies(SurveyDependencyType.fileName, [\n NodeDefExpressionFactory.createInstance({ expression: fileNameExpression }),\n ])\n }\n }\n if (NodeDefs.isEntity(nodeDef)) {\n const enumeratingItemsExpression = NodeDefs.getEnumeratingItemsExpression(nodeDef as ArenaNodeDefEntity)\n if (enumeratingItemsExpression) {\n graphsUpdated = await _addDependencies(SurveyDependencyType.enumeratingItems, [\n NodeDefExpressionFactory.createInstance({ expression: enumeratingItemsExpression }),\n ])\n }\n }\n // parent code\n if (NodeDefs.getType(nodeDef) === NodeDefType.code) {\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(nodeDef as ArenaNodeDefCode)\n if (parentCodeDefUuid) {\n graphsUpdated = addDependency({\n graphs: graphsUpdated,\n type: SurveyDependencyType.parentCode,\n nodeDefUuid: parentCodeDefUuid,\n nodeDefDepUuid: nodeDef.uuid,\n sideEffect,\n })\n }\n }\n if (sideEffect) {\n survey.dependencyGraph = graphsUpdated\n return survey\n }\n return { ...survey, dependencyGraph: graphsUpdated }\n}\n\n// DELETE\n\nconst _removeNodeDefDependenciesOfType = (params: {\n graphs: ArenaSurveyDependencyGraph\n dependencyType: SurveyDependencyType\n nodeDefUuid: string\n}): ArenaSurveyDependencyGraph => {\n const { graphs, nodeDefUuid, dependencyType } = params\n\n const graphsUpdated = { ...graphs }\n let graphUpdated = { ...graphsUpdated[dependencyType] }\n // dissoc nodeDefUuid dependency as dependent\n graphUpdated = Objects.dissoc({ obj: graphUpdated, prop: nodeDefUuid })\n\n if (dependencyType !== SurveyDependencyType.onUpdate) {\n // dissoc nodeDefUuid dependency from sources (if any)\n for (const [key, dependentUuids] of Object.entries(graphUpdated)) {\n graphUpdated[key] = Arrays.removeItem(nodeDefUuid)(dependentUuids as string[])\n }\n }\n\n graphsUpdated[dependencyType] = graphUpdated\n return graphsUpdated\n}\n\nexport const removeNodeDefDependencies = (params: {\n survey: ArenaSurvey\n nodeDefUuid: string\n dependencyType?: SurveyDependencyType\n}): ArenaSurvey => {\n const { survey, nodeDefUuid, dependencyType = null } = params\n const graphs = getDependencyGraph(survey)\n const dependencyTypes = dependencyType ? [dependencyType] : (Object.keys(graphs) as SurveyDependencyType[])\n const graphsUpdated = dependencyTypes.reduce(\n (dependencyGraphAcc, type) =>\n _removeNodeDefDependenciesOfType({ graphs: dependencyGraphAcc, dependencyType: type, nodeDefUuid }),\n graphs\n )\n return { ...survey, dependencyGraph: graphsUpdated }\n}\n\n/**\n * Builds the dependency graph of the survey.\n *\n * @param survey - The survey.\n * @returns A copy of the survey with the dependency graph (the survey passed in is not modified).\n */\nexport const buildAndAssocDependencyGraph = async (survey: ArenaSurvey): Promise<ArenaSurvey> => {\n // the new graph is built from scratch with side effect (to avoid re-creating objects): it belongs only to the copy of the survey\n const sideEffect = true\n\n // add dependencies for every node def\n let surveyUpdated: ArenaSurvey = { ...survey, dependencyGraph: newDependencyGraph() }\n for (const nodeDef of SurveyNodeDefs.getNodeDefsArray(survey)) {\n // sequential: each iteration updates the survey\n surveyUpdated = await addNodeDefDependencies({ nodeDef, survey: surveyUpdated, sideEffect }) // NOSONAR\n }\n return surveyUpdated\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeDefs.js","sourceRoot":"","sources":["../../../../src/survey/surveys/nodeDefs.ts"],"names":[],"mappings":"AACA,OAAO,EAQL,WAAW,EACX,QAAQ,GACT,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC1D,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,8BAA8B,CAAC;QACpC,MAAM;QACN,KAAK;QACL,OAAO;QACP,SAAS,EAAE,CAAC,cAAc,EAAE,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC;KACjG,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,GACvG,aAAa,CAAA;AACf,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,CAAA","sourcesContent":["import { ArenaSurvey } from '../survey'\nimport {\n ArenaNodeDef,\n ArenaNodeDefCode,\n ArenaNodeDefCodeProps,\n ArenaNodeDefEntity,\n ArenaNodeDefEntityChildPosition,\n ArenaNodeDefMap,\n ArenaNodeDefProps,\n NodeDefType,\n NodeDefs,\n} from '../../nodeDef'\nimport { Arrays, Objects, Queue } from '../../utils'\nimport { SystemError, SystemErrorKeys } from '../../error'\nimport * as NodeDefsReader from './_nodeDefs/nodeDefsReader'\nimport * as NodeDefsIndex from './_nodeDefs/nodeDefsIndex'\nimport { TraverseMethod } from '../../common'\nimport { getCategoryByUuid } from './surveysGetters'\n\nexport const getNodeDefsArray = NodeDefsReader.getNodeDefsArray\n\nexport const findNodeDefByUuid = (params: {\n survey: ArenaSurvey\n uuid: string\n}): ArenaNodeDef<NodeDefType, ArenaNodeDefProps> | undefined => {\n const { survey, uuid } = params\n return survey.nodeDefs?.[uuid]\n}\n\nexport const getNodeDefByUuid = (params: {\n survey: ArenaSurvey\n uuid: string\n}): ArenaNodeDef<NodeDefType, ArenaNodeDefProps> => {\n const { survey, uuid } = params\n const nodeDef = findNodeDefByUuid({ survey, uuid })\n if (!nodeDef) throw new SystemError(SystemErrorKeys.survey.nodeDefUuidNotFound, { uuid })\n return nodeDef\n}\n\nexport const findNodeDefByName = (params: {\n survey: ArenaSurvey\n name: string\n}): ArenaNodeDef<NodeDefType, ArenaNodeDefProps> | undefined => {\n const { survey, name } = params\n const nodeDefUuidByNameIndex = survey.nodeDefsIndex?.nodeDefUuidByName\n if (nodeDefUuidByNameIndex) {\n const uuid = nodeDefUuidByNameIndex[name]\n return findNodeDefByUuid({ survey, uuid })\n }\n return getNodeDefsArray(survey).find((nodeDef) => nodeDef.props.name === name)\n}\n\nexport const getNodeDefByName = (params: {\n survey: ArenaSurvey\n name: string\n}): ArenaNodeDef<NodeDefType, ArenaNodeDefProps> => {\n const { survey, name } = params\n const nodeDef = findNodeDefByName({ survey, name })\n if (!nodeDef) {\n throw new SystemError(SystemErrorKeys.survey.nodeDefNameNotFound, { name })\n }\n return nodeDef\n}\n\nexport const getNodeDefsByUuids = (params: { survey: ArenaSurvey; uuids: string[] }) => {\n const { survey, uuids } = params\n return uuids.map((uuid) => getNodeDefByUuid({ survey, uuid }))\n}\n\nexport const findNodeDefsByUuids = (params: {\n survey: ArenaSurvey\n uuids: string[]\n}): ArenaNodeDef<NodeDefType, ArenaNodeDefProps>[] => {\n const { survey, uuids } = params\n return uuids.reduce((acc: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>[], uuid) => {\n const nodeDef = findNodeDefByUuid({ survey, uuid })\n if (nodeDef) {\n acc.push(nodeDef)\n }\n return acc\n }, [])\n}\n\nexport const getNodeDefParent = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n}): ArenaNodeDefEntity | undefined => {\n const { survey, nodeDef } = params\n if (!nodeDef.parentUuid) return undefined\n return getNodeDefByUuid({ survey, uuid: nodeDef.parentUuid }) as ArenaNodeDefEntity\n}\n\nexport const getNodeDefAncestorMultipleEntity = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n}): ArenaNodeDefEntity | undefined => {\n const { survey, nodeDef } = params\n return findAncestorNodeDef({\n survey,\n nodeDef,\n predicate: (entityDef) => NodeDefs.isRoot(entityDef) || NodeDefs.isMultiple(entityDef),\n })\n}\n\nexport const isNodeDefAncestor = (params: {\n nodeDefAncestor: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n nodeDefDescendant: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n}): boolean => {\n const { nodeDefAncestor, nodeDefDescendant } = params\n\n return Arrays.startsWith(nodeDefDescendant.meta.h, [...nodeDefAncestor.meta.h, nodeDefAncestor.uuid])\n}\n\nexport const getNodeDefRoot = (params: { survey: ArenaSurvey }): ArenaNodeDefEntity => {\n const { survey } = params\n if (!survey.nodeDefs) throw new SystemError(SystemErrorKeys.survey.emptyNodeDefs)\n\n const rootDefUuidInIndex = survey.nodeDefsIndex?.rootDefUuid\n\n const rootDef = rootDefUuidInIndex\n ? getNodeDefByUuid({ survey, uuid: rootDefUuidInIndex })\n : getNodeDefsArray(survey).find((nodeDef) => !nodeDef.parentUuid)\n\n if (!rootDef) throw new SystemError(SystemErrorKeys.survey.rootDefNotFound)\n\n return rootDef as ArenaNodeDefEntity\n}\n\nexport const getNodeDefSource = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n}): ArenaNodeDef<NodeDefType, ArenaNodeDefProps> | undefined => {\n const { survey, nodeDef } = params\n return nodeDef.virtual ? getNodeDefParent({ survey, nodeDef }) : undefined\n}\n\nexport const getNodeDefChildren = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n includeAnalysis?: boolean\n includeLayoutElements?: boolean\n}): ArenaNodeDef<NodeDefType, ArenaNodeDefProps>[] => {\n const { survey, nodeDef, includeAnalysis = false, includeLayoutElements = false } = params\n\n if (!survey.nodeDefs) return []\n\n let childDefs = []\n // try to get children using index\n if (survey.nodeDefsIndex) {\n const childrenUuids = Object.keys(survey.nodeDefsIndex.childDefUuidPresenceByParentUuid?.[nodeDef.uuid] ?? {})\n childDefs = getNodeDefsByUuids({ survey, uuids: childrenUuids })\n } else {\n // calculate children\n childDefs = NodeDefsReader.calculateNodeDefChildren(nodeDef)(survey)\n }\n if (includeAnalysis && includeLayoutElements) {\n return childDefs\n }\n return childDefs.filter((childDef) => {\n if (!includeAnalysis && childDef.analysis) return false\n if (!includeLayoutElements && NodeDefs.isLayoutElement(childDef)) return false\n return true\n })\n}\n\nexport const getQualifierDefs = (params: { survey: ArenaSurvey }): ArenaNodeDef<NodeDefType, ArenaNodeDefProps>[] => {\n const { survey } = params\n const qualifierPresence = survey.nodeDefsIndex?.qualifierPresenceByUuid\n if (qualifierPresence) {\n const qualifierUuids = Object.keys(qualifierPresence)\n return getNodeDefsByUuids({ survey, uuids: qualifierUuids })\n } else {\n return getNodeDefsArray(survey).filter((nodeDef) => NodeDefs.isQualifier(nodeDef))\n }\n}\n\nconst getIndexInChain = (params: { survey: ArenaSurvey; nodeDef: ArenaNodeDef<any> }): number => {\n const { survey, nodeDef } = params\n const areaBasedEstimatedOf = NodeDefs.getAreaBasedEstimatedOf(nodeDef)\n const areaBasedEstimatedOfNodeDef = areaBasedEstimatedOf\n ? getNodeDefByUuid({ survey, uuid: areaBasedEstimatedOf })\n : null\n const nodeDefToConsider = areaBasedEstimatedOfNodeDef ?? nodeDef\n return nodeDefToConsider?.propsAdvanced?.index ?? 0\n}\n\nconst getNodeDefChildrenUuidsSortedByLayout = (params: {\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n cycle: string\n children: ArenaNodeDef<any>[]\n}): string[] => {\n const { nodeDef, cycle, children } = params\n\n const entityDef = nodeDef as ArenaNodeDefEntity\n\n const childrenEntitiesInOwnPageSortedUuids = NodeDefs.getChildrenEntitiesInOwnPageUuids(cycle)(entityDef) ?? []\n const layoutChildren = NodeDefs.getLayoutChildren(cycle)(entityDef) ?? []\n const childrenByUuids = children.reduce((acc: ArenaNodeDefMap, child) => {\n acc[child.uuid] = child\n return acc\n }, {})\n const childrenUuids = Object.keys(childrenByUuids)\n\n if (layoutChildren.length === 0 && childrenEntitiesInOwnPageSortedUuids.length === 0) {\n return childrenUuids\n }\n const sortedChildrenDefsInSamePageUuids = NodeDefs.isLayoutRenderTypeTable(cycle)(entityDef)\n ? (layoutChildren as string[])\n : [...(layoutChildren as ArenaNodeDefEntityChildPosition[])]\n .sort(\n (gridItem1: ArenaNodeDefEntityChildPosition, gridItem2: ArenaNodeDefEntityChildPosition) =>\n gridItem1.y - gridItem2.y || gridItem1.x - gridItem2.x\n )\n .map((gridItem) => gridItem.i)\n .filter((nodeDefUuid) => !!childrenByUuids[nodeDefUuid])\n\n const missingChildrenUuidsInLayout = childrenUuids.filter((childUuid) => {\n const childDef = childrenByUuids[childUuid]\n return (\n !sortedChildrenDefsInSamePageUuids.includes(childUuid) &&\n !childrenEntitiesInOwnPageSortedUuids.includes(childUuid) &&\n NodeDefs.isInCycle(cycle)(childDef)\n )\n })\n\n return (\n sortedChildrenDefsInSamePageUuids\n // add child uuids missing in layout at the end\n .concat(missingChildrenUuidsInLayout)\n // add child entities in own page at the very end\n .concat(childrenEntitiesInOwnPageSortedUuids)\n )\n}\n\nconst _booleanToNumber = (value: boolean | undefined): number => (value ? 1 : 0)\nconst _compareBooleans = (value1: boolean | undefined, value2: boolean | undefined): number =>\n _booleanToNumber(value1) - _booleanToNumber(value2)\n\nexport const getNodeDefChildrenSorted = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n cycle: string\n includeAnalysis?: boolean\n includeLayoutElements?: boolean\n}): ArenaNodeDef<NodeDefType, ArenaNodeDefProps>[] => {\n const { survey, nodeDef, cycle, includeAnalysis, includeLayoutElements } = params\n\n const children = getNodeDefChildren({ survey, nodeDef, includeAnalysis, includeLayoutElements }).filter(\n NodeDefs.isInCycle(cycle)\n )\n\n const childrenUuidsSortedByLayout = getNodeDefChildrenUuidsSortedByLayout({ nodeDef, cycle, children })\n // position lookup in the comparator without scanning the array (-1 for children not in the layout, as indexOf)\n const layoutIndexByUuid = new Map(childrenUuidsSortedByLayout.map((uuid, index) => [uuid, index]))\n const getLayoutIndex = (child: ArenaNodeDef<any>): number => layoutIndexByUuid.get(child.uuid) ?? -1\n\n return children.sort((child1, child2) => {\n if (includeAnalysis && (child1.analysis || child2.analysis)) {\n // analysis attribute at the end\n const analysisComparison = _compareBooleans(child1.analysis, child2.analysis)\n if (analysisComparison !== 0) return analysisComparison\n\n // sort by chain index\n const indexInChainComparison =\n getIndexInChain({ survey, nodeDef: child1 }) - getIndexInChain({ survey, nodeDef: child2 })\n if (indexInChainComparison !== 0) return indexInChainComparison\n\n // one node def is the area base estimated of the other\n const areaBasedEstimatedOfComparison = _compareBooleans(\n !!NodeDefs.getAreaBasedEstimatedOf(child1),\n !!NodeDefs.getAreaBasedEstimatedOf(child2)\n )\n if (areaBasedEstimatedOfComparison !== 0) return areaBasedEstimatedOfComparison\n\n return (child1.id ?? 0) - (child2.id ?? 0)\n }\n // keep sorting as defined in layout props\n return getLayoutIndex(child1) - getLayoutIndex(child2)\n })\n}\n\nexport const visitAncestorsAndSelfNodeDef = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDef<any>\n visitor: (nodeDef: ArenaNodeDef<any>) => void\n stopIfFn?: () => boolean\n includeSelf?: boolean\n}): void => {\n const { survey, nodeDef, visitor, stopIfFn, includeSelf = true } = params\n if (includeSelf) {\n visitor(nodeDef)\n }\n let currentParent = getNodeDefParent({ survey, nodeDef })\n while (currentParent) {\n visitor(currentParent)\n if (stopIfFn?.()) {\n break\n }\n currentParent = getNodeDefParent({ survey, nodeDef: currentParent })\n }\n}\n\nexport const findAncestorNodeDef = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDef<any>\n predicate: (entityDef: ArenaNodeDefEntity) => boolean\n}): ArenaNodeDefEntity | undefined => {\n const { survey, nodeDef, predicate } = params\n let result: ArenaNodeDefEntity | undefined = undefined\n visitAncestorsAndSelfNodeDef({\n survey,\n nodeDef,\n // ancestors only: the node def itself is never an ancestor (e.g. a multiple attribute)\n includeSelf: false,\n visitor: (entityDef) => {\n if (predicate(entityDef)) {\n result = entityDef\n }\n },\n stopIfFn: () => !!result,\n })\n return result\n}\n\ntype NodeDefTraverseParams = {\n nodeDef: ArenaNodeDef<any>\n visitor: (nodeDef: ArenaNodeDef<any>) => void\n shouldTraverse: (nodeDef: ArenaNodeDef<any>) => boolean\n getChildren: (nodeDef: ArenaNodeDef<any>) => ArenaNodeDef<any>[]\n}\n\nconst traverseBreadthFirst = ({ nodeDef, visitor, shouldTraverse, getChildren }: NodeDefTraverseParams) => {\n const queue = new Queue<ArenaNodeDef<NodeDefType>>()\n\n queue.enqueue(nodeDef)\n\n while (!queue.isEmpty()) {\n const visitedNodeDef = queue.dequeue()!\n\n visitor(visitedNodeDef)\n\n if (shouldTraverse(visitedNodeDef)) {\n queue.enqueueItems(getChildren(visitedNodeDef))\n }\n }\n}\n\nconst traverseDepthFirst = ({ nodeDef, visitor, shouldTraverse, getChildren }: NodeDefTraverseParams) => {\n const stack: ArenaNodeDef<any>[] = []\n\n stack.push(nodeDef)\n\n while (stack.length > 0) {\n const visitedNodeDef = stack.pop()!\n\n visitor(visitedNodeDef)\n\n if (shouldTraverse(visitedNodeDef)) {\n const children = getChildren(visitedNodeDef)\n // add children to stack in reverse order\n for (let index = children.length - 1; index >= 0; index--) {\n stack.push(children[index])\n }\n }\n }\n}\n\nexport const visitDescendantsAndSelfNodeDef = (params: {\n survey: ArenaSurvey\n cycle?: string\n nodeDef: ArenaNodeDef<any>\n visitor: (nodeDef: ArenaNodeDef<any>) => void\n includeAnalysis?: boolean\n traverseMethod?: TraverseMethod\n traverseOnlySingleEntities?: boolean\n}) => {\n const {\n survey,\n cycle,\n nodeDef,\n visitor,\n includeAnalysis = false,\n traverseMethod = TraverseMethod.bfs,\n traverseOnlySingleEntities = false,\n } = params\n\n const getNodeDefChildrenInternal = (visitedNodeDef: ArenaNodeDef<any>) =>\n Objects.isEmpty(cycle)\n ? getNodeDefChildren({ survey, nodeDef: visitedNodeDef, includeAnalysis })\n : getNodeDefChildrenSorted({ survey, nodeDef: visitedNodeDef, cycle: cycle!, includeAnalysis })\n\n const shouldTraverse = (visitedNodeDef: ArenaNodeDef<any>): boolean =>\n visitedNodeDef.type === NodeDefType.entity &&\n (visitedNodeDef === nodeDef ||\n NodeDefs.isRoot(visitedNodeDef) ||\n !traverseOnlySingleEntities ||\n NodeDefs.isSingle(visitedNodeDef))\n\n const traverseParams = { nodeDef, visitor, shouldTraverse, getChildren: getNodeDefChildrenInternal }\n if (traverseMethod === TraverseMethod.bfs) {\n traverseBreadthFirst(traverseParams)\n } else {\n traverseDepthFirst(traverseParams)\n }\n}\n\nexport const visitNodeDefs = (params: {\n survey: ArenaSurvey\n visitor: (nodeDef: ArenaNodeDef<any>) => void\n includeAnalysis?: boolean\n traverseMethod?: TraverseMethod\n}) => {\n const { survey, visitor, traverseMethod = TraverseMethod.bfs, includeAnalysis = false } = params\n const rootDef = getNodeDefRoot({ survey })\n return visitDescendantsAndSelfNodeDef({ survey, nodeDef: rootDef, visitor, traverseMethod, includeAnalysis })\n}\n\n// Node Def Code\nexport const getNodeDefParentCode = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDefCode\n}): ArenaNodeDefCode | undefined => {\n const { survey, nodeDef } = params\n const parentCodeDefUuid = nodeDef.props.parentCodeDefUuid\n if (!parentCodeDefUuid) return undefined\n const parentCodeDef = getNodeDefByUuid({ survey, uuid: parentCodeDefUuid })\n return parentCodeDef as ArenaNodeDefCode\n}\n\nexport const getNodeDefAncestorCodes = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDefCode\n}): ArenaNodeDefCode[] => {\n const { survey, nodeDef } = params\n const ancestors = []\n let currentParentCode = getNodeDefParentCode({ survey, nodeDef })\n while (currentParentCode) {\n ancestors.unshift(currentParentCode)\n currentParentCode = getNodeDefParentCode({ survey, nodeDef: currentParentCode })\n }\n return ancestors\n}\n\nexport const isNodeDefParentCode = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n}): boolean => {\n const { survey, nodeDef } = params\n const nodeDefsArray = getNodeDefsArray(survey)\n return nodeDefsArray.some(\n (def) => nodeDef.uuid === (def as ArenaNodeDef<NodeDefType.code, ArenaNodeDefCodeProps>).props?.parentCodeDefUuid\n )\n}\n\nexport const getNodeDefCategoryLevelIndex = (params: { survey: ArenaSurvey; nodeDef: ArenaNodeDefCode }): number => {\n const { survey, nodeDef } = params\n const parentCodeNodeDef = getNodeDefParentCode({ survey, nodeDef })\n return parentCodeNodeDef ? 1 + getNodeDefCategoryLevelIndex({ survey, nodeDef: parentCodeNodeDef }) : 0\n}\n\nexport const getDependentCodeAttributeDefs = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDefCode\n}): ArenaNodeDefCode[] => {\n const { survey, nodeDef } = params\n\n const categoryUuid = NodeDefs.getCategoryUuid(nodeDef)\n if (!categoryUuid) return []\n\n const category = getCategoryByUuid({ survey, categoryUuid })\n const levelsCount = Object.keys(category?.levels ?? {}).length\n if (levelsCount <= 1) return []\n\n const nodeDefsArray = getNodeDefsArray(survey)\n return nodeDefsArray.filter(\n (def) => def.type === NodeDefType.code && NodeDefs.getParentCodeDefUuid(def as ArenaNodeDefCode) === nodeDef.uuid\n ) as ArenaNodeDefCode[]\n}\n\nexport const getDependentEnumeratedEntityDefs = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDefCode\n}): ArenaNodeDefEntity[] => {\n const { survey, nodeDef } = params\n const result: ArenaNodeDefEntity[] = []\n const dependentCodeAttributeDefs = getDependentCodeAttributeDefs({ survey, nodeDef })\n for (const dependentCodeDef of dependentCodeAttributeDefs) {\n if (NodeDefs.isKey(dependentCodeDef)) {\n const entityDef = getNodeDefAncestorMultipleEntity({ survey, nodeDef: dependentCodeDef })\n if (entityDef && NodeDefs.isEnumerate(entityDef)) {\n result.push(entityDef)\n }\n }\n }\n return result\n}\n\nexport const getNodeDefKeys = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n cycle?: string\n}): ArenaNodeDef<NodeDefType, ArenaNodeDefProps>[] => {\n const { survey, cycle, nodeDef } = params\n\n return getDescendantsInSingleEntities({\n survey,\n cycle,\n nodeDef,\n predicate: (visitedNodeDef) =>\n NodeDefs.isKey(visitedNodeDef) &&\n !visitedNodeDef.deleted &&\n (Objects.isEmpty(cycle) || NodeDefs.isInCycle(cycle!)(visitedNodeDef)),\n })\n}\n\nexport const getRootKeys = (params: { survey: ArenaSurvey; cycle?: string }) => {\n const { survey, cycle } = params\n const rootDef = getNodeDefRoot({ survey })\n return getNodeDefKeys({ survey, nodeDef: rootDef, cycle })\n}\n\nexport const getNodeDefEnumerator = (params: {\n survey: ArenaSurvey\n entityDef: ArenaNodeDefEntity\n}): ArenaNodeDefCode | undefined => {\n const { survey, entityDef } = params\n if (!entityDef.props.enumerate) return undefined\n\n const children = getNodeDefChildren({ survey, nodeDef: entityDef })\n const codeAttributeKeys = children.filter((child) => child.type === NodeDefType.code && child.props.key)\n if (codeAttributeKeys.length === 1) {\n return codeAttributeKeys[0] as ArenaNodeDefCode\n }\n return undefined\n}\n\nexport const isNodeDefEnumerator = (params: { survey: ArenaSurvey; nodeDef: ArenaNodeDef<NodeDefType> }): boolean => {\n const { survey, nodeDef } = params\n if (nodeDef.type !== NodeDefType.code) return false\n const entityDef = getNodeDefParent({ survey, nodeDef })\n if (!entityDef) return false\n const enumerator = getNodeDefEnumerator({ survey, entityDef })\n return enumerator?.uuid === nodeDef.uuid\n}\n\nexport const getDescendantsInSingleEntities = (params: {\n survey: ArenaSurvey\n cycle?: string\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n predicate?: (visitedNodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>) => boolean\n includeAnalysis?: boolean\n}): ArenaNodeDef<NodeDefType, ArenaNodeDefProps>[] => {\n const { survey, cycle, nodeDef, predicate, includeAnalysis } = params\n const result: ArenaNodeDef<any>[] = []\n visitDescendantsAndSelfNodeDef({\n survey,\n cycle,\n nodeDef,\n visitor: (visitedNodeDef) => {\n if (!predicate || predicate(visitedNodeDef)) {\n result.push(visitedNodeDef)\n }\n },\n includeAnalysis,\n traverseOnlySingleEntities: true,\n })\n return result\n}\n\nexport const getNodeDefsIncludedInMultipleEntitySummary = (params: {\n survey: ArenaSurvey\n cycle: string\n nodeDef: ArenaNodeDef<NodeDefType, ArenaNodeDefProps>\n}): ArenaNodeDef<NodeDefType, ArenaNodeDefProps>[] => {\n const { survey, cycle, nodeDef } = params\n return getDescendantsInSingleEntities({\n survey,\n cycle,\n nodeDef,\n predicate: (visitedNodeDef) => NodeDefs.isIncludedInMultipleEntitySummary(cycle)(visitedNodeDef),\n })\n}\n\nconst { buildAndAssocNodeDefsIndex, addNodeDefToIndex, updateNodeDefUuidByNameIndex, deleteNodeDefIndex } =\n NodeDefsIndex\nexport { buildAndAssocNodeDefsIndex, addNodeDefToIndex, updateNodeDefUuidByNameIndex, deleteNodeDefIndex }\n"]}
|
|
1
|
+
{"version":3,"file":"nodeDefs.js","sourceRoot":"","sources":["../../../../src/survey/surveys/nodeDefs.ts"],"names":[],"mappings":"AACA,OAAO,EAQL,WAAW,EACX,QAAQ,GACT,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,KAAK,cAAc,MAAM,4BAA4B,CAAA;AAC5D,OAAO,KAAK,aAAa,MAAM,2BAA2B,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC,gBAAgB,CAAA;AAE/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAA6C,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EAAE,iBAAiB,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,CAAA","sourcesContent":["import { ArenaSurvey } from '../survey'\nimport {\n ArenaAnyNodeDef,\n ArenaNodeDef,\n ArenaNodeDefCode,\n ArenaNodeDefCodeProps,\n ArenaNodeDefEntity,\n ArenaNodeDefEntityChildPosition,\n ArenaNodeDefMap,\n NodeDefType,\n NodeDefs,\n} from '../../nodeDef'\nimport { Arrays, Objects, Queue } from '../../utils'\nimport { SystemError, SystemErrorKeys } from '../../error'\nimport * as NodeDefsReader from './_nodeDefs/nodeDefsReader'\nimport * as NodeDefsIndex from './_nodeDefs/nodeDefsIndex'\nimport { TraverseMethod } from '../../common'\nimport { getCategoryByUuid } from './surveysGetters'\n\nexport const getNodeDefsArray = NodeDefsReader.getNodeDefsArray\n\nexport const findNodeDefByUuid = (params: { survey: ArenaSurvey; uuid: string }): ArenaAnyNodeDef | undefined => {\n const { survey, uuid } = params\n return survey.nodeDefs?.[uuid]\n}\n\nexport const getNodeDefByUuid = (params: { survey: ArenaSurvey; uuid: string }): ArenaAnyNodeDef => {\n const { survey, uuid } = params\n const nodeDef = findNodeDefByUuid({ survey, uuid })\n if (!nodeDef) throw new SystemError(SystemErrorKeys.survey.nodeDefUuidNotFound, { uuid })\n return nodeDef\n}\n\nexport const findNodeDefByName = (params: { survey: ArenaSurvey; name: string }): ArenaAnyNodeDef | undefined => {\n const { survey, name } = params\n const nodeDefUuidByNameIndex = survey.nodeDefsIndex?.nodeDefUuidByName\n if (nodeDefUuidByNameIndex) {\n const uuid = nodeDefUuidByNameIndex[name]\n return findNodeDefByUuid({ survey, uuid })\n }\n return getNodeDefsArray(survey).find((nodeDef) => nodeDef.props.name === name)\n}\n\nexport const getNodeDefByName = (params: { survey: ArenaSurvey; name: string }): ArenaAnyNodeDef => {\n const { survey, name } = params\n const nodeDef = findNodeDefByName({ survey, name })\n if (!nodeDef) {\n throw new SystemError(SystemErrorKeys.survey.nodeDefNameNotFound, { name })\n }\n return nodeDef\n}\n\nexport const getNodeDefsByUuids = (params: { survey: ArenaSurvey; uuids: string[] }) => {\n const { survey, uuids } = params\n return uuids.map((uuid) => getNodeDefByUuid({ survey, uuid }))\n}\n\nexport const findNodeDefsByUuids = (params: { survey: ArenaSurvey; uuids: string[] }): ArenaAnyNodeDef[] => {\n const { survey, uuids } = params\n return uuids.reduce((acc: ArenaAnyNodeDef[], uuid) => {\n const nodeDef = findNodeDefByUuid({ survey, uuid })\n if (nodeDef) {\n acc.push(nodeDef)\n }\n return acc\n }, [])\n}\n\nexport const getNodeDefParent = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaAnyNodeDef\n}): ArenaNodeDefEntity | undefined => {\n const { survey, nodeDef } = params\n if (!nodeDef.parentUuid) return undefined\n return getNodeDefByUuid({ survey, uuid: nodeDef.parentUuid }) as ArenaNodeDefEntity\n}\n\nexport const getNodeDefAncestorMultipleEntity = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaAnyNodeDef\n}): ArenaNodeDefEntity | undefined => {\n const { survey, nodeDef } = params\n return findAncestorNodeDef({\n survey,\n nodeDef,\n predicate: (entityDef) => NodeDefs.isRoot(entityDef) || NodeDefs.isMultiple(entityDef),\n })\n}\n\nexport const isNodeDefAncestor = (params: {\n nodeDefAncestor: ArenaAnyNodeDef\n nodeDefDescendant: ArenaAnyNodeDef\n}): boolean => {\n const { nodeDefAncestor, nodeDefDescendant } = params\n\n return Arrays.startsWith(nodeDefDescendant.meta.h, [...nodeDefAncestor.meta.h, nodeDefAncestor.uuid])\n}\n\nexport const getNodeDefRoot = (params: { survey: ArenaSurvey }): ArenaNodeDefEntity => {\n const { survey } = params\n if (!survey.nodeDefs) throw new SystemError(SystemErrorKeys.survey.emptyNodeDefs)\n\n const rootDefUuidInIndex = survey.nodeDefsIndex?.rootDefUuid\n\n const rootDef = rootDefUuidInIndex\n ? getNodeDefByUuid({ survey, uuid: rootDefUuidInIndex })\n : getNodeDefsArray(survey).find((nodeDef) => !nodeDef.parentUuid)\n\n if (!rootDef) throw new SystemError(SystemErrorKeys.survey.rootDefNotFound)\n\n return rootDef as ArenaNodeDefEntity\n}\n\nexport const getNodeDefSource = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaAnyNodeDef\n}): ArenaAnyNodeDef | undefined => {\n const { survey, nodeDef } = params\n return nodeDef.virtual ? getNodeDefParent({ survey, nodeDef }) : undefined\n}\n\nexport const getNodeDefChildren = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaAnyNodeDef\n includeAnalysis?: boolean\n includeLayoutElements?: boolean\n}): ArenaAnyNodeDef[] => {\n const { survey, nodeDef, includeAnalysis = false, includeLayoutElements = false } = params\n\n if (!survey.nodeDefs) return []\n\n let childDefs = []\n // try to get children using index\n if (survey.nodeDefsIndex) {\n const childrenUuids = Object.keys(survey.nodeDefsIndex.childDefUuidPresenceByParentUuid?.[nodeDef.uuid] ?? {})\n childDefs = getNodeDefsByUuids({ survey, uuids: childrenUuids })\n } else {\n // calculate children\n childDefs = NodeDefsReader.calculateNodeDefChildren(nodeDef)(survey)\n }\n if (includeAnalysis && includeLayoutElements) {\n return childDefs\n }\n return childDefs.filter((childDef) => {\n if (!includeAnalysis && childDef.analysis) return false\n if (!includeLayoutElements && NodeDefs.isLayoutElement(childDef)) return false\n return true\n })\n}\n\nexport const getQualifierDefs = (params: { survey: ArenaSurvey }): ArenaAnyNodeDef[] => {\n const { survey } = params\n const qualifierPresence = survey.nodeDefsIndex?.qualifierPresenceByUuid\n if (qualifierPresence) {\n const qualifierUuids = Object.keys(qualifierPresence)\n return getNodeDefsByUuids({ survey, uuids: qualifierUuids })\n } else {\n return getNodeDefsArray(survey).filter((nodeDef) => NodeDefs.isQualifier(nodeDef))\n }\n}\n\nconst getIndexInChain = (params: { survey: ArenaSurvey; nodeDef: ArenaNodeDef<any> }): number => {\n const { survey, nodeDef } = params\n const areaBasedEstimatedOf = NodeDefs.getAreaBasedEstimatedOf(nodeDef)\n const areaBasedEstimatedOfNodeDef = areaBasedEstimatedOf\n ? getNodeDefByUuid({ survey, uuid: areaBasedEstimatedOf })\n : null\n const nodeDefToConsider = areaBasedEstimatedOfNodeDef ?? nodeDef\n return nodeDefToConsider?.propsAdvanced?.index ?? 0\n}\n\nconst getNodeDefChildrenUuidsSortedByLayout = (params: {\n nodeDef: ArenaAnyNodeDef\n cycle: string\n children: ArenaNodeDef<any>[]\n}): string[] => {\n const { nodeDef, cycle, children } = params\n\n const entityDef = nodeDef as ArenaNodeDefEntity\n\n const childrenEntitiesInOwnPageSortedUuids = NodeDefs.getChildrenEntitiesInOwnPageUuids(cycle)(entityDef) ?? []\n const layoutChildren = NodeDefs.getLayoutChildren(cycle)(entityDef) ?? []\n const childrenByUuids = children.reduce((acc: ArenaNodeDefMap, child) => {\n acc[child.uuid] = child\n return acc\n }, {})\n const childrenUuids = Object.keys(childrenByUuids)\n\n if (layoutChildren.length === 0 && childrenEntitiesInOwnPageSortedUuids.length === 0) {\n return childrenUuids\n }\n const sortedChildrenDefsInSamePageUuids = NodeDefs.isLayoutRenderTypeTable(cycle)(entityDef)\n ? (layoutChildren as string[])\n : [...(layoutChildren as ArenaNodeDefEntityChildPosition[])]\n .sort(\n (gridItem1: ArenaNodeDefEntityChildPosition, gridItem2: ArenaNodeDefEntityChildPosition) =>\n gridItem1.y - gridItem2.y || gridItem1.x - gridItem2.x\n )\n .map((gridItem) => gridItem.i)\n .filter((nodeDefUuid) => !!childrenByUuids[nodeDefUuid])\n\n const missingChildrenUuidsInLayout = childrenUuids.filter((childUuid) => {\n const childDef = childrenByUuids[childUuid]\n return (\n !sortedChildrenDefsInSamePageUuids.includes(childUuid) &&\n !childrenEntitiesInOwnPageSortedUuids.includes(childUuid) &&\n NodeDefs.isInCycle(cycle)(childDef)\n )\n })\n\n return (\n sortedChildrenDefsInSamePageUuids\n // add child uuids missing in layout at the end\n .concat(missingChildrenUuidsInLayout)\n // add child entities in own page at the very end\n .concat(childrenEntitiesInOwnPageSortedUuids)\n )\n}\n\nconst _booleanToNumber = (value: boolean | undefined): number => (value ? 1 : 0)\nconst _compareBooleans = (value1: boolean | undefined, value2: boolean | undefined): number =>\n _booleanToNumber(value1) - _booleanToNumber(value2)\n\nexport const getNodeDefChildrenSorted = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaAnyNodeDef\n cycle: string\n includeAnalysis?: boolean\n includeLayoutElements?: boolean\n}): ArenaAnyNodeDef[] => {\n const { survey, nodeDef, cycle, includeAnalysis, includeLayoutElements } = params\n\n const children = getNodeDefChildren({ survey, nodeDef, includeAnalysis, includeLayoutElements }).filter(\n NodeDefs.isInCycle(cycle)\n )\n\n const childrenUuidsSortedByLayout = getNodeDefChildrenUuidsSortedByLayout({ nodeDef, cycle, children })\n // position lookup in the comparator without scanning the array (-1 for children not in the layout, as indexOf)\n const layoutIndexByUuid = new Map(childrenUuidsSortedByLayout.map((uuid, index) => [uuid, index]))\n const getLayoutIndex = (child: ArenaNodeDef<any>): number => layoutIndexByUuid.get(child.uuid) ?? -1\n\n return children.sort((child1, child2) => {\n if (includeAnalysis && (child1.analysis || child2.analysis)) {\n // analysis attribute at the end\n const analysisComparison = _compareBooleans(child1.analysis, child2.analysis)\n if (analysisComparison !== 0) return analysisComparison\n\n // sort by chain index\n const indexInChainComparison =\n getIndexInChain({ survey, nodeDef: child1 }) - getIndexInChain({ survey, nodeDef: child2 })\n if (indexInChainComparison !== 0) return indexInChainComparison\n\n // one node def is the area base estimated of the other\n const areaBasedEstimatedOfComparison = _compareBooleans(\n !!NodeDefs.getAreaBasedEstimatedOf(child1),\n !!NodeDefs.getAreaBasedEstimatedOf(child2)\n )\n if (areaBasedEstimatedOfComparison !== 0) return areaBasedEstimatedOfComparison\n\n return (child1.id ?? 0) - (child2.id ?? 0)\n }\n // keep sorting as defined in layout props\n return getLayoutIndex(child1) - getLayoutIndex(child2)\n })\n}\n\nexport const visitAncestorsAndSelfNodeDef = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDef<any>\n visitor: (nodeDef: ArenaNodeDef<any>) => void\n stopIfFn?: () => boolean\n includeSelf?: boolean\n}): void => {\n const { survey, nodeDef, visitor, stopIfFn, includeSelf = true } = params\n if (includeSelf) {\n visitor(nodeDef)\n }\n let currentParent = getNodeDefParent({ survey, nodeDef })\n while (currentParent) {\n visitor(currentParent)\n if (stopIfFn?.()) {\n break\n }\n currentParent = getNodeDefParent({ survey, nodeDef: currentParent })\n }\n}\n\nexport const findAncestorNodeDef = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDef<any>\n predicate: (entityDef: ArenaNodeDefEntity) => boolean\n}): ArenaNodeDefEntity | undefined => {\n const { survey, nodeDef, predicate } = params\n let result: ArenaNodeDefEntity | undefined = undefined\n visitAncestorsAndSelfNodeDef({\n survey,\n nodeDef,\n // ancestors only: the node def itself is never an ancestor (e.g. a multiple attribute)\n includeSelf: false,\n visitor: (entityDef) => {\n if (predicate(entityDef)) {\n result = entityDef\n }\n },\n stopIfFn: () => !!result,\n })\n return result\n}\n\ntype NodeDefTraverseParams = {\n nodeDef: ArenaNodeDef<any>\n visitor: (nodeDef: ArenaNodeDef<any>) => void\n shouldTraverse: (nodeDef: ArenaNodeDef<any>) => boolean\n getChildren: (nodeDef: ArenaNodeDef<any>) => ArenaNodeDef<any>[]\n}\n\nconst traverseBreadthFirst = ({ nodeDef, visitor, shouldTraverse, getChildren }: NodeDefTraverseParams) => {\n const queue = new Queue<ArenaAnyNodeDef>()\n\n queue.enqueue(nodeDef)\n\n while (!queue.isEmpty()) {\n const visitedNodeDef = queue.dequeue()!\n\n visitor(visitedNodeDef)\n\n if (shouldTraverse(visitedNodeDef)) {\n queue.enqueueItems(getChildren(visitedNodeDef))\n }\n }\n}\n\nconst traverseDepthFirst = ({ nodeDef, visitor, shouldTraverse, getChildren }: NodeDefTraverseParams) => {\n const stack: ArenaNodeDef<any>[] = []\n\n stack.push(nodeDef)\n\n while (stack.length > 0) {\n const visitedNodeDef = stack.pop()!\n\n visitor(visitedNodeDef)\n\n if (shouldTraverse(visitedNodeDef)) {\n const children = getChildren(visitedNodeDef)\n // add children to stack in reverse order\n for (let index = children.length - 1; index >= 0; index--) {\n stack.push(children[index])\n }\n }\n }\n}\n\nexport const visitDescendantsAndSelfNodeDef = (params: {\n survey: ArenaSurvey\n cycle?: string\n nodeDef: ArenaNodeDef<any>\n visitor: (nodeDef: ArenaNodeDef<any>) => void\n includeAnalysis?: boolean\n traverseMethod?: TraverseMethod\n traverseOnlySingleEntities?: boolean\n}) => {\n const {\n survey,\n cycle,\n nodeDef,\n visitor,\n includeAnalysis = false,\n traverseMethod = TraverseMethod.bfs,\n traverseOnlySingleEntities = false,\n } = params\n\n const getNodeDefChildrenInternal = (visitedNodeDef: ArenaNodeDef<any>) =>\n Objects.isEmpty(cycle)\n ? getNodeDefChildren({ survey, nodeDef: visitedNodeDef, includeAnalysis })\n : getNodeDefChildrenSorted({ survey, nodeDef: visitedNodeDef, cycle: cycle!, includeAnalysis })\n\n const shouldTraverse = (visitedNodeDef: ArenaNodeDef<any>): boolean =>\n visitedNodeDef.type === NodeDefType.entity &&\n (visitedNodeDef === nodeDef ||\n NodeDefs.isRoot(visitedNodeDef) ||\n !traverseOnlySingleEntities ||\n NodeDefs.isSingle(visitedNodeDef))\n\n const traverseParams = { nodeDef, visitor, shouldTraverse, getChildren: getNodeDefChildrenInternal }\n if (traverseMethod === TraverseMethod.bfs) {\n traverseBreadthFirst(traverseParams)\n } else {\n traverseDepthFirst(traverseParams)\n }\n}\n\nexport const visitNodeDefs = (params: {\n survey: ArenaSurvey\n visitor: (nodeDef: ArenaNodeDef<any>) => void\n includeAnalysis?: boolean\n traverseMethod?: TraverseMethod\n}) => {\n const { survey, visitor, traverseMethod = TraverseMethod.bfs, includeAnalysis = false } = params\n const rootDef = getNodeDefRoot({ survey })\n return visitDescendantsAndSelfNodeDef({ survey, nodeDef: rootDef, visitor, traverseMethod, includeAnalysis })\n}\n\n// Node Def Code\nexport const getNodeDefParentCode = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDefCode\n}): ArenaNodeDefCode | undefined => {\n const { survey, nodeDef } = params\n const parentCodeDefUuid = nodeDef.props.parentCodeDefUuid\n if (!parentCodeDefUuid) return undefined\n const parentCodeDef = getNodeDefByUuid({ survey, uuid: parentCodeDefUuid })\n return parentCodeDef as ArenaNodeDefCode\n}\n\nexport const getNodeDefAncestorCodes = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDefCode\n}): ArenaNodeDefCode[] => {\n const { survey, nodeDef } = params\n const ancestors = []\n let currentParentCode = getNodeDefParentCode({ survey, nodeDef })\n while (currentParentCode) {\n ancestors.unshift(currentParentCode)\n currentParentCode = getNodeDefParentCode({ survey, nodeDef: currentParentCode })\n }\n return ancestors\n}\n\nexport const isNodeDefParentCode = (params: { survey: ArenaSurvey; nodeDef: ArenaAnyNodeDef }): boolean => {\n const { survey, nodeDef } = params\n const nodeDefsArray = getNodeDefsArray(survey)\n return nodeDefsArray.some(\n (def) => nodeDef.uuid === (def as ArenaNodeDef<NodeDefType.code, ArenaNodeDefCodeProps>).props?.parentCodeDefUuid\n )\n}\n\nexport const getNodeDefCategoryLevelIndex = (params: { survey: ArenaSurvey; nodeDef: ArenaNodeDefCode }): number => {\n const { survey, nodeDef } = params\n const parentCodeNodeDef = getNodeDefParentCode({ survey, nodeDef })\n return parentCodeNodeDef ? 1 + getNodeDefCategoryLevelIndex({ survey, nodeDef: parentCodeNodeDef }) : 0\n}\n\nexport const getDependentCodeAttributeDefs = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDefCode\n}): ArenaNodeDefCode[] => {\n const { survey, nodeDef } = params\n\n const categoryUuid = NodeDefs.getCategoryUuid(nodeDef)\n if (!categoryUuid) return []\n\n const category = getCategoryByUuid({ survey, categoryUuid })\n const levelsCount = Object.keys(category?.levels ?? {}).length\n if (levelsCount <= 1) return []\n\n const nodeDefsArray = getNodeDefsArray(survey)\n return nodeDefsArray.filter(\n (def) => def.type === NodeDefType.code && NodeDefs.getParentCodeDefUuid(def as ArenaNodeDefCode) === nodeDef.uuid\n ) as ArenaNodeDefCode[]\n}\n\nexport const getDependentEnumeratedEntityDefs = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaNodeDefCode\n}): ArenaNodeDefEntity[] => {\n const { survey, nodeDef } = params\n const result: ArenaNodeDefEntity[] = []\n const dependentCodeAttributeDefs = getDependentCodeAttributeDefs({ survey, nodeDef })\n for (const dependentCodeDef of dependentCodeAttributeDefs) {\n if (NodeDefs.isKey(dependentCodeDef)) {\n const entityDef = getNodeDefAncestorMultipleEntity({ survey, nodeDef: dependentCodeDef })\n if (entityDef && NodeDefs.isEnumerate(entityDef)) {\n result.push(entityDef)\n }\n }\n }\n return result\n}\n\nexport const getNodeDefKeys = (params: {\n survey: ArenaSurvey\n nodeDef: ArenaAnyNodeDef\n cycle?: string\n}): ArenaAnyNodeDef[] => {\n const { survey, cycle, nodeDef } = params\n\n return getDescendantsInSingleEntities({\n survey,\n cycle,\n nodeDef,\n predicate: (visitedNodeDef) =>\n NodeDefs.isKey(visitedNodeDef) &&\n !visitedNodeDef.deleted &&\n (Objects.isEmpty(cycle) || NodeDefs.isInCycle(cycle!)(visitedNodeDef)),\n })\n}\n\nexport const getRootKeys = (params: { survey: ArenaSurvey; cycle?: string }) => {\n const { survey, cycle } = params\n const rootDef = getNodeDefRoot({ survey })\n return getNodeDefKeys({ survey, nodeDef: rootDef, cycle })\n}\n\nexport const getNodeDefEnumerator = (params: {\n survey: ArenaSurvey\n entityDef: ArenaNodeDefEntity\n}): ArenaNodeDefCode | undefined => {\n const { survey, entityDef } = params\n if (!entityDef.props.enumerate) return undefined\n\n const children = getNodeDefChildren({ survey, nodeDef: entityDef })\n const codeAttributeKeys = children.filter((child) => child.type === NodeDefType.code && child.props.key)\n if (codeAttributeKeys.length === 1) {\n return codeAttributeKeys[0] as ArenaNodeDefCode\n }\n return undefined\n}\n\nexport const isNodeDefEnumerator = (params: { survey: ArenaSurvey; nodeDef: ArenaAnyNodeDef }): boolean => {\n const { survey, nodeDef } = params\n if (nodeDef.type !== NodeDefType.code) return false\n const entityDef = getNodeDefParent({ survey, nodeDef })\n if (!entityDef) return false\n const enumerator = getNodeDefEnumerator({ survey, entityDef })\n return enumerator?.uuid === nodeDef.uuid\n}\n\nexport const getDescendantsInSingleEntities = (params: {\n survey: ArenaSurvey\n cycle?: string\n nodeDef: ArenaAnyNodeDef\n predicate?: (visitedNodeDef: ArenaAnyNodeDef) => boolean\n includeAnalysis?: boolean\n}): ArenaAnyNodeDef[] => {\n const { survey, cycle, nodeDef, predicate, includeAnalysis } = params\n const result: ArenaNodeDef<any>[] = []\n visitDescendantsAndSelfNodeDef({\n survey,\n cycle,\n nodeDef,\n visitor: (visitedNodeDef) => {\n if (!predicate || predicate(visitedNodeDef)) {\n result.push(visitedNodeDef)\n }\n },\n includeAnalysis,\n traverseOnlySingleEntities: true,\n })\n return result\n}\n\nexport const getNodeDefsIncludedInMultipleEntitySummary = (params: {\n survey: ArenaSurvey\n cycle: string\n nodeDef: ArenaAnyNodeDef\n}): ArenaAnyNodeDef[] => {\n const { survey, cycle, nodeDef } = params\n return getDescendantsInSingleEntities({\n survey,\n cycle,\n nodeDef,\n predicate: (visitedNodeDef) => NodeDefs.isIncludedInMultipleEntitySummary(cycle)(visitedNodeDef),\n })\n}\n\nconst { buildAndAssocNodeDefsIndex, addNodeDefToIndex, updateNodeDefUuidByNameIndex, deleteNodeDefIndex } =\n NodeDefsIndex\nexport { buildAndAssocNodeDefsIndex, addNodeDefToIndex, updateNodeDefUuidByNameIndex, deleteNodeDefIndex }\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeBuilder.js","sourceRoot":"","sources":["../../../../../src/tests/builder/recordBuilder/nodeBuilder.ts"],"names":[],"mappings":"AAKA,MAAM,OAAgB,WAAW;IAG/B,YAAY,WAAmB;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAES,UAAU,CAAC,MAA+B;;QAClD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,OAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,mCAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,WAAW,CAAC,CAAA;QAE1G,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,CAAC,WAAW,sBAAsB,CAAC,CAAA;QAC/E,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CAGF","sourcesContent":["import { ArenaRecordNode } from '../../../node'\nimport {
|
|
1
|
+
{"version":3,"file":"nodeBuilder.js","sourceRoot":"","sources":["../../../../../src/tests/builder/recordBuilder/nodeBuilder.ts"],"names":[],"mappings":"AAKA,MAAM,OAAgB,WAAW;IAG/B,YAAY,WAAmB;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAES,UAAU,CAAC,MAA+B;;QAClD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,OAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,mCAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,WAAW,CAAC,CAAA;QAE1G,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,CAAC,WAAW,sBAAsB,CAAC,CAAA;QAC/E,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CAGF","sourcesContent":["import { ArenaRecordNode } from '../../../node'\nimport { ArenaAnyNodeDef } from '../../../nodeDef'\nimport { ArenaRecord } from '../../../record'\nimport { ArenaSurvey } from '../../../survey'\n\nexport abstract class NodeBuilder {\n protected nodeDefName: string\n\n constructor(nodeDefName: string) {\n this.nodeDefName = nodeDefName\n }\n\n protected getNodeDef(params: { survey: ArenaSurvey }): ArenaAnyNodeDef {\n const nodeDef = Object.values(params.survey.nodeDefs ?? {}).find((n) => n.props.name === this.nodeDefName)\n\n if (!nodeDef) {\n throw new Error(`Node def with name ${this.nodeDefName} not found in survey`)\n }\n\n return nodeDef\n }\n\n abstract build(params: { survey: ArenaSurvey; record: ArenaRecord; parentNode?: ArenaRecordNode }): ArenaRecord\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeDefAttributeBuilder.js","sourceRoot":"","sources":["../../../../../src/tests/builder/surveyBuilder/nodeDefAttributeBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"nodeDefAttributeBuilder.js","sourceRoot":"","sources":["../../../../../src/tests/builder/surveyBuilder/nodeDefAttributeBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnF,OAAO,EAA0B,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,OAAO,uBAAwB,SAAQ,cAAc;IACzD,YAAY,IAAY,EAAE,IAAI,GAAgB,WAAW,CAAC,IAAI;QAC5D,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACnB,CAAC;IAED,KAAK,CAAC,MAAM,GAA2C,EAAE;QACvD,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,CAAA;QAChC,MAAM,GAAG,GAAoB,IAAI,CAAC,aAAa,CAAC,EAAE,aAAa,EAAE,CAAC,CAAA;QAClE,OAAO,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;IAC5B,CAAC;IAED,GAAG;QACD,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,CAAA;QACrB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,SAAS;QACP,IAAI,CAAC,KAA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O,IAAI,CAAA;IACb,CAAC;CACF","sourcesContent":["import { ArenaAnyNodeDef, ArenaNodeDefEntity, NodeDefType } from '../../../nodeDef'\nimport { ArenaNodeDefExpression, NodeDefExpressionFactory } from '../../../nodeDef/nodeDef'\nimport { NodeDefBuilder } from './nodeDefBuilder'\n\nexport class NodeDefAttributeBuilder extends NodeDefBuilder {\n constructor(name: string, type: NodeDefType = NodeDefType.text) {\n super(name, type)\n }\n\n build(params: { nodeDefParent?: ArenaNodeDefEntity } = {}): { [uuid: string]: ArenaAnyNodeDef } {\n const { nodeDefParent } = params\n const def: ArenaAnyNodeDef = this.createNodeDef({ nodeDefParent })\n return { [def.uuid]: def }\n }\n\n key(): this {\n this.props.key = true\n return this\n }\n\n qualifier(): this {\n this.props.qualifier = true\n return this\n }\n\n autoIncrementalKey(): this {\n this.props.autoIncrementalKey = true\n return this\n }\n\n readOnly(): this {\n this.props.readOnly = true\n return this\n }\n\n excludeInClone(): this {\n this.propsAdvanced.excludedInClone = true\n return this\n }\n\n defaultValue(expression: string): this {\n this.propsAdvanced.defaultValues = [NodeDefExpressionFactory.createInstance({ expression })]\n return this\n }\n\n defaultValues(...expressions: string[]): this {\n this.propsAdvanced.defaultValues = expressions.map((expression) =>\n NodeDefExpressionFactory.createInstance({ expression })\n )\n return this\n }\n\n defaultValueEvaluatedOnlyOneTime(): this {\n this.propsAdvanced.defaultValueEvaluatedOneTime = true\n return this\n }\n\n validationExpressions(...expressions: (string | ArenaNodeDefExpression)[]): this {\n this.propsAdvanced.validations ??= {}\n this.propsAdvanced.validations.expressions = expressions.map((expression) =>\n typeof expression === 'string' ? NodeDefExpressionFactory.createInstance({ expression }) : expression\n )\n return this\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeDefBuilder.js","sourceRoot":"","sources":["../../../../../src/tests/builder/surveyBuilder/nodeDefBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,cAAc,GAKf,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAuD,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AACxH,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,MAAM,OAAgB,cAAc;IAKlC,YAAY,IAAY,EAAE,IAAiB;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,KAAK,GAAG;YACX,IAAI;SACL,CAAA;QACD,IAAI,CAAC,aAAa,GAAG,EAAE,CAAA;IACzB,CAAC;IAES,aAAa,
|
|
1
|
+
{"version":3,"file":"nodeDefBuilder.js","sourceRoot":"","sources":["../../../../../src/tests/builder/surveyBuilder/nodeDefBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,cAAc,GAKf,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAuD,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AACxH,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,MAAM,OAAgB,cAAc;IAKlC,YAAY,IAAY,EAAE,IAAiB;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,KAAK,GAAG;YACX,IAAI;SACL,CAAA;QACD,IAAI,CAAC,aAAa,GAAG,EAAE,CAAA;IACzB,CAAC;IAES,aAAa,CAAC,MAAM,GAA2C,EAAE;QACzE,MAAM,OAAO,GAAG,cAAc,CAAC,cAAc,CAAC;YAC5C,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,aAAa,EAAE,IAAI,CAAC,aAAa;SAClC,CAAC,CAAA;QACF,OAAO,CAAC,SAAS,GAAG,KAAK,CAAA;QACzB,OAAO,OAAO,CAAA;IAChB,CAAC;IAMD,QAAQ;QACN,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAA;QAC1B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,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GAAG,WAAgD;QAC5D,OAAO,OAAO,CAAC,SAAS,CAAC;YACvB,GAAG,EAAE,IAAI;YACT,IAAI,EAAE,CAAC,eAAe,EAAE,aAAa,EAAE,YAAY,CAAC;YACpD,KAAK,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CACpC,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,wBAAwB,CAAC,cAAc,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CACtG;YACD,UAAU,EAAE,IAAI;SACjB,CAAC,CAAA;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,OAAO,CAAC,SAAS,CAAC;YACvB,GAAG,EAAE,IAAI;YACT,IAAI,EAAE,CAAC,eAAe,EAAE,aAAa,EAAE,UAAU,CAAC;YAClD,KAAK,EAAE,IAAI;YACX,UAAU,EAAE,IAAI;SACjB,CAAC,CAAA;IACJ,CAAC;CACF","sourcesContent":["import { ArenaSurvey } from '../../../survey'\nimport {\n ArenaAnyNodeDef,\n NodeDefFactory,\n ArenaNodeDefEntity,\n ArenaNodeDefProps,\n ArenaNodeDefPropsAdvanced,\n NodeDefType,\n} from '../../../nodeDef'\nimport { ArenaNodeDefCountExpression, ArenaNodeDefExpression, NodeDefExpressionFactory } from '../../../nodeDef/nodeDef'\nimport { Objects } from '../../../utils'\n\nexport abstract class NodeDefBuilder {\n protected props: ArenaNodeDefProps\n protected propsAdvanced: ArenaNodeDefPropsAdvanced\n protected type: NodeDefType\n\n constructor(name: string, type: NodeDefType) {\n this.type = type\n this.props = {\n name,\n }\n this.propsAdvanced = {}\n }\n\n protected createNodeDef(params: { nodeDefParent?: ArenaNodeDefEntity } = {}): ArenaAnyNodeDef {\n const nodeDef = NodeDefFactory.createInstance({\n nodeDefParent: params.nodeDefParent,\n type: this.type,\n props: this.props,\n propsAdvanced: this.propsAdvanced,\n })\n nodeDef.temporary = false\n return nodeDef\n }\n\n abstract build(params: { survey: ArenaSurvey; nodeDefParent?: ArenaNodeDefEntity }): {\n [uuid: string]: ArenaAnyNodeDef\n }\n\n multiple(): this {\n this.props.multiple = true\n return this\n }\n\n applyIf(expression: string): this {\n this.propsAdvanced.applicable = [NodeDefExpressionFactory.createInstance({ expression })]\n return this\n }\n\n editableIf(...expressions: (string | ArenaNodeDefExpression)[]): this {\n this.propsAdvanced.editableIf = expressions.map((expression) =>\n typeof expression === 'string' ? NodeDefExpressionFactory.createInstance({ expression }) : expression\n )\n return this\n }\n\n visibleIf(...expressions: (string | ArenaNodeDefExpression)[]): this {\n this.propsAdvanced.visibleIf = expressions.map((expression) =>\n typeof expression === 'string' ? NodeDefExpressionFactory.createInstance({ expression }) : expression\n )\n return this\n }\n\n maxCount(countExpr: ArenaNodeDefCountExpression): this {\n return Objects.assocPath({\n obj: this,\n path: ['propsAdvanced', 'validations', 'count', 'max'],\n value: countExpr,\n sideEffect: true,\n })\n }\n\n minCount(countExpr: ArenaNodeDefCountExpression): this {\n return Objects.assocPath({\n obj: this,\n path: ['propsAdvanced', 'validations', 'count', 'min'],\n value: countExpr,\n sideEffect: true,\n })\n }\n\n requiredIf(...expressions: (string | ArenaNodeDefExpression)[]): this {\n return Objects.assocPath({\n obj: this,\n path: ['propsAdvanced', 'validations', 'requiredIf'],\n value: expressions.map((expression) =>\n typeof expression === 'string' ? NodeDefExpressionFactory.createInstance({ expression }) : expression\n ),\n sideEffect: true,\n })\n }\n\n required(): this {\n return Objects.assocPath({\n obj: this,\n path: ['propsAdvanced', 'validations', 'required'],\n value: true,\n sideEffect: true,\n })\n }\n}\n"]}
|