@openforis/arena-core 2.3.40 → 2.3.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/authorizer.d.ts +3 -3
- package/dist/auth/authorizer.js.map +1 -1
- package/dist/esm/auth/authorizer.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node/factory.js.map +1 -1
- package/dist/esm/node/index.js.map +1 -1
- package/dist/esm/node/node.js.map +1 -1
- package/dist/esm/node/nodePointer.js.map +1 -1
- package/dist/esm/node/nodeValueFormatter.js.map +1 -1
- package/dist/esm/node/nodeValues.js.map +1 -1
- package/dist/esm/node/nodes.js +13 -5
- package/dist/esm/node/nodes.js.map +1 -1
- package/dist/esm/node/service.js.map +1 -1
- package/dist/esm/nodeDefExpressionEvaluator/functions.js.map +1 -1
- package/dist/esm/record/_records/recordCompletion.js.map +1 -1
- package/dist/esm/record/_records/recordGetters.js.map +1 -1
- package/dist/esm/record/_records/recordNodesIndexUpdater.js +6 -4
- package/dist/esm/record/_records/recordNodesIndexUpdater.js.map +1 -1
- package/dist/esm/record/_records/recordPagesValidation.js.map +1 -1
- package/dist/esm/record/_records/recordUpdateOptions.js.map +1 -1
- package/dist/esm/record/_records/recordUpdater.js +1 -1
- package/dist/esm/record/_records/recordUpdater.js.map +1 -1
- package/dist/esm/record/_records/recordUtils.js.map +1 -1
- package/dist/esm/record/factory.js.map +1 -1
- package/dist/esm/record/index.js.map +1 -1
- package/dist/esm/record/nodePointers.js.map +1 -1
- package/dist/esm/record/record.js.map +1 -1
- package/dist/esm/record/recordCloner.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/context.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/node/identifier/nodesFinder.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/nodeValueExtractor.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
- package/dist/esm/record/recordFixer.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordEnumeratingItemsExpressionEvaluator.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordExpressionValueConverter.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEditableUpdater.js +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEditableUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsUpdateParams.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsVisibleUpdater.js +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsVisibleUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesCreator.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesDeleter.js +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesDeleter.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordUpdateResult.js.map +1 -1
- package/dist/esm/record/recordPrettyPrinter.js.map +1 -1
- package/dist/esm/record/recordUpdater.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeKeyValidator.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeTypeValidator.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeUniqueValidator.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeValidator.js.map +1 -1
- package/dist/esm/record/recordValidator/countVaildator.js.map +1 -1
- package/dist/esm/record/recordValidator/recordValidator.js.map +1 -1
- package/dist/esm/record/service.js.map +1 -1
- package/dist/esm/survey/nodeDefsFixer.js.map +1 -1
- package/dist/esm/survey/surveys/_nodeDefs/nodeDefsIndex.js +2 -2
- package/dist/esm/survey/surveys/_nodeDefs/nodeDefsIndex.js.map +1 -1
- package/dist/esm/tests/builder/recordBuilder/attributeBuilder.js.map +1 -1
- package/dist/esm/tests/builder/recordBuilder/entityBuilder.js.map +1 -1
- package/dist/esm/tests/builder/recordBuilder/nodeBuilder.js.map +1 -1
- package/dist/esm/tests/builder/recordBuilder/recordBuilder.js.map +1 -1
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/mutationOptions.js +5 -0
- package/dist/esm/utils/mutationOptions.js.map +1 -0
- package/dist/esm/validation/index.js.map +1 -1
- package/dist/esm/validation/validations.js +26 -19
- package/dist/esm/validation/validations.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js.map +1 -1
- package/dist/node/factory.d.ts +4 -4
- package/dist/node/factory.js.map +1 -1
- package/dist/node/index.d.ts +1 -2
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +7 -2
- package/dist/node/node.js.map +1 -1
- package/dist/node/nodePointer.d.ts +2 -2
- package/dist/node/nodePointer.js.map +1 -1
- package/dist/node/nodeValueFormatter.d.ts +2 -2
- package/dist/node/nodeValueFormatter.js.map +1 -1
- package/dist/node/nodeValues.d.ts +21 -21
- package/dist/node/nodeValues.js.map +1 -1
- package/dist/node/nodes.d.ts +38 -31
- package/dist/node/nodes.js +13 -5
- package/dist/node/nodes.js.map +1 -1
- package/dist/node/service.d.ts +6 -6
- package/dist/node/service.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/functions.js.map +1 -1
- package/dist/record/_records/recordCompletion.d.ts +9 -9
- package/dist/record/_records/recordCompletion.js.map +1 -1
- package/dist/record/_records/recordGetters.d.ts +69 -69
- package/dist/record/_records/recordGetters.js.map +1 -1
- package/dist/record/_records/recordNodesIndexUpdater.d.ts +13 -10
- package/dist/record/_records/recordNodesIndexUpdater.js +6 -4
- package/dist/record/_records/recordNodesIndexUpdater.js.map +1 -1
- package/dist/record/_records/recordPagesValidation.d.ts +11 -11
- package/dist/record/_records/recordPagesValidation.js.map +1 -1
- package/dist/record/_records/recordUpdateOptions.d.ts +2 -2
- package/dist/record/_records/recordUpdateOptions.js.map +1 -1
- package/dist/record/_records/recordUpdater.d.ts +5 -5
- package/dist/record/_records/recordUpdater.js +1 -1
- package/dist/record/_records/recordUpdater.js.map +1 -1
- package/dist/record/_records/recordUtils.d.ts +6 -6
- package/dist/record/_records/recordUtils.js.map +1 -1
- package/dist/record/factory.d.ts +2 -2
- package/dist/record/factory.js.map +1 -1
- package/dist/record/index.d.ts +1 -2
- package/dist/record/index.js.map +1 -1
- package/dist/record/nodePointers.d.ts +6 -6
- package/dist/record/nodePointers.js.map +1 -1
- package/dist/record/record.d.ts +8 -5
- package/dist/record/record.js.map +1 -1
- package/dist/record/recordCloner.d.ts +3 -3
- package/dist/record/recordCloner.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/context.d.ts +6 -6
- package/dist/record/recordExpressionEvaluator/context.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/node/identifier/nodesFinder.d.ts +5 -5
- package/dist/record/recordExpressionEvaluator/node/identifier/nodesFinder.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/nodeValueExtractor.d.ts +2 -2
- package/dist/record/recordExpressionEvaluator/nodeValueExtractor.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.d.ts +4 -4
- package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
- package/dist/record/recordFixer.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordEnumeratingItemsExpressionEvaluator.d.ts +4 -4
- package/dist/record/recordNodesUpdater/recordEnumeratingItemsExpressionEvaluator.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordExpressionValueConverter.d.ts +4 -4
- package/dist/record/recordNodesUpdater/recordExpressionValueConverter.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.d.ts +4 -3
- package/dist/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsBooleanUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsEditableUpdater.js +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsEditableUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.d.ts +2 -2
- package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.d.ts +2 -2
- package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsUpdateParams.d.ts +2 -2
- package/dist/record/recordNodesUpdater/recordNodeDependentsUpdateParams.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsVisibleUpdater.js +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsVisibleUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesCreator.d.ts +4 -4
- package/dist/record/recordNodesUpdater/recordNodesCreator.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesDeleter.d.ts +3 -3
- package/dist/record/recordNodesUpdater/recordNodesDeleter.js +1 -1
- package/dist/record/recordNodesUpdater/recordNodesDeleter.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.d.ts +4 -4
- package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesUpdater.d.ts +2 -2
- package/dist/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordUpdateResult.d.ts +6 -6
- package/dist/record/recordNodesUpdater/recordUpdateResult.js.map +1 -1
- package/dist/record/recordPrettyPrinter.d.ts +7 -7
- package/dist/record/recordPrettyPrinter.js.map +1 -1
- package/dist/record/recordUpdater.js.map +1 -1
- package/dist/record/recordValidator/attributeKeyValidator.d.ts +4 -4
- package/dist/record/recordValidator/attributeKeyValidator.js.map +1 -1
- package/dist/record/recordValidator/attributeTypeValidator.d.ts +4 -4
- package/dist/record/recordValidator/attributeTypeValidator.js.map +1 -1
- package/dist/record/recordValidator/attributeUniqueValidator.d.ts +4 -4
- package/dist/record/recordValidator/attributeUniqueValidator.js.map +1 -1
- package/dist/record/recordValidator/attributeValidator.d.ts +6 -6
- package/dist/record/recordValidator/attributeValidator.js.map +1 -1
- package/dist/record/recordValidator/countVaildator.d.ts +7 -7
- package/dist/record/recordValidator/countVaildator.js.map +1 -1
- package/dist/record/recordValidator/recordValidator.js.map +1 -1
- package/dist/record/records.d.ts +6 -6
- package/dist/record/service.d.ts +8 -8
- package/dist/record/service.js.map +1 -1
- package/dist/survey/nodeDefsFixer.d.ts +2 -2
- package/dist/survey/nodeDefsFixer.js.map +1 -1
- package/dist/survey/surveys/_nodeDefs/nodeDefsIndex.d.ts +3 -6
- package/dist/survey/surveys/_nodeDefs/nodeDefsIndex.js +2 -2
- package/dist/survey/surveys/_nodeDefs/nodeDefsIndex.js.map +1 -1
- package/dist/tests/builder/recordBuilder/attributeBuilder.d.ts +5 -5
- package/dist/tests/builder/recordBuilder/attributeBuilder.js.map +1 -1
- package/dist/tests/builder/recordBuilder/entityBuilder.d.ts +5 -5
- package/dist/tests/builder/recordBuilder/entityBuilder.js.map +1 -1
- package/dist/tests/builder/recordBuilder/nodeBuilder.d.ts +5 -5
- package/dist/tests/builder/recordBuilder/nodeBuilder.js.map +1 -1
- package/dist/tests/builder/recordBuilder/recordBuilder.d.ts +2 -2
- package/dist/tests/builder/recordBuilder/recordBuilder.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/mutationOptions.d.ts +14 -0
- package/dist/utils/mutationOptions.js +9 -0
- package/dist/utils/mutationOptions.js.map +1 -0
- package/dist/validation/index.d.ts +1 -0
- package/dist/validation/index.js.map +1 -1
- package/dist/validation/validations.d.ts +17 -2
- package/dist/validation/validations.js +26 -19
- package/dist/validation/validations.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributeValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/attributeValidator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,qCAA8D;AAC9D,2CAA+F;AAG/F,yCAA8C;AAC9C,gDAA0D;AAC1D,uCAAqC;AACrC,iDAMyB;AAEzB,kDAA8C;AAE9C,4EAAwE;AACxE,wCAAoC;AACpC,4DAAwD;AACxD,mEAAuG;AACvG,qEAAiE;AACjE,yEAAqE;AAErE,MAAM,mBAAm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AG,6BAA6B,iCAAM,MAAM,KAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,oBAAoB,IAAG,CAC5G,CAAA;QAED,IAAI,MAAA,kBAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,0CAAE,MAAM,EAAE,CAAC;YAC7C,MAAM,CAAC,IAAI,CAAC,GAAG,iBAAO,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;QACzE,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,MAAM,wCAAwC,GAAG,CAC/C,MAAuC,EACZ,EAAE;IAC7B,MAAM,eAAe,GAAW,yBAAyB,CAAC,MAAM,CAAC,CAAA;IACjE,MAAM,qBAAqB,GAAqB,EAAE,CAAA;IAClD,6EAA6E;IAC7E,MAAM,eAAe,GAAG,IAAA,6CAAqB,GAAE,CAAA;IAE/C,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE,CAAC;QAC7C,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAA;QACpC,iEAAiE;QACjE,IAAI,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAChE,qEAAqE;YACrE,MAAM,wBAAwB,mCAAQ,MAAM,KAAE,SAAS,EAAE,cAAc,EAAE,eAAe,GAAE,CAAA;YAC1F,qBAAqB,CAAC,QAAQ,CAAC,GAAG,MAAM,iBAAiB,CAAC,wBAAwB,CAAC,CAAA,CAAC,UAAU;QAChG,CAAC;IACH,CAAC;IACD,OAAO,qBAAqB,CAAA;AAC9B,CAAC,CAAA,CAAA;AAEY,QAAA,kBAAkB,GAAG;IAChC,wCAAwC;CACzC,CAAA","sourcesContent":["import { User } from '../../auth'\nimport { Dictionary } from '../../common'\nimport { Labels } from '../../language'\nimport { Node, 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 { Record } 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: Record\n}\n\nexport interface AttributeValidatorParams extends RecordValidatorParams {\n attribute: Node\n}\n\nexport interface AttributesValidatorParams extends RecordValidatorParams {\n nodes: Dictionary<Node>\n}\n\nexport interface SortedAttributesValidatorParams extends RecordValidatorParams {\n nodesArray: Node[]\n}\n\ntype SiblingKeyNodeItem = { entityUuid: string; keyNode: Node; 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({\n record,\n node: attribute,\n ancestorDefUuid: ancestorMultipleEntityDef.uuid,\n })\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({ record, entity: ancestorMultipleEntity, includeSelf: true })\n items = []\n for (const entity of entities) {\n const keyNodes = Records.getEntityKeyNodes({ survey, record, entity, keyDefs })\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: Record; nodeDef: NodeDef<NodeDefType, NodeDefProps> }) =>\n async (_propName: string, node: Node): 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({ record, node: attribute })) {\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?: Node\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: Node[] = []\n const siblingNodeKeysWithErrors: Node[] = []\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): Node[] => {\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 record,\n node,\n dependencyType: SurveyDependencyType.validations,\n includeSelf: true,\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({ record, node, nodeDef }))\n }\n }\n\n return result\n}\n\nconst validateSelfAndDependentSortedAttributes = async (\n params: SortedAttributesValidatorParams\n): Promise<ValidationFields> => {\n const nodesToValidate: Node[] = findSortedNodesToValidate(params)\n const validationsByNodeUuid: ValidationFields = {}\n // the record doesn't change during the validation: entity keys can be cached\n const entityKeysCache = createEntityKeysCache()\n\n for (const nodeToValidate of nodesToValidate) {\n const nodeUuid = nodeToValidate.uuid\n // Validate only attributes not deleted and not validated already\n if (!nodeToValidate.deleted && !validationsByNodeUuid[nodeUuid]) {\n // sequential: avoid concurrent item/taxon lookups on large node sets\n const attributeValidatorParams = { ...params, attribute: nodeToValidate, entityKeysCache }\n validationsByNodeUuid[nodeUuid] = await validateAttribute(attributeValidatorParams) // NOSONAR\n }\n }\n return validationsByNodeUuid\n}\n\nexport const AttributeValidator = {\n validateSelfAndDependentSortedAttributes,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"attributeValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/attributeValidator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,qCAAyE;AACzE,2CAA+F;AAG/F,yCAA8C;AAC9C,gDAA0D;AAC1D,uCAAqC;AACrC,iDAMyB;AAEzB,kDAA8C;AAE9C,4EAAwE;AACxE,wCAAoC;AACpC,4DAAwD;AACxD,mEAAuG;AACvG,qEAAiE;AACjE,yEAAqE;AAErE,MAAM,mBAAmB,GAAG,IAAI,qDAAyB,EAAE,CAAA;AA6B3D,MAAM,mBAAmB,GAAG,CAC1B,MAAkF,EAC5D,EAAE;IACxB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAA;IAElE,MAAM,YAAY,GAAG,gBAAO,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,WAAW,EAAE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,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;QACzE,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,MAAM,wCAAwC,GAAG,CAC/C,MAAuC,EACZ,EAAE;IAC7B,MAAM,eAAe,GAAsB,yBAAyB,CAAC,MAAM,CAAC,CAAA;IAC5E,MAAM,qBAAqB,GAAqB,EAAE,CAAA;IAClD,6EAA6E;IAC7E,MAAM,eAAe,GAAG,IAAA,6CAAqB,GAAE,CAAA;IAE/C,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE,CAAC;QAC7C,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAA;QACpC,iEAAiE;QACjE,IAAI,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAChE,qEAAqE;YACrE,MAAM,wBAAwB,mCAAQ,MAAM,KAAE,SAAS,EAAE,cAAc,EAAE,eAAe,GAAE,CAAA;YAC1F,qBAAqB,CAAC,QAAQ,CAAC,GAAG,MAAM,iBAAiB,CAAC,wBAAwB,CAAC,CAAA,CAAC,UAAU;QAChG,CAAC;IACH,CAAC;IACD,OAAO,qBAAqB,CAAA;AAC9B,CAAC,CAAA,CAAA;AAEY,QAAA,kBAAkB,GAAG;IAChC,wCAAwC;CACzC,CAAA","sourcesContent":["import { User } from '../../auth'\nimport { Dictionary } from '../../common'\nimport { Labels } from '../../language'\nimport { ArenaRecordNode, NodeKeys, Nodes, NodeValues } from '../../node'\nimport { NodeDef, NodeDefExpression, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { 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({\n record,\n node: attribute,\n ancestorDefUuid: ancestorMultipleEntityDef.uuid,\n })\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({ record, entity: ancestorMultipleEntity, includeSelf: true })\n items = []\n for (const entity of entities) {\n const keyNodes = Records.getEntityKeyNodes({ survey, record, entity, keyDefs })\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({ record, node: attribute })) {\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 record,\n node,\n dependencyType: SurveyDependencyType.validations,\n includeSelf: true,\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({ record, node, nodeDef }))\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,24 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArenaRecordNode } from '../../node';
|
|
2
2
|
import { NodeDef, NodeDefProps, NodeDefType } from '../../nodeDef';
|
|
3
3
|
import { Validation } from '../../validation';
|
|
4
|
-
import {
|
|
4
|
+
import { ArenaRecord } from '../record';
|
|
5
5
|
import { Survey } from '../../survey';
|
|
6
6
|
import { ValidationFields } from '../../validation/validation';
|
|
7
7
|
declare const validateChildrenCount: (params: {
|
|
8
|
-
parentNode:
|
|
8
|
+
parentNode: ArenaRecordNode;
|
|
9
9
|
nodeDefChild: NodeDef<NodeDefType, NodeDefProps>;
|
|
10
10
|
count: number;
|
|
11
11
|
}) => Validation;
|
|
12
12
|
declare const validateChildrenCountNodesArray: (params: {
|
|
13
13
|
survey: Survey;
|
|
14
|
-
record:
|
|
15
|
-
nodesArray:
|
|
14
|
+
record: ArenaRecord;
|
|
15
|
+
nodesArray: ArenaRecordNode[];
|
|
16
16
|
}) => ValidationFields;
|
|
17
17
|
declare const validateChildrenCountNodes: (params: {
|
|
18
18
|
survey: Survey;
|
|
19
|
-
record:
|
|
19
|
+
record: ArenaRecord;
|
|
20
20
|
nodes: {
|
|
21
|
-
[key: string]:
|
|
21
|
+
[key: string]: ArenaRecordNode;
|
|
22
22
|
};
|
|
23
23
|
}) => ValidationFields;
|
|
24
24
|
export declare const CountValidator: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"countVaildator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/countVaildator.ts"],"names":[],"mappings":";;;AAAA,qCAAqD;AACrD,2CAA4E;AAC5E,wCAAoC;AACpC,iDAA6G;AAE7G,yCAA8C;AAC9C,4DAAwD;AAGxD,MAAM,sBAAsB,GAAG,CAAC,MAK/B,EAAc,EAAE;IACf,MAAM,EAAE,WAAW,EAAE,oBAAoB,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;IAExE,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,8BAAiB,CAAC,cAAc,CAAC;YACtC,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE;gBACN,oCAAuB,CAAC,cAAc,CAAC;oBACrC,GAAG,EAAE,4BAA4B;oBACjC,MAAM,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE;oBACxC,QAAQ,EAAE,+BAAkB,CAAC,KAAK;iBACnC,CAAC;aACH;SACF,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,8BAAiB,CAAC,cAAc,CAAC;QACtC,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE;YACN,oCAAuB,CAAC,cAAc,CAAC;gBACrC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,gCAAgC;gBACjG,MAAM,kBAAI,WAAW,IAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAE;gBAChF,QAAQ,EAAE,+BAAkB,CAAC,KAAK;aACnC,CAAC;SACH;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,qBAAqB,GAAG,CAAC,MAI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mB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAA;gBAC/E,cAAc,CAAC,0BAA0B,CAAC,GAAG,qBAAqB,CAAA;YACpE,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,cAAc,CAAA;AACvB,CAAC,CAAA;AAED,MAAM,0BAA0B,GAAG,CAAC,MAInC,EAAoB,EAAE,CAAC,+BAA+B,iCAAM,MAAM,KAAE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAG,CAAA;AAElG,QAAA,cAAc,GAAG;IAC5B,qBAAqB;IACrB,+BAA+B;IAC/B,0BAA0B;CAC3B,CAAA","sourcesContent":["import { Node, NodePointer, Nodes } from '../../node'\nimport { NodeDef, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { Records } from '../records'\nimport { Validation, ValidationFactory, ValidationResultFactory, ValidationSeverity } from '../../validation'\nimport { Record } from '../record'\nimport { Survey, Surveys } from '../../survey'\nimport { RecordValidations } from '../recordValidations'\nimport { ValidationFields } from '../../validation/validation'\n\nconst createValidationResult = (params: {\n nodeDefUuid: string\n isMinCountValidation: boolean\n minCount: number\n maxCount: number\n}): Validation => {\n const { nodeDefUuid, isMinCountValidation, minCount, maxCount } = params\n\n if (minCount === maxCount) {\n return ValidationFactory.createInstance({\n valid: false,\n errors: [\n ValidationResultFactory.createInstance({\n key: 'record.nodes.count.invalid',\n params: { nodeDefUuid, count: minCount },\n severity: ValidationSeverity.error,\n }),\n ],\n })\n }\n return ValidationFactory.createInstance({\n valid: false,\n errors: [\n ValidationResultFactory.createInstance({\n key: isMinCountValidation ? 'record.nodes.count.minNotReached' : 'record.nodes.count.maxExceeded',\n params: { nodeDefUuid, ...(isMinCountValidation ? { minCount } : { maxCount }) },\n severity: ValidationSeverity.error,\n }),\n ],\n })\n}\n\nconst validateChildrenCount = (params: {\n parentNode: Node\n nodeDefChild: NodeDef<NodeDefType, NodeDefProps>\n count: number\n}): Validation => {\n const { parentNode, nodeDefChild, count } = params\n\n const minCount = Nodes.getChildrenMinCount({ parentNode, nodeDef: nodeDefChild })\n const maxCount = Nodes.getChildrenMaxCount({ parentNode, nodeDef: nodeDefChild })\n\n const minCountValid = Number.isNaN(minCount) || count >= minCount\n const maxCountValid = Number.isNaN(maxCount) || count <= maxCount\n\n return minCountValid && maxCountValid\n ? ValidationFactory.createInstance()\n : createValidationResult({\n nodeDefUuid: nodeDefChild.uuid,\n isMinCountValidation: !minCountValid,\n minCount,\n maxCount,\n })\n}\n\nconst _countChildren = (params: { record: Record; parentNode: Node; childDef: NodeDef<NodeDefType, NodeDefProps> }) => {\n const { record, parentNode, childDef } = params\n const children = Records.getChildren(parentNode, childDef.uuid)(record)\n const nonEmptyChildren = NodeDefs.isAttribute(childDef)\n ? children.filter((child) => !Nodes.isValueBlank(child))\n : children\n return nonEmptyChildren.length\n}\n\nconst isNodePointerToBeValidated = (nodePointer: NodePointer) => NodeDefs.hasMinOrMaxCount(nodePointer.nodeDef)\n\nconst validateNodePointer = (params: {\n record: Record\n nodeCtx: Node\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}) => {\n const { record, nodeCtx, nodeDef } = params\n // Check children count only for applicable nodes\n if (Nodes.isChildApplicable(nodeCtx, nodeDef.uuid)) {\n const count = _countChildren({ record, parentNode: nodeCtx, childDef: nodeDef })\n return validateChildrenCount({ parentNode: nodeCtx, nodeDefChild: nodeDef, count })\n }\n return ValidationFactory.createInstance()\n}\n\nconst getNodePointersToValidate = (params: { survey: Survey; record: Record; node: Node }): NodePointer[] => {\n const { survey, record, node } = params\n const nodePointersToValidate: NodePointer[] = []\n\n const nodeDef = Surveys.getNodeDefByUuid({ uuid: node.nodeDefUuid, survey })\n\n const nodeParent = Records.getParent(node)(record)\n if (nodeParent) {\n // always validate the node itself\n const nodePointer = { nodeCtx: nodeParent, nodeDef }\n if (isNodePointerToBeValidated(nodePointer)) {\n nodePointersToValidate.push(nodePointer)\n }\n }\n if (NodeDefs.isEntity(nodeDef) && !node.deleted) {\n // validate the count of every node def children\n const childDefs = Surveys.getNodeDefChildren({ survey, nodeDef })\n for (const childDef of childDefs) {\n const nodePointer = { nodeCtx: node, nodeDef: childDef }\n if (isNodePointerToBeValidated(nodePointer)) {\n nodePointersToValidate.push(nodePointer)\n }\n }\n }\n return nodePointersToValidate\n}\n\nconst validateChildrenCountNodesArray = (params: {\n survey: Survey\n record: Record\n nodesArray: Node[]\n}): ValidationFields => {\n const { survey, record, nodesArray } = params\n const validationsAcc: ValidationFields = {}\n for (const node of nodesArray) {\n const nodePointersToValidate = getNodePointersToValidate({ survey, record, node })\n\n for (const nodePointer of nodePointersToValidate) {\n const { nodeCtx, nodeDef } = nodePointer\n // check if validated already\n const validationChildrenCountKey = RecordValidations.getValidationChildrenCountKey({\n nodeParentUuid: nodeCtx.uuid,\n nodeDefChildUuid: nodeDef.uuid,\n })\n if (!(validationChildrenCountKey in validationsAcc)) {\n // validate the children count of this node pointer\n const validationNodePointer = validateNodePointer({ record, nodeCtx, nodeDef })\n validationsAcc[validationChildrenCountKey] = validationNodePointer\n }\n }\n }\n return validationsAcc\n}\n\nconst validateChildrenCountNodes = (params: {\n survey: Survey\n record: Record\n nodes: { [key: string]: Node }\n}): ValidationFields => validateChildrenCountNodesArray({ ...params, nodesArray: Object.values(params.nodes) })\n\nexport const CountValidator = {\n validateChildrenCount,\n validateChildrenCountNodesArray,\n validateChildrenCountNodes,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"countVaildator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/countVaildator.ts"],"names":[],"mappings":";;;AAAA,qCAAgE;AAChE,2CAA4E;AAC5E,wCAAoC;AACpC,iDAA6G;AAE7G,yCAA8C;AAC9C,4DAAwD;AAGxD,MAAM,sBAAsB,GAAG,CAAC,MAK/B,EAAc,EAAE;IACf,MAAM,EAAE,WAAW,EAAE,oBAAoB,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,CA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["import { ArenaRecordNode, NodePointer, Nodes } from '../../node'\nimport { NodeDef, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { Records } from '../records'\nimport { Validation, ValidationFactory, ValidationResultFactory, ValidationSeverity } from '../../validation'\nimport { ArenaRecord } from '../record'\nimport { Survey, Surveys } from '../../survey'\nimport { RecordValidations } from '../recordValidations'\nimport { ValidationFields } from '../../validation/validation'\n\nconst createValidationResult = (params: {\n nodeDefUuid: string\n isMinCountValidation: boolean\n minCount: number\n maxCount: number\n}): Validation => {\n const { nodeDefUuid, isMinCountValidation, minCount, maxCount } = params\n\n if (minCount === maxCount) {\n return ValidationFactory.createInstance({\n valid: false,\n errors: [\n ValidationResultFactory.createInstance({\n key: 'record.nodes.count.invalid',\n params: { nodeDefUuid, count: minCount },\n severity: ValidationSeverity.error,\n }),\n ],\n })\n }\n return ValidationFactory.createInstance({\n valid: false,\n errors: [\n ValidationResultFactory.createInstance({\n key: isMinCountValidation ? 'record.nodes.count.minNotReached' : 'record.nodes.count.maxExceeded',\n params: { nodeDefUuid, ...(isMinCountValidation ? { minCount } : { maxCount }) },\n severity: ValidationSeverity.error,\n }),\n ],\n })\n}\n\nconst validateChildrenCount = (params: {\n parentNode: ArenaRecordNode\n nodeDefChild: NodeDef<NodeDefType, NodeDefProps>\n count: number\n}): Validation => {\n const { parentNode, nodeDefChild, count } = params\n\n const minCount = Nodes.getChildrenMinCount({ parentNode, nodeDef: nodeDefChild })\n const maxCount = Nodes.getChildrenMaxCount({ parentNode, nodeDef: nodeDefChild })\n\n const minCountValid = Number.isNaN(minCount) || count >= minCount\n const maxCountValid = Number.isNaN(maxCount) || count <= maxCount\n\n return minCountValid && maxCountValid\n ? ValidationFactory.createInstance()\n : createValidationResult({\n nodeDefUuid: nodeDefChild.uuid,\n isMinCountValidation: !minCountValid,\n minCount,\n maxCount,\n })\n}\n\nconst _countChildren = (params: {\n record: ArenaRecord\n parentNode: ArenaRecordNode\n childDef: NodeDef<NodeDefType, NodeDefProps>\n}) => {\n const { record, parentNode, childDef } = params\n const children = Records.getChildren(parentNode, childDef.uuid)(record)\n const nonEmptyChildren = NodeDefs.isAttribute(childDef)\n ? children.filter((child) => !Nodes.isValueBlank(child))\n : children\n return nonEmptyChildren.length\n}\n\nconst isNodePointerToBeValidated = (nodePointer: NodePointer) => NodeDefs.hasMinOrMaxCount(nodePointer.nodeDef)\n\nconst validateNodePointer = (params: {\n record: ArenaRecord\n nodeCtx: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}) => {\n const { record, nodeCtx, nodeDef } = params\n // Check children count only for applicable nodes\n if (Nodes.isChildApplicable(nodeCtx, nodeDef.uuid)) {\n const count = _countChildren({ record, parentNode: nodeCtx, childDef: nodeDef })\n return validateChildrenCount({ parentNode: nodeCtx, nodeDefChild: nodeDef, count })\n }\n return ValidationFactory.createInstance()\n}\n\nconst getNodePointersToValidate = (params: {\n survey: Survey\n record: ArenaRecord\n node: ArenaRecordNode\n}): NodePointer[] => {\n const { survey, record, node } = params\n const nodePointersToValidate: NodePointer[] = []\n\n const nodeDef = Surveys.getNodeDefByUuid({ uuid: node.nodeDefUuid, survey })\n\n const nodeParent = Records.getParent(node)(record)\n if (nodeParent) {\n // always validate the node itself\n const nodePointer = { nodeCtx: nodeParent, nodeDef }\n if (isNodePointerToBeValidated(nodePointer)) {\n nodePointersToValidate.push(nodePointer)\n }\n }\n if (NodeDefs.isEntity(nodeDef) && !node.deleted) {\n // validate the count of every node def children\n const childDefs = Surveys.getNodeDefChildren({ survey, nodeDef })\n for (const childDef of childDefs) {\n const nodePointer = { nodeCtx: node, nodeDef: childDef }\n if (isNodePointerToBeValidated(nodePointer)) {\n nodePointersToValidate.push(nodePointer)\n }\n }\n }\n return nodePointersToValidate\n}\n\nconst validateChildrenCountNodesArray = (params: {\n survey: Survey\n record: ArenaRecord\n nodesArray: ArenaRecordNode[]\n}): ValidationFields => {\n const { survey, record, nodesArray } = params\n const validationsAcc: ValidationFields = {}\n for (const node of nodesArray) {\n const nodePointersToValidate = getNodePointersToValidate({ survey, record, node })\n\n for (const nodePointer of nodePointersToValidate) {\n const { nodeCtx, nodeDef } = nodePointer\n // check if validated already\n const validationChildrenCountKey = RecordValidations.getValidationChildrenCountKey({\n nodeParentUuid: nodeCtx.uuid,\n nodeDefChildUuid: nodeDef.uuid,\n })\n if (!(validationChildrenCountKey in validationsAcc)) {\n // validate the children count of this node pointer\n const validationNodePointer = validateNodePointer({ record, nodeCtx, nodeDef })\n validationsAcc[validationChildrenCountKey] = validationNodePointer\n }\n }\n }\n return validationsAcc\n}\n\nconst validateChildrenCountNodes = (params: {\n survey: Survey\n record: ArenaRecord\n nodes: { [key: string]: ArenaRecordNode }\n}): ValidationFields => validateChildrenCountNodesArray({ ...params, nodesArray: Object.values(params.nodes) })\n\nexport const CountValidator = {\n validateChildrenCount,\n validateChildrenCountNodesArray,\n validateChildrenCountNodes,\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/recordValidator.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,iDAAgE;AAChE,8DAA0D;AAC1D,wCAAoC;AACpC,6DAK6B;AAC7B,qDAAiD;AAE1C,MAAM,mBAAmB,GAAG,CAAO,MAAuC,EAAuB,EAAE;IACxG,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAA;IAE7C,yBAAyB;IACzB,MAAM,oBAAoB,GAAG,MAAM,uCAAkB,CAAC,wCAAwC,iCACzF,MAAM,KACT,UAAU,IACV,CAAA;IAEF,4BAA4B;IAC5B,MAAM,oBAAoB,GAAG,+BAAc,CAAC,+BAA+B,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA;IAE3G,uBAAuB;IACvB,OAAO,yBAAW,CAAC,mBAAmB,CACpC,8BAAiB,CAAC,cAAc,CAAC;QAC/B,KAAK,EAAE,IAAI;QACX,MAAM,kCACD,oBAAoB,GACpB,oBAAoB,CACxB;KACF,CAAC,CACH,CAAA;AACH,CAAC,CAAA,CAAA;AAtBY,QAAA,mBAAmB,GAAnB,mBAAmB,CAsB/B;AAEM,MAAM,aAAa,GAAG,CAAO,MAAiC,EAAuB,EAAE,kDAC5F,OAAA,IAAA,QAAA,mBAAmB,kCAAM,MAAM,KAAE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAG,CAAA,CAE7E,CAAC,CAF4E,CAAA;AADhE,QAAA,aAAa,GAAb,aAAa,CACmD;AAEtE,MAAM,cAAc,GAAG,CAAO,MAA6B,EAAuB,EAAE;IACzF,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IACzB,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"recordValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/recordValidator.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,iDAAgE;AAChE,8DAA0D;AAC1D,wCAAoC;AACpC,6DAK6B;AAC7B,qDAAiD;AAE1C,MAAM,mBAAmB,GAAG,CAAO,MAAuC,EAAuB,EAAE;IACxG,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAA;IAE7C,yBAAyB;IACzB,MAAM,oBAAoB,GAAG,MAAM,uCAAkB,CAAC,wCAAwC,iCACzF,MAAM,KACT,UAAU,IACV,CAAA;IAEF,4BAA4B;IAC5B,MAAM,oBAAoB,GAAG,+BAAc,CAAC,+BAA+B,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA;IAE3G,uBAAuB;IACvB,OAAO,yBAAW,CAAC,mBAAmB,CACpC,8BAAiB,CAAC,cAAc,CAAC;QAC/B,KAAK,EAAE,IAAI;QACX,MAAM,kCACD,oBAAoB,GACpB,oBAAoB,CACxB;KACF,CAAC,CACH,CAAA;AACH,CAAC,CAAA,CAAA;AAtBY,QAAA,mBAAmB,GAAnB,mBAAmB,CAsB/B;AAEM,MAAM,aAAa,GAAG,CAAO,MAAiC,EAAuB,EAAE,kDAC5F,OAAA,IAAA,QAAA,mBAAmB,kCAAM,MAAM,KAAE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAG,CAAA,CAE7E,CAAC,CAF4E,CAAA;AADhE,QAAA,aAAa,GAAb,aAAa,CACmD;AAEtE,MAAM,cAAc,GAAG,CAAO,MAA6B,EAAuB,EAAE;IACzF,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IACzB,MAAM,UAAU,GAAsB,EAAE,CAAA;IACxC,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,iBAAO,CAAC,uBAAuB,CAAC;QAC9B,MAAM;QACN,IAAI,EAAE,iBAAO,CAAC,OAAO,CAAC,MAAM,CAAE;QAC9B,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YAChB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACrB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;QACzB,CAAC;KACF,CAAC,CAAA;IAEF,OAAO,IAAA,QAAA,mBAAmB,kCAAM,MAAM,KAAE,UAAU,IAAG,CAAA;AACvD,CAAC,CAAA,CAAA;AAdY,QAAA,cAAc,GAAd,cAAc,CAc1B","sourcesContent":["import { ArenaRecordNode, NodesMap } from '../../node'\nimport { Validation, ValidationFactory } from '../../validation'\nimport { Validations } from '../../validation/validations'\nimport { Records } from '../records'\nimport {\n AttributesValidatorParams,\n AttributeValidator,\n RecordValidatorParams,\n SortedAttributesValidatorParams,\n} from './attributeValidator'\nimport { CountValidator } from './countVaildator'\n\nexport const validateSortedNodes = async (params: SortedAttributesValidatorParams): Promise<Validation> => {\n const { survey, record, nodesArray } = params\n\n // 1. validate attributes\n const attributeValidations = await AttributeValidator.validateSelfAndDependentSortedAttributes({\n ...params,\n nodesArray,\n })\n\n // 2. validate min/max count\n const nodeCountValidations = CountValidator.validateChildrenCountNodesArray({ survey, record, nodesArray })\n\n // 3. merge validations\n return Validations.recalculateValidity(\n ValidationFactory.createInstance({\n valid: true,\n fields: {\n ...attributeValidations,\n ...nodeCountValidations,\n },\n })\n )\n}\n\nexport const validateNodes = async (params: AttributesValidatorParams): Promise<Validation> =>\n validateSortedNodes({ ...params, nodesArray: Object.values(params.nodes) })\n\nexport const validateRecord = async (params: RecordValidatorParams): Promise<Validation> => {\n const { record } = params\n const nodesArray: ArenaRecordNode[] = []\n const nodes: NodesMap = {}\n Records.visitDescendantsAndSelf({\n record,\n node: Records.getRoot(record)!,\n visitor: (node) => {\n nodesArray.push(node)\n nodes[node.uuid] = node\n },\n })\n\n return validateSortedNodes({ ...params, nodesArray })\n}\n"]}
|
package/dist/record/records.d.ts
CHANGED
|
@@ -27,16 +27,16 @@ export declare const Records: {
|
|
|
27
27
|
getAttributeSiblings: typeof getAttributeSiblings;
|
|
28
28
|
getNodeIndex: typeof getNodeIndex;
|
|
29
29
|
isNodeApplicable: (params: {
|
|
30
|
-
record: import("./record").
|
|
31
|
-
node: import("..").
|
|
30
|
+
record: import("./record").ArenaRecord;
|
|
31
|
+
node: import("..").ArenaRecordNode;
|
|
32
32
|
}) => boolean;
|
|
33
33
|
isNodeEditable: (params: {
|
|
34
|
-
record: import("./record").
|
|
35
|
-
node: import("..").
|
|
34
|
+
record: import("./record").ArenaRecord;
|
|
35
|
+
node: import("..").ArenaRecordNode;
|
|
36
36
|
}) => boolean;
|
|
37
37
|
isNodeVisible: (params: {
|
|
38
|
-
record: import("./record").
|
|
39
|
-
node: import("..").
|
|
38
|
+
record: import("./record").ArenaRecord;
|
|
39
|
+
node: import("..").ArenaRecordNode;
|
|
40
40
|
}) => boolean;
|
|
41
41
|
visitAncestorsAndSelf: typeof visitAncestorsAndSelf;
|
|
42
42
|
getAncestorsAndSelf: typeof getAncestorsAndSelf;
|
package/dist/record/service.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { User } from '../auth';
|
|
2
2
|
import { ArenaService } from '../common';
|
|
3
|
-
import {
|
|
3
|
+
import { ArenaRecord } from './record';
|
|
4
4
|
export interface RecordService extends ArenaService {
|
|
5
5
|
create(options: {
|
|
6
6
|
socketId: string;
|
|
7
|
-
record:
|
|
7
|
+
record: ArenaRecord;
|
|
8
8
|
surveyId: number;
|
|
9
9
|
user: User;
|
|
10
|
-
}): Promise<
|
|
10
|
+
}): Promise<ArenaRecord>;
|
|
11
11
|
count(options: {
|
|
12
12
|
cycle: string;
|
|
13
13
|
surveyId: number;
|
|
@@ -15,30 +15,30 @@ export interface RecordService extends ArenaService {
|
|
|
15
15
|
get(options: {
|
|
16
16
|
recordUuid: string;
|
|
17
17
|
surveyId: number;
|
|
18
|
-
}): Promise<
|
|
18
|
+
}): Promise<ArenaRecord>;
|
|
19
19
|
getMany(options: {
|
|
20
20
|
cycle: string;
|
|
21
21
|
limit: number;
|
|
22
22
|
offset: number;
|
|
23
23
|
surveyId: number;
|
|
24
|
-
}): Promise<
|
|
24
|
+
}): Promise<ArenaRecord[]>;
|
|
25
25
|
getManyByUuids(options: {
|
|
26
26
|
surveyId: number;
|
|
27
27
|
uuids: string[];
|
|
28
|
-
}): Promise<
|
|
28
|
+
}): Promise<ArenaRecord[]>;
|
|
29
29
|
update(options: {
|
|
30
30
|
recordUuid: string;
|
|
31
31
|
step: string;
|
|
32
32
|
surveyId: number;
|
|
33
33
|
user: User;
|
|
34
|
-
}): Promise<
|
|
34
|
+
}): Promise<ArenaRecord>;
|
|
35
35
|
checkIn(options: {
|
|
36
36
|
draft?: boolean;
|
|
37
37
|
recordUuid: string;
|
|
38
38
|
socketId: string;
|
|
39
39
|
surveyId: number;
|
|
40
40
|
user: User;
|
|
41
|
-
}): Promise<
|
|
41
|
+
}): Promise<ArenaRecord>;
|
|
42
42
|
checkOut(options: {
|
|
43
43
|
recordUuid: string;
|
|
44
44
|
socketId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/record/service.ts"],"names":[],"mappings":"","sourcesContent":["import { User } from '../auth'\nimport { ArenaService } from '../common'\nimport {
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/record/service.ts"],"names":[],"mappings":"","sourcesContent":["import { User } from '../auth'\nimport { ArenaService } from '../common'\nimport { ArenaRecord } from './record'\n\nexport interface RecordService extends ArenaService {\n // ==== CREATE\n create(options: { socketId: string; record: ArenaRecord; surveyId: number; user: User }): Promise<ArenaRecord>\n\n // ==== READ\n count(options: { cycle: string; surveyId: number }): Promise<number>\n\n get(options: { recordUuid: string; surveyId: number }): Promise<ArenaRecord>\n\n getMany(options: { cycle: string; limit: number; offset: number; surveyId: number }): Promise<ArenaRecord[]>\n\n getManyByUuids(options: { surveyId: number; uuids: string[] }): Promise<ArenaRecord[]>\n\n // ==== UPDATE\n update(options: { recordUuid: string; step: string; surveyId: number; user: User }): Promise<ArenaRecord>\n\n checkIn(options: {\n draft?: boolean\n recordUuid: string\n socketId: string\n surveyId: number\n user: User\n }): Promise<ArenaRecord>\n\n checkOut(options: { recordUuid: string; socketId: string; surveyId: number; user: User }): void\n\n // ==== DELETE\n delete(options: { recordUuid: string; socketId: string; surveyId: number; user: User }): void\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NodeDefMap } from '../nodeDef';
|
|
2
|
-
|
|
2
|
+
import { MutationOptions } from '../utils/mutationOptions';
|
|
3
|
+
type NodeDefsFixParams = MutationOptions & {
|
|
3
4
|
nodeDefs: NodeDefMap;
|
|
4
|
-
sideEffect?: boolean;
|
|
5
5
|
cycles: string[];
|
|
6
6
|
};
|
|
7
7
|
declare const fixNodeDefs: (params: NodeDefsFixParams) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeDefsFixer.js","sourceRoot":"","sources":["../../src/survey/nodeDefsFixer.ts"],"names":[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,CAAA;AACH,CAAC,CAAA;AAEY,QAAA,aAAa,GAAG;IAC3B,WAAW;CACZ,CAAA","sourcesContent":["import { SystemError } from '../error'\nimport { NodeDef, NodeDefEntity, NodeDefMap, NodeDefs } from '../nodeDef'\nimport { NodeDefEntityLayoutChildItem } from '../nodeDef/types/entity'\nimport { Objects } from '../utils'\n\ntype NodeDefsFixParams = {\n nodeDefs: NodeDefMap\n
|
|
1
|
+
{"version":3,"file":"nodeDefsFixer.js","sourceRoot":"","sources":["../../src/survey/nodeDefsFixer.ts"],"names":[],"mappings":";;;AAAA,oCAAsC;AACtC,wCAAyE;AAEzE,oCAAkC;AAsBlC,MAAM,yBAAyB,GAAG,CAAC,MAAuD,EAAY,EAAE;;IACtG,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;IACpC,MAAM,QAAQ,GAAG,EAAE,CAAA;IACnB,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAU,CAAA;IAC7C,IAAI,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAA;IAC1C,OAAO,iBAAiB,EAAE,CAAC;QACzB,IAAI,mBAAmB,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,mBAAW,CAAC,qCAAqC,EAAE;gBAC3D,WAAW,EAAE,MAAA,OAAO,CAAC,KAAK,0CAAE,IAAI;gBAChC,WAAW,EAAE,OAAO,CAAC,IAAI;gBACzB,UAAU,EAAE,iBAAiB;aAC9B,CAAC,CAAA;QACJ,CAAC;QACD,mBAAmB,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;QAC1C,QAAQ,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;QACnC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAA;QACrD,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACvB,MAAM,IAAI,mBAAW,CAAC,wBAAwB,EAAE;gBAC9C,WAAW,EAAE,MAAA,OAAO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G,iCAAM,MAAM,KAAE,KAAK,EAAE,OAAO,EAAE,YAAY,IAAG,CAAA;YACrE,IAAI,YAAY,EAAE,CAAC;gBACjB,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,CAAA;YAC9C,CAAC;YACD,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,OAAO,CAAA;QACxD,CAAC;IACH,CAAC;IACD,OAAO;QACL,QAAQ,EAAE,cAAc;QACxB,eAAe;KAChB,CAAA;AACH,CAAC,CAAA;AAEY,QAAA,aAAa,GAAG;IAC3B,WAAW;CACZ,CAAA","sourcesContent":["import { SystemError } from '../error'\nimport { NodeDef, NodeDefEntity, NodeDefMap, NodeDefs } from '../nodeDef'\nimport { NodeDefEntityLayoutChildItem } from '../nodeDef/types/entity'\nimport { Objects } from '../utils'\nimport { MutationOptions } from '../utils/mutationOptions'\n\ntype NodeDefsFixParams = MutationOptions & {\n nodeDefs: NodeDefMap\n cycles: string[]\n}\n\ntype NodeDefsInCycleFixParams = NodeDefsFixParams & {\n cycle: string\n}\n\ntype NodeDefFixParams = NodeDefsInCycleFixParams & {\n nodeDef: NodeDef<any>\n}\n\ntype LayoutPropFixParams = NodeDefFixParams & {\n propName: string\n}\n\ntype LayoutPropFixerFnParams = LayoutPropFixParams & { propOld: any }\n\nconst calculateNodeDefHierarchy = (params: { nodeDef: NodeDef<any>; nodeDefs: NodeDefMap }): string[] => {\n const { nodeDef, nodeDefs } = params\n const hiearchy = []\n const visitedNodeDefUuids = new Set<string>()\n let currentParentUuid = nodeDef.parentUuid\n while (currentParentUuid) {\n if (visitedNodeDefUuids.has(currentParentUuid)) {\n throw new SystemError('nodeDef.hierarchyCircularDependency', {\n nodeDefName: nodeDef.props?.name,\n nodeDefUuid: nodeDef.uuid,\n parentUuid: currentParentUuid,\n })\n }\n visitedNodeDefUuids.add(currentParentUuid)\n hiearchy.unshift(currentParentUuid)\n const currentParentNode = nodeDefs[currentParentUuid]\n if (!currentParentNode) {\n throw new SystemError('nodeDef.parentNotFound', {\n nodeDefName: nodeDef.props?.name,\n nodeDefUuid: nodeDef.uuid,\n parentUuid: currentParentUuid,\n })\n }\n currentParentUuid = currentParentNode.parentUuid\n }\n return hiearchy\n}\n\nconst fixHiearchy = (params: NodeDefFixParams): NodeDef<any> | null => {\n const { nodeDefs, nodeDef, sideEffect } = params\n const calculatedHierarchy = calculateNodeDefHierarchy({ nodeDefs, nodeDef })\n // compare the whole hierarchy: a node def moved to another parent at the same depth has a hierarchy with the same length\n return Objects.isEqual(calculatedHierarchy, NodeDefs.getMetaHieararchy(nodeDef))\n ? null\n : Objects.assocPath({ obj: nodeDef, path: ['meta', 'h'], value: calculatedHierarchy, sideEffect })\n}\n\nconst fixLayoutProp = (\n params: LayoutPropFixParams & { fixerFn: (params: LayoutPropFixerFnParams) => any }\n): NodeDef<any> | null => {\n const { cycle, nodeDef, propName, sideEffect, fixerFn } = params\n\n const propPath = ['props', 'layout', cycle, propName]\n\n const propOld = Objects.path(propPath)(nodeDef)\n\n if (Objects.isEmpty(propOld)) return null\n\n const propFixed = fixerFn({ ...params, propOld })\n\n if (Objects.isEqual(propOld, propFixed)) return null\n\n return Objects.assocPath({\n obj: nodeDef,\n path: propPath,\n value: propFixed,\n sideEffect,\n })\n}\n\nconst fixIndexChildren = (params: NodeDefFixParams): NodeDef<any> | null =>\n fixLayoutProp({\n ...params,\n propName: 'indexChildren',\n fixerFn: ({ nodeDefs, cycle, propOld: indexChildren }) =>\n (indexChildren as string[]).filter((childDefUuid) => {\n const childDef = nodeDefs[childDefUuid]\n return (\n childDef?.parentUuid === params.nodeDef.uuid &&\n NodeDefs.isEntity(childDef) &&\n NodeDefs.isDisplayInOwnPage(cycle)(childDef as NodeDefEntity)\n )\n }),\n })\n\nconst fixLayoutChildren = (params: NodeDefFixParams): NodeDef<any> | null =>\n fixLayoutProp({\n ...params,\n propName: 'layoutChildren',\n fixerFn: ({ nodeDefs, cycle, propOld: layoutChildren }) =>\n (layoutChildren as NodeDefEntityLayoutChildItem[]).filter((item) => {\n const childDefUuid = typeof item === 'string' ? item : item.i\n const childDef = nodeDefs[childDefUuid]\n return (\n childDef?.parentUuid === params.nodeDef.uuid &&\n (!NodeDefs.isEntity(childDef) || !NodeDefs.isDisplayInOwnPage(cycle)(childDef as NodeDefEntity))\n )\n }),\n })\n\nconst fix = (params: NodeDefFixParams): NodeDef<any> | null => {\n const { nodeDef } = params\n let nodeDefFixed: NodeDef<any> | null = fixHiearchy(params)\n if (NodeDefs.isEntity(nodeDef)) {\n nodeDefFixed = fixIndexChildren({ ...params, nodeDef: nodeDefFixed ?? nodeDef }) ?? nodeDefFixed\n nodeDefFixed = fixLayoutChildren({ ...params, nodeDef: nodeDefFixed ?? nodeDef }) ?? nodeDefFixed\n }\n return nodeDefFixed\n}\n\nconst fixNodeDefs = (params: NodeDefsFixParams): { nodeDefs: NodeDefMap; updatedNodeDefs: NodeDefMap } => {\n const { nodeDefs, cycles } = params\n const nodeDefsResult: NodeDefMap = {}\n const updatedNodeDefs: NodeDefMap = {}\n\n for (const cycle of cycles) {\n for (const nodeDef of Object.values(nodeDefs)) {\n const nodeDefToFix = nodeDefsResult[nodeDef.uuid] ?? nodeDef\n const fixedNodeDef = fix({ ...params, cycle, nodeDef: nodeDefToFix })\n if (fixedNodeDef) {\n updatedNodeDefs[nodeDef.uuid] = fixedNodeDef\n }\n nodeDefsResult[nodeDef.uuid] = fixedNodeDef ?? nodeDef\n }\n }\n return {\n nodeDefs: nodeDefsResult,\n updatedNodeDefs,\n }\n}\n\nexport const NodeDefsFixer = {\n fixNodeDefs,\n}\n"]}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { NodeDef } from '../../../nodeDef';
|
|
2
|
+
import { MutationOptions } from '../../../utils/mutationOptions';
|
|
2
3
|
import { Survey, SurveyNodeDefsIndex } from '../../survey';
|
|
3
4
|
export declare const getNodeDefsIndex: (survey: Survey) => SurveyNodeDefsIndex;
|
|
4
|
-
export declare const addNodeDefToIndex: (nodeDef: NodeDef<any>, options:
|
|
5
|
-
|
|
6
|
-
}) => (survey: Survey) => Survey;
|
|
7
|
-
export declare const updateNodeDefUuidByNameIndex: (nodeDef: NodeDef<any>, nodeDefPrevious?: NodeDef<any>, options?: {
|
|
8
|
-
sideEffect?: boolean;
|
|
9
|
-
}) => (survey: Survey) => Survey;
|
|
5
|
+
export declare const addNodeDefToIndex: (nodeDef: NodeDef<any>, options?: MutationOptions) => (survey: Survey) => Survey;
|
|
6
|
+
export declare const updateNodeDefUuidByNameIndex: (nodeDef: NodeDef<any>, nodeDefPrevious?: NodeDef<any>, options?: MutationOptions) => (survey: Survey) => Survey;
|
|
10
7
|
export declare const deleteNodeDefIndex: (nodeDef: NodeDef<any>) => (survey: Survey) => Survey;
|
|
11
8
|
export declare const buildAndAssocNodeDefsIndex: (survey: Survey) => Survey;
|
|
@@ -22,8 +22,8 @@ const getNodeDefsIndex = (survey) => {
|
|
|
22
22
|
};
|
|
23
23
|
exports.getNodeDefsIndex = getNodeDefsIndex;
|
|
24
24
|
// ==== UPDATE
|
|
25
|
-
const addNodeDefToIndex = (nodeDef, options) => (survey) => {
|
|
26
|
-
const { sideEffect = false } = options
|
|
25
|
+
const addNodeDefToIndex = (nodeDef, options = {}) => (survey) => {
|
|
26
|
+
const { sideEffect = false } = options;
|
|
27
27
|
const { analysis, parentUuid, temporary, uuid } = nodeDef;
|
|
28
28
|
const name = nodeDef_1.NodeDefs.getName(nodeDef);
|
|
29
29
|
let surveyUpdated = utils_1.Objects.assocPath({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeDefsIndex.js","sourceRoot":"","sources":["../../../../src/survey/surveys/_nodeDefs/nodeDefsIndex.ts"],"names":[],"mappings":";;;AAAA,8CAAoD;AACpD,0CAAwC;
|
|
1
|
+
{"version":3,"file":"nodeDefsIndex.js","sourceRoot":"","sources":["../../../../src/survey/surveys/_nodeDefs/nod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","sourcesContent":["import { NodeDef, NodeDefs } from '../../../nodeDef'\nimport { Objects } from '../../../utils'\nimport { MutationOptions } from '../../../utils/mutationOptions'\nimport { Survey, SurveyNodeDefsIndex } from '../../survey'\nimport { getNodeDefsArray } from './nodeDefsReader'\n\nconst keys = {\n nodeDefsIndex: 'nodeDefsIndex',\n}\n\n// keys and values must match: forces every property of SurveyNodeDefsIndex to be present here,\n// and a rename/typo on either side becomes a compile error instead of a silent runtime mismatch.\nconst indexKeys: { [K in keyof SurveyNodeDefsIndex]-?: K } = {\n childDefUuidPresenceByParentUuid: 'childDefUuidPresenceByParentUuid',\n nodeDefUuidByName: 'nodeDefUuidByName',\n qualifierPresenceByUuid: 'qualifierPresenceByUuid',\n rootDefUuid: 'rootDefUuid',\n}\n\n// ==== READ\n\nexport const getNodeDefsIndex = (survey: Survey) => {\n const { nodeDefsIndex } = survey\n return nodeDefsIndex || {}\n}\n\n// ==== UPDATE\n\nexport const addNodeDefToIndex =\n (nodeDef: NodeDef<any>, options: MutationOptions = {}) =>\n (survey: Survey): Survey => {\n const { sideEffect = false } = options\n\n const { analysis, parentUuid, temporary, uuid } = nodeDef\n const name = NodeDefs.getName(nodeDef)\n\n let surveyUpdated: Survey = Objects.assocPath({\n obj: survey,\n path: [keys.nodeDefsIndex, indexKeys.nodeDefUuidByName, name],\n value: nodeDef.uuid,\n sideEffect,\n })\n\n if (parentUuid) {\n surveyUpdated = Objects.assocPath({\n obj: surveyUpdated,\n path: [keys.nodeDefsIndex, indexKeys.childDefUuidPresenceByParentUuid, parentUuid, uuid],\n value: true,\n sideEffect,\n }) as Survey\n } else if (!temporary && !analysis) {\n // nodeDef is root\n surveyUpdated = Objects.assocPath({\n obj: surveyUpdated,\n path: [keys.nodeDefsIndex, indexKeys.rootDefUuid],\n value: uuid,\n sideEffect,\n }) as Survey\n }\n\n if (NodeDefs.isQualifier(nodeDef)) {\n surveyUpdated = Objects.assocPath({\n obj: surveyUpdated,\n path: [keys.nodeDefsIndex, indexKeys.qualifierPresenceByUuid, uuid],\n value: true,\n sideEffect,\n }) as Survey\n }\n return surveyUpdated\n }\n\nexport const updateNodeDefUuidByNameIndex =\n (nodeDef: NodeDef<any>, nodeDefPrevious?: NodeDef<any>, options?: MutationOptions) =>\n (survey: Survey): Survey => {\n const { sideEffect } = options ?? {}\n let surveyUpdated = survey\n const currentName = NodeDefs.getName(nodeDef)\n const previousName = nodeDefPrevious ? NodeDefs.getName(nodeDefPrevious) : ''\n if (currentName !== previousName) {\n surveyUpdated = Objects.dissocPath({\n obj: surveyUpdated,\n path: [keys.nodeDefsIndex, indexKeys.nodeDefUuidByName, previousName],\n sideEffect,\n })\n surveyUpdated = Objects.assocPath({\n obj: surveyUpdated,\n path: [keys.nodeDefsIndex, indexKeys.nodeDefUuidByName, currentName],\n value: nodeDef.uuid,\n sideEffect,\n })\n }\n return surveyUpdated\n }\n\n// ==== DELETE\n\nexport const deleteNodeDefIndex =\n (nodeDef: NodeDef<any>) =>\n (survey: Survey): Survey => {\n const { parentUuid, uuid } = nodeDef\n const name = NodeDefs.getName(nodeDef)\n\n let surveyUpdated: Survey = Objects.dissocPath({\n obj: survey,\n path: [keys.nodeDefsIndex, indexKeys.childDefUuidPresenceByParentUuid, uuid],\n })\n\n surveyUpdated = Objects.dissocPath({\n obj: surveyUpdated,\n path: [keys.nodeDefsIndex, indexKeys.nodeDefUuidByName, name],\n })\n\n if (parentUuid) {\n surveyUpdated = Objects.dissocPath({\n obj: surveyUpdated,\n path: [keys.nodeDefsIndex, indexKeys.childDefUuidPresenceByParentUuid, parentUuid, uuid],\n })\n } else if (survey.nodeDefsIndex?.rootDefUuid === uuid) {\n // node def is root (other node defs without parent, e.g. temporary or analysis ones, are not)\n surveyUpdated = Objects.dissocPath({\n obj: surveyUpdated,\n path: [keys.nodeDefsIndex, indexKeys.rootDefUuid],\n })\n }\n\n if (NodeDefs.isQualifier(nodeDef)) {\n surveyUpdated = Objects.dissocPath({\n obj: surveyUpdated,\n path: [keys.nodeDefsIndex, indexKeys.qualifierPresenceByUuid, uuid],\n })\n }\n return surveyUpdated\n }\n\n// ==== CREATE\n\nexport const buildAndAssocNodeDefsIndex = (survey: Survey): Survey => {\n survey.nodeDefsIndex = {\n childDefUuidPresenceByParentUuid: {},\n qualifierPresenceByUuid: {},\n }\n getNodeDefsArray(survey)\n .sort((nodeDef1: NodeDef<any>, nodeDef2: NodeDef<any>) => (nodeDef1.id ?? 0) - (nodeDef2.id ?? 0))\n .forEach((nodeDef) => addNodeDefToIndex(nodeDef, { sideEffect: true })(survey))\n\n return survey\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ArenaRecordNode } from '../../../node';
|
|
2
|
+
import { ArenaRecord } from '../../../record';
|
|
3
3
|
import { Survey } from '../../../survey';
|
|
4
4
|
import { NodeBuilder } from './nodeBuilder';
|
|
5
5
|
export declare class AttributeBuilder extends NodeBuilder {
|
|
@@ -11,7 +11,7 @@ export declare class AttributeBuilder extends NodeBuilder {
|
|
|
11
11
|
private buildMeta;
|
|
12
12
|
build(params: {
|
|
13
13
|
survey: Survey;
|
|
14
|
-
record:
|
|
15
|
-
parentNode?:
|
|
16
|
-
}):
|
|
14
|
+
record: ArenaRecord;
|
|
15
|
+
parentNode?: ArenaRecordNode;
|
|
16
|
+
}): ArenaRecord;
|
|
17
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributeBuilder.js","sourceRoot":"","sources":["../../../../src/tests/builder/recordBuilder/attributeBuilder.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"attributeBuilder.js","sourceRoot":"","sources":["../../../../src/tests/builder/recordBuilder/attributeBuilder.ts"],"names":[],"mappings":";;;AAAA,wCAA2F;AAE3F,8CAAkF;AAClF,4CAAsD;AACtD,4CAAiD;AACjD,+CAA2C;AAE3C,sBAA8B,SAAQ,yBAAW;IAG/C,YAAY,WAAmB,EAAE,KAA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gBACtD,MAAM,mBAAmB,GAAG,gBAAO,CAAC,sBAAsB,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAA;gBACxG,IAAI,CAAC,mBAAmB;oBAAE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAA;gBACpF,uCAAY,IAAI,KAAE,KAAK,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAE;YACvD,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;IAED,KAAK,CAAC,MAA6E;QACjF,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAA;QAE7C,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;QAE3C,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;QAEzC,MAAM,SAAS,GAAG,kBAAW,CAAC,cAAc,CAAC;YAC3C,WAAW,EAAE,OAAO,CAAC,IAAI;YACzB,UAAU;YACV,UAAU,EAAE,MAAM,CAAC,IAAI;YACvB,KAAK;SACN,CAAC,CAAA;QACF,SAAS,CAAC,IAAI,mCACT,SAAS,CAAC,IAAI,GACd,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CACnD,CAAA;QACD,OAAO,gBAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAA;IAC3C,CAAC;CACF","sourcesContent":["import { ArenaRecordNode, NodeFactory, NodeValueCode, NodeValueTaxon } from '../../../node'\nimport { NodeMeta } from '../../../node/node'\nimport { NodeDef, NodeDefCode, NodeDefTaxon, NodeDefType } from '../../../nodeDef'\nimport { ArenaRecord, Records } from '../../../record'\nimport { Survey, Surveys } from '../../../survey'\nimport { NodeBuilder } from './nodeBuilder'\n\nexport class AttributeBuilder extends NodeBuilder {\n private readonly value: any\n\n constructor(nodeDefName: string, value: any = null) {\n super(nodeDefName)\n this.value = value\n }\n\n private buildCodeValue(params: { survey: Survey; nodeDef: NodeDefCode }) {\n const { survey, nodeDef } = params\n\n if (this.value.itemUuid) {\n // value is already a NodeValueCode object\n return this.value\n }\n\n const code = this.value\n const item = Surveys.getCategoryItemByCodePaths({\n survey,\n categoryUuid: nodeDef.props.categoryUuid,\n codePaths: [code],\n })\n if (!item) {\n throw new Error(`could not find category item with code: ${code}`)\n }\n\n return {\n itemUuid: item.uuid,\n code: item.props.code,\n } as NodeValueCode\n }\n\n private buildTaxonValue(params: { survey: Survey; nodeDef: NodeDefTaxon }) {\n const { survey, nodeDef } = params\n\n if (this.value.taxonUuid) {\n // value is already a NodeValueTaxon object\n return this.value\n }\n const taxonCode = this.value.code || this.value\n const taxonomyUuid = nodeDef.props.taxonomyUuid\n\n const taxon = Surveys.getTaxonByCode({ survey, taxonomyUuid, taxonCode })\n if (!taxon) {\n throw new Error(`could not find taxon with code: ${JSON.stringify(taxonCode)}`)\n }\n\n return {\n taxonUuid: taxon.uuid,\n code: taxon.props.code,\n scientificName: taxon.props.scientificName,\n } as NodeValueTaxon\n }\n\n private buildValue(params: { survey: Survey }) {\n const { survey } = params\n const nodeDef = this.getNodeDef({ survey })\n\n if (this.value === null || this.value === undefined) return null\n\n if (nodeDef.type === NodeDefType.code) {\n return this.buildCodeValue({ survey, nodeDef: nodeDef as NodeDefCode })\n }\n if (nodeDef.type === NodeDefType.taxon) {\n return this.buildTaxonValue({ survey, nodeDef: nodeDef as NodeDefTaxon })\n }\n return this.value\n }\n\n private buildMeta(params: { nodeDef: NodeDef<any>; record: ArenaRecord; parentNode?: ArenaRecordNode }): NodeMeta {\n const { nodeDef, record, parentNode } = params\n\n const meta: NodeMeta = {}\n\n if (nodeDef.type === NodeDefType.code) {\n const nodeDefCode = nodeDef as NodeDefCode\n if (nodeDefCode.props.parentCodeDefUuid && parentNode) {\n const parentCodeAttribute = Records.getParentCodeAttribute({ parentNode, nodeDef: nodeDefCode })(record)\n if (!parentCodeAttribute) throw new Error('Could not find the parent code attibute')\n return { ...meta, hCode: [parentCodeAttribute.uuid] }\n }\n }\n\n return meta\n }\n\n build(params: { survey: Survey; record: ArenaRecord; parentNode?: ArenaRecordNode }): ArenaRecord {\n const { survey, record, parentNode } = params\n\n const nodeDef = this.getNodeDef({ survey })\n\n const value = this.buildValue({ survey })\n\n const attribute = NodeFactory.createInstance({\n nodeDefUuid: nodeDef.uuid,\n parentNode,\n recordUuid: record.uuid,\n value,\n })\n attribute.meta = {\n ...attribute.meta,\n ...this.buildMeta({ nodeDef, parentNode, record }),\n }\n return Records.addNode(attribute)(record)\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ArenaRecordNode } from '../../../node';
|
|
2
|
+
import { ArenaRecord } from '../../../record';
|
|
3
3
|
import { Survey } from '../../../survey';
|
|
4
4
|
import { NodeBuilder } from './nodeBuilder';
|
|
5
5
|
export declare class EntityBuilder extends NodeBuilder {
|
|
@@ -7,7 +7,7 @@ export declare class EntityBuilder extends NodeBuilder {
|
|
|
7
7
|
constructor(nodeDefName: string, ...childBuilders: NodeBuilder[]);
|
|
8
8
|
build(params: {
|
|
9
9
|
survey: Survey;
|
|
10
|
-
record:
|
|
11
|
-
parentNode?:
|
|
12
|
-
}):
|
|
10
|
+
record: ArenaRecord;
|
|
11
|
+
parentNode?: ArenaRecordNode;
|
|
12
|
+
}): ArenaRecord;
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityBuilder.js","sourceRoot":"","sources":["../../../../src/tests/builder/recordBuilder/entityBuilder.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"entityBuilder.js","sourceRoot":"","sources":["../../../../src/tests/builder/recordBuilder/entityBuilder.ts"],"names":[],"mappings":";;;AAAA,wCAA4D;AAC5D,4CAAsD;AAEtD,+CAA2C;AAE3C,mBAA2B,SAAQ,yBAAW;IAG5C,YAAY,WAAmB,EAAE,GAAG,aAA4B;QAC9D,KAAK,CAAC,WAAW,CAAC,CAAA;QAHH,kBAAa,GAAkB,EAAE,CAAA;QAIhD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;IACpC,CAAC;IAED,KAAK,CAAC,MAA6E;QACjF,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAA;QAE7C,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;QAE3C,MAAM,MAAM,GAAG,kBAAW,CAAC,cAAc,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,CAAA;QAE7G,IAAI,aAAa,GAAG,gBAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;QAEnD,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;YAC1C,aAAa,GAAG,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAA;QAC3F,CAAC,CAAC,CAAA;QAEF,OAAO,aAAa,CAAA;IACtB,CAAC;CACF","sourcesContent":["import { ArenaRecordNode, NodeFactory } from '../../../node'\nimport { ArenaRecord, Records } from '../../../record'\nimport { Survey } from '../../../survey'\nimport { NodeBuilder } from './nodeBuilder'\n\nexport class EntityBuilder extends NodeBuilder {\n private readonly childBuilders: NodeBuilder[] = []\n\n constructor(nodeDefName: string, ...childBuilders: NodeBuilder[]) {\n super(nodeDefName)\n this.childBuilders = childBuilders\n }\n\n build(params: { survey: Survey; record: ArenaRecord; parentNode?: ArenaRecordNode }): ArenaRecord {\n const { survey, record, parentNode } = params\n\n const nodeDef = this.getNodeDef({ survey })\n\n const entity = NodeFactory.createInstance({ nodeDefUuid: nodeDef.uuid, recordUuid: record.uuid, parentNode })\n\n let recordUpdated = Records.addNode(entity)(record)\n\n this.childBuilders.forEach((childBuilder) => {\n recordUpdated = childBuilder.build({ survey, record: recordUpdated, parentNode: entity })\n })\n\n return recordUpdated\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArenaRecordNode } from '../../../node';
|
|
2
2
|
import { NodeDef, NodeDefProps, NodeDefType } from '../../../nodeDef';
|
|
3
|
-
import {
|
|
3
|
+
import { ArenaRecord } from '../../../record';
|
|
4
4
|
import { Survey } from '../../../survey';
|
|
5
5
|
export declare abstract class NodeBuilder {
|
|
6
6
|
protected nodeDefName: string;
|
|
@@ -10,7 +10,7 @@ export declare abstract class NodeBuilder {
|
|
|
10
10
|
}): NodeDef<NodeDefType, NodeDefProps>;
|
|
11
11
|
abstract build(params: {
|
|
12
12
|
survey: Survey;
|
|
13
|
-
record:
|
|
14
|
-
parentNode?:
|
|
15
|
-
}):
|
|
13
|
+
record: ArenaRecord;
|
|
14
|
+
parentNode?: ArenaRecordNode;
|
|
15
|
+
}): ArenaRecord;
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeBuilder.js","sourceRoot":"","sources":["../../../../src/tests/builder/recordBuilder/nodeBuilder.ts"],"names":[],"mappings":";;;AAKA;IAGE,YAAY,WAAmB;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAES,UAAU,CAAC,MAA0B;;QAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,OAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,mCAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,WAAW,CAAC,CAAA;QAE1G,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,CAAC,WAAW,sBAAsB,CAAC,CAAA;QAC/E,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CAGF","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"nodeBuilder.js","sourceRoot":"","sources":["../../../../src/tests/builder/recordBuilder/nodeBuilder.ts"],"names":[],"mappings":";;;AAKA;IAGE,YAAY,WAAmB;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAES,UAAU,CAAC,MAA0B;;QAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,OAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,mCAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,WAAW,CAAC,CAAA;QAE1G,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,CAAC,WAAW,sBAAsB,CAAC,CAAA;QAC/E,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CAGF","sourcesContent":["import { ArenaRecordNode } from '../../../node'\nimport { NodeDef, NodeDefProps, NodeDefType } from '../../../nodeDef'\nimport { ArenaRecord } from '../../../record'\nimport { Survey } from '../../../survey'\n\nexport abstract class NodeBuilder {\n protected nodeDefName: string\n\n constructor(nodeDefName: string) {\n this.nodeDefName = nodeDefName\n }\n\n protected getNodeDef(params: { survey: Survey }): NodeDef<NodeDefType, NodeDefProps> {\n const nodeDef = Object.values(params.survey.nodeDefs ?? {}).find((n) => n.props.name === this.nodeDefName)\n\n if (!nodeDef) {\n throw new Error(`Node def with name ${this.nodeDefName} not found in survey`)\n }\n\n return nodeDef\n }\n\n abstract build(params: { survey: Survey; record: ArenaRecord; parentNode?: ArenaRecordNode }): ArenaRecord\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArenaRecord } from '../../../record';
|
|
2
2
|
import { User } from '../../../auth';
|
|
3
3
|
import { Survey } from '../../../survey';
|
|
4
4
|
import { EntityBuilder } from './entityBuilder';
|
|
@@ -7,5 +7,5 @@ export declare class RecordBuilder {
|
|
|
7
7
|
private readonly user;
|
|
8
8
|
private readonly rootEntityBuilder;
|
|
9
9
|
constructor(user: User, survey: Survey, rootEntityBuilder: EntityBuilder);
|
|
10
|
-
build():
|
|
10
|
+
build(): ArenaRecord;
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordBuilder.js","sourceRoot":"","sources":["../../../../src/tests/builder/recordBuilder/recordBuilder.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"recordBuilder.js","sourceRoot":"","sources":["../../../../src/tests/builder/recordBuilder/recordBuilder.ts"],"names":[],"mappings":";;;AAAA,4CAA4D;AAK5D;IAKE,YAAY,IAAU,EAAE,MAAc,EAAE,iBAAgC;QACtE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;IAC5C,CAAC;IAED,KAAK;QACH,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;QAC7B,MAAM,MAAM,GAAG,sBAAa,CAAC,cAAc,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QAC9E,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IACzD,CAAC;CACF","sourcesContent":["import { ArenaRecord, RecordFactory } from '../../../record'\nimport { User } from '../../../auth'\nimport { Survey } from '../../../survey'\nimport { EntityBuilder } from './entityBuilder'\n\nexport class RecordBuilder {\n private readonly survey: Survey\n private readonly user: User\n private readonly rootEntityBuilder: EntityBuilder\n\n constructor(user: User, survey: Survey, rootEntityBuilder: EntityBuilder) {\n this.survey = survey\n this.user = user\n this.rootEntityBuilder = rootEntityBuilder\n }\n\n build(): ArenaRecord {\n const { survey, user } = this\n const record = RecordFactory.createInstance({ surveyUuid: survey.uuid, user })\n return this.rootEntityBuilder.build({ survey, record })\n }\n}\n"]}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { Arrays } from './arrays';
|
|
|
2
2
|
export { Dates, DateFormats, UnitOfTime } from './dates';
|
|
3
3
|
export { FileNames } from './fileNames';
|
|
4
4
|
export { FileProcessor } from './fileProcessor';
|
|
5
|
+
export type { MutationOptions } from './mutationOptions';
|
|
5
6
|
export type { FileProcessorConstructorArgs } from './fileProcessor';
|
|
6
7
|
export { Numbers } from './numbers';
|
|
7
8
|
export { Objects } from './_objects';
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AAAxB,gGAAA,MAAM,OAAA;AACf,iCAAwD;AAA/C,8FAAA,KAAK,OAAA;AAAE,oGAAA,WAAW,OAAA;AAAE,mGAAA,UAAU,OAAA;AACvC,yCAAuC;AAA9B,sGAAA,SAAS,OAAA;AAClB,iDAA+C;AAAtC,8GAAA,aAAa,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AAAxB,gGAAA,MAAM,OAAA;AACf,iCAAwD;AAA/C,8FAAA,KAAK,OAAA;AAAE,oGAAA,WAAW,OAAA;AAAE,mGAAA,UAAU,OAAA;AACvC,yCAAuC;AAA9B,sGAAA,SAAS,OAAA;AAClB,iDAA+C;AAAtC,8GAAA,aAAa,OAAA;AAGtB,qCAAmC;AAA1B,kGAAA,OAAO,OAAA;AAChB,uCAAoC;AAA3B,mGAAA,OAAO,OAAA;AAChB,uCAAqC;AAA5B,oGAAA,QAAQ,OAAA;AACjB,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,mDAAiD;AAAxC,gHAAA,cAAc,OAAA;AACvB,qCAAmC;AAA1B,kGAAA,OAAO,OAAA;AAChB,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,uCAAqC;AAA5B,oGAAA,QAAQ,OAAA","sourcesContent":["export { Arrays } from './arrays'\nexport { Dates, DateFormats, UnitOfTime } from './dates'\nexport { FileNames } from './fileNames'\nexport { FileProcessor } from './fileProcessor'\nexport type { MutationOptions } from './mutationOptions'\nexport type { FileProcessorConstructorArgs } from './fileProcessor'\nexport { Numbers } from './numbers'\nexport { Objects } from './_objects'\nexport { Promises } from './promises'\nexport { Queue } from './queue'\nexport { RetryProcessor } from './retryProcessor'\nexport { Strings } from './strings'\nexport { UUIDs } from './uuids'\nexport { Versions } from './versions'\nexport type { ParsedVersion } from './versions'\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options of the functions that return an updated version of the objects passed to them.
|
|
3
|
+
*/
|
|
4
|
+
export interface MutationOptions {
|
|
5
|
+
/**
|
|
6
|
+
* When true, the passed objects are modified in place instead of being copied: faster, but to be used only
|
|
7
|
+
* on objects not shared with other code (e.g. objects just created). Default: false.
|
|
8
|
+
*/
|
|
9
|
+
sideEffect?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Converts the (deprecated) positional sideEffect boolean parameter into MutationOptions.
|
|
13
|
+
*/
|
|
14
|
+
export declare const toMutationOptions: (options?: MutationOptions | boolean) => MutationOptions;
|