@openforis/arena-core 2.5.14 → 2.5.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/error/index.d.ts +1 -0
  2. package/dist/error/index.js +3 -1
  3. package/dist/error/index.js.map +1 -1
  4. package/dist/error/systemErrorKeys.d.ts +52 -0
  5. package/dist/error/systemErrorKeys.js +56 -0
  6. package/dist/error/systemErrorKeys.js.map +1 -0
  7. package/dist/esm/error/index.js +1 -0
  8. package/dist/esm/error/index.js.map +1 -1
  9. package/dist/esm/error/systemErrorKeys.js +53 -0
  10. package/dist/esm/error/systemErrorKeys.js.map +1 -0
  11. package/dist/esm/expression/javascript/evaluator.js +2 -2
  12. package/dist/esm/expression/javascript/evaluator.js.map +1 -1
  13. package/dist/esm/expression/javascript/global.js +2 -2
  14. package/dist/esm/expression/javascript/global.js.map +1 -1
  15. package/dist/esm/expression/javascript/node/array.js +2 -2
  16. package/dist/esm/expression/javascript/node/array.js.map +1 -1
  17. package/dist/esm/expression/javascript/node/binary.js +2 -2
  18. package/dist/esm/expression/javascript/node/binary.js.map +1 -1
  19. package/dist/esm/expression/javascript/node/call.js +5 -5
  20. package/dist/esm/expression/javascript/node/call.js.map +1 -1
  21. package/dist/esm/expression/javascript/node/compound.js +2 -2
  22. package/dist/esm/expression/javascript/node/compound.js.map +1 -1
  23. package/dist/esm/expression/javascript/node/conditional.js +2 -2
  24. package/dist/esm/expression/javascript/node/conditional.js.map +1 -1
  25. package/dist/esm/expression/javascript/node/identifier.js +2 -2
  26. package/dist/esm/expression/javascript/node/identifier.js.map +1 -1
  27. package/dist/esm/expression/javascript/node/this.js +2 -2
  28. package/dist/esm/expression/javascript/node/this.js.map +1 -1
  29. package/dist/esm/expression/javascript/node/unary.js +2 -2
  30. package/dist/esm/expression/javascript/node/unary.js.map +1 -1
  31. package/dist/esm/geo/points/transform.js +5 -5
  32. package/dist/esm/geo/points/transform.js.map +1 -1
  33. package/dist/esm/index.js +1 -1
  34. package/dist/esm/index.js.map +1 -1
  35. package/dist/esm/job/JobBase.js +2 -2
  36. package/dist/esm/job/JobBase.js.map +1 -1
  37. package/dist/esm/nodeDefExpressionEvaluator/functions.js +12 -10
  38. package/dist/esm/nodeDefExpressionEvaluator/functions.js.map +1 -1
  39. package/dist/esm/nodeDefExpressionEvaluator/node/identifier.js +2 -2
  40. package/dist/esm/nodeDefExpressionEvaluator/node/identifier.js.map +1 -1
  41. package/dist/esm/record/_records/recordGetters.js +4 -4
  42. package/dist/esm/record/_records/recordGetters.js.map +1 -1
  43. package/dist/esm/record/recordExpressionEvaluator/node/identifier/identifier.js +6 -6
  44. package/dist/esm/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
  45. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js +2 -1
  46. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js.map +1 -1
  47. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js +2 -1
  48. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
  49. package/dist/esm/record/recordNodesUpdater/recordNodesCreator.js +2 -2
  50. package/dist/esm/record/recordNodesUpdater/recordNodesCreator.js.map +1 -1
  51. package/dist/esm/record/recordUpdater.js +2 -2
  52. package/dist/esm/record/recordUpdater.js.map +1 -1
  53. package/dist/esm/survey/nodeDefsFixer.js +3 -3
  54. package/dist/esm/survey/nodeDefsFixer.js.map +1 -1
  55. package/dist/esm/survey/surveys/nodeDefs.js +5 -5
  56. package/dist/esm/survey/surveys/nodeDefs.js.map +1 -1
  57. package/dist/expression/javascript/evaluator.js +1 -1
  58. package/dist/expression/javascript/evaluator.js.map +1 -1
  59. package/dist/expression/javascript/global.js +1 -1
  60. package/dist/expression/javascript/global.js.map +1 -1
  61. package/dist/expression/javascript/node/array.js +1 -1
  62. package/dist/expression/javascript/node/array.js.map +1 -1
  63. package/dist/expression/javascript/node/binary.js +1 -1
  64. package/dist/expression/javascript/node/binary.js.map +1 -1
  65. package/dist/expression/javascript/node/call.js +4 -4
  66. package/dist/expression/javascript/node/call.js.map +1 -1
  67. package/dist/expression/javascript/node/compound.js +1 -1
  68. package/dist/expression/javascript/node/compound.js.map +1 -1
  69. package/dist/expression/javascript/node/conditional.js +1 -1
  70. package/dist/expression/javascript/node/conditional.js.map +1 -1
  71. package/dist/expression/javascript/node/identifier.js +1 -1
  72. package/dist/expression/javascript/node/identifier.js.map +1 -1
  73. package/dist/expression/javascript/node/this.js +1 -1
  74. package/dist/expression/javascript/node/this.js.map +1 -1
  75. package/dist/expression/javascript/node/unary.js +1 -1
  76. package/dist/expression/javascript/node/unary.js.map +1 -1
  77. package/dist/geo/points/transform.js +4 -4
  78. package/dist/geo/points/transform.js.map +1 -1
  79. package/dist/index.d.ts +1 -1
  80. package/dist/index.js +4 -3
  81. package/dist/index.js.map +1 -1
  82. package/dist/job/JobBase.js +1 -1
  83. package/dist/job/JobBase.js.map +1 -1
  84. package/dist/nodeDefExpressionEvaluator/functions.js +11 -9
  85. package/dist/nodeDefExpressionEvaluator/functions.js.map +1 -1
  86. package/dist/nodeDefExpressionEvaluator/node/identifier.js +1 -1
  87. package/dist/nodeDefExpressionEvaluator/node/identifier.js.map +1 -1
  88. package/dist/record/_records/recordGetters.js +3 -3
  89. package/dist/record/_records/recordGetters.js.map +1 -1
  90. package/dist/record/recordExpressionEvaluator/node/identifier/identifier.js +5 -5
  91. package/dist/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
  92. package/dist/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js +2 -1
  93. package/dist/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js.map +1 -1
  94. package/dist/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js +2 -1
  95. package/dist/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
  96. package/dist/record/recordNodesUpdater/recordNodesCreator.js +1 -1
  97. package/dist/record/recordNodesUpdater/recordNodesCreator.js.map +1 -1
  98. package/dist/record/recordUpdater.js +1 -1
  99. package/dist/record/recordUpdater.js.map +1 -1
  100. package/dist/survey/nodeDefsFixer.js +2 -2
  101. package/dist/survey/nodeDefsFixer.js.map +1 -1
  102. package/dist/survey/surveys/nodeDefs.js +4 -4
  103. package/dist/survey/surveys/nodeDefs.js.map +1 -1
  104. package/package.json +1 -1
@@ -1 +1,2 @@
1
1
  export { SystemError } from './SystemError';
2
+ export { SystemErrorKeys } from './systemErrorKeys';
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SystemError = void 0;
3
+ exports.SystemErrorKeys = exports.SystemError = void 0;
4
4
  var SystemError_1 = require("./SystemError");
5
5
  Object.defineProperty(exports, "SystemError", { enumerable: true, get: function () { return SystemError_1.SystemError; } });
6
+ var systemErrorKeys_1 = require("./systemErrorKeys");
7
+ Object.defineProperty(exports, "SystemErrorKeys", { enumerable: true, get: function () { return systemErrorKeys_1.SystemErrorKeys; } });
6
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAAlC,0GAAA,WAAW,OAAA","sourcesContent":["export { SystemError } from './SystemError'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAAlC,0GAAA,WAAW,OAAA;AACpB,qDAAmD;AAA1C,kHAAA,eAAe,OAAA","sourcesContent":["export { SystemError } from './SystemError'\nexport { SystemErrorKeys } from './systemErrorKeys'\n"]}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Keys of the errors thrown by arena-core as SystemError (translatable, see SystemError.key).
3
+ */
4
+ export declare const SystemErrorKeys: {
5
+ readonly expression: {
6
+ readonly booleanOperatorNotSupported: 'expression.booleanOperatorNotSupported';
7
+ readonly functionHasTooFewArguments: 'expression.functionHasTooFewArguments';
8
+ readonly functionHasTooManyArguments: 'expression.functionHasTooManyArguments';
9
+ readonly identifierNotFound: 'expression.identifierNotFound';
10
+ readonly invalidAttributeValuePropertyName: 'expression.invalidAttributeValuePropertyName';
11
+ readonly invalidCalleeType: 'expression.invalidCalleeType';
12
+ readonly invalidCategoryExtraProp: 'expression.invalidCategoryExtraProp';
13
+ readonly invalidCategoryName: 'expression.invalidCategoryName';
14
+ readonly invalidTaxonVernacularNameLanguageCode: 'expression.invalidTaxonVernacularNameLanguageCode';
15
+ readonly invalidTaxonomyExtraProp: 'expression.invalidTaxonomyExtraProp';
16
+ readonly invalidTaxonomyName: 'expression.invalidTaxonomyName';
17
+ readonly missingFunctionParameters: 'expression.missingFunctionParameters';
18
+ readonly multipleNodesFoundForNodeDef: 'expression.multipleNodesFoundForNodeDef';
19
+ readonly nodeNotFoundForNodeDef: 'expression.nodeNotFoundForNodeDef';
20
+ readonly notSupported: 'expression.notSupported';
21
+ readonly unaryOperatorNotSupported: 'expression.unaryOperatorNotSupported';
22
+ readonly undefinedFunction: 'expression.undefinedFunction';
23
+ readonly unsupportedFunctionType: 'expression.unsupportedFunctionType';
24
+ };
25
+ readonly geo: {
26
+ readonly pointNotFilled: 'geo.pointNotFilled';
27
+ readonly srsNotFound: 'geo.srsNotFound';
28
+ readonly transformFailed: 'geo.transformFailed';
29
+ };
30
+ readonly job: {
31
+ readonly canceledOrErrorsFound: 'jobCanceledOrErrorsFound';
32
+ };
33
+ readonly nodeDef: {
34
+ readonly hierarchyCircularDependency: 'nodeDef.hierarchyCircularDependency';
35
+ readonly parentNotFound: 'nodeDef.parentNotFound';
36
+ };
37
+ readonly record: {
38
+ readonly dependencyOnRootFound: 'record.nodes.dependents.dependencyOnRootFound';
39
+ readonly enumeratorNodeNotFound: 'record.enumeratorNodeNotFound';
40
+ readonly multipleNodesFound: 'systemError.record.multipleNodesFound';
41
+ readonly nodeNotFound: 'record.nodeNotFound';
42
+ readonly nodesIndexNotInitialized: 'record.nodesIndexNotInitialized';
43
+ readonly updateSelfAndDependentsDefaultValues: 'record.updateSelfAndDependentsDefaultValues';
44
+ readonly updateSelfAndDependentsFileNames: 'record.updateSelfAndDependentsFileNames';
45
+ };
46
+ readonly survey: {
47
+ readonly emptyNodeDefs: 'survey.emptyNodeDefs';
48
+ readonly nodeDefNameNotFound: 'survey.nodeDefNameNotFound';
49
+ readonly nodeDefUuidNotFound: 'survey.nodeDefUuidNotFound';
50
+ readonly rootDefNotFound: 'survey.rootDefNotFound';
51
+ };
52
+ };
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SystemErrorKeys = void 0;
4
+ /**
5
+ * Keys of the errors thrown by arena-core as SystemError (translatable, see SystemError.key).
6
+ */
7
+ exports.SystemErrorKeys = {
8
+ expression: {
9
+ booleanOperatorNotSupported: 'expression.booleanOperatorNotSupported',
10
+ functionHasTooFewArguments: 'expression.functionHasTooFewArguments',
11
+ functionHasTooManyArguments: 'expression.functionHasTooManyArguments',
12
+ identifierNotFound: 'expression.identifierNotFound',
13
+ invalidAttributeValuePropertyName: 'expression.invalidAttributeValuePropertyName',
14
+ invalidCalleeType: 'expression.invalidCalleeType',
15
+ invalidCategoryExtraProp: 'expression.invalidCategoryExtraProp',
16
+ invalidCategoryName: 'expression.invalidCategoryName',
17
+ invalidTaxonVernacularNameLanguageCode: 'expression.invalidTaxonVernacularNameLanguageCode',
18
+ invalidTaxonomyExtraProp: 'expression.invalidTaxonomyExtraProp',
19
+ invalidTaxonomyName: 'expression.invalidTaxonomyName',
20
+ missingFunctionParameters: 'expression.missingFunctionParameters',
21
+ multipleNodesFoundForNodeDef: 'expression.multipleNodesFoundForNodeDef',
22
+ nodeNotFoundForNodeDef: 'expression.nodeNotFoundForNodeDef',
23
+ notSupported: 'expression.notSupported',
24
+ unaryOperatorNotSupported: 'expression.unaryOperatorNotSupported',
25
+ undefinedFunction: 'expression.undefinedFunction',
26
+ unsupportedFunctionType: 'expression.unsupportedFunctionType',
27
+ },
28
+ geo: {
29
+ pointNotFilled: 'geo.pointNotFilled',
30
+ srsNotFound: 'geo.srsNotFound',
31
+ transformFailed: 'geo.transformFailed',
32
+ },
33
+ job: {
34
+ canceledOrErrorsFound: 'jobCanceledOrErrorsFound',
35
+ },
36
+ nodeDef: {
37
+ hierarchyCircularDependency: 'nodeDef.hierarchyCircularDependency',
38
+ parentNotFound: 'nodeDef.parentNotFound',
39
+ },
40
+ record: {
41
+ dependencyOnRootFound: 'record.nodes.dependents.dependencyOnRootFound',
42
+ enumeratorNodeNotFound: 'record.enumeratorNodeNotFound',
43
+ multipleNodesFound: 'systemError.record.multipleNodesFound',
44
+ nodeNotFound: 'record.nodeNotFound',
45
+ nodesIndexNotInitialized: 'record.nodesIndexNotInitialized',
46
+ updateSelfAndDependentsDefaultValues: 'record.updateSelfAndDependentsDefaultValues',
47
+ updateSelfAndDependentsFileNames: 'record.updateSelfAndDependentsFileNames',
48
+ },
49
+ survey: {
50
+ emptyNodeDefs: 'survey.emptyNodeDefs',
51
+ nodeDefNameNotFound: 'survey.nodeDefNameNotFound',
52
+ nodeDefUuidNotFound: 'survey.nodeDefUuidNotFound',
53
+ rootDefNotFound: 'survey.rootDefNotFound',
54
+ },
55
+ };
56
+ //# sourceMappingURL=systemErrorKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"systemErrorKeys.js","sourceRoot":"","sources":["../../src/error/systemErrorKeys.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,eAAe,GAAG;IAC7B,UAAU,EAAE;QACV,2BAA2B,EAAE,wCAAwC;QACrE,0BAA0B,EAAE,uCAAuC;QACnE,2BAA2B,EAAE,wCAAwC;QACrE,kBAAkB,EAAE,+BAA+B;QACnD,iCAAiC,EAAE,8CAA8C;QACjF,iBAAiB,EAAE,8BAA8B;QACjD,wBAAwB,EAAE,qCAAqC;QAC/D,mBAAmB,EAAE,gCAAgC;QACrD,sCAAsC,EAAE,mDAAmD;QAC3F,wBAAwB,EAAE,qCAAqC;QAC/D,mBAAmB,EAAE,gCAAgC;QACrD,yBAAyB,EAAE,sCAAsC;QACjE,4BAA4B,EAAE,yCAAyC;QACvE,sBAAsB,EAAE,mCAAmC;QAC3D,YAAY,EAAE,yBAAyB;QACvC,yBAAyB,EAAE,sCAAsC;QACjE,iBAAiB,EAAE,8BAA8B;QACjD,uBAAuB,EAAE,oCAAoC;KAC9D;IACD,GAAG,EAAE;QACH,cAAc,EAAE,oBAAoB;QACpC,WAAW,EAAE,iBAAiB;QAC9B,eAAe,EAAE,qBAAqB;KACvC;IACD,GAAG,EAAE;QACH,qBAAqB,EAAE,0BAA0B;KAClD;IACD,OAAO,EAAE;QACP,2BAA2B,EAAE,qCAAqC;QAClE,cAAc,EAAE,wBAAwB;KACzC;IACD,MAAM,EAAE;QACN,qBAAqB,EAAE,+CAA+C;QACtE,sBAAsB,EAAE,+BAA+B;QACvD,kBAAkB,EAAE,uCAAuC;QAC3D,YAAY,EAAE,qBAAqB;QACnC,wBAAwB,EAAE,iCAAiC;QAC3D,oCAAoC,EAAE,6CAA6C;QACnF,gCAAgC,EAAE,yCAAyC;KAC5E;IACD,MAAM,EAAE;QACN,aAAa,EAAE,sBAAsB;QACrC,mBAAmB,EAAE,4BAA4B;QACjD,mBAAmB,EAAE,4BAA4B;QACjD,eAAe,EAAE,wBAAwB;KAC1C;CACO,CAAA","sourcesContent":["/**\n * Keys of the errors thrown by arena-core as SystemError (translatable, see SystemError.key).\n */\nexport const SystemErrorKeys = {\n expression: {\n booleanOperatorNotSupported: 'expression.booleanOperatorNotSupported',\n functionHasTooFewArguments: 'expression.functionHasTooFewArguments',\n functionHasTooManyArguments: 'expression.functionHasTooManyArguments',\n identifierNotFound: 'expression.identifierNotFound',\n invalidAttributeValuePropertyName: 'expression.invalidAttributeValuePropertyName',\n invalidCalleeType: 'expression.invalidCalleeType',\n invalidCategoryExtraProp: 'expression.invalidCategoryExtraProp',\n invalidCategoryName: 'expression.invalidCategoryName',\n invalidTaxonVernacularNameLanguageCode: 'expression.invalidTaxonVernacularNameLanguageCode',\n invalidTaxonomyExtraProp: 'expression.invalidTaxonomyExtraProp',\n invalidTaxonomyName: 'expression.invalidTaxonomyName',\n missingFunctionParameters: 'expression.missingFunctionParameters',\n multipleNodesFoundForNodeDef: 'expression.multipleNodesFoundForNodeDef',\n nodeNotFoundForNodeDef: 'expression.nodeNotFoundForNodeDef',\n notSupported: 'expression.notSupported',\n unaryOperatorNotSupported: 'expression.unaryOperatorNotSupported',\n undefinedFunction: 'expression.undefinedFunction',\n unsupportedFunctionType: 'expression.unsupportedFunctionType',\n },\n geo: {\n pointNotFilled: 'geo.pointNotFilled',\n srsNotFound: 'geo.srsNotFound',\n transformFailed: 'geo.transformFailed',\n },\n job: {\n canceledOrErrorsFound: 'jobCanceledOrErrorsFound',\n },\n nodeDef: {\n hierarchyCircularDependency: 'nodeDef.hierarchyCircularDependency',\n parentNotFound: 'nodeDef.parentNotFound',\n },\n record: {\n dependencyOnRootFound: 'record.nodes.dependents.dependencyOnRootFound',\n enumeratorNodeNotFound: 'record.enumeratorNodeNotFound',\n multipleNodesFound: 'systemError.record.multipleNodesFound',\n nodeNotFound: 'record.nodeNotFound',\n nodesIndexNotInitialized: 'record.nodesIndexNotInitialized',\n updateSelfAndDependentsDefaultValues: 'record.updateSelfAndDependentsDefaultValues',\n updateSelfAndDependentsFileNames: 'record.updateSelfAndDependentsFileNames',\n },\n survey: {\n emptyNodeDefs: 'survey.emptyNodeDefs',\n nodeDefNameNotFound: 'survey.nodeDefNameNotFound',\n nodeDefUuidNotFound: 'survey.nodeDefUuidNotFound',\n rootDefNotFound: 'survey.rootDefNotFound',\n },\n} as const\n"]}
@@ -1,2 +1,3 @@
1
1
  export { SystemError } from './SystemError';
2
+ export { SystemErrorKeys } from './systemErrorKeys';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/error/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA","sourcesContent":["export { SystemError } from './SystemError'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/error/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA","sourcesContent":["export { SystemError } from './SystemError'\nexport { SystemErrorKeys } from './systemErrorKeys'\n"]}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Keys of the errors thrown by arena-core as SystemError (translatable, see SystemError.key).
3
+ */
4
+ export const SystemErrorKeys = {
5
+ expression: {
6
+ booleanOperatorNotSupported: 'expression.booleanOperatorNotSupported',
7
+ functionHasTooFewArguments: 'expression.functionHasTooFewArguments',
8
+ functionHasTooManyArguments: 'expression.functionHasTooManyArguments',
9
+ identifierNotFound: 'expression.identifierNotFound',
10
+ invalidAttributeValuePropertyName: 'expression.invalidAttributeValuePropertyName',
11
+ invalidCalleeType: 'expression.invalidCalleeType',
12
+ invalidCategoryExtraProp: 'expression.invalidCategoryExtraProp',
13
+ invalidCategoryName: 'expression.invalidCategoryName',
14
+ invalidTaxonVernacularNameLanguageCode: 'expression.invalidTaxonVernacularNameLanguageCode',
15
+ invalidTaxonomyExtraProp: 'expression.invalidTaxonomyExtraProp',
16
+ invalidTaxonomyName: 'expression.invalidTaxonomyName',
17
+ missingFunctionParameters: 'expression.missingFunctionParameters',
18
+ multipleNodesFoundForNodeDef: 'expression.multipleNodesFoundForNodeDef',
19
+ nodeNotFoundForNodeDef: 'expression.nodeNotFoundForNodeDef',
20
+ notSupported: 'expression.notSupported',
21
+ unaryOperatorNotSupported: 'expression.unaryOperatorNotSupported',
22
+ undefinedFunction: 'expression.undefinedFunction',
23
+ unsupportedFunctionType: 'expression.unsupportedFunctionType',
24
+ },
25
+ geo: {
26
+ pointNotFilled: 'geo.pointNotFilled',
27
+ srsNotFound: 'geo.srsNotFound',
28
+ transformFailed: 'geo.transformFailed',
29
+ },
30
+ job: {
31
+ canceledOrErrorsFound: 'jobCanceledOrErrorsFound',
32
+ },
33
+ nodeDef: {
34
+ hierarchyCircularDependency: 'nodeDef.hierarchyCircularDependency',
35
+ parentNotFound: 'nodeDef.parentNotFound',
36
+ },
37
+ record: {
38
+ dependencyOnRootFound: 'record.nodes.dependents.dependencyOnRootFound',
39
+ enumeratorNodeNotFound: 'record.enumeratorNodeNotFound',
40
+ multipleNodesFound: 'systemError.record.multipleNodesFound',
41
+ nodeNotFound: 'record.nodeNotFound',
42
+ nodesIndexNotInitialized: 'record.nodesIndexNotInitialized',
43
+ updateSelfAndDependentsDefaultValues: 'record.updateSelfAndDependentsDefaultValues',
44
+ updateSelfAndDependentsFileNames: 'record.updateSelfAndDependentsFileNames',
45
+ },
46
+ survey: {
47
+ emptyNodeDefs: 'survey.emptyNodeDefs',
48
+ nodeDefNameNotFound: 'survey.nodeDefNameNotFound',
49
+ nodeDefUuidNotFound: 'survey.nodeDefUuidNotFound',
50
+ rootDefNotFound: 'survey.rootDefNotFound',
51
+ },
52
+ };
53
+ //# sourceMappingURL=systemErrorKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"systemErrorKeys.js","sourceRoot":"","sources":["../../../src/error/systemErrorKeys.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,UAAU,EAAE;QACV,2BAA2B,EAAE,wCAAwC;QACrE,0BAA0B,EAAE,uCAAuC;QACnE,2BAA2B,EAAE,wCAAwC;QACrE,kBAAkB,EAAE,+BAA+B;QACnD,iCAAiC,EAAE,8CAA8C;QACjF,iBAAiB,EAAE,8BAA8B;QACjD,wBAAwB,EAAE,qCAAqC;QAC/D,mBAAmB,EAAE,gCAAgC;QACrD,sCAAsC,EAAE,mDAAmD;QAC3F,wBAAwB,EAAE,qCAAqC;QAC/D,mBAAmB,EAAE,gCAAgC;QACrD,yBAAyB,EAAE,sCAAsC;QACjE,4BAA4B,EAAE,yCAAyC;QACvE,sBAAsB,EAAE,mCAAmC;QAC3D,YAAY,EAAE,yBAAyB;QACvC,yBAAyB,EAAE,sCAAsC;QACjE,iBAAiB,EAAE,8BAA8B;QACjD,uBAAuB,EAAE,oCAAoC;KAC9D;IACD,GAAG,EAAE;QACH,cAAc,EAAE,oBAAoB;QACpC,WAAW,EAAE,iBAAiB;QAC9B,eAAe,EAAE,qBAAqB;KACvC;IACD,GAAG,EAAE;QACH,qBAAqB,EAAE,0BAA0B;KAClD;IACD,OAAO,EAAE;QACP,2BAA2B,EAAE,qCAAqC;QAClE,cAAc,EAAE,wBAAwB;KACzC;IACD,MAAM,EAAE;QACN,qBAAqB,EAAE,+CAA+C;QACtE,sBAAsB,EAAE,+BAA+B;QACvD,kBAAkB,EAAE,uCAAuC;QAC3D,YAAY,EAAE,qBAAqB;QACnC,wBAAwB,EAAE,iCAAiC;QAC3D,oCAAoC,EAAE,6CAA6C;QACnF,gCAAgC,EAAE,yCAAyC;KAC5E;IACD,MAAM,EAAE;QACN,aAAa,EAAE,sBAAsB;QACrC,mBAAmB,EAAE,4BAA4B;QACjD,mBAAmB,EAAE,4BAA4B;QACjD,eAAe,EAAE,wBAAwB;KAC1C;CACO,CAAA","sourcesContent":["/**\n * Keys of the errors thrown by arena-core as SystemError (translatable, see SystemError.key).\n */\nexport const SystemErrorKeys = {\n expression: {\n booleanOperatorNotSupported: 'expression.booleanOperatorNotSupported',\n functionHasTooFewArguments: 'expression.functionHasTooFewArguments',\n functionHasTooManyArguments: 'expression.functionHasTooManyArguments',\n identifierNotFound: 'expression.identifierNotFound',\n invalidAttributeValuePropertyName: 'expression.invalidAttributeValuePropertyName',\n invalidCalleeType: 'expression.invalidCalleeType',\n invalidCategoryExtraProp: 'expression.invalidCategoryExtraProp',\n invalidCategoryName: 'expression.invalidCategoryName',\n invalidTaxonVernacularNameLanguageCode: 'expression.invalidTaxonVernacularNameLanguageCode',\n invalidTaxonomyExtraProp: 'expression.invalidTaxonomyExtraProp',\n invalidTaxonomyName: 'expression.invalidTaxonomyName',\n missingFunctionParameters: 'expression.missingFunctionParameters',\n multipleNodesFoundForNodeDef: 'expression.multipleNodesFoundForNodeDef',\n nodeNotFoundForNodeDef: 'expression.nodeNotFoundForNodeDef',\n notSupported: 'expression.notSupported',\n unaryOperatorNotSupported: 'expression.unaryOperatorNotSupported',\n undefinedFunction: 'expression.undefinedFunction',\n unsupportedFunctionType: 'expression.unsupportedFunctionType',\n },\n geo: {\n pointNotFilled: 'geo.pointNotFilled',\n srsNotFound: 'geo.srsNotFound',\n transformFailed: 'geo.transformFailed',\n },\n job: {\n canceledOrErrorsFound: 'jobCanceledOrErrorsFound',\n },\n nodeDef: {\n hierarchyCircularDependency: 'nodeDef.hierarchyCircularDependency',\n parentNotFound: 'nodeDef.parentNotFound',\n },\n record: {\n dependencyOnRootFound: 'record.nodes.dependents.dependencyOnRootFound',\n enumeratorNodeNotFound: 'record.enumeratorNodeNotFound',\n multipleNodesFound: 'systemError.record.multipleNodesFound',\n nodeNotFound: 'record.nodeNotFound',\n nodesIndexNotInitialized: 'record.nodesIndexNotInitialized',\n updateSelfAndDependentsDefaultValues: 'record.updateSelfAndDependentsDefaultValues',\n updateSelfAndDependentsFileNames: 'record.updateSelfAndDependentsFileNames',\n },\n survey: {\n emptyNodeDefs: 'survey.emptyNodeDefs',\n nodeDefNameNotFound: 'survey.nodeDefNameNotFound',\n nodeDefUuidNotFound: 'survey.nodeDefUuidNotFound',\n rootDefNotFound: 'survey.rootDefNotFound',\n },\n} as const\n"]}
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { ExpressionNodeType } from '../node';
11
- import { SystemError } from '../../error';
11
+ import { SystemError, SystemErrorKeys } from '../../error';
12
12
  import { functionsDefault } from './functionsDefault';
13
13
  import { ArrayEvaluator } from './node/array';
14
14
  import { BinaryEvaluator } from './node/binary';
@@ -69,7 +69,7 @@ export class JavascriptExpressionEvaluator {
69
69
  const { type } = expressionNode;
70
70
  const NodeEvaluator = this.evaluators[type];
71
71
  if (!NodeEvaluator) {
72
- throw new SystemError('expression.unsupportedFunctionType', { type });
72
+ throw new SystemError(SystemErrorKeys.expression.unsupportedFunctionType, { type });
73
73
  }
74
74
  return new NodeEvaluator(this, context).evaluate(expressionNode);
75
75
  });
@@ -1 +1 @@
1
- {"version":3,"file":"evaluator.js","sourceRoot":"","sources":["../../../../src/expression/javascript/evaluator.ts"],"names":[],"mappings":";;;;;;;;;AAGA,OAAO,EAAsD,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAA;AAM5D,MAAM,iBAAiB,GAAG;I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C,CAAA;QACrF,CAAC;QACD,sBAAsB,CAAC,GAAG,CAAC,UAAU,EAAE,cAAc,CAAC,CAAA;IACxD,CAAC;IACD,OAAO,cAAc,CAAA;AACvB,CAAC,CAAA;AAED,MAAM,OAAO,6BAA6B;IAIxC,YAAY,SAAS,GAA2B,EAAE,EAAE,UAAU,GAAkB,EAAE;QAChF,IAAI,CAAC,UAAU,mCAAQ,iBAAiB,GAAK,UAAU,CAAE,CAAA;QACzD,IAAI,CAAC,SAAS,mCAAQ,gBAAgB,GAAK,SAAS,CAAE,CAAA;IACxD,CAAC;IAEK,QAAQ,CAAC,UAAkB,EAAE,OAAW;;YAC5C,OAAO,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAK,EAAQ,CAAC,CAAA;QAC7E,CAAC;KAAA;IAEK,YAAY,CAAC,cAAkD,EAAE,OAAU;;YAC/E,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc,CAAA;YAE/B,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;YAC3C,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,MAAM,IAAI,WAAW,CAAC,oCAAoC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;YACvE,CAAC;YACD,OAAO,IAAI,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAA;QAClE,CAAC;KAAA;CACF","sourcesContent":["import { ExpressionContext } from '../context'\nimport { ExpressionEvaluator } from '../evaluator'\nimport { ExpressionFunctions } from '../function'\nimport { ExpressionNode, ExpressionNodeEvaluatorConstructor, ExpressionNodeType } from '../node'\nimport { SystemError } from '../../error'\n\nimport { functionsDefault } from './functionsDefault'\nimport { ArrayEvaluator } from './node/array'\nimport { BinaryEvaluator } from './node/binary'\nimport { CallEvaluator } from './node/call'\nimport { CompoundEvaluator } from './node/compound'\nimport { ConditionalEvaluator } from './node/conditional'\nimport { IdentifierEvaluator } from './node/identifier'\nimport { LiteralEvaluator } from './node/literal'\nimport { MemberEvaluator } from './node/member'\nimport { SequenceEvaluator } from './node/sequence'\nimport { ThisEvaluator } from './node/this'\nimport { UnaryEvaluator } from './node/unary'\nimport { JavascriptExpressionParser } from './parser/parser'\n\ntype Evaluators<C extends ExpressionContext> = {\n [nodeType in ExpressionNodeType]?: ExpressionNodeEvaluatorConstructor<C, ExpressionNode<ExpressionNodeType>>\n}\n\nconst defaultEvaluators = {\n [ExpressionNodeType.Array]: ArrayEvaluator,\n [ExpressionNodeType.Binary]: BinaryEvaluator,\n [ExpressionNodeType.Call]: CallEvaluator,\n [ExpressionNodeType.Compound]: CompoundEvaluator,\n [ExpressionNodeType.Conditional]: ConditionalEvaluator,\n [ExpressionNodeType.Identifier]: IdentifierEvaluator,\n [ExpressionNodeType.Literal]: LiteralEvaluator,\n [ExpressionNodeType.Member]: MemberEvaluator,\n [ExpressionNodeType.Sequence]: SequenceEvaluator,\n [ExpressionNodeType.This]: ThisEvaluator,\n [ExpressionNodeType.Unary]: UnaryEvaluator,\n}\n\n// Parsed expressions cache: the same expressions are evaluated many times (e.g. for every node during a record update).\n// The cached expression nodes are shared, so evaluators must never modify them.\nconst PARSED_EXPRESSIONS_CACHE_MAX_SIZE = 1000\nconst parsedExpressionsCache = new Map<string, ExpressionNode<ExpressionNodeType>>()\nconst expressionParser = new JavascriptExpressionParser()\n\nexport const parseExpression = (expression: string): ExpressionNode<ExpressionNodeType> => {\n let expressionNode = parsedExpressionsCache.get(expression)\n if (!expressionNode) {\n expressionNode = expressionParser.parse(expression)\n if (parsedExpressionsCache.size >= PARSED_EXPRESSIONS_CACHE_MAX_SIZE) {\n // evict the oldest entry (Map keeps insertion order)\n const oldestExpression = parsedExpressionsCache.keys().next().value\n if (oldestExpression !== undefined) parsedExpressionsCache.delete(oldestExpression)\n }\n parsedExpressionsCache.set(expression, expressionNode)\n }\n return expressionNode\n}\n\nexport class JavascriptExpressionEvaluator<C extends ExpressionContext> implements ExpressionEvaluator<C> {\n functions: ExpressionFunctions<C>\n evaluators: Evaluators<C>\n\n constructor(functions: ExpressionFunctions<C> = {}, evaluators: Evaluators<C> = {}) {\n this.evaluators = { ...defaultEvaluators, ...evaluators }\n this.functions = { ...functionsDefault, ...functions }\n }\n\n async evaluate(expression: string, context?: C): Promise<any> {\n return this.evaluateNode(parseExpression(expression), context ?? ({} as C))\n }\n\n async evaluateNode(expressionNode: ExpressionNode<ExpressionNodeType>, context: C): Promise<any> {\n const { type } = expressionNode\n\n const NodeEvaluator = this.evaluators[type]\n if (!NodeEvaluator) {\n throw new SystemError('expression.unsupportedFunctionType', { type })\n }\n return new NodeEvaluator(this, context).evaluate(expressionNode)\n }\n}\n"]}
1
+ {"version":3,"file":"evaluator.js","sourceRoot":"","sources":["../../../../src/expression/javascript/evaluator.ts"],"names":[],"mappings":";;;;;;;;;AAGA,OAAO,EAAsD,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAChG,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,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gB,GAAG,sBAAsB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAA;YACnE,IAAI,gBAAgB,KAAK,SAAS;gBAAE,sBAAsB,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAA;QACrF,CAAC;QACD,sBAAsB,CAAC,GAAG,CAAC,UAAU,EAAE,cAAc,CAAC,CAAA;IACxD,CAAC;IACD,OAAO,cAAc,CAAA;AACvB,CAAC,CAAA;AAED,MAAM,OAAO,6BAA6B;IAIxC,YAAY,SAAS,GAA2B,EAAE,EAAE,UAAU,GAAkB,EAAE;QAChF,IAAI,CAAC,UAAU,mCAAQ,iBAAiB,GAAK,UAAU,CAAE,CAAA;QACzD,IAAI,CAAC,SAAS,mCAAQ,gBAAgB,GAAK,SAAS,CAAE,CAAA;IACxD,CAAC;IAEK,QAAQ,CAAC,UAAkB,EAAE,OAAW;;YAC5C,OAAO,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAK,EAAQ,CAAC,CAAA;QAC7E,CAAC;KAAA;IAEK,YAAY,CAAC,cAAkD,EAAE,OAAU;;YAC/E,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc,CAAA;YAE/B,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;YAC3C,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,MAAM,IAAI,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,uBAAuB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;YACrF,CAAC;YACD,OAAO,IAAI,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAA;QAClE,CAAC;KAAA;CACF","sourcesContent":["import { ExpressionContext } from '../context'\nimport { ExpressionEvaluator } from '../evaluator'\nimport { ExpressionFunctions } from '../function'\nimport { ExpressionNode, ExpressionNodeEvaluatorConstructor, ExpressionNodeType } from '../node'\nimport { SystemError, SystemErrorKeys } from '../../error'\n\nimport { functionsDefault } from './functionsDefault'\nimport { ArrayEvaluator } from './node/array'\nimport { BinaryEvaluator } from './node/binary'\nimport { CallEvaluator } from './node/call'\nimport { CompoundEvaluator } from './node/compound'\nimport { ConditionalEvaluator } from './node/conditional'\nimport { IdentifierEvaluator } from './node/identifier'\nimport { LiteralEvaluator } from './node/literal'\nimport { MemberEvaluator } from './node/member'\nimport { SequenceEvaluator } from './node/sequence'\nimport { ThisEvaluator } from './node/this'\nimport { UnaryEvaluator } from './node/unary'\nimport { JavascriptExpressionParser } from './parser/parser'\n\ntype Evaluators<C extends ExpressionContext> = {\n [nodeType in ExpressionNodeType]?: ExpressionNodeEvaluatorConstructor<C, ExpressionNode<ExpressionNodeType>>\n}\n\nconst defaultEvaluators = {\n [ExpressionNodeType.Array]: ArrayEvaluator,\n [ExpressionNodeType.Binary]: BinaryEvaluator,\n [ExpressionNodeType.Call]: CallEvaluator,\n [ExpressionNodeType.Compound]: CompoundEvaluator,\n [ExpressionNodeType.Conditional]: ConditionalEvaluator,\n [ExpressionNodeType.Identifier]: IdentifierEvaluator,\n [ExpressionNodeType.Literal]: LiteralEvaluator,\n [ExpressionNodeType.Member]: MemberEvaluator,\n [ExpressionNodeType.Sequence]: SequenceEvaluator,\n [ExpressionNodeType.This]: ThisEvaluator,\n [ExpressionNodeType.Unary]: UnaryEvaluator,\n}\n\n// Parsed expressions cache: the same expressions are evaluated many times (e.g. for every node during a record update).\n// The cached expression nodes are shared, so evaluators must never modify them.\nconst PARSED_EXPRESSIONS_CACHE_MAX_SIZE = 1000\nconst parsedExpressionsCache = new Map<string, ExpressionNode<ExpressionNodeType>>()\nconst expressionParser = new JavascriptExpressionParser()\n\nexport const parseExpression = (expression: string): ExpressionNode<ExpressionNodeType> => {\n let expressionNode = parsedExpressionsCache.get(expression)\n if (!expressionNode) {\n expressionNode = expressionParser.parse(expression)\n if (parsedExpressionsCache.size >= PARSED_EXPRESSIONS_CACHE_MAX_SIZE) {\n // evict the oldest entry (Map keeps insertion order)\n const oldestExpression = parsedExpressionsCache.keys().next().value\n if (oldestExpression !== undefined) parsedExpressionsCache.delete(oldestExpression)\n }\n parsedExpressionsCache.set(expression, expressionNode)\n }\n return expressionNode\n}\n\nexport class JavascriptExpressionEvaluator<C extends ExpressionContext> implements ExpressionEvaluator<C> {\n functions: ExpressionFunctions<C>\n evaluators: Evaluators<C>\n\n constructor(functions: ExpressionFunctions<C> = {}, evaluators: Evaluators<C> = {}) {\n this.evaluators = { ...defaultEvaluators, ...evaluators }\n this.functions = { ...functionsDefault, ...functions }\n }\n\n async evaluate(expression: string, context?: C): Promise<any> {\n return this.evaluateNode(parseExpression(expression), context ?? ({} as C))\n }\n\n async evaluateNode(expressionNode: ExpressionNode<ExpressionNodeType>, context: C): Promise<any> {\n const { type } = expressionNode\n\n const NodeEvaluator = this.evaluators[type]\n if (!NodeEvaluator) {\n throw new SystemError(SystemErrorKeys.expression.unsupportedFunctionType, { type })\n }\n return new NodeEvaluator(this, context).evaluate(expressionNode)\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { SystemError } from '../../error';
1
+ import { SystemError, SystemErrorKeys } from '../../error';
2
2
  const globalObjectsDictionary = {
3
3
  Array,
4
4
  Boolean,
@@ -16,7 +16,7 @@ export const getGlobalObjectProperty = (name, object) => {
16
16
  if (object && globalObjectsArray.includes(object)) {
17
17
  const property = object[name];
18
18
  if (!property) {
19
- throw new SystemError('expression.undefinedFunction', { name });
19
+ throw new SystemError(SystemErrorKeys.expression.undefinedFunction, { name });
20
20
  }
21
21
  return property;
22
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"global.js","sourceRoot":"","sources":["../../../../src/expression/javascript/global.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,MAAM,uBAAuB,GAAoB;IAC/C,KAAK;IACL,OAAO;IACP,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,MAAM;CACP,CAAA;AACD,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAA;AAEjE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,IAAY,EAAE,MAAW,EAAO,EAAE;IACxE,MAAM,YAAY,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAA;IAClD,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,YAAY,CAAA;IACrB,CAAC;IACD,IAAI,MAAM,IAAI,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;QAE7B,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,WAAW,CAAC,8BAA8B,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;QACjE,CAAC;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA","sourcesContent":["import { Dictionary } from '../../common'\nimport { SystemError } from '../../error'\n\nconst globalObjectsDictionary: Dictionary<any> = {\n Array,\n Boolean,\n Date,\n Math,\n Number,\n String,\n}\nconst globalObjectsArray = Object.values(globalObjectsDictionary)\n\nexport const getGlobalObjectProperty = (name: string, object: any): any => {\n const globalObject = globalObjectsDictionary[name]\n if (globalObject) {\n return globalObject\n }\n if (object && globalObjectsArray.includes(object)) {\n const property = object[name]\n\n if (!property) {\n throw new SystemError('expression.undefinedFunction', { name })\n }\n return property\n }\n return null\n}\n"]}
1
+ {"version":3,"file":"global.js","sourceRoot":"","sources":["../../../../src/expression/javascript/global.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE1D,MAAM,uBAAuB,GAAoB;IAC/C,KAAK;IACL,OAAO;IACP,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,MAAM;CACP,CAAA;AACD,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAA;AAEjE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,IAAY,EAAE,MAAW,EAAO,EAAE;IACxE,MAAM,YAAY,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAA;IAClD,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,YAAY,CAAA;IACrB,CAAC;IACD,IAAI,MAAM,IAAI,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;QAE7B,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;QAC/E,CAAC;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA","sourcesContent":["import { Dictionary } from '../../common'\nimport { SystemError, SystemErrorKeys } from '../../error'\n\nconst globalObjectsDictionary: Dictionary<any> = {\n Array,\n Boolean,\n Date,\n Math,\n Number,\n String,\n}\nconst globalObjectsArray = Object.values(globalObjectsDictionary)\n\nexport const getGlobalObjectProperty = (name: string, object: any): any => {\n const globalObject = globalObjectsDictionary[name]\n if (globalObject) {\n return globalObject\n }\n if (object && globalObjectsArray.includes(object)) {\n const property = object[name]\n\n if (!property) {\n throw new SystemError(SystemErrorKeys.expression.undefinedFunction, { name })\n }\n return property\n }\n return null\n}\n"]}
@@ -1,8 +1,8 @@
1
- import { SystemError } from '../../../error';
1
+ import { SystemError, SystemErrorKeys } from '../../../error';
2
2
  import { ExpressionNodeEvaluator } from '../../node';
3
3
  export class ArrayEvaluator extends ExpressionNodeEvaluator {
4
4
  evaluate() {
5
- return Promise.reject(new SystemError('expression.notSupported', { type: 'array' }));
5
+ return Promise.reject(new SystemError(SystemErrorKeys.expression.notSupported, { type: 'array' }));
6
6
  }
7
7
  }
8
8
  //# sourceMappingURL=array.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"array.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,EAAmB,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAErE,MAAM,OAAO,cAA4C,SAAQ,uBAA2C;IAC1G,QAAQ;QACN,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,yBAAyB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;IACtF,CAAC;CACF","sourcesContent":["import { SystemError } from '../../../error'\nimport { ExpressionContext } from '../../context'\nimport { ArrayExpression, ExpressionNodeEvaluator } from '../../node'\n\nexport class ArrayEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<C, ArrayExpression> {\n evaluate(): Promise<any> {\n return Promise.reject(new SystemError('expression.notSupported', { type: 'array' }))\n }\n}\n"]}
1
+ {"version":3,"file":"array.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAE7D,OAAO,EAAmB,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAErE,MAAM,OAAO,cAA4C,SAAQ,uBAA2C;IAC1G,QAAQ;QACN,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;IACpG,CAAC;CACF","sourcesContent":["import { SystemError, SystemErrorKeys } from '../../../error'\nimport { ExpressionContext } from '../../context'\nimport { ArrayExpression, ExpressionNodeEvaluator } from '../../node'\n\nexport class ArrayEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<C, ArrayExpression> {\n evaluate(): Promise<any> {\n return Promise.reject(new SystemError(SystemErrorKeys.expression.notSupported, { type: 'array' }))\n }\n}\n"]}
@@ -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 { Objects } from '../../../utils';
12
12
  import { ExpressionNodeEvaluator } from '../../node';
13
13
  const booleanOperators = {
@@ -54,7 +54,7 @@ export class BinaryEvaluator extends ExpressionNodeEvaluator {
54
54
  const { left, right, operator } = expressionNode;
55
55
  const fn = binaryOperators[operator];
56
56
  if (!fn) {
57
- throw new SystemError('expression.booleanOperatorNotSupported', { operator });
57
+ throw new SystemError(SystemErrorKeys.expression.booleanOperatorNotSupported, { operator });
58
58
  }
59
59
  const leftResult = yield this.evaluator.evaluateNode(left, this.context);
60
60
  const rightResult = yield this.evaluator.evaluateNode(right, this.context);
@@ -1 +1 @@
1
- {"version":3,"file":"binary.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/binary.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAoB,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAEtE,MAAM,gBAAgB,GAAwD;IAC5E,4DAA4D;IAC5D,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;IAC/B,4BAA4B;IAC5B,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC;IACvB,IAAI,EAAE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AAoB,EAAE,WAAqB,CAAC,CAAA;gBAC3D,CAAC;gBACD,yEAAyE;YAC3E,CAAC;YAED,2EAA2E;YAC3E,IAAI,QAAQ,IAAI,mBAAmB,EAAE,CAAC;gBACpC,IAAI,QAAQ,CAAC,UAAU,CAAC,IAAI,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;oBAClD,OAAO,EAAE,CAAC,UAAoB,EAAE,WAAqB,CAAC,CAAA;gBACxD,CAAC;gBACD,OAAO,IAAI,CAAA;YACb,CAAC;YAED,MAAM,SAAS,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,CAAC,CAAC,MAAM,CAAA;YAE9G,qBAAqB;YACrB,2DAA2D;YAC3D,yDAAyD;YACzD,gCAAgC;YAChC,4DAA4D;YAC5D,MAAM,OAAO,GAAG,CAAC,QAAQ,KAAK,IAAI,IAAI,SAAS,GAAG,CAAC,CAAC,IAAI,SAAS,KAAK,CAAC,CAAA;YAEvE,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QACrD,CAAC;KAAA;CACF","sourcesContent":["import { SystemError } from '../../../error'\nimport { Objects } from '../../../utils'\nimport { ExpressionContext } from '../../context'\nimport { BinaryExpression, ExpressionNodeEvaluator } from '../../node'\n\nconst booleanOperators: { [operator: string]: (a: any, b: any) => boolean } = {\n // Short-circuiting operators (we coerce the output to bool)\n '||': (a, b) => Boolean(a || b),\n '&&': (a, b) => Boolean(a && b),\n // Normal boolean operators:\n '==': (a, b) => a === b,\n '!=': (a, b) => a !== b,\n '<': (a, b) => a < b,\n '>': (a, b) => a > b,\n '<=': (a, b) => a <= b,\n '>=': (a, b) => a >= b,\n // Only allow one kind of equalities.\n // some hidden dependencies on === and !==...\n // '===': (a, b) => a === b,\n // '!==': (a, b) => a !== b,\n}\n\nconst arithmeticOperators: { [operator: string]: (a: number, b: number) => number } = {\n '+': (a, b) => a + b,\n '-': (a, b) => a - b,\n '*': (a, b) => a * b,\n '/': (a, b) => a / b,\n '%': (a, b) => a % b,\n '**': (a, b) => a ** b,\n // Don't allow bitwise operators:\n // '|': (a, b) => a | b,\n // '^': (a, b) => a ^ b,\n // '&': (a, b) => a & b,\n // Don't allow shifts either:\n // '<<': (a, b) => a << b,\n // '>>': (a, b) => a >> b,\n // '>>>': (a, b) => a >>> b,\n}\n\nconst stringOperators: { [operatos: string]: (a: string, b: string) => string } = {\n '+': (a, b) => a + b,\n}\n\nconst binaryOperators = {\n ...booleanOperators,\n ...arithmeticOperators,\n}\n\nconst isNumber = (value: any) => !Objects.isNil(value) && value.constructor === Number\nconst isString = (value: any) => !Objects.isNil(value) && value.constructor === String\n\nexport class BinaryEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<C, BinaryExpression> {\n async evaluate(expressionNode: BinaryExpression): Promise<any> {\n const { left, right, operator } = expressionNode\n\n const fn = binaryOperators[operator]\n if (!fn) {\n throw new SystemError('expression.booleanOperatorNotSupported', { operator })\n }\n\n const leftResult = await this.evaluator.evaluateNode(left, this.context)\n const rightResult = await this.evaluator.evaluateNode(right, this.context)\n\n // string operators\n if (operator in stringOperators) {\n if (isString(leftResult) || isString(rightResult)) {\n // string concatenation with null or undefined gives null (like arithmetic operations with null)\n if (Objects.isNil(leftResult) || Objects.isNil(rightResult)) {\n return null\n }\n const strFn = stringOperators[operator]\n return strFn(leftResult as string, rightResult as string)\n }\n // operator can be in arithmeticOperators (+), do not return anything now\n }\n\n // Arithmetic operators will always return nulls for any non-numeric inputs\n if (operator in arithmeticOperators) {\n if (isNumber(leftResult) && isNumber(rightResult)) {\n return fn(leftResult as number, rightResult as number)\n }\n return null\n }\n\n const nullCount = [leftResult, rightResult].filter((result) => result === null || result === undefined).length\n\n // Boolean operators:\n // Like ternary logic, but logical OR has special handling.\n // The expression is boolean if either value is not null.\n // Otherwise the result is null.\n // All other operators return null if either operand is null\n const isValid = (operator === '||' && nullCount < 2) || nullCount === 0\n\n return isValid ? fn(leftResult, rightResult) : null\n }\n}\n"]}
1
+ {"version":3,"file":"binary.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/binary.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAoB,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAEtE,MAAM,gBAAgB,GAAwD;IAC5E,4DAA4D;IAC5D,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;IAC/B,4BAA4B;IAC5B,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC;IACvB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC;IACvB,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC;IACpB,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC;IACpB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;IACtB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;IACtB,qCAAqC;IACrC,6CAA6C;IAC7C,6BAA6B;IAC7B,6BAA6B;CAC9B,CAAA;AAED,MAAM,mBAAmB,GAA6D;IACpF,GAAG,EAAE,CAAC,CAA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AAM,CAAA;YAE9G,qBAAqB;YACrB,2DAA2D;YAC3D,yDAAyD;YACzD,gCAAgC;YAChC,4DAA4D;YAC5D,MAAM,OAAO,GAAG,CAAC,QAAQ,KAAK,IAAI,IAAI,SAAS,GAAG,CAAC,CAAC,IAAI,SAAS,KAAK,CAAC,CAAA;YAEvE,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QACrD,CAAC;KAAA;CACF","sourcesContent":["import { SystemError, SystemErrorKeys } from '../../../error'\nimport { Objects } from '../../../utils'\nimport { ExpressionContext } from '../../context'\nimport { BinaryExpression, ExpressionNodeEvaluator } from '../../node'\n\nconst booleanOperators: { [operator: string]: (a: any, b: any) => boolean } = {\n // Short-circuiting operators (we coerce the output to bool)\n '||': (a, b) => Boolean(a || b),\n '&&': (a, b) => Boolean(a && b),\n // Normal boolean operators:\n '==': (a, b) => a === b,\n '!=': (a, b) => a !== b,\n '<': (a, b) => a < b,\n '>': (a, b) => a > b,\n '<=': (a, b) => a <= b,\n '>=': (a, b) => a >= b,\n // Only allow one kind of equalities.\n // some hidden dependencies on === and !==...\n // '===': (a, b) => a === b,\n // '!==': (a, b) => a !== b,\n}\n\nconst arithmeticOperators: { [operator: string]: (a: number, b: number) => number } = {\n '+': (a, b) => a + b,\n '-': (a, b) => a - b,\n '*': (a, b) => a * b,\n '/': (a, b) => a / b,\n '%': (a, b) => a % b,\n '**': (a, b) => a ** b,\n // Don't allow bitwise operators:\n // '|': (a, b) => a | b,\n // '^': (a, b) => a ^ b,\n // '&': (a, b) => a & b,\n // Don't allow shifts either:\n // '<<': (a, b) => a << b,\n // '>>': (a, b) => a >> b,\n // '>>>': (a, b) => a >>> b,\n}\n\nconst stringOperators: { [operatos: string]: (a: string, b: string) => string } = {\n '+': (a, b) => a + b,\n}\n\nconst binaryOperators = {\n ...booleanOperators,\n ...arithmeticOperators,\n}\n\nconst isNumber = (value: any) => !Objects.isNil(value) && value.constructor === Number\nconst isString = (value: any) => !Objects.isNil(value) && value.constructor === String\n\nexport class BinaryEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<C, BinaryExpression> {\n async evaluate(expressionNode: BinaryExpression): Promise<any> {\n const { left, right, operator } = expressionNode\n\n const fn = binaryOperators[operator]\n if (!fn) {\n throw new SystemError(SystemErrorKeys.expression.booleanOperatorNotSupported, { operator })\n }\n\n const leftResult = await this.evaluator.evaluateNode(left, this.context)\n const rightResult = await this.evaluator.evaluateNode(right, this.context)\n\n // string operators\n if (operator in stringOperators) {\n if (isString(leftResult) || isString(rightResult)) {\n // string concatenation with null or undefined gives null (like arithmetic operations with null)\n if (Objects.isNil(leftResult) || Objects.isNil(rightResult)) {\n return null\n }\n const strFn = stringOperators[operator]\n return strFn(leftResult as string, rightResult as string)\n }\n // operator can be in arithmeticOperators (+), do not return anything now\n }\n\n // Arithmetic operators will always return nulls for any non-numeric inputs\n if (operator in arithmeticOperators) {\n if (isNumber(leftResult) && isNumber(rightResult)) {\n return fn(leftResult as number, rightResult as number)\n }\n return null\n }\n\n const nullCount = [leftResult, rightResult].filter((result) => result === null || result === undefined).length\n\n // Boolean operators:\n // Like ternary logic, but logical OR has special handling.\n // The expression is boolean if either value is not null.\n // Otherwise the result is null.\n // All other operators return null if either operand is null\n const isValid = (operator === '||' && nullCount < 2) || nullCount === 0\n\n return isValid ? fn(leftResult, rightResult) : null\n }\n}\n"]}
@@ -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 { ExpressionNodeEvaluator, ExpressionNodeType, } from '../../node';
12
12
  import { getGlobalObjectProperty } from '../global';
13
13
  export class CallEvaluator extends ExpressionNodeEvaluator {
@@ -22,7 +22,7 @@ export class CallEvaluator extends ExpressionNodeEvaluator {
22
22
  }
23
23
  // No complex expressions may be put in place of a function body.
24
24
  // Only a plain identifier is allowed.
25
- throw new SystemError('expression.invalidCalleeType', { type: callee.type });
25
+ throw new SystemError(SystemErrorKeys.expression.invalidCalleeType, { type: callee.type });
26
26
  });
27
27
  }
28
28
  evaluateMember(expressionNode, callee) {
@@ -59,7 +59,7 @@ export class CallEvaluator extends ExpressionNodeEvaluator {
59
59
  const args = yield Promise.all(exprArgs.map((arg) => this.evaluator.evaluateNode(arg, contextArg)));
60
60
  return globalFn(...args);
61
61
  }
62
- throw new SystemError('expression.undefinedFunction', { name: fnName });
62
+ throw new SystemError(SystemErrorKeys.expression.undefinedFunction, { name: fnName });
63
63
  });
64
64
  }
65
65
  evaluateCustomIdentifier(expressionNode, fnName) {
@@ -70,9 +70,9 @@ export class CallEvaluator extends ExpressionNodeEvaluator {
70
70
  const expressionFunction = this.evaluator.functions[fnName];
71
71
  const { minArity, maxArity, evaluateArgsToNodes, executor } = expressionFunction;
72
72
  if (numArgs < minArity)
73
- throw new SystemError('expression.functionHasTooFewArguments', { fnName, minArity, numArgs });
73
+ throw new SystemError(SystemErrorKeys.expression.functionHasTooFewArguments, { fnName, minArity, numArgs });
74
74
  if (maxArity !== undefined && maxArity >= 0 && numArgs > maxArity)
75
- throw new SystemError('expression.functionHasTooManyArguments', { fnName, maxArity, numArgs });
75
+ throw new SystemError(SystemErrorKeys.expression.functionHasTooManyArguments, { fnName, maxArity, numArgs });
76
76
  // evaluate arguments
77
77
  const argsContext = Object.assign(Object.assign({}, this.context), { evaluateToNode: evaluateArgsToNodes });
78
78
  const args = yield Promise.all(exprArgs.map((arg) => this.evaluator.evaluateNode(arg, argsContext)));
@@ -1 +1 @@
1
- {"version":3,"file":"call.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/call.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAG5C,OAAO,EAEL,uBAAuB,EACvB,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AE,MAAM,EAAE,CAAC,CAAA;QACzE,CAAC;KAAA;IAEa,wBAAwB,CAAC,cAA8B,EAAE,MAAc;;YACnF,8CAA8C;YAC9C,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAA;YAC9C,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAA;YAE/B,MAAM,kBAAkB,GAA0B,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;YAElF,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,mBAAmB,EAAE,QAAQ,EAAE,GAAG,kBAAkB,CAAA;YAEhF,IAAI,OAAO,GAAG,QAAQ;gBACpB,MAAM,IAAI,WAAW,CAAC,uCAAuC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAA;YAC/F,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,IAAI,CAAC,IAAI,OAAO,GAAG,QAAQ;gBAC/D,MAAM,IAAI,WAAW,CAAC,wCAAwC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAA;YAEhG,qBAAqB;YACrB,MAAM,WAAW,mCAAQ,IAAI,CAAC,OAAO,KAAE,cAAc,EAAE,mBAAmB,GAAE,CAAA;YAC5E,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAA;YAEpG,uEAAuE;YACvE,wEAAwE;YACxE,sCAAsC;YACtC,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;QACxC,CAAC;KAAA;CACF","sourcesContent":["import { SystemError } from '../../../error'\nimport { ExpressionContext } from '../../context'\nimport { ExpressionFunction } from '../../function'\nimport {\n CallExpression,\n ExpressionNodeEvaluator,\n ExpressionNodeType,\n IdentifierExpression,\n MemberExpression,\n} from '../../node'\nimport { getGlobalObjectProperty } from '../global'\n\nexport class CallEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<C, CallExpression> {\n async evaluate(expressionNode: CallExpression): Promise<any> {\n const { callee } = expressionNode\n\n if (callee.type === ExpressionNodeType.Member) {\n return this.evaluateMember(expressionNode, callee)\n } else if (callee.type === ExpressionNodeType.Identifier) {\n return this.evaluateIdentifier(expressionNode, callee)\n }\n\n // No complex expressions may be put in place of a function body.\n // Only a plain identifier is allowed.\n throw new SystemError('expression.invalidCalleeType', { type: callee.type })\n }\n\n private async evaluateMember(expressionNode: CallExpression, callee: MemberExpression): Promise<any> {\n const { arguments: exprArgs } = expressionNode\n\n // global function (e.g. Math.round(...))\n const fn = await this.evaluator.evaluateNode(callee, this.context)\n if (fn) {\n const { object: calleeObj } = callee\n const fnObject = await this.evaluator.evaluateNode(calleeObj, this.context)\n const argsEvaluated = await Promise.all(exprArgs.map((arg) => this.evaluator.evaluateNode(arg, this.context)))\n const args = argsEvaluated.flat()\n return fn.call(fnObject, ...args)\n }\n return null\n }\n\n private async evaluateIdentifier(expressionNode: CallExpression, callee: IdentifierExpression): Promise<any> {\n // Arguments is a reserved word in strict mode\n const { arguments: exprArgs } = expressionNode\n const { object: contextObject } = this.context\n\n const { name: fnName } = callee\n\n const functionInfo = this.evaluator.functions[fnName]\n if (functionInfo) {\n // The function is among the custom functions.\n return this.evaluateCustomIdentifier(expressionNode, fnName)\n }\n // identifier is a global object\n const globalFn = getGlobalObjectProperty(fnName, contextObject)\n if (globalFn !== null) {\n // global functions like String, Number, must be invoked passing node value as argument, not the node itself\n const contextArg = { ...this.context, evaluateToNode: false }\n const args = await Promise.all(exprArgs.map((arg) => this.evaluator.evaluateNode(arg, contextArg)))\n return globalFn(...args)\n }\n\n throw new SystemError('expression.undefinedFunction', { name: fnName })\n }\n\n private async evaluateCustomIdentifier(expressionNode: CallExpression, fnName: string): Promise<any> {\n // Arguments is a reserved word in strict mode\n const { arguments: exprArgs } = expressionNode\n const numArgs = exprArgs.length\n\n const expressionFunction: ExpressionFunction<C> = this.evaluator.functions[fnName]\n\n const { minArity, maxArity, evaluateArgsToNodes, executor } = expressionFunction\n\n if (numArgs < minArity)\n throw new SystemError('expression.functionHasTooFewArguments', { fnName, minArity, numArgs })\n if (maxArity !== undefined && maxArity >= 0 && numArgs > maxArity)\n throw new SystemError('expression.functionHasTooManyArguments', { fnName, maxArity, numArgs })\n\n // evaluate arguments\n const argsContext = { ...this.context, evaluateToNode: evaluateArgsToNodes }\n const args = await Promise.all(exprArgs.map((arg) => this.evaluator.evaluateNode(arg, argsContext)))\n\n // Currently there are no side effects from function evaluation so it's\n // safe to call the function even when we're just parsing the expression\n // to find all identifiers being used.\n return executor(this.context)(...args)\n }\n}\n"]}
1
+ {"version":3,"file":"call.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/call.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAG7D,OAAO,EAEL,uBAAuB,EACvB,kBAAkB,GAGnB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AAEnD,MAAM,OAAO,aAA2C,SAAQ,uBAA0C;IAClG,QAAQ,CAAC,cAA8B;;YAC3C,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,CAAA;YAEjC,IAAI,MAAM,CAAC,IAAI,KAAK,kBAAkB,CAAC,MAAM,EAAE,CAAC;gBAC9C,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;YACpD,CAAC;iBAAM,IAAI,MAAM,CAAC,IAAI,KAAK,kBAAkB,CAAC,UAAU,EAAE,CAAC;gBACzD,OAAO,IAAI,CAAC,kBAAkB,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;YACxD,CAAC;YAED,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AC,UAAU,CAAC,0BAA0B,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAA;YAC7G,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,IAAI,CAAC,IAAI,OAAO,GAAG,QAAQ;gBAC/D,MAAM,IAAI,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,2BAA2B,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAA;YAE9G,qBAAqB;YACrB,MAAM,WAAW,mCAAQ,IAAI,CAAC,OAAO,KAAE,cAAc,EAAE,mBAAmB,GAAE,CAAA;YAC5E,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAA;YAEpG,uEAAuE;YACvE,wEAAwE;YACxE,sCAAsC;YACtC,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;QACxC,CAAC;KAAA;CACF","sourcesContent":["import { SystemError, SystemErrorKeys } from '../../../error'\nimport { ExpressionContext } from '../../context'\nimport { ExpressionFunction } from '../../function'\nimport {\n CallExpression,\n ExpressionNodeEvaluator,\n ExpressionNodeType,\n IdentifierExpression,\n MemberExpression,\n} from '../../node'\nimport { getGlobalObjectProperty } from '../global'\n\nexport class CallEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<C, CallExpression> {\n async evaluate(expressionNode: CallExpression): Promise<any> {\n const { callee } = expressionNode\n\n if (callee.type === ExpressionNodeType.Member) {\n return this.evaluateMember(expressionNode, callee)\n } else if (callee.type === ExpressionNodeType.Identifier) {\n return this.evaluateIdentifier(expressionNode, callee)\n }\n\n // No complex expressions may be put in place of a function body.\n // Only a plain identifier is allowed.\n throw new SystemError(SystemErrorKeys.expression.invalidCalleeType, { type: callee.type })\n }\n\n private async evaluateMember(expressionNode: CallExpression, callee: MemberExpression): Promise<any> {\n const { arguments: exprArgs } = expressionNode\n\n // global function (e.g. Math.round(...))\n const fn = await this.evaluator.evaluateNode(callee, this.context)\n if (fn) {\n const { object: calleeObj } = callee\n const fnObject = await this.evaluator.evaluateNode(calleeObj, this.context)\n const argsEvaluated = await Promise.all(exprArgs.map((arg) => this.evaluator.evaluateNode(arg, this.context)))\n const args = argsEvaluated.flat()\n return fn.call(fnObject, ...args)\n }\n return null\n }\n\n private async evaluateIdentifier(expressionNode: CallExpression, callee: IdentifierExpression): Promise<any> {\n // Arguments is a reserved word in strict mode\n const { arguments: exprArgs } = expressionNode\n const { object: contextObject } = this.context\n\n const { name: fnName } = callee\n\n const functionInfo = this.evaluator.functions[fnName]\n if (functionInfo) {\n // The function is among the custom functions.\n return this.evaluateCustomIdentifier(expressionNode, fnName)\n }\n // identifier is a global object\n const globalFn = getGlobalObjectProperty(fnName, contextObject)\n if (globalFn !== null) {\n // global functions like String, Number, must be invoked passing node value as argument, not the node itself\n const contextArg = { ...this.context, evaluateToNode: false }\n const args = await Promise.all(exprArgs.map((arg) => this.evaluator.evaluateNode(arg, contextArg)))\n return globalFn(...args)\n }\n\n throw new SystemError(SystemErrorKeys.expression.undefinedFunction, { name: fnName })\n }\n\n private async evaluateCustomIdentifier(expressionNode: CallExpression, fnName: string): Promise<any> {\n // Arguments is a reserved word in strict mode\n const { arguments: exprArgs } = expressionNode\n const numArgs = exprArgs.length\n\n const expressionFunction: ExpressionFunction<C> = this.evaluator.functions[fnName]\n\n const { minArity, maxArity, evaluateArgsToNodes, executor } = expressionFunction\n\n if (numArgs < minArity)\n throw new SystemError(SystemErrorKeys.expression.functionHasTooFewArguments, { fnName, minArity, numArgs })\n if (maxArity !== undefined && maxArity >= 0 && numArgs > maxArity)\n throw new SystemError(SystemErrorKeys.expression.functionHasTooManyArguments, { fnName, maxArity, numArgs })\n\n // evaluate arguments\n const argsContext = { ...this.context, evaluateToNode: evaluateArgsToNodes }\n const args = await Promise.all(exprArgs.map((arg) => this.evaluator.evaluateNode(arg, argsContext)))\n\n // Currently there are no side effects from function evaluation so it's\n // safe to call the function even when we're just parsing the expression\n // to find all identifiers being used.\n return executor(this.context)(...args)\n }\n}\n"]}
@@ -1,8 +1,8 @@
1
- import { SystemError } from '../../../error';
1
+ import { SystemError, SystemErrorKeys } from '../../../error';
2
2
  import { ExpressionNodeEvaluator } from '../../node';
3
3
  export class CompoundEvaluator extends ExpressionNodeEvaluator {
4
4
  evaluate() {
5
- return Promise.reject(new SystemError('expression.notSupported', { type: 'compound' }));
5
+ return Promise.reject(new SystemError(SystemErrorKeys.expression.notSupported, { type: 'compound' }));
6
6
  }
7
7
  }
8
8
  //# sourceMappingURL=compound.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compound.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/compound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,EAAsB,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAExE,MAAM,OAAO,iBAA+C,SAAQ,uBAA8C;IAChH,QAAQ;QACN,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,yBAAyB,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAA;IACzF,CAAC;CACF","sourcesContent":["import { SystemError } from '../../../error'\nimport { ExpressionContext } from '../../context'\nimport { CompoundExpression, ExpressionNodeEvaluator } from '../../node'\n\nexport class CompoundEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<C, CompoundExpression> {\n evaluate(): Promise<any> {\n return Promise.reject(new SystemError('expression.notSupported', { type: 'compound' }))\n }\n}\n"]}
1
+ {"version":3,"file":"compound.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/compound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAE7D,OAAO,EAAsB,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAExE,MAAM,OAAO,iBAA+C,SAAQ,uBAA8C;IAChH,QAAQ;QACN,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAA;IACvG,CAAC;CACF","sourcesContent":["import { SystemError, SystemErrorKeys } from '../../../error'\nimport { ExpressionContext } from '../../context'\nimport { CompoundExpression, ExpressionNodeEvaluator } from '../../node'\n\nexport class CompoundEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<C, CompoundExpression> {\n evaluate(): Promise<any> {\n return Promise.reject(new SystemError(SystemErrorKeys.expression.notSupported, { type: 'compound' }))\n }\n}\n"]}
@@ -1,8 +1,8 @@
1
- import { SystemError } from '../../../error';
1
+ import { SystemError, SystemErrorKeys } from '../../../error';
2
2
  import { ExpressionNodeEvaluator } from '../../node';
3
3
  export class ConditionalEvaluator extends ExpressionNodeEvaluator {
4
4
  evaluate() {
5
- return Promise.reject(new SystemError('expression.notSupported', { type: 'conditional' }));
5
+ return Promise.reject(new SystemError(SystemErrorKeys.expression.notSupported, { type: 'conditional' }));
6
6
  }
7
7
  }
8
8
  //# sourceMappingURL=conditional.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"conditional.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/conditional.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,EAAyB,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAE3E,MAAM,OAAO,oBAAkD,SAAQ,uBAGtE;IACC,QAAQ;QACN,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,yBAAyB,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC,CAAA;IAC5F,CAAC;CACF","sourcesContent":["import { SystemError } from '../../../error'\nimport { ExpressionContext } from '../../context'\nimport { ConditionalExpression, ExpressionNodeEvaluator } from '../../node'\n\nexport class ConditionalEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<\n C,\n ConditionalExpression\n> {\n evaluate(): Promise<any> {\n return Promise.reject(new SystemError('expression.notSupported', { type: 'conditional' }))\n }\n}\n"]}
1
+ {"version":3,"file":"conditional.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/conditional.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAE7D,OAAO,EAAyB,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAE3E,MAAM,OAAO,oBAAkD,SAAQ,uBAGtE;IACC,QAAQ;QACN,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC,CAAA;IAC1G,CAAC;CACF","sourcesContent":["import { SystemError, SystemErrorKeys } from '../../../error'\nimport { ExpressionContext } from '../../context'\nimport { ConditionalExpression, ExpressionNodeEvaluator } from '../../node'\n\nexport class ConditionalEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<\n C,\n ConditionalExpression\n> {\n evaluate(): Promise<any> {\n return Promise.reject(new SystemError(SystemErrorKeys.expression.notSupported, { type: 'conditional' }))\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { SystemError } from '../../../error';
1
+ import { SystemError, SystemErrorKeys } from '../../../error';
2
2
  import { ExpressionNodeEvaluator } from '../../node';
3
3
  import { getGlobalObjectProperty } from '../global';
4
4
  const getNativeProperty = (name, object) => {
@@ -34,7 +34,7 @@ export class IdentifierEvaluator extends ExpressionNodeEvaluator {
34
34
  if (property) {
35
35
  return Promise.resolve(property.value);
36
36
  }
37
- return Promise.reject(new SystemError('expression.identifierNotFound', { name: expressionNode.name }));
37
+ return Promise.reject(new SystemError(SystemErrorKeys.expression.identifierNotFound, { name: expressionNode.name }));
38
38
  }
39
39
  }
40
40
  //# sourceMappingURL=identifier.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,EAAE,uBAAuB,EAAwB,MAAM,YAAY,CAAA;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AAEnD,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,MAAW,EAAE,EAAE;IACtD,MAAM,IAAI,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,IAAI,CAAC,CAAA;IAC3B,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,OAAO,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAC9D,CAAC,CAAA;AAED,MAAM,OAAO,mBAAiD,SAAQ,uBAAgD;IACpH;;;;;;OAMG;IACO,0BAA0B,CAAC,cAAoC;QACvE,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc,CAAA;QAC/B,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,OAAO,CAAA;QAE9C,MAAM,UAAU,GAAG,uBAAuB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAA;QAC/D,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YACxB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAA;QAC9B,CAAC;QACD,MAAM,cAAc,GAAG,iBAAiB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAA;QAC7D,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;YACjC,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,CAAA;QAClC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,QAAQ,CAAC,cAAoC;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,0BAA0B,CAAC,cAAc,CAAC,CAAA;QAChE,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACxC,CAAC;QACD,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,+BAA+B,EAAE,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;IACxG,CAAC;CACF","sourcesContent":["import { SystemError } from '../../../error'\nimport { ExpressionContext } from '../../context'\nimport { ExpressionNodeEvaluator, IdentifierExpression } from '../../node'\nimport { getGlobalObjectProperty } from '../global'\n\nconst getNativeProperty = (name: string, object: any) => {\n const prop = object?.[name]\n if (prop === undefined) {\n return undefined\n }\n return typeof prop === 'function' ? prop.bind(object) : prop\n}\n\nexport class IdentifierEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<C, IdentifierExpression> {\n /**\n * Looks for the identifier among global or native properties, without throwing when it is not found\n * (creating errors captures stack traces, which is expensive when it happens for every evaluated identifier).\n *\n * @param expressionNode - The identifier expression node.\n * @returns The property value wrapped in an object, or null if the identifier has not been found.\n */\n protected findGlobalOrNativeProperty(expressionNode: IdentifierExpression): { value: any } | null {\n const { name } = expressionNode\n const { object: contextObject } = this.context\n\n const globalProp = getGlobalObjectProperty(name, contextObject)\n if (globalProp !== null) {\n return { value: globalProp }\n }\n const nativeProperty = getNativeProperty(name, contextObject)\n if (nativeProperty !== undefined) {\n return { value: nativeProperty }\n }\n return null\n }\n\n evaluate(expressionNode: IdentifierExpression): Promise<any> {\n const property = this.findGlobalOrNativeProperty(expressionNode)\n if (property) {\n return Promise.resolve(property.value)\n }\n return Promise.reject(new SystemError('expression.identifierNotFound', { name: expressionNode.name }))\n }\n}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3C,MAAM,QAAQ,GAAG,IAAI,CAAC,0BAA0B,CAAC,cAAc,CAAC,CAAA;QAChE,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACxC,CAAC;QACD,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;IACtH,CAAC;CACF","sourcesContent":["import { SystemError, SystemErrorKeys } from '../../../error'\nimport { ExpressionContext } from '../../context'\nimport { ExpressionNodeEvaluator, IdentifierExpression } from '../../node'\nimport { getGlobalObjectProperty } from '../global'\n\nconst getNativeProperty = (name: string, object: any) => {\n const prop = object?.[name]\n if (prop === undefined) {\n return undefined\n }\n return typeof prop === 'function' ? prop.bind(object) : prop\n}\n\nexport class IdentifierEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<C, IdentifierExpression> {\n /**\n * Looks for the identifier among global or native properties, without throwing when it is not found\n * (creating errors captures stack traces, which is expensive when it happens for every evaluated identifier).\n *\n * @param expressionNode - The identifier expression node.\n * @returns The property value wrapped in an object, or null if the identifier has not been found.\n */\n protected findGlobalOrNativeProperty(expressionNode: IdentifierExpression): { value: any } | null {\n const { name } = expressionNode\n const { object: contextObject } = this.context\n\n const globalProp = getGlobalObjectProperty(name, contextObject)\n if (globalProp !== null) {\n return { value: globalProp }\n }\n const nativeProperty = getNativeProperty(name, contextObject)\n if (nativeProperty !== undefined) {\n return { value: nativeProperty }\n }\n return null\n }\n\n evaluate(expressionNode: IdentifierExpression): Promise<any> {\n const property = this.findGlobalOrNativeProperty(expressionNode)\n if (property) {\n return Promise.resolve(property.value)\n }\n return Promise.reject(new SystemError(SystemErrorKeys.expression.identifierNotFound, { name: expressionNode.name }))\n }\n}\n"]}
@@ -1,8 +1,8 @@
1
- import { SystemError } from '../../../error';
1
+ import { SystemError, SystemErrorKeys } from '../../../error';
2
2
  import { ExpressionNodeEvaluator } from '../../node';
3
3
  export class ThisEvaluator extends ExpressionNodeEvaluator {
4
4
  evaluate() {
5
- return Promise.reject(new SystemError('expression.notSupported', { type: 'this' }));
5
+ return Promise.reject(new SystemError(SystemErrorKeys.expression.notSupported, { type: 'this' }));
6
6
  }
7
7
  }
8
8
  //# sourceMappingURL=this.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"this.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/this.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,EAAE,uBAAuB,EAAkB,MAAM,YAAY,CAAA;AAEpE,MAAM,OAAO,aAA2C,SAAQ,uBAA0C;IACxG,QAAQ;QACN,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,yBAAyB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;IACrF,CAAC;CACF","sourcesContent":["import { SystemError } from '../../../error'\nimport { ExpressionContext } from '../../context'\nimport { ExpressionNodeEvaluator, ThisExpression } from '../../node'\n\nexport class ThisEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<C, ThisExpression> {\n evaluate(): Promise<any> {\n return Promise.reject(new SystemError('expression.notSupported', { type: 'this' }))\n }\n}\n"]}
1
+ {"version":3,"file":"this.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/this.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAE7D,OAAO,EAAE,uBAAuB,EAAkB,MAAM,YAAY,CAAA;AAEpE,MAAM,OAAO,aAA2C,SAAQ,uBAA0C;IACxG,QAAQ;QACN,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;IACnG,CAAC;CACF","sourcesContent":["import { SystemError, SystemErrorKeys } from '../../../error'\nimport { ExpressionContext } from '../../context'\nimport { ExpressionNodeEvaluator, ThisExpression } from '../../node'\n\nexport class ThisEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<C, ThisExpression> {\n evaluate(): Promise<any> {\n return Promise.reject(new SystemError(SystemErrorKeys.expression.notSupported, { type: 'this' }))\n }\n}\n"]}
@@ -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 { ExpressionNodeEvaluator } from '../../node';
12
12
  const unaryOperators = {
13
13
  // Only accept bools and nulls as input.
@@ -27,7 +27,7 @@ export class UnaryEvaluator extends ExpressionNodeEvaluator {
27
27
  const { argument, operator } = expressionNode;
28
28
  const fn = unaryOperators[operator];
29
29
  if (!fn) {
30
- throw new SystemError('expression.unaryOperatorNotSupported', { operator });
30
+ throw new SystemError(SystemErrorKeys.expression.unaryOperatorNotSupported, { operator });
31
31
  }
32
32
  const res = yield this.evaluator.evaluateNode(argument, this.context);
33
33
  return fn(res);
@@ -1 +1 @@
1
- {"version":3,"file":"unary.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/unary.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,EAAE,uBAAuB,EAAmB,MAAM,YAAY,CAAA;AAErE,MAAM,cAAc,GAAuC;IACzD,wCAAwC;IACxC,wBAAwB;IACxB,GAAG,EAAE,CAAC,CAAM,EAAkB,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAEzG,qEAAqE;IACrE,yDAAyD;IACzD,GAAG,EAAE,CAAC,CAAM,EAAiB,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAEhE,uEAAuE;IACvE,wDAAwD;IACxD,uDAAuD;IACvD,oCAAoC;CACrC,CAAA;AAED,MAAM,OAAO,cAA4C,SAAQ,uBAA2C;IACpG,QAAQ,CAAC,cAA+B;;YAC5C,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAA;YAC7C,MAAM,EAAE,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAA;YAEnC,IAAI,CAAC,EAAE,EAAE,CAAC;gBACR,MAAM,IAAI,WAAW,CAAC,sCAAsC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;YAC7E,CAAC;YAED,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;YACrE,OAAO,EAAE,CAAC,GAAG,CAAC,CAAA;QAChB,CAAC;KAAA;CACF","sourcesContent":["import { SystemError } from '../../../error'\nimport { ExpressionContext } from '../../context'\nimport { ExpressionNodeEvaluator, UnaryExpression } from '../../node'\n\nconst unaryOperators: { [key: string]: (x: any) => any } = {\n // Only accept bools and nulls as input.\n // Otherwise return null\n '!': (x: any): boolean | null => (x === null || x === undefined || x.constructor === Boolean ? !x : null),\n\n // Negation: Only accept normal finite numbers, otherwise return null\n // NOTE: Under JS semantics, we would have -\"123\" -> -123\n '-': (x: any): number | null => (Number.isFinite(x) ? -x : null),\n\n // Don't allow the unary + operator now. Define semantics for it first.\n // Under JS semantics, \"+\" coerces a string to a number.\n // Maybe we should just have `parseNumber` in `stdlib`?\n // '+': x => R.isNil(x) ? null : +x,\n}\n\nexport class UnaryEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<C, UnaryExpression> {\n async evaluate(expressionNode: UnaryExpression): Promise<any> {\n const { argument, operator } = expressionNode\n const fn = unaryOperators[operator]\n\n if (!fn) {\n throw new SystemError('expression.unaryOperatorNotSupported', { operator })\n }\n\n const res = await this.evaluator.evaluateNode(argument, this.context)\n return fn(res)\n }\n}\n"]}
1
+ {"version":3,"file":"unary.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/unary.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAE7D,OAAO,EAAE,uBAAuB,EAAmB,MAAM,YAAY,CAAA;AAErE,MAAM,cAAc,GAAuC;IACzD,wCAAwC;IACxC,wBAAwB;IACxB,GAAG,EAAE,CAAC,CAAM,EAAkB,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAEzG,qEAAqE;IACrE,yDAAyD;IACzD,GAAG,EAAE,CAAC,CAAM,EAAiB,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAEhE,uEAAuE;IACvE,wDAAwD;IACxD,uDAAuD;IACvD,oCAAoC;CACrC,CAAA;AAED,MAAM,OAAO,cAA4C,SAAQ,uBAA2C;IACpG,QAAQ,CAAC,cAA+B;;YAC5C,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAA;YAC7C,MAAM,EAAE,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAA;YAEnC,IAAI,CAAC,EAAE,EAAE,CAAC;gBACR,MAAM,IAAI,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,yBAAyB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;YAC3F,CAAC;YAED,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;YACrE,OAAO,EAAE,CAAC,GAAG,CAAC,CAAA;QAChB,CAAC;KAAA;CACF","sourcesContent":["import { SystemError, SystemErrorKeys } from '../../../error'\nimport { ExpressionContext } from '../../context'\nimport { ExpressionNodeEvaluator, UnaryExpression } from '../../node'\n\nconst unaryOperators: { [key: string]: (x: any) => any } = {\n // Only accept bools and nulls as input.\n // Otherwise return null\n '!': (x: any): boolean | null => (x === null || x === undefined || x.constructor === Boolean ? !x : null),\n\n // Negation: Only accept normal finite numbers, otherwise return null\n // NOTE: Under JS semantics, we would have -\"123\" -> -123\n '-': (x: any): number | null => (Number.isFinite(x) ? -x : null),\n\n // Don't allow the unary + operator now. Define semantics for it first.\n // Under JS semantics, \"+\" coerces a string to a number.\n // Maybe we should just have `parseNumber` in `stdlib`?\n // '+': x => R.isNil(x) ? null : +x,\n}\n\nexport class UnaryEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<C, UnaryExpression> {\n async evaluate(expressionNode: UnaryExpression): Promise<any> {\n const { argument, operator } = expressionNode\n const fn = unaryOperators[operator]\n\n if (!fn) {\n throw new SystemError(SystemErrorKeys.expression.unaryOperatorNotSupported, { operator })\n }\n\n const res = await this.evaluator.evaluateNode(argument, this.context)\n return fn(res)\n }\n}\n"]}