@openforis/arena-core 2.12.0 → 2.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/geo/areaOfInterest.js +2 -0
- package/dist/esm/geo/areaOfInterest.js.map +1 -0
- package/dist/esm/geo/index.js.map +1 -1
- package/dist/esm/geo/points/distanceToPolygonBoundary.js +26 -0
- package/dist/esm/geo/points/distanceToPolygonBoundary.js.map +1 -0
- package/dist/esm/geo/points/index.js +2 -0
- package/dist/esm/geo/points/index.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/nodeDefExpressionEvaluator/functions.js +13 -1
- package/dist/esm/nodeDefExpressionEvaluator/functions.js.map +1 -1
- package/dist/esm/survey/survey.js.map +1 -1
- package/dist/esm/survey/surveys/index.js +2 -1
- package/dist/esm/survey/surveys/index.js.map +1 -1
- package/dist/esm/survey/surveys/surveysGetters.js +3 -0
- package/dist/esm/survey/surveys/surveysGetters.js.map +1 -1
- package/dist/geo/areaOfInterest.d.ts +5 -0
- package/dist/geo/areaOfInterest.js +3 -0
- package/dist/geo/areaOfInterest.js.map +1 -0
- package/dist/geo/index.d.ts +1 -0
- package/dist/geo/index.js.map +1 -1
- package/dist/geo/points/distanceToPolygonBoundary.d.ts +12 -0
- package/dist/geo/points/distanceToPolygonBoundary.js +33 -0
- package/dist/geo/points/distanceToPolygonBoundary.js.map +1 -0
- package/dist/geo/points/index.d.ts +2 -0
- package/dist/geo/points/index.js +2 -0
- package/dist/geo/points/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/nodeDefExpressionEvaluator/functions.js +12 -0
- package/dist/nodeDefExpressionEvaluator/functions.js.map +1 -1
- package/dist/survey/survey.d.ts +2 -0
- package/dist/survey/survey.js.map +1 -1
- package/dist/survey/surveys/index.d.ts +2 -1
- package/dist/survey/surveys/index.js +1 -0
- package/dist/survey/surveys/index.js.map +1 -1
- package/dist/survey/surveys/surveysGetters.d.ts +2 -0
- package/dist/survey/surveys/surveysGetters.js +5 -1
- package/dist/survey/surveys/surveysGetters.js.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"areaOfInterest.js","sourceRoot":"","sources":["../../../src/geo/areaOfInterest.ts"],"names":[],"mappings":"","sourcesContent":["import type { MultiPolygon, Polygon } from 'geojson'\n\n/**\n * Area of interest of a survey: GeoJSON polygon or multi polygon geometry in WGS84 (EPSG:4326).\n */\nexport type AreaOfInterest = Polygon | MultiPolygon\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/geo/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/geo/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA","sourcesContent":["export type { AreaOfInterest } from './areaOfInterest'\nexport type { Point } from './point'\n\nexport { PointFactory } from './pointFactory'\n\nexport { Points } from './points'\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import pointToPolygonDistance from '@turf/point-to-polygon-distance';
|
|
2
|
+
import { DEFAULT_SRS_INDEX } from '../../srs';
|
|
3
|
+
import { toLatLong } from './toLatLong';
|
|
4
|
+
/**
|
|
5
|
+
* Returns the distance (in meters) between a point and the boundary of a polygon: negative inside, positive outside.
|
|
6
|
+
*
|
|
7
|
+
* @param {!Point} point - The point.
|
|
8
|
+
* @param {!AreaOfInterest} polygon - Polygon or multi polygon in WGS84.
|
|
9
|
+
* @param {!SRSIndex} srsIndex - SRSs indexed by SRS code.
|
|
10
|
+
* @returns {number|null} - The signed distance in meters, or null if the point or the polygon are not valid.
|
|
11
|
+
*/
|
|
12
|
+
export const distanceToPolygonBoundary = (point, polygon, srsIndex = DEFAULT_SRS_INDEX) => {
|
|
13
|
+
const pointLatLong = toLatLong(point, srsIndex);
|
|
14
|
+
if (!pointLatLong)
|
|
15
|
+
return null;
|
|
16
|
+
try {
|
|
17
|
+
// turf expects [longitude, latitude]; planar: polygon edges are straight lines (as in GeoJSON and on the map),
|
|
18
|
+
// consistent with the inside/outside check (geodesic would measure to great-circle edges)
|
|
19
|
+
return pointToPolygonDistance([pointLatLong.x, pointLatLong.y], polygon, { units: 'meters', method: 'planar' });
|
|
20
|
+
}
|
|
21
|
+
catch (_a) {
|
|
22
|
+
// invalid polygon geometry
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=distanceToPolygonBoundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distanceToPolygonBoundary.js","sourceRoot":"","sources":["../../../../src/geo/points/distanceToPolygonBoundary.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,MAAM,iCAAiC,CAAA;AAEpE,OAAO,EAAE,iBAAiB,EAAY,MAAM,WAAW,CAAA;AAGvD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,KAAY,EACZ,OAAuB,EACvB,QAAQ,GAAa,iBAAiB,EACvB,EAAE;IACjB,MAAM,YAAY,GAAG,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;IAC/C,IAAI,CAAC,YAAY;QAAE,OAAO,IAAI,CAAA;IAC9B,IAAI,CAAC;QACH,+GAA+G;QAC/G,0FAA0F;QAC1F,OAAO,sBAAsB,CAAC,CAAC,YAAY,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;IACjH,CAAC;eAAO,CAAC;QACP,2BAA2B;QAC3B,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC,CAAA","sourcesContent":["import pointToPolygonDistance from '@turf/point-to-polygon-distance'\n\nimport { DEFAULT_SRS_INDEX, SRSIndex } from '../../srs'\nimport { AreaOfInterest } from '../areaOfInterest'\nimport { Point } from '../point'\nimport { toLatLong } from './toLatLong'\n\n/**\n * Returns the distance (in meters) between a point and the boundary of a polygon: negative inside, positive outside.\n *\n * @param {!Point} point - The point.\n * @param {!AreaOfInterest} polygon - Polygon or multi polygon in WGS84.\n * @param {!SRSIndex} srsIndex - SRSs indexed by SRS code.\n * @returns {number|null} - The signed distance in meters, or null if the point or the polygon are not valid.\n */\nexport const distanceToPolygonBoundary = (\n point: Point,\n polygon: AreaOfInterest,\n srsIndex: SRSIndex = DEFAULT_SRS_INDEX\n): number | null => {\n const pointLatLong = toLatLong(point, srsIndex)\n if (!pointLatLong) return null\n try {\n // turf expects [longitude, latitude]; planar: polygon edges are straight lines (as in GeoJSON and on the map),\n // consistent with the inside/outside check (geodesic would measure to great-circle edges)\n return pointToPolygonDistance([pointLatLong.x, pointLatLong.y], polygon, { units: 'meters', method: 'planar' })\n } catch {\n // invalid polygon geometry\n return null\n }\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { bearing } from './bearing';
|
|
2
2
|
import { distance } from './distance';
|
|
3
|
+
import { distanceToPolygonBoundary } from './distanceToPolygonBoundary';
|
|
3
4
|
import { equals } from './equals';
|
|
4
5
|
import { isValid } from './isValid';
|
|
5
6
|
import { pointAtDistance } from './pointAtDistance';
|
|
@@ -10,6 +11,7 @@ import { transform, transformOrThrow } from './transform';
|
|
|
10
11
|
export const Points = {
|
|
11
12
|
bearing,
|
|
12
13
|
distance,
|
|
14
|
+
distanceToPolygonBoundary,
|
|
13
15
|
equals,
|
|
14
16
|
isValid,
|
|
15
17
|
pointAtDistance,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/geo/points/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEzD,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,OAAO;IACP,QAAQ;IACR,MAAM;IACN,OAAO;IACP,eAAe;IACf,KAAK;IACL,SAAS;IACT,QAAQ;IACR,SAAS;IACT,gBAAgB;CACjB,CAAA","sourcesContent":["import { bearing } from './bearing'\nimport { distance } from './distance'\nimport { equals } from './equals'\nimport { isValid } from './isValid'\nimport { pointAtDistance } from './pointAtDistance'\nimport { parse } from './parse'\nimport { toLatLong } from './toLatLong'\nimport { toString } from './toString'\nimport { transform, transformOrThrow } from './transform'\n\nexport const Points = {\n bearing,\n distance,\n equals,\n isValid,\n pointAtDistance,\n parse,\n toLatLong,\n toString,\n transform,\n transformOrThrow,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/geo/points/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEzD,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,OAAO;IACP,QAAQ;IACR,yBAAyB;IACzB,MAAM;IACN,OAAO;IACP,eAAe;IACf,KAAK;IACL,SAAS;IACT,QAAQ;IACR,SAAS;IACT,gBAAgB;CACjB,CAAA","sourcesContent":["import { bearing } from './bearing'\nimport { distance } from './distance'\nimport { distanceToPolygonBoundary } from './distanceToPolygonBoundary'\nimport { equals } from './equals'\nimport { isValid } from './isValid'\nimport { pointAtDistance } from './pointAtDistance'\nimport { parse } from './parse'\nimport { toLatLong } from './toLatLong'\nimport { toString } from './toString'\nimport { transform, transformOrThrow } from './transform'\n\nexport const Points = {\n bearing,\n distance,\n distanceToPolygonBoundary,\n equals,\n isValid,\n pointAtDistance,\n parse,\n toLatLong,\n toString,\n transform,\n transformOrThrow,\n}\n"]}
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAwBzG,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAejH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEtD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,SAA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mB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,iBAAiB,GAClB,MAAM,UAAU,CAAA;AAgBjB,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAGzD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGlE,OAAO,EACL,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,OAAO,EACP,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,GACb,MAAM,UAAU,CAAA;AAkBjB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAenH,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACnF,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAEjF,OAAO,EACL,MAAM,EACN,WAAW,EACX,KAAK,EACL,SAAS,EACT,aAAa,EACb,OAAO,EACP,OAAO,EACP,QAAQ,EACR,KAAK,EACL,cAAc,EACd,OAAO,EACP,UAAU,EACV,KAAK,EACL,QAAQ,GACT,MAAM,SAAS,CAAA;AAIhB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,kBAAkB,GACnB,MAAM,cAAc,CAAA","sourcesContent":["export type { AppInfo } from './app'\n\nexport { Authorizer, AuthGroupName, UserStatus, Permission, UserTitle, UserFactory, Users } from './auth'\nexport type {\n AuthGroup,\n User,\n UserAuthGroup,\n UserAuthGroupProps,\n AuthToken,\n UserAuthTokenPayload,\n UserAuthTokenService,\n UserPrefs,\n UserPrefSurveys,\n UserProps,\n UserAuthRefreshToken,\n UserAuthRefreshTokenProps,\n UserAuthRefreshTokenPayload,\n UserService,\n UserTokenPayload,\n DownloadAuthTokenPayload,\n UserGroup,\n UserGroupProps,\n UserGroupQualifier,\n UserInvitation,\n} from './auth'\n\nexport { CategoryFactory, CategoryImportColumnType, CategoryItemFactory, CategoryLevelFactory } from './category'\nexport type {\n CategoryItemProps,\n Category,\n CategoryItem,\n CategoryLevel,\n CategoryLevelProps,\n CategoryImportSummary,\n CategoryImportSummaryColumn,\n CategoryItemService,\n CategoryLevelService,\n CategoryProps,\n CategoryService,\n} from './category'\n\nexport { Categories, CategoryItems } from './category'\n\nexport { ChainFactory, ChainStatusExec, ChainNodeDefFactory } from './chain'\nexport type {\n Chain,\n ChainProps,\n ChainService,\n ChainNodeDef,\n ChainNodeDefProps,\n ChainNodeDefService,\n ChainNodeDefAggregate,\n ChainNodeDefAggregateProps,\n} from './chain'\n\nexport { TraverseMethod } from './common'\nexport type { ArenaObject, ArenaService, Dictionary, Factory, I18n } from './common'\n\nexport type { FlatDataExportOptions, ArenaExportInfoFactoryParams, ArenaExportInfo } from './dataExport'\nexport {\n FlatDataExportDefaultOptions,\n FlatDataExportOption,\n FlatDataFiles,\n FlatDataExportModel,\n FlatDataExportColumnDataType,\n ArenaExportInfoFactory,\n ArenaExportType,\n UniqueFileNamesGenerator,\n} from './dataExport'\n\nexport { DataQueryMode, DataQuerySummaries } from './dataQuery'\nexport type { DataQuery, DataQuerySummary, DataQuerySummaryProps } from './dataQuery'\n\nexport { SystemError, SystemErrorKeys } from './error'\n\nexport {\n ExpressionNodeType,\n ExpressionNodeEvaluator,\n ExpressionVariable,\n JavascriptExpressionEvaluator,\n JavascriptExpressionParser,\n} from './expression'\nexport type {\n ArrayExpression,\n BinaryExpression,\n CallExpression,\n CompoundExpression,\n ConditionalExpression,\n ExpressionContext,\n ExpressionEvaluator,\n ExpressionFunction,\n ExpressionFunctions,\n AnyExpressionNode,\n ExpressionNode,\n ExpressionNodeEvaluatorConstructor,\n MemberExpression,\n IdentifierExpression,\n LiteralExpression,\n SequenceExpression,\n ThisExpression,\n UnaryExpression,\n} from './expression'\n\nexport { ExtraPropDataType, ExtraPropsDataGenerator } from './extraProp'\nexport type { ExtraPropDef, ExtraPropDefs } from './extraProp'\n\nexport { PointFactory, Points } from './geo'\nexport type { Point } from './geo'\n\nexport { JobBase, JobEventType, JobStatus } from './job'\nexport type { Job, JobContext, JobEvent, JobSerialized, JobTxClient } from './job'\n\nexport { LanguageCode, Languages, LanguagesISO639part2 } from './language'\nexport type { Labels } from './language'\n\nexport type { Logger } from './logger'\n\nexport type { Message } from './message'\nexport { MessageNotificationType, MessagePropsKey, MessageStatus, MessageTargetUserType, Messages } from './message'\n\nexport { NodeFactory, NodeKeys, NodeMetaKeys, Nodes, NodeValueFormatter, NodeValues } from './node'\nexport type {\n ArenaRecordNode,\n Node,\n NodeMeta,\n NodePointer,\n NodeRefData,\n NodeService,\n NodesMap,\n NodeValueCode,\n NodeValueCoordinate,\n NodeValueFile,\n NodeValueTaxon,\n} from './node'\n\nexport {\n NodeDefCountType,\n NodeDefType,\n NodeDefFactory,\n NodeDefs,\n NodeDefEntityRenderType,\n NodeDefFileType,\n NodeDefTextInputType,\n NodeDefTextRenderType,\n FormHeaderColor,\n} from './nodeDef'\n\nexport { NodeDefExpressionEvaluator, NodeDefExpressionValidator } from './nodeDefExpressionEvaluator'\nexport type { CategoryItemProvider, TaxonProvider } from './nodeDefExpressionEvaluator'\n\nexport type {\n NodeDef,\n NodeDefLayout,\n NodeDefMeta,\n NodeDefProps,\n NodeDefPropsWithLayout,\n NodeDefBoolean,\n NodeDefBooleanProps,\n NodeDefCode,\n NodeDefCodeLayout,\n NodeDefCodeProps,\n NodeDefCoordinate,\n NodeDefCoordinateProps,\n NodeDefDate,\n NodeDefDecimal,\n NodeDefDecimalProps,\n NodeDefEntity,\n NodeDefEntityChildPosition,\n NodeDefEntityLayout,\n NodeDefEntityProps,\n NodeDefPrintOrientation,\n NodeDefFile,\n NodeDefFileProps,\n NodeDefGeo,\n NodeDefGeoProps,\n NodeDefFormHeader,\n NodeDefFormHeaderProps,\n NodeDefInteger,\n NodeDefPropsAdvanced,\n NodeDefTaxon,\n NodeDefTaxonProps,\n NodeDefText,\n NodeDefTextProps,\n NodeDefTextLayout,\n NodeDefTime,\n NodeDefTimeProps,\n NodeDefExpression,\n NodeDefMap,\n NodeDefService,\n NodeDefValidations,\n} from './nodeDef'\n\nexport {\n NodePointers,\n RecordCloner,\n RecordFactory,\n RecordFixer,\n Records,\n RECORD_STEP_DEFAULT,\n RecordExpressionEvaluator,\n RecordNodesUpdater,\n RecordPrettyPrinter,\n RecordUpdater,\n RecordUpdateResult,\n RecordValidator,\n RecordValidations,\n} from './record'\nexport type {\n AttributeValidatorParams,\n AttributesValidatorParams,\n NodeCreateParams,\n NodesUpdateParams,\n ArenaRecord,\n Record,\n RecordExpressionContext,\n RecordExpressionEvaluationContext,\n RecordService,\n RecordUpdateOptions,\n RecordValidatorParams,\n SortedAttributesValidatorParams,\n} from './record'\n\nexport { ServiceRegistry, ServiceType } from './registry'\nexport type { ServiceTypeMap } from './registry'\n\nexport { DEFAULT_SRS, DEFAULT_SRS_INDEX, SRSFactory } from './srs'\nexport type { SRS, SRSIndex } from './srs'\n\nexport {\n NodeDefsFixer,\n SurveyDocImages,\n SurveyDocImageFactory,\n SurveyDocPlace,\n SurveyDependencyType,\n SurveyFactory,\n SurveyFileFactory,\n SurveyFileType,\n SurveyRefDataFactory,\n SurveySecurityProp,\n Surveys,\n surveyDocImagePropKeys,\n surveySecurityDefaults,\n defaultCycle,\n} from './survey'\nexport type {\n Survey,\n SurveyCycle,\n SurveyDependency,\n SurveyDependencyGraph,\n SurveyDocImage,\n SurveyDocImageFactoryParams,\n SurveyDocImageProps,\n SurveyFile,\n SurveyFileFactoryParams,\n SurveyFileProps,\n SurveyProps,\n SurveyRefData,\n SurveySecurity,\n SurveyService,\n} from './survey'\n\nexport { Taxa, Taxonomies, TaxonomyFactory, TaxonFactory, TaxonGenerator, VernacularNameFactory } from './taxonomy'\nexport type {\n VernacularNameParams,\n TaxonomyFactoryParams,\n TaxonFactoryParams,\n Taxonomy,\n TaxonomyService,\n VernacularNameProps,\n VernacularName,\n TaxonProps,\n Taxon,\n TaxonomyProps,\n TaxonService,\n} from './taxonomy'\n\nexport { SurveyBuilder, SurveyObjectBuilders } from './tests/builder/surveyBuilder'\nexport { RecordBuilder, RecordNodeBuilders } from './tests/builder/recordBuilder'\n\nexport {\n Arrays,\n DateFormats,\n Dates,\n FileNames,\n FileProcessor,\n Numbers,\n Objects,\n Promises,\n Queue,\n RetryProcessor,\n Strings,\n UnitOfTime,\n UUIDs,\n Versions,\n} from './utils'\n\nexport type { FileProcessorConstructorArgs, MutationOptions, ParsedVersion } from './utils'\n\nexport {\n FieldValidators,\n ValidationFactory,\n ValidationResultFactory,\n ValidationResults,\n Validations,\n ValidationSeverity,\n Validator,\n ValidatorErrorKeys,\n} from './validation'\nexport type {\n DissocFieldValidationOptions,\n FieldValidator,\n Validation,\n ValidationFields,\n ValidationResult,\n ValidationCounts,\n} from './validation'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAwBzG,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAejH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEtD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAY5E,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAIzC,OAAO,EACL,4BAA4B,EAC5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iBAAiB,GAClB,MAAM,UAAU,CAAA;AAgBjB,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAGzD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGlE,OAAO,EACL,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,OAAO,EACP,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,GACb,MAAM,UAAU,CAAA;AAkBjB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAenH,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACnF,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAEjF,OAAO,EACL,MAAM,EACN,WAAW,EACX,KAAK,EACL,SAAS,EACT,aAAa,EACb,OAAO,EACP,OAAO,EACP,QAAQ,EACR,KAAK,EACL,cAAc,EACd,OAAO,EACP,UAAU,EACV,KAAK,EACL,QAAQ,GACT,MAAM,SAAS,CAAA;AAIhB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,kBAAkB,GACnB,MAAM,cAAc,CAAA","sourcesContent":["export type { AppInfo } from './app'\n\nexport { Authorizer, AuthGroupName, UserStatus, Permission, UserTitle, UserFactory, Users } from './auth'\nexport type {\n AuthGroup,\n User,\n UserAuthGroup,\n UserAuthGroupProps,\n AuthToken,\n UserAuthTokenPayload,\n UserAuthTokenService,\n UserPrefs,\n UserPrefSurveys,\n UserProps,\n UserAuthRefreshToken,\n UserAuthRefreshTokenProps,\n UserAuthRefreshTokenPayload,\n UserService,\n UserTokenPayload,\n DownloadAuthTokenPayload,\n UserGroup,\n UserGroupProps,\n UserGroupQualifier,\n UserInvitation,\n} from './auth'\n\nexport { CategoryFactory, CategoryImportColumnType, CategoryItemFactory, CategoryLevelFactory } from './category'\nexport type {\n CategoryItemProps,\n Category,\n CategoryItem,\n CategoryLevel,\n CategoryLevelProps,\n CategoryImportSummary,\n CategoryImportSummaryColumn,\n CategoryItemService,\n CategoryLevelService,\n CategoryProps,\n CategoryService,\n} from './category'\n\nexport { Categories, CategoryItems } from './category'\n\nexport { ChainFactory, ChainStatusExec, ChainNodeDefFactory } from './chain'\nexport type {\n Chain,\n ChainProps,\n ChainService,\n ChainNodeDef,\n ChainNodeDefProps,\n ChainNodeDefService,\n ChainNodeDefAggregate,\n ChainNodeDefAggregateProps,\n} from './chain'\n\nexport { TraverseMethod } from './common'\nexport type { ArenaObject, ArenaService, Dictionary, Factory, I18n } from './common'\n\nexport type { FlatDataExportOptions, ArenaExportInfoFactoryParams, ArenaExportInfo } from './dataExport'\nexport {\n FlatDataExportDefaultOptions,\n FlatDataExportOption,\n FlatDataFiles,\n FlatDataExportModel,\n FlatDataExportColumnDataType,\n ArenaExportInfoFactory,\n ArenaExportType,\n UniqueFileNamesGenerator,\n} from './dataExport'\n\nexport { DataQueryMode, DataQuerySummaries } from './dataQuery'\nexport type { DataQuery, DataQuerySummary, DataQuerySummaryProps } from './dataQuery'\n\nexport { SystemError, SystemErrorKeys } from './error'\n\nexport {\n ExpressionNodeType,\n ExpressionNodeEvaluator,\n ExpressionVariable,\n JavascriptExpressionEvaluator,\n JavascriptExpressionParser,\n} from './expression'\nexport type {\n ArrayExpression,\n BinaryExpression,\n CallExpression,\n CompoundExpression,\n ConditionalExpression,\n ExpressionContext,\n ExpressionEvaluator,\n ExpressionFunction,\n ExpressionFunctions,\n AnyExpressionNode,\n ExpressionNode,\n ExpressionNodeEvaluatorConstructor,\n MemberExpression,\n IdentifierExpression,\n LiteralExpression,\n SequenceExpression,\n ThisExpression,\n UnaryExpression,\n} from './expression'\n\nexport { ExtraPropDataType, ExtraPropsDataGenerator } from './extraProp'\nexport type { ExtraPropDef, ExtraPropDefs } from './extraProp'\n\nexport { PointFactory, Points } from './geo'\nexport type { AreaOfInterest, Point } from './geo'\n\nexport { JobBase, JobEventType, JobStatus } from './job'\nexport type { Job, JobContext, JobEvent, JobSerialized, JobTxClient } from './job'\n\nexport { LanguageCode, Languages, LanguagesISO639part2 } from './language'\nexport type { Labels } from './language'\n\nexport type { Logger } from './logger'\n\nexport type { Message } from './message'\nexport { MessageNotificationType, MessagePropsKey, MessageStatus, MessageTargetUserType, Messages } from './message'\n\nexport { NodeFactory, NodeKeys, NodeMetaKeys, Nodes, NodeValueFormatter, NodeValues } from './node'\nexport type {\n ArenaRecordNode,\n Node,\n NodeMeta,\n NodePointer,\n NodeRefData,\n NodeService,\n NodesMap,\n NodeValueCode,\n NodeValueCoordinate,\n NodeValueFile,\n NodeValueTaxon,\n} from './node'\n\nexport {\n NodeDefCountType,\n NodeDefType,\n NodeDefFactory,\n NodeDefs,\n NodeDefEntityRenderType,\n NodeDefFileType,\n NodeDefTextInputType,\n NodeDefTextRenderType,\n FormHeaderColor,\n} from './nodeDef'\n\nexport { NodeDefExpressionEvaluator, NodeDefExpressionValidator } from './nodeDefExpressionEvaluator'\nexport type { CategoryItemProvider, TaxonProvider } from './nodeDefExpressionEvaluator'\n\nexport type {\n NodeDef,\n NodeDefLayout,\n NodeDefMeta,\n NodeDefProps,\n NodeDefPropsWithLayout,\n NodeDefBoolean,\n NodeDefBooleanProps,\n NodeDefCode,\n NodeDefCodeLayout,\n NodeDefCodeProps,\n NodeDefCoordinate,\n NodeDefCoordinateProps,\n NodeDefDate,\n NodeDefDecimal,\n NodeDefDecimalProps,\n NodeDefEntity,\n NodeDefEntityChildPosition,\n NodeDefEntityLayout,\n NodeDefEntityProps,\n NodeDefPrintOrientation,\n NodeDefFile,\n NodeDefFileProps,\n NodeDefGeo,\n NodeDefGeoProps,\n NodeDefFormHeader,\n NodeDefFormHeaderProps,\n NodeDefInteger,\n NodeDefPropsAdvanced,\n NodeDefTaxon,\n NodeDefTaxonProps,\n NodeDefText,\n NodeDefTextProps,\n NodeDefTextLayout,\n NodeDefTime,\n NodeDefTimeProps,\n NodeDefExpression,\n NodeDefMap,\n NodeDefService,\n NodeDefValidations,\n} from './nodeDef'\n\nexport {\n NodePointers,\n RecordCloner,\n RecordFactory,\n RecordFixer,\n Records,\n RECORD_STEP_DEFAULT,\n RecordExpressionEvaluator,\n RecordNodesUpdater,\n RecordPrettyPrinter,\n RecordUpdater,\n RecordUpdateResult,\n RecordValidator,\n RecordValidations,\n} from './record'\nexport type {\n AttributeValidatorParams,\n AttributesValidatorParams,\n NodeCreateParams,\n NodesUpdateParams,\n ArenaRecord,\n Record,\n RecordExpressionContext,\n RecordExpressionEvaluationContext,\n RecordService,\n RecordUpdateOptions,\n RecordValidatorParams,\n SortedAttributesValidatorParams,\n} from './record'\n\nexport { ServiceRegistry, ServiceType } from './registry'\nexport type { ServiceTypeMap } from './registry'\n\nexport { DEFAULT_SRS, DEFAULT_SRS_INDEX, SRSFactory } from './srs'\nexport type { SRS, SRSIndex } from './srs'\n\nexport {\n NodeDefsFixer,\n SurveyDocImages,\n SurveyDocImageFactory,\n SurveyDocPlace,\n SurveyDependencyType,\n SurveyFactory,\n SurveyFileFactory,\n SurveyFileType,\n SurveyRefDataFactory,\n SurveySecurityProp,\n Surveys,\n surveyDocImagePropKeys,\n surveySecurityDefaults,\n defaultCycle,\n} from './survey'\nexport type {\n Survey,\n SurveyCycle,\n SurveyDependency,\n SurveyDependencyGraph,\n SurveyDocImage,\n SurveyDocImageFactoryParams,\n SurveyDocImageProps,\n SurveyFile,\n SurveyFileFactoryParams,\n SurveyFileProps,\n SurveyProps,\n SurveyRefData,\n SurveySecurity,\n SurveyService,\n} from './survey'\n\nexport { Taxa, Taxonomies, TaxonomyFactory, TaxonFactory, TaxonGenerator, VernacularNameFactory } from './taxonomy'\nexport type {\n VernacularNameParams,\n TaxonomyFactoryParams,\n TaxonFactoryParams,\n Taxonomy,\n TaxonomyService,\n VernacularNameProps,\n VernacularName,\n TaxonProps,\n Taxon,\n TaxonomyProps,\n TaxonService,\n} from './taxonomy'\n\nexport { SurveyBuilder, SurveyObjectBuilders } from './tests/builder/surveyBuilder'\nexport { RecordBuilder, RecordNodeBuilders } from './tests/builder/recordBuilder'\n\nexport {\n Arrays,\n DateFormats,\n Dates,\n FileNames,\n FileProcessor,\n Numbers,\n Objects,\n Promises,\n Queue,\n RetryProcessor,\n Strings,\n UnitOfTime,\n UUIDs,\n Versions,\n} from './utils'\n\nexport type { FileProcessorConstructorArgs, MutationOptions, ParsedVersion } from './utils'\n\nexport {\n FieldValidators,\n ValidationFactory,\n ValidationResultFactory,\n ValidationResults,\n Validations,\n ValidationSeverity,\n Validator,\n ValidatorErrorKeys,\n} from './validation'\nexport type {\n DissocFieldValidationOptions,\n FieldValidator,\n Validation,\n ValidationFields,\n ValidationResult,\n ValidationCounts,\n} from './validation'\n"]}
|
|
@@ -14,7 +14,7 @@ import { Points } from '../geo';
|
|
|
14
14
|
import { LanguagesISO639part2 } from '../language';
|
|
15
15
|
import { getNodeDefParent } from '../survey/surveys/nodeDefs';
|
|
16
16
|
import { getCategoryItemByCodePaths, getTaxonByCode } from '../survey/surveys/refsData';
|
|
17
|
-
import { getCategoryByName, getSRSIndex, getTaxonomyByName } from '../survey/surveys/surveysGetters';
|
|
17
|
+
import { getAreaOfInterest, getCategoryByName, getSRSIndex, getTaxonomyByName } from '../survey/surveys/surveysGetters';
|
|
18
18
|
import { Dates, Numbers, Objects } from '../utils';
|
|
19
19
|
const sampleGeoJsonPolygon = {
|
|
20
20
|
type: 'Feature',
|
|
@@ -146,6 +146,18 @@ export const nodeDefExpressionFunctions = {
|
|
|
146
146
|
},
|
|
147
147
|
},
|
|
148
148
|
geoDistance: { minArity: 2, maxArity: 2, executor: geoDistanceExecutor },
|
|
149
|
+
geoDistanceToAOIBoundary: {
|
|
150
|
+
minArity: 1,
|
|
151
|
+
maxArity: 1,
|
|
152
|
+
executor: (context) => (coordinate) => {
|
|
153
|
+
const { survey } = context;
|
|
154
|
+
const areaOfInterest = getAreaOfInterest(survey);
|
|
155
|
+
const point = Points.parse(coordinate);
|
|
156
|
+
if (!areaOfInterest || !point)
|
|
157
|
+
return null;
|
|
158
|
+
return Points.distanceToPolygonBoundary(point, areaOfInterest, getSRSIndex(survey));
|
|
159
|
+
},
|
|
160
|
+
},
|
|
149
161
|
geoPolygon: {
|
|
150
162
|
minArity: 1,
|
|
151
163
|
evaluateArgsToNodes: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/nodeDefExpressionEvaluator/functions.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,0BAA0B,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AACvF,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAEpG,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAGlD,MAAM,oBAAoB,GAAG;IAC3B,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE;QACR,IAAI,EAAE,SAAS;QACf,WAAW,EAAE;YACX;gBACE,CAAC,KAAK,EAAE,GAAG,CAAC;gBACZ,CAAC,KAAK,EAAE,GAAG,CAAC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AI;gBAAE,OAAO,SAAS,CAAA;YACtC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,MAAM,CAAA;YACnC,MAAM,kBAAkB,GAAG,KAAK,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAA;YACxE,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAA;QACrC,CAAC;KACF;CACF,CAAA","sourcesContent":["import { Users } from '../auth'\nimport { CategoryItem } from '../category'\nimport { SystemError, SystemErrorKeys } from '../error'\nimport { ExpressionFunctions } from '../expression'\nimport { ExtraProps } from '../extraProp/extraProps'\nimport { Point, Points } from '../geo'\nimport { LanguagesISO639part2 } from '../language'\nimport { ArenaRecord } from '../record'\nimport { getNodeDefParent } from '../survey/surveys/nodeDefs'\nimport { getCategoryItemByCodePaths, getTaxonByCode } from '../survey/surveys/refsData'\nimport { 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"]}
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/nodeDefExpressionEvaluator/functions.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,0BAA0B,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AACvF,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAEvH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAGlD,MAAM,oBAAoB,GAAG;IAC3B,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE;QACR,IAAI,EAAE,SAAS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AE,KAAK,GAAA;KAC3E;IACD,iBAAiB,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,KAAK,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAA;YACxE,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAA;QACrC,CAAC;KACF;CACF,CAAA","sourcesContent":["import { Users } from '../auth'\nimport { CategoryItem } from '../category'\nimport { SystemError, SystemErrorKeys } from '../error'\nimport { ExpressionFunctions } from '../expression'\nimport { ExtraProps } from '../extraProp/extraProps'\nimport { Point, Points } from '../geo'\nimport { LanguagesISO639part2 } from '../language'\nimport { ArenaRecord } from '../record'\nimport { getNodeDefParent } from '../survey/surveys/nodeDefs'\nimport { getCategoryItemByCodePaths, getTaxonByCode } from '../survey/surveys/refsData'\nimport { getAreaOfInterest, getCategoryByName, getSRSIndex, getTaxonomyByName } from '../survey/surveys/surveysGetters'\nimport { Taxon } from '../taxonomy'\nimport { Dates, Numbers, Objects } from '../utils'\nimport { NodeDefExpressionContext } from './context'\n\nconst sampleGeoJsonPolygon = {\n type: 'Feature',\n geometry: {\n type: 'Polygon',\n coordinates: [\n [\n [100.0, 0.0],\n [101.0, 0.0],\n [101.0, 1.0],\n [100.0, 1.0],\n [100.0, 0.0],\n ],\n ],\n },\n}\n\nconst isNotValidString = (value: string): boolean => Objects.isEmpty(value) || typeof value !== 'string'\n\nconst emptyExecutor = (_context: NodeDefExpressionContext) => () => null\n\nconst isUsingDraftProps = (context: NodeDefExpressionContext) => {\n // use draft props when validating expression or previewing record\n const record: ArenaRecord = (context as any).record\n return !record || !!record.preview\n}\n\nconst getOrFetchCategoryItem = async (params: {\n context: NodeDefExpressionContext\n categoryUuid: string\n codePaths: string[]\n}): Promise<CategoryItem | undefined> => {\n const { context, categoryUuid, codePaths } = params\n // if any code path is empty, return null (no category item can be found)\n if (Objects.isEmpty(codePaths) || codePaths.some(Objects.isEmpty)) {\n return undefined\n }\n const { survey, categoryItemProvider } = context\n const categoryItem = getCategoryItemByCodePaths({ survey, categoryUuid, codePaths })\n const draft = isUsingDraftProps(context)\n return categoryItem ?? categoryItemProvider?.getItemByCodePaths({ survey, categoryUuid, codePaths, draft })\n}\n\nconst getOrFetchTaxon = async (params: {\n context: NodeDefExpressionContext\n taxonomyUuid: string\n taxonCode: string\n}): Promise<Taxon | undefined> => {\n const { context, taxonomyUuid, taxonCode } = params\n if (typeof taxonCode !== 'string' && typeof taxonCode !== 'number') {\n return undefined // node def expression validator could call it passing a node def object\n }\n // if taxonCode is empty, return undefined\n if (Objects.isEmpty(taxonCode)) {\n return undefined\n }\n const { survey, taxonProvider } = context\n const taxon = getTaxonByCode({ survey, taxonomyUuid, taxonCode })\n // fetch draft props when validating expression or previewing record\n const record: ArenaRecord = (context as any).record\n const draft = !record || !!record.preview\n return taxon ?? taxonProvider?.getTaxonByCode({ survey, taxonomyUuid, taxonCode, draft })\n}\n\nconst geoDistanceExecutor =\n (context: NodeDefExpressionContext) =>\n (coordinateFrom: Point | string, coordinateTo: Point | string): number | null => {\n const { survey } = context\n const srsIndex = getSRSIndex(survey)\n\n const pointFrom = Points.parse(coordinateFrom)\n const pointTo = Points.parse(coordinateTo)\n\n return pointFrom && pointTo ? Points.distance(pointFrom, pointTo, srsIndex) : null\n }\n\nexport const nodeDefExpressionFunctions: ExpressionFunctions<NodeDefExpressionContext> = {\n categoryItemProp: {\n minArity: 3,\n executor:\n (context: NodeDefExpressionContext) =>\n async (categoryName: string, itemPropName: string, ...codePaths: string[]): Promise<any> => {\n const { survey } = context\n\n if (Objects.isEmpty(categoryName) || Objects.isEmpty(itemPropName) || Objects.isEmpty(codePaths))\n throw new SystemError(SystemErrorKeys.expression.missingFunctionParameters)\n\n const category = getCategoryByName({ survey, categoryName })\n if (!category) throw new SystemError(SystemErrorKeys.expression.invalidCategoryName, { name: categoryName })\n\n const extraPropDef = category.props.itemExtraDef?.[itemPropName]\n if (!extraPropDef)\n throw new SystemError(SystemErrorKeys.expression.invalidCategoryExtraProp, { propName: itemPropName })\n\n const { uuid: categoryUuid } = category\n const categoryItem = await getOrFetchCategoryItem({ context, categoryUuid, codePaths })\n if (!categoryItem) return null\n\n const value = categoryItem.props.extra?.[itemPropName]\n return ExtraProps.convertValue({ survey, extraPropDef, value })\n },\n },\n count: {\n minArity: 1,\n maxArity: 1,\n executor:\n (_context: NodeDefExpressionContext) =>\n (_nodeSet): number =>\n 1,\n },\n dateTimeDiff: {\n minArity: 4,\n maxArity: 4,\n executor:\n (_context: NodeDefExpressionContext) =>\n (date1: string, time1: string, date2: string, time2: string): number | null => {\n if (isNotValidString(date1) || isNotValidString(time1) || isNotValidString(date2) || isNotValidString(time2))\n return null\n const [hours1, minutes1] = time1.split(':')\n const [hours2, minutes2] = time2.split(':')\n let dt1 = Dates.addHours(date1, Number(hours1))\n dt1 = Dates.addMinutes(dt1, Number(minutes1))\n let dt2 = Dates.addHours(date2, Number(hours2))\n dt2 = Dates.addMinutes(dt2, Number(minutes2))\n return Dates.diffInMinutes(dt1, dt2)\n },\n },\n // deprecated, use geoDistance instead\n distance: { minArity: 2, maxArity: 2, executor: geoDistanceExecutor },\n first: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: emptyExecutor,\n },\n geoCoordinateAtDistance: {\n minArity: 3,\n maxArity: 3,\n executor:\n (context: NodeDefExpressionContext) =>\n (coordinate: Point | string, distanceMeters: number, bearingDeg: number): Point | null => {\n // validate parameters\n const origin = Points.parse(coordinate)\n if (!origin) return null\n\n const distanceMetersNumber = Number(distanceMeters)\n const bearingDegNumber = Number(bearingDeg)\n if (!Number.isFinite(distanceMetersNumber) || distanceMetersNumber < 0 || !Number.isFinite(bearingDegNumber)) {\n return null\n }\n\n const { survey } = context\n const srsIndex = getSRSIndex(survey)\n\n return Points.pointAtDistance({\n origin,\n distanceMeters: distanceMetersNumber,\n bearingDeg: bearingDegNumber,\n srsIndex,\n })\n },\n },\n geoDistance: { minArity: 2, maxArity: 2, executor: geoDistanceExecutor },\n geoDistanceToAOIBoundary: {\n minArity: 1,\n maxArity: 1,\n executor:\n (context: NodeDefExpressionContext) =>\n (coordinate: Point | string): number | null => {\n const { survey } = context\n const areaOfInterest = getAreaOfInterest(survey)\n const point = Points.parse(coordinate)\n if (!areaOfInterest || !point) return null\n return Points.distanceToPolygonBoundary(point, areaOfInterest, getSRSIndex(survey))\n },\n },\n geoPolygon: {\n minArity: 1,\n evaluateArgsToNodes: true,\n executor: () => () => sampleGeoJsonPolygon,\n },\n includes: {\n minArity: 2,\n maxArity: 2,\n evaluateArgsToNodes: false,\n executor:\n () =>\n (items: any, value: any): boolean =>\n Array.isArray(items) && items.map(String).includes(String(value)),\n },\n index: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: () => () => -1,\n },\n last: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: emptyExecutor,\n },\n now: {\n minArity: 0,\n maxArity: 0,\n evaluateToNode: false,\n executor: () => () => Dates.nowFormattedForStorage(),\n },\n numberToWords: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: false,\n executor:\n (context: NodeDefExpressionContext) =>\n (value: any): string | null => {\n if (Objects.isEmpty(value)) return null\n return Numbers.toWords(value, context.lang)\n },\n },\n parent: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n evaluateToNode: true,\n executor: (context: NodeDefExpressionContext) => (nodeDef) => {\n const { survey } = context\n return getNodeDefParent({ survey, nodeDef })\n },\n },\n prevCycleValue: {\n minArity: 1,\n maxArity: 1,\n executor: emptyExecutor,\n },\n prevCycleValues: {\n minArity: 1,\n maxArity: 1,\n executor: emptyExecutor,\n },\n recordCycle: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordDateCreated: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordDateLastModified: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordOwnerEmail: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordOwnerName: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordOwnerRole: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n sum: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: (_context: NodeDefExpressionContext) => (_nodeSet) => 1,\n },\n taxonProp: {\n minArity: 3,\n maxArity: 3,\n executor:\n (context: NodeDefExpressionContext) => async (taxonomyName: string, propName: string, taxonCode: string) => {\n if (Objects.isEmpty(taxonomyName) || Objects.isEmpty(propName))\n throw new SystemError(SystemErrorKeys.expression.missingFunctionParameters)\n if (Objects.isEmpty(taxonCode)) return null\n\n const { survey } = context\n const taxonomy = getTaxonomyByName({ survey, taxonomyName })\n if (!taxonomy) throw new SystemError(SystemErrorKeys.expression.invalidTaxonomyName, { name: taxonomyName })\n\n const extraPropDef = taxonomy.props.extraPropsDefs?.[propName]\n if (!extraPropDef) throw new SystemError(SystemErrorKeys.expression.invalidTaxonomyExtraProp, { propName })\n\n const taxon = await getOrFetchTaxon({ context, taxonomyUuid: taxonomy.uuid, taxonCode })\n if (!taxon) return null\n\n const value = taxon.props.extra?.[propName]\n return ExtraProps.convertValue({ survey, extraPropDef, value })\n },\n },\n taxonVernacularName: {\n minArity: 3,\n maxArity: 3,\n executor:\n (context: NodeDefExpressionContext) =>\n async (taxonomyName: string, vernacularLangCode: string, taxonCode: string) => {\n if (Objects.isEmpty(taxonomyName) || Objects.isEmpty(vernacularLangCode))\n throw new SystemError(SystemErrorKeys.expression.missingFunctionParameters)\n if (Objects.isEmpty(taxonCode)) return null\n\n const { survey } = context\n const taxonomy = getTaxonomyByName({ survey, taxonomyName })\n if (!taxonomy) throw new SystemError(SystemErrorKeys.expression.invalidTaxonomyName, { name: taxonomyName })\n\n if (!LanguagesISO639part2[vernacularLangCode]) {\n throw new SystemError(SystemErrorKeys.expression.invalidTaxonVernacularNameLanguageCode, {\n vernacularLangCode,\n })\n }\n\n const taxon = await getOrFetchTaxon({ context, taxonomyUuid: taxonomy.uuid, taxonCode })\n if (!taxon) return null\n\n const vernacularNameArray = taxon.vernacularNames?.[vernacularLangCode]\n // consider first vernacular name object only\n const firstVernacularName = vernacularNameArray?.[0]\n return firstVernacularName?.props?.name\n },\n },\n unique: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: (_context: NodeDefExpressionContext) => (_nodeSet) => [],\n },\n userEmail: {\n minArity: 0,\n maxArity: 0,\n executor: (context: NodeDefExpressionContext) => () => context.user?.email,\n },\n userIsRecordOwner: {\n minArity: 0,\n maxArity: 0,\n executor: (_context: NodeDefExpressionContext) => () => false,\n },\n userName: {\n minArity: 0,\n maxArity: 0,\n executor: (context: NodeDefExpressionContext) => () => context.user?.name,\n },\n userProp: {\n minArity: 1,\n maxArity: 1,\n executor: (context: NodeDefExpressionContext) => (propName: string) => {\n const { user, survey } = context\n if (!survey || !user) return undefined\n const { uuid: surveyUuid } = survey\n const combinedExtraProps = Users.getCombinedExtraProps(surveyUuid)(user)\n return combinedExtraProps[propName]\n },\n },\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"survey.js","sourceRoot":"","sources":["../../../src/survey/survey.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"survey.js","sourceRoot":"","sources":["../../../src/survey/survey.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;AAM/B,MAAM,CAAN,IAAY,oBAcX;AAdD,WAAY,oBAAoB;IAC9B,iDAAyB,CAAA;IACzB,uDAA+B,CAAA;IAC/B,6CAAqB,CAAA;IACrB,6DAAqC,CAAA;IACrC,6CAAqB,CAAA;IACrB,2CAAmB,CAAA;IACnB,6CAAqB,CAAA;IACrB,6CAAqB,CAAA;IACrB,iDAAyB,CAAA;IACzB,6CAAqB,CAAA;IACrB,mDAA2B,CAAA;IAC3B,2CAAmB,CAAA;IACnB,6CAAqB,CAAA;AACvB,CAAC,EAdW,oBAAoB,KAApB,oBAAoB,QAc/B;AAWD,MAAM,CAAN,IAAY,kBAQX;AARD,WAAY,kBAAkB;IAC5B,mGAA6E,CAAA;IAC7E,qGAA+E,CAAA;IAC/E,yDAAmC,CAAA;IACnC,mFAA6D,CAAA;IAC7D,mFAA6D,CAAA;IAC7D,uGAAiF,CAAA;IACjF,qFAA+D,CAAA;AACjE,CAAC,EARW,kBAAkB,KAAlB,kBAAkB,QAQ7B;AAMD,MAAM,CAAC,MAAM,sBAAsB,GAAmB;IACpD,CAAC,kBAAkB,CAAC,oCAAoC,CAAC,EAAE,IAAI;IAC/D,CAAC,kBAAkB,CAAC,qCAAqC,CAAC,EAAE,IAAI;IAChE,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,IAAI;IAC1C,CAAC,kBAAkB,CAAC,4BAA4B,CAAC,EAAE,IAAI;IACvD,CAAC,kBAAkB,CAAC,4BAA4B,CAAC,EAAE,IAAI;IACvD,CAAC,kBAAkB,CAAC,sCAAsC,CAAC,EAAE,IAAI;IACjE,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,EAAE,IAAI;CACzD,CAAA;AAED,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;AACnB,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,aAAa,EAAE,eAAe;IAC9B,OAAO,EAAE,SAAS;CACV,CAAA","sourcesContent":["import { ArenaObject, Dictionary } from '../common'\nimport { AuthGroup } from '../auth'\nimport { Labels, LanguageCode } from '../language'\nimport type { AreaOfInterest } from '../geo'\nimport { SRS } from '../srs'\n\nimport { NodeDef, NodeDefType } from '../nodeDef'\nimport { Category } from '../category'\nimport { Taxonomy } from '../taxonomy'\nimport { SurveyRefData } from './refData/refData'\n\nexport const defaultCycle = '0'\n\nexport interface SurveyDependency {\n [nodeDefUuid: string]: string[] | boolean\n}\n\nexport enum SurveyDependencyType {\n applicable = 'applicable',\n defaultValues = 'defaultValues',\n editable = 'editable',\n enumeratingItems = 'enumeratingItems',\n fileName = 'fileName',\n formula = 'formula',\n maxCount = 'maxCount',\n minCount = 'minCount',\n parentCode = 'parentCode',\n required = 'required',\n validations = 'validations',\n visible = 'visible',\n onUpdate = 'onUpdate', // dependencies updated on every record update, stored as dictionary of booleans\n}\n\nexport type SurveyDependencyGraph = {\n [key in SurveyDependencyType]: SurveyDependency\n}\n\nexport interface SurveyCycle {\n dateEnd?: string\n dateStart: string\n}\n\nexport enum SurveySecurityProp {\n dataEditorViewNotOwnedRecordsAllowed = 'dataEditorViewNotOwnedRecordsAllowed',\n dataAnalystViewNotOwnedRecordsAllowed = 'dataAnalystViewNotOwnedRecordsAllowed',\n visibleInMobile = 'visibleInMobile',\n allowRecordsDownloadInMobile = 'allowRecordsDownloadInMobile',\n allowRecordsUploadFromMobile = 'allowRecordsUploadFromMobile',\n allowRecordsWithErrorsUploadFromMobile = 'allowRecordsWithErrorsUploadFromMobile',\n allowRecordsMergeWithSameKeys = 'allowRecordsMergeWithSameKeys',\n}\n\nexport type SurveySecurity = {\n [key in SurveySecurityProp]?: boolean\n}\n\nexport const surveySecurityDefaults: SurveySecurity = {\n [SurveySecurityProp.dataEditorViewNotOwnedRecordsAllowed]: true,\n [SurveySecurityProp.dataAnalystViewNotOwnedRecordsAllowed]: true,\n [SurveySecurityProp.visibleInMobile]: true,\n [SurveySecurityProp.allowRecordsDownloadInMobile]: true,\n [SurveySecurityProp.allowRecordsUploadFromMobile]: true,\n [SurveySecurityProp.allowRecordsWithErrorsUploadFromMobile]: true,\n [SurveySecurityProp.allowRecordsMergeWithSameKeys]: true,\n}\n\nexport enum SurveyDocPlace {\n header = 'header',\n footer = 'footer',\n}\n\nexport const surveyDocImagePropKeys = {\n documentPlace: 'documentPlace',\n applyIf: 'applyIf',\n} as const\n\nexport type SurveyDocImageProps = SurveyFileProps & {\n documentPlace?: SurveyDocPlace\n applyIf?: string\n}\n\nexport type SurveyFileProps = {\n deleted?: boolean\n labels?: Labels\n name?: string\n nodeUuid?: string\n recordUuid?: string\n size?: number | null\n temporary?: boolean\n type?: string\n}\n\nexport type SurveyFile = {\n uuid: string\n props: SurveyFileProps\n content?: Buffer | null\n dateCreated: string\n}\n\nexport type SurveyDocImage = SurveyFile & {\n props: SurveyDocImageProps\n}\n\nexport type SurveyDocOptions = {\n headerOnFirstPageOnly?: boolean // default: true\n}\n\nexport interface SurveyProps {\n areaOfInterest?: AreaOfInterest\n collectUri?: string\n cycles: {\n [key: string]: SurveyCycle\n }\n defaultCycleKey?: string\n descriptions?: Labels\n fieldManualLinks?: Labels\n // when true, values of attributes becoming non-applicable are kept during data entry (default: cleared)\n keepNonApplicableValues?: boolean\n labels?: Labels\n languages: LanguageCode[]\n name: string\n preloadedMapLayers?: SurveyFile[]\n preloadedMapLayersEnabled?: boolean\n security?: SurveySecurity\n srs: SRS[]\n surveyDocImages?: SurveyDocImage[]\n surveyDocOptions?: SurveyDocOptions\n}\n\nexport interface SurveyNodeDefsIndex {\n rootDefUuid?: string\n childDefUuidPresenceByParentUuid?: { [parentUuid: string]: { [nodeDefUuid: string]: boolean } }\n nodeDefUuidByName?: Dictionary<string>\n qualifierPresenceByUuid?: { [nodeDefUuid: string]: boolean }\n}\n\nexport interface Survey extends ArenaObject<SurveyProps> {\n authGroups: Array<AuthGroup>\n dateCreated?: string\n dateModified?: string\n datePublished?: string\n dependencyGraph?: SurveyDependencyGraph\n draft: boolean\n nodeDefs?: { [nodeDefUuid: string]: NodeDef<NodeDefType> }\n ownerUuid: string\n published: boolean\n readonly id?: number\n template: boolean\n uuid: string\n /**\n * Categories indexed by uuid.\n */\n categories?: { [categoryUuid: string]: Category }\n /**\n * Taxonomies indexed by uuid.\n */\n taxonomies?: { [taxonomyUuid: string]: Taxonomy }\n /**\n * Reference data cache (category items and taxa).\n */\n refData?: SurveyRefData\n\n nodeDefsIndex?: SurveyNodeDefsIndex\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { addNodeDefDependencies, buildAndAssocDependencyGraph, getNodeDefDependents, getOnUpdateDependents, removeNodeDefDependencies, } from './dependencies';
|
|
2
2
|
import { addNodeDefToIndex, buildAndAssocNodeDefsIndex, deleteNodeDefIndex, findNodeDefByName, findNodeDefByUuid, findNodeDefsByUuids, getDependentCodeAttributeDefs, getDependentEnumeratedEntityDefs, getDescendantsInSingleEntities, getNodeDefsArray, getNodeDefAncestorCodes, getNodeDefAncestorMultipleEntity, getNodeDefByName, getNodeDefByUuid, getNodeDefCategoryLevelIndex, getNodeDefChildren, getNodeDefChildrenSorted, getNodeDefEnumerator, getNodeDefKeys, getNodeDefParent, getNodeDefParentCode, getNodeDefRoot, getNodeDefSource, getNodeDefsByUuids, getNodeDefsIncludedInMultipleEntitySummary, getQualifierDefs, getRootKeys, isNodeDefAncestor, isNodeDefEnumerator, isNodeDefParentCode, updateNodeDefUuidByNameIndex, visitAncestorsAndSelfNodeDef, visitDescendantsAndSelfNodeDef, visitNodeDefs, } from './nodeDefs';
|
|
3
3
|
import { getCategoryItemByCodePaths, getCategoryItemByUuid, getCategoryItemUuidByCode, getCategoryItems, getCategoryItemsByNodeDef, getCategoryItemsInLevel, getTaxonByCode, getTaxonByUuid, getTaxonVernacularNameUuid, includesTaxonVernacularName, } from './refsData';
|
|
4
|
-
import { getCategoryByName, getCategoryByUuid, getCycleKeys, getDefaultCycleKey, getDefaultLanguage, getDescription, getFieldManualLink, getLabel, getLabelOrName, getLanguages, getLastCycleKey, getName, getSRSByCode, getSRSIndex, getSRSs, getTaxonomyByName, getTaxonomyByUuid, getAuthGroups, getAuthGroupAdmin, isKeepNonApplicableValues, } from './surveysGetters';
|
|
4
|
+
import { getCategoryByName, getCategoryByUuid, getCycleKeys, getDefaultCycleKey, getDefaultLanguage, getDescription, getFieldManualLink, getLabel, getLabelOrName, getLanguages, getLastCycleKey, getName, getSRSByCode, getSRSIndex, getAreaOfInterest, getSRSs, getTaxonomyByName, getTaxonomyByUuid, getAuthGroups, getAuthGroupAdmin, isKeepNonApplicableValues, } from './surveysGetters';
|
|
5
5
|
import { getSecurity, isDataAnalystViewNotOwnedRecordsAllowed, isDataEditorViewNotOwnedRecordsAllowed, isRecordsDownloadInMobileAllowed, isRecordsMergeWithSameKeysAllowed, isRecordsUploadFromMobileAllowed, isRecordsWithErrorsUploadFromMobileAllowed, isVisibleInMobile, } from './surveyGettersSecurity';
|
|
6
6
|
import { findApplicableDependentEnumeratedEntityDefs, getEnumeratingCategoryItems } from './surveysUtils';
|
|
7
7
|
export const Surveys = {
|
|
@@ -18,6 +18,7 @@ export const Surveys = {
|
|
|
18
18
|
getSRSs,
|
|
19
19
|
getSRSByCode,
|
|
20
20
|
getSRSIndex,
|
|
21
|
+
getAreaOfInterest,
|
|
21
22
|
getCategoryByName,
|
|
22
23
|
getCategoryByUuid,
|
|
23
24
|
getTaxonomyByName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/survey/surveys/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC5B,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,6BAA6B,EAC7B,gCAAgC,EAChC,8BAA8B,EAC9B,gBAAgB,EAChB,uBAAuB,EACvB,gCAAgC,EAChC,gBAAgB,EAChB,gBAAgB,EAChB,4BAA4B,EAC5B,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,0CAA0C,EAC1C,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,4BAA4B,EAC5B,4BAA4B,EAC5B,8BAA8B,EAC9B,aAAa,GACd,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,gBAAgB,EAChB,yBAAyB,EACzB,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,eAAe,EACf,OAAO,EACP,YAAY,EACZ,WAAW,EACX,OAAO,EACP,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,kBAAkB,CAAA;AAEzB,OAAO,E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;IAC5B,kBAAkB;IAElB,WAAW;IACX,WAAW;IACX,uCAAuC;IACvC,sCAAsC;IACtC,iBAAiB;IACjB,gCAAgC;IAChC,gCAAgC;IAChC,0CAA0C;IAC1C,iCAAiC;IAEjC,QAAQ;IACR,2BAA2B;IAC3B,2CAA2C;CAC5C,CAAA","sourcesContent":["import {\n addNodeDefDependencies,\n buildAndAssocDependencyGraph,\n getNodeDefDependents,\n getOnUpdateDependents,\n removeNodeDefDependencies,\n} from './dependencies'\n\nimport {\n addNodeDefToIndex,\n buildAndAssocNodeDefsIndex,\n deleteNodeDefIndex,\n findNodeDefByName,\n findNodeDefByUuid,\n findNodeDefsByUuids,\n getDependentCodeAttributeDefs,\n getDependentEnumeratedEntityDefs,\n getDescendantsInSingleEntities,\n getNodeDefsArray,\n getNodeDefAncestorCodes,\n getNodeDefAncestorMultipleEntity,\n getNodeDefByName,\n getNodeDefByUuid,\n getNodeDefCategoryLevelIndex,\n getNodeDefChildren,\n getNodeDefChildrenSorted,\n getNodeDefEnumerator,\n getNodeDefKeys,\n getNodeDefParent,\n getNodeDefParentCode,\n getNodeDefRoot,\n getNodeDefSource,\n getNodeDefsByUuids,\n getNodeDefsIncludedInMultipleEntitySummary,\n getQualifierDefs,\n getRootKeys,\n isNodeDefAncestor,\n isNodeDefEnumerator,\n isNodeDefParentCode,\n updateNodeDefUuidByNameIndex,\n visitAncestorsAndSelfNodeDef,\n visitDescendantsAndSelfNodeDef,\n visitNodeDefs,\n} from './nodeDefs'\n\nimport {\n getCategoryItemByCodePaths,\n getCategoryItemByUuid,\n getCategoryItemUuidByCode,\n getCategoryItems,\n getCategoryItemsByNodeDef,\n getCategoryItemsInLevel,\n getTaxonByCode,\n getTaxonByUuid,\n getTaxonVernacularNameUuid,\n includesTaxonVernacularName,\n} from './refsData'\n\nimport {\n getCategoryByName,\n getCategoryByUuid,\n getCycleKeys,\n getDefaultCycleKey,\n getDefaultLanguage,\n getDescription,\n getFieldManualLink,\n getLabel,\n getLabelOrName,\n getLanguages,\n getLastCycleKey,\n getName,\n getSRSByCode,\n getSRSIndex,\n getSRSs,\n getTaxonomyByName,\n getTaxonomyByUuid,\n getAuthGroups,\n getAuthGroupAdmin,\n isKeepNonApplicableValues,\n} from './surveysGetters'\n\nimport {\n getSecurity,\n isDataAnalystViewNotOwnedRecordsAllowed,\n isDataEditorViewNotOwnedRecordsAllowed,\n isRecordsDownloadInMobileAllowed,\n isRecordsMergeWithSameKeysAllowed,\n isRecordsUploadFromMobileAllowed,\n isRecordsWithErrorsUploadFromMobileAllowed,\n isVisibleInMobile,\n} from './surveyGettersSecurity'\n\nimport { findApplicableDependentEnumeratedEntityDefs, getEnumeratingCategoryItems } from './surveysUtils'\n\nexport const Surveys = {\n getName,\n getLanguages,\n getDefaultLanguage,\n getLabel,\n getLabelOrName,\n getDescription,\n getFieldManualLink,\n getCycleKeys,\n getLastCycleKey,\n getDefaultCycleKey,\n getSRSs,\n getSRSByCode,\n getSRSIndex,\n getCategoryByName,\n getCategoryByUuid,\n getTaxonomyByName,\n getTaxonomyByUuid,\n getAuthGroups,\n getAuthGroupAdmin,\n isKeepNonApplicableValues,\n\n findNodeDefByName,\n findNodeDefByUuid,\n findNodeDefsByUuids,\n getNodeDefsArray,\n getNodeDefByName,\n getNodeDefsByUuids,\n getNodeDefByUuid,\n getNodeDefChildren,\n getNodeDefChildrenSorted,\n getNodeDefParent,\n getNodeDefAncestorMultipleEntity,\n getNodeDefRoot,\n getNodeDefSource,\n isNodeDefAncestor,\n getNodeDefKeys,\n getRootKeys,\n getNodeDefsIncludedInMultipleEntitySummary,\n getQualifierDefs,\n isNodeDefEnumerator,\n getNodeDefEnumerator,\n visitAncestorsAndSelfNodeDef,\n visitDescendantsAndSelfNodeDef,\n visitNodeDefs,\n getDescendantsInSingleEntities,\n\n // ref data\n getCategoryItemByCodePaths,\n getCategoryItemByUuid,\n getCategoryItemUuidByCode,\n getCategoryItems,\n getCategoryItemsByNodeDef,\n getCategoryItemsInLevel,\n getTaxonByCode,\n getTaxonByUuid,\n getTaxonVernacularNameUuid,\n includesTaxonVernacularName,\n\n // node def code\n getNodeDefParentCode,\n getNodeDefAncestorCodes,\n isNodeDefParentCode,\n getNodeDefCategoryLevelIndex,\n getDependentCodeAttributeDefs,\n getDependentEnumeratedEntityDefs,\n\n // dependencies\n buildAndAssocDependencyGraph,\n addNodeDefDependencies,\n getNodeDefDependents,\n getOnUpdateDependents,\n removeNodeDefDependencies,\n\n // index\n buildAndAssocNodeDefsIndex,\n addNodeDefToIndex,\n updateNodeDefUuidByNameIndex,\n deleteNodeDefIndex,\n\n // security\n getSecurity,\n isDataAnalystViewNotOwnedRecordsAllowed,\n isDataEditorViewNotOwnedRecordsAllowed,\n isVisibleInMobile,\n isRecordsDownloadInMobileAllowed,\n isRecordsUploadFromMobileAllowed,\n isRecordsWithErrorsUploadFromMobileAllowed,\n isRecordsMergeWithSameKeysAllowed,\n\n // utils\n getEnumeratingCategoryItems,\n findApplicableDependentEnumeratedEntityDefs,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/survey/surveys/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC5B,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,6BAA6B,EAC7B,gCAAgC,EAChC,8BAA8B,EAC9B,gBAAgB,EAChB,uBAAuB,EACvB,gCAAgC,EAChC,gBAAgB,EAChB,gBAAgB,EAChB,4BAA4B,EAC5B,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,0CAA0C,EAC1C,gBAAgB,EAChB,WAAW,EACX,iBAAiB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BAAkB;IAClB,wBAAwB;IACxB,gBAAgB;IAChB,gCAAgC;IAChC,cAAc;IACd,gBAAgB;IAChB,iBAAiB;IACjB,cAAc;IACd,WAAW;IACX,0CAA0C;IAC1C,gBAAgB;IAChB,mBAAmB;IACnB,oBAAoB;IACpB,4BAA4B;IAC5B,8BAA8B;IAC9B,aAAa;IACb,8BAA8B;IAE9B,WAAW;IACX,0BAA0B;IAC1B,qBAAqB;IACrB,yBAAyB;IACzB,gBAAgB;IAChB,yBAAyB;IACzB,uBAAuB;IACvB,cAAc;IACd,cAAc;IACd,0BAA0B;IAC1B,2BAA2B;IAE3B,gBAAgB;IAChB,oBAAoB;IACpB,uBAAuB;IACvB,mBAAmB;IACnB,4BAA4B;IAC5B,6BAA6B;IAC7B,gCAAgC;IAEhC,eAAe;IACf,4BAA4B;IAC5B,sBAAsB;IACtB,oBAAoB;IACpB,qBAAqB;IACrB,yBAAyB;IAEzB,QAAQ;IACR,0BAA0B;IAC1B,iBAAiB;IACjB,4BAA4B;IAC5B,kBAAkB;IAElB,WAAW;IACX,WAAW;IACX,uCAAuC;IACvC,sCAAsC;IACtC,iBAAiB;IACjB,gCAAgC;IAChC,gCAAgC;IAChC,0CAA0C;IAC1C,iCAAiC;IAEjC,QAAQ;IACR,2BAA2B;IAC3B,2CAA2C;CAC5C,CAAA","sourcesContent":["import {\n addNodeDefDependencies,\n buildAndAssocDependencyGraph,\n getNodeDefDependents,\n getOnUpdateDependents,\n removeNodeDefDependencies,\n} from './dependencies'\n\nimport {\n addNodeDefToIndex,\n buildAndAssocNodeDefsIndex,\n deleteNodeDefIndex,\n findNodeDefByName,\n findNodeDefByUuid,\n findNodeDefsByUuids,\n getDependentCodeAttributeDefs,\n getDependentEnumeratedEntityDefs,\n getDescendantsInSingleEntities,\n getNodeDefsArray,\n getNodeDefAncestorCodes,\n getNodeDefAncestorMultipleEntity,\n getNodeDefByName,\n getNodeDefByUuid,\n getNodeDefCategoryLevelIndex,\n getNodeDefChildren,\n getNodeDefChildrenSorted,\n getNodeDefEnumerator,\n getNodeDefKeys,\n getNodeDefParent,\n getNodeDefParentCode,\n getNodeDefRoot,\n getNodeDefSource,\n getNodeDefsByUuids,\n getNodeDefsIncludedInMultipleEntitySummary,\n getQualifierDefs,\n getRootKeys,\n isNodeDefAncestor,\n isNodeDefEnumerator,\n isNodeDefParentCode,\n updateNodeDefUuidByNameIndex,\n visitAncestorsAndSelfNodeDef,\n visitDescendantsAndSelfNodeDef,\n visitNodeDefs,\n} from './nodeDefs'\n\nimport {\n getCategoryItemByCodePaths,\n getCategoryItemByUuid,\n getCategoryItemUuidByCode,\n getCategoryItems,\n getCategoryItemsByNodeDef,\n getCategoryItemsInLevel,\n getTaxonByCode,\n getTaxonByUuid,\n getTaxonVernacularNameUuid,\n includesTaxonVernacularName,\n} from './refsData'\n\nimport {\n getCategoryByName,\n getCategoryByUuid,\n getCycleKeys,\n getDefaultCycleKey,\n getDefaultLanguage,\n getDescription,\n getFieldManualLink,\n getLabel,\n getLabelOrName,\n getLanguages,\n getLastCycleKey,\n getName,\n getSRSByCode,\n getSRSIndex,\n getAreaOfInterest,\n getSRSs,\n getTaxonomyByName,\n getTaxonomyByUuid,\n getAuthGroups,\n getAuthGroupAdmin,\n isKeepNonApplicableValues,\n} from './surveysGetters'\n\nimport {\n getSecurity,\n isDataAnalystViewNotOwnedRecordsAllowed,\n isDataEditorViewNotOwnedRecordsAllowed,\n isRecordsDownloadInMobileAllowed,\n isRecordsMergeWithSameKeysAllowed,\n isRecordsUploadFromMobileAllowed,\n isRecordsWithErrorsUploadFromMobileAllowed,\n isVisibleInMobile,\n} from './surveyGettersSecurity'\n\nimport { findApplicableDependentEnumeratedEntityDefs, getEnumeratingCategoryItems } from './surveysUtils'\n\nexport const Surveys = {\n getName,\n getLanguages,\n getDefaultLanguage,\n getLabel,\n getLabelOrName,\n getDescription,\n getFieldManualLink,\n getCycleKeys,\n getLastCycleKey,\n getDefaultCycleKey,\n getSRSs,\n getSRSByCode,\n getSRSIndex,\n getAreaOfInterest,\n getCategoryByName,\n getCategoryByUuid,\n getTaxonomyByName,\n getTaxonomyByUuid,\n getAuthGroups,\n getAuthGroupAdmin,\n isKeepNonApplicableValues,\n\n findNodeDefByName,\n findNodeDefByUuid,\n findNodeDefsByUuids,\n getNodeDefsArray,\n getNodeDefByName,\n getNodeDefsByUuids,\n getNodeDefByUuid,\n getNodeDefChildren,\n getNodeDefChildrenSorted,\n getNodeDefParent,\n getNodeDefAncestorMultipleEntity,\n getNodeDefRoot,\n getNodeDefSource,\n isNodeDefAncestor,\n getNodeDefKeys,\n getRootKeys,\n getNodeDefsIncludedInMultipleEntitySummary,\n getQualifierDefs,\n isNodeDefEnumerator,\n getNodeDefEnumerator,\n visitAncestorsAndSelfNodeDef,\n visitDescendantsAndSelfNodeDef,\n visitNodeDefs,\n getDescendantsInSingleEntities,\n\n // ref data\n getCategoryItemByCodePaths,\n getCategoryItemByUuid,\n getCategoryItemUuidByCode,\n getCategoryItems,\n getCategoryItemsByNodeDef,\n getCategoryItemsInLevel,\n getTaxonByCode,\n getTaxonByUuid,\n getTaxonVernacularNameUuid,\n includesTaxonVernacularName,\n\n // node def code\n getNodeDefParentCode,\n getNodeDefAncestorCodes,\n isNodeDefParentCode,\n getNodeDefCategoryLevelIndex,\n getDependentCodeAttributeDefs,\n getDependentEnumeratedEntityDefs,\n\n // dependencies\n buildAndAssocDependencyGraph,\n addNodeDefDependencies,\n getNodeDefDependents,\n getOnUpdateDependents,\n removeNodeDefDependencies,\n\n // index\n buildAndAssocNodeDefsIndex,\n addNodeDefToIndex,\n updateNodeDefUuidByNameIndex,\n deleteNodeDefIndex,\n\n // security\n getSecurity,\n isDataAnalystViewNotOwnedRecordsAllowed,\n isDataEditorViewNotOwnedRecordsAllowed,\n isVisibleInMobile,\n isRecordsDownloadInMobileAllowed,\n isRecordsUploadFromMobileAllowed,\n isRecordsWithErrorsUploadFromMobileAllowed,\n isRecordsMergeWithSameKeysAllowed,\n\n // utils\n getEnumeratingCategoryItems,\n findApplicableDependentEnumeratedEntityDefs,\n}\n"]}
|
|
@@ -63,6 +63,9 @@ export const getSRSIndex = (survey) => getSRSs(survey).reduce((acc, srs) => {
|
|
|
63
63
|
return acc;
|
|
64
64
|
}, {});
|
|
65
65
|
export const getSRSByCode = (code) => (survey) => getSRSIndex(survey)[code];
|
|
66
|
+
export const getAreaOfInterest = (survey) => { var _a, _b, _c; var _d, _e; return (_e = (_d = (_a = survey === null || survey === void 0 ? void 0 : survey.props) === null || _a === void 0 ? void 0 : _a.areaOfInterest) !== null && _d !== void 0 ? _d :
|
|
67
|
+
// backwards compatibility with Arena: survey info props stored in info
|
|
68
|
+
(_c = (_b = survey === null || survey === void 0 ? void 0 : survey.info) === null || _b === void 0 ? void 0 : _b.props) === null || _c === void 0 ? void 0 : _c.areaOfInterest) !== null && _e !== void 0 ? _e : undefined; };
|
|
66
69
|
export const getAuthGroups = (survey) => { var _a; return (_a = survey === null || survey === void 0 ? void 0 : survey.authGroups) !== null && _a !== void 0 ? _a : []; };
|
|
67
70
|
export const getAuthGroupAdmin = (survey) => getAuthGroups(survey).find((authGroup) => authGroup.name === AuthGroupName.surveyAdmin);
|
|
68
71
|
//# sourceMappingURL=surveysGetters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surveysGetters.js","sourceRoot":"","sources":["../../../../src/survey/surveys/surveysGetters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAiB,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"surveysGetters.js","sourceRoot":"","sources":["../../../../src/survey/surveys/surveysGetters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAiB,MAAM,YAAY,CAAA;AAIzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAGzD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAG7C,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC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,CAAC,CAAC,IAAI,CAAC,CAAA;AAE7B,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAA8B,EAAE,kDAC9E,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,0CAAE,cAAc;AAC7B,uEAAuE;AACvE,MAAA,MAAC,MAAc,aAAd,MAAM,uBAAN,MAAM,CAAU,IAAI,0CAAE,KAAK,0CAAE,cAAc,mCAC5C,SAAS,GAAA,CAAA;AAEX,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAc,EAAmB,EAAE,wBAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,UAAU,mCAAI,EAAE,GAAA,CAAA;AAE1F,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAA6B,EAAE,CAC7E,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,aAAa,CAAC,WAAW,CAAC,CAAA","sourcesContent":["import { AuthGroupName, UserAuthGroup } from '../../auth'\nimport { Category } from '../../category'\nimport type { AreaOfInterest } from '../../geo'\nimport { LanguageCode } from '../../language'\nimport { getLabelOrDefault } from '../../language/labels'\nimport { SRS, SRSIndex } from '../../srs'\nimport { Taxonomy } from '../../taxonomy'\nimport { Arrays, Objects } from '../../utils'\nimport { Survey } from '../survey'\n\nexport const getName = (survey: Survey): string => survey.props.name\n\nexport const getLanguages = (survey: Survey): LanguageCode[] => survey.props.languages\n\nexport const getDefaultLanguage = (survey: Survey): LanguageCode => getLanguages(survey)[0]\n\nconst getMultilangPropValue =\n (prop: 'labels' | 'descriptions' | 'fieldManualLinks') =>\n (langCode?: LanguageCode) =>\n (survey: Survey): string | undefined => {\n const languageCode = langCode ?? getDefaultLanguage(survey)\n return survey.props[prop]?.[languageCode]\n }\nexport const getLabel = getMultilangPropValue('labels')\nexport const getDescription = getMultilangPropValue('descriptions')\nexport const getFieldManualLink = getMultilangPropValue('fieldManualLinks')\n\n/**\n * Returns the survey label in the specified language (the default language if not specified), or the survey name\n * when the label is missing or empty.\n */\nexport const getLabelOrName =\n (langCode?: LanguageCode) =>\n (survey: Survey): string =>\n getLabelOrDefault(survey.props.labels, langCode ?? getDefaultLanguage(survey), getName(survey))\n\nexport const getCategoryByName = (params: { survey: Survey; categoryName: string }): Category | undefined => {\n const { survey, categoryName } = params\n return survey.categories\n ? Object.values(survey.categories).find((category) => category.props.name === categoryName)\n : undefined\n}\n\nexport const getCategoryByUuid = (params: { survey: Survey; categoryUuid: string }): Category | undefined => {\n const { survey, categoryUuid } = params\n return survey.categories?.[categoryUuid]\n}\n\nexport const getTaxonomyByName = (params: { survey: Survey; taxonomyName: string }): Taxonomy | undefined => {\n const { survey, taxonomyName } = params\n return survey.taxonomies\n ? Object.values(survey.taxonomies).find((taxonomy) => taxonomy.props.name === taxonomyName)\n : undefined\n}\n\nexport const getTaxonomyByUuid = (params: { survey: Survey; taxonomyUuid: string }): Taxonomy | undefined => {\n const { survey, taxonomyUuid } = params\n return survey.taxonomies?.[taxonomyUuid]\n}\n\nexport const getCycleKeys = (survey: Survey): string[] => {\n const cycles = survey.props?.cycles ?? {}\n return Object.keys(cycles)\n}\n\nexport const getLastCycleKey = (survey: Survey): string => Arrays.last(getCycleKeys(survey)) as string\n\nexport const isKeepNonApplicableValues = (survey: Survey): boolean => survey?.props?.keepNonApplicableValues === true\n\nexport const getDefaultCycleKey = (survey: Survey) => {\n const defaultCycleKey = survey.props?.defaultCycleKey\n const lastCycleKey = getLastCycleKey(survey)\n return Objects.isEmpty(defaultCycleKey) || Number(defaultCycleKey) > Number(lastCycleKey)\n ? lastCycleKey\n : defaultCycleKey\n}\n\nexport const getSRSs = (survey: Survey): SRS[] =>\n survey.props?.srs ??\n // backwards compatibility with Arena: srs stored in info in UI\n (survey as any).info?.props?.srs ??\n []\n\nexport const getSRSIndex = (survey: Survey): SRSIndex =>\n getSRSs(survey).reduce((acc: SRSIndex, srs) => {\n acc[srs.code] = srs\n return acc\n }, {})\n\nexport const getSRSByCode =\n (code: string) =>\n (survey: Survey): SRS | undefined =>\n getSRSIndex(survey)[code]\n\nexport const getAreaOfInterest = (survey: Survey): AreaOfInterest | undefined =>\n survey?.props?.areaOfInterest ??\n // backwards compatibility with Arena: survey info props stored in info\n (survey as any)?.info?.props?.areaOfInterest ??\n undefined\n\nexport const getAuthGroups = (survey: Survey): UserAuthGroup[] => survey?.authGroups ?? []\n\nexport const getAuthGroupAdmin = (survey: Survey): UserAuthGroup | undefined =>\n getAuthGroups(survey).find((authGroup) => authGroup.name === AuthGroupName.surveyAdmin)\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"areaOfInterest.js","sourceRoot":"","sources":["../../src/geo/areaOfInterest.ts"],"names":[],"mappings":"","sourcesContent":["import type { MultiPolygon, Polygon } from 'geojson'\n\n/**\n * Area of interest of a survey: GeoJSON polygon or multi polygon geometry in WGS84 (EPSG:4326).\n */\nexport type AreaOfInterest = Polygon | MultiPolygon\n"]}
|
package/dist/geo/index.d.ts
CHANGED
package/dist/geo/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/geo/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/geo/index.ts"],"names":[],"mappings":";;;AAGA,+CAA6C;AAApC,4GAAA,YAAY,OAAA;AAErB,mCAAiC;AAAxB,gGAAA,MAAM,OAAA","sourcesContent":["export type { AreaOfInterest } from './areaOfInterest'\nexport type { Point } from './point'\n\nexport { PointFactory } from './pointFactory'\n\nexport { Points } from './points'\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SRSIndex } from '../../srs';
|
|
2
|
+
import { AreaOfInterest } from '../areaOfInterest';
|
|
3
|
+
import { Point } from '../point';
|
|
4
|
+
/**
|
|
5
|
+
* Returns the distance (in meters) between a point and the boundary of a polygon: negative inside, positive outside.
|
|
6
|
+
*
|
|
7
|
+
* @param {!Point} point - The point.
|
|
8
|
+
* @param {!AreaOfInterest} polygon - Polygon or multi polygon in WGS84.
|
|
9
|
+
* @param {!SRSIndex} srsIndex - SRSs indexed by SRS code.
|
|
10
|
+
* @returns {number|null} - The signed distance in meters, or null if the point or the polygon are not valid.
|
|
11
|
+
*/
|
|
12
|
+
export declare const distanceToPolygonBoundary: (point: Point, polygon: AreaOfInterest, srsIndex?: SRSIndex) => number | null;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.distanceToPolygonBoundary = void 0;
|
|
7
|
+
const point_to_polygon_distance_1 = __importDefault(require("@turf/point-to-polygon-distance"));
|
|
8
|
+
const srs_1 = require("../../srs");
|
|
9
|
+
const toLatLong_1 = require("./toLatLong");
|
|
10
|
+
/**
|
|
11
|
+
* Returns the distance (in meters) between a point and the boundary of a polygon: negative inside, positive outside.
|
|
12
|
+
*
|
|
13
|
+
* @param {!Point} point - The point.
|
|
14
|
+
* @param {!AreaOfInterest} polygon - Polygon or multi polygon in WGS84.
|
|
15
|
+
* @param {!SRSIndex} srsIndex - SRSs indexed by SRS code.
|
|
16
|
+
* @returns {number|null} - The signed distance in meters, or null if the point or the polygon are not valid.
|
|
17
|
+
*/
|
|
18
|
+
const distanceToPolygonBoundary = (point, polygon, srsIndex = srs_1.DEFAULT_SRS_INDEX) => {
|
|
19
|
+
const pointLatLong = (0, toLatLong_1.toLatLong)(point, srsIndex);
|
|
20
|
+
if (!pointLatLong)
|
|
21
|
+
return null;
|
|
22
|
+
try {
|
|
23
|
+
// turf expects [longitude, latitude]; planar: polygon edges are straight lines (as in GeoJSON and on the map),
|
|
24
|
+
// consistent with the inside/outside check (geodesic would measure to great-circle edges)
|
|
25
|
+
return (0, point_to_polygon_distance_1.default)([pointLatLong.x, pointLatLong.y], polygon, { units: 'meters', method: 'planar' });
|
|
26
|
+
}
|
|
27
|
+
catch (_a) {
|
|
28
|
+
// invalid polygon geometry
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.distanceToPolygonBoundary = distanceToPolygonBoundary;
|
|
33
|
+
//# sourceMappingURL=distanceToPolygonBoundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distanceToPolygonBoundary.js","sourceRoot":"","sources":["../../../src/geo/points/distanceToPolygonBoundary.ts"],"names":[],"mappings":";;;;;;AAAA,gGAAoE;AAEpE,mCAAuD;AAGvD,2CAAuC;AAEvC;;;;;;;GAOG;AACI,MAAM,yBAAyB,GAAG,CACvC,KAAY,EACZ,OAAuB,EACvB,QAAQ,GAAa,uBAAiB,EACvB,EAAE;IACjB,MAAM,YAAY,GAAG,IAAA,qBAAS,EAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;IAC/C,IAAI,CAAC,YAAY;QAAE,OAAO,IAAI,CAAA;IAC9B,IAAI,CAAC;QACH,+GAA+G;QAC/G,0FAA0F;QAC1F,OAAO,IAAA,mCAAsB,EAAC,CAAC,YAAY,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;IACjH,CAAC;eAAO,CAAC;QACP,2BAA2B;QAC3B,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC,CAAA;AAfY,QAAA,yBAAyB,GAAzB,yBAAyB,CAerC","sourcesContent":["import pointToPolygonDistance from '@turf/point-to-polygon-distance'\n\nimport { DEFAULT_SRS_INDEX, SRSIndex } from '../../srs'\nimport { AreaOfInterest } from '../areaOfInterest'\nimport { Point } from '../point'\nimport { toLatLong } from './toLatLong'\n\n/**\n * Returns the distance (in meters) between a point and the boundary of a polygon: negative inside, positive outside.\n *\n * @param {!Point} point - The point.\n * @param {!AreaOfInterest} polygon - Polygon or multi polygon in WGS84.\n * @param {!SRSIndex} srsIndex - SRSs indexed by SRS code.\n * @returns {number|null} - The signed distance in meters, or null if the point or the polygon are not valid.\n */\nexport const distanceToPolygonBoundary = (\n point: Point,\n polygon: AreaOfInterest,\n srsIndex: SRSIndex = DEFAULT_SRS_INDEX\n): number | null => {\n const pointLatLong = toLatLong(point, srsIndex)\n if (!pointLatLong) return null\n try {\n // turf expects [longitude, latitude]; planar: polygon edges are straight lines (as in GeoJSON and on the map),\n // consistent with the inside/outside check (geodesic would measure to great-circle edges)\n return pointToPolygonDistance([pointLatLong.x, pointLatLong.y], polygon, { units: 'meters', method: 'planar' })\n } catch {\n // invalid polygon geometry\n return null\n }\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { bearing } from './bearing';
|
|
2
2
|
import { distance } from './distance';
|
|
3
|
+
import { distanceToPolygonBoundary } from './distanceToPolygonBoundary';
|
|
3
4
|
import { equals } from './equals';
|
|
4
5
|
import { isValid } from './isValid';
|
|
5
6
|
import { pointAtDistance } from './pointAtDistance';
|
|
@@ -10,6 +11,7 @@ import { transform, transformOrThrow } from './transform';
|
|
|
10
11
|
export declare const Points: {
|
|
11
12
|
bearing: typeof bearing;
|
|
12
13
|
distance: typeof distance;
|
|
14
|
+
distanceToPolygonBoundary: typeof distanceToPolygonBoundary;
|
|
13
15
|
equals: typeof equals;
|
|
14
16
|
isValid: typeof isValid;
|
|
15
17
|
pointAtDistance: typeof pointAtDistance;
|
package/dist/geo/points/index.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Points = void 0;
|
|
4
4
|
const bearing_1 = require("./bearing");
|
|
5
5
|
const distance_1 = require("./distance");
|
|
6
|
+
const distanceToPolygonBoundary_1 = require("./distanceToPolygonBoundary");
|
|
6
7
|
const equals_1 = require("./equals");
|
|
7
8
|
const isValid_1 = require("./isValid");
|
|
8
9
|
const pointAtDistance_1 = require("./pointAtDistance");
|
|
@@ -13,6 +14,7 @@ const transform_1 = require("./transform");
|
|
|
13
14
|
exports.Points = {
|
|
14
15
|
bearing: bearing_1.bearing,
|
|
15
16
|
distance: distance_1.distance,
|
|
17
|
+
distanceToPolygonBoundary: distanceToPolygonBoundary_1.distanceToPolygonBoundary,
|
|
16
18
|
equals: equals_1.equals,
|
|
17
19
|
isValid: isValid_1.isValid,
|
|
18
20
|
pointAtDistance: pointAtDistance_1.pointAtDistance,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/geo/points/index.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AACnC,yCAAqC;AACrC,qCAAiC;AACjC,uCAAmC;AACnC,uDAAmD;AACnD,mCAA+B;AAC/B,2CAAuC;AACvC,yCAAqC;AACrC,2CAAyD;AAE5C,QAAA,MAAM,GAAG;IACpB,OAAO,EAAP,iBAAO;IACP,QAAQ,EAAR,mBAAQ;IACR,MAAM,EAAN,eAAM;IACN,OAAO,EAAP,iBAAO;IACP,eAAe,EAAf,iCAAe;IACf,KAAK,EAAL,aAAK;IACL,SAAS,EAAT,qBAAS;IACT,QAAQ,EAAR,mBAAQ;IACR,SAAS,EAAT,qBAAS;IACT,gBAAgB,EAAhB,4BAAgB;CACjB,CAAA","sourcesContent":["import { bearing } from './bearing'\nimport { distance } from './distance'\nimport { equals } from './equals'\nimport { isValid } from './isValid'\nimport { pointAtDistance } from './pointAtDistance'\nimport { parse } from './parse'\nimport { toLatLong } from './toLatLong'\nimport { toString } from './toString'\nimport { transform, transformOrThrow } from './transform'\n\nexport const Points = {\n bearing,\n distance,\n equals,\n isValid,\n pointAtDistance,\n parse,\n toLatLong,\n toString,\n transform,\n transformOrThrow,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/geo/points/index.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AACnC,yCAAqC;AACrC,2EAAuE;AACvE,qCAAiC;AACjC,uCAAmC;AACnC,uDAAmD;AACnD,mCAA+B;AAC/B,2CAAuC;AACvC,yCAAqC;AACrC,2CAAyD;AAE5C,QAAA,MAAM,GAAG;IACpB,OAAO,EAAP,iBAAO;IACP,QAAQ,EAAR,mBAAQ;IACR,yBAAyB,EAAzB,qDAAyB;IACzB,MAAM,EAAN,eAAM;IACN,OAAO,EAAP,iBAAO;IACP,eAAe,EAAf,iCAAe;IACf,KAAK,EAAL,aAAK;IACL,SAAS,EAAT,qBAAS;IACT,QAAQ,EAAR,mBAAQ;IACR,SAAS,EAAT,qBAAS;IACT,gBAAgB,EAAhB,4BAAgB;CACjB,CAAA","sourcesContent":["import { bearing } from './bearing'\nimport { distance } from './distance'\nimport { distanceToPolygonBoundary } from './distanceToPolygonBoundary'\nimport { equals } from './equals'\nimport { isValid } from './isValid'\nimport { pointAtDistance } from './pointAtDistance'\nimport { parse } from './parse'\nimport { toLatLong } from './toLatLong'\nimport { toString } from './toString'\nimport { transform, transformOrThrow } from './transform'\n\nexport const Points = {\n bearing,\n distance,\n distanceToPolygonBoundary,\n equals,\n isValid,\n pointAtDistance,\n parse,\n toLatLong,\n toString,\n transform,\n transformOrThrow,\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type { ArrayExpression, BinaryExpression, CallExpression, CompoundExpress
|
|
|
18
18
|
export { ExtraPropDataType, ExtraPropsDataGenerator } from './extraProp';
|
|
19
19
|
export type { ExtraPropDef, ExtraPropDefs } from './extraProp';
|
|
20
20
|
export { PointFactory, Points } from './geo';
|
|
21
|
-
export type { Point } from './geo';
|
|
21
|
+
export type { AreaOfInterest, Point } from './geo';
|
|
22
22
|
export { JobBase, JobEventType, JobStatus } from './job';
|
|
23
23
|
export type { Job, JobContext, JobEvent, JobSerialized, JobTxClient } from './job';
|
|
24
24
|
export { LanguageCode, Languages, LanguagesISO639part2 } from './language';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAEA,+BAAyG;AAAhG,kGAAA,UAAU,OAAA;AAAE,qGAAA,aAAa,OAAA;AAAE,kGAAA,UAAU,OAAA;AAAE,kGAAA,UAAU,OAAA;AAAE,iGAAA,SAAS,OAAA;AAAE,mGAAA,WAAW,OAAA;AAAE,6FAAA,KAAK,OAAA;AAwBzF,uCAAiH;AAAxG,2GAAA,eAAe,OAAA;AAAE,oHAAA,wBAAwB,OAAA;AAAE,+GAAA,mBAAmB,OAAA;AAAE,gHAAA,oBAAoB,OAAA;AAe7F,uCAAsD;AAA7C,sGAAA,UAAU,OAAA;AAAE,yGAAA,aAAa,OAAA;AAElC,iCAA4E;AAAnE,qGAAA,YAAY,OAAA;AAAE,wGAAA,eAAe,OAAA;AAAE,4GAAA,mBAAmB,OAAA;AAY3D,mCAAyC;AAAhC,wGAAA,cAAc,OAAA;AAIvB,2CASqB;AARnB,0HAAA,4BAA4B,OAAA;AAC5B,kHAAA,oBAAoB,OAAA;AACpB,2GAAA,aAAa,OAAA;AACb,iHAAA,mBAAmB,OAAA;AACnB,0HAAA,4BAA4B,OAAA;AAC5B,oHAAA,sBAAsB,OAAA;AACtB,6GAAA,eAAe,OAAA;AACf,sHAAA,wBAAwB,OAAA;AAG1B,yCAA+D;AAAtD,0GAAA,aAAa,OAAA;AAAE,+GAAA,kBAAkB,OAAA;AAG1C,iCAAsD;AAA7C,oGAAA,WAAW,OAAA;AAAE,wGAAA,eAAe,OAAA;AAErC,2CAMqB;AALnB,gHAAA,kBAAkB,OAAA;AAClB,qHAAA,uBAAuB,OAAA;AACvB,gHAAA,kBAAkB,OAAA;AAClB,2HAAA,6BAA6B,OAAA;AAC7B,wHAAA,0BAA0B,OAAA;AAuB5B,yCAAwE;AAA/D,8GA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,KAAK,OAAA;AACL,iGAAA,QAAQ,OAAA;AAKV,2CASqB;AARnB,6GAAA,eAAe,OAAA;AACf,+GAAA,iBAAiB,OAAA;AACjB,qHAAA,uBAAuB,OAAA;AACvB,+GAAA,iBAAiB,OAAA;AACjB,yGAAA,WAAW,OAAA;AACX,gHAAA,kBAAkB,OAAA;AAClB,uGAAA,SAAS,OAAA;AACT,gHAAA,kBAAkB,OAAA","sourcesContent":["export type { AppInfo } from './app'\n\nexport { Authorizer, AuthGroupName, UserStatus, Permission, UserTitle, UserFactory, Users } from './auth'\nexport type {\n AuthGroup,\n User,\n UserAuthGroup,\n UserAuthGroupProps,\n AuthToken,\n UserAuthTokenPayload,\n UserAuthTokenService,\n UserPrefs,\n UserPrefSurveys,\n UserProps,\n UserAuthRefreshToken,\n UserAuthRefreshTokenProps,\n UserAuthRefreshTokenPayload,\n UserService,\n UserTokenPayload,\n DownloadAuthTokenPayload,\n UserGroup,\n UserGroupProps,\n UserGroupQualifier,\n UserInvitation,\n} from './auth'\n\nexport { CategoryFactory, CategoryImportColumnType, CategoryItemFactory, CategoryLevelFactory } from './category'\nexport type {\n CategoryItemProps,\n Category,\n CategoryItem,\n CategoryLevel,\n CategoryLevelProps,\n CategoryImportSummary,\n CategoryImportSummaryColumn,\n CategoryItemService,\n CategoryLevelService,\n CategoryProps,\n CategoryService,\n} from './category'\n\nexport { Categories, CategoryItems } from './category'\n\nexport { ChainFactory, ChainStatusExec, ChainNodeDefFactory } from './chain'\nexport type {\n Chain,\n ChainProps,\n ChainService,\n ChainNodeDef,\n ChainNodeDefProps,\n ChainNodeDefService,\n ChainNodeDefAggregate,\n ChainNodeDefAggregateProps,\n} from './chain'\n\nexport { TraverseMethod } from './common'\nexport type { ArenaObject, ArenaService, Dictionary, Factory, I18n } from './common'\n\nexport type { FlatDataExportOptions, ArenaExportInfoFactoryParams, ArenaExportInfo } from './dataExport'\nexport {\n FlatDataExportDefaultOptions,\n FlatDataExportOption,\n FlatDataFiles,\n FlatDataExportModel,\n FlatDataExportColumnDataType,\n ArenaExportInfoFactory,\n ArenaExportType,\n UniqueFileNamesGenerator,\n} from './dataExport'\n\nexport { DataQueryMode, DataQuerySummaries } from './dataQuery'\nexport type { DataQuery, DataQuerySummary, DataQuerySummaryProps } from './dataQuery'\n\nexport { SystemError, SystemErrorKeys } from './error'\n\nexport {\n ExpressionNodeType,\n ExpressionNodeEvaluator,\n ExpressionVariable,\n JavascriptExpressionEvaluator,\n JavascriptExpressionParser,\n} from './expression'\nexport type {\n ArrayExpression,\n BinaryExpression,\n CallExpression,\n CompoundExpression,\n ConditionalExpression,\n ExpressionContext,\n ExpressionEvaluator,\n ExpressionFunction,\n ExpressionFunctions,\n AnyExpressionNode,\n ExpressionNode,\n ExpressionNodeEvaluatorConstructor,\n MemberExpression,\n IdentifierExpression,\n LiteralExpression,\n SequenceExpression,\n ThisExpression,\n UnaryExpression,\n} from './expression'\n\nexport { ExtraPropDataType, ExtraPropsDataGenerator } from './extraProp'\nexport type { ExtraPropDef, ExtraPropDefs } from './extraProp'\n\nexport { PointFactory, Points } from './geo'\nexport type { Point } from './geo'\n\nexport { JobBase, JobEventType, JobStatus } from './job'\nexport type { Job, JobContext, JobEvent, JobSerialized, JobTxClient } from './job'\n\nexport { LanguageCode, Languages, LanguagesISO639part2 } from './language'\nexport type { Labels } from './language'\n\nexport type { Logger } from './logger'\n\nexport type { Message } from './message'\nexport { MessageNotificationType, MessagePropsKey, MessageStatus, MessageTargetUserType, Messages } from './message'\n\nexport { NodeFactory, NodeKeys, NodeMetaKeys, Nodes, NodeValueFormatter, NodeValues } from './node'\nexport type {\n ArenaRecordNode,\n Node,\n NodeMeta,\n NodePointer,\n NodeRefData,\n NodeService,\n NodesMap,\n NodeValueCode,\n NodeValueCoordinate,\n NodeValueFile,\n NodeValueTaxon,\n} from './node'\n\nexport {\n NodeDefCountType,\n NodeDefType,\n NodeDefFactory,\n NodeDefs,\n NodeDefEntityRenderType,\n NodeDefFileType,\n NodeDefTextInputType,\n NodeDefTextRenderType,\n FormHeaderColor,\n} from './nodeDef'\n\nexport { NodeDefExpressionEvaluator, NodeDefExpressionValidator } from './nodeDefExpressionEvaluator'\nexport type { CategoryItemProvider, TaxonProvider } from './nodeDefExpressionEvaluator'\n\nexport type {\n NodeDef,\n NodeDefLayout,\n NodeDefMeta,\n NodeDefProps,\n NodeDefPropsWithLayout,\n NodeDefBoolean,\n NodeDefBooleanProps,\n NodeDefCode,\n NodeDefCodeLayout,\n NodeDefCodeProps,\n NodeDefCoordinate,\n NodeDefCoordinateProps,\n NodeDefDate,\n NodeDefDecimal,\n NodeDefDecimalProps,\n NodeDefEntity,\n NodeDefEntityChildPosition,\n NodeDefEntityLayout,\n NodeDefEntityProps,\n NodeDefPrintOrientation,\n NodeDefFile,\n NodeDefFileProps,\n NodeDefGeo,\n NodeDefGeoProps,\n NodeDefFormHeader,\n NodeDefFormHeaderProps,\n NodeDefInteger,\n NodeDefPropsAdvanced,\n NodeDefTaxon,\n NodeDefTaxonProps,\n NodeDefText,\n NodeDefTextProps,\n NodeDefTextLayout,\n NodeDefTime,\n NodeDefTimeProps,\n NodeDefExpression,\n NodeDefMap,\n NodeDefService,\n NodeDefValidations,\n} from './nodeDef'\n\nexport {\n NodePointers,\n RecordCloner,\n RecordFactory,\n RecordFixer,\n Records,\n RECORD_STEP_DEFAULT,\n RecordExpressionEvaluator,\n RecordNodesUpdater,\n RecordPrettyPrinter,\n RecordUpdater,\n RecordUpdateResult,\n RecordValidator,\n RecordValidations,\n} from './record'\nexport type {\n AttributeValidatorParams,\n AttributesValidatorParams,\n NodeCreateParams,\n NodesUpdateParams,\n ArenaRecord,\n Record,\n RecordExpressionContext,\n RecordExpressionEvaluationContext,\n RecordService,\n RecordUpdateOptions,\n RecordValidatorParams,\n SortedAttributesValidatorParams,\n} from './record'\n\nexport { ServiceRegistry, ServiceType } from './registry'\nexport type { ServiceTypeMap } from './registry'\n\nexport { DEFAULT_SRS, DEFAULT_SRS_INDEX, SRSFactory } from './srs'\nexport type { SRS, SRSIndex } from './srs'\n\nexport {\n NodeDefsFixer,\n SurveyDocImages,\n SurveyDocImageFactory,\n SurveyDocPlace,\n SurveyDependencyType,\n SurveyFactory,\n SurveyFileFactory,\n SurveyFileType,\n SurveyRefDataFactory,\n SurveySecurityProp,\n Surveys,\n surveyDocImagePropKeys,\n surveySecurityDefaults,\n defaultCycle,\n} from './survey'\nexport type {\n Survey,\n SurveyCycle,\n SurveyDependency,\n SurveyDependencyGraph,\n SurveyDocImage,\n SurveyDocImageFactoryParams,\n SurveyDocImageProps,\n SurveyFile,\n SurveyFileFactoryParams,\n SurveyFileProps,\n SurveyProps,\n SurveyRefData,\n SurveySecurity,\n SurveyService,\n} from './survey'\n\nexport { Taxa, Taxonomies, TaxonomyFactory, TaxonFactory, TaxonGenerator, VernacularNameFactory } from './taxonomy'\nexport type {\n VernacularNameParams,\n TaxonomyFactoryParams,\n TaxonFactoryParams,\n Taxonomy,\n TaxonomyService,\n VernacularNameProps,\n VernacularName,\n TaxonProps,\n Taxon,\n TaxonomyProps,\n TaxonService,\n} from './taxonomy'\n\nexport { SurveyBuilder, SurveyObjectBuilders } from './tests/builder/surveyBuilder'\nexport { RecordBuilder, RecordNodeBuilders } from './tests/builder/recordBuilder'\n\nexport {\n Arrays,\n DateFormats,\n Dates,\n FileNames,\n FileProcessor,\n Numbers,\n Objects,\n Promises,\n Queue,\n RetryProcessor,\n Strings,\n UnitOfTime,\n UUIDs,\n Versions,\n} from './utils'\n\nexport type { FileProcessorConstructorArgs, MutationOptions, ParsedVersion } from './utils'\n\nexport {\n FieldValidators,\n ValidationFactory,\n ValidationResultFactory,\n ValidationResults,\n Validations,\n ValidationSeverity,\n Validator,\n ValidatorErrorKeys,\n} from './validation'\nexport type {\n DissocFieldValidationOptions,\n FieldValidator,\n Validation,\n ValidationFields,\n ValidationResult,\n ValidationCounts,\n} from './validation'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"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AA,iBAAiB,OAAA;AACjB,yGAAA,WAAW,OAAA;AACX,gHAAA,kBAAkB,OAAA;AAClB,uGAAA,SAAS,OAAA;AACT,gHAAA,kBAAkB,OAAA","sourcesContent":["export type { AppInfo } from './app'\n\nexport { Authorizer, AuthGroupName, UserStatus, Permission, UserTitle, UserFactory, Users } from './auth'\nexport type {\n AuthGroup,\n User,\n UserAuthGroup,\n UserAuthGroupProps,\n AuthToken,\n UserAuthTokenPayload,\n UserAuthTokenService,\n UserPrefs,\n UserPrefSurveys,\n UserProps,\n UserAuthRefreshToken,\n UserAuthRefreshTokenProps,\n UserAuthRefreshTokenPayload,\n UserService,\n UserTokenPayload,\n DownloadAuthTokenPayload,\n UserGroup,\n UserGroupProps,\n UserGroupQualifier,\n UserInvitation,\n} from './auth'\n\nexport { CategoryFactory, CategoryImportColumnType, CategoryItemFactory, CategoryLevelFactory } from './category'\nexport type {\n CategoryItemProps,\n Category,\n CategoryItem,\n CategoryLevel,\n CategoryLevelProps,\n CategoryImportSummary,\n CategoryImportSummaryColumn,\n CategoryItemService,\n CategoryLevelService,\n CategoryProps,\n CategoryService,\n} from './category'\n\nexport { Categories, CategoryItems } from './category'\n\nexport { ChainFactory, ChainStatusExec, ChainNodeDefFactory } from './chain'\nexport type {\n Chain,\n ChainProps,\n ChainService,\n ChainNodeDef,\n ChainNodeDefProps,\n ChainNodeDefService,\n ChainNodeDefAggregate,\n ChainNodeDefAggregateProps,\n} from './chain'\n\nexport { TraverseMethod } from './common'\nexport type { ArenaObject, ArenaService, Dictionary, Factory, I18n } from './common'\n\nexport type { FlatDataExportOptions, ArenaExportInfoFactoryParams, ArenaExportInfo } from './dataExport'\nexport {\n FlatDataExportDefaultOptions,\n FlatDataExportOption,\n FlatDataFiles,\n FlatDataExportModel,\n FlatDataExportColumnDataType,\n ArenaExportInfoFactory,\n ArenaExportType,\n UniqueFileNamesGenerator,\n} from './dataExport'\n\nexport { DataQueryMode, DataQuerySummaries } from './dataQuery'\nexport type { DataQuery, DataQuerySummary, DataQuerySummaryProps } from './dataQuery'\n\nexport { SystemError, SystemErrorKeys } from './error'\n\nexport {\n ExpressionNodeType,\n ExpressionNodeEvaluator,\n ExpressionVariable,\n JavascriptExpressionEvaluator,\n JavascriptExpressionParser,\n} from './expression'\nexport type {\n ArrayExpression,\n BinaryExpression,\n CallExpression,\n CompoundExpression,\n ConditionalExpression,\n ExpressionContext,\n ExpressionEvaluator,\n ExpressionFunction,\n ExpressionFunctions,\n AnyExpressionNode,\n ExpressionNode,\n ExpressionNodeEvaluatorConstructor,\n MemberExpression,\n IdentifierExpression,\n LiteralExpression,\n SequenceExpression,\n ThisExpression,\n UnaryExpression,\n} from './expression'\n\nexport { ExtraPropDataType, ExtraPropsDataGenerator } from './extraProp'\nexport type { ExtraPropDef, ExtraPropDefs } from './extraProp'\n\nexport { PointFactory, Points } from './geo'\nexport type { AreaOfInterest, Point } from './geo'\n\nexport { JobBase, JobEventType, JobStatus } from './job'\nexport type { Job, JobContext, JobEvent, JobSerialized, JobTxClient } from './job'\n\nexport { LanguageCode, Languages, LanguagesISO639part2 } from './language'\nexport type { Labels } from './language'\n\nexport type { Logger } from './logger'\n\nexport type { Message } from './message'\nexport { MessageNotificationType, MessagePropsKey, MessageStatus, MessageTargetUserType, Messages } from './message'\n\nexport { NodeFactory, NodeKeys, NodeMetaKeys, Nodes, NodeValueFormatter, NodeValues } from './node'\nexport type {\n ArenaRecordNode,\n Node,\n NodeMeta,\n NodePointer,\n NodeRefData,\n NodeService,\n NodesMap,\n NodeValueCode,\n NodeValueCoordinate,\n NodeValueFile,\n NodeValueTaxon,\n} from './node'\n\nexport {\n NodeDefCountType,\n NodeDefType,\n NodeDefFactory,\n NodeDefs,\n NodeDefEntityRenderType,\n NodeDefFileType,\n NodeDefTextInputType,\n NodeDefTextRenderType,\n FormHeaderColor,\n} from './nodeDef'\n\nexport { NodeDefExpressionEvaluator, NodeDefExpressionValidator } from './nodeDefExpressionEvaluator'\nexport type { CategoryItemProvider, TaxonProvider } from './nodeDefExpressionEvaluator'\n\nexport type {\n NodeDef,\n NodeDefLayout,\n NodeDefMeta,\n NodeDefProps,\n NodeDefPropsWithLayout,\n NodeDefBoolean,\n NodeDefBooleanProps,\n NodeDefCode,\n NodeDefCodeLayout,\n NodeDefCodeProps,\n NodeDefCoordinate,\n NodeDefCoordinateProps,\n NodeDefDate,\n NodeDefDecimal,\n NodeDefDecimalProps,\n NodeDefEntity,\n NodeDefEntityChildPosition,\n NodeDefEntityLayout,\n NodeDefEntityProps,\n NodeDefPrintOrientation,\n NodeDefFile,\n NodeDefFileProps,\n NodeDefGeo,\n NodeDefGeoProps,\n NodeDefFormHeader,\n NodeDefFormHeaderProps,\n NodeDefInteger,\n NodeDefPropsAdvanced,\n NodeDefTaxon,\n NodeDefTaxonProps,\n NodeDefText,\n NodeDefTextProps,\n NodeDefTextLayout,\n NodeDefTime,\n NodeDefTimeProps,\n NodeDefExpression,\n NodeDefMap,\n NodeDefService,\n NodeDefValidations,\n} from './nodeDef'\n\nexport {\n NodePointers,\n RecordCloner,\n RecordFactory,\n RecordFixer,\n Records,\n RECORD_STEP_DEFAULT,\n RecordExpressionEvaluator,\n RecordNodesUpdater,\n RecordPrettyPrinter,\n RecordUpdater,\n RecordUpdateResult,\n RecordValidator,\n RecordValidations,\n} from './record'\nexport type {\n AttributeValidatorParams,\n AttributesValidatorParams,\n NodeCreateParams,\n NodesUpdateParams,\n ArenaRecord,\n Record,\n RecordExpressionContext,\n RecordExpressionEvaluationContext,\n RecordService,\n RecordUpdateOptions,\n RecordValidatorParams,\n SortedAttributesValidatorParams,\n} from './record'\n\nexport { ServiceRegistry, ServiceType } from './registry'\nexport type { ServiceTypeMap } from './registry'\n\nexport { DEFAULT_SRS, DEFAULT_SRS_INDEX, SRSFactory } from './srs'\nexport type { SRS, SRSIndex } from './srs'\n\nexport {\n NodeDefsFixer,\n SurveyDocImages,\n SurveyDocImageFactory,\n SurveyDocPlace,\n SurveyDependencyType,\n SurveyFactory,\n SurveyFileFactory,\n SurveyFileType,\n SurveyRefDataFactory,\n SurveySecurityProp,\n Surveys,\n surveyDocImagePropKeys,\n surveySecurityDefaults,\n defaultCycle,\n} from './survey'\nexport type {\n Survey,\n SurveyCycle,\n SurveyDependency,\n SurveyDependencyGraph,\n SurveyDocImage,\n SurveyDocImageFactoryParams,\n SurveyDocImageProps,\n SurveyFile,\n SurveyFileFactoryParams,\n SurveyFileProps,\n SurveyProps,\n SurveyRefData,\n SurveySecurity,\n SurveyService,\n} from './survey'\n\nexport { Taxa, Taxonomies, TaxonomyFactory, TaxonFactory, TaxonGenerator, VernacularNameFactory } from './taxonomy'\nexport type {\n VernacularNameParams,\n TaxonomyFactoryParams,\n TaxonFactoryParams,\n Taxonomy,\n TaxonomyService,\n VernacularNameProps,\n VernacularName,\n TaxonProps,\n Taxon,\n TaxonomyProps,\n TaxonService,\n} from './taxonomy'\n\nexport { SurveyBuilder, SurveyObjectBuilders } from './tests/builder/surveyBuilder'\nexport { RecordBuilder, RecordNodeBuilders } from './tests/builder/recordBuilder'\n\nexport {\n Arrays,\n DateFormats,\n Dates,\n FileNames,\n FileProcessor,\n Numbers,\n Objects,\n Promises,\n Queue,\n RetryProcessor,\n Strings,\n UnitOfTime,\n UUIDs,\n Versions,\n} from './utils'\n\nexport type { FileProcessorConstructorArgs, MutationOptions, ParsedVersion } from './utils'\n\nexport {\n FieldValidators,\n ValidationFactory,\n ValidationResultFactory,\n ValidationResults,\n Validations,\n ValidationSeverity,\n Validator,\n ValidatorErrorKeys,\n} from './validation'\nexport type {\n DissocFieldValidationOptions,\n FieldValidator,\n Validation,\n ValidationFields,\n ValidationResult,\n ValidationCounts,\n} from './validation'\n"]}
|
|
@@ -149,6 +149,18 @@ exports.nodeDefExpressionFunctions = {
|
|
|
149
149
|
},
|
|
150
150
|
},
|
|
151
151
|
geoDistance: { minArity: 2, maxArity: 2, executor: geoDistanceExecutor },
|
|
152
|
+
geoDistanceToAOIBoundary: {
|
|
153
|
+
minArity: 1,
|
|
154
|
+
maxArity: 1,
|
|
155
|
+
executor: (context) => (coordinate) => {
|
|
156
|
+
const { survey } = context;
|
|
157
|
+
const areaOfInterest = (0, surveysGetters_1.getAreaOfInterest)(survey);
|
|
158
|
+
const point = geo_1.Points.parse(coordinate);
|
|
159
|
+
if (!areaOfInterest || !point)
|
|
160
|
+
return null;
|
|
161
|
+
return geo_1.Points.distanceToPolygonBoundary(point, areaOfInterest, (0, surveysGetters_1.getSRSIndex)(survey));
|
|
162
|
+
},
|
|
163
|
+
},
|
|
152
164
|
geoPolygon: {
|
|
153
165
|
minArity: 1,
|
|
154
166
|
evaluateArgsToNodes: true,
|
|
@@ -1 +1 @@
|
|
|
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,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,C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ys } 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"]}
|
|
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,qEAAuH;AAEvH,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,CAAC,MAAM,CAAC,OAAO,CAAA;AACpC,CAAC,CAAA;AAED,MAAM,sBAAsB,GAAG,CAAO,MAIrC,EAAqC,EAAE;IACtC,MAAM,EAAE,OAAO,EA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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 { getAreaOfInterest, getCategoryByName, getSRSIndex, getTaxonomyByName } from '../survey/surveys/surveysGetters'\nimport { Taxon } from '../taxonomy'\nimport { Dates, Numbers, Objects } from '../utils'\nimport { NodeDefExpressionContext } from './context'\n\nconst sampleGeoJsonPolygon = {\n type: 'Feature',\n geometry: {\n type: 'Polygon',\n coordinates: [\n [\n [100.0, 0.0],\n [101.0, 0.0],\n [101.0, 1.0],\n [100.0, 1.0],\n [100.0, 0.0],\n ],\n ],\n },\n}\n\nconst isNotValidString = (value: string): boolean => Objects.isEmpty(value) || typeof value !== 'string'\n\nconst emptyExecutor = (_context: NodeDefExpressionContext) => () => null\n\nconst isUsingDraftProps = (context: NodeDefExpressionContext) => {\n // use draft props when validating expression or previewing record\n const record: ArenaRecord = (context as any).record\n return !record || !!record.preview\n}\n\nconst getOrFetchCategoryItem = async (params: {\n context: NodeDefExpressionContext\n categoryUuid: string\n codePaths: string[]\n}): Promise<CategoryItem | undefined> => {\n const { context, categoryUuid, codePaths } = params\n // if any code path is empty, return null (no category item can be found)\n if (Objects.isEmpty(codePaths) || codePaths.some(Objects.isEmpty)) {\n return undefined\n }\n const { survey, categoryItemProvider } = context\n const categoryItem = getCategoryItemByCodePaths({ survey, categoryUuid, codePaths })\n const draft = isUsingDraftProps(context)\n return categoryItem ?? categoryItemProvider?.getItemByCodePaths({ survey, categoryUuid, codePaths, draft })\n}\n\nconst getOrFetchTaxon = async (params: {\n context: NodeDefExpressionContext\n taxonomyUuid: string\n taxonCode: string\n}): Promise<Taxon | undefined> => {\n const { context, taxonomyUuid, taxonCode } = params\n if (typeof taxonCode !== 'string' && typeof taxonCode !== 'number') {\n return undefined // node def expression validator could call it passing a node def object\n }\n // if taxonCode is empty, return undefined\n if (Objects.isEmpty(taxonCode)) {\n return undefined\n }\n const { survey, taxonProvider } = context\n const taxon = getTaxonByCode({ survey, taxonomyUuid, taxonCode })\n // fetch draft props when validating expression or previewing record\n const record: ArenaRecord = (context as any).record\n const draft = !record || !!record.preview\n return taxon ?? taxonProvider?.getTaxonByCode({ survey, taxonomyUuid, taxonCode, draft })\n}\n\nconst geoDistanceExecutor =\n (context: NodeDefExpressionContext) =>\n (coordinateFrom: Point | string, coordinateTo: Point | string): number | null => {\n const { survey } = context\n const srsIndex = getSRSIndex(survey)\n\n const pointFrom = Points.parse(coordinateFrom)\n const pointTo = Points.parse(coordinateTo)\n\n return pointFrom && pointTo ? Points.distance(pointFrom, pointTo, srsIndex) : null\n }\n\nexport const nodeDefExpressionFunctions: ExpressionFunctions<NodeDefExpressionContext> = {\n categoryItemProp: {\n minArity: 3,\n executor:\n (context: NodeDefExpressionContext) =>\n async (categoryName: string, itemPropName: string, ...codePaths: string[]): Promise<any> => {\n const { survey } = context\n\n if (Objects.isEmpty(categoryName) || Objects.isEmpty(itemPropName) || Objects.isEmpty(codePaths))\n throw new SystemError(SystemErrorKeys.expression.missingFunctionParameters)\n\n const category = getCategoryByName({ survey, categoryName })\n if (!category) throw new SystemError(SystemErrorKeys.expression.invalidCategoryName, { name: categoryName })\n\n const extraPropDef = category.props.itemExtraDef?.[itemPropName]\n if (!extraPropDef)\n throw new SystemError(SystemErrorKeys.expression.invalidCategoryExtraProp, { propName: itemPropName })\n\n const { uuid: categoryUuid } = category\n const categoryItem = await getOrFetchCategoryItem({ context, categoryUuid, codePaths })\n if (!categoryItem) return null\n\n const value = categoryItem.props.extra?.[itemPropName]\n return ExtraProps.convertValue({ survey, extraPropDef, value })\n },\n },\n count: {\n minArity: 1,\n maxArity: 1,\n executor:\n (_context: NodeDefExpressionContext) =>\n (_nodeSet): number =>\n 1,\n },\n dateTimeDiff: {\n minArity: 4,\n maxArity: 4,\n executor:\n (_context: NodeDefExpressionContext) =>\n (date1: string, time1: string, date2: string, time2: string): number | null => {\n if (isNotValidString(date1) || isNotValidString(time1) || isNotValidString(date2) || isNotValidString(time2))\n return null\n const [hours1, minutes1] = time1.split(':')\n const [hours2, minutes2] = time2.split(':')\n let dt1 = Dates.addHours(date1, Number(hours1))\n dt1 = Dates.addMinutes(dt1, Number(minutes1))\n let dt2 = Dates.addHours(date2, Number(hours2))\n dt2 = Dates.addMinutes(dt2, Number(minutes2))\n return Dates.diffInMinutes(dt1, dt2)\n },\n },\n // deprecated, use geoDistance instead\n distance: { minArity: 2, maxArity: 2, executor: geoDistanceExecutor },\n first: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: emptyExecutor,\n },\n geoCoordinateAtDistance: {\n minArity: 3,\n maxArity: 3,\n executor:\n (context: NodeDefExpressionContext) =>\n (coordinate: Point | string, distanceMeters: number, bearingDeg: number): Point | null => {\n // validate parameters\n const origin = Points.parse(coordinate)\n if (!origin) return null\n\n const distanceMetersNumber = Number(distanceMeters)\n const bearingDegNumber = Number(bearingDeg)\n if (!Number.isFinite(distanceMetersNumber) || distanceMetersNumber < 0 || !Number.isFinite(bearingDegNumber)) {\n return null\n }\n\n const { survey } = context\n const srsIndex = getSRSIndex(survey)\n\n return Points.pointAtDistance({\n origin,\n distanceMeters: distanceMetersNumber,\n bearingDeg: bearingDegNumber,\n srsIndex,\n })\n },\n },\n geoDistance: { minArity: 2, maxArity: 2, executor: geoDistanceExecutor },\n geoDistanceToAOIBoundary: {\n minArity: 1,\n maxArity: 1,\n executor:\n (context: NodeDefExpressionContext) =>\n (coordinate: Point | string): number | null => {\n const { survey } = context\n const areaOfInterest = getAreaOfInterest(survey)\n const point = Points.parse(coordinate)\n if (!areaOfInterest || !point) return null\n return Points.distanceToPolygonBoundary(point, areaOfInterest, getSRSIndex(survey))\n },\n },\n geoPolygon: {\n minArity: 1,\n evaluateArgsToNodes: true,\n executor: () => () => sampleGeoJsonPolygon,\n },\n includes: {\n minArity: 2,\n maxArity: 2,\n evaluateArgsToNodes: false,\n executor:\n () =>\n (items: any, value: any): boolean =>\n Array.isArray(items) && items.map(String).includes(String(value)),\n },\n index: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: () => () => -1,\n },\n last: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: emptyExecutor,\n },\n now: {\n minArity: 0,\n maxArity: 0,\n evaluateToNode: false,\n executor: () => () => Dates.nowFormattedForStorage(),\n },\n numberToWords: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: false,\n executor:\n (context: NodeDefExpressionContext) =>\n (value: any): string | null => {\n if (Objects.isEmpty(value)) return null\n return Numbers.toWords(value, context.lang)\n },\n },\n parent: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n evaluateToNode: true,\n executor: (context: NodeDefExpressionContext) => (nodeDef) => {\n const { survey } = context\n return getNodeDefParent({ survey, nodeDef })\n },\n },\n prevCycleValue: {\n minArity: 1,\n maxArity: 1,\n executor: emptyExecutor,\n },\n prevCycleValues: {\n minArity: 1,\n maxArity: 1,\n executor: emptyExecutor,\n },\n recordCycle: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordDateCreated: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordDateLastModified: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordOwnerEmail: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordOwnerName: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n recordOwnerRole: {\n minArity: 0,\n maxArity: 0,\n executor: emptyExecutor,\n },\n sum: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: (_context: NodeDefExpressionContext) => (_nodeSet) => 1,\n },\n taxonProp: {\n minArity: 3,\n maxArity: 3,\n executor:\n (context: NodeDefExpressionContext) => async (taxonomyName: string, propName: string, taxonCode: string) => {\n if (Objects.isEmpty(taxonomyName) || Objects.isEmpty(propName))\n throw new SystemError(SystemErrorKeys.expression.missingFunctionParameters)\n if (Objects.isEmpty(taxonCode)) return null\n\n const { survey } = context\n const taxonomy = getTaxonomyByName({ survey, taxonomyName })\n if (!taxonomy) throw new SystemError(SystemErrorKeys.expression.invalidTaxonomyName, { name: taxonomyName })\n\n const extraPropDef = taxonomy.props.extraPropsDefs?.[propName]\n if (!extraPropDef) throw new SystemError(SystemErrorKeys.expression.invalidTaxonomyExtraProp, { propName })\n\n const taxon = await getOrFetchTaxon({ context, taxonomyUuid: taxonomy.uuid, taxonCode })\n if (!taxon) return null\n\n const value = taxon.props.extra?.[propName]\n return ExtraProps.convertValue({ survey, extraPropDef, value })\n },\n },\n taxonVernacularName: {\n minArity: 3,\n maxArity: 3,\n executor:\n (context: NodeDefExpressionContext) =>\n async (taxonomyName: string, vernacularLangCode: string, taxonCode: string) => {\n if (Objects.isEmpty(taxonomyName) || Objects.isEmpty(vernacularLangCode))\n throw new SystemError(SystemErrorKeys.expression.missingFunctionParameters)\n if (Objects.isEmpty(taxonCode)) return null\n\n const { survey } = context\n const taxonomy = getTaxonomyByName({ survey, taxonomyName })\n if (!taxonomy) throw new SystemError(SystemErrorKeys.expression.invalidTaxonomyName, { name: taxonomyName })\n\n if (!LanguagesISO639part2[vernacularLangCode]) {\n throw new SystemError(SystemErrorKeys.expression.invalidTaxonVernacularNameLanguageCode, {\n vernacularLangCode,\n })\n }\n\n const taxon = await getOrFetchTaxon({ context, taxonomyUuid: taxonomy.uuid, taxonCode })\n if (!taxon) return null\n\n const vernacularNameArray = taxon.vernacularNames?.[vernacularLangCode]\n // consider first vernacular name object only\n const firstVernacularName = vernacularNameArray?.[0]\n return firstVernacularName?.props?.name\n },\n },\n unique: {\n minArity: 1,\n maxArity: 1,\n evaluateArgsToNodes: true,\n executor: (_context: NodeDefExpressionContext) => (_nodeSet) => [],\n },\n userEmail: {\n minArity: 0,\n maxArity: 0,\n executor: (context: NodeDefExpressionContext) => () => context.user?.email,\n },\n userIsRecordOwner: {\n minArity: 0,\n maxArity: 0,\n executor: (_context: NodeDefExpressionContext) => () => false,\n },\n userName: {\n minArity: 0,\n maxArity: 0,\n executor: (context: NodeDefExpressionContext) => () => context.user?.name,\n },\n userProp: {\n minArity: 1,\n maxArity: 1,\n executor: (context: NodeDefExpressionContext) => (propName: string) => {\n const { user, survey } = context\n if (!survey || !user) return undefined\n const { uuid: surveyUuid } = survey\n const combinedExtraProps = Users.getCombinedExtraProps(surveyUuid)(user)\n return combinedExtraProps[propName]\n },\n },\n}\n"]}
|
package/dist/survey/survey.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ArenaObject, Dictionary } from '../common';
|
|
2
2
|
import { AuthGroup } from '../auth';
|
|
3
3
|
import { Labels, LanguageCode } from '../language';
|
|
4
|
+
import type { AreaOfInterest } from '../geo';
|
|
4
5
|
import { SRS } from '../srs';
|
|
5
6
|
import { NodeDef, NodeDefType } from '../nodeDef';
|
|
6
7
|
import { Category } from '../category';
|
|
@@ -80,6 +81,7 @@ export type SurveyDocOptions = {
|
|
|
80
81
|
headerOnFirstPageOnly?: boolean;
|
|
81
82
|
};
|
|
82
83
|
export interface SurveyProps {
|
|
84
|
+
areaOfInterest?: AreaOfInterest;
|
|
83
85
|
collectUri?: string;
|
|
84
86
|
cycles: {
|
|
85
87
|
[key: string]: SurveyCycle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"survey.js","sourceRoot":"","sources":["../../src/survey/survey.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"survey.js","sourceRoot":"","sources":["../../src/survey/survey.ts"],"names":[],"mappings":";;;AAWa,QAAA,YAAY,GAAG,GAAG,CAAA;AAM/B,IAAY,oBAcX;AAdD,WAAY,oBAAoB;IAC9B,iDAAyB,CAAA;IACzB,uDAA+B,CAAA;IAC/B,6CAAqB,CAAA;IACrB,6DAAqC,CAAA;IACrC,6CAAqB,CAAA;IACrB,2CAAmB,CAAA;IACnB,6CAAqB,CAAA;IACrB,6CAAqB,CAAA;IACrB,iDAAyB,CAAA;IACzB,6CAAqB,CAAA;IACrB,mDAA2B,CAAA;IAC3B,2CAAmB,CAAA;IACnB,6CAAqB,CAAA;AACvB,CAAC,EAdW,oBAAoB,aAApB,oBAAoB,GAApB,oBAAoB,QAc/B;AAWD,IAAY,kBAQX;AARD,WAAY,kBAAkB;IAC5B,mGAA6E,CAAA;IAC7E,qGAA+E,CAAA;IAC/E,yDAAmC,CAAA;IACnC,mFAA6D,CAAA;IAC7D,mFAA6D,CAAA;IAC7D,uGAAiF,CAAA;IACjF,qFAA+D,CAAA;AACjE,CAAC,EARW,kBAAkB,aAAlB,kBAAkB,GAAlB,kBAAkB,QAQ7B;AAMY,QAAA,sBAAsB,GAAmB;IACpD,CAAC,kBAAkB,CAAC,oCAAoC,CAAC,EAAE,IAAI;IAC/D,CAAC,kBAAkB,CAAC,qCAAqC,CAAC,EAAE,IAAI;IAChE,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,IAAI;IAC1C,CAAC,kBAAkB,CAAC,4BAA4B,CAAC,EAAE,IAAI;IACvD,CAAC,kBAAkB,CAAC,4BAA4B,CAAC,EAAE,IAAI;IACvD,CAAC,kBAAkB,CAAC,sCAAsC,CAAC,EAAE,IAAI;IACjE,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,EAAE,IAAI;CACzD,CAAA;AAED,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;AACnB,CAAC,EAHW,cAAc,aAAd,cAAc,GAAd,cAAc,QAGzB;AAEY,QAAA,sBAAsB,GAAG;IACpC,aAAa,EAAE,eAAe;IAC9B,OAAO,EAAE,SAAS;CACV,CAAA","sourcesContent":["import { ArenaObject, Dictionary } from '../common'\nimport { AuthGroup } from '../auth'\nimport { Labels, LanguageCode } from '../language'\nimport type { AreaOfInterest } from '../geo'\nimport { SRS } from '../srs'\n\nimport { NodeDef, NodeDefType } from '../nodeDef'\nimport { Category } from '../category'\nimport { Taxonomy } from '../taxonomy'\nimport { SurveyRefData } from './refData/refData'\n\nexport const defaultCycle = '0'\n\nexport interface SurveyDependency {\n [nodeDefUuid: string]: string[] | boolean\n}\n\nexport enum SurveyDependencyType {\n applicable = 'applicable',\n defaultValues = 'defaultValues',\n editable = 'editable',\n enumeratingItems = 'enumeratingItems',\n fileName = 'fileName',\n formula = 'formula',\n maxCount = 'maxCount',\n minCount = 'minCount',\n parentCode = 'parentCode',\n required = 'required',\n validations = 'validations',\n visible = 'visible',\n onUpdate = 'onUpdate', // dependencies updated on every record update, stored as dictionary of booleans\n}\n\nexport type SurveyDependencyGraph = {\n [key in SurveyDependencyType]: SurveyDependency\n}\n\nexport interface SurveyCycle {\n dateEnd?: string\n dateStart: string\n}\n\nexport enum SurveySecurityProp {\n dataEditorViewNotOwnedRecordsAllowed = 'dataEditorViewNotOwnedRecordsAllowed',\n dataAnalystViewNotOwnedRecordsAllowed = 'dataAnalystViewNotOwnedRecordsAllowed',\n visibleInMobile = 'visibleInMobile',\n allowRecordsDownloadInMobile = 'allowRecordsDownloadInMobile',\n allowRecordsUploadFromMobile = 'allowRecordsUploadFromMobile',\n allowRecordsWithErrorsUploadFromMobile = 'allowRecordsWithErrorsUploadFromMobile',\n allowRecordsMergeWithSameKeys = 'allowRecordsMergeWithSameKeys',\n}\n\nexport type SurveySecurity = {\n [key in SurveySecurityProp]?: boolean\n}\n\nexport const surveySecurityDefaults: SurveySecurity = {\n [SurveySecurityProp.dataEditorViewNotOwnedRecordsAllowed]: true,\n [SurveySecurityProp.dataAnalystViewNotOwnedRecordsAllowed]: true,\n [SurveySecurityProp.visibleInMobile]: true,\n [SurveySecurityProp.allowRecordsDownloadInMobile]: true,\n [SurveySecurityProp.allowRecordsUploadFromMobile]: true,\n [SurveySecurityProp.allowRecordsWithErrorsUploadFromMobile]: true,\n [SurveySecurityProp.allowRecordsMergeWithSameKeys]: true,\n}\n\nexport enum SurveyDocPlace {\n header = 'header',\n footer = 'footer',\n}\n\nexport const surveyDocImagePropKeys = {\n documentPlace: 'documentPlace',\n applyIf: 'applyIf',\n} as const\n\nexport type SurveyDocImageProps = SurveyFileProps & {\n documentPlace?: SurveyDocPlace\n applyIf?: string\n}\n\nexport type SurveyFileProps = {\n deleted?: boolean\n labels?: Labels\n name?: string\n nodeUuid?: string\n recordUuid?: string\n size?: number | null\n temporary?: boolean\n type?: string\n}\n\nexport type SurveyFile = {\n uuid: string\n props: SurveyFileProps\n content?: Buffer | null\n dateCreated: string\n}\n\nexport type SurveyDocImage = SurveyFile & {\n props: SurveyDocImageProps\n}\n\nexport type SurveyDocOptions = {\n headerOnFirstPageOnly?: boolean // default: true\n}\n\nexport interface SurveyProps {\n areaOfInterest?: AreaOfInterest\n collectUri?: string\n cycles: {\n [key: string]: SurveyCycle\n }\n defaultCycleKey?: string\n descriptions?: Labels\n fieldManualLinks?: Labels\n // when true, values of attributes becoming non-applicable are kept during data entry (default: cleared)\n keepNonApplicableValues?: boolean\n labels?: Labels\n languages: LanguageCode[]\n name: string\n preloadedMapLayers?: SurveyFile[]\n preloadedMapLayersEnabled?: boolean\n security?: SurveySecurity\n srs: SRS[]\n surveyDocImages?: SurveyDocImage[]\n surveyDocOptions?: SurveyDocOptions\n}\n\nexport interface SurveyNodeDefsIndex {\n rootDefUuid?: string\n childDefUuidPresenceByParentUuid?: { [parentUuid: string]: { [nodeDefUuid: string]: boolean } }\n nodeDefUuidByName?: Dictionary<string>\n qualifierPresenceByUuid?: { [nodeDefUuid: string]: boolean }\n}\n\nexport interface Survey extends ArenaObject<SurveyProps> {\n authGroups: Array<AuthGroup>\n dateCreated?: string\n dateModified?: string\n datePublished?: string\n dependencyGraph?: SurveyDependencyGraph\n draft: boolean\n nodeDefs?: { [nodeDefUuid: string]: NodeDef<NodeDefType> }\n ownerUuid: string\n published: boolean\n readonly id?: number\n template: boolean\n uuid: string\n /**\n * Categories indexed by uuid.\n */\n categories?: { [categoryUuid: string]: Category }\n /**\n * Taxonomies indexed by uuid.\n */\n taxonomies?: { [taxonomyUuid: string]: Taxonomy }\n /**\n * Reference data cache (category items and taxa).\n */\n refData?: SurveyRefData\n\n nodeDefsIndex?: SurveyNodeDefsIndex\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { addNodeDefDependencies, buildAndAssocDependencyGraph, getNodeDefDependents, getOnUpdateDependents, removeNodeDefDependencies } from './dependencies';
|
|
2
2
|
import { findNodeDefByName, findNodeDefByUuid, findNodeDefsByUuids, getDependentCodeAttributeDefs, getDependentEnumeratedEntityDefs, getDescendantsInSingleEntities, getNodeDefAncestorCodes, getNodeDefAncestorMultipleEntity, getNodeDefByName, getNodeDefByUuid, getNodeDefCategoryLevelIndex, getNodeDefChildren, getNodeDefChildrenSorted, getNodeDefEnumerator, getNodeDefKeys, getNodeDefParent, getNodeDefParentCode, getNodeDefRoot, getNodeDefSource, getNodeDefsByUuids, getNodeDefsIncludedInMultipleEntitySummary, getQualifierDefs, getRootKeys, isNodeDefAncestor, isNodeDefEnumerator, isNodeDefParentCode, visitAncestorsAndSelfNodeDef, visitDescendantsAndSelfNodeDef, visitNodeDefs } from './nodeDefs';
|
|
3
3
|
import { getCategoryItemByCodePaths, getCategoryItemByUuid, getCategoryItemUuidByCode, getCategoryItems, getCategoryItemsByNodeDef, getCategoryItemsInLevel, getTaxonByCode, getTaxonByUuid, getTaxonVernacularNameUuid, includesTaxonVernacularName } from './refsData';
|
|
4
|
-
import { getCategoryByName, getCategoryByUuid, getCycleKeys, getDefaultCycleKey, getDefaultLanguage, getLabelOrName, getLanguages, getLastCycleKey, getName, getSRSByCode, getSRSIndex, getSRSs, getTaxonomyByName, getTaxonomyByUuid, getAuthGroups, getAuthGroupAdmin, isKeepNonApplicableValues } from './surveysGetters';
|
|
4
|
+
import { getCategoryByName, getCategoryByUuid, getCycleKeys, getDefaultCycleKey, getDefaultLanguage, getLabelOrName, getLanguages, getLastCycleKey, getName, getSRSByCode, getSRSIndex, getAreaOfInterest, getSRSs, getTaxonomyByName, getTaxonomyByUuid, getAuthGroups, getAuthGroupAdmin, isKeepNonApplicableValues } from './surveysGetters';
|
|
5
5
|
import { getSecurity, isDataAnalystViewNotOwnedRecordsAllowed, isDataEditorViewNotOwnedRecordsAllowed, isRecordsDownloadInMobileAllowed, isRecordsMergeWithSameKeysAllowed, isRecordsUploadFromMobileAllowed, isRecordsWithErrorsUploadFromMobileAllowed, isVisibleInMobile } from './surveyGettersSecurity';
|
|
6
6
|
import { findApplicableDependentEnumeratedEntityDefs, getEnumeratingCategoryItems } from './surveysUtils';
|
|
7
7
|
export declare const Surveys: {
|
|
@@ -18,6 +18,7 @@ export declare const Surveys: {
|
|
|
18
18
|
getSRSs: typeof getSRSs;
|
|
19
19
|
getSRSByCode: typeof getSRSByCode;
|
|
20
20
|
getSRSIndex: typeof getSRSIndex;
|
|
21
|
+
getAreaOfInterest: typeof getAreaOfInterest;
|
|
21
22
|
getCategoryByName: typeof getCategoryByName;
|
|
22
23
|
getCategoryByUuid: typeof getCategoryByUuid;
|
|
23
24
|
getTaxonomyByName: typeof getTaxonomyByName;
|
|
@@ -21,6 +21,7 @@ exports.Surveys = {
|
|
|
21
21
|
getSRSs: surveysGetters_1.getSRSs,
|
|
22
22
|
getSRSByCode: surveysGetters_1.getSRSByCode,
|
|
23
23
|
getSRSIndex: surveysGetters_1.getSRSIndex,
|
|
24
|
+
getAreaOfInterest: surveysGetters_1.getAreaOfInterest,
|
|
24
25
|
getCategoryByName: surveysGetters_1.getCategoryByName,
|
|
25
26
|
getCategoryByUuid: surveysGetters_1.getCategoryByUuid,
|
|
26
27
|
getTaxonomyByName: surveysGetters_1.getTaxonomyByName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/survey/surveys/index.ts"],"names":[],"mappings":";;;AAAA,iDAMuB;AAEvB,yCAmCmB;AAEnB,yCAWmB;AAEnB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/survey/surveys/index.ts"],"names":[],"mappings":";;;AAAA,iDAMuB;AAEvB,yCAmCmB;AAEnB,yCAWmB;AAEnB,qDAsByB;AAEzB,mEASgC;AAEhC,iDAAyG;AAE5F,QAAA,OAAO,GAAG;IACrB,OAAO,EAAP,wBAAO;IACP,YAAY,EAAZ,6BAAY;IACZ,kBAAkB,EAAlB,mCAAkB;IAClB,QAAQ,EAAR,yBAAQ;IACR,cAAc,EAAd,+BAAc;IACd,cAAc,EAAd,+BAAc;IACd,kBAAkB,EAAlB,mCAAkB;IAClB,YAAY,EAAZ,6BAAY;IACZ,eAAe,EAAf,gCAAe;IACf,kBAAkB,EAAlB,mCAAkB;IAClB,OAAO,EAAP,wBAAO;IACP,YAAY,EAAZ,6BAAY;IACZ,WAAW,EAAX,4BAAW;IACX,iBAAiB,EAAjB,kCAAiB;IACjB,iBAAiB,EAAjB,kCAAiB;IACjB,iBAAiB,EAAjB,kCAAiB;IACjB,iBAAiB,EAAjB,kCAAiB;IACjB,iBAAiB,EAAjB,kCAAiB;IACjB,aAAa,EAAb,8BAAa;IACb,iBAAiB,EAAjB,kCAAiB;IACjB,yBAAyB,EAAzB,0CAAyB;IAEzB,iBAAiB,EAAjB,4BAAiB;IACjB,iBAAiB,EAAjB,4BAAiB;IACjB,mBAAmB,EAAnB,8BAAmB;IACnB,gBAAgB,EAAhB,2BAAgB;IAChB,gBAA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EzB,QAAQ;IACR,0BAA0B,EAA1B,qCAA0B;IAC1B,iBAAiB,EAAjB,4BAAiB;IACjB,4BAA4B,EAA5B,uCAA4B;IAC5B,kBAAkB,EAAlB,6BAAkB;IAElB,WAAW;IACX,WAAW,EAAX,mCAAW;IACX,uCAAuC,EAAvC,+DAAuC;IACvC,sCAAsC,EAAtC,8DAAsC;IACtC,iBAAiB,EAAjB,yCAAiB;IACjB,gCAAgC,EAAhC,wDAAgC;IAChC,gCAAgC,EAAhC,wDAAgC;IAChC,0CAA0C,EAA1C,kEAA0C;IAC1C,iCAAiC,EAAjC,yDAAiC;IAEjC,QAAQ;IACR,2BAA2B,EAA3B,0CAA2B;IAC3B,2CAA2C,EAA3C,0DAA2C;CAC5C,CAAA","sourcesContent":["import {\n addNodeDefDependencies,\n buildAndAssocDependencyGraph,\n getNodeDefDependents,\n getOnUpdateDependents,\n removeNodeDefDependencies,\n} from './dependencies'\n\nimport {\n addNodeDefToIndex,\n buildAndAssocNodeDefsIndex,\n deleteNodeDefIndex,\n findNodeDefByName,\n findNodeDefByUuid,\n findNodeDefsByUuids,\n getDependentCodeAttributeDefs,\n getDependentEnumeratedEntityDefs,\n getDescendantsInSingleEntities,\n getNodeDefsArray,\n getNodeDefAncestorCodes,\n getNodeDefAncestorMultipleEntity,\n getNodeDefByName,\n getNodeDefByUuid,\n getNodeDefCategoryLevelIndex,\n getNodeDefChildren,\n getNodeDefChildrenSorted,\n getNodeDefEnumerator,\n getNodeDefKeys,\n getNodeDefParent,\n getNodeDefParentCode,\n getNodeDefRoot,\n getNodeDefSource,\n getNodeDefsByUuids,\n getNodeDefsIncludedInMultipleEntitySummary,\n getQualifierDefs,\n getRootKeys,\n isNodeDefAncestor,\n isNodeDefEnumerator,\n isNodeDefParentCode,\n updateNodeDefUuidByNameIndex,\n visitAncestorsAndSelfNodeDef,\n visitDescendantsAndSelfNodeDef,\n visitNodeDefs,\n} from './nodeDefs'\n\nimport {\n getCategoryItemByCodePaths,\n getCategoryItemByUuid,\n getCategoryItemUuidByCode,\n getCategoryItems,\n getCategoryItemsByNodeDef,\n getCategoryItemsInLevel,\n getTaxonByCode,\n getTaxonByUuid,\n getTaxonVernacularNameUuid,\n includesTaxonVernacularName,\n} from './refsData'\n\nimport {\n getCategoryByName,\n getCategoryByUuid,\n getCycleKeys,\n getDefaultCycleKey,\n getDefaultLanguage,\n getDescription,\n getFieldManualLink,\n getLabel,\n getLabelOrName,\n getLanguages,\n getLastCycleKey,\n getName,\n getSRSByCode,\n getSRSIndex,\n getAreaOfInterest,\n getSRSs,\n getTaxonomyByName,\n getTaxonomyByUuid,\n getAuthGroups,\n getAuthGroupAdmin,\n isKeepNonApplicableValues,\n} from './surveysGetters'\n\nimport {\n getSecurity,\n isDataAnalystViewNotOwnedRecordsAllowed,\n isDataEditorViewNotOwnedRecordsAllowed,\n isRecordsDownloadInMobileAllowed,\n isRecordsMergeWithSameKeysAllowed,\n isRecordsUploadFromMobileAllowed,\n isRecordsWithErrorsUploadFromMobileAllowed,\n isVisibleInMobile,\n} from './surveyGettersSecurity'\n\nimport { findApplicableDependentEnumeratedEntityDefs, getEnumeratingCategoryItems } from './surveysUtils'\n\nexport const Surveys = {\n getName,\n getLanguages,\n getDefaultLanguage,\n getLabel,\n getLabelOrName,\n getDescription,\n getFieldManualLink,\n getCycleKeys,\n getLastCycleKey,\n getDefaultCycleKey,\n getSRSs,\n getSRSByCode,\n getSRSIndex,\n getAreaOfInterest,\n getCategoryByName,\n getCategoryByUuid,\n getTaxonomyByName,\n getTaxonomyByUuid,\n getAuthGroups,\n getAuthGroupAdmin,\n isKeepNonApplicableValues,\n\n findNodeDefByName,\n findNodeDefByUuid,\n findNodeDefsByUuids,\n getNodeDefsArray,\n getNodeDefByName,\n getNodeDefsByUuids,\n getNodeDefByUuid,\n getNodeDefChildren,\n getNodeDefChildrenSorted,\n getNodeDefParent,\n getNodeDefAncestorMultipleEntity,\n getNodeDefRoot,\n getNodeDefSource,\n isNodeDefAncestor,\n getNodeDefKeys,\n getRootKeys,\n getNodeDefsIncludedInMultipleEntitySummary,\n getQualifierDefs,\n isNodeDefEnumerator,\n getNodeDefEnumerator,\n visitAncestorsAndSelfNodeDef,\n visitDescendantsAndSelfNodeDef,\n visitNodeDefs,\n getDescendantsInSingleEntities,\n\n // ref data\n getCategoryItemByCodePaths,\n getCategoryItemByUuid,\n getCategoryItemUuidByCode,\n getCategoryItems,\n getCategoryItemsByNodeDef,\n getCategoryItemsInLevel,\n getTaxonByCode,\n getTaxonByUuid,\n getTaxonVernacularNameUuid,\n includesTaxonVernacularName,\n\n // node def code\n getNodeDefParentCode,\n getNodeDefAncestorCodes,\n isNodeDefParentCode,\n getNodeDefCategoryLevelIndex,\n getDependentCodeAttributeDefs,\n getDependentEnumeratedEntityDefs,\n\n // dependencies\n buildAndAssocDependencyGraph,\n addNodeDefDependencies,\n getNodeDefDependents,\n getOnUpdateDependents,\n removeNodeDefDependencies,\n\n // index\n buildAndAssocNodeDefsIndex,\n addNodeDefToIndex,\n updateNodeDefUuidByNameIndex,\n deleteNodeDefIndex,\n\n // security\n getSecurity,\n isDataAnalystViewNotOwnedRecordsAllowed,\n isDataEditorViewNotOwnedRecordsAllowed,\n isVisibleInMobile,\n isRecordsDownloadInMobileAllowed,\n isRecordsUploadFromMobileAllowed,\n isRecordsWithErrorsUploadFromMobileAllowed,\n isRecordsMergeWithSameKeysAllowed,\n\n // utils\n getEnumeratingCategoryItems,\n findApplicableDependentEnumeratedEntityDefs,\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { UserAuthGroup } from '../../auth';
|
|
2
2
|
import { Category } from '../../category';
|
|
3
|
+
import type { AreaOfInterest } from '../../geo';
|
|
3
4
|
import { LanguageCode } from '../../language';
|
|
4
5
|
import { SRS, SRSIndex } from '../../srs';
|
|
5
6
|
import { Taxonomy } from '../../taxonomy';
|
|
@@ -38,5 +39,6 @@ export declare const getDefaultCycleKey: (survey: Survey) => string | undefined;
|
|
|
38
39
|
export declare const getSRSs: (survey: Survey) => SRS[];
|
|
39
40
|
export declare const getSRSIndex: (survey: Survey) => SRSIndex;
|
|
40
41
|
export declare const getSRSByCode: (code: string) => (survey: Survey) => SRS | undefined;
|
|
42
|
+
export declare const getAreaOfInterest: (survey: Survey) => AreaOfInterest | undefined;
|
|
41
43
|
export declare const getAuthGroups: (survey: Survey) => UserAuthGroup[];
|
|
42
44
|
export declare const getAuthGroupAdmin: (survey: Survey) => UserAuthGroup | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAuthGroupAdmin = exports.getAuthGroups = exports.getSRSByCode = exports.getSRSIndex = exports.getSRSs = exports.getDefaultCycleKey = exports.isKeepNonApplicableValues = exports.getLastCycleKey = exports.getCycleKeys = exports.getTaxonomyByUuid = exports.getTaxonomyByName = exports.getCategoryByUuid = exports.getCategoryByName = exports.getLabelOrName = exports.getFieldManualLink = exports.getDescription = exports.getLabel = exports.getDefaultLanguage = exports.getLanguages = exports.getName = void 0;
|
|
3
|
+
exports.getAuthGroupAdmin = exports.getAuthGroups = exports.getAreaOfInterest = exports.getSRSByCode = exports.getSRSIndex = exports.getSRSs = exports.getDefaultCycleKey = exports.isKeepNonApplicableValues = exports.getLastCycleKey = exports.getCycleKeys = exports.getTaxonomyByUuid = exports.getTaxonomyByName = exports.getCategoryByUuid = exports.getCategoryByName = exports.getLabelOrName = exports.getFieldManualLink = exports.getDescription = exports.getLabel = exports.getDefaultLanguage = exports.getLanguages = exports.getName = void 0;
|
|
4
4
|
const auth_1 = require("../../auth");
|
|
5
5
|
const labels_1 = require("../../language/labels");
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
@@ -81,6 +81,10 @@ const getSRSIndex = (survey) => (0, exports.getSRSs)(survey).reduce((acc, srs) =
|
|
|
81
81
|
exports.getSRSIndex = getSRSIndex;
|
|
82
82
|
const getSRSByCode = (code) => (survey) => (0, exports.getSRSIndex)(survey)[code];
|
|
83
83
|
exports.getSRSByCode = getSRSByCode;
|
|
84
|
+
const getAreaOfInterest = (survey) => { var _a, _b, _c; var _d, _e; return (_e = (_d = (_a = survey === null || survey === void 0 ? void 0 : survey.props) === null || _a === void 0 ? void 0 : _a.areaOfInterest) !== null && _d !== void 0 ? _d :
|
|
85
|
+
// backwards compatibility with Arena: survey info props stored in info
|
|
86
|
+
(_c = (_b = survey === null || survey === void 0 ? void 0 : survey.info) === null || _b === void 0 ? void 0 : _b.props) === null || _c === void 0 ? void 0 : _c.areaOfInterest) !== null && _e !== void 0 ? _e : undefined; };
|
|
87
|
+
exports.getAreaOfInterest = getAreaOfInterest;
|
|
84
88
|
const getAuthGroups = (survey) => { var _a; return (_a = survey === null || survey === void 0 ? void 0 : survey.authGroups) !== null && _a !== void 0 ? _a : []; };
|
|
85
89
|
exports.getAuthGroups = getAuthGroups;
|
|
86
90
|
const getAuthGroupAdmin = (survey) => (0, exports.getAuthGroups)(survey).find((authGroup) => authGroup.name === auth_1.AuthGroupName.surveyAdmin);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surveysGetters.js","sourceRoot":"","sources":["../../../src/survey/surveys/surveysGetters.ts"],"names":[],"mappings":";;;AAAA,qCAAyD;
|
|
1
|
+
{"version":3,"file":"surveysGetters.js","sourceRoot":"","sources":["../../../src/survey/surveys/surveysGetters.ts"],"names":[],"mappings":";;;AAAA,qCAAyD;AAIzD,kDAAyD;AAGzD,uCAA6C;AAGtC,MAAM,OAAO,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAA;AAAvD,QAAA,OAAO,GAAP,OAAO,CAAgD;AAE7D,MAAM,YAAY,GAAG,CAAC,MAAc,EAAkB,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAA;AAAzE,QAAA,YAAY,GAAZ,YAAY,CAA6D;AAE/E,MAAM,kBAAkB,GAAG,CAAC,M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ACnB,OAAO,GAAG,CAAA;AACZ,CAAC,EAAE,EAAE,CAAC,CAAA;AAJK,QAAA,WAAW,GAAX,WAAW,CAIhB;AAED,MAAM,YAAY,GACvB,CAAC,IAAY,EAAE,EAAE,CACjB,CAAC,MAAc,EAAmB,EAAE,CAClC,IAAA,QAAA,WAAW,EAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAA;AAHhB,QAAA,YAAY,GAAZ,YAAY,CAGI;AAEtB,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAA8B,EAAE,kDAC9E,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,0CAAE,cAAc;AAC7B,uEAAuE;AACvE,MAAA,MAAC,MAAc,aAAd,MAAM,uBAAN,MAAM,CAAU,IAAI,0CAAE,KAAK,0CAAE,cAAc,mCAC5C,SAAS,GAAA,CAAA;AAJE,QAAA,iBAAiB,GAAjB,iBAAiB,CAInB;AAEJ,MAAM,aAAa,GAAG,CAAC,MAAc,EAAmB,EAAE,wBAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,UAAU,mCAAI,EAAE,GAAA,CAAA;AAA7E,QAAA,aAAa,GAAb,aAAa,CAAgE;AAEnF,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAA6B,EAAE,CAC7E,IAAA,QAAA,aAAa,EAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,oBAAa,CAAC,WAAW,CAAC,CAAA;AAD5E,QAAA,iBAAiB,GAAjB,iBAAiB,CAC2D","sourcesContent":["import { AuthGroupName, UserAuthGroup } from '../../auth'\nimport { Category } from '../../category'\nimport type { AreaOfInterest } from '../../geo'\nimport { LanguageCode } from '../../language'\nimport { getLabelOrDefault } from '../../language/labels'\nimport { SRS, SRSIndex } from '../../srs'\nimport { Taxonomy } from '../../taxonomy'\nimport { Arrays, Objects } from '../../utils'\nimport { Survey } from '../survey'\n\nexport const getName = (survey: Survey): string => survey.props.name\n\nexport const getLanguages = (survey: Survey): LanguageCode[] => survey.props.languages\n\nexport const getDefaultLanguage = (survey: Survey): LanguageCode => getLanguages(survey)[0]\n\nconst getMultilangPropValue =\n (prop: 'labels' | 'descriptions' | 'fieldManualLinks') =>\n (langCode?: LanguageCode) =>\n (survey: Survey): string | undefined => {\n const languageCode = langCode ?? getDefaultLanguage(survey)\n return survey.props[prop]?.[languageCode]\n }\nexport const getLabel = getMultilangPropValue('labels')\nexport const getDescription = getMultilangPropValue('descriptions')\nexport const getFieldManualLink = getMultilangPropValue('fieldManualLinks')\n\n/**\n * Returns the survey label in the specified language (the default language if not specified), or the survey name\n * when the label is missing or empty.\n */\nexport const getLabelOrName =\n (langCode?: LanguageCode) =>\n (survey: Survey): string =>\n getLabelOrDefault(survey.props.labels, langCode ?? getDefaultLanguage(survey), getName(survey))\n\nexport const getCategoryByName = (params: { survey: Survey; categoryName: string }): Category | undefined => {\n const { survey, categoryName } = params\n return survey.categories\n ? Object.values(survey.categories).find((category) => category.props.name === categoryName)\n : undefined\n}\n\nexport const getCategoryByUuid = (params: { survey: Survey; categoryUuid: string }): Category | undefined => {\n const { survey, categoryUuid } = params\n return survey.categories?.[categoryUuid]\n}\n\nexport const getTaxonomyByName = (params: { survey: Survey; taxonomyName: string }): Taxonomy | undefined => {\n const { survey, taxonomyName } = params\n return survey.taxonomies\n ? Object.values(survey.taxonomies).find((taxonomy) => taxonomy.props.name === taxonomyName)\n : undefined\n}\n\nexport const getTaxonomyByUuid = (params: { survey: Survey; taxonomyUuid: string }): Taxonomy | undefined => {\n const { survey, taxonomyUuid } = params\n return survey.taxonomies?.[taxonomyUuid]\n}\n\nexport const getCycleKeys = (survey: Survey): string[] => {\n const cycles = survey.props?.cycles ?? {}\n return Object.keys(cycles)\n}\n\nexport const getLastCycleKey = (survey: Survey): string => Arrays.last(getCycleKeys(survey)) as string\n\nexport const isKeepNonApplicableValues = (survey: Survey): boolean => survey?.props?.keepNonApplicableValues === true\n\nexport const getDefaultCycleKey = (survey: Survey) => {\n const defaultCycleKey = survey.props?.defaultCycleKey\n const lastCycleKey = getLastCycleKey(survey)\n return Objects.isEmpty(defaultCycleKey) || Number(defaultCycleKey) > Number(lastCycleKey)\n ? lastCycleKey\n : defaultCycleKey\n}\n\nexport const getSRSs = (survey: Survey): SRS[] =>\n survey.props?.srs ??\n // backwards compatibility with Arena: srs stored in info in UI\n (survey as any).info?.props?.srs ??\n []\n\nexport const getSRSIndex = (survey: Survey): SRSIndex =>\n getSRSs(survey).reduce((acc: SRSIndex, srs) => {\n acc[srs.code] = srs\n return acc\n }, {})\n\nexport const getSRSByCode =\n (code: string) =>\n (survey: Survey): SRS | undefined =>\n getSRSIndex(survey)[code]\n\nexport const getAreaOfInterest = (survey: Survey): AreaOfInterest | undefined =>\n survey?.props?.areaOfInterest ??\n // backwards compatibility with Arena: survey info props stored in info\n (survey as any)?.info?.props?.areaOfInterest ??\n undefined\n\nexport const getAuthGroups = (survey: Survey): UserAuthGroup[] => survey?.authGroups ?? []\n\nexport const getAuthGroupAdmin = (survey: Survey): UserAuthGroup | undefined =>\n getAuthGroups(survey).find((authGroup) => authGroup.name === AuthGroupName.surveyAdmin)\n"]}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"name": "OpenForis",
|
|
5
5
|
"email": "openforis.arena@gmail.com"
|
|
6
6
|
},
|
|
7
|
-
"version": "2.
|
|
7
|
+
"version": "2.13.1",
|
|
8
8
|
"description": "Arena core module",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -48,6 +48,8 @@
|
|
|
48
48
|
"@turf/bearing": "^7.4.0",
|
|
49
49
|
"@turf/destination": "^7.4.0",
|
|
50
50
|
"@turf/distance": "^7.4.0",
|
|
51
|
+
"@turf/point-to-polygon-distance": "^7.4.0",
|
|
52
|
+
"@types/geojson": "^7946.0.16",
|
|
51
53
|
"bignumber.js": "^11.1.5",
|
|
52
54
|
"change-case": "^5.4.4",
|
|
53
55
|
"dayjs": "^1.11.23",
|