@openforis/arena-core 2.5.11 → 2.5.13
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/geo/points/index.js +2 -1
- package/dist/esm/geo/points/index.js.map +1 -1
- package/dist/esm/geo/points/transform.js +30 -15
- package/dist/esm/geo/points/transform.js.map +1 -1
- package/dist/esm/nodeDefExpressionEvaluator/node/identifier.js.map +1 -1
- package/dist/esm/record/_records/recordGetters.js +1 -1
- package/dist/esm/record/_records/recordGetters.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
- package/dist/esm/survey/surveys/nodeDefs.js.map +1 -1
- package/dist/esm/utils/numbers.js +2 -0
- package/dist/esm/utils/numbers.js.map +1 -1
- package/dist/esm/utils/queue.js.map +1 -1
- package/dist/geo/points/index.d.ts +2 -1
- package/dist/geo/points/index.js +1 -0
- package/dist/geo/points/index.js.map +1 -1
- package/dist/geo/points/transform.d.ts +16 -5
- package/dist/geo/points/transform.js +32 -16
- package/dist/geo/points/transform.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/node/identifier.js.map +1 -1
- package/dist/record/_records/recordGetters.js +1 -1
- package/dist/record/_records/recordGetters.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
- package/dist/survey/surveys/nodeDefs.js.map +1 -1
- package/dist/utils/numbers.d.ts +2 -0
- package/dist/utils/numbers.js +2 -0
- package/dist/utils/numbers.js.map +1 -1
- package/dist/utils/queue.d.ts +8 -8
- package/dist/utils/queue.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import { pointAtDistance } from './pointAtDistance';
|
|
|
6
6
|
import { parse } from './parse';
|
|
7
7
|
import { toLatLong } from './toLatLong';
|
|
8
8
|
import { toString } from './toString';
|
|
9
|
-
import { transform } from './transform';
|
|
9
|
+
import { transform, transformOrThrow } from './transform';
|
|
10
10
|
export const Points = {
|
|
11
11
|
bearing,
|
|
12
12
|
distance,
|
|
@@ -17,5 +17,6 @@ export const Points = {
|
|
|
17
17
|
toLatLong,
|
|
18
18
|
toString,
|
|
19
19
|
transform,
|
|
20
|
+
transformOrThrow,
|
|
20
21
|
};
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/geo/points/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/geo/points/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEzD,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,OAAO;IACP,QAAQ;IACR,MAAM;IACN,OAAO;IACP,eAAe;IACf,KAAK;IACL,SAAS;IACT,QAAQ;IACR,SAAS;IACT,gBAAgB;CACjB,CAAA","sourcesContent":["import { bearing } from './bearing'\nimport { distance } from './distance'\nimport { equals } from './equals'\nimport { isValid } from './isValid'\nimport { pointAtDistance } from './pointAtDistance'\nimport { parse } from './parse'\nimport { toLatLong } from './toLatLong'\nimport { toString } from './toString'\nimport { transform, transformOrThrow } from './transform'\n\nexport const Points = {\n bearing,\n distance,\n equals,\n isValid,\n pointAtDistance,\n parse,\n toLatLong,\n toString,\n transform,\n transformOrThrow,\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import proj4 from 'proj4';
|
|
2
|
+
import { SystemError } from '../../error';
|
|
2
3
|
import { DEFAULT_SRS_INDEX } from '../../srs';
|
|
3
4
|
import { PointFactory } from '../pointFactory';
|
|
4
5
|
import { isFilled } from './isFilled';
|
|
@@ -15,36 +16,50 @@ const getConverter = (wktFrom, wktTo) => {
|
|
|
15
16
|
return converter;
|
|
16
17
|
};
|
|
17
18
|
/**
|
|
18
|
-
*
|
|
19
|
+
* Transforms the specified point from one SRS into another, throwing a SystemError with the reason when it cannot.
|
|
19
20
|
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
23
|
-
* @returns
|
|
21
|
+
* @param point - The point to transform.
|
|
22
|
+
* @param srsCodeTo - The SRS code to transform the point into.
|
|
23
|
+
* @param srsIndex - SRSs indexed by SRS code.
|
|
24
|
+
* @returns The transformed point (the point itself if it is already in the target SRS).
|
|
25
|
+
* @throws {SystemError} `geo.pointNotFilled`, `geo.srsNotFound` (with the `code` param) or `geo.transformFailed`.
|
|
24
26
|
*/
|
|
25
|
-
export const
|
|
27
|
+
export const transformOrThrow = (point, srsCodeTo, srsIndex = DEFAULT_SRS_INDEX) => {
|
|
26
28
|
if (!isFilled(point))
|
|
27
|
-
|
|
29
|
+
throw new SystemError('geo.pointNotFilled');
|
|
28
30
|
const { srs: srsCodeFrom } = point;
|
|
29
31
|
if (srsCodeFrom === srsCodeTo) {
|
|
30
32
|
// projection is not needed
|
|
31
33
|
return point;
|
|
32
34
|
}
|
|
33
35
|
const srsFrom = getSrs({ code: srsCodeFrom, srsIndex });
|
|
34
|
-
if (!srsFrom)
|
|
35
|
-
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
36
|
+
if (!srsFrom)
|
|
37
|
+
throw new SystemError('geo.srsNotFound', { code: srsCodeFrom });
|
|
38
38
|
const srsTo = getSrs({ code: srsCodeTo, srsIndex });
|
|
39
|
-
if (!srsTo)
|
|
40
|
-
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
39
|
+
if (!srsTo)
|
|
40
|
+
throw new SystemError('geo.srsNotFound', { code: srsCodeTo });
|
|
43
41
|
try {
|
|
44
42
|
const { x, y } = point;
|
|
45
43
|
const [long, lat] = getConverter(srsFrom.wkt, srsTo.wkt).forward([Number(x), Number(y)]);
|
|
46
44
|
return PointFactory.createInstance(Object.assign(Object.assign({}, point), { srs: srsCodeTo, x: long, y: lat }));
|
|
47
45
|
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
throw new SystemError('geo.transformFailed', { srsFrom: srsCodeFrom, srsTo: srsCodeTo }, { cause: error });
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Transforms the specified point from one SRS into another.
|
|
52
|
+
* Use `transformOrThrow` to know why a point cannot be transformed.
|
|
53
|
+
*
|
|
54
|
+
* @param point - The point to transform.
|
|
55
|
+
* @param srsCodeTo - The SRS code to transform the point into.
|
|
56
|
+
* @param srsIndex - SRSs indexed by SRS code.
|
|
57
|
+
* @returns The transformed point, or null if the point is not filled, an SRS is unknown or the transformation fails.
|
|
58
|
+
*/
|
|
59
|
+
export const transform = (point, srsCodeTo, srsIndex = DEFAULT_SRS_INDEX) => {
|
|
60
|
+
try {
|
|
61
|
+
return transformOrThrow(point, srsCodeTo, srsIndex);
|
|
62
|
+
}
|
|
48
63
|
catch (_a) {
|
|
49
64
|
return null;
|
|
50
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../../src/geo/points/transform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAyB,MAAM,OAAO,CAAA;AAE7C,OAAO,EAAE,iBAAiB,EAAY,MAAM,WAAW,CAAA;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,oGAAoG;AACpG,MAAM,eAAe,GAAG,IAAI,GAAG,EAAqB,CAAA;AAEpD,MAAM,YAAY,GAAG,CAAC,OAAe,EAAE,KAAa,EAAa,EAAE;IACjE,MAAM,GAAG,GAAG,GAAG,OAAO,KAAK,KAAK,EAAE,CAAA;IAClC,IAAI,SAAS,GAAG,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACxC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,SAAS,GAAG,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QACjC,eAAe,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAA;IACrC,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAED
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../../src/geo/points/transform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAyB,MAAM,OAAO,CAAA;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAY,MAAM,WAAW,CAAA;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,E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;QAAE,MAAM,IAAI,WAAW,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;IAEzE,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,KAAK,CAAA;QACtB,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAExF,OAAO,YAAY,CAAC,cAAc,iCAAM,KAAK,KAAE,GAAG,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,IAAG,CAAA;IACnF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,WAAW,CAAC,qBAAqB,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;IAC5G,CAAC;AACH,CAAC,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAY,EAAE,SAAiB,EAAE,QAAQ,GAAa,iBAAiB,EAAgB,EAAE;IACjH,IAAI,CAAC;QACH,OAAO,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;IACrD,CAAC;eAAO,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC,CAAA","sourcesContent":["import proj4, { type Converter } from 'proj4'\n\nimport { SystemError } from '../../error'\nimport { DEFAULT_SRS_INDEX, SRSIndex } from '../../srs'\nimport { Point } from '../point'\nimport { PointFactory } from '../pointFactory'\nimport { isFilled } from './isFilled'\nimport { getSrs } from './getSrs'\n\n// proj4 parses both WKT strings every time it is called with them: cache the converters by WKT pair\nconst convertersCache = new Map<string, Converter>()\n\nconst getConverter = (wktFrom: string, wktTo: string): Converter => {\n const key = `${wktFrom}\\n${wktTo}`\n let converter = convertersCache.get(key)\n if (!converter) {\n converter = proj4(wktFrom, wktTo)\n convertersCache.set(key, converter)\n }\n return converter\n}\n\n/**\n * Transforms the specified point from one SRS into another, throwing a SystemError with the reason when it cannot.\n *\n * @param point - The point to transform.\n * @param srsCodeTo - The SRS code to transform the point into.\n * @param srsIndex - SRSs indexed by SRS code.\n * @returns The transformed point (the point itself if it is already in the target SRS).\n * @throws {SystemError} `geo.pointNotFilled`, `geo.srsNotFound` (with the `code` param) or `geo.transformFailed`.\n */\nexport const transformOrThrow = (point: Point, srsCodeTo: string, srsIndex: SRSIndex = DEFAULT_SRS_INDEX): Point => {\n if (!isFilled(point)) throw new SystemError('geo.pointNotFilled')\n\n const { srs: srsCodeFrom } = point\n\n if (srsCodeFrom === srsCodeTo) {\n // projection is not needed\n return point\n }\n const srsFrom = getSrs({ code: srsCodeFrom, srsIndex })\n if (!srsFrom) throw new SystemError('geo.srsNotFound', { code: srsCodeFrom })\n\n const srsTo = getSrs({ code: srsCodeTo, srsIndex })\n if (!srsTo) throw new SystemError('geo.srsNotFound', { code: srsCodeTo })\n\n try {\n const { x, y } = point\n const [long, lat] = getConverter(srsFrom.wkt, srsTo.wkt).forward([Number(x), Number(y)])\n\n return PointFactory.createInstance({ ...point, srs: srsCodeTo, x: long, y: lat })\n } catch (error) {\n throw new SystemError('geo.transformFailed', { srsFrom: srsCodeFrom, srsTo: srsCodeTo }, { cause: error })\n }\n}\n\n/**\n * Transforms the specified point from one SRS into another.\n * Use `transformOrThrow` to know why a point cannot be transformed.\n *\n * @param point - The point to transform.\n * @param srsCodeTo - The SRS code to transform the point into.\n * @param srsIndex - SRSs indexed by SRS code.\n * @returns The transformed point, or null if the point is not filled, an SRS is unknown or the transformation fails.\n */\nexport const transform = (point: Point, srsCodeTo: string, srsIndex: SRSIndex = DEFAULT_SRS_INDEX): Point | null => {\n try {\n return transformOrThrow(point, srsCodeTo, srsIndex)\n } catch {\n return null\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../../src/nodeDefExpressionEvaluator/node/identifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AACtG,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAA;AAE5E,OAAO,EAAE,kBAAkB,EAAwB,MAAM,kBAAkB,CAAA;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAElD;;;;;GAKG;AACH,MAAM,qBAAqB,GAAG,CAAC,MAE9B,EAAkD,EAAE;IACnD,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IAC1B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAA;IAExD,IAAI,CAAC,oBAAoB;QAAE,OAAO,SAAS,CAAA;IAE3C,IAAI,QAAQ,CAAC,WAAW,CAAC,oBAAoB,CAAC,EAAE,CAAC;QAC/C,OAAO,gBAAgB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC,CAAA;IACpE,CAAC;IACD,IAAI,oBAAoB,CAAC,OAAO,EAAE,CAAC;QACjC,OAAO,gBAAgB,CAAC,EAAE,MAAM,EAAE,OA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AC;IACH,CAAC;CACF","sourcesContent":["import { NodeDef, NodeDefProps, NodeDefType } from '../../nodeDef/nodeDef'\nimport { getNodeDefChildren, getNodeDefParent, getNodeDefSource } from '../../survey/surveys/nodeDefs'\nimport { NodeDefs } from '../../nodeDef/nodeDefs'\nimport { Objects, Queue } from '../../utils'\nimport { IdentifierEvaluator } from '../../expression/javascript/node/identifier'\nimport { getGlobalObjectProperty } from '../../expression/javascript/global'\nimport { NodeDefExpressionContext } from '../context'\nimport { ExpressionVariable, IdentifierExpression } from '../../expression'\nimport { SystemError } from '../../error'\nimport { ValidatorErrorKeys } from '../../validation'\nimport { NodeNativeProperties } from './nodeDefExpressionNativeProperties'\nimport { NodeValues } from '../../node/nodeValues'\n\n/**\n * Determines the actual context node def\n * - attribute def => parent entity def\n * - virtual entity def => source node def\n * - entity def => entity def itself\n */\nconst findActualContextNode = (params: {\n context: NodeDefExpressionContext\n}): NodeDef<NodeDefType, NodeDefProps> | undefined => {\n const { context } = params\n const { survey, object: nodeDefObjectContext } = context\n\n if (!nodeDefObjectContext) return undefined\n\n if (NodeDefs.isAttribute(nodeDefObjectContext)) {\n return getNodeDefParent({ survey, nodeDef: nodeDefObjectContext })\n }\n if (nodeDefObjectContext.virtual) {\n return getNodeDefSource({ survey, nodeDef: nodeDefObjectContext })\n }\n return nodeDefObjectContext\n}\n\nexport class NodeDefIdentifierEvaluator extends IdentifierEvaluator<NodeDefExpressionContext> {\n evaluate(expressionNode: IdentifierExpression): Promise<any> {\n try {\n return Promise.resolve(this.evaluateIdentifier(expressionNode))\n } catch (error) {\n return Promise.reject(error)\n }\n }\n\n private evaluateIdentifier(expressionNode: IdentifierExpression): any {\n const { context } = this\n const { nodeDefContext, object: objectContext, itemsFilter, memberProperty } = context\n const { name: exprName } = expressionNode\n\n if (exprName === ExpressionVariable.CONTEXT) {\n if (nodeDefContext) {\n this.addReferencedNodeDefUuid(nodeDefContext.uuid)\n }\n return nodeDefContext\n }\n\n // global objects (e.g. Math, String)\n const globalObjectProperty = getGlobalObjectProperty(exprName, objectContext)\n if (globalObjectProperty !== null) {\n return globalObjectProperty\n }\n\n if (itemsFilter) {\n const prop = objectContext?.props?.[exprName] ?? objectContext?.props?.extra?.[exprName]\n if (!Objects.isEmpty(prop)) {\n return prop\n }\n }\n\n // check if identifier is a composite attribute value prop\n if (NodeDefs.isAttribute(objectContext) && NodeValues.isValueProp({ nodeDef: objectContext, prop: exprName })) {\n return objectContext\n }\n\n if (memberProperty) {\n // property of a member expression (e.g. text_attr.length or text_attr.toUpperCase()): native properties first\n const nativeProperty = this.findNativeProperty(expressionNode)\n if (nativeProperty) return nativeProperty.value\n return this.getReferencedNodeDef(expressionNode)\n }\n // identifier not in a member expression: node defs first, so that node defs named like native properties\n // (e.g. \"name\", \"type\", \"trim\") are always found (and registered as dependencies)\n const referencedNodeDef = this.findReferencedNodeDef(expressionNode)\n if (referencedNodeDef) return referencedNodeDef\n\n const nativeProperty = this.findNativeProperty(expressionNode)\n if (nativeProperty) return nativeProperty.value\n\n return this.throwIdentifierNotFound(expressionNode)\n }\n\n /**\n * Finds the identifier among the native properties or functions of the context object\n * (e.g. String.length or String.toUpperCase()).\n */\n private findNativeProperty(expressionNode: IdentifierExpression): { value: any } | null {\n const { object: objectContext } = this.context\n const { name: exprName } = expressionNode\n\n const globalOrNativeProperty = this.findGlobalOrNativeProperty(expressionNode)\n if (globalOrNativeProperty) {\n return globalOrNativeProperty\n }\n if (NodeNativeProperties.hasNativeProperty({ nodeDefOrValue: objectContext, propName: exprName })) {\n return {\n value: NodeNativeProperties.evalNodeDefProperty({ nodeDefOrValue: objectContext, propName: exprName }),\n }\n }\n return null\n }\n\n private findReferencedNodeDef(expressionNode: IdentifierExpression): NodeDef<NodeDefType, NodeDefProps> | undefined {\n const { nodeDefCurrent, selfReferenceAllowed } = this.context\n const referencedNodeDef = this.findIdentifierAmongReachableNodeDefs(expressionNode)\n if (!referencedNodeDef) return undefined\n\n if (!selfReferenceAllowed && referencedNodeDef.uuid === nodeDefCurrent?.uuid) {\n throw new SystemError(ValidatorErrorKeys.expressions.cannotUseCurrentNode, { name: expressionNode.name })\n }\n this.addReferencedNodeDefUuid(referencedNodeDef.uuid)\n return referencedNodeDef\n }\n\n private getReferencedNodeDef(expressionNode: IdentifierExpression): NodeDef<NodeDefType, NodeDefProps> {\n return this.findReferencedNodeDef(expressionNode) ?? this.throwIdentifierNotFound(expressionNode)\n }\n\n private throwIdentifierNotFound(expressionNode: IdentifierExpression): never {\n throw new SystemError('expression.identifierNotFound', {\n name: expressionNode.name,\n contextObject: this.context.object?.props?.name,\n })\n }\n\n private addReferencedNodeDefUuid(uuid: string) {\n const { context } = this\n const { referencedNodeDefUuids = new Set() } = context\n context.referencedNodeDefUuids = referencedNodeDefUuids.add(uuid)\n }\n\n /**\n * Tries to find the specified identifier among the node defs that can be \"reached\" from the context node def.\n */\n protected findIdentifierAmongReachableNodeDefs(\n expressionNode: IdentifierExpression\n ): NodeDef<NodeDefType, NodeDefProps> | undefined {\n const { object: contextObject } = this.context\n\n if (!contextObject) return undefined\n\n // stop at the first match (same order as getReachableNodeDefs), without visiting all the reachable node defs\n for (const reachableNodeDef of this.iterateReachableNodeDefs()) {\n if (reachableNodeDef.props.name === expressionNode.name) {\n return reachableNodeDef\n }\n }\n return undefined\n }\n\n /**\n * Get reachable node defs, i.e. the children of the node definition's ancestors.\n * NOTE: The root node def is excluded, but it _should_ be an entity, so that is fine.\n */\n protected getReachableNodeDefs(): NodeDef<NodeDefType, NodeDefProps>[] {\n return Array.from(this.iterateReachableNodeDefs())\n }\n\n /**\n * Iterates over the reachable node defs (see getReachableNodeDefs), yielding every node def only once.\n */\n private *iterateReachableNodeDefs(): Generator<NodeDef<NodeDefType, NodeDefProps>> {\n const { context } = this\n const { survey, includeAnalysis } = context\n\n const reachableNodeDefUuids = new Set<string>()\n const visitedUuids = new Set<string>()\n\n const queue = new Queue()\n\n const actualContextNode = findActualContextNode({ context })\n if (actualContextNode) {\n queue.enqueue(actualContextNode)\n reachableNodeDefUuids.add(actualContextNode.uuid)\n yield actualContextNode\n }\n\n while (!queue.isEmpty()) {\n const entityDefCurrent = queue.dequeue()\n const entityDefCurrentChildren = getNodeDefChildren({ survey, nodeDef: entityDefCurrent, includeAnalysis })\n for (const childDef of entityDefCurrentChildren) {\n if (!reachableNodeDefUuids.has(childDef.uuid)) {\n reachableNodeDefUuids.add(childDef.uuid)\n yield childDef\n }\n }\n // visit nodes inside single entities\n queue.enqueueItems(entityDefCurrentChildren.filter(NodeDefs.isSingleEntity))\n\n // avoid visiting 2 times the same entity definition when traversing single entities\n if (!visitedUuids.has(entityDefCurrent.uuid)) {\n const entityDefCurrentParent = getNodeDefParent({ survey, nodeDef: entityDefCurrent })\n if (entityDefCurrentParent) {\n queue.enqueue(entityDefCurrentParent)\n }\n if (!reachableNodeDefUuids.has(entityDefCurrent.uuid)) {\n reachableNodeDefUuids.add(entityDefCurrent.uuid)\n yield entityDefCurrent\n }\n visitedUuids.add(entityDefCurrent.uuid)\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../../src/nodeDefExpressionEvaluator/node/identifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AACtG,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAA;AAE5E,OAAO,EAAE,kBAAkB,EAAwB,MAAM,kBAAkB,CAAA;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,MA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E5E,oFAAoF;YACpF,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC7C,MAAM,sBAAsB,GAAG,gBAAgB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAA;gBACtF,IAAI,sBAAsB,EAAE,CAAC;oBAC3B,KAAK,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAA;gBACvC,CAAC;gBACD,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;oBACtD,qBAAqB,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;oBAChD,MAAM,gBAAgB,CAAA;gBACxB,CAAC;gBACD,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;YACzC,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { NodeDef, NodeDefProps, NodeDefType } from '../../nodeDef/nodeDef'\nimport { getNodeDefChildren, getNodeDefParent, getNodeDefSource } from '../../survey/surveys/nodeDefs'\nimport { NodeDefs } from '../../nodeDef/nodeDefs'\nimport { Objects, Queue } from '../../utils'\nimport { IdentifierEvaluator } from '../../expression/javascript/node/identifier'\nimport { getGlobalObjectProperty } from '../../expression/javascript/global'\nimport { NodeDefExpressionContext } from '../context'\nimport { ExpressionVariable, IdentifierExpression } from '../../expression'\nimport { SystemError } from '../../error'\nimport { ValidatorErrorKeys } from '../../validation'\nimport { NodeNativeProperties } from './nodeDefExpressionNativeProperties'\nimport { NodeValues } from '../../node/nodeValues'\n\n/**\n * Determines the actual context node def\n * - attribute def => parent entity def\n * - virtual entity def => source node def\n * - entity def => entity def itself\n */\nconst findActualContextNode = (params: {\n context: NodeDefExpressionContext\n}): NodeDef<NodeDefType, NodeDefProps> | undefined => {\n const { context } = params\n const { survey, object: nodeDefObjectContext } = context\n\n if (!nodeDefObjectContext) return undefined\n\n if (NodeDefs.isAttribute(nodeDefObjectContext)) {\n return getNodeDefParent({ survey, nodeDef: nodeDefObjectContext })\n }\n if (nodeDefObjectContext.virtual) {\n return getNodeDefSource({ survey, nodeDef: nodeDefObjectContext })\n }\n return nodeDefObjectContext\n}\n\nexport class NodeDefIdentifierEvaluator extends IdentifierEvaluator<NodeDefExpressionContext> {\n evaluate(expressionNode: IdentifierExpression): Promise<any> {\n try {\n return Promise.resolve(this.evaluateIdentifier(expressionNode))\n } catch (error) {\n return Promise.reject(error)\n }\n }\n\n private evaluateIdentifier(expressionNode: IdentifierExpression): any {\n const { context } = this\n const { nodeDefContext, object: objectContext, itemsFilter, memberProperty } = context\n const { name: exprName } = expressionNode\n\n if (exprName === ExpressionVariable.CONTEXT) {\n if (nodeDefContext) {\n this.addReferencedNodeDefUuid(nodeDefContext.uuid)\n }\n return nodeDefContext\n }\n\n // global objects (e.g. Math, String)\n const globalObjectProperty = getGlobalObjectProperty(exprName, objectContext)\n if (globalObjectProperty !== null) {\n return globalObjectProperty\n }\n\n if (itemsFilter) {\n const prop = objectContext?.props?.[exprName] ?? objectContext?.props?.extra?.[exprName]\n if (!Objects.isEmpty(prop)) {\n return prop\n }\n }\n\n // check if identifier is a composite attribute value prop\n if (NodeDefs.isAttribute(objectContext) && NodeValues.isValueProp({ nodeDef: objectContext, prop: exprName })) {\n return objectContext\n }\n\n if (memberProperty) {\n // property of a member expression (e.g. text_attr.length or text_attr.toUpperCase()): native properties first\n const nativeProperty = this.findNativeProperty(expressionNode)\n if (nativeProperty) return nativeProperty.value\n return this.getReferencedNodeDef(expressionNode)\n }\n // identifier not in a member expression: node defs first, so that node defs named like native properties\n // (e.g. \"name\", \"type\", \"trim\") are always found (and registered as dependencies)\n const referencedNodeDef = this.findReferencedNodeDef(expressionNode)\n if (referencedNodeDef) return referencedNodeDef\n\n const nativeProperty = this.findNativeProperty(expressionNode)\n if (nativeProperty) return nativeProperty.value\n\n return this.throwIdentifierNotFound(expressionNode)\n }\n\n /**\n * Finds the identifier among the native properties or functions of the context object\n * (e.g. String.length or String.toUpperCase()).\n */\n private findNativeProperty(expressionNode: IdentifierExpression): { value: any } | null {\n const { object: objectContext } = this.context\n const { name: exprName } = expressionNode\n\n const globalOrNativeProperty = this.findGlobalOrNativeProperty(expressionNode)\n if (globalOrNativeProperty) {\n return globalOrNativeProperty\n }\n if (NodeNativeProperties.hasNativeProperty({ nodeDefOrValue: objectContext, propName: exprName })) {\n return {\n value: NodeNativeProperties.evalNodeDefProperty({ nodeDefOrValue: objectContext, propName: exprName }),\n }\n }\n return null\n }\n\n private findReferencedNodeDef(expressionNode: IdentifierExpression): NodeDef<NodeDefType, NodeDefProps> | undefined {\n const { nodeDefCurrent, selfReferenceAllowed } = this.context\n const referencedNodeDef = this.findIdentifierAmongReachableNodeDefs(expressionNode)\n if (!referencedNodeDef) return undefined\n\n if (!selfReferenceAllowed && referencedNodeDef.uuid === nodeDefCurrent?.uuid) {\n throw new SystemError(ValidatorErrorKeys.expressions.cannotUseCurrentNode, { name: expressionNode.name })\n }\n this.addReferencedNodeDefUuid(referencedNodeDef.uuid)\n return referencedNodeDef\n }\n\n private getReferencedNodeDef(expressionNode: IdentifierExpression): NodeDef<NodeDefType, NodeDefProps> {\n return this.findReferencedNodeDef(expressionNode) ?? this.throwIdentifierNotFound(expressionNode)\n }\n\n private throwIdentifierNotFound(expressionNode: IdentifierExpression): never {\n throw new SystemError('expression.identifierNotFound', {\n name: expressionNode.name,\n contextObject: this.context.object?.props?.name,\n })\n }\n\n private addReferencedNodeDefUuid(uuid: string) {\n const { context } = this\n const { referencedNodeDefUuids = new Set() } = context\n context.referencedNodeDefUuids = referencedNodeDefUuids.add(uuid)\n }\n\n /**\n * Tries to find the specified identifier among the node defs that can be \"reached\" from the context node def.\n */\n protected findIdentifierAmongReachableNodeDefs(\n expressionNode: IdentifierExpression\n ): NodeDef<NodeDefType, NodeDefProps> | undefined {\n const { object: contextObject } = this.context\n\n if (!contextObject) return undefined\n\n // stop at the first match (same order as getReachableNodeDefs), without visiting all the reachable node defs\n for (const reachableNodeDef of this.iterateReachableNodeDefs()) {\n if (reachableNodeDef.props.name === expressionNode.name) {\n return reachableNodeDef\n }\n }\n return undefined\n }\n\n /**\n * Get reachable node defs, i.e. the children of the node definition's ancestors.\n * NOTE: The root node def is excluded, but it _should_ be an entity, so that is fine.\n */\n protected getReachableNodeDefs(): NodeDef<NodeDefType, NodeDefProps>[] {\n return Array.from(this.iterateReachableNodeDefs())\n }\n\n /**\n * Iterates over the reachable node defs (see getReachableNodeDefs), yielding every node def only once.\n */\n private *iterateReachableNodeDefs(): Generator<NodeDef<NodeDefType, NodeDefProps>> {\n const { context } = this\n const { survey, includeAnalysis } = context\n\n const reachableNodeDefUuids = new Set<string>()\n const visitedUuids = new Set<string>()\n\n const queue = new Queue<NodeDef<NodeDefType>>()\n\n const actualContextNode = findActualContextNode({ context })\n if (actualContextNode) {\n queue.enqueue(actualContextNode)\n reachableNodeDefUuids.add(actualContextNode.uuid)\n yield actualContextNode\n }\n\n while (!queue.isEmpty()) {\n const entityDefCurrent = queue.dequeue()!\n const entityDefCurrentChildren = getNodeDefChildren({ survey, nodeDef: entityDefCurrent, includeAnalysis })\n for (const childDef of entityDefCurrentChildren) {\n if (!reachableNodeDefUuids.has(childDef.uuid)) {\n reachableNodeDefUuids.add(childDef.uuid)\n yield childDef\n }\n }\n // visit nodes inside single entities\n queue.enqueueItems(entityDefCurrentChildren.filter(NodeDefs.isSingleEntity))\n\n // avoid visiting 2 times the same entity definition when traversing single entities\n if (!visitedUuids.has(entityDefCurrent.uuid)) {\n const entityDefCurrentParent = getNodeDefParent({ survey, nodeDef: entityDefCurrent })\n if (entityDefCurrentParent) {\n queue.enqueue(entityDefCurrentParent)\n }\n if (!reachableNodeDefUuids.has(entityDefCurrent.uuid)) {\n reachableNodeDefUuids.add(entityDefCurrent.uuid)\n yield entityDefCurrent\n }\n visitedUuids.add(entityDefCurrent.uuid)\n }\n }\n }\n}\n"]}
|
|
@@ -257,7 +257,7 @@ export const visitDescendantsAndSelf = recordGetter((params) => {
|
|
|
257
257
|
// stop if visitor returns true
|
|
258
258
|
return;
|
|
259
259
|
}
|
|
260
|
-
const children = getChildren(visitedNode)(record);
|
|
260
|
+
const children = getChildren({ parentNode: visitedNode })(record);
|
|
261
261
|
queue.enqueueItems(children);
|
|
262
262
|
}
|
|
263
263
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordGetters.js","sourceRoot":"","sources":["../../../../src/record/_records/recordGetters.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAc,cAAc,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAgC,KAAK,EAAY,MAAM,YAAY,CAAA;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAwD,QAAQ,EAAe,MAAM,eAAe,CAAA;AAC3G,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEpD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAe,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;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,CAA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'../../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"]}
|
|
1
|
+
{"version":3,"file":"recordGetters.js","sourceRoot":"","sources":["../../../../src/record/_records/recordGetters.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAc,cAAc,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAgC,KAAK,EAAY,MAAM,YAAY,CAAA;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAwD,QAAQ,EAAe,MA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AAY,EAAE,YAAY;IAC1B,QAAQ,EAAE,CAAC,IAAqB,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;CAChD,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,MAAmB,EAAW,EAAE;IACtD,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAChC,OAAO,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAClE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,MAAmB,EAAU,EAAE,wBAAC,MAAM,CAAC,IAAI,mCAAI,mBAAmB,GAAA,CAAA;AAE1F,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAmB,EAAW,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,sBAAsB,CAAA","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<ArenaRecordNode>()\n\n queue.enqueue(node)\n\n while (!queue.isEmpty()) {\n const visitedNode = queue.dequeue()!\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren({ parentNode: 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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordNodesUpdater.js","sourceRoot":"","sources":["../../../../src/record/recordNodesUpdater/recordNodesUpdater.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAInC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,yCAAyC,CAAA;AAC3F,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAA;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAC1E,OAAO,EAAE,oCAAoC,EAAE,MAAM,4CAA4C,CAAA;AACjG,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAA;AACvF,OAAO,EAAE,iCAAiC,EAAE,MAAM,iDAAiD,CAAA;AACnG,OAAO,EAAE,uCAAuC,EAAE,MAAM,+CAA+C,CAAA;AACvG,OAAO,EAAE,gCAAgC,EAAE,MAAM,0CAA0C,CAAA;AAE3F,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAA;AAErF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD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AAC,CAAA,CAAA","sourcesContent":["import { Queue } from '../../utils'\n\nimport { Dictionary } from '../../common'\nimport { ArenaRecordNode } from '../../node'\nimport { NodeDefCountType } from '../../nodeDef'\nimport { Surveys } from '../../survey'\nimport { getNodesByDefUuid } from '../_records/recordGetters'\nimport { updateSelfAndDependentsApplicable } from './recordNodeDependentsApplicableUpdater'\nimport { updateDependentCodeAttributes } from './recordNodeDependentsCodeAttributesUpdater'\nimport { updateDependentsCount } from './recordNodeDependentsCountUpdater'\nimport { updateSelfAndDependentsDefaultValues } from './recordNodeDependentsDefaultValuesUpdater'\nimport { updateSelfAndDependentsEditable } from './recordNodeDependentsEditableUpdater'\nimport { updateDependentEnumeratedEntities } from './recordNodeDependentsEnumeratedEntitiesUpdater'\nimport { updateDependentEnumeratingItemsEntities } from './recordNodeDependentsEnumeratingItemsUpdater'\nimport { updateSelfAndDependentsFileNames } from './recordNodeDependentsFileNamesEvaluator'\nimport { RecordNodeDependentsUpdateParams } from './recordNodeDependentsUpdateParams'\nimport { updateSelfAndDependentsVisible } from './recordNodeDependentsVisibleUpdater'\nimport { NodesUpdateParams } from './recordNodesCreator'\nimport { RecordUpdateResult } from './recordUpdateResult'\n\n/**\n * Nodes can be visited maximum 2 times during the update of the dependent nodes, to avoid loops in the evaluation.\n * The first time the applicability can depend on attributes with default values not applied yet.\n * The second time the applicability expression can be evaluated correctly.\n */\nconst MAX_DEPENDENTS_VISITING_TIMES = 2\n\ntype RecordNodeDependentsUpdater = (params: RecordNodeDependentsUpdateParams) => Promise<RecordUpdateResult>\n\n/**\n * Updaters applied (in this order) to every visited node and to its dependents.\n */\nconst dependentsUpdaters: RecordNodeDependentsUpdater[] = [\n (params) => updateDependentsCount({ ...params, countType: NodeDefCountType.min }),\n (params) => updateDependentsCount({ ...params, countType: NodeDefCountType.max }),\n updateSelfAndDependentsApplicable,\n updateSelfAndDependentsDefaultValues,\n updateSelfAndDependentsEditable,\n updateSelfAndDependentsVisible,\n updateDependentCodeAttributes,\n updateDependentEnumeratedEntities,\n updateDependentEnumeratingItemsEntities,\n updateSelfAndDependentsFileNames,\n]\n\nexport const updateNodesDependents = async (\n params: NodesUpdateParams & { nodes: Dictionary<ArenaRecordNode> }\n): Promise<RecordUpdateResult> => {\n const { survey, record, nodes, sideEffect = false } = params\n const initialNodesToVisit = sideEffect ? nodes : { ...nodes }\n\n // include onUpdate dependents (always included in every record update)\n const onUpdateDependentDefs = Surveys.getOnUpdateDependents({ survey })\n if (onUpdateDependentDefs.length > 0) {\n for (const dependentDef of onUpdateDependentDefs) {\n const dependentNodes = getNodesByDefUuid({ nodeDefUuid: dependentDef.uuid })(record)\n for (const node of dependentNodes) {\n initialNodesToVisit[node.uuid] = node\n }\n }\n }\n\n const updateResult = new RecordUpdateResult({ record, nodes: initialNodesToVisit })\n\n const createNodeUpdateParams = (node: ArenaRecordNode): RecordNodeDependentsUpdateParams => ({\n ...params,\n record: updateResult.record, // updateResult.record changes at every step (when sideEffect=false)\n node,\n })\n\n const nodeUuidsToVisit = new Queue(Object.keys(initialNodesToVisit))\n\n // Avoid loops: visit the same node maximum 2 times (the second time the applicability could have been changed)\n const visitedCountByUuid: Dictionary<number> = {}\n\n while (!nodeUuidsToVisit.isEmpty()) {\n const nodeUuid = nodeUuidsToVisit.dequeue()!\n\n const visitedCount = visitedCountByUuid[nodeUuid] ?? 0\n\n if (visitedCount < MAX_DEPENDENTS_VISITING_TIMES) {\n const nodesUpdatedCurrent: Dictionary<ArenaRecordNode> = {}\n for (const dependentsUpdater of dependentsUpdaters) {\n // updaters must run sequentially: each one works on the record (and node) updated by the previous ones\n const node = updateResult.getNodeByUuid(nodeUuid)\n const dependentsUpdateResult = await dependentsUpdater(createNodeUpdateParams(node)) // NOSONAR\n updateResult.merge(dependentsUpdateResult)\n Object.assign(nodesUpdatedCurrent, dependentsUpdateResult.nodes)\n }\n\n // Mark updated nodes to visit\n nodeUuidsToVisit.enqueueItems(Object.keys(nodesUpdatedCurrent))\n\n // Mark node as visited\n visitedCountByUuid[nodeUuid] = visitedCount + 1\n }\n }\n\n return updateResult\n}\n"]}
|