@openforis/arena-core 2.5.14 → 2.6.0
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/error/index.d.ts +1 -0
- package/dist/error/index.js +3 -1
- package/dist/error/index.js.map +1 -1
- package/dist/error/systemErrorKeys.d.ts +52 -0
- package/dist/error/systemErrorKeys.js +56 -0
- package/dist/error/systemErrorKeys.js.map +1 -0
- package/dist/esm/error/index.js +1 -0
- package/dist/esm/error/index.js.map +1 -1
- package/dist/esm/error/systemErrorKeys.js +53 -0
- package/dist/esm/error/systemErrorKeys.js.map +1 -0
- package/dist/esm/expression/javascript/evaluator.js +2 -2
- package/dist/esm/expression/javascript/evaluator.js.map +1 -1
- package/dist/esm/expression/javascript/global.js +2 -2
- package/dist/esm/expression/javascript/global.js.map +1 -1
- package/dist/esm/expression/javascript/node/array.js +2 -2
- package/dist/esm/expression/javascript/node/array.js.map +1 -1
- package/dist/esm/expression/javascript/node/binary.js +2 -2
- package/dist/esm/expression/javascript/node/binary.js.map +1 -1
- package/dist/esm/expression/javascript/node/call.js +5 -5
- package/dist/esm/expression/javascript/node/call.js.map +1 -1
- package/dist/esm/expression/javascript/node/compound.js +2 -2
- package/dist/esm/expression/javascript/node/compound.js.map +1 -1
- package/dist/esm/expression/javascript/node/conditional.js +2 -2
- package/dist/esm/expression/javascript/node/conditional.js.map +1 -1
- package/dist/esm/expression/javascript/node/identifier.js +2 -2
- package/dist/esm/expression/javascript/node/identifier.js.map +1 -1
- package/dist/esm/expression/javascript/node/this.js +2 -2
- package/dist/esm/expression/javascript/node/this.js.map +1 -1
- package/dist/esm/expression/javascript/node/unary.js +2 -2
- package/dist/esm/expression/javascript/node/unary.js.map +1 -1
- package/dist/esm/geo/points/transform.js +5 -5
- package/dist/esm/geo/points/transform.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/job/JobBase.js +2 -2
- package/dist/esm/job/JobBase.js.map +1 -1
- package/dist/esm/node/nodeValues.js +1 -1
- package/dist/esm/node/nodeValues.js.map +1 -1
- package/dist/esm/nodeDefExpressionEvaluator/functions.js +12 -10
- package/dist/esm/nodeDefExpressionEvaluator/functions.js.map +1 -1
- package/dist/esm/nodeDefExpressionEvaluator/node/identifier.js +2 -2
- package/dist/esm/nodeDefExpressionEvaluator/node/identifier.js.map +1 -1
- package/dist/esm/record/_records/recordCompletion.js +3 -3
- package/dist/esm/record/_records/recordCompletion.js.map +1 -1
- package/dist/esm/record/_records/recordGetters.js +148 -261
- package/dist/esm/record/_records/recordGetters.js.map +1 -1
- package/dist/esm/record/_records/recordPagesValidation.js +5 -5
- package/dist/esm/record/_records/recordPagesValidation.js.map +1 -1
- package/dist/esm/record/_records/recordUtils.js +4 -4
- package/dist/esm/record/_records/recordUtils.js.map +1 -1
- package/dist/esm/record/nodePointers.js +1 -1
- package/dist/esm/record/nodePointers.js.map +1 -1
- package/dist/esm/record/recordCloner.js +1 -1
- package/dist/esm/record/recordCloner.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/functions.js +4 -9
- package/dist/esm/record/recordExpressionEvaluator/functions.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/node/identifier/identifier.js +7 -7
- package/dist/esm/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/node/identifier/nodesFinder.js +2 -2
- package/dist/esm/record/recordExpressionEvaluator/node/identifier/nodesFinder.js.map +1 -1
- package/dist/esm/record/recordExpressionEvaluator/recordExpressionEvaluator.js +1 -1
- package/dist/esm/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
- package/dist/esm/record/recordFixer.js +7 -7
- package/dist/esm/record/recordFixer.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordExpressionValueConverter.js +2 -2
- package/dist/esm/record/recordNodesUpdater/recordExpressionValueConverter.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js +20 -24
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsCountUpdater.js +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsCountUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js +5 -10
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js +3 -3
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js +4 -8
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js +4 -8
- package/dist/esm/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesCreator.js +2 -2
- package/dist/esm/record/recordNodesUpdater/recordNodesCreator.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesDeleter.js +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesDeleter.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js +2 -2
- package/dist/esm/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesUpdater.js +1 -1
- package/dist/esm/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
- package/dist/esm/record/recordPrettyPrinter.js +19 -26
- package/dist/esm/record/recordPrettyPrinter.js.map +1 -1
- package/dist/esm/record/recordUpdater.js +4 -4
- package/dist/esm/record/recordUpdater.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeKeyValidator.js +4 -4
- package/dist/esm/record/recordValidator/attributeKeyValidator.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeUniqueValidator.js +1 -1
- package/dist/esm/record/recordValidator/attributeUniqueValidator.js.map +1 -1
- package/dist/esm/record/recordValidator/attributeValidator.js +8 -16
- package/dist/esm/record/recordValidator/attributeValidator.js.map +1 -1
- package/dist/esm/record/recordValidator/countValidator.js +2 -2
- package/dist/esm/record/recordValidator/countValidator.js.map +1 -1
- package/dist/esm/record/recordValidator/recordValidator.js +2 -5
- package/dist/esm/record/recordValidator/recordValidator.js.map +1 -1
- package/dist/esm/survey/nodeDefsFixer.js +3 -3
- package/dist/esm/survey/nodeDefsFixer.js.map +1 -1
- package/dist/esm/survey/surveys/nodeDefs.js +5 -5
- package/dist/esm/survey/surveys/nodeDefs.js.map +1 -1
- package/dist/esm/tests/builder/recordBuilder/attributeBuilder.js +1 -1
- package/dist/esm/tests/builder/recordBuilder/attributeBuilder.js.map +1 -1
- package/dist/expression/javascript/evaluator.js +1 -1
- package/dist/expression/javascript/evaluator.js.map +1 -1
- package/dist/expression/javascript/global.js +1 -1
- package/dist/expression/javascript/global.js.map +1 -1
- package/dist/expression/javascript/node/array.js +1 -1
- package/dist/expression/javascript/node/array.js.map +1 -1
- package/dist/expression/javascript/node/binary.js +1 -1
- package/dist/expression/javascript/node/binary.js.map +1 -1
- package/dist/expression/javascript/node/call.js +4 -4
- package/dist/expression/javascript/node/call.js.map +1 -1
- package/dist/expression/javascript/node/compound.js +1 -1
- package/dist/expression/javascript/node/compound.js.map +1 -1
- package/dist/expression/javascript/node/conditional.js +1 -1
- package/dist/expression/javascript/node/conditional.js.map +1 -1
- package/dist/expression/javascript/node/identifier.js +1 -1
- package/dist/expression/javascript/node/identifier.js.map +1 -1
- package/dist/expression/javascript/node/this.js +1 -1
- package/dist/expression/javascript/node/this.js.map +1 -1
- package/dist/expression/javascript/node/unary.js +1 -1
- package/dist/expression/javascript/node/unary.js.map +1 -1
- package/dist/geo/points/transform.js +4 -4
- package/dist/geo/points/transform.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/job/JobBase.js +1 -1
- package/dist/job/JobBase.js.map +1 -1
- package/dist/node/nodeValues.js +1 -1
- package/dist/node/nodeValues.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/functions.js +11 -9
- package/dist/nodeDefExpressionEvaluator/functions.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/node/identifier.js +1 -1
- package/dist/nodeDefExpressionEvaluator/node/identifier.js.map +1 -1
- package/dist/record/_records/recordCompletion.js +3 -3
- package/dist/record/_records/recordCompletion.js.map +1 -1
- package/dist/record/_records/recordGetters.d.ts +39 -165
- package/dist/record/_records/recordGetters.js +174 -260
- package/dist/record/_records/recordGetters.js.map +1 -1
- package/dist/record/_records/recordPagesValidation.js +5 -5
- package/dist/record/_records/recordPagesValidation.js.map +1 -1
- package/dist/record/_records/recordUtils.js +4 -4
- package/dist/record/_records/recordUtils.js.map +1 -1
- package/dist/record/nodePointers.js +1 -1
- package/dist/record/nodePointers.js.map +1 -1
- package/dist/record/recordCloner.js +1 -1
- package/dist/record/recordCloner.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/functions.js +4 -9
- package/dist/record/recordExpressionEvaluator/functions.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/node/identifier/identifier.js +6 -6
- package/dist/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/node/identifier/nodesFinder.js +2 -2
- package/dist/record/recordExpressionEvaluator/node/identifier/nodesFinder.js.map +1 -1
- package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.js +1 -1
- package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
- package/dist/record/recordFixer.js +7 -7
- package/dist/record/recordFixer.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordExpressionValueConverter.js +2 -2
- package/dist/record/recordNodesUpdater/recordExpressionValueConverter.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js +20 -24
- package/dist/record/recordNodesUpdater/recordNodeDependentsApplicableUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsCodeAttributesUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsCountUpdater.js +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsCountUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js +5 -10
- package/dist/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js +3 -3
- package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratedEntitiesUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js +4 -8
- package/dist/record/recordNodesUpdater/recordNodeDependentsEnumeratingItemsUpdater.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js +4 -8
- package/dist/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesCreator.js +1 -1
- package/dist/record/recordNodesUpdater/recordNodesCreator.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesDeleter.js +1 -1
- package/dist/record/recordNodesUpdater/recordNodesDeleter.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js +2 -2
- package/dist/record/recordNodesUpdater/recordNodesDependentsUpdaterCommons.js.map +1 -1
- package/dist/record/recordNodesUpdater/recordNodesUpdater.js +1 -1
- package/dist/record/recordNodesUpdater/recordNodesUpdater.js.map +1 -1
- package/dist/record/recordPrettyPrinter.js +19 -26
- package/dist/record/recordPrettyPrinter.js.map +1 -1
- package/dist/record/recordUpdater.js +3 -3
- package/dist/record/recordUpdater.js.map +1 -1
- package/dist/record/recordValidator/attributeKeyValidator.js +4 -4
- package/dist/record/recordValidator/attributeKeyValidator.js.map +1 -1
- package/dist/record/recordValidator/attributeUniqueValidator.js +1 -1
- package/dist/record/recordValidator/attributeUniqueValidator.js.map +1 -1
- package/dist/record/recordValidator/attributeValidator.js +8 -16
- package/dist/record/recordValidator/attributeValidator.js.map +1 -1
- package/dist/record/recordValidator/countValidator.js +2 -2
- package/dist/record/recordValidator/countValidator.js.map +1 -1
- package/dist/record/recordValidator/recordValidator.js +2 -5
- package/dist/record/recordValidator/recordValidator.js.map +1 -1
- package/dist/record/records.d.ts +31 -146
- package/dist/survey/nodeDefsFixer.js +2 -2
- package/dist/survey/nodeDefsFixer.js.map +1 -1
- package/dist/survey/surveys/nodeDefs.js +4 -4
- package/dist/survey/surveys/nodeDefs.js.map +1 -1
- package/dist/tests/builder/recordBuilder/attributeBuilder.js +1 -1
- package/dist/tests/builder/recordBuilder/attributeBuilder.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import proj4 from 'proj4';
|
|
2
|
-
import { SystemError } from '../../error';
|
|
2
|
+
import { SystemError, SystemErrorKeys } from '../../error';
|
|
3
3
|
import { DEFAULT_SRS_INDEX } from '../../srs';
|
|
4
4
|
import { PointFactory } from '../pointFactory';
|
|
5
5
|
import { isFilled } from './isFilled';
|
|
@@ -26,7 +26,7 @@ const getConverter = (wktFrom, wktTo) => {
|
|
|
26
26
|
*/
|
|
27
27
|
export const transformOrThrow = (point, srsCodeTo, srsIndex = DEFAULT_SRS_INDEX) => {
|
|
28
28
|
if (!isFilled(point))
|
|
29
|
-
throw new SystemError(
|
|
29
|
+
throw new SystemError(SystemErrorKeys.geo.pointNotFilled);
|
|
30
30
|
const { srs: srsCodeFrom } = point;
|
|
31
31
|
if (srsCodeFrom === srsCodeTo) {
|
|
32
32
|
// projection is not needed
|
|
@@ -34,17 +34,17 @@ export const transformOrThrow = (point, srsCodeTo, srsIndex = DEFAULT_SRS_INDEX)
|
|
|
34
34
|
}
|
|
35
35
|
const srsFrom = getSrs({ code: srsCodeFrom, srsIndex });
|
|
36
36
|
if (!srsFrom)
|
|
37
|
-
throw new SystemError(
|
|
37
|
+
throw new SystemError(SystemErrorKeys.geo.srsNotFound, { code: srsCodeFrom });
|
|
38
38
|
const srsTo = getSrs({ code: srsCodeTo, srsIndex });
|
|
39
39
|
if (!srsTo)
|
|
40
|
-
throw new SystemError(
|
|
40
|
+
throw new SystemError(SystemErrorKeys.geo.srsNotFound, { code: srsCodeTo });
|
|
41
41
|
try {
|
|
42
42
|
const { x, y } = point;
|
|
43
43
|
const [long, lat] = getConverter(srsFrom.wkt, srsTo.wkt).forward([Number(x), Number(y)]);
|
|
44
44
|
return PointFactory.createInstance(Object.assign(Object.assign({}, point), { srs: srsCodeTo, x: long, y: lat }));
|
|
45
45
|
}
|
|
46
46
|
catch (error) {
|
|
47
|
-
throw new SystemError(
|
|
47
|
+
throw new SystemError(SystemErrorKeys.geo.transformFailed, { srsFrom: srsCodeFrom, srsTo: srsCodeTo }, { cause: error });
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
/**
|
|
@@ -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,WAAW,EAAE,MAAM,aAAa,CAAA;
|
|
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,EA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A","sourcesContent":["import proj4, { type Converter } from 'proj4'\n\nimport { SystemError, SystemErrorKeys } 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(SystemErrorKeys.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(SystemErrorKeys.geo.srsNotFound, { code: srsCodeFrom })\n\n const srsTo = getSrs({ code: srsCodeTo, srsIndex })\n if (!srsTo) throw new SystemError(SystemErrorKeys.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(\n SystemErrorKeys.geo.transformFailed,\n { srsFrom: srsCodeFrom, srsTo: srsCodeTo },\n { cause: error }\n )\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"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export { ChainFactory, ChainStatusExec, ChainNodeDefFactory } from './chain';
|
|
|
5
5
|
export { TraverseMethod } from './common';
|
|
6
6
|
export { FlatDataExportDefaultOptions, FlatDataExportOption, FlatDataFiles, FlatDataExportModel, FlatDataExportColumnDataType, ArenaExportInfoFactory, UniqueFileNamesGenerator, } from './dataExport';
|
|
7
7
|
export { DataQueryMode, DataQuerySummaries } from './dataQuery';
|
|
8
|
-
export { SystemError } from './error';
|
|
8
|
+
export { SystemError, SystemErrorKeys } from './error';
|
|
9
9
|
export { ExpressionNodeType, ExpressionNodeEvaluator, ExpressionVariable, JavascriptExpressionEvaluator, JavascriptExpressionParser, } from './expression';
|
|
10
10
|
export { ExtraPropDataType, ExtraPropsDataGenerator } from './extraProp';
|
|
11
11
|
export { PointFactory, Points } from './geo';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAwBzG,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CA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AAkB,EAClB,OAAO,EACP,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,GACb,MAAM,UAAU,CAAA;AAkBjB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAenH,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACnF,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAEjF,OAAO,EACL,MAAM,EACN,WAAW,EACX,KAAK,EACL,SAAS,EACT,aAAa,EACb,OAAO,EACP,OAAO,EACP,QAAQ,EACR,KAAK,EACL,cAAc,EACd,OAAO,EACP,UAAU,EACV,KAAK,EACL,QAAQ,GACT,MAAM,SAAS,CAAA;AAIhB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,kBAAkB,GACnB,MAAM,cAAc,CAAA","sourcesContent":["export type { AppInfo } from './app'\n\nexport { Authorizer, AuthGroupName, UserStatus, Permission, UserTitle, UserFactory, Users } from './auth'\nexport type {\n AuthGroup,\n User,\n UserAuthGroup,\n UserAuthGroupProps,\n AuthToken,\n UserAuthTokenPayload,\n UserAuthTokenService,\n UserPrefs,\n UserPrefSurveys,\n UserProps,\n UserAuthRefreshToken,\n UserAuthRefreshTokenProps,\n UserAuthRefreshTokenPayload,\n UserService,\n UserTokenPayload,\n DownloadAuthTokenPayload,\n UserGroup,\n UserGroupProps,\n UserGroupQualifier,\n UserInvitation,\n} from './auth'\n\nexport { CategoryFactory, CategoryImportColumnType, CategoryItemFactory, CategoryLevelFactory } from './category'\nexport type {\n CategoryItemProps,\n Category,\n CategoryItem,\n CategoryLevel,\n CategoryLevelProps,\n CategoryImportSummary,\n CategoryImportSummaryColumn,\n CategoryItemService,\n CategoryLevelService,\n CategoryProps,\n CategoryService,\n} from './category'\n\nexport { Categories, CategoryItems } from './category'\n\nexport { ChainFactory, ChainStatusExec, ChainNodeDefFactory } from './chain'\nexport type {\n Chain,\n ChainProps,\n ChainService,\n ChainNodeDef,\n ChainNodeDefProps,\n ChainNodeDefService,\n ChainNodeDefAggregate,\n ChainNodeDefAggregateProps,\n} from './chain'\n\nexport { TraverseMethod } from './common'\nexport type { ArenaObject, ArenaService, Dictionary, Factory, I18n } from './common'\n\nexport type { FlatDataExportOptions, ArenaExportInfoFactoryParams, ArenaExportInfo } from './dataExport'\nexport {\n FlatDataExportDefaultOptions,\n FlatDataExportOption,\n FlatDataFiles,\n FlatDataExportModel,\n FlatDataExportColumnDataType,\n ArenaExportInfoFactory,\n UniqueFileNamesGenerator,\n} from './dataExport'\n\nexport { DataQueryMode, DataQuerySummaries } from './dataQuery'\nexport type { DataQuery, DataQuerySummary, DataQuerySummaryProps } from './dataQuery'\n\nexport { SystemError, SystemErrorKeys } from './error'\n\nexport {\n ExpressionNodeType,\n ExpressionNodeEvaluator,\n ExpressionVariable,\n JavascriptExpressionEvaluator,\n JavascriptExpressionParser,\n} from './expression'\nexport type {\n ArrayExpression,\n BinaryExpression,\n CallExpression,\n CompoundExpression,\n ConditionalExpression,\n ExpressionContext,\n ExpressionEvaluator,\n ExpressionFunction,\n ExpressionFunctions,\n AnyExpressionNode,\n ExpressionNode,\n ExpressionNodeEvaluatorConstructor,\n MemberExpression,\n IdentifierExpression,\n LiteralExpression,\n SequenceExpression,\n ThisExpression,\n UnaryExpression,\n} from './expression'\n\nexport { ExtraPropDataType, ExtraPropsDataGenerator } from './extraProp'\nexport type { ExtraPropDef, ExtraPropDefs } from './extraProp'\n\nexport { PointFactory, Points } from './geo'\nexport type { Point } from './geo'\n\nexport { JobBase, JobEventType, JobStatus } from './job'\nexport type { Job, JobContext, JobEvent, JobSerialized, JobTxClient } from './job'\n\nexport { LanguageCode, Languages, LanguagesISO639part2 } from './language'\nexport type { Labels } from './language'\n\nexport type { Logger } from './logger'\n\nexport type { Message } from './message'\nexport { MessageNotificationType, MessagePropsKey, MessageStatus, MessageTargetUserType, Messages } from './message'\n\nexport { NodeFactory, NodeKeys, NodeMetaKeys, Nodes, NodeValueFormatter, NodeValues } from './node'\nexport type {\n ArenaRecordNode,\n Node,\n NodeMeta,\n NodePointer,\n NodeRefData,\n NodeService,\n NodesMap,\n NodeValueCode,\n NodeValueCoordinate,\n NodeValueFile,\n NodeValueTaxon,\n} from './node'\n\nexport {\n NodeDefCountType,\n NodeDefType,\n NodeDefFactory,\n NodeDefs,\n NodeDefEntityRenderType,\n NodeDefFileType,\n NodeDefTextInputType,\n NodeDefTextRenderType,\n FormHeaderColor,\n} from './nodeDef'\n\nexport { NodeDefExpressionEvaluator, NodeDefExpressionValidator } from './nodeDefExpressionEvaluator'\nexport type { CategoryItemProvider, TaxonProvider } from './nodeDefExpressionEvaluator'\n\nexport type {\n NodeDef,\n NodeDefLayout,\n NodeDefMeta,\n NodeDefProps,\n NodeDefPropsWithLayout,\n NodeDefBoolean,\n NodeDefBooleanProps,\n NodeDefCode,\n NodeDefCodeLayout,\n NodeDefCodeProps,\n NodeDefCoordinate,\n NodeDefCoordinateProps,\n NodeDefDate,\n NodeDefDecimal,\n NodeDefDecimalProps,\n NodeDefEntity,\n NodeDefEntityChildPosition,\n NodeDefEntityLayout,\n NodeDefEntityProps,\n NodeDefPrintOrientation,\n NodeDefFile,\n NodeDefFileProps,\n NodeDefFormHeader,\n NodeDefFormHeaderProps,\n NodeDefInteger,\n NodeDefPropsAdvanced,\n NodeDefTaxon,\n NodeDefTaxonProps,\n NodeDefText,\n NodeDefTextProps,\n NodeDefTextLayout,\n NodeDefTime,\n NodeDefTimeProps,\n NodeDefExpression,\n NodeDefMap,\n NodeDefService,\n NodeDefValidations,\n} from './nodeDef'\n\nexport {\n NodePointers,\n RecordCloner,\n RecordFactory,\n RecordFixer,\n Records,\n RECORD_STEP_DEFAULT,\n RecordExpressionEvaluator,\n RecordNodesUpdater,\n RecordPrettyPrinter,\n RecordUpdater,\n RecordUpdateResult,\n RecordValidator,\n RecordValidations,\n} from './record'\nexport type {\n AttributeValidatorParams,\n AttributesValidatorParams,\n NodeCreateParams,\n NodesUpdateParams,\n ArenaRecord,\n Record,\n RecordExpressionContext,\n RecordExpressionEvaluationContext,\n RecordService,\n RecordUpdateOptions,\n RecordValidatorParams,\n SortedAttributesValidatorParams,\n} from './record'\n\nexport { ServiceRegistry, ServiceType } from './registry'\nexport type { ServiceTypeMap } from './registry'\n\nexport { DEFAULT_SRS, DEFAULT_SRS_INDEX, SRSFactory } from './srs'\nexport type { SRS, SRSIndex } from './srs'\n\nexport {\n NodeDefsFixer,\n SurveyDocImages,\n SurveyDocImageFactory,\n SurveyDocPlace,\n SurveyDependencyType,\n SurveyFactory,\n SurveyFileFactory,\n SurveyFileType,\n SurveyRefDataFactory,\n SurveySecurityProp,\n Surveys,\n surveyDocImagePropKeys,\n surveySecurityDefaults,\n defaultCycle,\n} from './survey'\nexport type {\n Survey,\n SurveyCycle,\n SurveyDependency,\n SurveyDependencyGraph,\n SurveyDocImage,\n SurveyDocImageFactoryParams,\n SurveyDocImageProps,\n SurveyFile,\n SurveyFileFactoryParams,\n SurveyFileProps,\n SurveyProps,\n SurveyRefData,\n SurveySecurity,\n SurveyService,\n} from './survey'\n\nexport { Taxa, Taxonomies, TaxonomyFactory, TaxonFactory, TaxonGenerator, VernacularNameFactory } from './taxonomy'\nexport type {\n VernacularNameParams,\n TaxonomyFactoryParams,\n TaxonFactoryParams,\n Taxonomy,\n TaxonomyService,\n VernacularNameProps,\n VernacularName,\n TaxonProps,\n Taxon,\n TaxonomyProps,\n TaxonService,\n} from './taxonomy'\n\nexport { SurveyBuilder, SurveyObjectBuilders } from './tests/builder/surveyBuilder'\nexport { RecordBuilder, RecordNodeBuilders } from './tests/builder/recordBuilder'\n\nexport {\n Arrays,\n DateFormats,\n Dates,\n FileNames,\n FileProcessor,\n Numbers,\n Objects,\n Promises,\n Queue,\n RetryProcessor,\n Strings,\n UnitOfTime,\n UUIDs,\n Versions,\n} from './utils'\n\nexport type { FileProcessorConstructorArgs, MutationOptions, ParsedVersion } from './utils'\n\nexport {\n FieldValidators,\n ValidationFactory,\n ValidationResultFactory,\n ValidationResults,\n Validations,\n ValidationSeverity,\n Validator,\n ValidatorErrorKeys,\n} from './validation'\nexport type {\n DissocFieldValidationOptions,\n FieldValidator,\n Validation,\n ValidationFields,\n ValidationResult,\n ValidationCounts,\n} from './validation'\n"]}
|
package/dist/esm/job/JobBase.js
CHANGED
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { SystemError } from '../error';
|
|
10
|
+
import { SystemError, SystemErrorKeys } from '../error';
|
|
11
11
|
import { UUIDs } from '../utils';
|
|
12
12
|
import { JobEventType } from './jobEvent';
|
|
13
13
|
import { JobStatus } from './status';
|
|
@@ -229,7 +229,7 @@ export class JobBase {
|
|
|
229
229
|
this.context.tx = undefined;
|
|
230
230
|
}
|
|
231
231
|
if (this.isCancelRequestedOrNotRunning()) {
|
|
232
|
-
this.throwError(
|
|
232
|
+
this.throwError(SystemErrorKeys.job.canceledOrErrorsFound);
|
|
233
233
|
}
|
|
234
234
|
});
|
|
235
235
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JobBase.js","sourceRoot":"","sources":["../../../src/job/JobBase.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAGtC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAIhC,OAAO,EAAY,YAAY,EAAE,MAAM,YAAY,CAAA;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAcpC,MAAM,qCAAqC,GAAG,IAAI,CAAA;AAElD;;;;;;;;;;;;;;;;;;;;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B,CAAC,KAAK,CAAC,CAAA;QAC9B,CAAC;IACH,CAAC;IAEO,gBAAgB,CAAC,KAAU;;QACjC,IAAI,CAAC,QAAQ,CAAC,gCAAgC,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,mCAAI,KAAK,EAAE,CAAC,CAAA;IACxE,CAAC;CACF;AAvjBiB,mBAAW,GAAG;IAC5B,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;CACb,AAJ0B,CAI1B","sourcesContent":["import { User } from '../auth'\nimport { Dictionary } from '../common'\nimport { SystemError } from '../error'\nimport { Logger } from '../logger'\nimport { Survey } from '../survey'\nimport { UUIDs } from '../utils'\n\nimport { Job } from './job'\nimport { JobContext } from './jobContext'\nimport { JobEvent, JobEventType } from './jobEvent'\nimport { JobSerialized } from './jobSerialized'\nimport { JobStatus } from './status'\n\nexport interface JobConstructor {\n new <C extends JobContext, R>(context: C, innerJobs?: JobBase<any>[]): JobBase<C, R>\n readonly prototype: JobBase<any, any>\n}\n\n/**\n * Client able to open a transaction (e.g. a pg-promise database): the job runs inside `client.tx(callback)`.\n */\nexport interface JobTxClient {\n tx(callback: (tx: any) => Promise<void>): Promise<unknown>\n}\n\nconst PROGRESS_NOTIFICATION_THROTTLE_MILLIS = 1000\n\n/**\n * Asynchronous task handler.\n *\n * Status workflow:\n * - pending\n * - running\n * - (end)\n * -- succeeded\n * -- failed\n * -- canceled\n *\n * Methods that can be overwritten by subclasses:\n * - shouldExecute (in tx)\n * - onStart (in tx)\n * - execute (in tx)\n * - beforeSuccess (in tx)\n * - generateResult (in tx)\n * - beforeEnd (in tx)\n * - onEnd (out of tx)\n * - getErrorInfo\n */\nexport abstract class JobBase<C extends JobContext, R = undefined> implements Job<R> {\n static readonly keysContext = {\n surveyId: 'surveyId',\n survey: 'survey',\n user: 'user',\n }\n\n readonly uuid: string\n readonly type: string\n status: JobStatus = JobStatus.pending\n startTime?: Date\n endTime?: Date\n total: number\n result: R | undefined = undefined\n errors: Record<string, any> = {}\n canceledByAdmin?: boolean\n\n protected logger: Logger\n protected context: C\n protected innerJobs: JobBase<C, any>[]\n protected currentInnerJobIndex = -1\n\n private _processed = 0\n private eventListener: ((event: JobEvent) => unknown) | undefined = undefined\n private progressThrottleTimeoutId: ReturnType<typeof setTimeout> | undefined = undefined\n private progressThrottleLastRunTime = 0\n private _stopOnInnerJobFailure = true\n // set as soon as cancel() is called (the canceled status is set only after beforeEnd has run)\n private cancelRequested = false\n private beforeEndCalled = false\n // inner job events are handled in sequence; executeJobs waits for them before going on\n private innerJobEventsQueue: Promise<void> = Promise.resolve()\n\n public constructor(context: C, innerJobs: JobBase<C, any>[] = []) {\n this.context = { ...context }\n this.innerJobs = innerJobs\n\n this.uuid = UUIDs.v4()\n this.type = this.context.type ?? this.constructor.name\n this.total = innerJobs.length > 0 ? innerJobs.length : 1\n\n // Created last, so that createLogger() overrides can safely build the logger name out of\n // the job identity (e.g. arena's `Job <ClassName> (<uuid>)` log correlation id).\n this.logger = this.createLogger()\n }\n\n get processed(): number {\n return this._processed\n }\n\n set processed(value: number) {\n this._processed = value\n this.notifyProgress()\n }\n\n get stopOnInnerJobFailure(): boolean {\n return this._stopOnInnerJobFailure\n }\n\n set stopOnInnerJobFailure(value: boolean) {\n this._stopOnInnerJobFailure = value\n }\n\n protected get surveyId(): number | null {\n return this.context.surveyId ?? null\n }\n\n protected get user(): User {\n return this.context.user\n }\n\n protected get userUuid(): string | undefined {\n return this.user?.uuid\n }\n\n protected get contextSurvey(): Survey | undefined {\n return this.context.survey\n }\n\n /**\n * Returns the value of the specified context prop, or the default value (null if not specified) when not set.\n */\n protected getContextProp<K extends keyof C & string>(prop: K, defaultValue?: C[K] | null): C[K] | null\n /** Context prop not declared in the context type: the value is typed by the caller. */\n protected getContextProp<T = any, P extends string = string>(\n prop: P extends keyof C ? never : P,\n defaultValue?: T | null\n ): T | null\n protected getContextProp(prop: string, defaultValue: unknown = null): unknown {\n const value = (this.context as Record<string, unknown>)[prop]\n return value ?? defaultValue\n }\n\n protected setContext(context: Partial<C>): void {\n Object.assign(this.context, context)\n }\n\n protected deleteContextProps(...propNames: string[]): void {\n propNames.forEach((propName) => {\n delete (this.context as any)[propName]\n })\n }\n\n /**\n * Registers the listener notified of job events (status changes and progress).\n * Only one listener can be registered at a time; registering a new one replaces the previous one.\n * Errors thrown (or rejections returned) by the listener are logged and do not affect the job execution.\n */\n onEvent(listener: (event: JobEvent) => unknown): this {\n this.eventListener = listener\n return this\n }\n\n isPending(): boolean {\n return this.status === JobStatus.pending\n }\n\n isRunning(): boolean {\n return this.status === JobStatus.running\n }\n\n isSucceeded(): boolean {\n return this.status === JobStatus.succeeded\n }\n\n isFailed(): boolean {\n return this.status === JobStatus.failed\n }\n\n isCanceled(): boolean {\n return this.status === JobStatus.canceled\n }\n\n isEnded(): boolean {\n return [JobStatus.succeeded, JobStatus.failed, JobStatus.canceled].includes(this.status)\n }\n\n hasErrors(): boolean {\n return Object.keys(this.errors).length > 0\n }\n\n protected getCurrentInnerJob(): JobBase<C, any> | undefined {\n return this.innerJobs[this.currentInnerJobIndex]\n }\n\n protected combineInnerJobsResults(): Record<string, any> {\n const results: Record<string, any> = {}\n this.innerJobs.forEach((innerJob) => Object.assign(results, innerJob.result ?? {}))\n return results\n }\n\n protected combineInnerJobsErrors(): Record<string, any> {\n const errors: Record<string, any> = {}\n this.innerJobs.forEach((innerJob) => Object.assign(errors, innerJob.errors ?? {}))\n return errors\n }\n\n async cancel(options: { canceledByAdmin?: boolean } = {}): Promise<void> {\n const { canceledByAdmin = false } = options\n if (this.isEnded()) return\n\n this.cancelRequested = true\n\n const currentInnerJob = this.getCurrentInnerJob()\n if (currentInnerJob?.isRunning()) {\n // the parent job status will be set to canceled when handling the canceled event of the inner job\n await currentInnerJob.cancel({ canceledByAdmin })\n return\n }\n // no inner job running (job without inner jobs, or between two inner jobs)\n this.canceledByAdmin = canceledByAdmin\n // release the resources (temp files/directories, streams) allocated before the cancellation\n await this.runBeforeEnd()\n await this.setStatus(JobStatus.canceled)\n }\n\n private isCancelRequestedOrNotRunning(): boolean {\n return this.cancelRequested || !this.isRunning()\n }\n\n /**\n * Runs beforeEnd only once (it can be called by cancel() and when the job execution ends).\n */\n private async runBeforeEnd(): Promise<void> {\n if (this.beforeEndCalled) return\n this.beforeEndCalled = true\n await this.beforeEnd()\n }\n\n async start(client: JobTxClient | null = null): Promise<void> {\n this.logDebug('start')\n\n try {\n if (client) {\n await client.tx(async (tx: any) => {\n this.context.tx = tx\n await this.executeInTransaction()\n })\n } else {\n await this.executeInTransaction()\n }\n if (!this.isCancelRequestedOrNotRunning()) {\n await this.setStatus(JobStatus.succeeded)\n }\n } catch (error: any) {\n // a job can fail while still pending (e.g. the transaction cannot be opened, or onStart fails)\n if (!this.cancelRequested && !this.isFailed() && !this.isCanceled()) {\n this.logError(error.stack ?? error)\n const { key, params } = this.getErrorInfo(error)\n this.addError({ error: { valid: false, errors: [{ key, params }] } })\n await this.setStatus(JobStatus.failed)\n }\n } finally {\n this.context.tx = undefined\n }\n }\n\n private async executeInTransaction(): Promise<void> {\n try {\n await this.onStart()\n\n const shouldExecute = await this.shouldExecute()\n if (shouldExecute) {\n if (this.innerJobs.length > 0) {\n await this.executeJobs()\n } else {\n await this.execute()\n }\n if (!this.isCancelRequestedOrNotRunning()) {\n await this.beforeSuccess()\n }\n }\n } finally {\n // runs only if not already run by cancel()\n await this.runBeforeEnd()\n this.context.tx = undefined\n }\n\n if (this.isCancelRequestedOrNotRunning()) {\n this.throwError('jobCanceledOrErrorsFound')\n }\n }\n\n /**\n * Generates a plain JSON-serializable representation of the job, including its inner jobs.\n */\n toJSON(): JobSerialized<R> {\n const { errors, processed, result, status, total, type, userUuid, uuid } = this\n\n return {\n uuid,\n type,\n userUuid,\n surveyId: this.surveyId,\n innerJobs: this.innerJobs.map((job) => job.toJSON()),\n currentInnerJobIndex: this.currentInnerJobIndex,\n\n status,\n pending: this.isPending(),\n running: this.isRunning(),\n succeeded: this.isSucceeded(),\n canceled: this.isCanceled(),\n failed: this.isFailed(),\n ended: this.isEnded(),\n\n total,\n processed,\n progressPercent: this.calculateProgressPercent(),\n elapsedMillis: this.calculateElapsedMillis(),\n\n errors: this.isFailed() ? errors : undefined,\n result: this.isSucceeded() ? result : undefined,\n }\n }\n\n private async executeJobs(): Promise<void> {\n this.logDebug(`- ${this.total} inner jobs found`)\n\n for (let i = 0; i < this.innerJobs.length; i++) {\n this.logDebug(`- executing inner job ${i + 1}`)\n this.currentInnerJobIndex = i\n const currentInnerJob = this.innerJobs[i]\n if (currentInnerJob.context) {\n Object.assign(this.context, currentInnerJob.context)\n }\n currentInnerJob.context = this.context\n currentInnerJob.onEvent((event) => {\n // handle the inner job events in sequence; errors are logged (they would be unhandled rejections otherwise)\n this.innerJobEventsQueue = this.innerJobEventsQueue\n .then(() => this.onInnerJobEvent(event))\n .catch((error) => this.logError(error?.stack ?? error))\n })\n\n // The inner job shares this very context object, and its own start()/executeInTransaction()\n // clear `context.tx` when they terminate: without saving and restoring it here, the first\n // inner job would wipe the parent's transaction handle, leaving every following inner job\n // (and the parent's own beforeSuccess()/beforeEnd()) running outside of the transaction.\n // start() never throws (it swallows/records errors internally), so a plain restore is enough.\n const parentTx = this.context.tx\n await currentInnerJob.start(parentTx)\n this.context.tx = parentTx\n // the inner job events (e.g. canceled, failed) update the status of this job\n await this.innerJobEventsQueue\n\n if (this.cancelRequested || this.isCanceled() || currentInnerJob.isCanceled()) {\n break\n }\n if (currentInnerJob.isSucceeded()) {\n this.incrementProcessedItems()\n } else if (this.stopOnInnerJobFailure) {\n break\n }\n }\n\n this.logDebug(`- ${this.processed} inner jobs processed successfully`)\n }\n\n /**\n * Runs the job's own work when it has no inner jobs. Default implementation is a no-op, so\n * subclasses that only supply inner jobs (and never override this) don't need to. It also means\n * a subclass can safely call `super.execute()` defensively without knowing whether any ancestor\n * overrides it - if this were `abstract` instead, TypeScript would compile away any runtime\n * property for it entirely, so `super.execute()` would throw the moment no ancestor overrides it\n * (confirmed in production: a subclass whose immediate parent didn't override `execute()` crashed\n * with \"(intermediate value).execute is not a function\" the instant it called `super.execute()`).\n */\n protected async execute(): Promise<void> {\n // to be extended by subclasses\n }\n\n /**\n * Determines whether the job should actually run.\n * When it returns false, \"execute\" (or the inner jobs) will be skipped, but the job will still succeed.\n */\n protected shouldExecute(): Promise<boolean> {\n return Promise.resolve(true)\n }\n\n protected incrementProcessedItems(incrementBy = 1): void {\n this.processed += incrementBy\n }\n\n protected async setStatus(status: JobStatus): Promise<void> {\n this.logDebug(`set status: ${status}`)\n this.status = status\n\n const event: JobEvent = { type: JobEventType.statusChange, status, total: this.total, processed: this.processed }\n if (status === JobStatus.failed) {\n event.errors = this.errors\n }\n\n if (this.isEnded()) {\n this.logDebug('onEnd...')\n await this.onEnd()\n this.logDebug(`onEnd run. Job completed in ${this.elapsedTimePrettyFormat}`)\n }\n\n this.notifyEvent(event)\n }\n\n /**\n * Inner job event handler.\n */\n protected async onInnerJobEvent(event: JobEvent): Promise<void> {\n const { status } = event\n if (status === JobStatus.canceled) {\n this.canceledByAdmin = this.getCurrentInnerJob()?.canceledByAdmin ?? false\n return this.setStatus(status)\n }\n if (status === JobStatus.failed) {\n // report the errors of the failed inner job in the failed event (and in the errors) of this job\n Object.assign(this.errors, this.getCurrentInnerJob()?.errors ?? {})\n return this.setStatus(status)\n }\n if (status === JobStatus.running) {\n this.notifyEvent({\n type: JobEventType.progress,\n status: this.status,\n total: this.total,\n processed: this.processed,\n })\n return\n }\n this.logDebug(`Unknown inner job status: ${status}`)\n }\n\n /**\n * Called when the job just has been started.\n */\n protected async onStart(): Promise<void> {\n this.startTime = new Date()\n await this.setStatus(JobStatus.running)\n }\n\n /**\n * Called before beforeEnd only if the status will change to 'success'.\n * Default implementation stores the value returned by generateResult() via setResult().\n * It runs INSIDE the current db transaction.\n */\n protected async beforeSuccess(): Promise<void> {\n this.setResult(await this.generateResult())\n }\n\n /**\n * Computes the value beforeSuccess() will store as this job's result.\n * Default implementation returns whatever is already in `this.result`\n * (e.g. accumulated via earlier setResult() calls during execute()).\n */\n protected generateResult(): Promise<R | undefined> {\n return Promise.resolve(this.result)\n }\n\n /**\n * Updates this job's result. When both the current and incoming values are plain objects,\n * they are merged (Object.assign); otherwise the incoming value replaces the current one.\n * This keeps it safe for subclasses whose result is a primitive (e.g. a plain number) as\n * well as ones that build an object result incrementally across multiple setResult() calls.\n */\n protected setResult(result: R | undefined): void {\n if (result && typeof result === 'object' && this.result && typeof this.result === 'object') {\n Object.assign(this.result, result)\n } else {\n this.result = result\n }\n }\n\n /**\n * Called before onEnd. Useful for flushing resources used by the job before it terminates completely.\n * It runs INSIDE the current db transaction.\n */\n protected beforeEnd(): Promise<void> {\n this.logDebug('Cleanup')\n return Promise.resolve()\n }\n\n /**\n * Called when the job status changes to success, failed or canceled\n * (it runs OUTSIDE of the current db transaction)\n */\n protected onEnd(): Promise<void> {\n this.endTime = new Date()\n this.cancelNotifyProgress()\n return Promise.resolve()\n }\n\n protected addError(error: any, errorKey?: string): void {\n const key = errorKey ?? String(this.processed + 1)\n this.errors[key] = error\n }\n\n protected throwError(errorKey: string, params?: Dictionary<any>): void {\n // SystemError: getErrorInfo will report the translatable key instead of a generic error\n throw new SystemError(errorKey, params)\n }\n\n protected getErrorInfo(error: any): { key: string; params: Record<string, any> } {\n if (error instanceof SystemError) {\n return { key: `appErrors:${error.key}`, params: error.params }\n }\n return { key: 'appErrors:generic', params: { text: error.toString() } }\n }\n\n protected abstract createLogger(): Logger\n\n protected logDebug(...msgs: any[]): void {\n this.logger.debug(...msgs)\n }\n\n protected logInfo(...msgs: any[]): void {\n this.logger.info(...msgs)\n }\n\n protected logWarn(...msgs: any[]): void {\n this.logger.warn(...msgs)\n }\n\n protected logError(...msgs: any[]): void {\n this.logger.error(...msgs)\n }\n\n private get elapsedTimePrettyFormat(): string {\n const elapsedTime = this.calculateElapsedMillis()\n const elapsedMins = Math.floor(elapsedTime / 1000 / 60)\n const elapsedSeconds = String(Math.floor(elapsedTime / 1000) % 60).padStart(2, '0')\n const elapsedMillis = String(elapsedTime % 1000).padStart(3, '0')\n return `${elapsedMins}:${elapsedSeconds}.${elapsedMillis}`\n }\n\n private calculatePartialProgress(): number {\n if (this.isSucceeded()) return 100\n if (this.total > 0) return Math.floor((100 * this.processed) / this.total)\n return 0\n }\n\n private calculateProgressPercent(): number {\n const partialProgress = this.calculatePartialProgress()\n const currentInnerJob = this.getCurrentInnerJob()\n if (\n !currentInnerJob ||\n this.currentInnerJobIndex < 0 ||\n partialProgress === 100 ||\n this.processed > this.currentInnerJobIndex\n ) {\n return partialProgress\n }\n return partialProgress + Math.floor(currentInnerJob.calculateProgressPercent() / this.total)\n }\n\n private calculateElapsedMillis(): number {\n if (!this.startTime) return 0\n return (this.endTime ?? new Date()).getTime() - this.startTime.getTime()\n }\n\n /**\n * Notifies a progress event to the registered listener, throttled so that fast-changing\n * progress does not flood consumers (e.g. web socket clients).\n */\n private notifyProgress(): void {\n const run = (): void => {\n this.progressThrottleTimeoutId = undefined\n this.progressThrottleLastRunTime = Date.now()\n this.notifyEvent({\n type: JobEventType.progress,\n status: this.status,\n total: this.total,\n processed: this.processed,\n })\n }\n\n if (this.progressThrottleTimeoutId) return\n\n const elapsed = Date.now() - this.progressThrottleLastRunTime\n if (!this.progressThrottleLastRunTime || elapsed >= PROGRESS_NOTIFICATION_THROTTLE_MILLIS) {\n run()\n } else {\n this.progressThrottleTimeoutId = setTimeout(run, PROGRESS_NOTIFICATION_THROTTLE_MILLIS - elapsed)\n }\n }\n\n /**\n * Cancels any pending throttled progress notification and resets the throttle state.\n */\n private cancelNotifyProgress(): void {\n if (this.progressThrottleTimeoutId) {\n clearTimeout(this.progressThrottleTimeoutId)\n this.progressThrottleTimeoutId = undefined\n }\n this.progressThrottleLastRunTime = 0\n }\n\n /**\n * Notifies the event to the registered listener.\n * Listener errors are only logged: they would otherwise fail the job or, when thrown inside the progress\n * throttle timeout, crash the process.\n */\n private notifyEvent(event: JobEvent): void {\n const listener = this.eventListener\n if (!listener) return\n try {\n Promise.resolve(listener(event)).catch((error) => this.logListenerError(error))\n } catch (error) {\n this.logListenerError(error)\n }\n }\n\n private logListenerError(error: any): void {\n this.logError(`error in job event listener: ${error?.stack ?? error}`)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"JobBase.js","sourceRoot":"","sources":["../../../src/job/JobBase.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAGvD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAIhC,OAAO,EAAY,YAAY,EAAE,MAAM,YAAY,CAAA;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAcpC,MAAM,qCAAqC,GAAG,IAAI,CAAA;AAElD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAgB,OAAO;IAiC3B,YAAmB,OAAU,EAAE,SAAS,GAAsB,EAAE;;QAxBhE,WAAM,GAAc,SAAS,CAAC,OAAO,CAAA;QAIrC,WAAM,GAAkB,SAAS,CAAA;QACjC,WAAM,GAAwB,EAAE,CAAA;QAMtB,yBAAoB,GAAG,CAAC,CAAC,CAAA;QAE3B,eAAU,GAAG,CAAC,CAAA;QACd,kBAAa,GAA+C,SAAS,CAAA;QACrE,8BAAyB,GAA8C,SAAS,CAAA;QAChF,gCAA2B,GAAG,CAAC,CAAA;QAC/B,2BAAsB,GAAG,IAAI,CAAA;QACrC,8FAA8F;QACtF,oBAAe,GAAG,KAAK,CAAA;QACvB,oBAAe,GAAG,KAAK,CAAA;QAC/B,uFAAuF;QAC/E,wBAAmB,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAA;QAG5D,IAAI,CAAC,OAAO,qBAAQ,OAAO,CAAE,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAE1B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC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BAAoB;QAC1B,IAAI,IAAI,CAAC,yBAAyB,EAAE,CAAC;YACnC,YAAY,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAA;YAC5C,IAAI,CAAC,yBAAyB,GAAG,SAAS,CAAA;QAC5C,CAAC;QACD,IAAI,CAAC,2BAA2B,GAAG,CAAC,CAAA;IACtC,CAAC;IAED;;;;OAIG;IACK,WAAW,CAAC,KAAe;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAA;QACnC,IAAI,CAAC,QAAQ;YAAE,OAAM;QACrB,IAAI,CAAC;YACH,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAA;QACjF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;QAC9B,CAAC;IACH,CAAC;IAEO,gBAAgB,CAAC,KAAU;;QACjC,IAAI,CAAC,QAAQ,CAAC,gCAAgC,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,mCAAI,KAAK,EAAE,CAAC,CAAA;IACxE,CAAC;CACF;AAvjBiB,mBAAW,GAAG;IAC5B,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;CACb,AAJ0B,CAI1B","sourcesContent":["import { User } from '../auth'\nimport { Dictionary } from '../common'\nimport { SystemError, SystemErrorKeys } from '../error'\nimport { Logger } from '../logger'\nimport { Survey } from '../survey'\nimport { UUIDs } from '../utils'\n\nimport { Job } from './job'\nimport { JobContext } from './jobContext'\nimport { JobEvent, JobEventType } from './jobEvent'\nimport { JobSerialized } from './jobSerialized'\nimport { JobStatus } from './status'\n\nexport interface JobConstructor {\n new <C extends JobContext, R>(context: C, innerJobs?: JobBase<any>[]): JobBase<C, R>\n readonly prototype: JobBase<any, any>\n}\n\n/**\n * Client able to open a transaction (e.g. a pg-promise database): the job runs inside `client.tx(callback)`.\n */\nexport interface JobTxClient {\n tx(callback: (tx: any) => Promise<void>): Promise<unknown>\n}\n\nconst PROGRESS_NOTIFICATION_THROTTLE_MILLIS = 1000\n\n/**\n * Asynchronous task handler.\n *\n * Status workflow:\n * - pending\n * - running\n * - (end)\n * -- succeeded\n * -- failed\n * -- canceled\n *\n * Methods that can be overwritten by subclasses:\n * - shouldExecute (in tx)\n * - onStart (in tx)\n * - execute (in tx)\n * - beforeSuccess (in tx)\n * - generateResult (in tx)\n * - beforeEnd (in tx)\n * - onEnd (out of tx)\n * - getErrorInfo\n */\nexport abstract class JobBase<C extends JobContext, R = undefined> implements Job<R> {\n static readonly keysContext = {\n surveyId: 'surveyId',\n survey: 'survey',\n user: 'user',\n }\n\n readonly uuid: string\n readonly type: string\n status: JobStatus = JobStatus.pending\n startTime?: Date\n endTime?: Date\n total: number\n result: R | undefined = undefined\n errors: Record<string, any> = {}\n canceledByAdmin?: boolean\n\n protected logger: Logger\n protected context: C\n protected innerJobs: JobBase<C, any>[]\n protected currentInnerJobIndex = -1\n\n private _processed = 0\n private eventListener: ((event: JobEvent) => unknown) | undefined = undefined\n private progressThrottleTimeoutId: ReturnType<typeof setTimeout> | undefined = undefined\n private progressThrottleLastRunTime = 0\n private _stopOnInnerJobFailure = true\n // set as soon as cancel() is called (the canceled status is set only after beforeEnd has run)\n private cancelRequested = false\n private beforeEndCalled = false\n // inner job events are handled in sequence; executeJobs waits for them before going on\n private innerJobEventsQueue: Promise<void> = Promise.resolve()\n\n public constructor(context: C, innerJobs: JobBase<C, any>[] = []) {\n this.context = { ...context }\n this.innerJobs = innerJobs\n\n this.uuid = UUIDs.v4()\n this.type = this.context.type ?? this.constructor.name\n this.total = innerJobs.length > 0 ? innerJobs.length : 1\n\n // Created last, so that createLogger() overrides can safely build the logger name out of\n // the job identity (e.g. arena's `Job <ClassName> (<uuid>)` log correlation id).\n this.logger = this.createLogger()\n }\n\n get processed(): number {\n return this._processed\n }\n\n set processed(value: number) {\n this._processed = value\n this.notifyProgress()\n }\n\n get stopOnInnerJobFailure(): boolean {\n return this._stopOnInnerJobFailure\n }\n\n set stopOnInnerJobFailure(value: boolean) {\n this._stopOnInnerJobFailure = value\n }\n\n protected get surveyId(): number | null {\n return this.context.surveyId ?? null\n }\n\n protected get user(): User {\n return this.context.user\n }\n\n protected get userUuid(): string | undefined {\n return this.user?.uuid\n }\n\n protected get contextSurvey(): Survey | undefined {\n return this.context.survey\n }\n\n /**\n * Returns the value of the specified context prop, or the default value (null if not specified) when not set.\n */\n protected getContextProp<K extends keyof C & string>(prop: K, defaultValue?: C[K] | null): C[K] | null\n /** Context prop not declared in the context type: the value is typed by the caller. */\n protected getContextProp<T = any, P extends string = string>(\n prop: P extends keyof C ? never : P,\n defaultValue?: T | null\n ): T | null\n protected getContextProp(prop: string, defaultValue: unknown = null): unknown {\n const value = (this.context as Record<string, unknown>)[prop]\n return value ?? defaultValue\n }\n\n protected setContext(context: Partial<C>): void {\n Object.assign(this.context, context)\n }\n\n protected deleteContextProps(...propNames: string[]): void {\n propNames.forEach((propName) => {\n delete (this.context as any)[propName]\n })\n }\n\n /**\n * Registers the listener notified of job events (status changes and progress).\n * Only one listener can be registered at a time; registering a new one replaces the previous one.\n * Errors thrown (or rejections returned) by the listener are logged and do not affect the job execution.\n */\n onEvent(listener: (event: JobEvent) => unknown): this {\n this.eventListener = listener\n return this\n }\n\n isPending(): boolean {\n return this.status === JobStatus.pending\n }\n\n isRunning(): boolean {\n return this.status === JobStatus.running\n }\n\n isSucceeded(): boolean {\n return this.status === JobStatus.succeeded\n }\n\n isFailed(): boolean {\n return this.status === JobStatus.failed\n }\n\n isCanceled(): boolean {\n return this.status === JobStatus.canceled\n }\n\n isEnded(): boolean {\n return [JobStatus.succeeded, JobStatus.failed, JobStatus.canceled].includes(this.status)\n }\n\n hasErrors(): boolean {\n return Object.keys(this.errors).length > 0\n }\n\n protected getCurrentInnerJob(): JobBase<C, any> | undefined {\n return this.innerJobs[this.currentInnerJobIndex]\n }\n\n protected combineInnerJobsResults(): Record<string, any> {\n const results: Record<string, any> = {}\n this.innerJobs.forEach((innerJob) => Object.assign(results, innerJob.result ?? {}))\n return results\n }\n\n protected combineInnerJobsErrors(): Record<string, any> {\n const errors: Record<string, any> = {}\n this.innerJobs.forEach((innerJob) => Object.assign(errors, innerJob.errors ?? {}))\n return errors\n }\n\n async cancel(options: { canceledByAdmin?: boolean } = {}): Promise<void> {\n const { canceledByAdmin = false } = options\n if (this.isEnded()) return\n\n this.cancelRequested = true\n\n const currentInnerJob = this.getCurrentInnerJob()\n if (currentInnerJob?.isRunning()) {\n // the parent job status will be set to canceled when handling the canceled event of the inner job\n await currentInnerJob.cancel({ canceledByAdmin })\n return\n }\n // no inner job running (job without inner jobs, or between two inner jobs)\n this.canceledByAdmin = canceledByAdmin\n // release the resources (temp files/directories, streams) allocated before the cancellation\n await this.runBeforeEnd()\n await this.setStatus(JobStatus.canceled)\n }\n\n private isCancelRequestedOrNotRunning(): boolean {\n return this.cancelRequested || !this.isRunning()\n }\n\n /**\n * Runs beforeEnd only once (it can be called by cancel() and when the job execution ends).\n */\n private async runBeforeEnd(): Promise<void> {\n if (this.beforeEndCalled) return\n this.beforeEndCalled = true\n await this.beforeEnd()\n }\n\n async start(client: JobTxClient | null = null): Promise<void> {\n this.logDebug('start')\n\n try {\n if (client) {\n await client.tx(async (tx: any) => {\n this.context.tx = tx\n await this.executeInTransaction()\n })\n } else {\n await this.executeInTransaction()\n }\n if (!this.isCancelRequestedOrNotRunning()) {\n await this.setStatus(JobStatus.succeeded)\n }\n } catch (error: any) {\n // a job can fail while still pending (e.g. the transaction cannot be opened, or onStart fails)\n if (!this.cancelRequested && !this.isFailed() && !this.isCanceled()) {\n this.logError(error.stack ?? error)\n const { key, params } = this.getErrorInfo(error)\n this.addError({ error: { valid: false, errors: [{ key, params }] } })\n await this.setStatus(JobStatus.failed)\n }\n } finally {\n this.context.tx = undefined\n }\n }\n\n private async executeInTransaction(): Promise<void> {\n try {\n await this.onStart()\n\n const shouldExecute = await this.shouldExecute()\n if (shouldExecute) {\n if (this.innerJobs.length > 0) {\n await this.executeJobs()\n } else {\n await this.execute()\n }\n if (!this.isCancelRequestedOrNotRunning()) {\n await this.beforeSuccess()\n }\n }\n } finally {\n // runs only if not already run by cancel()\n await this.runBeforeEnd()\n this.context.tx = undefined\n }\n\n if (this.isCancelRequestedOrNotRunning()) {\n this.throwError(SystemErrorKeys.job.canceledOrErrorsFound)\n }\n }\n\n /**\n * Generates a plain JSON-serializable representation of the job, including its inner jobs.\n */\n toJSON(): JobSerialized<R> {\n const { errors, processed, result, status, total, type, userUuid, uuid } = this\n\n return {\n uuid,\n type,\n userUuid,\n surveyId: this.surveyId,\n innerJobs: this.innerJobs.map((job) => job.toJSON()),\n currentInnerJobIndex: this.currentInnerJobIndex,\n\n status,\n pending: this.isPending(),\n running: this.isRunning(),\n succeeded: this.isSucceeded(),\n canceled: this.isCanceled(),\n failed: this.isFailed(),\n ended: this.isEnded(),\n\n total,\n processed,\n progressPercent: this.calculateProgressPercent(),\n elapsedMillis: this.calculateElapsedMillis(),\n\n errors: this.isFailed() ? errors : undefined,\n result: this.isSucceeded() ? result : undefined,\n }\n }\n\n private async executeJobs(): Promise<void> {\n this.logDebug(`- ${this.total} inner jobs found`)\n\n for (let i = 0; i < this.innerJobs.length; i++) {\n this.logDebug(`- executing inner job ${i + 1}`)\n this.currentInnerJobIndex = i\n const currentInnerJob = this.innerJobs[i]\n if (currentInnerJob.context) {\n Object.assign(this.context, currentInnerJob.context)\n }\n currentInnerJob.context = this.context\n currentInnerJob.onEvent((event) => {\n // handle the inner job events in sequence; errors are logged (they would be unhandled rejections otherwise)\n this.innerJobEventsQueue = this.innerJobEventsQueue\n .then(() => this.onInnerJobEvent(event))\n .catch((error) => this.logError(error?.stack ?? error))\n })\n\n // The inner job shares this very context object, and its own start()/executeInTransaction()\n // clear `context.tx` when they terminate: without saving and restoring it here, the first\n // inner job would wipe the parent's transaction handle, leaving every following inner job\n // (and the parent's own beforeSuccess()/beforeEnd()) running outside of the transaction.\n // start() never throws (it swallows/records errors internally), so a plain restore is enough.\n const parentTx = this.context.tx\n await currentInnerJob.start(parentTx)\n this.context.tx = parentTx\n // the inner job events (e.g. canceled, failed) update the status of this job\n await this.innerJobEventsQueue\n\n if (this.cancelRequested || this.isCanceled() || currentInnerJob.isCanceled()) {\n break\n }\n if (currentInnerJob.isSucceeded()) {\n this.incrementProcessedItems()\n } else if (this.stopOnInnerJobFailure) {\n break\n }\n }\n\n this.logDebug(`- ${this.processed} inner jobs processed successfully`)\n }\n\n /**\n * Runs the job's own work when it has no inner jobs. Default implementation is a no-op, so\n * subclasses that only supply inner jobs (and never override this) don't need to. It also means\n * a subclass can safely call `super.execute()` defensively without knowing whether any ancestor\n * overrides it - if this were `abstract` instead, TypeScript would compile away any runtime\n * property for it entirely, so `super.execute()` would throw the moment no ancestor overrides it\n * (confirmed in production: a subclass whose immediate parent didn't override `execute()` crashed\n * with \"(intermediate value).execute is not a function\" the instant it called `super.execute()`).\n */\n protected async execute(): Promise<void> {\n // to be extended by subclasses\n }\n\n /**\n * Determines whether the job should actually run.\n * When it returns false, \"execute\" (or the inner jobs) will be skipped, but the job will still succeed.\n */\n protected shouldExecute(): Promise<boolean> {\n return Promise.resolve(true)\n }\n\n protected incrementProcessedItems(incrementBy = 1): void {\n this.processed += incrementBy\n }\n\n protected async setStatus(status: JobStatus): Promise<void> {\n this.logDebug(`set status: ${status}`)\n this.status = status\n\n const event: JobEvent = { type: JobEventType.statusChange, status, total: this.total, processed: this.processed }\n if (status === JobStatus.failed) {\n event.errors = this.errors\n }\n\n if (this.isEnded()) {\n this.logDebug('onEnd...')\n await this.onEnd()\n this.logDebug(`onEnd run. Job completed in ${this.elapsedTimePrettyFormat}`)\n }\n\n this.notifyEvent(event)\n }\n\n /**\n * Inner job event handler.\n */\n protected async onInnerJobEvent(event: JobEvent): Promise<void> {\n const { status } = event\n if (status === JobStatus.canceled) {\n this.canceledByAdmin = this.getCurrentInnerJob()?.canceledByAdmin ?? false\n return this.setStatus(status)\n }\n if (status === JobStatus.failed) {\n // report the errors of the failed inner job in the failed event (and in the errors) of this job\n Object.assign(this.errors, this.getCurrentInnerJob()?.errors ?? {})\n return this.setStatus(status)\n }\n if (status === JobStatus.running) {\n this.notifyEvent({\n type: JobEventType.progress,\n status: this.status,\n total: this.total,\n processed: this.processed,\n })\n return\n }\n this.logDebug(`Unknown inner job status: ${status}`)\n }\n\n /**\n * Called when the job just has been started.\n */\n protected async onStart(): Promise<void> {\n this.startTime = new Date()\n await this.setStatus(JobStatus.running)\n }\n\n /**\n * Called before beforeEnd only if the status will change to 'success'.\n * Default implementation stores the value returned by generateResult() via setResult().\n * It runs INSIDE the current db transaction.\n */\n protected async beforeSuccess(): Promise<void> {\n this.setResult(await this.generateResult())\n }\n\n /**\n * Computes the value beforeSuccess() will store as this job's result.\n * Default implementation returns whatever is already in `this.result`\n * (e.g. accumulated via earlier setResult() calls during execute()).\n */\n protected generateResult(): Promise<R | undefined> {\n return Promise.resolve(this.result)\n }\n\n /**\n * Updates this job's result. When both the current and incoming values are plain objects,\n * they are merged (Object.assign); otherwise the incoming value replaces the current one.\n * This keeps it safe for subclasses whose result is a primitive (e.g. a plain number) as\n * well as ones that build an object result incrementally across multiple setResult() calls.\n */\n protected setResult(result: R | undefined): void {\n if (result && typeof result === 'object' && this.result && typeof this.result === 'object') {\n Object.assign(this.result, result)\n } else {\n this.result = result\n }\n }\n\n /**\n * Called before onEnd. Useful for flushing resources used by the job before it terminates completely.\n * It runs INSIDE the current db transaction.\n */\n protected beforeEnd(): Promise<void> {\n this.logDebug('Cleanup')\n return Promise.resolve()\n }\n\n /**\n * Called when the job status changes to success, failed or canceled\n * (it runs OUTSIDE of the current db transaction)\n */\n protected onEnd(): Promise<void> {\n this.endTime = new Date()\n this.cancelNotifyProgress()\n return Promise.resolve()\n }\n\n protected addError(error: any, errorKey?: string): void {\n const key = errorKey ?? String(this.processed + 1)\n this.errors[key] = error\n }\n\n protected throwError(errorKey: string, params?: Dictionary<any>): void {\n // SystemError: getErrorInfo will report the translatable key instead of a generic error\n throw new SystemError(errorKey, params)\n }\n\n protected getErrorInfo(error: any): { key: string; params: Record<string, any> } {\n if (error instanceof SystemError) {\n return { key: `appErrors:${error.key}`, params: error.params }\n }\n return { key: 'appErrors:generic', params: { text: error.toString() } }\n }\n\n protected abstract createLogger(): Logger\n\n protected logDebug(...msgs: any[]): void {\n this.logger.debug(...msgs)\n }\n\n protected logInfo(...msgs: any[]): void {\n this.logger.info(...msgs)\n }\n\n protected logWarn(...msgs: any[]): void {\n this.logger.warn(...msgs)\n }\n\n protected logError(...msgs: any[]): void {\n this.logger.error(...msgs)\n }\n\n private get elapsedTimePrettyFormat(): string {\n const elapsedTime = this.calculateElapsedMillis()\n const elapsedMins = Math.floor(elapsedTime / 1000 / 60)\n const elapsedSeconds = String(Math.floor(elapsedTime / 1000) % 60).padStart(2, '0')\n const elapsedMillis = String(elapsedTime % 1000).padStart(3, '0')\n return `${elapsedMins}:${elapsedSeconds}.${elapsedMillis}`\n }\n\n private calculatePartialProgress(): number {\n if (this.isSucceeded()) return 100\n if (this.total > 0) return Math.floor((100 * this.processed) / this.total)\n return 0\n }\n\n private calculateProgressPercent(): number {\n const partialProgress = this.calculatePartialProgress()\n const currentInnerJob = this.getCurrentInnerJob()\n if (\n !currentInnerJob ||\n this.currentInnerJobIndex < 0 ||\n partialProgress === 100 ||\n this.processed > this.currentInnerJobIndex\n ) {\n return partialProgress\n }\n return partialProgress + Math.floor(currentInnerJob.calculateProgressPercent() / this.total)\n }\n\n private calculateElapsedMillis(): number {\n if (!this.startTime) return 0\n return (this.endTime ?? new Date()).getTime() - this.startTime.getTime()\n }\n\n /**\n * Notifies a progress event to the registered listener, throttled so that fast-changing\n * progress does not flood consumers (e.g. web socket clients).\n */\n private notifyProgress(): void {\n const run = (): void => {\n this.progressThrottleTimeoutId = undefined\n this.progressThrottleLastRunTime = Date.now()\n this.notifyEvent({\n type: JobEventType.progress,\n status: this.status,\n total: this.total,\n processed: this.processed,\n })\n }\n\n if (this.progressThrottleTimeoutId) return\n\n const elapsed = Date.now() - this.progressThrottleLastRunTime\n if (!this.progressThrottleLastRunTime || elapsed >= PROGRESS_NOTIFICATION_THROTTLE_MILLIS) {\n run()\n } else {\n this.progressThrottleTimeoutId = setTimeout(run, PROGRESS_NOTIFICATION_THROTTLE_MILLIS - elapsed)\n }\n }\n\n /**\n * Cancels any pending throttled progress notification and resets the throttle state.\n */\n private cancelNotifyProgress(): void {\n if (this.progressThrottleTimeoutId) {\n clearTimeout(this.progressThrottleTimeoutId)\n this.progressThrottleTimeoutId = undefined\n }\n this.progressThrottleLastRunTime = 0\n }\n\n /**\n * Notifies the event to the registered listener.\n * Listener errors are only logged: they would otherwise fail the job or, when thrown inside the progress\n * throttle timeout, crash the process.\n */\n private notifyEvent(event: JobEvent): void {\n const listener = this.eventListener\n if (!listener) return\n try {\n Promise.resolve(listener(event)).catch((error) => this.logListenerError(error))\n } catch (error) {\n this.logListenerError(error)\n }\n }\n\n private logListenerError(error: any): void {\n this.logError(`error in job event listener: ${error?.stack ?? error}`)\n }\n}\n"]}
|
|
@@ -125,7 +125,7 @@ const extractCategoryItemUuidFromValue = (params) => {
|
|
|
125
125
|
}
|
|
126
126
|
if (!record || !parentNode)
|
|
127
127
|
return undefined;
|
|
128
|
-
const parentCodeAttribute = Records.getParentCodeAttribute(
|
|
128
|
+
const parentCodeAttribute = Records.getParentCodeAttribute(parentNode, nodeDef)(record);
|
|
129
129
|
if (!parentCodeAttribute)
|
|
130
130
|
return undefined;
|
|
131
131
|
const parentItemUuid = getItemUuid(parentCodeAttribute);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeValues.js","sourceRoot":"","sources":["../../../src/node/nodeValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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from '../geo'\nimport { NodeDef, NodeDefCode, NodeDefProps, NodeDefType } from '../nodeDef'\nimport { ArenaRecord, Records } from '../record'\nimport { Survey, Surveys } from '../survey'\nimport { DateFormats, Dates, Objects } from '../utils'\nimport { ArenaRecordNode } from './node'\nimport { NodeValueCoordinate } from './nodeValue/coordinate'\nimport {\n ValuePropsCode,\n ValuePropsCoordinate,\n ValuePropsDate,\n ValuePropsFile,\n ValuePropsTaxon,\n ValuePropsTime,\n} from './nodeValueProps'\n\n/**\n * Props of node value indexed by node def type.\n * The node definitions here are only the ones of \"composite\" attributes.\n */\nexport const ValuePropsByType: { [key in NodeDefType]: { [key: string]: string } | null } = {\n [NodeDefType.boolean]: null,\n [NodeDefType.code]: ValuePropsCode,\n [NodeDefType.coordinate]: ValuePropsCoordinate,\n [NodeDefType.date]: ValuePropsDate,\n [NodeDefType.decimal]: null,\n [NodeDefType.geo]: null,\n [NodeDefType.entity]: null,\n [NodeDefType.file]: ValuePropsFile,\n [NodeDefType.integer]: null,\n [NodeDefType.taxon]: ValuePropsTaxon,\n [NodeDefType.time]: ValuePropsTime,\n [NodeDefType.text]: null,\n // layout elements\n [NodeDefType.formHeader]: null,\n}\n\nconst getValuePropRaw = (params: { value: any; prop: string; defaultValue?: any }): any => {\n const { value, prop, defaultValue } = params\n const valueProp = value?.[prop]\n return valueProp === undefined ? defaultValue : valueProp\n}\n\nconst getNodeValuePropRaw = (params: { node: ArenaRecordNode; prop: string; defaultValue?: any }): any => {\n const { node, prop, defaultValue } = params\n return getValuePropRaw({ value: node.value, prop, defaultValue })\n}\n\n// Code\nconst newCodeValue = (params: { itemUuid: string }) => {\n const { itemUuid } = params\n return { [ValuePropsCode[ValuePropsCode.itemUuid]]: itemUuid }\n}\n\nconst getItemUuid = (node: ArenaRecordNode): string | undefined =>\n getNodeValuePropRaw({ node, prop: ValuePropsCode[ValuePropsCode.itemUuid] })\n\nconst getValueCode = (value: any): string | undefined =>\n getValuePropRaw({ value, prop: ValuePropsCode[ValuePropsCode.code] })\n\nconst getValueItemUuid = (value: any): string | undefined =>\n getValuePropRaw({ value, prop: ValuePropsCode[ValuePropsCode.itemUuid] })\n\nconst getDateTimePart = (params: { node: ArenaRecordNode; index: number; separator: string }): number => {\n const { node, index, separator } = params\n return Number((node.value ?? '').split(separator)[index]?.trim())\n}\n\n// Date\nconst getDatePart =\n (index: number) =>\n (node: ArenaRecordNode): number =>\n getDateTimePart({ node, index, separator: '-' })\nconst getDateYear = getDatePart(0)\nconst getDateMonth = getDatePart(1)\nconst getDateDay = getDatePart(2)\n\nconst _datePropGetters: { [key in ValuePropsDate]: (node: ArenaRecordNode) => number } = {\n [ValuePropsDate.day]: getDateDay,\n [ValuePropsDate.month]: getDateMonth,\n [ValuePropsDate.year]: getDateYear,\n}\n\n// File\nconst getFileName = (node: ArenaRecordNode): string | undefined =>\n getNodeValuePropRaw({ node, prop: ValuePropsFile.fileName })\nconst getFileNameCalculated = (node: ArenaRecordNode): string | undefined =>\n getNodeValuePropRaw({ node, prop: ValuePropsFile.fileNameCalculated })\nconst getFileSize = (node: ArenaRecordNode): string | undefined =>\n getNodeValuePropRaw({ node, prop: ValuePropsFile.fileSize })\nconst getFileUuid = (node: ArenaRecordNode): string | undefined =>\n getNodeValuePropRaw({ node, prop: ValuePropsFile.fileUuid })\n\n// Taxon\nconst getTaxonUuid = (node: ArenaRecordNode): string | undefined =>\n getNodeValuePropRaw({ node, prop: ValuePropsTaxon[ValuePropsTaxon.taxonUuid] })\nconst getValueTaxonUuid = (value: any): string | undefined =>\n getValuePropRaw({ value, prop: ValuePropsTaxon[ValuePropsTaxon.taxonUuid] })\nconst getScientificName = (node: ArenaRecordNode): string | undefined =>\n getNodeValuePropRaw({ node, prop: ValuePropsTaxon[ValuePropsTaxon.scientificName] })\nconst getValueScientificName = (value: any): string | undefined =>\n getValuePropRaw({ value, prop: ValuePropsTaxon[ValuePropsTaxon.scientificName] })\nconst getVernacularName = (node: ArenaRecordNode): string | undefined =>\n getNodeValuePropRaw({ node, prop: ValuePropsTaxon[ValuePropsTaxon.vernacularName] })\nconst getValueVernacularName = (value: any): string | undefined =>\n getValuePropRaw({ value, prop: ValuePropsTaxon[ValuePropsTaxon.vernacularName] })\nconst getVernacularNameUuid = (node: ArenaRecordNode): string | undefined =>\n getNodeValuePropRaw({ node, prop: ValuePropsTaxon[ValuePropsTaxon.vernacularNameUuid] })\nconst getValueVernacularNameUuid = (value: any): string | undefined =>\n getValuePropRaw({ value, prop: ValuePropsTaxon[ValuePropsTaxon.vernacularNameUuid] })\n\n// Time\nconst _getTimePart =\n (index: number) =>\n (node: ArenaRecordNode): number =>\n getDateTimePart({ node, index, separator: ':' })\nconst getTimeHour = _getTimePart(0)\nconst getTimeMinute = _getTimePart(1)\nconst getTimeSeconds = (node: ArenaRecordNode): number => {\n const parts = (node.value ?? '').split(':')\n return parts.length > 2 ? _getTimePart(2)(node) : 0\n}\n\nconst _timePropGetters: { [key in ValuePropsTime]: any } = {\n [ValuePropsTime.hour]: getTimeHour,\n [ValuePropsTime.minute]: getTimeMinute,\n [ValuePropsTime.seconds]: getTimeSeconds,\n}\n\nconst _valuePropGetters: { [key in NodeDefType]?: (prop: string) => (node: ArenaRecordNode) => number } = {\n [NodeDefType.date]: (prop: string) => _datePropGetters[ValuePropsDate[prop as keyof typeof ValuePropsDate]],\n [NodeDefType.time]: (prop: string) => _timePropGetters[ValuePropsTime[prop as keyof typeof ValuePropsTime]],\n}\n\nconst isValueProp = (params: { nodeDef: NodeDef<NodeDefType, NodeDefProps>; prop: string }): boolean => {\n const { nodeDef, prop } = params\n return Object.values(ValuePropsByType[nodeDef.type] ?? {}).includes(prop)\n}\n\nconst getNodeValueProp = (params: {\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n node: ArenaRecordNode\n prop: string\n}): any => {\n const { nodeDef, node, prop } = params\n const propGetter: any = _valuePropGetters[nodeDef.type]\n return propGetter ? propGetter(prop)(node) : getNodeValuePropRaw({ node, prop })\n}\n\n// value compare\n\nconst singlePropValueEqualComparator = (params: NodeValuesCompareParams): boolean => {\n const { value, valueSearch } = params\n return value === valueSearch || String(value) === String(valueSearch)\n}\n\nconst extractCategoryItemUuidFromValue = (params: NodeValuesCompareParams): string | undefined => {\n const { survey, nodeDef, record, parentNode, value } = params\n const valueItemUuid = getValueItemUuid(value)\n if (valueItemUuid) {\n return valueItemUuid\n }\n // find itemUuid by code\n const valueCode = getValueCode(value)\n if (Objects.isEmpty(valueCode)) return undefined\n\n const nodeDefCode = nodeDef as NodeDefCode\n const code = valueCode!\n const categoryUuid = nodeDefCode.props?.categoryUuid\n const levelIndex = Surveys.getNodeDefCategoryLevelIndex({ survey, nodeDef: nodeDefCode })\n if (levelIndex === 0) {\n return Surveys.getCategoryItemUuidByCode({ survey, categoryUuid, parentItemUuid: undefined, code })\n }\n if (!record || !parentNode) return undefined\n\n const parentCodeAttribute = Records.getParentCodeAttribute({ parentNode, nodeDef: nodeDef as NodeDefCode })(record)\n if (!parentCodeAttribute) return undefined\n\n const parentItemUuid = getItemUuid(parentCodeAttribute)\n if (!parentItemUuid) return undefined\n\n return Surveys.getCategoryItemUuidByCode({\n survey,\n categoryUuid,\n parentItemUuid,\n code,\n })\n}\n\nconst extractCategoryItemCodeFromValue = (params: { survey: Survey; value: any }): string | undefined => {\n const { survey, value } = params\n const itemUuid = getValueItemUuid(value)\n if (itemUuid) {\n const item = Surveys.getCategoryItemByUuid({ survey, itemUuid })\n return item ? CategoryItems.getCode(item) : undefined\n }\n return getValueCode(value)\n}\n\nconst dateTimeComparator =\n (params: { formatsSource: DateFormats[]; formatTo: DateFormats }) =>\n (paramsComparator: NodeValuesCompareParams): boolean => {\n const { formatsSource, formatTo } = params\n const { value, valueSearch } = paramsComparator\n const toDateTime = (val: any) => {\n if (val instanceof Date) {\n return Dates.format(val, formatTo)\n }\n const formatFrom = formatsSource.find((format) => Dates.isValidDateInFormat(val, format))\n return formatFrom ? Dates.convertDate({ dateStr: val, formatFrom, formatTo }) : null\n }\n const dateTime = toDateTime(value)\n const dateTimeSearch = toDateTime(valueSearch)\n return !!dateTime && !!dateTimeSearch && dateTime === dateTimeSearch\n }\n\nconst valueComparatorByNodeDefType: { [key in NodeDefType]?: (params: NodeValuesCompareParams) => boolean } = {\n [NodeDefType.boolean]: singlePropValueEqualComparator,\n [NodeDefType.code]: (params: NodeValuesCompareParams): boolean => {\n const { survey, record, value, valueSearch, strict } = params\n if (!strict || !record) {\n // compare just codes (record not available, tricky to find the \"correct\" category item without knowing its parent item)\n const code = extractCategoryItemCodeFromValue({ survey, value })\n const codeSearch = extractCategoryItemCodeFromValue({ survey, value: valueSearch })\n return !!code && !!codeSearch && code === codeSearch\n }\n const itemUuid = extractCategoryItemUuidFromValue(params)\n const itemUuidSearch = extractCategoryItemUuidFromValue({\n ...params,\n value: valueSearch,\n })\n return !!itemUuidSearch && !!itemUuid && itemUuidSearch === itemUuid\n },\n [NodeDefType.coordinate]: (params: NodeValuesCompareParams) => {\n const { value, valueSearch } = params\n return Objects.isEqual(value, valueSearch)\n },\n [NodeDefType.date]: dateTimeComparator({\n formatsSource: [DateFormats.dateDisplay, DateFormats.dateStorage],\n formatTo: DateFormats.dateStorage,\n }),\n [NodeDefType.decimal]: singlePropValueEqualComparator,\n [NodeDefType.integer]: singlePropValueEqualComparator,\n [NodeDefType.taxon]: ({ value, valueSearch }) => {\n if (value === valueSearch) return true\n if (!value) return false\n if (!valueSearch) return false\n return value[ValuePropsTaxon.taxonUuid] === valueSearch[ValuePropsTaxon.taxonUuid]\n },\n [NodeDefType.text]: singlePropValueEqualComparator,\n [NodeDefType.time]: dateTimeComparator({\n formatsSource: [DateFormats.timeStorage, DateFormats.timeWithSeconds],\n formatTo: DateFormats.timeWithSeconds,\n }),\n}\n\ninterface NodeValuesCompareParams {\n survey: Survey\n nodeDef: NodeDef<NodeDefType, any>\n value: any\n valueSearch: any\n record?: ArenaRecord\n parentNode?: ArenaRecordNode\n strict?: boolean\n}\n\nconst isValueEqual = (params: NodeValuesCompareParams): boolean => {\n const { survey, nodeDef, value, valueSearch, record = undefined, parentNode = undefined, strict = false } = params\n if (value === valueSearch) return true\n if (Objects.isEmpty(value) || Objects.isEmpty(valueSearch)) return false\n\n const valueComparator = valueComparatorByNodeDefType[nodeDef.type]\n if (!valueComparator) {\n return Objects.isEqual(value, valueSearch)\n }\n return valueComparator({ survey, nodeDef, record, parentNode, value, valueSearch, strict })\n}\n\nconst getValueAsPoint = (params: { survey: Survey; node: ArenaRecordNode }): Point | null => {\n const { survey, node } = params\n const nodeValue = node?.value\n\n if (!nodeValue) return null\n\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid })\n if (nodeDef.type === NodeDefType.coordinate) {\n const { x, y, srs } = nodeValue as NodeValueCoordinate\n\n const srsObject = Surveys.getSRSByCode(srs)(survey)\n if (!srsObject) return null\n\n return PointFactory.createInstance({ srs, x, y })\n }\n return null\n}\n\nexport const NodeValues = {\n ValuePropsByType,\n ValuePropsCode,\n ValuePropsCoordinate,\n ValuePropsDate,\n ValuePropsFile,\n ValuePropsTaxon,\n ValuePropsTime,\n\n getNodeValueProp,\n isValueProp,\n\n // coordinate\n getValueAsPoint,\n\n // code\n newCodeValue,\n getItemUuid,\n getValueCode,\n getValueItemUuid,\n\n // date\n getDateYear,\n getDateMonth,\n getDateDay,\n\n // file\n getFileName,\n getFileNameCalculated,\n getFileSize,\n getFileUuid,\n\n // taxon\n getTaxonUuid,\n getValueTaxonUuid,\n getScientificName,\n getValueScientificName,\n getVernacularName,\n getValueVernacularName,\n getVernacularNameUuid,\n getValueVernacularNameUuid,\n\n // time\n getTimeHour,\n getTimeMinute,\n getTimeSeconds,\n\n // utils\n isValueEqual,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nodeValues.js","sourceRoot":"","sources":["../../../src/node/nodeValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAS,YAAY,EAAE,MAAM,QAAQ,CAA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AI,CAAA;IAE3B,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAA;IAC5E,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,UAAU,EAAE,CAAC;QAC5C,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,SAAgC,CAAA;QAEtD,MAAM,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAA;QACnD,IAAI,CAAC,SAAS;YAAE,OAAO,IAAI,CAAA;QAE3B,OAAO,YAAY,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;IACnD,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,gBAAgB;IAChB,cAAc;IACd,oBAAoB;IACpB,cAAc;IACd,cAAc;IACd,eAAe;IACf,cAAc;IAEd,gBAAgB;IAChB,WAAW;IAEX,aAAa;IACb,eAAe;IAEf,OAAO;IACP,YAAY;IACZ,WAAW;IACX,YAAY;IACZ,gBAAgB;IAEhB,OAAO;IACP,WAAW;IACX,YAAY;IACZ,UAAU;IAEV,OAAO;IACP,WAAW;IACX,qBAAqB;IACrB,WAAW;IACX,WAAW;IAEX,QAAQ;IACR,YAAY;IACZ,iBAAiB;IACjB,iBAAiB;IACjB,sBAAsB;IACtB,iBAAiB;IACjB,sBAAsB;IACtB,qBAAqB;IACrB,0BAA0B;IAE1B,OAAO;IACP,WAAW;IACX,aAAa;IACb,cAAc;IAEd,QAAQ;IACR,YAAY;CACb,CAAA","sourcesContent":["import { CategoryItems } from '../category'\nimport { Point, PointFactory } from '../geo'\nimport { NodeDef, NodeDefCode, NodeDefProps, NodeDefType } from '../nodeDef'\nimport { ArenaRecord, Records } from '../record'\nimport { Survey, Surveys } from '../survey'\nimport { DateFormats, Dates, Objects } from '../utils'\nimport { ArenaRecordNode } from './node'\nimport { NodeValueCoordinate } from './nodeValue/coordinate'\nimport {\n ValuePropsCode,\n ValuePropsCoordinate,\n ValuePropsDate,\n ValuePropsFile,\n ValuePropsTaxon,\n ValuePropsTime,\n} from './nodeValueProps'\n\n/**\n * Props of node value indexed by node def type.\n * The node definitions here are only the ones of \"composite\" attributes.\n */\nexport const ValuePropsByType: { [key in NodeDefType]: { [key: string]: string } | null } = {\n [NodeDefType.boolean]: null,\n [NodeDefType.code]: ValuePropsCode,\n [NodeDefType.coordinate]: ValuePropsCoordinate,\n [NodeDefType.date]: ValuePropsDate,\n [NodeDefType.decimal]: null,\n [NodeDefType.geo]: null,\n [NodeDefType.entity]: null,\n [NodeDefType.file]: ValuePropsFile,\n [NodeDefType.integer]: null,\n [NodeDefType.taxon]: ValuePropsTaxon,\n [NodeDefType.time]: ValuePropsTime,\n [NodeDefType.text]: null,\n // layout elements\n [NodeDefType.formHeader]: null,\n}\n\nconst getValuePropRaw = (params: { value: any; prop: string; defaultValue?: any }): any => {\n const { value, prop, defaultValue } = params\n const valueProp = value?.[prop]\n return valueProp === undefined ? defaultValue : valueProp\n}\n\nconst getNodeValuePropRaw = (params: { node: ArenaRecordNode; prop: string; defaultValue?: any }): any => {\n const { node, prop, defaultValue } = params\n return getValuePropRaw({ value: node.value, prop, defaultValue })\n}\n\n// Code\nconst newCodeValue = (params: { itemUuid: string }) => {\n const { itemUuid } = params\n return { [ValuePropsCode[ValuePropsCode.itemUuid]]: itemUuid }\n}\n\nconst getItemUuid = (node: ArenaRecordNode): string | undefined =>\n getNodeValuePropRaw({ node, prop: ValuePropsCode[ValuePropsCode.itemUuid] })\n\nconst getValueCode = (value: any): string | undefined =>\n getValuePropRaw({ value, prop: ValuePropsCode[ValuePropsCode.code] })\n\nconst getValueItemUuid = (value: any): string | undefined =>\n getValuePropRaw({ value, prop: ValuePropsCode[ValuePropsCode.itemUuid] })\n\nconst getDateTimePart = (params: { node: ArenaRecordNode; index: number; separator: string }): number => {\n const { node, index, separator } = params\n return Number((node.value ?? '').split(separator)[index]?.trim())\n}\n\n// Date\nconst getDatePart =\n (index: number) =>\n (node: ArenaRecordNode): number =>\n getDateTimePart({ node, index, separator: '-' })\nconst getDateYear = getDatePart(0)\nconst getDateMonth = getDatePart(1)\nconst getDateDay = getDatePart(2)\n\nconst _datePropGetters: { [key in ValuePropsDate]: (node: ArenaRecordNode) => number } = {\n [ValuePropsDate.day]: getDateDay,\n [ValuePropsDate.month]: getDateMonth,\n [ValuePropsDate.year]: getDateYear,\n}\n\n// File\nconst getFileName = (node: ArenaRecordNode): string | undefined =>\n getNodeValuePropRaw({ node, prop: ValuePropsFile.fileName })\nconst getFileNameCalculated = (node: ArenaRecordNode): string | undefined =>\n getNodeValuePropRaw({ node, prop: ValuePropsFile.fileNameCalculated })\nconst getFileSize = (node: ArenaRecordNode): string | undefined =>\n getNodeValuePropRaw({ node, prop: ValuePropsFile.fileSize })\nconst getFileUuid = (node: ArenaRecordNode): string | undefined =>\n getNodeValuePropRaw({ node, prop: ValuePropsFile.fileUuid })\n\n// Taxon\nconst getTaxonUuid = (node: ArenaRecordNode): string | undefined =>\n getNodeValuePropRaw({ node, prop: ValuePropsTaxon[ValuePropsTaxon.taxonUuid] })\nconst getValueTaxonUuid = (value: any): string | undefined =>\n getValuePropRaw({ value, prop: ValuePropsTaxon[ValuePropsTaxon.taxonUuid] })\nconst getScientificName = (node: ArenaRecordNode): string | undefined =>\n getNodeValuePropRaw({ node, prop: ValuePropsTaxon[ValuePropsTaxon.scientificName] })\nconst getValueScientificName = (value: any): string | undefined =>\n getValuePropRaw({ value, prop: ValuePropsTaxon[ValuePropsTaxon.scientificName] })\nconst getVernacularName = (node: ArenaRecordNode): string | undefined =>\n getNodeValuePropRaw({ node, prop: ValuePropsTaxon[ValuePropsTaxon.vernacularName] })\nconst getValueVernacularName = (value: any): string | undefined =>\n getValuePropRaw({ value, prop: ValuePropsTaxon[ValuePropsTaxon.vernacularName] })\nconst getVernacularNameUuid = (node: ArenaRecordNode): string | undefined =>\n getNodeValuePropRaw({ node, prop: ValuePropsTaxon[ValuePropsTaxon.vernacularNameUuid] })\nconst getValueVernacularNameUuid = (value: any): string | undefined =>\n getValuePropRaw({ value, prop: ValuePropsTaxon[ValuePropsTaxon.vernacularNameUuid] })\n\n// Time\nconst _getTimePart =\n (index: number) =>\n (node: ArenaRecordNode): number =>\n getDateTimePart({ node, index, separator: ':' })\nconst getTimeHour = _getTimePart(0)\nconst getTimeMinute = _getTimePart(1)\nconst getTimeSeconds = (node: ArenaRecordNode): number => {\n const parts = (node.value ?? '').split(':')\n return parts.length > 2 ? _getTimePart(2)(node) : 0\n}\n\nconst _timePropGetters: { [key in ValuePropsTime]: any } = {\n [ValuePropsTime.hour]: getTimeHour,\n [ValuePropsTime.minute]: getTimeMinute,\n [ValuePropsTime.seconds]: getTimeSeconds,\n}\n\nconst _valuePropGetters: { [key in NodeDefType]?: (prop: string) => (node: ArenaRecordNode) => number } = {\n [NodeDefType.date]: (prop: string) => _datePropGetters[ValuePropsDate[prop as keyof typeof ValuePropsDate]],\n [NodeDefType.time]: (prop: string) => _timePropGetters[ValuePropsTime[prop as keyof typeof ValuePropsTime]],\n}\n\nconst isValueProp = (params: { nodeDef: NodeDef<NodeDefType, NodeDefProps>; prop: string }): boolean => {\n const { nodeDef, prop } = params\n return Object.values(ValuePropsByType[nodeDef.type] ?? {}).includes(prop)\n}\n\nconst getNodeValueProp = (params: {\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n node: ArenaRecordNode\n prop: string\n}): any => {\n const { nodeDef, node, prop } = params\n const propGetter: any = _valuePropGetters[nodeDef.type]\n return propGetter ? propGetter(prop)(node) : getNodeValuePropRaw({ node, prop })\n}\n\n// value compare\n\nconst singlePropValueEqualComparator = (params: NodeValuesCompareParams): boolean => {\n const { value, valueSearch } = params\n return value === valueSearch || String(value) === String(valueSearch)\n}\n\nconst extractCategoryItemUuidFromValue = (params: NodeValuesCompareParams): string | undefined => {\n const { survey, nodeDef, record, parentNode, value } = params\n const valueItemUuid = getValueItemUuid(value)\n if (valueItemUuid) {\n return valueItemUuid\n }\n // find itemUuid by code\n const valueCode = getValueCode(value)\n if (Objects.isEmpty(valueCode)) return undefined\n\n const nodeDefCode = nodeDef as NodeDefCode\n const code = valueCode!\n const categoryUuid = nodeDefCode.props?.categoryUuid\n const levelIndex = Surveys.getNodeDefCategoryLevelIndex({ survey, nodeDef: nodeDefCode })\n if (levelIndex === 0) {\n return Surveys.getCategoryItemUuidByCode({ survey, categoryUuid, parentItemUuid: undefined, code })\n }\n if (!record || !parentNode) return undefined\n\n const parentCodeAttribute = Records.getParentCodeAttribute(parentNode, nodeDef as NodeDefCode)(record)\n if (!parentCodeAttribute) return undefined\n\n const parentItemUuid = getItemUuid(parentCodeAttribute)\n if (!parentItemUuid) return undefined\n\n return Surveys.getCategoryItemUuidByCode({\n survey,\n categoryUuid,\n parentItemUuid,\n code,\n })\n}\n\nconst extractCategoryItemCodeFromValue = (params: { survey: Survey; value: any }): string | undefined => {\n const { survey, value } = params\n const itemUuid = getValueItemUuid(value)\n if (itemUuid) {\n const item = Surveys.getCategoryItemByUuid({ survey, itemUuid })\n return item ? CategoryItems.getCode(item) : undefined\n }\n return getValueCode(value)\n}\n\nconst dateTimeComparator =\n (params: { formatsSource: DateFormats[]; formatTo: DateFormats }) =>\n (paramsComparator: NodeValuesCompareParams): boolean => {\n const { formatsSource, formatTo } = params\n const { value, valueSearch } = paramsComparator\n const toDateTime = (val: any) => {\n if (val instanceof Date) {\n return Dates.format(val, formatTo)\n }\n const formatFrom = formatsSource.find((format) => Dates.isValidDateInFormat(val, format))\n return formatFrom ? Dates.convertDate({ dateStr: val, formatFrom, formatTo }) : null\n }\n const dateTime = toDateTime(value)\n const dateTimeSearch = toDateTime(valueSearch)\n return !!dateTime && !!dateTimeSearch && dateTime === dateTimeSearch\n }\n\nconst valueComparatorByNodeDefType: { [key in NodeDefType]?: (params: NodeValuesCompareParams) => boolean } = {\n [NodeDefType.boolean]: singlePropValueEqualComparator,\n [NodeDefType.code]: (params: NodeValuesCompareParams): boolean => {\n const { survey, record, value, valueSearch, strict } = params\n if (!strict || !record) {\n // compare just codes (record not available, tricky to find the \"correct\" category item without knowing its parent item)\n const code = extractCategoryItemCodeFromValue({ survey, value })\n const codeSearch = extractCategoryItemCodeFromValue({ survey, value: valueSearch })\n return !!code && !!codeSearch && code === codeSearch\n }\n const itemUuid = extractCategoryItemUuidFromValue(params)\n const itemUuidSearch = extractCategoryItemUuidFromValue({\n ...params,\n value: valueSearch,\n })\n return !!itemUuidSearch && !!itemUuid && itemUuidSearch === itemUuid\n },\n [NodeDefType.coordinate]: (params: NodeValuesCompareParams) => {\n const { value, valueSearch } = params\n return Objects.isEqual(value, valueSearch)\n },\n [NodeDefType.date]: dateTimeComparator({\n formatsSource: [DateFormats.dateDisplay, DateFormats.dateStorage],\n formatTo: DateFormats.dateStorage,\n }),\n [NodeDefType.decimal]: singlePropValueEqualComparator,\n [NodeDefType.integer]: singlePropValueEqualComparator,\n [NodeDefType.taxon]: ({ value, valueSearch }) => {\n if (value === valueSearch) return true\n if (!value) return false\n if (!valueSearch) return false\n return value[ValuePropsTaxon.taxonUuid] === valueSearch[ValuePropsTaxon.taxonUuid]\n },\n [NodeDefType.text]: singlePropValueEqualComparator,\n [NodeDefType.time]: dateTimeComparator({\n formatsSource: [DateFormats.timeStorage, DateFormats.timeWithSeconds],\n formatTo: DateFormats.timeWithSeconds,\n }),\n}\n\ninterface NodeValuesCompareParams {\n survey: Survey\n nodeDef: NodeDef<NodeDefType, any>\n value: any\n valueSearch: any\n record?: ArenaRecord\n parentNode?: ArenaRecordNode\n strict?: boolean\n}\n\nconst isValueEqual = (params: NodeValuesCompareParams): boolean => {\n const { survey, nodeDef, value, valueSearch, record = undefined, parentNode = undefined, strict = false } = params\n if (value === valueSearch) return true\n if (Objects.isEmpty(value) || Objects.isEmpty(valueSearch)) return false\n\n const valueComparator = valueComparatorByNodeDefType[nodeDef.type]\n if (!valueComparator) {\n return Objects.isEqual(value, valueSearch)\n }\n return valueComparator({ survey, nodeDef, record, parentNode, value, valueSearch, strict })\n}\n\nconst getValueAsPoint = (params: { survey: Survey; node: ArenaRecordNode }): Point | null => {\n const { survey, node } = params\n const nodeValue = node?.value\n\n if (!nodeValue) return null\n\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: node.nodeDefUuid })\n if (nodeDef.type === NodeDefType.coordinate) {\n const { x, y, srs } = nodeValue as NodeValueCoordinate\n\n const srsObject = Surveys.getSRSByCode(srs)(survey)\n if (!srsObject) return null\n\n return PointFactory.createInstance({ srs, x, y })\n }\n return null\n}\n\nexport const NodeValues = {\n ValuePropsByType,\n ValuePropsCode,\n ValuePropsCoordinate,\n ValuePropsDate,\n ValuePropsFile,\n ValuePropsTaxon,\n ValuePropsTime,\n\n getNodeValueProp,\n isValueProp,\n\n // coordinate\n getValueAsPoint,\n\n // code\n newCodeValue,\n getItemUuid,\n getValueCode,\n getValueItemUuid,\n\n // date\n getDateYear,\n getDateMonth,\n getDateDay,\n\n // file\n getFileName,\n getFileNameCalculated,\n getFileSize,\n getFileUuid,\n\n // taxon\n getTaxonUuid,\n getValueTaxonUuid,\n getScientificName,\n getValueScientificName,\n getVernacularName,\n getValueVernacularName,\n getVernacularNameUuid,\n getValueVernacularNameUuid,\n\n // time\n getTimeHour,\n getTimeMinute,\n getTimeSeconds,\n\n // utils\n isValueEqual,\n}\n"]}
|
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { Users } from '../auth';
|
|
11
|
-
import { SystemError } from '../error';
|
|
11
|
+
import { SystemError, SystemErrorKeys } from '../error';
|
|
12
12
|
import { ExtraProps } from '../extraProp/extraProps';
|
|
13
13
|
import { Points } from '../geo';
|
|
14
14
|
import { LanguagesISO639part2 } from '../language';
|
|
@@ -79,13 +79,13 @@ export const nodeDefExpressionFunctions = {
|
|
|
79
79
|
var _a, _b;
|
|
80
80
|
const { survey } = context;
|
|
81
81
|
if (Objects.isEmpty(categoryName) || Objects.isEmpty(itemPropName) || Objects.isEmpty(codePaths))
|
|
82
|
-
throw new SystemError(
|
|
82
|
+
throw new SystemError(SystemErrorKeys.expression.missingFunctionParameters);
|
|
83
83
|
const category = getCategoryByName({ survey, categoryName });
|
|
84
84
|
if (!category)
|
|
85
|
-
throw new SystemError(
|
|
85
|
+
throw new SystemError(SystemErrorKeys.expression.invalidCategoryName, { name: categoryName });
|
|
86
86
|
const extraPropDef = (_a = category.props.itemExtraDef) === null || _a === void 0 ? void 0 : _a[itemPropName];
|
|
87
87
|
if (!extraPropDef)
|
|
88
|
-
throw new SystemError(
|
|
88
|
+
throw new SystemError(SystemErrorKeys.expression.invalidCategoryExtraProp, { propName: itemPropName });
|
|
89
89
|
const { uuid: categoryUuid } = category;
|
|
90
90
|
const categoryItem = yield getOrFetchCategoryItem({ context, categoryUuid, codePaths });
|
|
91
91
|
if (!categoryItem)
|
|
@@ -247,16 +247,16 @@ export const nodeDefExpressionFunctions = {
|
|
|
247
247
|
executor: (context) => (taxonomyName, propName, taxonCode) => __awaiter(void 0, void 0, void 0, function* () {
|
|
248
248
|
var _a, _b;
|
|
249
249
|
if (Objects.isEmpty(taxonomyName) || Objects.isEmpty(propName))
|
|
250
|
-
throw new SystemError(
|
|
250
|
+
throw new SystemError(SystemErrorKeys.expression.missingFunctionParameters);
|
|
251
251
|
if (Objects.isEmpty(taxonCode))
|
|
252
252
|
return null;
|
|
253
253
|
const { survey } = context;
|
|
254
254
|
const taxonomy = getTaxonomyByName({ survey, taxonomyName });
|
|
255
255
|
if (!taxonomy)
|
|
256
|
-
throw new SystemError(
|
|
256
|
+
throw new SystemError(SystemErrorKeys.expression.invalidTaxonomyName, { name: taxonomyName });
|
|
257
257
|
const extraPropDef = (_a = taxonomy.props.extraPropsDefs) === null || _a === void 0 ? void 0 : _a[propName];
|
|
258
258
|
if (!extraPropDef)
|
|
259
|
-
throw new SystemError(
|
|
259
|
+
throw new SystemError(SystemErrorKeys.expression.invalidTaxonomyExtraProp, { propName });
|
|
260
260
|
const taxon = yield getOrFetchTaxon({ context, taxonomyUuid: taxonomy.uuid, taxonCode });
|
|
261
261
|
if (!taxon)
|
|
262
262
|
return null;
|
|
@@ -270,15 +270,17 @@ export const nodeDefExpressionFunctions = {
|
|
|
270
270
|
executor: (context) => (taxonomyName, vernacularLangCode, taxonCode) => __awaiter(void 0, void 0, void 0, function* () {
|
|
271
271
|
var _a, _b;
|
|
272
272
|
if (Objects.isEmpty(taxonomyName) || Objects.isEmpty(vernacularLangCode))
|
|
273
|
-
throw new SystemError(
|
|
273
|
+
throw new SystemError(SystemErrorKeys.expression.missingFunctionParameters);
|
|
274
274
|
if (Objects.isEmpty(taxonCode))
|
|
275
275
|
return null;
|
|
276
276
|
const { survey } = context;
|
|
277
277
|
const taxonomy = getTaxonomyByName({ survey, taxonomyName });
|
|
278
278
|
if (!taxonomy)
|
|
279
|
-
throw new SystemError(
|
|
279
|
+
throw new SystemError(SystemErrorKeys.expression.invalidTaxonomyName, { name: taxonomyName });
|
|
280
280
|
if (!LanguagesISO639part2[vernacularLangCode]) {
|
|
281
|
-
throw new SystemError(
|
|
281
|
+
throw new SystemError(SystemErrorKeys.expression.invalidTaxonVernacularNameLanguageCode, {
|
|
282
|
+
vernacularLangCode,
|
|
283
|
+
});
|
|
282
284
|
}
|
|
283
285
|
const taxon = yield getOrFetchTaxon({ context, taxonomyUuid: taxonomy.uuid, taxonCode });
|
|
284
286
|
if (!taxon)
|