@openforis/arena-core 2.5.14 → 2.5.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/error/index.d.ts +1 -0
  2. package/dist/error/index.js +3 -1
  3. package/dist/error/index.js.map +1 -1
  4. package/dist/error/systemErrorKeys.d.ts +52 -0
  5. package/dist/error/systemErrorKeys.js +56 -0
  6. package/dist/error/systemErrorKeys.js.map +1 -0
  7. package/dist/esm/error/index.js +1 -0
  8. package/dist/esm/error/index.js.map +1 -1
  9. package/dist/esm/error/systemErrorKeys.js +53 -0
  10. package/dist/esm/error/systemErrorKeys.js.map +1 -0
  11. package/dist/esm/expression/javascript/evaluator.js +2 -2
  12. package/dist/esm/expression/javascript/evaluator.js.map +1 -1
  13. package/dist/esm/expression/javascript/global.js +2 -2
  14. package/dist/esm/expression/javascript/global.js.map +1 -1
  15. package/dist/esm/expression/javascript/node/array.js +2 -2
  16. package/dist/esm/expression/javascript/node/array.js.map +1 -1
  17. package/dist/esm/expression/javascript/node/binary.js +2 -2
  18. package/dist/esm/expression/javascript/node/binary.js.map +1 -1
  19. package/dist/esm/expression/javascript/node/call.js +5 -5
  20. package/dist/esm/expression/javascript/node/call.js.map +1 -1
  21. package/dist/esm/expression/javascript/node/compound.js +2 -2
  22. package/dist/esm/expression/javascript/node/compound.js.map +1 -1
  23. package/dist/esm/expression/javascript/node/conditional.js +2 -2
  24. package/dist/esm/expression/javascript/node/conditional.js.map +1 -1
  25. package/dist/esm/expression/javascript/node/identifier.js +2 -2
  26. package/dist/esm/expression/javascript/node/identifier.js.map +1 -1
  27. package/dist/esm/expression/javascript/node/this.js +2 -2
  28. package/dist/esm/expression/javascript/node/this.js.map +1 -1
  29. package/dist/esm/expression/javascript/node/unary.js +2 -2
  30. package/dist/esm/expression/javascript/node/unary.js.map +1 -1
  31. package/dist/esm/geo/points/transform.js +5 -5
  32. package/dist/esm/geo/points/transform.js.map +1 -1
  33. package/dist/esm/index.js +1 -1
  34. package/dist/esm/index.js.map +1 -1
  35. package/dist/esm/job/JobBase.js +2 -2
  36. package/dist/esm/job/JobBase.js.map +1 -1
  37. package/dist/esm/nodeDefExpressionEvaluator/functions.js +12 -10
  38. package/dist/esm/nodeDefExpressionEvaluator/functions.js.map +1 -1
  39. package/dist/esm/nodeDefExpressionEvaluator/node/identifier.js +2 -2
  40. package/dist/esm/nodeDefExpressionEvaluator/node/identifier.js.map +1 -1
  41. package/dist/esm/record/_records/recordGetters.js +4 -4
  42. package/dist/esm/record/_records/recordGetters.js.map +1 -1
  43. package/dist/esm/record/recordExpressionEvaluator/node/identifier/identifier.js +6 -6
  44. package/dist/esm/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
  45. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js +2 -1
  46. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js.map +1 -1
  47. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js +2 -1
  48. package/dist/esm/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
  49. package/dist/esm/record/recordNodesUpdater/recordNodesCreator.js +2 -2
  50. package/dist/esm/record/recordNodesUpdater/recordNodesCreator.js.map +1 -1
  51. package/dist/esm/record/recordUpdater.js +2 -2
  52. package/dist/esm/record/recordUpdater.js.map +1 -1
  53. package/dist/esm/survey/nodeDefsFixer.js +3 -3
  54. package/dist/esm/survey/nodeDefsFixer.js.map +1 -1
  55. package/dist/esm/survey/surveys/nodeDefs.js +5 -5
  56. package/dist/esm/survey/surveys/nodeDefs.js.map +1 -1
  57. package/dist/expression/javascript/evaluator.js +1 -1
  58. package/dist/expression/javascript/evaluator.js.map +1 -1
  59. package/dist/expression/javascript/global.js +1 -1
  60. package/dist/expression/javascript/global.js.map +1 -1
  61. package/dist/expression/javascript/node/array.js +1 -1
  62. package/dist/expression/javascript/node/array.js.map +1 -1
  63. package/dist/expression/javascript/node/binary.js +1 -1
  64. package/dist/expression/javascript/node/binary.js.map +1 -1
  65. package/dist/expression/javascript/node/call.js +4 -4
  66. package/dist/expression/javascript/node/call.js.map +1 -1
  67. package/dist/expression/javascript/node/compound.js +1 -1
  68. package/dist/expression/javascript/node/compound.js.map +1 -1
  69. package/dist/expression/javascript/node/conditional.js +1 -1
  70. package/dist/expression/javascript/node/conditional.js.map +1 -1
  71. package/dist/expression/javascript/node/identifier.js +1 -1
  72. package/dist/expression/javascript/node/identifier.js.map +1 -1
  73. package/dist/expression/javascript/node/this.js +1 -1
  74. package/dist/expression/javascript/node/this.js.map +1 -1
  75. package/dist/expression/javascript/node/unary.js +1 -1
  76. package/dist/expression/javascript/node/unary.js.map +1 -1
  77. package/dist/geo/points/transform.js +4 -4
  78. package/dist/geo/points/transform.js.map +1 -1
  79. package/dist/index.d.ts +1 -1
  80. package/dist/index.js +4 -3
  81. package/dist/index.js.map +1 -1
  82. package/dist/job/JobBase.js +1 -1
  83. package/dist/job/JobBase.js.map +1 -1
  84. package/dist/nodeDefExpressionEvaluator/functions.js +11 -9
  85. package/dist/nodeDefExpressionEvaluator/functions.js.map +1 -1
  86. package/dist/nodeDefExpressionEvaluator/node/identifier.js +1 -1
  87. package/dist/nodeDefExpressionEvaluator/node/identifier.js.map +1 -1
  88. package/dist/record/_records/recordGetters.js +3 -3
  89. package/dist/record/_records/recordGetters.js.map +1 -1
  90. package/dist/record/recordExpressionEvaluator/node/identifier/identifier.js +5 -5
  91. package/dist/record/recordExpressionEvaluator/node/identifier/identifier.js.map +1 -1
  92. package/dist/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js +2 -1
  93. package/dist/record/recordNodesUpdater/recordNodeDependentsDefaultValuesUpdater.js.map +1 -1
  94. package/dist/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js +2 -1
  95. package/dist/record/recordNodesUpdater/recordNodeDependentsFileNamesEvaluator.js.map +1 -1
  96. package/dist/record/recordNodesUpdater/recordNodesCreator.js +1 -1
  97. package/dist/record/recordNodesUpdater/recordNodesCreator.js.map +1 -1
  98. package/dist/record/recordUpdater.js +1 -1
  99. package/dist/record/recordUpdater.js.map +1 -1
  100. package/dist/survey/nodeDefsFixer.js +2 -2
  101. package/dist/survey/nodeDefsFixer.js.map +1 -1
  102. package/dist/survey/surveys/nodeDefs.js +4 -4
  103. package/dist/survey/surveys/nodeDefs.js.map +1 -1
  104. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../src/nodeDefExpressionEvaluator/functions.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kCAA+B;AAE/B,oCAAsC;AAEtC,wDAAoD;AACpD,gCAAsC;AACtC,0CAAkD;AAElD,yDAA6D;AAC7D,yDAAuF;AACvF,qEAAoG;AAEpG,oCAAkD;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,eAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAA;AAExG,MAAM,aAAa,GAAG,CAAC,QAAkC,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAA;AAExE,MAAM,iBAAiB,GAAG,CAAC,OAAiC,EAAE,EAAE;IAC9D,kEAAkE;IAClE,MAAM,MAAM,GAAiB,OAAe,CAAC,MAAM,CAAA;IACnD,OAAO,CAAC,MAAM,IAAI,CAAC,CA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EAAE;QACjB,QAAQ,EAAE,CAAC;QACX,QAAQ,EAAE,CAAC;QACX,QAAQ,EAAE,CAAC,QAAkC,EAAE,EAAE,CAAC,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,YAAK,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 } 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 { 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('expression.missingFunctionParameters')\n\n const category = getCategoryByName({ survey, categoryName })\n if (!category) throw new SystemError('expression.invalidCategoryName', { name: categoryName })\n\n const extraPropDef = category.props.itemExtraDef?.[itemPropName]\n if (!extraPropDef) throw new SystemError('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 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('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('expression.invalidTaxonomyName', { name: taxonomyName })\n\n const extraPropDef = taxonomy.props.extraPropsDefs?.[propName]\n if (!extraPropDef) throw new SystemError('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('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('expression.invalidTaxonomyName', { name: taxonomyName })\n\n if (!LanguagesISO639part2[vernacularLangCode]) {\n throw new SystemError('expression.invalidTaxonVernacularNameLanguageCode', { vernacularLangCode })\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,kCAA+B;AAE/B,oCAAuD;AAEvD,wDAAoD;AACpD,gCAAsC;AACtC,0CAAkD;AAElD,yDAA6D;AAC7D,yDAAuF;AACvF,qEAAoG;AAEpG,oCAAkD;AAGlD,MAAM,oBAAoB,GAAG;IAC3B,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE;QACR,IA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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,YAAK,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 { 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 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"]}
@@ -118,7 +118,7 @@ class NodeDefIdentifierEvaluator extends identifier_1.IdentifierEvaluator {
118
118
  }
119
119
  throwIdentifierNotFound(expressionNode) {
120
120
  var _a, _b;
121
- throw new error_1.SystemError('expression.identifierNotFound', {
121
+ throw new error_1.SystemError(error_1.SystemErrorKeys.expression.identifierNotFound, {
122
122
  name: expressionNode.name,
123
123
  contextObject: (_b = (_a = this.context.object) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.name,
124
124
  });
@@ -1 +1 @@
1
- {"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../src/nodeDefExpressionEvaluator/node/identifier.ts"],"names":[],"mappings":";;;AACA,4DAAsG;AACtG,qDAAiD;AACjD,uCAA4C;AAC5C,4EAAiF;AACjF,+DAA4E;AAE5E,iDAA2E;AAC3E,uCAAyC;AACzC,iDAAqD;AACrD,2FAA0E;AAC1E,sDAAkD;AA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C,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC7C,MAAM,sBAAsB,GAAG,IAAA,2BAAgB,EAAC,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAA;gBACtF,IAAI,sBAAsB,EAAE,CAAC;oBAC3B,KAAK,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAA;gBACvC,CAAC;gBACD,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;oBACtD,qBAAqB,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;oBAChD,MAAM,gBAAgB,CAAA;gBACxB,CAAC;gBACD,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;YACzC,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { NodeDef, NodeDefProps, NodeDefType } from '../../nodeDef/nodeDef'\nimport { getNodeDefChildren, getNodeDefParent, getNodeDefSource } from '../../survey/surveys/nodeDefs'\nimport { NodeDefs } from '../../nodeDef/nodeDefs'\nimport { Objects, Queue } from '../../utils'\nimport { IdentifierEvaluator } from '../../expression/javascript/node/identifier'\nimport { getGlobalObjectProperty } from '../../expression/javascript/global'\nimport { NodeDefExpressionContext } from '../context'\nimport { ExpressionVariable, IdentifierExpression } from '../../expression'\nimport { SystemError } from '../../error'\nimport { ValidatorErrorKeys } from '../../validation'\nimport { NodeNativeProperties } from './nodeDefExpressionNativeProperties'\nimport { NodeValues } from '../../node/nodeValues'\n\n/**\n * Determines the actual context node def\n * - attribute def => parent entity def\n * - virtual entity def => source node def\n * - entity def => entity def itself\n */\nconst findActualContextNode = (params: {\n context: NodeDefExpressionContext\n}): NodeDef<NodeDefType, NodeDefProps> | undefined => {\n const { context } = params\n const { survey, object: nodeDefObjectContext } = context\n\n if (!nodeDefObjectContext) return undefined\n\n if (NodeDefs.isAttribute(nodeDefObjectContext)) {\n return getNodeDefParent({ survey, nodeDef: nodeDefObjectContext })\n }\n if (nodeDefObjectContext.virtual) {\n return getNodeDefSource({ survey, nodeDef: nodeDefObjectContext })\n }\n return nodeDefObjectContext\n}\n\nexport class NodeDefIdentifierEvaluator extends IdentifierEvaluator<NodeDefExpressionContext> {\n evaluate(expressionNode: IdentifierExpression): Promise<any> {\n try {\n return Promise.resolve(this.evaluateIdentifier(expressionNode))\n } catch (error) {\n return Promise.reject(error)\n }\n }\n\n private evaluateIdentifier(expressionNode: IdentifierExpression): any {\n const { context } = this\n const { nodeDefContext, object: objectContext, itemsFilter, memberProperty } = context\n const { name: exprName } = expressionNode\n\n if (exprName === ExpressionVariable.CONTEXT) {\n if (nodeDefContext) {\n this.addReferencedNodeDefUuid(nodeDefContext.uuid)\n }\n return nodeDefContext\n }\n\n // global objects (e.g. Math, String)\n const globalObjectProperty = getGlobalObjectProperty(exprName, objectContext)\n if (globalObjectProperty !== null) {\n return globalObjectProperty\n }\n\n if (itemsFilter) {\n const prop = objectContext?.props?.[exprName] ?? objectContext?.props?.extra?.[exprName]\n if (!Objects.isEmpty(prop)) {\n return prop\n }\n }\n\n // check if identifier is a composite attribute value prop\n if (NodeDefs.isAttribute(objectContext) && NodeValues.isValueProp({ nodeDef: objectContext, prop: exprName })) {\n return objectContext\n }\n\n if (memberProperty) {\n // property of a member expression (e.g. text_attr.length or text_attr.toUpperCase()): native properties first\n const nativeProperty = this.findNativeProperty(expressionNode)\n if (nativeProperty) return nativeProperty.value\n return this.getReferencedNodeDef(expressionNode)\n }\n // identifier not in a member expression: node defs first, so that node defs named like native properties\n // (e.g. \"name\", \"type\", \"trim\") are always found (and registered as dependencies)\n const referencedNodeDef = this.findReferencedNodeDef(expressionNode)\n if (referencedNodeDef) return referencedNodeDef\n\n const nativeProperty = this.findNativeProperty(expressionNode)\n if (nativeProperty) return nativeProperty.value\n\n return this.throwIdentifierNotFound(expressionNode)\n }\n\n /**\n * Finds the identifier among the native properties or functions of the context object\n * (e.g. String.length or String.toUpperCase()).\n */\n private findNativeProperty(expressionNode: IdentifierExpression): { value: any } | null {\n const { object: objectContext } = this.context\n const { name: exprName } = expressionNode\n\n const globalOrNativeProperty = this.findGlobalOrNativeProperty(expressionNode)\n if (globalOrNativeProperty) {\n return globalOrNativeProperty\n }\n if (NodeNativeProperties.hasNativeProperty({ nodeDefOrValue: objectContext, propName: exprName })) {\n return {\n value: NodeNativeProperties.evalNodeDefProperty({ nodeDefOrValue: objectContext, propName: exprName }),\n }\n }\n return null\n }\n\n private findReferencedNodeDef(expressionNode: IdentifierExpression): NodeDef<NodeDefType, NodeDefProps> | undefined {\n const { nodeDefCurrent, selfReferenceAllowed } = this.context\n const referencedNodeDef = this.findIdentifierAmongReachableNodeDefs(expressionNode)\n if (!referencedNodeDef) return undefined\n\n if (!selfReferenceAllowed && referencedNodeDef.uuid === nodeDefCurrent?.uuid) {\n throw new SystemError(ValidatorErrorKeys.expressions.cannotUseCurrentNode, { name: expressionNode.name })\n }\n this.addReferencedNodeDefUuid(referencedNodeDef.uuid)\n return referencedNodeDef\n }\n\n private getReferencedNodeDef(expressionNode: IdentifierExpression): NodeDef<NodeDefType, NodeDefProps> {\n return this.findReferencedNodeDef(expressionNode) ?? this.throwIdentifierNotFound(expressionNode)\n }\n\n private throwIdentifierNotFound(expressionNode: IdentifierExpression): never {\n throw new SystemError('expression.identifierNotFound', {\n name: expressionNode.name,\n contextObject: this.context.object?.props?.name,\n })\n }\n\n private addReferencedNodeDefUuid(uuid: string) {\n const { context } = this\n const { referencedNodeDefUuids = new Set() } = context\n context.referencedNodeDefUuids = referencedNodeDefUuids.add(uuid)\n }\n\n /**\n * Tries to find the specified identifier among the node defs that can be \"reached\" from the context node def.\n */\n protected findIdentifierAmongReachableNodeDefs(\n expressionNode: IdentifierExpression\n ): NodeDef<NodeDefType, NodeDefProps> | undefined {\n const { object: contextObject } = this.context\n\n if (!contextObject) return undefined\n\n // stop at the first match (same order as getReachableNodeDefs), without visiting all the reachable node defs\n for (const reachableNodeDef of this.iterateReachableNodeDefs()) {\n if (reachableNodeDef.props.name === expressionNode.name) {\n return reachableNodeDef\n }\n }\n return undefined\n }\n\n /**\n * Get reachable node defs, i.e. the children of the node definition's ancestors.\n * NOTE: The root node def is excluded, but it _should_ be an entity, so that is fine.\n */\n protected getReachableNodeDefs(): NodeDef<NodeDefType, NodeDefProps>[] {\n return Array.from(this.iterateReachableNodeDefs())\n }\n\n /**\n * Iterates over the reachable node defs (see getReachableNodeDefs), yielding every node def only once.\n */\n private *iterateReachableNodeDefs(): Generator<NodeDef<NodeDefType, NodeDefProps>> {\n const { context } = this\n const { survey, includeAnalysis } = context\n\n const reachableNodeDefUuids = new Set<string>()\n const visitedUuids = new Set<string>()\n\n const queue = new Queue<NodeDef<NodeDefType>>()\n\n const actualContextNode = findActualContextNode({ context })\n if (actualContextNode) {\n queue.enqueue(actualContextNode)\n reachableNodeDefUuids.add(actualContextNode.uuid)\n yield actualContextNode\n }\n\n while (!queue.isEmpty()) {\n const entityDefCurrent = queue.dequeue()!\n const entityDefCurrentChildren = getNodeDefChildren({ survey, nodeDef: entityDefCurrent, includeAnalysis })\n for (const childDef of entityDefCurrentChildren) {\n if (!reachableNodeDefUuids.has(childDef.uuid)) {\n reachableNodeDefUuids.add(childDef.uuid)\n yield childDef\n }\n }\n // visit nodes inside single entities\n queue.enqueueItems(entityDefCurrentChildren.filter(NodeDefs.isSingleEntity))\n\n // avoid visiting 2 times the same entity definition when traversing single entities\n if (!visitedUuids.has(entityDefCurrent.uuid)) {\n const entityDefCurrentParent = getNodeDefParent({ survey, nodeDef: entityDefCurrent })\n if (entityDefCurrentParent) {\n queue.enqueue(entityDefCurrentParent)\n }\n if (!reachableNodeDefUuids.has(entityDefCurrent.uuid)) {\n reachableNodeDefUuids.add(entityDefCurrent.uuid)\n yield entityDefCurrent\n }\n visitedUuids.add(entityDefCurrent.uuid)\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../src/nodeDef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A;oBACxC,MAAM,QAAQ,CAAA;gBAChB,CAAC;YACH,CAAC;YACD,qCAAqC;YACrC,KAAK,CAAC,YAAY,CAAC,wBAAwB,CAAC,MAAM,CAAC,mBAAQ,CAAC,cAAc,CAAC,CAAC,CAAA;YAE5E,oFAAoF;YACpF,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC7C,MAAM,sBAAsB,GAAG,IAAA,2BAAgB,EAAC,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"]}
@@ -92,7 +92,7 @@ exports.getChild = positionalRecordGetter({
92
92
  const children = (0, exports.getChildren)({ parentNode, childDefUuid })(record);
93
93
  if (children.length > 1) {
94
94
  const errorParams = { childDefUuid, parentNodeUuid: parentNode.uuid, recordUuid: record.uuid };
95
- throw new error_1.SystemError('systemError.record.multipleNodesFound', errorParams);
95
+ throw new error_1.SystemError(error_1.SystemErrorKeys.record.multipleNodesFound, errorParams);
96
96
  }
97
97
  return children[0];
98
98
  },
@@ -135,7 +135,7 @@ exports.getDependentCodeAttributes = positionalRecordGetter({
135
135
  const nodeUuids = recordNodesIndexReader_1.RecordNodesIndexReader.getNodeCodeDependentUuids(node.uuid)(record._nodesIndex);
136
136
  return (0, exports.getNodesByUuids)({ uuids: nodeUuids })(record);
137
137
  }
138
- throw new error_1.SystemError('record.nodesIndexNotInitialized');
138
+ throw new error_1.SystemError(error_1.SystemErrorKeys.record.nodesIndexNotInitialized);
139
139
  },
140
140
  isPositional: isRecordNode,
141
141
  toParams: (node) => ({ node }),
@@ -443,7 +443,7 @@ exports.getDependentNodePointers = recordGetter((params) => {
443
443
  continue;
444
444
  const nodeDefDependentParent = survey_1.Surveys.getNodeDefParent({ survey, nodeDef: dependentDef });
445
445
  if (!nodeDefDependentParent)
446
- throw new error_1.SystemError('record.nodes.dependents.dependencyOnRootFound');
446
+ throw new error_1.SystemError(error_1.SystemErrorKeys.record.dependencyOnRootFound);
447
447
  // 2 find descendant nodes of common parent node with nodeDefUuid = dependentDef uuid
448
448
  const dependentContextNodes = (0, exports.getDescendantsOrSelf)({
449
449
  node: commonAncestorNode,
@@ -1 +1 @@
1
- {"version":3,"file":"recordGetters.js","sourceRoot":"","sources":["../../../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CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC;IAC5G,YAAY,EAAE,YAAY;IAC1B,QAAQ,EAAE,CAAC,IAAqB,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;CAChD,CAAC,CAAA;AAEW,QAAA,WAAW,GAAG,sBAAsB,CAAC;IAChD,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAA4C,EAAW,EAAE,CAC9E,CAAC,IAAA,QAAA,kBAAkB,EAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACvC,YAAY,EAAE,YAAY;IAC1B,QAAQ,EAAE,CAAC,IAAqB,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;CAChD,CAAC,CAAA;AAEK,MAAM,OAAO,GAAG,CAAC,MAAmB,EAAW,EAAE;IACtD,MAAM,QAAQ,GAAG,IAAA,QAAA,OAAO,EAAC,MAAM,CAAC,CAAA;IAChC,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAA,QAAA,WAAW,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAClE,CAAC,CAAA;AAHY,QAAA,OAAO,GAAP,OAAO,CAGnB;AAEM,MAAM,OAAO,GAAG,CAAC,MAAmB,EAAU,EAAE,wBAAC,MAAM,CAAC,IAAI,mCAAI,4BAAmB,GAAA,CAAA;AAA7E,QAAA,OAAO,GAAP,OAAO,CAAsE;AAEnF,MAAM,gBAAgB,GAAG,CAAC,MAAmB,EAAW,EAAE,CAAC,IAAA,QAAA,OAAO,EAAC,MAAM,CAAC,KAAK,mCAAsB,CAAA;AAA/F,QAAA,gBAAgB,GAAhB,gBAAgB,CAA+E","sourcesContent":["import { Dictionary, TraverseMethod } from '../../common'\nimport { SystemError } from '../../error'\nimport { ArenaRecordNode, NodePointer, Nodes, NodesMap } from '../../node'\nimport { NodeValues } from '../../node/nodeValues'\nimport { NodeDef, NodeDefCode, NodeDefCodeProps, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { defaultCycle, Surveys } from '../../survey'\nimport { Survey, SurveyDependencyType } from '../../survey/survey'\nimport { Arrays, Queue } from '../../utils'\nimport { ArenaRecord, RECORD_STEP_DEFAULT } from '../record'\nimport { RecordStepAnalysisCode } from '../recordStep'\nimport { RecordNodesIndexReader } from './recordNodesIndexReader'\nimport { NodeDefSelfReferences } from './nodeDefSelfReferences'\n\nexport type RecordParams = { record: ArenaRecord }\n\n/**\n * Record getter: takes the parameters first and the record as separate (curried) parameter: `getter(params)(record)`.\n * The deprecated form, with the record inside the parameters (`getter({ record, ...params })`), is still supported.\n */\nexport type RecordGetter<P extends RecordParams, R> = {\n /** @deprecated Pass the record as separate parameter: `getter(params)(record)` */\n (params: P): R\n (params: Omit<P, 'record'>): (record: ArenaRecord) => R\n}\n\nconst isRecordParams = (params: object): params is RecordParams => 'record' in params\n\nconst recordGetter = <P extends RecordParams, R>(getter: (params: P) => R): RecordGetter<P, R> =>\n ((params: P | Omit<P, 'record'>) =>\n isRecordParams(params)\n ? getter(params as P)\n : (record: ArenaRecord) => getter({ ...params, record } as P)) as RecordGetter<P, R>\n\n/**\n * Record getter (with parameters object) that also supports the deprecated form with positional parameters:\n * `getter(arg1, arg2)(record)`.\n */\nexport type PositionalRecordGetter<P, A extends unknown[], R> = {\n (params: P): (record: ArenaRecord) => R\n /** @deprecated Pass the parameters as an object: `getter({ ...params })(record)` */\n (...args: A): (record: ArenaRecord) => R\n}\n\nconst positionalRecordGetter = <P, A extends unknown[], R>(params: {\n getter: (params: P & RecordParams) => R\n isPositional: (firstArg: unknown) => boolean\n toParams: (...args: A) => NoInfer<P>\n}): PositionalRecordGetter<P, A, R> => {\n const { getter, isPositional, toParams } = params\n return ((...args: unknown[]) => {\n const getterParams = isPositional(args[0]) ? toParams(...(args as A)) : (args[0] as P)\n return (record: ArenaRecord) => getter({ ...getterParams, record })\n }) as PositionalRecordGetter<P, A, R>\n}\n\nconst isRecordNode = (arg: unknown): arg is ArenaRecordNode =>\n typeof arg === 'object' && arg !== null && 'uuid' in arg && 'nodeDefUuid' in arg\nconst isString = (arg: unknown): arg is string => typeof arg === 'string'\n\nexport const getCycle = (record: ArenaRecord): string => record.cycle ?? defaultCycle\n\nexport const getNodes = (record: ArenaRecord): Dictionary<ArenaRecordNode> => record.nodes ?? {}\n\nexport const getNodesArray = (record: ArenaRecord): ArenaRecordNode[] => Object.values(getNodes(record))\n\n/**\n * Returns the node with the specified uuid, or undefined if not found.\n * Like the other node getters, it does not throw an error when the node is not found.\n */\nexport const getNodeByUuid = positionalRecordGetter({\n getter: ({ record, uuid }: RecordParams & { uuid: string }): ArenaRecordNode | undefined => record.nodes?.[uuid],\n isPositional: isString,\n toParams: (uuid: string) => ({ uuid }),\n})\n\nexport const getNodesByUuids = positionalRecordGetter({\n getter: ({ record, uuids }: RecordParams & { uuids: string[] }): ArenaRecordNode[] =>\n uuids.map((uuid: string) => record.nodes?.[uuid]) as ArenaRecordNode[],\n isPositional: Array.isArray,\n toParams: (uuids: string[]) => ({ uuids }),\n})\n\n/**\n * Returns the root node, or undefined if the record has no nodes.\n */\nexport const getRoot = (record: ArenaRecord): ArenaRecordNode | undefined => {\n const rootUuid = record._nodesIndex ? RecordNodesIndexReader.getNodeRootUuid(record._nodesIndex) : null\n if (rootUuid) {\n return getNodeByUuid({ uuid: rootUuid })(record)\n }\n return getNodesArray(record).find((node) => !node.parentUuid)\n}\n\nexport const getChildren = positionalRecordGetter({\n getter: ({\n record,\n parentNode,\n childDefUuid,\n }: RecordParams & { parentNode: ArenaRecordNode; childDefUuid?: string }): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const childrenUuids = childDefUuid\n ? RecordNodesIndexReader.getNodeUuidsByParentAndChildDef({\n parentNodeUuid: parentNode.uuid,\n childDefUuid,\n })(record._nodesIndex)\n : RecordNodesIndexReader.getNodeUuidsByParent(parentNode.uuid)(record._nodesIndex)\n return getNodesByUuids({ uuids: childrenUuids })(record)\n }\n return getNodesArray(record).filter(\n (node) => node.parentUuid === parentNode.uuid && (!childDefUuid || node.nodeDefUuid == childDefUuid)\n )\n },\n isPositional: isRecordNode,\n toParams: (parentNode: ArenaRecordNode, childDefUuid?: string) => ({ parentNode, childDefUuid }),\n})\n\n/**\n * Returns the only child of the parent node with the specified node def, or undefined if not found.\n * Throws an error if more than one child is found.\n */\nexport const getChild = positionalRecordGetter({\n getter: ({\n record,\n parentNode,\n childDefUuid,\n }: RecordParams & { parentNode: ArenaRecordNode; childDefUuid: string }): ArenaRecordNode | undefined => {\n const children = getChildren({ parentNode, childDefUuid })(record)\n if (children.length > 1) {\n const errorParams = { childDefUuid, parentNodeUuid: parentNode.uuid, recordUuid: record.uuid }\n throw new SystemError('systemError.record.multipleNodesFound', errorParams)\n }\n return children[0]\n },\n isPositional: isRecordNode,\n toParams: (parentNode: ArenaRecordNode, childDefUuid: string) => ({ parentNode, childDefUuid }),\n})\n\nexport const getParent = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): ArenaRecordNode | undefined =>\n node.parentUuid ? getNodeByUuid({ uuid: node.parentUuid })(record) : undefined,\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const getNodesByDefUuid = positionalRecordGetter({\n getter: ({ record, nodeDefUuid }: RecordParams & { nodeDefUuid: string }): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeUuidsByDef(nodeDefUuid)(record._nodesIndex)\n return getNodesByUuids({ uuids: nodeUuids })(record)\n }\n return getNodesArray(record).filter((node) => node.nodeDefUuid === nodeDefUuid)\n },\n isPositional: isString,\n toParams: (nodeDefUuid: string) => ({ nodeDefUuid }),\n})\n\nconst isNodeFlagTrue = (isChildFlagTrue: (parent: ArenaRecordNode, nodeDefUuid: string) => boolean) =>\n recordGetter((params: RecordParams & { node: ArenaRecordNode }): boolean => {\n const { record, node } = params\n const ancestorsAndSelf = getAncestorsAndSelf({ node })(record)\n for (let i = 0; i < ancestorsAndSelf.length - 1; i++) {\n const child = ancestorsAndSelf[i]\n const parent = ancestorsAndSelf[i + 1]\n if (!isChildFlagTrue(parent, child.nodeDefUuid)) return false\n }\n return true\n })\n\nexport const isNodeApplicable = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildApplicable(parent, nodeDefUuid))\nexport const isNodeEditable = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildEditable(parent, nodeDefUuid))\nexport const isNodeVisible = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildVisible(parent, nodeDefUuid))\n\nexport const getDependentCodeAttributes = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeCodeDependentUuids(node.uuid)(record._nodesIndex)\n return getNodesByUuids({ uuids: nodeUuids })(record)\n }\n throw new SystemError('record.nodesIndexNotInitialized')\n },\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const getParentCodeAttribute =\n (params: { parentNode: ArenaRecordNode; nodeDef: NodeDefCode }) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const { parentNode, nodeDef } = params\n\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(nodeDef)\n if (!parentCodeDefUuid) return undefined\n\n const ancestors = getAncestorsAndSelf({ node: parentNode })(record)\n for (const ancestor of ancestors) {\n const children = getChildren({ parentNode: ancestor, childDefUuid: parentCodeDefUuid })(record)\n if (children.length === 1) {\n return children[0]\n }\n }\n return undefined\n }\n\n// ancestors\n\n/**\n * Visits the specified node and its ancestors, from the node up to the root: the visit stops when the visitor returns true.\n */\nexport const visitAncestorsAndSelf = positionalRecordGetter({\n getter: ({\n record,\n node,\n visitor,\n }: RecordParams & { node: ArenaRecordNode; visitor: (node: ArenaRecordNode) => boolean | void }): void => {\n let currentNode: ArenaRecordNode | undefined = node\n while (currentNode) {\n if (visitor(currentNode)) return\n currentNode = getParent({ node: currentNode })(record)\n }\n },\n isPositional: isRecordNode,\n // deprecated form: the visit stops when stopIfFn returns true\n toParams: (node: ArenaRecordNode, visitor: (node: ArenaRecordNode) => void, stopIfFn?: () => boolean) => ({\n node,\n visitor: (visitedNode: ArenaRecordNode): boolean => {\n visitor(visitedNode)\n return !!stopIfFn?.()\n },\n }),\n})\n\n/**\n * Returns the first node satisfying the predicate among the specified node and its ancestors (from the node up to the root).\n */\nexport const findAncestor =\n (params: { node: ArenaRecordNode; predicate: (node: ArenaRecordNode) => boolean }) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const { node, predicate } = params\n let result: ArenaRecordNode | undefined = undefined\n visitAncestorsAndSelf({\n node,\n visitor: (visitedNode) => {\n if (predicate(visitedNode)) {\n result = visitedNode\n return true\n }\n return false\n },\n })(record)\n return result\n }\n\n/**\n * Returns the specified node, if it has the specified node def, or its ancestor with that node def; undefined if not found.\n */\nexport const getAncestor = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode; ancestorDefUuid: string }): ArenaRecordNode | undefined => {\n const { record, node, ancestorDefUuid } = params\n if (node.nodeDefUuid === ancestorDefUuid) return node\n\n let ancestor = getParent({ node })(record)\n while (ancestor && ancestor.nodeDefUuid !== ancestorDefUuid) {\n ancestor = getParent({ node: ancestor })(record)\n }\n return ancestor\n }\n)\n\n/**\n * Returns the list of ancestors from the given node to the root entity\n */\nexport const getAncestorsAndSelf = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode }): Array<ArenaRecordNode> => {\n const { record, node } = params\n const ancestors: Array<ArenaRecordNode> = []\n visitAncestorsAndSelf({\n node,\n visitor: (currentNode) => {\n ancestors.push(currentNode)\n },\n })(record)\n return ancestors\n }\n)\n\n// descendants\n\nexport const getDescendantsOrSelf = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode; nodeDefDescendant: NodeDef<any> }): ArenaRecordNode[] => {\n const { record, node, nodeDefDescendant } = params\n\n if (nodeDefDescendant.uuid === node.nodeDefUuid) return [node]\n\n const nodeDefDescendantFullHierarchy = [...nodeDefDescendant.meta.h, nodeDefDescendant.uuid]\n\n // 1. get the descendant node defs uuids starting from node nodeDefUuid (not inclusive) down to the specified nodeDefDescendant uuid\n const descendantNodeDefUuids = nodeDefDescendantFullHierarchy.slice(\n nodeDefDescendantFullHierarchy.indexOf(node.nodeDefUuid) + 1\n )\n // 2. for every level in the hierarchy, find the children having the nodeDefUuid equal to the current one\n let currentAncestors = [node]\n let currentDescendants: ArenaRecordNode[] = []\n for (const currentDescendantDefUuid of descendantNodeDefUuids) {\n for (const currentAncestor of currentAncestors) {\n currentDescendants.push(\n ...getChildren({ parentNode: currentAncestor, childDefUuid: currentDescendantDefUuid })(record)\n )\n }\n currentAncestors = currentDescendants\n currentDescendants = []\n }\n return currentAncestors // currentAncestors is equal to the currentDescendants of the last level\n }\n)\n\n/**\n * Returns the first descendant (or the node itself) with the specified node def, or undefined if not found.\n */\nexport const getDescendant = recordGetter(\n (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n nodeDefDescendant: NodeDef<any>\n }): ArenaRecordNode | undefined => {\n const { record, node, nodeDefDescendant } = params\n\n return getDescendantsOrSelf({ node, nodeDefDescendant })(record)[0]\n }\n)\n\nexport const isDescendantOf = (params: { node: ArenaRecordNode; ancestor: ArenaRecordNode }): boolean => {\n const { node, ancestor } = params\n return Nodes.getHierarchy(node).includes(ancestor.uuid)\n}\n\nexport const visitDescendantsAndSelf = recordGetter(\n (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n visitor: (node: ArenaRecordNode) => boolean | void\n traverseMethod?: TraverseMethod\n }): void => {\n const { record, node, visitor, traverseMethod = TraverseMethod.bfs } = params\n\n if (traverseMethod === TraverseMethod.bfs) {\n const queue = new Queue<ArenaRecordNode>()\n\n queue.enqueue(node)\n\n while (!queue.isEmpty()) {\n const visitedNode = queue.dequeue()!\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren({ parentNode: visitedNode })(record)\n queue.enqueueItems(children)\n }\n } else {\n const stack = []\n\n stack.push(node)\n\n while (stack.length > 0) {\n const visitedNode = stack.pop() as ArenaRecordNode\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren({ parentNode: visitedNode })(record)\n\n // add children to stack in reverse order\n for (let index = children.length - 1; index >= 0; index--) {\n const child = children[index]\n stack.push(child)\n }\n }\n }\n }\n)\n\nexport const findDescendantOrSelf =\n (params: { node: ArenaRecordNode; predicate: (node: ArenaRecordNode) => boolean }) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const { node, predicate } = params\n let found = undefined\n\n visitDescendantsAndSelf({\n node,\n visitor: (currentNode) => {\n if (predicate(currentNode)) {\n found = currentNode\n return true\n }\n return false\n },\n })(record)\n return found\n }\n\nconst getClosestAncestorNode = recordGetter(\n (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n dependentDef: NodeDef<NodeDefType, NodeDefProps>\n dependencyType: SurveyDependencyType\n }): ArenaRecordNode | undefined => {\n const { record, node, nodeDef, dependentDef, dependencyType } = params\n\n // 1a if dependent def is the same as node def, potentially all nodes with\n // nodeDefUuid === dependentDef.uuid in record could be dependent of nodeDef;\n // consider the root node as the closest ancestor node,\n // unless the node def references itself only among the children of its parent entity (e.g. validation \"dbh > 0\")\n if (nodeDef.uuid === dependentDef.uuid) {\n return NodeDefSelfReferences.isSelfReferenceLocal({ nodeDef, dependencyType })\n ? getParent({ node })(record)\n : getRoot(record)\n }\n // 1 find common ancestor def\n const commonAncestorDefUuid = Arrays.last(Arrays.intersection(nodeDef.meta.h, dependentDef.meta.h))\n if (!commonAncestorDefUuid) return undefined\n\n // 2 get ancestor node with common parent def\n return getAncestor({ node, ancestorDefUuid: commonAncestorDefUuid })(record)\n }\n)\n\ntype EntityKeyNodesGetterParams = {\n survey: Survey\n cycle?: string\n record: ArenaRecord\n entity: ArenaRecordNode\n keyDefs?: NodeDef<NodeDefType, NodeDefProps>[]\n}\n\nexport const getEntityKeyNodesByDefUuid = recordGetter((params: EntityKeyNodesGetterParams): NodesMap => {\n const { survey, cycle, record, entity, keyDefs } = params\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const nodeDefKeys = keyDefs ?? Surveys.getNodeDefKeys({ survey, cycle, nodeDef })\n return nodeDefKeys.reduce((acc: NodesMap, nodeDefKey) => {\n const nodeKey = getDescendant({ node: entity, nodeDefDescendant: nodeDefKey })(record)\n // missing key nodes are kept as undefined entries\n acc[nodeDefKey.uuid] = nodeKey as ArenaRecordNode\n return acc\n }, {})\n})\n\nexport const getEntityKeyNodes = recordGetter(\n ({ record, ...otherParams }: EntityKeyNodesGetterParams): ArenaRecordNode[] =>\n Object.values(getEntityKeyNodesByDefUuid(otherParams)(record))\n)\n\nexport const getEntityKeyValuesByDefUuid = recordGetter((params: EntityKeyNodesGetterParams): Dictionary<any> => {\n const { record, ...otherParams } = params\n const keyNodesByDefUuid = getEntityKeyNodesByDefUuid(otherParams)(record)\n return Object.entries(keyNodesByDefUuid).reduce((acc: Dictionary<any>, [uuid, keyNode]) => {\n acc[uuid] = keyNode?.value\n return acc\n }, {})\n})\n\nexport const getEntityKeyValues = recordGetter(({ record, ...otherParams }: EntityKeyNodesGetterParams): any[] =>\n Object.values(getEntityKeyValuesByDefUuid(otherParams)(record))\n)\n\nexport const getEntitySiblings = recordGetter(\n (params: { record: ArenaRecord; entity: ArenaRecordNode; includeSelf?: boolean }) => {\n const { record, entity, includeSelf = false } = params\n const parentEntity = getParent({ node: entity })(record)\n if (!parentEntity) return []\n const siblingEntities = getChildren({ parentNode: parentEntity, childDefUuid: entity.nodeDefUuid })(record)\n return includeSelf ? siblingEntities : siblingEntities.filter((sibling) => !Nodes.areEqual(sibling, entity))\n }\n)\n\nexport const getAttributeSiblings = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode; nodeDef: NodeDef<NodeDefType, NodeDefProps> }) => {\n const { record, node, nodeDef } = params\n const parentEntity = getParent({ node })(record)\n if (!parentEntity) return []\n const siblingParentEntities = getEntitySiblings({ entity: parentEntity })(record)\n return siblingParentEntities.reduce((siblingsAcc: ArenaRecordNode[], siblingEntity) => {\n siblingsAcc.push(...getChildren({ parentNode: siblingEntity, childDefUuid: nodeDef.uuid })(record))\n return siblingsAcc\n }, [])\n }\n)\n\nexport const getNodeIndex = recordGetter((params: { record: ArenaRecord; node: ArenaRecordNode }) => {\n const { record, node } = params\n const parentEntity = getParent({ node })(record)\n if (!parentEntity) return 0 // root entity\n const siblings = getChildren({ parentNode: parentEntity, childDefUuid: node.nodeDefUuid })(record)\n return siblings.indexOf(node)\n})\n\nexport const findEntityByKeyValues = recordGetter(\n (params: {\n survey: Survey\n cycle: string\n record: ArenaRecord\n parentEntity: ArenaRecordNode\n entityDefUuid: string\n keyValuesByDefUuid: Dictionary<any>\n }): ArenaRecordNode | undefined => {\n const { survey, cycle, record, parentEntity, entityDefUuid, keyValuesByDefUuid } = params\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entityDefUuid })\n const siblingEntities = getChildren({ parentNode: parentEntity, childDefUuid: entityDefUuid })(record)\n if (NodeDefs.isSingle(entityDef)) {\n return siblingEntities[0]\n }\n const keyDefs = Surveys.getNodeDefKeys({ survey, cycle, nodeDef: entityDef })\n\n return siblingEntities.find((siblingEntity) => {\n const siblingEntityKeyValuesByDefUuid = getEntityKeyValuesByDefUuid({ survey, entity: siblingEntity, keyDefs })(\n record\n )\n return keyDefs.every((keyDef) => {\n const keyValue = siblingEntityKeyValuesByDefUuid[keyDef.uuid]\n const keyValueSearch = keyValuesByDefUuid[keyDef.uuid]\n return NodeValues.isValueEqual({\n survey,\n nodeDef: keyDef,\n value: keyValue,\n valueSearch: keyValueSearch,\n })\n })\n })\n }\n)\n\nexport const findEntityWithSameKeysInAnotherRecord = recordGetter(\n (params: {\n survey: Survey\n cycle: string\n entityUuid: string\n record: ArenaRecord\n recordOther: ArenaRecord\n }): ArenaRecordNode | undefined => {\n const { survey, cycle, entityUuid, record, recordOther } = params\n const entity = getNodeByUuid({ uuid: entityUuid })(record)\n if (!entity) return undefined\n\n let otherRecordCurrentParentEntity = getRoot(recordOther)\n if (!otherRecordCurrentParentEntity) return undefined\n\n const entityAncestorsAndSelf = getAncestorsAndSelf({ node: entity })(record)\n const ancestorDefUuidsAndKeys = entityAncestorsAndSelf.map((ancestor) => ({\n entityDefUuid: ancestor.nodeDefUuid,\n keyValuesByDefUuid: getEntityKeyValuesByDefUuid({ survey, entity: ancestor })(record),\n }))\n\n const ancestorDefUuidsAndKeysToVisit = [...ancestorDefUuidsAndKeys].reverse()\n\n for (let index = 1; otherRecordCurrentParentEntity && index < ancestorDefUuidsAndKeysToVisit.length; index++) {\n const { entityDefUuid, keyValuesByDefUuid } = ancestorDefUuidsAndKeysToVisit[index]\n otherRecordCurrentParentEntity = findEntityByKeyValues({\n survey,\n cycle,\n parentEntity: otherRecordCurrentParentEntity,\n entityDefUuid,\n keyValuesByDefUuid,\n })(recordOther)\n }\n return otherRecordCurrentParentEntity\n }\n)\n\nexport const getDependentNodePointers = recordGetter(\n (params: {\n survey: Survey\n record: ArenaRecord\n node: ArenaRecordNode\n dependencyType: SurveyDependencyType\n includeSelf?: boolean\n filterFn?: (nodePointer: NodePointer) => boolean\n }) => {\n const { survey, record, node, dependencyType, includeSelf = false, filterFn = null } = params\n const nodeDefUuid = node.nodeDefUuid\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: nodeDefUuid })\n const dependentDefs = Surveys.getNodeDefDependents({ survey, nodeDefUuid, dependencyType })\n const nodePointers: Array<NodePointer> = []\n\n const addToNodePointers = (nodePointer: NodePointer): void => {\n if (filterFn === null || filterFn(nodePointer)) {\n nodePointers.push(nodePointer)\n }\n }\n\n for (const dependentDef of dependentDefs) {\n // 1 find common ancestor node\n const commonAncestorNode = getClosestAncestorNode({ node, nodeDef, dependentDef, dependencyType })(record)\n if (!commonAncestorNode) continue\n\n const nodeDefDependentParent = Surveys.getNodeDefParent({ survey, nodeDef: dependentDef })\n if (!nodeDefDependentParent) throw new SystemError('record.nodes.dependents.dependencyOnRootFound')\n\n // 2 find descendant nodes of common parent node with nodeDefUuid = dependentDef uuid\n const dependentContextNodes = getDescendantsOrSelf({\n node: commonAncestorNode,\n nodeDefDescendant: nodeDefDependentParent,\n })(record)\n\n for (const dependentContextNode of dependentContextNodes) {\n addToNodePointers({\n nodeCtx: dependentContextNode,\n nodeDef: dependentDef,\n })\n }\n }\n if (includeSelf) {\n const parentNode = getParent({ node })(record)\n if (parentNode) {\n addToNodePointers({\n nodeCtx: parentNode,\n nodeDef,\n })\n }\n }\n\n return nodePointers\n }\n)\n\nexport const getAncestorCodePath = recordGetter(\n (params: {\n survey: Survey\n record: ArenaRecord\n parentNode: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>\n }): string[] => {\n const { record, parentNode, nodeDef, survey } = params\n\n const getCodeAttributeItemCode = (codeAttribute: ArenaRecordNode | undefined): string => {\n const codeItemUuid = codeAttribute ? NodeValues.getItemUuid(codeAttribute) : undefined\n if (!codeItemUuid) return ''\n const item = Surveys.getCategoryItemByUuid({ survey, itemUuid: codeItemUuid })\n return item?.props.code ?? ''\n }\n\n const codePaths = []\n let currentParentCodeAttribute = getParentCodeAttribute({ parentNode, nodeDef })(record)\n\n while (currentParentCodeAttribute) {\n const ancestorItemCode = getCodeAttributeItemCode(currentParentCodeAttribute)\n codePaths.unshift(ancestorItemCode)\n const ancestorCodeDef = Surveys.getNodeDefByUuid({\n survey,\n uuid: currentParentCodeAttribute.nodeDefUuid,\n }) as NodeDefCode\n currentParentCodeAttribute = getParentCodeAttribute({ parentNode, nodeDef: ancestorCodeDef })(record)\n }\n return codePaths\n }\n)\n\nexport const getCategoryItemUuid = recordGetter(\n (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>\n record: ArenaRecord\n parentNode: ArenaRecordNode\n code: string\n }): string | undefined => {\n const { survey, nodeDef, record, parentNode, code } = params\n const categoryUuid = nodeDef.props.categoryUuid\n\n const codePaths = [...getAncestorCodePath({ survey, parentNode, nodeDef })(record), code]\n\n const item = Surveys.getCategoryItemByCodePaths({ survey, categoryUuid, codePaths })\n\n return item?.uuid\n }\n)\n\nexport const isNodeFilledByUser = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): boolean =>\n !!findDescendantOrSelf({ node, predicate: (visitedNode) => Nodes.hasUserInputValue(visitedNode) })(record),\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const isNodeEmpty = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): boolean =>\n !isNodeFilledByUser({ node })(record),\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const isEmpty = (record: ArenaRecord): boolean => {\n const rootNode = getRoot(record)\n return rootNode ? isNodeEmpty({ node: rootNode })(record) : true\n}\n\nexport const getStep = (record: ArenaRecord): string => record.step ?? RECORD_STEP_DEFAULT\n\nexport const isInAnalysisStep = (record: ArenaRecord): boolean => getStep(record) === RecordStepAnalysisCode\n"]}
1
+ {"version":3,"file":"recordGetters.js","sourceRoot":"","sources":["../../../src/record/_records/recordGetters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,yCAAyD;AACzD,uCAA0D;AAC1D,qCAA0E;AAC1E,sDAAkD;AAClD,2CAA2G;AAC3G,yCAAoD;AAEpD,uCAA2C;AAC3C,sCAA4D;AAC5D,8CAAsD;AACtD,qEAAiE;AACjE,mEAA+D;AAc/D,MAAM,cAAc,GAAG,CAAC,MAAc,EAA0B,EAAE,CAAC,QAAQ,IAAI,MAAM,CAAA;AAErF,MAAM,YAAY,GAAG,CAA4B,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AE,MAAM,EAAE,IAAI,EAA4C,EAAW,EAAE,CAC9E,CAAC,IAAA,QAAA,kBAAkB,EAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACvC,YAAY,EAAE,YAAY;IAC1B,QAAQ,EAAE,CAAC,IAAqB,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;CAChD,CAAC,CAAA;AAEK,MAAM,OAAO,GAAG,CAAC,MAAmB,EAAW,EAAE;IACtD,MAAM,QAAQ,GAAG,IAAA,QAAA,OAAO,EAAC,MAAM,CAAC,CAAA;IAChC,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAA,QAAA,WAAW,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAClE,CAAC,CAAA;AAHY,QAAA,OAAO,GAAP,OAAO,CAGnB;AAEM,MAAM,OAAO,GAAG,CAAC,MAAmB,EAAU,EAAE,wBAAC,MAAM,CAAC,IAAI,mCAAI,4BAAmB,GAAA,CAAA;AAA7E,QAAA,OAAO,GAAP,OAAO,CAAsE;AAEnF,MAAM,gBAAgB,GAAG,CAAC,MAAmB,EAAW,EAAE,CAAC,IAAA,QAAA,OAAO,EAAC,MAAM,CAAC,KAAK,mCAAsB,CAAA;AAA/F,QAAA,gBAAgB,GAAhB,gBAAgB,CAA+E","sourcesContent":["import { Dictionary, TraverseMethod } from '../../common'\nimport { SystemError, SystemErrorKeys } from '../../error'\nimport { ArenaRecordNode, NodePointer, Nodes, NodesMap } from '../../node'\nimport { NodeValues } from '../../node/nodeValues'\nimport { NodeDef, NodeDefCode, NodeDefCodeProps, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { defaultCycle, Surveys } from '../../survey'\nimport { Survey, SurveyDependencyType } from '../../survey/survey'\nimport { Arrays, Queue } from '../../utils'\nimport { ArenaRecord, RECORD_STEP_DEFAULT } from '../record'\nimport { RecordStepAnalysisCode } from '../recordStep'\nimport { RecordNodesIndexReader } from './recordNodesIndexReader'\nimport { NodeDefSelfReferences } from './nodeDefSelfReferences'\n\nexport type RecordParams = { record: ArenaRecord }\n\n/**\n * Record getter: takes the parameters first and the record as separate (curried) parameter: `getter(params)(record)`.\n * The deprecated form, with the record inside the parameters (`getter({ record, ...params })`), is still supported.\n */\nexport type RecordGetter<P extends RecordParams, R> = {\n /** @deprecated Pass the record as separate parameter: `getter(params)(record)` */\n (params: P): R\n (params: Omit<P, 'record'>): (record: ArenaRecord) => R\n}\n\nconst isRecordParams = (params: object): params is RecordParams => 'record' in params\n\nconst recordGetter = <P extends RecordParams, R>(getter: (params: P) => R): RecordGetter<P, R> =>\n ((params: P | Omit<P, 'record'>) =>\n isRecordParams(params)\n ? getter(params as P)\n : (record: ArenaRecord) => getter({ ...params, record } as P)) as RecordGetter<P, R>\n\n/**\n * Record getter (with parameters object) that also supports the deprecated form with positional parameters:\n * `getter(arg1, arg2)(record)`.\n */\nexport type PositionalRecordGetter<P, A extends unknown[], R> = {\n (params: P): (record: ArenaRecord) => R\n /** @deprecated Pass the parameters as an object: `getter({ ...params })(record)` */\n (...args: A): (record: ArenaRecord) => R\n}\n\nconst positionalRecordGetter = <P, A extends unknown[], R>(params: {\n getter: (params: P & RecordParams) => R\n isPositional: (firstArg: unknown) => boolean\n toParams: (...args: A) => NoInfer<P>\n}): PositionalRecordGetter<P, A, R> => {\n const { getter, isPositional, toParams } = params\n return ((...args: unknown[]) => {\n const getterParams = isPositional(args[0]) ? toParams(...(args as A)) : (args[0] as P)\n return (record: ArenaRecord) => getter({ ...getterParams, record })\n }) as PositionalRecordGetter<P, A, R>\n}\n\nconst isRecordNode = (arg: unknown): arg is ArenaRecordNode =>\n typeof arg === 'object' && arg !== null && 'uuid' in arg && 'nodeDefUuid' in arg\nconst isString = (arg: unknown): arg is string => typeof arg === 'string'\n\nexport const getCycle = (record: ArenaRecord): string => record.cycle ?? defaultCycle\n\nexport const getNodes = (record: ArenaRecord): Dictionary<ArenaRecordNode> => record.nodes ?? {}\n\nexport const getNodesArray = (record: ArenaRecord): ArenaRecordNode[] => Object.values(getNodes(record))\n\n/**\n * Returns the node with the specified uuid, or undefined if not found.\n * Like the other node getters, it does not throw an error when the node is not found.\n */\nexport const getNodeByUuid = positionalRecordGetter({\n getter: ({ record, uuid }: RecordParams & { uuid: string }): ArenaRecordNode | undefined => record.nodes?.[uuid],\n isPositional: isString,\n toParams: (uuid: string) => ({ uuid }),\n})\n\nexport const getNodesByUuids = positionalRecordGetter({\n getter: ({ record, uuids }: RecordParams & { uuids: string[] }): ArenaRecordNode[] =>\n uuids.map((uuid: string) => record.nodes?.[uuid]) as ArenaRecordNode[],\n isPositional: Array.isArray,\n toParams: (uuids: string[]) => ({ uuids }),\n})\n\n/**\n * Returns the root node, or undefined if the record has no nodes.\n */\nexport const getRoot = (record: ArenaRecord): ArenaRecordNode | undefined => {\n const rootUuid = record._nodesIndex ? RecordNodesIndexReader.getNodeRootUuid(record._nodesIndex) : null\n if (rootUuid) {\n return getNodeByUuid({ uuid: rootUuid })(record)\n }\n return getNodesArray(record).find((node) => !node.parentUuid)\n}\n\nexport const getChildren = positionalRecordGetter({\n getter: ({\n record,\n parentNode,\n childDefUuid,\n }: RecordParams & { parentNode: ArenaRecordNode; childDefUuid?: string }): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const childrenUuids = childDefUuid\n ? RecordNodesIndexReader.getNodeUuidsByParentAndChildDef({\n parentNodeUuid: parentNode.uuid,\n childDefUuid,\n })(record._nodesIndex)\n : RecordNodesIndexReader.getNodeUuidsByParent(parentNode.uuid)(record._nodesIndex)\n return getNodesByUuids({ uuids: childrenUuids })(record)\n }\n return getNodesArray(record).filter(\n (node) => node.parentUuid === parentNode.uuid && (!childDefUuid || node.nodeDefUuid == childDefUuid)\n )\n },\n isPositional: isRecordNode,\n toParams: (parentNode: ArenaRecordNode, childDefUuid?: string) => ({ parentNode, childDefUuid }),\n})\n\n/**\n * Returns the only child of the parent node with the specified node def, or undefined if not found.\n * Throws an error if more than one child is found.\n */\nexport const getChild = positionalRecordGetter({\n getter: ({\n record,\n parentNode,\n childDefUuid,\n }: RecordParams & { parentNode: ArenaRecordNode; childDefUuid: string }): ArenaRecordNode | undefined => {\n const children = getChildren({ parentNode, childDefUuid })(record)\n if (children.length > 1) {\n const errorParams = { childDefUuid, parentNodeUuid: parentNode.uuid, recordUuid: record.uuid }\n throw new SystemError(SystemErrorKeys.record.multipleNodesFound, errorParams)\n }\n return children[0]\n },\n isPositional: isRecordNode,\n toParams: (parentNode: ArenaRecordNode, childDefUuid: string) => ({ parentNode, childDefUuid }),\n})\n\nexport const getParent = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): ArenaRecordNode | undefined =>\n node.parentUuid ? getNodeByUuid({ uuid: node.parentUuid })(record) : undefined,\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const getNodesByDefUuid = positionalRecordGetter({\n getter: ({ record, nodeDefUuid }: RecordParams & { nodeDefUuid: string }): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeUuidsByDef(nodeDefUuid)(record._nodesIndex)\n return getNodesByUuids({ uuids: nodeUuids })(record)\n }\n return getNodesArray(record).filter((node) => node.nodeDefUuid === nodeDefUuid)\n },\n isPositional: isString,\n toParams: (nodeDefUuid: string) => ({ nodeDefUuid }),\n})\n\nconst isNodeFlagTrue = (isChildFlagTrue: (parent: ArenaRecordNode, nodeDefUuid: string) => boolean) =>\n recordGetter((params: RecordParams & { node: ArenaRecordNode }): boolean => {\n const { record, node } = params\n const ancestorsAndSelf = getAncestorsAndSelf({ node })(record)\n for (let i = 0; i < ancestorsAndSelf.length - 1; i++) {\n const child = ancestorsAndSelf[i]\n const parent = ancestorsAndSelf[i + 1]\n if (!isChildFlagTrue(parent, child.nodeDefUuid)) return false\n }\n return true\n })\n\nexport const isNodeApplicable = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildApplicable(parent, nodeDefUuid))\nexport const isNodeEditable = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildEditable(parent, nodeDefUuid))\nexport const isNodeVisible = isNodeFlagTrue((parent, nodeDefUuid) => Nodes.isChildVisible(parent, nodeDefUuid))\n\nexport const getDependentCodeAttributes = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): ArenaRecordNode[] => {\n if (record._nodesIndex) {\n const nodeUuids = RecordNodesIndexReader.getNodeCodeDependentUuids(node.uuid)(record._nodesIndex)\n return getNodesByUuids({ uuids: nodeUuids })(record)\n }\n throw new SystemError(SystemErrorKeys.record.nodesIndexNotInitialized)\n },\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const getParentCodeAttribute =\n (params: { parentNode: ArenaRecordNode; nodeDef: NodeDefCode }) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const { parentNode, nodeDef } = params\n\n const parentCodeDefUuid = NodeDefs.getParentCodeDefUuid(nodeDef)\n if (!parentCodeDefUuid) return undefined\n\n const ancestors = getAncestorsAndSelf({ node: parentNode })(record)\n for (const ancestor of ancestors) {\n const children = getChildren({ parentNode: ancestor, childDefUuid: parentCodeDefUuid })(record)\n if (children.length === 1) {\n return children[0]\n }\n }\n return undefined\n }\n\n// ancestors\n\n/**\n * Visits the specified node and its ancestors, from the node up to the root: the visit stops when the visitor returns true.\n */\nexport const visitAncestorsAndSelf = positionalRecordGetter({\n getter: ({\n record,\n node,\n visitor,\n }: RecordParams & { node: ArenaRecordNode; visitor: (node: ArenaRecordNode) => boolean | void }): void => {\n let currentNode: ArenaRecordNode | undefined = node\n while (currentNode) {\n if (visitor(currentNode)) return\n currentNode = getParent({ node: currentNode })(record)\n }\n },\n isPositional: isRecordNode,\n // deprecated form: the visit stops when stopIfFn returns true\n toParams: (node: ArenaRecordNode, visitor: (node: ArenaRecordNode) => void, stopIfFn?: () => boolean) => ({\n node,\n visitor: (visitedNode: ArenaRecordNode): boolean => {\n visitor(visitedNode)\n return !!stopIfFn?.()\n },\n }),\n})\n\n/**\n * Returns the first node satisfying the predicate among the specified node and its ancestors (from the node up to the root).\n */\nexport const findAncestor =\n (params: { node: ArenaRecordNode; predicate: (node: ArenaRecordNode) => boolean }) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const { node, predicate } = params\n let result: ArenaRecordNode | undefined = undefined\n visitAncestorsAndSelf({\n node,\n visitor: (visitedNode) => {\n if (predicate(visitedNode)) {\n result = visitedNode\n return true\n }\n return false\n },\n })(record)\n return result\n }\n\n/**\n * Returns the specified node, if it has the specified node def, or its ancestor with that node def; undefined if not found.\n */\nexport const getAncestor = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode; ancestorDefUuid: string }): ArenaRecordNode | undefined => {\n const { record, node, ancestorDefUuid } = params\n if (node.nodeDefUuid === ancestorDefUuid) return node\n\n let ancestor = getParent({ node })(record)\n while (ancestor && ancestor.nodeDefUuid !== ancestorDefUuid) {\n ancestor = getParent({ node: ancestor })(record)\n }\n return ancestor\n }\n)\n\n/**\n * Returns the list of ancestors from the given node to the root entity\n */\nexport const getAncestorsAndSelf = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode }): Array<ArenaRecordNode> => {\n const { record, node } = params\n const ancestors: Array<ArenaRecordNode> = []\n visitAncestorsAndSelf({\n node,\n visitor: (currentNode) => {\n ancestors.push(currentNode)\n },\n })(record)\n return ancestors\n }\n)\n\n// descendants\n\nexport const getDescendantsOrSelf = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode; nodeDefDescendant: NodeDef<any> }): ArenaRecordNode[] => {\n const { record, node, nodeDefDescendant } = params\n\n if (nodeDefDescendant.uuid === node.nodeDefUuid) return [node]\n\n const nodeDefDescendantFullHierarchy = [...nodeDefDescendant.meta.h, nodeDefDescendant.uuid]\n\n // 1. get the descendant node defs uuids starting from node nodeDefUuid (not inclusive) down to the specified nodeDefDescendant uuid\n const descendantNodeDefUuids = nodeDefDescendantFullHierarchy.slice(\n nodeDefDescendantFullHierarchy.indexOf(node.nodeDefUuid) + 1\n )\n // 2. for every level in the hierarchy, find the children having the nodeDefUuid equal to the current one\n let currentAncestors = [node]\n let currentDescendants: ArenaRecordNode[] = []\n for (const currentDescendantDefUuid of descendantNodeDefUuids) {\n for (const currentAncestor of currentAncestors) {\n currentDescendants.push(\n ...getChildren({ parentNode: currentAncestor, childDefUuid: currentDescendantDefUuid })(record)\n )\n }\n currentAncestors = currentDescendants\n currentDescendants = []\n }\n return currentAncestors // currentAncestors is equal to the currentDescendants of the last level\n }\n)\n\n/**\n * Returns the first descendant (or the node itself) with the specified node def, or undefined if not found.\n */\nexport const getDescendant = recordGetter(\n (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n nodeDefDescendant: NodeDef<any>\n }): ArenaRecordNode | undefined => {\n const { record, node, nodeDefDescendant } = params\n\n return getDescendantsOrSelf({ node, nodeDefDescendant })(record)[0]\n }\n)\n\nexport const isDescendantOf = (params: { node: ArenaRecordNode; ancestor: ArenaRecordNode }): boolean => {\n const { node, ancestor } = params\n return Nodes.getHierarchy(node).includes(ancestor.uuid)\n}\n\nexport const visitDescendantsAndSelf = recordGetter(\n (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n visitor: (node: ArenaRecordNode) => boolean | void\n traverseMethod?: TraverseMethod\n }): void => {\n const { record, node, visitor, traverseMethod = TraverseMethod.bfs } = params\n\n if (traverseMethod === TraverseMethod.bfs) {\n const queue = new Queue<ArenaRecordNode>()\n\n queue.enqueue(node)\n\n while (!queue.isEmpty()) {\n const visitedNode = queue.dequeue()!\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren({ parentNode: visitedNode })(record)\n queue.enqueueItems(children)\n }\n } else {\n const stack = []\n\n stack.push(node)\n\n while (stack.length > 0) {\n const visitedNode = stack.pop() as ArenaRecordNode\n\n if (visitor(visitedNode)) {\n // stop if visitor returns true\n return\n }\n\n const children = getChildren({ parentNode: visitedNode })(record)\n\n // add children to stack in reverse order\n for (let index = children.length - 1; index >= 0; index--) {\n const child = children[index]\n stack.push(child)\n }\n }\n }\n }\n)\n\nexport const findDescendantOrSelf =\n (params: { node: ArenaRecordNode; predicate: (node: ArenaRecordNode) => boolean }) =>\n (record: ArenaRecord): ArenaRecordNode | undefined => {\n const { node, predicate } = params\n let found = undefined\n\n visitDescendantsAndSelf({\n node,\n visitor: (currentNode) => {\n if (predicate(currentNode)) {\n found = currentNode\n return true\n }\n return false\n },\n })(record)\n return found\n }\n\nconst getClosestAncestorNode = recordGetter(\n (params: {\n record: ArenaRecord\n node: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n dependentDef: NodeDef<NodeDefType, NodeDefProps>\n dependencyType: SurveyDependencyType\n }): ArenaRecordNode | undefined => {\n const { record, node, nodeDef, dependentDef, dependencyType } = params\n\n // 1a if dependent def is the same as node def, potentially all nodes with\n // nodeDefUuid === dependentDef.uuid in record could be dependent of nodeDef;\n // consider the root node as the closest ancestor node,\n // unless the node def references itself only among the children of its parent entity (e.g. validation \"dbh > 0\")\n if (nodeDef.uuid === dependentDef.uuid) {\n return NodeDefSelfReferences.isSelfReferenceLocal({ nodeDef, dependencyType })\n ? getParent({ node })(record)\n : getRoot(record)\n }\n // 1 find common ancestor def\n const commonAncestorDefUuid = Arrays.last(Arrays.intersection(nodeDef.meta.h, dependentDef.meta.h))\n if (!commonAncestorDefUuid) return undefined\n\n // 2 get ancestor node with common parent def\n return getAncestor({ node, ancestorDefUuid: commonAncestorDefUuid })(record)\n }\n)\n\ntype EntityKeyNodesGetterParams = {\n survey: Survey\n cycle?: string\n record: ArenaRecord\n entity: ArenaRecordNode\n keyDefs?: NodeDef<NodeDefType, NodeDefProps>[]\n}\n\nexport const getEntityKeyNodesByDefUuid = recordGetter((params: EntityKeyNodesGetterParams): NodesMap => {\n const { survey, cycle, record, entity, keyDefs } = params\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: entity.nodeDefUuid })\n const nodeDefKeys = keyDefs ?? Surveys.getNodeDefKeys({ survey, cycle, nodeDef })\n return nodeDefKeys.reduce((acc: NodesMap, nodeDefKey) => {\n const nodeKey = getDescendant({ node: entity, nodeDefDescendant: nodeDefKey })(record)\n // missing key nodes are kept as undefined entries\n acc[nodeDefKey.uuid] = nodeKey as ArenaRecordNode\n return acc\n }, {})\n})\n\nexport const getEntityKeyNodes = recordGetter(\n ({ record, ...otherParams }: EntityKeyNodesGetterParams): ArenaRecordNode[] =>\n Object.values(getEntityKeyNodesByDefUuid(otherParams)(record))\n)\n\nexport const getEntityKeyValuesByDefUuid = recordGetter((params: EntityKeyNodesGetterParams): Dictionary<any> => {\n const { record, ...otherParams } = params\n const keyNodesByDefUuid = getEntityKeyNodesByDefUuid(otherParams)(record)\n return Object.entries(keyNodesByDefUuid).reduce((acc: Dictionary<any>, [uuid, keyNode]) => {\n acc[uuid] = keyNode?.value\n return acc\n }, {})\n})\n\nexport const getEntityKeyValues = recordGetter(({ record, ...otherParams }: EntityKeyNodesGetterParams): any[] =>\n Object.values(getEntityKeyValuesByDefUuid(otherParams)(record))\n)\n\nexport const getEntitySiblings = recordGetter(\n (params: { record: ArenaRecord; entity: ArenaRecordNode; includeSelf?: boolean }) => {\n const { record, entity, includeSelf = false } = params\n const parentEntity = getParent({ node: entity })(record)\n if (!parentEntity) return []\n const siblingEntities = getChildren({ parentNode: parentEntity, childDefUuid: entity.nodeDefUuid })(record)\n return includeSelf ? siblingEntities : siblingEntities.filter((sibling) => !Nodes.areEqual(sibling, entity))\n }\n)\n\nexport const getAttributeSiblings = recordGetter(\n (params: { record: ArenaRecord; node: ArenaRecordNode; nodeDef: NodeDef<NodeDefType, NodeDefProps> }) => {\n const { record, node, nodeDef } = params\n const parentEntity = getParent({ node })(record)\n if (!parentEntity) return []\n const siblingParentEntities = getEntitySiblings({ entity: parentEntity })(record)\n return siblingParentEntities.reduce((siblingsAcc: ArenaRecordNode[], siblingEntity) => {\n siblingsAcc.push(...getChildren({ parentNode: siblingEntity, childDefUuid: nodeDef.uuid })(record))\n return siblingsAcc\n }, [])\n }\n)\n\nexport const getNodeIndex = recordGetter((params: { record: ArenaRecord; node: ArenaRecordNode }) => {\n const { record, node } = params\n const parentEntity = getParent({ node })(record)\n if (!parentEntity) return 0 // root entity\n const siblings = getChildren({ parentNode: parentEntity, childDefUuid: node.nodeDefUuid })(record)\n return siblings.indexOf(node)\n})\n\nexport const findEntityByKeyValues = recordGetter(\n (params: {\n survey: Survey\n cycle: string\n record: ArenaRecord\n parentEntity: ArenaRecordNode\n entityDefUuid: string\n keyValuesByDefUuid: Dictionary<any>\n }): ArenaRecordNode | undefined => {\n const { survey, cycle, record, parentEntity, entityDefUuid, keyValuesByDefUuid } = params\n const entityDef = Surveys.getNodeDefByUuid({ survey, uuid: entityDefUuid })\n const siblingEntities = getChildren({ parentNode: parentEntity, childDefUuid: entityDefUuid })(record)\n if (NodeDefs.isSingle(entityDef)) {\n return siblingEntities[0]\n }\n const keyDefs = Surveys.getNodeDefKeys({ survey, cycle, nodeDef: entityDef })\n\n return siblingEntities.find((siblingEntity) => {\n const siblingEntityKeyValuesByDefUuid = getEntityKeyValuesByDefUuid({ survey, entity: siblingEntity, keyDefs })(\n record\n )\n return keyDefs.every((keyDef) => {\n const keyValue = siblingEntityKeyValuesByDefUuid[keyDef.uuid]\n const keyValueSearch = keyValuesByDefUuid[keyDef.uuid]\n return NodeValues.isValueEqual({\n survey,\n nodeDef: keyDef,\n value: keyValue,\n valueSearch: keyValueSearch,\n })\n })\n })\n }\n)\n\nexport const findEntityWithSameKeysInAnotherRecord = recordGetter(\n (params: {\n survey: Survey\n cycle: string\n entityUuid: string\n record: ArenaRecord\n recordOther: ArenaRecord\n }): ArenaRecordNode | undefined => {\n const { survey, cycle, entityUuid, record, recordOther } = params\n const entity = getNodeByUuid({ uuid: entityUuid })(record)\n if (!entity) return undefined\n\n let otherRecordCurrentParentEntity = getRoot(recordOther)\n if (!otherRecordCurrentParentEntity) return undefined\n\n const entityAncestorsAndSelf = getAncestorsAndSelf({ node: entity })(record)\n const ancestorDefUuidsAndKeys = entityAncestorsAndSelf.map((ancestor) => ({\n entityDefUuid: ancestor.nodeDefUuid,\n keyValuesByDefUuid: getEntityKeyValuesByDefUuid({ survey, entity: ancestor })(record),\n }))\n\n const ancestorDefUuidsAndKeysToVisit = [...ancestorDefUuidsAndKeys].reverse()\n\n for (let index = 1; otherRecordCurrentParentEntity && index < ancestorDefUuidsAndKeysToVisit.length; index++) {\n const { entityDefUuid, keyValuesByDefUuid } = ancestorDefUuidsAndKeysToVisit[index]\n otherRecordCurrentParentEntity = findEntityByKeyValues({\n survey,\n cycle,\n parentEntity: otherRecordCurrentParentEntity,\n entityDefUuid,\n keyValuesByDefUuid,\n })(recordOther)\n }\n return otherRecordCurrentParentEntity\n }\n)\n\nexport const getDependentNodePointers = recordGetter(\n (params: {\n survey: Survey\n record: ArenaRecord\n node: ArenaRecordNode\n dependencyType: SurveyDependencyType\n includeSelf?: boolean\n filterFn?: (nodePointer: NodePointer) => boolean\n }) => {\n const { survey, record, node, dependencyType, includeSelf = false, filterFn = null } = params\n const nodeDefUuid = node.nodeDefUuid\n const nodeDef = Surveys.getNodeDefByUuid({ survey, uuid: nodeDefUuid })\n const dependentDefs = Surveys.getNodeDefDependents({ survey, nodeDefUuid, dependencyType })\n const nodePointers: Array<NodePointer> = []\n\n const addToNodePointers = (nodePointer: NodePointer): void => {\n if (filterFn === null || filterFn(nodePointer)) {\n nodePointers.push(nodePointer)\n }\n }\n\n for (const dependentDef of dependentDefs) {\n // 1 find common ancestor node\n const commonAncestorNode = getClosestAncestorNode({ node, nodeDef, dependentDef, dependencyType })(record)\n if (!commonAncestorNode) continue\n\n const nodeDefDependentParent = Surveys.getNodeDefParent({ survey, nodeDef: dependentDef })\n if (!nodeDefDependentParent) throw new SystemError(SystemErrorKeys.record.dependencyOnRootFound)\n\n // 2 find descendant nodes of common parent node with nodeDefUuid = dependentDef uuid\n const dependentContextNodes = getDescendantsOrSelf({\n node: commonAncestorNode,\n nodeDefDescendant: nodeDefDependentParent,\n })(record)\n\n for (const dependentContextNode of dependentContextNodes) {\n addToNodePointers({\n nodeCtx: dependentContextNode,\n nodeDef: dependentDef,\n })\n }\n }\n if (includeSelf) {\n const parentNode = getParent({ node })(record)\n if (parentNode) {\n addToNodePointers({\n nodeCtx: parentNode,\n nodeDef,\n })\n }\n }\n\n return nodePointers\n }\n)\n\nexport const getAncestorCodePath = recordGetter(\n (params: {\n survey: Survey\n record: ArenaRecord\n parentNode: ArenaRecordNode\n nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>\n }): string[] => {\n const { record, parentNode, nodeDef, survey } = params\n\n const getCodeAttributeItemCode = (codeAttribute: ArenaRecordNode | undefined): string => {\n const codeItemUuid = codeAttribute ? NodeValues.getItemUuid(codeAttribute) : undefined\n if (!codeItemUuid) return ''\n const item = Surveys.getCategoryItemByUuid({ survey, itemUuid: codeItemUuid })\n return item?.props.code ?? ''\n }\n\n const codePaths = []\n let currentParentCodeAttribute = getParentCodeAttribute({ parentNode, nodeDef })(record)\n\n while (currentParentCodeAttribute) {\n const ancestorItemCode = getCodeAttributeItemCode(currentParentCodeAttribute)\n codePaths.unshift(ancestorItemCode)\n const ancestorCodeDef = Surveys.getNodeDefByUuid({\n survey,\n uuid: currentParentCodeAttribute.nodeDefUuid,\n }) as NodeDefCode\n currentParentCodeAttribute = getParentCodeAttribute({ parentNode, nodeDef: ancestorCodeDef })(record)\n }\n return codePaths\n }\n)\n\nexport const getCategoryItemUuid = recordGetter(\n (params: {\n survey: Survey\n nodeDef: NodeDef<NodeDefType.code, NodeDefCodeProps>\n record: ArenaRecord\n parentNode: ArenaRecordNode\n code: string\n }): string | undefined => {\n const { survey, nodeDef, record, parentNode, code } = params\n const categoryUuid = nodeDef.props.categoryUuid\n\n const codePaths = [...getAncestorCodePath({ survey, parentNode, nodeDef })(record), code]\n\n const item = Surveys.getCategoryItemByCodePaths({ survey, categoryUuid, codePaths })\n\n return item?.uuid\n }\n)\n\nexport const isNodeFilledByUser = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): boolean =>\n !!findDescendantOrSelf({ node, predicate: (visitedNode) => Nodes.hasUserInputValue(visitedNode) })(record),\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const isNodeEmpty = positionalRecordGetter({\n getter: ({ record, node }: RecordParams & { node: ArenaRecordNode }): boolean =>\n !isNodeFilledByUser({ node })(record),\n isPositional: isRecordNode,\n toParams: (node: ArenaRecordNode) => ({ node }),\n})\n\nexport const isEmpty = (record: ArenaRecord): boolean => {\n const rootNode = getRoot(record)\n return rootNode ? isNodeEmpty({ node: rootNode })(record) : true\n}\n\nexport const getStep = (record: ArenaRecord): string => record.step ?? RECORD_STEP_DEFAULT\n\nexport const isInAnalysisStep = (record: ArenaRecord): boolean => getStep(record) === RecordStepAnalysisCode\n"]}
@@ -16,11 +16,11 @@ const getNodesOrValues = (params) => {
16
16
  if (single) {
17
17
  if (referencedNodes.length === 0) {
18
18
  // do not throw error if node is missing, consider its value as null
19
- // throw new SystemError('expression.nodeNotFoundForNodeDef', { nodeDefName: propName })
19
+ // throw new SystemError(SystemErrorKeys.expression.nodeNotFoundForNodeDef, { nodeDefName: propName })
20
20
  return [];
21
21
  }
22
22
  if (referencedNodes.length > 1)
23
- throw new error_1.SystemError('expression.multipleNodesFoundForNodeDef', { nodeDefName: propName });
23
+ throw new error_1.SystemError(error_1.SystemErrorKeys.expression.multipleNodesFoundForNodeDef, { nodeDefName: propName });
24
24
  }
25
25
  if (nodeDefReferenced.type === nodeDef_1.NodeDefType.entity || evaluateToNode) {
26
26
  // return nodes
@@ -33,7 +33,7 @@ const evaluateIdentifierOnNode = (params) => {
33
33
  const { survey, record, nodeObject, evaluateToNode = false, propName } = params;
34
34
  const { nodeDefUuid: nodeDefObjectUuid, value } = nodeObject;
35
35
  if (!nodeDefObjectUuid) {
36
- throw new error_1.SystemError('expression.identifierNotFound', { name: propName });
36
+ throw new error_1.SystemError(error_1.SystemErrorKeys.expression.identifierNotFound, { name: propName });
37
37
  }
38
38
  const nodeDefObject = survey_1.Surveys.getNodeDefByUuid({ survey, uuid: nodeDefObjectUuid });
39
39
  // node value prop (native)
@@ -47,7 +47,7 @@ const evaluateIdentifierOnNode = (params) => {
47
47
  return nodeValues_1.NodeValues.getNodeValueProp({ nodeDef: nodeDefObject, node: nodeObject, prop: propName });
48
48
  }
49
49
  else {
50
- throw new error_1.SystemError('expression.invalidAttributeValuePropertyName', {
50
+ throw new error_1.SystemError(error_1.SystemErrorKeys.expression.invalidAttributeValuePropertyName, {
51
51
  attributeName: nodeDef_1.NodeDefs.getName(nodeDefObject),
52
52
  propName,
53
53
  });
@@ -55,7 +55,7 @@ const evaluateIdentifierOnNode = (params) => {
55
55
  }
56
56
  const nodeDefReferenced = survey_1.Surveys.findNodeDefByName({ survey, name: propName });
57
57
  if (!nodeDefReferenced) {
58
- throw new error_1.SystemError('expression.identifierNotFound', { name: propName });
58
+ throw new error_1.SystemError(error_1.SystemErrorKeys.expression.identifierNotFound, { name: propName });
59
59
  }
60
60
  if (nodeObject.nodeDefUuid === nodeDefReferenced.uuid) {
61
61
  // the referenced node is the current node itself
@@ -1 +1 @@
1
- {"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../../../src/record/recordExpressionEvaluator/node/identifier/identifier.ts"],"names":[],"mappings":";;;AAAA,uDAAiF;AACjF,kFAAuF;AAEvF,iDAAoE;AACpE,8CAA0C;AAC1C,4DAAwD;AACxD,+CAAoD;AAEpD,+CAA2C;AAC3C,6CAA+C;AAC/C,iEAA6D;AAG7D,MAAM,gBAAgB,GAAG,CAAC,MAMzB,EAAS,EAAE;IACV,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,MAAM,CAAA;IACv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AC;YACnC,uDAAuD;YACvD,aAAO,MAAA,IAAI,CAAC,KAAK,0CAAG,QAAQ,CAAC,mCAAI,MAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,KAAK,0CAAG,QAAQ,CAAC,CAAA;QAChE,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;YACjC,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;gBAC3C,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;oBAChD,MAAM;oBACN,MAAM;oBACN,UAAU,EAAE,WAAW;oBACvB,cAAc;oBACd,QAAQ;iBACT,CAAC,CAAA;gBACF,OAAO,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAA;YAChF,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,wBAAwB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC1G,CAAC;CACF","sourcesContent":["import { ExpressionVariable, IdentifierExpression } from '../../../../expression'\nimport { IdentifierEvaluator } from '../../../../expression/javascript/node/identifier'\nimport { ArenaRecordNode } from '../../../../node'\nimport { NodeDef, NodeDefs, NodeDefType } from '../../../../nodeDef'\nimport { Records } from '../../../records'\nimport { NodeValues } from '../../../../node/nodeValues'\nimport { Survey, Surveys } from '../../../../survey'\nimport { RecordExpressionContext } from '../../context'\nimport { NodesFinder } from './nodesFinder'\nimport { SystemError } from '../../../../error'\nimport { NodeValueExtractor } from '../../nodeValueExtractor'\nimport { ArenaRecord } from '../../../record'\n\nconst getNodesOrValues = (params: {\n survey: Survey\n referencedNodes: ArenaRecordNode[]\n nodeDefReferenced: NodeDef<any>\n propName: string\n evaluateToNode?: boolean\n}): any[] => {\n const { survey, nodeDefReferenced, referencedNodes, propName, evaluateToNode } = params\n const single = !nodeDefReferenced.props.multiple\n if (single) {\n if (referencedNodes.length === 0) {\n // do not throw error if node is missing, consider its value as null\n // throw new SystemError('expression.nodeNotFoundForNodeDef', { nodeDefName: propName })\n return []\n }\n if (referencedNodes.length > 1)\n throw new SystemError('expression.multipleNodesFoundForNodeDef', { nodeDefName: propName })\n }\n if (nodeDefReferenced.type === NodeDefType.entity || evaluateToNode) {\n // return nodes\n return referencedNodes\n }\n // return node values\n return referencedNodes.map((referencedNode) =>\n NodeValueExtractor.getNodeValue({ survey, node: referencedNode, nodeDef: nodeDefReferenced })\n )\n}\n\nconst evaluateIdentifierOnNode = (params: {\n survey: Survey\n record: ArenaRecord\n nodeObject: ArenaRecordNode\n evaluateToNode?: boolean\n propName: string\n}) => {\n const { survey, record, nodeObject, evaluateToNode = false, propName } = params\n const { nodeDefUuid: nodeDefObjectUuid, value } = nodeObject\n if (!nodeDefObjectUuid) {\n throw new SystemError('expression.identifierNotFound', { name: propName })\n }\n\n const nodeDefObject = Surveys.getNodeDefByUuid({ survey, uuid: nodeDefObjectUuid })\n\n // node value prop (native)\n const valueProp = value?.[propName]\n if (valueProp !== undefined) {\n return valueProp\n }\n if (NodeDefs.isAttribute(nodeDefObject)) {\n // node value prop (Arena specific value property)\n if (NodeValues.isValueProp({ nodeDef: nodeDefObject, prop: propName })) {\n return NodeValues.getNodeValueProp({ nodeDef: nodeDefObject, node: nodeObject, prop: propName })\n } else {\n throw new SystemError('expression.invalidAttributeValuePropertyName', {\n attributeName: NodeDefs.getName(nodeDefObject),\n propName,\n })\n }\n }\n\n const nodeDefReferenced = Surveys.findNodeDefByName({ survey, name: propName })\n\n if (!nodeDefReferenced) {\n throw new SystemError('expression.identifierNotFound', { name: propName })\n }\n\n if (nodeObject.nodeDefUuid === nodeDefReferenced.uuid) {\n // the referenced node is the current node itself\n return nodeObject\n }\n if (Surveys.isNodeDefAncestor({ nodeDefAncestor: nodeDefReferenced, nodeDefDescendant: nodeDefObject })) {\n return Records.getAncestor({ node: nodeObject, ancestorDefUuid: nodeDefReferenced.uuid })(record)\n }\n // the referenced nodes can be siblings of the current node\n const referencedNodes = NodesFinder.findDescendants({ survey, record, nodeContext: nodeObject, nodeDefReferenced })\n const nodesOrValues = getNodesOrValues({ survey, referencedNodes, nodeDefReferenced, propName, evaluateToNode })\n return nodeDefReferenced.props.multiple ? nodesOrValues : nodesOrValues[0]\n}\n\nexport class RecordIdentifierEvaluator extends IdentifierEvaluator<RecordExpressionContext> {\n evaluate(expressionNode: IdentifierExpression): Promise<any> {\n return Promise.resolve(this.evaluateValue(expressionNode))\n }\n\n private evaluateValue(expressionNode: IdentifierExpression): any {\n const { name: propName } = expressionNode\n\n if (propName === ExpressionVariable.CONTEXT) {\n return this.context.nodeContext\n }\n\n // try to find identifier among global or native properties\n // (not-found is signaled without throwing; the try/catch only handles the rare case of an unknown member of a global object)\n try {\n const property = this.findGlobalOrNativeProperty(expressionNode)\n if (property) {\n return property.value\n }\n } catch {\n // ignore it\n }\n\n // identifier not found among global or native properties\n // identifier should be a node or a node value property\n const { survey, record, evaluateToNode, object: contextObject, item } = this.context\n\n if (item && item === contextObject) {\n // evaluating category or taxon item prop or extra prop\n return item.props?.[propName] ?? item.props?.extra?.[propName]\n }\n\n if (Array.isArray(contextObject)) {\n return contextObject.flatMap((contextNode) => {\n const evaluationResult = evaluateIdentifierOnNode({\n survey,\n record,\n nodeObject: contextNode,\n evaluateToNode,\n propName,\n })\n return Array.isArray(evaluationResult) ? evaluationResult : [evaluationResult]\n })\n }\n return evaluateIdentifierOnNode({ survey, record, nodeObject: contextObject, evaluateToNode, propName })\n }\n}\n"]}
1
+ {"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../../../src/record/recordExpressionEvaluator/node/identifier/identifier.ts"],"names":[],"mappings":";;;AAAA,uDAAiF;AACjF,kFAAuF;AAEvF,iDAAoE;AACpE,8CAA0C;AAC1C,4DAAwD;AACxD,+CAAoD;AAEpD,+CAA2C;AAC3C,6CAAgE;A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KAAK,CAAA;YACvB,CAAC;QACH,CAAC;mBAAO,CAAC;YACP,YAAY;QACd,CAAC;QAED,yDAAyD;QACzD,uDAAuD;QACvD,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,OAAO,CAAA;QAEpF,IAAI,IAAI,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;YACnC,uDAAuD;YACvD,aAAO,MAAA,IAAI,CAAC,KAAK,0CAAG,QAAQ,CAAC,mCAAI,MAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,KAAK,0CAAG,QAAQ,CAAC,CAAA;QAChE,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;YACjC,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;gBAC3C,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;oBAChD,MAAM;oBACN,MAAM;oBACN,UAAU,EAAE,WAAW;oBACvB,cAAc;oBACd,QAAQ;iBACT,CAAC,CAAA;gBACF,OAAO,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAA;YAChF,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,wBAAwB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC1G,CAAC;CACF","sourcesContent":["import { ExpressionVariable, IdentifierExpression } from '../../../../expression'\nimport { IdentifierEvaluator } from '../../../../expression/javascript/node/identifier'\nimport { ArenaRecordNode } from '../../../../node'\nimport { NodeDef, NodeDefs, NodeDefType } from '../../../../nodeDef'\nimport { Records } from '../../../records'\nimport { NodeValues } from '../../../../node/nodeValues'\nimport { Survey, Surveys } from '../../../../survey'\nimport { RecordExpressionContext } from '../../context'\nimport { NodesFinder } from './nodesFinder'\nimport { SystemError, SystemErrorKeys } from '../../../../error'\nimport { NodeValueExtractor } from '../../nodeValueExtractor'\nimport { ArenaRecord } from '../../../record'\n\nconst getNodesOrValues = (params: {\n survey: Survey\n referencedNodes: ArenaRecordNode[]\n nodeDefReferenced: NodeDef<any>\n propName: string\n evaluateToNode?: boolean\n}): any[] => {\n const { survey, nodeDefReferenced, referencedNodes, propName, evaluateToNode } = params\n const single = !nodeDefReferenced.props.multiple\n if (single) {\n if (referencedNodes.length === 0) {\n // do not throw error if node is missing, consider its value as null\n // throw new SystemError(SystemErrorKeys.expression.nodeNotFoundForNodeDef, { nodeDefName: propName })\n return []\n }\n if (referencedNodes.length > 1)\n throw new SystemError(SystemErrorKeys.expression.multipleNodesFoundForNodeDef, { nodeDefName: propName })\n }\n if (nodeDefReferenced.type === NodeDefType.entity || evaluateToNode) {\n // return nodes\n return referencedNodes\n }\n // return node values\n return referencedNodes.map((referencedNode) =>\n NodeValueExtractor.getNodeValue({ survey, node: referencedNode, nodeDef: nodeDefReferenced })\n )\n}\n\nconst evaluateIdentifierOnNode = (params: {\n survey: Survey\n record: ArenaRecord\n nodeObject: ArenaRecordNode\n evaluateToNode?: boolean\n propName: string\n}) => {\n const { survey, record, nodeObject, evaluateToNode = false, propName } = params\n const { nodeDefUuid: nodeDefObjectUuid, value } = nodeObject\n if (!nodeDefObjectUuid) {\n throw new SystemError(SystemErrorKeys.expression.identifierNotFound, { name: propName })\n }\n\n const nodeDefObject = Surveys.getNodeDefByUuid({ survey, uuid: nodeDefObjectUuid })\n\n // node value prop (native)\n const valueProp = value?.[propName]\n if (valueProp !== undefined) {\n return valueProp\n }\n if (NodeDefs.isAttribute(nodeDefObject)) {\n // node value prop (Arena specific value property)\n if (NodeValues.isValueProp({ nodeDef: nodeDefObject, prop: propName })) {\n return NodeValues.getNodeValueProp({ nodeDef: nodeDefObject, node: nodeObject, prop: propName })\n } else {\n throw new SystemError(SystemErrorKeys.expression.invalidAttributeValuePropertyName, {\n attributeName: NodeDefs.getName(nodeDefObject),\n propName,\n })\n }\n }\n\n const nodeDefReferenced = Surveys.findNodeDefByName({ survey, name: propName })\n\n if (!nodeDefReferenced) {\n throw new SystemError(SystemErrorKeys.expression.identifierNotFound, { name: propName })\n }\n\n if (nodeObject.nodeDefUuid === nodeDefReferenced.uuid) {\n // the referenced node is the current node itself\n return nodeObject\n }\n if (Surveys.isNodeDefAncestor({ nodeDefAncestor: nodeDefReferenced, nodeDefDescendant: nodeDefObject })) {\n return Records.getAncestor({ node: nodeObject, ancestorDefUuid: nodeDefReferenced.uuid })(record)\n }\n // the referenced nodes can be siblings of the current node\n const referencedNodes = NodesFinder.findDescendants({ survey, record, nodeContext: nodeObject, nodeDefReferenced })\n const nodesOrValues = getNodesOrValues({ survey, referencedNodes, nodeDefReferenced, propName, evaluateToNode })\n return nodeDefReferenced.props.multiple ? nodesOrValues : nodesOrValues[0]\n}\n\nexport class RecordIdentifierEvaluator extends IdentifierEvaluator<RecordExpressionContext> {\n evaluate(expressionNode: IdentifierExpression): Promise<any> {\n return Promise.resolve(this.evaluateValue(expressionNode))\n }\n\n private evaluateValue(expressionNode: IdentifierExpression): any {\n const { name: propName } = expressionNode\n\n if (propName === ExpressionVariable.CONTEXT) {\n return this.context.nodeContext\n }\n\n // try to find identifier among global or native properties\n // (not-found is signaled without throwing; the try/catch only handles the rare case of an unknown member of a global object)\n try {\n const property = this.findGlobalOrNativeProperty(expressionNode)\n if (property) {\n return property.value\n }\n } catch {\n // ignore it\n }\n\n // identifier not found among global or native properties\n // identifier should be a node or a node value property\n const { survey, record, evaluateToNode, object: contextObject, item } = this.context\n\n if (item && item === contextObject) {\n // evaluating category or taxon item prop or extra prop\n return item.props?.[propName] ?? item.props?.extra?.[propName]\n }\n\n if (Array.isArray(contextObject)) {\n return contextObject.flatMap((contextNode) => {\n const evaluationResult = evaluateIdentifierOnNode({\n survey,\n record,\n nodeObject: contextNode,\n evaluateToNode,\n propName,\n })\n return Array.isArray(evaluationResult) ? evaluationResult : [evaluationResult]\n })\n }\n return evaluateIdentifierOnNode({ survey, record, nodeObject: contextObject, evaluateToNode, propName })\n }\n}\n"]}
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.updateSelfAndDependentsDefaultValues = void 0;
13
+ const error_1 = require("../../error");
13
14
  const node_1 = require("../../node");
14
15
  const nodeDef_1 = require("../../nodeDef");
15
16
  const survey_1 = require("../../survey");
@@ -114,7 +115,7 @@ const updateDefaultValuesInNodes = (params) => __awaiter(void 0, void 0, void 0,
114
115
  catch (error) {
115
116
  (0, recordNodesDependentsUpdaterCommons_1.throwError)({
116
117
  error,
117
- errorKey: 'record.updateSelfAndDependentsDefaultValues',
118
+ errorKey: error_1.SystemErrorKeys.record.updateSelfAndDependentsDefaultValues,
118
119
  expressionType: survey_2.SurveyDependencyType.defaultValues,
119
120
  survey,
120
121
  nodeDef,