@rytass/bpm-core-nestjs-module 0.18.1 → 0.20.0
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/CHANGELOG.md +52 -0
- package/package.json +3 -2
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
- package/src/lib/attachment/attachment.service.d.ts +23 -1
- package/src/lib/attachment/attachment.service.js +111 -24
- package/src/lib/attachment/attachment.service.js.map +1 -1
- package/src/lib/bpm/bpm-root-options.d.ts +13 -0
- package/src/lib/bpm/bpm-root-options.js.map +1 -1
- package/src/lib/bpm/bpm-root.module.d.ts +12 -0
- package/src/lib/bpm/bpm-root.module.js +5 -0
- package/src/lib/bpm/bpm-root.module.js.map +1 -1
- package/src/lib/condition/adapters/cel-legacy.adapter.d.ts +62 -0
- package/src/lib/condition/adapters/cel-legacy.adapter.js +141 -0
- package/src/lib/condition/adapters/cel-legacy.adapter.js.map +1 -0
- package/src/lib/condition/adapters/cel-v2.adapter.d.ts +76 -0
- package/src/lib/condition/adapters/cel-v2.adapter.js +371 -0
- package/src/lib/condition/adapters/cel-v2.adapter.js.map +1 -0
- package/src/lib/condition/condition.service.d.ts +90 -5
- package/src/lib/condition/condition.service.js +287 -71
- package/src/lib/condition/condition.service.js.map +1 -1
- package/src/lib/condition/expression-ast.d.ts +176 -0
- package/src/lib/condition/expression-ast.js +1254 -0
- package/src/lib/condition/expression-ast.js.map +1 -0
- package/src/lib/condition/expression-budget.d.ts +44 -0
- package/src/lib/condition/expression-budget.js +61 -0
- package/src/lib/condition/expression-budget.js.map +1 -0
- package/src/lib/condition/expression-dialect.d.ts +29 -0
- package/src/lib/condition/expression-dialect.js +44 -0
- package/src/lib/condition/expression-dialect.js.map +1 -0
- package/src/lib/condition/expression-differential.corpus.d.ts +34 -0
- package/src/lib/condition/expression-differential.corpus.js +995 -0
- package/src/lib/condition/expression-differential.corpus.js.map +1 -0
- package/src/lib/condition/expression-differential.d.ts +33 -0
- package/src/lib/condition/expression-differential.js +48 -0
- package/src/lib/condition/expression-differential.js.map +1 -0
- package/src/lib/condition/expression-engine-failure.d.ts +15 -0
- package/src/lib/condition/expression-engine-failure.js +22 -0
- package/src/lib/condition/expression-engine-failure.js.map +1 -0
- package/src/lib/condition/expression-errors.d.ts +40 -0
- package/src/lib/condition/expression-errors.js +105 -0
- package/src/lib/condition/expression-errors.js.map +1 -0
- package/src/lib/condition/expression-function-invocation.d.ts +50 -0
- package/src/lib/condition/expression-function-invocation.js +290 -0
- package/src/lib/condition/expression-function-invocation.js.map +1 -0
- package/src/lib/condition/expression-result.walker.d.ts +18 -0
- package/src/lib/condition/expression-result.walker.js +152 -0
- package/src/lib/condition/expression-result.walker.js.map +1 -0
- package/src/lib/condition/expression-runtime.d.ts +70 -0
- package/src/lib/condition/expression-runtime.js +134 -0
- package/src/lib/condition/expression-runtime.js.map +1 -0
- package/src/lib/condition/index.d.ts +4 -0
- package/src/lib/condition/index.js +8 -0
- package/src/lib/condition/index.js.map +1 -1
- package/src/lib/delegation/delegation-rule.entity.d.ts +7 -0
- package/src/lib/delegation/delegation-rule.entity.js +10 -0
- package/src/lib/delegation/delegation-rule.entity.js.map +1 -1
- package/src/lib/delegation/delegation.service.d.ts +7 -1
- package/src/lib/delegation/delegation.service.js +22 -5
- package/src/lib/delegation/delegation.service.js.map +1 -1
- package/src/lib/delegation/dto/delegation-rule.input.d.ts +2 -0
- package/src/lib/delegation/dto/delegation-rule.input.js +10 -0
- package/src/lib/delegation/dto/delegation-rule.input.js.map +1 -1
- package/src/lib/expression-function/expression-function.built-ins.d.ts +9 -0
- package/src/lib/expression-function/expression-function.built-ins.js +117 -0
- package/src/lib/expression-function/expression-function.built-ins.js.map +1 -0
- package/src/lib/expression-function/expression-function.module.d.ts +19 -0
- package/src/lib/expression-function/expression-function.module.js +34 -0
- package/src/lib/expression-function/expression-function.module.js.map +1 -0
- package/src/lib/expression-function/expression-function.provider.d.ts +17 -0
- package/src/lib/expression-function/expression-function.provider.js +39 -0
- package/src/lib/expression-function/expression-function.provider.js.map +1 -0
- package/src/lib/expression-function/expression-function.registry.d.ts +36 -0
- package/src/lib/expression-function/expression-function.registry.js +231 -0
- package/src/lib/expression-function/expression-function.registry.js.map +1 -0
- package/src/lib/expression-function/expression-function.types.d.ts +30 -0
- package/src/lib/expression-function/expression-function.types.js +8 -0
- package/src/lib/expression-function/expression-function.types.js.map +1 -0
- package/src/lib/expression-function/index.d.ts +5 -0
- package/src/lib/expression-function/index.js +9 -0
- package/src/lib/expression-function/index.js.map +1 -0
- package/src/lib/form/form-schema.validator.js +53 -6
- package/src/lib/form/form-schema.validator.js.map +1 -1
- package/src/lib/form-data-source/form-data-source-value-resolver.service.d.ts +12 -1
- package/src/lib/form-data-source/form-data-source-value-resolver.service.js +45 -26
- package/src/lib/form-data-source/form-data-source-value-resolver.service.js.map +1 -1
- package/src/lib/form-data-source/form-data-source.expression.d.ts +95 -0
- package/src/lib/form-data-source/form-data-source.expression.js +267 -0
- package/src/lib/form-data-source/form-data-source.expression.js.map +1 -0
- package/src/lib/form-data-source/form-data-source.module.js +4 -0
- package/src/lib/form-data-source/form-data-source.module.js.map +1 -1
- package/src/lib/form-data-source/form-data-source.service.d.ts +22 -3
- package/src/lib/form-data-source/form-data-source.service.js +78 -18
- package/src/lib/form-data-source/form-data-source.service.js.map +1 -1
- package/src/lib/form-data-source/form-data-source.validation.d.ts +47 -4
- package/src/lib/form-data-source/form-data-source.validation.js +151 -23
- package/src/lib/form-data-source/form-data-source.validation.js.map +1 -1
- package/src/lib/migrations/0000000030000-delegation-scope-condition-dialect.d.ts +22 -0
- package/src/lib/migrations/0000000030000-delegation-scope-condition-dialect.js +76 -0
- package/src/lib/migrations/0000000030000-delegation-scope-condition-dialect.js.map +1 -0
- package/src/lib/migrations/index.d.ts +1 -0
- package/src/lib/migrations/index.js +3 -0
- package/src/lib/migrations/index.js.map +1 -1
- package/src/lib/notification/notification.service.d.ts +1 -1
- package/src/lib/notification/notification.service.js +7 -3
- package/src/lib/notification/notification.service.js.map +1 -1
- package/src/lib/template/dto/expression-designer.dto.d.ts +107 -0
- package/src/lib/template/dto/expression-designer.dto.js +415 -0
- package/src/lib/template/dto/expression-designer.dto.js.map +1 -0
- package/src/lib/template/expression-designer.queries.d.ts +16 -0
- package/src/lib/template/expression-designer.queries.js +66 -0
- package/src/lib/template/expression-designer.queries.js.map +1 -0
- package/src/lib/template/expression-designer.service.d.ts +72 -0
- package/src/lib/template/expression-designer.service.js +543 -0
- package/src/lib/template/expression-designer.service.js.map +1 -0
- package/src/lib/template/index.d.ts +2 -0
- package/src/lib/template/index.js +2 -0
- package/src/lib/template/index.js.map +1 -1
- package/src/lib/template/template.module.js +4 -0
- package/src/lib/template/template.module.js.map +1 -1
- package/src/lib/template/template.service.d.ts +37 -1
- package/src/lib/template/template.service.js +317 -29
- package/src/lib/template/template.service.js.map +1 -1
- package/src/lib/template/workflow-definition.validator.d.ts +7 -0
- package/src/lib/template/workflow-definition.validator.js +26 -2
- package/src/lib/template/workflow-definition.validator.js.map +1 -1
- package/src/lib/workflow-engine/time-budget.d.ts +13 -0
- package/src/lib/workflow-engine/time-budget.js +58 -0
- package/src/lib/workflow-engine/time-budget.js.map +1 -0
- package/src/lib/workflow-engine/workflow-engine.service.d.ts +24 -0
- package/src/lib/workflow-engine/workflow-engine.service.js +249 -65
- package/src/lib/workflow-engine/workflow-engine.service.js.map +1 -1
- package/src/lib/workflow-engine/workflow-service-task-dispatcher.token.js +4 -0
- package/src/lib/workflow-engine/workflow-service-task-dispatcher.token.js.map +1 -1
- package/src/lib/workflow-webhook/workflow-webhook-delivery.service.d.ts +3 -1
- package/src/lib/workflow-webhook/workflow-webhook-delivery.service.js +11 -2
- package/src/lib/workflow-webhook/workflow-webhook-delivery.service.js.map +1 -1
- package/src/lib/workflow-webhook/workflow-webhook-enqueue.d.ts +8 -1
- package/src/lib/workflow-webhook/workflow-webhook-enqueue.js +70 -27
- package/src/lib/workflow-webhook/workflow-webhook-enqueue.js.map +1 -1
- package/src/lib/workflow-webhook/workflow-webhook-expression.d.ts +57 -0
- package/src/lib/workflow-webhook/workflow-webhook-expression.js +123 -0
- package/src/lib/workflow-webhook/workflow-webhook-expression.js.map +1 -0
- package/src/lib/workflow-webhook/workflow-webhook.module.js +4 -0
- package/src/lib/workflow-webhook/workflow-webhook.module.js.map +1 -1
- package/src/lib/workflow-webhook/workflow-webhook.validator.d.ts +7 -0
- package/src/lib/workflow-webhook/workflow-webhook.validator.js +29 -6
- package/src/lib/workflow-webhook/workflow-webhook.validator.js.map +1 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.celLegacyAdapter = exports.createCelLegacyAdapter = exports.readCelLegacyFunctions = void 0;
|
|
4
|
+
exports.loadCelEngine = loadCelEngine;
|
|
5
|
+
exports.parseCelLegacy = parseCelLegacy;
|
|
6
|
+
const expression_function_registry_1 = require("../../expression-function/expression-function.registry");
|
|
7
|
+
const expression_engine_failure_1 = require("../expression-engine-failure");
|
|
8
|
+
const expression_function_invocation_1 = require("../expression-function-invocation");
|
|
9
|
+
let celEngine = null;
|
|
10
|
+
/**
|
|
11
|
+
* Loads `cel-js` on first use rather than when this module is imported.
|
|
12
|
+
*
|
|
13
|
+
* `cel-js` is ESM-only and its `chevrotain` dependency ships an exports map
|
|
14
|
+
* that `jest-resolve` cannot follow. While the import sat at the top of this
|
|
15
|
+
* file, the package root pulled it in through
|
|
16
|
+
* `index → bpm-root → delegation → condition`, so *any* consumer test that
|
|
17
|
+
* imported anything from `@rytass/bpm-core-nestjs-module` failed to load with
|
|
18
|
+
* `Cannot find module 'chevrotain'` — pointing deep into `node_modules`, far
|
|
19
|
+
* from the code under test. Hosts had to stub `cel-js` before they could write
|
|
20
|
+
* a single test.
|
|
21
|
+
*
|
|
22
|
+
* Deferring the load means a host that never evaluates a CEL expression never
|
|
23
|
+
* resolves the package at all. `require` (not `await import`) keeps every
|
|
24
|
+
* caller in this file synchronous.
|
|
25
|
+
*
|
|
26
|
+
* The engine is loaded before a budget starts, so an interrupt can never land
|
|
27
|
+
* halfway through loading a module.
|
|
28
|
+
*/
|
|
29
|
+
function loadCelEngine() {
|
|
30
|
+
if (celEngine === null) {
|
|
31
|
+
try {
|
|
32
|
+
celEngine = require('cel-js');
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
// Deferring the load also defers this failure: it used to surface at
|
|
36
|
+
// boot as a bare ERR_REQUIRE_ESM, and would now surface as a 500 on
|
|
37
|
+
// whichever request first evaluated a condition. Name the cause where it
|
|
38
|
+
// is thrown.
|
|
39
|
+
if (isRequireEsmError(error)) {
|
|
40
|
+
throw new Error(`[@rytass/bpm-core-nestjs-module] This Node version cannot require the ESM-only 'cel-js'. BPM needs Node >=20.19 or >=22.12 to evaluate CEL conditions. Original error: ${error instanceof Error ? error.message : String(error)}`);
|
|
41
|
+
}
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return celEngine;
|
|
46
|
+
}
|
|
47
|
+
function isRequireEsmError(error) {
|
|
48
|
+
return (typeof error === 'object' &&
|
|
49
|
+
error !== null &&
|
|
50
|
+
'code' in error &&
|
|
51
|
+
error.code === 'ERR_REQUIRE_ESM');
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Parses with `cel-js`. Returns `null` when the expression does not parse.
|
|
55
|
+
*
|
|
56
|
+
* `cel-js` can throw instead of reporting failure: a deeply nested expression
|
|
57
|
+
* (about 200 levels, still under the length limit) overflows the parser's stack
|
|
58
|
+
* with a bare `RangeError`. That is a syntax refusal, not a crash, so it maps to
|
|
59
|
+
* `null`. The engine is loaded outside the `try`: a failure to load it is a
|
|
60
|
+
* configuration error and must not be reported as a bad expression.
|
|
61
|
+
*/
|
|
62
|
+
function parseCelLegacy(expression) {
|
|
63
|
+
const engine = loadCelEngine();
|
|
64
|
+
let parseResult;
|
|
65
|
+
try {
|
|
66
|
+
parseResult = engine.parse(expression);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return parseResult.isSuccess ? { native: parseResult.cst } : null;
|
|
72
|
+
}
|
|
73
|
+
const isCstNode = (value) => typeof value === 'object' &&
|
|
74
|
+
value !== null &&
|
|
75
|
+
typeof value.name === 'string' &&
|
|
76
|
+
typeof value.children === 'object' &&
|
|
77
|
+
value.children !== null;
|
|
78
|
+
const readTokenImage = (token) => typeof token === 'object' &&
|
|
79
|
+
token !== null &&
|
|
80
|
+
typeof token.image === 'string'
|
|
81
|
+
? token.image
|
|
82
|
+
: null;
|
|
83
|
+
/**
|
|
84
|
+
* Names of the global functions a `cel-js` CST calls: its `macrosExpression`
|
|
85
|
+
* nodes, which is where `cel-js` looks a global call up in the function table.
|
|
86
|
+
* Anything that is not a CST node yields nothing, so the jest shim's stand-in
|
|
87
|
+
* CST simply has no calls.
|
|
88
|
+
*/
|
|
89
|
+
const readCalledFunctionNames = (node) => {
|
|
90
|
+
if (!isCstNode(node)) {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
const identifier = node.name === 'macrosExpression'
|
|
94
|
+
? readTokenImage(node.children.Identifier?.[0])
|
|
95
|
+
: null;
|
|
96
|
+
return [
|
|
97
|
+
...(identifier === null ? [] : [identifier]),
|
|
98
|
+
...Object.values(node.children).flatMap((children) => children.flatMap(readCalledFunctionNames)),
|
|
99
|
+
];
|
|
100
|
+
};
|
|
101
|
+
const celLegacyFunctionTables = new WeakMap();
|
|
102
|
+
/**
|
|
103
|
+
* The function table handed to `cel-js` for a registry, built once: every
|
|
104
|
+
* function the registry lists, wrapped for cel-legacy. Verified on the real
|
|
105
|
+
* engine (2026-11-07): `cel-js` 0.8.2 accepts the table and calls it.
|
|
106
|
+
*
|
|
107
|
+
* Exported so `ConditionService.prepareEngine` can build it before a budget
|
|
108
|
+
* starts; otherwise the first evaluation builds it inside its budget.
|
|
109
|
+
*/
|
|
110
|
+
const readCelLegacyFunctions = (registry) => {
|
|
111
|
+
const cached = celLegacyFunctionTables.get(registry);
|
|
112
|
+
if (cached) {
|
|
113
|
+
return cached;
|
|
114
|
+
}
|
|
115
|
+
const functions = Object.freeze(Object.fromEntries((0, expression_function_invocation_1.readExpressionFunctionTable)(registry).functions.map((fn) => [
|
|
116
|
+
fn.name,
|
|
117
|
+
(0, expression_function_invocation_1.createExpressionFunctionInvoker)(fn, 'cel-legacy'),
|
|
118
|
+
])));
|
|
119
|
+
celLegacyFunctionTables.set(registry, functions);
|
|
120
|
+
return functions;
|
|
121
|
+
};
|
|
122
|
+
exports.readCelLegacyFunctions = readCelLegacyFunctions;
|
|
123
|
+
/**
|
|
124
|
+
* The cel-legacy adapter for a registry. A host function the registry no
|
|
125
|
+
* longer has fails the evaluation with `EXPRESSION_FUNCTION_FAILED` before the
|
|
126
|
+
* engine runs; any other unknown name keeps `cel-js`'s own error.
|
|
127
|
+
*/
|
|
128
|
+
const createCelLegacyAdapter = (registry) => ({
|
|
129
|
+
compile: parseCelLegacy,
|
|
130
|
+
evaluate: (handle, roots) => {
|
|
131
|
+
if ((0, expression_function_invocation_1.callsUnavailableFunction)(readCalledFunctionNames(handle.native), (0, expression_function_invocation_1.readExpressionFunctionTable)(registry))) {
|
|
132
|
+
throw new expression_engine_failure_1.ExpressionEngineFailure('EXPRESSION_FUNCTION_FAILED');
|
|
133
|
+
}
|
|
134
|
+
const functions = (0, exports.readCelLegacyFunctions)(registry);
|
|
135
|
+
return (0, expression_function_invocation_1.runWithExpressionFunctionFrame)(() => loadCelEngine().evaluate(handle.native, { ...roots }, functions));
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
exports.createCelLegacyAdapter = createCelLegacyAdapter;
|
|
139
|
+
/** The built-ins-only adapter, used wherever no registry was handed in. */
|
|
140
|
+
exports.celLegacyAdapter = (0, exports.createCelLegacyAdapter)(expression_function_registry_1.BUILT_IN_EXPRESSION_FUNCTION_REGISTRY);
|
|
141
|
+
//# sourceMappingURL=cel-legacy.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cel-legacy.adapter.js","sourceRoot":"","sources":["../../../../../../../libs/bpm-core/src/lib/condition/adapters/cel-legacy.adapter.ts"],"names":[],"mappings":";;;AAqDA,sCAsBC;AAoBD,wCAWC;AAzGD,yGAA+G;AAE/G,4EAAuE;AACvE,sFAK2C;AAuB3C,IAAI,SAAS,GAAqB,IAAI,CAAC;AAEvC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,aAAa;IAC3B,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC;YACH,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAc,CAAC;QAC7C,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,qEAAqE;YACrE,oEAAoE;YACpE,yEAAyE;YACzE,aAAa;YACb,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7B,MAAM,IAAI,KAAK,CACb,0KACE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,CACH,CAAC;YACJ,CAAC;YAED,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,IAAI,KAAK;QACd,KAAqC,CAAC,IAAI,KAAK,iBAAiB,CAClE,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAAC,UAAkB;IAC/C,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,IAAI,WAAwB,CAAC;IAE7B,IAAI,CAAC;QACH,WAAW,GAAG,MAAM,CAAC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CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,CAAC,CACjE,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AApBU,QAAA,sBAAsB,0BAoBhC;AAEH,2EAA2E;AAC9D,QAAA,gBAAgB,GAA4B,IAAA,8BAAsB,EAC7E,oEAAqC,CACtC,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Environment } from '@marcbachmann/cel-js';
|
|
2
|
+
import type { BPMExpressionValueType } from '@rytass/bpm-core-shared';
|
|
3
|
+
import type { BPMExpressionFunctionRegistry } from '../../expression-function/expression-function.types';
|
|
4
|
+
import type { ExpressionEngineAdapter, ExpressionHandle } from '../expression-runtime';
|
|
5
|
+
/**
|
|
6
|
+
* Parse-time structure limits (ADR 22 §3.4, docs/24 §2.7). They are applied by
|
|
7
|
+
* the engine while parsing, so an over-large expression never reaches the
|
|
8
|
+
* budget. Comprehension nesting is not an engine limit; P2 checks it on the AST.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CEL_V2_LIMITS: {
|
|
11
|
+
readonly maxAstNodes: 200;
|
|
12
|
+
readonly maxDepth: 32;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The cel-v2 environment for a registry: the base environment plus every
|
|
16
|
+
* function the registry lists (the nine built-ins and the host's), built once
|
|
17
|
+
* per registry and cached. Without a registry it is the built-ins-only one.
|
|
18
|
+
*
|
|
19
|
+
* Every function is registered as a global call (`round(x)`), never as a
|
|
20
|
+
* method. The name `trim` therefore sits beside cel-v2's own `string.trim()`
|
|
21
|
+
* method without replacing it; no other built-in name exists in cel-v2.
|
|
22
|
+
*
|
|
23
|
+
* The returned environment is frozen: registering on it throws. For a
|
|
24
|
+
* type check with declared variables (P2's `env.check()`), `clone()` it and
|
|
25
|
+
* register the variables on the clone.
|
|
26
|
+
*/
|
|
27
|
+
export declare function loadCelV2Environment(registry?: BPMExpressionFunctionRegistry): Environment;
|
|
28
|
+
/** A call argument whose checked type its declared parameter never accepts. */
|
|
29
|
+
export interface CelV2ArgumentTypeMismatch {
|
|
30
|
+
/** The argument's AST node, for the caller to read the fields it uses. */
|
|
31
|
+
readonly argument: unknown;
|
|
32
|
+
readonly functionName: string;
|
|
33
|
+
readonly parameterType: BPMExpressionValueType;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The first global call to a registered function whose argument the type
|
|
37
|
+
* check typed as something the declared parameter refuses (ADR 22 §3.5): a
|
|
38
|
+
* text field handed to a `double` parameter, say. Only meaningful on the AST
|
|
39
|
+
* of an expression `check()` accepted, parsed in a clone of
|
|
40
|
+
* `loadCelV2Environment(...)`'s environment (`environment` is that
|
|
41
|
+
* environment, not the clone); an argument without a checked type, or a
|
|
42
|
+
* function the environment does not know, is skipped.
|
|
43
|
+
*
|
|
44
|
+
* The engine checks every other parameter type itself through the
|
|
45
|
+
* signature; numbers are registered as `dyn` there, which is what this
|
|
46
|
+
* closes for the publish lint.
|
|
47
|
+
*
|
|
48
|
+
* `readArgumentType`, when given, may name the type to compare instead of
|
|
49
|
+
* the checked one (a base type, `null` to keep the checked one): the lint
|
|
50
|
+
* passes the schema type of a field it had to check as `dyn`, so that
|
|
51
|
+
* `form.title != null && f(form.title)` is compared as the text it is.
|
|
52
|
+
*/
|
|
53
|
+
export declare function findCelV2ArgumentTypeMismatch(ast: unknown, environment: Environment, readArgumentType?: (argument: unknown) => string | null): CelV2ArgumentTypeMismatch | null;
|
|
54
|
+
/**
|
|
55
|
+
* Parses with cel-v2. Returns `null` when the expression does not parse or
|
|
56
|
+
* breaks a structure limit. The engine is loaded outside the `try`: a failure
|
|
57
|
+
* to load it is a configuration error, not a bad expression.
|
|
58
|
+
*
|
|
59
|
+
* Parsing does not check that a called function exists; evaluation does.
|
|
60
|
+
*/
|
|
61
|
+
export declare function parseCelV2(expression: string, registry?: BPMExpressionFunctionRegistry): ExpressionHandle | null;
|
|
62
|
+
/**
|
|
63
|
+
* Maps an error cel-v2 threw to a classified failure, by its `code` only. Any
|
|
64
|
+
* code not listed is a type or evaluation error. Errors that are not cel-v2's
|
|
65
|
+
* (an operator handler's own failure, a stack overflow) pass through unchanged
|
|
66
|
+
* and are classified by the runtime.
|
|
67
|
+
*/
|
|
68
|
+
export declare function classifyCelV2Error(error: unknown): unknown;
|
|
69
|
+
/**
|
|
70
|
+
* The cel-v2 adapter for a registry. A host function the registry no longer
|
|
71
|
+
* has (withdrawn after publishing) fails the evaluation with
|
|
72
|
+
* `EXPRESSION_FUNCTION_FAILED` before the engine runs, wherever the call sits.
|
|
73
|
+
*/
|
|
74
|
+
export declare const createCelV2Adapter: (registry: BPMExpressionFunctionRegistry) => ExpressionEngineAdapter;
|
|
75
|
+
/** The built-ins-only adapter, used wherever no registry was handed in. */
|
|
76
|
+
export declare const celV2Adapter: ExpressionEngineAdapter;
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.celV2Adapter = exports.createCelV2Adapter = exports.CEL_V2_LIMITS = void 0;
|
|
4
|
+
exports.loadCelV2Environment = loadCelV2Environment;
|
|
5
|
+
exports.findCelV2ArgumentTypeMismatch = findCelV2ArgumentTypeMismatch;
|
|
6
|
+
exports.parseCelV2 = parseCelV2;
|
|
7
|
+
exports.classifyCelV2Error = classifyCelV2Error;
|
|
8
|
+
const expression_function_registry_1 = require("../../expression-function/expression-function.registry");
|
|
9
|
+
const expression_engine_failure_1 = require("../expression-engine-failure");
|
|
10
|
+
const expression_function_invocation_1 = require("../expression-function-invocation");
|
|
11
|
+
/**
|
|
12
|
+
* Parse-time structure limits (ADR 22 §3.4, docs/24 §2.7). They are applied by
|
|
13
|
+
* the engine while parsing, so an over-large expression never reaches the
|
|
14
|
+
* budget. Comprehension nesting is not an engine limit; P2 checks it on the AST.
|
|
15
|
+
*/
|
|
16
|
+
exports.CEL_V2_LIMITS = {
|
|
17
|
+
maxAstNodes: 200,
|
|
18
|
+
maxDepth: 32,
|
|
19
|
+
};
|
|
20
|
+
const MIXED_ARITHMETIC_OPERATORS = ['+', '-', '*', '/', '%'];
|
|
21
|
+
/**
|
|
22
|
+
* A CEL `int` (a `bigint`) or `double` (a `number`) as a JS number. An int
|
|
23
|
+
* outside the safe range cannot become a double without silently changing,
|
|
24
|
+
* so it is refused (docs/24 §2.1: out of safe range is `EXPRESSION_INVALID_RESULT`).
|
|
25
|
+
*/
|
|
26
|
+
const toDouble = (value) => {
|
|
27
|
+
if (typeof value === 'number') {
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
if (typeof value === 'bigint' &&
|
|
31
|
+
value <= BigInt(Number.MAX_SAFE_INTEGER) &&
|
|
32
|
+
value >= BigInt(Number.MIN_SAFE_INTEGER)) {
|
|
33
|
+
return Number(value);
|
|
34
|
+
}
|
|
35
|
+
throw new expression_engine_failure_1.ExpressionEngineFailure('EXPRESSION_INVALID_RESULT');
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* The mixed `int`/`double` arithmetic cel-legacy gives for free (it only has
|
|
39
|
+
* JS numbers) and cel-v2 refuses with `no such overload`. Form values arrive as
|
|
40
|
+
* JS numbers, which cel-v2 types as `double`, while integer literals are `int`,
|
|
41
|
+
* so without these `form.amount * 2` fails (ADR 22 §3.3). The result is a
|
|
42
|
+
* `double`, as in cel-legacy.
|
|
43
|
+
*
|
|
44
|
+
* A zero divisor throws `EXPRESSION_TYPE_ERROR` (docs/24 §2.1) instead of
|
|
45
|
+
* returning `Infinity`/`NaN`, which a comparison would quietly turn into a
|
|
46
|
+
* routing decision.
|
|
47
|
+
*/
|
|
48
|
+
const MIXED_ARITHMETIC = {
|
|
49
|
+
'%': (left, right) => left % right,
|
|
50
|
+
'*': (left, right) => left * right,
|
|
51
|
+
'+': (left, right) => left + right,
|
|
52
|
+
'-': (left, right) => left - right,
|
|
53
|
+
'/': (left, right) => left / right,
|
|
54
|
+
};
|
|
55
|
+
const runMixedArithmetic = (operator, left, right) => {
|
|
56
|
+
const leftNumber = toDouble(left);
|
|
57
|
+
const rightNumber = toDouble(right);
|
|
58
|
+
if ((operator === '/' || operator === '%') && rightNumber === 0) {
|
|
59
|
+
throw new expression_engine_failure_1.ExpressionEngineFailure('EXPRESSION_TYPE_ERROR');
|
|
60
|
+
}
|
|
61
|
+
return MIXED_ARITHMETIC[operator](leftNumber, rightNumber);
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* `int == double`, exact: the int is compared as a `bigint`, so a large int is
|
|
65
|
+
* never rounded into equality with a nearby double. Registering it also gives
|
|
66
|
+
* the reverse order and `!=` (the engine derives them).
|
|
67
|
+
*/
|
|
68
|
+
const isIntEqualToDouble = (left, right) => {
|
|
69
|
+
const [int, double] = typeof left === 'bigint' ? [left, right] : [right, left];
|
|
70
|
+
return (typeof int === 'bigint' &&
|
|
71
|
+
typeof double === 'number' &&
|
|
72
|
+
Number.isInteger(double) &&
|
|
73
|
+
BigInt(double) === int);
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Options that make cel-v2 read a BPM context the way cel-legacy did:
|
|
77
|
+
* undeclared roots are `dyn` (the roots are checked by the runtime's
|
|
78
|
+
* allowlist, not by declaration), and list and map literals may mix value
|
|
79
|
+
* types (`{"a": "x", "b": 2}`, which cel-legacy refuses).
|
|
80
|
+
*/
|
|
81
|
+
const ENVIRONMENT_OPTIONS = {
|
|
82
|
+
homogeneousAggregateLiterals: false,
|
|
83
|
+
limits: exports.CEL_V2_LIMITS,
|
|
84
|
+
unlistedVariablesAreDyn: true,
|
|
85
|
+
};
|
|
86
|
+
const createEnvironment = (module) => {
|
|
87
|
+
const environment = new module.Environment(ENVIRONMENT_OPTIONS);
|
|
88
|
+
MIXED_ARITHMETIC_OPERATORS.forEach((operator) => {
|
|
89
|
+
environment.registerOperator(`double ${operator} int: double`, (left, right) => runMixedArithmetic(operator, left, right));
|
|
90
|
+
environment.registerOperator(`int ${operator} double: double`, (left, right) => runMixedArithmetic(operator, left, right));
|
|
91
|
+
});
|
|
92
|
+
// `in` is deliberately not registered for mixed lists: an `int in
|
|
93
|
+
// list<double>` overload makes the engine's own `V in list<V>` ambiguous for
|
|
94
|
+
// `dyn` values, and `form.qty in [1, 2.5]` then fails at evaluation.
|
|
95
|
+
environment.registerOperator('int == double', isIntEqualToDouble);
|
|
96
|
+
return environment;
|
|
97
|
+
};
|
|
98
|
+
let celV2BaseEnvironment = null;
|
|
99
|
+
/**
|
|
100
|
+
* Loads `@marcbachmann/cel-js` on first use, like `loadCelEngine` does for
|
|
101
|
+
* cel-legacy, and for the same reasons: a host that never evaluates a cel-v2
|
|
102
|
+
* expression never resolves the package, and the ESM-only package is loaded
|
|
103
|
+
* with `require` so every caller stays synchronous (Node >=20.19 / >=22.12).
|
|
104
|
+
*
|
|
105
|
+
* This is the environment every function environment is cloned from: options,
|
|
106
|
+
* limits and the mixed-number operators, no functions. Cloning freezes it, so
|
|
107
|
+
* it is complete before the first clone.
|
|
108
|
+
*/
|
|
109
|
+
const loadCelV2BaseEnvironment = () => {
|
|
110
|
+
if (celV2BaseEnvironment === null) {
|
|
111
|
+
let module;
|
|
112
|
+
try {
|
|
113
|
+
module = require('@marcbachmann/cel-js');
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
if (typeof error === 'object' &&
|
|
117
|
+
error !== null &&
|
|
118
|
+
error.code === 'ERR_REQUIRE_ESM') {
|
|
119
|
+
throw new Error(`[@rytass/bpm-core-nestjs-module] This Node version cannot require the ESM-only '@marcbachmann/cel-js'. BPM needs Node >=20.19 or >=22.12 to evaluate cel-v2 expressions. Original error: ${error instanceof Error ? error.message : String(error)}`);
|
|
120
|
+
}
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
celV2BaseEnvironment = createEnvironment(module);
|
|
124
|
+
}
|
|
125
|
+
return celV2BaseEnvironment;
|
|
126
|
+
};
|
|
127
|
+
/*
|
|
128
|
+
* How a declared type is written in a cel-v2 signature. Numbers are `dyn`:
|
|
129
|
+
* cel-v2 tells an `int` literal (`1000`) from a `double` (a form value, which
|
|
130
|
+
* is a JS number), so a `double` parameter would refuse `f_v1(1000)` and an
|
|
131
|
+
* `int` one would refuse `f_v1(form.qty)`. The wrapper checks the number
|
|
132
|
+
* against the declared type instead. Every other type is enforced by the
|
|
133
|
+
* engine's overload resolution, which reports a mismatch as a type error.
|
|
134
|
+
*/
|
|
135
|
+
const toSignatureParameterType = (type) => type === 'double' || type === 'int' ? 'dyn' : type;
|
|
136
|
+
const toSignature = (fn) => `${fn.name}(${fn.parameters
|
|
137
|
+
.map((parameter) => toSignatureParameterType(parameter.type))
|
|
138
|
+
.join(', ')}): ${fn.returnType}`;
|
|
139
|
+
const celV2Environments = new WeakMap();
|
|
140
|
+
/**
|
|
141
|
+
* The declared parameter types of every function registered on a function
|
|
142
|
+
* environment, by name. Kept beside the environment because numbers are
|
|
143
|
+
* registered as `dyn` (see `toSignatureParameterType`), so the engine's own
|
|
144
|
+
* check cannot tell a `string` argument handed to a `double` parameter.
|
|
145
|
+
*/
|
|
146
|
+
const celV2FunctionParameters = new WeakMap();
|
|
147
|
+
/**
|
|
148
|
+
* The cel-v2 environment for a registry: the base environment plus every
|
|
149
|
+
* function the registry lists (the nine built-ins and the host's), built once
|
|
150
|
+
* per registry and cached. Without a registry it is the built-ins-only one.
|
|
151
|
+
*
|
|
152
|
+
* Every function is registered as a global call (`round(x)`), never as a
|
|
153
|
+
* method. The name `trim` therefore sits beside cel-v2's own `string.trim()`
|
|
154
|
+
* method without replacing it; no other built-in name exists in cel-v2.
|
|
155
|
+
*
|
|
156
|
+
* The returned environment is frozen: registering on it throws. For a
|
|
157
|
+
* type check with declared variables (P2's `env.check()`), `clone()` it and
|
|
158
|
+
* register the variables on the clone.
|
|
159
|
+
*/
|
|
160
|
+
function loadCelV2Environment(registry = expression_function_registry_1.BUILT_IN_EXPRESSION_FUNCTION_REGISTRY) {
|
|
161
|
+
const cached = celV2Environments.get(registry);
|
|
162
|
+
if (cached) {
|
|
163
|
+
return cached;
|
|
164
|
+
}
|
|
165
|
+
const environment = loadCelV2BaseEnvironment().clone();
|
|
166
|
+
const { functions } = (0, expression_function_invocation_1.readExpressionFunctionTable)(registry);
|
|
167
|
+
functions.forEach((fn) => {
|
|
168
|
+
environment.registerFunction(toSignature(fn), (0, expression_function_invocation_1.createExpressionFunctionInvoker)(fn, 'cel-v2'));
|
|
169
|
+
});
|
|
170
|
+
// Cloning stops the parent from registering more (documented engine
|
|
171
|
+
// behaviour), so the shared environment cannot be changed by a caller.
|
|
172
|
+
environment.clone();
|
|
173
|
+
celV2FunctionParameters.set(environment, new Map(functions.map((fn) => [
|
|
174
|
+
fn.name,
|
|
175
|
+
fn.parameters.map((parameter) => parameter.type),
|
|
176
|
+
])));
|
|
177
|
+
celV2Environments.set(registry, environment);
|
|
178
|
+
return environment;
|
|
179
|
+
}
|
|
180
|
+
const isAstNode = (value) => typeof value === 'object' &&
|
|
181
|
+
value !== null &&
|
|
182
|
+
typeof value.op === 'string';
|
|
183
|
+
const NUMERIC_CHECKED_TYPES = new Set([
|
|
184
|
+
'double',
|
|
185
|
+
'int',
|
|
186
|
+
'uint',
|
|
187
|
+
]);
|
|
188
|
+
/*
|
|
189
|
+
* The checked types (their base, `list<string>` is `list`) a parameter of
|
|
190
|
+
* each declared type accepts. `dyn` is accepted everywhere: a value the check
|
|
191
|
+
* cannot type is decided at evaluation, as before. A `double` parameter takes
|
|
192
|
+
* an `int` and an `int` one a `double` (a form number is a `double` even when
|
|
193
|
+
* it is whole); the wrapper decides those at evaluation.
|
|
194
|
+
*/
|
|
195
|
+
const isCheckedTypeAccepted = (checkedType, parameterType) => {
|
|
196
|
+
if (checkedType === 'dyn' || parameterType === 'dyn') {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
switch (parameterType) {
|
|
200
|
+
case 'double':
|
|
201
|
+
case 'int':
|
|
202
|
+
return NUMERIC_CHECKED_TYPES.has(checkedType);
|
|
203
|
+
case 'null':
|
|
204
|
+
return checkedType === 'null';
|
|
205
|
+
default:
|
|
206
|
+
return checkedType === parameterType;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
const readCheckedBaseType = (node) => {
|
|
210
|
+
const checked = node
|
|
211
|
+
?.checkedType;
|
|
212
|
+
const name = typeof checked === 'object' && checked !== null
|
|
213
|
+
? checked.name
|
|
214
|
+
: undefined;
|
|
215
|
+
return typeof name === 'string' ? name.split('<')[0].trim() : null;
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* The first global call to a registered function whose argument the type
|
|
219
|
+
* check typed as something the declared parameter refuses (ADR 22 §3.5): a
|
|
220
|
+
* text field handed to a `double` parameter, say. Only meaningful on the AST
|
|
221
|
+
* of an expression `check()` accepted, parsed in a clone of
|
|
222
|
+
* `loadCelV2Environment(...)`'s environment (`environment` is that
|
|
223
|
+
* environment, not the clone); an argument without a checked type, or a
|
|
224
|
+
* function the environment does not know, is skipped.
|
|
225
|
+
*
|
|
226
|
+
* The engine checks every other parameter type itself through the
|
|
227
|
+
* signature; numbers are registered as `dyn` there, which is what this
|
|
228
|
+
* closes for the publish lint.
|
|
229
|
+
*
|
|
230
|
+
* `readArgumentType`, when given, may name the type to compare instead of
|
|
231
|
+
* the checked one (a base type, `null` to keep the checked one): the lint
|
|
232
|
+
* passes the schema type of a field it had to check as `dyn`, so that
|
|
233
|
+
* `form.title != null && f(form.title)` is compared as the text it is.
|
|
234
|
+
*/
|
|
235
|
+
function findCelV2ArgumentTypeMismatch(ast, environment, readArgumentType = () => null) {
|
|
236
|
+
const parameters = celV2FunctionParameters.get(environment);
|
|
237
|
+
if (!parameters) {
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
const visit = (node) => {
|
|
241
|
+
if (Array.isArray(node)) {
|
|
242
|
+
return node.reduce((found, child) => found ?? visit(child), null);
|
|
243
|
+
}
|
|
244
|
+
if (!isAstNode(node)) {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
const args = node.args;
|
|
248
|
+
if (node.op === 'call' &&
|
|
249
|
+
Array.isArray(args) &&
|
|
250
|
+
typeof args[0] === 'string' &&
|
|
251
|
+
Array.isArray(args[1])) {
|
|
252
|
+
const declared = parameters.get(args[0]);
|
|
253
|
+
const callArguments = args[1];
|
|
254
|
+
const mismatchIndex = declared && declared.length === callArguments.length
|
|
255
|
+
? callArguments.findIndex((argument, index) => {
|
|
256
|
+
const checkedType = readArgumentType(argument) ?? readCheckedBaseType(argument);
|
|
257
|
+
return (checkedType !== null &&
|
|
258
|
+
!isCheckedTypeAccepted(checkedType, declared[index]));
|
|
259
|
+
})
|
|
260
|
+
: -1;
|
|
261
|
+
if (declared && mismatchIndex >= 0) {
|
|
262
|
+
return {
|
|
263
|
+
argument: callArguments[mismatchIndex],
|
|
264
|
+
functionName: args[0],
|
|
265
|
+
parameterType: declared[mismatchIndex],
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return visit(args);
|
|
270
|
+
};
|
|
271
|
+
return visit(ast);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Parses with cel-v2. Returns `null` when the expression does not parse or
|
|
275
|
+
* breaks a structure limit. The engine is loaded outside the `try`: a failure
|
|
276
|
+
* to load it is a configuration error, not a bad expression.
|
|
277
|
+
*
|
|
278
|
+
* Parsing does not check that a called function exists; evaluation does.
|
|
279
|
+
*/
|
|
280
|
+
function parseCelV2(expression, registry = expression_function_registry_1.BUILT_IN_EXPRESSION_FUNCTION_REGISTRY) {
|
|
281
|
+
const environment = loadCelV2Environment(registry);
|
|
282
|
+
try {
|
|
283
|
+
return { native: environment.parse(expression) };
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Names of the global functions an expression calls (`call` nodes; methods are
|
|
291
|
+
* `rcall` and never host functions). A small walk of the engine's AST, only
|
|
292
|
+
* for the evaluation-time check; the publish lint reads references through
|
|
293
|
+
* P2's AST module.
|
|
294
|
+
*/
|
|
295
|
+
const readCalledFunctionNames = (node) => {
|
|
296
|
+
if (Array.isArray(node)) {
|
|
297
|
+
return node.flatMap(readCalledFunctionNames);
|
|
298
|
+
}
|
|
299
|
+
if (!isAstNode(node)) {
|
|
300
|
+
return [];
|
|
301
|
+
}
|
|
302
|
+
const args = node.args;
|
|
303
|
+
const own = node.op === 'call' && Array.isArray(args) && typeof args[0] === 'string'
|
|
304
|
+
? [args[0]]
|
|
305
|
+
: [];
|
|
306
|
+
return [...own, ...readCalledFunctionNames(args)];
|
|
307
|
+
};
|
|
308
|
+
const isCelError = (error) => error instanceof Error &&
|
|
309
|
+
(error.name === 'EvaluationError' ||
|
|
310
|
+
error.name === 'TypeError' ||
|
|
311
|
+
error.name === 'ParseError') &&
|
|
312
|
+
typeof error.code === 'string' &&
|
|
313
|
+
typeof error.summary === 'string';
|
|
314
|
+
/*
|
|
315
|
+
* The only engine summaries a key name is read from. Anchored at both ends;
|
|
316
|
+
* the candidate is checked against the expression before anyone sees it.
|
|
317
|
+
* `No such key: index out of bounds, ...` does not match, by design.
|
|
318
|
+
*/
|
|
319
|
+
const KEY_NAME_PATTERNS = [
|
|
320
|
+
/^No such key: ([A-Za-z_][A-Za-z0-9_]*)$/u,
|
|
321
|
+
/^Unknown variable: ([A-Za-z_][A-Za-z0-9_]*)$/u,
|
|
322
|
+
];
|
|
323
|
+
const readKeyNameCandidate = (summary) => KEY_NAME_PATTERNS.reduce((found, pattern) => found ?? pattern.exec(summary)?.[1] ?? null, null);
|
|
324
|
+
const CEL_V2_CODE_MAP = {
|
|
325
|
+
index_out_of_bounds: 'EXPRESSION_MISSING_KEY',
|
|
326
|
+
index_out_of_range: 'EXPRESSION_MISSING_KEY',
|
|
327
|
+
no_such_key: 'EXPRESSION_MISSING_KEY',
|
|
328
|
+
numeric_overflow: 'EXPRESSION_INVALID_RESULT',
|
|
329
|
+
unknown_variable: 'EXPRESSION_MISSING_KEY',
|
|
330
|
+
};
|
|
331
|
+
/**
|
|
332
|
+
* Maps an error cel-v2 threw to a classified failure, by its `code` only. Any
|
|
333
|
+
* code not listed is a type or evaluation error. Errors that are not cel-v2's
|
|
334
|
+
* (an operator handler's own failure, a stack overflow) pass through unchanged
|
|
335
|
+
* and are classified by the runtime.
|
|
336
|
+
*/
|
|
337
|
+
function classifyCelV2Error(error) {
|
|
338
|
+
if (!isCelError(error)) {
|
|
339
|
+
return error;
|
|
340
|
+
}
|
|
341
|
+
const code = CEL_V2_CODE_MAP[error.code] ?? 'EXPRESSION_TYPE_ERROR';
|
|
342
|
+
return new expression_engine_failure_1.ExpressionEngineFailure(code, code === 'EXPRESSION_MISSING_KEY'
|
|
343
|
+
? readKeyNameCandidate(error.summary)
|
|
344
|
+
: null);
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* The cel-v2 adapter for a registry. A host function the registry no longer
|
|
348
|
+
* has (withdrawn after publishing) fails the evaluation with
|
|
349
|
+
* `EXPRESSION_FUNCTION_FAILED` before the engine runs, wherever the call sits.
|
|
350
|
+
*/
|
|
351
|
+
const createCelV2Adapter = (registry) => ({
|
|
352
|
+
compile: (expression) => parseCelV2(expression, registry),
|
|
353
|
+
evaluate: (handle, roots) => {
|
|
354
|
+
const parsed = handle.native;
|
|
355
|
+
if ((0, expression_function_invocation_1.callsUnavailableFunction)(readCalledFunctionNames(parsed.ast), (0, expression_function_invocation_1.readExpressionFunctionTable)(registry))) {
|
|
356
|
+
throw new expression_engine_failure_1.ExpressionEngineFailure('EXPRESSION_FUNCTION_FAILED');
|
|
357
|
+
}
|
|
358
|
+
return (0, expression_function_invocation_1.runWithExpressionFunctionFrame)(() => {
|
|
359
|
+
try {
|
|
360
|
+
return parsed({ ...roots });
|
|
361
|
+
}
|
|
362
|
+
catch (error) {
|
|
363
|
+
throw classifyCelV2Error(error);
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
},
|
|
367
|
+
});
|
|
368
|
+
exports.createCelV2Adapter = createCelV2Adapter;
|
|
369
|
+
/** The built-ins-only adapter, used wherever no registry was handed in. */
|
|
370
|
+
exports.celV2Adapter = (0, exports.createCelV2Adapter)(expression_function_registry_1.BUILT_IN_EXPRESSION_FUNCTION_REGISTRY);
|
|
371
|
+
//# sourceMappingURL=cel-v2.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cel-v2.adapter.js","sourceRoot":"","sources":["../../../../../../../libs/bpm-core/src/lib/condition/adapters/cel-v2.adapter.ts"],"names":[],"mappings":";;;AA6OA,oDAmCC;AAiFD,sEA2DC;AASD,gCAWC;AAsED,gDAaC;AA7fD,yGAA+G;AAK/G,4EAAuE;AAEvE,sFAK2C;AAW3C;;;;GAIG;AACU,QAAA,aAAa,GAAG;IAC3B,WAAW,EAAE,GAAG;IAChB,QAAQ,EAAE,EAAE;CACJ,CAAC;AAEX,MAAM,0BAA0B,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC;AAItE;;;;GAIG;AACH,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAU,EAAE;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC;QACxC,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,EACxC,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,IAAI,mDAAuB,CAAC,2BAA2B,CAAC,CAAC;AACjE,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,gBAAgB,GAElB;IACF,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CA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