@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.
Files changed (149) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/package.json +3 -2
  3. package/src/index.d.ts +1 -0
  4. package/src/index.js +1 -0
  5. package/src/index.js.map +1 -1
  6. package/src/lib/attachment/attachment.service.d.ts +23 -1
  7. package/src/lib/attachment/attachment.service.js +111 -24
  8. package/src/lib/attachment/attachment.service.js.map +1 -1
  9. package/src/lib/bpm/bpm-root-options.d.ts +13 -0
  10. package/src/lib/bpm/bpm-root-options.js.map +1 -1
  11. package/src/lib/bpm/bpm-root.module.d.ts +12 -0
  12. package/src/lib/bpm/bpm-root.module.js +5 -0
  13. package/src/lib/bpm/bpm-root.module.js.map +1 -1
  14. package/src/lib/condition/adapters/cel-legacy.adapter.d.ts +62 -0
  15. package/src/lib/condition/adapters/cel-legacy.adapter.js +141 -0
  16. package/src/lib/condition/adapters/cel-legacy.adapter.js.map +1 -0
  17. package/src/lib/condition/adapters/cel-v2.adapter.d.ts +76 -0
  18. package/src/lib/condition/adapters/cel-v2.adapter.js +371 -0
  19. package/src/lib/condition/adapters/cel-v2.adapter.js.map +1 -0
  20. package/src/lib/condition/condition.service.d.ts +90 -5
  21. package/src/lib/condition/condition.service.js +287 -71
  22. package/src/lib/condition/condition.service.js.map +1 -1
  23. package/src/lib/condition/expression-ast.d.ts +176 -0
  24. package/src/lib/condition/expression-ast.js +1254 -0
  25. package/src/lib/condition/expression-ast.js.map +1 -0
  26. package/src/lib/condition/expression-budget.d.ts +44 -0
  27. package/src/lib/condition/expression-budget.js +61 -0
  28. package/src/lib/condition/expression-budget.js.map +1 -0
  29. package/src/lib/condition/expression-dialect.d.ts +29 -0
  30. package/src/lib/condition/expression-dialect.js +44 -0
  31. package/src/lib/condition/expression-dialect.js.map +1 -0
  32. package/src/lib/condition/expression-differential.corpus.d.ts +34 -0
  33. package/src/lib/condition/expression-differential.corpus.js +995 -0
  34. package/src/lib/condition/expression-differential.corpus.js.map +1 -0
  35. package/src/lib/condition/expression-differential.d.ts +33 -0
  36. package/src/lib/condition/expression-differential.js +48 -0
  37. package/src/lib/condition/expression-differential.js.map +1 -0
  38. package/src/lib/condition/expression-engine-failure.d.ts +15 -0
  39. package/src/lib/condition/expression-engine-failure.js +22 -0
  40. package/src/lib/condition/expression-engine-failure.js.map +1 -0
  41. package/src/lib/condition/expression-errors.d.ts +40 -0
  42. package/src/lib/condition/expression-errors.js +105 -0
  43. package/src/lib/condition/expression-errors.js.map +1 -0
  44. package/src/lib/condition/expression-function-invocation.d.ts +50 -0
  45. package/src/lib/condition/expression-function-invocation.js +290 -0
  46. package/src/lib/condition/expression-function-invocation.js.map +1 -0
  47. package/src/lib/condition/expression-result.walker.d.ts +18 -0
  48. package/src/lib/condition/expression-result.walker.js +152 -0
  49. package/src/lib/condition/expression-result.walker.js.map +1 -0
  50. package/src/lib/condition/expression-runtime.d.ts +70 -0
  51. package/src/lib/condition/expression-runtime.js +134 -0
  52. package/src/lib/condition/expression-runtime.js.map +1 -0
  53. package/src/lib/condition/index.d.ts +4 -0
  54. package/src/lib/condition/index.js +8 -0
  55. package/src/lib/condition/index.js.map +1 -1
  56. package/src/lib/delegation/delegation-rule.entity.d.ts +7 -0
  57. package/src/lib/delegation/delegation-rule.entity.js +10 -0
  58. package/src/lib/delegation/delegation-rule.entity.js.map +1 -1
  59. package/src/lib/delegation/delegation.service.d.ts +7 -1
  60. package/src/lib/delegation/delegation.service.js +22 -5
  61. package/src/lib/delegation/delegation.service.js.map +1 -1
  62. package/src/lib/delegation/dto/delegation-rule.input.d.ts +2 -0
  63. package/src/lib/delegation/dto/delegation-rule.input.js +10 -0
  64. package/src/lib/delegation/dto/delegation-rule.input.js.map +1 -1
  65. package/src/lib/expression-function/expression-function.built-ins.d.ts +9 -0
  66. package/src/lib/expression-function/expression-function.built-ins.js +117 -0
  67. package/src/lib/expression-function/expression-function.built-ins.js.map +1 -0
  68. package/src/lib/expression-function/expression-function.module.d.ts +19 -0
  69. package/src/lib/expression-function/expression-function.module.js +34 -0
  70. package/src/lib/expression-function/expression-function.module.js.map +1 -0
  71. package/src/lib/expression-function/expression-function.provider.d.ts +17 -0
  72. package/src/lib/expression-function/expression-function.provider.js +39 -0
  73. package/src/lib/expression-function/expression-function.provider.js.map +1 -0
  74. package/src/lib/expression-function/expression-function.registry.d.ts +36 -0
  75. package/src/lib/expression-function/expression-function.registry.js +231 -0
  76. package/src/lib/expression-function/expression-function.registry.js.map +1 -0
  77. package/src/lib/expression-function/expression-function.types.d.ts +30 -0
  78. package/src/lib/expression-function/expression-function.types.js +8 -0
  79. package/src/lib/expression-function/expression-function.types.js.map +1 -0
  80. package/src/lib/expression-function/index.d.ts +5 -0
  81. package/src/lib/expression-function/index.js +9 -0
  82. package/src/lib/expression-function/index.js.map +1 -0
  83. package/src/lib/form/form-schema.validator.js +53 -6
  84. package/src/lib/form/form-schema.validator.js.map +1 -1
  85. package/src/lib/form-data-source/form-data-source-value-resolver.service.d.ts +12 -1
  86. package/src/lib/form-data-source/form-data-source-value-resolver.service.js +45 -26
  87. package/src/lib/form-data-source/form-data-source-value-resolver.service.js.map +1 -1
  88. package/src/lib/form-data-source/form-data-source.expression.d.ts +95 -0
  89. package/src/lib/form-data-source/form-data-source.expression.js +267 -0
  90. package/src/lib/form-data-source/form-data-source.expression.js.map +1 -0
  91. package/src/lib/form-data-source/form-data-source.module.js +4 -0
  92. package/src/lib/form-data-source/form-data-source.module.js.map +1 -1
  93. package/src/lib/form-data-source/form-data-source.service.d.ts +22 -3
  94. package/src/lib/form-data-source/form-data-source.service.js +78 -18
  95. package/src/lib/form-data-source/form-data-source.service.js.map +1 -1
  96. package/src/lib/form-data-source/form-data-source.validation.d.ts +47 -4
  97. package/src/lib/form-data-source/form-data-source.validation.js +151 -23
  98. package/src/lib/form-data-source/form-data-source.validation.js.map +1 -1
  99. package/src/lib/migrations/0000000030000-delegation-scope-condition-dialect.d.ts +22 -0
  100. package/src/lib/migrations/0000000030000-delegation-scope-condition-dialect.js +76 -0
  101. package/src/lib/migrations/0000000030000-delegation-scope-condition-dialect.js.map +1 -0
  102. package/src/lib/migrations/index.d.ts +1 -0
  103. package/src/lib/migrations/index.js +3 -0
  104. package/src/lib/migrations/index.js.map +1 -1
  105. package/src/lib/notification/notification.service.d.ts +1 -1
  106. package/src/lib/notification/notification.service.js +7 -3
  107. package/src/lib/notification/notification.service.js.map +1 -1
  108. package/src/lib/template/dto/expression-designer.dto.d.ts +107 -0
  109. package/src/lib/template/dto/expression-designer.dto.js +415 -0
  110. package/src/lib/template/dto/expression-designer.dto.js.map +1 -0
  111. package/src/lib/template/expression-designer.queries.d.ts +16 -0
  112. package/src/lib/template/expression-designer.queries.js +66 -0
  113. package/src/lib/template/expression-designer.queries.js.map +1 -0
  114. package/src/lib/template/expression-designer.service.d.ts +72 -0
  115. package/src/lib/template/expression-designer.service.js +543 -0
  116. package/src/lib/template/expression-designer.service.js.map +1 -0
  117. package/src/lib/template/index.d.ts +2 -0
  118. package/src/lib/template/index.js +2 -0
  119. package/src/lib/template/index.js.map +1 -1
  120. package/src/lib/template/template.module.js +4 -0
  121. package/src/lib/template/template.module.js.map +1 -1
  122. package/src/lib/template/template.service.d.ts +37 -1
  123. package/src/lib/template/template.service.js +317 -29
  124. package/src/lib/template/template.service.js.map +1 -1
  125. package/src/lib/template/workflow-definition.validator.d.ts +7 -0
  126. package/src/lib/template/workflow-definition.validator.js +26 -2
  127. package/src/lib/template/workflow-definition.validator.js.map +1 -1
  128. package/src/lib/workflow-engine/time-budget.d.ts +13 -0
  129. package/src/lib/workflow-engine/time-budget.js +58 -0
  130. package/src/lib/workflow-engine/time-budget.js.map +1 -0
  131. package/src/lib/workflow-engine/workflow-engine.service.d.ts +24 -0
  132. package/src/lib/workflow-engine/workflow-engine.service.js +249 -65
  133. package/src/lib/workflow-engine/workflow-engine.service.js.map +1 -1
  134. package/src/lib/workflow-engine/workflow-service-task-dispatcher.token.js +4 -0
  135. package/src/lib/workflow-engine/workflow-service-task-dispatcher.token.js.map +1 -1
  136. package/src/lib/workflow-webhook/workflow-webhook-delivery.service.d.ts +3 -1
  137. package/src/lib/workflow-webhook/workflow-webhook-delivery.service.js +11 -2
  138. package/src/lib/workflow-webhook/workflow-webhook-delivery.service.js.map +1 -1
  139. package/src/lib/workflow-webhook/workflow-webhook-enqueue.d.ts +8 -1
  140. package/src/lib/workflow-webhook/workflow-webhook-enqueue.js +70 -27
  141. package/src/lib/workflow-webhook/workflow-webhook-enqueue.js.map +1 -1
  142. package/src/lib/workflow-webhook/workflow-webhook-expression.d.ts +57 -0
  143. package/src/lib/workflow-webhook/workflow-webhook-expression.js +123 -0
  144. package/src/lib/workflow-webhook/workflow-webhook-expression.js.map +1 -0
  145. package/src/lib/workflow-webhook/workflow-webhook.module.js +4 -0
  146. package/src/lib/workflow-webhook/workflow-webhook.module.js.map +1 -1
  147. package/src/lib/workflow-webhook/workflow-webhook.validator.d.ts +7 -0
  148. package/src/lib/workflow-webhook/workflow-webhook.validator.js +29 -6
  149. package/src/lib/workflow-webhook/workflow-webhook.validator.js.map +1 -1
@@ -0,0 +1,267 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EXPRESSION_BINDING_DIALECT = void 0;
4
+ exports.readExpressionBindingDependencies = readExpressionBindingDependencies;
5
+ exports.callsOnlyBuiltInExpressionFunctions = callsOnlyBuiltInExpressionFunctions;
6
+ exports.isExpressionBindingValue = isExpressionBindingValue;
7
+ exports.createFormDataSourceExpressionEvaluator = createFormDataSourceExpressionEvaluator;
8
+ exports.readExpressionBindingResultType = readExpressionBindingResultType;
9
+ exports.lintExpressionBindings = lintExpressionBindings;
10
+ const bpm_core_shared_1 = require("@rytass/bpm-core-shared");
11
+ const cel_v2_adapter_1 = require("../condition/adapters/cel-v2.adapter");
12
+ const expression_ast_1 = require("../condition/expression-ast");
13
+ const expression_errors_1 = require("../condition/expression-errors");
14
+ const form_data_source_errors_1 = require("./form-data-source.errors");
15
+ /*
16
+ * `EXPRESSION` binding sources (ADR 22 §3.7, docs/24 §2.8). One evaluator is
17
+ * shared by search, resolve and submit through `readBindingValues`, so the
18
+ * three paths cannot compute different parameter values for the same input.
19
+ *
20
+ * An `EXPRESSION` binding is always cel-v2 and may only call the built-in
21
+ * functions. It is evaluated from the stored schema; nothing the browser sends
22
+ * is ever read as an expression.
23
+ */
24
+ /** The binding dialect: there is no field for it (docs/24 §2.4). */
25
+ exports.EXPRESSION_BINDING_DIALECT = 'cel-v2';
26
+ /** The roots a DataSource binding may read: `form`, and `row` in a table column. */
27
+ const DATA_SOURCE_BINDING_ROOTS = bpm_core_shared_1.EXPRESSION_ROOT_IDENTIFIERS_BY_USAGE_POINT.DATA_SOURCE_BINDING;
28
+ /** The roots a top-level field's binding may read: `form` only. */
29
+ const TOP_LEVEL_BINDING_ROOTS = ['form'];
30
+ const BUILT_IN_FUNCTION_NAMES = new Set(bpm_core_shared_1.BPM_BUILT_IN_EXPRESSION_FUNCTION_NAMES);
31
+ /**
32
+ * The static dependencies of a binding expression, or `null` when they cannot
33
+ * be known: it does not parse, reads a root other than `form` and `row`, uses
34
+ * a root as a whole value, or indexes with a computed key. The publish lint
35
+ * refuses each of those; reaching one at run time means the schema was written
36
+ * around it, and the caller fails closed.
37
+ */
38
+ function readExpressionBindingDependencies(expression) {
39
+ const parsed = (0, expression_ast_1.readExpressionReferences)(expression.trim(), exports.EXPRESSION_BINDING_DIALECT);
40
+ if (parsed.status !== 'OK') {
41
+ return null;
42
+ }
43
+ const { references } = parsed;
44
+ if (references.roots.some((root) => !DATA_SOURCE_BINDING_ROOTS.includes(root)) ||
45
+ references.wholeRootReferences.length > 0 ||
46
+ references.computedKeys.length > 0 ||
47
+ references.reservedSegments.length > 0) {
48
+ return null;
49
+ }
50
+ const rowColumnKeys = [
51
+ ...new Set(references.fieldPaths
52
+ .filter((path) => path.root === 'row' && path.segments.length > 0)
53
+ .map((path) => path.segments[0])),
54
+ ];
55
+ const formFieldKeys = [
56
+ ...new Set(references.fieldPaths
57
+ .filter((path) => path.root === 'form' && path.segments.length > 0)
58
+ .map((path) => path.segments[0])),
59
+ ];
60
+ return { formFieldKeys, rowColumnKeys };
61
+ }
62
+ /**
63
+ * Whether the expression calls only cel-v2's own functions and the nine
64
+ * built-ins (docs/24 §1: no host functions in a binding in v1). `false` for an
65
+ * expression that cannot be read.
66
+ */
67
+ function callsOnlyBuiltInExpressionFunctions(expression) {
68
+ const names = (0, expression_ast_1.readExpressionHostFunctionNames)(expression.trim(), exports.EXPRESSION_BINDING_DIALECT);
69
+ return names !== null && names.every((name) => BUILT_IN_FUNCTION_NAMES.has(name));
70
+ }
71
+ function isExpressionBindingValue(value) {
72
+ return (value === null ||
73
+ typeof value === 'boolean' ||
74
+ typeof value === 'string' ||
75
+ (typeof value === 'number' && Number.isFinite(value)));
76
+ }
77
+ const EXPRESSION_BINDING_LABEL = 'dataSource.binding';
78
+ const invalidBinding = () => new form_data_source_errors_1.BPMFormDataSourceException(form_data_source_errors_1.BPM_FORM_DATA_SOURCE_ERROR_CODES.INVALID_BINDING);
79
+ /**
80
+ * Picks own properties only: a field may be named `constructor`, and a plain
81
+ * index would hand the engine a function off the prototype.
82
+ */
83
+ function pickOwnValues(source, keys) {
84
+ return Object.fromEntries(keys
85
+ .filter((key) => Object.prototype.hasOwnProperty.call(source, key))
86
+ .map((key) => [key, source[key]]));
87
+ }
88
+ function createFormDataSourceExpressionEvaluator(options) {
89
+ return {
90
+ evaluate({ expression, formData, isPresent, position, }) {
91
+ const conditionService = options.conditionService;
92
+ if (!conditionService || typeof expression !== 'string') {
93
+ throw invalidBinding();
94
+ }
95
+ const dependencies = readExpressionBindingDependencies(expression);
96
+ if (dependencies === null ||
97
+ !callsOnlyBuiltInExpressionFunctions(expression)) {
98
+ throw invalidBinding();
99
+ }
100
+ // Roots by position (docs/24 §2.8), mirroring the publish lint: only a
101
+ // table column has a row, so at the top level `row` is not a root at
102
+ // all. A top-level field whose stored expression reads `row` was
103
+ // written around the lint and fails closed instead of waiting forever.
104
+ const rowValues = position.kind === 'TABLE_COLUMN' ? position.rowValues : undefined;
105
+ const allowedRootIdentifiers = position.kind === 'TABLE_COLUMN'
106
+ ? DATA_SOURCE_BINDING_ROOTS
107
+ : TOP_LEVEL_BINDING_ROOTS;
108
+ if (position.kind === 'TOP_LEVEL' && dependencies.rowColumnKeys.length > 0) {
109
+ throw invalidBinding();
110
+ }
111
+ const form = pickOwnValues(formData, dependencies.formFieldKeys);
112
+ const row = rowValues
113
+ ? pickOwnValues(rowValues, dependencies.rowColumnKeys)
114
+ : undefined;
115
+ const waiting = dependencies.formFieldKeys.some((key) => !isPresent(form[key])) ||
116
+ (dependencies.rowColumnKeys.length > 0 &&
117
+ (!row ||
118
+ dependencies.rowColumnKeys.some((key) => !isPresent(row[key]))));
119
+ if (waiting) {
120
+ return undefined;
121
+ }
122
+ const value = (() => {
123
+ try {
124
+ return conditionService.evaluateValue(expression, row ? { form, row } : { form }, EXPRESSION_BINDING_LABEL, {
125
+ allowedRootIdentifiers,
126
+ ...(options.budget ? { budget: options.budget } : {}),
127
+ dialect: exports.EXPRESSION_BINDING_DIALECT,
128
+ });
129
+ }
130
+ catch (error) {
131
+ // Out of budget keeps the source's existing UNAVAILABLE meaning;
132
+ // anything else the expression did wrong is a binding that does not
133
+ // work (docs/24 §2.1: no new DataSource code). The engine's text
134
+ // never leaves: only the code is read.
135
+ throw new form_data_source_errors_1.BPMFormDataSourceException(error instanceof expression_errors_1.ExpressionRuntimeError &&
136
+ error.code === 'EXPRESSION_BUDGET_EXCEEDED'
137
+ ? form_data_source_errors_1.BPM_FORM_DATA_SOURCE_ERROR_CODES.TIMEOUT
138
+ : form_data_source_errors_1.BPM_FORM_DATA_SOURCE_ERROR_CODES.INVALID_BINDING);
139
+ }
140
+ })();
141
+ if (!isExpressionBindingValue(value)) {
142
+ throw invalidBinding();
143
+ }
144
+ return value;
145
+ },
146
+ };
147
+ }
148
+ // ------------------------------------------------------------- publish lint --
149
+ /** CEL base types a parameter of each type accepts from an expression. */
150
+ const ACCEPTED_RESULT_TYPES = {
151
+ BOOLEAN: ['bool'],
152
+ NUMBER: ['double', 'int', 'uint'],
153
+ STRING: ['string'],
154
+ // ADR 22 §3.7: an expression yields a scalar, never a list.
155
+ STRING_ARRAY: [],
156
+ };
157
+ const readSchemaVariable = (fields) => Object.fromEntries(fields
158
+ .filter((field) => typeof field?.fieldKey === 'string' &&
159
+ !expression_ast_1.RESERVED_PATH_SEGMENTS.has(field.fieldKey))
160
+ .map((field) => [
161
+ field.fieldKey,
162
+ (0, expression_ast_1.readExpressionFieldType)(field),
163
+ ]));
164
+ /**
165
+ * The CEL type the expression evaluates to, read with `form` (and `row`) at
166
+ * their schema types, then untyped; `null` when neither check passes or the
167
+ * engine cannot say. Only built-ins can appear here (host functions are
168
+ * refused first), so the built-ins environment is the right one.
169
+ */
170
+ function readExpressionBindingResultType(expression, schema, columns) {
171
+ const check = (typed) => {
172
+ try {
173
+ const environment = (0, cel_v2_adapter_1.loadCelV2Environment)().clone();
174
+ if (typed) {
175
+ environment.registerVariable({
176
+ name: 'form',
177
+ schema: readSchemaVariable(schema.fields),
178
+ });
179
+ if (columns) {
180
+ environment.registerVariable({
181
+ name: 'row',
182
+ schema: readSchemaVariable(columns),
183
+ });
184
+ }
185
+ }
186
+ const result = environment.parse(expression).check();
187
+ return result.valid && typeof result.type === 'string'
188
+ ? result.type
189
+ : null;
190
+ }
191
+ catch {
192
+ return null;
193
+ }
194
+ };
195
+ return check(true) ?? check(false);
196
+ }
197
+ const isResultTypeAccepted = (type, parameterType) => {
198
+ if (parameterType === 'STRING_ARRAY') {
199
+ return false;
200
+ }
201
+ if (type === null) {
202
+ return true;
203
+ }
204
+ const base = type.split('<')[0].trim();
205
+ return (base === 'dyn' ||
206
+ base === 'null_type' ||
207
+ ACCEPTED_RESULT_TYPES[parameterType].includes(base));
208
+ };
209
+ /**
210
+ * The publish lint of a field's `EXPRESSION` bindings (docs/24 §2.8): each
211
+ * one must pass the cel-v2 lint of `DATA_SOURCE_BINDING` — roots by position
212
+ * (`form`; `form` and `row` in a table column), built-in functions only
213
+ * (`EXPR_FUNCTION_NOT_ALLOWED`), the bound form's fields and types — read only
214
+ * sibling columns through `row`, and produce a value of the parameter's type
215
+ * (`EXPR_RESULT_TYPE_MISMATCH`; a `STRING_ARRAY` parameter never fits).
216
+ *
217
+ * Lines are `<path>.bindings[<i>].from.expression: <code>[ <subject>]`. Lint
218
+ * and evaluation share the injected `ConditionService`; without one the
219
+ * binding cannot be checked and the line says so.
220
+ */
221
+ function lintExpressionBindings(input) {
222
+ const parameterTypes = new Map(input.descriptor.parameters.map((parameter) => [
223
+ parameter.key,
224
+ parameter.type,
225
+ ]));
226
+ return input.reference.bindings.flatMap((binding, index) => {
227
+ if (binding.from.kind !== 'EXPRESSION') {
228
+ return [];
229
+ }
230
+ const label = `${input.path}.bindings[${index}].from.expression`;
231
+ const expression = typeof binding.from.expression === 'string'
232
+ ? binding.from.expression.trim()
233
+ : '';
234
+ if (!input.conditionService) {
235
+ return [
236
+ `${input.path}.bindings expression cannot be checked: no ConditionService is available`,
237
+ ];
238
+ }
239
+ const lintErrors = input.conditionService.lintExpression(expression, label, {
240
+ allowedRootIdentifiers: input.columns
241
+ ? DATA_SOURCE_BINDING_ROOTS
242
+ : TOP_LEVEL_BINDING_ROOTS,
243
+ dialect: exports.EXPRESSION_BINDING_DIALECT,
244
+ formSchema: input.schema,
245
+ usagePoint: 'DATA_SOURCE_BINDING',
246
+ });
247
+ if (lintErrors.length > 0) {
248
+ return lintErrors;
249
+ }
250
+ const dependencies = readExpressionBindingDependencies(expression);
251
+ const columnKeys = new Set((input.columns ?? []).map((column) => column.fieldKey));
252
+ const unknownColumns = (dependencies?.rowColumnKeys ?? []).filter((key) => !columnKeys.has(key));
253
+ if (dependencies === null) {
254
+ return [`${label}: EXPR_PARSE_FAILED`];
255
+ }
256
+ if (unknownColumns.length > 0) {
257
+ return unknownColumns.map((key) => `${label}: EXPR_FIELD_UNKNOWN ${key}`);
258
+ }
259
+ const parameterType = parameterTypes.get(binding.parameter);
260
+ // An unknown parameter is reported by the binding lint already.
261
+ return parameterType &&
262
+ !isResultTypeAccepted(readExpressionBindingResultType(expression, input.schema, input.columns), parameterType)
263
+ ? [`${label}: EXPR_RESULT_TYPE_MISMATCH`]
264
+ : [];
265
+ });
266
+ }
267
+ //# sourceMappingURL=form-data-source.expression.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-data-source.expression.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/form-data-source/form-data-source.expression.ts"],"names":[],"mappings":";;;AAwEA,8EAuCC;AAOD,kFASC;AAKD,4DASC;AA0DD,0FAuFC;AAqCD,0EAkCC;AA8CD,wDAyEC;AA5dD,6DAGiC;AAQjC,yEAA4E;AAE5E,gEAKqC;AAIrC,sEAAwE;AACxE,uEAGmC;AAMnC;;;;;;;;GAQG;AAEH,oEAAoE;AACvD,QAAA,0BAA0B,GAAG,QAAiB,CAAC;AAE5D,oFAAoF;AACpF,MAAM,yBAAyB,GAC7B,4DAA0C,CAAC,mBAAmB,CAAC;AAEjE,mEAAmE;AACnE,MAAM,uBAAuB,GAAsB,CAAC,MAAM,CAAC,CAAC;AAE5D,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAC1D,wDAAsC,CACvC,CAAC;AAWF;;;;;;GAMG;AACH,SAAgB,iCAAiC,CAC/C,UAAkB;IAElB,MAAM,MAAM,GAAG,IAAA,yCAAwB,EACrC,UAAU,CAAC,IAAI,EAAE,EACjB,kCAA0B,CAC3B,CAAC;IAEF,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAE9B,IACE,UAAU,CAAC,KAAK,CAAC,IAAI,CA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,GAAG,KAAK,6BAA6B,CAAC;YACzC,CAAC,CAAC,EAAE,CAAC;IACT,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -5,6 +5,7 @@ exports.FormDataSourceModule = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const common_1 = require("@nestjs/common");
7
7
  const typeorm_1 = require("@nestjs/typeorm");
8
+ const condition_module_1 = require("../condition/condition.module");
8
9
  const workflow_engine_module_1 = require("../workflow-engine/workflow-engine.module");
9
10
  const approval_template_version_entity_1 = require("../template/approval-template-version.entity");
10
11
  const form_definition_version_entity_1 = require("../form/form-definition-version.entity");
@@ -26,6 +27,9 @@ let FormDataSourceModule = FormDataSourceModule_1 = class FormDataSourceModule {
26
27
  imports: [
27
28
  ...(options.imports ?? []),
28
29
  workflow_engine_module_1.WorkflowEngineModule,
30
+ // `EXPRESSION` bindings are linted and evaluated by the shared
31
+ // `ConditionService`, with the host's function registry.
32
+ condition_module_1.ConditionModule,
29
33
  typeorm_1.TypeOrmModule.forFeature([
30
34
  approval_template_version_entity_1.ApprovalTemplateVersionEntity,
31
35
  form_definition_version_entity_1.FormDefinitionVersionEntity,
@@ -1 +1 @@
1
- {"version":3,"file":"form-data-source.module.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/form-data-source/form-data-source.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAMwB;AACxB,6CAAgD;AAChD,sFAAiF;AACjF,mGAA6F;AAC7F,2FAAqF;AACrF,2EAAoF;AACpF,yEAAmE;AACnE,yEAAmE;AACnE,uGAA+F;AAC/F,qEAIkC;AAW3B,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAC/B,MAAM,CAAC,OAAO,CAAC,UAAuC,EAAE;QACtD,MAAM,gBAAgB,GACpB,OAAO,CAAC,gBAAgB,IAAI,iEAAqC,CAAC;QAEpE,OAAO;YACL,OAAO,EAAE;gBACP,sDAA6B;gBAC7B,4DAAmC;gBACnC,gDAAqB;aACtB;YACD,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE;gBACP,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;gBAC1B,6CAAoB;gBACpB,uBAAa,CAAC,UAAU,CAAC;oBACvB,gEAA6B;oBAC7B,4DAA2B;iBAC5B,CAAC;aACH;YACD,MAAM,EAAE,sBAAoB;YAC5B,SAAS,EAAE;gBACT,gBAAgB;gBAChB,gDAAqB;gBACrB,gDAAqB;gBACrB,4EAAkC;gBAClC;oBACE,OAAO,EAAE,4DAAmC;oBAC5C,WAAW,EAAE,4EAAkC;iBAChD;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAjCY,oDAAoB;+BAApB,oBAAoB;IAFhC,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,oBAAoB,CAiChC"}
1
+ {"version":3,"file":"form-data-source.module.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/form-data-source/form-data-source.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAMwB;AACxB,6CAAgD;AAChD,oEAAgE;AAChE,sFAAiF;AACjF,mGAA6F;AAC7F,2FAAqF;AACrF,2EAAoF;AACpF,yEAAmE;AACnE,yEAAmE;AACnE,uGAA+F;AAC/F,qEAIkC;AAW3B,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAC/B,MAAM,CAAC,OAAO,CAAC,UAAuC,EAAE;QACtD,MAAM,gBAAgB,GACpB,OAAO,CAAC,gBAAgB,IAAI,iEAAqC,CAAC;QAEpE,OAAO;YACL,OAAO,EAAE;gBACP,sDAA6B;gBAC7B,4DAAmC;gBACnC,gDAAqB;aACtB;YACD,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE;gBACP,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;gBAC1B,6CAAoB;gBACpB,+DAA+D;gBAC/D,yDAAyD;gBACzD,kCAAe;gBACf,uBAAa,CAAC,UAAU,CAAC;oBACvB,gEAA6B;oBAC7B,4DAA2B;iBAC5B,CAAC;aACH;YACD,MAAM,EAAE,sBAAoB;YAC5B,SAAS,EAAE;gBACT,gBAAgB;gBAChB,gDAAqB;gBACrB,gDAAqB;gBACrB,4EAAkC;gBAClC;oBACE,OAAO,EAAE,4DAAmC;oBAC5C,WAAW,EAAE,4EAAkC;iBAChD;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AApCY,oDAAoB;+BAApB,oBAAoB;IAFhC,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,oBAAoB,CAoChC"}
@@ -1,11 +1,14 @@
1
1
  import { FormDefinitionSchema, FormOptionFieldDefinition } from '@rytass/bpm-core-shared/form';
2
2
  import { Repository } from 'typeorm';
3
3
  import { BPMAuthContext } from '../bpm-auth';
4
+ import { ConditionService } from '../condition/condition.service';
4
5
  import { ApprovalTemplateVersionEntity } from '../template/approval-template-version.entity';
5
6
  import { FormDefinitionVersionEntity } from '../form/form-definition-version.entity';
6
7
  import { WorkflowEngineService } from '../workflow-engine/workflow-engine.service';
7
8
  import { BPMFormDataSourceDescriptor, BPMFormDataSourceOptionResult, BPMFormDataSourceRegistry, BPMFormDataSourceResolveResult } from './form-data-source.types';
8
- import { RowFieldValues } from './form-data-source.validation';
9
+ import { FormDataSourceBindingPosition } from './form-data-source.validation';
10
+ export type { FormDataSourceBindingPosition } from './form-data-source.validation';
11
+ export { createTableColumnBindingPosition, TOP_LEVEL_BINDING_POSITION, } from './form-data-source.validation';
9
12
  export interface BPMFormDataSourcePreviewInput {
10
13
  readonly cursor?: string | null;
11
14
  readonly fieldKey: string;
@@ -45,8 +48,9 @@ export declare class FormDataSourceService {
45
48
  private readonly approvalTemplateVersionRepository;
46
49
  private readonly formDefinitionVersionRepository;
47
50
  private readonly workflowEngineService;
51
+ private readonly conditionService?;
48
52
  private readonly logger;
49
- constructor(registry: BPMFormDataSourceRegistry, approvalTemplateVersionRepository: Repository<ApprovalTemplateVersionEntity>, formDefinitionVersionRepository: Repository<FormDefinitionVersionEntity>, workflowEngineService: WorkflowEngineService);
53
+ constructor(registry: BPMFormDataSourceRegistry, approvalTemplateVersionRepository: Repository<ApprovalTemplateVersionEntity>, formDefinitionVersionRepository: Repository<FormDefinitionVersionEntity>, workflowEngineService: WorkflowEngineService, conditionService?: (ConditionService | null) | undefined);
50
54
  listDescriptors(): readonly BPMFormDataSourceDescriptor[];
51
55
  lintDefinitionSchemaEnvironment(schema: FormDefinitionSchema): readonly string[];
52
56
  private readFieldEnvironmentErrors;
@@ -54,14 +58,19 @@ export declare class FormDataSourceService {
54
58
  formFieldOptions(input: BPMFormDataSourceRuntimeInput, authContext: BPMAuthContext): Promise<BPMFormDataSourceOptionResult>;
55
59
  previewResolveFormFieldOptionValues(input: BPMFormDataSourcePreviewResolveInput, authContext: BPMAuthContext): Promise<BPMFormDataSourceResolveResult>;
56
60
  resolveFormFieldOptionValues(input: BPMFormDataSourceRuntimeResolveInput, authContext: BPMAuthContext): Promise<BPMFormDataSourceResolveResult>;
61
+ /**
62
+ * One search is one expression operation (ADR 22 §3.2): its `EXPRESSION`
63
+ * bindings share one cumulative budget.
64
+ */
57
65
  searchFormFieldOptions(input: {
58
66
  readonly authContext: BPMAuthContext;
59
67
  readonly cursor: string | null;
60
68
  readonly field: FormOptionFieldDefinition;
61
69
  readonly formData: Readonly<Record<string, unknown>>;
62
- readonly rowValues?: RowFieldValues;
70
+ readonly position: FormDataSourceBindingPosition;
63
71
  readonly searchText: string;
64
72
  }): Promise<BPMFormDataSourceOptionResult>;
73
+ private searchInOperation;
65
74
  /**
66
75
  * Read-only value check for the renderer. A value the provider no longer
67
76
  * offers is reported in `unresolvedValues` rather than thrown, because the
@@ -69,6 +78,7 @@ export declare class FormDataSourceService {
69
78
  * contract breaches and transport failures still throw.
70
79
  */
71
80
  private reportFormFieldOptionValues;
81
+ private reportInOperation;
72
82
  private callResolve;
73
83
  /**
74
84
  * Wraps the runtime context lookup so a failure from the storage layer never
@@ -84,6 +94,15 @@ export declare class FormDataSourceService {
84
94
  private parseSchema;
85
95
  private assertEnvironmentSchema;
86
96
  private parseFormData;
97
+ /**
98
+ * Where the queried field sits, read from the schema: a table column
99
+ * carries its row (empty when the caller sent none), a top-level field none.
100
+ * For a top-level field whatever the browser sent is dropped, so neither a
101
+ * `ROW_FIELD` nor an `EXPRESSION` binding's `row` root can read it there even
102
+ * if a schema got past the publish lint (ADR 22 §3.7: roots by position).
103
+ * Matches `readOptionField`, which prefers a top-level field of that key.
104
+ */
105
+ private readBindingPosition;
87
106
  /**
88
107
  * The cell values of the row a column query belongs to. Absent is legal and
89
108
  * distinct from empty: it means the caller sent none, so a `ROW_FIELD`
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
  var FormDataSourceService_1;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.FormDataSourceService = void 0;
4
+ exports.FormDataSourceService = exports.TOP_LEVEL_BINDING_POSITION = exports.createTableColumnBindingPosition = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const common_1 = require("@nestjs/common");
7
7
  const typeorm_1 = require("@nestjs/typeorm");
8
8
  const form_1 = require("@rytass/bpm-core-shared/form");
9
9
  const typeorm_2 = require("typeorm");
10
+ const condition_service_1 = require("../condition/condition.service");
11
+ const expression_budget_1 = require("../condition/expression-budget");
10
12
  const approval_template_version_entity_1 = require("../template/approval-template-version.entity");
11
13
  const template_enums_1 = require("../template/template.enums");
12
14
  const form_definition_version_entity_1 = require("../form/form-definition-version.entity");
@@ -15,14 +17,19 @@ const form_schema_validator_1 = require("../form/form-schema.validator");
15
17
  const workflow_engine_enums_1 = require("../workflow-engine/workflow-engine.enums");
16
18
  const workflow_engine_service_1 = require("../workflow-engine/workflow-engine.service");
17
19
  const form_data_source_errors_1 = require("./form-data-source.errors");
20
+ const form_data_source_expression_1 = require("./form-data-source.expression");
18
21
  const form_data_source_types_1 = require("./form-data-source.types");
19
22
  const form_data_source_validation_1 = require("./form-data-source.validation");
23
+ var form_data_source_validation_2 = require("./form-data-source.validation");
24
+ Object.defineProperty(exports, "createTableColumnBindingPosition", { enumerable: true, get: function () { return form_data_source_validation_2.createTableColumnBindingPosition; } });
25
+ Object.defineProperty(exports, "TOP_LEVEL_BINDING_POSITION", { enumerable: true, get: function () { return form_data_source_validation_2.TOP_LEVEL_BINDING_POSITION; } });
20
26
  let FormDataSourceService = FormDataSourceService_1 = class FormDataSourceService {
21
- constructor(registry, approvalTemplateVersionRepository, formDefinitionVersionRepository, workflowEngineService) {
27
+ constructor(registry, approvalTemplateVersionRepository, formDefinitionVersionRepository, workflowEngineService, conditionService) {
22
28
  this.registry = registry;
23
29
  this.approvalTemplateVersionRepository = approvalTemplateVersionRepository;
24
30
  this.formDefinitionVersionRepository = formDefinitionVersionRepository;
25
31
  this.workflowEngineService = workflowEngineService;
32
+ this.conditionService = conditionService;
26
33
  this.logger = new common_1.Logger(FormDataSourceService_1.name);
27
34
  }
28
35
  listDescriptors() {
@@ -38,12 +45,12 @@ let FormDataSourceService = FormDataSourceService_1 = class FormDataSourceServic
38
45
  // whose source is gone must block publication exactly like a top-level
39
46
  // one (ADR 16 §3.7).
40
47
  if ((0, form_1.isTableFieldDefinition)(field)) {
41
- return field.columns.flatMap((column, columnIndex) => this.readFieldEnvironmentErrors(column, `schema.fields[${index}].columns[${columnIndex}].dataSource`));
48
+ return field.columns.flatMap((column, columnIndex) => this.readFieldEnvironmentErrors(column, `schema.fields[${index}].columns[${columnIndex}].dataSource`, { columns: field.columns, schema }));
42
49
  }
43
- return this.readFieldEnvironmentErrors(field, `schema.fields[${index}].dataSource`);
50
+ return this.readFieldEnvironmentErrors(field, `schema.fields[${index}].dataSource`, { columns: null, schema });
44
51
  });
45
52
  }
46
- readFieldEnvironmentErrors(field, path) {
53
+ readFieldEnvironmentErrors(field, path, scope) {
47
54
  if (!(0, form_1.isFormDataSourceFieldDefinition)(field)) {
48
55
  return [];
49
56
  }
@@ -56,7 +63,24 @@ let FormDataSourceService = FormDataSourceService_1 = class FormDataSourceServic
56
63
  const descriptorErrors = (0, form_data_source_validation_1.readDescriptorErrors)(source.descriptor);
57
64
  const controlErrors = this.readControlErrors(field, source.descriptor, path);
58
65
  const bindingErrors = this.readBindingEnvironmentErrors(field.dataSource, source.descriptor, path);
59
- return [...descriptorErrors, ...controlErrors, ...bindingErrors];
66
+ // The cel-v2 lint of every `EXPRESSION` binding (docs/24 §2.8): roots by
67
+ // position, built-in functions only, the bound form's field types, and
68
+ // a result that fits the parameter. It needs the descriptor for the
69
+ // parameter types, so it lives here with the other registry checks.
70
+ const expressionErrors = (0, form_data_source_expression_1.lintExpressionBindings)({
71
+ columns: scope.columns,
72
+ conditionService: this.conditionService,
73
+ descriptor: source.descriptor,
74
+ path,
75
+ reference: field.dataSource,
76
+ schema: scope.schema,
77
+ });
78
+ return [
79
+ ...descriptorErrors,
80
+ ...controlErrors,
81
+ ...bindingErrors,
82
+ ...expressionErrors,
83
+ ];
60
84
  }
61
85
  async previewFormFieldOptions(input, authContext) {
62
86
  const { schema } = this.parseSchema(input.schemaJson, input.uiSchemaJson);
@@ -68,7 +92,7 @@ let FormDataSourceService = FormDataSourceService_1 = class FormDataSourceServic
68
92
  cursor: input.cursor ?? null,
69
93
  field,
70
94
  formData,
71
- rowValues: this.parseRowValues(input.rowValuesJson),
95
+ position: this.readBindingPosition(schema, input.fieldKey, input.rowValuesJson),
72
96
  searchText: input.searchText ?? '',
73
97
  });
74
98
  }
@@ -81,7 +105,7 @@ let FormDataSourceService = FormDataSourceService_1 = class FormDataSourceServic
81
105
  cursor: input.cursor ?? null,
82
106
  field,
83
107
  formData,
84
- rowValues: this.parseRowValues(input.rowValuesJson),
108
+ position: this.readBindingPosition(context.schema, input.fieldKey, input.rowValuesJson),
85
109
  searchText: input.searchText ?? '',
86
110
  });
87
111
  }
@@ -93,7 +117,7 @@ let FormDataSourceService = FormDataSourceService_1 = class FormDataSourceServic
93
117
  authContext,
94
118
  field,
95
119
  formData: this.parseFormData(input.formDataJson),
96
- rowValues: this.parseRowValues(input.rowValuesJson),
120
+ position: this.readBindingPosition(schema, input.fieldKey, input.rowValuesJson),
97
121
  values: this.parseValues(input.valuesJson),
98
122
  });
99
123
  }
@@ -104,15 +128,24 @@ let FormDataSourceService = FormDataSourceService_1 = class FormDataSourceServic
104
128
  authContext,
105
129
  field,
106
130
  formData: this.parseFormData(input.formDataJson),
107
- rowValues: this.parseRowValues(input.rowValuesJson),
131
+ position: this.readBindingPosition(context.schema, input.fieldKey, input.rowValuesJson),
108
132
  values: this.parseValues(input.valuesJson),
109
133
  });
110
134
  }
111
- async searchFormFieldOptions(input) {
135
+ /**
136
+ * One search is one expression operation (ADR 22 §3.2): its `EXPRESSION`
137
+ * bindings share one cumulative budget.
138
+ */
139
+ searchFormFieldOptions(input) {
140
+ return (0, expression_budget_1.runExpressionOperation)(() => this.searchInOperation(input));
141
+ }
142
+ async searchInOperation(input) {
112
143
  const field = (0, form_data_source_validation_1.readDynamicOptionField)(input.field);
113
144
  const source = (0, form_data_source_validation_1.readSourceOrThrow)(this.registry, field.dataSource);
114
145
  (0, form_data_source_validation_1.assertControlSupported)(field, source.descriptor);
115
- const bindings = (0, form_data_source_validation_1.readBindingValues)(field, source.descriptor, input.formData, input.rowValues);
146
+ const bindings = (0, form_data_source_validation_1.readBindingValues)(field, source.descriptor, input.formData, input.position, (0, form_data_source_expression_1.createFormDataSourceExpressionEvaluator)({
147
+ conditionService: this.conditionService,
148
+ }));
116
149
  // Waiting on a dependency is a state, not a failure: the caller needs the
117
150
  // field names to prompt for, and an error carries none of them.
118
151
  if (bindings.missingParameters.length > 0) {
@@ -121,7 +154,10 @@ let FormDataSourceService = FormDataSourceService_1 = class FormDataSourceServic
121
154
  dataSourceVersion: source.descriptor.version,
122
155
  nextCursor: null,
123
156
  options: [],
124
- waitingForFieldKeys: (0, form_data_source_validation_1.readWaitingForFieldKeys)(field, bindings.missingParameters),
157
+ waitingForFieldKeys: (0, form_data_source_validation_1.readWaitingForFieldKeys)(field, bindings.missingParameters, {
158
+ formData: input.formData,
159
+ rowValues: (0, form_data_source_validation_1.readBindingPositionRowValues)(input.position),
160
+ }),
125
161
  };
126
162
  }
127
163
  const searchText = input.searchText.trim();
@@ -153,7 +189,10 @@ let FormDataSourceService = FormDataSourceService_1 = class FormDataSourceServic
153
189
  * field has to show which of several selected options went dead. Provider
154
190
  * contract breaches and transport failures still throw.
155
191
  */
156
- async reportFormFieldOptionValues(input) {
192
+ reportFormFieldOptionValues(input) {
193
+ return (0, expression_budget_1.runExpressionOperation)(() => this.reportInOperation(input));
194
+ }
195
+ async reportInOperation(input) {
157
196
  const field = (0, form_data_source_validation_1.readDynamicOptionField)(input.field);
158
197
  const source = (0, form_data_source_validation_1.readSourceOrThrow)(this.registry, field.dataSource);
159
198
  (0, form_data_source_validation_1.assertControlSupported)(field, source.descriptor);
@@ -169,14 +208,19 @@ let FormDataSourceService = FormDataSourceService_1 = class FormDataSourceServic
169
208
  };
170
209
  }
171
210
  const values = (0, form_data_source_validation_1.validateRequestedValues)(input.values, source.descriptor.maximumResultCount);
172
- const bindings = (0, form_data_source_validation_1.readBindingValues)(field, source.descriptor, input.formData, input.rowValues);
211
+ const bindings = (0, form_data_source_validation_1.readBindingValues)(field, source.descriptor, input.formData, input.position, (0, form_data_source_expression_1.createFormDataSourceExpressionEvaluator)({
212
+ conditionService: this.conditionService,
213
+ }));
173
214
  if (bindings.missingParameters.length > 0) {
174
215
  return {
175
216
  dataSourceKey: source.descriptor.key,
176
217
  dataSourceVersion: source.descriptor.version,
177
218
  options: [],
178
219
  unresolvedValues: [],
179
- waitingForFieldKeys: (0, form_data_source_validation_1.readWaitingForFieldKeys)(field, bindings.missingParameters),
220
+ waitingForFieldKeys: (0, form_data_source_validation_1.readWaitingForFieldKeys)(field, bindings.missingParameters, {
221
+ formData: input.formData,
222
+ rowValues: (0, form_data_source_validation_1.readBindingPositionRowValues)(input.position),
223
+ }),
180
224
  };
181
225
  }
182
226
  const result = await this.callResolve(source, input.authContext, bindings.values, values);
@@ -314,6 +358,20 @@ let FormDataSourceService = FormDataSourceService_1 = class FormDataSourceServic
314
358
  }
315
359
  throw new form_data_source_errors_1.BPMFormDataSourceException(form_data_source_errors_1.BPM_FORM_DATA_SOURCE_ERROR_CODES.INVALID_BINDING);
316
360
  }
361
+ /**
362
+ * Where the queried field sits, read from the schema: a table column
363
+ * carries its row (empty when the caller sent none), a top-level field none.
364
+ * For a top-level field whatever the browser sent is dropped, so neither a
365
+ * `ROW_FIELD` nor an `EXPRESSION` binding's `row` root can read it there even
366
+ * if a schema got past the publish lint (ADR 22 §3.7: roots by position).
367
+ * Matches `readOptionField`, which prefers a top-level field of that key.
368
+ */
369
+ readBindingPosition(schema, fieldKey, rowValuesJson) {
370
+ const isTopLevelField = schema.fields.some((candidate) => candidate.fieldKey === fieldKey);
371
+ return isTopLevelField
372
+ ? form_data_source_validation_1.TOP_LEVEL_BINDING_POSITION
373
+ : (0, form_data_source_validation_1.createTableColumnBindingPosition)(this.parseRowValues(rowValuesJson));
374
+ }
317
375
  /**
318
376
  * The cell values of the row a column query belongs to. Absent is legal and
319
377
  * distinct from empty: it means the caller sent none, so a `ROW_FIELD`
@@ -435,9 +493,11 @@ exports.FormDataSourceService = FormDataSourceService = FormDataSourceService_1
435
493
  tslib_1.__param(0, (0, common_1.Inject)(form_data_source_types_1.BPM_FORM_DATA_SOURCE_REGISTRY)),
436
494
  tslib_1.__param(1, (0, typeorm_1.InjectRepository)(approval_template_version_entity_1.ApprovalTemplateVersionEntity)),
437
495
  tslib_1.__param(2, (0, typeorm_1.InjectRepository)(form_definition_version_entity_1.FormDefinitionVersionEntity)),
496
+ tslib_1.__param(4, (0, common_1.Optional)()),
497
+ tslib_1.__param(4, (0, common_1.Inject)(condition_service_1.ConditionService)),
438
498
  tslib_1.__metadata("design:paramtypes", [Object, typeorm_2.Repository,
439
499
  typeorm_2.Repository,
440
- workflow_engine_service_1.WorkflowEngineService])
500
+ workflow_engine_service_1.WorkflowEngineService, Object])
441
501
  ], FormDataSourceService);
442
502
  function isFormOptionField(field) {
443
503
  return (field.type === 'select' ||
@@ -467,7 +527,7 @@ const LINT_LINE_CODE_PATTERN = /^\S+\.dataSource (FORM_DATA_SOURCE_[A-Z_]+)$/u;
467
527
  * Without this the preview would fall back to `INVALID_DESCRIPTOR` ("contact
468
528
  * your administrator") for a binding the designer can fix themselves.
469
529
  */
470
- const LINT_BINDING_LINE_PATTERN = /^schema\.fields\[\d+\](?:\.columns\[\d+\])?\.dataSource\.bindings /u;
530
+ const LINT_BINDING_LINE_PATTERN = /^schema\.fields\[\d+\](?:\.columns\[\d+\])?\.dataSource\.bindings(?: |\[\d+\]\.from\.expression: EXPR_)/u;
471
531
  function readBindingLintErrorCode(error) {
472
532
  return LINT_BINDING_LINE_PATTERN.test(error)
473
533
  ? [form_data_source_errors_1.BPM_FORM_DATA_SOURCE_ERROR_CODES.INVALID_BINDING]