@openforis/arena-core 2.6.0 → 2.8.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/node.js.map +1 -1
- package/dist/esm/node/nodes.js +21 -2
- package/dist/esm/node/nodes.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 +14 -0
- package/dist/esm/nodeDef/nodeDefs.js.map +1 -1
- package/dist/esm/nodeDef/types/geo.js +2 -0
- package/dist/esm/nodeDef/types/geo.js.map +1 -0
- package/dist/esm/record/_records/recordCompletion.js +4 -1
- package/dist/esm/record/_records/recordCompletion.js.map +1 -1
- package/dist/esm/record/_records/recordGetters.js +12 -0
- package/dist/esm/record/_records/recordGetters.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/index.js +3 -0
- package/dist/esm/record/recordNodesUpdater/index.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.js +87 -0
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.js.map +1 -0
- package/dist/esm/record/recordNodesUpdater/recordNodesUpdater.js +2 -0
- package/dist/esm/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
- package/dist/esm/record/recordUpdater.js +1 -0
- package/dist/esm/record/recordUpdater.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeValidator.js +24 -8
- package/dist/esm/record/recordValidator/attributeValidator.js.map +1 -1
- package/dist/esm/record/records.js +2 -1
- package/dist/esm/record/records.js.map +1 -1
- package/dist/esm/survey/survey.js +1 -0
- package/dist/esm/survey/survey.js.map +1 -1
- package/dist/esm/survey/surveys/dependencies.js +4 -0
- package/dist/esm/survey/surveys/dependencies.js.map +1 -1
- package/dist/esm/tests/builder/surveyBuilder/nodeDefBuilder.js +8 -0
- package/dist/esm/tests/builder/surveyBuilder/nodeDefBuilder.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/node/node.d.ts +7 -0
- package/dist/node/node.js.map +1 -1
- package/dist/node/nodes.d.ts +7 -0
- package/dist/node/nodes.js +21 -2
- package/dist/node/nodes.js.map +1 -1
- package/dist/nodeDef/index.d.ts +1 -0
- package/dist/nodeDef/index.js.map +1 -1
- package/dist/nodeDef/nodeDef.d.ts +4 -0
- package/dist/nodeDef/nodeDef.js.map +1 -1
- package/dist/nodeDef/nodeDefs.d.ts +14 -0
- package/dist/nodeDef/nodeDefs.js +14 -0
- package/dist/nodeDef/nodeDefs.js.map +1 -1
- package/dist/nodeDef/types/geo.d.ts +5 -0
- package/dist/nodeDef/types/geo.js +3 -0
- package/dist/nodeDef/types/geo.js.map +1 -0
- package/dist/record/_records/recordCompletion.js +4 -1
- package/dist/record/_records/recordCompletion.js.map +1 -1
- package/dist/record/_records/recordGetters.d.ts +5 -0
- package/dist/record/_records/recordGetters.js +14 -1
- package/dist/record/_records/recordGetters.js.map +1 -1
- package/dist/record/recordNodesUpdater/index.d.ts +3 -0
- package/dist/record/recordNodesUpdater/index.js +3 -0
- package/dist/record/recordNodesUpdater/index.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.d.ts +23 -0
- package/dist/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.js +93 -0
- package/dist/record/recordNodesUpdater/recordNodeDependentsRequiredUpdater.js.map +1 -0
- package/dist/record/recordNodesUpdater/recordNodesUpdater.js +2 -0
- package/dist/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
- package/dist/record/recordUpdater.js +1 -0
- package/dist/record/recordUpdater.js.map +1 -1
- package/dist/record/recordValidator/attributeValidator.js +24 -8
- package/dist/record/recordValidator/attributeValidator.js.map +1 -1
- package/dist/record/records.d.ts +2 -1
- package/dist/record/records.js +1 -0
- package/dist/record/records.js.map +1 -1
- package/dist/survey/survey.d.ts +1 -0
- package/dist/survey/survey.js +1 -0
- package/dist/survey/survey.js.map +1 -1
- package/dist/survey/surveys/dependencies.js +4 -0
- package/dist/survey/surveys/dependencies.js.map +1 -1
- package/dist/tests/builder/surveyBuilder/nodeDefBuilder.d.ts +1 -0
- package/dist/tests/builder/surveyBuilder/nodeDefBuilder.js +8 -0
- package/dist/tests/builder/surveyBuilder/nodeDefBuilder.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":";;;;;;;;;AAGA,OAAO,EAAmB,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACzE,OAAO,EAA4C,QAAQ,EAAe,MAAM,eAAe,CAAA;AAG/F,OAAO,EAAU,OAAO,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrC,OAAO,EACL,iBAAiB,EAEjB,uBAAuB,EACvB,kBAAkB,EAClB,SAAS,GACV,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAA;AACxE,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;AA6B3D,MAAM,mBAAmB,GAAG,CAC1B,MAAkF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CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;QACrE,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,MAAM,wCAAwC,GAAG,CAC/C,MAAuC,EACZ,EAAE;IAC7B,MAAM,eAAe,GAAsB,yBAAyB,CAAC,MAAM,CAAC,CAAA;IAC5E,MAAM,qBAAqB,GAAqB,EAAE,CAAA;IAClD,6EAA6E;IAC7E,MAAM,eAAe,GAAG,qBAAqB,EAAE,CAAA;IAE/C,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE,CAAC;QAC7C,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAA;QACpC,iEAAiE;QACjE,IAAI,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAChE,qEAAqE;YACrE,MAAM,wBAAwB,mCAAQ,MAAM,KAAE,SAAS,EAAE,cAAc,EAAE,eAAe,GAAE,CAAA;YAC1F,qBAAqB,CAAC,QAAQ,CAAC,GAAG,MAAM,iBAAiB,CAAC,wBAAwB,CAAC,CAAA,CAAC,UAAU;QAChG,CAAC;IACH,CAAC;IACD,OAAO,qBAAqB,CAAA;AAC9B,CAAC,CAAA,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,wCAAwC;CACzC,CAAA","sourcesContent":["import { User } from '../../auth'\nimport { Dictionary } from '../../common'\nimport { Labels } from '../../language'\nimport { ArenaRecordNode, NodeKeys, Nodes, NodeValues } from '../../node'\nimport { NodeDef, NodeDefExpression, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { CategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider'\nimport { TaxonProvider } from '../../nodeDefExpressionEvaluator/taxonProvider'\nimport { Survey, Surveys } from '../../survey'\nimport { SurveyDependencyType } from '../../survey/survey'\nimport { Objects } from '../../utils'\nimport {\n ValidationFactory,\n ValidationResult,\n ValidationResultFactory,\n ValidationSeverity,\n Validator,\n} from '../../validation'\nimport { ValidationFields } from '../../validation/validation'\nimport { NodePointers } from '../nodePointers'\nimport { ArenaRecord } from '../record'\nimport { RecordExpressionEvaluator } from '../recordExpressionEvaluator'\nimport { Records } from '../records'\nimport { RecordValidations } from '../recordValidations'\nimport { AttributeKeyValidator, createEntityKeysCache, EntityKeysCache } from './attributeKeyValidator'\nimport { AttributeTypeValidator } from './attributeTypeValidator'\nimport { AttributeUniqueValidator } from './attributeUniqueValidator'\n\nconst expressionEvaluator = new RecordExpressionEvaluator()\n\nexport interface RecordValidatorParams {\n user: User\n survey: Survey\n categoryItemProvider?: CategoryItemProvider\n taxonProvider?: TaxonProvider\n record: ArenaRecord\n}\n\nexport interface AttributeValidatorParams extends RecordValidatorParams {\n attribute: ArenaRecordNode\n}\n\nexport interface AttributesValidatorParams extends RecordValidatorParams {\n nodes: Dictionary<ArenaRecordNode>\n}\n\nexport interface SortedAttributesValidatorParams extends RecordValidatorParams {\n nodesArray: ArenaRecordNode[]\n}\n\ntype SiblingKeyNodeItem = { entityUuid: string; keyNode: ArenaRecordNode; hasErrors: boolean }\n\n// sibling key nodes are cached by ancestor multiple entity parent and def uuid during the same validation call:\n// when many entities are added to the same parent entity (e.g. data import), computing them for every updated\n// key attribute would take a time that grows quadratically with the number of entities\ntype SiblingKeyNodesCache = Map<string, SiblingKeyNodeItem[]>\n\nconst _getSiblingNodeKeys = (\n params: AttributeValidatorParams & { siblingKeyNodesCache?: SiblingKeyNodesCache }\n): SiblingKeyNodeItem[] => {\n const { survey, record, attribute, siblingKeyNodesCache } = params\n\n const attributeDef = Surveys.getNodeDefByUuid({ survey, uuid: attribute.nodeDefUuid })\n const ancestorMultipleEntityDef = Surveys.getNodeDefAncestorMultipleEntity({ survey, nodeDef: attributeDef })\n if (!ancestorMultipleEntityDef) {\n return []\n }\n const ancestorMultipleEntity = Records.getAncestor(attribute, ancestorMultipleEntityDef.uuid)(record)\n if (!ancestorMultipleEntity) return []\n\n const ancestorMultipleEntityParent = Records.getParent(ancestorMultipleEntity)(record)\n if (!ancestorMultipleEntityParent) return []\n\n const cacheKey = `${ancestorMultipleEntityParent.uuid}_${ancestorMultipleEntityDef.uuid}`\n let items = siblingKeyNodesCache?.get(cacheKey)\n if (!items) {\n const keyDefs = Surveys.getNodeDefKeys({ survey, nodeDef: ancestorMultipleEntityDef })\n const entities = Records.getEntitySiblings(ancestorMultipleEntity, true)(record)\n items = []\n for (const entity of entities) {\n const keyNodes = Records.getEntityKeyNodes(survey, entity, undefined, keyDefs)(record)\n for (const keyNode of keyNodes) {\n if (!keyNode) continue\n const nodeValidation =\n record.validation && RecordValidations.getValidationNode({ nodeUuid: keyNode.uuid })(record.validation)\n items.push({ entityUuid: entity.uuid, keyNode, hasErrors: !!nodeValidation && !nodeValidation.valid })\n }\n }\n siblingKeyNodesCache?.set(cacheKey, items)\n }\n return items.filter((item) => item.entityUuid !== ancestorMultipleEntity.uuid)\n}\n\nconst _getValidationMessagesWithDefault = (params: {\n survey: Survey\n expression: NodeDefExpression\n defaultMessage?: string\n}): Labels => {\n const { survey, expression, defaultMessage } = params\n const messages: Labels = { ...expression.messages }\n\n const languages = Surveys.getLanguages(survey)\n const defaultMessageDefined = Objects.isNotEmpty(defaultMessage)\n\n for (const lang of languages) {\n const customMessage = messages[lang]\n if (Objects.isEmpty(customMessage) && defaultMessageDefined) {\n messages[lang] = defaultMessage\n }\n }\n\n return messages\n}\n\nconst _validateRequired =\n (params: { nodeDef: NodeDef<NodeDefType, NodeDefProps> }) =>\n (_field: string, node: any): Promise<ValidationResult> => {\n const { nodeDef } = params\n const valid = (!NodeDefs.isKey(nodeDef) && !NodeDefs.isRequired(nodeDef)) || !Nodes.isValueBlank(node)\n return Promise.resolve(\n valid\n ? ValidationResultFactory.createInstance()\n : ValidationResultFactory.createInstance({\n key: 'record.attribute.valueRequired',\n severity: ValidationSeverity.error,\n valid,\n })\n )\n }\n\n/**\n * Evaluates the validation expressions.\n */\nconst _validateNodeValidations =\n (params: { user: User; survey: Survey; record: ArenaRecord; nodeDef: NodeDef<NodeDefType, NodeDefProps> }) =>\n async (_propName: string, node: ArenaRecordNode): Promise<ValidationResult> => {\n const { user, survey, record, nodeDef } = params\n if (Nodes.isValueBlank(node)) return ValidationResultFactory.createInstance()\n\n const validations = NodeDefs.getValidations(nodeDef)\n if (!validations?.expressions?.length) return ValidationResultFactory.createInstance()\n\n const applicableExpressionsEval = await expressionEvaluator.evalApplicableExpressions({\n user,\n survey,\n record,\n nodeCtx: node,\n expressions: validations.expressions,\n stopAtFirstFound: false,\n })\n\n let validationResult = ValidationResultFactory.createInstance()\n\n for (const { expression, value: valid } of applicableExpressionsEval) {\n if (!valid) {\n const messages = _getValidationMessagesWithDefault({\n survey,\n expression,\n defaultMessage: expression.expression,\n })\n\n validationResult = ValidationResultFactory.createInstance({\n valid: false,\n key: 'record.attribute.customValidation',\n severity: expression.severity,\n messages,\n })\n break\n }\n }\n\n return validationResult\n }\n\nconst validateAttribute = async (params: AttributeValidatorParams & { entityKeysCache?: EntityKeysCache }) => {\n const { survey, record, attribute } = params\n if (Records.isNodeApplicable(attribute)(record)) {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: attribute.nodeDefUuid })\n const validatorParams = { ...params, nodeDef }\n return new Validator().validate(attribute, {\n [NodeKeys.value]: [\n _validateRequired({ nodeDef }),\n AttributeTypeValidator.validateValueType(validatorParams),\n _validateNodeValidations(validatorParams),\n AttributeKeyValidator.validateAttributeKey(validatorParams),\n AttributeUniqueValidator.validateAttributeUnique(validatorParams),\n ],\n })\n }\n return ValidationFactory.createInstance()\n}\n\nconst findSiblingKeyNodesToValidate = (\n params: AttributeValidatorParams & {\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n nodeParent?: ArenaRecordNode\n siblingKeyNodesCache?: SiblingKeyNodesCache\n }\n) => {\n const { survey, nodeDef, nodeParent: parentNode, attribute } = params\n if (\n !NodeDefs.isKey(nodeDef) ||\n !parentNode ||\n (NodeDefs.isAutoIncrementalKey(nodeDef) && attribute.created && Nodes.isDefaultValueApplied(attribute))\n ) {\n // when a new node is created and the key is autoincremental, its value will be unique\n // and the validation of sibling key attributes is not necessary\n return []\n }\n // when a key attribute is updated, a sibling key attribute with the same value\n // or a sibling attribute with a validation error (duplicate key) should be re-validated\n const siblingNodeKeys = _getSiblingNodeKeys(params)\n const siblingNodeKeysWithSameValue: ArenaRecordNode[] = []\n const siblingNodeKeysWithErrors: ArenaRecordNode[] = []\n siblingNodeKeys.forEach(({ keyNode, hasErrors }) => {\n if (NodeValues.isValueEqual({ survey, nodeDef, parentNode, value: keyNode.value, valueSearch: attribute.value })) {\n siblingNodeKeysWithSameValue.push(keyNode)\n }\n if (hasErrors) {\n siblingNodeKeysWithErrors.push(keyNode)\n }\n })\n return [...siblingNodeKeysWithSameValue, ...siblingNodeKeysWithErrors]\n}\n\nconst findSortedNodesToValidate = (params: SortedAttributesValidatorParams): ArenaRecordNode[] => {\n const { survey, record, nodesArray } = params\n\n const result = []\n const siblingKeyNodesCache: SiblingKeyNodesCache = new Map()\n for (const node of nodesArray) {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid })\n if (!NodeDefs.isAttribute(nodeDef)) {\n continue\n }\n // Get dependents and attribute itself\n const nodePointersAttributeAndDependents = Records.getDependentNodePointers(\n survey,\n node,\n SurveyDependencyType.validations,\n true\n )(record)\n\n const nodeParent = Records.getParent(node)(record)\n\n result.push(\n ...NodePointers.getNodesFromNodePointers({ record, nodePointers: nodePointersAttributeAndDependents }),\n ...findSiblingKeyNodesToValidate({ ...params, nodeDef, nodeParent, attribute: node, siblingKeyNodesCache })\n )\n\n if (NodeDefs.getValidations(nodeDef)?.unique) {\n result.push(...Records.getAttributeSiblings(node, nodeDef)(record))\n }\n }\n\n return result\n}\n\nconst validateSelfAndDependentSortedAttributes = async (\n params: SortedAttributesValidatorParams\n): Promise<ValidationFields> => {\n const nodesToValidate: ArenaRecordNode[] = findSortedNodesToValidate(params)\n const validationsByNodeUuid: ValidationFields = {}\n // the record doesn't change during the validation: entity keys can be cached\n const entityKeysCache = createEntityKeysCache()\n\n for (const nodeToValidate of nodesToValidate) {\n const nodeUuid = nodeToValidate.uuid\n // Validate only attributes not deleted and not validated already\n if (!nodeToValidate.deleted && !validationsByNodeUuid[nodeUuid]) {\n // sequential: avoid concurrent item/taxon lookups on large node sets\n const attributeValidatorParams = { ...params, attribute: nodeToValidate, entityKeysCache }\n validationsByNodeUuid[nodeUuid] = await validateAttribute(attributeValidatorParams) // NOSONAR\n }\n }\n return validationsByNodeUuid\n}\n\nexport const AttributeValidator = {\n validateSelfAndDependentSortedAttributes,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"attributeValidator.js","sourceRoot":"","sources":["../../../../src/record/recordValidator/attributeValidator.ts"],"names":[],"mappings":";;;;;;;;;AAGA,OAAO,EAAmB,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACzE,OAAO,EAA4C,QAAQ,EAAe,MAAM,eAAe,CAAA;AAG/F,OAAO,EAAU,OAAO,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrC,OAAO,EACL,iBAAiB,EAEjB,uBAAuB,EACvB,kBAAkB,EAClB,SAAS,GACV,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2DAA2D,CAAA;AAC9F,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,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AAK,MAAM,cAAc,IAAI,eAAe,EAAE,CAAC;QAC7C,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAA;QACpC,iEAAiE;QACjE,IAAI,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAChE,qEAAqE;YACrE,MAAM,wBAAwB,mCAAQ,MAAM,KAAE,SAAS,EAAE,cAAc,EAAE,eAAe,GAAE,CAAA;YAC1F,qBAAqB,CAAC,QAAQ,CAAC,GAAG,MAAM,iBAAiB,CAAC,wBAAwB,CAAC,CAAA,CAAC,UAAU;QAChG,CAAC;IACH,CAAC;IACD,OAAO,qBAAqB,CAAA;AAC9B,CAAC,CAAA,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,wCAAwC;CACzC,CAAA","sourcesContent":["import { User } from '../../auth'\nimport { Dictionary } from '../../common'\nimport { Labels } from '../../language'\nimport { ArenaRecordNode, NodeKeys, Nodes, NodeValues } from '../../node'\nimport { NodeDef, NodeDefExpression, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { CategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider'\nimport { TaxonProvider } from '../../nodeDefExpressionEvaluator/taxonProvider'\nimport { Survey, Surveys } from '../../survey'\nimport { SurveyDependencyType } from '../../survey/survey'\nimport { Objects } from '../../utils'\nimport {\n ValidationFactory,\n ValidationResult,\n ValidationResultFactory,\n ValidationSeverity,\n Validator,\n} from '../../validation'\nimport { ValidationFields } from '../../validation/validation'\nimport { NodePointers } from '../nodePointers'\nimport { ArenaRecord } from '../record'\nimport { RecordExpressionEvaluator } from '../recordExpressionEvaluator'\nimport { evaluateRequiredIf } from '../recordNodesUpdater/recordNodeDependentsRequiredUpdater'\nimport { Records } from '../records'\nimport { RecordValidations } from '../recordValidations'\nimport { AttributeKeyValidator, createEntityKeysCache, EntityKeysCache } from './attributeKeyValidator'\nimport { AttributeTypeValidator } from './attributeTypeValidator'\nimport { AttributeUniqueValidator } from './attributeUniqueValidator'\n\nconst expressionEvaluator = new RecordExpressionEvaluator()\n\nexport interface RecordValidatorParams {\n user: User\n survey: Survey\n categoryItemProvider?: CategoryItemProvider\n taxonProvider?: TaxonProvider\n record: ArenaRecord\n}\n\nexport interface AttributeValidatorParams extends RecordValidatorParams {\n attribute: ArenaRecordNode\n}\n\nexport interface AttributesValidatorParams extends RecordValidatorParams {\n nodes: Dictionary<ArenaRecordNode>\n}\n\nexport interface SortedAttributesValidatorParams extends RecordValidatorParams {\n nodesArray: ArenaRecordNode[]\n}\n\ntype SiblingKeyNodeItem = { entityUuid: string; keyNode: ArenaRecordNode; hasErrors: boolean }\n\n// sibling key nodes are cached by ancestor multiple entity parent and def uuid during the same validation call:\n// when many entities are added to the same parent entity (e.g. data import), computing them for every updated\n// key attribute would take a time that grows quadratically with the number of entities\ntype SiblingKeyNodesCache = Map<string, SiblingKeyNodeItem[]>\n\nconst _getSiblingNodeKeys = (\n params: AttributeValidatorParams & { siblingKeyNodesCache?: SiblingKeyNodesCache }\n): SiblingKeyNodeItem[] => {\n const { survey, record, attribute, siblingKeyNodesCache } = params\n\n const attributeDef = Surveys.getNodeDefByUuid({ survey, uuid: attribute.nodeDefUuid })\n const ancestorMultipleEntityDef = Surveys.getNodeDefAncestorMultipleEntity({ survey, nodeDef: attributeDef })\n if (!ancestorMultipleEntityDef) {\n return []\n }\n const ancestorMultipleEntity = Records.getAncestor(attribute, ancestorMultipleEntityDef.uuid)(record)\n if (!ancestorMultipleEntity) return []\n\n const ancestorMultipleEntityParent = Records.getParent(ancestorMultipleEntity)(record)\n if (!ancestorMultipleEntityParent) return []\n\n const cacheKey = `${ancestorMultipleEntityParent.uuid}_${ancestorMultipleEntityDef.uuid}`\n let items = siblingKeyNodesCache?.get(cacheKey)\n if (!items) {\n const keyDefs = Surveys.getNodeDefKeys({ survey, nodeDef: ancestorMultipleEntityDef })\n const entities = Records.getEntitySiblings(ancestorMultipleEntity, true)(record)\n items = []\n for (const entity of entities) {\n const keyNodes = Records.getEntityKeyNodes(survey, entity, undefined, keyDefs)(record)\n for (const keyNode of keyNodes) {\n if (!keyNode) continue\n const nodeValidation =\n record.validation && RecordValidations.getValidationNode({ nodeUuid: keyNode.uuid })(record.validation)\n items.push({ entityUuid: entity.uuid, keyNode, hasErrors: !!nodeValidation && !nodeValidation.valid })\n }\n }\n siblingKeyNodesCache?.set(cacheKey, items)\n }\n return items.filter((item) => item.entityUuid !== ancestorMultipleEntity.uuid)\n}\n\nconst _getValidationMessagesWithDefault = (params: {\n survey: Survey\n expression: NodeDefExpression\n defaultMessage?: string\n}): Labels => {\n const { survey, expression, defaultMessage } = params\n const messages: Labels = { ...expression.messages }\n\n const languages = Surveys.getLanguages(survey)\n const defaultMessageDefined = Objects.isNotEmpty(defaultMessage)\n\n for (const lang of languages) {\n const customMessage = messages[lang]\n if (Objects.isEmpty(customMessage) && defaultMessageDefined) {\n messages[lang] = defaultMessage\n }\n }\n\n return messages\n}\n\nconst _isValueRequired = async (\n params: AttributeValidatorParams & { nodeDef: NodeDef<NodeDefType, NodeDefProps> }\n): Promise<boolean> => {\n const { record, attribute, nodeDef } = params\n if (NodeDefs.isKey(nodeDef) || NodeDefs.isRequired(nodeDef)) return true\n if (!NodeDefs.isRequiredIfDefined(nodeDef)) return false\n const parentNode = Records.getParent(attribute)(record)\n if (!parentNode) return false\n // evaluated here (not read from the parent node meta flag) so validation doesn't depend on up to date node meta\n // (e.g. records created before the \"required if\" condition was defined)\n return evaluateRequiredIf({ ...params, nodeCtx: parentNode, nodeDef })\n}\n\nconst _validateRequired =\n (params: AttributeValidatorParams & { nodeDef: NodeDef<NodeDefType, NodeDefProps> }) =>\n async (_field: string, node: any): Promise<ValidationResult> => {\n const valid = !Nodes.isValueBlank(node) || !(await _isValueRequired(params))\n return valid\n ? ValidationResultFactory.createInstance()\n : ValidationResultFactory.createInstance({\n key: 'record.attribute.valueRequired',\n severity: ValidationSeverity.error,\n valid,\n })\n }\n\n/**\n * Evaluates the validation expressions.\n */\nconst _validateNodeValidations =\n (params: { user: User; survey: Survey; record: ArenaRecord; nodeDef: NodeDef<NodeDefType, NodeDefProps> }) =>\n async (_propName: string, node: ArenaRecordNode): Promise<ValidationResult> => {\n const { user, survey, record, nodeDef } = params\n if (Nodes.isValueBlank(node)) return ValidationResultFactory.createInstance()\n\n const validations = NodeDefs.getValidations(nodeDef)\n if (!validations?.expressions?.length) return ValidationResultFactory.createInstance()\n\n const applicableExpressionsEval = await expressionEvaluator.evalApplicableExpressions({\n user,\n survey,\n record,\n nodeCtx: node,\n expressions: validations.expressions,\n stopAtFirstFound: false,\n })\n\n let validationResult = ValidationResultFactory.createInstance()\n\n for (const { expression, value: valid } of applicableExpressionsEval) {\n if (!valid) {\n const messages = _getValidationMessagesWithDefault({\n survey,\n expression,\n defaultMessage: expression.expression,\n })\n\n validationResult = ValidationResultFactory.createInstance({\n valid: false,\n key: 'record.attribute.customValidation',\n severity: expression.severity,\n messages,\n })\n break\n }\n }\n\n return validationResult\n }\n\nconst validateAttribute = async (params: AttributeValidatorParams & { entityKeysCache?: EntityKeysCache }) => {\n const { survey, record, attribute } = params\n if (Records.isNodeApplicable(attribute)(record)) {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: attribute.nodeDefUuid })\n const validatorParams = { ...params, nodeDef }\n return new Validator().validate(attribute, {\n [NodeKeys.value]: [\n _validateRequired(validatorParams),\n AttributeTypeValidator.validateValueType(validatorParams),\n _validateNodeValidations(validatorParams),\n AttributeKeyValidator.validateAttributeKey(validatorParams),\n AttributeUniqueValidator.validateAttributeUnique(validatorParams),\n ],\n })\n }\n return ValidationFactory.createInstance()\n}\n\nconst findSiblingKeyNodesToValidate = (\n params: AttributeValidatorParams & {\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n nodeParent?: ArenaRecordNode\n siblingKeyNodesCache?: SiblingKeyNodesCache\n }\n) => {\n const { survey, nodeDef, nodeParent: parentNode, attribute } = params\n if (\n !NodeDefs.isKey(nodeDef) ||\n !parentNode ||\n (NodeDefs.isAutoIncrementalKey(nodeDef) && attribute.created && Nodes.isDefaultValueApplied(attribute))\n ) {\n // when a new node is created and the key is autoincremental, its value will be unique\n // and the validation of sibling key attributes is not necessary\n return []\n }\n // when a key attribute is updated, a sibling key attribute with the same value\n // or a sibling attribute with a validation error (duplicate key) should be re-validated\n const siblingNodeKeys = _getSiblingNodeKeys(params)\n const siblingNodeKeysWithSameValue: ArenaRecordNode[] = []\n const siblingNodeKeysWithErrors: ArenaRecordNode[] = []\n siblingNodeKeys.forEach(({ keyNode, hasErrors }) => {\n if (NodeValues.isValueEqual({ survey, nodeDef, parentNode, value: keyNode.value, valueSearch: attribute.value })) {\n siblingNodeKeysWithSameValue.push(keyNode)\n }\n if (hasErrors) {\n siblingNodeKeysWithErrors.push(keyNode)\n }\n })\n return [...siblingNodeKeysWithSameValue, ...siblingNodeKeysWithErrors]\n}\n\nconst findSortedNodesToValidate = (params: SortedAttributesValidatorParams): ArenaRecordNode[] => {\n const { survey, record, nodesArray } = params\n\n const result = []\n const siblingKeyNodesCache: SiblingKeyNodesCache = new Map()\n for (const node of nodesArray) {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid })\n if (!NodeDefs.isAttribute(nodeDef)) {\n continue\n }\n // Get dependents and attribute itself\n const nodePointersAttributeAndDependents = [\n ...Records.getDependentNodePointers(survey, node, SurveyDependencyType.validations, true)(record),\n ...Records.getDependentNodePointers(survey, node, SurveyDependencyType.required)(record),\n ]\n\n const nodeParent = Records.getParent(node)(record)\n\n result.push(\n ...NodePointers.getNodesFromNodePointers({ record, nodePointers: nodePointersAttributeAndDependents }),\n ...findSiblingKeyNodesToValidate({ ...params, nodeDef, nodeParent, attribute: node, siblingKeyNodesCache })\n )\n\n if (NodeDefs.getValidations(nodeDef)?.unique) {\n result.push(...Records.getAttributeSiblings(node, nodeDef)(record))\n }\n }\n\n return result\n}\n\nconst validateSelfAndDependentSortedAttributes = async (\n params: SortedAttributesValidatorParams\n): Promise<ValidationFields> => {\n const nodesToValidate: ArenaRecordNode[] = findSortedNodesToValidate(params)\n const validationsByNodeUuid: ValidationFields = {}\n // the record doesn't change during the validation: entity keys can be cached\n const entityKeysCache = createEntityKeysCache()\n\n for (const nodeToValidate of nodesToValidate) {\n const nodeUuid = nodeToValidate.uuid\n // Validate only attributes not deleted and not validated already\n if (!nodeToValidate.deleted && !validationsByNodeUuid[nodeUuid]) {\n // sequential: avoid concurrent item/taxon lookups on large node sets\n const attributeValidatorParams = { ...params, attribute: nodeToValidate, entityKeysCache }\n validationsByNodeUuid[nodeUuid] = await validateAttribute(attributeValidatorParams) // NOSONAR\n }\n }\n return validationsByNodeUuid\n}\n\nexport const AttributeValidator = {\n validateSelfAndDependentSortedAttributes,\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getCycle, getRoot, getNodes, getNodesArray, getNodeByUuid, getNodesByUuids, getNodesByDefUuid, getChild, getChildren, getParent, getParentCodeAttribute, getAncestorCodePath, getDependentCodeAttributes, getAncestor, getEntityKeyNodes, getEntityKeyNodesByDefUuid, getEntityKeyValues, getEntityKeyValuesByDefUuid, getEntitySiblings, getAttributeSiblings, getNodeIndex, isNodeApplicable, isNodeEditable, isNodeVisible, visitAncestorsAndSelf, getAncestorsAndSelf, getDescendant, getDescendantsOrSelf, isDescendantOf, visitDescendantsAndSelf, getDependentNodePointers, findEntityByKeyValues, findEntityWithSameKeysInAnotherRecord, getCategoryItemUuid, isNodeEmpty, isNodeFilledByUser, isEmpty, getStep, isInAnalysisStep, } from './_records/recordGetters';
|
|
1
|
+
import { getCycle, getRoot, getNodes, getNodesArray, getNodeByUuid, getNodesByUuids, getNodesByDefUuid, getChild, getChildren, getParent, getParentCodeAttribute, getAncestorCodePath, getDependentCodeAttributes, getAncestor, getEntityKeyNodes, getEntityKeyNodesByDefUuid, getEntityKeyValues, getEntityKeyValuesByDefUuid, getEntitySiblings, getAttributeSiblings, getNodeIndex, isNodeApplicable, isNodeEditable, isNodeVisible, isNodeRequired, visitAncestorsAndSelf, getAncestorsAndSelf, getDescendant, getDescendantsOrSelf, isDescendantOf, visitDescendantsAndSelf, getDependentNodePointers, findEntityByKeyValues, findEntityWithSameKeysInAnotherRecord, getCategoryItemUuid, isNodeEmpty, isNodeFilledByUser, isEmpty, getStep, isInAnalysisStep, } from './_records/recordGetters';
|
|
2
2
|
import { addNode, addNodes } from './_records/recordUpdater';
|
|
3
3
|
import { getEnumeratingCategoryItems, findDependentEnumeratedEntityDefsNotEmpty } from './_records/recordUtils';
|
|
4
4
|
import { getEntityCompletionPercent, getEntityCompletionStats, getEntityOwnCompletionPercent, getRecordCompletionPercent, } from './_records/recordCompletion';
|
|
@@ -30,6 +30,7 @@ export const Records = {
|
|
|
30
30
|
isNodeApplicable,
|
|
31
31
|
isNodeEditable,
|
|
32
32
|
isNodeVisible,
|
|
33
|
+
isNodeRequired,
|
|
33
34
|
visitAncestorsAndSelf,
|
|
34
35
|
getAncestorsAndSelf,
|
|
35
36
|
getDescendant,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../../src/record/records.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,aAAa,EACb,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,SAAS,EACT,sBAAsB,EACtB,mBAAmB,EACnB,0BAA0B,EAC1B,WAAW,EACX,iBAAiB,EACjB,0BAA0B,EAC1B,kBAAkB,EAClB,2BAA2B,EAC3B,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,qCAAqC,EACrC,mBAAmB,EACnB,WAAW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oBAAoB;IACpB,uBAAuB;IACvB,gBAAgB;IAChB,gCAAgC;IAChC,sBAAsB;IACtB,6BAA6B;IAC7B,SAAS;IACT,OAAO;IACP,QAAQ;IACR,gIAAgI;IAChI,UAAU;IACV,oIAAoI;IACpI,WAAW;IACX,uGAAuG;IACvG,UAAU,EAAE,UAAU;IACtB,yGAAyG;IACzG,WAAW,EAAE,WAAW;IACxB,QAAQ;IACR,2BAA2B;IAC3B,yCAAyC;CAC1C,CAAA","sourcesContent":["import {\n getCycle,\n getRoot,\n getNodes,\n getNodesArray,\n getNodeByUuid,\n getNodesByUuids,\n getNodesByDefUuid,\n getChild,\n getChildren,\n getParent,\n getParentCodeAttribute,\n getAncestorCodePath,\n getDependentCodeAttributes,\n getAncestor,\n getEntityKeyNodes,\n getEntityKeyNodesByDefUuid,\n getEntityKeyValues,\n getEntityKeyValuesByDefUuid,\n getEntitySiblings,\n getAttributeSiblings,\n getNodeIndex,\n isNodeApplicable,\n isNodeEditable,\n isNodeVisible,\n visitAncestorsAndSelf,\n getAncestorsAndSelf,\n getDescendant,\n getDescendantsOrSelf,\n isDescendantOf,\n visitDescendantsAndSelf,\n getDependentNodePointers,\n findEntityByKeyValues,\n findEntityWithSameKeysInAnotherRecord,\n getCategoryItemUuid,\n isNodeEmpty,\n isNodeFilledByUser,\n isEmpty,\n getStep,\n isInAnalysisStep,\n} from './_records/recordGetters'\nimport { addNode, addNodes } from './_records/recordUpdater'\nimport { getEnumeratingCategoryItems, findDependentEnumeratedEntityDefsNotEmpty } from './_records/recordUtils'\nimport {\n getEntityCompletionPercent,\n getEntityCompletionStats,\n getEntityOwnCompletionPercent,\n getRecordCompletionPercent,\n} from './_records/recordCompletion'\nimport {\n getDescendantPageNodeDefUuids,\n getEntitySubtreeStatus,\n getMultiplePageEntitiesStatus,\n getNodeDefChildrenInOwnPage,\n getPageNodeDefs,\n getPageValidationStatus,\n getRecordPagesValidationProgress,\n nodeBelongsToOwnPage,\n nodeBelongsToPage,\n pageHasOwnErrors,\n} from './_records/recordPagesValidation'\nimport { removeNode, removeNodes } from './recordNodesUpdater/recordNodesDeleter'\n\nexport const Records = {\n // READ\n getCycle,\n getRoot,\n getNodes,\n getNodesArray,\n getNodeByUuid,\n getNodesByUuids,\n getNodesByDefUuid,\n getChild,\n getChildren,\n getParent,\n getParentCodeAttribute,\n getAncestorCodePath,\n getDependentCodeAttributes,\n getAncestor,\n getEntityKeyNodes,\n getEntityKeyNodesByDefUuid,\n getEntityKeyValues,\n getEntityKeyValuesByDefUuid,\n getEntitySiblings,\n getAttributeSiblings,\n getNodeIndex,\n isNodeApplicable,\n isNodeEditable,\n isNodeVisible,\n visitAncestorsAndSelf,\n getAncestorsAndSelf,\n getDescendant,\n getDescendantsOrSelf,\n isDescendantOf,\n visitDescendantsAndSelf,\n getDependentNodePointers,\n findEntityByKeyValues,\n findEntityWithSameKeysInAnotherRecord,\n getCategoryItemUuid,\n isNodeEmpty,\n isNodeFilledByUser,\n isEmpty,\n getStep,\n isInAnalysisStep,\n getEntityCompletionPercent,\n getEntityCompletionStats,\n getEntityOwnCompletionPercent,\n getRecordCompletionPercent,\n getNodeDefChildrenInOwnPage,\n getPageNodeDefs,\n getDescendantPageNodeDefUuids,\n nodeBelongsToPage,\n nodeBelongsToOwnPage,\n getPageValidationStatus,\n pageHasOwnErrors,\n getRecordPagesValidationProgress,\n getEntitySubtreeStatus,\n getMultiplePageEntitiesStatus,\n // UPDATE\n addNode,\n addNodes,\n /** Low-level: removes the node and its descendants without updating dependents and validation (see RecordUpdater.deleteNode) */\n removeNode,\n /** Low-level: removes the nodes and their descendants without updating dependents and validation (see RecordUpdater.deleteNodes) */\n removeNodes,\n /** @deprecated Use removeNode (or RecordUpdater.deleteNode to update dependents and validation too) */\n deleteNode: removeNode,\n /** @deprecated Use removeNodes (or RecordUpdater.deleteNodes to update dependents and validation too) */\n deleteNodes: removeNodes,\n // Utils\n getEnumeratingCategoryItems,\n findDependentEnumeratedEntityDefsNotEmpty,\n}\n\nexport type { RecordUpdateOptions } from './_records/recordUpdateOptions'\nexport type {\n EntitySubtreeStatus,\n PageValidationStatus,\n PagesValidationProgress,\n} from './_records/recordPagesValidation'\n"]}
|
|
1
|
+
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../../src/record/records.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,aAAa,EACb,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,SAAS,EACT,sBAAsB,EACtB,mBAAmB,EACnB,0BAA0B,EAC1B,WAAW,EACX,iBAAiB,EACjB,0BAA0B,EAC1B,kBAAkB,EAClB,2BAA2B,EAC3B,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,qCAAqC,EACrC,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,OAAO,EACP,gBAAgB,GACjB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,2BAA2B,EAAE,yCAAyC,EAAE,MAAM,wBAAwB,CAAA;AAC/G,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EACtB,6BAA6B,EAC7B,2BAA2B,EAC3B,eAAe,EACf,uBAAuB,EACvB,gCAAgC,EAChC,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAA;AAEjF,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,OAAO;IACP,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,aAAa;IACb,aAAa;IACb,eAAe;IACf,iBAAiB;IACjB,QAAQ;IACR,WAAW;IACX,SAAS;IACT,sBAAsB;IACtB,mBAAmB;IACnB,0BAA0B;IAC1B,WAAW;IACX,iBAAiB;IACjB,0BAA0B;IAC1B,kBAAkB;IAClB,2BAA2B;IAC3B,iBAAiB;IACjB,oBAAoB;IACpB,YAAY;IACZ,gBAAgB;IAChB,cAAc;IACd,aAAa;IACb,cAAc;IACd,qBAAqB;IACrB,mBAAmB;IACnB,aAAa;IACb,oBAAoB;IACpB,cAAc;IACd,uBAAuB;IACvB,wBAAwB;IACxB,qBAAqB;IACrB,qCAAqC;IACrC,mBAAmB;IACnB,WAAW;IACX,kBAAkB;IAClB,OAAO;IACP,OAAO;IACP,gBAAgB;IAChB,0BAA0B;IAC1B,wBAAwB;IACxB,6BAA6B;IAC7B,0BAA0B;IAC1B,2BAA2B;IAC3B,eAAe;IACf,6BAA6B;IAC7B,iBAAiB;IACjB,oBAAoB;IACpB,uBAAuB;IACvB,gBAAgB;IAChB,gCAAgC;IAChC,sBAAsB;IACtB,6BAA6B;IAC7B,SAAS;IACT,OAAO;IACP,QAAQ;IACR,gIAAgI;IAChI,UAAU;IACV,oIAAoI;IACpI,WAAW;IACX,uGAAuG;IACvG,UAAU,EAAE,UAAU;IACtB,yGAAyG;IACzG,WAAW,EAAE,WAAW;IACxB,QAAQ;IACR,2BAA2B;IAC3B,yCAAyC;CAC1C,CAAA","sourcesContent":["import {\n getCycle,\n getRoot,\n getNodes,\n getNodesArray,\n getNodeByUuid,\n getNodesByUuids,\n getNodesByDefUuid,\n getChild,\n getChildren,\n getParent,\n getParentCodeAttribute,\n getAncestorCodePath,\n getDependentCodeAttributes,\n getAncestor,\n getEntityKeyNodes,\n getEntityKeyNodesByDefUuid,\n getEntityKeyValues,\n getEntityKeyValuesByDefUuid,\n getEntitySiblings,\n getAttributeSiblings,\n getNodeIndex,\n isNodeApplicable,\n isNodeEditable,\n isNodeVisible,\n isNodeRequired,\n visitAncestorsAndSelf,\n getAncestorsAndSelf,\n getDescendant,\n getDescendantsOrSelf,\n isDescendantOf,\n visitDescendantsAndSelf,\n getDependentNodePointers,\n findEntityByKeyValues,\n findEntityWithSameKeysInAnotherRecord,\n getCategoryItemUuid,\n isNodeEmpty,\n isNodeFilledByUser,\n isEmpty,\n getStep,\n isInAnalysisStep,\n} from './_records/recordGetters'\nimport { addNode, addNodes } from './_records/recordUpdater'\nimport { getEnumeratingCategoryItems, findDependentEnumeratedEntityDefsNotEmpty } from './_records/recordUtils'\nimport {\n getEntityCompletionPercent,\n getEntityCompletionStats,\n getEntityOwnCompletionPercent,\n getRecordCompletionPercent,\n} from './_records/recordCompletion'\nimport {\n getDescendantPageNodeDefUuids,\n getEntitySubtreeStatus,\n getMultiplePageEntitiesStatus,\n getNodeDefChildrenInOwnPage,\n getPageNodeDefs,\n getPageValidationStatus,\n getRecordPagesValidationProgress,\n nodeBelongsToOwnPage,\n nodeBelongsToPage,\n pageHasOwnErrors,\n} from './_records/recordPagesValidation'\nimport { removeNode, removeNodes } from './recordNodesUpdater/recordNodesDeleter'\n\nexport const Records = {\n // READ\n getCycle,\n getRoot,\n getNodes,\n getNodesArray,\n getNodeByUuid,\n getNodesByUuids,\n getNodesByDefUuid,\n getChild,\n getChildren,\n getParent,\n getParentCodeAttribute,\n getAncestorCodePath,\n getDependentCodeAttributes,\n getAncestor,\n getEntityKeyNodes,\n getEntityKeyNodesByDefUuid,\n getEntityKeyValues,\n getEntityKeyValuesByDefUuid,\n getEntitySiblings,\n getAttributeSiblings,\n getNodeIndex,\n isNodeApplicable,\n isNodeEditable,\n isNodeVisible,\n isNodeRequired,\n visitAncestorsAndSelf,\n getAncestorsAndSelf,\n getDescendant,\n getDescendantsOrSelf,\n isDescendantOf,\n visitDescendantsAndSelf,\n getDependentNodePointers,\n findEntityByKeyValues,\n findEntityWithSameKeysInAnotherRecord,\n getCategoryItemUuid,\n isNodeEmpty,\n isNodeFilledByUser,\n isEmpty,\n getStep,\n isInAnalysisStep,\n getEntityCompletionPercent,\n getEntityCompletionStats,\n getEntityOwnCompletionPercent,\n getRecordCompletionPercent,\n getNodeDefChildrenInOwnPage,\n getPageNodeDefs,\n getDescendantPageNodeDefUuids,\n nodeBelongsToPage,\n nodeBelongsToOwnPage,\n getPageValidationStatus,\n pageHasOwnErrors,\n getRecordPagesValidationProgress,\n getEntitySubtreeStatus,\n getMultiplePageEntitiesStatus,\n // UPDATE\n addNode,\n addNodes,\n /** Low-level: removes the node and its descendants without updating dependents and validation (see RecordUpdater.deleteNode) */\n removeNode,\n /** Low-level: removes the nodes and their descendants without updating dependents and validation (see RecordUpdater.deleteNodes) */\n removeNodes,\n /** @deprecated Use removeNode (or RecordUpdater.deleteNode to update dependents and validation too) */\n deleteNode: removeNode,\n /** @deprecated Use removeNodes (or RecordUpdater.deleteNodes to update dependents and validation too) */\n deleteNodes: removeNodes,\n // Utils\n getEnumeratingCategoryItems,\n findDependentEnumeratedEntityDefsNotEmpty,\n}\n\nexport type { RecordUpdateOptions } from './_records/recordUpdateOptions'\nexport type {\n EntitySubtreeStatus,\n PageValidationStatus,\n PagesValidationProgress,\n} from './_records/recordPagesValidation'\n"]}
|
|
@@ -10,6 +10,7 @@ export var SurveyDependencyType;
|
|
|
10
10
|
SurveyDependencyType["maxCount"] = "maxCount";
|
|
11
11
|
SurveyDependencyType["minCount"] = "minCount";
|
|
12
12
|
SurveyDependencyType["parentCode"] = "parentCode";
|
|
13
|
+
SurveyDependencyType["required"] = "required";
|
|
13
14
|
SurveyDependencyType["validations"] = "validations";
|
|
14
15
|
SurveyDependencyType["visible"] = "visible";
|
|
15
16
|
SurveyDependencyType["onUpdate"] = "onUpdate";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"survey.js","sourceRoot":"","sources":["../../../src/survey/survey.ts"],"names":[],"mappings":"AAUA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AAA;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, Dictionary } from '../common'\nimport { AuthGroup } from '../auth'\nimport { Labels, LanguageCode } from '../language'\nimport { SRS } from '../srs'\n\nimport { NodeDef, NodeDefType } from '../nodeDef'\nimport { Category } from '../category'\nimport { Taxonomy } from '../taxonomy'\nimport { SurveyRefData } from './refData/refData'\n\nexport const defaultCycle = '0'\n\nexport interface SurveyDependency {\n [nodeDefUuid: string]: string[] | boolean\n}\n\nexport enum SurveyDependencyType {\n applicable = 'applicable',\n defaultValues = 'defaultValues',\n editable = 'editable',\n enumeratingItems = 'enumeratingItems',\n fileName = 'fileName',\n formula = 'formula',\n maxCount = 'maxCount',\n minCount = 'minCount',\n parentCode = 'parentCode',\n required = 'required',\n validations = 'validations',\n visible = 'visible',\n onUpdate = 'onUpdate', // dependencies updated on every record update, stored as dictionary of booleans\n}\n\nexport type SurveyDependencyGraph = {\n [key in SurveyDependencyType]: SurveyDependency\n}\n\nexport interface SurveyCycle {\n dateEnd?: string\n dateStart: string\n}\n\nexport enum SurveySecurityProp {\n dataEditorViewNotOwnedRecordsAllowed = 'dataEditorViewNotOwnedRecordsAllowed',\n dataAnalystViewNotOwnedRecordsAllowed = 'dataAnalystViewNotOwnedRecordsAllowed',\n visibleInMobile = 'visibleInMobile',\n allowRecordsDownloadInMobile = 'allowRecordsDownloadInMobile',\n allowRecordsUploadFromMobile = 'allowRecordsUploadFromMobile',\n allowRecordsWithErrorsUploadFromMobile = 'allowRecordsWithErrorsUploadFromMobile',\n allowRecordsMergeWithSameKeys = 'allowRecordsMergeWithSameKeys',\n}\n\nexport type SurveySecurity = {\n [key in SurveySecurityProp]?: boolean\n}\n\nexport const surveySecurityDefaults: SurveySecurity = {\n [SurveySecurityProp.dataEditorViewNotOwnedRecordsAllowed]: true,\n [SurveySecurityProp.dataAnalystViewNotOwnedRecordsAllowed]: true,\n [SurveySecurityProp.visibleInMobile]: true,\n [SurveySecurityProp.allowRecordsDownloadInMobile]: true,\n [SurveySecurityProp.allowRecordsUploadFromMobile]: true,\n [SurveySecurityProp.allowRecordsWithErrorsUploadFromMobile]: true,\n [SurveySecurityProp.allowRecordsMergeWithSameKeys]: true,\n}\n\nexport enum SurveyDocPlace {\n header = 'header',\n footer = 'footer',\n}\n\nexport const surveyDocImagePropKeys = {\n documentPlace: 'documentPlace',\n applyIf: 'applyIf',\n} as const\n\nexport type SurveyDocImageProps = SurveyFileProps & {\n documentPlace?: SurveyDocPlace\n applyIf?: string\n}\n\nexport type SurveyFileProps = {\n deleted?: boolean\n labels?: Labels\n name?: string\n nodeUuid?: string\n recordUuid?: string\n size?: number | null\n temporary?: boolean\n type?: string\n}\n\nexport type SurveyFile = {\n uuid: string\n props: SurveyFileProps\n content?: Buffer | null\n dateCreated: string\n}\n\nexport type SurveyDocImage = SurveyFile & {\n props: SurveyDocImageProps\n}\n\nexport type SurveyDocOptions = {\n headerOnFirstPageOnly?: boolean // default: true\n}\n\nexport interface SurveyProps {\n collectUri?: string\n cycles: {\n [key: string]: SurveyCycle\n }\n defaultCycleKey?: string\n descriptions?: Labels\n fieldManualLinks?: Labels\n // when true, values of attributes becoming non-applicable are kept during data entry (default: cleared)\n keepNonApplicableValues?: boolean\n labels?: Labels\n languages: LanguageCode[]\n name: string\n preloadedMapLayers?: SurveyFile[]\n preloadedMapLayersEnabled?: boolean\n security?: SurveySecurity\n srs: SRS[]\n surveyDocImages?: SurveyDocImage[]\n surveyDocOptions?: SurveyDocOptions\n}\n\nexport interface SurveyNodeDefsIndex {\n rootDefUuid?: string\n childDefUuidPresenceByParentUuid?: { [parentUuid: string]: { [nodeDefUuid: string]: boolean } }\n nodeDefUuidByName?: Dictionary<string>\n qualifierPresenceByUuid?: { [nodeDefUuid: string]: boolean }\n}\n\nexport interface Survey extends ArenaObject<SurveyProps> {\n authGroups: Array<AuthGroup>\n dateCreated?: string\n dateModified?: string\n datePublished?: string\n dependencyGraph?: SurveyDependencyGraph\n draft: boolean\n nodeDefs?: { [nodeDefUuid: string]: NodeDef<NodeDefType> }\n ownerUuid: string\n published: boolean\n readonly id?: number\n template: boolean\n uuid: string\n /**\n * Categories indexed by uuid.\n */\n categories?: { [categoryUuid: string]: Category }\n /**\n * Taxonomies indexed by uuid.\n */\n taxonomies?: { [taxonomyUuid: string]: Taxonomy }\n /**\n * Reference data cache (category items and taxa).\n */\n refData?: SurveyRefData\n\n nodeDefsIndex?: SurveyNodeDefsIndex\n}\n"]}
|
|
@@ -25,6 +25,7 @@ const isContextParentByDependencyType = {
|
|
|
25
25
|
[SurveyDependencyType.minCount]: true,
|
|
26
26
|
[SurveyDependencyType.onUpdate]: true,
|
|
27
27
|
[SurveyDependencyType.parentCode]: false,
|
|
28
|
+
[SurveyDependencyType.required]: true,
|
|
28
29
|
[SurveyDependencyType.validations]: true,
|
|
29
30
|
[SurveyDependencyType.visible]: true,
|
|
30
31
|
};
|
|
@@ -39,6 +40,7 @@ const selfReferenceAllowedByDependencyType = {
|
|
|
39
40
|
[SurveyDependencyType.minCount]: false,
|
|
40
41
|
[SurveyDependencyType.onUpdate]: false,
|
|
41
42
|
[SurveyDependencyType.parentCode]: false,
|
|
43
|
+
[SurveyDependencyType.required]: false,
|
|
42
44
|
[SurveyDependencyType.validations]: true,
|
|
43
45
|
[SurveyDependencyType.visible]: false,
|
|
44
46
|
};
|
|
@@ -53,6 +55,7 @@ const newDependencyGraph = () => ({
|
|
|
53
55
|
[SurveyDependencyType.minCount]: {},
|
|
54
56
|
[SurveyDependencyType.onUpdate]: {},
|
|
55
57
|
[SurveyDependencyType.parentCode]: {},
|
|
58
|
+
[SurveyDependencyType.required]: {},
|
|
56
59
|
[SurveyDependencyType.validations]: {},
|
|
57
60
|
[SurveyDependencyType.visible]: {},
|
|
58
61
|
});
|
|
@@ -158,6 +161,7 @@ export const addNodeDefDependencies = (params) => __awaiter(void 0, void 0, void
|
|
|
158
161
|
graphsUpdated = yield _addDependencies(SurveyDependencyType.applicable, NodeDefs.getApplicable(nodeDef));
|
|
159
162
|
graphsUpdated = yield _addDependencies(SurveyDependencyType.defaultValues, NodeDefs.getDefaultValues(nodeDef));
|
|
160
163
|
graphsUpdated = yield _addDependencies(SurveyDependencyType.editable, NodeDefs.getEditableIf(nodeDef));
|
|
164
|
+
graphsUpdated = yield _addDependencies(SurveyDependencyType.required, NodeDefs.getRequiredIf(nodeDef));
|
|
161
165
|
graphsUpdated = yield _addDependencies(SurveyDependencyType.validations, NodeDefs.getValidationsExpressions(nodeDef));
|
|
162
166
|
graphsUpdated = yield _addDependencies(SurveyDependencyType.visible, NodeDefs.getVisibleIf(nodeDef));
|
|
163
167
|
const maxCount = NodeDefs.getMaxCount(nodeDef);
|
|
@@ -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,EAAiC,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAC/E,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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B,CAAC,CAAA,CAAA","sourcesContent":["import * as SurveyNodeDefs from './nodeDefs'\nimport {\n NodeDef,\n NodeDefCode,\n NodeDefEntity,\n NodeDefExpression,\n NodeDefFile,\n NodeDefProps,\n NodeDefs,\n NodeDefType,\n} from '../../nodeDef'\nimport { NodeDefExpressionEvaluator } from '../../nodeDefExpressionEvaluator'\n\nimport { Survey, SurveyDependencyGraph, SurveyDependencyType } from '../survey'\nimport { Arrays, Objects } from '../../utils'\nimport { NodeDefExpressionFactory } from '../../nodeDef/nodeDef'\nimport { Dictionary } 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.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.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.validations]: {},\n [SurveyDependencyType.visible]: {},\n})\n\nconst getDependencyGraph = (survey: Survey): SurveyDependencyGraph => survey.dependencyGraph ?? newDependencyGraph()\n\nconst getDependencies = (params: {\n graphs: SurveyDependencyGraph\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: Survey\n nodeDefUuid: string\n dependencyType?: SurveyDependencyType\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\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: Survey }) => {\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: SurveyDependencyGraph\n type: SurveyDependencyType\n nodeDefUuid: string\n nodeDefDepUuid: string\n sideEffect: boolean\n}): SurveyDependencyGraph => {\n const { graphs, type, nodeDefUuid, nodeDefDepUuid, sideEffect = false } = params\n const deps = getDependencies({ graphs, type, nodeDefUuid })\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: Survey\n nodeDef: NodeDef<NodeDefType>\n type: SurveyDependencyType\n graphs: SurveyDependencyGraph\n expressions: NodeDefExpression[]\n sideEffect?: boolean\n}): Promise<SurveyDependencyGraph> => {\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]: NodeDef<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: Dictionary<NodeDef<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: Dictionary<NodeDef<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: NodeDef<NodeDefType>\n survey: Survey\n sideEffect?: boolean\n}): Promise<Survey> => {\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: NodeDefExpression[]) => {\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.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 NodeDefFile)\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 NodeDefEntity)\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 NodeDefCode)\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: SurveyDependencyGraph\n dependencyType: SurveyDependencyType\n nodeDefUuid: string\n}): SurveyDependencyGraph => {\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: Survey\n nodeDefUuid: string\n dependencyType?: SurveyDependencyType\n}): Survey => {\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: Survey): Promise<Survey> => {\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: Survey = { ...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,EAAiC,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAC/E,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,CAA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AC,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 NodeDef,\n NodeDefCode,\n NodeDefEntity,\n NodeDefExpression,\n NodeDefFile,\n NodeDefProps,\n NodeDefs,\n NodeDefType,\n} from '../../nodeDef'\nimport { NodeDefExpressionEvaluator } from '../../nodeDefExpressionEvaluator'\n\nimport { Survey, SurveyDependencyGraph, SurveyDependencyType } from '../survey'\nimport { Arrays, Objects } from '../../utils'\nimport { NodeDefExpressionFactory } from '../../nodeDef/nodeDef'\nimport { Dictionary } 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: Survey): SurveyDependencyGraph => survey.dependencyGraph ?? newDependencyGraph()\n\nconst getDependencies = (params: {\n graphs: SurveyDependencyGraph\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: Survey\n nodeDefUuid: string\n dependencyType?: SurveyDependencyType\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\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: Survey }) => {\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: SurveyDependencyGraph\n type: SurveyDependencyType\n nodeDefUuid: string\n nodeDefDepUuid: string\n sideEffect: boolean\n}): SurveyDependencyGraph => {\n const { graphs, type, nodeDefUuid, nodeDefDepUuid, sideEffect = false } = params\n const deps = getDependencies({ graphs, type, nodeDefUuid })\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: Survey\n nodeDef: NodeDef<NodeDefType>\n type: SurveyDependencyType\n graphs: SurveyDependencyGraph\n expressions: NodeDefExpression[]\n sideEffect?: boolean\n}): Promise<SurveyDependencyGraph> => {\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]: NodeDef<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: Dictionary<NodeDef<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: Dictionary<NodeDef<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: NodeDef<NodeDefType>\n survey: Survey\n sideEffect?: boolean\n}): Promise<Survey> => {\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: NodeDefExpression[]) => {\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 NodeDefFile)\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 NodeDefEntity)\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 NodeDefCode)\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: SurveyDependencyGraph\n dependencyType: SurveyDependencyType\n nodeDefUuid: string\n}): SurveyDependencyGraph => {\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: Survey\n nodeDefUuid: string\n dependencyType?: SurveyDependencyType\n}): Survey => {\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: Survey): Promise<Survey> => {\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: Survey = { ...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"]}
|
|
@@ -51,6 +51,14 @@ export class NodeDefBuilder {
|
|
|
51
51
|
sideEffect: true,
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
+
requiredIf(...expressions) {
|
|
55
|
+
return Objects.assocPath({
|
|
56
|
+
obj: this,
|
|
57
|
+
path: ['propsAdvanced', 'validations', 'requiredIf'],
|
|
58
|
+
value: expressions.map((expression) => typeof expression === 'string' ? NodeDefExpressionFactory.createInstance({ expression }) : expression),
|
|
59
|
+
sideEffect: true,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
54
62
|
required() {
|
|
55
63
|
return Objects.assocPath({
|
|
56
64
|
obj: this,
|
|
@@ -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,EAA6C,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AAC9G,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,GAAsC,EAAE;QACpE,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;IAID,QAAQ;QACN,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAA;QAC1B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,CAAC,UAAkB;QACxB,IAAI,CAAC,aAAa,CAAC,UAAU,GAAG,CAAC,wBAAwB,CAAC,cAAc,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAA;QACzF,OAAO,IAAI,CAAA;IACb,CAAC;IAED,UAAU,CAAC,GAAG,WAA2C;QACvD,IAAI,CAAC,aAA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../../survey'\nimport {\n NodeDef,\n NodeDefFactory,\n NodeDefEntity,\n NodeDefProps,\n NodeDefPropsAdvanced,\n NodeDefType,\n} from '../../../nodeDef'\nimport { NodeDefCountExpression, NodeDefExpression, NodeDefExpressionFactory } from '../../../nodeDef/nodeDef'\nimport { Objects } from '../../../utils'\n\nexport abstract class NodeDefBuilder {\n protected props: NodeDefProps\n protected propsAdvanced: NodeDefPropsAdvanced\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?: NodeDefEntity } = {}): NodeDef<NodeDefType, NodeDefProps> {\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: Survey; nodeDefParent?: NodeDefEntity }): { [uuid: string]: NodeDef<NodeDefType> }\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 | NodeDefExpression)[]): 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 | NodeDefExpression)[]): 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: NodeDefCountExpression): 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: NodeDefCountExpression): this {\n return Objects.assocPath({\n obj: this,\n path: ['propsAdvanced', 'validations', 'count', 'min'],\n value: countExpr,\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"]}
|
|
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,EAA6C,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AAC9G,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,GAAsC,EAAE;QACpE,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;IAID,QAAQ;QACN,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAA;QAC1B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,CAAC,UAAkB;QACxB,IAAI,CAAC,aAAa,CAAC,UAAU,GAAG,CAAC,wBAAwB,CAAC,cAAc,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAA;QACzF,OAAO,IAAI,CAAA;IACb,CAAC;IAED,UAAU,CAAC,GAAG,WAA2C;QACvD,IAAI,CAAC,aAAa,CAAC,UAA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,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 { Survey } from '../../../survey'\nimport {\n NodeDef,\n NodeDefFactory,\n NodeDefEntity,\n NodeDefProps,\n NodeDefPropsAdvanced,\n NodeDefType,\n} from '../../../nodeDef'\nimport { NodeDefCountExpression, NodeDefExpression, NodeDefExpressionFactory } from '../../../nodeDef/nodeDef'\nimport { Objects } from '../../../utils'\n\nexport abstract class NodeDefBuilder {\n protected props: NodeDefProps\n protected propsAdvanced: NodeDefPropsAdvanced\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?: NodeDefEntity } = {}): NodeDef<NodeDefType, NodeDefProps> {\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: Survey; nodeDefParent?: NodeDefEntity }): { [uuid: string]: NodeDef<NodeDefType> }\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 | NodeDefExpression)[]): 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 | NodeDefExpression)[]): 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: NodeDefCountExpression): 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: NodeDefCountExpression): 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 | NodeDefExpression)[]): 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"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export type { ArenaRecordNode, Node, NodeMeta, NodePointer, NodeRefData, NodeSer
|
|
|
31
31
|
export { NodeDefCountType, NodeDefType, NodeDefFactory, NodeDefs, NodeDefEntityRenderType, NodeDefFileType, NodeDefTextInputType, NodeDefTextRenderType, FormHeaderColor, } from './nodeDef';
|
|
32
32
|
export { NodeDefExpressionEvaluator, NodeDefExpressionValidator } from './nodeDefExpressionEvaluator';
|
|
33
33
|
export type { CategoryItemProvider, TaxonProvider } from './nodeDefExpressionEvaluator';
|
|
34
|
-
export type { NodeDef, NodeDefLayout, NodeDefMeta, NodeDefProps, NodeDefPropsWithLayout, NodeDefBoolean, NodeDefBooleanProps, NodeDefCode, NodeDefCodeLayout, NodeDefCodeProps, NodeDefCoordinate, NodeDefCoordinateProps, NodeDefDate, NodeDefDecimal, NodeDefDecimalProps, NodeDefEntity, NodeDefEntityChildPosition, NodeDefEntityLayout, NodeDefEntityProps, NodeDefPrintOrientation, NodeDefFile, NodeDefFileProps, NodeDefFormHeader, NodeDefFormHeaderProps, NodeDefInteger, NodeDefPropsAdvanced, NodeDefTaxon, NodeDefTaxonProps, NodeDefText, NodeDefTextProps, NodeDefTextLayout, NodeDefTime, NodeDefTimeProps, NodeDefExpression, NodeDefMap, NodeDefService, NodeDefValidations, } from './nodeDef';
|
|
34
|
+
export type { NodeDef, NodeDefLayout, NodeDefMeta, NodeDefProps, NodeDefPropsWithLayout, NodeDefBoolean, NodeDefBooleanProps, NodeDefCode, NodeDefCodeLayout, NodeDefCodeProps, NodeDefCoordinate, NodeDefCoordinateProps, NodeDefDate, NodeDefDecimal, NodeDefDecimalProps, NodeDefEntity, NodeDefEntityChildPosition, NodeDefEntityLayout, NodeDefEntityProps, NodeDefPrintOrientation, NodeDefFile, NodeDefFileProps, NodeDefGeo, NodeDefGeoProps, NodeDefFormHeader, NodeDefFormHeaderProps, NodeDefInteger, NodeDefPropsAdvanced, NodeDefTaxon, NodeDefTaxonProps, NodeDefText, NodeDefTextProps, NodeDefTextLayout, NodeDefTime, NodeDefTimeProps, NodeDefExpression, NodeDefMap, NodeDefService, NodeDefValidations, } from './nodeDef';
|
|
35
35
|
export { NodePointers, RecordCloner, RecordFactory, RecordFixer, Records, RECORD_STEP_DEFAULT, RecordExpressionEvaluator, RecordNodesUpdater, RecordPrettyPrinter, RecordUpdater, RecordUpdateResult, RecordValidator, RecordValidations, } from './record';
|
|
36
36
|
export type { AttributeValidatorParams, AttributesValidatorParams, NodeCreateParams, NodesUpdateParams, ArenaRecord, Record, RecordExpressionContext, RecordExpressionEvaluationContext, RecordService, RecordUpdateOptions, RecordValidatorParams, SortedAttributesValidatorParams, } from './record';
|
|
37
37
|
export { ServiceRegistry, ServiceType } from './registry';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceR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A,iBAAiB,OAAA;AACjB,yGAAA,WAAW,OAAA;AACX,gHAAA,kBAAkB,OAAA;AAClB,uGAAA,SAAS,OAAA;AACT,gHAAA,kBAAkB,OAAA","sourcesContent":["export type { AppInfo } from './app'\n\nexport { Authorizer, AuthGroupName, UserStatus, Permission, UserTitle, UserFactory, Users } from './auth'\nexport type {\n AuthGroup,\n User,\n UserAuthGroup,\n UserAuthGroupProps,\n AuthToken,\n UserAuthTokenPayload,\n UserAuthTokenService,\n UserPrefs,\n UserPrefSurveys,\n UserProps,\n UserAuthRefreshToken,\n UserAuthRefreshTokenProps,\n UserAuthRefreshTokenPayload,\n UserService,\n UserTokenPayload,\n DownloadAuthTokenPayload,\n UserGroup,\n UserGroupProps,\n UserGroupQualifier,\n UserInvitation,\n} from './auth'\n\nexport { CategoryFactory, CategoryImportColumnType, CategoryItemFactory, CategoryLevelFactory } from './category'\nexport type {\n CategoryItemProps,\n Category,\n CategoryItem,\n CategoryLevel,\n CategoryLevelProps,\n CategoryImportSummary,\n CategoryImportSummaryColumn,\n CategoryItemService,\n CategoryLevelService,\n CategoryProps,\n CategoryService,\n} from './category'\n\nexport { Categories, CategoryItems } from './category'\n\nexport { ChainFactory, ChainStatusExec, ChainNodeDefFactory } from './chain'\nexport type {\n Chain,\n ChainProps,\n ChainService,\n ChainNodeDef,\n ChainNodeDefProps,\n ChainNodeDefService,\n ChainNodeDefAggregate,\n ChainNodeDefAggregateProps,\n} from './chain'\n\nexport { TraverseMethod } from './common'\nexport type { ArenaObject, ArenaService, Dictionary, Factory, I18n } from './common'\n\nexport type { FlatDataExportOptions, ArenaExportInfoFactoryParams, ArenaExportInfo } from './dataExport'\nexport {\n FlatDataExportDefaultOptions,\n FlatDataExportOption,\n FlatDataFiles,\n FlatDataExportModel,\n FlatDataExportColumnDataType,\n ArenaExportInfoFactory,\n UniqueFileNamesGenerator,\n} from './dataExport'\n\nexport { DataQueryMode, DataQuerySummaries } from './dataQuery'\nexport type { DataQuery, DataQuerySummary, DataQuerySummaryProps } from './dataQuery'\n\nexport { SystemError, SystemErrorKeys } from './error'\n\nexport {\n ExpressionNodeType,\n ExpressionNodeEvaluator,\n ExpressionVariable,\n JavascriptExpressionEvaluator,\n JavascriptExpressionParser,\n} from './expression'\nexport type {\n ArrayExpression,\n BinaryExpression,\n CallExpression,\n CompoundExpression,\n ConditionalExpression,\n ExpressionContext,\n ExpressionEvaluator,\n ExpressionFunction,\n ExpressionFunctions,\n AnyExpressionNode,\n ExpressionNode,\n ExpressionNodeEvaluatorConstructor,\n MemberExpression,\n IdentifierExpression,\n LiteralExpression,\n SequenceExpression,\n ThisExpression,\n UnaryExpression,\n} from './expression'\n\nexport { ExtraPropDataType, ExtraPropsDataGenerator } from './extraProp'\nexport type { ExtraPropDef, ExtraPropDefs } from './extraProp'\n\nexport { PointFactory, Points } from './geo'\nexport type { Point } from './geo'\n\nexport { JobBase, JobEventType, JobStatus } from './job'\nexport type { Job, JobContext, JobEvent, JobSerialized, JobTxClient } from './job'\n\nexport { LanguageCode, Languages, LanguagesISO639part2 } from './language'\nexport type { Labels } from './language'\n\nexport type { Logger } from './logger'\n\nexport type { Message } from './message'\nexport { MessageNotificationType, MessagePropsKey, MessageStatus, MessageTargetUserType, Messages } from './message'\n\nexport { NodeFactory, NodeKeys, NodeMetaKeys, Nodes, NodeValueFormatter, NodeValues } from './node'\nexport type {\n ArenaRecordNode,\n Node,\n NodeMeta,\n NodePointer,\n NodeRefData,\n NodeService,\n NodesMap,\n NodeValueCode,\n NodeValueCoordinate,\n NodeValueFile,\n NodeValueTaxon,\n} from './node'\n\nexport {\n NodeDefCountType,\n NodeDefType,\n NodeDefFactory,\n NodeDefs,\n NodeDefEntityRenderType,\n NodeDefFileType,\n NodeDefTextInputType,\n NodeDefTextRenderType,\n FormHeaderColor,\n} from './nodeDef'\n\nexport { NodeDefExpressionEvaluator, NodeDefExpressionValidator } from './nodeDefExpressionEvaluator'\nexport type { CategoryItemProvider, TaxonProvider } from './nodeDefExpressionEvaluator'\n\nexport type {\n NodeDef,\n NodeDefLayout,\n NodeDefMeta,\n NodeDefProps,\n NodeDefPropsWithLayout,\n NodeDefBoolean,\n NodeDefBooleanProps,\n NodeDefCode,\n NodeDefCodeLayout,\n NodeDefCodeProps,\n NodeDefCoordinate,\n NodeDefCoordinateProps,\n NodeDefDate,\n NodeDefDecimal,\n NodeDefDecimalProps,\n NodeDefEntity,\n NodeDefEntityChildPosition,\n NodeDefEntityLayout,\n NodeDefEntityProps,\n NodeDefPrintOrientation,\n NodeDefFile,\n NodeDefFileProps,\n NodeDefFormHeader,\n NodeDefFormHeaderProps,\n NodeDefInteger,\n NodeDefPropsAdvanced,\n NodeDefTaxon,\n NodeDefTaxonProps,\n NodeDefText,\n NodeDefTextProps,\n NodeDefTextLayout,\n NodeDefTime,\n NodeDefTimeProps,\n NodeDefExpression,\n NodeDefMap,\n NodeDefService,\n NodeDefValidations,\n} from './nodeDef'\n\nexport {\n NodePointers,\n RecordCloner,\n RecordFactory,\n RecordFixer,\n Records,\n RECORD_STEP_DEFAULT,\n RecordExpressionEvaluator,\n RecordNodesUpdater,\n RecordPrettyPrinter,\n RecordUpdater,\n RecordUpdateResult,\n RecordValidator,\n RecordValidations,\n} from './record'\nexport type {\n AttributeValidatorParams,\n AttributesValidatorParams,\n NodeCreateParams,\n NodesUpdateParams,\n ArenaRecord,\n Record,\n RecordExpressionContext,\n RecordExpressionEvaluationContext,\n RecordService,\n RecordUpdateOptions,\n RecordValidatorParams,\n SortedAttributesValidatorParams,\n} from './record'\n\nexport { ServiceRegistry, ServiceType } from './registry'\nexport type { ServiceTypeMap } from './registry'\n\nexport { DEFAULT_SRS, DEFAULT_SRS_INDEX, SRSFactory } from './srs'\nexport type { SRS, SRSIndex } from './srs'\n\nexport {\n NodeDefsFixer,\n SurveyDocImages,\n SurveyDocImageFactory,\n SurveyDocPlace,\n SurveyDependencyType,\n SurveyFactory,\n SurveyFileFactory,\n SurveyFileType,\n SurveyRefDataFactory,\n SurveySecurityProp,\n Surveys,\n surveyDocImagePropKeys,\n surveySecurityDefaults,\n defaultCycle,\n} from './survey'\nexport type {\n Survey,\n SurveyCycle,\n SurveyDependency,\n SurveyDependencyGraph,\n SurveyDocImage,\n SurveyDocImageFactoryParams,\n SurveyDocImageProps,\n SurveyFile,\n SurveyFileFactoryParams,\n SurveyFileProps,\n SurveyProps,\n SurveyRefData,\n SurveySecurity,\n SurveyService,\n} from './survey'\n\nexport { Taxa, Taxonomies, TaxonomyFactory, TaxonFactory, TaxonGenerator, VernacularNameFactory } from './taxonomy'\nexport type {\n VernacularNameParams,\n TaxonomyFactoryParams,\n TaxonFactoryParams,\n Taxonomy,\n TaxonomyService,\n VernacularNameProps,\n VernacularName,\n TaxonProps,\n Taxon,\n TaxonomyProps,\n TaxonService,\n} from './taxonomy'\n\nexport { SurveyBuilder, SurveyObjectBuilders } from './tests/builder/surveyBuilder'\nexport { RecordBuilder, RecordNodeBuilders } from './tests/builder/recordBuilder'\n\nexport {\n Arrays,\n DateFormats,\n Dates,\n FileNames,\n FileProcessor,\n Numbers,\n Objects,\n Promises,\n Queue,\n RetryProcessor,\n Strings,\n UnitOfTime,\n UUIDs,\n Versions,\n} from './utils'\n\nexport type { FileProcessorConstructorArgs, MutationOptions, ParsedVersion } from './utils'\n\nexport {\n FieldValidators,\n ValidationFactory,\n ValidationResultFactory,\n ValidationResults,\n Validations,\n ValidationSeverity,\n Validator,\n ValidatorErrorKeys,\n} from './validation'\nexport type {\n DissocFieldValidationOptions,\n FieldValidator,\n Validation,\n ValidationFields,\n ValidationResult,\n ValidationCounts,\n} from './validation'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAEA,+BAAyG;AAAhG,kGAAA,UAAU,OAAA;AAAE,qGAAA,aAAa,OAAA;AAAE,kGAAA,UAAU,OAAA;AAAE,kGAAA,UAAU,OAAA;AAAE,iGAAA,SAAS,OAAA;AAAE,mGAAA,WAAW,OA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d,8GAAA,oBAAoB,OAAA;AACpB,uGAAA,aAAa,OAAA;AACb,2GAAA,iBAAiB,OAAA;AACjB,wGAAA,cAAc,OAAA;AACd,8GAAA,oBAAoB,OAAA;AACpB,4GAAA,kBAAkB,OAAA;AAClB,iGAAA,OAAO,OAAA;AACP,gHAAA,sBAAsB,OAAA;AACtB,gHAAA,sBAAsB,OAAA;AACtB,sGAAA,YAAY,OAAA;AAmBd,uCAAmH;AAA1G,gGAAA,IAAI,OAAA;AAAE,sGAAA,UAAU,OAAA;AAAE,2GAAA,eAAe,OAAA;AAAE,wGAAA,YAAY,OAAA;AAAE,0GAAA,cAAc,OAAA;AAAE,iHAAA,qBAAqB,OAAA;AAe/F,+DAAmF;AAA1E,8GAAA,aAAa,OAAA;AAAE,qHAAA,oBAAoB,OAAA;AAC5C,+DAAiF;AAAxE,8GAAA,aAAa,OAAA;AAAE,mHAAA,kBAAkB,OAAA;AAE1C,iCAegB;AAdd,+FAAA,MAAM,OAAA;AACN,oGAAA,WAAW,OAAA;AACX,8FAAA,KAAK,OAAA;AACL,kGAAA,SAAS,OAAA;AACT,sGAAA,aAAa,OAAA;AACb,gGAAA,OAAO,OAAA;AACP,gGAAA,OAAO,OAAA;AACP,iGAAA,QAAQ,OAAA;AACR,8FAAA,KAAK,OAAA;AACL,uGAAA,cAAc,OAAA;AACd,gGAAA,OAAO,OAAA;AACP,mGAAA,UAAU,OAAA;AACV,8FAAA,KAAK,OAAA;AACL,iGAAA,QAAQ,OAAA;AAKV,2CASqB;AARnB,6GAAA,eAAe,OAAA;AACf,+GAAA,iBAAiB,OAAA;AACjB,qHAAA,uBAAuB,OAAA;AACvB,+GAAA,iBAAiB,OAAA;AACjB,yGAAA,WAAW,OAAA;AACX,gHAAA,kBAAkB,OAAA;AAClB,uGAAA,SAAS,OAAA;AACT,gHAAA,kBAAkB,OAAA","sourcesContent":["export type { AppInfo } from './app'\n\nexport { Authorizer, AuthGroupName, UserStatus, Permission, UserTitle, UserFactory, Users } from './auth'\nexport type {\n AuthGroup,\n User,\n UserAuthGroup,\n UserAuthGroupProps,\n AuthToken,\n UserAuthTokenPayload,\n UserAuthTokenService,\n UserPrefs,\n UserPrefSurveys,\n UserProps,\n UserAuthRefreshToken,\n UserAuthRefreshTokenProps,\n UserAuthRefreshTokenPayload,\n UserService,\n UserTokenPayload,\n DownloadAuthTokenPayload,\n UserGroup,\n UserGroupProps,\n UserGroupQualifier,\n UserInvitation,\n} from './auth'\n\nexport { CategoryFactory, CategoryImportColumnType, CategoryItemFactory, CategoryLevelFactory } from './category'\nexport type {\n CategoryItemProps,\n Category,\n CategoryItem,\n CategoryLevel,\n CategoryLevelProps,\n CategoryImportSummary,\n CategoryImportSummaryColumn,\n CategoryItemService,\n CategoryLevelService,\n CategoryProps,\n CategoryService,\n} from './category'\n\nexport { Categories, CategoryItems } from './category'\n\nexport { ChainFactory, ChainStatusExec, ChainNodeDefFactory } from './chain'\nexport type {\n Chain,\n ChainProps,\n ChainService,\n ChainNodeDef,\n ChainNodeDefProps,\n ChainNodeDefService,\n ChainNodeDefAggregate,\n ChainNodeDefAggregateProps,\n} from './chain'\n\nexport { TraverseMethod } from './common'\nexport type { ArenaObject, ArenaService, Dictionary, Factory, I18n } from './common'\n\nexport type { FlatDataExportOptions, ArenaExportInfoFactoryParams, ArenaExportInfo } from './dataExport'\nexport {\n FlatDataExportDefaultOptions,\n FlatDataExportOption,\n FlatDataFiles,\n FlatDataExportModel,\n FlatDataExportColumnDataType,\n ArenaExportInfoFactory,\n UniqueFileNamesGenerator,\n} from './dataExport'\n\nexport { DataQueryMode, DataQuerySummaries } from './dataQuery'\nexport type { DataQuery, DataQuerySummary, DataQuerySummaryProps } from './dataQuery'\n\nexport { SystemError, SystemErrorKeys } from './error'\n\nexport {\n ExpressionNodeType,\n ExpressionNodeEvaluator,\n ExpressionVariable,\n JavascriptExpressionEvaluator,\n JavascriptExpressionParser,\n} from './expression'\nexport type {\n ArrayExpression,\n BinaryExpression,\n CallExpression,\n CompoundExpression,\n ConditionalExpression,\n ExpressionContext,\n ExpressionEvaluator,\n ExpressionFunction,\n ExpressionFunctions,\n AnyExpressionNode,\n ExpressionNode,\n ExpressionNodeEvaluatorConstructor,\n MemberExpression,\n IdentifierExpression,\n LiteralExpression,\n SequenceExpression,\n ThisExpression,\n UnaryExpression,\n} from './expression'\n\nexport { ExtraPropDataType, ExtraPropsDataGenerator } from './extraProp'\nexport type { ExtraPropDef, ExtraPropDefs } from './extraProp'\n\nexport { PointFactory, Points } from './geo'\nexport type { Point } from './geo'\n\nexport { JobBase, JobEventType, JobStatus } from './job'\nexport type { Job, JobContext, JobEvent, JobSerialized, JobTxClient } from './job'\n\nexport { LanguageCode, Languages, LanguagesISO639part2 } from './language'\nexport type { Labels } from './language'\n\nexport type { Logger } from './logger'\n\nexport type { Message } from './message'\nexport { MessageNotificationType, MessagePropsKey, MessageStatus, MessageTargetUserType, Messages } from './message'\n\nexport { NodeFactory, NodeKeys, NodeMetaKeys, Nodes, NodeValueFormatter, NodeValues } from './node'\nexport type {\n ArenaRecordNode,\n Node,\n NodeMeta,\n NodePointer,\n NodeRefData,\n NodeService,\n NodesMap,\n NodeValueCode,\n NodeValueCoordinate,\n NodeValueFile,\n NodeValueTaxon,\n} from './node'\n\nexport {\n NodeDefCountType,\n NodeDefType,\n NodeDefFactory,\n NodeDefs,\n NodeDefEntityRenderType,\n NodeDefFileType,\n NodeDefTextInputType,\n NodeDefTextRenderType,\n FormHeaderColor,\n} from './nodeDef'\n\nexport { NodeDefExpressionEvaluator, NodeDefExpressionValidator } from './nodeDefExpressionEvaluator'\nexport type { CategoryItemProvider, TaxonProvider } from './nodeDefExpressionEvaluator'\n\nexport type {\n NodeDef,\n NodeDefLayout,\n NodeDefMeta,\n NodeDefProps,\n NodeDefPropsWithLayout,\n NodeDefBoolean,\n NodeDefBooleanProps,\n NodeDefCode,\n NodeDefCodeLayout,\n NodeDefCodeProps,\n NodeDefCoordinate,\n NodeDefCoordinateProps,\n NodeDefDate,\n NodeDefDecimal,\n NodeDefDecimalProps,\n NodeDefEntity,\n NodeDefEntityChildPosition,\n NodeDefEntityLayout,\n NodeDefEntityProps,\n NodeDefPrintOrientation,\n NodeDefFile,\n NodeDefFileProps,\n NodeDefGeo,\n NodeDefGeoProps,\n NodeDefFormHeader,\n NodeDefFormHeaderProps,\n NodeDefInteger,\n NodeDefPropsAdvanced,\n NodeDefTaxon,\n NodeDefTaxonProps,\n NodeDefText,\n NodeDefTextProps,\n NodeDefTextLayout,\n NodeDefTime,\n NodeDefTimeProps,\n NodeDefExpression,\n NodeDefMap,\n NodeDefService,\n NodeDefValidations,\n} from './nodeDef'\n\nexport {\n NodePointers,\n RecordCloner,\n RecordFactory,\n RecordFixer,\n Records,\n RECORD_STEP_DEFAULT,\n RecordExpressionEvaluator,\n RecordNodesUpdater,\n RecordPrettyPrinter,\n RecordUpdater,\n RecordUpdateResult,\n RecordValidator,\n RecordValidations,\n} from './record'\nexport type {\n AttributeValidatorParams,\n AttributesValidatorParams,\n NodeCreateParams,\n NodesUpdateParams,\n ArenaRecord,\n Record,\n RecordExpressionContext,\n RecordExpressionEvaluationContext,\n RecordService,\n RecordUpdateOptions,\n RecordValidatorParams,\n SortedAttributesValidatorParams,\n} from './record'\n\nexport { ServiceRegistry, ServiceType } from './registry'\nexport type { ServiceTypeMap } from './registry'\n\nexport { DEFAULT_SRS, DEFAULT_SRS_INDEX, SRSFactory } from './srs'\nexport type { SRS, SRSIndex } from './srs'\n\nexport {\n NodeDefsFixer,\n SurveyDocImages,\n SurveyDocImageFactory,\n SurveyDocPlace,\n SurveyDependencyType,\n SurveyFactory,\n SurveyFileFactory,\n SurveyFileType,\n SurveyRefDataFactory,\n SurveySecurityProp,\n Surveys,\n surveyDocImagePropKeys,\n surveySecurityDefaults,\n defaultCycle,\n} from './survey'\nexport type {\n Survey,\n SurveyCycle,\n SurveyDependency,\n SurveyDependencyGraph,\n SurveyDocImage,\n SurveyDocImageFactoryParams,\n SurveyDocImageProps,\n SurveyFile,\n SurveyFileFactoryParams,\n SurveyFileProps,\n SurveyProps,\n SurveyRefData,\n SurveySecurity,\n SurveyService,\n} from './survey'\n\nexport { Taxa, Taxonomies, TaxonomyFactory, TaxonFactory, TaxonGenerator, VernacularNameFactory } from './taxonomy'\nexport type {\n VernacularNameParams,\n TaxonomyFactoryParams,\n TaxonFactoryParams,\n Taxonomy,\n TaxonomyService,\n VernacularNameProps,\n VernacularName,\n TaxonProps,\n Taxon,\n TaxonomyProps,\n TaxonService,\n} from './taxonomy'\n\nexport { SurveyBuilder, SurveyObjectBuilders } from './tests/builder/surveyBuilder'\nexport { RecordBuilder, RecordNodeBuilders } from './tests/builder/recordBuilder'\n\nexport {\n Arrays,\n DateFormats,\n Dates,\n FileNames,\n FileProcessor,\n Numbers,\n Objects,\n Promises,\n Queue,\n RetryProcessor,\n Strings,\n UnitOfTime,\n UUIDs,\n Versions,\n} from './utils'\n\nexport type { FileProcessorConstructorArgs, MutationOptions, ParsedVersion } from './utils'\n\nexport {\n FieldValidators,\n ValidationFactory,\n ValidationResultFactory,\n ValidationResults,\n Validations,\n ValidationSeverity,\n Validator,\n ValidatorErrorKeys,\n} from './validation'\nexport type {\n DissocFieldValidationOptions,\n FieldValidator,\n Validation,\n ValidationFields,\n ValidationResult,\n ValidationCounts,\n} from './validation'\n"]}
|
package/dist/node/node.d.ts
CHANGED
|
@@ -21,6 +21,13 @@ export interface NodeMeta {
|
|
|
21
21
|
cEdit?: {
|
|
22
22
|
[uuid: string]: boolean;
|
|
23
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Whether the node children (by definition UUID) are required because their "required if" condition is met (true).
|
|
26
|
+
* If not defined, the children are not required by a condition (only true values are stored).
|
|
27
|
+
*/
|
|
28
|
+
cReq?: {
|
|
29
|
+
[uuid: string]: boolean;
|
|
30
|
+
};
|
|
24
31
|
/**
|
|
25
32
|
* Maximum number of children (by definition UUID) for the node.
|
|
26
33
|
*/
|
package/dist/node/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node/node.ts"],"names":[],"mappings":";;;AAGA,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,2BAAe,CAAA;AACjB,CAAC,EAHW,QAAQ,aAAR,QAAQ,GAAR,QAAQ,QAGnB;AAED,IAAY,YAEX;AAFD,WAAY,YAAY;IACtB,uBAAO,CAAA;AACT,CAAC,EAFW,YAAY,aAAZ,YAAY,GAAZ,YAAY,QAEvB","sourcesContent":["import { CategoryItem } from '../category'\nimport { Taxon } from '../taxonomy'\n\nexport enum NodeKeys {\n meta = 'meta',\n value = 'value',\n}\n\nexport enum NodeMetaKeys {\n h = 'h',\n}\n\nexport interface NodeMeta {\n /**\n * Applicability of the node children (by definition UUID). If not defined, the children are applicable by default.\n */\n childApplicability?: { [uuid: string]: boolean }\n /**\n * Whether the node children (by definition UUID) are editable (true) or read-only (false).\n * If not defined, the children are editable by default.\n */\n cEdit?: { [uuid: string]: boolean }\n /**\n * Maximum number of children (by definition UUID) for the node.\n */\n childrenMaxCount?: { [uuid: string]: number }\n /**\n * Minimum number of children (by definition UUID) for the node.\n */\n childrenMinCount?: { [uuid: string]: number }\n /**\n * Whether the node children (by definition UUID) are visible (true) or hidden (false).\n * If not defined, the children are visible by default.\n */\n cVis?: { [uuid: string]: boolean }\n /**\n * Hierarchy of ancestor node UUIDs.\n */\n h?: string[]\n /**\n * Hierarchy of code attribute ancestor UUIDs (according to the parent code defs specified).\n */\n hCode?: string[]\n /**\n * True if the value has been auto-filled from the node default value\n */\n defaultValueApplied?: boolean\n /**\n * True if the value has been auto-filled from the user group qualifier\n */\n qualifierValueApplied?: boolean\n}\n\nexport interface NodeRefData {\n categoryItem?: CategoryItem\n taxon?: Taxon\n}\n\nexport interface ArenaRecordNode {\n dateCreated?: string\n dateModified?: string\n id?: number\n meta?: NodeMeta\n nodeDefUuid: string\n parentUuid?: string\n recordUuid: string\n refData?: NodeRefData\n uuid: string\n value?: any\n placeholder?: boolean\n surveyUuid?: string\n\n // transient status variables\n /**\n * Record node has been created but not persisted yet.\n */\n created?: boolean\n /**\n * Record node has been deleted.\n */\n deleted?: boolean\n /**\n * Record node has been modified but not persisted yet.\n */\n updated?: boolean\n}\n\n/**\n * @deprecated Use ArenaRecordNode: this name shadows the DOM Node type.\n * It will be removed in the next major version.\n */\nexport type Node = ArenaRecordNode\n\nexport interface NodesMap {\n [key: string]: ArenaRecordNode\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node/node.ts"],"names":[],"mappings":";;;AAGA,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,2BAAe,CAAA;AACjB,CAAC,EAHW,QAAQ,aAAR,QAAQ,GAAR,QAAQ,QAGnB;AAED,IAAY,YAEX;AAFD,WAAY,YAAY;IACtB,uBAAO,CAAA;AACT,CAAC,EAFW,YAAY,aAAZ,YAAY,GAAZ,YAAY,QAEvB","sourcesContent":["import { CategoryItem } from '../category'\nimport { Taxon } from '../taxonomy'\n\nexport enum NodeKeys {\n meta = 'meta',\n value = 'value',\n}\n\nexport enum NodeMetaKeys {\n h = 'h',\n}\n\nexport interface NodeMeta {\n /**\n * Applicability of the node children (by definition UUID). If not defined, the children are applicable by default.\n */\n childApplicability?: { [uuid: string]: boolean }\n /**\n * Whether the node children (by definition UUID) are editable (true) or read-only (false).\n * If not defined, the children are editable by default.\n */\n cEdit?: { [uuid: string]: boolean }\n /**\n * Whether the node children (by definition UUID) are required because their \"required if\" condition is met (true).\n * If not defined, the children are not required by a condition (only true values are stored).\n */\n cReq?: { [uuid: string]: boolean }\n /**\n * Maximum number of children (by definition UUID) for the node.\n */\n childrenMaxCount?: { [uuid: string]: number }\n /**\n * Minimum number of children (by definition UUID) for the node.\n */\n childrenMinCount?: { [uuid: string]: number }\n /**\n * Whether the node children (by definition UUID) are visible (true) or hidden (false).\n * If not defined, the children are visible by default.\n */\n cVis?: { [uuid: string]: boolean }\n /**\n * Hierarchy of ancestor node UUIDs.\n */\n h?: string[]\n /**\n * Hierarchy of code attribute ancestor UUIDs (according to the parent code defs specified).\n */\n hCode?: string[]\n /**\n * True if the value has been auto-filled from the node default value\n */\n defaultValueApplied?: boolean\n /**\n * True if the value has been auto-filled from the user group qualifier\n */\n qualifierValueApplied?: boolean\n}\n\nexport interface NodeRefData {\n categoryItem?: CategoryItem\n taxon?: Taxon\n}\n\nexport interface ArenaRecordNode {\n dateCreated?: string\n dateModified?: string\n id?: number\n meta?: NodeMeta\n nodeDefUuid: string\n parentUuid?: string\n recordUuid: string\n refData?: NodeRefData\n uuid: string\n value?: any\n placeholder?: boolean\n surveyUuid?: string\n\n // transient status variables\n /**\n * Record node has been created but not persisted yet.\n */\n created?: boolean\n /**\n * Record node has been deleted.\n */\n deleted?: boolean\n /**\n * Record node has been modified but not persisted yet.\n */\n updated?: boolean\n}\n\n/**\n * @deprecated Use ArenaRecordNode: this name shadows the DOM Node type.\n * It will be removed in the next major version.\n */\nexport type Node = ArenaRecordNode\n\nexport interface NodesMap {\n [key: string]: ArenaRecordNode\n}\n"]}
|
package/dist/node/nodes.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ declare const areEqual: (nodeA: ArenaRecordNode, nodeB: ArenaRecordNode) => bool
|
|
|
6
6
|
declare const isChildApplicable: (node: ArenaRecordNode, nodeDefUuid: string) => boolean;
|
|
7
7
|
declare const isChildEditable: (node: ArenaRecordNode, nodeDefUuid: string) => boolean;
|
|
8
8
|
declare const isChildVisible: (node: ArenaRecordNode, nodeDefUuid: string) => boolean;
|
|
9
|
+
declare const isChildRequired: (node: ArenaRecordNode, nodeDefUuid: string) => boolean;
|
|
9
10
|
declare const getChildrenMinOrMaxCount: (params: {
|
|
10
11
|
parentNode: ArenaRecordNode;
|
|
11
12
|
nodeDef: NodeDef<any>;
|
|
@@ -47,6 +48,9 @@ declare const dissocChildApplicability: (node: ArenaRecordNode, nodeDefUuid: str
|
|
|
47
48
|
cEdit?: {
|
|
48
49
|
[uuid: string]: boolean;
|
|
49
50
|
};
|
|
51
|
+
cReq?: {
|
|
52
|
+
[uuid: string]: boolean;
|
|
53
|
+
};
|
|
50
54
|
childrenMaxCount?: {
|
|
51
55
|
[uuid: string]: number;
|
|
52
56
|
};
|
|
@@ -68,6 +72,7 @@ declare const dissocChildApplicability: (node: ArenaRecordNode, nodeDefUuid: str
|
|
|
68
72
|
declare function assocChildEditable(node: ArenaRecordNode, nodeDefUuid: string, editable: boolean, options?: MutationOptions): ArenaRecordNode;
|
|
69
73
|
/** @deprecated Pass the options object instead of the positional boolean: `{ sideEffect }` */
|
|
70
74
|
declare function assocChildEditable(node: ArenaRecordNode, nodeDefUuid: string, editable: boolean, sideEffect: boolean): ArenaRecordNode;
|
|
75
|
+
declare const assocChildRequired: (node: ArenaRecordNode, nodeDefUuid: string, required: boolean, options?: MutationOptions) => ArenaRecordNode;
|
|
71
76
|
declare function assocChildVisible(node: ArenaRecordNode, nodeDefUuid: string, visible: boolean, options?: MutationOptions): ArenaRecordNode;
|
|
72
77
|
/** @deprecated Pass the options object instead of the positional boolean: `{ sideEffect }` */
|
|
73
78
|
declare function assocChildVisible(node: ArenaRecordNode, nodeDefUuid: string, visible: boolean, sideEffect: boolean): ArenaRecordNode;
|
|
@@ -100,6 +105,7 @@ export declare const Nodes: {
|
|
|
100
105
|
isChildApplicable: typeof isChildApplicable;
|
|
101
106
|
isChildEditable: typeof isChildEditable;
|
|
102
107
|
isChildVisible: typeof isChildVisible;
|
|
108
|
+
isChildRequired: typeof isChildRequired;
|
|
103
109
|
getChildrenMinOrMaxCount: typeof getChildrenMinOrMaxCount;
|
|
104
110
|
getChildrenMaxCount: typeof getChildrenMaxCount;
|
|
105
111
|
getChildrenMinCount: typeof getChildrenMinCount;
|
|
@@ -114,6 +120,7 @@ export declare const Nodes: {
|
|
|
114
120
|
dissocChildApplicability: typeof dissocChildApplicability;
|
|
115
121
|
assocChildEditable: typeof assocChildEditable;
|
|
116
122
|
assocChildVisible: typeof assocChildVisible;
|
|
123
|
+
assocChildRequired: typeof assocChildRequired;
|
|
117
124
|
assocChildrenCount: typeof assocChildrenCount;
|
|
118
125
|
assocChildrenMaxCount: typeof assocChildrenMaxCount;
|
|
119
126
|
assocChildrenMinCount: typeof assocChildrenMinCount;
|
package/dist/node/nodes.js
CHANGED
|
@@ -32,6 +32,11 @@ const isChildVisible = (node, nodeDefUuid) => {
|
|
|
32
32
|
// if child visibility is not defined for a node definition, consider it visible
|
|
33
33
|
return ((_b = (_a = node.meta) === null || _a === void 0 ? void 0 : _a.cVis) === null || _b === void 0 ? void 0 : _b[nodeDefUuid]) !== false;
|
|
34
34
|
};
|
|
35
|
+
const isChildRequired = (node, nodeDefUuid) => {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
// if child "required if" condition is not defined or not met for a node definition, consider it not required
|
|
38
|
+
return ((_b = (_a = node.meta) === null || _a === void 0 ? void 0 : _a.cReq) === null || _b === void 0 ? void 0 : _b[nodeDefUuid]) === true;
|
|
39
|
+
};
|
|
35
40
|
const getChildrenMinOrMaxCount = (params) => {
|
|
36
41
|
var _a, _b;
|
|
37
42
|
const { parentNode, nodeDef, countType } = params;
|
|
@@ -70,14 +75,15 @@ const dissocChildApplicability = (node, nodeDefUuid) => {
|
|
|
70
75
|
delete childApplicability[nodeDefUuid];
|
|
71
76
|
return Object.assign(Object.assign({}, node), { meta: Object.assign(Object.assign({}, node.meta), { childApplicability }) });
|
|
72
77
|
};
|
|
73
|
-
const updateMetaDictionary = ({ node, nodeDefUuid, propName, propValue, sideEffect, }) => {
|
|
78
|
+
const updateMetaDictionary = ({ node, nodeDefUuid, propName, propValue, defaultValue = true, sideEffect, }) => {
|
|
74
79
|
var _a, _b;
|
|
75
80
|
const nodeUpdated = sideEffect ? node : Object.assign({}, node);
|
|
76
81
|
const metaOriginal = (_a = nodeUpdated.meta) !== null && _a !== void 0 ? _a : {};
|
|
77
82
|
const meta = sideEffect ? metaOriginal : Object.assign({}, metaOriginal);
|
|
78
83
|
const existingDictionary = (_b = meta[propName]) !== null && _b !== void 0 ? _b : {};
|
|
79
84
|
const dictionary = sideEffect ? existingDictionary : Object.assign({}, existingDictionary);
|
|
80
|
-
if (propValue) {
|
|
85
|
+
if (propValue === defaultValue) {
|
|
86
|
+
// default value: not stored
|
|
81
87
|
delete dictionary[nodeDefUuid];
|
|
82
88
|
}
|
|
83
89
|
else {
|
|
@@ -93,6 +99,17 @@ function assocChildEditable(node, nodeDefUuid, editable, options) {
|
|
|
93
99
|
const { sideEffect = false } = (0, mutationOptions_1.toMutationOptions)(options);
|
|
94
100
|
return updateMetaDictionary({ node, nodeDefUuid, propName: 'cEdit', propValue: editable, sideEffect });
|
|
95
101
|
}
|
|
102
|
+
const assocChildRequired = (node, nodeDefUuid, required, options) => {
|
|
103
|
+
const { sideEffect = false } = options !== null && options !== void 0 ? options : {};
|
|
104
|
+
return updateMetaDictionary({
|
|
105
|
+
node,
|
|
106
|
+
nodeDefUuid,
|
|
107
|
+
propName: 'cReq',
|
|
108
|
+
propValue: required,
|
|
109
|
+
defaultValue: false,
|
|
110
|
+
sideEffect,
|
|
111
|
+
});
|
|
112
|
+
};
|
|
96
113
|
function assocChildVisible(node, nodeDefUuid, visible, options) {
|
|
97
114
|
const { sideEffect = false } = (0, mutationOptions_1.toMutationOptions)(options);
|
|
98
115
|
return updateMetaDictionary({ node, nodeDefUuid, propName: 'cVis', propValue: visible, sideEffect });
|
|
@@ -154,6 +171,7 @@ exports.Nodes = {
|
|
|
154
171
|
isChildApplicable,
|
|
155
172
|
isChildEditable,
|
|
156
173
|
isChildVisible,
|
|
174
|
+
isChildRequired,
|
|
157
175
|
getChildrenMinOrMaxCount,
|
|
158
176
|
getChildrenMaxCount,
|
|
159
177
|
getChildrenMinCount,
|
|
@@ -169,6 +187,7 @@ exports.Nodes = {
|
|
|
169
187
|
dissocChildApplicability,
|
|
170
188
|
assocChildEditable,
|
|
171
189
|
assocChildVisible,
|
|
190
|
+
assocChildRequired,
|
|
172
191
|
assocChildrenCount,
|
|
173
192
|
assocChildrenMaxCount,
|
|
174
193
|
assocChildrenMinCount,
|