@openforis/arena-core 2.15.0 → 2.16.1

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 (74) hide show
  1. package/dist/error/systemErrorKeys.d.ts +1 -0
  2. package/dist/error/systemErrorKeys.js +1 -0
  3. package/dist/error/systemErrorKeys.js.map +1 -1
  4. package/dist/esm/error/systemErrorKeys.js +1 -0
  5. package/dist/esm/error/systemErrorKeys.js.map +1 -1
  6. package/dist/esm/expression/javascript/global.js +3 -1
  7. package/dist/esm/expression/javascript/global.js.map +1 -1
  8. package/dist/esm/expression/javascript/node/identifier.js +4 -1
  9. package/dist/esm/expression/javascript/node/identifier.js.map +1 -1
  10. package/dist/esm/geo/areaOfInterest.js.map +1 -1
  11. package/dist/esm/geo/index.js.map +1 -1
  12. package/dist/esm/index.js.map +1 -1
  13. package/dist/esm/nodeDefExpressionEvaluator/areaOfInterestProvider.js +2 -0
  14. package/dist/esm/nodeDefExpressionEvaluator/areaOfInterestProvider.js.map +1 -0
  15. package/dist/esm/nodeDefExpressionEvaluator/context.js.map +1 -1
  16. package/dist/esm/nodeDefExpressionEvaluator/functions.js +45 -8
  17. package/dist/esm/nodeDefExpressionEvaluator/functions.js.map +1 -1
  18. package/dist/esm/nodeDefExpressionEvaluator/index.js.map +1 -1
  19. package/dist/esm/nodeDefExpressionEvaluator/node/identifier.js +4 -1
  20. package/dist/esm/nodeDefExpressionEvaluator/node/identifier.js.map +1 -1
  21. package/dist/esm/record/recordExpressionEvaluator/context.js.map +1 -1
  22. package/dist/esm/record/recordExpressionEvaluator/node/identifier/identifier.js +4 -0
  23. package/dist/esm/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
  24. package/dist/esm/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
  25. package/dist/esm/record/recordNodesUpdater/recordExpressionEvaluationContext.js.map +1 -1
  26. package/dist/esm/record/recordValidator/attributeValidator.js +2 -1
  27. package/dist/esm/record/recordValidator/attributeValidator.js.map +1 -1
  28. package/dist/esm/survey/survey.js.map +1 -1
  29. package/dist/esm/survey/surveys/index.js +3 -2
  30. package/dist/esm/survey/surveys/index.js.map +1 -1
  31. package/dist/esm/survey/surveys/surveysGetters.js +3 -2
  32. package/dist/esm/survey/surveys/surveysGetters.js.map +1 -1
  33. package/dist/expression/javascript/global.d.ts +1 -0
  34. package/dist/expression/javascript/global.js +5 -2
  35. package/dist/expression/javascript/global.js.map +1 -1
  36. package/dist/expression/javascript/node/identifier.js +3 -0
  37. package/dist/expression/javascript/node/identifier.js.map +1 -1
  38. package/dist/geo/areaOfInterest.d.ts +14 -1
  39. package/dist/geo/areaOfInterest.js.map +1 -1
  40. package/dist/geo/index.d.ts +1 -1
  41. package/dist/geo/index.js.map +1 -1
  42. package/dist/index.d.ts +2 -2
  43. package/dist/index.js.map +1 -1
  44. package/dist/nodeDefExpressionEvaluator/areaOfInterestProvider.d.ts +11 -0
  45. package/dist/nodeDefExpressionEvaluator/areaOfInterestProvider.js +3 -0
  46. package/dist/nodeDefExpressionEvaluator/areaOfInterestProvider.js.map +1 -0
  47. package/dist/nodeDefExpressionEvaluator/context.d.ts +2 -0
  48. package/dist/nodeDefExpressionEvaluator/context.js.map +1 -1
  49. package/dist/nodeDefExpressionEvaluator/functions.js +44 -7
  50. package/dist/nodeDefExpressionEvaluator/functions.js.map +1 -1
  51. package/dist/nodeDefExpressionEvaluator/index.d.ts +1 -0
  52. package/dist/nodeDefExpressionEvaluator/index.js.map +1 -1
  53. package/dist/nodeDefExpressionEvaluator/node/identifier.js +3 -0
  54. package/dist/nodeDefExpressionEvaluator/node/identifier.js.map +1 -1
  55. package/dist/record/recordExpressionEvaluator/context.d.ts +2 -0
  56. package/dist/record/recordExpressionEvaluator/context.js.map +1 -1
  57. package/dist/record/recordExpressionEvaluator/node/identifier/identifier.js +4 -0
  58. package/dist/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
  59. package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.d.ts +2 -0
  60. package/dist/record/recordExpressionEvaluator/recordExpressionEvaluator.js.map +1 -1
  61. package/dist/record/recordNodesUpdater/recordExpressionEvaluationContext.d.ts +2 -0
  62. package/dist/record/recordNodesUpdater/recordExpressionEvaluationContext.js.map +1 -1
  63. package/dist/record/recordValidator/attributeValidator.d.ts +2 -0
  64. package/dist/record/recordValidator/attributeValidator.js +2 -1
  65. package/dist/record/recordValidator/attributeValidator.js.map +1 -1
  66. package/dist/survey/survey.d.ts +2 -2
  67. package/dist/survey/survey.js.map +1 -1
  68. package/dist/survey/surveys/index.d.ts +3 -2
  69. package/dist/survey/surveys/index.js +2 -1
  70. package/dist/survey/surveys/index.js.map +1 -1
  71. package/dist/survey/surveys/surveysGetters.d.ts +6 -2
  72. package/dist/survey/surveys/surveysGetters.js +6 -4
  73. package/dist/survey/surveys/surveysGetters.js.map +1 -1
  74. package/package.json +1 -1
@@ -3,6 +3,7 @@
3
3
  */
4
4
  export declare const SystemErrorKeys: {
5
5
  readonly expression: {
6
+ readonly areaOfInterestNotFound: 'expression.areaOfInterestNotFound';
6
7
  readonly booleanOperatorNotSupported: 'expression.booleanOperatorNotSupported';
7
8
  readonly functionHasTooFewArguments: 'expression.functionHasTooFewArguments';
8
9
  readonly functionHasTooManyArguments: 'expression.functionHasTooManyArguments';
@@ -6,6 +6,7 @@ exports.SystemErrorKeys = void 0;
6
6
  */
7
7
  exports.SystemErrorKeys = {
8
8
  expression: {
9
+ areaOfInterestNotFound: 'expression.areaOfInterestNotFound',
9
10
  booleanOperatorNotSupported: 'expression.booleanOperatorNotSupported',
10
11
  functionHasTooFewArguments: 'expression.functionHasTooFewArguments',
11
12
  functionHasTooManyArguments: 'expression.functionHasTooManyArguments',
@@ -1 +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
+ {"version":3,"file":"systemErrorKeys.js","sourceRoot":"","sources":["../../src/error/systemErrorKeys.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,eAAe,GAAG;IAC7B,UAAU,EAAE;QACV,sBAAsB,EAAE,mCAAmC;QAC3D,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 areaOfInterestNotFound: 'expression.areaOfInterestNotFound',\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"]}
@@ -3,6 +3,7 @@
3
3
  */
4
4
  export const SystemErrorKeys = {
5
5
  expression: {
6
+ areaOfInterestNotFound: 'expression.areaOfInterestNotFound',
6
7
  booleanOperatorNotSupported: 'expression.booleanOperatorNotSupported',
7
8
  functionHasTooFewArguments: 'expression.functionHasTooFewArguments',
8
9
  functionHasTooManyArguments: 'expression.functionHasTooManyArguments',
@@ -1 +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"]}
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,sBAAsB,EAAE,mCAAmC;QAC3D,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 areaOfInterestNotFound: 'expression.areaOfInterestNotFound',\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,13 +8,15 @@ const globalObjectsDictionary = {
8
8
  String,
9
9
  };
10
10
  const globalObjectsArray = Object.values(globalObjectsDictionary);
11
+ // properties leading to Object, Function or the prototypes would let an expression run arbitrary code
12
+ export const isForbiddenPropertyName = (name) => name === 'constructor' || name === 'prototype' || name.startsWith('__');
11
13
  export const getGlobalObjectProperty = (name, object) => {
12
14
  const globalObject = globalObjectsDictionary[name];
13
15
  if (globalObject) {
14
16
  return globalObject;
15
17
  }
16
18
  if (object && globalObjectsArray.includes(object)) {
17
- const property = object[name];
19
+ const property = isForbiddenPropertyName(name) ? undefined : object[name];
18
20
  if (!property) {
19
21
  throw new SystemError(SystemErrorKeys.expression.undefinedFunction, { name });
20
22
  }
@@ -1 +1 @@
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
+ {"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,sGAAsG;AACtG,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,IAAY,EAAW,EAAE,CAC/D,IAAI,KAAK,aAAa,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AAEzE,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,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAEzE,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\n// properties leading to Object, Function or the prototypes would let an expression run arbitrary code\nexport const isForbiddenPropertyName = (name: string): boolean =>\n name === 'constructor' || name === 'prototype' || name.startsWith('__')\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 = isForbiddenPropertyName(name) ? undefined : 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,7 +1,10 @@
1
1
  import { SystemError, SystemErrorKeys } from '../../../error';
2
2
  import { ExpressionNodeEvaluator } from '../../node';
3
- import { getGlobalObjectProperty } from '../global';
3
+ import { getGlobalObjectProperty, isForbiddenPropertyName } from '../global';
4
4
  const getNativeProperty = (name, object) => {
5
+ if (isForbiddenPropertyName(name)) {
6
+ return undefined;
7
+ }
5
8
  const prop = object === null || object === void 0 ? void 0 : object[name];
6
9
  if (prop === undefined) {
7
10
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAA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AAQ,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
+ {"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAE7D,OAAO,EAAE,uBAAuB,EAA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Q,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, isForbiddenPropertyName } from '../global'\n\nconst getNativeProperty = (name: string, object: any) => {\n if (isForbiddenPropertyName(name)) {\n return undefined\n }\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 +1 @@
1
- {"version":3,"file":"areaOfInterest.js","sourceRoot":"","sources":["../../../src/geo/areaOfInterest.ts"],"names":[],"mappings":"","sourcesContent":["import type { MultiPolygon, Polygon } from 'geojson'\n\n/**\n * Area of interest of a survey: GeoJSON polygon or multi polygon geometry in WGS84 (EPSG:4326).\n */\nexport type AreaOfInterest = Polygon | MultiPolygon\n"]}
1
+ {"version":3,"file":"areaOfInterest.js","sourceRoot":"","sources":["../../../src/geo/areaOfInterest.ts"],"names":[],"mappings":"","sourcesContent":["import type { MultiPolygon, Polygon } from 'geojson'\n\nimport type { Labels } from '../language'\n\n/**\n * Area of interest geometry: GeoJSON polygon or multi polygon in WGS84 (EPSG:4326).\n */\nexport type AreaOfInterest = Polygon | MultiPolygon\n\n/**\n * Area of interest defined in a survey; the geometry is stored in a separate file (fetched by AreaOfInterestProvider).\n */\nexport interface AreaOfInterestDescriptor {\n // identifier used in expressions\n name: string\n labels?: Labels\n fileUuid: string\n fileName: string\n size: number\n polygons: number\n vertices: number\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/geo/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA","sourcesContent":["export type { AreaOfInterest } from './areaOfInterest'\nexport type { Point } from './point'\n\nexport { PointFactory } from './pointFactory'\n\nexport { Points } from './points'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/geo/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA","sourcesContent":["export type { AreaOfInterest, AreaOfInterestDescriptor } from './areaOfInterest'\nexport type { Point } from './point'\n\nexport { PointFactory } from './pointFactory'\n\nexport { Points } from './points'\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAA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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 ArenaExportFile,\n ArenaExportInfoFactory,\n ArenaExportType,\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 { AreaOfInterest, 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 NodeDefGeo,\n NodeDefGeoProps,\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"]}
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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B,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 ArenaExportFile,\n ArenaExportInfoFactory,\n ArenaExportType,\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 { AreaOfInterest, AreaOfInterestDescriptor, 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 { AreaOfInterestProvider, 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 NodeDefGeo,\n NodeDefGeoProps,\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"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=areaOfInterestProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"areaOfInterestProvider.js","sourceRoot":"","sources":["../../../src/nodeDefExpressionEvaluator/areaOfInterestProvider.ts"],"names":[],"mappings":"","sourcesContent":["import type { AreaOfInterest } from '../geo'\nimport { Survey } from '../survey'\n\n/**\n * Fetches the geometry of the areas of interest of a survey: they are stored outside the survey (e.g. in files).\n */\nexport interface AreaOfInterestProvider {\n getAreaOfInterest: (params: { survey: Survey; name: string }) => Promise<AreaOfInterest | undefined>\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/nodeDefExpressionEvaluator/context.ts"],"names":[],"mappings":"","sourcesContent":["import { User } from '../auth'\nimport { ExpressionContext } from '../expression'\nimport { NodeDef } from '../nodeDef'\nimport { NodeDefProps, NodeDefType } from '../nodeDef/nodeDef'\nimport { Survey } from '../survey'\nimport { CategoryItemProvider } from './categoryItemProvider'\nimport { TaxonProvider } from './taxonProvider'\n\nexport interface NodeDefExpressionContext extends ExpressionContext {\n survey: Survey\n user?: User\n nodeDefCurrent: NodeDef<NodeDefType, NodeDefProps>\n nodeDefContext?: NodeDef<NodeDefType, NodeDefProps>\n /**\n * Unique UUIDs of node definitions being visited during expression evaluation.\n */\n referencedNodeDefUuids?: Set<string>\n selfReferenceAllowed?: boolean\n // true when the expression is used to filter code or taxon items\n itemsFilter?: boolean\n // true when evaluating the property of a member expression (e.g. \"length\" in \"text_attr.length\")\n memberProperty?: boolean\n\n categoryItemProvider?: CategoryItemProvider\n taxonProvider?: TaxonProvider\n}\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/nodeDefExpressionEvaluator/context.ts"],"names":[],"mappings":"","sourcesContent":["import { User } from '../auth'\nimport { ExpressionContext } from '../expression'\nimport { NodeDef } from '../nodeDef'\nimport { NodeDefProps, NodeDefType } from '../nodeDef/nodeDef'\nimport { Survey } from '../survey'\nimport { AreaOfInterestProvider } from './areaOfInterestProvider'\nimport { CategoryItemProvider } from './categoryItemProvider'\nimport { TaxonProvider } from './taxonProvider'\n\nexport interface NodeDefExpressionContext extends ExpressionContext {\n survey: Survey\n user?: User\n nodeDefCurrent: NodeDef<NodeDefType, NodeDefProps>\n nodeDefContext?: NodeDef<NodeDefType, NodeDefProps>\n /**\n * Unique UUIDs of node definitions being visited during expression evaluation.\n */\n referencedNodeDefUuids?: Set<string>\n selfReferenceAllowed?: boolean\n // true when the expression is used to filter code or taxon items\n itemsFilter?: boolean\n // true when evaluating the property of a member expression (e.g. \"length\" in \"text_attr.length\")\n memberProperty?: boolean\n\n categoryItemProvider?: CategoryItemProvider\n taxonProvider?: TaxonProvider\n areaOfInterestProvider?: AreaOfInterestProvider\n}\n"]}
@@ -14,7 +14,7 @@ import { Points } from '../geo';
14
14
  import { LanguagesISO639part2 } from '../language';
15
15
  import { getNodeDefParent } from '../survey/surveys/nodeDefs';
16
16
  import { getCategoryItemByCodePaths, getTaxonByCode } from '../survey/surveys/refsData';
17
- import { getAreaOfInterest, getCategoryByName, getSRSIndex, getTaxonomyByName } from '../survey/surveys/surveysGetters';
17
+ import { getAreaOfInterestByName, getAreasOfInterest, getCategoryByName, getSRSIndex, getTaxonomyByName, } from '../survey/surveys/surveysGetters';
18
18
  import { Dates, Numbers, Objects } from '../utils';
19
19
  const sampleGeoJsonPolygon = {
20
20
  type: 'Feature',
@@ -65,6 +65,28 @@ const getOrFetchTaxon = (params) => __awaiter(void 0, void 0, void 0, function*
65
65
  const draft = !record || !!record.preview;
66
66
  return taxon !== null && taxon !== void 0 ? taxon : taxonProvider === null || taxonProvider === void 0 ? void 0 : taxonProvider.getTaxonByCode({ survey, taxonomyUuid, taxonCode, draft });
67
67
  });
68
+ const fetchAreaOfInterest = (params) => __awaiter(void 0, void 0, void 0, function* () {
69
+ const { context, name } = params;
70
+ const { survey, areaOfInterestProvider } = context;
71
+ if (!areaOfInterestProvider || !getAreaOfInterestByName({ survey, name }))
72
+ return undefined;
73
+ return areaOfInterestProvider.getAreaOfInterest({ survey, name });
74
+ });
75
+ // expression validation (no record): a literal area name must be defined in the survey
76
+ const validateAreaOfInterestName = (params) => {
77
+ const { context, name } = params;
78
+ const record = context.record;
79
+ if (!record && typeof name === 'string' && !getAreaOfInterestByName({ survey: context.survey, name })) {
80
+ throw new SystemError(SystemErrorKeys.expression.areaOfInterestNotFound, { name });
81
+ }
82
+ };
83
+ const distanceToAreaOfInterestBoundary = (params) => __awaiter(void 0, void 0, void 0, function* () {
84
+ const { context, point, name } = params;
85
+ const areaOfInterest = yield fetchAreaOfInterest({ context, name });
86
+ if (!areaOfInterest)
87
+ return null;
88
+ return Points.distanceToPolygonBoundary(point, areaOfInterest, getSRSIndex(context.survey));
89
+ });
68
90
  const geoDistanceExecutor = (context) => (coordinateFrom, coordinateTo) => {
69
91
  const { survey } = context;
70
92
  const srsIndex = getSRSIndex(survey);
@@ -146,17 +168,32 @@ export const nodeDefExpressionFunctions = {
146
168
  },
147
169
  },
148
170
  geoDistance: { minArity: 2, maxArity: 2, executor: geoDistanceExecutor },
149
- geoDistanceToAOIBoundary: {
171
+ geoAOIContaining: {
150
172
  minArity: 1,
151
173
  maxArity: 1,
152
- executor: (context) => (coordinate) => {
153
- const { survey } = context;
154
- const areaOfInterest = getAreaOfInterest(survey);
174
+ executor: (context) => (coordinate) => __awaiter(void 0, void 0, void 0, function* () {
155
175
  const point = Points.parse(coordinate);
156
- if (!areaOfInterest || !point)
176
+ if (!point || !context.areaOfInterestProvider)
157
177
  return null;
158
- return Points.distanceToPolygonBoundary(point, areaOfInterest, getSRSIndex(survey));
159
- },
178
+ // the survey order is the priority of overlapping areas
179
+ for (const { name } of getAreasOfInterest(context.survey)) {
180
+ const distance = yield distanceToAreaOfInterestBoundary({ context, point, name }); // NOSONAR
181
+ if (distance !== null && distance <= 0)
182
+ return name;
183
+ }
184
+ return null;
185
+ }),
186
+ },
187
+ geoDistanceToAOIBoundary: {
188
+ minArity: 2,
189
+ maxArity: 2,
190
+ executor: (context) => (coordinate, name) => __awaiter(void 0, void 0, void 0, function* () {
191
+ validateAreaOfInterestName({ context, name });
192
+ const point = Points.parse(coordinate);
193
+ if (!point || typeof name !== 'string')
194
+ return null;
195
+ return distanceToAreaOfInterestBoundary({ context, point, name });
196
+ }),
160
197
  },
161
198
  geoPolygon: {
162
199
  minArity: 1,
@@ -1 +1 @@
1
- {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/nodeDefExpressionEvaluator/functions.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,0BAA0B,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AACvF,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAEvH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAGlD,MAAM,oBAAoB,GAAG;IAC3B,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE;QACR,IAAI,EAAE,SAAS;QACf,WAAW,EAAE;YACX;gBACE,CAAC,KAAK,EAAE,GAAG,CAAC;gBACZ,CAAC,KAAK,EAAE,GAAG,CAAC;gBACZ,CAAC,KAAK,EAAE,GAAG,CAAC;gBACZ,CAAC,KAAK,EAAE,GAAG,CAAC;gBACZ,CAAC,KAAK,EAAE,GAAG,CAAC;aACb;SACF;KACF;CACF,CAAA;AAED,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAW,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAA;AAExG,MAAM,aAAa,GAAG,CAAC,QAA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AC;QACX,QAAQ,EAAE,CAAC;QACX,QAAQ,EAAE,CAAC,OAAiC,EAAE,EAAE,CAAC,CAAC,QAAgB,EAAE,EAAE;YACpE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;YAChC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI;gBAAE,OAAO,SAAS,CAAA;YACtC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,MAAM,CAAA;YACnC,MAAM,kBAAkB,GAAG,KAAK,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAA;YACxE,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAA;QACrC,CAAC;KACF;CACF,CAAA","sourcesContent":["import { Users } from '../auth'\nimport { CategoryItem } from '../category'\nimport { SystemError, SystemErrorKeys } from '../error'\nimport { ExpressionFunctions } from '../expression'\nimport { ExtraProps } from '../extraProp/extraProps'\nimport { Point, Points } from '../geo'\nimport { LanguagesISO639part2 } from '../language'\nimport { ArenaRecord } from '../record'\nimport { getNodeDefParent } from '../survey/surveys/nodeDefs'\nimport { getCategoryItemByCodePaths, getTaxonByCode } from '../survey/surveys/refsData'\nimport { getAreaOfInterest, getCategoryByName, getSRSIndex, getTaxonomyByName } from '../survey/surveys/surveysGetters'\nimport { Taxon } from '../taxonomy'\nimport { Dates, Numbers, Objects } from '../utils'\nimport { NodeDefExpressionContext } from './context'\n\nconst sampleGeoJsonPolygon = {\n type: 'Feature',\n geometry: {\n type: 'Polygon',\n coordinates: [\n [\n [100.0, 0.0],\n [101.0, 0.0],\n [101.0, 1.0],\n [100.0, 1.0],\n [100.0, 0.0],\n ],\n ],\n },\n}\n\nconst isNotValidString = (value: string): boolean => Objects.isEmpty(value) || typeof value !== 'string'\n\nconst emptyExecutor = (_context: NodeDefExpressionContext) => () => null\n\nconst isUsingDraftProps = (context: NodeDefExpressionContext) => {\n // use draft props when validating expression or previewing record\n const record: ArenaRecord = (context as any).record\n return !record || !!record.preview\n}\n\nconst getOrFetchCategoryItem = async (params: {\n context: NodeDefExpressionContext\n categoryUuid: string\n codePaths: string[]\n}): Promise<CategoryItem | undefined> => {\n const { context, categoryUuid, codePaths } = params\n // if any code path is empty, return null (no category item can be found)\n if (Objects.isEmpty(codePaths) || codePaths.some(Objects.isEmpty)) {\n return undefined\n }\n const { survey, categoryItemProvider } = context\n const categoryItem = getCategoryItemByCodePaths({ survey, categoryUuid, codePaths })\n const draft = isUsingDraftProps(context)\n return categoryItem ?? categoryItemProvider?.getItemByCodePaths({ survey, categoryUuid, codePaths, draft })\n}\n\nconst getOrFetchTaxon = async (params: {\n context: NodeDefExpressionContext\n taxonomyUuid: string\n taxonCode: string\n}): Promise<Taxon | undefined> => {\n const { context, taxonomyUuid, taxonCode } = params\n if (typeof taxonCode !== 'string' && typeof taxonCode !== 'number') {\n return undefined // node def expression validator could call it passing a node def object\n }\n // if taxonCode is empty, return undefined\n if (Objects.isEmpty(taxonCode)) {\n return undefined\n }\n const { survey, taxonProvider } = context\n const taxon = getTaxonByCode({ survey, taxonomyUuid, taxonCode })\n // fetch draft props when validating expression or previewing record\n const record: ArenaRecord = (context as any).record\n const draft = !record || !!record.preview\n return taxon ?? taxonProvider?.getTaxonByCode({ survey, taxonomyUuid, taxonCode, draft })\n}\n\nconst geoDistanceExecutor =\n (context: NodeDefExpressionContext) =>\n (coordinateFrom: Point | string, coordinateTo: Point | string): number | null => {\n const { survey } = context\n const srsIndex = getSRSIndex(survey)\n\n const pointFrom = Points.parse(coordinateFrom)\n const pointTo = Points.parse(coordinateTo)\n\n return pointFrom && pointTo ? Points.distance(pointFrom, pointTo, srsIndex) : null\n }\n\nexport const nodeDefExpressionFunctions: ExpressionFunctions<NodeDefExpressionContext> = {\n categoryItemProp: {\n minArity: 3,\n executor:\n (context: NodeDefExpressionContext) =>\n async (categoryName: string, itemPropName: string, ...codePaths: string[]): Promise<any> => {\n const { survey } = context\n\n if (Objects.isEmpty(categoryName) || Objects.isEmpty(itemPropName) || Objects.isEmpty(codePaths))\n throw new SystemError(SystemErrorKeys.expression.missingFunctionParameters)\n\n const category = getCategoryByName({ survey, categoryName })\n if (!category) throw new SystemError(SystemErrorKeys.expression.invalidCategoryName, { name: categoryName })\n\n const extraPropDef = category.props.itemExtraDef?.[itemPropName]\n if (!extraPropDef)\n throw new SystemError(SystemErrorKeys.expression.invalidCategoryExtraProp, { propName: itemPropName })\n\n const { uuid: categoryUuid } = category\n const categoryItem = await getOrFetchCategoryItem({ context, categoryUuid, codePaths })\n if (!categoryItem) return null\n\n const value = categoryItem.props.extra?.[itemPropName]\n return ExtraProps.convertValue({ survey, extraPropDef, value })\n },\n },\n count: {\n minArity: 1,\n maxArity: 1,\n executor:\n (_context: NodeDefExpressionContext) =>\n (_nodeSet): number =>\n 1,\n },\n dateTimeDiff: {\n minArity: 4,\n maxArity: 4,\n executor:\n (_context: NodeDefExpressionContext) =>\n (date1: string, time1: string, date2: string, time2: string): number | null => {\n if (isNotValidString(date1) || isNotValidString(time1) || isNotValidString(date2) || isNotValidString(time2))\n return null\n const [hours1, minutes1] = time1.split(':')\n const [hours2, minutes2] = time2.split(':')\n let dt1 = Dates.addHours(date1, Number(hours1))\n dt1 = Dates.addMinutes(dt1, Number(minutes1))\n let dt2 = Dates.addHours(date2, Number(hours2))\n dt2 = Dates.addMinutes(dt2, Number(minutes2))\n return Dates.diffInMinutes(dt1, dt2)\n },\n },\n // deprecated, use geoDistance instead\n distance: { minArity: 2, maxArity: 2, executor: geoDistanceExecutor },\n first: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: emptyExecutor,\n },\n geoCoordinateAtDistance: {\n minArity: 3,\n maxArity: 3,\n executor:\n (context: NodeDefExpressionContext) =>\n (coordinate: Point | string, distanceMeters: number, bearingDeg: number): Point | null => {\n // validate parameters\n const origin = Points.parse(coordinate)\n if (!origin) return null\n\n const distanceMetersNumber = Number(distanceMeters)\n const bearingDegNumber = Number(bearingDeg)\n if (!Number.isFinite(distanceMetersNumber) || distanceMetersNumber < 0 || !Number.isFinite(bearingDegNumber)) {\n return null\n }\n\n const { survey } = context\n const srsIndex = getSRSIndex(survey)\n\n return Points.pointAtDistance({\n origin,\n distanceMeters: distanceMetersNumber,\n bearingDeg: bearingDegNumber,\n srsIndex,\n })\n },\n },\n geoDistance: { minArity: 2, maxArity: 2, executor: geoDistanceExecutor },\n geoDistanceToAOIBoundary: {\n minArity: 1,\n maxArity: 1,\n executor:\n (context: NodeDefExpressionContext) =>\n (coordinate: Point | string): number | null => {\n const { survey } = context\n const areaOfInterest = getAreaOfInterest(survey)\n const point = Points.parse(coordinate)\n if (!areaOfInterest || !point) return null\n return Points.distanceToPolygonBoundary(point, areaOfInterest, getSRSIndex(survey))\n },\n },\n geoPolygon: {\n minArity: 1,\n evaluateArgsToNodes: true,\n executor: () => () => sampleGeoJsonPolygon,\n },\n includes: {\n minArity: 2,\n maxArity: 2,\n evaluateArgsToNodes: false,\n executor:\n () =>\n (items: any, value: any): boolean =>\n Array.isArray(items) && items.map(String).includes(String(value)),\n },\n index: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: () => () => -1,\n },\n last: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: emptyExecutor,\n },\n now: {\n minArity: 0,\n maxArity: 0,\n evaluateToNode: false,\n executor: () => () => Dates.nowFormattedForStorage(),\n },\n numberToWords: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: false,\n executor:\n (context: NodeDefExpressionContext) =>\n (value: any): string | null => {\n if (Objects.isEmpty(value)) return null\n return Numbers.toWords(value, context.lang)\n },\n },\n parent: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n evaluateToNode: true,\n executor: (context: NodeDefExpressionContext) => (nodeDef) => {\n const { survey } = context\n return getNodeDefParent({ survey, nodeDef })\n },\n },\n prevCycleValue: {\n minArity: 1,\n maxArity: 1,\n executor: emptyExecutor,\n },\n prevCycleValues: {\n minArity: 1,\n maxArity: 1,\n executor: emptyExecutor,\n },\n recordCycle: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordDateCreated: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordDateLastModified: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordOwnerEmail: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordOwnerName: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordOwnerRole: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n sum: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: (_context: NodeDefExpressionContext) => (_nodeSet) => 1,\n },\n taxonProp: {\n minArity: 3,\n maxArity: 3,\n executor:\n (context: NodeDefExpressionContext) => async (taxonomyName: string, propName: string, taxonCode: string) => {\n if (Objects.isEmpty(taxonomyName) || Objects.isEmpty(propName))\n throw new SystemError(SystemErrorKeys.expression.missingFunctionParameters)\n if (Objects.isEmpty(taxonCode)) return null\n\n const { survey } = context\n const taxonomy = getTaxonomyByName({ survey, taxonomyName })\n if (!taxonomy) throw new SystemError(SystemErrorKeys.expression.invalidTaxonomyName, { name: taxonomyName })\n\n const extraPropDef = taxonomy.props.extraPropsDefs?.[propName]\n if (!extraPropDef) throw new SystemError(SystemErrorKeys.expression.invalidTaxonomyExtraProp, { propName })\n\n const taxon = await getOrFetchTaxon({ context, taxonomyUuid: taxonomy.uuid, taxonCode })\n if (!taxon) return null\n\n const value = taxon.props.extra?.[propName]\n return ExtraProps.convertValue({ survey, extraPropDef, value })\n },\n },\n taxonVernacularName: {\n minArity: 3,\n maxArity: 3,\n executor:\n (context: NodeDefExpressionContext) =>\n async (taxonomyName: string, vernacularLangCode: string, taxonCode: string) => {\n if (Objects.isEmpty(taxonomyName) || Objects.isEmpty(vernacularLangCode))\n throw new SystemError(SystemErrorKeys.expression.missingFunctionParameters)\n if (Objects.isEmpty(taxonCode)) return null\n\n const { survey } = context\n const taxonomy = getTaxonomyByName({ survey, taxonomyName })\n if (!taxonomy) throw new SystemError(SystemErrorKeys.expression.invalidTaxonomyName, { name: taxonomyName })\n\n if (!LanguagesISO639part2[vernacularLangCode]) {\n throw new SystemError(SystemErrorKeys.expression.invalidTaxonVernacularNameLanguageCode, {\n vernacularLangCode,\n })\n }\n\n const taxon = await getOrFetchTaxon({ context, taxonomyUuid: taxonomy.uuid, taxonCode })\n if (!taxon) return null\n\n const vernacularNameArray = taxon.vernacularNames?.[vernacularLangCode]\n // consider first vernacular name object only\n const firstVernacularName = vernacularNameArray?.[0]\n return firstVernacularName?.props?.name\n },\n },\n unique: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: (_context: NodeDefExpressionContext) => (_nodeSet) => [],\n },\n userEmail: {\n minArity: 0,\n maxArity: 0,\n executor: (context: NodeDefExpressionContext) => () => context.user?.email,\n },\n userIsRecordOwner: {\n minArity: 0,\n maxArity: 0,\n executor: (_context: NodeDefExpressionContext) => () => false,\n },\n userName: {\n minArity: 0,\n maxArity: 0,\n executor: (context: NodeDefExpressionContext) => () => context.user?.name,\n },\n userProp: {\n minArity: 1,\n maxArity: 1,\n executor: (context: NodeDefExpressionContext) => (propName: string) => {\n const { user, survey } = context\n if (!survey || !user) return undefined\n const { uuid: surveyUuid } = survey\n const combinedExtraProps = Users.getCombinedExtraProps(surveyUuid)(user)\n return combinedExtraProps[propName]\n },\n },\n}\n"]}
1
+ {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/nodeDefExpressionEvaluator/functions.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAyB,MAAM,EAAE,MAAM,QAAQ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,GAAG,EAAE,CAAC,KAAK;KAC9D;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,CAAC;QACX,QAAQ,EAAE,CAAC;QACX,QAAQ,EAAE,CAAC,OAAiC,EAAE,EAAE,CAAC,GAAG,EAAE,kBAAC,MAAA,OAAO,CAAC,IAAI,0CAAE,IAAI,GAAA;KAC1E;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,CAAC;QACX,QAAQ,EAAE,CAAC;QACX,QAAQ,EAAE,CAAC,OAAiC,EAAE,EAAE,CAAC,CAAC,QAAgB,EAAE,EAAE;YACpE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;YAChC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI;gBAAE,OAAO,SAAS,CAAA;YACtC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,MAAM,CAAA;YACnC,MAAM,kBAAkB,GAAG,KAAK,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAA;YACxE,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAA;QACrC,CAAC;KACF;CACF,CAAA","sourcesContent":["import { Users } from '../auth'\nimport { CategoryItem } from '../category'\nimport { SystemError, SystemErrorKeys } from '../error'\nimport { ExpressionFunctions } from '../expression'\nimport { ExtraProps } from '../extraProp/extraProps'\nimport { AreaOfInterest, Point, Points } from '../geo'\nimport { LanguagesISO639part2 } from '../language'\nimport { ArenaRecord } from '../record'\nimport { getNodeDefParent } from '../survey/surveys/nodeDefs'\nimport { getCategoryItemByCodePaths, getTaxonByCode } from '../survey/surveys/refsData'\nimport {\n getAreaOfInterestByName,\n getAreasOfInterest,\n getCategoryByName,\n getSRSIndex,\n getTaxonomyByName,\n} from '../survey/surveys/surveysGetters'\nimport { Taxon } from '../taxonomy'\nimport { Dates, Numbers, Objects } from '../utils'\nimport { NodeDefExpressionContext } from './context'\n\nconst sampleGeoJsonPolygon = {\n type: 'Feature',\n geometry: {\n type: 'Polygon',\n coordinates: [\n [\n [100.0, 0.0],\n [101.0, 0.0],\n [101.0, 1.0],\n [100.0, 1.0],\n [100.0, 0.0],\n ],\n ],\n },\n}\n\nconst isNotValidString = (value: string): boolean => Objects.isEmpty(value) || typeof value !== 'string'\n\nconst emptyExecutor = (_context: NodeDefExpressionContext) => () => null\n\nconst isUsingDraftProps = (context: NodeDefExpressionContext) => {\n // use draft props when validating expression or previewing record\n const record: ArenaRecord = (context as any).record\n return !record || !!record.preview\n}\n\nconst getOrFetchCategoryItem = async (params: {\n context: NodeDefExpressionContext\n categoryUuid: string\n codePaths: string[]\n}): Promise<CategoryItem | undefined> => {\n const { context, categoryUuid, codePaths } = params\n // if any code path is empty, return null (no category item can be found)\n if (Objects.isEmpty(codePaths) || codePaths.some(Objects.isEmpty)) {\n return undefined\n }\n const { survey, categoryItemProvider } = context\n const categoryItem = getCategoryItemByCodePaths({ survey, categoryUuid, codePaths })\n const draft = isUsingDraftProps(context)\n return categoryItem ?? categoryItemProvider?.getItemByCodePaths({ survey, categoryUuid, codePaths, draft })\n}\n\nconst getOrFetchTaxon = async (params: {\n context: NodeDefExpressionContext\n taxonomyUuid: string\n taxonCode: string\n}): Promise<Taxon | undefined> => {\n const { context, taxonomyUuid, taxonCode } = params\n if (typeof taxonCode !== 'string' && typeof taxonCode !== 'number') {\n return undefined // node def expression validator could call it passing a node def object\n }\n // if taxonCode is empty, return undefined\n if (Objects.isEmpty(taxonCode)) {\n return undefined\n }\n const { survey, taxonProvider } = context\n const taxon = getTaxonByCode({ survey, taxonomyUuid, taxonCode })\n // fetch draft props when validating expression or previewing record\n const record: ArenaRecord = (context as any).record\n const draft = !record || !!record.preview\n return taxon ?? taxonProvider?.getTaxonByCode({ survey, taxonomyUuid, taxonCode, draft })\n}\n\nconst fetchAreaOfInterest = async (params: {\n context: NodeDefExpressionContext\n name: string\n}): Promise<AreaOfInterest | undefined> => {\n const { context, name } = params\n const { survey, areaOfInterestProvider } = context\n if (!areaOfInterestProvider || !getAreaOfInterestByName({ survey, name })) return undefined\n return areaOfInterestProvider.getAreaOfInterest({ survey, name })\n}\n\n// expression validation (no record): a literal area name must be defined in the survey\nconst validateAreaOfInterestName = (params: { context: NodeDefExpressionContext; name: unknown }): void => {\n const { context, name } = params\n const record: ArenaRecord = (context as any).record\n if (!record && typeof name === 'string' && !getAreaOfInterestByName({ survey: context.survey, name })) {\n throw new SystemError(SystemErrorKeys.expression.areaOfInterestNotFound, { name })\n }\n}\n\nconst distanceToAreaOfInterestBoundary = async (params: {\n context: NodeDefExpressionContext\n point: Point\n name: string\n}): Promise<number | null> => {\n const { context, point, name } = params\n const areaOfInterest = await fetchAreaOfInterest({ context, name })\n if (!areaOfInterest) return null\n return Points.distanceToPolygonBoundary(point, areaOfInterest, getSRSIndex(context.survey))\n}\n\nconst geoDistanceExecutor =\n (context: NodeDefExpressionContext) =>\n (coordinateFrom: Point | string, coordinateTo: Point | string): number | null => {\n const { survey } = context\n const srsIndex = getSRSIndex(survey)\n\n const pointFrom = Points.parse(coordinateFrom)\n const pointTo = Points.parse(coordinateTo)\n\n return pointFrom && pointTo ? Points.distance(pointFrom, pointTo, srsIndex) : null\n }\n\nexport const nodeDefExpressionFunctions: ExpressionFunctions<NodeDefExpressionContext> = {\n categoryItemProp: {\n minArity: 3,\n executor:\n (context: NodeDefExpressionContext) =>\n async (categoryName: string, itemPropName: string, ...codePaths: string[]): Promise<any> => {\n const { survey } = context\n\n if (Objects.isEmpty(categoryName) || Objects.isEmpty(itemPropName) || Objects.isEmpty(codePaths))\n throw new SystemError(SystemErrorKeys.expression.missingFunctionParameters)\n\n const category = getCategoryByName({ survey, categoryName })\n if (!category) throw new SystemError(SystemErrorKeys.expression.invalidCategoryName, { name: categoryName })\n\n const extraPropDef = category.props.itemExtraDef?.[itemPropName]\n if (!extraPropDef)\n throw new SystemError(SystemErrorKeys.expression.invalidCategoryExtraProp, { propName: itemPropName })\n\n const { uuid: categoryUuid } = category\n const categoryItem = await getOrFetchCategoryItem({ context, categoryUuid, codePaths })\n if (!categoryItem) return null\n\n const value = categoryItem.props.extra?.[itemPropName]\n return ExtraProps.convertValue({ survey, extraPropDef, value })\n },\n },\n count: {\n minArity: 1,\n maxArity: 1,\n executor:\n (_context: NodeDefExpressionContext) =>\n (_nodeSet): number =>\n 1,\n },\n dateTimeDiff: {\n minArity: 4,\n maxArity: 4,\n executor:\n (_context: NodeDefExpressionContext) =>\n (date1: string, time1: string, date2: string, time2: string): number | null => {\n if (isNotValidString(date1) || isNotValidString(time1) || isNotValidString(date2) || isNotValidString(time2))\n return null\n const [hours1, minutes1] = time1.split(':')\n const [hours2, minutes2] = time2.split(':')\n let dt1 = Dates.addHours(date1, Number(hours1))\n dt1 = Dates.addMinutes(dt1, Number(minutes1))\n let dt2 = Dates.addHours(date2, Number(hours2))\n dt2 = Dates.addMinutes(dt2, Number(minutes2))\n return Dates.diffInMinutes(dt1, dt2)\n },\n },\n // deprecated, use geoDistance instead\n distance: { minArity: 2, maxArity: 2, executor: geoDistanceExecutor },\n first: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: emptyExecutor,\n },\n geoCoordinateAtDistance: {\n minArity: 3,\n maxArity: 3,\n executor:\n (context: NodeDefExpressionContext) =>\n (coordinate: Point | string, distanceMeters: number, bearingDeg: number): Point | null => {\n // validate parameters\n const origin = Points.parse(coordinate)\n if (!origin) return null\n\n const distanceMetersNumber = Number(distanceMeters)\n const bearingDegNumber = Number(bearingDeg)\n if (!Number.isFinite(distanceMetersNumber) || distanceMetersNumber < 0 || !Number.isFinite(bearingDegNumber)) {\n return null\n }\n\n const { survey } = context\n const srsIndex = getSRSIndex(survey)\n\n return Points.pointAtDistance({\n origin,\n distanceMeters: distanceMetersNumber,\n bearingDeg: bearingDegNumber,\n srsIndex,\n })\n },\n },\n geoDistance: { minArity: 2, maxArity: 2, executor: geoDistanceExecutor },\n geoAOIContaining: {\n minArity: 1,\n maxArity: 1,\n executor:\n (context: NodeDefExpressionContext) =>\n async (coordinate: Point | string): Promise<string | null> => {\n const point = Points.parse(coordinate)\n if (!point || !context.areaOfInterestProvider) return null\n // the survey order is the priority of overlapping areas\n for (const { name } of getAreasOfInterest(context.survey)) {\n const distance = await distanceToAreaOfInterestBoundary({ context, point, name }) // NOSONAR\n if (distance !== null && distance <= 0) return name\n }\n return null\n },\n },\n geoDistanceToAOIBoundary: {\n minArity: 2,\n maxArity: 2,\n executor:\n (context: NodeDefExpressionContext) =>\n async (coordinate: Point | string, name: string): Promise<number | null> => {\n validateAreaOfInterestName({ context, name })\n const point = Points.parse(coordinate)\n if (!point || typeof name !== 'string') return null\n return distanceToAreaOfInterestBoundary({ context, point, name })\n },\n },\n geoPolygon: {\n minArity: 1,\n evaluateArgsToNodes: true,\n executor: () => () => sampleGeoJsonPolygon,\n },\n includes: {\n minArity: 2,\n maxArity: 2,\n evaluateArgsToNodes: false,\n executor:\n () =>\n (items: any, value: any): boolean =>\n Array.isArray(items) && items.map(String).includes(String(value)),\n },\n index: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: () => () => -1,\n },\n last: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: emptyExecutor,\n },\n now: {\n minArity: 0,\n maxArity: 0,\n evaluateToNode: false,\n executor: () => () => Dates.nowFormattedForStorage(),\n },\n numberToWords: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: false,\n executor:\n (context: NodeDefExpressionContext) =>\n (value: any): string | null => {\n if (Objects.isEmpty(value)) return null\n return Numbers.toWords(value, context.lang)\n },\n },\n parent: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n evaluateToNode: true,\n executor: (context: NodeDefExpressionContext) => (nodeDef) => {\n const { survey } = context\n return getNodeDefParent({ survey, nodeDef })\n },\n },\n prevCycleValue: {\n minArity: 1,\n maxArity: 1,\n executor: emptyExecutor,\n },\n prevCycleValues: {\n minArity: 1,\n maxArity: 1,\n executor: emptyExecutor,\n },\n recordCycle: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordDateCreated: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordDateLastModified: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordOwnerEmail: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordOwnerName: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordOwnerRole: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n sum: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: (_context: NodeDefExpressionContext) => (_nodeSet) => 1,\n },\n taxonProp: {\n minArity: 3,\n maxArity: 3,\n executor:\n (context: NodeDefExpressionContext) => async (taxonomyName: string, propName: string, taxonCode: string) => {\n if (Objects.isEmpty(taxonomyName) || Objects.isEmpty(propName))\n throw new SystemError(SystemErrorKeys.expression.missingFunctionParameters)\n if (Objects.isEmpty(taxonCode)) return null\n\n const { survey } = context\n const taxonomy = getTaxonomyByName({ survey, taxonomyName })\n if (!taxonomy) throw new SystemError(SystemErrorKeys.expression.invalidTaxonomyName, { name: taxonomyName })\n\n const extraPropDef = taxonomy.props.extraPropsDefs?.[propName]\n if (!extraPropDef) throw new SystemError(SystemErrorKeys.expression.invalidTaxonomyExtraProp, { propName })\n\n const taxon = await getOrFetchTaxon({ context, taxonomyUuid: taxonomy.uuid, taxonCode })\n if (!taxon) return null\n\n const value = taxon.props.extra?.[propName]\n return ExtraProps.convertValue({ survey, extraPropDef, value })\n },\n },\n taxonVernacularName: {\n minArity: 3,\n maxArity: 3,\n executor:\n (context: NodeDefExpressionContext) =>\n async (taxonomyName: string, vernacularLangCode: string, taxonCode: string) => {\n if (Objects.isEmpty(taxonomyName) || Objects.isEmpty(vernacularLangCode))\n throw new SystemError(SystemErrorKeys.expression.missingFunctionParameters)\n if (Objects.isEmpty(taxonCode)) return null\n\n const { survey } = context\n const taxonomy = getTaxonomyByName({ survey, taxonomyName })\n if (!taxonomy) throw new SystemError(SystemErrorKeys.expression.invalidTaxonomyName, { name: taxonomyName })\n\n if (!LanguagesISO639part2[vernacularLangCode]) {\n throw new SystemError(SystemErrorKeys.expression.invalidTaxonVernacularNameLanguageCode, {\n vernacularLangCode,\n })\n }\n\n const taxon = await getOrFetchTaxon({ context, taxonomyUuid: taxonomy.uuid, taxonCode })\n if (!taxon) return null\n\n const vernacularNameArray = taxon.vernacularNames?.[vernacularLangCode]\n // consider first vernacular name object only\n const firstVernacularName = vernacularNameArray?.[0]\n return firstVernacularName?.props?.name\n },\n },\n unique: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: (_context: NodeDefExpressionContext) => (_nodeSet) => [],\n },\n userEmail: {\n minArity: 0,\n maxArity: 0,\n executor: (context: NodeDefExpressionContext) => () => context.user?.email,\n },\n userIsRecordOwner: {\n minArity: 0,\n maxArity: 0,\n executor: (_context: NodeDefExpressionContext) => () => false,\n },\n userName: {\n minArity: 0,\n maxArity: 0,\n executor: (context: NodeDefExpressionContext) => () => context.user?.name,\n },\n userProp: {\n minArity: 1,\n maxArity: 1,\n executor: (context: NodeDefExpressionContext) => (propName: string) => {\n const { user, survey } = context\n if (!survey || !user) return undefined\n const { uuid: surveyUuid } = survey\n const combinedExtraProps = Users.getCombinedExtraProps(surveyUuid)(user)\n return combinedExtraProps[propName]\n },\n },\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/nodeDefExpressionEvaluator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA","sourcesContent":["export { NodeDefExpressionEvaluator } from './evaluator'\nexport { NodeDefExpressionValidator } from './validator'\nexport type { CategoryItemProvider } from './categoryItemProvider'\nexport type { TaxonProvider } from './taxonProvider'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/nodeDefExpressionEvaluator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA","sourcesContent":["export { NodeDefExpressionEvaluator } from './evaluator'\nexport { NodeDefExpressionValidator } from './validator'\nexport type { AreaOfInterestProvider } from './areaOfInterestProvider'\nexport type { CategoryItemProvider } from './categoryItemProvider'\nexport type { TaxonProvider } from './taxonProvider'\n"]}
@@ -2,7 +2,7 @@ import { getNodeDefChildren, getNodeDefParent, getNodeDefSource } from '../../su
2
2
  import { NodeDefs } from '../../nodeDef/nodeDefs';
3
3
  import { Objects, Queue } from '../../utils';
4
4
  import { IdentifierEvaluator } from '../../expression/javascript/node/identifier';
5
- import { getGlobalObjectProperty } from '../../expression/javascript/global';
5
+ import { getGlobalObjectProperty, isForbiddenPropertyName } from '../../expression/javascript/global';
6
6
  import { ExpressionVariable } from '../../expression';
7
7
  import { SystemError, SystemErrorKeys } from '../../error';
8
8
  import { ValidatorErrorKeys } from '../../validation';
@@ -42,6 +42,9 @@ export class NodeDefIdentifierEvaluator extends IdentifierEvaluator {
42
42
  const { context } = this;
43
43
  const { nodeDefContext, object: objectContext, itemsFilter, memberProperty } = context;
44
44
  const { name: exprName } = expressionNode;
45
+ if (isForbiddenPropertyName(exprName)) {
46
+ this.throwIdentifierNotFound(expressionNode);
47
+ }
45
48
  if (exprName === ExpressionVariable.CONTEXT) {
46
49
  if (nodeDefContext) {
47
50
  this.addReferencedNodeDefUuid(nodeDefContext.uuid);
@@ -1 +1 @@
1
- {"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../../src/nodeDefExpressionEvaluator/node/identifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AACtG,OAAO,EAAE,QAAQ,EAAE,MAAM,w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AO,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC,CAAA;YAC3G,KAAK,MAAM,QAAQ,IAAI,wBAAwB,EAAE,CAAC;gBAChD,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC9C,qBAAqB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;oBACxC,MAAM,QAAQ,CAAA;gBAChB,CAAC;YACH,CAAC;YACD,qCAAqC;YACrC,KAAK,CAAC,YAAY,CAAC,wBAAwB,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAA;YAE5E,oFAAoF;YACpF,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC7C,MAAM,sBAAsB,GAAG,gBAAgB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAA;gBACtF,IAAI,sBAAsB,EAAE,CAAC;oBAC3B,KAAK,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAA;gBACvC,CAAC;gBACD,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;oBACtD,qBAAqB,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;oBAChD,MAAM,gBAAgB,CAAA;gBACxB,CAAC;gBACD,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;YACzC,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { NodeDef, NodeDefProps, NodeDefType } from '../../nodeDef/nodeDef'\nimport { getNodeDefChildren, getNodeDefParent, getNodeDefSource } from '../../survey/surveys/nodeDefs'\nimport { NodeDefs } from '../../nodeDef/nodeDefs'\nimport { Objects, Queue } from '../../utils'\nimport { IdentifierEvaluator } from '../../expression/javascript/node/identifier'\nimport { getGlobalObjectProperty } from '../../expression/javascript/global'\nimport { NodeDefExpressionContext } from '../context'\nimport { ExpressionVariable, IdentifierExpression } from '../../expression'\nimport { SystemError, SystemErrorKeys } from '../../error'\nimport { ValidatorErrorKeys } from '../../validation'\nimport { NodeNativeProperties } from './nodeDefExpressionNativeProperties'\nimport { NodeValues } from '../../node/nodeValues'\n\n/**\n * Determines the actual context node def\n * - attribute def => parent entity def\n * - virtual entity def => source node def\n * - entity def => entity def itself\n */\nconst findActualContextNode = (params: {\n context: NodeDefExpressionContext\n}): NodeDef<NodeDefType, NodeDefProps> | undefined => {\n const { context } = params\n const { survey, object: nodeDefObjectContext } = context\n\n if (!nodeDefObjectContext) return undefined\n\n if (NodeDefs.isAttribute(nodeDefObjectContext)) {\n return getNodeDefParent({ survey, nodeDef: nodeDefObjectContext })\n }\n if (nodeDefObjectContext.virtual) {\n return getNodeDefSource({ survey, nodeDef: nodeDefObjectContext })\n }\n return nodeDefObjectContext\n}\n\nexport class NodeDefIdentifierEvaluator extends IdentifierEvaluator<NodeDefExpressionContext> {\n evaluate(expressionNode: IdentifierExpression): Promise<any> {\n try {\n return Promise.resolve(this.evaluateIdentifier(expressionNode))\n } catch (error) {\n return Promise.reject(error)\n }\n }\n\n private evaluateIdentifier(expressionNode: IdentifierExpression): any {\n const { context } = this\n const { nodeDefContext, object: objectContext, itemsFilter, memberProperty } = context\n const { name: exprName } = expressionNode\n\n if (exprName === ExpressionVariable.CONTEXT) {\n if (nodeDefContext) {\n this.addReferencedNodeDefUuid(nodeDefContext.uuid)\n }\n return nodeDefContext\n }\n\n // global objects (e.g. Math, String)\n const globalObjectProperty = getGlobalObjectProperty(exprName, objectContext)\n if (globalObjectProperty !== null) {\n return globalObjectProperty\n }\n\n if (itemsFilter) {\n const prop = objectContext?.props?.[exprName] ?? objectContext?.props?.extra?.[exprName]\n if (!Objects.isEmpty(prop)) {\n return prop\n }\n }\n\n // check if identifier is a composite attribute value prop\n if (NodeDefs.isAttribute(objectContext) && NodeValues.isValueProp({ nodeDef: objectContext, prop: exprName })) {\n return objectContext\n }\n\n if (memberProperty) {\n // property of a member expression (e.g. text_attr.length or text_attr.toUpperCase()): native properties first\n const nativeProperty = this.findNativeProperty(expressionNode)\n if (nativeProperty) return nativeProperty.value\n return this.getReferencedNodeDef(expressionNode)\n }\n // identifier not in a member expression: node defs first, so that node defs named like native properties\n // (e.g. \"name\", \"type\", \"trim\") are always found (and registered as dependencies)\n const referencedNodeDef = this.findReferencedNodeDef(expressionNode)\n if (referencedNodeDef) return referencedNodeDef\n\n const nativeProperty = this.findNativeProperty(expressionNode)\n if (nativeProperty) return nativeProperty.value\n\n return this.throwIdentifierNotFound(expressionNode)\n }\n\n /**\n * Finds the identifier among the native properties or functions of the context object\n * (e.g. String.length or String.toUpperCase()).\n */\n private findNativeProperty(expressionNode: IdentifierExpression): { value: any } | null {\n const { object: objectContext } = this.context\n const { name: exprName } = expressionNode\n\n const globalOrNativeProperty = this.findGlobalOrNativeProperty(expressionNode)\n if (globalOrNativeProperty) {\n return globalOrNativeProperty\n }\n if (NodeNativeProperties.hasNativeProperty({ nodeDefOrValue: objectContext, propName: exprName })) {\n return {\n value: NodeNativeProperties.evalNodeDefProperty({ nodeDefOrValue: objectContext, propName: exprName }),\n }\n }\n return null\n }\n\n private findReferencedNodeDef(expressionNode: IdentifierExpression): NodeDef<NodeDefType, NodeDefProps> | undefined {\n const { nodeDefCurrent, selfReferenceAllowed } = this.context\n const referencedNodeDef = this.findIdentifierAmongReachableNodeDefs(expressionNode)\n if (!referencedNodeDef) return undefined\n\n if (!selfReferenceAllowed && referencedNodeDef.uuid === nodeDefCurrent?.uuid) {\n throw new SystemError(ValidatorErrorKeys.expressions.cannotUseCurrentNode, { name: expressionNode.name })\n }\n this.addReferencedNodeDefUuid(referencedNodeDef.uuid)\n return referencedNodeDef\n }\n\n private getReferencedNodeDef(expressionNode: IdentifierExpression): NodeDef<NodeDefType, NodeDefProps> {\n return this.findReferencedNodeDef(expressionNode) ?? this.throwIdentifierNotFound(expressionNode)\n }\n\n private throwIdentifierNotFound(expressionNode: IdentifierExpression): never {\n throw new SystemError(SystemErrorKeys.expression.identifierNotFound, {\n name: expressionNode.name,\n contextObject: this.context.object?.props?.name,\n })\n }\n\n private addReferencedNodeDefUuid(uuid: string) {\n const { context } = this\n const { referencedNodeDefUuids = new Set() } = context\n context.referencedNodeDefUuids = referencedNodeDefUuids.add(uuid)\n }\n\n /**\n * Tries to find the specified identifier among the node defs that can be \"reached\" from the context node def.\n */\n protected findIdentifierAmongReachableNodeDefs(\n expressionNode: IdentifierExpression\n ): NodeDef<NodeDefType, NodeDefProps> | undefined {\n const { object: contextObject } = this.context\n\n if (!contextObject) return undefined\n\n // stop at the first match (same order as getReachableNodeDefs), without visiting all the reachable node defs\n for (const reachableNodeDef of this.iterateReachableNodeDefs()) {\n if (reachableNodeDef.props.name === expressionNode.name) {\n return reachableNodeDef\n }\n }\n return undefined\n }\n\n /**\n * Get reachable node defs, i.e. the children of the node definition's ancestors.\n * NOTE: The root node def is excluded, but it _should_ be an entity, so that is fine.\n */\n protected getReachableNodeDefs(): NodeDef<NodeDefType, NodeDefProps>[] {\n return Array.from(this.iterateReachableNodeDefs())\n }\n\n /**\n * Iterates over the reachable node defs (see getReachableNodeDefs), yielding every node def only once.\n */\n private *iterateReachableNodeDefs(): Generator<NodeDef<NodeDefType, NodeDefProps>> {\n const { context } = this\n const { survey, includeAnalysis } = context\n\n const reachableNodeDefUuids = new Set<string>()\n const visitedUuids = new Set<string>()\n\n const queue = new Queue<NodeDef<NodeDefType>>()\n\n const actualContextNode = findActualContextNode({ context })\n if (actualContextNode) {\n queue.enqueue(actualContextNode)\n reachableNodeDefUuids.add(actualContextNode.uuid)\n yield actualContextNode\n }\n\n while (!queue.isEmpty()) {\n const entityDefCurrent = queue.dequeue()!\n const entityDefCurrentChildren = getNodeDefChildren({ survey, nodeDef: entityDefCurrent, includeAnalysis })\n for (const childDef of entityDefCurrentChildren) {\n if (!reachableNodeDefUuids.has(childDef.uuid)) {\n reachableNodeDefUuids.add(childDef.uuid)\n yield childDef\n }\n }\n // visit nodes inside single entities\n queue.enqueueItems(entityDefCurrentChildren.filter(NodeDefs.isSingleEntity))\n\n // avoid visiting 2 times the same entity definition when traversing single entities\n if (!visitedUuids.has(entityDefCurrent.uuid)) {\n const entityDefCurrentParent = getNodeDefParent({ survey, nodeDef: entityDefCurrent })\n if (entityDefCurrentParent) {\n queue.enqueue(entityDefCurrentParent)\n }\n if (!reachableNodeDefUuids.has(entityDefCurrent.uuid)) {\n reachableNodeDefUuids.add(entityDefCurrent.uuid)\n yield entityDefCurrent\n }\n visitedUuids.add(entityDefCurrent.uuid)\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../../src/nodeDefExpressionEvaluator/node/identifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AACtG,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AACjF,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAA;AAErG,OAAO,EAAE,kBAAkB,EAAwB,MAAM,kBAAkB,CAAA;AAC3E,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAElD;;;;;GAKG;AACH,MAAM,qBAAqB,GAAG,CAAC,MAE9B,EAAkD,EAAE;IACnD,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IAC1B,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gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC7C,MAAM,sBAAsB,GAAG,gBAAgB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAA;gBACtF,IAAI,sBAAsB,EAAE,CAAC;oBAC3B,KAAK,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAA;gBACvC,CAAC;gBACD,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;oBACtD,qBAAqB,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;oBAChD,MAAM,gBAAgB,CAAA;gBACxB,CAAC;gBACD,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;YACzC,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { NodeDef, NodeDefProps, NodeDefType } from '../../nodeDef/nodeDef'\nimport { getNodeDefChildren, getNodeDefParent, getNodeDefSource } from '../../survey/surveys/nodeDefs'\nimport { NodeDefs } from '../../nodeDef/nodeDefs'\nimport { Objects, Queue } from '../../utils'\nimport { IdentifierEvaluator } from '../../expression/javascript/node/identifier'\nimport { getGlobalObjectProperty, isForbiddenPropertyName } from '../../expression/javascript/global'\nimport { NodeDefExpressionContext } from '../context'\nimport { ExpressionVariable, IdentifierExpression } from '../../expression'\nimport { SystemError, SystemErrorKeys } from '../../error'\nimport { ValidatorErrorKeys } from '../../validation'\nimport { NodeNativeProperties } from './nodeDefExpressionNativeProperties'\nimport { NodeValues } from '../../node/nodeValues'\n\n/**\n * Determines the actual context node def\n * - attribute def => parent entity def\n * - virtual entity def => source node def\n * - entity def => entity def itself\n */\nconst findActualContextNode = (params: {\n context: NodeDefExpressionContext\n}): NodeDef<NodeDefType, NodeDefProps> | undefined => {\n const { context } = params\n const { survey, object: nodeDefObjectContext } = context\n\n if (!nodeDefObjectContext) return undefined\n\n if (NodeDefs.isAttribute(nodeDefObjectContext)) {\n return getNodeDefParent({ survey, nodeDef: nodeDefObjectContext })\n }\n if (nodeDefObjectContext.virtual) {\n return getNodeDefSource({ survey, nodeDef: nodeDefObjectContext })\n }\n return nodeDefObjectContext\n}\n\nexport class NodeDefIdentifierEvaluator extends IdentifierEvaluator<NodeDefExpressionContext> {\n evaluate(expressionNode: IdentifierExpression): Promise<any> {\n try {\n return Promise.resolve(this.evaluateIdentifier(expressionNode))\n } catch (error) {\n return Promise.reject(error)\n }\n }\n\n private evaluateIdentifier(expressionNode: IdentifierExpression): any {\n const { context } = this\n const { nodeDefContext, object: objectContext, itemsFilter, memberProperty } = context\n const { name: exprName } = expressionNode\n\n if (isForbiddenPropertyName(exprName)) {\n this.throwIdentifierNotFound(expressionNode)\n }\n\n if (exprName === ExpressionVariable.CONTEXT) {\n if (nodeDefContext) {\n this.addReferencedNodeDefUuid(nodeDefContext.uuid)\n }\n return nodeDefContext\n }\n\n // global objects (e.g. Math, String)\n const globalObjectProperty = getGlobalObjectProperty(exprName, objectContext)\n if (globalObjectProperty !== null) {\n return globalObjectProperty\n }\n\n if (itemsFilter) {\n const prop = objectContext?.props?.[exprName] ?? objectContext?.props?.extra?.[exprName]\n if (!Objects.isEmpty(prop)) {\n return prop\n }\n }\n\n // check if identifier is a composite attribute value prop\n if (NodeDefs.isAttribute(objectContext) && NodeValues.isValueProp({ nodeDef: objectContext, prop: exprName })) {\n return objectContext\n }\n\n if (memberProperty) {\n // property of a member expression (e.g. text_attr.length or text_attr.toUpperCase()): native properties first\n const nativeProperty = this.findNativeProperty(expressionNode)\n if (nativeProperty) return nativeProperty.value\n return this.getReferencedNodeDef(expressionNode)\n }\n // identifier not in a member expression: node defs first, so that node defs named like native properties\n // (e.g. \"name\", \"type\", \"trim\") are always found (and registered as dependencies)\n const referencedNodeDef = this.findReferencedNodeDef(expressionNode)\n if (referencedNodeDef) return referencedNodeDef\n\n const nativeProperty = this.findNativeProperty(expressionNode)\n if (nativeProperty) return nativeProperty.value\n\n return this.throwIdentifierNotFound(expressionNode)\n }\n\n /**\n * Finds the identifier among the native properties or functions of the context object\n * (e.g. String.length or String.toUpperCase()).\n */\n private findNativeProperty(expressionNode: IdentifierExpression): { value: any } | null {\n const { object: objectContext } = this.context\n const { name: exprName } = expressionNode\n\n const globalOrNativeProperty = this.findGlobalOrNativeProperty(expressionNode)\n if (globalOrNativeProperty) {\n return globalOrNativeProperty\n }\n if (NodeNativeProperties.hasNativeProperty({ nodeDefOrValue: objectContext, propName: exprName })) {\n return {\n value: NodeNativeProperties.evalNodeDefProperty({ nodeDefOrValue: objectContext, propName: exprName }),\n }\n }\n return null\n }\n\n private findReferencedNodeDef(expressionNode: IdentifierExpression): NodeDef<NodeDefType, NodeDefProps> | undefined {\n const { nodeDefCurrent, selfReferenceAllowed } = this.context\n const referencedNodeDef = this.findIdentifierAmongReachableNodeDefs(expressionNode)\n if (!referencedNodeDef) return undefined\n\n if (!selfReferenceAllowed && referencedNodeDef.uuid === nodeDefCurrent?.uuid) {\n throw new SystemError(ValidatorErrorKeys.expressions.cannotUseCurrentNode, { name: expressionNode.name })\n }\n this.addReferencedNodeDefUuid(referencedNodeDef.uuid)\n return referencedNodeDef\n }\n\n private getReferencedNodeDef(expressionNode: IdentifierExpression): NodeDef<NodeDefType, NodeDefProps> {\n return this.findReferencedNodeDef(expressionNode) ?? this.throwIdentifierNotFound(expressionNode)\n }\n\n private throwIdentifierNotFound(expressionNode: IdentifierExpression): never {\n throw new SystemError(SystemErrorKeys.expression.identifierNotFound, {\n name: expressionNode.name,\n contextObject: this.context.object?.props?.name,\n })\n }\n\n private addReferencedNodeDefUuid(uuid: string) {\n const { context } = this\n const { referencedNodeDefUuids = new Set() } = context\n context.referencedNodeDefUuids = referencedNodeDefUuids.add(uuid)\n }\n\n /**\n * Tries to find the specified identifier among the node defs that can be \"reached\" from the context node def.\n */\n protected findIdentifierAmongReachableNodeDefs(\n expressionNode: IdentifierExpression\n ): NodeDef<NodeDefType, NodeDefProps> | undefined {\n const { object: contextObject } = this.context\n\n if (!contextObject) return undefined\n\n // stop at the first match (same order as getReachableNodeDefs), without visiting all the reachable node defs\n for (const reachableNodeDef of this.iterateReachableNodeDefs()) {\n if (reachableNodeDef.props.name === expressionNode.name) {\n return reachableNodeDef\n }\n }\n return undefined\n }\n\n /**\n * Get reachable node defs, i.e. the children of the node definition's ancestors.\n * NOTE: The root node def is excluded, but it _should_ be an entity, so that is fine.\n */\n protected getReachableNodeDefs(): NodeDef<NodeDefType, NodeDefProps>[] {\n return Array.from(this.iterateReachableNodeDefs())\n }\n\n /**\n * Iterates over the reachable node defs (see getReachableNodeDefs), yielding every node def only once.\n */\n private *iterateReachableNodeDefs(): Generator<NodeDef<NodeDefType, NodeDefProps>> {\n const { context } = this\n const { survey, includeAnalysis } = context\n\n const reachableNodeDefUuids = new Set<string>()\n const visitedUuids = new Set<string>()\n\n const queue = new Queue<NodeDef<NodeDefType>>()\n\n const actualContextNode = findActualContextNode({ context })\n if (actualContextNode) {\n queue.enqueue(actualContextNode)\n reachableNodeDefUuids.add(actualContextNode.uuid)\n yield actualContextNode\n }\n\n while (!queue.isEmpty()) {\n const entityDefCurrent = queue.dequeue()!\n const entityDefCurrentChildren = getNodeDefChildren({ survey, nodeDef: entityDefCurrent, includeAnalysis })\n for (const childDef of entityDefCurrentChildren) {\n if (!reachableNodeDefUuids.has(childDef.uuid)) {\n reachableNodeDefUuids.add(childDef.uuid)\n yield childDef\n }\n }\n // visit nodes inside single entities\n queue.enqueueItems(entityDefCurrentChildren.filter(NodeDefs.isSingleEntity))\n\n // avoid visiting 2 times the same entity definition when traversing single entities\n if (!visitedUuids.has(entityDefCurrent.uuid)) {\n const entityDefCurrentParent = getNodeDefParent({ survey, nodeDef: entityDefCurrent })\n if (entityDefCurrentParent) {\n queue.enqueue(entityDefCurrentParent)\n }\n if (!reachableNodeDefUuids.has(entityDefCurrent.uuid)) {\n reachableNodeDefUuids.add(entityDefCurrent.uuid)\n yield entityDefCurrent\n }\n visitedUuids.add(entityDefCurrent.uuid)\n }\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/record/recordExpressionEvaluator/context.ts"],"names":[],"mappings":"","sourcesContent":["import { User } from '../../auth'\nimport { ExpressionContext } from '../../expression'\nimport { ArenaRecordNode } from '../../node'\nimport { CategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider'\nimport { TaxonProvider } from '../../nodeDefExpressionEvaluator/taxonProvider'\nimport { Survey } from '../../survey'\nimport { ArenaRecord } from '../record'\n\nexport interface RecordExpressionContext extends ExpressionContext {\n user: User\n survey: Survey\n record: ArenaRecord\n prevCycleRecord?: ArenaRecord\n nodeContext: ArenaRecordNode\n nodeCurrent?: ArenaRecordNode\n item?: any\n categoryItemProvider?: CategoryItemProvider\n taxonProvider?: TaxonProvider\n}\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/record/recordExpressionEvaluator/context.ts"],"names":[],"mappings":"","sourcesContent":["import { User } from '../../auth'\nimport { ExpressionContext } from '../../expression'\nimport { ArenaRecordNode } from '../../node'\nimport { AreaOfInterestProvider } from '../../nodeDefExpressionEvaluator/areaOfInterestProvider'\nimport { CategoryItemProvider } from '../../nodeDefExpressionEvaluator/categoryItemProvider'\nimport { TaxonProvider } from '../../nodeDefExpressionEvaluator/taxonProvider'\nimport { Survey } from '../../survey'\nimport { ArenaRecord } from '../record'\n\nexport interface RecordExpressionContext extends ExpressionContext {\n user: User\n survey: Survey\n record: ArenaRecord\n prevCycleRecord?: ArenaRecord\n nodeContext: ArenaRecordNode\n nodeCurrent?: ArenaRecordNode\n item?: any\n categoryItemProvider?: CategoryItemProvider\n taxonProvider?: TaxonProvider\n areaOfInterestProvider?: AreaOfInterestProvider\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import { ExpressionVariable } from '../../../../expression';
2
+ import { isForbiddenPropertyName } from '../../../../expression/javascript/global';
2
3
  import { IdentifierEvaluator } from '../../../../expression/javascript/node/identifier';
3
4
  import { NodeDefs, NodeDefType } from '../../../../nodeDef';
4
5
  import { Records } from '../../../records';
@@ -77,6 +78,9 @@ export class RecordIdentifierEvaluator extends IdentifierEvaluator {
77
78
  if (propName === ExpressionVariable.CONTEXT) {
78
79
  return this.context.nodeContext;
79
80
  }
81
+ if (isForbiddenPropertyName(propName)) {
82
+ throw new SystemError(SystemErrorKeys.expression.identifierNotFound, { name: propName });
83
+ }
80
84
  // try to find identifier among global or native properties
81
85
  // (not-found is signaled without throwing; the try/catch only handles the rare case of an unknown member of a global object)
82
86
  try {