@openforis/arena-core 2.4.3 → 2.4.5

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.
Files changed (40) hide show
  1. package/dist/error/SystemError.d.ts +8 -1
  2. package/dist/error/SystemError.js +7 -2
  3. package/dist/error/SystemError.js.map +1 -1
  4. package/dist/esm/error/SystemError.js +7 -2
  5. package/dist/esm/error/SystemError.js.map +1 -1
  6. package/dist/esm/nodeDef/nodeDefs.js +4 -4
  7. package/dist/esm/nodeDef/nodeDefs.js.map +1 -1
  8. package/dist/esm/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js +1 -1
  9. package/dist/esm/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
  10. package/dist/esm/record/recordUpdater.js +1 -1
  11. package/dist/esm/record/recordUpdater.js.map +1 -1
  12. package/dist/esm/record/recordValidator/{countVaildator.js → countValidator.js} +1 -1
  13. package/dist/esm/record/recordValidator/{countVaildator.js.map → countValidator.js.map} +1 -1
  14. package/dist/esm/record/recordValidator/recordValidator.js +1 -1
  15. package/dist/esm/record/recordValidator/recordValidator.js.map +1 -1
  16. package/dist/esm/survey/nodeDefsFixer.js +6 -6
  17. package/dist/esm/survey/nodeDefsFixer.js.map +1 -1
  18. package/dist/esm/survey/surveys/dependencies.js +3 -3
  19. package/dist/esm/survey/surveys/dependencies.js.map +1 -1
  20. package/dist/esm/survey/surveys/nodeDefs.js +1 -1
  21. package/dist/esm/survey/surveys/nodeDefs.js.map +1 -1
  22. package/dist/nodeDef/nodeDefs.d.ts +4 -4
  23. package/dist/nodeDef/nodeDefs.js +4 -4
  24. package/dist/nodeDef/nodeDefs.js.map +1 -1
  25. package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js +1 -1
  26. package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
  27. package/dist/record/recordUpdater.js +1 -1
  28. package/dist/record/recordUpdater.js.map +1 -1
  29. package/dist/record/recordValidator/{countVaildator.js → countValidator.js} +1 -1
  30. package/dist/record/recordValidator/{countVaildator.js.map → countValidator.js.map} +1 -1
  31. package/dist/record/recordValidator/recordValidator.js +2 -2
  32. package/dist/record/recordValidator/recordValidator.js.map +1 -1
  33. package/dist/survey/nodeDefsFixer.js +6 -6
  34. package/dist/survey/nodeDefsFixer.js.map +1 -1
  35. package/dist/survey/surveys/dependencies.js +3 -3
  36. package/dist/survey/surveys/dependencies.js.map +1 -1
  37. package/dist/survey/surveys/nodeDefs.js +1 -1
  38. package/dist/survey/surveys/nodeDefs.js.map +1 -1
  39. package/package.json +1 -1
  40. /package/dist/record/recordValidator/{countVaildator.d.ts → countValidator.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"recordUpdater.js","sourceRoot":"","sources":["../../src/record/recordUpdater.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,oCAAsC;AAEtC,sCAAiE;AACjE,oCAAyC;AACzC,2DAAuD;AACvD,iDAA6C;AAE7C,6DAA6E;AAE7E,uCAAmC;AACnC,uDAAmD;AAEnD,MAAM,yBAAyB,GAAG;IAChC,6BAAoB,CAAC,WAAW;IAChC,6BAAoB,CAAC,QAAQ;IAC7B,6BAAoB,CAAC,QAAQ;CAC9B,CAAA;AAED,MAAM,kCAAkC,GAAG,CAAC,MAI3C,EAAiB,EAAE;IAClB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IACxC,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAuB,CAAA;IAC1D,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACxC,KAAK,MAAM,cAAc,IAAI,yBAAyB,EAAE,CAAC;YACvD,MAAM,YAAY,GAAG,iBAAO,CAAC,wBAAwB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC,MAAM,CAAC,CAAA;YAC/F,KAAK,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,MAEC,EAC4B,EAAE;IAC/B,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,MAAM,CAAA;IAEjE,MAAM,YAAY,GAAG,iBAAO,CAAC,WAAW,CAAC,SAAS,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,CAAA;IAC5E,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,YAAY,CAAA;IAE7C,MAAM,MAAM,GAAG,MAAM,4BAA4B,iCAAM,MAAM,KAAE,MAAM,EAAE,KAAK,EAAE,YAAY,IAAG,CAAA;IAC7F,MAAM,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,OAAO,MAAM,CAAA;AACf,CAAC,CAAA,CAAA;AAED,MAAM,UAAU,GAAG,CAAO,MAAgD,EAA+B,EAAE;IACzG,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;IAC3B,OAAO,WAAW,iCAAM,MAAM,KAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,IAAG,CAAA;AAC1D,CAAC,CAAA,CAAA;AAEY,QAAA,aAAa,GAAG;IAC3B,iBAAiB;IACjB,wBAAwB;IACxB,gBAAgB;IAChB,oBAAoB;IACpB,UAAU;IACV,WAAW;CACZ,CAAA","sourcesContent":["import { Dictionary } from '../common'\nimport { SystemError } from '../error'\nimport { ArenaRecordNode, NodePointer, NodesMap } from '../node'\nimport { Survey, SurveyDependencyType, Surveys } from '../survey'\nimport { Dates, Objects } from '../utils'\nimport { Validations } from '../validation/validations'\nimport { NodePointers } from './nodePointers'\nimport { ArenaRecord } from './record'\nimport { RecordNodesUpdater, RecordUpdateResult } from './recordNodesUpdater'\nimport { NodeCreateParams, NodesUpdateParams } from './recordNodesUpdater/recordNodesCreator'\nimport { Records } from './records'\nimport { RecordValidator } from './recordValidator'\n\nconst validationDependencyTypes = [\n SurveyDependencyType.validations,\n SurveyDependencyType.minCount,\n SurveyDependencyType.maxCount,\n]\n\nconst getDependentValidationNodePointers = (params: {\n survey: Survey\n record: ArenaRecord\n nodes: NodesMap\n}): NodePointer[] => {\n const { survey, record, nodes } = params\n const uniquePointersByKey = new Map<string, NodePointer>()\n for (const node of Object.values(nodes)) {\n for (const dependencyType of validationDependencyTypes) {\n const nodePointers = Records.getDependentNodePointers({ survey, node, dependencyType })(record)\n for (const pointer of nodePointers) {\n const nodeCtxUuid = pointer.nodeCtx.uuid\n const nodeDefUuid = pointer.nodeDef.uuid\n const key = `${nodeCtxUuid ?? ''}:${nodeDefUuid ?? ''}`\n if (!uniquePointersByKey.has(key)) {\n uniquePointersByKey.set(key, pointer)\n }\n }\n }\n }\n return Array.from(uniquePointersByKey.values())\n}\n\nconst _onRecordNodesCreateOrUpdate = async (\n params: NodesUpdateParams & { nodes: Dictionary<ArenaRecordNode> }\n): Promise<RecordUpdateResult> => {\n const { user, survey, dateModified = Dates.nowFormattedForStorage() } = params\n\n const updateResult = await RecordNodesUpdater.updateNodesDependents(params)\n const { nodes: updatedNodes, record: updatedRecord } = updateResult\n\n const dependentValidationNodePointers = getDependentValidationNodePointers({\n survey,\n record: updatedRecord,\n nodes: updatedNodes,\n })\n\n const dependentValidationNodes = NodePointers.getNodesMapFromNodePointers({\n record: updatedRecord,\n nodePointers: dependentValidationNodePointers,\n })\n\n const nodesToValidate = { ...updatedNodes, ...dependentValidationNodes }\n\n const validationUpdatedNodes = await RecordValidator.validateNodes({\n user,\n survey,\n record: updatedRecord,\n nodes: nodesToValidate,\n })\n\n const validation = Validations.mergeValidations(validationUpdatedNodes)(Validations.getValidation(updatedRecord))\n updatedRecord.validation = validation\n updatedRecord.dateModified = dateModified\n\n updateResult.validation = validation\n\n return updateResult\n}\n\nconst createDescendants = async (params: NodeCreateParams): Promise<RecordUpdateResult> => {\n const { record: updatedRecord, nodes: createdNodes } = await RecordNodesUpdater.createDescendants(params)\n\n return _onRecordNodesCreateOrUpdate({ ...params, record: updatedRecord, nodes: createdNodes })\n}\n\nconst _createNodeAndDescendants = async (params: NodeCreateParams): Promise<RecordUpdateResult> => {\n const { record: updatedRecord, nodes: createdNodes } = await RecordNodesUpdater.createNodeAndDescendants(params)\n\n return _onRecordNodesCreateOrUpdate({ ...params, record: updatedRecord, nodes: createdNodes })\n}\n\nconst createNodeAndDescendants = async (params: NodeCreateParams): Promise<RecordUpdateResult> =>\n _createNodeAndDescendants(params)\n\nconst createRootEntity = async (\n params: NodesUpdateParams & {\n createMultipleEntities?: boolean\n }\n): Promise<RecordUpdateResult> => {\n const { survey, createMultipleEntities = true } = params\n\n return _createNodeAndDescendants({ ...params, nodeDef: Surveys.getNodeDefRoot({ survey }), createMultipleEntities })\n}\n\nconst updateAttributeValue = async (\n params: NodesUpdateParams & {\n attributeUuid: string\n value: any\n }\n): Promise<RecordUpdateResult> => {\n const { attributeUuid, record, value, dateModified = Dates.nowFormattedForStorage(), sideEffect = false } = params\n const attribute = Records.getNodeByUuid({ uuid: attributeUuid })(record)\n if (!attribute) throw new SystemError('record.nodeNotFound')\n\n let attributeUpdated = sideEffect ? attribute : { ...attribute }\n attributeUpdated.value = value\n attributeUpdated.dateModified = dateModified\n // reset defaultValueApplied flag\n attributeUpdated = Objects.dissocPath({ obj: attributeUpdated, path: ['meta', 'defaultValueApplied'], sideEffect })\n\n const nodesUpdated = { [attributeUuid]: attributeUpdated }\n\n const _record = Records.addNode(attributeUpdated, { sideEffect })(record)\n\n return _onRecordNodesCreateOrUpdate({ ...params, record: _record, nodes: nodesUpdated })\n}\n\nconst deleteNodes = async (\n params: NodesUpdateParams & {\n nodeUuids: string[]\n }\n): Promise<RecordUpdateResult> => {\n const { nodeUuids, record: _record, sideEffect = false } = params\n\n const updateResult = Records.deleteNodes(nodeUuids, { sideEffect })(_record)\n const { record, nodesDeleted } = updateResult\n\n const result = await _onRecordNodesCreateOrUpdate({ ...params, record, nodes: nodesDeleted })\n result.nodesDeleted = nodesDeleted\n return result\n}\n\nconst deleteNode = async (params: NodesUpdateParams & { nodeUuid: string }): Promise<RecordUpdateResult> => {\n const { nodeUuid } = params\n return deleteNodes({ ...params, nodeUuids: [nodeUuid] })\n}\n\nexport const RecordUpdater = {\n createDescendants,\n createNodeAndDescendants,\n createRootEntity,\n updateAttributeValue,\n deleteNode,\n deleteNodes,\n}\n"]}
1
+ {"version":3,"file":"recordUpdater.js","sourceRoot":"","sources":["../../src/record/recordUpdater.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,oCAAsC;AAEtC,sCAAiE;AACjE,oCAAyC;AACzC,2DAAuD;AACvD,iDAA6C;AAE7C,6DAA6E;AAE7E,uCAAmC;AACnC,uDAAmD;AAEnD,MAAM,yBAAyB,GAAG;IAChC,6BAAoB,CAAC,WAAW;IAChC,6BAAoB,CAAC,QAAQ;IAC7B,6BAAoB,CAAC,QAAQ;CAC9B,CAAA;AAED,MAAM,kCAAkC,GAAG,CAAC,MAI3C,EAAiB,EAAE;IAClB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IACxC,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAuB,CAAA;IAC1D,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACxC,KAAK,MAAM,cAAc,IAAI,yBAAyB,EAAE,CAAC;YACvD,MAAM,YAAY,GAAG,iBAAO,CAAC,wBAAwB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC,MAAM,CAAC,CAAA;YAC/F,KAAK,MAAM,OAAO,IAAI,YAAY,EAAE,CAAC;gBACnC,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAA;gBACxC,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAA;gBACxC,MAAM,GAAG,GAAG,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE,IAAI,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE,EA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MAAM,EAAE,YAAY,EAAE,GAAG,YAAY,CAAA;IAE7C,MAAM,MAAM,GAAG,MAAM,4BAA4B,iCAAM,MAAM,KAAE,MAAM,EAAE,KAAK,EAAE,YAAY,IAAG,CAAA;IAC7F,MAAM,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,OAAO,MAAM,CAAA;AACf,CAAC,CAAA,CAAA;AAED,MAAM,UAAU,GAAG,CAAO,MAAgD,EAA+B,EAAE;IACzG,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;IAC3B,OAAO,WAAW,iCAAM,MAAM,KAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,IAAG,CAAA;AAC1D,CAAC,CAAA,CAAA;AAEY,QAAA,aAAa,GAAG;IAC3B,iBAAiB;IACjB,wBAAwB;IACxB,gBAAgB;IAChB,oBAAoB;IACpB,UAAU;IACV,WAAW;CACZ,CAAA","sourcesContent":["import { Dictionary } from '../common'\nimport { SystemError } from '../error'\nimport { ArenaRecordNode, NodePointer, NodesMap } from '../node'\nimport { Survey, SurveyDependencyType, Surveys } from '../survey'\nimport { Dates, Objects } from '../utils'\nimport { Validations } from '../validation/validations'\nimport { NodePointers } from './nodePointers'\nimport { ArenaRecord } from './record'\nimport { RecordNodesUpdater, RecordUpdateResult } from './recordNodesUpdater'\nimport { NodeCreateParams, NodesUpdateParams } from './recordNodesUpdater/recordNodesCreator'\nimport { Records } from './records'\nimport { RecordValidator } from './recordValidator'\n\nconst validationDependencyTypes = [\n SurveyDependencyType.validations,\n SurveyDependencyType.minCount,\n SurveyDependencyType.maxCount,\n]\n\nconst getDependentValidationNodePointers = (params: {\n survey: Survey\n record: ArenaRecord\n nodes: NodesMap\n}): NodePointer[] => {\n const { survey, record, nodes } = params\n const uniquePointersByKey = new Map<string, NodePointer>()\n for (const node of Object.values(nodes)) {\n for (const dependencyType of validationDependencyTypes) {\n const nodePointers = Records.getDependentNodePointers({ survey, node, dependencyType })(record)\n for (const pointer of nodePointers) {\n const nodeCtxUuid = pointer.nodeCtx.uuid\n const nodeDefUuid = pointer.nodeDef.uuid\n const key = `${nodeCtxUuid ?? ''}:${nodeDefUuid ?? ''}`\n if (!uniquePointersByKey.has(key)) {\n uniquePointersByKey.set(key, pointer)\n }\n }\n }\n }\n return Array.from(uniquePointersByKey.values())\n}\n\nconst _onRecordNodesCreateOrUpdate = async (\n params: NodesUpdateParams & { nodes: Dictionary<ArenaRecordNode> }\n): Promise<RecordUpdateResult> => {\n const { user, survey, dateModified = Dates.nowFormattedForStorage() } = params\n\n const updateResult = await RecordNodesUpdater.updateNodesDependents(params)\n const { nodes: updatedNodes, record: updatedRecord } = updateResult\n\n const dependentValidationNodePointers = getDependentValidationNodePointers({\n survey,\n record: updatedRecord,\n nodes: updatedNodes,\n })\n\n const dependentValidationNodes = NodePointers.getNodesMapFromNodePointers({\n record: updatedRecord,\n nodePointers: dependentValidationNodePointers,\n })\n\n const nodesToValidate = { ...updatedNodes, ...dependentValidationNodes }\n\n const validationUpdatedNodes = await RecordValidator.validateNodes({\n user,\n survey,\n record: updatedRecord,\n nodes: nodesToValidate,\n })\n\n const validation = Validations.mergeValidations(validationUpdatedNodes)(Validations.getValidation(updatedRecord))\n updatedRecord.validation = validation\n updatedRecord.dateModified = dateModified\n\n updateResult.validation = validation\n\n return updateResult\n}\n\nconst createDescendants = async (params: NodeCreateParams): Promise<RecordUpdateResult> => {\n const { record: updatedRecord, nodes: createdNodes } = await RecordNodesUpdater.createDescendants(params)\n\n return _onRecordNodesCreateOrUpdate({ ...params, record: updatedRecord, nodes: createdNodes })\n}\n\nconst _createNodeAndDescendants = async (params: NodeCreateParams): Promise<RecordUpdateResult> => {\n const { record: updatedRecord, nodes: createdNodes } = await RecordNodesUpdater.createNodeAndDescendants(params)\n\n return _onRecordNodesCreateOrUpdate({ ...params, record: updatedRecord, nodes: createdNodes })\n}\n\nconst createNodeAndDescendants = async (params: NodeCreateParams): Promise<RecordUpdateResult> =>\n _createNodeAndDescendants(params)\n\nconst createRootEntity = async (\n params: NodesUpdateParams & {\n createMultipleEntities?: boolean\n }\n): Promise<RecordUpdateResult> => {\n const { survey, createMultipleEntities = true } = params\n\n return _createNodeAndDescendants({ ...params, nodeDef: Surveys.getNodeDefRoot({ survey }), createMultipleEntities })\n}\n\nconst updateAttributeValue = async (\n params: NodesUpdateParams & {\n attributeUuid: string\n value: any\n }\n): Promise<RecordUpdateResult> => {\n const { attributeUuid, record, value, dateModified = Dates.nowFormattedForStorage(), sideEffect = false } = params\n const attribute = Records.getNodeByUuid({ uuid: attributeUuid })(record)\n if (!attribute) throw new SystemError('record.nodeNotFound', { uuid: attributeUuid })\n\n let attributeUpdated = sideEffect ? attribute : { ...attribute }\n attributeUpdated.value = value\n attributeUpdated.dateModified = dateModified\n // reset defaultValueApplied flag\n attributeUpdated = Objects.dissocPath({ obj: attributeUpdated, path: ['meta', 'defaultValueApplied'], sideEffect })\n\n const nodesUpdated = { [attributeUuid]: attributeUpdated }\n\n const _record = Records.addNode(attributeUpdated, { sideEffect })(record)\n\n return _onRecordNodesCreateOrUpdate({ ...params, record: _record, nodes: nodesUpdated })\n}\n\nconst deleteNodes = async (\n params: NodesUpdateParams & {\n nodeUuids: string[]\n }\n): Promise<RecordUpdateResult> => {\n const { nodeUuids, record: _record, sideEffect = false } = params\n\n const updateResult = Records.deleteNodes(nodeUuids, { sideEffect })(_record)\n const { record, nodesDeleted } = updateResult\n\n const result = await _onRecordNodesCreateOrUpdate({ ...params, record, nodes: nodesDeleted })\n result.nodesDeleted = nodesDeleted\n return result\n}\n\nconst deleteNode = async (params: NodesUpdateParams & { nodeUuid: string }): Promise<RecordUpdateResult> => {\n const { nodeUuid } = params\n return deleteNodes({ ...params, nodeUuids: [nodeUuid] })\n}\n\nexport const RecordUpdater = {\n createDescendants,\n createNodeAndDescendants,\n createRootEntity,\n updateAttributeValue,\n deleteNode,\n deleteNodes,\n}\n"]}
@@ -116,4 +116,4 @@ exports.CountValidator = {
116
116
  validateChildrenCountNodesArray,
117
117
  validateChildrenCountNodes,
118
118
  };
119
- //# sourceMappingURL=countVaildator.js.map
119
+ //# sourceMappingURL=countValidator.js.map
@@ -1 +1 @@
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,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,MAI9B,EAAc,EAAE;IACf,MAAM,E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,mBAAmB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAA;gBAC/E,cAAc,CAAC,0BAA0B,CAAC,GAAG,qBAAqB,CAAA;YACpE,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,cAAc,CAAA;AACvB,CAAC,CAAA;AAED,MAAM,0BAA0B,GAAG,CAAC,MAInC,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 { 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, childDefUuid: 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
+ {"version":3,"file":"countValidator.js","sourceRoot":"","sources":["../../../src/record/recordValidator/countValidator.ts"],"names":[],"mappings":";;;AAAA,qCAAgE;AAChE,2CAA4E;AAC5E,wCAAoC;AACpC,iDAA6G;AAE7G,yCAA8C;AAC9C,4DAAwD;AAGxD,MAAM,sBAAsB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,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 { 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, childDefUuid: 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"]}
@@ -14,13 +14,13 @@ const validation_1 = require("../../validation");
14
14
  const validations_1 = require("../../validation/validations");
15
15
  const records_1 = require("../records");
16
16
  const attributeValidator_1 = require("./attributeValidator");
17
- const countVaildator_1 = require("./countVaildator");
17
+ const countValidator_1 = require("./countValidator");
18
18
  const validateSortedNodes = (params) => __awaiter(void 0, void 0, void 0, function* () {
19
19
  const { survey, record, nodesArray } = params;
20
20
  // 1. validate attributes
21
21
  const attributeValidations = yield attributeValidator_1.AttributeValidator.validateSelfAndDependentSortedAttributes(Object.assign(Object.assign({}, params), { nodesArray }));
22
22
  // 2. validate min/max count
23
- const nodeCountValidations = countVaildator_1.CountValidator.validateChildrenCountNodesArray({ survey, record, nodesArray });
23
+ const nodeCountValidations = countValidator_1.CountValidator.validateChildrenCountNodesArray({ survey, record, nodesArray });
24
24
  // 3. merge validations
25
25
  return validations_1.Validations.recalculateValidity(validation_1.ValidationFactory.createInstance({
26
26
  valid: true,
@@ -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,GAAsB,EAAE,CAAA;IACxC,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,iBAAO,CAAC,uBAAuB,CAAC;QAC9B,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,CAAC,MAAM,CAAC,CAAA;IAEV,OAAO,IAAA,QAAA,mBAAmB,kCAAM,MAAM,KAAE,UAAU,IAAG,CAAA;AACvD,CAAC,CAAA,CAAA;AAbY,QAAA,cAAc,GAAd,cAAc,CAa1B","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 node: Records.getRoot(record)!,\n visitor: (node) => {\n nodesArray.push(node)\n nodes[node.uuid] = node\n },\n })(record)\n\n return validateSortedNodes({ ...params, nodesArray })\n}\n"]}
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,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,CAAC,MAAM,CAAC,CAAA;IAEV,OAAO,IAAA,QAAA,mBAAmB,kCAAM,MAAM,KAAE,UAAU,IAAG,CAAA;AACvD,CAAC,CAAA,CAAA;AAbY,QAAA,cAAc,GAAd,cAAc,CAa1B","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 './countValidator'\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 node: Records.getRoot(record)!,\n visitor: (node) => {\n nodesArray.push(node)\n nodes[node.uuid] = node\n },\n })(record)\n\n return validateSortedNodes({ ...params, nodesArray })\n}\n"]}
@@ -7,7 +7,7 @@ const utils_1 = require("../utils");
7
7
  const calculateNodeDefHierarchy = (params) => {
8
8
  var _a, _b;
9
9
  const { nodeDef, nodeDefs } = params;
10
- const hiearchy = [];
10
+ const hierarchy = [];
11
11
  const visitedNodeDefUuids = new Set();
12
12
  let currentParentUuid = nodeDef.parentUuid;
13
13
  while (currentParentUuid) {
@@ -19,7 +19,7 @@ const calculateNodeDefHierarchy = (params) => {
19
19
  });
20
20
  }
21
21
  visitedNodeDefUuids.add(currentParentUuid);
22
- hiearchy.unshift(currentParentUuid);
22
+ hierarchy.unshift(currentParentUuid);
23
23
  const currentParentNode = nodeDefs[currentParentUuid];
24
24
  if (!currentParentNode) {
25
25
  throw new error_1.SystemError('nodeDef.parentNotFound', {
@@ -30,13 +30,13 @@ const calculateNodeDefHierarchy = (params) => {
30
30
  }
31
31
  currentParentUuid = currentParentNode.parentUuid;
32
32
  }
33
- return hiearchy;
33
+ return hierarchy;
34
34
  };
35
- const fixHiearchy = (params) => {
35
+ const fixHierarchy = (params) => {
36
36
  const { nodeDefs, nodeDef, sideEffect } = params;
37
37
  const calculatedHierarchy = calculateNodeDefHierarchy({ nodeDefs, nodeDef });
38
38
  // compare the whole hierarchy: a node def moved to another parent at the same depth has a hierarchy with the same length
39
- return utils_1.Objects.isEqual(calculatedHierarchy, nodeDef_1.NodeDefs.getMetaHieararchy(nodeDef))
39
+ return utils_1.Objects.isEqual(calculatedHierarchy, nodeDef_1.NodeDefs.getMetaHierarchy(nodeDef))
40
40
  ? null
41
41
  : utils_1.Objects.assocPath({ obj: nodeDef, path: ['meta', 'h'], value: calculatedHierarchy, sideEffect });
42
42
  };
@@ -71,7 +71,7 @@ const fixLayoutChildren = (params) => fixLayoutProp(Object.assign(Object.assign(
71
71
  const fix = (params) => {
72
72
  var _a, _b;
73
73
  const { nodeDef } = params;
74
- let nodeDefFixed = fixHiearchy(params);
74
+ let nodeDefFixed = fixHierarchy(params);
75
75
  if (nodeDef_1.NodeDefs.isEntity(nodeDef)) {
76
76
  nodeDefFixed = (_a = fixIndexChildren(Object.assign(Object.assign({}, params), { nodeDef: nodeDefFixed !== null && nodeDefFixed !== void 0 ? nodeDefFixed : nodeDef }))) !== null && _a !== void 0 ? _a : nodeDefFixed;
77
77
  nodeDefFixed = (_b = fixLayoutChildren(Object.assign(Object.assign({}, params), { nodeDef: nodeDefFixed !== null && nodeDefFixed !== void 0 ? nodeDefFixed : nodeDef }))) !== null && _b !== void 0 ? _b : nodeDefFixed;
@@ -1 +1 @@
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;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AAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9C,MAAM,YAAY,SAAG,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,mCAAI,OAAO,CAAA;YAC5D,MAAM,YAAY,GAAG,GAAG,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
+ {"version":3,"file":"node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;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 hierarchy = []\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 hierarchy.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 hierarchy\n}\n\nconst fixHierarchy = (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.getMetaHierarchy(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 = fixHierarchy(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"]}
@@ -78,7 +78,7 @@ const selfReferenceAllowedByDependencyType = {
78
78
  [survey_1.SurveyDependencyType.validations]: true,
79
79
  [survey_1.SurveyDependencyType.visible]: false,
80
80
  };
81
- const newDependecyGraph = () => ({
81
+ const newDependencyGraph = () => ({
82
82
  [survey_1.SurveyDependencyType.applicable]: {},
83
83
  [survey_1.SurveyDependencyType.defaultValues]: {},
84
84
  [survey_1.SurveyDependencyType.editable]: {},
@@ -92,7 +92,7 @@ const newDependecyGraph = () => ({
92
92
  [survey_1.SurveyDependencyType.validations]: {},
93
93
  [survey_1.SurveyDependencyType.visible]: {},
94
94
  });
95
- const getDependencyGraph = (survey) => { var _a; return (_a = survey.dependencyGraph) !== null && _a !== void 0 ? _a : newDependecyGraph(); };
95
+ const getDependencyGraph = (survey) => { var _a; return (_a = survey.dependencyGraph) !== null && _a !== void 0 ? _a : newDependencyGraph(); };
96
96
  const getDependencies = (params) => {
97
97
  var _a;
98
98
  var _b;
@@ -268,7 +268,7 @@ const removeNodeDefDependencies = (params) => {
268
268
  };
269
269
  exports.removeNodeDefDependencies = removeNodeDefDependencies;
270
270
  const buildAndAssocDependencyGraph = (survey) => __awaiter(void 0, void 0, void 0, function* () {
271
- survey.dependencyGraph = newDependecyGraph();
271
+ survey.dependencyGraph = newDependencyGraph();
272
272
  const sideEffect = true; // when the dependency graph is built from scratch, do side effect to avoid re-creating objects
273
273
  // add dependencies for every node def
274
274
  let surveyUpdated = survey;
@@ -1 +1 @@
1
- {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../src/survey/surveys/dependencies.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,cAAc,uCAAkB;AAC5C,2CASsB;AACtB,iFAA6E;AAE7E,sCAA+E;AAC/E,uCAA6C;AAC7C,mDAAgE;AAGhE,MAAM,oCAAoC,GAAG,CAAC,wBAAwB,CAAC,CAAA;AAEvE,MAAM,+BAA+B,GAAG;IACtC,CAAC,6BAAoB,CAAC,UAAU,CAAC,EAAE,IAAI;IACvC,CAAC,6BAAoB,CAAC,aAAa,CAAC,EAAE,IAAI;IAC1C,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,gBAAgB,CAAC,EAAE,IAAI;IAC7C,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,OAAO,CAAC,EAAE,KAAK;IACrC,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC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7D,MAAM,MAAM,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAA;IACzC,MAAM,eAAe,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAA4B,CAAA;IAC3G,MAAM,aAAa,GAAG,eAAe,CAAC,MAAM,CAC1C,CAAC,kBAAkB,EAAE,IAAI,EAAE,EAAE,CAC3B,gCAAgC,CAAC,EAAE,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,EACrG,MAAM,CACP,CAAA;IACD,uCAAY,MAAM,KAAE,eAAe,EAAE,aAAa,IAAE;AACtD,CAAC,CAAA;AAdY,QAAA,yBAAyB,GAAzB,yBAAyB,CAcrC;AAEM,MAAM,4BAA4B,GAAG,CAAO,MAAc,EAAmB,EAAE;IACpF,MAAM,CAAC,eAAe,GAAG,iBAAiB,EAAE,CAAA;IAE5C,MAAM,UAAU,GAAG,IAAI,CAAA,CAAC,+FAA+F;IAEvH,sCAAsC;IACtC,IAAI,aAAa,GAAG,MAAM,CAAA;IAC1B,KAAK,MAAM,OAAO,IAAI,cAAc,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9D,gDAAgD;QAChD,aAAa,GAAG,MAAM,IAAA,QAAA,sBAAsB,EAAC,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAA,CAAC,UAAU;IACzG,CAAC;IACD,OAAO,aAAa,CAAA;AACtB,CAAC,CAAA,CAAA;AAZY,QAAA,4BAA4B,GAA5B,4BAA4B,CAYxC","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 newDependecyGraph = () => ({\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 ?? newDependecyGraph()\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\nexport const buildAndAssocDependencyGraph = async (survey: Survey): Promise<Survey> => {\n survey.dependencyGraph = newDependecyGraph()\n\n const sideEffect = true // when the dependency graph is built from scratch, do side effect to avoid re-creating objects\n\n // add dependencies for every node def\n let surveyUpdated = survey\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,MAAY,cAAc,uCAAkB;AAC5C,2CASsB;AACtB,iFAA6E;AAE7E,sCAA+E;AAC/E,uCAA6C;AAC7C,mDAAgE;AAGhE,MAAM,oCAAoC,GAAG,CAAC,wBAAwB,CAAC,CAAA;AAEvE,MAAM,+BAA+B,GAAG;IACtC,CAAC,6BAAoB,CAAC,UAAU,CAAC,EAAE,IAAI;IACvC,CAAC,6BAAoB,CAAC,aAAa,CAAC,EAAE,IAAI;IAC1C,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,gBAAgB,CAAC,EAAE,IAAI;IAC7C,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,OAAO,CAAC,EAAE,KAAK;IACrC,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,QAAQ,CAAC,EAAE,IAAI;IACrC,CAAC,6BAAoB,CAAC,UAAU,CAAC,EAAE,KAAK;IACxC,CAAC,6BAAoB,CAAC,WAAW,CAAC,EAAE,IAAI;IACxC,CAAC,6BAAoB,CAAC,OAAO,CAAC,EAAE,IAAI;CACrC,CAAA;AAED,MAAM,oCAAoC,G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C,MAAM,CAA4B,CAAA;IAC3G,MAAM,aAAa,GAAG,eAAe,CAAC,MAAM,CAC1C,CAAC,kBAAkB,EAAE,IAAI,EAAE,EAAE,CAC3B,gCAAgC,CAAC,EAAE,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,EACrG,MAAM,CACP,CAAA;IACD,uCAAY,MAAM,KAAE,eAAe,EAAE,aAAa,IAAE;AACtD,CAAC,CAAA;AAdY,QAAA,yBAAyB,GAAzB,yBAAyB,CAcrC;AAEM,MAAM,4BAA4B,GAAG,CAAO,MAAc,EAAmB,EAAE;IACpF,MAAM,CAAC,eAAe,GAAG,kBAAkB,EAAE,CAAA;IAE7C,MAAM,UAAU,GAAG,IAAI,CAAA,CAAC,+FAA+F;IAEvH,sCAAsC;IACtC,IAAI,aAAa,GAAG,MAAM,CAAA;IAC1B,KAAK,MAAM,OAAO,IAAI,cAAc,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9D,gDAAgD;QAChD,aAAa,GAAG,MAAM,IAAA,QAAA,sBAAsB,EAAC,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAA,CAAC,UAAU;IACzG,CAAC;IACD,OAAO,aAAa,CAAA;AACtB,CAAC,CAAA,CAAA;AAZY,QAAA,4BAA4B,GAA5B,4BAA4B,CAYxC","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\nexport const buildAndAssocDependencyGraph = async (survey: Survey): Promise<Survey> => {\n survey.dependencyGraph = newDependencyGraph()\n\n const sideEffect = true // when the dependency graph is built from scratch, do side effect to avoid re-creating objects\n\n // add dependencies for every node def\n let surveyUpdated = survey\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"]}
@@ -188,7 +188,7 @@ const getNodeDefChildrenUuidsSortedByLayout = (params) => {
188
188
  var _a, _b;
189
189
  const { nodeDef, cycle, children } = params;
190
190
  const entityDef = nodeDef;
191
- const childrenEntitiesInOwnPageSortedUuids = (_a = nodeDef_1.NodeDefs.getChildrenEntitiesInOwnPageUudis(cycle)(entityDef)) !== null && _a !== void 0 ? _a : [];
191
+ const childrenEntitiesInOwnPageSortedUuids = (_a = nodeDef_1.NodeDefs.getChildrenEntitiesInOwnPageUuids(cycle)(entityDef)) !== null && _a !== void 0 ? _a : [];
192
192
  const layoutChildren = (_b = nodeDef_1.NodeDefs.getLayoutChildren(cycle)(entityDef)) !== null && _b !== void 0 ? _b : [];
193
193
  const childrenByUuids = children.reduce((acc, child) => {
194
194
  acc[child.uuid] = child;
@@ -1 +1 @@
1
- {"version":3,"file":"nodeDefs.js","sourceRoot":"","sources":["../../../src/survey/surveys/nodeDefs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAUsB;AACtB,uCAAoD;AACpD,uCAAyC;AACzC,MAAY,cAAc,uDAAkC;AAC5D,MAAY,aAAa,sDAAiC;AAC1D,yCAA6C;AAC7C,qDAAoD;AAEvC,QAAA,gBAAgB,GAAG,cAAc,CAAC,gBAAgB,CAAA;AAExD,MAAM,iBAAiB,GAAG,CAAC,MAGjC,EAAkD,EAAE;;IACnD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;IAC/B,OAAO,MAAA,MAAM,CAAC,QAAQ,0CAAG,IAAI,CAAC,CAAA;AAChC,CAAC,CAAA;AANY,QAAA,iBAAiB,GAAjB,iBAAiB,CAM7B;AAEM,MAAM,gBAAgB,GAAG,CAAC,MAAwC,EAAsC,EAAE;IAC/G,MAAM,EAAE,MAA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GAAG,MAAM,CAAA;IACrE,MAAM,MAAM,GAAmB,EAAE,CAAA;IACjC,IAAA,QAAA,8BAA8B,EAAC;QAC7B,MAAM;QACN,KAAK;QACL,OAAO;QACP,OAAO,EAAE,CAAC,cAAc,EAAE,EAAE;YAC1B,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC;gBAC5C,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;YAC7B,CAAC;QACH,CAAC;QACD,eAAe;QACf,0BAA0B,EAAE,IAAI;KACjC,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAtBY,QAAA,8BAA8B,GAA9B,8BAA8B,CAsB1C;AAEM,MAAM,0CAA0C,GAAG,CAAC,MAI1D,EAAwC,EAAE;IACzC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IACzC,OAAO,IAAA,QAAA,8BAA8B,EAAC;QACpC,MAAM;QACN,KAAK;QACL,OAAO;QACP,SAAS,EAAE,CAAC,cAAc,EAAE,EAAE,CAAC,kBAAQ,CAAC,iCAAiC,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC;KACjG,CAAC,CAAA;AACJ,CAAC,CAAA;AAZY,QAAA,0CAA0C,GAA1C,0CAA0C,CAYtD;AAED,MAAM,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,GACvG,aAAa,CAAA;QACN,0BAA0B;QAAE,iBAAiB;QAAE,4BAA4B;QAAE,kBAAkB","sourcesContent":["import { Survey } from '../survey'\nimport {\n NodeDef,\n NodeDefCode,\n NodeDefCodeProps,\n NodeDefEntity,\n NodeDefEntityChildPosition,\n NodeDefMap,\n NodeDefProps,\n NodeDefType,\n NodeDefs,\n} from '../../nodeDef'\nimport { Arrays, Objects, Queue } from '../../utils'\nimport { SystemError } from '../../error'\nimport * as NodeDefsReader from './_nodeDefs/nodeDefsReader'\nimport * as NodeDefsIndex from './_nodeDefs/nodeDefsIndex'\nimport { TraverseMethod } from '../../common'\nimport { getCategoryByUuid } from './surveysGetters'\n\nexport const getNodeDefsArray = NodeDefsReader.getNodeDefsArray\n\nexport const findNodeDefByUuid = (params: {\n survey: Survey\n uuid: string\n}): NodeDef<NodeDefType, NodeDefProps> | undefined => {\n const { survey, uuid } = params\n return survey.nodeDefs?.[uuid]\n}\n\nexport const getNodeDefByUuid = (params: { survey: Survey; uuid: string }): NodeDef<NodeDefType, NodeDefProps> => {\n const { survey, uuid } = params\n const nodeDef = findNodeDefByUuid({ survey, uuid })\n if (!nodeDef) throw new SystemError('survey.nodeDefUuidNotFound', { uuid })\n return nodeDef\n}\n\nexport const findNodeDefByName = (params: {\n survey: Survey\n name: string\n}): NodeDef<NodeDefType, NodeDefProps> | undefined => {\n const { survey, name } = params\n const nodeDefUuidByNameIndex = survey.nodeDefsIndex?.nodeDefUuidByName\n if (nodeDefUuidByNameIndex) {\n const uuid = nodeDefUuidByNameIndex[name]\n return findNodeDefByUuid({ survey, uuid })\n }\n return getNodeDefsArray(survey).find((nodeDef) => nodeDef.props.name === name)\n}\n\nexport const getNodeDefByName = (params: { survey: Survey; name: string }): NodeDef<NodeDefType, NodeDefProps> => {\n const { survey, name } = params\n const nodeDef = findNodeDefByName({ survey, name })\n if (!nodeDef) {\n throw new SystemError('survey.nodeDefNameNotFound', { name })\n }\n return nodeDef\n}\n\nexport const getNodeDefsByUuids = (params: { survey: Survey; uuids: string[] }) => {\n const { survey, uuids } = params\n return uuids.map((uuid) => getNodeDefByUuid({ survey, uuid }))\n}\n\nexport const findNodeDefsByUuids = (params: {\n survey: Survey\n uuids: string[]\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey, uuids } = params\n return uuids.reduce((acc: NodeDef<NodeDefType, NodeDefProps>[], uuid) => {\n const nodeDef = findNodeDefByUuid({ survey, uuid })\n if (nodeDef) {\n acc.push(nodeDef)\n }\n return acc\n }, [])\n}\n\nexport const getNodeDefParent = (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): NodeDefEntity | undefined => {\n const { survey, nodeDef } = params\n if (!nodeDef.parentUuid) return undefined\n return getNodeDefByUuid({ survey, uuid: nodeDef.parentUuid }) as NodeDefEntity\n}\n\nexport const getNodeDefAncestorMultipleEntity = (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): NodeDefEntity | undefined => {\n const { survey, nodeDef } = params\n return findAncestorNodeDef({\n survey,\n nodeDef,\n predicate: (entityDef) => NodeDefs.isRoot(entityDef) || NodeDefs.isMultiple(entityDef),\n })\n}\n\nexport const isNodeDefAncestor = (params: {\n nodeDefAncestor: NodeDef<NodeDefType, NodeDefProps>\n nodeDefDescendant: NodeDef<NodeDefType, NodeDefProps>\n}): boolean => {\n const { nodeDefAncestor, nodeDefDescendant } = params\n\n return Arrays.startsWith(nodeDefDescendant.meta.h, [...nodeDefAncestor.meta.h, nodeDefAncestor.uuid])\n}\n\nexport const getNodeDefRoot = (params: { survey: Survey }): NodeDefEntity => {\n const { survey } = params\n if (!survey.nodeDefs) throw new SystemError('survey.emptyNodeDefs')\n\n const rootDefUuidInIndex = survey.nodeDefsIndex?.rootDefUuid\n\n const rootDef = rootDefUuidInIndex\n ? getNodeDefByUuid({ survey, uuid: rootDefUuidInIndex })\n : getNodeDefsArray(survey).find((nodeDef) => !nodeDef.parentUuid)\n\n if (!rootDef) throw new SystemError('survey.rootDefNotFound')\n\n return rootDef as NodeDefEntity\n}\n\nexport const getNodeDefSource = (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): NodeDef<NodeDefType, NodeDefProps> | undefined => {\n const { survey, nodeDef } = params\n return nodeDef.virtual ? getNodeDefParent({ survey, nodeDef }) : undefined\n}\n\nexport const getNodeDefChildren = (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n includeAnalysis?: boolean\n includeLayoutElements?: boolean\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey, nodeDef, includeAnalysis = false, includeLayoutElements = false } = params\n\n if (!survey.nodeDefs) return []\n\n let childDefs = []\n // try to get children using index\n if (survey.nodeDefsIndex) {\n const childrenUuids = Object.keys(survey.nodeDefsIndex.childDefUuidPresenceByParentUuid?.[nodeDef.uuid] ?? {})\n childDefs = getNodeDefsByUuids({ survey, uuids: childrenUuids })\n } else {\n // calculate children\n childDefs = NodeDefsReader.calculateNodeDefChildren(nodeDef)(survey)\n }\n if (includeAnalysis && includeLayoutElements) {\n return childDefs\n }\n return childDefs.filter((childDef) => {\n if (!includeAnalysis && childDef.analysis) return false\n if (!includeLayoutElements && NodeDefs.isLayoutElement(childDef)) return false\n return true\n })\n}\n\nexport const getQualifierDefs = (params: { survey: Survey }): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey } = params\n const qualifierPresence = survey.nodeDefsIndex?.qualifierPresenceByUuid\n if (qualifierPresence) {\n const qualifierUuids = Object.keys(qualifierPresence)\n return getNodeDefsByUuids({ survey, uuids: qualifierUuids })\n } else {\n return getNodeDefsArray(survey).filter((nodeDef) => NodeDefs.isQualifier(nodeDef))\n }\n}\n\nconst getIndexInChain = (params: { survey: Survey; nodeDef: NodeDef<any> }): number => {\n const { survey, nodeDef } = params\n const areaBasedEstimatedOf = NodeDefs.getAreaBasedEstimatedOf(nodeDef)\n const areaBasedEstimatedOfNodeDef = areaBasedEstimatedOf\n ? getNodeDefByUuid({ survey, uuid: areaBasedEstimatedOf })\n : null\n const nodeDefToConsider = areaBasedEstimatedOfNodeDef ?? nodeDef\n return nodeDefToConsider?.propsAdvanced?.index ?? 0\n}\n\nconst getNodeDefChildrenUuidsSortedByLayout = (params: {\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n cycle: string\n children: NodeDef<any>[]\n}): string[] => {\n const { nodeDef, cycle, children } = params\n\n const entityDef = nodeDef as NodeDefEntity\n\n const childrenEntitiesInOwnPageSortedUuids = NodeDefs.getChildrenEntitiesInOwnPageUudis(cycle)(entityDef) ?? []\n const layoutChildren = NodeDefs.getLayoutChildren(cycle)(entityDef) ?? []\n const childrenByUuids = children.reduce((acc: NodeDefMap, child) => {\n acc[child.uuid] = child\n return acc\n }, {})\n const childrenUuids = Object.keys(childrenByUuids)\n\n if (layoutChildren.length === 0 && childrenEntitiesInOwnPageSortedUuids.length === 0) {\n return childrenUuids\n }\n const sortedChildrenDefsInSamePageUuids = NodeDefs.isLayoutRenderTypeTable(cycle)(entityDef)\n ? (layoutChildren as string[])\n : [...(layoutChildren as NodeDefEntityChildPosition[])]\n .sort(\n (gridItem1: NodeDefEntityChildPosition, gridItem2: NodeDefEntityChildPosition) =>\n gridItem1.y - gridItem2.y || gridItem1.x - gridItem2.x\n )\n .map((gridItem) => gridItem.i)\n .filter((nodeDefUuid) => !!childrenByUuids[nodeDefUuid])\n\n const missingChildrenUuidsInLayout = childrenUuids.filter((childUuid) => {\n const childDef = childrenByUuids[childUuid]\n return (\n !sortedChildrenDefsInSamePageUuids.includes(childUuid) &&\n !childrenEntitiesInOwnPageSortedUuids.includes(childUuid) &&\n NodeDefs.isInCycle(cycle)(childDef)\n )\n })\n\n return (\n sortedChildrenDefsInSamePageUuids\n // add child uuids missing in layout at the end\n .concat(missingChildrenUuidsInLayout)\n // add child entities in own page at the very end\n .concat(childrenEntitiesInOwnPageSortedUuids)\n )\n}\n\nconst _booleanToNumber = (value: boolean | undefined): number => (value ? 1 : 0)\nconst _compareBooleans = (value1: boolean | undefined, value2: boolean | undefined): number =>\n _booleanToNumber(value1) - _booleanToNumber(value2)\n\nexport const getNodeDefChildrenSorted = (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n cycle: string\n includeAnalysis?: boolean\n includeLayoutElements?: boolean\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey, nodeDef, cycle, includeAnalysis, includeLayoutElements } = params\n\n const children = getNodeDefChildren({ survey, nodeDef, includeAnalysis, includeLayoutElements }).filter(\n NodeDefs.isInCycle(cycle)\n )\n\n const childrenUuidsSortedByLayout = getNodeDefChildrenUuidsSortedByLayout({ nodeDef, cycle, children })\n\n return children.sort((child1, child2) => {\n if (includeAnalysis && (child1.analysis || child2.analysis)) {\n // analysis attribute at the end\n const analysisComparison = _compareBooleans(child1.analysis, child2.analysis)\n if (analysisComparison !== 0) return analysisComparison\n\n // sort by chain index\n const indexInChainComparison =\n getIndexInChain({ survey, nodeDef: child1 }) - getIndexInChain({ survey, nodeDef: child2 })\n if (indexInChainComparison !== 0) return indexInChainComparison\n\n // one node def is the area base estimated of the other\n const areaBasedEstimatedOfComparison = _compareBooleans(\n !!NodeDefs.getAreaBasedEstimatedOf(child1),\n !!NodeDefs.getAreaBasedEstimatedOf(child2)\n )\n if (areaBasedEstimatedOfComparison !== 0) return areaBasedEstimatedOfComparison\n\n return (child1.id ?? 0) - (child2.id ?? 0)\n }\n // keep sorting as defined in layout props\n return childrenUuidsSortedByLayout.indexOf(child1.uuid) - childrenUuidsSortedByLayout.indexOf(child2.uuid)\n })\n}\n\nexport const visitAncestorsAndSelfNodeDef = (params: {\n survey: Survey\n nodeDef: NodeDef<any>\n visitor: (nodeDef: NodeDef<any>) => void\n stopIfFn?: () => boolean\n includeSelf?: boolean\n}): void => {\n const { survey, nodeDef, visitor, stopIfFn, includeSelf = true } = params\n if (includeSelf) {\n visitor(nodeDef)\n }\n let currentParent = getNodeDefParent({ survey, nodeDef })\n while (currentParent) {\n visitor(currentParent)\n if (stopIfFn?.()) {\n break\n }\n currentParent = getNodeDefParent({ survey, nodeDef: currentParent })\n }\n}\n\nexport const findAncestorNodeDef = (params: {\n survey: Survey\n nodeDef: NodeDef<any>\n predicate: (entityDef: NodeDefEntity) => boolean\n}): NodeDefEntity | undefined => {\n const { survey, nodeDef, predicate } = params\n let result: NodeDefEntity | undefined = undefined\n visitAncestorsAndSelfNodeDef({\n survey,\n nodeDef,\n // ancestors only: the node def itself is never an ancestor (e.g. a multiple attribute)\n includeSelf: false,\n visitor: (entityDef) => {\n if (predicate(entityDef)) {\n result = entityDef\n }\n },\n stopIfFn: () => !!result,\n })\n return result\n}\n\ntype NodeDefTraverseParams = {\n nodeDef: NodeDef<any>\n visitor: (nodeDef: NodeDef<any>) => void\n shouldTraverse: (nodeDef: NodeDef<any>) => boolean\n getChildren: (nodeDef: NodeDef<any>) => NodeDef<any>[]\n}\n\nconst traverseBreadthFirst = ({ nodeDef, visitor, shouldTraverse, getChildren }: NodeDefTraverseParams) => {\n const queue = new Queue()\n\n queue.enqueue(nodeDef)\n\n while (!queue.isEmpty()) {\n const visitedNodeDef = queue.dequeue()\n\n visitor(visitedNodeDef)\n\n if (shouldTraverse(visitedNodeDef)) {\n queue.enqueueItems(getChildren(visitedNodeDef))\n }\n }\n}\n\nconst traverseDepthFirst = ({ nodeDef, visitor, shouldTraverse, getChildren }: NodeDefTraverseParams) => {\n const stack: NodeDef<any>[] = []\n\n stack.push(nodeDef)\n\n while (stack.length > 0) {\n const visitedNodeDef = stack.pop()!\n\n visitor(visitedNodeDef)\n\n if (shouldTraverse(visitedNodeDef)) {\n const children = getChildren(visitedNodeDef)\n // add children to stack in reverse order\n for (let index = children.length - 1; index >= 0; index--) {\n stack.push(children[index])\n }\n }\n }\n}\n\nexport const visitDescendantsAndSelfNodeDef = (params: {\n survey: Survey\n cycle?: string\n nodeDef: NodeDef<any>\n visitor: (nodeDef: NodeDef<any>) => void\n includeAnalysis?: boolean\n traverseMethod?: TraverseMethod\n traverseOnlySingleEntities?: boolean\n}) => {\n const {\n survey,\n cycle,\n nodeDef,\n visitor,\n includeAnalysis = false,\n traverseMethod = TraverseMethod.bfs,\n traverseOnlySingleEntities = false,\n } = params\n\n const getNodeDefChildrenInternal = (visitedNodeDef: NodeDef<any>) =>\n Objects.isEmpty(cycle)\n ? getNodeDefChildren({ survey, nodeDef: visitedNodeDef, includeAnalysis })\n : getNodeDefChildrenSorted({ survey, nodeDef: visitedNodeDef, cycle: cycle!, includeAnalysis })\n\n const shouldTraverse = (visitedNodeDef: NodeDef<any>): boolean =>\n visitedNodeDef.type === NodeDefType.entity &&\n (visitedNodeDef === nodeDef ||\n NodeDefs.isRoot(visitedNodeDef) ||\n !traverseOnlySingleEntities ||\n NodeDefs.isSingle(visitedNodeDef))\n\n const traverseParams = { nodeDef, visitor, shouldTraverse, getChildren: getNodeDefChildrenInternal }\n if (traverseMethod === TraverseMethod.bfs) {\n traverseBreadthFirst(traverseParams)\n } else {\n traverseDepthFirst(traverseParams)\n }\n}\n\nexport const visitNodeDefs = (params: {\n survey: Survey\n visitor: (nodeDef: NodeDef<any>) => void\n includeAnalysis?: boolean\n traverseMethod?: TraverseMethod\n}) => {\n const { survey, visitor, traverseMethod = TraverseMethod.bfs, includeAnalysis = false } = params\n const rootDef = getNodeDefRoot({ survey })\n return visitDescendantsAndSelfNodeDef({ survey, nodeDef: rootDef, visitor, traverseMethod, includeAnalysis })\n}\n\n// Node Def Code\nexport const getNodeDefParentCode = (params: { survey: Survey; nodeDef: NodeDefCode }): NodeDefCode | undefined => {\n const { survey, nodeDef } = params\n const parentCodeDefUuid = nodeDef.props.parentCodeDefUuid\n if (!parentCodeDefUuid) return undefined\n const parentCodeDef = getNodeDefByUuid({ survey, uuid: parentCodeDefUuid })\n return parentCodeDef as NodeDefCode\n}\n\nexport const getNodeDefAncestorCodes = (params: { survey: Survey; nodeDef: NodeDefCode }): NodeDefCode[] => {\n const { survey, nodeDef } = params\n const ancestors = []\n let currentParentCode = getNodeDefParentCode({ survey, nodeDef })\n while (currentParentCode) {\n ancestors.unshift(currentParentCode)\n currentParentCode = getNodeDefParentCode({ survey, nodeDef: currentParentCode })\n }\n return ancestors\n}\n\nexport const isNodeDefParentCode = (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): boolean => {\n const { survey, nodeDef } = params\n const nodeDefsArray = getNodeDefsArray(survey)\n return nodeDefsArray.some((def) => {\n try {\n return nodeDef.uuid === (def as NodeDef<NodeDefType.code, NodeDefCodeProps>).props.parentCodeDefUuid\n } catch {\n // ignore it: def is not a code attribute definition\n return\n }\n })\n}\n\nexport const getNodeDefCategoryLevelIndex = (params: { survey: Survey; nodeDef: NodeDefCode }): number => {\n const { survey, nodeDef } = params\n const parentCodeNodeDef = getNodeDefParentCode({ survey, nodeDef })\n return parentCodeNodeDef ? 1 + getNodeDefCategoryLevelIndex({ survey, nodeDef: parentCodeNodeDef }) : 0\n}\n\nexport const getDependentCodeAttributeDefs = (params: { survey: Survey; nodeDef: NodeDefCode }): NodeDefCode[] => {\n const { survey, nodeDef } = params\n\n const categoryUuid = NodeDefs.getCategoryUuid(nodeDef)\n if (!categoryUuid) return []\n\n const category = getCategoryByUuid({ survey, categoryUuid })\n const levelsCount = Object.keys(category?.levels ?? {}).length\n if (levelsCount <= 1) return []\n\n const nodeDefsArray = getNodeDefsArray(survey)\n return nodeDefsArray.filter(\n (def) => def.type === NodeDefType.code && NodeDefs.getParentCodeDefUuid(def as NodeDefCode) === nodeDef.uuid\n ) as NodeDefCode[]\n}\n\nexport const getDependentEnumeratedEntityDefs = (params: { survey: Survey; nodeDef: NodeDefCode }): NodeDefEntity[] => {\n const { survey, nodeDef } = params\n const result: NodeDefEntity[] = []\n const dependentCodeAttributeDefs = getDependentCodeAttributeDefs({ survey, nodeDef })\n for (const dependentCodeDef of dependentCodeAttributeDefs) {\n if (NodeDefs.isKey(dependentCodeDef)) {\n const entityDef = getNodeDefAncestorMultipleEntity({ survey, nodeDef: dependentCodeDef })\n if (entityDef && NodeDefs.isEnumerate(entityDef)) {\n result.push(entityDef)\n }\n }\n }\n return result\n}\n\nexport const getNodeDefKeys = (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n cycle?: string\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey, cycle, nodeDef } = params\n\n return getDescendantsInSingleEntities({\n survey,\n cycle,\n nodeDef,\n predicate: (visitedNodeDef) =>\n NodeDefs.isKey(visitedNodeDef) &&\n !visitedNodeDef.deleted &&\n (Objects.isEmpty(cycle) || NodeDefs.isInCycle(cycle!)(visitedNodeDef)),\n })\n}\n\nexport const getRootKeys = (params: { survey: Survey; cycle?: string }) => {\n const { survey, cycle } = params\n const rootDef = getNodeDefRoot({ survey })\n return getNodeDefKeys({ survey, nodeDef: rootDef, cycle })\n}\n\nexport const getNodeDefEnumerator = (params: { survey: Survey; entityDef: NodeDefEntity }): NodeDefCode | undefined => {\n const { survey, entityDef } = params\n if (!entityDef.props.enumerate) return undefined\n\n const children = getNodeDefChildren({ survey, nodeDef: entityDef })\n const codeAttributeKeys = children.filter((child) => child.type === NodeDefType.code && child.props.key)\n if (codeAttributeKeys.length === 1) {\n return codeAttributeKeys[0] as NodeDefCode\n }\n return undefined\n}\n\nexport const isNodeDefEnumerator = (params: { survey: Survey; nodeDef: NodeDef<NodeDefType> }): boolean => {\n const { survey, nodeDef } = params\n if (nodeDef.type !== NodeDefType.code) return false\n const entityDef = getNodeDefParent({ survey, nodeDef })\n if (!entityDef) return false\n const enumerator = getNodeDefEnumerator({ survey, entityDef })\n return enumerator?.uuid === nodeDef.uuid\n}\n\nexport const getDescendantsInSingleEntities = (params: {\n survey: Survey\n cycle?: string\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n predicate?: (visitedNodeDef: NodeDef<NodeDefType, NodeDefProps>) => boolean\n includeAnalysis?: boolean\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey, cycle, nodeDef, predicate, includeAnalysis } = params\n const result: NodeDef<any>[] = []\n visitDescendantsAndSelfNodeDef({\n survey,\n cycle,\n nodeDef,\n visitor: (visitedNodeDef) => {\n if (!predicate || predicate(visitedNodeDef)) {\n result.push(visitedNodeDef)\n }\n },\n includeAnalysis,\n traverseOnlySingleEntities: true,\n })\n return result\n}\n\nexport const getNodeDefsIncludedInMultipleEntitySummary = (params: {\n survey: Survey\n cycle: string\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey, cycle, nodeDef } = params\n return getDescendantsInSingleEntities({\n survey,\n cycle,\n nodeDef,\n predicate: (visitedNodeDef) => NodeDefs.isIncludedInMultipleEntitySummary(cycle)(visitedNodeDef),\n })\n}\n\nconst { buildAndAssocNodeDefsIndex, addNodeDefToIndex, updateNodeDefUuidByNameIndex, deleteNodeDefIndex } =\n NodeDefsIndex\nexport { buildAndAssocNodeDefsIndex, addNodeDefToIndex, updateNodeDefUuidByNameIndex, deleteNodeDefIndex }\n"]}
1
+ {"version":3,"file":"nodeDefs.js","sourceRoot":"","sources":["../../../src/survey/surveys/nodeDefs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAUsB;AACtB,uCAAoD;AACpD,uCAAyC;AACzC,MAAY,cAAc,uDAAkC;AAC5D,MAAY,aAAa,sDAAiC;AAC1D,yCAA6C;AAC7C,qDAAoD;AAEvC,QAAA,gBAAgB,GAAG,cAAc,CAAC,gBAAgB,CAAA;AAExD,MAAM,iBAAiB,GAAG,CAAC,MAGjC,EAAkD,EAAE;;IACnD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;IAC/B,OAAO,MAAA,MAAM,CAAC,QAAQ,0CAAG,IAAI,CAAC,CAAA;AAChC,CAAC,CAAA;AANY,QAAA,iBAAiB,GAAjB,iBAAiB,CAM7B;AAEM,MAAM,gBAAgB,GAAG,CAAC,MAAwC,EAAsC,EAAE;IAC/G,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;IAC/B,MAAM,OAAO,GAAG,IAAA,QAAA,iBAAiB,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IACnD,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,mBAAW,CAAC,4BAA4B,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;IAC3E,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AALY,QAAA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7B,CAAC;QACH,CAAC;QACD,eAAe;QACf,0BAA0B,EAAE,IAAI;KACjC,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAtBY,QAAA,8BAA8B,GAA9B,8BAA8B,CAsB1C;AAEM,MAAM,0CAA0C,GAAG,CAAC,MAI1D,EAAwC,EAAE;IACzC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IACzC,OAAO,IAAA,QAAA,8BAA8B,EAAC;QACpC,MAAM;QACN,KAAK;QACL,OAAO;QACP,SAAS,EAAE,CAAC,cAAc,EAAE,EAAE,CAAC,kBAAQ,CAAC,iCAAiC,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC;KACjG,CAAC,CAAA;AACJ,CAAC,CAAA;AAZY,QAAA,0CAA0C,GAA1C,0CAA0C,CAYtD;AAED,MAAM,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,GACvG,aAAa,CAAA;QACN,0BAA0B;QAAE,iBAAiB;QAAE,4BAA4B;QAAE,kBAAkB","sourcesContent":["import { Survey } from '../survey'\nimport {\n NodeDef,\n NodeDefCode,\n NodeDefCodeProps,\n NodeDefEntity,\n NodeDefEntityChildPosition,\n NodeDefMap,\n NodeDefProps,\n NodeDefType,\n NodeDefs,\n} from '../../nodeDef'\nimport { Arrays, Objects, Queue } from '../../utils'\nimport { SystemError } from '../../error'\nimport * as NodeDefsReader from './_nodeDefs/nodeDefsReader'\nimport * as NodeDefsIndex from './_nodeDefs/nodeDefsIndex'\nimport { TraverseMethod } from '../../common'\nimport { getCategoryByUuid } from './surveysGetters'\n\nexport const getNodeDefsArray = NodeDefsReader.getNodeDefsArray\n\nexport const findNodeDefByUuid = (params: {\n survey: Survey\n uuid: string\n}): NodeDef<NodeDefType, NodeDefProps> | undefined => {\n const { survey, uuid } = params\n return survey.nodeDefs?.[uuid]\n}\n\nexport const getNodeDefByUuid = (params: { survey: Survey; uuid: string }): NodeDef<NodeDefType, NodeDefProps> => {\n const { survey, uuid } = params\n const nodeDef = findNodeDefByUuid({ survey, uuid })\n if (!nodeDef) throw new SystemError('survey.nodeDefUuidNotFound', { uuid })\n return nodeDef\n}\n\nexport const findNodeDefByName = (params: {\n survey: Survey\n name: string\n}): NodeDef<NodeDefType, NodeDefProps> | undefined => {\n const { survey, name } = params\n const nodeDefUuidByNameIndex = survey.nodeDefsIndex?.nodeDefUuidByName\n if (nodeDefUuidByNameIndex) {\n const uuid = nodeDefUuidByNameIndex[name]\n return findNodeDefByUuid({ survey, uuid })\n }\n return getNodeDefsArray(survey).find((nodeDef) => nodeDef.props.name === name)\n}\n\nexport const getNodeDefByName = (params: { survey: Survey; name: string }): NodeDef<NodeDefType, NodeDefProps> => {\n const { survey, name } = params\n const nodeDef = findNodeDefByName({ survey, name })\n if (!nodeDef) {\n throw new SystemError('survey.nodeDefNameNotFound', { name })\n }\n return nodeDef\n}\n\nexport const getNodeDefsByUuids = (params: { survey: Survey; uuids: string[] }) => {\n const { survey, uuids } = params\n return uuids.map((uuid) => getNodeDefByUuid({ survey, uuid }))\n}\n\nexport const findNodeDefsByUuids = (params: {\n survey: Survey\n uuids: string[]\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey, uuids } = params\n return uuids.reduce((acc: NodeDef<NodeDefType, NodeDefProps>[], uuid) => {\n const nodeDef = findNodeDefByUuid({ survey, uuid })\n if (nodeDef) {\n acc.push(nodeDef)\n }\n return acc\n }, [])\n}\n\nexport const getNodeDefParent = (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): NodeDefEntity | undefined => {\n const { survey, nodeDef } = params\n if (!nodeDef.parentUuid) return undefined\n return getNodeDefByUuid({ survey, uuid: nodeDef.parentUuid }) as NodeDefEntity\n}\n\nexport const getNodeDefAncestorMultipleEntity = (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): NodeDefEntity | undefined => {\n const { survey, nodeDef } = params\n return findAncestorNodeDef({\n survey,\n nodeDef,\n predicate: (entityDef) => NodeDefs.isRoot(entityDef) || NodeDefs.isMultiple(entityDef),\n })\n}\n\nexport const isNodeDefAncestor = (params: {\n nodeDefAncestor: NodeDef<NodeDefType, NodeDefProps>\n nodeDefDescendant: NodeDef<NodeDefType, NodeDefProps>\n}): boolean => {\n const { nodeDefAncestor, nodeDefDescendant } = params\n\n return Arrays.startsWith(nodeDefDescendant.meta.h, [...nodeDefAncestor.meta.h, nodeDefAncestor.uuid])\n}\n\nexport const getNodeDefRoot = (params: { survey: Survey }): NodeDefEntity => {\n const { survey } = params\n if (!survey.nodeDefs) throw new SystemError('survey.emptyNodeDefs')\n\n const rootDefUuidInIndex = survey.nodeDefsIndex?.rootDefUuid\n\n const rootDef = rootDefUuidInIndex\n ? getNodeDefByUuid({ survey, uuid: rootDefUuidInIndex })\n : getNodeDefsArray(survey).find((nodeDef) => !nodeDef.parentUuid)\n\n if (!rootDef) throw new SystemError('survey.rootDefNotFound')\n\n return rootDef as NodeDefEntity\n}\n\nexport const getNodeDefSource = (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): NodeDef<NodeDefType, NodeDefProps> | undefined => {\n const { survey, nodeDef } = params\n return nodeDef.virtual ? getNodeDefParent({ survey, nodeDef }) : undefined\n}\n\nexport const getNodeDefChildren = (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n includeAnalysis?: boolean\n includeLayoutElements?: boolean\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey, nodeDef, includeAnalysis = false, includeLayoutElements = false } = params\n\n if (!survey.nodeDefs) return []\n\n let childDefs = []\n // try to get children using index\n if (survey.nodeDefsIndex) {\n const childrenUuids = Object.keys(survey.nodeDefsIndex.childDefUuidPresenceByParentUuid?.[nodeDef.uuid] ?? {})\n childDefs = getNodeDefsByUuids({ survey, uuids: childrenUuids })\n } else {\n // calculate children\n childDefs = NodeDefsReader.calculateNodeDefChildren(nodeDef)(survey)\n }\n if (includeAnalysis && includeLayoutElements) {\n return childDefs\n }\n return childDefs.filter((childDef) => {\n if (!includeAnalysis && childDef.analysis) return false\n if (!includeLayoutElements && NodeDefs.isLayoutElement(childDef)) return false\n return true\n })\n}\n\nexport const getQualifierDefs = (params: { survey: Survey }): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey } = params\n const qualifierPresence = survey.nodeDefsIndex?.qualifierPresenceByUuid\n if (qualifierPresence) {\n const qualifierUuids = Object.keys(qualifierPresence)\n return getNodeDefsByUuids({ survey, uuids: qualifierUuids })\n } else {\n return getNodeDefsArray(survey).filter((nodeDef) => NodeDefs.isQualifier(nodeDef))\n }\n}\n\nconst getIndexInChain = (params: { survey: Survey; nodeDef: NodeDef<any> }): number => {\n const { survey, nodeDef } = params\n const areaBasedEstimatedOf = NodeDefs.getAreaBasedEstimatedOf(nodeDef)\n const areaBasedEstimatedOfNodeDef = areaBasedEstimatedOf\n ? getNodeDefByUuid({ survey, uuid: areaBasedEstimatedOf })\n : null\n const nodeDefToConsider = areaBasedEstimatedOfNodeDef ?? nodeDef\n return nodeDefToConsider?.propsAdvanced?.index ?? 0\n}\n\nconst getNodeDefChildrenUuidsSortedByLayout = (params: {\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n cycle: string\n children: NodeDef<any>[]\n}): string[] => {\n const { nodeDef, cycle, children } = params\n\n const entityDef = nodeDef as NodeDefEntity\n\n const childrenEntitiesInOwnPageSortedUuids = NodeDefs.getChildrenEntitiesInOwnPageUuids(cycle)(entityDef) ?? []\n const layoutChildren = NodeDefs.getLayoutChildren(cycle)(entityDef) ?? []\n const childrenByUuids = children.reduce((acc: NodeDefMap, child) => {\n acc[child.uuid] = child\n return acc\n }, {})\n const childrenUuids = Object.keys(childrenByUuids)\n\n if (layoutChildren.length === 0 && childrenEntitiesInOwnPageSortedUuids.length === 0) {\n return childrenUuids\n }\n const sortedChildrenDefsInSamePageUuids = NodeDefs.isLayoutRenderTypeTable(cycle)(entityDef)\n ? (layoutChildren as string[])\n : [...(layoutChildren as NodeDefEntityChildPosition[])]\n .sort(\n (gridItem1: NodeDefEntityChildPosition, gridItem2: NodeDefEntityChildPosition) =>\n gridItem1.y - gridItem2.y || gridItem1.x - gridItem2.x\n )\n .map((gridItem) => gridItem.i)\n .filter((nodeDefUuid) => !!childrenByUuids[nodeDefUuid])\n\n const missingChildrenUuidsInLayout = childrenUuids.filter((childUuid) => {\n const childDef = childrenByUuids[childUuid]\n return (\n !sortedChildrenDefsInSamePageUuids.includes(childUuid) &&\n !childrenEntitiesInOwnPageSortedUuids.includes(childUuid) &&\n NodeDefs.isInCycle(cycle)(childDef)\n )\n })\n\n return (\n sortedChildrenDefsInSamePageUuids\n // add child uuids missing in layout at the end\n .concat(missingChildrenUuidsInLayout)\n // add child entities in own page at the very end\n .concat(childrenEntitiesInOwnPageSortedUuids)\n )\n}\n\nconst _booleanToNumber = (value: boolean | undefined): number => (value ? 1 : 0)\nconst _compareBooleans = (value1: boolean | undefined, value2: boolean | undefined): number =>\n _booleanToNumber(value1) - _booleanToNumber(value2)\n\nexport const getNodeDefChildrenSorted = (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n cycle: string\n includeAnalysis?: boolean\n includeLayoutElements?: boolean\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey, nodeDef, cycle, includeAnalysis, includeLayoutElements } = params\n\n const children = getNodeDefChildren({ survey, nodeDef, includeAnalysis, includeLayoutElements }).filter(\n NodeDefs.isInCycle(cycle)\n )\n\n const childrenUuidsSortedByLayout = getNodeDefChildrenUuidsSortedByLayout({ nodeDef, cycle, children })\n\n return children.sort((child1, child2) => {\n if (includeAnalysis && (child1.analysis || child2.analysis)) {\n // analysis attribute at the end\n const analysisComparison = _compareBooleans(child1.analysis, child2.analysis)\n if (analysisComparison !== 0) return analysisComparison\n\n // sort by chain index\n const indexInChainComparison =\n getIndexInChain({ survey, nodeDef: child1 }) - getIndexInChain({ survey, nodeDef: child2 })\n if (indexInChainComparison !== 0) return indexInChainComparison\n\n // one node def is the area base estimated of the other\n const areaBasedEstimatedOfComparison = _compareBooleans(\n !!NodeDefs.getAreaBasedEstimatedOf(child1),\n !!NodeDefs.getAreaBasedEstimatedOf(child2)\n )\n if (areaBasedEstimatedOfComparison !== 0) return areaBasedEstimatedOfComparison\n\n return (child1.id ?? 0) - (child2.id ?? 0)\n }\n // keep sorting as defined in layout props\n return childrenUuidsSortedByLayout.indexOf(child1.uuid) - childrenUuidsSortedByLayout.indexOf(child2.uuid)\n })\n}\n\nexport const visitAncestorsAndSelfNodeDef = (params: {\n survey: Survey\n nodeDef: NodeDef<any>\n visitor: (nodeDef: NodeDef<any>) => void\n stopIfFn?: () => boolean\n includeSelf?: boolean\n}): void => {\n const { survey, nodeDef, visitor, stopIfFn, includeSelf = true } = params\n if (includeSelf) {\n visitor(nodeDef)\n }\n let currentParent = getNodeDefParent({ survey, nodeDef })\n while (currentParent) {\n visitor(currentParent)\n if (stopIfFn?.()) {\n break\n }\n currentParent = getNodeDefParent({ survey, nodeDef: currentParent })\n }\n}\n\nexport const findAncestorNodeDef = (params: {\n survey: Survey\n nodeDef: NodeDef<any>\n predicate: (entityDef: NodeDefEntity) => boolean\n}): NodeDefEntity | undefined => {\n const { survey, nodeDef, predicate } = params\n let result: NodeDefEntity | undefined = undefined\n visitAncestorsAndSelfNodeDef({\n survey,\n nodeDef,\n // ancestors only: the node def itself is never an ancestor (e.g. a multiple attribute)\n includeSelf: false,\n visitor: (entityDef) => {\n if (predicate(entityDef)) {\n result = entityDef\n }\n },\n stopIfFn: () => !!result,\n })\n return result\n}\n\ntype NodeDefTraverseParams = {\n nodeDef: NodeDef<any>\n visitor: (nodeDef: NodeDef<any>) => void\n shouldTraverse: (nodeDef: NodeDef<any>) => boolean\n getChildren: (nodeDef: NodeDef<any>) => NodeDef<any>[]\n}\n\nconst traverseBreadthFirst = ({ nodeDef, visitor, shouldTraverse, getChildren }: NodeDefTraverseParams) => {\n const queue = new Queue()\n\n queue.enqueue(nodeDef)\n\n while (!queue.isEmpty()) {\n const visitedNodeDef = queue.dequeue()\n\n visitor(visitedNodeDef)\n\n if (shouldTraverse(visitedNodeDef)) {\n queue.enqueueItems(getChildren(visitedNodeDef))\n }\n }\n}\n\nconst traverseDepthFirst = ({ nodeDef, visitor, shouldTraverse, getChildren }: NodeDefTraverseParams) => {\n const stack: NodeDef<any>[] = []\n\n stack.push(nodeDef)\n\n while (stack.length > 0) {\n const visitedNodeDef = stack.pop()!\n\n visitor(visitedNodeDef)\n\n if (shouldTraverse(visitedNodeDef)) {\n const children = getChildren(visitedNodeDef)\n // add children to stack in reverse order\n for (let index = children.length - 1; index >= 0; index--) {\n stack.push(children[index])\n }\n }\n }\n}\n\nexport const visitDescendantsAndSelfNodeDef = (params: {\n survey: Survey\n cycle?: string\n nodeDef: NodeDef<any>\n visitor: (nodeDef: NodeDef<any>) => void\n includeAnalysis?: boolean\n traverseMethod?: TraverseMethod\n traverseOnlySingleEntities?: boolean\n}) => {\n const {\n survey,\n cycle,\n nodeDef,\n visitor,\n includeAnalysis = false,\n traverseMethod = TraverseMethod.bfs,\n traverseOnlySingleEntities = false,\n } = params\n\n const getNodeDefChildrenInternal = (visitedNodeDef: NodeDef<any>) =>\n Objects.isEmpty(cycle)\n ? getNodeDefChildren({ survey, nodeDef: visitedNodeDef, includeAnalysis })\n : getNodeDefChildrenSorted({ survey, nodeDef: visitedNodeDef, cycle: cycle!, includeAnalysis })\n\n const shouldTraverse = (visitedNodeDef: NodeDef<any>): boolean =>\n visitedNodeDef.type === NodeDefType.entity &&\n (visitedNodeDef === nodeDef ||\n NodeDefs.isRoot(visitedNodeDef) ||\n !traverseOnlySingleEntities ||\n NodeDefs.isSingle(visitedNodeDef))\n\n const traverseParams = { nodeDef, visitor, shouldTraverse, getChildren: getNodeDefChildrenInternal }\n if (traverseMethod === TraverseMethod.bfs) {\n traverseBreadthFirst(traverseParams)\n } else {\n traverseDepthFirst(traverseParams)\n }\n}\n\nexport const visitNodeDefs = (params: {\n survey: Survey\n visitor: (nodeDef: NodeDef<any>) => void\n includeAnalysis?: boolean\n traverseMethod?: TraverseMethod\n}) => {\n const { survey, visitor, traverseMethod = TraverseMethod.bfs, includeAnalysis = false } = params\n const rootDef = getNodeDefRoot({ survey })\n return visitDescendantsAndSelfNodeDef({ survey, nodeDef: rootDef, visitor, traverseMethod, includeAnalysis })\n}\n\n// Node Def Code\nexport const getNodeDefParentCode = (params: { survey: Survey; nodeDef: NodeDefCode }): NodeDefCode | undefined => {\n const { survey, nodeDef } = params\n const parentCodeDefUuid = nodeDef.props.parentCodeDefUuid\n if (!parentCodeDefUuid) return undefined\n const parentCodeDef = getNodeDefByUuid({ survey, uuid: parentCodeDefUuid })\n return parentCodeDef as NodeDefCode\n}\n\nexport const getNodeDefAncestorCodes = (params: { survey: Survey; nodeDef: NodeDefCode }): NodeDefCode[] => {\n const { survey, nodeDef } = params\n const ancestors = []\n let currentParentCode = getNodeDefParentCode({ survey, nodeDef })\n while (currentParentCode) {\n ancestors.unshift(currentParentCode)\n currentParentCode = getNodeDefParentCode({ survey, nodeDef: currentParentCode })\n }\n return ancestors\n}\n\nexport const isNodeDefParentCode = (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): boolean => {\n const { survey, nodeDef } = params\n const nodeDefsArray = getNodeDefsArray(survey)\n return nodeDefsArray.some((def) => {\n try {\n return nodeDef.uuid === (def as NodeDef<NodeDefType.code, NodeDefCodeProps>).props.parentCodeDefUuid\n } catch {\n // ignore it: def is not a code attribute definition\n return\n }\n })\n}\n\nexport const getNodeDefCategoryLevelIndex = (params: { survey: Survey; nodeDef: NodeDefCode }): number => {\n const { survey, nodeDef } = params\n const parentCodeNodeDef = getNodeDefParentCode({ survey, nodeDef })\n return parentCodeNodeDef ? 1 + getNodeDefCategoryLevelIndex({ survey, nodeDef: parentCodeNodeDef }) : 0\n}\n\nexport const getDependentCodeAttributeDefs = (params: { survey: Survey; nodeDef: NodeDefCode }): NodeDefCode[] => {\n const { survey, nodeDef } = params\n\n const categoryUuid = NodeDefs.getCategoryUuid(nodeDef)\n if (!categoryUuid) return []\n\n const category = getCategoryByUuid({ survey, categoryUuid })\n const levelsCount = Object.keys(category?.levels ?? {}).length\n if (levelsCount <= 1) return []\n\n const nodeDefsArray = getNodeDefsArray(survey)\n return nodeDefsArray.filter(\n (def) => def.type === NodeDefType.code && NodeDefs.getParentCodeDefUuid(def as NodeDefCode) === nodeDef.uuid\n ) as NodeDefCode[]\n}\n\nexport const getDependentEnumeratedEntityDefs = (params: { survey: Survey; nodeDef: NodeDefCode }): NodeDefEntity[] => {\n const { survey, nodeDef } = params\n const result: NodeDefEntity[] = []\n const dependentCodeAttributeDefs = getDependentCodeAttributeDefs({ survey, nodeDef })\n for (const dependentCodeDef of dependentCodeAttributeDefs) {\n if (NodeDefs.isKey(dependentCodeDef)) {\n const entityDef = getNodeDefAncestorMultipleEntity({ survey, nodeDef: dependentCodeDef })\n if (entityDef && NodeDefs.isEnumerate(entityDef)) {\n result.push(entityDef)\n }\n }\n }\n return result\n}\n\nexport const getNodeDefKeys = (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n cycle?: string\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey, cycle, nodeDef } = params\n\n return getDescendantsInSingleEntities({\n survey,\n cycle,\n nodeDef,\n predicate: (visitedNodeDef) =>\n NodeDefs.isKey(visitedNodeDef) &&\n !visitedNodeDef.deleted &&\n (Objects.isEmpty(cycle) || NodeDefs.isInCycle(cycle!)(visitedNodeDef)),\n })\n}\n\nexport const getRootKeys = (params: { survey: Survey; cycle?: string }) => {\n const { survey, cycle } = params\n const rootDef = getNodeDefRoot({ survey })\n return getNodeDefKeys({ survey, nodeDef: rootDef, cycle })\n}\n\nexport const getNodeDefEnumerator = (params: { survey: Survey; entityDef: NodeDefEntity }): NodeDefCode | undefined => {\n const { survey, entityDef } = params\n if (!entityDef.props.enumerate) return undefined\n\n const children = getNodeDefChildren({ survey, nodeDef: entityDef })\n const codeAttributeKeys = children.filter((child) => child.type === NodeDefType.code && child.props.key)\n if (codeAttributeKeys.length === 1) {\n return codeAttributeKeys[0] as NodeDefCode\n }\n return undefined\n}\n\nexport const isNodeDefEnumerator = (params: { survey: Survey; nodeDef: NodeDef<NodeDefType> }): boolean => {\n const { survey, nodeDef } = params\n if (nodeDef.type !== NodeDefType.code) return false\n const entityDef = getNodeDefParent({ survey, nodeDef })\n if (!entityDef) return false\n const enumerator = getNodeDefEnumerator({ survey, entityDef })\n return enumerator?.uuid === nodeDef.uuid\n}\n\nexport const getDescendantsInSingleEntities = (params: {\n survey: Survey\n cycle?: string\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n predicate?: (visitedNodeDef: NodeDef<NodeDefType, NodeDefProps>) => boolean\n includeAnalysis?: boolean\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey, cycle, nodeDef, predicate, includeAnalysis } = params\n const result: NodeDef<any>[] = []\n visitDescendantsAndSelfNodeDef({\n survey,\n cycle,\n nodeDef,\n visitor: (visitedNodeDef) => {\n if (!predicate || predicate(visitedNodeDef)) {\n result.push(visitedNodeDef)\n }\n },\n includeAnalysis,\n traverseOnlySingleEntities: true,\n })\n return result\n}\n\nexport const getNodeDefsIncludedInMultipleEntitySummary = (params: {\n survey: Survey\n cycle: string\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey, cycle, nodeDef } = params\n return getDescendantsInSingleEntities({\n survey,\n cycle,\n nodeDef,\n predicate: (visitedNodeDef) => NodeDefs.isIncludedInMultipleEntitySummary(cycle)(visitedNodeDef),\n })\n}\n\nconst { buildAndAssocNodeDefsIndex, addNodeDefToIndex, updateNodeDefUuidByNameIndex, deleteNodeDefIndex } =\n NodeDefsIndex\nexport { buildAndAssocNodeDefsIndex, addNodeDefToIndex, updateNodeDefUuidByNameIndex, deleteNodeDefIndex }\n"]}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "OpenForis",
5
5
  "email": "openforis.arena@gmail.com"
6
6
  },
7
- "version": "2.4.3",
7
+ "version": "2.4.5",
8
8
  "description": "Arena core module",
9
9
  "repository": {
10
10
  "type": "git",