@object-ui/core 17.6.0 → 17.7.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 +6610 -0
- package/README.md +101 -14
- package/dist/actions/ActionEngine.d.ts +4 -2
- package/dist/actions/ActionEngine.js +13 -8
- package/dist/actions/ActionRunner.d.ts +288 -27
- package/dist/actions/ActionRunner.js +443 -63
- package/dist/actions/TransactionManager.d.ts +7 -2
- package/dist/actions/actionKeys.d.ts +9 -7
- package/dist/actions/actionKeys.js +57 -14
- package/dist/actions/actionResponse.js +2 -2
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.js +1 -0
- package/dist/actions/recordDelete.d.ts +118 -0
- package/dist/actions/recordDelete.js +112 -0
- package/dist/adapters/ValueDataSource.d.ts +6 -1
- package/dist/adapters/ValueDataSource.js +1090 -98
- package/dist/adapters/batchTransaction.d.ts +1 -1
- package/dist/adapters/batchTransaction.js +1 -1
- package/dist/builder/schema-builder.d.ts +38 -81
- package/dist/builder/schema-builder.js +33 -152
- package/dist/data-scope/ViewDataProvider.d.ts +1 -1
- package/dist/data-scope/ViewDataProvider.js +21 -1
- package/dist/data-scope/element-data-source.d.ts +261 -7
- package/dist/data-scope/element-data-source.js +342 -52
- package/dist/data-scope/index.d.ts +9 -4
- package/dist/data-scope/index.js +9 -4
- package/dist/evaluator/ExpressionEvaluator.d.ts +86 -0
- package/dist/evaluator/ExpressionEvaluator.js +184 -12
- package/dist/evaluator/FormulaFunctions.d.ts +0 -10
- package/dist/evaluator/FormulaFunctions.js +166 -27
- package/dist/evaluator/declaredPredicate.d.ts +93 -9
- package/dist/evaluator/declaredPredicate.js +117 -16
- package/dist/evaluator/fieldRules.d.ts +88 -4
- package/dist/evaluator/fieldRules.js +203 -31
- package/dist/evaluator/index.d.ts +1 -0
- package/dist/evaluator/index.js +1 -0
- package/dist/evaluator/listConditional.d.ts +103 -34
- package/dist/evaluator/listConditional.js +127 -50
- package/dist/evaluator/optionRules.d.ts +77 -6
- package/dist/evaluator/optionRules.js +87 -10
- package/dist/evaluator/predicateInput.d.ts +15 -4
- package/dist/evaluator/predicateInput.js +35 -2
- package/dist/evaluator/rowPredicateCanon.d.ts +7 -18
- package/dist/evaluator/rowPredicateCanon.js +65 -115
- package/dist/evaluator/subjectPermissions.d.ts +76 -0
- package/dist/evaluator/subjectPermissions.js +44 -0
- package/dist/evaluator/unevaluablePredicate.d.ts +57 -0
- package/dist/evaluator/unevaluablePredicate.js +70 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +80 -2
- package/dist/protocols/index.d.ts +0 -1
- package/dist/protocols/index.js +9 -1
- package/dist/registry/Registry.d.ts +358 -31
- package/dist/registry/Registry.js +263 -11
- package/dist/registry/WidgetRegistry.js +7 -3
- package/dist/registry/html-tier-intrinsics.d.ts +90 -0
- package/dist/registry/html-tier-intrinsics.js +110 -0
- package/dist/registry/public-blocks.d.ts +8 -0
- package/dist/registry/public-blocks.js +57 -0
- package/dist/theme/ThemeEngine.js +1 -1
- package/dist/utils/chart-category-key.d.ts +82 -0
- package/dist/utils/chart-category-key.js +84 -0
- package/dist/utils/chart-measure-key.d.ts +64 -0
- package/dist/utils/chart-measure-key.js +65 -0
- package/dist/utils/chart-presentation.d.ts +95 -112
- package/dist/utils/chart-presentation.js +169 -104
- package/dist/utils/chart-series.d.ts +131 -5
- package/dist/utils/chart-series.js +98 -16
- package/dist/utils/column-sortability.d.ts +157 -0
- package/dist/utils/column-sortability.js +217 -0
- package/dist/utils/dashboard-filters.d.ts +38 -6
- package/dist/utils/dashboard-filters.js +107 -61
- package/dist/utils/dataset-format.d.ts +211 -30
- package/dist/utils/dataset-format.js +389 -46
- package/dist/utils/date-display.d.ts +354 -0
- package/dist/utils/date-display.js +463 -0
- package/dist/utils/date-macros.js +7 -0
- package/dist/utils/drill-down.d.ts +78 -0
- package/dist/utils/drill-down.js +93 -0
- package/dist/utils/emptiness.d.ts +96 -0
- package/dist/utils/emptiness.js +101 -0
- package/dist/utils/expand-fields.d.ts +76 -6
- package/dist/utils/expand-fields.js +76 -6
- package/dist/utils/extract-records.d.ts +65 -5
- package/dist/utils/extract-records.js +65 -8
- package/dist/utils/filter-converter.d.ts +152 -4
- package/dist/utils/filter-converter.js +1092 -22
- package/dist/utils/filter-tokens.d.ts +49 -5
- package/dist/utils/filter-tokens.js +105 -33
- package/dist/utils/grouping-fields.d.ts +61 -0
- package/dist/utils/grouping-fields.js +84 -0
- package/dist/utils/managedBy.d.ts +3 -3
- package/dist/utils/managedBy.js +5 -5
- package/dist/utils/native-date-value.d.ts +48 -0
- package/dist/utils/native-date-value.js +167 -0
- package/dist/utils/non-grid-row-ceiling.d.ts +143 -0
- package/dist/utils/non-grid-row-ceiling.js +141 -0
- package/dist/utils/normalize-list-view.d.ts +121 -1
- package/dist/utils/normalize-list-view.js +186 -6
- package/dist/utils/number-display.d.ts +63 -14
- package/dist/utils/number-display.js +34 -12
- package/dist/utils/object-aggregate-query.d.ts +113 -0
- package/dist/utils/object-aggregate-query.js +50 -0
- package/dist/utils/parent-scope.d.ts +123 -0
- package/dist/utils/parent-scope.js +140 -0
- package/dist/utils/predicate-fields.d.ts +45 -12
- package/dist/utils/predicate-fields.js +137 -12
- package/dist/utils/record-color.d.ts +75 -0
- package/dist/utils/record-color.js +65 -0
- package/dist/utils/record-source.d.ts +298 -0
- package/dist/utils/record-source.js +331 -0
- package/dist/utils/record-title.d.ts +148 -8
- package/dist/utils/record-title.js +220 -26
- package/dist/utils/reference-keys.d.ts +21 -22
- package/dist/utils/reference-keys.js +532 -29
- package/dist/utils/sort-query.d.ts +115 -15
- package/dist/utils/sort-query.js +240 -13
- package/dist/utils/text-comparand.d.ts +92 -0
- package/dist/utils/text-comparand.js +99 -0
- package/dist/utils/without-denied-fields.d.ts +49 -0
- package/dist/utils/without-denied-fields.js +52 -0
- package/dist/validation/index.d.ts +8 -4
- package/dist/validation/index.js +8 -4
- package/dist/validation/schema-validator.d.ts +1 -1
- package/dist/validation/schema-validator.js +200 -82
- package/dist/validation/validators/object-validation-engine.d.ts +1 -1
- package/dist/validation/validators/object-validation-engine.js +14 -3
- package/package.json +8 -9
- package/dist/data-scope/DataScopeManager.d.ts +0 -127
- package/dist/data-scope/DataScopeManager.js +0 -229
- package/dist/protocols/ResponsiveProtocol.d.ts +0 -73
- package/dist/protocols/ResponsiveProtocol.js +0 -158
- package/dist/validation/validation-engine.d.ts +0 -88
- package/dist/validation/validation-engine.js +0 -434
|
@@ -44,8 +44,10 @@ export interface RowPredicateOptions {
|
|
|
44
44
|
* row-action `visible`/`disabled`; `false` (no style) for formatting. */
|
|
45
45
|
fallback?: boolean;
|
|
46
46
|
/** Extra top-level scope merged alongside the row — e.g. the global predicate
|
|
47
|
-
* scope (`features` / `user`
|
|
48
|
-
* collision: a `record`
|
|
47
|
+
* scope (`features` / `user`) a host shell provides. The row wins on
|
|
48
|
+
* collision: a `record` key here never shadows the row. Every OTHER key —
|
|
49
|
+
* a host's own `data` included — reaches the predicate as the host's own
|
|
50
|
+
* (`83fe6e741`: `data` no longer names the row on a record surface). */
|
|
49
51
|
scope?: Record<string, unknown>;
|
|
50
52
|
/** When true, log a one-time warning if a *present* predicate faults. */
|
|
51
53
|
warnOnError?: boolean;
|
|
@@ -53,16 +55,16 @@ export interface RowPredicateOptions {
|
|
|
53
55
|
label?: string;
|
|
54
56
|
/**
|
|
55
57
|
* This surface has **no row of its own** — bind NOTHING for the row instead
|
|
56
|
-
* of binding an empty one, so a `record`
|
|
57
|
-
*
|
|
58
|
+
* of binding an empty one, so a `record` the HOST SCOPE carries survives to
|
|
59
|
+
* the predicate (objectui#4640).
|
|
58
60
|
*
|
|
59
61
|
* The default (`false`) is this function's whole subject rule: the row is
|
|
60
|
-
* pinned over the scope
|
|
61
|
-
*
|
|
62
|
+
* pinned over the scope as `record`, on both dialect paths, so `record`
|
|
63
|
+
* always names THIS row even when the host scope carries a key of that name
|
|
62
64
|
* (objectui#3796). That is right for every row surface — and exactly wrong
|
|
63
65
|
* for a surface that has no row, because the pin then writes an EMPTY
|
|
64
|
-
* `record`
|
|
65
|
-
*
|
|
66
|
+
* `record` over the host's real one and every `record.*` predicate faults
|
|
67
|
+
* with "No such key". "This surface has no row of its own" and "this
|
|
66
68
|
* surface's row is empty" are different facts; only the latter is entitled to
|
|
67
69
|
* shadow the scope. Same distinction, same words, as `usePredicateRecordContext`
|
|
68
70
|
* in `@object-ui/react` (objectui#4075) — which is the BINDING half of this
|
|
@@ -86,38 +88,105 @@ export interface RowPredicateOptions {
|
|
|
86
88
|
}
|
|
87
89
|
/**
|
|
88
90
|
* Evaluate a single boolean predicate against a row record on the canonical CEL
|
|
89
|
-
* engine (with a legacy-dialect fallback — see the module note). The row
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* `
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* the
|
|
114
|
-
*
|
|
91
|
+
* engine (with a legacy-dialect fallback — see the module note). The row is
|
|
92
|
+
* bound ONE way: as `record.*` — **the canon** (maintainer ruling 2026-08-20 on
|
|
93
|
+
* objectui#5330, option B; Phase 2 executed by `83fe6e741`).
|
|
94
|
+
*
|
|
95
|
+
* Until Phase 2 the row was also bound as bare fields (`status`, the row-action
|
|
96
|
+
* shorthand) and as `data.*`, and Phase 1 (`d1ab06f0f`) warned once per
|
|
97
|
+
* non-canonical spelling. Both bindings and that warning are gone. A bare-field
|
|
98
|
+
* or `data.*` predicate on a record surface now FAULTS here exactly as it always
|
|
99
|
+
* did on the server — measured on `@objectstack/formula@17.1.0`,
|
|
100
|
+
* `buildScope({ record })` mounts exactly `['record']`, so a bare field faults
|
|
101
|
+
* `Unknown variable: status` and `data.*` faults `Unknown variable: data` — and
|
|
102
|
+
* takes this function's EXISTING fault policy: the caller's `fallback`, reported
|
|
103
|
+
* once by `warnEvalError` (when `warnOnError` is set) or by the canonical
|
|
104
|
+
* helper's own one-time warning, either of which names the unknown variable.
|
|
105
|
+
* Nothing detects a retired spelling on this path; it is simply unbound. The
|
|
106
|
+
* same holds on the legacy `${…}` path below — one scope shape per surface,
|
|
107
|
+
* both dialects — so `${data.x}` / `${x}` strings on a row surface fault there
|
|
108
|
+
* too, and land in the same fallback / warning.
|
|
109
|
+
*
|
|
110
|
+
* The retirement is scoped to the RUNTIME RECORD layer. `data` is the canonical
|
|
111
|
+
* root one layer over, in a metadata-editing form (ADR-0089 D3,
|
|
112
|
+
* `CANONICAL_ROOT_BY_LAYER` = `{ runtime: 'record', metadata: 'data' }`), and
|
|
113
|
+
* that layer evaluates through its own entry (`app-shell`'s metadata-admin
|
|
114
|
+
* `predicate.ts`), never through this one. See {@link ./rowPredicateCanon.ts}
|
|
115
|
+
* for the canon statement, the server measurement and the offline detector.
|
|
116
|
+
*
|
|
117
|
+
* The optional `scope` (host predicate scope) is bound alongside so
|
|
118
|
+
* `features.*` / `user.*` predicates keep working — but the row is the subject:
|
|
119
|
+
* `record` always names THIS row, on both dialect paths, even when the host
|
|
120
|
+
* scope carries a key of that name (objectui#3796). Every OTHER host key —
|
|
121
|
+
* a host's own `data` included — reaches the predicate as the host's own.
|
|
115
122
|
*
|
|
116
123
|
* A caller with no row at all passes {@link RowPredicateOptions.rowless}, and
|
|
117
124
|
* then nothing is bound over the scope — see that option for why an absent row
|
|
118
125
|
* must not be spelled as an empty one.
|
|
119
126
|
*/
|
|
120
127
|
export declare function evalRowPredicate(pred: FieldRulePredicate | undefined | null, row: Record<string, unknown> | null | undefined, opts?: RowPredicateOptions): boolean;
|
|
128
|
+
/** The two halves of a {@link partitionRowsByPredicate} verdict over a selection. */
|
|
129
|
+
export interface RowPartition<TRow> {
|
|
130
|
+
/** Records whose predicate passed — the ones an operation may act on. */
|
|
131
|
+
eligible: TRow[];
|
|
132
|
+
/**
|
|
133
|
+
* How many records were filtered out. A caller that shrinks a user's
|
|
134
|
+
* selection owes them this number: a run over fewer records than they picked
|
|
135
|
+
* must say so rather than quietly shrinking.
|
|
136
|
+
*/
|
|
137
|
+
skipped: number;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Split a set of records by one per-record predicate — the SET-shaped
|
|
141
|
+
* counterpart of {@link evalRowPredicate}, and the reason a bulk gate never
|
|
142
|
+
* needs a hook.
|
|
143
|
+
*
|
|
144
|
+
* A bulk affordance spans N records, so its gate is a **loop**, and React
|
|
145
|
+
* forbids calling `useRowPredicate` (or any hook) per iteration. Every bulk
|
|
146
|
+
* surface therefore reaches for `evalRowPredicate` directly; this wrapper is
|
|
147
|
+
* that loop written once, with the three cases each caller was otherwise
|
|
148
|
+
* re-deriving:
|
|
149
|
+
*
|
|
150
|
+
* - **absent** (`null` / `undefined` / `''`) — nothing is gated, so `rows` is
|
|
151
|
+
* returned BY REFERENCE and `skipped` is 0. The common case allocates
|
|
152
|
+
* nothing and a caller's downstream memo still holds. Whitespace-only text
|
|
153
|
+
* and an envelope whose `source` is blank are NOT absent here: they are
|
|
154
|
+
* evaluated, and fail closed like any other predicate that cannot run.
|
|
155
|
+
* - **boolean** — a verdict, not an expression, short-circuited exactly as
|
|
156
|
+
* `useCondition` / `useRowPredicate` do. Handing `true` to the engine
|
|
157
|
+
* produces `{ dialect: 'cel', source: undefined }`, which faults and — on
|
|
158
|
+
* this fail-closed path — would disqualify every record, so the most
|
|
159
|
+
* explicit way to say "always" would exclude everyone (objectui#3492).
|
|
160
|
+
* - **expression** — evaluated once per record with that record in scope,
|
|
161
|
+
* **fail-closed**: a predicate that faults must not hand the caller records
|
|
162
|
+
* it was written to exclude. `warnOnError` (default `true`) makes the
|
|
163
|
+
* resulting exclusion diagnosable once per predicate instead of silent.
|
|
164
|
+
*
|
|
165
|
+
* The fail-closed default is what separates this from a lenient record-free
|
|
166
|
+
* evaluation, and the difference is not mere strictness: evaluated with NO
|
|
167
|
+
* record bound, `record.status != 'paid'` returns `true` for every row —
|
|
168
|
+
* including the ones it was written to exclude — so an authored gate is not
|
|
169
|
+
* weakened, it is inverted for half its inputs (objectui#3067).
|
|
170
|
+
*
|
|
171
|
+
* ## Who calls it, and who decides "is a gate declared?" (objectui#11322)
|
|
172
|
+
*
|
|
173
|
+
* This is a shared partitioner, and its opening test is not the action
|
|
174
|
+
* family's "is a gate declared?" question. Its callers:
|
|
175
|
+
*
|
|
176
|
+
* - the bulk ACTION fold, plugin-grid's `partitionBulkRows` (a bulk def's
|
|
177
|
+
* `visible`). The action family decides "declared?" BEFORE calling here,
|
|
178
|
+
* through `hasDeclaredVisibilityGate`, and hands an undeclared gate over as
|
|
179
|
+
* `undefined`. So a whitespace-only `visible` or a blank-`source` envelope
|
|
180
|
+
* never reaches the test below from that caller.
|
|
181
|
+
* - the built-in Delete's `userActions.delete.visibleWhen`, a field-rule key,
|
|
182
|
+
* from plugin-grid's `ObjectGrid` and from plugin-list's `ListView`
|
|
183
|
+
* (`bulkDeleteEligibility`). The test below is THEIR answer: a blank one
|
|
184
|
+
* that is not `''` is evaluated and excludes every record.
|
|
185
|
+
*
|
|
186
|
+
* A caller that needs the action family's answer asks it first; it does not
|
|
187
|
+
* write a second blank test in front of this one.
|
|
188
|
+
*/
|
|
189
|
+
export declare function partitionRowsByPredicate<TRow extends Record<string, unknown>>(pred: FieldRulePredicate | boolean | undefined | null, rows: readonly TRow[], opts?: Omit<RowPredicateOptions, 'fallback' | 'rowless'>): RowPartition<TRow>;
|
|
121
190
|
/** A conditional-formatting rule in any of the three historical shapes. */
|
|
122
191
|
export type ConditionalFormattingRuleLike = {
|
|
123
192
|
/** Spec shape: a CEL predicate (`ExpressionInputSchema`). */
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
import { evalFieldPredicate } from './fieldRules.js';
|
|
37
37
|
import { ExpressionEvaluator } from './ExpressionEvaluator.js';
|
|
38
38
|
import { toPredicateRecord } from '../utils/predicate-record.js';
|
|
39
|
-
import { warnNonCanonicalRowSpelling } from './rowPredicateCanon.js';
|
|
40
39
|
/**
|
|
41
40
|
* Syntax that only the legacy JS-dialect evaluator understands and that is NOT
|
|
42
41
|
* valid CEL: `${…}` templates, strict (in)equality, JS optional-chaining
|
|
@@ -119,7 +118,7 @@ function evalCel(pred, record, scope) {
|
|
|
119
118
|
// verbatim — no second engine — so CEL semantics never drift from B2.
|
|
120
119
|
// `warn: false`: this caller reports the fault itself (the labelled
|
|
121
120
|
// `warnEvalError` in `evalRowPredicate`) — one warning per broken predicate,
|
|
122
|
-
// not two (#5149). `onFault` carries the engine's reason across that silence
|
|
121
|
+
// not two (objectstack-ai/objectstack#5149). `onFault` carries the engine's reason across that silence
|
|
123
122
|
// so the labelled report can still name it (objectui#3792); both probes fault
|
|
124
123
|
// identically, so the first reason is the reason.
|
|
125
124
|
let reason;
|
|
@@ -135,32 +134,37 @@ function evalCel(pred, record, scope) {
|
|
|
135
134
|
}
|
|
136
135
|
/**
|
|
137
136
|
* Evaluate a single boolean predicate against a row record on the canonical CEL
|
|
138
|
-
* engine (with a legacy-dialect fallback — see the module note). The row
|
|
139
|
-
*
|
|
140
|
-
*
|
|
137
|
+
* engine (with a legacy-dialect fallback — see the module note). The row is
|
|
138
|
+
* bound ONE way: as `record.*` — **the canon** (maintainer ruling 2026-08-20 on
|
|
139
|
+
* objectui#5330, option B; Phase 2 executed by `83fe6e741`).
|
|
141
140
|
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* `
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
141
|
+
* Until Phase 2 the row was also bound as bare fields (`status`, the row-action
|
|
142
|
+
* shorthand) and as `data.*`, and Phase 1 (`d1ab06f0f`) warned once per
|
|
143
|
+
* non-canonical spelling. Both bindings and that warning are gone. A bare-field
|
|
144
|
+
* or `data.*` predicate on a record surface now FAULTS here exactly as it always
|
|
145
|
+
* did on the server — measured on `@objectstack/formula@17.1.0`,
|
|
146
|
+
* `buildScope({ record })` mounts exactly `['record']`, so a bare field faults
|
|
147
|
+
* `Unknown variable: status` and `data.*` faults `Unknown variable: data` — and
|
|
148
|
+
* takes this function's EXISTING fault policy: the caller's `fallback`, reported
|
|
149
|
+
* once by `warnEvalError` (when `warnOnError` is set) or by the canonical
|
|
150
|
+
* helper's own one-time warning, either of which names the unknown variable.
|
|
151
|
+
* Nothing detects a retired spelling on this path; it is simply unbound. The
|
|
152
|
+
* same holds on the legacy `${…}` path below — one scope shape per surface,
|
|
153
|
+
* both dialects — so `${data.x}` / `${x}` strings on a row surface fault there
|
|
154
|
+
* too, and land in the same fallback / warning.
|
|
156
155
|
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
156
|
+
* The retirement is scoped to the RUNTIME RECORD layer. `data` is the canonical
|
|
157
|
+
* root one layer over, in a metadata-editing form (ADR-0089 D3,
|
|
158
|
+
* `CANONICAL_ROOT_BY_LAYER` = `{ runtime: 'record', metadata: 'data' }`), and
|
|
159
|
+
* that layer evaluates through its own entry (`app-shell`'s metadata-admin
|
|
160
|
+
* `predicate.ts`), never through this one. See {@link ./rowPredicateCanon.ts}
|
|
161
|
+
* for the canon statement, the server measurement and the offline detector.
|
|
159
162
|
*
|
|
160
|
-
* The optional `scope` (host predicate scope) is bound
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
163
|
+
* The optional `scope` (host predicate scope) is bound alongside so
|
|
164
|
+
* `features.*` / `user.*` predicates keep working — but the row is the subject:
|
|
165
|
+
* `record` always names THIS row, on both dialect paths, even when the host
|
|
166
|
+
* scope carries a key of that name (objectui#3796). Every OTHER host key —
|
|
167
|
+
* a host's own `data` included — reaches the predicate as the host's own.
|
|
164
168
|
*
|
|
165
169
|
* A caller with no row at all passes {@link RowPredicateOptions.rowless}, and
|
|
166
170
|
* then nothing is bound over the scope — see that option for why an absent row
|
|
@@ -170,9 +174,16 @@ export function evalRowPredicate(pred, row, opts = {}) {
|
|
|
170
174
|
const fallback = opts.fallback ?? false;
|
|
171
175
|
if (pred == null)
|
|
172
176
|
return fallback;
|
|
177
|
+
// A BLANK predicate is not answered here. It used to be, for the bare-string
|
|
178
|
+
// spelling only: `''` / whitespace returned the fallback on this line, in
|
|
179
|
+
// silence, while a blank ENVELOPE went on to `evalFieldPredicate`'s `[blank]`
|
|
180
|
+
// report below (objectui#11262, ADR-0137 D4: a blank gate predicate is
|
|
181
|
+
// "diagnosed, never a silent `true`"). Both spellings now take that one
|
|
182
|
+
// route: no legacy marker can match blank text, so a blank string reaches
|
|
183
|
+
// the CEL path like its envelope twin and gets the same verdict — the
|
|
184
|
+
// caller's fallback — and the same report, labelled on the fail-closed route
|
|
185
|
+
// and by the canonical helper on the single-eval one.
|
|
173
186
|
const source = typeof pred === 'string' ? pred : undefined;
|
|
174
|
-
if (source !== undefined && !source.trim())
|
|
175
|
-
return fallback;
|
|
176
187
|
// Relations collapse to the foreign key the server stores, so `record.owner`
|
|
177
188
|
// means one thing whether or not this surface expanded the column
|
|
178
189
|
// (objectui#3501). Returned by reference when there is nothing to collapse.
|
|
@@ -180,24 +191,26 @@ export function evalRowPredicate(pred, row, opts = {}) {
|
|
|
180
191
|
const rowObj = opts.rowless
|
|
181
192
|
? {}
|
|
182
193
|
: toPredicateRecord(row && typeof row === 'object' ? row : {}, opts.fields);
|
|
183
|
-
//
|
|
194
|
+
// `record.*` + the host scope, all top-level. The row is bound ONE way
|
|
195
|
+
// (`83fe6e741`, Phase 2 of the objectui#5330 canon): no bare-field spread
|
|
196
|
+
// and no `data` — a predicate spelled either way is simply unbound here and
|
|
197
|
+
// faults, on both dialect paths, exactly as it does on the server.
|
|
184
198
|
//
|
|
185
|
-
// `
|
|
186
|
-
//
|
|
187
|
-
//
|
|
188
|
-
//
|
|
189
|
-
//
|
|
190
|
-
//
|
|
191
|
-
//
|
|
192
|
-
//
|
|
193
|
-
// deliberately (objectui#3796). Pinning here fixes both paths at the merge,
|
|
199
|
+
// `record` is pinned AFTER the spread, so a host scope that happens to carry
|
|
200
|
+
// that key is background and the ROW stays the subject of this function — on
|
|
201
|
+
// BOTH dialect paths. Before objectui#3796 it relied instead on each engine's
|
|
202
|
+
// own binding, which disagreed: the legacy evaluator re-pinned `record` (row
|
|
203
|
+
// won) while the CEL engine takes `extra` over its `record` binding (host
|
|
204
|
+
// scope won). Same function, same predicate text, opposite subjects — decided
|
|
205
|
+
// by whether the string happens to contain `===`/`${…}`, which no author is
|
|
206
|
+
// choosing deliberately. Pinning here fixes both paths at the merge,
|
|
194
207
|
// independently of either engine's precedence.
|
|
195
208
|
//
|
|
196
209
|
// …UNLESS the caller has no row (`rowless`), in which case there is nothing
|
|
197
|
-
// to pin and the host scope keeps its own `record`
|
|
210
|
+
// to pin and the host scope keeps its own `record` — see the option.
|
|
198
211
|
const scope = opts.rowless
|
|
199
212
|
? { ...(opts.scope ?? {}) }
|
|
200
|
-
: { ...(opts.scope ?? {}),
|
|
213
|
+
: { ...(opts.scope ?? {}), record: rowObj };
|
|
201
214
|
// The predicate TEXT for diagnostics: a bare string is itself, an envelope is
|
|
202
215
|
// its `source`. Reported separately from `source` above, which is `undefined`
|
|
203
216
|
// for an envelope *by design* (it drives the dialect routing, and an envelope
|
|
@@ -231,19 +244,17 @@ export function evalRowPredicate(pred, row, opts = {}) {
|
|
|
231
244
|
return fallback;
|
|
232
245
|
}
|
|
233
246
|
}
|
|
234
|
-
// CEL path — everything reaching here is CEL
|
|
235
|
-
//
|
|
236
|
-
//
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
//
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
// CEL path. The fault-aware `evalCel` costs two evaluations (to tell a fault
|
|
247
|
+
// CEL path — everything reaching here is CEL. No spelling detector runs here
|
|
248
|
+
// (`83fe6e741` removed the Phase-1 warning with the bindings): a retired
|
|
249
|
+
// bare-field / `data.*` spelling is unbound above and faults in the engine
|
|
250
|
+
// like any other unknown variable, and the fault report below is what names
|
|
251
|
+
// it. `detectNonCanonicalRowSpelling` stays exported for OFFLINE sweeps of
|
|
252
|
+
// authored metadata, not for this hot path.
|
|
253
|
+
//
|
|
254
|
+
// The fault-aware `evalCel` costs two evaluations (to tell a fault
|
|
244
255
|
// from a genuine `false`), so only pay it when a caller wants the labelled
|
|
245
256
|
// fail-closed warning — the formatting hot path takes the single-eval fast
|
|
246
|
-
// route. Since #5149 the fast route is no longer silent either: the
|
|
257
|
+
// route. Since objectstack-ai/objectstack#5149 the fast route is no longer silent either: the
|
|
247
258
|
// canonical helper itself warns once per broken predicate (with `opts.label`
|
|
248
259
|
// as the locator when given).
|
|
249
260
|
if (!opts.warnOnError) {
|
|
@@ -256,6 +267,72 @@ export function evalRowPredicate(pred, row, opts = {}) {
|
|
|
256
267
|
}
|
|
257
268
|
return verdict.value;
|
|
258
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* Split a set of records by one per-record predicate — the SET-shaped
|
|
272
|
+
* counterpart of {@link evalRowPredicate}, and the reason a bulk gate never
|
|
273
|
+
* needs a hook.
|
|
274
|
+
*
|
|
275
|
+
* A bulk affordance spans N records, so its gate is a **loop**, and React
|
|
276
|
+
* forbids calling `useRowPredicate` (or any hook) per iteration. Every bulk
|
|
277
|
+
* surface therefore reaches for `evalRowPredicate` directly; this wrapper is
|
|
278
|
+
* that loop written once, with the three cases each caller was otherwise
|
|
279
|
+
* re-deriving:
|
|
280
|
+
*
|
|
281
|
+
* - **absent** (`null` / `undefined` / `''`) — nothing is gated, so `rows` is
|
|
282
|
+
* returned BY REFERENCE and `skipped` is 0. The common case allocates
|
|
283
|
+
* nothing and a caller's downstream memo still holds. Whitespace-only text
|
|
284
|
+
* and an envelope whose `source` is blank are NOT absent here: they are
|
|
285
|
+
* evaluated, and fail closed like any other predicate that cannot run.
|
|
286
|
+
* - **boolean** — a verdict, not an expression, short-circuited exactly as
|
|
287
|
+
* `useCondition` / `useRowPredicate` do. Handing `true` to the engine
|
|
288
|
+
* produces `{ dialect: 'cel', source: undefined }`, which faults and — on
|
|
289
|
+
* this fail-closed path — would disqualify every record, so the most
|
|
290
|
+
* explicit way to say "always" would exclude everyone (objectui#3492).
|
|
291
|
+
* - **expression** — evaluated once per record with that record in scope,
|
|
292
|
+
* **fail-closed**: a predicate that faults must not hand the caller records
|
|
293
|
+
* it was written to exclude. `warnOnError` (default `true`) makes the
|
|
294
|
+
* resulting exclusion diagnosable once per predicate instead of silent.
|
|
295
|
+
*
|
|
296
|
+
* The fail-closed default is what separates this from a lenient record-free
|
|
297
|
+
* evaluation, and the difference is not mere strictness: evaluated with NO
|
|
298
|
+
* record bound, `record.status != 'paid'` returns `true` for every row —
|
|
299
|
+
* including the ones it was written to exclude — so an authored gate is not
|
|
300
|
+
* weakened, it is inverted for half its inputs (objectui#3067).
|
|
301
|
+
*
|
|
302
|
+
* ## Who calls it, and who decides "is a gate declared?" (objectui#11322)
|
|
303
|
+
*
|
|
304
|
+
* This is a shared partitioner, and its opening test is not the action
|
|
305
|
+
* family's "is a gate declared?" question. Its callers:
|
|
306
|
+
*
|
|
307
|
+
* - the bulk ACTION fold, plugin-grid's `partitionBulkRows` (a bulk def's
|
|
308
|
+
* `visible`). The action family decides "declared?" BEFORE calling here,
|
|
309
|
+
* through `hasDeclaredVisibilityGate`, and hands an undeclared gate over as
|
|
310
|
+
* `undefined`. So a whitespace-only `visible` or a blank-`source` envelope
|
|
311
|
+
* never reaches the test below from that caller.
|
|
312
|
+
* - the built-in Delete's `userActions.delete.visibleWhen`, a field-rule key,
|
|
313
|
+
* from plugin-grid's `ObjectGrid` and from plugin-list's `ListView`
|
|
314
|
+
* (`bulkDeleteEligibility`). The test below is THEIR answer: a blank one
|
|
315
|
+
* that is not `''` is evaluated and excludes every record.
|
|
316
|
+
*
|
|
317
|
+
* A caller that needs the action family's answer asks it first; it does not
|
|
318
|
+
* write a second blank test in front of this one.
|
|
319
|
+
*/
|
|
320
|
+
export function partitionRowsByPredicate(pred, rows, opts = {}) {
|
|
321
|
+
if (pred == null || pred === '') {
|
|
322
|
+
return { eligible: rows, skipped: 0 };
|
|
323
|
+
}
|
|
324
|
+
if (typeof pred === 'boolean') {
|
|
325
|
+
return pred
|
|
326
|
+
? { eligible: rows, skipped: 0 }
|
|
327
|
+
: { eligible: [], skipped: rows.length };
|
|
328
|
+
}
|
|
329
|
+
const eligible = rows.filter(row => evalRowPredicate(pred, row, {
|
|
330
|
+
...opts,
|
|
331
|
+
warnOnError: opts.warnOnError ?? true,
|
|
332
|
+
fallback: false,
|
|
333
|
+
}));
|
|
334
|
+
return { eligible, skipped: rows.length - eligible.length };
|
|
335
|
+
}
|
|
259
336
|
/** Serialize a JS value as a CEL literal (string / number / bool / list / null). */
|
|
260
337
|
function celLiteral(v) {
|
|
261
338
|
if (v === null || v === undefined)
|
|
@@ -69,6 +69,68 @@ export declare function isOptionGroupGated(dependsOn: DependsOnInput, record: Re
|
|
|
69
69
|
* no predicate are always kept; a predicate that errors fails open (kept).
|
|
70
70
|
*/
|
|
71
71
|
export declare function resolveVisibleOptions<T extends OptionLike>(options: readonly T[] | undefined | null, record: Record<string, unknown>, scope?: Record<string, unknown>): T[];
|
|
72
|
+
/**
|
|
73
|
+
* The text an option widget SHOWS for one option: its `label`, or its `value`
|
|
74
|
+
* when the label is blank (`20b507aff`).
|
|
75
|
+
*
|
|
76
|
+
* ## Why a blank label reaches a renderer at all — it is a LEGAL document
|
|
77
|
+
*
|
|
78
|
+
* This is deliberately NOT the lenient renderer fallback AGENTS.md #0.1
|
|
79
|
+
* forbids. That rule governs metadata the contract REFUSES ("if the metadata
|
|
80
|
+
* is off-spec, fix it at the producer"); an empty label is metadata the
|
|
81
|
+
* contract ACCEPTS. Measured on the installed `@objectstack/spec` 17.6.0,
|
|
82
|
+
* `SelectOptionSchema`:
|
|
83
|
+
*
|
|
84
|
+
* { value: 'low', label: 'Low' } -> ACCEPT (lit control)
|
|
85
|
+
* { value: 'low', label: '' } -> ACCEPT <- the key reading
|
|
86
|
+
* { value: 'low' } -> REJECT invalid_type at [label]
|
|
87
|
+
*
|
|
88
|
+
* `@object-ui/types` mirrors that reading in prose on `SelectOptionBase`:
|
|
89
|
+
* "An empty string is a valid label; an ABSENT one is not." So the producer
|
|
90
|
+
* is right to emit `label: ''` — the field designer's `patchOptions` does,
|
|
91
|
+
* under the ruling `f0f774b0d` landed, and a pin
|
|
92
|
+
* (`ObjectFieldInspector.optionLabel.test.tsx`) fails if it ever invents
|
|
93
|
+
* content to fill the hole instead. A document every layer calls legal has to
|
|
94
|
+
* render as something a person can click.
|
|
95
|
+
*
|
|
96
|
+
* ## What the contract does NOT say, and who had already answered it
|
|
97
|
+
*
|
|
98
|
+
* The spec states no display default for a legal-but-blank label, so nothing
|
|
99
|
+
* upstream decides this. objectui had nevertheless already decided it — on
|
|
100
|
+
* HALF its read sites. Measured across the four option widgets before this
|
|
101
|
+
* helper existed, with `{ value: 'low', label: '' }` authored and
|
|
102
|
+
* `{ value: 'high', label: 'High' }` beside it as the lit control:
|
|
103
|
+
*
|
|
104
|
+
* | widget | readonly path | interactive path |
|
|
105
|
+
* | select | "low" | "" |
|
|
106
|
+
* | multiselect | "low" | "" |
|
|
107
|
+
* | radio | "low" | "" |
|
|
108
|
+
* | checkboxes | "low" | "" |
|
|
109
|
+
*
|
|
110
|
+
* Four summary paths spelled `opt?.label || value` and fell back; the four
|
|
111
|
+
* interactive paths spelled `{opt.label}` and rendered nothing. So the same
|
|
112
|
+
* option read "low" in a read-only form and blank in the editable one — the
|
|
113
|
+
* bug was never "tolerate or refuse", it was a widget family disagreeing with
|
|
114
|
+
* itself, and the blank half is the one a person has to click.
|
|
115
|
+
*
|
|
116
|
+
* This function is that decision written ONCE, the same "one definition, N
|
|
117
|
+
* surfaces" move as {@link CASCADE_OPTION_WIDGET_TYPES} below. All eight sites
|
|
118
|
+
* call it, so the two halves cannot drift apart again.
|
|
119
|
+
*
|
|
120
|
+
* ## Boundaries
|
|
121
|
+
*
|
|
122
|
+
* - Blank means TRIM-empty, so a whitespace-only label falls back too: it is
|
|
123
|
+
* the same invisible row to the person looking at it, and it is the
|
|
124
|
+
* spelling the producer's own reader already uses to call an authored
|
|
125
|
+
* `value` blank (`classifyOption`, `o.value.trim() === ''`).
|
|
126
|
+
* - `label` is typed required, but this reads defensively because renderers
|
|
127
|
+
* are handed unvalidated runtime metadata: a non-string label must fall back
|
|
128
|
+
* rather than throw where `{opt.label}` merely rendered nothing.
|
|
129
|
+
* - This changes DISPLAY only. It writes nothing, and it is not a licence to
|
|
130
|
+
* author blank labels — whether the contract should refuse them outright is
|
|
131
|
+
* a `packages/spec` question, not a renderer one.
|
|
132
|
+
*/
|
|
133
|
+
export declare function optionDisplayLabel(option: OptionLike): string;
|
|
72
134
|
/**
|
|
73
135
|
* Whether a scalar field value is still valid given the currently-visible
|
|
74
136
|
* options — used to decide a cascade clear (parent changed, child's old choice
|
|
@@ -132,12 +194,21 @@ export declare function resolveCascadingOptions<T extends OptionLike>(rawOptions
|
|
|
132
194
|
*
|
|
133
195
|
* `dependentValues` is also the channel two widget-hint pickers read a specific
|
|
134
196
|
* SIBLING KEY from (`filter-condition` reads `object_name`, `recipient-picker`
|
|
135
|
-
* reads `recipient_type`), and the lookup family filters its query by it
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
197
|
+
* reads `recipient_type`), and the lookup family filters its query by it —
|
|
198
|
+
* neither of which is an option list, so ⛔ no member is ever added to THIS set
|
|
199
|
+
* to serve them. Each surface decides that separately, by OR-ing its own rule
|
|
200
|
+
* beside this one, and they do not agree:
|
|
201
|
+
*
|
|
202
|
+
* - the object form has fed both families all along — `needsDataSourceWiring`,
|
|
203
|
+
* its own line beside the one that reads this set;
|
|
204
|
+
* - the single-record action dialog feeds the lookup family since
|
|
205
|
+
* objectui#8672 ruling A — `paramNeedsDependentValues()`, same shape;
|
|
206
|
+
* - the bulk action dialog feeds neither, and nothing has ruled on it.
|
|
207
|
+
*
|
|
208
|
+
* ⇒ objectui#4771 is the open boundary for the widget-hint pickers everywhere,
|
|
209
|
+
* and for the lookup family on the bulk dialog. Stated here so the surfaces'
|
|
210
|
+
* copies of the statement become one; ⛔ do not read a member of this set as
|
|
211
|
+
* the answer to "does widget X get the record on surface Y".
|
|
141
212
|
*
|
|
142
213
|
* ## Normalization stays with the consumer
|
|
143
214
|
*
|