@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,176 @@
|
|
|
1
|
+
import { ExpressionLintIssue, ExpressionUsagePoint } from '@rytass/bpm-core-shared';
|
|
2
|
+
import { FormDefinitionSchema, FormFieldDefinition } from '@rytass/bpm-core-shared/form';
|
|
3
|
+
import type { BPMExpressionFunctionRegistry } from '../expression-function/expression-function.types';
|
|
4
|
+
import { ExpressionDialect } from './expression-dialect';
|
|
5
|
+
/**
|
|
6
|
+
* A chain of member and index steps from a root: `form.items[0].qty` is
|
|
7
|
+
* `{ root: 'form', segments: ['items', '0', 'qty'] }`. `segments` stops at the
|
|
8
|
+
* first step that is not a literal (a computed index or a method call), and
|
|
9
|
+
* `complete` is then `false`.
|
|
10
|
+
*/
|
|
11
|
+
export interface ExpressionFieldPath {
|
|
12
|
+
readonly complete: boolean;
|
|
13
|
+
readonly root: string;
|
|
14
|
+
readonly segments: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
export interface ExpressionFunctionCall {
|
|
17
|
+
readonly argumentCount: number;
|
|
18
|
+
readonly name: string;
|
|
19
|
+
/** `true` for a method call (`x.contains(y)`), `false` for `f(x)`. */
|
|
20
|
+
readonly receiver: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A method or macro called directly on a path from a root:
|
|
24
|
+
* `form.items.exists(r, ...)` is `{ name: 'exists', path: form.items }`.
|
|
25
|
+
*/
|
|
26
|
+
export interface ExpressionReceiverPath {
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly path: ExpressionFieldPath;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A key that is not a literal: an index (`form[k]`, `form.a[form.b]`) or a map
|
|
32
|
+
* literal key (`{form.k: 1}`). `root` is the root the indexed chain starts at,
|
|
33
|
+
* `null` for map keys and chains that start elsewhere.
|
|
34
|
+
*/
|
|
35
|
+
export interface ExpressionComputedKey {
|
|
36
|
+
readonly kind: 'INDEX' | 'MAP_KEY';
|
|
37
|
+
readonly root: string | null;
|
|
38
|
+
}
|
|
39
|
+
export interface ExpressionReferences {
|
|
40
|
+
/** Highest nesting of `all`/`exists`/`exists_one`/`map`/`filter`. */
|
|
41
|
+
readonly comprehensionDepth: number;
|
|
42
|
+
readonly computedKeys: readonly ExpressionComputedKey[];
|
|
43
|
+
readonly dialect: ExpressionDialect;
|
|
44
|
+
/** Paths read on the right of a `/`. */
|
|
45
|
+
readonly divisorFieldPaths: readonly ExpressionFieldPath[];
|
|
46
|
+
readonly fieldPaths: readonly ExpressionFieldPath[];
|
|
47
|
+
/** Top-level form field keys read through `form` or `formData`. */
|
|
48
|
+
readonly formFieldKeys: readonly string[];
|
|
49
|
+
readonly functionCalls: readonly ExpressionFunctionCall[];
|
|
50
|
+
/** Paths tested by `has(...)` or compared with `null`, `""` or `[]`. */
|
|
51
|
+
readonly guardedFieldPaths: readonly ExpressionFieldPath[];
|
|
52
|
+
/** The arguments of `has(...)`. */
|
|
53
|
+
readonly hasArguments: readonly ExpressionFieldPath[];
|
|
54
|
+
/**
|
|
55
|
+
* Parsed nodes. cel-v2 counts AST nodes (the engine refuses more than
|
|
56
|
+
* 200); cel-legacy counts CST atoms, steps and operators, which is a
|
|
57
|
+
* different measure and only comparable with itself.
|
|
58
|
+
*/
|
|
59
|
+
readonly nodeCount: number;
|
|
60
|
+
/** Paths read inside an operand of `||`. */
|
|
61
|
+
readonly orOperandFieldPaths: readonly ExpressionFieldPath[];
|
|
62
|
+
readonly receiverPaths: readonly ExpressionReceiverPath[];
|
|
63
|
+
/** `__proto__`, `constructor` or `prototype` used as a member, key or map key. */
|
|
64
|
+
readonly reservedSegments: readonly string[];
|
|
65
|
+
/** Free identifiers: names the expression reads that nothing in it binds. */
|
|
66
|
+
readonly roots: readonly string[];
|
|
67
|
+
/** Roots used as a value themselves, not as the start of a path. */
|
|
68
|
+
readonly wholeRootReferences: readonly string[];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* What `readExpressionReferences` found. `UNAVAILABLE` is a cel-legacy
|
|
72
|
+
* expression whose parser returned no CST to walk (the unit tests' `cel-js`
|
|
73
|
+
* shim does that): per docs/24 §1 the old dialect then keeps its textual lint.
|
|
74
|
+
*/
|
|
75
|
+
export type ExpressionReferencesResult = {
|
|
76
|
+
readonly references: ExpressionReferences;
|
|
77
|
+
readonly status: 'OK';
|
|
78
|
+
} | {
|
|
79
|
+
readonly limitExceeded: boolean;
|
|
80
|
+
readonly status: 'PARSE_FAILED';
|
|
81
|
+
} | {
|
|
82
|
+
readonly status: 'UNAVAILABLE';
|
|
83
|
+
};
|
|
84
|
+
export declare const RESERVED_PATH_SEGMENTS: ReadonlySet<string>;
|
|
85
|
+
/** ADR 22 §3.4 / docs/24 §2.7. */
|
|
86
|
+
export declare const EXPRESSION_MAX_COMPREHENSION_DEPTH = 2;
|
|
87
|
+
/** Unique top-level keys of the paths rooted at `form` or `formData`, in first-seen order. */
|
|
88
|
+
export declare const readFormFieldKeys: (paths: readonly ExpressionFieldPath[]) => readonly string[];
|
|
89
|
+
/**
|
|
90
|
+
* The roots, field paths, function calls and structure an expression uses,
|
|
91
|
+
* read from its AST without evaluating it. Names a comprehension binds (`x`
|
|
92
|
+
* in `form.items.exists(x, x.qty > 0)`) are only in scope inside it: the same
|
|
93
|
+
* name outside it is a root.
|
|
94
|
+
*
|
|
95
|
+
* Works for both dialects. cel-v2 reads the engine's AST; cel-legacy walks the
|
|
96
|
+
* CST of `cel-js` and answers `UNAVAILABLE` when there is none to walk.
|
|
97
|
+
*/
|
|
98
|
+
export declare function readExpressionReferences(expression: string, dialect?: ExpressionDialect): ExpressionReferencesResult;
|
|
99
|
+
/** Whether the expression reads the top-level form field `fieldKey`. */
|
|
100
|
+
export declare const readsFormField: (references: ExpressionReferences, fieldKey: string) => boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Whether the expression steps inside the table field `tableKey`
|
|
103
|
+
* (`form.items.qty`, `form.items[0]`, `form.items.exists(r, ...)`), the AST
|
|
104
|
+
* twin of `referencesTableInternals` (ADR 16 §3.8). The table as a whole
|
|
105
|
+
* (`size(form.items)`, `form.items.size()`, `form.items == null`) is not.
|
|
106
|
+
*/
|
|
107
|
+
export declare const readsTableInternals: (references: ExpressionReferences, tableKey: string) => boolean;
|
|
108
|
+
/** The slice of the function registry the lint uses (docs/24 §3: P3 implements it). */
|
|
109
|
+
export type ExpressionFunctionAvailability = Pick<BPMExpressionFunctionRegistry, 'assertPublishable' | 'get'>;
|
|
110
|
+
export interface ExpressionLintContext {
|
|
111
|
+
/** Overrides the use point's roots. Without either, roots are not checked. */
|
|
112
|
+
readonly allowedRootIdentifiers?: readonly string[];
|
|
113
|
+
/**
|
|
114
|
+
* The bound form. With it, field keys are checked against the schema and
|
|
115
|
+
* the type check knows each field's type; without it every field is `dyn`.
|
|
116
|
+
*/
|
|
117
|
+
readonly formSchema?: FormDefinitionSchema | null;
|
|
118
|
+
/**
|
|
119
|
+
* The registry that answers which functions are available. Absent means
|
|
120
|
+
* only the nine built-ins exist (`BPM_BUILT_IN_EXPRESSION_FUNCTION_NAMES`);
|
|
121
|
+
* `ConditionService` fills it with the registry it was given. Host code:
|
|
122
|
+
* a throw or a malformed answer is isolated and refuses the names asked
|
|
123
|
+
* about (`EXPR_FUNCTION_NOT_REGISTERED`), never its message.
|
|
124
|
+
*/
|
|
125
|
+
readonly functionRegistry?: ExpressionFunctionAvailability | null;
|
|
126
|
+
/** The field a `SET_FORM_FIELD` writes; decides its result type. */
|
|
127
|
+
readonly targetField?: FormFieldDefinition | null;
|
|
128
|
+
readonly usagePoint?: ExpressionUsagePoint;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The CEL types a form field is declared with for the lint's type check
|
|
132
|
+
* (docs/24-design/p2-p3 §2.2). Only names the engine accepts are produced;
|
|
133
|
+
* anything else is `dyn`. Never `optional(...)`: the engine cannot convert it.
|
|
134
|
+
*/
|
|
135
|
+
export declare const readExpressionFieldType: (field: FormFieldDefinition) => string;
|
|
136
|
+
/**
|
|
137
|
+
* The called function names the registry cannot vouch for, in first-seen
|
|
138
|
+
* order and without duplicates (ADR 22 §5.3; publish and rollback share it).
|
|
139
|
+
*
|
|
140
|
+
* Only names {@link isRegistryFunctionName} accepts — `…_vN` and the nine
|
|
141
|
+
* built-ins — are put to `assertPublishable`; any other name can never be
|
|
142
|
+
* registered and is always reported. Without a registry only the built-ins
|
|
143
|
+
* exist.
|
|
144
|
+
*
|
|
145
|
+
* The registry is host code and is isolated: an `assertPublishable` that
|
|
146
|
+
* throws or answers something other than a list of strings makes every name
|
|
147
|
+
* asked about unavailable. The result only ever holds names the expression
|
|
148
|
+
* itself called, never a value the registry returned.
|
|
149
|
+
*/
|
|
150
|
+
export declare function readUnavailableExpressionFunctions(names: readonly string[], registry: ExpressionFunctionAvailability | null | undefined): readonly string[];
|
|
151
|
+
/**
|
|
152
|
+
* The cel-v2 lint of one expression (ADR 22 §3.4, docs/24 §2.2): errors that
|
|
153
|
+
* refuse a publish and warnings that do not, in that order. The expression is
|
|
154
|
+
* expected trimmed and within the length limit (`ConditionService` checks
|
|
155
|
+
* both first).
|
|
156
|
+
*
|
|
157
|
+
* `environmentRegistry` is the registry evaluation will run with (the one
|
|
158
|
+
* `ConditionService` was given): the expression is parsed and type-checked in
|
|
159
|
+
* its cel-v2 environment, so the built-ins and the host's functions are
|
|
160
|
+
* type-checked like the engine's own. Absent means the built-ins only. It is
|
|
161
|
+
* separate from `context.functionRegistry`, which only answers availability
|
|
162
|
+
* (`assertPublishable`, `get`) and need not be able to build an environment.
|
|
163
|
+
*
|
|
164
|
+
* The type check (`env.check()`) runs only when nothing structural is wrong
|
|
165
|
+
* and every function called is one that environment knows; a call to one it
|
|
166
|
+
* does not know is covered by `EXPR_FUNCTION_NOT_REGISTERED` instead.
|
|
167
|
+
*/
|
|
168
|
+
export declare function lintCelV2Expression(expression: string, label: string, context?: ExpressionLintContext, environmentRegistry?: BPMExpressionFunctionRegistry | null): readonly ExpressionLintIssue[];
|
|
169
|
+
/**
|
|
170
|
+
* The global function names an expression calls that cel-v2 does not provide
|
|
171
|
+
* itself: the built-ins and host functions a rollback must find registered
|
|
172
|
+
* (docs/24 §1). `null` when the expression cannot be read. Hand the result to
|
|
173
|
+
* {@link readUnavailableExpressionFunctions}, which applies the same name
|
|
174
|
+
* rule and registry isolation as the publish lint.
|
|
175
|
+
*/
|
|
176
|
+
export declare function readExpressionHostFunctionNames(expression: string, dialect?: ExpressionDialect): readonly string[] | null;
|