@openforis/arena-core 2.16.3 → 2.16.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.
- package/dist/esm/node/node.js +1 -0
- package/dist/esm/node/node.js.map +1 -1
- package/dist/esm/record/_records/recordGetters.js +17 -13
- package/dist/esm/record/_records/recordGetters.js.map +1 -1
- package/dist/esm/record/recordCloner.js +14 -2
- package/dist/esm/record/recordCloner.js.map +1 -1
- package/dist/esm/record/recordFixer.js +1 -8
- package/dist/esm/record/recordFixer.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesCreator.js +6 -0
- package/dist/esm/record/recordNodesUpdater/recordNodesCreator.js.map +1 -1
- package/dist/esm/record/recordUpdater.js +46 -4
- package/dist/esm/record/recordUpdater.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeKeyValidator.js +2 -1
- package/dist/esm/record/recordValidator/attributeKeyValidator.js.map +1 -1
- package/dist/esm/record/records.js +2 -1
- package/dist/esm/record/records.js.map +1 -1
- package/dist/node/node.d.ts +2 -1
- package/dist/node/node.js +1 -0
- package/dist/node/node.js.map +1 -1
- package/dist/record/_records/recordGetters.d.ts +4 -0
- package/dist/record/_records/recordGetters.js +19 -14
- package/dist/record/_records/recordGetters.js.map +1 -1
- package/dist/record/recordCloner.js +14 -2
- package/dist/record/recordCloner.js.map +1 -1
- package/dist/record/recordFixer.js +1 -8
- package/dist/record/recordFixer.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesCreator.js +6 -0
- package/dist/record/recordNodesUpdater/recordNodesCreator.js.map +1 -1
- package/dist/record/recordUpdater.js +46 -4
- package/dist/record/recordUpdater.js.map +1 -1
- package/dist/record/recordValidator/attributeKeyValidator.js +2 -1
- package/dist/record/recordValidator/attributeKeyValidator.js.map +1 -1
- package/dist/record/records.d.ts +2 -1
- package/dist/record/records.js +1 -0
- package/dist/record/records.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { SystemError, SystemErrorKeys } from '../error';
|
|
11
|
+
import { NodeDefs } from '../nodeDef';
|
|
11
12
|
import { SurveyDependencyType, Surveys } from '../survey';
|
|
12
13
|
import { Dates, Objects } from '../utils';
|
|
13
14
|
import { Validations } from '../validation/validations';
|
|
@@ -40,7 +41,7 @@ const getDependentValidationNodePointers = (params) => {
|
|
|
40
41
|
return Array.from(uniquePointersByKey.values());
|
|
41
42
|
};
|
|
42
43
|
const _onRecordNodesCreateOrUpdate = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
-
const { user, survey, dateModified = Dates.nowFormattedForStorage() } = params;
|
|
44
|
+
const { user, survey, categoryItemProvider, taxonProvider, areaOfInterestProvider, additionalNodesToValidate, dateModified = Dates.nowFormattedForStorage(), } = params;
|
|
44
45
|
const updateResult = yield RecordNodesUpdater.updateNodesDependents(params);
|
|
45
46
|
const { nodes: updatedNodes, record: updatedRecord } = updateResult;
|
|
46
47
|
const dependentValidationNodePointers = getDependentValidationNodePointers({
|
|
@@ -52,10 +53,13 @@ const _onRecordNodesCreateOrUpdate = (params) => __awaiter(void 0, void 0, void
|
|
|
52
53
|
record: updatedRecord,
|
|
53
54
|
nodePointers: dependentValidationNodePointers,
|
|
54
55
|
});
|
|
55
|
-
const nodesToValidate = Object.assign(Object.assign({}, updatedNodes), dependentValidationNodes);
|
|
56
|
+
const nodesToValidate = Object.assign(Object.assign(Object.assign({}, updatedNodes), dependentValidationNodes), additionalNodesToValidate);
|
|
56
57
|
const validationUpdatedNodes = yield RecordValidator.validateNodes({
|
|
57
58
|
user,
|
|
58
59
|
survey,
|
|
60
|
+
categoryItemProvider,
|
|
61
|
+
taxonProvider,
|
|
62
|
+
areaOfInterestProvider,
|
|
59
63
|
record: updatedRecord,
|
|
60
64
|
nodes: nodesToValidate,
|
|
61
65
|
});
|
|
@@ -91,11 +95,49 @@ const updateAttributeValue = (params) => __awaiter(void 0, void 0, void 0, funct
|
|
|
91
95
|
const _record = Records.addNode(attributeUpdated, { sideEffect })(record);
|
|
92
96
|
return _onRecordNodesCreateOrUpdate(Object.assign(Object.assign({}, params), { record: _record, nodes: nodesUpdated }));
|
|
93
97
|
});
|
|
98
|
+
/**
|
|
99
|
+
* Returns the key and unique attributes of the siblings of the specified entities:
|
|
100
|
+
* they could have been duplicates of the ones being deleted, so they must be validated again.
|
|
101
|
+
*/
|
|
102
|
+
const getEntityKeyOrUniqueAttributes = (params) => {
|
|
103
|
+
const { survey, record, entity, uniqueAttributeDefs } = params;
|
|
104
|
+
return [
|
|
105
|
+
...Records.getEntityKeyNodes(survey, entity)(record),
|
|
106
|
+
...uniqueAttributeDefs.flatMap((uniqueDef) => Records.getChildren(entity, uniqueDef.uuid)(record)),
|
|
107
|
+
].filter(Boolean);
|
|
108
|
+
};
|
|
109
|
+
const getSiblingKeyOrUniqueAttributes = (params) => {
|
|
110
|
+
const { survey, record, nodeUuids } = params;
|
|
111
|
+
const nodeUuidsSet = new Set(nodeUuids);
|
|
112
|
+
const result = {};
|
|
113
|
+
for (const nodeUuid of nodeUuids) {
|
|
114
|
+
const node = Records.getNodeByUuid(nodeUuid)(record);
|
|
115
|
+
const parentNode = node ? Records.getParent(node)(record) : undefined;
|
|
116
|
+
const nodeDef = node ? Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid }) : undefined;
|
|
117
|
+
if (!parentNode || !nodeDef || !NodeDefs.isEntity(nodeDef))
|
|
118
|
+
continue;
|
|
119
|
+
const uniqueAttributeDefs = Surveys.getNodeDefChildren({ survey, nodeDef }).filter((childDef) => { var _a; return (_a = NodeDefs.getValidations(childDef)) === null || _a === void 0 ? void 0 : _a.unique; });
|
|
120
|
+
const siblings = Records.getChildren(parentNode, nodeDef.uuid)(record).filter((s) => !nodeUuidsSet.has(s.uuid));
|
|
121
|
+
for (const sibling of siblings) {
|
|
122
|
+
for (const attribute of getEntityKeyOrUniqueAttributes({
|
|
123
|
+
survey,
|
|
124
|
+
record,
|
|
125
|
+
entity: sibling,
|
|
126
|
+
uniqueAttributeDefs,
|
|
127
|
+
})) {
|
|
128
|
+
result[attribute.uuid] = attribute;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return result;
|
|
133
|
+
};
|
|
94
134
|
const deleteNodes = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
|
-
const { nodeUuids, record: _record, sideEffect = false } = params;
|
|
135
|
+
const { survey, nodeUuids, record: _record, sideEffect = false } = params;
|
|
136
|
+
// found before removing the nodes: the deleted nodes are no longer reachable from their siblings afterwards
|
|
137
|
+
const siblingKeyOrUniqueAttributes = getSiblingKeyOrUniqueAttributes({ survey, record: _record, nodeUuids });
|
|
96
138
|
const updateResult = Records.removeNodes(nodeUuids, { sideEffect })(_record);
|
|
97
139
|
const { record, nodesDeleted } = updateResult;
|
|
98
|
-
const result = yield _onRecordNodesCreateOrUpdate(Object.assign(Object.assign({}, params), { record, nodes: nodesDeleted }));
|
|
140
|
+
const result = yield _onRecordNodesCreateOrUpdate(Object.assign(Object.assign({}, params), { record, nodes: nodesDeleted, additionalNodesToValidate: siblingKeyOrUniqueAttributes }));
|
|
99
141
|
result.nodesDeleted = nodesDeleted;
|
|
100
142
|
return result;
|
|
101
143
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordUpdater.js","sourceRoot":"","sources":["../../../src/record/recordUpdater.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAEvD,OAAO,EAAU,oBAAoB,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACjE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,gBA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AAO,WAAW,iCAAM,MAAM,KAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,IAAG,CAAA;AAC1D,CAAC,CAAA,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,+HAA+H;IAC/H,iBAAiB;IACjB,gIAAgI;IAChI,wBAAwB;IACxB,gBAAgB;IAChB,oBAAoB;IACpB,kIAAkI;IAClI,UAAU;IACV,qIAAqI;IACrI,WAAW;CACZ,CAAA","sourcesContent":["import { Dictionary } from '../common'\nimport { SystemError, SystemErrorKeys } 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.required,\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.addDescendants(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.addNodeAndDescendants(params)\n\n return _onRecordNodesCreateOrUpdate({ ...params, record: updatedRecord, nodes: createdNodes })\n}\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(attributeUuid)(record)\n if (!attribute) throw new SystemError(SystemErrorKeys.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.removeNodes(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 /** Creates the descendants of a node and updates dependents (applicability, default values, calculations...) and validation */\n createDescendants,\n /** Creates a node and its descendants and updates dependents (applicability, default values, calculations...) and validation */\n createNodeAndDescendants,\n createRootEntity,\n updateAttributeValue,\n /** Deletes the node and its descendants and updates dependents (applicability, default values, calculations...) and validation */\n deleteNode,\n /** Deletes the nodes and their descendants and updates dependents (applicability, default values, calculations...) and validation */\n deleteNodes,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"recordUpdater.js","sourceRoot":"","sources":["../../../src/record/recordUpdater.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAEvD,OAAO,EAAW,QAAQ,EAAE,MAAM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OAAO,WAAW,iCAAM,MAAM,KAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,IAAG,CAAA;AAC1D,CAAC,CAAA,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,+HAA+H;IAC/H,iBAAiB;IACjB,gIAAgI;IAChI,wBAAwB;IACxB,gBAAgB;IAChB,oBAAoB;IACpB,kIAAkI;IAClI,UAAU;IACV,qIAAqI;IACrI,WAAW;CACZ,CAAA","sourcesContent":["import { Dictionary } from '../common'\nimport { SystemError, SystemErrorKeys } from '../error'\nimport { ArenaRecordNode, NodePointer, NodesMap } from '../node'\nimport { NodeDef, NodeDefs } from '../nodeDef'\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.required,\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>; additionalNodesToValidate?: NodesMap }\n): Promise<RecordUpdateResult> => {\n const {\n user,\n survey,\n categoryItemProvider,\n taxonProvider,\n areaOfInterestProvider,\n additionalNodesToValidate,\n dateModified = Dates.nowFormattedForStorage(),\n } = 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, ...additionalNodesToValidate }\n\n const validationUpdatedNodes = await RecordValidator.validateNodes({\n user,\n survey,\n categoryItemProvider,\n taxonProvider,\n areaOfInterestProvider,\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.addDescendants(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.addNodeAndDescendants(params)\n\n return _onRecordNodesCreateOrUpdate({ ...params, record: updatedRecord, nodes: createdNodes })\n}\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(attributeUuid)(record)\n if (!attribute) throw new SystemError(SystemErrorKeys.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\n/**\n * Returns the key and unique attributes of the siblings of the specified entities:\n * they could have been duplicates of the ones being deleted, so they must be validated again.\n */\nconst getEntityKeyOrUniqueAttributes = (params: {\n survey: Survey\n record: ArenaRecord\n entity: ArenaRecordNode\n uniqueAttributeDefs: NodeDef<any>[]\n}): ArenaRecordNode[] => {\n const { survey, record, entity, uniqueAttributeDefs } = params\n return [\n ...Records.getEntityKeyNodes(survey, entity)(record),\n ...uniqueAttributeDefs.flatMap((uniqueDef) => Records.getChildren(entity, uniqueDef.uuid)(record)),\n ].filter(Boolean)\n}\n\nconst getSiblingKeyOrUniqueAttributes = (params: {\n survey: Survey\n record: ArenaRecord\n nodeUuids: string[]\n}): NodesMap => {\n const { survey, record, nodeUuids } = params\n const nodeUuidsSet = new Set(nodeUuids)\n const result: NodesMap = {}\n for (const nodeUuid of nodeUuids) {\n const node = Records.getNodeByUuid(nodeUuid)(record)\n const parentNode = node ? Records.getParent(node)(record) : undefined\n const nodeDef = node ? Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid }) : undefined\n if (!parentNode || !nodeDef || !NodeDefs.isEntity(nodeDef)) continue\n\n const uniqueAttributeDefs = Surveys.getNodeDefChildren({ survey, nodeDef }).filter(\n (childDef) => NodeDefs.getValidations(childDef)?.unique\n )\n const siblings = Records.getChildren(parentNode, nodeDef.uuid)(record).filter((s) => !nodeUuidsSet.has(s.uuid))\n for (const sibling of siblings) {\n for (const attribute of getEntityKeyOrUniqueAttributes({\n survey,\n record,\n entity: sibling,\n uniqueAttributeDefs,\n })) {\n result[attribute.uuid] = attribute\n }\n }\n }\n return result\n}\n\nconst deleteNodes = async (\n params: NodesUpdateParams & {\n nodeUuids: string[]\n }\n): Promise<RecordUpdateResult> => {\n const { survey, nodeUuids, record: _record, sideEffect = false } = params\n\n // found before removing the nodes: the deleted nodes are no longer reachable from their siblings afterwards\n const siblingKeyOrUniqueAttributes = getSiblingKeyOrUniqueAttributes({ survey, record: _record, nodeUuids })\n\n const updateResult = Records.removeNodes(nodeUuids, { sideEffect })(_record)\n const { record, nodesDeleted } = updateResult\n\n const result = await _onRecordNodesCreateOrUpdate({\n ...params,\n record,\n nodes: nodesDeleted,\n additionalNodesToValidate: siblingKeyOrUniqueAttributes,\n })\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 /** Creates the descendants of a node and updates dependents (applicability, default values, calculations...) and validation */\n createDescendants,\n /** Creates a node and its descendants and updates dependents (applicability, default values, calculations...) and validation */\n createNodeAndDescendants,\n createRootEntity,\n updateAttributeValue,\n /** Deletes the node and its descendants and updates dependents (applicability, default values, calculations...) and validation */\n deleteNode,\n /** Deletes the nodes and their descendants and updates dependents (applicability, default values, calculations...) and validation */\n deleteNodes,\n}\n"]}
|
|
@@ -40,7 +40,8 @@ const _isEntityDuplicate = (params) => {
|
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
42
|
const keyValuesByDefUuid = _getKeyValuesByDefUuid({ survey, record, entity, keyDefs, cache });
|
|
43
|
-
|
|
43
|
+
// entities with all key values empty are never duplicates (they are reported as missing values)
|
|
44
|
+
return (!Object.values(keyValuesByDefUuid).every(Objects.isEmpty) &&
|
|
44
45
|
siblingEntities.some((sibilingEntity) => {
|
|
45
46
|
const siblingKeyValuesByDefUuid = _getKeyValuesByDefUuid({
|
|
46
47
|
survey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributeKeyValidator.js","sourceRoot":"","sources":["../../../../src/record/recordValidator/attributeKeyValidator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAW,QAAQ,EAA6B,MAAM,eAAe,CAAA;AAC5E,OAAO,EAAmB,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC/D,OAAO,EAAoB,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAChG,OAAO,EAAU,OAAO,EAAE,MAAM,cAAc,CAAA;AAG9C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAWrC,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAoB,EAAE,CAAC,CAAC;IAC3D,sBAAsB,EAAE,IAAI,GAAG,EAAE;IACjC,qBAAqB,EAAE,IAAI,GAAG,EAAE;CACjC,CAAC,CAAA;AAEF,MAAM,WAAW,GAAG,CAAC,MAIpB,EAAwC,EAAE;IACzC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IAC3C,IAAI,OAAO,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAC/D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,S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AK;gBACZ,QAAQ,EAAE,kBAAkB,CAAC,KAAK;gBAClC,GAAG,EAAE,4BAA4B;aAClC,CAAC,CACH,CAAA;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,uBAAuB,CAAC,cAAc,EAAE,CAAC,CAAA;AAClE,CAAC,CAAA;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,oBAAoB;CACrB,CAAA","sourcesContent":["import { ArenaRecord } from '../record'\nimport { Records } from '../records'\nimport { NodeDef, NodeDefs, NodeDefProps, NodeDefType } from '../../nodeDef'\nimport { ArenaRecordNode, Nodes, NodeValues } from '../../node'\nimport { ValidationResult, ValidationResultFactory, ValidationSeverity } from '../../validation'\nimport { Survey, Surveys } from '../../survey'\n\nimport { Dictionary } from '../../common'\nimport { Objects } from '../../utils'\n\n/**\n * Cache of entity key values (and key defs by entity def) used during a single validation run (the record doesn't change):\n * without it, validating the keys of S sibling entities would compute the key values of every sibling S times.\n */\nexport type EntityKeysCache = {\n keyDefsByEntityDefUuid: Map<string, NodeDef<NodeDefType, NodeDefProps>[]>\n keyValuesByEntityUuid: Map<string, Dictionary<any>>\n}\n\nexport const createEntityKeysCache = (): EntityKeysCache => ({\n keyDefsByEntityDefUuid: new Map(),\n keyValuesByEntityUuid: new Map(),\n})\n\nconst _getKeyDefs = (params: {\n survey: Survey\n entityDef: NodeDef<NodeDefType, NodeDefProps>\n cache?: EntityKeysCache\n}): NodeDef<NodeDefType, NodeDefProps>[] => {\n const { survey, entityDef, cache } = params\n let keyDefs = cache?.keyDefsByEntityDefUuid.get(entityDef.uuid)\n if (!keyDefs) {\n keyDefs = Surveys.getNodeDefKeys({ survey, nodeDef: entityDef })\n cache?.keyDefsByEntityDefUuid.set(entityDef.uuid, keyDefs)\n }\n return keyDefs\n}\n\nconst _getKeyValuesByDefUuid = (params: {\n survey: Survey\n record: ArenaRecord\n entity: ArenaRecordNode\n keyDefs: NodeDef<NodeDefType, NodeDefProps>[]\n cache?: EntityKeysCache\n}): Dictionary<any> => {\n const { survey, record, entity, keyDefs, cache } = params\n let keyValues = cache?.keyValuesByEntityUuid.get(entity.uuid)\n if (!keyValues) {\n keyValues = Records.getEntityKeyValuesByDefUuid(survey, entity, undefined, keyDefs)(record)\n cache?.keyValuesByEntityUuid.set(entity.uuid, keyValues)\n }\n return keyValues\n}\n\nconst _isEntityDuplicate = (params: {\n survey: Survey\n record: ArenaRecord\n entity: ArenaRecordNode\n entityKeysCache?: EntityKeysCache\n}): boolean => {\n const { survey, entity, record, entityKeysCache: cache } = params\n // 1. get sibling entities\n const nodeParent = Records.getParent(entity)(record)\n if (!nodeParent) return false\n\n const siblingEntities = Records.getChildren(\n nodeParent,\n entity.nodeDefUuid\n )(record).filter((node) => !Nodes.areEqual(entity, node))\n\n // 2. get key values\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const keyDefs = _getKeyDefs({ survey, entityDef, cache })\n\n if (Objects.isEmpty(siblingEntities) || Objects.isEmpty(keyDefs)) {\n return false\n }\n const keyValuesByDefUuid = _getKeyValuesByDefUuid({ survey, record, entity, keyDefs, cache })\n // entities with all key values empty are never duplicates (they are reported as missing values)\n return (\n !Object.values(keyValuesByDefUuid).every(Objects.isEmpty) &&\n siblingEntities.some((sibilingEntity) => {\n const siblingKeyValuesByDefUuid = _getKeyValuesByDefUuid({\n survey,\n record,\n entity: sibilingEntity,\n keyDefs,\n cache,\n })\n return keyDefs.every((keyDef) => {\n const keyValue = keyValuesByDefUuid[keyDef.uuid]\n const siblingKeyValue = siblingKeyValuesByDefUuid[keyDef.uuid]\n return NodeValues.isValueEqual({\n survey,\n nodeDef: keyDef,\n value: keyValue,\n valueSearch: siblingKeyValue,\n })\n })\n })\n )\n}\n\nconst isNodeDefToBeValidated = (params: { survey: Survey; nodeDef: NodeDef<NodeDefType, NodeDefProps> }): boolean => {\n const { survey, nodeDef } = params\n if (!NodeDefs.isKey(nodeDef)) return false\n\n const nodeDefParent = Surveys.getNodeDefParent({ survey, nodeDef })\n // root entity key attributes will be validated by another validator\n return !!nodeDefParent && !NodeDefs.isRoot(nodeDefParent)\n}\n\nconst validateAttributeKey =\n (params: {\n survey: Survey\n record: ArenaRecord\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n entityKeysCache?: EntityKeysCache\n }) =>\n (_propName: string, node: ArenaRecordNode): Promise<ValidationResult> => {\n const { survey, nodeDef, record, entityKeysCache } = params\n\n if (isNodeDefToBeValidated({ survey, nodeDef })) {\n const entity = Records.getParent(node)(record)\n if (entity && _isEntityDuplicate({ survey, record, entity, entityKeysCache })) {\n return Promise.resolve(\n ValidationResultFactory.createInstance({\n valid: false,\n severity: ValidationSeverity.error,\n key: 'record.entity.keyDuplicate',\n })\n )\n }\n }\n\n return Promise.resolve(ValidationResultFactory.createInstance())\n }\n\nexport const AttributeKeyValidator = {\n validateAttributeKey,\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getCycle, getRoot, getNodes, getNodesArray, getNodeByUuid, getNodesByUuids, getNodesByDefUuid, getChild, getChildren, getParent, getParentCodeAttribute, getAncestorCodePath, getDependentCodeAttributes, getAncestor, getEntityKeyNodes, getEntityKeyNodesByDefUuid, getEntityKeyValues, getEntityKeyValuesByDefUuid, getEntitySiblings, getAttributeSiblings, getNodeIndex, isNodeApplicable, isNodeEditable, isNodeVisible, isNodeRequired, visitAncestorsAndSelf, getAncestorsAndSelf, getDescendant, getDescendantsOrSelf, isDescendantOf, visitDescendantsAndSelf, getDependentNodePointers, findEntityByKeyValues, findEntityWithSameKeysInAnotherRecord, getCategoryItemUuid, isNodeEmpty, isNodeFilledByUser, isEmpty, getStep, isInAnalysisStep, } from './_records/recordGetters';
|
|
1
|
+
import { getCycle, getRoot, getNodes, getNodesArray, getNodeByUuid, getNodesByUuids, getNodesByDefUuid, getChild, getChildren, getParent, getParentCodeAttribute, getAncestorCodeAttributes, getAncestorCodePath, getDependentCodeAttributes, getAncestor, getEntityKeyNodes, getEntityKeyNodesByDefUuid, getEntityKeyValues, getEntityKeyValuesByDefUuid, getEntitySiblings, getAttributeSiblings, getNodeIndex, isNodeApplicable, isNodeEditable, isNodeVisible, isNodeRequired, visitAncestorsAndSelf, getAncestorsAndSelf, getDescendant, getDescendantsOrSelf, isDescendantOf, visitDescendantsAndSelf, getDependentNodePointers, findEntityByKeyValues, findEntityWithSameKeysInAnotherRecord, getCategoryItemUuid, isNodeEmpty, isNodeFilledByUser, isEmpty, getStep, isInAnalysisStep, } from './_records/recordGetters';
|
|
2
2
|
import { addNode, addNodes } from './_records/recordUpdater';
|
|
3
3
|
import { getEnumeratingCategoryItems, findDependentEnumeratedEntityDefsNotEmpty } from './_records/recordUtils';
|
|
4
4
|
import { getEntityCompletionPercent, getEntityCompletionStats, getEntityOwnCompletionPercent, getRecordCompletionPercent, } from './_records/recordCompletion';
|
|
@@ -17,6 +17,7 @@ export const Records = {
|
|
|
17
17
|
getChildren,
|
|
18
18
|
getParent,
|
|
19
19
|
getParentCodeAttribute,
|
|
20
|
+
getAncestorCodeAttributes,
|
|
20
21
|
getAncestorCodePath,
|
|
21
22
|
getDependentCodeAttributes,
|
|
22
23
|
getAncestor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../../src/record/records.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,aAAa,EACb,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,SAAS,EACT,sBAAsB,EACtB,mBAAmB,EACnB,0BAA0B,EAC1B,WAAW,EACX,iBAAiB,EACjB,0BAA0B,EAC1B,kBAAkB,EAClB,2BAA2B,EAC3B,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,cA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B;IACxB,6BAA6B;IAC7B,0BAA0B;IAC1B,2BAA2B;IAC3B,eAAe;IACf,6BAA6B;IAC7B,iBAAiB;IACjB,oBAAoB;IACpB,uBAAuB;IACvB,gBAAgB;IAChB,gCAAgC;IAChC,sBAAsB;IACtB,6BAA6B;IAC7B,SAAS;IACT,OAAO;IACP,QAAQ;IACR,gIAAgI;IAChI,UAAU;IACV,oIAAoI;IACpI,WAAW;IACX,uGAAuG;IACvG,UAAU,EAAE,UAAU;IACtB,yGAAyG;IACzG,WAAW,EAAE,WAAW;IACxB,QAAQ;IACR,2BAA2B;IAC3B,yCAAyC;CAC1C,CAAA","sourcesContent":["import {\n getCycle,\n getRoot,\n getNodes,\n getNodesArray,\n getNodeByUuid,\n getNodesByUuids,\n getNodesByDefUuid,\n getChild,\n getChildren,\n getParent,\n getParentCodeAttribute,\n getAncestorCodePath,\n getDependentCodeAttributes,\n getAncestor,\n getEntityKeyNodes,\n getEntityKeyNodesByDefUuid,\n getEntityKeyValues,\n getEntityKeyValuesByDefUuid,\n getEntitySiblings,\n getAttributeSiblings,\n getNodeIndex,\n isNodeApplicable,\n isNodeEditable,\n isNodeVisible,\n isNodeRequired,\n visitAncestorsAndSelf,\n getAncestorsAndSelf,\n getDescendant,\n getDescendantsOrSelf,\n isDescendantOf,\n visitDescendantsAndSelf,\n getDependentNodePointers,\n findEntityByKeyValues,\n findEntityWithSameKeysInAnotherRecord,\n getCategoryItemUuid,\n isNodeEmpty,\n isNodeFilledByUser,\n isEmpty,\n getStep,\n isInAnalysisStep,\n} from './_records/recordGetters'\nimport { addNode, addNodes } from './_records/recordUpdater'\nimport { getEnumeratingCategoryItems, findDependentEnumeratedEntityDefsNotEmpty } from './_records/recordUtils'\nimport {\n getEntityCompletionPercent,\n getEntityCompletionStats,\n getEntityOwnCompletionPercent,\n getRecordCompletionPercent,\n} from './_records/recordCompletion'\nimport {\n getDescendantPageNodeDefUuids,\n getEntitySubtreeStatus,\n getMultiplePageEntitiesStatus,\n getNodeDefChildrenInOwnPage,\n getPageNodeDefs,\n getPageValidationStatus,\n getRecordPagesValidationProgress,\n nodeBelongsToOwnPage,\n nodeBelongsToPage,\n pageHasOwnErrors,\n} from './_records/recordPagesValidation'\nimport { removeNode, removeNodes } from './recordNodesUpdater/recordNodesDeleter'\n\nexport const Records = {\n // READ\n getCycle,\n getRoot,\n getNodes,\n getNodesArray,\n getNodeByUuid,\n getNodesByUuids,\n getNodesByDefUuid,\n getChild,\n getChildren,\n getParent,\n getParentCodeAttribute,\n getAncestorCodePath,\n getDependentCodeAttributes,\n getAncestor,\n getEntityKeyNodes,\n getEntityKeyNodesByDefUuid,\n getEntityKeyValues,\n getEntityKeyValuesByDefUuid,\n getEntitySiblings,\n getAttributeSiblings,\n getNodeIndex,\n isNodeApplicable,\n isNodeEditable,\n isNodeVisible,\n isNodeRequired,\n visitAncestorsAndSelf,\n getAncestorsAndSelf,\n getDescendant,\n getDescendantsOrSelf,\n isDescendantOf,\n visitDescendantsAndSelf,\n getDependentNodePointers,\n findEntityByKeyValues,\n findEntityWithSameKeysInAnotherRecord,\n getCategoryItemUuid,\n isNodeEmpty,\n isNodeFilledByUser,\n isEmpty,\n getStep,\n isInAnalysisStep,\n getEntityCompletionPercent,\n getEntityCompletionStats,\n getEntityOwnCompletionPercent,\n getRecordCompletionPercent,\n getNodeDefChildrenInOwnPage,\n getPageNodeDefs,\n getDescendantPageNodeDefUuids,\n nodeBelongsToPage,\n nodeBelongsToOwnPage,\n getPageValidationStatus,\n pageHasOwnErrors,\n getRecordPagesValidationProgress,\n getEntitySubtreeStatus,\n getMultiplePageEntitiesStatus,\n // UPDATE\n addNode,\n addNodes,\n /** Low-level: removes the node and its descendants without updating dependents and validation (see RecordUpdater.deleteNode) */\n removeNode,\n /** Low-level: removes the nodes and their descendants without updating dependents and validation (see RecordUpdater.deleteNodes) */\n removeNodes,\n /** @deprecated Use removeNode (or RecordUpdater.deleteNode to update dependents and validation too) */\n deleteNode: removeNode,\n /** @deprecated Use removeNodes (or RecordUpdater.deleteNodes to update dependents and validation too) */\n deleteNodes: removeNodes,\n // Utils\n getEnumeratingCategoryItems,\n findDependentEnumeratedEntityDefsNotEmpty,\n}\n\nexport type { RecordUpdateOptions } from './_records/recordUpdateOptions'\nexport type {\n EntitySubtreeStatus,\n PageValidationStatus,\n PagesValidationProgress,\n} from './_records/recordPagesValidation'\n"]}
|
|
1
|
+
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../../src/record/records.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,aAAa,EACb,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,SAAS,EACT,sBAAsB,EACtB,yBAAyB,EACzB,mBAAmB,EACnB,0BAA0B,EAC1B,WAAW,EACX,iBAAiB,EACjB,0BAA0B,EAC1B,kBAAkB,EAClB,2BAA2B,EAC3B,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,qCAAqC,EACrC,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,OAAO,EACP,gBAAgB,GACjB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,2BAA2B,EAAE,yCAAyC,EAAE,MAAM,wBAAwB,CAAA;AAC/G,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EACtB,6BAA6B,EAC7B,2BAA2B,EAC3B,eAAe,EACf,uBAAuB,EACvB,gCAAgC,EAChC,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAA;AAEjF,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,OAAO;IACP,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,aAAa;IACb,aAAa;IACb,eAAe;IACf,iBAAiB;IACjB,QAAQ;IACR,WAAW;IACX,SAAS;IACT,sBAAsB;IACtB,yBAAyB;IACzB,mBAAmB;IACnB,0BAA0B;IAC1B,WAAW;IACX,iBAAiB;IACjB,0BAA0B;IAC1B,kBAAkB;IAClB,2BAA2B;IAC3B,iBAAiB;IACjB,oBAAoB;IACpB,YAAY;IACZ,gBAAgB;IAChB,cAAc;IACd,aAAa;IACb,cAAc;IACd,qBAAqB;IACrB,mBAAmB;IACnB,aAAa;IACb,oBAAoB;IACpB,cAAc;IACd,uBAAuB;IACvB,wBAAwB;IACxB,qBAAqB;IACrB,qCAAqC;IACrC,mBAAmB;IACnB,WAAW;IACX,kBAAkB;IAClB,OAAO;IACP,OAAO;IACP,gBAAgB;IAChB,0BAA0B;IAC1B,wBAAwB;IACxB,6BAA6B;IAC7B,0BAA0B;IAC1B,2BAA2B;IAC3B,eAAe;IACf,6BAA6B;IAC7B,iBAAiB;IACjB,oBAAoB;IACpB,uBAAuB;IACvB,gBAAgB;IAChB,gCAAgC;IAChC,sBAAsB;IACtB,6BAA6B;IAC7B,SAAS;IACT,OAAO;IACP,QAAQ;IACR,gIAAgI;IAChI,UAAU;IACV,oIAAoI;IACpI,WAAW;IACX,uGAAuG;IACvG,UAAU,EAAE,UAAU;IACtB,yGAAyG;IACzG,WAAW,EAAE,WAAW;IACxB,QAAQ;IACR,2BAA2B;IAC3B,yCAAyC;CAC1C,CAAA","sourcesContent":["import {\n getCycle,\n getRoot,\n getNodes,\n getNodesArray,\n getNodeByUuid,\n getNodesByUuids,\n getNodesByDefUuid,\n getChild,\n getChildren,\n getParent,\n getParentCodeAttribute,\n getAncestorCodeAttributes,\n getAncestorCodePath,\n getDependentCodeAttributes,\n getAncestor,\n getEntityKeyNodes,\n getEntityKeyNodesByDefUuid,\n getEntityKeyValues,\n getEntityKeyValuesByDefUuid,\n getEntitySiblings,\n getAttributeSiblings,\n getNodeIndex,\n isNodeApplicable,\n isNodeEditable,\n isNodeVisible,\n isNodeRequired,\n visitAncestorsAndSelf,\n getAncestorsAndSelf,\n getDescendant,\n getDescendantsOrSelf,\n isDescendantOf,\n visitDescendantsAndSelf,\n getDependentNodePointers,\n findEntityByKeyValues,\n findEntityWithSameKeysInAnotherRecord,\n getCategoryItemUuid,\n isNodeEmpty,\n isNodeFilledByUser,\n isEmpty,\n getStep,\n isInAnalysisStep,\n} from './_records/recordGetters'\nimport { addNode, addNodes } from './_records/recordUpdater'\nimport { getEnumeratingCategoryItems, findDependentEnumeratedEntityDefsNotEmpty } from './_records/recordUtils'\nimport {\n getEntityCompletionPercent,\n getEntityCompletionStats,\n getEntityOwnCompletionPercent,\n getRecordCompletionPercent,\n} from './_records/recordCompletion'\nimport {\n getDescendantPageNodeDefUuids,\n getEntitySubtreeStatus,\n getMultiplePageEntitiesStatus,\n getNodeDefChildrenInOwnPage,\n getPageNodeDefs,\n getPageValidationStatus,\n getRecordPagesValidationProgress,\n nodeBelongsToOwnPage,\n nodeBelongsToPage,\n pageHasOwnErrors,\n} from './_records/recordPagesValidation'\nimport { removeNode, removeNodes } from './recordNodesUpdater/recordNodesDeleter'\n\nexport const Records = {\n // READ\n getCycle,\n getRoot,\n getNodes,\n getNodesArray,\n getNodeByUuid,\n getNodesByUuids,\n getNodesByDefUuid,\n getChild,\n getChildren,\n getParent,\n getParentCodeAttribute,\n getAncestorCodeAttributes,\n getAncestorCodePath,\n getDependentCodeAttributes,\n getAncestor,\n getEntityKeyNodes,\n getEntityKeyNodesByDefUuid,\n getEntityKeyValues,\n getEntityKeyValuesByDefUuid,\n getEntitySiblings,\n getAttributeSiblings,\n getNodeIndex,\n isNodeApplicable,\n isNodeEditable,\n isNodeVisible,\n isNodeRequired,\n visitAncestorsAndSelf,\n getAncestorsAndSelf,\n getDescendant,\n getDescendantsOrSelf,\n isDescendantOf,\n visitDescendantsAndSelf,\n getDependentNodePointers,\n findEntityByKeyValues,\n findEntityWithSameKeysInAnotherRecord,\n getCategoryItemUuid,\n isNodeEmpty,\n isNodeFilledByUser,\n isEmpty,\n getStep,\n isInAnalysisStep,\n getEntityCompletionPercent,\n getEntityCompletionStats,\n getEntityOwnCompletionPercent,\n getRecordCompletionPercent,\n getNodeDefChildrenInOwnPage,\n getPageNodeDefs,\n getDescendantPageNodeDefUuids,\n nodeBelongsToPage,\n nodeBelongsToOwnPage,\n getPageValidationStatus,\n pageHasOwnErrors,\n getRecordPagesValidationProgress,\n getEntitySubtreeStatus,\n getMultiplePageEntitiesStatus,\n // UPDATE\n addNode,\n addNodes,\n /** Low-level: removes the node and its descendants without updating dependents and validation (see RecordUpdater.deleteNode) */\n removeNode,\n /** Low-level: removes the nodes and their descendants without updating dependents and validation (see RecordUpdater.deleteNodes) */\n removeNodes,\n /** @deprecated Use removeNode (or RecordUpdater.deleteNode to update dependents and validation too) */\n deleteNode: removeNode,\n /** @deprecated Use removeNodes (or RecordUpdater.deleteNodes to update dependents and validation too) */\n deleteNodes: removeNodes,\n // Utils\n getEnumeratingCategoryItems,\n findDependentEnumeratedEntityDefsNotEmpty,\n}\n\nexport type { RecordUpdateOptions } from './_records/recordUpdateOptions'\nexport type {\n EntitySubtreeStatus,\n PageValidationStatus,\n PagesValidationProgress,\n} from './_records/recordPagesValidation'\n"]}
|
package/dist/node/node.d.ts
CHANGED
package/dist/node/node.js
CHANGED
package/dist/node/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node/node.ts"],"names":[],"mappings":";;;AAGA,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,2BAAe,CAAA;AACjB,CAAC,EAHW,QAAQ,aAAR,QAAQ,GAAR,QAAQ,QAGnB;AAED,IAAY,
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node/node.ts"],"names":[],"mappings":";;;AAGA,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,2BAAe,CAAA;AACjB,CAAC,EAHW,QAAQ,aAAR,QAAQ,GAAR,QAAQ,QAGnB;AAED,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,uBAAO,CAAA;IACP,+BAAe,CAAA;AACjB,CAAC,EAHW,YAAY,aAAZ,YAAY,GAAZ,YAAY,QAGvB","sourcesContent":["import { CategoryItem } from '../category'\nimport { Taxon } from '../taxonomy'\n\nexport enum NodeKeys {\n meta = 'meta',\n value = 'value',\n}\n\nexport enum NodeMetaKeys {\n h = 'h',\n hCode = 'hCode',\n}\n\nexport interface NodeMeta {\n /**\n * Applicability of the node children (by definition UUID). If not defined, the children are applicable by default.\n */\n childApplicability?: { [uuid: string]: boolean }\n /**\n * Whether the node children (by definition UUID) are editable (true) or read-only (false).\n * If not defined, the children are editable by default.\n */\n cEdit?: { [uuid: string]: boolean }\n /**\n * Whether the node children (by definition UUID) are required because their \"required if\" condition is met (true).\n * If not defined, the children are not required by a condition (only true values are stored).\n */\n cReq?: { [uuid: string]: boolean }\n /**\n * Maximum number of children (by definition UUID) for the node.\n */\n childrenMaxCount?: { [uuid: string]: number }\n /**\n * Minimum number of children (by definition UUID) for the node.\n */\n childrenMinCount?: { [uuid: string]: number }\n /**\n * Whether the node children (by definition UUID) are visible (true) or hidden (false).\n * If not defined, the children are visible by default.\n */\n cVis?: { [uuid: string]: boolean }\n /**\n * Hierarchy of ancestor node UUIDs.\n */\n h?: string[]\n /**\n * Hierarchy of code attribute ancestor UUIDs (according to the parent code defs specified).\n */\n hCode?: string[]\n /**\n * True if the value has been auto-filled from the node default value\n */\n defaultValueApplied?: boolean\n /**\n * True if the value has been auto-filled from the user group qualifier\n */\n qualifierValueApplied?: boolean\n}\n\nexport interface NodeRefData {\n categoryItem?: CategoryItem\n taxon?: Taxon\n}\n\nexport interface ArenaRecordNode {\n dateCreated?: string\n dateModified?: string\n id?: number\n meta?: NodeMeta\n nodeDefUuid: string\n parentUuid?: string\n recordUuid: string\n refData?: NodeRefData\n uuid: string\n value?: any\n placeholder?: boolean\n surveyUuid?: string\n\n // transient status variables\n /**\n * Record node has been created but not persisted yet.\n */\n created?: boolean\n /**\n * Record node has been deleted.\n */\n deleted?: boolean\n /**\n * Record node has been modified but not persisted yet.\n */\n updated?: boolean\n}\n\n/**\n * @deprecated Use ArenaRecordNode: this name shadows the DOM Node type.\n * It will be removed in the next major version.\n */\nexport type Node = ArenaRecordNode\n\nexport interface NodesMap {\n [key: string]: ArenaRecordNode\n}\n"]}
|
|
@@ -73,6 +73,10 @@ export declare const getNodeIndex: (node: ArenaRecordNode) => (record: ArenaReco
|
|
|
73
73
|
export declare const findEntityByKeyValues: (survey: Survey, cycle: string, parentEntity: ArenaRecordNode, entityDefUuid: string, keyValuesByDefUuid: Dictionary<any>) => (record: ArenaRecord) => ArenaRecordNode | undefined;
|
|
74
74
|
export declare const findEntityWithSameKeysInAnotherRecord: (survey: Survey, cycle: string, entityUuid: string, recordOther: ArenaRecord) => (record: ArenaRecord) => ArenaRecordNode | undefined;
|
|
75
75
|
export declare const getDependentNodePointers: (survey: Survey, node: ArenaRecordNode, dependencyType: SurveyDependencyType, includeSelf?: boolean, filterFn?: ((nodePointer: NodePointer) => boolean) | null) => (record: ArenaRecord) => NodePointer[];
|
|
76
|
+
/**
|
|
77
|
+
* Returns the code attributes the specified code attribute depends on, from the top level one to the parent one.
|
|
78
|
+
*/
|
|
79
|
+
export declare const getAncestorCodeAttributes: (survey: Survey, parentNode: ArenaRecordNode, nodeDef: NodeDefCode) => (record: ArenaRecord) => ArenaRecordNode[];
|
|
76
80
|
export declare const getAncestorCodePath: (survey: Survey, parentNode: ArenaRecordNode, nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>) => (record: ArenaRecord) => string[];
|
|
77
81
|
export declare const getCategoryItemUuid: (survey: Survey, nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>, parentNode: ArenaRecordNode, code: string) => (record: ArenaRecord) => string | undefined;
|
|
78
82
|
export declare const isNodeFilledByUser: (node: ArenaRecordNode) => (record: ArenaRecord) => boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isInAnalysisStep = exports.getStep = exports.isEmpty = exports.isNodeEmpty = exports.isNodeFilledByUser = exports.getCategoryItemUuid = exports.getAncestorCodePath = exports.getDependentNodePointers = exports.findEntityWithSameKeysInAnotherRecord = exports.findEntityByKeyValues = exports.getNodeIndex = exports.getAttributeSiblings = exports.getEntitySiblings = exports.getEntityKeyValues = exports.getEntityKeyValuesByDefUuid = exports.getEntityKeyNodes = exports.getEntityKeyNodesByDefUuid = exports.findDescendantOrSelf = exports.visitDescendantsAndSelf = exports.isDescendantOf = exports.getDescendant = exports.getDescendantsOrSelf = exports.getAncestorsAndSelf = exports.getAncestor = exports.findAncestor = exports.visitAncestorsAndSelf = exports.getParentCodeAttribute = exports.getDependentCodeAttributes = exports.isNodeRequired = exports.isNodeVisible = exports.isNodeEditable = exports.isNodeApplicable = exports.getNodesByDefUuid = exports.getParent = exports.getChild = exports.getChildren = exports.getRoot = exports.getNodesByUuids = exports.getNodeByUuid = exports.getNodesArray = exports.getNodes = exports.getCycle = void 0;
|
|
3
|
+
exports.isInAnalysisStep = exports.getStep = exports.isEmpty = exports.isNodeEmpty = exports.isNodeFilledByUser = exports.getCategoryItemUuid = exports.getAncestorCodePath = exports.getAncestorCodeAttributes = exports.getDependentNodePointers = exports.findEntityWithSameKeysInAnotherRecord = exports.findEntityByKeyValues = exports.getNodeIndex = exports.getAttributeSiblings = exports.getEntitySiblings = exports.getEntityKeyValues = exports.getEntityKeyValuesByDefUuid = exports.getEntityKeyNodes = exports.getEntityKeyNodesByDefUuid = exports.findDescendantOrSelf = exports.visitDescendantsAndSelf = exports.isDescendantOf = exports.getDescendant = exports.getDescendantsOrSelf = exports.getAncestorsAndSelf = exports.getAncestor = exports.findAncestor = exports.visitAncestorsAndSelf = exports.getParentCodeAttribute = exports.getDependentCodeAttributes = exports.isNodeRequired = exports.isNodeVisible = exports.isNodeEditable = exports.isNodeApplicable = exports.getNodesByDefUuid = exports.getParent = exports.getChild = exports.getChildren = exports.getRoot = exports.getNodesByUuids = exports.getNodeByUuid = exports.getNodesArray = exports.getNodes = exports.getCycle = void 0;
|
|
4
4
|
const common_1 = require("../../common");
|
|
5
5
|
const error_1 = require("../../error");
|
|
6
6
|
const node_1 = require("../../node");
|
|
@@ -400,28 +400,33 @@ const getDependentNodePointers = (survey, node, dependencyType, includeSelf = fa
|
|
|
400
400
|
return nodePointers;
|
|
401
401
|
};
|
|
402
402
|
exports.getDependentNodePointers = getDependentNodePointers;
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
return '';
|
|
409
|
-
const item = survey_1.Surveys.getCategoryItemByUuid({ survey, itemUuid: codeItemUuid });
|
|
410
|
-
return (_a = item === null || item === void 0 ? void 0 : item.props.code) !== null && _a !== void 0 ? _a : '';
|
|
411
|
-
};
|
|
412
|
-
const codePaths = [];
|
|
403
|
+
/**
|
|
404
|
+
* Returns the code attributes the specified code attribute depends on, from the top level one to the parent one.
|
|
405
|
+
*/
|
|
406
|
+
const getAncestorCodeAttributes = (survey, parentNode, nodeDef) => (record) => {
|
|
407
|
+
const ancestorCodeAttributes = [];
|
|
413
408
|
let currentParentCodeAttribute = (0, exports.getParentCodeAttribute)(parentNode, nodeDef)(record);
|
|
414
409
|
while (currentParentCodeAttribute) {
|
|
415
|
-
|
|
416
|
-
codePaths.unshift(ancestorItemCode);
|
|
410
|
+
ancestorCodeAttributes.unshift(currentParentCodeAttribute);
|
|
417
411
|
const ancestorCodeDef = survey_1.Surveys.getNodeDefByUuid({
|
|
418
412
|
survey,
|
|
419
413
|
uuid: currentParentCodeAttribute.nodeDefUuid,
|
|
420
414
|
});
|
|
421
415
|
currentParentCodeAttribute = (0, exports.getParentCodeAttribute)(parentNode, ancestorCodeDef)(record);
|
|
422
416
|
}
|
|
423
|
-
return
|
|
417
|
+
return ancestorCodeAttributes;
|
|
424
418
|
};
|
|
419
|
+
exports.getAncestorCodeAttributes = getAncestorCodeAttributes;
|
|
420
|
+
const getAncestorCodePath = (survey, parentNode, nodeDef) => (record) => (0, exports.getAncestorCodeAttributes)(survey, parentNode, nodeDef)(record).map((codeAttribute) => {
|
|
421
|
+
var _a;
|
|
422
|
+
var _b, _c;
|
|
423
|
+
const codeItemUuid = nodeValues_1.NodeValues.getItemUuid(codeAttribute);
|
|
424
|
+
if (!codeItemUuid)
|
|
425
|
+
return '';
|
|
426
|
+
// items of big categories are not in the survey ref data: they can be in the node ref data
|
|
427
|
+
const item = (_b = (_a = codeAttribute.refData) === null || _a === void 0 ? void 0 : _a.categoryItem) !== null && _b !== void 0 ? _b : survey_1.Surveys.getCategoryItemByUuid({ survey, itemUuid: codeItemUuid });
|
|
428
|
+
return (_c = item === null || item === void 0 ? void 0 : item.props.code) !== null && _c !== void 0 ? _c : '';
|
|
429
|
+
});
|
|
425
430
|
exports.getAncestorCodePath = getAncestorCodePath;
|
|
426
431
|
const getCategoryItemUuid = (survey, nodeDef, parentNode, code) => (record) => {
|
|
427
432
|
const categoryUuid = nodeDef.props.categoryUuid;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordGetters.js","sourceRoot":"","sources":["../../../src/record/_records/recordGetters.ts"],"names":[],"mappings":";;;AAAA,yCAAyD;AACzD,uCAA0D;AAC1D,qCAA0E;AAC1E,sDAAkD;AAClD,2CAA2G;AAC3G,yCAAoD;AAEpD,uCAA2C;AAC3C,sCAA4D;AAC5D,8CAAsD;AACtD,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,OAAO,GAAP,OAAO,CAGnB;AAEM,MAAM,OAAO,GAAG,CAAC,MAAmB,EAAU,EAAE,wBAAC,MAAM,CAAC,IAAI,mCAAI,4BAAmB,GAAA,CAAA;AAA7E,QAAA,OAAO,GAAP,OAAO,CAAsE;AAEnF,MAAM,gBAAgB,GAAG,CAAC,MAAmB,EAAW,EAAE,CAAC,IAAA,QAAA,OAAO,EAAC,MAAM,CAAC,KAAK,mCAAsB,CAAA;AAA/F,QAAA,gBAAgB,GAAhB,gBAAgB,CAA+E","sourcesContent":["import { Dictionary, TraverseMethod } from '../../common'\nimport { SystemError, SystemErrorKeys } from '../../error'\nimport { ArenaRecordNode, NodePointer, Nodes, NodesMap } from '../../node'\nimport { NodeValues } from '../../node/nodeValues'\nimport { NodeDef, NodeDefCode, NodeDefCodeProps, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { defaultCycle, Surveys } from '../../survey'\nimport { Survey, SurveyDependencyType } from '../../survey/survey'\nimport { Arrays, Queue } from '../../utils'\nimport { ArenaRecord, RECORD_STEP_DEFAULT } from '../record'\nimport { RecordStepAnalysisCode } from '../recordStep'\nimport { RecordNodesIndexReader } from './recordNodesIndexReader'\nimport { NodeDefSelfReferences } from './nodeDefSelfReferences'\n\nexport const getCycle = (record: ArenaRecord): string => record.cycle ?? defaultCycle\n\nexport const getNodes = (record: ArenaRecord): Dictionary<ArenaRecordNode> => record.nodes ?? {}\n\nexport const getNodesArray = (record: ArenaRecord): ArenaRecordNode[] => Object.values(getNodes(record))\n\n/**\n * Returns the node with the specified uuid, or undefined if not found.\n * Like the other node getters, it does not throw an error when the node is not found.\n */\nexport const getNodeByUuid =\n (uuid: string) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n record.nodes?.[uuid]\n\nexport const getNodesByUuids =\n (uuids: string[]) =>\n (record: ArenaRecord): ArenaRecordNode[] =>\n uuids.map((uuid: string) => record.nodes?.[uuid]) as ArenaRecordNode[]\n\n/**\n * Returns the root node, or undefined if the record has no nodes.\n */\nexport const getRoot = (record: ArenaRecord): ArenaRecordNode | undefined => {\n const rootUuid = record._nodesIndex ? RecordNodesIndexReader.getNodeRootUuid(record._nodesIndex) : null\n if (rootUuid) {\n return getNodeByUuid(rootUuid)(record)\n }\n return getNodesArray(record).find((node) => !node.parentUuid)\n}\n\nexport const getChildren =\n (parentNode: ArenaRecordNode, childDefUuid?: string) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const childrenUuids = childDefUuid\n ? RecordNodesIndexReader.getNodeUuidsByParentAndChildDef({\n parentNodeUuid: parentNode.uuid,\n childDefUuid,\n })(record._nodesIndex)\n : RecordNodesIndexReader.getNodeUuidsByParent(parentNode.uuid)(record._nodesIndex)\n return getNodesByUuids(childrenUuids)(record)\n }\n return getNodesArray(record).filter(\n (node) => node.parentUuid === parentNode.uuid && (!childDefUuid || node.nodeDefUuid == childDefUuid)\n )\n }\n\n/**\n * Returns the only child of the parent node with the specified node def, or undefined if not found.\n * Throws an error if more than one child is found.\n */\nexport const getChild =\n (parentNode: ArenaRecordNode, childDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const children = getChildren(parentNode, childDefUuid)(record)\n if (children.length > 1) {\n const errorParams = { childDefUuid, parentNodeUuid: parentNode.uuid, recordUuid: record.uuid }\n throw new SystemError(SystemErrorKeys.record.multipleNodesFound, errorParams)\n }\n return children[0]\n }\n\n// called for every ancestor in the record update loops: keep it a plain lookup\nconst getParentNode = (record: ArenaRecord, node: ArenaRecordNode): ArenaRecordNode | undefined =>\n node.parentUuid ? record.nodes?.[node.parentUuid] : undefined\n\nexport const getParent =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n getParentNode(record, node)\n\nexport const getNodesByDefUuid =\n (nodeDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeUuidsByDef(nodeDefUuid)(record._nodesIndex)\n return getNodesByUuids(nodeUuids)(record)\n }\n return getNodesArray(record).filter((node) => node.nodeDefUuid === nodeDefUuid)\n }\n\nconst isNodeFlagTrue =\n (isChildFlagTrue: (parent: ArenaRecordNode, nodeDefUuid: string) => boolean) =>\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean => {\n let child = node\n let parent = getParentNode(record, child)\n while (parent) {\n if (!isChildFlagTrue(parent, child.nodeDefUuid)) return false\n child = parent\n parent = getParentNode(record, child)\n }\n return true\n }\n\nexport const isNodeApplicable = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildApplicable(parent, nodeDefUuid))\nexport const isNodeEditable = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildEditable(parent, nodeDefUuid))\nexport const isNodeVisible = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildVisible(parent, nodeDefUuid))\n\n/**\n * Whether a value is required for the node: key or always required attribute, or attribute with a \"required if\"\n * condition met in its parent entity (evaluated condition stored in the parent node meta).\n */\nexport const isNodeRequired =\n (nodeDef: NodeDef<NodeDefType>, node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean => {\n if (NodeDefs.isKey(nodeDef) || NodeDefs.isRequired(nodeDef)) return true\n if (!NodeDefs.isRequiredIfDefined(nodeDef)) return false\n const parent = getParentNode(record, node)\n return !!parent && Nodes.isChildRequired(parent, nodeDef.uuid)\n }\n\nexport const getDependentCodeAttributes =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeCodeDependentUuids(node.uuid)(record._nodesIndex)\n return getNodesByUuids(nodeUuids)(record)\n }\n throw new SystemError(SystemErrorKeys.record.nodesIndexNotInitialized)\n }\n\nexport const getParentCodeAttribute =\n (parentNode: ArenaRecordNode, nodeDef: NodeDefCode) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(nodeDef)\n if (!parentCodeDefUuid) return undefined\n\n const ancestors = getAncestorsAndSelf(parentNode)(record)\n for (const ancestor of ancestors) {\n const children = getChildren(ancestor, parentCodeDefUuid)(record)\n if (children.length === 1) {\n return children[0]\n }\n }\n return undefined\n }\n\n// ancestors\n\n/**\n * Visits the specified node and its ancestors, from the node up to the root: the visit stops when the visitor returns true.\n */\nexport const visitAncestorsAndSelf =\n (node: ArenaRecordNode, visitor: (node: ArenaRecordNode) => boolean | void) =>\n (record: ArenaRecord): void => {\n let currentNode: ArenaRecordNode | undefined = node\n while (currentNode) {\n if (visitor(currentNode)) return\n currentNode = getParentNode(record, currentNode)\n }\n }\n\n/**\n * Returns the first node satisfying the predicate among the specified node and its ancestors (from the node up to the root).\n */\nexport const findAncestor =\n (node: ArenaRecordNode, predicate: (node: ArenaRecordNode) => boolean) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let result: ArenaRecordNode | undefined = undefined\n visitAncestorsAndSelf(node, (visitedNode) => {\n if (predicate(visitedNode)) {\n result = visitedNode\n return true\n }\n return false\n })(record)\n return result\n }\n\n/**\n * Returns the specified node, if it has the specified node def, or its ancestor with that node def; undefined if not found.\n */\nexport const getAncestor =\n (node: ArenaRecordNode, ancestorDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let ancestor: ArenaRecordNode | undefined = node\n while (ancestor && ancestor.nodeDefUuid !== ancestorDefUuid) {\n ancestor = getParentNode(record, ancestor)\n }\n return ancestor\n }\n\n/**\n * Returns the list of ancestors from the given node to the root entity\n */\nexport const getAncestorsAndSelf =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): Array<ArenaRecordNode> => {\n const ancestors: Array<ArenaRecordNode> = []\n let currentNode: ArenaRecordNode | undefined = node\n while (currentNode) {\n ancestors.push(currentNode)\n currentNode = getParentNode(record, currentNode)\n }\n return ancestors\n }\n\n// descendants\n\nexport const getDescendantsOrSelf =\n (node: ArenaRecordNode, nodeDefDescendant: NodeDef<any>) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (nodeDefDescendant.uuid === node.nodeDefUuid) return [node]\n\n const nodeDefDescendantFullHierarchy = [...nodeDefDescendant.meta.h, nodeDefDescendant.uuid]\n\n // 1. get the descendant node defs uuids starting from node nodeDefUuid (not inclusive) down to the specified nodeDefDescendant uuid\n const descendantNodeDefUuids = nodeDefDescendantFullHierarchy.slice(\n nodeDefDescendantFullHierarchy.indexOf(node.nodeDefUuid) + 1\n )\n // 2. for every level in the hierarchy, find the children having the nodeDefUuid equal to the current one\n let currentAncestors = [node]\n let currentDescendants: ArenaRecordNode[] = []\n for (const currentDescendantDefUuid of descendantNodeDefUuids) {\n for (const currentAncestor of currentAncestors) {\n currentDescendants.push(...getChildren(currentAncestor, currentDescendantDefUuid)(record))\n }\n currentAncestors = currentDescendants\n currentDescendants = []\n }\n return currentAncestors // currentAncestors is equal to the currentDescendants of the last level\n }\n\n/**\n * Returns the first descendant (or the node itself) with the specified node def, or undefined if not found.\n */\nexport const getDescendant =\n (node: ArenaRecordNode, nodeDefDescendant: NodeDef<any>) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n getDescendantsOrSelf(node, nodeDefDescendant)(record)[0]\n\nexport const isDescendantOf = (node: ArenaRecordNode, ancestor: ArenaRecordNode): boolean =>\n Nodes.getHierarchy(node).includes(ancestor.uuid)\n\nexport const visitDescendantsAndSelf =\n (\n node: ArenaRecordNode,\n visitor: (node: ArenaRecordNode) => boolean | void,\n traverseMethod: TraverseMethod = TraverseMethod.bfs\n ) =>\n (record: ArenaRecord): void => {\n if (traverseMethod === TraverseMethod.bfs) {\n const queue = new Queue<ArenaRecordNode>()\n\n queue.enqueue(node)\n\n while (!queue.isEmpty()) {\n const visitedNode = queue.dequeue()!\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren(visitedNode)(record)\n queue.enqueueItems(children)\n }\n } else {\n const stack = []\n\n stack.push(node)\n\n while (stack.length > 0) {\n const visitedNode = stack.pop() as ArenaRecordNode\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren(visitedNode)(record)\n\n // add children to stack in reverse order\n for (let index = children.length - 1; index >= 0; index--) {\n const child = children[index]\n stack.push(child)\n }\n }\n }\n }\n\nexport const findDescendantOrSelf =\n (node: ArenaRecordNode, predicate: (node: ArenaRecordNode) => boolean) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let found = undefined\n\n visitDescendantsAndSelf(node, (currentNode) => {\n if (predicate(currentNode)) {\n found = currentNode\n return true\n }\n return false\n })(record)\n return found\n }\n\nconst getClosestAncestorNode =\n (\n node: ArenaRecordNode,\n nodeDef: NodeDef<NodeDefType, NodeDefProps>,\n dependentDef: NodeDef<NodeDefType, NodeDefProps>,\n dependencyType: SurveyDependencyType\n ) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n // 1a if dependent def is the same as node def, potentially all nodes with\n // nodeDefUuid === dependentDef.uuid in record could be dependent of nodeDef;\n // consider the root node as the closest ancestor node,\n // unless the node def references itself only among the children of its parent entity (e.g. validation \"dbh > 0\")\n if (nodeDef.uuid === dependentDef.uuid) {\n return NodeDefSelfReferences.isSelfReferenceLocal({ nodeDef, dependencyType })\n ? getParent(node)(record)\n : getRoot(record)\n }\n // 1 find common ancestor def\n const commonAncestorDefUuid = Arrays.last(Arrays.intersection(nodeDef.meta.h, dependentDef.meta.h))\n if (!commonAncestorDefUuid) return undefined\n\n // 2 get ancestor node with common parent def\n return getAncestor(node, commonAncestorDefUuid)(record)\n }\n\ntype KeyDefs = NodeDef<NodeDefType, NodeDefProps>[]\n\n/**\n * Returns the key nodes of the entity, indexed by key def uuid; keyDefs, when specified, are used instead of the\n * entity def keys in the cycle.\n */\nexport const getEntityKeyNodesByDefUuid =\n (survey: Survey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): NodesMap => {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const nodeDefKeys = keyDefs ?? Surveys.getNodeDefKeys({ survey, cycle, nodeDef })\n return nodeDefKeys.reduce((acc: NodesMap, nodeDefKey) => {\n const nodeKey = getDescendant(entity, nodeDefKey)(record)\n // missing key nodes are kept as undefined entries\n acc[nodeDefKey.uuid] = nodeKey as ArenaRecordNode\n return acc\n }, {})\n }\n\nexport const getEntityKeyNodes =\n (survey: Survey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): ArenaRecordNode[] =>\n Object.values(getEntityKeyNodesByDefUuid(survey, entity, cycle, keyDefs)(record))\n\nexport const getEntityKeyValuesByDefUuid =\n (survey: Survey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): Dictionary<any> => {\n const keyNodesByDefUuid = getEntityKeyNodesByDefUuid(survey, entity, cycle, keyDefs)(record)\n return Object.entries(keyNodesByDefUuid).reduce((acc: Dictionary<any>, [uuid, keyNode]) => {\n acc[uuid] = keyNode?.value\n return acc\n }, {})\n }\n\nexport const getEntityKeyValues =\n (survey: Survey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): any[] =>\n Object.values(getEntityKeyValuesByDefUuid(survey, entity, cycle, keyDefs)(record))\n\nexport const getEntitySiblings =\n (entity: ArenaRecordNode, includeSelf = false) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n const parentEntity = getParent(entity)(record)\n if (!parentEntity) return []\n const siblingEntities = getChildren(parentEntity, entity.nodeDefUuid)(record)\n return includeSelf ? siblingEntities : siblingEntities.filter((sibling) => !Nodes.areEqual(sibling, entity))\n }\n\nexport const getAttributeSiblings =\n (node: ArenaRecordNode, nodeDef: NodeDef<NodeDefType, NodeDefProps>) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n const parentEntity = getParent(node)(record)\n if (!parentEntity) return []\n const siblingParentEntities = getEntitySiblings(parentEntity)(record)\n return siblingParentEntities.reduce((siblingsAcc: ArenaRecordNode[], siblingEntity) => {\n siblingsAcc.push(...getChildren(siblingEntity, nodeDef.uuid)(record))\n return siblingsAcc\n }, [])\n }\n\nexport const getNodeIndex = (node: ArenaRecordNode) => (record: ArenaRecord) => {\n const parentEntity = getParent(node)(record)\n if (!parentEntity) return 0 // root entity\n const siblings = getChildren(parentEntity, node.nodeDefUuid)(record)\n return siblings.indexOf(node)\n}\n\nexport const findEntityByKeyValues =\n (\n survey: Survey,\n cycle: string,\n parentEntity: ArenaRecordNode,\n entityDefUuid: string,\n keyValuesByDefUuid: Dictionary<any>\n ) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entityDefUuid })\n const siblingEntities = getChildren(parentEntity, entityDefUuid)(record)\n if (NodeDefs.isSingle(entityDef)) {\n return siblingEntities[0]\n }\n const keyDefs = Surveys.getNodeDefKeys({ survey, cycle, nodeDef: entityDef })\n\n return siblingEntities.find((siblingEntity) => {\n const siblingEntityKeyValuesByDefUuid = getEntityKeyValuesByDefUuid(\n survey,\n siblingEntity,\n undefined,\n keyDefs\n )(record)\n return keyDefs.every((keyDef) => {\n const keyValue = siblingEntityKeyValuesByDefUuid[keyDef.uuid]\n const keyValueSearch = keyValuesByDefUuid[keyDef.uuid]\n return NodeValues.isValueEqual({\n survey,\n nodeDef: keyDef,\n value: keyValue,\n valueSearch: keyValueSearch,\n })\n })\n })\n }\n\nexport const findEntityWithSameKeysInAnotherRecord =\n (survey: Survey, cycle: string, entityUuid: string, recordOther: ArenaRecord) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const entity = getNodeByUuid(entityUuid)(record)\n if (!entity) return undefined\n\n let otherRecordCurrentParentEntity = getRoot(recordOther)\n if (!otherRecordCurrentParentEntity) return undefined\n\n const entityAncestorsAndSelf = getAncestorsAndSelf(entity)(record)\n const ancestorDefUuidsAndKeys = entityAncestorsAndSelf.map((ancestor) => ({\n entityDefUuid: ancestor.nodeDefUuid,\n keyValuesByDefUuid: getEntityKeyValuesByDefUuid(survey, ancestor)(record),\n }))\n\n const ancestorDefUuidsAndKeysToVisit = [...ancestorDefUuidsAndKeys].reverse()\n\n for (let index = 1; otherRecordCurrentParentEntity && index < ancestorDefUuidsAndKeysToVisit.length; index++) {\n const { entityDefUuid, keyValuesByDefUuid } = ancestorDefUuidsAndKeysToVisit[index]\n otherRecordCurrentParentEntity = findEntityByKeyValues(\n survey,\n cycle,\n otherRecordCurrentParentEntity,\n entityDefUuid,\n keyValuesByDefUuid\n )(recordOther)\n }\n return otherRecordCurrentParentEntity\n }\n\nexport const getDependentNodePointers =\n (\n survey: Survey,\n node: ArenaRecordNode,\n dependencyType: SurveyDependencyType,\n includeSelf = false,\n filterFn: ((nodePointer: NodePointer) => boolean) | null = null\n ) =>\n (record: ArenaRecord): NodePointer[] => {\n const nodeDefUuid = node.nodeDefUuid\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: nodeDefUuid })\n const dependentDefs = Surveys.getNodeDefDependents({ survey, nodeDefUuid, dependencyType })\n const nodePointers: Array<NodePointer> = []\n\n const addToNodePointers = (nodePointer: NodePointer): void => {\n if (filterFn === null || filterFn(nodePointer)) {\n nodePointers.push(nodePointer)\n }\n }\n\n for (const dependentDef of dependentDefs) {\n // 1 find common ancestor node\n const commonAncestorNode = getClosestAncestorNode(node, nodeDef, dependentDef, dependencyType)(record)\n if (!commonAncestorNode) continue\n\n const nodeDefDependentParent = Surveys.getNodeDefParent({ survey, nodeDef: dependentDef })\n if (!nodeDefDependentParent) throw new SystemError(SystemErrorKeys.record.dependencyOnRootFound)\n\n // 2 find descendant nodes of common parent node with nodeDefUuid = dependentDef uuid\n const dependentContextNodes = getDescendantsOrSelf(commonAncestorNode, nodeDefDependentParent)(record)\n\n for (const dependentContextNode of dependentContextNodes) {\n addToNodePointers({\n nodeCtx: dependentContextNode,\n nodeDef: dependentDef,\n })\n }\n }\n if (includeSelf) {\n const parentNode = getParent(node)(record)\n if (parentNode) {\n addToNodePointers({\n nodeCtx: parentNode,\n nodeDef,\n })\n }\n }\n\n return nodePointers\n }\n\nexport const getAncestorCodePath =\n (survey: Survey, parentNode: ArenaRecordNode, nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>) =>\n (record: ArenaRecord): string[] => {\n const getCodeAttributeItemCode = (codeAttribute: ArenaRecordNode | undefined): string => {\n const codeItemUuid = codeAttribute ? NodeValues.getItemUuid(codeAttribute) : undefined\n if (!codeItemUuid) return ''\n const item = Surveys.getCategoryItemByUuid({ survey, itemUuid: codeItemUuid })\n return item?.props.code ?? ''\n }\n\n const codePaths = []\n let currentParentCodeAttribute = getParentCodeAttribute(parentNode, nodeDef)(record)\n\n while (currentParentCodeAttribute) {\n const ancestorItemCode = getCodeAttributeItemCode(currentParentCodeAttribute)\n codePaths.unshift(ancestorItemCode)\n const ancestorCodeDef = Surveys.getNodeDefByUuid({\n survey,\n uuid: currentParentCodeAttribute.nodeDefUuid,\n }) as NodeDefCode\n currentParentCodeAttribute = getParentCodeAttribute(parentNode, ancestorCodeDef)(record)\n }\n return codePaths\n }\n\nexport const getCategoryItemUuid =\n (survey: Survey, nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>, parentNode: ArenaRecordNode, code: string) =>\n (record: ArenaRecord): string | undefined => {\n const categoryUuid = nodeDef.props.categoryUuid\n\n const codePaths = [...getAncestorCodePath(survey, parentNode, nodeDef)(record), code]\n\n const item = Surveys.getCategoryItemByCodePaths({ survey, categoryUuid, codePaths })\n\n return item?.uuid\n }\n\nexport const isNodeFilledByUser =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean =>\n !!findDescendantOrSelf(node, (visitedNode) => Nodes.hasUserInputValue(visitedNode))(record)\n\nexport const isNodeEmpty =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean =>\n !isNodeFilledByUser(node)(record)\n\nexport const isEmpty = (record: ArenaRecord): boolean => {\n const rootNode = getRoot(record)\n return rootNode ? isNodeEmpty(rootNode)(record) : true\n}\n\nexport const getStep = (record: ArenaRecord): string => record.step ?? RECORD_STEP_DEFAULT\n\nexport const isInAnalysisStep = (record: ArenaRecord): boolean => getStep(record) === RecordStepAnalysisCode\n"]}
|
|
1
|
+
{"version":3,"file":"recordGetters.js","sourceRoot":"","sources":["../../../src/record/_records/recordGetters.ts"],"names":[],"mappings":";;;AAAA,yCAAyD;AACzD,uCAA0D;AAC1D,qCAA0E;AAC1E,sDAAkD;AAClD,2CAA2G;AAC3G,yCAAoD;AAEpD,uCAA2C;AAC3C,sCAA4D;AAC5D,8CAAsD;AACtD,qEAAiE;AACjE,mEAA+D;AAExD,MAAM,QAAQ,GAAG,CAAC,MAAmB,EAAU,EAAE,wBAAC,MAAM,CAAC,KAAK,mCAAI,qBAAY,GAAA,CAAA;AAAxE,QAAA,QAAQ,GAAR,QAAQ,CAAgE;AAE9E,MAAM,QAAQ,GAAG,CAAC,MAAmB,EAA+B,EAAE,wBAAC,MAAM,CAAC,KAAK,mCAAI,EAAE,GAAA,CAAA;AAAnF,QAAA,QAAQ,GAAR,QAAQ,CAA2E;AAEzF,MAAM,aAAa,GAAG,CAAC,MAAmB,EAAqB,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAA,QAAA,QAAQ,EAAC,MAAM,CAAC,CAAC,CAAA;AAA3F,QAAA,aAAa,GAAb,aAAa,CAA8E;AAExG;;;GAGG;AACI,MAAM,aAAa,GACxB,CAAC,IAAY,EAAE,EAAE,CACjB,CAAC,MAAmB,EAA+B,EAAE,kBACnD,MAAA,MAAM,CAAC,KAAK,0CAAG,IAAI,CAAC,GAAA,CAAA;AAHX,QAAA,aAAa,GAAb,aAAa,CAGF;AAEjB,MAAM,eAAe,GAC1B,CAAC,KAAe,EAAE,EAAE,CACpB,CAAC,MAAmB,EAAqB,EAAE,CACzC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE,kBAAC,MAAA,MAAM,CAAC,KAAK,0CAAG,IAAI,CAAC,GA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,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AAHlF,QAAA,kBAAkB,GAAlB,kBAAkB,CAGgE;AAExF,MAAM,WAAW,GACtB,CAAC,IAAqB,EAAE,EAAE,CAC1B,CAAC,MAAmB,EAAW,EAAE,CAC/B,CAAC,IAAA,QAAA,kBAAkB,EAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAA;AAHxB,QAAA,WAAW,GAAX,WAAW,CAGa;AAE9B,MAAM,OAAO,GAAG,CAAC,MAAmB,EAAW,EAAE;IACtD,MAAM,QAAQ,GAAG,IAAA,QAAA,OAAO,EAAC,MAAM,CAAC,CAAA;IAChC,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAA,QAAA,WAAW,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACxD,CAAC,CAAA;AAHY,QAAA,OAAO,GAAP,OAAO,CAGnB;AAEM,MAAM,OAAO,GAAG,CAAC,MAAmB,EAAU,EAAE,wBAAC,MAAM,CAAC,IAAI,mCAAI,4BAAmB,GAAA,CAAA;AAA7E,QAAA,OAAO,GAAP,OAAO,CAAsE;AAEnF,MAAM,gBAAgB,GAAG,CAAC,MAAmB,EAAW,EAAE,CAAC,IAAA,QAAA,OAAO,EAAC,MAAM,CAAC,KAAK,mCAAsB,CAAA;AAA/F,QAAA,gBAAgB,GAAhB,gBAAgB,CAA+E","sourcesContent":["import { Dictionary, TraverseMethod } from '../../common'\nimport { SystemError, SystemErrorKeys } from '../../error'\nimport { ArenaRecordNode, NodePointer, Nodes, NodesMap } from '../../node'\nimport { NodeValues } from '../../node/nodeValues'\nimport { NodeDef, NodeDefCode, NodeDefCodeProps, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { defaultCycle, Surveys } from '../../survey'\nimport { Survey, SurveyDependencyType } from '../../survey/survey'\nimport { Arrays, Queue } from '../../utils'\nimport { ArenaRecord, RECORD_STEP_DEFAULT } from '../record'\nimport { RecordStepAnalysisCode } from '../recordStep'\nimport { RecordNodesIndexReader } from './recordNodesIndexReader'\nimport { NodeDefSelfReferences } from './nodeDefSelfReferences'\n\nexport const getCycle = (record: ArenaRecord): string => record.cycle ?? defaultCycle\n\nexport const getNodes = (record: ArenaRecord): Dictionary<ArenaRecordNode> => record.nodes ?? {}\n\nexport const getNodesArray = (record: ArenaRecord): ArenaRecordNode[] => Object.values(getNodes(record))\n\n/**\n * Returns the node with the specified uuid, or undefined if not found.\n * Like the other node getters, it does not throw an error when the node is not found.\n */\nexport const getNodeByUuid =\n (uuid: string) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n record.nodes?.[uuid]\n\nexport const getNodesByUuids =\n (uuids: string[]) =>\n (record: ArenaRecord): ArenaRecordNode[] =>\n uuids.map((uuid: string) => record.nodes?.[uuid]) as ArenaRecordNode[]\n\n/**\n * Returns the root node, or undefined if the record has no nodes.\n */\nexport const getRoot = (record: ArenaRecord): ArenaRecordNode | undefined => {\n const rootUuid = record._nodesIndex ? RecordNodesIndexReader.getNodeRootUuid(record._nodesIndex) : null\n if (rootUuid) {\n return getNodeByUuid(rootUuid)(record)\n }\n return getNodesArray(record).find((node) => !node.parentUuid)\n}\n\nexport const getChildren =\n (parentNode: ArenaRecordNode, childDefUuid?: string) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const childrenUuids = childDefUuid\n ? RecordNodesIndexReader.getNodeUuidsByParentAndChildDef({\n parentNodeUuid: parentNode.uuid,\n childDefUuid,\n })(record._nodesIndex)\n : RecordNodesIndexReader.getNodeUuidsByParent(parentNode.uuid)(record._nodesIndex)\n return getNodesByUuids(childrenUuids)(record)\n }\n return getNodesArray(record).filter(\n (node) => node.parentUuid === parentNode.uuid && (!childDefUuid || node.nodeDefUuid == childDefUuid)\n )\n }\n\n/**\n * Returns the only child of the parent node with the specified node def, or undefined if not found.\n * Throws an error if more than one child is found.\n */\nexport const getChild =\n (parentNode: ArenaRecordNode, childDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const children = getChildren(parentNode, childDefUuid)(record)\n if (children.length > 1) {\n const errorParams = { childDefUuid, parentNodeUuid: parentNode.uuid, recordUuid: record.uuid }\n throw new SystemError(SystemErrorKeys.record.multipleNodesFound, errorParams)\n }\n return children[0]\n }\n\n// called for every ancestor in the record update loops: keep it a plain lookup\nconst getParentNode = (record: ArenaRecord, node: ArenaRecordNode): ArenaRecordNode | undefined =>\n node.parentUuid ? record.nodes?.[node.parentUuid] : undefined\n\nexport const getParent =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n getParentNode(record, node)\n\nexport const getNodesByDefUuid =\n (nodeDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeUuidsByDef(nodeDefUuid)(record._nodesIndex)\n return getNodesByUuids(nodeUuids)(record)\n }\n return getNodesArray(record).filter((node) => node.nodeDefUuid === nodeDefUuid)\n }\n\nconst isNodeFlagTrue =\n (isChildFlagTrue: (parent: ArenaRecordNode, nodeDefUuid: string) => boolean) =>\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean => {\n let child = node\n let parent = getParentNode(record, child)\n while (parent) {\n if (!isChildFlagTrue(parent, child.nodeDefUuid)) return false\n child = parent\n parent = getParentNode(record, child)\n }\n return true\n }\n\nexport const isNodeApplicable = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildApplicable(parent, nodeDefUuid))\nexport const isNodeEditable = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildEditable(parent, nodeDefUuid))\nexport const isNodeVisible = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildVisible(parent, nodeDefUuid))\n\n/**\n * Whether a value is required for the node: key or always required attribute, or attribute with a \"required if\"\n * condition met in its parent entity (evaluated condition stored in the parent node meta).\n */\nexport const isNodeRequired =\n (nodeDef: NodeDef<NodeDefType>, node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean => {\n if (NodeDefs.isKey(nodeDef) || NodeDefs.isRequired(nodeDef)) return true\n if (!NodeDefs.isRequiredIfDefined(nodeDef)) return false\n const parent = getParentNode(record, node)\n return !!parent && Nodes.isChildRequired(parent, nodeDef.uuid)\n }\n\nexport const getDependentCodeAttributes =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeCodeDependentUuids(node.uuid)(record._nodesIndex)\n return getNodesByUuids(nodeUuids)(record)\n }\n throw new SystemError(SystemErrorKeys.record.nodesIndexNotInitialized)\n }\n\nexport const getParentCodeAttribute =\n (parentNode: ArenaRecordNode, nodeDef: NodeDefCode) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(nodeDef)\n if (!parentCodeDefUuid) return undefined\n\n const ancestors = getAncestorsAndSelf(parentNode)(record)\n for (const ancestor of ancestors) {\n const children = getChildren(ancestor, parentCodeDefUuid)(record)\n if (children.length === 1) {\n return children[0]\n }\n }\n return undefined\n }\n\n// ancestors\n\n/**\n * Visits the specified node and its ancestors, from the node up to the root: the visit stops when the visitor returns true.\n */\nexport const visitAncestorsAndSelf =\n (node: ArenaRecordNode, visitor: (node: ArenaRecordNode) => boolean | void) =>\n (record: ArenaRecord): void => {\n let currentNode: ArenaRecordNode | undefined = node\n while (currentNode) {\n if (visitor(currentNode)) return\n currentNode = getParentNode(record, currentNode)\n }\n }\n\n/**\n * Returns the first node satisfying the predicate among the specified node and its ancestors (from the node up to the root).\n */\nexport const findAncestor =\n (node: ArenaRecordNode, predicate: (node: ArenaRecordNode) => boolean) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let result: ArenaRecordNode | undefined = undefined\n visitAncestorsAndSelf(node, (visitedNode) => {\n if (predicate(visitedNode)) {\n result = visitedNode\n return true\n }\n return false\n })(record)\n return result\n }\n\n/**\n * Returns the specified node, if it has the specified node def, or its ancestor with that node def; undefined if not found.\n */\nexport const getAncestor =\n (node: ArenaRecordNode, ancestorDefUuid: string) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let ancestor: ArenaRecordNode | undefined = node\n while (ancestor && ancestor.nodeDefUuid !== ancestorDefUuid) {\n ancestor = getParentNode(record, ancestor)\n }\n return ancestor\n }\n\n/**\n * Returns the list of ancestors from the given node to the root entity\n */\nexport const getAncestorsAndSelf =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): Array<ArenaRecordNode> => {\n const ancestors: Array<ArenaRecordNode> = []\n let currentNode: ArenaRecordNode | undefined = node\n while (currentNode) {\n ancestors.push(currentNode)\n currentNode = getParentNode(record, currentNode)\n }\n return ancestors\n }\n\n// descendants\n\nexport const getDescendantsOrSelf =\n (node: ArenaRecordNode, nodeDefDescendant: NodeDef<any>) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n if (nodeDefDescendant.uuid === node.nodeDefUuid) return [node]\n\n const nodeDefDescendantFullHierarchy = [...nodeDefDescendant.meta.h, nodeDefDescendant.uuid]\n\n // 1. get the descendant node defs uuids starting from node nodeDefUuid (not inclusive) down to the specified nodeDefDescendant uuid\n const descendantNodeDefUuids = nodeDefDescendantFullHierarchy.slice(\n nodeDefDescendantFullHierarchy.indexOf(node.nodeDefUuid) + 1\n )\n // 2. for every level in the hierarchy, find the children having the nodeDefUuid equal to the current one\n let currentAncestors = [node]\n let currentDescendants: ArenaRecordNode[] = []\n for (const currentDescendantDefUuid of descendantNodeDefUuids) {\n for (const currentAncestor of currentAncestors) {\n currentDescendants.push(...getChildren(currentAncestor, currentDescendantDefUuid)(record))\n }\n currentAncestors = currentDescendants\n currentDescendants = []\n }\n return currentAncestors // currentAncestors is equal to the currentDescendants of the last level\n }\n\n/**\n * Returns the first descendant (or the node itself) with the specified node def, or undefined if not found.\n */\nexport const getDescendant =\n (node: ArenaRecordNode, nodeDefDescendant: NodeDef<any>) =>\n (record: ArenaRecord): ArenaRecordNode | undefined =>\n getDescendantsOrSelf(node, nodeDefDescendant)(record)[0]\n\nexport const isDescendantOf = (node: ArenaRecordNode, ancestor: ArenaRecordNode): boolean =>\n Nodes.getHierarchy(node).includes(ancestor.uuid)\n\nexport const visitDescendantsAndSelf =\n (\n node: ArenaRecordNode,\n visitor: (node: ArenaRecordNode) => boolean | void,\n traverseMethod: TraverseMethod = TraverseMethod.bfs\n ) =>\n (record: ArenaRecord): void => {\n if (traverseMethod === TraverseMethod.bfs) {\n const queue = new Queue<ArenaRecordNode>()\n\n queue.enqueue(node)\n\n while (!queue.isEmpty()) {\n const visitedNode = queue.dequeue()!\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren(visitedNode)(record)\n queue.enqueueItems(children)\n }\n } else {\n const stack = []\n\n stack.push(node)\n\n while (stack.length > 0) {\n const visitedNode = stack.pop() as ArenaRecordNode\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren(visitedNode)(record)\n\n // add children to stack in reverse order\n for (let index = children.length - 1; index >= 0; index--) {\n const child = children[index]\n stack.push(child)\n }\n }\n }\n }\n\nexport const findDescendantOrSelf =\n (node: ArenaRecordNode, predicate: (node: ArenaRecordNode) => boolean) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n let found = undefined\n\n visitDescendantsAndSelf(node, (currentNode) => {\n if (predicate(currentNode)) {\n found = currentNode\n return true\n }\n return false\n })(record)\n return found\n }\n\nconst getClosestAncestorNode =\n (\n node: ArenaRecordNode,\n nodeDef: NodeDef<NodeDefType, NodeDefProps>,\n dependentDef: NodeDef<NodeDefType, NodeDefProps>,\n dependencyType: SurveyDependencyType\n ) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n // 1a if dependent def is the same as node def, potentially all nodes with\n // nodeDefUuid === dependentDef.uuid in record could be dependent of nodeDef;\n // consider the root node as the closest ancestor node,\n // unless the node def references itself only among the children of its parent entity (e.g. validation \"dbh > 0\")\n if (nodeDef.uuid === dependentDef.uuid) {\n return NodeDefSelfReferences.isSelfReferenceLocal({ nodeDef, dependencyType })\n ? getParent(node)(record)\n : getRoot(record)\n }\n // 1 find common ancestor def\n const commonAncestorDefUuid = Arrays.last(Arrays.intersection(nodeDef.meta.h, dependentDef.meta.h))\n if (!commonAncestorDefUuid) return undefined\n\n // 2 get ancestor node with common parent def\n return getAncestor(node, commonAncestorDefUuid)(record)\n }\n\ntype KeyDefs = NodeDef<NodeDefType, NodeDefProps>[]\n\n/**\n * Returns the key nodes of the entity, indexed by key def uuid; keyDefs, when specified, are used instead of the\n * entity def keys in the cycle.\n */\nexport const getEntityKeyNodesByDefUuid =\n (survey: Survey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): NodesMap => {\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const nodeDefKeys = keyDefs ?? Surveys.getNodeDefKeys({ survey, cycle, nodeDef })\n return nodeDefKeys.reduce((acc: NodesMap, nodeDefKey) => {\n const nodeKey = getDescendant(entity, nodeDefKey)(record)\n // missing key nodes are kept as undefined entries\n acc[nodeDefKey.uuid] = nodeKey as ArenaRecordNode\n return acc\n }, {})\n }\n\nexport const getEntityKeyNodes =\n (survey: Survey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): ArenaRecordNode[] =>\n Object.values(getEntityKeyNodesByDefUuid(survey, entity, cycle, keyDefs)(record))\n\nexport const getEntityKeyValuesByDefUuid =\n (survey: Survey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): Dictionary<any> => {\n const keyNodesByDefUuid = getEntityKeyNodesByDefUuid(survey, entity, cycle, keyDefs)(record)\n return Object.entries(keyNodesByDefUuid).reduce((acc: Dictionary<any>, [uuid, keyNode]) => {\n acc[uuid] = keyNode?.value\n return acc\n }, {})\n }\n\nexport const getEntityKeyValues =\n (survey: Survey, entity: ArenaRecordNode, cycle?: string, keyDefs?: KeyDefs) =>\n (record: ArenaRecord): any[] =>\n Object.values(getEntityKeyValuesByDefUuid(survey, entity, cycle, keyDefs)(record))\n\nexport const getEntitySiblings =\n (entity: ArenaRecordNode, includeSelf = false) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n const parentEntity = getParent(entity)(record)\n if (!parentEntity) return []\n const siblingEntities = getChildren(parentEntity, entity.nodeDefUuid)(record)\n return includeSelf ? siblingEntities : siblingEntities.filter((sibling) => !Nodes.areEqual(sibling, entity))\n }\n\nexport const getAttributeSiblings =\n (node: ArenaRecordNode, nodeDef: NodeDef<NodeDefType, NodeDefProps>) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n const parentEntity = getParent(node)(record)\n if (!parentEntity) return []\n const siblingParentEntities = getEntitySiblings(parentEntity)(record)\n return siblingParentEntities.reduce((siblingsAcc: ArenaRecordNode[], siblingEntity) => {\n siblingsAcc.push(...getChildren(siblingEntity, nodeDef.uuid)(record))\n return siblingsAcc\n }, [])\n }\n\nexport const getNodeIndex = (node: ArenaRecordNode) => (record: ArenaRecord) => {\n const parentEntity = getParent(node)(record)\n if (!parentEntity) return 0 // root entity\n const siblings = getChildren(parentEntity, node.nodeDefUuid)(record)\n return siblings.indexOf(node)\n}\n\nexport const findEntityByKeyValues =\n (\n survey: Survey,\n cycle: string,\n parentEntity: ArenaRecordNode,\n entityDefUuid: string,\n keyValuesByDefUuid: Dictionary<any>\n ) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entityDefUuid })\n const siblingEntities = getChildren(parentEntity, entityDefUuid)(record)\n if (NodeDefs.isSingle(entityDef)) {\n return siblingEntities[0]\n }\n const keyDefs = Surveys.getNodeDefKeys({ survey, cycle, nodeDef: entityDef })\n\n return siblingEntities.find((siblingEntity) => {\n const siblingEntityKeyValuesByDefUuid = getEntityKeyValuesByDefUuid(\n survey,\n siblingEntity,\n undefined,\n keyDefs\n )(record)\n return keyDefs.every((keyDef) => {\n const keyValue = siblingEntityKeyValuesByDefUuid[keyDef.uuid]\n const keyValueSearch = keyValuesByDefUuid[keyDef.uuid]\n return NodeValues.isValueEqual({\n survey,\n nodeDef: keyDef,\n value: keyValue,\n valueSearch: keyValueSearch,\n })\n })\n })\n }\n\nexport const findEntityWithSameKeysInAnotherRecord =\n (survey: Survey, cycle: string, entityUuid: string, recordOther: ArenaRecord) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const entity = getNodeByUuid(entityUuid)(record)\n if (!entity) return undefined\n\n let otherRecordCurrentParentEntity = getRoot(recordOther)\n if (!otherRecordCurrentParentEntity) return undefined\n\n const entityAncestorsAndSelf = getAncestorsAndSelf(entity)(record)\n const ancestorDefUuidsAndKeys = entityAncestorsAndSelf.map((ancestor) => ({\n entityDefUuid: ancestor.nodeDefUuid,\n keyValuesByDefUuid: getEntityKeyValuesByDefUuid(survey, ancestor)(record),\n }))\n\n const ancestorDefUuidsAndKeysToVisit = [...ancestorDefUuidsAndKeys].reverse()\n\n for (let index = 1; otherRecordCurrentParentEntity && index < ancestorDefUuidsAndKeysToVisit.length; index++) {\n const { entityDefUuid, keyValuesByDefUuid } = ancestorDefUuidsAndKeysToVisit[index]\n otherRecordCurrentParentEntity = findEntityByKeyValues(\n survey,\n cycle,\n otherRecordCurrentParentEntity,\n entityDefUuid,\n keyValuesByDefUuid\n )(recordOther)\n }\n return otherRecordCurrentParentEntity\n }\n\nexport const getDependentNodePointers =\n (\n survey: Survey,\n node: ArenaRecordNode,\n dependencyType: SurveyDependencyType,\n includeSelf = false,\n filterFn: ((nodePointer: NodePointer) => boolean) | null = null\n ) =>\n (record: ArenaRecord): NodePointer[] => {\n const nodeDefUuid = node.nodeDefUuid\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: nodeDefUuid })\n const dependentDefs = Surveys.getNodeDefDependents({ survey, nodeDefUuid, dependencyType })\n const nodePointers: Array<NodePointer> = []\n\n const addToNodePointers = (nodePointer: NodePointer): void => {\n if (filterFn === null || filterFn(nodePointer)) {\n nodePointers.push(nodePointer)\n }\n }\n\n for (const dependentDef of dependentDefs) {\n // 1 find common ancestor node\n const commonAncestorNode = getClosestAncestorNode(node, nodeDef, dependentDef, dependencyType)(record)\n if (!commonAncestorNode) continue\n\n const nodeDefDependentParent = Surveys.getNodeDefParent({ survey, nodeDef: dependentDef })\n if (!nodeDefDependentParent) throw new SystemError(SystemErrorKeys.record.dependencyOnRootFound)\n\n // 2 find descendant nodes of common parent node with nodeDefUuid = dependentDef uuid\n const dependentContextNodes = getDescendantsOrSelf(commonAncestorNode, nodeDefDependentParent)(record)\n\n for (const dependentContextNode of dependentContextNodes) {\n addToNodePointers({\n nodeCtx: dependentContextNode,\n nodeDef: dependentDef,\n })\n }\n }\n if (includeSelf) {\n const parentNode = getParent(node)(record)\n if (parentNode) {\n addToNodePointers({\n nodeCtx: parentNode,\n nodeDef,\n })\n }\n }\n\n return nodePointers\n }\n\n/**\n * Returns the code attributes the specified code attribute depends on, from the top level one to the parent one.\n */\nexport const getAncestorCodeAttributes =\n (survey: Survey, parentNode: ArenaRecordNode, nodeDef: NodeDefCode) =>\n (record: ArenaRecord): ArenaRecordNode[] => {\n const ancestorCodeAttributes = []\n let currentParentCodeAttribute = getParentCodeAttribute(parentNode, nodeDef)(record)\n while (currentParentCodeAttribute) {\n ancestorCodeAttributes.unshift(currentParentCodeAttribute)\n const ancestorCodeDef = Surveys.getNodeDefByUuid({\n survey,\n uuid: currentParentCodeAttribute.nodeDefUuid,\n }) as NodeDefCode\n currentParentCodeAttribute = getParentCodeAttribute(parentNode, ancestorCodeDef)(record)\n }\n return ancestorCodeAttributes\n }\n\nexport const getAncestorCodePath =\n (survey: Survey, parentNode: ArenaRecordNode, nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>) =>\n (record: ArenaRecord): string[] =>\n getAncestorCodeAttributes(\n survey,\n parentNode,\n nodeDef\n )(record).map((codeAttribute) => {\n const codeItemUuid = NodeValues.getItemUuid(codeAttribute)\n if (!codeItemUuid) return ''\n // items of big categories are not in the survey ref data: they can be in the node ref data\n const item =\n codeAttribute.refData?.categoryItem ?? Surveys.getCategoryItemByUuid({ survey, itemUuid: codeItemUuid })\n return item?.props.code ?? ''\n })\n\nexport const getCategoryItemUuid =\n (survey: Survey, nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>, parentNode: ArenaRecordNode, code: string) =>\n (record: ArenaRecord): string | undefined => {\n const categoryUuid = nodeDef.props.categoryUuid\n\n const codePaths = [...getAncestorCodePath(survey, parentNode, nodeDef)(record), code]\n\n const item = Surveys.getCategoryItemByCodePaths({ survey, categoryUuid, codePaths })\n\n return item?.uuid\n }\n\nexport const isNodeFilledByUser =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean =>\n !!findDescendantOrSelf(node, (visitedNode) => Nodes.hasUserInputValue(visitedNode))(record)\n\nexport const isNodeEmpty =\n (node: ArenaRecordNode) =>\n (record: ArenaRecord): boolean =>\n !isNodeFilledByUser(node)(record)\n\nexport const isEmpty = (record: ArenaRecord): boolean => {\n const rootNode = getRoot(record)\n return rootNode ? isNodeEmpty(rootNode)(record) : true\n}\n\nexport const getStep = (record: ArenaRecord): string => record.step ?? RECORD_STEP_DEFAULT\n\nexport const isInAnalysisStep = (record: ArenaRecord): boolean => getStep(record) === RecordStepAnalysisCode\n"]}
|
|
@@ -21,6 +21,10 @@ const assignNewUuidsToNodes = (params) => {
|
|
|
21
21
|
const recordUpdated = sideEffect ? record : Object.assign({}, record);
|
|
22
22
|
const nodes = (_a = recordUpdated.nodes) !== null && _a !== void 0 ? _a : {};
|
|
23
23
|
const nodesUpdated = sideEffect ? nodes : Object.assign({}, nodes);
|
|
24
|
+
// new uuids generated in advance: meta.hCode can reference nodes cloned later (e.g. sibling code attributes)
|
|
25
|
+
for (const node of nodesArray) {
|
|
26
|
+
newNodeUuidsByOldUuid[node.uuid] = utils_1.UUIDs.v4();
|
|
27
|
+
}
|
|
24
28
|
// update nodes recordUuid and properties (it does side effect on nodes)
|
|
25
29
|
nodesArray.forEach((node) => {
|
|
26
30
|
var _a;
|
|
@@ -29,8 +33,7 @@ const assignNewUuidsToNodes = (params) => {
|
|
|
29
33
|
nodeUpdated.recordUuid = record.uuid;
|
|
30
34
|
nodeUpdated.dateCreated = nodeUpdated.dateModified = utils_1.Dates.nowFormattedForStorage();
|
|
31
35
|
const oldUuid = node.uuid;
|
|
32
|
-
const newUuid =
|
|
33
|
-
newNodeUuidsByOldUuid[oldUuid] = newUuid;
|
|
36
|
+
const newUuid = newNodeUuidsByOldUuid[oldUuid];
|
|
34
37
|
nodeUpdated.uuid = newUuid;
|
|
35
38
|
// consider every node as just created node
|
|
36
39
|
delete nodeUpdated.id;
|
|
@@ -50,6 +53,15 @@ const assignNewUuidsToNodes = (params) => {
|
|
|
50
53
|
sideEffect,
|
|
51
54
|
});
|
|
52
55
|
}
|
|
56
|
+
const hierarchyCode = node_1.Nodes.getHierarchyCode(node);
|
|
57
|
+
if (hierarchyCode.length > 0) {
|
|
58
|
+
nodeUpdated = utils_1.Objects.assocPath({
|
|
59
|
+
obj: nodeUpdated,
|
|
60
|
+
path: [node_2.NodeKeys.meta, node_2.NodeMetaKeys.hCode],
|
|
61
|
+
value: hierarchyCode.map((ancestorCodeUuid) => newNodeUuidsByOldUuid[ancestorCodeUuid]),
|
|
62
|
+
sideEffect,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
53
65
|
// assign new file uuid (file should be cloned elsewhere)
|
|
54
66
|
const fileUuid = node_1.NodeValues.getFileUuid(node);
|
|
55
67
|
if (fileUuid) {
|