Skip to content

Commit 401eb44

Browse files
fix(app-shell): the formula inspector asks inferFormulaReturn before it keeps a currency result type (#35774)
repo:objectstack#7 · os-tesla · session_01L9qibvVRcFWKrfWeG5jzPb <!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoK8YCcS3hkJHvVLxZNeiKG8)_ Fixes #35631 Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 在 Studio 里编辑公式字段的建模者会看到:公式从算金额改成算数量后,结果类型由"货币"改回"数字",不再按金额显示;仍在算金额的公式保持"货币"并带上源金额的币种;无法判定是否为金额的公式(例如引用汇总字段)保持原样。 - 为什么做:修正公式结果类型在编辑后变旧的问题,替在 Studio 里写货币公式的建模者解决显示错误。 - 出错会怎样:只影响 Studio 编辑公式时写入草稿的结果类型,存储的数值不变;可直接撤回本次合并。 - 要你做什么:无。 ## What changes `settleFormulaType` in the Studio field inspector now asks the engine's `inferFormulaReturn` (from `@objectstack/formula`, loaded through the same lazy seam as the other CEL verdicts) whether an edited formula computes money, over the object's declared field map: - **Provably money** stamps `returnType: 'currency'` with the proven `currencyConfig` (absent for the tenant default currency), also on a formula that was `number`. - **A `number` answer withdraws a declared `currency`**: `returnType` becomes `number` and the stale `currencyConfig` is removed (the producer's contract in `formula-return.ts`: the declaration is the pair, and an absent member is cleared). - **Unproven** (`{}`: a field-over-field quotient, two currencies meeting) keeps a declared `currency`, as before. An engine without the export gives no money verdict and also keeps it. - **`percent` is unchanged** (the #35047 rule): it survives a `number` or unproven verdict, and a money verdict too (never re-stamped `currency`; the spec text now says so). A text, boolean or date verdict still stamps, and now also clears a stale `currencyConfig`. The money verdict lands one microtask after the two editor verdicts. A newer verdict supersedes it (identity check on the verdict record), and the write uses the latest render's draft, so it builds on the current definition and not on an earlier closure. `packages/formula/src/formula-return.ts` (the producer, PM ruling A, completed after the L2 record at `e5a7e08b`): a `number` answer means "proved not money". On the numeric path the answer is `{}` (unproven) unless one of two things holds. Either the unit proof succeeds (a plain quantity or constant), or every read of the record is one segment naming a declared field whose unit can be read and is not money. This covers all four spellings, `record.x`, `record['x']`, `record.?x`, `record[?'x']`, and a bare `x`. Only then does the CEL inference answer. Unproven, measured, with the answer at `e5a7e08b` in brackets: - a hop `record.account.balance * 0.9` [number]; - a formula operand with no `returnType`, `record.subtotal * 0.2` [number]; - `record['amount'] * 0.1` [number]; - `record.unknown_field * 2` [number]; - a roll-up, division by an amount, a remainder, two currencies, amount times amount, an unparseable currency [number since round 2]; - `record.?amount * 0.1` and `record[?'amount'] * 0.1` [`{}`: the CEL checker does not type the optional spellings, so they never reach the numeric path]. One shape per leg of the unit check: `100 / record.weighted` (a formula declared `currency`) and `100 / amount` (a bare identifier). CONTROLs that still answer `number`: declared quantities in any spelling (`record['quantity'] * 2`, a bare `quantity * 2`), a percent field, a formula declaring `number`, and a `count` roll-up whose `summaryOperations` is passed. A call with no field map now answers `{}` for a numeric expression that reads the record, because no read has a declared unit; it was `number`. A bare same-currency ratio (`record.amount / record.tax`) is proven plain, but cel-js types it `dyn`, so it answers `{}` as before. `FormulaSourceField` gains the optional member `summaryOperations` (a widening, hence `Clause-②: yes (widening)`). A roll-up passed without it, a `count` included, is read as possibly money. The header, the `FormulaReturnDeclaration` doc (an absent `returnType` is no verdict; the pair rule covers `currencyConfig` beside a `currency` answer) and the function doc say exactly this. Runtime callers on `main`: only the inspector, plus the showcase test `money-format-declarations` (proven money, unchanged, green). `packages/spec/src/data/field.zod.ts`: the `returnType` JSDoc and `.describe()` said a declared `currency` survives a `number` verdict. That is no longer true, so the prose now restates the card's ruling (the Done-when on #35631): `currency` is stamped when money is proven and withdrawn for `number`, an unproven verdict keeps it, and a declared `percent` is kept under a money verdict. The generated `content/docs/references` pages were regenerated with `gen:docs`. Prose only: no key, value or shape changes. Files to read first, by risk: 1. `ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.tsx`: `settleFormulaType` / `stampFormulaType` (the async hand-off and the decision order). 2. `ui/packages/app-shell/src/views/metadata-admin/celAuthoring.ts`: `inferFormulaReturnDeclaration` (feature-detected, error-swallowing, `null` means no verdict). 3. `packages/formula/src/formula-return.ts`: `hasPlainUnit` / `readsOnlyPlainFields` / `memberRead` and the one new early return. Two-minute check: `cd ui && pnpm exec vitest run packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.returnTypeHeld-27485.test.tsx`. Expect 24 passing, including the thirteen in the `objectstack#35631` describe. Producer: `pnpm --filter @objectstack/formula exec vitest run src/formula-return.test.ts`. ## Tests New top-level describe in the existing harness file `ObjectFieldInspector.returnTypeHeld-27485.test.tsx`. Its stub keeps the editor verdicts deterministic and hands in the real, unstubbed `inferFormulaReturn`: - money to count (`record.amount * 0.1` to `record.est_hours * 2`) drops `currency` and `currencyConfig`; - an edit that still proves money keeps `currency` and `{ fixed, USD }`; - a `number` formula edited into money is stamped `currency` with the source's config; - an unproven field-over-field quotient keeps a declared `currency`; - a roll-up the proof cannot read as money (`record.total * 0.9`) is unproven and keeps a declared `currency`; - a NEW formula over an amount the proof cannot follow (`100 / record.amount`, verdict `{}`) is still stamped `number` from the editor's CEL type. The non-currency stamp reads the editor's type, not this verdict, so Studio's save is unchanged for new formulas; - CONTROL: a declared `percent` is kept under a `number` verdict. The edit is now to a different quantity expression (`record.est_hours * 3`); the old one equalled the harness default, so no stamp ran; - a declared `percent` edited to `record.amount * 0.2` (a money verdict) stays `percent`; - config-update path: a USD amount to a EUR amount updates the config; a move to a dynamic amount removes it; a record-mode source stamps its code field; - a hand-declared `currency` over a formula with no `returnType` survives `record.subtotal * 0.1` to `* 0.12` (route b; it was withdrawn at `e5a7e08b`); - CONTROL: a boolean verdict still stamps over `currency` and clears the config. Producer, in `formula-return.test.ts`: one describe pins each unproven shape as `{}`. It lists the round-2 shapes, the shapes that already answered `{}`, the four M1 routes (a hop, a formula with no `returnType`, the three other spellings, an undeclared name) and one shape per leg (`100 / record.weighted`, `100 / amount`). CONTROLs: proven money still stamps `currency` with its config; quantities in every spelling, a percent field and a `number` formula still answer `number`; a `count` roll-up still answers `number`. The plain-inference pin now covers only declared non-money units and non-numeric results. The no-field-map pin is retitled: `{}` for a record read, `number` for a constant. The existing pin "a `number` verdict keeps a declared `currency` too" is renamed to say it runs with no money verdict from the engine. It holds unchanged. Readings at the final head `b9ce479e` unless named: <details><summary>Test runs</summary> - `@objectstack/formula` test: Test Files 69 passed (69), Tests 1906 passed (1906). `typecheck`: exit 0 (at `ae8b9cf9`, producer source unchanged since). - Inspector, celAuthoring and CelPredicateField suites plus `column-identity.ratchet.test.ts`, run with `@objectstack/formula` rebuilt first: Test Files 40 passed (40), Tests 510 passed (510). The harness file alone: 24 passed. - `pnpm --filter @object-ui/app-shell type-check` (both tsc programs): exit 0. - `@objectstack/example-showcase` `money-format-declarations.test.ts`: 5 passed. - `@objectstack/spec` `formula-currency-result`, `form-return-type-options`, `field`: 327 passed. - `pnpm --dir ui exec vitest run scripts/`: 171 files passed, 2 skipped; 5092 tests passed, 2 skipped. - Round 2's ratchet fix stands: the stamp's field check is two plain comparisons, not a column-identity dual read. There is no inventory entry. </details> <details><summary>Ablations (scripts/ablation-replace.mjs; each leg landed on disk and was restored to blob == HEAD with an empty git diff HEAD)</summary> - A (4ea7e78), the withdraw branch: replaced with a bare return. Red: "the card's repro ... drops currency and its currencyConfig". - B (4ea7e78), the money-proof branch: the condition replaced with `false`. Red: "a number formula edited into money is stamped currency". - C (76bbb54), the producer's unproven early return: removed. Red: "each answers {}". - D (ae8b9cf), M1 route (b): `hasPlainUnit` read a formula with no `returnType` as plain (`return field.returnType !== 'currency'`), blob 61722a6 to 7b5806c3. Red: "each answers {}" (`record.subtotal * 0.2`) and the no-field-map pin. - E (ae8b9cf), S1, the percent guard in `stampFormulaType` removed, blob 80b3157 to 4817a67a. Red: the corrected CONTROL "a declared percent is still kept under a number verdict", "a declared percent is kept under a money verdict too", and the two #35047 percent pins. - F (ae8b9cf), S1, the config comparison forced equal (`sameFlatRecord(...)` to `true`), blob 80b3157 to d6c9c6f3. Red: the USD-to-EUR, dynamic and record-mode pins. - A's first attempt used a replacement text already present in the file. The tool refused it before running, so that attempt measured nothing. </details> ## Acceptance notes - **L2 record at `e5a7e08b` (FAIL): M1 and S1 to S4 are fixed here.** N1 and N2 are left for follow-up cards, as directed. - The optional spellings `record.?amount` and `record[?'amount']` answered `{}` at `e5a7e08b` too: the CEL checker does not type them, so they never reach the numeric path. Their pins guard the new read check, but they would not discriminate against that head. - **Summary roll-ups: ruled A by the PM, done here.** The producer answers `{}` for a money-reaching expression it cannot prove, so a currency formula over a roll-up keeps its declared `currency` on edit. Before, it was withdrawn on a `number` answer. - The card's example `count(record.lines)` answers `{}` (unproven: `count` is not a CEL function the checker types), so a declared `currency` is kept for that exact text. The pins use a typed count (`record.est_hours * 2`), which answers `number`. - When money is proven, the stamp writes the proven `currencyConfig` and clears one that is absent. A `currencyConfig` the author set by hand on a currency formula over a dynamic amount is therefore removed on the next expression edit. That is the producer's stated contract (the declaration is the pair). Selecting a field still writes nothing. - File surface: beyond the claim's surface, this PR also touches `@objectstack/formula` (the producer, ruling A), `celAuthoring.ts` (the lazy engine seam; a static import would put cel-js in the main bundle and bypass the test seam) and the spec prose plus its regenerated reference docs (they would otherwise state the old rule). The spec edit is prose only, but it touches `packages/spec/src/**`, so an L2 record is owed. ## Verification <details><summary>Local gates at b9ce479</summary> - Derived with `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack`: 117 families. `--ran` reconciliation: 117 of 117 accounted for, exit 0. - 112 exit 0 on the first pass, and the ui scripts vitest passed. - `check:dts-closure` went red during the concurrent client build, which was rewriting the spec dist at the time; re-run once it finished: exit 0, 228 of 228 declaration files present. - `check:skill-examples` answered exit 3 before the client packages were built; re-run after: exit 0, 346 examples. - The 22 families that read the spec dist were re-run on a stable dist: all exit 0. - Two NOT MEASURED (exit 3, PREREQUISITE NOT MET), which CI runs: `check-plugin-teardown-shape --self-test` (shallow clone) and `check:dual-build-cjs-loads` (needs a full build). - `overlap-check`: VERDICT clean before the push. `check-nul-bytes`: OK. </details> CI runs the full farm. --- _Generated by [Claude Code](https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb)_ --- Body refreshed 2026-11-20T09:05Z for rework round 3 (contract review 7034135842: M1, S1–S4), head b9ce479. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent cbc50a5 commit 401eb44

10 files changed

Lines changed: 475 additions & 62 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@objectstack/spec': patch
4+
'@objectstack/formula': patch
5+
---
6+
7+
fix(app-shell): Studio's formula inspector asks whether the formula still computes money before it keeps a `currency` result type
8+
9+
Clause-②: yes (widening)
10+
Metadata-protocol: none
11+
12+
When an author edited a formula field in Studio, the inspector re-stamped `returnType` from the expression's inferred CEL type, and kept a declared `currency` under every `number` or unproven verdict, because that type never says "money". So a formula edited from an amount (`record.amount * 0.1`) into a count (`record.est_hours * 2`) kept `returnType: 'currency'` and its `currencyConfig`, and its value was still shown as an amount.
13+
14+
The stamp now also asks `@objectstack/formula`'s `inferFormulaReturn`, over the object's declared fields, whether the edited expression computes money:
15+
16+
- Provably money: `returnType` is stamped `currency`, with the currency the source amounts are in as the formula's `currencyConfig` (absent for the tenant default currency). This holds for a formula that was `number` too.
17+
- An edit it answers `number` for withdraws a declared `currency`: `returnType` becomes `number` and the `currencyConfig` is removed.
18+
- An unproven verdict (a field-over-field quotient, two currencies meeting) keeps a declared `currency`, as before, and so does an engine that does not offer `inferFormulaReturn`.
19+
- A declared `percent` is unchanged: it survives a `number`, unproven or money verdict, and is never re-stamped `currency`. A verdict that proves `text`, `boolean` or `date` still stamps, and now also removes a stale `currencyConfig`.
20+
21+
`@objectstack/formula`'s `inferFormulaReturn` now answers `{}` (unproven) where it used to answer `{ returnType: 'number' }` on the numeric path, unless the unit proof succeeds or every read of the record (`record.x`, `record['x']`, `record.?x`, `record[?'x']`, or a bare `x`) is one segment naming a declared field whose unit can be read and is not money. FROM `inferFormulaReturn('record.rollup * 0.9', fields)` → `{ returnType: 'number' }` TO → `{}`. The same holds for `100 / record.amount`, `record.amount % 3`, `record.amount * 1.0 + record.fee_eur * 1.0` (two currencies), `double(record.amount) * double(record.tax)`, an amount whose `currencyConfig` does not parse, a hop through a reference (`record.account.balance * 0.9`), a formula operand that declares no `returnType` (`record.subtotal * 0.2`), the indexed and optional spellings of an amount (`record['amount'] * 0.1`), and a name the field map does not declare (`record.unknown_field * 2`). A call with no field map therefore answers `{}` for any numeric expression that reads the record (`inferFormulaReturn('record.amount * 0.1')` was `number`). So a `number` answer means "proved not money", and only that answer withdraws a declared `currency`.
22+
23+
What still answers `number` is an expression over declared fields of readable non-money units: number, percent and other plain fields, a formula declaring a non-`currency` `returnType`, and a `count` roll-up whose `summaryOperations` is passed. A bare ratio of two amounts in one currency (`record.amount / record.tax`) types `dyn` and answers `{}`, as before. A caller that read the old `number` for these shapes should read the expression's CEL type (`inferExpressionType`) instead. In Studio, a new formula over such an amount is still stamped `number` from that CEL type.
24+
25+
Widened: the published `FormulaSourceField` type gains one optional member, `summaryOperations` (a `summary` field's roll-up, as declared). A `count` roll-up is read as a plain number only when it is passed. A roll-up passed without `summaryOperations`, a `count` included, is read as possibly money, so an expression over it answers `{}`.
26+
27+
The stamp still runs only after the author edits the expression; selecting a field writes nothing. The `returnType` description in `@objectstack/spec` now says the same: `currency` is stamped when the expression provably computes money and withdrawn for `number` when an edit leaves it a plain number, and a declared `percent` is kept under a money verdict.

‎content/docs/references/data/field.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const result = CurrencyConfigSchema.parse(data);
9898
| **allowCreate** | `boolean` | optional | Allow inline quick-create from the record picker: when no match exists the user can create a record from the typed text (optimistic dataSource.create with the display field). Best for simple objects whose only required field is the display field. |
9999
| **lookupAutofill** | `{ target: string; source: string; overwrite?: boolean }[]` | optional | Fields a pick in this lookup fills on the record being edited: each `{ target, source }` pair copies the picked record's `source` field (a field of the `reference` object) into this object's `target` field — e.g. `[{ target: 'unit_price', source: 'list_price' }]` on a quote line's product lookup. Read wherever this field is picked: the record form, and a line-item grid column over it. OVERWRITE RULE — the default, `overwrite` absent or false: a pick never replaces a value somebody wrote. The target is filled only while it is empty or still holds the value an earlier pick filled in; a value the user typed, or one the record already stored, stays. Only a pair that declares `overwrite: true` replaces the target on every pick, whatever it holds. Client-side only: it fills the form, and nothing on the write path reads it — the filled value is saved as an ordinary write, and an import or API write that sets the lookup fills nothing. Only on a single-value `lookup` / `master_detail`. Each target is a field of this object other than this one, written by its author — not `readonly`, not computed (`formula`, `summary`, `autonumber`, or an `expression`) — and named once. Each source is a field of the referenced object that the record carries (not `internal`) and whose value the target can hold; `os validate` / `os build` judge the source. In a line-item grid the column key `autofill` still governs only the same-named copy and is unchanged; a declared pair takes its target out of that copy. |
100100
| **expression** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | CEL expression the field's value is computed from, e.g. F`record.amount * 0.1`. On a `formula` field: computed on read, no column. On any other (stored) field: computed by the engine from the row the write stores and stored, so a client-sent value never stands and a `summary` can roll the column up — on every insert and every update by id (the stored row merged with the patch), and on a predicate update only when the patch moves an input (one value for every matched row, else the update is refused). |
101-
| **returnType** | `Enum<'number' \| 'text' \| 'boolean' \| 'date' \| 'currency' \| 'percent'>` | optional | Value type of a formula field (number/text/boolean/date/currency/percent). Authoring stamps `number`, `text`, `boolean` or `date` from the expression's inferred type and leaves it absent when none is proven; `currency` and `percent` are declared by the author, and a verdict that proves no other type (`number`, or none) keeps them. `currency`: an amount of money, in the currency the formula's own `currencyConfig` declares, as a currency field declares it (no `currencyConfig`: dynamic, the tenant default currency). `percent`: a ratio, read and displayed as a `percent` field reads its stored value — a fraction (0.25 shows 25%, so the expression divides and does not multiply by 100) unless the formula declares a `max` above 1, then percentage points; its `scale` is the decimal places of the displayed percentage (absent: 0), and its `percentDisplay` picks the bar or the plain face. |
101+
| **returnType** | `Enum<'number' \| 'text' \| 'boolean' \| 'date' \| 'currency' \| 'percent'>` | optional | Value type of a formula field (number/text/boolean/date/currency/percent). Authoring stamps `number`, `text`, `boolean` or `date` from the expression's inferred type and leaves it absent when none is proven; `percent` is declared by the author, and a verdict that proves no other type (`number`, or none) keeps it, as does a money verdict: a declared `percent` is never re-stamped `currency`. Otherwise `currency` is stamped when the expression provably computes money, and withdrawn for `number` (its `currencyConfig` dropped) when an edit leaves it a plain number; an unproven verdict keeps it. `currency`: an amount of money, in the currency the formula's own `currencyConfig` declares, as a currency field declares it (no `currencyConfig`: dynamic, the tenant default currency). `percent`: a ratio, read and displayed as a `percent` field reads its stored value — a fraction (0.25 shows 25%, so the expression divides and does not multiply by 100) unless the formula declares a `max` above 1, then percentage points; its `scale` is the decimal places of the displayed percentage (absent: 0), and its `percentDisplay` picks the bar or the plain face. |
102102
| **summaryOperations** | `{ object: string; field?: string; function: Enum<'count' \| 'sum' \| 'min' \| 'max' \| 'avg'>; relationshipField?: string; … }` | optional | Roll-up summary definition. The engine recomputes the value when child records are inserted/updated/deleted. |
103103
| **language** | `string` | optional | Programming language for syntax highlighting (e.g., javascript, python, sql) |
104104
| **step** | `number` | optional | Step increment for slider (default: 1) |

‎content/docs/references/data/object.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ const result = ApiMethod.parse(data);
277277
| **allowCreate** | `boolean` | optional | Allow inline quick-create from the record picker: when no match exists the user can create a record from the typed text (optimistic dataSource.create with the display field). Best for simple objects whose only required field is the display field. |
278278
| **lookupAutofill** | `{ target: string; source: string; overwrite?: boolean }[]` | optional | Fields a pick in this lookup fills on the record being edited: each `{ target, source }` pair copies the picked record's `source` field (a field of the `reference` object) into this object's `target` field — e.g. `[{ target: 'unit_price', source: 'list_price' }]` on a quote line's product lookup. Read wherever this field is picked: the record form, and a line-item grid column over it. OVERWRITE RULE — the default, `overwrite` absent or false: a pick never replaces a value somebody wrote. The target is filled only while it is empty or still holds the value an earlier pick filled in; a value the user typed, or one the record already stored, stays. Only a pair that declares `overwrite: true` replaces the target on every pick, whatever it holds. Client-side only: it fills the form, and nothing on the write path reads it — the filled value is saved as an ordinary write, and an import or API write that sets the lookup fills nothing. Only on a single-value `lookup` / `master_detail`. Each target is a field of this object other than this one, written by its author — not `readonly`, not computed (`formula`, `summary`, `autonumber`, or an `expression`) — and named once. Each source is a field of the referenced object that the record carries (not `internal`) and whose value the target can hold; `os validate` / `os build` judge the source. In a line-item grid the column key `autofill` still governs only the same-named copy and is unchanged; a declared pair takes its target out of that copy. |
279279
| **expression** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | CEL expression the field's value is computed from, e.g. F`record.amount * 0.1`. On a `formula` field: computed on read, no column. On any other (stored) field: computed by the engine from the row the write stores and stored, so a client-sent value never stands and a `summary` can roll the column up — on every insert and every update by id (the stored row merged with the patch), and on a predicate update only when the patch moves an input (one value for every matched row, else the update is refused). |
280-
| **returnType** | `Enum<'number' \| 'text' \| 'boolean' \| 'date' \| 'currency' \| 'percent'>` | optional | Value type of a formula field (number/text/boolean/date/currency/percent). Authoring stamps `number`, `text`, `boolean` or `date` from the expression's inferred type and leaves it absent when none is proven; `currency` and `percent` are declared by the author, and a verdict that proves no other type (`number`, or none) keeps them. `currency`: an amount of money, in the currency the formula's own `currencyConfig` declares, as a currency field declares it (no `currencyConfig`: dynamic, the tenant default currency). `percent`: a ratio, read and displayed as a `percent` field reads its stored value — a fraction (0.25 shows 25%, so the expression divides and does not multiply by 100) unless the formula declares a `max` above 1, then percentage points; its `scale` is the decimal places of the displayed percentage (absent: 0), and its `percentDisplay` picks the bar or the plain face. |
280+
| **returnType** | `Enum<'number' \| 'text' \| 'boolean' \| 'date' \| 'currency' \| 'percent'>` | optional | Value type of a formula field (number/text/boolean/date/currency/percent). Authoring stamps `number`, `text`, `boolean` or `date` from the expression's inferred type and leaves it absent when none is proven; `percent` is declared by the author, and a verdict that proves no other type (`number`, or none) keeps it, as does a money verdict: a declared `percent` is never re-stamped `currency`. Otherwise `currency` is stamped when the expression provably computes money, and withdrawn for `number` (its `currencyConfig` dropped) when an edit leaves it a plain number; an unproven verdict keeps it. `currency`: an amount of money, in the currency the formula's own `currencyConfig` declares, as a currency field declares it (no `currencyConfig`: dynamic, the tenant default currency). `percent`: a ratio, read and displayed as a `percent` field reads its stored value — a fraction (0.25 shows 25%, so the expression divides and does not multiply by 100) unless the formula declares a `max` above 1, then percentage points; its `scale` is the decimal places of the displayed percentage (absent: 0), and its `percentDisplay` picks the bar or the plain face. |
281281
| **summaryOperations** | `{ object: string; field?: string; function: Enum<'count' \| 'sum' \| 'min' \| 'max' \| 'avg'>; relationshipField?: string; … }` | optional | Roll-up summary definition. The engine recomputes the value when child records are inserted/updated/deleted. |
282282
| **language** | `string` | optional | Programming language for syntax highlighting (e.g., javascript, python, sql) |
283283
| **step** | `number` | optional | Step increment for slider (default: 1) |
@@ -657,7 +657,7 @@ const result = ApiMethod.parse(data);
657657
| **allowCreate** | `boolean` | optional | Allow inline quick-create from the record picker: when no match exists the user can create a record from the typed text (optimistic dataSource.create with the display field). Best for simple objects whose only required field is the display field. |
658658
| **lookupAutofill** | `{ target: string; source: string; overwrite?: boolean }[]` | optional | Fields a pick in this lookup fills on the record being edited: each `{ target, source }` pair copies the picked record's `source` field (a field of the `reference` object) into this object's `target` field — e.g. `[{ target: 'unit_price', source: 'list_price' }]` on a quote line's product lookup. Read wherever this field is picked: the record form, and a line-item grid column over it. OVERWRITE RULE — the default, `overwrite` absent or false: a pick never replaces a value somebody wrote. The target is filled only while it is empty or still holds the value an earlier pick filled in; a value the user typed, or one the record already stored, stays. Only a pair that declares `overwrite: true` replaces the target on every pick, whatever it holds. Client-side only: it fills the form, and nothing on the write path reads it — the filled value is saved as an ordinary write, and an import or API write that sets the lookup fills nothing. Only on a single-value `lookup` / `master_detail`. Each target is a field of this object other than this one, written by its author — not `readonly`, not computed (`formula`, `summary`, `autonumber`, or an `expression`) — and named once. Each source is a field of the referenced object that the record carries (not `internal`) and whose value the target can hold; `os validate` / `os build` judge the source. In a line-item grid the column key `autofill` still governs only the same-named copy and is unchanged; a declared pair takes its target out of that copy. |
659659
| **expression** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | CEL expression the field's value is computed from, e.g. F`record.amount * 0.1`. On a `formula` field: computed on read, no column. On any other (stored) field: computed by the engine from the row the write stores and stored, so a client-sent value never stands and a `summary` can roll the column up — on every insert and every update by id (the stored row merged with the patch), and on a predicate update only when the patch moves an input (one value for every matched row, else the update is refused). |
660-
| **returnType** | `Enum<'number' \| 'text' \| 'boolean' \| 'date' \| 'currency' \| 'percent'>` | optional | Value type of a formula field (number/text/boolean/date/currency/percent). Authoring stamps `number`, `text`, `boolean` or `date` from the expression's inferred type and leaves it absent when none is proven; `currency` and `percent` are declared by the author, and a verdict that proves no other type (`number`, or none) keeps them. `currency`: an amount of money, in the currency the formula's own `currencyConfig` declares, as a currency field declares it (no `currencyConfig`: dynamic, the tenant default currency). `percent`: a ratio, read and displayed as a `percent` field reads its stored value — a fraction (0.25 shows 25%, so the expression divides and does not multiply by 100) unless the formula declares a `max` above 1, then percentage points; its `scale` is the decimal places of the displayed percentage (absent: 0), and its `percentDisplay` picks the bar or the plain face. |
660+
| **returnType** | `Enum<'number' \| 'text' \| 'boolean' \| 'date' \| 'currency' \| 'percent'>` | optional | Value type of a formula field (number/text/boolean/date/currency/percent). Authoring stamps `number`, `text`, `boolean` or `date` from the expression's inferred type and leaves it absent when none is proven; `percent` is declared by the author, and a verdict that proves no other type (`number`, or none) keeps it, as does a money verdict: a declared `percent` is never re-stamped `currency`. Otherwise `currency` is stamped when the expression provably computes money, and withdrawn for `number` (its `currencyConfig` dropped) when an edit leaves it a plain number; an unproven verdict keeps it. `currency`: an amount of money, in the currency the formula's own `currencyConfig` declares, as a currency field declares it (no `currencyConfig`: dynamic, the tenant default currency). `percent`: a ratio, read and displayed as a `percent` field reads its stored value — a fraction (0.25 shows 25%, so the expression divides and does not multiply by 100) unless the formula declares a `max` above 1, then percentage points; its `scale` is the decimal places of the displayed percentage (absent: 0), and its `percentDisplay` picks the bar or the plain face. |
661661
| **summaryOperations** | `{ object: string; field?: string; function: Enum<'count' \| 'sum' \| 'min' \| 'max' \| 'avg'>; relationshipField?: string; … }` | optional | Roll-up summary definition. The engine recomputes the value when child records are inserted/updated/deleted. |
662662
| **language** | `string` | optional | Programming language for syntax highlighting (e.g., javascript, python, sql) |
663663
| **step** | `number` | optional | Step increment for slider (default: 1) |

0 commit comments

Comments
 (0)