@openforis/arena-core 2.5.5 → 2.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/record/_records/recordGetters.js +20 -5
- package/dist/esm/record/_records/recordGetters.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js +3 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js.map +1 -1
- package/dist/esm/registry/index.js.map +1 -1
- package/dist/esm/registry/serviceRegistry.js.map +1 -1
- package/dist/esm/registry/serviceTypeMap.js +2 -0
- package/dist/esm/registry/serviceTypeMap.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js.map +1 -1
- package/dist/record/_records/recordGetters.d.ts +19 -2
- package/dist/record/_records/recordGetters.js +20 -5
- package/dist/record/_records/recordGetters.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js +3 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js.map +1 -1
- package/dist/record/records.d.ts +2 -2
- package/dist/registry/index.d.ts +1 -0
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/serviceRegistry.d.ts +2 -0
- package/dist/registry/serviceRegistry.js.map +1 -1
- package/dist/registry/serviceTypeMap.d.ts +28 -0
- package/dist/registry/serviceTypeMap.js +4 -0
- package/dist/registry/serviceTypeMap.js.map +1 -0
- package/package.json +1 -1
|
@@ -27,21 +27,32 @@ export type PositionalRecordGetter<P, A extends unknown[], R> = {
|
|
|
27
27
|
export declare const getCycle: (record: ArenaRecord) => string;
|
|
28
28
|
export declare const getNodes: (record: ArenaRecord) => Dictionary<ArenaRecordNode>;
|
|
29
29
|
export declare const getNodesArray: (record: ArenaRecord) => ArenaRecordNode[];
|
|
30
|
+
/**
|
|
31
|
+
* Returns the node with the specified uuid, or undefined if not found.
|
|
32
|
+
* Like the other node getters, it does not throw an error when the node is not found.
|
|
33
|
+
*/
|
|
30
34
|
export declare const getNodeByUuid: PositionalRecordGetter<{
|
|
31
35
|
uuid: string;
|
|
32
36
|
}, [uuid: string], ArenaRecordNode | undefined>;
|
|
33
37
|
export declare const getNodesByUuids: PositionalRecordGetter<{
|
|
34
38
|
uuids: string[];
|
|
35
39
|
}, [uuids: string[]], ArenaRecordNode[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the root node, or undefined if the record has no nodes.
|
|
42
|
+
*/
|
|
36
43
|
export declare const getRoot: (record: ArenaRecord) => ArenaRecordNode | undefined;
|
|
37
44
|
export declare const getChildren: PositionalRecordGetter<{
|
|
38
45
|
parentNode: ArenaRecordNode;
|
|
39
46
|
childDefUuid?: string;
|
|
40
47
|
}, [parentNode: ArenaRecordNode, childDefUuid?: string | undefined], ArenaRecordNode[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Returns the only child of the parent node with the specified node def, or undefined if not found.
|
|
50
|
+
* Throws an error if more than one child is found.
|
|
51
|
+
*/
|
|
41
52
|
export declare const getChild: PositionalRecordGetter<{
|
|
42
53
|
parentNode: ArenaRecordNode;
|
|
43
54
|
childDefUuid: string;
|
|
44
|
-
}, [parentNode: ArenaRecordNode, childDefUuid: string], ArenaRecordNode>;
|
|
55
|
+
}, [parentNode: ArenaRecordNode, childDefUuid: string], ArenaRecordNode | undefined>;
|
|
45
56
|
export declare const getParent: PositionalRecordGetter<{
|
|
46
57
|
node: ArenaRecordNode;
|
|
47
58
|
}, [node: ArenaRecordNode], ArenaRecordNode | undefined>;
|
|
@@ -78,6 +89,9 @@ export declare const findAncestor: (params: {
|
|
|
78
89
|
node: ArenaRecordNode;
|
|
79
90
|
predicate: (node: ArenaRecordNode) => boolean;
|
|
80
91
|
}) => (record: ArenaRecord) => ArenaRecordNode | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Returns the specified node, if it has the specified node def, or its ancestor with that node def; undefined if not found.
|
|
94
|
+
*/
|
|
81
95
|
export declare const getAncestor: RecordGetter<{
|
|
82
96
|
record: ArenaRecord;
|
|
83
97
|
node: ArenaRecordNode;
|
|
@@ -95,11 +109,14 @@ export declare const getDescendantsOrSelf: RecordGetter<{
|
|
|
95
109
|
node: ArenaRecordNode;
|
|
96
110
|
nodeDefDescendant: NodeDef<any>;
|
|
97
111
|
}, ArenaRecordNode[]>;
|
|
112
|
+
/**
|
|
113
|
+
* Returns the first descendant (or the node itself) with the specified node def, or undefined if not found.
|
|
114
|
+
*/
|
|
98
115
|
export declare const getDescendant: RecordGetter<{
|
|
99
116
|
record: ArenaRecord;
|
|
100
117
|
node: ArenaRecordNode;
|
|
101
118
|
nodeDefDescendant: NodeDef<any>;
|
|
102
|
-
}, ArenaRecordNode>;
|
|
119
|
+
}, ArenaRecordNode | undefined>;
|
|
103
120
|
export declare const isDescendantOf: (params: {
|
|
104
121
|
node: ArenaRecordNode;
|
|
105
122
|
ancestor: ArenaRecordNode;
|
|
@@ -42,6 +42,10 @@ const getNodes = (record) => { var _a; return (_a = record.nodes) !== null && _a
|
|
|
42
42
|
exports.getNodes = getNodes;
|
|
43
43
|
const getNodesArray = (record) => Object.values((0, exports.getNodes)(record));
|
|
44
44
|
exports.getNodesArray = getNodesArray;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the node with the specified uuid, or undefined if not found.
|
|
47
|
+
* Like the other node getters, it does not throw an error when the node is not found.
|
|
48
|
+
*/
|
|
45
49
|
exports.getNodeByUuid = positionalRecordGetter({
|
|
46
50
|
getter: ({ record, uuid }) => { var _a; return (_a = record.nodes) === null || _a === void 0 ? void 0 : _a[uuid]; },
|
|
47
51
|
isPositional: isString,
|
|
@@ -52,6 +56,9 @@ exports.getNodesByUuids = positionalRecordGetter({
|
|
|
52
56
|
isPositional: Array.isArray,
|
|
53
57
|
toParams: (uuids) => ({ uuids }),
|
|
54
58
|
});
|
|
59
|
+
/**
|
|
60
|
+
* Returns the root node, or undefined if the record has no nodes.
|
|
61
|
+
*/
|
|
55
62
|
const getRoot = (record) => {
|
|
56
63
|
const rootUuid = record._nodesIndex ? recordNodesIndexReader_1.RecordNodesIndexReader.getNodeRootUuid(record._nodesIndex) : null;
|
|
57
64
|
if (rootUuid) {
|
|
@@ -76,17 +83,18 @@ exports.getChildren = positionalRecordGetter({
|
|
|
76
83
|
isPositional: isRecordNode,
|
|
77
84
|
toParams: (parentNode, childDefUuid) => ({ parentNode, childDefUuid }),
|
|
78
85
|
});
|
|
86
|
+
/**
|
|
87
|
+
* Returns the only child of the parent node with the specified node def, or undefined if not found.
|
|
88
|
+
* Throws an error if more than one child is found.
|
|
89
|
+
*/
|
|
79
90
|
exports.getChild = positionalRecordGetter({
|
|
80
91
|
getter: ({ record, parentNode, childDefUuid, }) => {
|
|
81
92
|
const children = (0, exports.getChildren)({ parentNode, childDefUuid })(record);
|
|
82
|
-
const errorParams = { childDefUuid, parentNodeUuid: parentNode.uuid, recordUuid: record.uuid };
|
|
83
|
-
if (children.length === 1) {
|
|
84
|
-
return children[0];
|
|
85
|
-
}
|
|
86
93
|
if (children.length > 1) {
|
|
94
|
+
const errorParams = { childDefUuid, parentNodeUuid: parentNode.uuid, recordUuid: record.uuid };
|
|
87
95
|
throw new error_1.SystemError('systemError.record.multipleNodesFound', errorParams);
|
|
88
96
|
}
|
|
89
|
-
|
|
97
|
+
return children[0];
|
|
90
98
|
},
|
|
91
99
|
isPositional: isRecordNode,
|
|
92
100
|
toParams: (parentNode, childDefUuid) => ({ parentNode, childDefUuid }),
|
|
@@ -189,6 +197,9 @@ const findAncestor = (params) => (record) => {
|
|
|
189
197
|
return result;
|
|
190
198
|
};
|
|
191
199
|
exports.findAncestor = findAncestor;
|
|
200
|
+
/**
|
|
201
|
+
* Returns the specified node, if it has the specified node def, or its ancestor with that node def; undefined if not found.
|
|
202
|
+
*/
|
|
192
203
|
exports.getAncestor = recordGetter((params) => {
|
|
193
204
|
const { record, node, ancestorDefUuid } = params;
|
|
194
205
|
if (node.nodeDefUuid === ancestorDefUuid)
|
|
@@ -233,6 +244,9 @@ exports.getDescendantsOrSelf = recordGetter((params) => {
|
|
|
233
244
|
}
|
|
234
245
|
return currentAncestors; // currentAncestors is equal to the currentDescendants of the last level
|
|
235
246
|
});
|
|
247
|
+
/**
|
|
248
|
+
* Returns the first descendant (or the node itself) with the specified node def, or undefined if not found.
|
|
249
|
+
*/
|
|
236
250
|
exports.getDescendant = recordGetter((params) => {
|
|
237
251
|
const { record, node, nodeDefDescendant } = params;
|
|
238
252
|
return (0, exports.getDescendantsOrSelf)({ node, nodeDefDescendant })(record)[0];
|
|
@@ -315,6 +329,7 @@ exports.getEntityKeyNodesByDefUuid = recordGetter((params) => {
|
|
|
315
329
|
const nodeDefKeys = keyDefs !== null && keyDefs !== void 0 ? keyDefs : survey_1.Surveys.getNodeDefKeys({ survey, cycle, nodeDef });
|
|
316
330
|
return nodeDefKeys.reduce((acc, nodeDefKey) => {
|
|
317
331
|
const nodeKey = (0, exports.getDescendant)({ node: entity, nodeDefDescendant: nodeDefKey })(record);
|
|
332
|
+
// missing key nodes are kept as undefined entries
|
|
318
333
|
acc[nodeDefKey.uuid] = nodeKey;
|
|
319
334
|
return acc;
|
|
320
335
|
}, {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordGetters.js","sourceRoot":"","sources":["../../../src/record/_records/recordGetters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,yCAAyD;AACzD,uCAAyC;AACzC,qCAA0E;AAC1E,sDAAkD;AAClD,2CAA2G;AAC3G,yCAAoD;AAEpD,uCAA2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AqB,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;CAChD,CAAC,CAAA;AAEW,QAAA,WAAW,GAAG,sBAAsB,CAAC;IAChD,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAA4C,EAAW,EAAE,CAC9E,CAAC,IAAA,QAAA,kBAAkB,EAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACvC,YAAY,EAAE,YAAY;IAC1B,QAAQ,EAAE,CAAC,IAAqB,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;CAChD,CAAC,CAAA;AAEK,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,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAClE,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 } 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 type RecordParams = { record: ArenaRecord }\n\n/**\n * Record getter: takes the parameters first and the record as separate (curried) parameter: `getter(params)(record)`.\n * The deprecated form, with the record inside the parameters (`getter({ record, ...params })`), is still supported.\n */\nexport type RecordGetter<P extends RecordParams, R> = {\n /** @deprecated Pass the record as separate parameter: `getter(params)(record)` */\n (params: P): R\n (params: Omit<P, 'record'>): (record: ArenaRecord) => R\n}\n\nconst isRecordParams = (params: object): params is RecordParams => 'record' in params\n\nconst recordGetter = <P extends RecordParams, R>(getter: (params: P) => R): RecordGetter<P, R> =>\n ((params: P | Omit<P, 'record'>) =>\n isRecordParams(params)\n ? getter(params as P)\n : (record: ArenaRecord) => getter({ ...params, record } as P)) as RecordGetter<P, R>\n\n/**\n * Record getter (with parameters object) that also supports the deprecated form with positional parameters:\n * `getter(arg1, arg2)(record)`.\n */\nexport type PositionalRecordGetter<P, A extends unknown[], R> = {\n (params: P): (record: ArenaRecord) => R\n /** @deprecated Pass the parameters as an object: `getter({ ...params })(record)` */\n (...args: A): (record: ArenaRecord) => R\n}\n\nconst positionalRecordGetter = <P, A extends unknown[], R>(params: {\n getter: (params: P & RecordParams) => R\n isPositional: (firstArg: unknown) => boolean\n toParams: (...args: A) => NoInfer<P>\n}): PositionalRecordGetter<P, A, R> => {\n const { getter, isPositional, toParams } = params\n return ((...args: unknown[]) => {\n const getterParams = isPositional(args[0]) ? toParams(...(args as A)) : (args[0] as P)\n return (record: ArenaRecord) => getter({ ...getterParams, record })\n }) as PositionalRecordGetter<P, A, R>\n}\n\nconst isRecordNode = (arg: unknown): arg is ArenaRecordNode =>\n typeof arg === 'object' && arg !== null && 'uuid' in arg && 'nodeDefUuid' in arg\nconst isString = (arg: unknown): arg is string => typeof arg === 'string'\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\nexport const getNodeByUuid = positionalRecordGetter({\n getter: ({ record, uuid }: RecordParams & { uuid: string }): ArenaRecordNode | undefined => record.nodes?.[uuid],\n isPositional: isString,\n toParams: (uuid: string) => ({ uuid }),\n})\n\nexport const getNodesByUuids = positionalRecordGetter({\n getter: ({ record, uuids }: RecordParams & { uuids: string[] }): ArenaRecordNode[] =>\n uuids.map((uuid: string) => record.nodes?.[uuid]) as ArenaRecordNode[],\n isPositional: Array.isArray,\n toParams: (uuids: string[]) => ({ uuids }),\n})\n\nexport const getRoot = (record: ArenaRecord): ArenaRecordNode | undefined => {\n const rootUuid = record._nodesIndex ? RecordNodesIndexReader.getNodeRootUuid(record._nodesIndex) : null\n if (rootUuid) {\n return getNodeByUuid({ uuid: rootUuid })(record)\n }\n return getNodesArray(record).find((node) => !node.parentUuid)\n}\n\nexport const getChildren = positionalRecordGetter({\n getter: ({\n record,\n parentNode,\n childDefUuid,\n }: RecordParams & { parentNode: ArenaRecordNode; childDefUuid?: string }): 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({ uuids: childrenUuids })(record)\n }\n return getNodesArray(record).filter(\n (node) => node.parentUuid === parentNode.uuid && (!childDefUuid || node.nodeDefUuid == childDefUuid)\n )\n },\n isPositional: isRecordNode,\n toParams: (parentNode: ArenaRecordNode, childDefUuid?: string) => ({ parentNode, childDefUuid }),\n})\n\nexport const getChild = positionalRecordGetter({\n getter: ({\n record,\n parentNode,\n childDefUuid,\n }: RecordParams & { parentNode: ArenaRecordNode; childDefUuid: string }): ArenaRecordNode => {\n const children = getChildren({ parentNode, childDefUuid })(record)\n const errorParams = { childDefUuid, parentNodeUuid: parentNode.uuid, recordUuid: record.uuid }\n if (children.length === 1) {\n return children[0]\n }\n if (children.length > 1) {\n throw new SystemError('systemError.record.multipleNodesFound', errorParams)\n }\n throw new SystemError('systemError.record.childNotFound', errorParams)\n },\n isPositional: isRecordNode,\n toParams: (parentNode: ArenaRecordNode, childDefUuid: string) => ({ parentNode, childDefUuid }),\n})\n\nexport const getParent = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): ArenaRecordNode | undefined =>\n node.parentUuid ? getNodeByUuid({ uuid: node.parentUuid })(record) : undefined,\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const getNodesByDefUuid = positionalRecordGetter({\n getter: ({ record, nodeDefUuid }: RecordParams & { nodeDefUuid: string }): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeUuidsByDef(nodeDefUuid)(record._nodesIndex)\n return getNodesByUuids({ uuids: nodeUuids })(record)\n }\n return getNodesArray(record).filter((node) => node.nodeDefUuid === nodeDefUuid)\n },\n isPositional: isString,\n toParams: (nodeDefUuid: string) => ({ nodeDefUuid }),\n})\n\nconst isNodeFlagTrue = (isChildFlagTrue: (parent: ArenaRecordNode, nodeDefUuid: string) => boolean) =>\n recordGetter((params: RecordParams & { node: ArenaRecordNode }): boolean => {\n const { record, node } = params\n const ancestorsAndSelf = getAncestorsAndSelf({ node })(record)\n for (let i = 0; i < ancestorsAndSelf.length - 1; i++) {\n const child = ancestorsAndSelf[i]\n const parent = ancestorsAndSelf[i + 1]\n if (!isChildFlagTrue(parent, child.nodeDefUuid)) return false\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\nexport const getDependentCodeAttributes = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeCodeDependentUuids(node.uuid)(record._nodesIndex)\n return getNodesByUuids({ uuids: nodeUuids })(record)\n }\n throw new SystemError('record.nodesIndexNotInitialized')\n },\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const getParentCodeAttribute =\n (params: { parentNode: ArenaRecordNode; nodeDef: NodeDefCode }) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const { parentNode, nodeDef } = params\n\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(nodeDef)\n if (!parentCodeDefUuid) return undefined\n\n const ancestors = getAncestorsAndSelf({ node: parentNode })(record)\n for (const ancestor of ancestors) {\n const children = getChildren({ parentNode: ancestor, childDefUuid: 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 = positionalRecordGetter({\n getter: ({\n record,\n node,\n visitor,\n }: RecordParams & { node: ArenaRecordNode; visitor: (node: ArenaRecordNode) => boolean | void }): void => {\n let currentNode: ArenaRecordNode | undefined = node\n while (currentNode) {\n if (visitor(currentNode)) return\n currentNode = getParent({ node: currentNode })(record)\n }\n },\n isPositional: isRecordNode,\n // deprecated form: the visit stops when stopIfFn returns true\n toParams: (node: ArenaRecordNode, visitor: (node: ArenaRecordNode) => void, stopIfFn?: () => boolean) => ({\n node,\n visitor: (visitedNode: ArenaRecordNode): boolean => {\n visitor(visitedNode)\n return !!stopIfFn?.()\n },\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 (params: { node: ArenaRecordNode; predicate: (node: ArenaRecordNode) => boolean }) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const { node, predicate } = params\n let result: ArenaRecordNode | undefined = undefined\n visitAncestorsAndSelf({\n node,\n visitor: (visitedNode) => {\n if (predicate(visitedNode)) {\n result = visitedNode\n return true\n }\n return false\n },\n })(record)\n return result\n }\n\nexport const getAncestor = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode; ancestorDefUuid: string }): ArenaRecordNode | undefined => {\n const { record, node, ancestorDefUuid } = params\n if (node.nodeDefUuid === ancestorDefUuid) return node\n\n let ancestor = getParent({ node })(record)\n while (ancestor && ancestor.nodeDefUuid !== ancestorDefUuid) {\n ancestor = getParent({ node: ancestor })(record)\n }\n return ancestor\n }\n)\n\n/**\n * Returns the list of ancestors from the given node to the root entity\n */\nexport const getAncestorsAndSelf = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode }): Array<ArenaRecordNode> => {\n const { record, node } = params\n const ancestors: Array<ArenaRecordNode> = []\n visitAncestorsAndSelf({\n node,\n visitor: (currentNode) => {\n ancestors.push(currentNode)\n },\n })(record)\n return ancestors\n }\n)\n\n// descendants\n\nexport const getDescendantsOrSelf = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode; nodeDefDescendant: NodeDef<any> }): ArenaRecordNode[] => {\n const { record, node, nodeDefDescendant } = params\n\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(\n ...getChildren({ parentNode: currentAncestor, childDefUuid: currentDescendantDefUuid })(record)\n )\n }\n currentAncestors = currentDescendants\n currentDescendants = []\n }\n return currentAncestors // currentAncestors is equal to the currentDescendants of the last level\n }\n)\n\nexport const getDescendant = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode; nodeDefDescendant: NodeDef<any> }): ArenaRecordNode => {\n const { record, node, nodeDefDescendant } = params\n\n return getDescendantsOrSelf({ node, nodeDefDescendant })(record)[0]\n }\n)\n\nexport const isDescendantOf = (params: { node: ArenaRecordNode; ancestor: ArenaRecordNode }): boolean => {\n const { node, ancestor } = params\n return Nodes.getHierarchy(node).includes(ancestor.uuid)\n}\n\nexport const visitDescendantsAndSelf = recordGetter(\n (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n visitor: (node: ArenaRecordNode) => boolean | void\n traverseMethod?: TraverseMethod\n }): void => {\n const { record, node, visitor, traverseMethod = TraverseMethod.bfs } = params\n\n if (traverseMethod === TraverseMethod.bfs) {\n const queue = new Queue()\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({ parentNode: 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)\n\nexport const findDescendantOrSelf =\n (params: { node: ArenaRecordNode; predicate: (node: ArenaRecordNode) => boolean }) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const { node, predicate } = params\n let found = undefined\n\n visitDescendantsAndSelf({\n node,\n visitor: (currentNode) => {\n if (predicate(currentNode)) {\n found = currentNode\n return true\n }\n return false\n },\n })(record)\n return found\n }\n\nconst getClosestAncestorNode = recordGetter(\n (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n dependentDef: NodeDef<NodeDefType, NodeDefProps>\n dependencyType: SurveyDependencyType\n }): ArenaRecordNode | undefined => {\n const { record, node, nodeDef, dependentDef, dependencyType } = params\n\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, ancestorDefUuid: commonAncestorDefUuid })(record)\n }\n)\n\ntype EntityKeyNodesGetterParams = {\n survey: Survey\n cycle?: string\n record: ArenaRecord\n entity: ArenaRecordNode\n keyDefs?: NodeDef<NodeDefType, NodeDefProps>[]\n}\n\nexport const getEntityKeyNodesByDefUuid = recordGetter((params: EntityKeyNodesGetterParams): NodesMap => {\n const { survey, cycle, record, entity, keyDefs } = params\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({ node: entity, nodeDefDescendant: nodeDefKey })(record)\n acc[nodeDefKey.uuid] = nodeKey\n return acc\n }, {})\n})\n\nexport const getEntityKeyNodes = recordGetter(\n ({ record, ...otherParams }: EntityKeyNodesGetterParams): ArenaRecordNode[] =>\n Object.values(getEntityKeyNodesByDefUuid(otherParams)(record))\n)\n\nexport const getEntityKeyValuesByDefUuid = recordGetter((params: EntityKeyNodesGetterParams): Dictionary<any> => {\n const { record, ...otherParams } = params\n const keyNodesByDefUuid = getEntityKeyNodesByDefUuid(otherParams)(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 = recordGetter(({ record, ...otherParams }: EntityKeyNodesGetterParams): any[] =>\n Object.values(getEntityKeyValuesByDefUuid(otherParams)(record))\n)\n\nexport const getEntitySiblings = recordGetter(\n (params: { record: ArenaRecord; entity: ArenaRecordNode; includeSelf?: boolean }) => {\n const { record, entity, includeSelf = false } = params\n const parentEntity = getParent({ node: entity })(record)\n if (!parentEntity) return []\n const siblingEntities = getChildren({ parentNode: parentEntity, childDefUuid: entity.nodeDefUuid })(record)\n return includeSelf ? siblingEntities : siblingEntities.filter((sibling) => !Nodes.areEqual(sibling, entity))\n }\n)\n\nexport const getAttributeSiblings = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode; nodeDef: NodeDef<NodeDefType, NodeDefProps> }) => {\n const { record, node, nodeDef } = params\n const parentEntity = getParent({ node })(record)\n if (!parentEntity) return []\n const siblingParentEntities = getEntitySiblings({ entity: parentEntity })(record)\n return siblingParentEntities.reduce((siblingsAcc: ArenaRecordNode[], siblingEntity) => {\n siblingsAcc.push(...getChildren({ parentNode: siblingEntity, childDefUuid: nodeDef.uuid })(record))\n return siblingsAcc\n }, [])\n }\n)\n\nexport const getNodeIndex = recordGetter((params: { record: ArenaRecord; node: ArenaRecordNode }) => {\n const { record, node } = params\n const parentEntity = getParent({ node })(record)\n if (!parentEntity) return 0 // root entity\n const siblings = getChildren({ parentNode: parentEntity, childDefUuid: node.nodeDefUuid })(record)\n return siblings.indexOf(node)\n})\n\nexport const findEntityByKeyValues = recordGetter(\n (params: {\n survey: Survey\n cycle: string\n record: ArenaRecord\n parentEntity: ArenaRecordNode\n entityDefUuid: string\n keyValuesByDefUuid: Dictionary<any>\n }): ArenaRecordNode | undefined => {\n const { survey, cycle, record, parentEntity, entityDefUuid, keyValuesByDefUuid } = params\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entityDefUuid })\n const siblingEntities = getChildren({ parentNode: parentEntity, childDefUuid: 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({ survey, entity: siblingEntity, keyDefs })(\n record\n )\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)\n\nexport const findEntityWithSameKeysInAnotherRecord = recordGetter(\n (params: {\n survey: Survey\n cycle: string\n entityUuid: string\n record: ArenaRecord\n recordOther: ArenaRecord\n }): ArenaRecordNode | undefined => {\n const { survey, cycle, entityUuid, record, recordOther } = params\n const entity = getNodeByUuid({ uuid: entityUuid })(record)\n if (!entity) return undefined\n\n let otherRecordCurrentParentEntity = getRoot(recordOther)\n if (!otherRecordCurrentParentEntity) return undefined\n\n const entityAncestorsAndSelf = getAncestorsAndSelf({ node: entity })(record)\n const ancestorDefUuidsAndKeys = entityAncestorsAndSelf.map((ancestor) => ({\n entityDefUuid: ancestor.nodeDefUuid,\n keyValuesByDefUuid: getEntityKeyValuesByDefUuid({ survey, entity: 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 parentEntity: otherRecordCurrentParentEntity,\n entityDefUuid,\n keyValuesByDefUuid,\n })(recordOther)\n }\n return otherRecordCurrentParentEntity\n }\n)\n\nexport const getDependentNodePointers = recordGetter(\n (params: {\n survey: Survey\n record: ArenaRecord\n node: ArenaRecordNode\n dependencyType: SurveyDependencyType\n includeSelf?: boolean\n filterFn?: (nodePointer: NodePointer) => boolean\n }) => {\n const { survey, record, node, dependencyType, includeSelf = false, filterFn = null } = params\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('record.nodes.dependents.dependencyOnRootFound')\n\n // 2 find descendant nodes of common parent node with nodeDefUuid = dependentDef uuid\n const dependentContextNodes = getDescendantsOrSelf({\n node: commonAncestorNode,\n nodeDefDescendant: nodeDefDependentParent,\n })(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\nexport const getAncestorCodePath = recordGetter(\n (params: {\n survey: Survey\n record: ArenaRecord\n parentNode: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>\n }): string[] => {\n const { record, parentNode, nodeDef, survey } = params\n\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, nodeDef: ancestorCodeDef })(record)\n }\n return codePaths\n }\n)\n\nexport const getCategoryItemUuid = recordGetter(\n (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>\n record: ArenaRecord\n parentNode: ArenaRecordNode\n code: string\n }): string | undefined => {\n const { survey, nodeDef, record, parentNode, code } = params\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)\n\nexport const isNodeFilledByUser = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): boolean =>\n !!findDescendantOrSelf({ node, predicate: (visitedNode) => Nodes.hasUserInputValue(visitedNode) })(record),\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const isNodeEmpty = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): boolean =>\n !isNodeFilledByUser({ node })(record),\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const isEmpty = (record: ArenaRecord): boolean => {\n const rootNode = getRoot(record)\n return rootNode ? isNodeEmpty({ node: 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,uCAAyC;AACzC,qCAA0E;AAC1E,sDAAkD;AAClD,2CAA2G;AAC3G,yCAAoD;AAEpD,uCAA2C;AAC3C,sCAA4D;AAC5D,8CAAsD;AACtD,qEAAiE;AACjE,mEAA+D;AAc/D,MAAM,cAAc,GAAG,CAAC,MAAc,EAA0B,EAAE,CAAC,QAAQ,IAAI,MAAM,CAAA;AAErF,MAAM,YAAY,GAAG,CAA4B,MAAwB,EAAsB,EAAE,CAC/F,CAAC,CAAC,MAA6B,EAAE,EAAE,CACjC,cAAc,CAAC,MAAM,CAAC;IACpB,CAAC,CAAC,MAAM,CAAC,MAAW,CAAC;IACrB,CAAC,CAAC,CAAC,MAAmB,EAAE,EAAE,CAAC,MAAM,CAAC,gCAAK,MAAM,KAAE,MAAM,GAAO,CAAC,CAAuB,CAAA;AAY1F,MAAM,sBAAsB,GAAG,CAA4B,MAI1D,EAAmC,EAAE;IACpC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;IACjD,OAAO,CAAC,CAAC,GAAG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AI,CAAA;AAClE,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 } 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 type RecordParams = { record: ArenaRecord }\n\n/**\n * Record getter: takes the parameters first and the record as separate (curried) parameter: `getter(params)(record)`.\n * The deprecated form, with the record inside the parameters (`getter({ record, ...params })`), is still supported.\n */\nexport type RecordGetter<P extends RecordParams, R> = {\n /** @deprecated Pass the record as separate parameter: `getter(params)(record)` */\n (params: P): R\n (params: Omit<P, 'record'>): (record: ArenaRecord) => R\n}\n\nconst isRecordParams = (params: object): params is RecordParams => 'record' in params\n\nconst recordGetter = <P extends RecordParams, R>(getter: (params: P) => R): RecordGetter<P, R> =>\n ((params: P | Omit<P, 'record'>) =>\n isRecordParams(params)\n ? getter(params as P)\n : (record: ArenaRecord) => getter({ ...params, record } as P)) as RecordGetter<P, R>\n\n/**\n * Record getter (with parameters object) that also supports the deprecated form with positional parameters:\n * `getter(arg1, arg2)(record)`.\n */\nexport type PositionalRecordGetter<P, A extends unknown[], R> = {\n (params: P): (record: ArenaRecord) => R\n /** @deprecated Pass the parameters as an object: `getter({ ...params })(record)` */\n (...args: A): (record: ArenaRecord) => R\n}\n\nconst positionalRecordGetter = <P, A extends unknown[], R>(params: {\n getter: (params: P & RecordParams) => R\n isPositional: (firstArg: unknown) => boolean\n toParams: (...args: A) => NoInfer<P>\n}): PositionalRecordGetter<P, A, R> => {\n const { getter, isPositional, toParams } = params\n return ((...args: unknown[]) => {\n const getterParams = isPositional(args[0]) ? toParams(...(args as A)) : (args[0] as P)\n return (record: ArenaRecord) => getter({ ...getterParams, record })\n }) as PositionalRecordGetter<P, A, R>\n}\n\nconst isRecordNode = (arg: unknown): arg is ArenaRecordNode =>\n typeof arg === 'object' && arg !== null && 'uuid' in arg && 'nodeDefUuid' in arg\nconst isString = (arg: unknown): arg is string => typeof arg === 'string'\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 = positionalRecordGetter({\n getter: ({ record, uuid }: RecordParams & { uuid: string }): ArenaRecordNode | undefined => record.nodes?.[uuid],\n isPositional: isString,\n toParams: (uuid: string) => ({ uuid }),\n})\n\nexport const getNodesByUuids = positionalRecordGetter({\n getter: ({ record, uuids }: RecordParams & { uuids: string[] }): ArenaRecordNode[] =>\n uuids.map((uuid: string) => record.nodes?.[uuid]) as ArenaRecordNode[],\n isPositional: Array.isArray,\n toParams: (uuids: string[]) => ({ uuids }),\n})\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({ uuid: rootUuid })(record)\n }\n return getNodesArray(record).find((node) => !node.parentUuid)\n}\n\nexport const getChildren = positionalRecordGetter({\n getter: ({\n record,\n parentNode,\n childDefUuid,\n }: RecordParams & { parentNode: ArenaRecordNode; childDefUuid?: string }): 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({ uuids: childrenUuids })(record)\n }\n return getNodesArray(record).filter(\n (node) => node.parentUuid === parentNode.uuid && (!childDefUuid || node.nodeDefUuid == childDefUuid)\n )\n },\n isPositional: isRecordNode,\n toParams: (parentNode: ArenaRecordNode, childDefUuid?: string) => ({ parentNode, childDefUuid }),\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 = positionalRecordGetter({\n getter: ({\n record,\n parentNode,\n childDefUuid,\n }: RecordParams & { parentNode: ArenaRecordNode; childDefUuid: string }): 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('systemError.record.multipleNodesFound', errorParams)\n }\n return children[0]\n },\n isPositional: isRecordNode,\n toParams: (parentNode: ArenaRecordNode, childDefUuid: string) => ({ parentNode, childDefUuid }),\n})\n\nexport const getParent = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): ArenaRecordNode | undefined =>\n node.parentUuid ? getNodeByUuid({ uuid: node.parentUuid })(record) : undefined,\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const getNodesByDefUuid = positionalRecordGetter({\n getter: ({ record, nodeDefUuid }: RecordParams & { nodeDefUuid: string }): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeUuidsByDef(nodeDefUuid)(record._nodesIndex)\n return getNodesByUuids({ uuids: nodeUuids })(record)\n }\n return getNodesArray(record).filter((node) => node.nodeDefUuid === nodeDefUuid)\n },\n isPositional: isString,\n toParams: (nodeDefUuid: string) => ({ nodeDefUuid }),\n})\n\nconst isNodeFlagTrue = (isChildFlagTrue: (parent: ArenaRecordNode, nodeDefUuid: string) => boolean) =>\n recordGetter((params: RecordParams & { node: ArenaRecordNode }): boolean => {\n const { record, node } = params\n const ancestorsAndSelf = getAncestorsAndSelf({ node })(record)\n for (let i = 0; i < ancestorsAndSelf.length - 1; i++) {\n const child = ancestorsAndSelf[i]\n const parent = ancestorsAndSelf[i + 1]\n if (!isChildFlagTrue(parent, child.nodeDefUuid)) return false\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\nexport const getDependentCodeAttributes = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeCodeDependentUuids(node.uuid)(record._nodesIndex)\n return getNodesByUuids({ uuids: nodeUuids })(record)\n }\n throw new SystemError('record.nodesIndexNotInitialized')\n },\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const getParentCodeAttribute =\n (params: { parentNode: ArenaRecordNode; nodeDef: NodeDefCode }) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const { parentNode, nodeDef } = params\n\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(nodeDef)\n if (!parentCodeDefUuid) return undefined\n\n const ancestors = getAncestorsAndSelf({ node: parentNode })(record)\n for (const ancestor of ancestors) {\n const children = getChildren({ parentNode: ancestor, childDefUuid: 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 = positionalRecordGetter({\n getter: ({\n record,\n node,\n visitor,\n }: RecordParams & { node: ArenaRecordNode; visitor: (node: ArenaRecordNode) => boolean | void }): void => {\n let currentNode: ArenaRecordNode | undefined = node\n while (currentNode) {\n if (visitor(currentNode)) return\n currentNode = getParent({ node: currentNode })(record)\n }\n },\n isPositional: isRecordNode,\n // deprecated form: the visit stops when stopIfFn returns true\n toParams: (node: ArenaRecordNode, visitor: (node: ArenaRecordNode) => void, stopIfFn?: () => boolean) => ({\n node,\n visitor: (visitedNode: ArenaRecordNode): boolean => {\n visitor(visitedNode)\n return !!stopIfFn?.()\n },\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 (params: { node: ArenaRecordNode; predicate: (node: ArenaRecordNode) => boolean }) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const { node, predicate } = params\n let result: ArenaRecordNode | undefined = undefined\n visitAncestorsAndSelf({\n node,\n visitor: (visitedNode) => {\n if (predicate(visitedNode)) {\n result = visitedNode\n return true\n }\n return false\n },\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 = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode; ancestorDefUuid: string }): ArenaRecordNode | undefined => {\n const { record, node, ancestorDefUuid } = params\n if (node.nodeDefUuid === ancestorDefUuid) return node\n\n let ancestor = getParent({ node })(record)\n while (ancestor && ancestor.nodeDefUuid !== ancestorDefUuid) {\n ancestor = getParent({ node: ancestor })(record)\n }\n return ancestor\n }\n)\n\n/**\n * Returns the list of ancestors from the given node to the root entity\n */\nexport const getAncestorsAndSelf = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode }): Array<ArenaRecordNode> => {\n const { record, node } = params\n const ancestors: Array<ArenaRecordNode> = []\n visitAncestorsAndSelf({\n node,\n visitor: (currentNode) => {\n ancestors.push(currentNode)\n },\n })(record)\n return ancestors\n }\n)\n\n// descendants\n\nexport const getDescendantsOrSelf = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode; nodeDefDescendant: NodeDef<any> }): ArenaRecordNode[] => {\n const { record, node, nodeDefDescendant } = params\n\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(\n ...getChildren({ parentNode: currentAncestor, childDefUuid: currentDescendantDefUuid })(record)\n )\n }\n currentAncestors = currentDescendants\n currentDescendants = []\n }\n return currentAncestors // currentAncestors is equal to the currentDescendants of the last level\n }\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 = recordGetter(\n (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n nodeDefDescendant: NodeDef<any>\n }): ArenaRecordNode | undefined => {\n const { record, node, nodeDefDescendant } = params\n\n return getDescendantsOrSelf({ node, nodeDefDescendant })(record)[0]\n }\n)\n\nexport const isDescendantOf = (params: { node: ArenaRecordNode; ancestor: ArenaRecordNode }): boolean => {\n const { node, ancestor } = params\n return Nodes.getHierarchy(node).includes(ancestor.uuid)\n}\n\nexport const visitDescendantsAndSelf = recordGetter(\n (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n visitor: (node: ArenaRecordNode) => boolean | void\n traverseMethod?: TraverseMethod\n }): void => {\n const { record, node, visitor, traverseMethod = TraverseMethod.bfs } = params\n\n if (traverseMethod === TraverseMethod.bfs) {\n const queue = new Queue()\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({ parentNode: 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)\n\nexport const findDescendantOrSelf =\n (params: { node: ArenaRecordNode; predicate: (node: ArenaRecordNode) => boolean }) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const { node, predicate } = params\n let found = undefined\n\n visitDescendantsAndSelf({\n node,\n visitor: (currentNode) => {\n if (predicate(currentNode)) {\n found = currentNode\n return true\n }\n return false\n },\n })(record)\n return found\n }\n\nconst getClosestAncestorNode = recordGetter(\n (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n dependentDef: NodeDef<NodeDefType, NodeDefProps>\n dependencyType: SurveyDependencyType\n }): ArenaRecordNode | undefined => {\n const { record, node, nodeDef, dependentDef, dependencyType } = params\n\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, ancestorDefUuid: commonAncestorDefUuid })(record)\n }\n)\n\ntype EntityKeyNodesGetterParams = {\n survey: Survey\n cycle?: string\n record: ArenaRecord\n entity: ArenaRecordNode\n keyDefs?: NodeDef<NodeDefType, NodeDefProps>[]\n}\n\nexport const getEntityKeyNodesByDefUuid = recordGetter((params: EntityKeyNodesGetterParams): NodesMap => {\n const { survey, cycle, record, entity, keyDefs } = params\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({ node: entity, nodeDefDescendant: 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 = recordGetter(\n ({ record, ...otherParams }: EntityKeyNodesGetterParams): ArenaRecordNode[] =>\n Object.values(getEntityKeyNodesByDefUuid(otherParams)(record))\n)\n\nexport const getEntityKeyValuesByDefUuid = recordGetter((params: EntityKeyNodesGetterParams): Dictionary<any> => {\n const { record, ...otherParams } = params\n const keyNodesByDefUuid = getEntityKeyNodesByDefUuid(otherParams)(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 = recordGetter(({ record, ...otherParams }: EntityKeyNodesGetterParams): any[] =>\n Object.values(getEntityKeyValuesByDefUuid(otherParams)(record))\n)\n\nexport const getEntitySiblings = recordGetter(\n (params: { record: ArenaRecord; entity: ArenaRecordNode; includeSelf?: boolean }) => {\n const { record, entity, includeSelf = false } = params\n const parentEntity = getParent({ node: entity })(record)\n if (!parentEntity) return []\n const siblingEntities = getChildren({ parentNode: parentEntity, childDefUuid: entity.nodeDefUuid })(record)\n return includeSelf ? siblingEntities : siblingEntities.filter((sibling) => !Nodes.areEqual(sibling, entity))\n }\n)\n\nexport const getAttributeSiblings = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode; nodeDef: NodeDef<NodeDefType, NodeDefProps> }) => {\n const { record, node, nodeDef } = params\n const parentEntity = getParent({ node })(record)\n if (!parentEntity) return []\n const siblingParentEntities = getEntitySiblings({ entity: parentEntity })(record)\n return siblingParentEntities.reduce((siblingsAcc: ArenaRecordNode[], siblingEntity) => {\n siblingsAcc.push(...getChildren({ parentNode: siblingEntity, childDefUuid: nodeDef.uuid })(record))\n return siblingsAcc\n }, [])\n }\n)\n\nexport const getNodeIndex = recordGetter((params: { record: ArenaRecord; node: ArenaRecordNode }) => {\n const { record, node } = params\n const parentEntity = getParent({ node })(record)\n if (!parentEntity) return 0 // root entity\n const siblings = getChildren({ parentNode: parentEntity, childDefUuid: node.nodeDefUuid })(record)\n return siblings.indexOf(node)\n})\n\nexport const findEntityByKeyValues = recordGetter(\n (params: {\n survey: Survey\n cycle: string\n record: ArenaRecord\n parentEntity: ArenaRecordNode\n entityDefUuid: string\n keyValuesByDefUuid: Dictionary<any>\n }): ArenaRecordNode | undefined => {\n const { survey, cycle, record, parentEntity, entityDefUuid, keyValuesByDefUuid } = params\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entityDefUuid })\n const siblingEntities = getChildren({ parentNode: parentEntity, childDefUuid: 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({ survey, entity: siblingEntity, keyDefs })(\n record\n )\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)\n\nexport const findEntityWithSameKeysInAnotherRecord = recordGetter(\n (params: {\n survey: Survey\n cycle: string\n entityUuid: string\n record: ArenaRecord\n recordOther: ArenaRecord\n }): ArenaRecordNode | undefined => {\n const { survey, cycle, entityUuid, record, recordOther } = params\n const entity = getNodeByUuid({ uuid: entityUuid })(record)\n if (!entity) return undefined\n\n let otherRecordCurrentParentEntity = getRoot(recordOther)\n if (!otherRecordCurrentParentEntity) return undefined\n\n const entityAncestorsAndSelf = getAncestorsAndSelf({ node: entity })(record)\n const ancestorDefUuidsAndKeys = entityAncestorsAndSelf.map((ancestor) => ({\n entityDefUuid: ancestor.nodeDefUuid,\n keyValuesByDefUuid: getEntityKeyValuesByDefUuid({ survey, entity: 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 parentEntity: otherRecordCurrentParentEntity,\n entityDefUuid,\n keyValuesByDefUuid,\n })(recordOther)\n }\n return otherRecordCurrentParentEntity\n }\n)\n\nexport const getDependentNodePointers = recordGetter(\n (params: {\n survey: Survey\n record: ArenaRecord\n node: ArenaRecordNode\n dependencyType: SurveyDependencyType\n includeSelf?: boolean\n filterFn?: (nodePointer: NodePointer) => boolean\n }) => {\n const { survey, record, node, dependencyType, includeSelf = false, filterFn = null } = params\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('record.nodes.dependents.dependencyOnRootFound')\n\n // 2 find descendant nodes of common parent node with nodeDefUuid = dependentDef uuid\n const dependentContextNodes = getDescendantsOrSelf({\n node: commonAncestorNode,\n nodeDefDescendant: nodeDefDependentParent,\n })(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\nexport const getAncestorCodePath = recordGetter(\n (params: {\n survey: Survey\n record: ArenaRecord\n parentNode: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>\n }): string[] => {\n const { record, parentNode, nodeDef, survey } = params\n\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, nodeDef: ancestorCodeDef })(record)\n }\n return codePaths\n }\n)\n\nexport const getCategoryItemUuid = recordGetter(\n (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>\n record: ArenaRecord\n parentNode: ArenaRecordNode\n code: string\n }): string | undefined => {\n const { survey, nodeDef, record, parentNode, code } = params\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)\n\nexport const isNodeFilledByUser = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): boolean =>\n !!findDescendantOrSelf({ node, predicate: (visitedNode) => Nodes.hasUserInputValue(visitedNode) })(record),\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const isNodeEmpty = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): boolean =>\n !isNodeFilledByUser({ node })(record),\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const isEmpty = (record: ArenaRecord): boolean => {\n const rootNode = getRoot(record)\n return rootNode ? isNodeEmpty({ node: 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"]}
|
|
@@ -26,8 +26,10 @@ const shouldExistingEntitiesBeDeleted = (params) => __awaiter(void 0, void 0, vo
|
|
|
26
26
|
const enumeratorDef = survey_1.Surveys.getNodeDefEnumerator({ survey, entityDef });
|
|
27
27
|
const existingEnumeratingItemUuids = existingEntities
|
|
28
28
|
.map((existingEntity) => {
|
|
29
|
+
var _a;
|
|
29
30
|
const existingEnumerator = (0, recordGetters_1.getChild)({ parentNode: existingEntity, childDefUuid: enumeratorDef.uuid })(updateResult.record);
|
|
30
|
-
|
|
31
|
+
// an entity without enumerator item makes the lists differ, so the entities are recreated
|
|
32
|
+
return (_a = (existingEnumerator ? node_1.NodeValues.getItemUuid(existingEnumerator) : undefined)) !== null && _a !== void 0 ? _a : '';
|
|
31
33
|
})
|
|
32
34
|
.sort(uuidsCompare);
|
|
33
35
|
const allowedCodes = yield (0, recordEnumeratingItemsExpressionEvaluator_1.getEnumeratingItemsAllowedCodes)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordNodeDependentsEnumeratedEntitiesUpdater.js","sourceRoot":"","sources":["../../../src/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA+D;AAC/D,2CAAuE;AAEvE,yCAA8C;AAC9C,uCAAqC;AACrC,6DAA8E;AAC9E,yDAAqE;AACrE,2GAA6F;AAG7F,6DAAkE;AAClE,6DAAkD;AAClD,6DAAyD;AAEzD,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;AAEzF,MAAM,+BAA+B,GAAG,CAAO,MAQ9C,EAAE,EAAE;IACH,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,oBAAoB,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;IAC5G,MAAM,aAAa,GAAG,gBAAO,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAE,CAAA;IAC1E,MAAM,4BAA4B,GAAG,gBAAgB;SAClD,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE
|
|
1
|
+
{"version":3,"file":"recordNodeDependentsEnumeratedEntitiesUpdater.js","sourceRoot":"","sources":["../../../src/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA+D;AAC/D,2CAAuE;AAEvE,yCAA8C;AAC9C,uCAAqC;AACrC,6DAA8E;AAC9E,yDAAqE;AACrE,2GAA6F;AAG7F,6DAAkE;AAClE,6DAAkD;AAClD,6DAAyD;AAEzD,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;AAEzF,MAAM,+BAA+B,GAAG,CAAO,MAQ9C,EAAE,EAAE;IACH,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,oBAAoB,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;IAC5G,MAAM,aAAa,GAAG,gBAAO,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAE,CAAA;IAC1E,MAAM,4BAA4B,GAAG,gBAAgB;SAClD,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE;;QACtB,MAAM,kBAAkB,GAAG,IAAA,wBAAQ,EAAC,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,CAAC,IAAI,EAAE,CAAC,CACnG,YAAY,CAAC,MAAM,CACpB,CAAA;QACD,0FAA0F;QAC1F,aAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,iBAAU,CAAC,WAAW,CAAC,kBAAkB,CA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,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAA;IACvE,IAAI,OAAO,CAAC,IAAI,KAAK,qBAAW,CAAC,IAAI;QAAE,OAAO,YAAY,CAAA;IAC1D,MAAM,OAAO,GAAG,OAAsB,CAAA;IAEtC,MAAM,6BAA6B,GAAG,gBAAO,CAAC,gCAAgC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAA;IAC5G,IAAI,6BAA6B,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,YAAY,CAAA;IAEnE,MAAM,yBAAyB,GAAG,gBAAO,CAAC,gCAAgC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAE,CAAA;IAChG,MAAM,sBAAsB,GAAG,IAAA,2BAAW,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,yBAAyB,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAE,CAAA;IAE9G,gCAAgC;IAChC,KAAK,MAAM,SAAS,IAAI,6BAA6B,EAAE,CAAC;QACtD,gDAAgD;QAChD,MAAM,IAAA,QAAA,gCAAgC,kCAAM,MAAM,KAAE,SAAS,EAAE,UAAU,EAAE,sBAAsB,EAAE,YAAY,IAAG,CAAA,CAAC,UAAU;IAC/H,CAAC;IACD,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA,CAAA;AAzBY,QAAA,iCAAiC,GAAjC,iCAAiC,CAyB7C","sourcesContent":["import { ArenaRecordNode, Nodes, NodeValues } from '../../node'\nimport { NodeDefCode, NodeDefEntity, NodeDefType } from '../../nodeDef'\nimport { CategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider'\nimport { Survey, Surveys } from '../../survey'\nimport { Objects } from '../../utils'\nimport { getAncestor, getChild, getChildren } from '../_records/recordGetters'\nimport { getEnumeratingCategoryItems } from '../_records/recordUtils'\nimport { getEnumeratingItemsAllowedCodes } from './recordEnumeratingItemsExpressionEvaluator'\nimport { RecordExpressionEvaluationContext } from './recordExpressionEvaluationContext'\nimport { RecordNodeDependentsUpdateParams } from './recordNodeDependentsUpdateParams'\nimport { createEnumeratedEntityNodes } from './recordNodesCreator'\nimport { deleteNodes } from './recordNodesDeleter'\nimport { RecordUpdateResult } from './recordUpdateResult'\n\nconst uuidsCompare = (uuidA: string, uuidB: string): number => uuidA.localeCompare(uuidB)\n\nconst shouldExistingEntitiesBeDeleted = async (params: {\n survey: Survey\n entityDef: NodeDefEntity\n existingEntities: ArenaRecordNode[]\n parentNode: ArenaRecordNode\n updateResult: RecordUpdateResult\n categoryItemProvider?: CategoryItemProvider\n user: RecordExpressionEvaluationContext['user']\n}) => {\n const { survey, entityDef, existingEntities, parentNode, updateResult, categoryItemProvider, user } = params\n const enumeratorDef = Surveys.getNodeDefEnumerator({ survey, entityDef })!\n const existingEnumeratingItemUuids = existingEntities\n .map((existingEntity) => {\n const existingEnumerator = getChild({ parentNode: existingEntity, childDefUuid: enumeratorDef.uuid })(\n updateResult.record\n )\n // an entity without enumerator item makes the lists differ, so the entities are recreated\n return (existingEnumerator ? NodeValues.getItemUuid(existingEnumerator) : undefined) ?? ''\n })\n .sort(uuidsCompare)\n\n const allowedCodes = await getEnumeratingItemsAllowedCodes({\n survey,\n user,\n record: updateResult.record,\n entityDef,\n parentNode,\n })\n\n const enumeratingCategoryItems = await getEnumeratingCategoryItems({\n survey,\n enumeratorDef,\n parentNode,\n categoryItemProvider,\n allowedCodes,\n })(updateResult.record)\n const newEnumeratingItemUuids = enumeratingCategoryItems.map((item) => item.uuid).sort(uuidsCompare)\n\n return !Objects.isEqual(newEnumeratingItemUuids, existingEnumeratingItemUuids)\n}\n\nexport const createOrDeleteEnumeratedEntities = async (\n params: RecordExpressionEvaluationContext & {\n parentNode: ArenaRecordNode\n entityDef: NodeDefEntity\n updateResult: RecordUpdateResult\n }\n) => {\n const { survey, parentNode, entityDef, categoryItemProvider, updateResult, sideEffect } = params\n const recordUpdateOptions = { sideEffect }\n const existingEntities = getChildren({ parentNode, childDefUuid: entityDef.uuid })(updateResult.record)\n const existingEntitiesCount = existingEntities.length\n const hasExistingEntities = existingEntitiesCount > 0\n const applicable = Nodes.isChildApplicable(parentNode, entityDef.uuid)\n\n const deleteExistingEntities = () => {\n const existingEntityUuids = existingEntities.map((node) => node.uuid)\n const nodesDeleteUpdatedResult = deleteNodes(existingEntityUuids, recordUpdateOptions)(updateResult.record)\n updateResult.merge(nodesDeleteUpdatedResult)\n }\n\n if (applicable) {\n if (hasExistingEntities) {\n const existingEntitiesToBeDeleted = await shouldExistingEntitiesBeDeleted({\n survey,\n entityDef,\n existingEntities,\n parentNode,\n updateResult,\n categoryItemProvider,\n user: params.user,\n })\n if (!existingEntitiesToBeDeleted) {\n // existing entities already match the enumerating items: nothing to do (do not create them again)\n return\n }\n deleteExistingEntities()\n }\n await createEnumeratedEntityNodes({ ...params, nodeDef: entityDef, parentNode })\n } else if (hasExistingEntities) {\n deleteExistingEntities()\n }\n}\n\nexport const updateDependentEnumeratedEntities = async (\n params: RecordNodeDependentsUpdateParams\n): Promise<RecordUpdateResult> => {\n const { survey, record, node } = params\n\n const updateResult = new RecordUpdateResult({ record })\n\n // 1. get dependent enumerated entities\n const { nodeDefUuid } = node\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: nodeDefUuid })\n if (nodeDef.type !== NodeDefType.code) return updateResult\n const codeDef = nodeDef as NodeDefCode\n\n const dependentEnumeratedEntityDefs = Surveys.getDependentEnumeratedEntityDefs({ survey, nodeDef: codeDef })\n if (dependentEnumeratedEntityDefs.length === 0) return updateResult\n\n const ancestorMultipleEntityDef = Surveys.getNodeDefAncestorMultipleEntity({ survey, nodeDef })!\n const ancestorMultipleEntity = getAncestor({ node, ancestorDefUuid: ancestorMultipleEntityDef.uuid })(record)!\n\n // 2. update enumerated entities\n for (const entityDef of dependentEnumeratedEntityDefs) {\n // sequential: each iteration updates the record\n await createOrDeleteEnumeratedEntities({ ...params, entityDef, parentNode: ancestorMultipleEntity, updateResult }) // NOSONAR\n }\n return updateResult\n}\n"]}
|
|
@@ -91,7 +91,7 @@ const syncEnumeratingItemsEntities = (params) => __awaiter(void 0, void 0, void
|
|
|
91
91
|
const existingItemUuids = new Set();
|
|
92
92
|
for (const existingEntity of existingEntities) {
|
|
93
93
|
const existingEnumerator = (0, recordGetters_1.getChild)({ parentNode: existingEntity, childDefUuid: enumeratorDef.uuid })(updateResult.record);
|
|
94
|
-
const itemUuid = node_1.NodeValues.getItemUuid(existingEnumerator);
|
|
94
|
+
const itemUuid = existingEnumerator ? node_1.NodeValues.getItemUuid(existingEnumerator) : undefined;
|
|
95
95
|
if (!itemUuid || !targetItemUuids.has(itemUuid)) {
|
|
96
96
|
const nodesDeleteUpdatedResult = (0, recordNodesDeleter_1.deleteNodes)([existingEntity.uuid], recordUpdateOptions)(updateResult.record);
|
|
97
97
|
updateResult.merge(nodesDeleteUpdatedResult);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordNodeDependentsEnumeratingItemsUpdater.js","sourceRoot":"","sources":["../../../src/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA4E;AAC5E,2CAAuD;AACvD,yCAA8C;AAC9C,gDAA0D;AAC1D,6DAA0E;AAE1E,wCAAoC;AACpC,yDAAqE;AACrE,2GAA6F;AAE7F,6DAAiE;AACjE,6DAAkD;AAClD,6DAAyD;AAEzD,MAAM,+BAA+B,GAAG,CAAC,MAIxC,EAAiB,EAAE;IAClB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;IACvC,MAAM,YAAY,GAAG,iBAAO,CAAC,wBAAwB,CAAC;QACpD,MAAM;QACN,IAAI;QACJ,cAAc,EAAE,6BAAoB,CAAC,gBAAgB;KACtD,CAAC,CAAC,MAAM,CAAC,CAAA;IAEV,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO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AAM,uCAAuC,GAAG,CACrD,MAAwC,EACX,EAAE;IAC/B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;IAEvC,MAAM,YAAY,GAAG,IAAI,uCAAkB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IAEvD,MAAM,YAAY,GAAG,+BAA+B,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IAE9E,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,WAAW,CAAA;QACpD,IAAI,CAAC,kBAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,SAAQ;QAEzC,MAAM,SAAS,GAAG,OAAwB,CAAA;QAC1C,IAAI,CAAC,kBAAQ,CAAC,WAAW,CAAC,SAAS,CAAC;YAAE,SAAQ;QAC9C,IAAI,CAAC,kBAAQ,CAAC,6BAA6B,CAAC,SAAS,CAAC;YAAE,SAAQ;QAEhE,gDAAgD;QAChD,MAAM,IAAA,QAAA,4BAA4B,kCAAM,MAAM,KAAE,UAAU,EAAE,SAAS,EAAE,YAAY,IAAG,CAAA,CAAC,UAAU;IACnG,CAAC;IAED,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA,CAAA;AAtBY,QAAA,uCAAuC,GAAvC,uCAAuC,CAsBnD","sourcesContent":["import { ArenaRecordNode, NodePointer, Nodes, NodeValues } from '../../node'\nimport { NodeDefEntity, NodeDefs } from '../../nodeDef'\nimport { Survey, Surveys } from '../../survey'\nimport { SurveyDependencyType } from '../../survey/survey'\nimport { getChild, getChildren, getRoot } from '../_records/recordGetters'\nimport { ArenaRecord } from '../record'\nimport { Records } from '../records'\nimport { getEnumeratingCategoryItems } from '../_records/recordUtils'\nimport { getEnumeratingItemsAllowedCodes } from './recordEnumeratingItemsExpressionEvaluator'\nimport { RecordNodeDependentsUpdateParams } from './recordNodeDependentsUpdateParams'\nimport { createEnumeratedEntityNode } from './recordNodesCreator'\nimport { deleteNodes } from './recordNodesDeleter'\nimport { RecordUpdateResult } from './recordUpdateResult'\n\nconst getEnumeratingItemsNodePointers = (params: {\n survey: Survey\n record: ArenaRecord\n node: ArenaRecordNode\n}): NodePointer[] => {\n const { survey, record, node } = params\n const nodePointers = Records.getDependentNodePointers({\n survey,\n node,\n dependencyType: SurveyDependencyType.enumeratingItems,\n })(record)\n\n if (nodePointers.length > 0 || !node.deleted) {\n return nodePointers\n }\n\n const dependentDefs = Surveys.getNodeDefDependents({\n survey,\n nodeDefUuid: node.nodeDefUuid,\n dependencyType: SurveyDependencyType.enumeratingItems,\n })\n const root = getRoot(record)\n if (!root) {\n return nodePointers\n }\n\n for (const dependentDef of dependentDefs) {\n if (!NodeDefs.isEntity(dependentDef) || !NodeDefs.getEnumeratingItemsExpression(dependentDef as NodeDefEntity)) {\n continue\n }\n const parentDef = Surveys.getNodeDefParent({ survey, nodeDef: dependentDef })\n if (!parentDef) continue\n\n const contextNodes = Records.getDescendantsOrSelf({ node: root, nodeDefDescendant: parentDef })(record)\n for (const contextNode of contextNodes) {\n nodePointers.push({ nodeCtx: contextNode, nodeDef: dependentDef })\n }\n }\n\n return nodePointers\n}\n\nexport const syncEnumeratingItemsEntities = async (\n params: RecordNodeDependentsUpdateParams & {\n parentNode: ArenaRecordNode\n entityDef: NodeDefEntity\n updateResult: RecordUpdateResult\n }\n): Promise<void> => {\n const { survey, user, parentNode, entityDef, categoryItemProvider, updateResult, sideEffect } = params\n const recordUpdateOptions = { sideEffect }\n const existingEntities = getChildren({ parentNode, childDefUuid: entityDef.uuid })(updateResult.record)\n const applicable = Nodes.isChildApplicable(parentNode, entityDef.uuid)\n\n const deleteExistingEntities = () => {\n const existingEntityUuids = existingEntities.map((node) => node.uuid)\n const nodesDeleteUpdatedResult = deleteNodes(existingEntityUuids, recordUpdateOptions)(updateResult.record)\n updateResult.merge(nodesDeleteUpdatedResult)\n }\n\n if (!applicable) {\n if (existingEntities.length > 0) {\n deleteExistingEntities()\n }\n return\n }\n\n const enumeratorDef = Surveys.getNodeDefEnumerator({ survey, entityDef })\n if (!enumeratorDef) return\n\n const allowedCodes = await getEnumeratingItemsAllowedCodes({\n survey,\n user,\n record: updateResult.record,\n entityDef,\n parentNode,\n })\n\n const categoryItems = await getEnumeratingCategoryItems({\n survey,\n enumeratorDef,\n parentNode,\n categoryItemProvider,\n allowedCodes,\n })(updateResult.record)\n\n const targetItemUuids = new Set(categoryItems.map((item) => item.uuid))\n const existingItemUuids = new Set<string>()\n\n for (const existingEntity of existingEntities) {\n const existingEnumerator = getChild({ parentNode: existingEntity, childDefUuid: enumeratorDef.uuid })(\n updateResult.record\n )\n const itemUuid = NodeValues.getItemUuid(existingEnumerator)\n if (!itemUuid || !targetItemUuids.has(itemUuid)) {\n const nodesDeleteUpdatedResult = deleteNodes([existingEntity.uuid], recordUpdateOptions)(updateResult.record)\n updateResult.merge(nodesDeleteUpdatedResult)\n } else {\n existingItemUuids.add(itemUuid)\n }\n }\n\n for (const categoryItem of categoryItems) {\n if (!existingItemUuids.has(categoryItem.uuid)) {\n const createParams = {\n user,\n survey,\n parentNode,\n nodeDef: entityDef,\n enumeratorDef,\n categoryItem,\n updateResult,\n sideEffect,\n }\n // create entities sequentially: every iteration updates the record\n await createEnumeratedEntityNode(createParams) // NOSONAR\n }\n }\n}\n\nexport const updateDependentEnumeratingItemsEntities = async (\n params: RecordNodeDependentsUpdateParams\n): Promise<RecordUpdateResult> => {\n const { survey, record, node } = params\n\n const updateResult = new RecordUpdateResult({ record })\n\n const nodePointers = getEnumeratingItemsNodePointers({ survey, record, node })\n\n for (const nodePointer of nodePointers) {\n const { nodeCtx: parentNode, nodeDef } = nodePointer\n if (!NodeDefs.isEntity(nodeDef)) continue\n\n const entityDef = nodeDef as NodeDefEntity\n if (!NodeDefs.isEnumerate(entityDef)) continue\n if (!NodeDefs.getEnumeratingItemsExpression(entityDef)) continue\n\n // sequential: each iteration updates the record\n await syncEnumeratingItemsEntities({ ...params, parentNode, entityDef, updateResult }) // NOSONAR\n }\n\n return updateResult\n}\n"]}
|
|
1
|
+
{"version":3,"file":"recordNodeDependentsEnumeratingItemsUpdater.js","sourceRoot":"","sources":["../../../src/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA4E;AAC5E,2CAAuD;AACvD,yCAA8C;AAC9C,gDAA0D;AAC1D,6DAA0E;AAE1E,wCAAoC;AACpC,yDAAqE;AACrE,2GAA6F;AAE7F,6DAAiE;AACjE,6DAAkD;AAClD,6DAAyD;AAEzD,MAAM,+BAA+B,GAAG,CAAC,MAIxC,EAAiB,EAAE;IAClB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;IACvC,MAAM,YAAY,GAAG,iBAAO,CAAC,wBAAwB,CAAC;QACpD,MAAM;QACN,IAAI;QACJ,cAAc,EAAE,6BAAoB,CAAC,gBAAgB;KACtD,CAAC,CAAC,MAAM,CAAC,CAAA;IAEV,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAC7C,OAAO,YAAY,CAAA;IACrB,CAAC;IAED,MAAM,aAAa,GAAG,gBAAO,CAAC,oBAAoB,CAAC;QACjD,MAAM;QACN,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,cAAc,EAAE,6BAAoB,CAAC,gBAAgB;KACtD,CAAC,CAAA;IACF,MAAM,IAAI,GAAG,IAAA,uBAAO,EAAC,MAAM,CAAC,CAAA;IAC5B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,YAAY,CAAA;IACrB,CAAC;IAED,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;QACzC,IAAI,CAAC,kBAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,kBAAQ,CAAC,6BA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,kBAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,SAAQ;QAEzC,MAAM,SAAS,GAAG,OAAwB,CAAA;QAC1C,IAAI,CAAC,kBAAQ,CAAC,WAAW,CAAC,SAAS,CAAC;YAAE,SAAQ;QAC9C,IAAI,CAAC,kBAAQ,CAAC,6BAA6B,CAAC,SAAS,CAAC;YAAE,SAAQ;QAEhE,gDAAgD;QAChD,MAAM,IAAA,QAAA,4BAA4B,kCAAM,MAAM,KAAE,UAAU,EAAE,SAAS,EAAE,YAAY,IAAG,CAAA,CAAC,UAAU;IACnG,CAAC;IAED,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA,CAAA;AAtBY,QAAA,uCAAuC,GAAvC,uCAAuC,CAsBnD","sourcesContent":["import { ArenaRecordNode, NodePointer, Nodes, NodeValues } from '../../node'\nimport { NodeDefEntity, NodeDefs } from '../../nodeDef'\nimport { Survey, Surveys } from '../../survey'\nimport { SurveyDependencyType } from '../../survey/survey'\nimport { getChild, getChildren, getRoot } from '../_records/recordGetters'\nimport { ArenaRecord } from '../record'\nimport { Records } from '../records'\nimport { getEnumeratingCategoryItems } from '../_records/recordUtils'\nimport { getEnumeratingItemsAllowedCodes } from './recordEnumeratingItemsExpressionEvaluator'\nimport { RecordNodeDependentsUpdateParams } from './recordNodeDependentsUpdateParams'\nimport { createEnumeratedEntityNode } from './recordNodesCreator'\nimport { deleteNodes } from './recordNodesDeleter'\nimport { RecordUpdateResult } from './recordUpdateResult'\n\nconst getEnumeratingItemsNodePointers = (params: {\n survey: Survey\n record: ArenaRecord\n node: ArenaRecordNode\n}): NodePointer[] => {\n const { survey, record, node } = params\n const nodePointers = Records.getDependentNodePointers({\n survey,\n node,\n dependencyType: SurveyDependencyType.enumeratingItems,\n })(record)\n\n if (nodePointers.length > 0 || !node.deleted) {\n return nodePointers\n }\n\n const dependentDefs = Surveys.getNodeDefDependents({\n survey,\n nodeDefUuid: node.nodeDefUuid,\n dependencyType: SurveyDependencyType.enumeratingItems,\n })\n const root = getRoot(record)\n if (!root) {\n return nodePointers\n }\n\n for (const dependentDef of dependentDefs) {\n if (!NodeDefs.isEntity(dependentDef) || !NodeDefs.getEnumeratingItemsExpression(dependentDef as NodeDefEntity)) {\n continue\n }\n const parentDef = Surveys.getNodeDefParent({ survey, nodeDef: dependentDef })\n if (!parentDef) continue\n\n const contextNodes = Records.getDescendantsOrSelf({ node: root, nodeDefDescendant: parentDef })(record)\n for (const contextNode of contextNodes) {\n nodePointers.push({ nodeCtx: contextNode, nodeDef: dependentDef })\n }\n }\n\n return nodePointers\n}\n\nexport const syncEnumeratingItemsEntities = async (\n params: RecordNodeDependentsUpdateParams & {\n parentNode: ArenaRecordNode\n entityDef: NodeDefEntity\n updateResult: RecordUpdateResult\n }\n): Promise<void> => {\n const { survey, user, parentNode, entityDef, categoryItemProvider, updateResult, sideEffect } = params\n const recordUpdateOptions = { sideEffect }\n const existingEntities = getChildren({ parentNode, childDefUuid: entityDef.uuid })(updateResult.record)\n const applicable = Nodes.isChildApplicable(parentNode, entityDef.uuid)\n\n const deleteExistingEntities = () => {\n const existingEntityUuids = existingEntities.map((node) => node.uuid)\n const nodesDeleteUpdatedResult = deleteNodes(existingEntityUuids, recordUpdateOptions)(updateResult.record)\n updateResult.merge(nodesDeleteUpdatedResult)\n }\n\n if (!applicable) {\n if (existingEntities.length > 0) {\n deleteExistingEntities()\n }\n return\n }\n\n const enumeratorDef = Surveys.getNodeDefEnumerator({ survey, entityDef })\n if (!enumeratorDef) return\n\n const allowedCodes = await getEnumeratingItemsAllowedCodes({\n survey,\n user,\n record: updateResult.record,\n entityDef,\n parentNode,\n })\n\n const categoryItems = await getEnumeratingCategoryItems({\n survey,\n enumeratorDef,\n parentNode,\n categoryItemProvider,\n allowedCodes,\n })(updateResult.record)\n\n const targetItemUuids = new Set(categoryItems.map((item) => item.uuid))\n const existingItemUuids = new Set<string>()\n\n for (const existingEntity of existingEntities) {\n const existingEnumerator = getChild({ parentNode: existingEntity, childDefUuid: enumeratorDef.uuid })(\n updateResult.record\n )\n const itemUuid = existingEnumerator ? NodeValues.getItemUuid(existingEnumerator) : undefined\n if (!itemUuid || !targetItemUuids.has(itemUuid)) {\n const nodesDeleteUpdatedResult = deleteNodes([existingEntity.uuid], recordUpdateOptions)(updateResult.record)\n updateResult.merge(nodesDeleteUpdatedResult)\n } else {\n existingItemUuids.add(itemUuid)\n }\n }\n\n for (const categoryItem of categoryItems) {\n if (!existingItemUuids.has(categoryItem.uuid)) {\n const createParams = {\n user,\n survey,\n parentNode,\n nodeDef: entityDef,\n enumeratorDef,\n categoryItem,\n updateResult,\n sideEffect,\n }\n // create entities sequentially: every iteration updates the record\n await createEnumeratedEntityNode(createParams) // NOSONAR\n }\n }\n}\n\nexport const updateDependentEnumeratingItemsEntities = async (\n params: RecordNodeDependentsUpdateParams\n): Promise<RecordUpdateResult> => {\n const { survey, record, node } = params\n\n const updateResult = new RecordUpdateResult({ record })\n\n const nodePointers = getEnumeratingItemsNodePointers({ survey, record, node })\n\n for (const nodePointer of nodePointers) {\n const { nodeCtx: parentNode, nodeDef } = nodePointer\n if (!NodeDefs.isEntity(nodeDef)) continue\n\n const entityDef = nodeDef as NodeDefEntity\n if (!NodeDefs.isEnumerate(entityDef)) continue\n if (!NodeDefs.getEnumeratingItemsExpression(entityDef)) continue\n\n // sequential: each iteration updates the record\n await syncEnumeratingItemsEntities({ ...params, parentNode, entityDef, updateResult }) // NOSONAR\n }\n\n return updateResult\n}\n"]}
|
package/dist/record/records.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare const Records: {
|
|
|
21
21
|
getChild: import("./_records/recordGetters").PositionalRecordGetter<{
|
|
22
22
|
parentNode: import("..").ArenaRecordNode;
|
|
23
23
|
childDefUuid: string;
|
|
24
|
-
}, [parentNode: import("..").ArenaRecordNode, childDefUuid: string], import("..").ArenaRecordNode>;
|
|
24
|
+
}, [parentNode: import("..").ArenaRecordNode, childDefUuid: string], import("..").ArenaRecordNode | undefined>;
|
|
25
25
|
getChildren: import("./_records/recordGetters").PositionalRecordGetter<{
|
|
26
26
|
parentNode: import("..").ArenaRecordNode;
|
|
27
27
|
childDefUuid?: string;
|
|
@@ -107,7 +107,7 @@ export declare const Records: {
|
|
|
107
107
|
record: import("./record").ArenaRecord;
|
|
108
108
|
node: import("..").ArenaRecordNode;
|
|
109
109
|
nodeDefDescendant: import("..").NodeDef<any>;
|
|
110
|
-
}, import("..").ArenaRecordNode>;
|
|
110
|
+
}, import("..").ArenaRecordNode | undefined>;
|
|
111
111
|
getDescendantsOrSelf: import("./_records/recordGetters").RecordGetter<{
|
|
112
112
|
record: import("./record").ArenaRecord;
|
|
113
113
|
node: import("..").ArenaRecordNode;
|
package/dist/registry/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AAA1C,kHAAA,eAAe,OAAA;AACxB,6CAA2C;AAAlC,0GAAA,WAAW,OAAA","sourcesContent":["export { ServiceRegistry } from './serviceRegistry'\nexport { ServiceType } from './serviceType'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AAA1C,kHAAA,eAAe,OAAA;AACxB,6CAA2C;AAAlC,0GAAA,WAAW,OAAA","sourcesContent":["export { ServiceRegistry } from './serviceRegistry'\nexport { ServiceType } from './serviceType'\nexport type { ServiceTypeMap } from './serviceTypeMap'\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ArenaService } from '../common';
|
|
2
|
+
import type { ServiceTypeMap } from './serviceTypeMap';
|
|
2
3
|
export declare class ServiceRegistry {
|
|
3
4
|
private static _instance;
|
|
4
5
|
private readonly services;
|
|
5
6
|
private constructor();
|
|
6
7
|
static getInstance(): ServiceRegistry;
|
|
8
|
+
getService<K extends keyof ServiceTypeMap>(key: K): ServiceTypeMap[K];
|
|
7
9
|
getService<S extends ArenaService>(key: string): S;
|
|
8
10
|
registerService(type: string, service: ArenaService): this;
|
|
9
11
|
registerServicesFromRegistry(registry: ServiceRegistry): this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceRegistry.js","sourceRoot":"","sources":["../../src/registry/serviceRegistry.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"serviceRegistry.js","sourceRoot":"","sources":["../../src/registry/serviceRegistry.ts"],"names":[],"mappings":";;;AAGA;IAIE;QACE,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;IACpB,CAAC;IAEM,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,CAAC;YAC/B,eAAe,CAAC,SAAS,GAAG,IAAI,eAAe,EAAE,CAAA;QACnD,CAAC;QACD,OAAO,eAAe,CAAC,SAAS,CAAA;IAClC,CAAC;IAID,UAAU,CAAC,GAAW;QACpB,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;QAClC,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,WAAW,GAAG,iBAAiB,CAAC,CAAA;QAC9D,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,eAAe,CAAC,IAAY,EAAE,OAAqB;QACjD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,CAAA;QAC7B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,4BAA4B,CAAC,QAAyB;QACpD,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE;YAC3D,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QACpC,CAAC,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;IACb,CAAC;CACF","sourcesContent":["import { ArenaService } from '../common'\nimport type { ServiceTypeMap } from './serviceTypeMap'\n\nexport class ServiceRegistry {\n private static _instance: ServiceRegistry\n private readonly services: { [key: string]: ArenaService }\n\n private constructor() {\n this.services = {}\n }\n\n public static getInstance(): ServiceRegistry {\n if (!ServiceRegistry._instance) {\n ServiceRegistry._instance = new ServiceRegistry()\n }\n return ServiceRegistry._instance\n }\n\n getService<K extends keyof ServiceTypeMap>(key: K): ServiceTypeMap[K]\n getService<S extends ArenaService>(key: string): S\n getService(key: string): ArenaService {\n const service = this.services[key]\n if (!service) throw new Error(`Service ${key} not registered`)\n return service\n }\n\n registerService(type: string, service: ArenaService): this {\n this.services[type] = service\n return this\n }\n\n registerServicesFromRegistry(registry: ServiceRegistry): this {\n Object.entries(registry.services).forEach(([key, service]) => {\n this.registerService(key, service)\n })\n return this\n }\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { UserAuthTokenService, UserService } from '../auth';
|
|
2
|
+
import type { CategoryItemService, CategoryLevelService, CategoryService } from '../category';
|
|
3
|
+
import type { ChainNodeDefService, ChainService } from '../chain';
|
|
4
|
+
import type { NodeService } from '../node';
|
|
5
|
+
import type { NodeDefService } from '../nodeDef';
|
|
6
|
+
import type { RecordService } from '../record';
|
|
7
|
+
import type { SurveyService } from '../survey';
|
|
8
|
+
import type { TaxonomyService, TaxonService } from '../taxonomy';
|
|
9
|
+
import { ServiceType } from './serviceType';
|
|
10
|
+
/**
|
|
11
|
+
* Type of the service registered for each ServiceType, used to type ServiceRegistry.getService.
|
|
12
|
+
* Being an interface, it can be augmented (declaration merging) with other service types.
|
|
13
|
+
*/
|
|
14
|
+
export interface ServiceTypeMap {
|
|
15
|
+
[ServiceType.category]: CategoryService;
|
|
16
|
+
[ServiceType.categoryItem]: CategoryItemService;
|
|
17
|
+
[ServiceType.categoryLevel]: CategoryLevelService;
|
|
18
|
+
[ServiceType.chain]: ChainService;
|
|
19
|
+
[ServiceType.chainNodeDef]: ChainNodeDefService;
|
|
20
|
+
[ServiceType.node]: NodeService;
|
|
21
|
+
[ServiceType.nodeDef]: NodeDefService;
|
|
22
|
+
[ServiceType.record]: RecordService;
|
|
23
|
+
[ServiceType.survey]: SurveyService;
|
|
24
|
+
[ServiceType.taxon]: TaxonService;
|
|
25
|
+
[ServiceType.taxonomy]: TaxonomyService;
|
|
26
|
+
[ServiceType.user]: UserService;
|
|
27
|
+
[ServiceType.userAuthToken]: UserAuthTokenService;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serviceTypeMap.js","sourceRoot":"","sources":["../../src/registry/serviceTypeMap.ts"],"names":[],"mappings":";;AASA,+CAA2C","sourcesContent":["import type { UserAuthTokenService, UserService } from '../auth'\nimport type { CategoryItemService, CategoryLevelService, CategoryService } from '../category'\nimport type { ChainNodeDefService, ChainService } from '../chain'\nimport type { NodeService } from '../node'\nimport type { NodeDefService } from '../nodeDef'\nimport type { RecordService } from '../record'\nimport type { SurveyService } from '../survey'\nimport type { TaxonomyService, TaxonService } from '../taxonomy'\n\nimport { ServiceType } from './serviceType'\n\n/**\n * Type of the service registered for each ServiceType, used to type ServiceRegistry.getService.\n * Being an interface, it can be augmented (declaration merging) with other service types.\n */\nexport interface ServiceTypeMap {\n [ServiceType.category]: CategoryService\n [ServiceType.categoryItem]: CategoryItemService\n [ServiceType.categoryLevel]: CategoryLevelService\n [ServiceType.chain]: ChainService\n [ServiceType.chainNodeDef]: ChainNodeDefService\n [ServiceType.node]: NodeService\n [ServiceType.nodeDef]: NodeDefService\n [ServiceType.record]: RecordService\n [ServiceType.survey]: SurveyService\n [ServiceType.taxon]: TaxonService\n [ServiceType.taxonomy]: TaxonomyService\n [ServiceType.user]: UserService\n [ServiceType.userAuthToken]: UserAuthTokenService\n}\n"]}
|