@openforis/arena-core 2.5.10 → 2.5.11
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/expression/index.js.map +1 -1
- package/dist/esm/expression/javascript/node/call.js +10 -11
- package/dist/esm/expression/javascript/node/call.js.map +1 -1
- package/dist/esm/expression/javascript/parser/parser.js.map +1 -1
- package/dist/esm/expression/node.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/record/_records/nodeDefSelfReferences.js +6 -5
- package/dist/esm/record/_records/nodeDefSelfReferences.js.map +1 -1
- package/dist/expression/index.d.ts +1 -1
- package/dist/expression/index.js.map +1 -1
- package/dist/expression/javascript/node/call.d.ts +3 -3
- package/dist/expression/javascript/node/call.js +9 -10
- package/dist/expression/javascript/node/call.js.map +1 -1
- package/dist/expression/javascript/parser/parser.d.ts +2 -2
- package/dist/expression/javascript/parser/parser.js.map +1 -1
- package/dist/expression/node.d.ts +16 -12
- package/dist/expression/node.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/record/_records/nodeDefSelfReferences.js +6 -5
- package/dist/record/_records/nodeDefSelfReferences.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/expression/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/expression/index.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAA;AAEpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAE/C,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAA;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAA","sourcesContent":["export type { ExpressionContext } from './context'\n\nexport type { ExpressionEvaluator } from './evaluator'\n\nexport type { ExpressionFunction, ExpressionFunctions } from './function'\n\nexport type {\n AnyExpressionNode,\n ExpressionNode,\n ExpressionNodeEvaluatorConstructor,\n ArrayExpression,\n BinaryExpression,\n CallExpression,\n CompoundExpression,\n ConditionalExpression,\n IdentifierExpression,\n LiteralExpression,\n MemberExpression,\n SequenceExpression,\n ThisExpression,\n UnaryExpression,\n} from './node'\nexport { ExpressionNodeType, ExpressionNodeEvaluator } from './node'\n\nexport { ExpressionVariable } from './variable'\n\nexport { JavascriptExpressionEvaluator } from './javascript/evaluator'\nexport { JavascriptExpressionParser } from './javascript/parser/parser'\n"]}
|
|
@@ -8,26 +8,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { SystemError } from '../../../error';
|
|
11
|
-
import { ExpressionNodeEvaluator, ExpressionNodeType } from '../../node';
|
|
11
|
+
import { ExpressionNodeEvaluator, ExpressionNodeType, } from '../../node';
|
|
12
12
|
import { getGlobalObjectProperty } from '../global';
|
|
13
13
|
export class CallEvaluator extends ExpressionNodeEvaluator {
|
|
14
14
|
evaluate(expressionNode) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
const { callee } = expressionNode;
|
|
17
17
|
if (callee.type === ExpressionNodeType.Member) {
|
|
18
|
-
return this.evaluateMember(expressionNode);
|
|
18
|
+
return this.evaluateMember(expressionNode, callee);
|
|
19
19
|
}
|
|
20
20
|
else if (callee.type === ExpressionNodeType.Identifier) {
|
|
21
|
-
return this.evaluateIdentifier(expressionNode);
|
|
21
|
+
return this.evaluateIdentifier(expressionNode, callee);
|
|
22
22
|
}
|
|
23
23
|
// No complex expressions may be put in place of a function body.
|
|
24
24
|
// Only a plain identifier is allowed.
|
|
25
25
|
throw new SystemError('expression.invalidCalleeType', { type: callee.type });
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
evaluateMember(expressionNode) {
|
|
28
|
+
evaluateMember(expressionNode, callee) {
|
|
29
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
const {
|
|
30
|
+
const { arguments: exprArgs } = expressionNode;
|
|
31
31
|
// global function (e.g. Math.round(...))
|
|
32
32
|
const fn = yield this.evaluator.evaluateNode(callee, this.context);
|
|
33
33
|
if (fn) {
|
|
@@ -40,16 +40,16 @@ export class CallEvaluator extends ExpressionNodeEvaluator {
|
|
|
40
40
|
return null;
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
evaluateIdentifier(expressionNode) {
|
|
43
|
+
evaluateIdentifier(expressionNode, callee) {
|
|
44
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
45
|
// Arguments is a reserved word in strict mode
|
|
46
|
-
const {
|
|
46
|
+
const { arguments: exprArgs } = expressionNode;
|
|
47
47
|
const { object: contextObject } = this.context;
|
|
48
48
|
const { name: fnName } = callee;
|
|
49
49
|
const functionInfo = this.evaluator.functions[fnName];
|
|
50
50
|
if (functionInfo) {
|
|
51
51
|
// The function is among the custom functions.
|
|
52
|
-
return this.evaluateCustomIdentifier(expressionNode);
|
|
52
|
+
return this.evaluateCustomIdentifier(expressionNode, fnName);
|
|
53
53
|
}
|
|
54
54
|
// identifier is a global object
|
|
55
55
|
const globalFn = getGlobalObjectProperty(fnName, contextObject);
|
|
@@ -62,11 +62,10 @@ export class CallEvaluator extends ExpressionNodeEvaluator {
|
|
|
62
62
|
throw new SystemError('expression.undefinedFunction', { name: fnName });
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
evaluateCustomIdentifier(expressionNode) {
|
|
65
|
+
evaluateCustomIdentifier(expressionNode, fnName) {
|
|
66
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
67
|
// Arguments is a reserved word in strict mode
|
|
68
|
-
const {
|
|
69
|
-
const { name: fnName } = callee;
|
|
68
|
+
const { arguments: exprArgs } = expressionNode;
|
|
70
69
|
const numArgs = exprArgs.length;
|
|
71
70
|
const expressionFunction = this.evaluator.functions[fnName];
|
|
72
71
|
const { minArity, maxArity, evaluateArgsToNodes, executor } = expressionFunction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/call.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/node/call.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAG5C,OAAO,EAEL,uBAAuB,EACvB,kBAAkB,GAGnB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AAEnD,MAAM,OAAO,aAA2C,SAAQ,uBAA0C;IAClG,QAAQ,CAAC,cAA8B;;YAC3C,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,CAAA;YAEjC,IAAI,MAAM,CAAC,IAAI,KAAK,kBAAkB,CAAC,MAAM,EAAE,CAAC;gBAC9C,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;YACpD,CAAC;iBAAM,IAAI,MAAM,CAAC,IAAI,KAAK,kBAAkB,CAAC,UAAU,EAAE,CAAC;gBACzD,OAAO,IAAI,CAAC,kBAAkB,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;YACxD,CAAC;YAED,iEAAiE;YACjE,sCAAsC;YACtC,MAAM,IAAI,WAAW,CAAC,8BAA8B,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;QAC9E,CAAC;KAAA;IAEa,cAAc,CAAC,cAA8B,EAAE,MAAwB;;YACnF,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAA;YAE9C,yCAAyC;YACzC,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;YA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AG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAA;YAEpG,uEAAuE;YACvE,wEAAwE;YACxE,sCAAsC;YACtC,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;QACxC,CAAC;KAAA;CACF","sourcesContent":["import { SystemError } from '../../../error'\nimport { ExpressionContext } from '../../context'\nimport { ExpressionFunction } from '../../function'\nimport {\n CallExpression,\n ExpressionNodeEvaluator,\n ExpressionNodeType,\n IdentifierExpression,\n MemberExpression,\n} from '../../node'\nimport { getGlobalObjectProperty } from '../global'\n\nexport class CallEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<C, CallExpression> {\n async evaluate(expressionNode: CallExpression): Promise<any> {\n const { callee } = expressionNode\n\n if (callee.type === ExpressionNodeType.Member) {\n return this.evaluateMember(expressionNode, callee)\n } else if (callee.type === ExpressionNodeType.Identifier) {\n return this.evaluateIdentifier(expressionNode, callee)\n }\n\n // No complex expressions may be put in place of a function body.\n // Only a plain identifier is allowed.\n throw new SystemError('expression.invalidCalleeType', { type: callee.type })\n }\n\n private async evaluateMember(expressionNode: CallExpression, callee: MemberExpression): Promise<any> {\n const { arguments: exprArgs } = expressionNode\n\n // global function (e.g. Math.round(...))\n const fn = await this.evaluator.evaluateNode(callee, this.context)\n if (fn) {\n const { object: calleeObj } = callee\n const fnObject = await this.evaluator.evaluateNode(calleeObj, this.context)\n const argsEvaluated = await Promise.all(exprArgs.map((arg) => this.evaluator.evaluateNode(arg, this.context)))\n const args = argsEvaluated.flat()\n return fn.call(fnObject, ...args)\n }\n return null\n }\n\n private async evaluateIdentifier(expressionNode: CallExpression, callee: IdentifierExpression): Promise<any> {\n // Arguments is a reserved word in strict mode\n const { arguments: exprArgs } = expressionNode\n const { object: contextObject } = this.context\n\n const { name: fnName } = callee\n\n const functionInfo = this.evaluator.functions[fnName]\n if (functionInfo) {\n // The function is among the custom functions.\n return this.evaluateCustomIdentifier(expressionNode, fnName)\n }\n // identifier is a global object\n const globalFn = getGlobalObjectProperty(fnName, contextObject)\n if (globalFn !== null) {\n // global functions like String, Number, must be invoked passing node value as argument, not the node itself\n const contextArg = { ...this.context, evaluateToNode: false }\n const args = await Promise.all(exprArgs.map((arg) => this.evaluator.evaluateNode(arg, contextArg)))\n return globalFn(...args)\n }\n\n throw new SystemError('expression.undefinedFunction', { name: fnName })\n }\n\n private async evaluateCustomIdentifier(expressionNode: CallExpression, fnName: string): Promise<any> {\n // Arguments is a reserved word in strict mode\n const { arguments: exprArgs } = expressionNode\n const numArgs = exprArgs.length\n\n const expressionFunction: ExpressionFunction<C> = this.evaluator.functions[fnName]\n\n const { minArity, maxArity, evaluateArgsToNodes, executor } = expressionFunction\n\n if (numArgs < minArity)\n throw new SystemError('expression.functionHasTooFewArguments', { fnName, minArity, numArgs })\n if (maxArity !== undefined && maxArity >= 0 && numArgs > maxArity)\n throw new SystemError('expression.functionHasTooManyArguments', { fnName, maxArity, numArgs })\n\n // evaluate arguments\n const argsContext = { ...this.context, evaluateToNode: evaluateArgsToNodes }\n const args = await Promise.all(exprArgs.map((arg) => this.evaluator.evaluateNode(arg, argsContext)))\n\n // Currently there are no side effects from function evaluation so it's\n // safe to call the function even when we're just parsing the expression\n // to find all identifiers being used.\n return executor(this.context)(...args)\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/parser/parser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,MAAM,OAAO,0BAA0B;IACrC,KAAK,CAAC,UAAkB;QACtB,OAAO,IAAI,CAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../../src/expression/javascript/parser/parser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,MAAM,OAAO,0BAA0B;IACrC,KAAK,CAAC,UAAkB;QACtB,OAAO,IAAI,CAAC,UAAU,CAAsB,CAAA;IAC9C,CAAC;CACF","sourcesContent":["import { AnyExpressionNode } from '../../node'\nimport { ExpressionParser } from '../../parser'\nimport { jsep } from './jsep'\n\nexport class JavascriptExpressionParser implements ExpressionParser {\n parse(expression: string): AnyExpressionNode {\n return jsep(expression) as AnyExpressionNode\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/expression/node.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,kBAYX;AAZD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,iDAA2B,CAAA;IAC3B,6CAAuB,CAAA;IACvB,2CAAqB,CAAA;IACrB,2DAAqC,CAAA;IACrC,+CAAyB,CAAA;IACzB,yCAAmB,CAAA;IACnB,iDAA2B,CAAA;IAC3B,qDAA+B,CAAA;IAC/B,6CAAuB,CAAA;IACvB,+CAAyB,CAAA;AAC3B,CAAC,EAZW,kBAAkB,KAAlB,kBAAkB,QAY7B;
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/expression/node.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,kBAYX;AAZD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,iDAA2B,CAAA;IAC3B,6CAAuB,CAAA;IACvB,2CAAqB,CAAA;IACrB,2DAAqC,CAAA;IACrC,+CAAyB,CAAA;IACzB,yCAAmB,CAAA;IACnB,iDAA2B,CAAA;IAC3B,qDAA+B,CAAA;IAC/B,6CAAuB,CAAA;IACvB,+CAAyB,CAAA;AAC3B,CAAC,EAZW,kBAAkB,KAAlB,kBAAkB,QAY7B;AAsED,MAAM,OAAgB,uBAAuB;IAO3C,YAAY,SAAiC,EAAE,OAAU;QACvD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;CAGF","sourcesContent":["import { ExpressionEvaluator } from './evaluator'\nimport { ExpressionContext } from './context'\n\nexport enum ExpressionNodeType {\n Array = 'ArrayExpression',\n Binary = 'BinaryExpression',\n Call = 'CallExpression',\n Compound = 'Compound',\n Conditional = 'ConditionalExpression',\n Identifier = 'Identifier',\n Literal = 'Literal',\n Member = 'MemberExpression',\n Sequence = 'SequenceExpression',\n This = 'ThisExpression',\n Unary = 'UnaryExpression',\n}\n\nexport interface ExpressionNode<T extends ExpressionNodeType> {\n type: T\n}\n\nexport interface ArrayExpression extends ExpressionNode<ExpressionNodeType.Array> {\n elements: Array<AnyExpressionNode>\n}\nexport interface BinaryExpression extends ExpressionNode<ExpressionNodeType.Binary> {\n left: AnyExpressionNode\n right: AnyExpressionNode\n operator: string\n}\nexport interface CallExpression extends ExpressionNode<ExpressionNodeType.Call> {\n arguments: Array<AnyExpressionNode>\n callee: AnyExpressionNode\n}\nexport type CompoundExpression = ExpressionNode<ExpressionNodeType.Compound>\nexport interface ConditionalExpression extends ExpressionNode<ExpressionNodeType.Conditional> {\n test: AnyExpressionNode\n consequent: AnyExpressionNode\n alternate: AnyExpressionNode\n}\nexport interface IdentifierExpression extends ExpressionNode<ExpressionNodeType.Identifier> {\n name: string\n}\nexport interface LiteralExpression extends ExpressionNode<ExpressionNodeType.Literal> {\n raw: string\n value: any\n}\nexport interface MemberExpression extends ExpressionNode<ExpressionNodeType.Member> {\n computed: boolean\n object: AnyExpressionNode\n property: AnyExpressionNode\n optional?: boolean\n}\nexport interface SequenceExpression extends ExpressionNode<ExpressionNodeType.Sequence> {\n expression: AnyExpressionNode\n}\nexport type ThisExpression = ExpressionNode<ExpressionNodeType.This>\nexport interface UnaryExpression extends ExpressionNode<ExpressionNodeType.Unary> {\n argument: AnyExpressionNode\n operator: string\n prefix: boolean\n}\n\n/**\n * Union of all the expression node types: narrow it by `type` to get the specific node.\n */\nexport type AnyExpressionNode =\n | ArrayExpression\n | BinaryExpression\n | CallExpression\n | CompoundExpression\n | ConditionalExpression\n | IdentifierExpression\n | LiteralExpression\n | MemberExpression\n | SequenceExpression\n | ThisExpression\n | UnaryExpression\n\nexport interface ExpressionNodeEvaluatorConstructor<\n C extends ExpressionContext,\n N extends ExpressionNode<ExpressionNodeType>,\n> {\n new (evaluator: ExpressionEvaluator<C>, context: C): ExpressionNodeEvaluator<C, N>\n}\n\nexport abstract class ExpressionNodeEvaluator<\n C extends ExpressionContext,\n N extends ExpressionNode<ExpressionNodeType>,\n> {\n readonly evaluator: ExpressionEvaluator<C>\n readonly context: C\n\n constructor(evaluator: ExpressionEvaluator<C>, context: C) {\n this.evaluator = evaluator\n this.context = context\n }\n\n abstract evaluate(expressionNode: N): Promise<any>\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,SAAS,CAAA;AAY5E,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAIzC,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,4BAA4B,EAC5B,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,M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E,aAAa,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAEjF,OAAO,EACL,MAAM,EACN,WAAW,EACX,KAAK,EACL,SAAS,EACT,aAAa,EACb,OAAO,EACP,OAAO,EACP,QAAQ,EACR,KAAK,EACL,cAAc,EACd,OAAO,EACP,UAAU,EACV,KAAK,EACL,QAAQ,GACT,MAAM,SAAS,CAAA;AAIhB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,kBAAkB,GACnB,MAAM,cAAc,CAAA","sourcesContent":["export type { AppInfo } from './app'\n\nexport { Authorizer, AuthGroupName, UserStatus, Permission, UserTitle, UserFactory, Users } from './auth'\nexport type {\n AuthGroup,\n User,\n UserAuthGroup,\n UserAuthGroupProps,\n AuthToken,\n UserAuthTokenPayload,\n UserAuthTokenService,\n UserPrefs,\n UserPrefSurveys,\n UserProps,\n UserAuthRefreshToken,\n UserAuthRefreshTokenProps,\n UserAuthRefreshTokenPayload,\n UserService,\n UserTokenPayload,\n DownloadAuthTokenPayload,\n UserGroup,\n UserGroupProps,\n UserGroupQualifier,\n UserInvitation,\n} from './auth'\n\nexport { CategoryFactory, CategoryImportColumnType, CategoryItemFactory, CategoryLevelFactory } from './category'\nexport type {\n CategoryItemProps,\n Category,\n CategoryItem,\n CategoryLevel,\n CategoryLevelProps,\n CategoryImportSummary,\n CategoryImportSummaryColumn,\n CategoryItemService,\n CategoryLevelService,\n CategoryProps,\n CategoryService,\n} from './category'\n\nexport { Categories, CategoryItems } from './category'\n\nexport { ChainFactory, ChainStatusExec, ChainNodeDefFactory } from './chain'\nexport type {\n Chain,\n ChainProps,\n ChainService,\n ChainNodeDef,\n ChainNodeDefProps,\n ChainNodeDefService,\n ChainNodeDefAggregate,\n ChainNodeDefAggregateProps,\n} from './chain'\n\nexport { TraverseMethod } from './common'\nexport type { ArenaObject, ArenaService, Dictionary, Factory, I18n } from './common'\n\nexport type { FlatDataExportOptions, ArenaExportInfoFactoryParams, ArenaExportInfo } from './dataExport'\nexport {\n FlatDataExportDefaultOptions,\n FlatDataExportOption,\n FlatDataFiles,\n FlatDataExportModel,\n FlatDataExportColumnDataType,\n ArenaExportInfoFactory,\n UniqueFileNamesGenerator,\n} from './dataExport'\n\nexport { DataQueryMode, DataQuerySummaries } from './dataQuery'\nexport type { DataQuery, DataQuerySummary, DataQuerySummaryProps } from './dataQuery'\n\nexport { SystemError } from './error'\n\nexport {\n ExpressionNodeType,\n ExpressionNodeEvaluator,\n ExpressionVariable,\n JavascriptExpressionEvaluator,\n JavascriptExpressionParser,\n} from './expression'\nexport type {\n ArrayExpression,\n BinaryExpression,\n CallExpression,\n CompoundExpression,\n ConditionalExpression,\n ExpressionContext,\n ExpressionEvaluator,\n ExpressionFunction,\n ExpressionFunctions,\n AnyExpressionNode,\n ExpressionNode,\n ExpressionNodeEvaluatorConstructor,\n MemberExpression,\n IdentifierExpression,\n LiteralExpression,\n SequenceExpression,\n ThisExpression,\n UnaryExpression,\n} from './expression'\n\nexport { ExtraPropDataType, ExtraPropsDataGenerator } from './extraProp'\nexport type { ExtraPropDef, ExtraPropDefs } from './extraProp'\n\nexport { PointFactory, Points } from './geo'\nexport type { Point } from './geo'\n\nexport { JobBase, JobEventType, JobStatus } from './job'\nexport type { Job, JobContext, JobEvent, JobSerialized, JobTxClient } from './job'\n\nexport { LanguageCode, Languages, LanguagesISO639part2 } from './language'\nexport type { Labels } from './language'\n\nexport type { Logger } from './logger'\n\nexport type { Message } from './message'\nexport { MessageNotificationType, MessagePropsKey, MessageStatus, MessageTargetUserType, Messages } from './message'\n\nexport { NodeFactory, NodeKeys, NodeMetaKeys, Nodes, NodeValueFormatter, NodeValues } from './node'\nexport type {\n ArenaRecordNode,\n Node,\n NodeMeta,\n NodePointer,\n NodeRefData,\n NodeService,\n NodesMap,\n NodeValueCode,\n NodeValueCoordinate,\n NodeValueFile,\n NodeValueTaxon,\n} from './node'\n\nexport {\n NodeDefCountType,\n NodeDefType,\n NodeDefFactory,\n NodeDefs,\n NodeDefEntityRenderType,\n NodeDefFileType,\n NodeDefTextInputType,\n NodeDefTextRenderType,\n FormHeaderColor,\n} from './nodeDef'\n\nexport { NodeDefExpressionEvaluator, NodeDefExpressionValidator } from './nodeDefExpressionEvaluator'\nexport type { CategoryItemProvider, TaxonProvider } from './nodeDefExpressionEvaluator'\n\nexport type {\n NodeDef,\n NodeDefLayout,\n NodeDefMeta,\n NodeDefProps,\n NodeDefPropsWithLayout,\n NodeDefBoolean,\n NodeDefBooleanProps,\n NodeDefCode,\n NodeDefCodeLayout,\n NodeDefCodeProps,\n NodeDefCoordinate,\n NodeDefCoordinateProps,\n NodeDefDate,\n NodeDefDecimal,\n NodeDefDecimalProps,\n NodeDefEntity,\n NodeDefEntityChildPosition,\n NodeDefEntityLayout,\n NodeDefEntityProps,\n NodeDefPrintOrientation,\n NodeDefFile,\n NodeDefFileProps,\n NodeDefFormHeader,\n NodeDefFormHeaderProps,\n NodeDefInteger,\n NodeDefPropsAdvanced,\n NodeDefTaxon,\n NodeDefTaxonProps,\n NodeDefText,\n NodeDefTextProps,\n NodeDefTextLayout,\n NodeDefTime,\n NodeDefTimeProps,\n NodeDefExpression,\n NodeDefMap,\n NodeDefService,\n NodeDefValidations,\n} from './nodeDef'\n\nexport {\n NodePointers,\n RecordCloner,\n RecordFactory,\n RecordFixer,\n Records,\n RECORD_STEP_DEFAULT,\n RecordExpressionEvaluator,\n RecordNodesUpdater,\n RecordPrettyPrinter,\n RecordUpdater,\n RecordUpdateResult,\n RecordValidator,\n RecordValidations,\n} from './record'\nexport type {\n AttributeValidatorParams,\n AttributesValidatorParams,\n NodeCreateParams,\n NodesUpdateParams,\n ArenaRecord,\n Record,\n RecordExpressionContext,\n RecordExpressionEvaluationContext,\n RecordService,\n RecordUpdateOptions,\n RecordValidatorParams,\n SortedAttributesValidatorParams,\n} from './record'\n\nexport { ServiceRegistry, ServiceType } from './registry'\nexport type { ServiceTypeMap } from './registry'\n\nexport { DEFAULT_SRS, DEFAULT_SRS_INDEX, SRSFactory } from './srs'\nexport type { SRS, SRSIndex } from './srs'\n\nexport {\n NodeDefsFixer,\n SurveyDocImages,\n SurveyDocImageFactory,\n SurveyDocPlace,\n SurveyDependencyType,\n SurveyFactory,\n SurveyFileFactory,\n SurveyFileType,\n SurveyRefDataFactory,\n SurveySecurityProp,\n Surveys,\n surveyDocImagePropKeys,\n surveySecurityDefaults,\n defaultCycle,\n} from './survey'\nexport type {\n Survey,\n SurveyCycle,\n SurveyDependency,\n SurveyDependencyGraph,\n SurveyDocImage,\n SurveyDocImageFactoryParams,\n SurveyDocImageProps,\n SurveyFile,\n SurveyFileFactoryParams,\n SurveyFileProps,\n SurveyProps,\n SurveyRefData,\n SurveySecurity,\n SurveyService,\n} from './survey'\n\nexport { Taxa, Taxonomies, TaxonomyFactory, TaxonFactory, TaxonGenerator, VernacularNameFactory } from './taxonomy'\nexport type {\n VernacularNameParams,\n TaxonomyFactoryParams,\n TaxonFactoryParams,\n Taxonomy,\n TaxonomyService,\n VernacularNameProps,\n VernacularName,\n TaxonProps,\n Taxon,\n TaxonomyProps,\n TaxonService,\n} from './taxonomy'\n\nexport { SurveyBuilder, SurveyObjectBuilders } from './tests/builder/surveyBuilder'\nexport { RecordBuilder, RecordNodeBuilders } from './tests/builder/recordBuilder'\n\nexport {\n Arrays,\n DateFormats,\n Dates,\n FileNames,\n FileProcessor,\n Numbers,\n Objects,\n Promises,\n Queue,\n RetryProcessor,\n Strings,\n UnitOfTime,\n UUIDs,\n Versions,\n} from './utils'\n\nexport type { FileProcessorConstructorArgs, MutationOptions, ParsedVersion } from './utils'\n\nexport {\n FieldValidators,\n ValidationFactory,\n ValidationResultFactory,\n ValidationResults,\n Validations,\n ValidationSeverity,\n Validator,\n ValidatorErrorKeys,\n} from './validation'\nexport type {\n DissocFieldValidationOptions,\n FieldValidator,\n Validation,\n ValidationFields,\n ValidationResult,\n ValidationCounts,\n} from './validation'\n"]}
|
|
@@ -13,12 +13,13 @@ const isReferencedThroughMember = (params) => {
|
|
|
13
13
|
if (Array.isArray(expressionNode)) {
|
|
14
14
|
return expressionNode.some((item) => isReferencedThroughMember({ expressionNode: item, name, inMemberProperty }));
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
// parsed expression nodes (or their array or object properties)
|
|
17
|
+
const node = expressionNode;
|
|
18
|
+
if (node.type === ExpressionNodeType.Identifier) {
|
|
19
|
+
return inMemberProperty && node.name === name;
|
|
19
20
|
}
|
|
20
|
-
if (type === ExpressionNodeType.Member) {
|
|
21
|
-
const { object, property } =
|
|
21
|
+
if (node.type === ExpressionNodeType.Member) {
|
|
22
|
+
const { object, property } = node;
|
|
22
23
|
return (isReferencedThroughMember({ expressionNode: object, name, inMemberProperty }) ||
|
|
23
24
|
isReferencedThroughMember({ expressionNode: property, name, inMemberProperty: true }));
|
|
24
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeDefSelfReferences.js","sourceRoot":"","sources":["../../../../src/record/_records/nodeDefSelfReferences.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"nodeDefSelfReferences.js","sourceRoot":"","sources":["../../../../src/record/_records/nodeDefSelfReferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAA;AACvE,OAAO,EAAyB,QAAQ,EAAe,MAAM,eAAe,CAAA;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE1D;;;GAGG;AACH,MAAM,yBAAyB,GAAG,CAAC,MAIlC,EAAW,EAAE;IACZ,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAAA;IACzD,IAAI,CAAC,cAAc,IAAI,OAAO,cAAc,KAAK,Q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,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,CAAA;IACnH,CAAC;eAAO,CAAC;QACP,sCAAsC;QACtC,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG,CAAC,MAG7B,EAAW,EAAE;IACZ,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,MAAM,CAAA;IAC1C,uGAAuG;IACvG,IAAI,cAAc,KAAK,oBAAoB,CAAC,WAAW;QAAE,OAAO,KAAK,CAAA;IACrE,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IACtC,OAAO,QAAQ,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC,KAAK,CACtD,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,EAAE,CAC1B,8BAA8B,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QACpD,8BAA8B,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAChE,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,oBAAoB;CACrB,CAAA","sourcesContent":["import { AnyExpressionNode, ExpressionNodeType } from '../../expression'\nimport { parseExpression } from '../../expression/javascript/evaluator'\nimport { NodeDef, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { SurveyDependencyType } from '../../survey/survey'\n\n/**\n * True if the identifier is used as (or inside) the property of a member expression (e.g. \"dbh\" in\n * \"parent(tree).tree.dbh\" or in \"tree[dbh > 10]\"): there it can refer to nodes outside the context entity.\n */\nconst isReferencedThroughMember = (params: {\n expressionNode: unknown\n name: string\n inMemberProperty: boolean\n}): boolean => {\n const { expressionNode, name, inMemberProperty } = params\n if (!expressionNode || typeof expressionNode !== 'object') return false\n if (Array.isArray(expressionNode)) {\n return expressionNode.some((item) => isReferencedThroughMember({ expressionNode: item, name, inMemberProperty }))\n }\n // parsed expression nodes (or their array or object properties)\n const node = expressionNode as AnyExpressionNode\n if (node.type === ExpressionNodeType.Identifier) {\n return inMemberProperty && node.name === name\n }\n if (node.type === ExpressionNodeType.Member) {\n const { object, property } = node\n return (\n isReferencedThroughMember({ expressionNode: object, name, inMemberProperty }) ||\n isReferencedThroughMember({ expressionNode: property, name, inMemberProperty: true })\n )\n }\n return Object.values(expressionNode).some((child) =>\n isReferencedThroughMember({ expressionNode: child, name, inMemberProperty })\n )\n}\n\nconst isExpressionSelfReferenceLocal = (params: { expression: string | undefined; name: string }): boolean => {\n const { expression, name } = params\n if (!expression) return true\n try {\n return !isReferencedThroughMember({ expressionNode: parseExpression(expression), name, inMemberProperty: false })\n } catch {\n // invalid expression: be conservative\n return false\n }\n}\n\n/**\n * Returns true if the node def references itself in its expressions of the specified dependency type only\n * as a plain identifier (e.g. \"dbh > 0\" in a validation of \"dbh\"): such a reference is resolved among the\n * children of the node's parent entity, so only the node and its siblings depend on it, not every node with\n * the same node def in the record.\n */\nconst isSelfReferenceLocal = (params: {\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n dependencyType: SurveyDependencyType\n}): boolean => {\n const { nodeDef, dependencyType } = params\n // self references by plain identifier are allowed only in validation expressions (see dependencies.ts)\n if (dependencyType !== SurveyDependencyType.validations) return false\n const name = NodeDefs.getName(nodeDef)\n return NodeDefs.getValidationsExpressions(nodeDef).every(\n ({ expression, applyIf }) =>\n isExpressionSelfReferenceLocal({ expression, name }) &&\n isExpressionSelfReferenceLocal({ expression: applyIf, name })\n )\n}\n\nexport const NodeDefSelfReferences = {\n isSelfReferenceLocal,\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { ExpressionContext } from './context';
|
|
2
2
|
export type { ExpressionEvaluator } from './evaluator';
|
|
3
3
|
export type { ExpressionFunction, ExpressionFunctions } from './function';
|
|
4
|
-
export type { ExpressionNode, ExpressionNodeEvaluatorConstructor, ArrayExpression, BinaryExpression, CallExpression, CompoundExpression, ConditionalExpression, IdentifierExpression, LiteralExpression, MemberExpression, SequenceExpression, ThisExpression, UnaryExpression, } from './node';
|
|
4
|
+
export type { AnyExpressionNode, ExpressionNode, ExpressionNodeEvaluatorConstructor, ArrayExpression, BinaryExpression, CallExpression, CompoundExpression, ConditionalExpression, IdentifierExpression, LiteralExpression, MemberExpression, SequenceExpression, ThisExpression, UnaryExpression, } from './node';
|
|
5
5
|
export { ExpressionNodeType, ExpressionNodeEvaluator } from './node';
|
|
6
6
|
export { ExpressionVariable } from './variable';
|
|
7
7
|
export { JavascriptExpressionEvaluator } from './javascript/evaluator';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/expression/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/expression/index.ts"],"names":[],"mappings":";;;AAsBA,+BAAoE;AAA3D,0GAAA,kBAAkB,OAAA;AAAE,+GAAA,uBAAuB,OAAA;AAEpD,uCAA+C;AAAtC,8GAAA,kBAAkB,OAAA;AAE3B,oDAAsE;AAA7D,0HAAA,6BAA6B,OAAA;AACtC,qDAAuE;AAA9D,oHAAA,0BAA0B,OAAA","sourcesContent":["export type { ExpressionContext } from './context'\n\nexport type { ExpressionEvaluator } from './evaluator'\n\nexport type { ExpressionFunction, ExpressionFunctions } from './function'\n\nexport type {\n AnyExpressionNode,\n ExpressionNode,\n ExpressionNodeEvaluatorConstructor,\n ArrayExpression,\n BinaryExpression,\n CallExpression,\n CompoundExpression,\n ConditionalExpression,\n IdentifierExpression,\n LiteralExpression,\n MemberExpression,\n SequenceExpression,\n ThisExpression,\n UnaryExpression,\n} from './node'\nexport { ExpressionNodeType, ExpressionNodeEvaluator } from './node'\n\nexport { ExpressionVariable } from './variable'\n\nexport { JavascriptExpressionEvaluator } from './javascript/evaluator'\nexport { JavascriptExpressionParser } from './javascript/parser/parser'\n"]}
|
|
@@ -2,7 +2,7 @@ import { ExpressionContext } from '../../context';
|
|
|
2
2
|
import { CallExpression, ExpressionNodeEvaluator } from '../../node';
|
|
3
3
|
export declare class CallEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<C, CallExpression> {
|
|
4
4
|
evaluate(expressionNode: CallExpression): Promise<any>;
|
|
5
|
-
evaluateMember
|
|
6
|
-
evaluateIdentifier
|
|
7
|
-
evaluateCustomIdentifier
|
|
5
|
+
private evaluateMember;
|
|
6
|
+
private evaluateIdentifier;
|
|
7
|
+
private evaluateCustomIdentifier;
|
|
8
8
|
}
|
|
@@ -18,19 +18,19 @@ class CallEvaluator extends node_1.ExpressionNodeEvaluator {
|
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
const { callee } = expressionNode;
|
|
20
20
|
if (callee.type === node_1.ExpressionNodeType.Member) {
|
|
21
|
-
return this.evaluateMember(expressionNode);
|
|
21
|
+
return this.evaluateMember(expressionNode, callee);
|
|
22
22
|
}
|
|
23
23
|
else if (callee.type === node_1.ExpressionNodeType.Identifier) {
|
|
24
|
-
return this.evaluateIdentifier(expressionNode);
|
|
24
|
+
return this.evaluateIdentifier(expressionNode, callee);
|
|
25
25
|
}
|
|
26
26
|
// No complex expressions may be put in place of a function body.
|
|
27
27
|
// Only a plain identifier is allowed.
|
|
28
28
|
throw new error_1.SystemError('expression.invalidCalleeType', { type: callee.type });
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
evaluateMember(expressionNode) {
|
|
31
|
+
evaluateMember(expressionNode, callee) {
|
|
32
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
const {
|
|
33
|
+
const { arguments: exprArgs } = expressionNode;
|
|
34
34
|
// global function (e.g. Math.round(...))
|
|
35
35
|
const fn = yield this.evaluator.evaluateNode(callee, this.context);
|
|
36
36
|
if (fn) {
|
|
@@ -43,16 +43,16 @@ class CallEvaluator extends node_1.ExpressionNodeEvaluator {
|
|
|
43
43
|
return null;
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
evaluateIdentifier(expressionNode) {
|
|
46
|
+
evaluateIdentifier(expressionNode, callee) {
|
|
47
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
48
|
// Arguments is a reserved word in strict mode
|
|
49
|
-
const {
|
|
49
|
+
const { arguments: exprArgs } = expressionNode;
|
|
50
50
|
const { object: contextObject } = this.context;
|
|
51
51
|
const { name: fnName } = callee;
|
|
52
52
|
const functionInfo = this.evaluator.functions[fnName];
|
|
53
53
|
if (functionInfo) {
|
|
54
54
|
// The function is among the custom functions.
|
|
55
|
-
return this.evaluateCustomIdentifier(expressionNode);
|
|
55
|
+
return this.evaluateCustomIdentifier(expressionNode, fnName);
|
|
56
56
|
}
|
|
57
57
|
// identifier is a global object
|
|
58
58
|
const globalFn = (0, global_1.getGlobalObjectProperty)(fnName, contextObject);
|
|
@@ -65,11 +65,10 @@ class CallEvaluator extends node_1.ExpressionNodeEvaluator {
|
|
|
65
65
|
throw new error_1.SystemError('expression.undefinedFunction', { name: fnName });
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
evaluateCustomIdentifier(expressionNode) {
|
|
68
|
+
evaluateCustomIdentifier(expressionNode, fnName) {
|
|
69
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
70
|
// Arguments is a reserved word in strict mode
|
|
71
|
-
const {
|
|
72
|
-
const { name: fnName } = callee;
|
|
71
|
+
const { arguments: exprArgs } = expressionNode;
|
|
73
72
|
const numArgs = exprArgs.length;
|
|
74
73
|
const expressionFunction = this.evaluator.functions[fnName];
|
|
75
74
|
const { minArity, maxArity, evaluateArgsToNodes, executor } = expressionFunction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../../../src/expression/javascript/node/call.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../../../src/expression/javascript/node/call.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AAE,CAAC,CAAA;QACzE,CAAC;KAAA;IAEa,wBAAwB,CAAC,cAA8B,EAAE,MAAc;;YACnF,8CAA8C;YAC9C,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAA;YAC9C,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAA;YAE/B,MAAM,kBAAkB,GAA0B,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;YAElF,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,mBAAmB,EAAE,QAAQ,EAAE,GAAG,kBAAkB,CAAA;YAEhF,IAAI,OAAO,GAAG,QAAQ;gBACpB,MAAM,IAAI,mBAAW,CAAC,uCAAuC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAA;YAC/F,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,IAAI,CAAC,IAAI,OAAO,GAAG,QAAQ;gBAC/D,MAAM,IAAI,mBAAW,CAAC,wCAAwC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAA;YAEhG,qBAAqB;YACrB,MAAM,WAAW,mCAAQ,IAAI,CAAC,OAAO,KAAE,cAAc,EAAE,mBAAmB,GAAE,CAAA;YAC5E,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAA;YAEpG,uEAAuE;YACvE,wEAAwE;YACxE,sCAAsC;YACtC,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;QACxC,CAAC;KAAA;CACF","sourcesContent":["import { SystemError } from '../../../error'\nimport { ExpressionContext } from '../../context'\nimport { ExpressionFunction } from '../../function'\nimport {\n CallExpression,\n ExpressionNodeEvaluator,\n ExpressionNodeType,\n IdentifierExpression,\n MemberExpression,\n} from '../../node'\nimport { getGlobalObjectProperty } from '../global'\n\nexport class CallEvaluator<C extends ExpressionContext> extends ExpressionNodeEvaluator<C, CallExpression> {\n async evaluate(expressionNode: CallExpression): Promise<any> {\n const { callee } = expressionNode\n\n if (callee.type === ExpressionNodeType.Member) {\n return this.evaluateMember(expressionNode, callee)\n } else if (callee.type === ExpressionNodeType.Identifier) {\n return this.evaluateIdentifier(expressionNode, callee)\n }\n\n // No complex expressions may be put in place of a function body.\n // Only a plain identifier is allowed.\n throw new SystemError('expression.invalidCalleeType', { type: callee.type })\n }\n\n private async evaluateMember(expressionNode: CallExpression, callee: MemberExpression): Promise<any> {\n const { arguments: exprArgs } = expressionNode\n\n // global function (e.g. Math.round(...))\n const fn = await this.evaluator.evaluateNode(callee, this.context)\n if (fn) {\n const { object: calleeObj } = callee\n const fnObject = await this.evaluator.evaluateNode(calleeObj, this.context)\n const argsEvaluated = await Promise.all(exprArgs.map((arg) => this.evaluator.evaluateNode(arg, this.context)))\n const args = argsEvaluated.flat()\n return fn.call(fnObject, ...args)\n }\n return null\n }\n\n private async evaluateIdentifier(expressionNode: CallExpression, callee: IdentifierExpression): Promise<any> {\n // Arguments is a reserved word in strict mode\n const { arguments: exprArgs } = expressionNode\n const { object: contextObject } = this.context\n\n const { name: fnName } = callee\n\n const functionInfo = this.evaluator.functions[fnName]\n if (functionInfo) {\n // The function is among the custom functions.\n return this.evaluateCustomIdentifier(expressionNode, fnName)\n }\n // identifier is a global object\n const globalFn = getGlobalObjectProperty(fnName, contextObject)\n if (globalFn !== null) {\n // global functions like String, Number, must be invoked passing node value as argument, not the node itself\n const contextArg = { ...this.context, evaluateToNode: false }\n const args = await Promise.all(exprArgs.map((arg) => this.evaluator.evaluateNode(arg, contextArg)))\n return globalFn(...args)\n }\n\n throw new SystemError('expression.undefinedFunction', { name: fnName })\n }\n\n private async evaluateCustomIdentifier(expressionNode: CallExpression, fnName: string): Promise<any> {\n // Arguments is a reserved word in strict mode\n const { arguments: exprArgs } = expressionNode\n const numArgs = exprArgs.length\n\n const expressionFunction: ExpressionFunction<C> = this.evaluator.functions[fnName]\n\n const { minArity, maxArity, evaluateArgsToNodes, executor } = expressionFunction\n\n if (numArgs < minArity)\n throw new SystemError('expression.functionHasTooFewArguments', { fnName, minArity, numArgs })\n if (maxArity !== undefined && maxArity >= 0 && numArgs > maxArity)\n throw new SystemError('expression.functionHasTooManyArguments', { fnName, maxArity, numArgs })\n\n // evaluate arguments\n const argsContext = { ...this.context, evaluateToNode: evaluateArgsToNodes }\n const args = await Promise.all(exprArgs.map((arg) => this.evaluator.evaluateNode(arg, argsContext)))\n\n // Currently there are no side effects from function evaluation so it's\n // safe to call the function even when we're just parsing the expression\n // to find all identifiers being used.\n return executor(this.context)(...args)\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AnyExpressionNode } from '../../node';
|
|
2
2
|
import { ExpressionParser } from '../../parser';
|
|
3
3
|
export declare class JavascriptExpressionParser implements ExpressionParser {
|
|
4
|
-
parse(expression: string):
|
|
4
|
+
parse(expression: string): AnyExpressionNode;
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../src/expression/javascript/parser/parser.ts"],"names":[],"mappings":";;;AAEA,iCAA6B;AAE7B;IACE,KAAK,CAAC,UAAkB;QACtB,OAAO,IAAA,WAAI,EAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../src/expression/javascript/parser/parser.ts"],"names":[],"mappings":";;;AAEA,iCAA6B;AAE7B;IACE,KAAK,CAAC,UAAkB;QACtB,OAAO,IAAA,WAAI,EAAC,UAAU,CAAsB,CAAA;IAC9C,CAAC;CACF","sourcesContent":["import { AnyExpressionNode } from '../../node'\nimport { ExpressionParser } from '../../parser'\nimport { jsep } from './jsep'\n\nexport class JavascriptExpressionParser implements ExpressionParser {\n parse(expression: string): AnyExpressionNode {\n return jsep(expression) as AnyExpressionNode\n }\n}\n"]}
|
|
@@ -17,22 +17,22 @@ export interface ExpressionNode<T extends ExpressionNodeType> {
|
|
|
17
17
|
type: T;
|
|
18
18
|
}
|
|
19
19
|
export interface ArrayExpression extends ExpressionNode<ExpressionNodeType.Array> {
|
|
20
|
-
elements: Array<
|
|
20
|
+
elements: Array<AnyExpressionNode>;
|
|
21
21
|
}
|
|
22
22
|
export interface BinaryExpression extends ExpressionNode<ExpressionNodeType.Binary> {
|
|
23
|
-
left:
|
|
24
|
-
right:
|
|
23
|
+
left: AnyExpressionNode;
|
|
24
|
+
right: AnyExpressionNode;
|
|
25
25
|
operator: string;
|
|
26
26
|
}
|
|
27
27
|
export interface CallExpression extends ExpressionNode<ExpressionNodeType.Call> {
|
|
28
|
-
arguments: Array<
|
|
29
|
-
callee:
|
|
28
|
+
arguments: Array<AnyExpressionNode>;
|
|
29
|
+
callee: AnyExpressionNode;
|
|
30
30
|
}
|
|
31
31
|
export type CompoundExpression = ExpressionNode<ExpressionNodeType.Compound>;
|
|
32
32
|
export interface ConditionalExpression extends ExpressionNode<ExpressionNodeType.Conditional> {
|
|
33
|
-
test:
|
|
34
|
-
consequent:
|
|
35
|
-
alternate:
|
|
33
|
+
test: AnyExpressionNode;
|
|
34
|
+
consequent: AnyExpressionNode;
|
|
35
|
+
alternate: AnyExpressionNode;
|
|
36
36
|
}
|
|
37
37
|
export interface IdentifierExpression extends ExpressionNode<ExpressionNodeType.Identifier> {
|
|
38
38
|
name: string;
|
|
@@ -43,19 +43,23 @@ export interface LiteralExpression extends ExpressionNode<ExpressionNodeType.Lit
|
|
|
43
43
|
}
|
|
44
44
|
export interface MemberExpression extends ExpressionNode<ExpressionNodeType.Member> {
|
|
45
45
|
computed: boolean;
|
|
46
|
-
object:
|
|
47
|
-
property:
|
|
46
|
+
object: AnyExpressionNode;
|
|
47
|
+
property: AnyExpressionNode;
|
|
48
48
|
optional?: boolean;
|
|
49
49
|
}
|
|
50
50
|
export interface SequenceExpression extends ExpressionNode<ExpressionNodeType.Sequence> {
|
|
51
|
-
expression:
|
|
51
|
+
expression: AnyExpressionNode;
|
|
52
52
|
}
|
|
53
53
|
export type ThisExpression = ExpressionNode<ExpressionNodeType.This>;
|
|
54
54
|
export interface UnaryExpression extends ExpressionNode<ExpressionNodeType.Unary> {
|
|
55
|
-
argument:
|
|
55
|
+
argument: AnyExpressionNode;
|
|
56
56
|
operator: string;
|
|
57
57
|
prefix: boolean;
|
|
58
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Union of all the expression node types: narrow it by `type` to get the specific node.
|
|
61
|
+
*/
|
|
62
|
+
export type AnyExpressionNode = ArrayExpression | BinaryExpression | CallExpression | CompoundExpression | ConditionalExpression | IdentifierExpression | LiteralExpression | MemberExpression | SequenceExpression | ThisExpression | UnaryExpression;
|
|
59
63
|
export interface ExpressionNodeEvaluatorConstructor<C extends ExpressionContext, N extends ExpressionNode<ExpressionNodeType>> {
|
|
60
64
|
new (evaluator: ExpressionEvaluator<C>, context: C): ExpressionNodeEvaluator<C, N>;
|
|
61
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/expression/node.ts"],"names":[],"mappings":";;;AAGA,IAAY,kBAYX;AAZD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,iDAA2B,CAAA;IAC3B,6CAAuB,CAAA;IACvB,2CAAqB,CAAA;IACrB,2DAAqC,CAAA;IACrC,+CAAyB,CAAA;IACzB,yCAAmB,CAAA;IACnB,iDAA2B,CAAA;IAC3B,qDAA+B,CAAA;IAC/B,6CAAuB,CAAA;IACvB,+CAAyB,CAAA;AAC3B,CAAC,EAZW,kBAAkB,aAAlB,kBAAkB,GAAlB,kBAAkB,QAY7B;
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/expression/node.ts"],"names":[],"mappings":";;;AAGA,IAAY,kBAYX;AAZD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,iDAA2B,CAAA;IAC3B,6CAAuB,CAAA;IACvB,2CAAqB,CAAA;IACrB,2DAAqC,CAAA;IACrC,+CAAyB,CAAA;IACzB,yCAAmB,CAAA;IACnB,iDAA2B,CAAA;IAC3B,qDAA+B,CAAA;IAC/B,6CAAuB,CAAA;IACvB,+CAAyB,CAAA;AAC3B,CAAC,EAZW,kBAAkB,aAAlB,kBAAkB,GAAlB,kBAAkB,QAY7B;AAsED;IAOE,YAAY,SAAiC,EAAE,OAAU;QACvD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;CAGF","sourcesContent":["import { ExpressionEvaluator } from './evaluator'\nimport { ExpressionContext } from './context'\n\nexport enum ExpressionNodeType {\n Array = 'ArrayExpression',\n Binary = 'BinaryExpression',\n Call = 'CallExpression',\n Compound = 'Compound',\n Conditional = 'ConditionalExpression',\n Identifier = 'Identifier',\n Literal = 'Literal',\n Member = 'MemberExpression',\n Sequence = 'SequenceExpression',\n This = 'ThisExpression',\n Unary = 'UnaryExpression',\n}\n\nexport interface ExpressionNode<T extends ExpressionNodeType> {\n type: T\n}\n\nexport interface ArrayExpression extends ExpressionNode<ExpressionNodeType.Array> {\n elements: Array<AnyExpressionNode>\n}\nexport interface BinaryExpression extends ExpressionNode<ExpressionNodeType.Binary> {\n left: AnyExpressionNode\n right: AnyExpressionNode\n operator: string\n}\nexport interface CallExpression extends ExpressionNode<ExpressionNodeType.Call> {\n arguments: Array<AnyExpressionNode>\n callee: AnyExpressionNode\n}\nexport type CompoundExpression = ExpressionNode<ExpressionNodeType.Compound>\nexport interface ConditionalExpression extends ExpressionNode<ExpressionNodeType.Conditional> {\n test: AnyExpressionNode\n consequent: AnyExpressionNode\n alternate: AnyExpressionNode\n}\nexport interface IdentifierExpression extends ExpressionNode<ExpressionNodeType.Identifier> {\n name: string\n}\nexport interface LiteralExpression extends ExpressionNode<ExpressionNodeType.Literal> {\n raw: string\n value: any\n}\nexport interface MemberExpression extends ExpressionNode<ExpressionNodeType.Member> {\n computed: boolean\n object: AnyExpressionNode\n property: AnyExpressionNode\n optional?: boolean\n}\nexport interface SequenceExpression extends ExpressionNode<ExpressionNodeType.Sequence> {\n expression: AnyExpressionNode\n}\nexport type ThisExpression = ExpressionNode<ExpressionNodeType.This>\nexport interface UnaryExpression extends ExpressionNode<ExpressionNodeType.Unary> {\n argument: AnyExpressionNode\n operator: string\n prefix: boolean\n}\n\n/**\n * Union of all the expression node types: narrow it by `type` to get the specific node.\n */\nexport type AnyExpressionNode =\n | ArrayExpression\n | BinaryExpression\n | CallExpression\n | CompoundExpression\n | ConditionalExpression\n | IdentifierExpression\n | LiteralExpression\n | MemberExpression\n | SequenceExpression\n | ThisExpression\n | UnaryExpression\n\nexport interface ExpressionNodeEvaluatorConstructor<\n C extends ExpressionContext,\n N extends ExpressionNode<ExpressionNodeType>,\n> {\n new (evaluator: ExpressionEvaluator<C>, context: C): ExpressionNodeEvaluator<C, N>\n}\n\nexport abstract class ExpressionNodeEvaluator<\n C extends ExpressionContext,\n N extends ExpressionNode<ExpressionNodeType>,\n> {\n readonly evaluator: ExpressionEvaluator<C>\n readonly context: C\n\n constructor(evaluator: ExpressionEvaluator<C>, context: C) {\n this.evaluator = evaluator\n this.context = context\n }\n\n abstract evaluate(expressionNode: N): Promise<any>\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export { DataQueryMode, DataQuerySummaries } from './dataQuery';
|
|
|
14
14
|
export type { DataQuery, DataQuerySummary, DataQuerySummaryProps } from './dataQuery';
|
|
15
15
|
export { SystemError } from './error';
|
|
16
16
|
export { ExpressionNodeType, ExpressionNodeEvaluator, ExpressionVariable, JavascriptExpressionEvaluator, JavascriptExpressionParser, } from './expression';
|
|
17
|
-
export type { ArrayExpression, BinaryExpression, CallExpression, CompoundExpression, ConditionalExpression, ExpressionContext, ExpressionEvaluator, ExpressionFunction, ExpressionFunctions, ExpressionNode, ExpressionNodeEvaluatorConstructor, MemberExpression, IdentifierExpression, LiteralExpression, SequenceExpression, ThisExpression, UnaryExpression, } from './expression';
|
|
17
|
+
export type { ArrayExpression, BinaryExpression, CallExpression, CompoundExpression, ConditionalExpression, ExpressionContext, ExpressionEvaluator, ExpressionFunction, ExpressionFunctions, AnyExpressionNode, ExpressionNode, ExpressionNodeEvaluatorConstructor, MemberExpression, IdentifierExpression, LiteralExpression, SequenceExpression, ThisExpression, UnaryExpression, } from './expression';
|
|
18
18
|
export { ExtraPropDataType, ExtraPropsDataGenerator } from './extraProp';
|
|
19
19
|
export type { ExtraPropDef, ExtraPropDefs } from './extraProp';
|
|
20
20
|
export { PointFactory, Points } from './geo';
|
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,2CAQqB;AAPnB,0HAAA,4BAA4B,OAAA;AAC5B,kHAAA,oBAAoB,OAAA;AACpB,2G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a,OAAA;AAAE,qHAAA,oBAAoB,OAAA;AAC5C,+DAAiF;AAAxE,8GAAA,aAAa,OAAA;AAAE,mHAAA,kBAAkB,OAAA;AAE1C,iCAegB;AAdd,+FAAA,MAAM,OAAA;AACN,oGAAA,WAAW,OAAA;AACX,8FAAA,KAAK,OAAA;AACL,kGAAA,SAAS,OAAA;AACT,sGAAA,aAAa,OAAA;AACb,gGAAA,OAAO,OAAA;AACP,gGAAA,OAAO,OAAA;AACP,iGAAA,QAAQ,OAAA;AACR,8FAAA,KAAK,OAAA;AACL,uGAAA,cAAc,OAAA;AACd,gGAAA,OAAO,OAAA;AACP,mGAAA,UAAU,OAAA;AACV,8FAAA,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 UniqueFileNamesGenerator,\n} from './dataExport'\n\nexport { DataQueryMode, DataQuerySummaries } from './dataQuery'\nexport type { DataQuery, DataQuerySummary, DataQuerySummaryProps } from './dataQuery'\n\nexport { SystemError } 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 ExpressionNode,\n ExpressionNodeEvaluatorConstructor,\n MemberExpression,\n IdentifierExpression,\n LiteralExpression,\n SequenceExpression,\n ThisExpression,\n UnaryExpression,\n} from './expression'\n\nexport { ExtraPropDataType, ExtraPropsDataGenerator } from './extraProp'\nexport type { ExtraPropDef, ExtraPropDefs } from './extraProp'\n\nexport { PointFactory, Points } from './geo'\nexport type { Point } from './geo'\n\nexport { JobBase, JobEventType, JobStatus } from './job'\nexport type { Job, JobContext, JobEvent, JobSerialized, JobTxClient } from './job'\n\nexport { LanguageCode, Languages, LanguagesISO639part2 } from './language'\nexport type { Labels } from './language'\n\nexport type { Logger } from './logger'\n\nexport type { Message } from './message'\nexport { MessageNotificationType, MessagePropsKey, MessageStatus, MessageTargetUserType, Messages } from './message'\n\nexport { NodeFactory, NodeKeys, NodeMetaKeys, Nodes, NodeValueFormatter, NodeValues } from './node'\nexport type {\n ArenaRecordNode,\n Node,\n NodeMeta,\n NodePointer,\n NodeRefData,\n NodeService,\n NodesMap,\n NodeValueCode,\n NodeValueCoordinate,\n NodeValueFile,\n NodeValueTaxon,\n} from './node'\n\nexport {\n NodeDefCountType,\n NodeDefType,\n NodeDefFactory,\n NodeDefs,\n NodeDefEntityRenderType,\n NodeDefFileType,\n NodeDefTextInputType,\n NodeDefTextRenderType,\n FormHeaderColor,\n} from './nodeDef'\n\nexport { NodeDefExpressionEvaluator, NodeDefExpressionValidator } from './nodeDefExpressionEvaluator'\nexport type { CategoryItemProvider, TaxonProvider } from './nodeDefExpressionEvaluator'\n\nexport type {\n NodeDef,\n NodeDefLayout,\n NodeDefMeta,\n NodeDefProps,\n NodeDefPropsWithLayout,\n NodeDefBoolean,\n NodeDefBooleanProps,\n NodeDefCode,\n NodeDefCodeLayout,\n NodeDefCodeProps,\n NodeDefCoordinate,\n NodeDefCoordinateProps,\n NodeDefDate,\n NodeDefDecimal,\n NodeDefDecimalProps,\n NodeDefEntity,\n NodeDefEntityChildPosition,\n NodeDefEntityLayout,\n NodeDefEntityProps,\n NodeDefPrintOrientation,\n NodeDefFile,\n NodeDefFileProps,\n NodeDefFormHeader,\n NodeDefFormHeaderProps,\n NodeDefInteger,\n NodeDefPropsAdvanced,\n NodeDefTaxon,\n NodeDefTaxonProps,\n NodeDefText,\n NodeDefTextProps,\n NodeDefTextLayout,\n NodeDefTime,\n NodeDefTimeProps,\n NodeDefExpression,\n NodeDefMap,\n NodeDefService,\n NodeDefValidations,\n} from './nodeDef'\n\nexport {\n NodePointers,\n RecordCloner,\n RecordFactory,\n RecordFixer,\n Records,\n RECORD_STEP_DEFAULT,\n RecordExpressionEvaluator,\n RecordNodesUpdater,\n RecordPrettyPrinter,\n RecordUpdater,\n RecordUpdateResult,\n RecordValidator,\n RecordValidations,\n} from './record'\nexport type {\n AttributeValidatorParams,\n AttributesValidatorParams,\n NodeCreateParams,\n NodesUpdateParams,\n ArenaRecord,\n Record,\n RecordExpressionContext,\n RecordExpressionEvaluationContext,\n RecordService,\n RecordUpdateOptions,\n RecordValidatorParams,\n SortedAttributesValidatorParams,\n} from './record'\n\nexport { ServiceRegistry, ServiceType } from './registry'\nexport type { ServiceTypeMap } from './registry'\n\nexport { DEFAULT_SRS, DEFAULT_SRS_INDEX, SRSFactory } from './srs'\nexport type { SRS, SRSIndex } from './srs'\n\nexport {\n NodeDefsFixer,\n SurveyDocImages,\n SurveyDocImageFactory,\n SurveyDocPlace,\n SurveyDependencyType,\n SurveyFactory,\n SurveyFileFactory,\n SurveyFileType,\n SurveyRefDataFactory,\n SurveySecurityProp,\n Surveys,\n surveyDocImagePropKeys,\n surveySecurityDefaults,\n defaultCycle,\n} from './survey'\nexport type {\n Survey,\n SurveyCycle,\n SurveyDependency,\n SurveyDependencyGraph,\n SurveyDocImage,\n SurveyDocImageFactoryParams,\n SurveyDocImageProps,\n SurveyFile,\n SurveyFileFactoryParams,\n SurveyFileProps,\n SurveyProps,\n SurveyRefData,\n SurveySecurity,\n SurveyService,\n} from './survey'\n\nexport { Taxa, Taxonomies, TaxonomyFactory, TaxonFactory, TaxonGenerator, VernacularNameFactory } from './taxonomy'\nexport type {\n VernacularNameParams,\n TaxonomyFactoryParams,\n TaxonFactoryParams,\n Taxonomy,\n TaxonomyService,\n VernacularNameProps,\n VernacularName,\n TaxonProps,\n Taxon,\n TaxonomyProps,\n TaxonService,\n} from './taxonomy'\n\nexport { SurveyBuilder, SurveyObjectBuilders } from './tests/builder/surveyBuilder'\nexport { RecordBuilder, RecordNodeBuilders } from './tests/builder/recordBuilder'\n\nexport {\n Arrays,\n DateFormats,\n Dates,\n FileNames,\n FileProcessor,\n Numbers,\n Objects,\n Promises,\n Queue,\n RetryProcessor,\n Strings,\n UnitOfTime,\n UUIDs,\n Versions,\n} from './utils'\n\nexport type { FileProcessorConstructorArgs, MutationOptions, ParsedVersion } from './utils'\n\nexport {\n FieldValidators,\n ValidationFactory,\n ValidationResultFactory,\n ValidationResults,\n Validations,\n ValidationSeverity,\n Validator,\n ValidatorErrorKeys,\n} from './validation'\nexport type {\n DissocFieldValidationOptions,\n FieldValidator,\n Validation,\n ValidationFields,\n ValidationResult,\n ValidationCounts,\n} from './validation'\n"]}
|
|
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,2CAQqB;AAPnB,0HAAA,4BAA4B,OAAA;AAC5B,kHAAA,oBAAoB,OAAA;AACpB,2GAAA,aAAa,OAAA;AACb,iHAAA,mBAAmB,OAAA;AACnB,0HAAA,4BAA4B,OAAA;AAC5B,oHAAA,sBAAsB,OAAA;AACtB,sHAAA,wBAAwB,OAAA;AAG1B,yCAA+D;AAAtD,0GAAA,aAAa,OAAA;AAAE,+GAAA,kBAAkB,OAAA;AAG1C,iCAAqC;AAA5B,oGAAA,WAAW,OAAA;AAEpB,2CAMqB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OAAO,OAAA;AACP,gGAAA,OAAO,OAAA;AACP,iGAAA,QAAQ,OAAA;AACR,8FAAA,KAAK,OAAA;AACL,uGAAA,cAAc,OAAA;AACd,gGAAA,OAAO,OAAA;AACP,mGAAA,UAAU,OAAA;AACV,8FAAA,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 UniqueFileNamesGenerator,\n} from './dataExport'\n\nexport { DataQueryMode, DataQuerySummaries } from './dataQuery'\nexport type { DataQuery, DataQuerySummary, DataQuerySummaryProps } from './dataQuery'\n\nexport { SystemError } from './error'\n\nexport {\n ExpressionNodeType,\n ExpressionNodeEvaluator,\n ExpressionVariable,\n JavascriptExpressionEvaluator,\n JavascriptExpressionParser,\n} from './expression'\nexport type {\n ArrayExpression,\n BinaryExpression,\n CallExpression,\n CompoundExpression,\n ConditionalExpression,\n ExpressionContext,\n ExpressionEvaluator,\n ExpressionFunction,\n ExpressionFunctions,\n AnyExpressionNode,\n ExpressionNode,\n ExpressionNodeEvaluatorConstructor,\n MemberExpression,\n IdentifierExpression,\n LiteralExpression,\n SequenceExpression,\n ThisExpression,\n UnaryExpression,\n} from './expression'\n\nexport { ExtraPropDataType, ExtraPropsDataGenerator } from './extraProp'\nexport type { ExtraPropDef, ExtraPropDefs } from './extraProp'\n\nexport { PointFactory, Points } from './geo'\nexport type { Point } from './geo'\n\nexport { JobBase, JobEventType, JobStatus } from './job'\nexport type { Job, JobContext, JobEvent, JobSerialized, JobTxClient } from './job'\n\nexport { LanguageCode, Languages, LanguagesISO639part2 } from './language'\nexport type { Labels } from './language'\n\nexport type { Logger } from './logger'\n\nexport type { Message } from './message'\nexport { MessageNotificationType, MessagePropsKey, MessageStatus, MessageTargetUserType, Messages } from './message'\n\nexport { NodeFactory, NodeKeys, NodeMetaKeys, Nodes, NodeValueFormatter, NodeValues } from './node'\nexport type {\n ArenaRecordNode,\n Node,\n NodeMeta,\n NodePointer,\n NodeRefData,\n NodeService,\n NodesMap,\n NodeValueCode,\n NodeValueCoordinate,\n NodeValueFile,\n NodeValueTaxon,\n} from './node'\n\nexport {\n NodeDefCountType,\n NodeDefType,\n NodeDefFactory,\n NodeDefs,\n NodeDefEntityRenderType,\n NodeDefFileType,\n NodeDefTextInputType,\n NodeDefTextRenderType,\n FormHeaderColor,\n} from './nodeDef'\n\nexport { NodeDefExpressionEvaluator, NodeDefExpressionValidator } from './nodeDefExpressionEvaluator'\nexport type { CategoryItemProvider, TaxonProvider } from './nodeDefExpressionEvaluator'\n\nexport type {\n NodeDef,\n NodeDefLayout,\n NodeDefMeta,\n NodeDefProps,\n NodeDefPropsWithLayout,\n NodeDefBoolean,\n NodeDefBooleanProps,\n NodeDefCode,\n NodeDefCodeLayout,\n NodeDefCodeProps,\n NodeDefCoordinate,\n NodeDefCoordinateProps,\n NodeDefDate,\n NodeDefDecimal,\n NodeDefDecimalProps,\n NodeDefEntity,\n NodeDefEntityChildPosition,\n NodeDefEntityLayout,\n NodeDefEntityProps,\n NodeDefPrintOrientation,\n NodeDefFile,\n NodeDefFileProps,\n NodeDefFormHeader,\n NodeDefFormHeaderProps,\n NodeDefInteger,\n NodeDefPropsAdvanced,\n NodeDefTaxon,\n NodeDefTaxonProps,\n NodeDefText,\n NodeDefTextProps,\n NodeDefTextLayout,\n NodeDefTime,\n NodeDefTimeProps,\n NodeDefExpression,\n NodeDefMap,\n NodeDefService,\n NodeDefValidations,\n} from './nodeDef'\n\nexport {\n NodePointers,\n RecordCloner,\n RecordFactory,\n RecordFixer,\n Records,\n RECORD_STEP_DEFAULT,\n RecordExpressionEvaluator,\n RecordNodesUpdater,\n RecordPrettyPrinter,\n RecordUpdater,\n RecordUpdateResult,\n RecordValidator,\n RecordValidations,\n} from './record'\nexport type {\n AttributeValidatorParams,\n AttributesValidatorParams,\n NodeCreateParams,\n NodesUpdateParams,\n ArenaRecord,\n Record,\n RecordExpressionContext,\n RecordExpressionEvaluationContext,\n RecordService,\n RecordUpdateOptions,\n RecordValidatorParams,\n SortedAttributesValidatorParams,\n} from './record'\n\nexport { ServiceRegistry, ServiceType } from './registry'\nexport type { ServiceTypeMap } from './registry'\n\nexport { DEFAULT_SRS, DEFAULT_SRS_INDEX, SRSFactory } from './srs'\nexport type { SRS, SRSIndex } from './srs'\n\nexport {\n NodeDefsFixer,\n SurveyDocImages,\n SurveyDocImageFactory,\n SurveyDocPlace,\n SurveyDependencyType,\n SurveyFactory,\n SurveyFileFactory,\n SurveyFileType,\n SurveyRefDataFactory,\n SurveySecurityProp,\n Surveys,\n surveyDocImagePropKeys,\n surveySecurityDefaults,\n defaultCycle,\n} from './survey'\nexport type {\n Survey,\n SurveyCycle,\n SurveyDependency,\n SurveyDependencyGraph,\n SurveyDocImage,\n SurveyDocImageFactoryParams,\n SurveyDocImageProps,\n SurveyFile,\n SurveyFileFactoryParams,\n SurveyFileProps,\n SurveyProps,\n SurveyRefData,\n SurveySecurity,\n SurveyService,\n} from './survey'\n\nexport { Taxa, Taxonomies, TaxonomyFactory, TaxonFactory, TaxonGenerator, VernacularNameFactory } from './taxonomy'\nexport type {\n VernacularNameParams,\n TaxonomyFactoryParams,\n TaxonFactoryParams,\n Taxonomy,\n TaxonomyService,\n VernacularNameProps,\n VernacularName,\n TaxonProps,\n Taxon,\n TaxonomyProps,\n TaxonService,\n} from './taxonomy'\n\nexport { SurveyBuilder, SurveyObjectBuilders } from './tests/builder/surveyBuilder'\nexport { RecordBuilder, RecordNodeBuilders } from './tests/builder/recordBuilder'\n\nexport {\n Arrays,\n DateFormats,\n Dates,\n FileNames,\n FileProcessor,\n Numbers,\n Objects,\n Promises,\n Queue,\n RetryProcessor,\n Strings,\n UnitOfTime,\n UUIDs,\n Versions,\n} from './utils'\n\nexport type { FileProcessorConstructorArgs, MutationOptions, ParsedVersion } from './utils'\n\nexport {\n FieldValidators,\n ValidationFactory,\n ValidationResultFactory,\n ValidationResults,\n Validations,\n ValidationSeverity,\n Validator,\n ValidatorErrorKeys,\n} from './validation'\nexport type {\n DissocFieldValidationOptions,\n FieldValidator,\n Validation,\n ValidationFields,\n ValidationResult,\n ValidationCounts,\n} from './validation'\n"]}
|
|
@@ -16,12 +16,13 @@ const isReferencedThroughMember = (params) => {
|
|
|
16
16
|
if (Array.isArray(expressionNode)) {
|
|
17
17
|
return expressionNode.some((item) => isReferencedThroughMember({ expressionNode: item, name, inMemberProperty }));
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
// parsed expression nodes (or their array or object properties)
|
|
20
|
+
const node = expressionNode;
|
|
21
|
+
if (node.type === expression_1.ExpressionNodeType.Identifier) {
|
|
22
|
+
return inMemberProperty && node.name === name;
|
|
22
23
|
}
|
|
23
|
-
if (type === expression_1.ExpressionNodeType.Member) {
|
|
24
|
-
const { object, property } =
|
|
24
|
+
if (node.type === expression_1.ExpressionNodeType.Member) {
|
|
25
|
+
const { object, property } = node;
|
|
25
26
|
return (isReferencedThroughMember({ expressionNode: object, name, inMemberProperty }) ||
|
|
26
27
|
isReferencedThroughMember({ expressionNode: property, name, inMemberProperty: true }));
|
|
27
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeDefSelfReferences.js","sourceRoot":"","sources":["../../../src/record/_records/nodeDefSelfReferences.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"nodeDefSelfReferences.js","sourceRoot":"","sources":["../../../src/record/_records/nodeDefSelfReferences.ts"],"names":[],"mappings":";;;AAAA,iDAAwE;AACxE,qEAAuE;AACvE,2CAA4E;AAC5E,gDAA0D;AAE1D;;;GAGG;AACH,MAAM,yBAAyB,GAAG,CAAC,MAIlC,EAAW,EAAE;IACZ,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAAA;IACzD,IAAI,CAAC,cAAc,IAAI,OAAO,cAAc,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IACvE,IAAI,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,C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nH,CAAC;eAAO,CAAC;QACP,sCAAsC;QACtC,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG,CAAC,MAG7B,EAAW,EAAE;IACZ,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,MAAM,CAAA;IAC1C,uGAAuG;IACvG,IAAI,cAAc,KAAK,6BAAoB,CAAC,WAAW;QAAE,OAAO,KAAK,CAAA;IACrE,MAAM,IAAI,GAAG,kBAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IACtC,OAAO,kBAAQ,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC,KAAK,CACtD,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,EAAE,CAC1B,8BAA8B,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QACpD,8BAA8B,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAChE,CAAA;AACH,CAAC,CAAA;AAEY,QAAA,qBAAqB,GAAG;IACnC,oBAAoB;CACrB,CAAA","sourcesContent":["import { AnyExpressionNode, ExpressionNodeType } from '../../expression'\nimport { parseExpression } from '../../expression/javascript/evaluator'\nimport { NodeDef, NodeDefProps, NodeDefs, NodeDefType } from '../../nodeDef'\nimport { SurveyDependencyType } from '../../survey/survey'\n\n/**\n * True if the identifier is used as (or inside) the property of a member expression (e.g. \"dbh\" in\n * \"parent(tree).tree.dbh\" or in \"tree[dbh > 10]\"): there it can refer to nodes outside the context entity.\n */\nconst isReferencedThroughMember = (params: {\n expressionNode: unknown\n name: string\n inMemberProperty: boolean\n}): boolean => {\n const { expressionNode, name, inMemberProperty } = params\n if (!expressionNode || typeof expressionNode !== 'object') return false\n if (Array.isArray(expressionNode)) {\n return expressionNode.some((item) => isReferencedThroughMember({ expressionNode: item, name, inMemberProperty }))\n }\n // parsed expression nodes (or their array or object properties)\n const node = expressionNode as AnyExpressionNode\n if (node.type === ExpressionNodeType.Identifier) {\n return inMemberProperty && node.name === name\n }\n if (node.type === ExpressionNodeType.Member) {\n const { object, property } = node\n return (\n isReferencedThroughMember({ expressionNode: object, name, inMemberProperty }) ||\n isReferencedThroughMember({ expressionNode: property, name, inMemberProperty: true })\n )\n }\n return Object.values(expressionNode).some((child) =>\n isReferencedThroughMember({ expressionNode: child, name, inMemberProperty })\n )\n}\n\nconst isExpressionSelfReferenceLocal = (params: { expression: string | undefined; name: string }): boolean => {\n const { expression, name } = params\n if (!expression) return true\n try {\n return !isReferencedThroughMember({ expressionNode: parseExpression(expression), name, inMemberProperty: false })\n } catch {\n // invalid expression: be conservative\n return false\n }\n}\n\n/**\n * Returns true if the node def references itself in its expressions of the specified dependency type only\n * as a plain identifier (e.g. \"dbh > 0\" in a validation of \"dbh\"): such a reference is resolved among the\n * children of the node's parent entity, so only the node and its siblings depend on it, not every node with\n * the same node def in the record.\n */\nconst isSelfReferenceLocal = (params: {\n nodeDef: NodeDef<NodeDefType, NodeDefProps>\n dependencyType: SurveyDependencyType\n}): boolean => {\n const { nodeDef, dependencyType } = params\n // self references by plain identifier are allowed only in validation expressions (see dependencies.ts)\n if (dependencyType !== SurveyDependencyType.validations) return false\n const name = NodeDefs.getName(nodeDef)\n return NodeDefs.getValidationsExpressions(nodeDef).every(\n ({ expression, applyIf }) =>\n isExpressionSelfReferenceLocal({ expression, name }) &&\n isExpressionSelfReferenceLocal({ expression: applyIf, name })\n )\n}\n\nexport const NodeDefSelfReferences = {\n isSelfReferenceLocal,\n}\n"]}
|