@rytass/bpm-core-nestjs-module 0.19.0 → 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 +36 -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/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 +240 -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
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
## 0.20.0 (2026-11-08)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **workflow-chat:** require a BPM API session for /api/chat ([9906851](https://github.com/Rytass/BPMCore/commit/9906851))
|
|
6
|
+
- ⚠️ **form-data-source:** pass a binding's position explicitly and lint NOTIFY expressions ([9987b12](https://github.com/Rytass/BPMCore/commit/9987b12))
|
|
7
|
+
- **form-data-source:** bind DataSource and webhook parameters to expressions ([c2b18d3](https://github.com/Rytass/BPMCore/commit/c2b18d3))
|
|
8
|
+
- **designer:** write, preview and upgrade expressions in the designer ([ec36bb7](https://github.com/Rytass/BPMCore/commit/ec36bb7))
|
|
9
|
+
- **condition:** call registered functions from every evaluation and lint ([0c2a18f](https://github.com/Rytass/BPMCore/commit/0c2a18f))
|
|
10
|
+
- **template:** lint expressions against their AST at publish ([61d07f5](https://github.com/Rytass/BPMCore/commit/61d07f5))
|
|
11
|
+
- **expression-function:** register host and built-in functions ([f8763b4](https://github.com/Rytass/BPMCore/commit/f8763b4))
|
|
12
|
+
- **expression-function:** define the function registry contract ([31e7e16](https://github.com/Rytass/BPMCore/commit/31e7e16))
|
|
13
|
+
- **workflow-engine:** evaluate each definition in its expression dialect ([45b15c3](https://github.com/Rytass/BPMCore/commit/45b15c3))
|
|
14
|
+
- **delegation:** store the dialect of a rule's scope condition ([acea3d0](https://github.com/Rytass/BPMCore/commit/acea3d0))
|
|
15
|
+
- **condition:** evaluate expressions under a budget with sanitized errors ([38ef1f8](https://github.com/Rytass/BPMCore/commit/38ef1f8))
|
|
16
|
+
|
|
17
|
+
### 🩹 Fixes
|
|
18
|
+
|
|
19
|
+
- **form-data-source:** take a new pick over an expired EXPRESSION value ([3499115](https://github.com/Rytass/BPMCore/commit/3499115))
|
|
20
|
+
- **condition:** check cel-v2 function argument types and log engine warm-up ([0834758](https://github.com/Rytass/BPMCore/commit/0834758))
|
|
21
|
+
- **workflow-engine:** send webhooks after the transaction commits ([d74aba6](https://github.com/Rytass/BPMCore/commit/d74aba6))
|
|
22
|
+
- **workflow-engine:** bound the work of one dry run ([7afacec](https://github.com/Rytass/BPMCore/commit/7afacec))
|
|
23
|
+
- **workflow-engine:** keep transaction reads on one connection ([9bd9ee7](https://github.com/Rytass/BPMCore/commit/9bd9ee7))
|
|
24
|
+
|
|
25
|
+
### ⚠️ Breaking Changes
|
|
26
|
+
|
|
27
|
+
- **form-data-source:** pass a binding's position explicitly and lint NOTIFY expressions ([9987b12](https://github.com/Rytass/BPMCore/commit/9987b12))
|
|
28
|
+
FormDataSourceService.searchFormFieldOptions takes a
|
|
29
|
+
required position instead of optional rowValues, and the
|
|
30
|
+
NotifyWebhookBindingSource union gains an EXPRESSION member, so an
|
|
31
|
+
exhaustive switch over from.kind needs a new case.
|
|
32
|
+
|
|
33
|
+
### ❤️ Thank You
|
|
34
|
+
|
|
35
|
+
- Chia Yu Pai @fantasywind
|
|
36
|
+
|
|
1
37
|
## 0.19.0 (2026-11-04)
|
|
2
38
|
|
|
3
39
|
### 🩹 Fixes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rytass/bpm-core-nestjs-module",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Embeddable NestJS BPM approval workflow module: workflow engine, approval templates, forms, organization/member contracts, attachments, signatures, notifications, delegation, and TypeORM migrations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bpm",
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
"@nestjs/core": ">=10.0.0",
|
|
163
163
|
"@nestjs/graphql": ">=12.0.0",
|
|
164
164
|
"@nestjs/typeorm": ">=10.0.0",
|
|
165
|
-
"@rytass/bpm-core-shared": "^0.
|
|
165
|
+
"@rytass/bpm-core-shared": "^0.20.0",
|
|
166
166
|
"@rytass/secret-adapter-vault-nestjs": ">=0.4.5",
|
|
167
167
|
"express": ">=4.0.0",
|
|
168
168
|
"graphql": ">=16.0.0",
|
|
@@ -178,6 +178,7 @@
|
|
|
178
178
|
}
|
|
179
179
|
},
|
|
180
180
|
"dependencies": {
|
|
181
|
+
"@marcbachmann/cel-js": "^8.0.0",
|
|
181
182
|
"@rytass/storages": "^0.3.0",
|
|
182
183
|
"@rytass/storages-adapter-local": "^0.3.0",
|
|
183
184
|
"cel-js": "^0.8.2",
|
package/src/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './lib/common';
|
|
|
6
6
|
export * from './lib/condition';
|
|
7
7
|
export * from './lib/database';
|
|
8
8
|
export * from './lib/delegation';
|
|
9
|
+
export * from './lib/expression-function';
|
|
9
10
|
export * from './lib/form';
|
|
10
11
|
export * from './lib/form-data-source';
|
|
11
12
|
export * from './lib/identity';
|
package/src/index.js
CHANGED
|
@@ -9,6 +9,7 @@ tslib_1.__exportStar(require("./lib/common"), exports);
|
|
|
9
9
|
tslib_1.__exportStar(require("./lib/condition"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./lib/database"), exports);
|
|
11
11
|
tslib_1.__exportStar(require("./lib/delegation"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./lib/expression-function"), exports);
|
|
12
13
|
tslib_1.__exportStar(require("./lib/form"), exports);
|
|
13
14
|
tslib_1.__exportStar(require("./lib/form-data-source"), exports);
|
|
14
15
|
tslib_1.__exportStar(require("./lib/identity"), exports);
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/bpm-core/src/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,oDAA0B;AAC1B,yDAA+B;AAC/B,yDAA+B;AAC/B,uDAA6B;AAC7B,0DAAgC;AAChC,yDAA+B;AAC/B,2DAAiC;AACjC,qDAA2B;AAC3B,iEAAuC;AACvC,yDAA+B;AAC/B,6DAAmC;AACnC,6DAAmC;AACnC,0DAAgC;AAChC,yDAA+B;AAC/B,gEAAsC;AACtC,iEAAuC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/bpm-core/src/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,oDAA0B;AAC1B,yDAA+B;AAC/B,yDAA+B;AAC/B,uDAA6B;AAC7B,0DAAgC;AAChC,yDAA+B;AAC/B,2DAAiC;AACjC,oEAA0C;AAC1C,qDAA2B;AAC3B,iEAAuC;AACvC,yDAA+B;AAC/B,6DAAmC;AACnC,6DAAmC;AACnC,0DAAgC;AAChC,yDAA+B;AAC/B,gEAAsC;AACtC,iEAAuC"}
|
|
@@ -3,6 +3,7 @@ import { BPMRootAttachmentOptions } from '../attachment/attachment-options';
|
|
|
3
3
|
import { AttachmentStorage } from '../attachment/attachment-storage.token';
|
|
4
4
|
import { BPMAuthModuleOptions } from '../bpm-auth/bpm-auth.options';
|
|
5
5
|
import { BPMBusinessCalendar } from '../calendar/business-calendar.token';
|
|
6
|
+
import type { BPMExpressionFunction } from '../expression-function/expression-function.types';
|
|
6
7
|
import { BPMFormDataSourceRegistry } from '../form-data-source/form-data-source.types';
|
|
7
8
|
import { BPMRootIdentityOptions } from '../identity/identity-options';
|
|
8
9
|
import { BPMMemberResolver } from '../identity/member-resolver.interface';
|
|
@@ -65,6 +66,18 @@ export interface BPMRootRuntimeOptions extends BPMRootAttachmentOptions, BPMRoot
|
|
|
65
66
|
* chain never runs through BPM's module context.
|
|
66
67
|
*/
|
|
67
68
|
readonly businessCalendar?: BPMBusinessCalendar;
|
|
69
|
+
/**
|
|
70
|
+
* Host functions that expressions may call (ADR 22 §3.5), next to the nine
|
|
71
|
+
* built-ins that are always available. Each name ends in its version
|
|
72
|
+
* (`erp_costBand_v1`); handlers must be synchronous and pure, and only see
|
|
73
|
+
* deep-frozen copies of their arguments. Validated while BPM boots: a bad
|
|
74
|
+
* name, an async handler or an unsupported type fails the boot.
|
|
75
|
+
*
|
|
76
|
+
* Keep every function a published version still calls: once one is gone,
|
|
77
|
+
* cases on that version fail closed with `EXPRESSION_FUNCTION_FAILED`.
|
|
78
|
+
* When omitted, only the built-ins are available.
|
|
79
|
+
*/
|
|
80
|
+
readonly expressionFunctions?: readonly BPMExpressionFunction[];
|
|
68
81
|
/**
|
|
69
82
|
* Versioned form option DataSource catalog, as a ready instance. When
|
|
70
83
|
* omitted, BPM exposes an empty catalog.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bpm-root-options.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/bpm/bpm-root-options.ts"],"names":[],"mappings":";;;;;AAAA,2CAMwB;
|
|
1
|
+
{"version":3,"file":"bpm-root-options.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/bpm/bpm-root-options.ts"],"names":[],"mappings":";;;;;AAAA,2CAMwB;AAUxB,mFAGgD;AAuHhD;;;;;;;;;;;GAWG;AACU,QAAA,gBAAgB,GAC3B,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAoB7B;;;;;;GAMG;AAGI,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAC/B,MAAM,CAAC,OAAO,CAAC,UAAiC,EAAE;QAChD,IAAA,uDAA8B,EAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;QAE7D,OAAO;YACL,OAAO,EAAE,CAAC,wBAAgB,CAAC;YAC3B,MAAM,EAAE,sBAAoB;YAC5B,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,wBAAgB;oBACzB,QAAQ,EAAE,OAAO;iBAClB;aACF;SACF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,YAAY,CACjB,UAA4C,EAAE;QAE9C,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QAEtC,OAAO;YACL,OAAO,EAAE,CAAC,wBAAgB,CAAC;YAC3B,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;YACpD,MAAM,EAAE,sBAAoB;YAC5B,SAAS,EAAE;gBACT;oBACE,MAAM,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;oBACnC,OAAO,EAAE,wBAAgB;oBACzB,UAAU,EAAE,KAAK,EACf,GAAG,IAAwB,EACK,EAAE;wBAClC,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;wBAE7D,IAAA,uDAA8B,EAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;wBAE9D,OAAO,QAAQ,CAAC;oBAClB,CAAC;iBACF;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA1CY,oDAAoB;+BAApB,oBAAoB;IAFhC,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,oBAAoB,CA0ChC"}
|
|
@@ -2,6 +2,7 @@ import { DynamicModule, InjectionToken, ModuleMetadata, Provider } from '@nestjs
|
|
|
2
2
|
import { AttachmentStorage } from '../attachment/attachment-storage.token';
|
|
3
3
|
import { BPMResolverMetadataFactory } from '../bpm-auth/bpm-resolver-metadata';
|
|
4
4
|
import { BPMBusinessCalendar } from '../calendar/business-calendar.token';
|
|
5
|
+
import type { BPMExpressionFunction } from '../expression-function/expression-function.types';
|
|
5
6
|
import { BPMFormDataSourceRegistry } from '../form-data-source';
|
|
6
7
|
import { BPMMemberResolver } from '../identity/member-resolver.interface';
|
|
7
8
|
import { BPMWorkflowWebhookRegistry } from '../workflow-webhook/workflow-webhook.types';
|
|
@@ -40,6 +41,17 @@ interface BPMRootModuleWiringOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
|
40
41
|
* `notificationSlaBusinessCalendarTimeZone`).
|
|
41
42
|
*/
|
|
42
43
|
readonly businessCalendarProvider?: Provider<BPMBusinessCalendar>;
|
|
44
|
+
/**
|
|
45
|
+
* Host expression functions as a Nest provider for
|
|
46
|
+
* `BPM_EXPRESSION_FUNCTIONS` (a list), for functions that need injected
|
|
47
|
+
* dependencies to be built.
|
|
48
|
+
*
|
|
49
|
+
* Runtime twin: {@link BPMRootRuntimeOptions.expressionFunctions}. Unlike
|
|
50
|
+
* the other twins the two are **combined**, the runtime list first; a name
|
|
51
|
+
* in both fails the boot. When neither is given, only the nine built-ins are
|
|
52
|
+
* available.
|
|
53
|
+
*/
|
|
54
|
+
readonly expressionFunctionsProvider?: Provider<readonly BPMExpressionFunction[]>;
|
|
43
55
|
/**
|
|
44
56
|
* Host-provided registry containing versioned form option DataSources, as a
|
|
45
57
|
* Nest provider.
|
|
@@ -9,6 +9,7 @@ const bpm_auth_module_1 = require("../bpm-auth/bpm-auth.module");
|
|
|
9
9
|
const bpm_resolver_metadata_1 = require("../bpm-auth/bpm-resolver-metadata");
|
|
10
10
|
const calendar_module_1 = require("../calendar/calendar.module");
|
|
11
11
|
const delegation_module_1 = require("../delegation/delegation.module");
|
|
12
|
+
const expression_function_module_1 = require("../expression-function/expression-function.module");
|
|
12
13
|
const form_module_1 = require("../form/form.module");
|
|
13
14
|
const form_data_source_1 = require("../form-data-source");
|
|
14
15
|
const identity_module_1 = require("../identity/identity.module");
|
|
@@ -141,6 +142,10 @@ function createBPMFeatureModules(wiring) {
|
|
|
141
142
|
storageProvider: wiring.attachmentStorageProvider,
|
|
142
143
|
useFactory,
|
|
143
144
|
}),
|
|
145
|
+
expression_function_module_1.ExpressionFunctionModule.forRoot({
|
|
146
|
+
functionsProvider: wiring.expressionFunctionsProvider,
|
|
147
|
+
imports: wiring.imports,
|
|
148
|
+
}),
|
|
144
149
|
form_module_1.FormModule,
|
|
145
150
|
form_data_source_1.FormDataSourceModule.forRoot({
|
|
146
151
|
imports: wiring.imports,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bpm-root.module.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/bpm/bpm-root.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAOwB;AACxB,uEAAmE;AAEnE,iEAA4D;AAC5D,6EAG2C;AAG3C,iEAA6D;AAC7D,uEAAmE;AACnE,qDAAiD;AACjD,0DAI6B;AAC7B,iEAA6D;AAE7D,6EAAyE;AACzE,6FAAwF;AACxF,yGAAmG;AACnG,yFAGqD;AAErD,6EAAyE;AACzE,oEAAgE;AAChE,iEAA6D;AAC7D,sFAAiF;AAEjF,yDAI4B;
|
|
1
|
+
{"version":3,"file":"bpm-root.module.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/bpm/bpm-root.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAOwB;AACxB,uEAAmE;AAEnE,iEAA4D;AAC5D,6EAG2C;AAG3C,iEAA6D;AAC7D,uEAAmE;AACnE,kGAA6F;AAE7F,qDAAiD;AACjD,0DAI6B;AAC7B,iEAA6D;AAE7D,6EAAyE;AACzE,6FAAwF;AACxF,yGAAmG;AACnG,yFAGqD;AAErD,6EAAyE;AACzE,oEAAgE;AAChE,iEAA6D;AAC7D,sFAAiF;AAEjF,yDAI4B;AA+K5B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEI,IAAM,aAAa,qBAAnB,MAAM,aAAa;IACxB;;;OAGG;IACH,MAAM,CAAC,OAAO,CAAC,UAAgC,EAAE;QAC/C,IAAI,OAAO,CAAC,uBAAuB,EAAE,CAAC;YACpC,IAAA,gDAAwB,EAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;QAC5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3B,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,6BAA6B,EAC3B,MAAM,CAAC,qCAAqC;SAC/C,CAAC;QACF,+CAAqB,CAAC,OAAO,CAAC;YAC5B,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,gBAAgB,EAAE,MAAM,CAAC,+BAA+B;SAClB,CAAC;KAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { ParseResult } from 'cel-js';
|
|
2
|
+
import type { BPMExpressionFunctionRegistry } from '../../expression-function/expression-function.types';
|
|
3
|
+
import type { ExpressionEngineAdapter, ExpressionHandle } from '../expression-runtime';
|
|
4
|
+
type CelLegacyFunction = (...args: readonly unknown[]) => unknown;
|
|
5
|
+
/**
|
|
6
|
+
* The slice of `cel-js` this adapter uses. The third `evaluate` argument is
|
|
7
|
+
* the function table: `cel-js` 0.8.2 merges it over its own `has` and `size`
|
|
8
|
+
* and calls an entry for every global call (`round(x)`), with the evaluated
|
|
9
|
+
* arguments. Methods (`x.round()`) never reach it.
|
|
10
|
+
*/
|
|
11
|
+
interface CelEngine {
|
|
12
|
+
readonly evaluate: (cst: unknown, context: Readonly<Record<string, unknown>>, functions?: Readonly<Record<string, CelLegacyFunction>>) => unknown;
|
|
13
|
+
readonly parse: (expression: string) => ParseResult;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Loads `cel-js` on first use rather than when this module is imported.
|
|
17
|
+
*
|
|
18
|
+
* `cel-js` is ESM-only and its `chevrotain` dependency ships an exports map
|
|
19
|
+
* that `jest-resolve` cannot follow. While the import sat at the top of this
|
|
20
|
+
* file, the package root pulled it in through
|
|
21
|
+
* `index → bpm-root → delegation → condition`, so *any* consumer test that
|
|
22
|
+
* imported anything from `@rytass/bpm-core-nestjs-module` failed to load with
|
|
23
|
+
* `Cannot find module 'chevrotain'` — pointing deep into `node_modules`, far
|
|
24
|
+
* from the code under test. Hosts had to stub `cel-js` before they could write
|
|
25
|
+
* a single test.
|
|
26
|
+
*
|
|
27
|
+
* Deferring the load means a host that never evaluates a CEL expression never
|
|
28
|
+
* resolves the package at all. `require` (not `await import`) keeps every
|
|
29
|
+
* caller in this file synchronous.
|
|
30
|
+
*
|
|
31
|
+
* The engine is loaded before a budget starts, so an interrupt can never land
|
|
32
|
+
* halfway through loading a module.
|
|
33
|
+
*/
|
|
34
|
+
export declare function loadCelEngine(): CelEngine;
|
|
35
|
+
/**
|
|
36
|
+
* Parses with `cel-js`. Returns `null` when the expression does not parse.
|
|
37
|
+
*
|
|
38
|
+
* `cel-js` can throw instead of reporting failure: a deeply nested expression
|
|
39
|
+
* (about 200 levels, still under the length limit) overflows the parser's stack
|
|
40
|
+
* with a bare `RangeError`. That is a syntax refusal, not a crash, so it maps to
|
|
41
|
+
* `null`. The engine is loaded outside the `try`: a failure to load it is a
|
|
42
|
+
* configuration error and must not be reported as a bad expression.
|
|
43
|
+
*/
|
|
44
|
+
export declare function parseCelLegacy(expression: string): ExpressionHandle | null;
|
|
45
|
+
/**
|
|
46
|
+
* The function table handed to `cel-js` for a registry, built once: every
|
|
47
|
+
* function the registry lists, wrapped for cel-legacy. Verified on the real
|
|
48
|
+
* engine (2026-11-07): `cel-js` 0.8.2 accepts the table and calls it.
|
|
49
|
+
*
|
|
50
|
+
* Exported so `ConditionService.prepareEngine` can build it before a budget
|
|
51
|
+
* starts; otherwise the first evaluation builds it inside its budget.
|
|
52
|
+
*/
|
|
53
|
+
export declare const readCelLegacyFunctions: (registry: BPMExpressionFunctionRegistry) => Readonly<Record<string, CelLegacyFunction>>;
|
|
54
|
+
/**
|
|
55
|
+
* The cel-legacy adapter for a registry. A host function the registry no
|
|
56
|
+
* longer has fails the evaluation with `EXPRESSION_FUNCTION_FAILED` before the
|
|
57
|
+
* engine runs; any other unknown name keeps `cel-js`'s own error.
|
|
58
|
+
*/
|
|
59
|
+
export declare const createCelLegacyAdapter: (registry: BPMExpressionFunctionRegistry) => ExpressionEngineAdapter;
|
|
60
|
+
/** The built-ins-only adapter, used wherever no registry was handed in. */
|
|
61
|
+
export declare const celLegacyAdapter: ExpressionEngineAdapter;
|
|
62
|
+
export {};
|
|
@@ -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,4E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
|
|
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;
|