Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +1 -1
- VERSION +1 -1
- api/automation_engine.py +0 -0
- platform/aios_grid.py +6 -1
- platform/core/grid_events.py +10 -1
- platform/core/user_tables.py +200 -1
- web/src/customer-grid/ColumnMenu.tsx +270 -3
- web/src/customer-grid/CustomerGrid.tsx +30 -1
- web/src/customer-grid/apiBridge.ts +29 -0
- web/src/customer-grid/cells.ts +40 -0
- web/src/customer-grid/clipboard.ts +10 -1
- web/src/customer-grid/iconShapes.ts +23 -0
- web/src/customer-grid/types.ts +124 -2
- web/src/settings/permsModel.ts +5 -0
- web/src/viz/seriesData.ts +4 -0
- web/src/viz/types.ts +9 -1
RELEASES.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": [
|
| 4 |
{
|
| 5 |
"version": "v14",
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "cd54156",
|
| 3 |
"releases": [
|
| 4 |
{
|
| 5 |
"version": "v14",
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
cd54156
|
api/automation_engine.py
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
platform/aios_grid.py
CHANGED
|
@@ -115,9 +115,14 @@ def _round(v):
|
|
| 115 |
#: string on the wire, so it rides the ordinary overlay wall β what makes it a json field is that
|
| 116 |
#: `grid_events` REFUSES a write that does not parse (a column promising structure must not
|
| 117 |
#: silently hold something that isn't).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
CUSTOM_FIELD_TYPES = {"text", "select", "multiselect", "user", "int", "currency", "pct", "date",
|
| 119 |
"checkbox", "phone", "email", "url", "rating", "created_time", "formula",
|
| 120 |
-
"automation", "image", "json"}
|
| 121 |
#: User-created types whose CELLS are read-only: their values are computed (formula β client
|
| 122 |
#: side, any error degrades to BLANK) or system-owned (created_time = the row's `_created`).
|
| 123 |
#: Emitted with the cohort column's read-only mechanism β `source: 'odoo'` + `derived` β so
|
|
|
|
| 115 |
#: string on the wire, so it rides the ordinary overlay wall β what makes it a json field is that
|
| 116 |
#: `grid_events` REFUSES a write that does not parse (a column promising structure must not
|
| 117 |
#: silently hold something that isn't).
|
| 118 |
+
#: β 2026-08-07 β `link` and `rollup` JOINED (the relational wave). They ride here because
|
| 119 |
+
#: `UT_FIELD_TYPES` must stay a SUBSET of this set (gated in verify_api's W18-UT section) β the
|
| 120 |
+
#: surfaces that CREATE them are the user-table databases, where a relation between two tables is
|
| 121 |
+
#: a thing that exists. On the Odoo-backed Customer/Product grids there is no second user table to
|
| 122 |
+
#: point at, so the column menu there simply never offers one.
|
| 123 |
CUSTOM_FIELD_TYPES = {"text", "select", "multiselect", "user", "int", "currency", "pct", "date",
|
| 124 |
"checkbox", "phone", "email", "url", "rating", "created_time", "formula",
|
| 125 |
+
"automation", "image", "json", "link", "rollup"}
|
| 126 |
#: User-created types whose CELLS are read-only: their values are computed (formula β client
|
| 127 |
#: side, any error degrades to BLANK) or system-owned (created_time = the row's `_created`).
|
| 128 |
#: Emitted with the cohort column's read-only mechanism β `source: 'odoo'` + `derived` β so
|
platform/core/grid_events.py
CHANGED
|
@@ -1742,7 +1742,16 @@ def handle_one(event, ctx):
|
|
| 1742 |
# C7 (wave 22): a METRIC cell is engine-computed from the master series β a
|
| 1743 |
# human write would be an invented measurement, refused the way an automation
|
| 1744 |
# cell is (the wall, not the courtesy).
|
| 1745 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1746 |
refused = True
|
| 1747 |
continue
|
| 1748 |
_auto = (_fdef or {}).get('automation')
|
|
|
|
| 1742 |
# C7 (wave 22): a METRIC cell is engine-computed from the master series β a
|
| 1743 |
# human write would be an invented measurement, refused the way an automation
|
| 1744 |
# cell is (the wall, not the courtesy).
|
| 1745 |
+
# β 2026-08-07 β EXTENDED TO THE RELATIONAL PAIR, and read through the field
|
| 1746 |
+
# layer's own predicate rather than re-tested here. A `rollup` cell is an
|
| 1747 |
+
# aggregate the server computes; a DERIVED `link` cell is a join the server
|
| 1748 |
+
# resolves. Both would be overwritten by the next refresh anyway, so accepting
|
| 1749 |
+
# the write would not merely be wrong β it would look like it worked and then
|
| 1750 |
+
# silently revert, which is worse than a refusal.
|
| 1751 |
+
# β An ORDINARY (user-picked) link is deliberately NOT refused: `is_computed_cell`
|
| 1752 |
+
# answers per FIELD, not per type, because one kind is read-only in one mode and
|
| 1753 |
+
# editable in the other.
|
| 1754 |
+
if _ut_mod.is_computed_cell(_fdef):
|
| 1755 |
refused = True
|
| 1756 |
continue
|
| 1757 |
_auto = (_fdef or {}).get('automation')
|
platform/core/user_tables.py
CHANGED
|
@@ -61,8 +61,14 @@ KEY_PREFIX = 'ut_'
|
|
| 61 |
#: β `json` JOINED IN WAVE 23 (C7) β and it belongs here rather than staying grid-only the way
|
| 62 |
#: `image` did, because the databases that need it are exactly these: a scrape lands a comment
|
| 63 |
#: thread or a webhook payload against a row, and the automation engine writes those cells.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
UT_FIELD_TYPES = {'text', 'select', 'multiselect', 'user', 'int', 'currency', 'pct', 'date',
|
| 65 |
-
'checkbox', 'phone', 'email', 'url', 'rating', 'automation', 'json'
|
|
|
|
| 66 |
#: C7's ceiling. A cell is still a scalar on the wire (`Row` values are strings/numbers) β what
|
| 67 |
#: this bounds is the DOCUMENT inside it. 32 KB holds a long comment thread and refuses a payload
|
| 68 |
#: somebody meant to store as a file.
|
|
@@ -116,6 +122,11 @@ PROFILE_PRESET_KEYS = (
|
|
| 116 |
'external_url', 'verified', 'category', 'business_category', 'is_business',
|
| 117 |
'is_professional', 'is_private', 'highlights_count', 'bio_hashtags', 'post_hashtags',
|
| 118 |
'pronouns', 'ig_id', 'profile_url',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
# R3's LATEST-value stamp. The full series stays in `ut_ig_snapshots` β one store for one
|
| 120 |
# series β which is why clearing here can never be a history delete.
|
| 121 |
'enriched_at',
|
|
@@ -571,6 +582,150 @@ def _clean_metric(raw):
|
|
| 571 |
return out
|
| 572 |
|
| 573 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 574 |
def _clean_field(raw, previous=None):
|
| 575 |
"""One field dict β the stored shape, or None. The single validator for create AND patch, so
|
| 576 |
a column cannot be typed one way on the way in and another on the way back."""
|
|
@@ -632,9 +787,53 @@ def _clean_field(raw, previous=None):
|
|
| 632 |
if p is None or ftype != 'text':
|
| 633 |
return None
|
| 634 |
out['profile'] = p
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 635 |
return out
|
| 636 |
|
| 637 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 638 |
def clean_machine_fields(fields):
|
| 639 |
"""`(clean, refused)` β the SANCTIONED way for a machine writer to seed a table's schema
|
| 640 |
(wave 25, doc order step 2). `clean` is the list as this module would store it; `refused`
|
|
|
|
| 61 |
#: β `json` JOINED IN WAVE 23 (C7) β and it belongs here rather than staying grid-only the way
|
| 62 |
#: `image` did, because the databases that need it are exactly these: a scrape lands a comment
|
| 63 |
#: thread or a webhook payload against a row, and the automation engine writes those cells.
|
| 64 |
+
#: β 2026-08-07 β `link` and `rollup` JOINED (the relational wave). They belong here for
|
| 65 |
+
#: `metric`'s reason, not `formula`'s: their cells are MACHINE-COMPUTED SERVER-SIDE and
|
| 66 |
+
#: materialised into the row, because a rollup reads ANOTHER TABLE'S ROWS β data the client has
|
| 67 |
+
#: not loaded and must not have to. `formula` stayed out of this list because it computes
|
| 68 |
+
#: client-side over one row; that argument does not reach these two.
|
| 69 |
UT_FIELD_TYPES = {'text', 'select', 'multiselect', 'user', 'int', 'currency', 'pct', 'date',
|
| 70 |
+
'checkbox', 'phone', 'email', 'url', 'rating', 'automation', 'json',
|
| 71 |
+
'link', 'rollup'}
|
| 72 |
#: C7's ceiling. A cell is still a scalar on the wire (`Row` values are strings/numbers) β what
|
| 73 |
#: this bounds is the DOCUMENT inside it. 32 KB holds a long comment thread and refuses a payload
|
| 74 |
#: somebody meant to store as a file.
|
|
|
|
| 122 |
'external_url', 'verified', 'category', 'business_category', 'is_business',
|
| 123 |
'is_professional', 'is_private', 'highlights_count', 'bio_hashtags', 'post_hashtags',
|
| 124 |
'pronouns', 'ig_id', 'profile_url',
|
| 125 |
+
# β 2026-08-07 β the rest of the Bright Data profile schema, promoted to preset columns by
|
| 126 |
+
# owner instruction. They are profile FACTS like the nineteen above, so blanking the handle
|
| 127 |
+
# clears them for the same reason (R6): they describe an account this row no longer names.
|
| 128 |
+
'profile_name', 'is_joined_recently', 'has_channel', 'partner_id', 'external_url_title',
|
| 129 |
+
'fbid', 'related_accounts', 'country_code',
|
| 130 |
# R3's LATEST-value stamp. The full series stays in `ut_ig_snapshots` β one store for one
|
| 131 |
# series β which is why clearing here can never be a history delete.
|
| 132 |
'enriched_at',
|
|
|
|
| 582 |
return out
|
| 583 |
|
| 584 |
|
| 585 |
+
# ---------------------------------------------------------------------------------------------
|
| 586 |
+
# ββ THE RELATIONAL PAIR (2026-08-07, owner instruction) β `link` and `rollup`
|
| 587 |
+
# ---------------------------------------------------------------------------------------------
|
| 588 |
+
# Owner: *"adding relational database function with links and rollups⦠exactly like how Airtable
|
| 589 |
+
# does it⦠and this rollup needs to have formula that we can use to calculate things like average
|
| 590 |
+
# Views over last N posts."*
|
| 591 |
+
#
|
| 592 |
+
# Airtable's own contract, fetched 2026-08-07 (SPEC):
|
| 593 |
+
# multipleRecordLinks.options : linkedTableId Β· isReversed Β· prefersSingleRecordLink Β·
|
| 594 |
+
# inverseLinkFieldId Β· viewIdForRecordSelection
|
| 595 |
+
# rollup.options : recordLinkFieldId Β· fieldIdInLinkedTable Β· result Β·
|
| 596 |
+
# referencedFieldIds Β· isValid
|
| 597 |
+
# 17 functions, and a rollup is exactly ONE HOP.
|
| 598 |
+
#
|
| 599 |
+
# β THE CELL IS A SCALAR, WHICH IS NOT A PREFERENCE. Airtable's link cell is an ARRAY of record
|
| 600 |
+
# ids; the `Row` contract here is scalars end to end and `grid_events` refuses a non-scalar write.
|
| 601 |
+
# So a link cell holds a COMMA-JOINED list of linked row ids β the shape `multiselect` already
|
| 602 |
+
# uses for a set, so the grouping/filter/copy paths already know what to do with it.
|
| 603 |
+
#
|
| 604 |
+
# β TWO MODES, ONE KIND, AND `on` IS THE DISCRIMINATOR:
|
| 605 |
+
# `on` DECLARED -> a DERIVED link. The linked rows are those whose `on` column equals this
|
| 606 |
+
# row's `from` column. Machine-maintained, read-only, recomputed on the same
|
| 607 |
+
# pass that already recomputes `metric` cells. THIS IS THE INSTAGRAM CASE, and
|
| 608 |
+
# it is why the mode exists: `ut_ig_posts.influencer_key` ALREADY holds the
|
| 609 |
+
# relation and is rewritten by the engine on every pull, so a second
|
| 610 |
+
# user-editable copy of the same relation could only ever drift away from it.
|
| 611 |
+
# `on` ABSENT -> an ORDINARY link. The user picks records; the cell is editable; `single` is
|
| 612 |
+
# Airtable's `prefersSingleRecordLink`.
|
| 613 |
+
#
|
| 614 |
+
# β NO `inverse` (Airtable's symmetric back-link field) THIS WAVE, and it is an omission rather
|
| 615 |
+
# than an oversight: maintaining one means every cell write fans out into a second table's rows
|
| 616 |
+
# through `grid_events`' emit guard β the cross-table write-amplification class D-40 was
|
| 617 |
+
# re-deferred BY RULING over. A derived link gets symmetry free (both sides re-derive from the
|
| 618 |
+
# same join), so the gap only touches ordinary links, where a back-link is a convenience.
|
| 619 |
+
|
| 620 |
+
#: How many linked ids one link cell may carry. Row ids are short numeric strings, so 500 ids is
|
| 621 |
+
#: ~3 KB β comfortably inside a text cell, and `MAX_ROWS` bounds the absolute worst case anyway.
|
| 622 |
+
LINK_MAX_IDS = 500
|
| 623 |
+
|
| 624 |
+
#: Airtable's 17 aggregations, minus the two that are meaningless over scalar cells.
|
| 625 |
+
#: β `arrayflatten` and `arrayslice` are NOT here: both operate on NESTED arrays, and a cell in
|
| 626 |
+
#: this product is a scalar β they could only ever return their own input, so offering them would
|
| 627 |
+
#: mint columns that compute nothing. `arrayslice`'s real use ("just the first N") is what `limit`
|
| 628 |
+
#: does below, honestly and by declared rank.
|
| 629 |
+
ROLLUP_FNS = ('sum', 'average', 'min', 'max', 'count', 'counta', 'countall',
|
| 630 |
+
'and', 'or', 'xor', 'concatenate', 'arrayjoin', 'arraycompact', 'arrayunique')
|
| 631 |
+
ROLLUP_SORT_DIRS = ('asc', 'desc')
|
| 632 |
+
#: The ceiling on `limit`. Not a performance bound β `MAX_ROWS` is that β but a refusal to let a
|
| 633 |
+
#: column claim a window bigger than a table can hold.
|
| 634 |
+
ROLLUP_MAX_LIMIT = MAX_ROWS
|
| 635 |
+
|
| 636 |
+
|
| 637 |
+
def _field_key(raw):
|
| 638 |
+
"""A field/table key as this module spells them, or '' β the same normalisation
|
| 639 |
+
`_clean_field` applies to `key`, so a bag can never name a key the field layer would store
|
| 640 |
+
differently."""
|
| 641 |
+
k = re.sub(r'[^a-z0-9_]+', '_', str(raw or '').strip().lower()).strip('_')[:60]
|
| 642 |
+
return k
|
| 643 |
+
|
| 644 |
+
|
| 645 |
+
def _clean_link(raw):
|
| 646 |
+
"""One `link` bag β the stored shape, or None (refused).
|
| 647 |
+
|
| 648 |
+
Same posture as `_clean_metric`: a mis-shaped bag REFUSES THE FIELD. A link column stored
|
| 649 |
+
without a usable target is a column promising a relation that nothing can ever resolve.
|
| 650 |
+
"""
|
| 651 |
+
if not isinstance(raw, dict):
|
| 652 |
+
return None
|
| 653 |
+
table = _field_key(raw.get('table'))
|
| 654 |
+
# β It must NAME A USER TABLE. A link into a connector-backed module key (`customer`,
|
| 655 |
+
# `product`) would promise a join across two strata with different row-id namespaces and
|
| 656 |
+
# different permission walls β a different feature, not a smaller version of this one.
|
| 657 |
+
if not table.startswith(KEY_PREFIX) or len(table) <= len(KEY_PREFIX):
|
| 658 |
+
return None
|
| 659 |
+
out = {'table': table}
|
| 660 |
+
on = _field_key(raw.get('on'))
|
| 661 |
+
frm = _field_key(raw.get('from'))
|
| 662 |
+
if on:
|
| 663 |
+
out['on'] = on
|
| 664 |
+
# `from` is OPTIONAL and resolved at compute time (the profile-flagged column, then the
|
| 665 |
+
# pinned one) β which is what makes an Instagram database link up with no configuration
|
| 666 |
+
# at all, i.e. the "automatically" in the instruction.
|
| 667 |
+
if frm:
|
| 668 |
+
out['from'] = frm
|
| 669 |
+
elif frm:
|
| 670 |
+
# β A `from` with no `on` configures NOTHING β there is no join to drive. Refused rather
|
| 671 |
+
# than dropped: a bag half of which is silently ignored is [[wrong-parent-not-broken-control]]
|
| 672 |
+
# with the control still on screen.
|
| 673 |
+
return None
|
| 674 |
+
if raw.get('single') is True:
|
| 675 |
+
out['single'] = True
|
| 676 |
+
return out
|
| 677 |
+
|
| 678 |
+
|
| 679 |
+
def _clean_rollup(raw):
|
| 680 |
+
"""One `rollup` bag β the stored shape, or None (refused).
|
| 681 |
+
|
| 682 |
+
β `limit` + `sortBy` ARE THE DELIBERATE SUPERSET OF AIRTABLE, and they are the owner's
|
| 683 |
+
headline: *"average Views over last N posts"*. Airtable's rollup conditions filter by
|
| 684 |
+
PREDICATE, never by RANK, so "the last 12" is not expressible there at all.
|
| 685 |
+
|
| 686 |
+
β `limit` REQUIRES `sortBy`, and that refusal is the whole care in this function. "The last
|
| 687 |
+
N" with no declared order is not a measurement β it is whichever N rows happen to sit first
|
| 688 |
+
in the store, which for an append table is capture order and for a merged one is nothing at
|
| 689 |
+
all. A wrong number that looks right is the failure this module refuses everywhere else.
|
| 690 |
+
"""
|
| 691 |
+
if not isinstance(raw, dict):
|
| 692 |
+
return None
|
| 693 |
+
link = _field_key(raw.get('link'))
|
| 694 |
+
field = _field_key(raw.get('field'))
|
| 695 |
+
fn = str(raw.get('fn') or '').strip().lower()
|
| 696 |
+
if not link or fn not in ROLLUP_FNS:
|
| 697 |
+
return None
|
| 698 |
+
# `countall` counts LINKED RECORDS, so it alone needs no field to read (Airtable's rule).
|
| 699 |
+
if not field and fn != 'countall':
|
| 700 |
+
return None
|
| 701 |
+
out = {'link': link, 'fn': fn}
|
| 702 |
+
if field:
|
| 703 |
+
out['field'] = field
|
| 704 |
+
try:
|
| 705 |
+
limit = int(str(raw.get('limit') or '0').strip() or 0)
|
| 706 |
+
except (TypeError, ValueError):
|
| 707 |
+
return None
|
| 708 |
+
sort_by = _field_key(raw.get('sortBy'))
|
| 709 |
+
sort_dir = str(raw.get('sortDir') or '').strip().lower()
|
| 710 |
+
if limit < 0 or limit > ROLLUP_MAX_LIMIT:
|
| 711 |
+
return None
|
| 712 |
+
if limit and not sort_by:
|
| 713 |
+
return None
|
| 714 |
+
if sort_dir and sort_dir not in ROLLUP_SORT_DIRS:
|
| 715 |
+
return None
|
| 716 |
+
if sort_by:
|
| 717 |
+
out['sortBy'] = sort_by
|
| 718 |
+
# Newest-first is the default because every window this feature exists for is "the LAST
|
| 719 |
+
# N", and a default that silently means "the first N" would answer a different question
|
| 720 |
+
# with the same column name.
|
| 721 |
+
out['sortDir'] = sort_dir or 'desc'
|
| 722 |
+
if limit:
|
| 723 |
+
out['limit'] = limit
|
| 724 |
+
elif sort_dir:
|
| 725 |
+
return None
|
| 726 |
+
return out
|
| 727 |
+
|
| 728 |
+
|
| 729 |
def _clean_field(raw, previous=None):
|
| 730 |
"""One field dict β the stored shape, or None. The single validator for create AND patch, so
|
| 731 |
a column cannot be typed one way on the way in and another on the way back."""
|
|
|
|
| 787 |
if p is None or ftype != 'text':
|
| 788 |
return None
|
| 789 |
out['profile'] = p
|
| 790 |
+
# β 2026-08-07 β the relational pair. Same posture as the two bags above: a mis-shaped bag
|
| 791 |
+
# refuses the FIELD, and the bag is required for its own type. β THE TYPE/BAG PAIRING IS
|
| 792 |
+
# ENFORCED BOTH WAYS β a `link` with no `link` bag is a column that can never resolve a row,
|
| 793 |
+
# and a `link` bag on an `int` column is a declaration nothing reads. Either half alone is the
|
| 794 |
+
# silent kind of broken: the column exists, renders, and means nothing.
|
| 795 |
+
link_raw = raw.get('link') if 'link' in raw else prev.get('link')
|
| 796 |
+
if link_raw is not None:
|
| 797 |
+
lk = _clean_link(link_raw)
|
| 798 |
+
if lk is None or ftype != 'link':
|
| 799 |
+
return None
|
| 800 |
+
out['link'] = lk
|
| 801 |
+
elif ftype == 'link':
|
| 802 |
+
return None
|
| 803 |
+
rollup_raw = raw.get('rollup') if 'rollup' in raw else prev.get('rollup')
|
| 804 |
+
if rollup_raw is not None:
|
| 805 |
+
rl = _clean_rollup(rollup_raw)
|
| 806 |
+
if rl is None or ftype != 'rollup':
|
| 807 |
+
return None
|
| 808 |
+
out['rollup'] = rl
|
| 809 |
+
elif ftype == 'rollup':
|
| 810 |
+
return None
|
| 811 |
return out
|
| 812 |
|
| 813 |
|
| 814 |
+
def is_derived_link(field):
|
| 815 |
+
"""Is this a link whose cell the ENGINE owns? (an `on` join, not a user-picked set)
|
| 816 |
+
|
| 817 |
+
β ONE definition, read by the write wall, the compute pass and the wire. The alternative is
|
| 818 |
+
three places independently asking "does the bag have an `on`", which is how one of them
|
| 819 |
+
silently keeps taking writes after the other two stop.
|
| 820 |
+
"""
|
| 821 |
+
lk = (field or {}).get('link')
|
| 822 |
+
return isinstance(lk, dict) and bool(lk.get('on'))
|
| 823 |
+
|
| 824 |
+
|
| 825 |
+
def is_computed_cell(field):
|
| 826 |
+
"""Is this field's cell computed by the SERVER, so a human write is an invented value?
|
| 827 |
+
|
| 828 |
+
The `ut_*` twin of `aios_grid.READONLY_CUSTOM_TYPES`, and deliberately a PREDICATE rather
|
| 829 |
+
than a type set: a `link` is read-only when it is derived and editable when it is not, which
|
| 830 |
+
a set of type names cannot express. `grid_events` is the wall that reads it.
|
| 831 |
+
"""
|
| 832 |
+
f = field or {}
|
| 833 |
+
return (isinstance(f.get('metric'), dict) or f.get('type') == 'rollup'
|
| 834 |
+
or is_derived_link(f))
|
| 835 |
+
|
| 836 |
+
|
| 837 |
def clean_machine_fields(fields):
|
| 838 |
"""`(clean, refused)` β the SANCTIONED way for a machine writer to seed a table's schema
|
| 839 |
(wave 25, doc order step 2). `clean` is the list as this module would store it; `refused`
|
web/src/customer-grid/ColumnMenu.tsx
CHANGED
|
@@ -4,8 +4,10 @@ import type { AnchorRect } from "./OverlaySurface";
|
|
| 4 |
import { FieldTypeIcon, MenuLabel } from "./icons";
|
| 5 |
import { FieldSelectButton } from "./FieldSelect";
|
| 6 |
import { CREATABLE_TYPES, choiceOptions, choiceRenames, directionLabel, isMachineOwned,
|
| 7 |
-
isProfileField, parseOptions, ratingMax } from "./types";
|
| 8 |
-
import type { Field, FieldFormat, FieldScope, FieldType, Measure,
|
|
|
|
|
|
|
| 9 |
import type { WindowSpec } from "./windows";
|
| 10 |
import { normalizeWindow, windowLabel } from "./windows";
|
| 11 |
import { WindowPicker } from "../filter-kit";
|
|
@@ -54,6 +56,14 @@ interface FieldConfigExtra {
|
|
| 54 |
/** Wave-18 C5-AUTOFIELD β an automation column's configuration, the same way `formula`
|
| 55 |
* carries an expression. Validated host-side (`aios_grid._clean_automation`). */
|
| 56 |
automation?: { kind: string; source: "record_url_field" | "self"; urlField?: string };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
}
|
| 58 |
|
| 59 |
interface ColumnMenuProps {
|
|
@@ -62,6 +72,16 @@ interface ColumnMenuProps {
|
|
| 62 |
/** Every field of the table, for "Change field" (owner item 9): the clicked column can be
|
| 63 |
* swapped for any other field β including hidden ones like Notes β in place. */
|
| 64 |
fields: Field[];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
locked: boolean;
|
| 66 |
/** Wave-5 item 1 β who is looking. Gates the permissions entry (creator-or-admin). */
|
| 67 |
viewer?: Viewer;
|
|
@@ -713,6 +733,21 @@ function ExtraTypeEditor({
|
|
| 713 |
onAutomationKind,
|
| 714 |
automationUrlField = "",
|
| 715 |
onAutomationUrlField,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 716 |
}: {
|
| 717 |
kind: FieldType | "measure";
|
| 718 |
fields: Field[];
|
|
@@ -729,6 +764,24 @@ function ExtraTypeEditor({
|
|
| 729 |
onAutomationKind?: (v: string) => void;
|
| 730 |
automationUrlField?: string;
|
| 731 |
onAutomationUrlField?: (v: string) => void;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 732 |
}) {
|
| 733 |
if (kind === "formula") {
|
| 734 |
// 2026-07-31 (owner item 2): other FORMULA fields are referencable now β evaluation is
|
|
@@ -866,6 +919,161 @@ function ExtraTypeEditor({
|
|
| 866 |
</>
|
| 867 |
);
|
| 868 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 869 |
return null;
|
| 870 |
}
|
| 871 |
|
|
@@ -873,6 +1081,7 @@ export default function ColumnMenu({
|
|
| 873 |
state,
|
| 874 |
field,
|
| 875 |
fields,
|
|
|
|
| 876 |
locked,
|
| 877 |
viewer,
|
| 878 |
sortedDir,
|
|
@@ -934,6 +1143,22 @@ export default function ColumnMenu({
|
|
| 934 |
const [automationUrlField, setAutomationUrlField] = useState(
|
| 935 |
() => fields.find((f) => f.type === "url")?.key ?? ""
|
| 936 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 937 |
const [swapTo, setSwapTo] = useState("");
|
| 938 |
/** The "New field" half of Change-field keeps its own name/options β a half-typed insert
|
| 939 |
* form must not leak into a swap and vice versa. */
|
|
@@ -1058,7 +1283,14 @@ export default function ColumnMenu({
|
|
| 1058 |
// C5-AUTOFIELD: an automation column with no URL column to read is a column no run can
|
| 1059 |
// ever fill β the same "permanently blank column" the formula rule above refuses, so it
|
| 1060 |
// is refused here rather than created and then discovered.
|
| 1061 |
-
(kind !== "automation" || automationUrlField !== "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1062 |
|
| 1063 |
const extraFor = (
|
| 1064 |
t: CreateKind,
|
|
@@ -1075,6 +1307,26 @@ export default function ColumnMenu({
|
|
| 1075 |
urlField: automationUrlField,
|
| 1076 |
},
|
| 1077 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1078 |
return undefined;
|
| 1079 |
};
|
| 1080 |
const optionExtraFor = (
|
|
@@ -1413,6 +1665,21 @@ export default function ColumnMenu({
|
|
| 1413 |
onAutomationKind={setAutomationKind}
|
| 1414 |
automationUrlField={automationUrlField}
|
| 1415 |
onAutomationUrlField={setAutomationUrlField}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1416 |
/>
|
| 1417 |
{needsOptions(kind) && (
|
| 1418 |
<OptionsEditor
|
|
|
|
| 4 |
import { FieldTypeIcon, MenuLabel } from "./icons";
|
| 5 |
import { FieldSelectButton } from "./FieldSelect";
|
| 6 |
import { CREATABLE_TYPES, choiceOptions, choiceRenames, directionLabel, isMachineOwned,
|
| 7 |
+
isProfileField, parseOptions, ratingMax, ROLLUP_FN_LABELS, ROLLUP_FNS } from "./types";
|
| 8 |
+
import type { Field, FieldFormat, FieldScope, FieldType, Measure, RollupFn,
|
| 9 |
+
Viewer } from "./types";
|
| 10 |
+
import type { LinkTarget } from "./apiBridge";
|
| 11 |
import type { WindowSpec } from "./windows";
|
| 12 |
import { normalizeWindow, windowLabel } from "./windows";
|
| 13 |
import { WindowPicker } from "../filter-kit";
|
|
|
|
| 56 |
/** Wave-18 C5-AUTOFIELD β an automation column's configuration, the same way `formula`
|
| 57 |
* carries an expression. Validated host-side (`aios_grid._clean_automation`). */
|
| 58 |
automation?: { kind: string; source: "record_url_field" | "self"; urlField?: string };
|
| 59 |
+
/** β 2026-08-07 β a `link` column's target. REQUIRED for the type: `_clean_field` returns
|
| 60 |
+
* None for a link with no bag, so a create without this is a column that never appears. */
|
| 61 |
+
link?: { table: string; single?: boolean };
|
| 62 |
+
/** β 2026-08-07 β a `rollup` column's aggregate. Same requirement, same reason. */
|
| 63 |
+
rollup?: {
|
| 64 |
+
link: string; field?: string; fn: string;
|
| 65 |
+
limit?: number; sortBy?: string; sortDir?: "asc" | "desc";
|
| 66 |
+
};
|
| 67 |
}
|
| 68 |
|
| 69 |
interface ColumnMenuProps {
|
|
|
|
| 72 |
/** Every field of the table, for "Change field" (owner item 9): the clicked column can be
|
| 73 |
* swapped for any other field β including hidden ones like Notes β in place. */
|
| 74 |
fields: Field[];
|
| 75 |
+
/**
|
| 76 |
+
* β 2026-08-07 β the OTHER databases a `link` column may point at, with their fields (so the
|
| 77 |
+
* rollup editor can offer real column names rather than a free-text key). Supplied by the host
|
| 78 |
+
* from `GET /tables`, which already filters by `may_open`.
|
| 79 |
+
*
|
| 80 |
+
* β ABSENT on the Odoo-backed Customer/Product grids, and that is what withdraws the two
|
| 81 |
+
* relational types from their create menu β there is no second user table to point at there,
|
| 82 |
+
* so offering "Link to another record" would be offering a column that can never resolve.
|
| 83 |
+
*/
|
| 84 |
+
linkTargets?: LinkTarget[];
|
| 85 |
locked: boolean;
|
| 86 |
/** Wave-5 item 1 β who is looking. Gates the permissions entry (creator-or-admin). */
|
| 87 |
viewer?: Viewer;
|
|
|
|
| 733 |
onAutomationKind,
|
| 734 |
automationUrlField = "",
|
| 735 |
onAutomationUrlField,
|
| 736 |
+
linkTargets = [],
|
| 737 |
+
linkTable = "",
|
| 738 |
+
onLinkTable,
|
| 739 |
+
linkSingle = false,
|
| 740 |
+
onLinkSingle,
|
| 741 |
+
rollupLink = "",
|
| 742 |
+
onRollupLink,
|
| 743 |
+
rollupField = "",
|
| 744 |
+
onRollupField,
|
| 745 |
+
rollupFn = "sum",
|
| 746 |
+
onRollupFn,
|
| 747 |
+
rollupLimit = 0,
|
| 748 |
+
onRollupLimit,
|
| 749 |
+
rollupSortBy = "",
|
| 750 |
+
onRollupSortBy,
|
| 751 |
}: {
|
| 752 |
kind: FieldType | "measure";
|
| 753 |
fields: Field[];
|
|
|
|
| 764 |
onAutomationKind?: (v: string) => void;
|
| 765 |
automationUrlField?: string;
|
| 766 |
onAutomationUrlField?: (v: string) => void;
|
| 767 |
+
/** β 2026-08-07 β the relational drafts. Optional for the same reason the automation ones
|
| 768 |
+
* are: the Change-field "new field" form reaches these kinds too, and a call site that does
|
| 769 |
+
* not offer them should need no change. */
|
| 770 |
+
linkTargets?: LinkTarget[];
|
| 771 |
+
linkTable?: string;
|
| 772 |
+
onLinkTable?: (v: string) => void;
|
| 773 |
+
linkSingle?: boolean;
|
| 774 |
+
onLinkSingle?: (v: boolean) => void;
|
| 775 |
+
rollupLink?: string;
|
| 776 |
+
onRollupLink?: (v: string) => void;
|
| 777 |
+
rollupField?: string;
|
| 778 |
+
onRollupField?: (v: string) => void;
|
| 779 |
+
rollupFn?: RollupFn;
|
| 780 |
+
onRollupFn?: (v: RollupFn) => void;
|
| 781 |
+
rollupLimit?: number;
|
| 782 |
+
onRollupLimit?: (v: number) => void;
|
| 783 |
+
rollupSortBy?: string;
|
| 784 |
+
onRollupSortBy?: (v: string) => void;
|
| 785 |
}) {
|
| 786 |
if (kind === "formula") {
|
| 787 |
// 2026-07-31 (owner item 2): other FORMULA fields are referencable now β evaluation is
|
|
|
|
| 919 |
</>
|
| 920 |
);
|
| 921 |
}
|
| 922 |
+
if (kind === "link") {
|
| 923 |
+
// β 2026-08-07 β Airtable's "Link to another record", and the whole editor is ONE question:
|
| 924 |
+
// which database. The relation itself is then the cell (a set of linked rows).
|
| 925 |
+
return (
|
| 926 |
+
<>
|
| 927 |
+
<label>
|
| 928 |
+
<span>Database</span>
|
| 929 |
+
<select
|
| 930 |
+
id={`${idPrefix}-link-table`}
|
| 931 |
+
className="cg-input"
|
| 932 |
+
value={linkTable}
|
| 933 |
+
aria-label="Database to link to"
|
| 934 |
+
onChange={(event) => onLinkTable?.(event.target.value)}
|
| 935 |
+
>
|
| 936 |
+
<option value="">Choose a databaseβ¦</option>
|
| 937 |
+
{linkTargets.map((t) => (
|
| 938 |
+
<option key={t.key} value={t.key}>{t.label}</option>
|
| 939 |
+
))}
|
| 940 |
+
</select>
|
| 941 |
+
</label>
|
| 942 |
+
{linkTargets.length === 0 ? (
|
| 943 |
+
<div className="cg-field-hint">
|
| 944 |
+
There is no other database to link to yet. Create one first, then come back.
|
| 945 |
+
</div>
|
| 946 |
+
) : null}
|
| 947 |
+
<label className="cg-cond-line">
|
| 948 |
+
<input
|
| 949 |
+
type="checkbox"
|
| 950 |
+
checked={linkSingle}
|
| 951 |
+
aria-label="Allow only one linked record"
|
| 952 |
+
onChange={(event) => onLinkSingle?.(event.target.checked)}
|
| 953 |
+
/>
|
| 954 |
+
<span>Allow only one linked record</span>
|
| 955 |
+
</label>
|
| 956 |
+
<div className="cg-field-hint">
|
| 957 |
+
A cell here holds the records you pick. Add a Rollup column afterwards to summarise a
|
| 958 |
+
column of those records β an average, a total, a count.
|
| 959 |
+
</div>
|
| 960 |
+
</>
|
| 961 |
+
);
|
| 962 |
+
}
|
| 963 |
+
if (kind === "rollup") {
|
| 964 |
+
// β 2026-08-07 β Airtable's rollup, plus the LAST-N window Airtable does not have.
|
| 965 |
+
//
|
| 966 |
+
// The editor reads as the sentence the column answers, in order: through WHICH relation, over
|
| 967 |
+
// WHICH column, folded HOW, and across WHICH records. That last control is the owner's
|
| 968 |
+
// headline ("average Views over last N posts") and Airtable cannot express it β its rollup
|
| 969 |
+
// conditions filter by predicate, never by rank.
|
| 970 |
+
const linkFields = fields.filter((f) => f.type === "link");
|
| 971 |
+
const chosenLink = linkFields.find((f) => f.key === rollupLink);
|
| 972 |
+
const target = linkTargets.find((t) => t.key === chosenLink?.link?.table);
|
| 973 |
+
const targetFields = target?.fields ?? [];
|
| 974 |
+
// β COUNTALL IS THE ONE FUNCTION WITH NO SOURCE COLUMN β it counts linked RECORDS, so the
|
| 975 |
+
// field picker would be a control that configures nothing. Airtable's rule, and ours.
|
| 976 |
+
const needsField = rollupFn !== "countall";
|
| 977 |
+
return (
|
| 978 |
+
<>
|
| 979 |
+
<label>
|
| 980 |
+
<span>Through</span>
|
| 981 |
+
<select
|
| 982 |
+
id={`${idPrefix}-rollup-link`}
|
| 983 |
+
className="cg-input"
|
| 984 |
+
value={rollupLink}
|
| 985 |
+
aria-label="Link column"
|
| 986 |
+
onChange={(event) => onRollupLink?.(event.target.value)}
|
| 987 |
+
>
|
| 988 |
+
<option value="">Choose a link columnβ¦</option>
|
| 989 |
+
{linkFields.map((f) => (
|
| 990 |
+
<option key={f.key} value={f.key}>{f.label}</option>
|
| 991 |
+
))}
|
| 992 |
+
</select>
|
| 993 |
+
</label>
|
| 994 |
+
{linkFields.length === 0 ? (
|
| 995 |
+
<div className="cg-field-hint">
|
| 996 |
+
This database has no link column yet. A rollup summarises records reached through a
|
| 997 |
+
link, so add one of those first.
|
| 998 |
+
</div>
|
| 999 |
+
) : null}
|
| 1000 |
+
<label>
|
| 1001 |
+
<span>Fold</span>
|
| 1002 |
+
<select
|
| 1003 |
+
id={`${idPrefix}-rollup-fn`}
|
| 1004 |
+
className="cg-input"
|
| 1005 |
+
value={rollupFn}
|
| 1006 |
+
aria-label="Rollup function"
|
| 1007 |
+
onChange={(event) => onRollupFn?.(event.target.value as RollupFn)}
|
| 1008 |
+
>
|
| 1009 |
+
{ROLLUP_FNS.map((fn) => (
|
| 1010 |
+
<option key={fn} value={fn}>{ROLLUP_FN_LABELS[fn]}</option>
|
| 1011 |
+
))}
|
| 1012 |
+
</select>
|
| 1013 |
+
</label>
|
| 1014 |
+
{needsField ? (
|
| 1015 |
+
<label>
|
| 1016 |
+
<span>Column</span>
|
| 1017 |
+
<select
|
| 1018 |
+
id={`${idPrefix}-rollup-field`}
|
| 1019 |
+
className="cg-input"
|
| 1020 |
+
value={rollupField}
|
| 1021 |
+
aria-label="Column to roll up"
|
| 1022 |
+
onChange={(event) => onRollupField?.(event.target.value)}
|
| 1023 |
+
>
|
| 1024 |
+
<option value="">Choose a columnβ¦</option>
|
| 1025 |
+
{targetFields.map((f) => (
|
| 1026 |
+
<option key={f.key} value={f.key}>{f.label}</option>
|
| 1027 |
+
))}
|
| 1028 |
+
</select>
|
| 1029 |
+
</label>
|
| 1030 |
+
) : null}
|
| 1031 |
+
<label>
|
| 1032 |
+
<span>Across</span>
|
| 1033 |
+
<select
|
| 1034 |
+
id={`${idPrefix}-rollup-sort`}
|
| 1035 |
+
className="cg-input"
|
| 1036 |
+
value={rollupSortBy}
|
| 1037 |
+
aria-label="Which records to include"
|
| 1038 |
+
onChange={(event) => onRollupSortBy?.(event.target.value)}
|
| 1039 |
+
>
|
| 1040 |
+
<option value="">Every linked record</option>
|
| 1041 |
+
{targetFields.map((f) => (
|
| 1042 |
+
<option key={f.key} value={f.key}>Most recent by {f.label}</option>
|
| 1043 |
+
))}
|
| 1044 |
+
</select>
|
| 1045 |
+
</label>
|
| 1046 |
+
{rollupSortBy ? (
|
| 1047 |
+
<label>
|
| 1048 |
+
<span>How many</span>
|
| 1049 |
+
<input
|
| 1050 |
+
type="number"
|
| 1051 |
+
className="cg-input"
|
| 1052 |
+
min={1}
|
| 1053 |
+
value={rollupLimit || 1}
|
| 1054 |
+
aria-label="How many records"
|
| 1055 |
+
onChange={(event) =>
|
| 1056 |
+
onRollupLimit?.(Math.max(1, Number(event.target.value) || 1))
|
| 1057 |
+
}
|
| 1058 |
+
/>
|
| 1059 |
+
</label>
|
| 1060 |
+
) : null}
|
| 1061 |
+
{/* β THE RULE STATED AT THE CONTROL, because the server refuses the pair and a refusal
|
| 1062 |
+
the user meets after pressing Create is a refusal they had no way to avoid. "The
|
| 1063 |
+
last N" with no declared order is not a measurement β it is whichever N rows happen
|
| 1064 |
+
to sit first in the store. */}
|
| 1065 |
+
<div className="cg-field-hint">
|
| 1066 |
+
{rollupSortBy
|
| 1067 |
+
? `The ${rollupLimit || 1} most recent linked records, newest first.`
|
| 1068 |
+
: "Every linked record. Choose an order above to summarise just the most recent few."}
|
| 1069 |
+
</div>
|
| 1070 |
+
<div className="cg-field-hint">
|
| 1071 |
+
Computed for you and refreshed as the linked records change β the cell cannot be typed
|
| 1072 |
+
into.
|
| 1073 |
+
</div>
|
| 1074 |
+
</>
|
| 1075 |
+
);
|
| 1076 |
+
}
|
| 1077 |
return null;
|
| 1078 |
}
|
| 1079 |
|
|
|
|
| 1081 |
state,
|
| 1082 |
field,
|
| 1083 |
fields,
|
| 1084 |
+
linkTargets = [],
|
| 1085 |
locked,
|
| 1086 |
viewer,
|
| 1087 |
sortedDir,
|
|
|
|
| 1143 |
const [automationUrlField, setAutomationUrlField] = useState(
|
| 1144 |
() => fields.find((f) => f.type === "url")?.key ?? ""
|
| 1145 |
);
|
| 1146 |
+
/**
|
| 1147 |
+
* β 2026-08-07 β the create form's LINK and ROLLUP configuration.
|
| 1148 |
+
*
|
| 1149 |
+
* β BOTH KINDS ARE UNCREATABLE WITHOUT THEIR BAG β `core.user_tables._clean_field` returns
|
| 1150 |
+
* None for a `link` with no `link` bag and for a `rollup` with no `rollup` bag β so `canCreate`
|
| 1151 |
+
* gates on these below rather than letting the server refuse a column the user just named.
|
| 1152 |
+
* That refusal would be silent in the worst way: created, named, configured, gone on reload.
|
| 1153 |
+
*/
|
| 1154 |
+
const [linkTable, setLinkTable] = useState("");
|
| 1155 |
+
const [linkSingle, setLinkSingle] = useState(false);
|
| 1156 |
+
const [rollupLink, setRollupLink] = useState("");
|
| 1157 |
+
const [rollupField, setRollupField] = useState("");
|
| 1158 |
+
const [rollupFn, setRollupFn] = useState<RollupFn>("sum");
|
| 1159 |
+
/** 0 = every linked record (Airtable's only behaviour). Non-zero needs a sort β see below. */
|
| 1160 |
+
const [rollupLimit, setRollupLimit] = useState(0);
|
| 1161 |
+
const [rollupSortBy, setRollupSortBy] = useState("");
|
| 1162 |
const [swapTo, setSwapTo] = useState("");
|
| 1163 |
/** The "New field" half of Change-field keeps its own name/options β a half-typed insert
|
| 1164 |
* form must not leak into a swap and vice versa. */
|
|
|
|
| 1283 |
// C5-AUTOFIELD: an automation column with no URL column to read is a column no run can
|
| 1284 |
// ever fill β the same "permanently blank column" the formula rule above refuses, so it
|
| 1285 |
// is refused here rather than created and then discovered.
|
| 1286 |
+
(kind !== "automation" || automationUrlField !== "") &&
|
| 1287 |
+
// β 2026-08-07 β both relational kinds are UNCREATABLE without their bag: `_clean_field`
|
| 1288 |
+
// returns None for a `link` with no target and a `rollup` with no link/function, so
|
| 1289 |
+
// creating one without this gate produces a column that is named, configured and simply
|
| 1290 |
+
// absent on the next read. The same "permanently blank column" argument as the two rules
|
| 1291 |
+
// above, one step worse β the column does not exist at all.
|
| 1292 |
+
(kind !== "link" || linkTable !== "") &&
|
| 1293 |
+
(kind !== "rollup" || (rollupLink !== "" && (rollupFn === "countall" || rollupField !== "")));
|
| 1294 |
|
| 1295 |
const extraFor = (
|
| 1296 |
t: CreateKind,
|
|
|
|
| 1307 |
urlField: automationUrlField,
|
| 1308 |
},
|
| 1309 |
};
|
| 1310 |
+
// β 2026-08-07 β the relational bags, shaped exactly as `_clean_link` / `_clean_rollup`
|
| 1311 |
+
// store them. β NO `on` KEY: a link created from this menu is an ORDINARY one (the user
|
| 1312 |
+
// picks records). The DERIVED mode is the automation's, spawned with its join declared β
|
| 1313 |
+
// offering "join on a column of the other table" here would be a second, harder mental
|
| 1314 |
+
// model for the same button.
|
| 1315 |
+
if (t === "link") return { link: { table: linkTable, ...(linkSingle ? { single: true } : {}) } };
|
| 1316 |
+
if (t === "rollup")
|
| 1317 |
+
return {
|
| 1318 |
+
rollup: {
|
| 1319 |
+
link: rollupLink,
|
| 1320 |
+
...(rollupFn === "countall" ? {} : { field: rollupField }),
|
| 1321 |
+
fn: rollupFn,
|
| 1322 |
+
// β `limit` AND `sortBy` TRAVEL TOGETHER OR NEITHER TRAVELS. The host refuses a limit
|
| 1323 |
+
// with no declared order, so sending one would turn a valid-looking form into a 400.
|
| 1324 |
+
...(rollupSortBy
|
| 1325 |
+
? { sortBy: rollupSortBy, sortDir: "desc" as const,
|
| 1326 |
+
...(rollupLimit ? { limit: rollupLimit } : {}) }
|
| 1327 |
+
: {}),
|
| 1328 |
+
},
|
| 1329 |
+
};
|
| 1330 |
return undefined;
|
| 1331 |
};
|
| 1332 |
const optionExtraFor = (
|
|
|
|
| 1665 |
onAutomationKind={setAutomationKind}
|
| 1666 |
automationUrlField={automationUrlField}
|
| 1667 |
onAutomationUrlField={setAutomationUrlField}
|
| 1668 |
+
linkTargets={linkTargets}
|
| 1669 |
+
linkTable={linkTable}
|
| 1670 |
+
onLinkTable={setLinkTable}
|
| 1671 |
+
linkSingle={linkSingle}
|
| 1672 |
+
onLinkSingle={setLinkSingle}
|
| 1673 |
+
rollupLink={rollupLink}
|
| 1674 |
+
onRollupLink={setRollupLink}
|
| 1675 |
+
rollupField={rollupField}
|
| 1676 |
+
onRollupField={setRollupField}
|
| 1677 |
+
rollupFn={rollupFn}
|
| 1678 |
+
onRollupFn={setRollupFn}
|
| 1679 |
+
rollupLimit={rollupLimit}
|
| 1680 |
+
onRollupLimit={setRollupLimit}
|
| 1681 |
+
rollupSortBy={rollupSortBy}
|
| 1682 |
+
onRollupSortBy={setRollupSortBy}
|
| 1683 |
/>
|
| 1684 |
{needsOptions(kind) && (
|
| 1685 |
<OptionsEditor
|
web/src/customer-grid/CustomerGrid.tsx
CHANGED
|
@@ -44,7 +44,9 @@ import { NAV_MINIMIZE_EVENT, ROWS_STALE_EVENT, TOAST_EVENT, VIEW_OPEN_EVENT,
|
|
| 44 |
WORKSPACE_STALE_EVENT, signal }
|
| 45 |
from "../apiContract";
|
| 46 |
import type { ViewOpenDetail } from "../apiContract";
|
| 47 |
-
import { addTableField, addTableRow, deleteTableRow,
|
|
|
|
|
|
|
| 48 |
import SelectFromFile from "./SelectFromFile";
|
| 49 |
// Owner item 16 / R4 / C-UNDO β the stack and every inverse. Pure, so a node gate can run it.
|
| 50 |
import { describe, directed, popRedo, popUndo, pushUndo, stackFor } from "./undoStack";
|
|
@@ -895,6 +897,29 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 895 |
* row.
|
| 896 |
*/
|
| 897 |
const isUserTable = scope.startsWith("ut_");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 898 |
const appendRow = useCallback(async (): Promise<undefined> => {
|
| 899 |
if (!isUserTable) return undefined;
|
| 900 |
const made = await addTableRow(scope);
|
|
@@ -4714,6 +4739,10 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 4714 |
state={columnMenu}
|
| 4715 |
field={menuField}
|
| 4716 |
fields={fields}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4717 |
locked={menuField.key === lockedKey}
|
| 4718 |
viewer={viewer}
|
| 4719 |
sortedDir={menuSortedDir}
|
|
|
|
| 44 |
WORKSPACE_STALE_EVENT, signal }
|
| 45 |
from "../apiContract";
|
| 46 |
import type { ViewOpenDetail } from "../apiContract";
|
| 47 |
+
import { addTableField, addTableRow, deleteTableRow, fetchLinkTargets,
|
| 48 |
+
patchTableField } from "./apiBridge";
|
| 49 |
+
import type { LinkTarget } from "./apiBridge";
|
| 50 |
import SelectFromFile from "./SelectFromFile";
|
| 51 |
// Owner item 16 / R4 / C-UNDO β the stack and every inverse. Pure, so a node gate can run it.
|
| 52 |
import { describe, directed, popRedo, popUndo, pushUndo, stackFor } from "./undoStack";
|
|
|
|
| 897 |
* row.
|
| 898 |
*/
|
| 899 |
const isUserTable = scope.startsWith("ut_");
|
| 900 |
+
/**
|
| 901 |
+
* β 2026-08-07 β the databases a `link` column may point at, fetched when the column menu
|
| 902 |
+
* OPENS rather than on every render of the grid.
|
| 903 |
+
*
|
| 904 |
+
* β ON DEMAND IS THE WHOLE DESIGN. `GET /tables` walks every table in the tenant and returns
|
| 905 |
+
* their full field lists; hanging that off the grid's mount would put a workspace-wide read
|
| 906 |
+
* behind every page view for a picker almost nobody opens. The column menu is the only surface
|
| 907 |
+
* that needs it, so it is the surface that asks.
|
| 908 |
+
* β The list is left standing once fetched β a database created in another tab mid-session is
|
| 909 |
+
* a staleness a menu re-open corrects, and re-fetching per open would spend the same read
|
| 910 |
+
* repeatedly for a list that changes about once a week.
|
| 911 |
+
*/
|
| 912 |
+
const [linkTargets, setLinkTargets] = useState<LinkTarget[]>([]);
|
| 913 |
+
useEffect(() => {
|
| 914 |
+
if (!columnMenu || linkTargets.length) return;
|
| 915 |
+
let live = true;
|
| 916 |
+
void fetchLinkTargets().then((t) => {
|
| 917 |
+
if (live) setLinkTargets(t);
|
| 918 |
+
});
|
| 919 |
+
return () => {
|
| 920 |
+
live = false;
|
| 921 |
+
};
|
| 922 |
+
}, [columnMenu, linkTargets.length]);
|
| 923 |
const appendRow = useCallback(async (): Promise<undefined> => {
|
| 924 |
if (!isUserTable) return undefined;
|
| 925 |
const made = await addTableRow(scope);
|
|
|
|
| 4739 |
state={columnMenu}
|
| 4740 |
field={menuField}
|
| 4741 |
fields={fields}
|
| 4742 |
+
// β 2026-08-07 β the link picker's options. Filtered to OTHER databases: a link from a
|
| 4743 |
+
// table to itself is a legal relation in Airtable and a confusing one to explain in a
|
| 4744 |
+
// one-line picker, so it is left out until somebody asks for it.
|
| 4745 |
+
linkTargets={linkTargets.filter((t) => t.key !== scope)}
|
| 4746 |
locked={menuField.key === lockedKey}
|
| 4747 |
viewer={viewer}
|
| 4748 |
sortedDir={menuSortedDir}
|
web/src/customer-grid/apiBridge.ts
CHANGED
|
@@ -366,6 +366,35 @@ export async function addTableRow(
|
|
| 366 |
* `_clean_field` enforces `type: 'text'` for a profile flag and refuses a SECOND one with a
|
| 367 |
* sentence naming the column that already has it, so the refusal is worth surfacing verbatim.
|
| 368 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 369 |
export async function patchTableField(
|
| 370 |
tableKey: string,
|
| 371 |
fieldKey: string,
|
|
|
|
| 366 |
* `_clean_field` enforces `type: 'text'` for a profile flag and refuses a SECOND one with a
|
| 367 |
* sentence naming the column that already has it, so the refusal is worth surfacing verbatim.
|
| 368 |
*/
|
| 369 |
+
/**
|
| 370 |
+
* β 2026-08-07 β the sibling databases a `link` column may point at, WITH their fields.
|
| 371 |
+
*
|
| 372 |
+
* `GET /tables` already returns exactly this (key, label, fields) filtered by `may_open`, so
|
| 373 |
+
* there is no new route and no new wall: a database you cannot open is a database you cannot
|
| 374 |
+
* link to, decided by the same predicate that decides whether you can see it at all.
|
| 375 |
+
*
|
| 376 |
+
* β Returns `[]` on any failure rather than throwing. The link editor renders "no other
|
| 377 |
+
* databases yet" for an empty list, which is the truthful reading of both an empty workspace
|
| 378 |
+
* and an unreachable server β and a create pane that explodes because a picker could not fetch
|
| 379 |
+
* is worse than one that says it has nothing to offer.
|
| 380 |
+
*/
|
| 381 |
+
export async function fetchLinkTargets(): Promise<LinkTarget[]> {
|
| 382 |
+
try {
|
| 383 |
+
const res = await fetch(`${API_V1}/tables`, { credentials: CREDENTIALS });
|
| 384 |
+
if (handledUnauthorized(res.status) || !res.ok) return [];
|
| 385 |
+
const body = (await readJson(res)) as { tables?: LinkTarget[] } | null;
|
| 386 |
+
return Array.isArray(body?.tables) ? body.tables : [];
|
| 387 |
+
} catch {
|
| 388 |
+
return [];
|
| 389 |
+
}
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
export interface LinkTarget {
|
| 393 |
+
key: string;
|
| 394 |
+
label: string;
|
| 395 |
+
fields: Field[];
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
export async function patchTableField(
|
| 399 |
tableKey: string,
|
| 400 |
fieldKey: string,
|
web/src/customer-grid/cells.ts
CHANGED
|
@@ -615,6 +615,46 @@ function baseCell(
|
|
| 615 |
themeOverride: AUTOMATION_TINT[automationState(text)],
|
| 616 |
};
|
| 617 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 618 |
case "status":
|
| 619 |
return {
|
| 620 |
kind: GridCellKind.Bubble,
|
|
|
|
| 615 |
themeOverride: AUTOMATION_TINT[automationState(text)],
|
| 616 |
};
|
| 617 |
}
|
| 618 |
+
case "link": {
|
| 619 |
+
// β 2026-08-07 β a relation, painted as ONE bubble saying how many rows it reaches.
|
| 620 |
+
//
|
| 621 |
+
// β NOT one bubble per linked row, and that is a measured decision rather than a
|
| 622 |
+
// simplification: the cell holds row IDS, and a column of `1,2,3` pills tells a reader
|
| 623 |
+
// nothing β the ids are not names. Airtable can paint the linked record's PRIMARY value
|
| 624 |
+
// because it has that row loaded; this client has not loaded the other table at all. So
|
| 625 |
+
// the honest cell is the COUNT, and the record drawer is where the rows themselves belong.
|
| 626 |
+
//
|
| 627 |
+
// β `copyData` carries the RAW id list, never the "12 posts" sentence β the W26 date-cell
|
| 628 |
+
// lesson, where a glide Text cell copies `copyData ?? displayData` and the FORMATTED
|
| 629 |
+
// string silently reached the clipboard and then the paste path. A count is not data and
|
| 630 |
+
// cannot be pasted back into a relation.
|
| 631 |
+
const ids = String(v ?? "").split(",").map((s) => s.trim()).filter((s) => s !== "");
|
| 632 |
+
return {
|
| 633 |
+
kind: GridCellKind.Bubble,
|
| 634 |
+
data: ids.length ? [ids.length === 1 ? "1 record" : `${ids.length} records`] : [],
|
| 635 |
+
copyData: String(v ?? ""),
|
| 636 |
+
allowOverlay: false,
|
| 637 |
+
};
|
| 638 |
+
}
|
| 639 |
+
case "rollup": {
|
| 640 |
+
// β 2026-08-07 β an aggregate the HOST computed. Read-only by nature, exactly like
|
| 641 |
+
// `formula`: the value is arithmetic, and a value box over arithmetic is an editor that
|
| 642 |
+
// can only produce a number the next refresh throws away.
|
| 643 |
+
//
|
| 644 |
+
// β BLANK STAYS BLANK. `_rollup_fold` returns "" for "no rows to aggregate" and only the
|
| 645 |
+
// count family ever returns a real 0 β so painting `0` here for an empty cell would invent
|
| 646 |
+
// the measurement the server just refused to invent. `num(v)` would do exactly that
|
| 647 |
+
// (`num("")` is 0), which is why the raw string is rendered rather than a parsed number.
|
| 648 |
+
const text = String(v ?? "");
|
| 649 |
+
return {
|
| 650 |
+
kind: GridCellKind.Text,
|
| 651 |
+
data: text,
|
| 652 |
+
displayData: text,
|
| 653 |
+
copyData: text,
|
| 654 |
+
allowOverlay: false,
|
| 655 |
+
readonly: true,
|
| 656 |
+
};
|
| 657 |
+
}
|
| 658 |
case "status":
|
| 659 |
return {
|
| 660 |
kind: GridCellKind.Bubble,
|
web/src/customer-grid/clipboard.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import { choiceOptions, isMachineWritten, ratingMax } from "./types";
|
| 2 |
import type { Field } from "./types";
|
| 3 |
|
| 4 |
function choiceMatch(raw: string, allowed: string[]): string | undefined {
|
|
@@ -32,12 +32,21 @@ export function coerceClipboardValue(
|
|
| 32 |
// multi-cell paste would paint optimistically across them and then bounce, which reads to the
|
| 33 |
// person doing it as the app losing their data rather than as a wall.
|
| 34 |
if (isMachineWritten(field)) return undefined;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
const value = raw.replace(/\r/g, "");
|
| 36 |
const trimmed = value.trim();
|
| 37 |
switch (field.type) {
|
| 38 |
case "formula":
|
| 39 |
case "created_time":
|
| 40 |
case "status":
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
// C5-AUTOFIELD (wave 18) β an automation cell is what the last RUN wrote, so a paste into
|
| 42 |
// one is refused HERE and not only by the renderer. `READONLY_CELL_TYPES` decides what
|
| 43 |
// gets an editor; a paste never opens one, so a type that is read-only by nature and
|
|
|
|
| 1 |
+
import { choiceOptions, isDerivedLink, isMachineWritten, ratingMax } from "./types";
|
| 2 |
import type { Field } from "./types";
|
| 3 |
|
| 4 |
function choiceMatch(raw: string, allowed: string[]): string | undefined {
|
|
|
|
| 32 |
// multi-cell paste would paint optimistically across them and then bounce, which reads to the
|
| 33 |
// person doing it as the app losing their data rather than as a wall.
|
| 34 |
if (isMachineWritten(field)) return undefined;
|
| 35 |
+
// β 2026-08-07 β the DERIVED half of `link`, refused for the same reason and by the same
|
| 36 |
+
// shape: it is read-only per FIELD, not per type, so the switch below structurally cannot see
|
| 37 |
+
// it. The server rewrites the cell on the next refresh pass, so a pasted value would paint,
|
| 38 |
+
// survive a moment, and vanish β the failure this whole function exists to prevent.
|
| 39 |
+
if (isDerivedLink(field)) return undefined;
|
| 40 |
const value = raw.replace(/\r/g, "");
|
| 41 |
const trimmed = value.trim();
|
| 42 |
switch (field.type) {
|
| 43 |
case "formula":
|
| 44 |
case "created_time":
|
| 45 |
case "status":
|
| 46 |
+
// β 2026-08-07 β a ROLLUP cell is an aggregate the host computed. Same argument as
|
| 47 |
+
// `automation` below: a paste would be overwritten by the next refresh with nothing on any
|
| 48 |
+
// surface saying so.
|
| 49 |
+
case "rollup":
|
| 50 |
// C5-AUTOFIELD (wave 18) β an automation cell is what the last RUN wrote, so a paste into
|
| 51 |
// one is refused HERE and not only by the renderer. `READONLY_CELL_TYPES` decides what
|
| 52 |
// gets an editor; a paste never opens one, so a type that is read-only by nature and
|
web/src/customer-grid/iconShapes.ts
CHANGED
|
@@ -130,6 +130,24 @@ export const TYPE_SHAPES: Record<FieldType, IconShape[]> = {
|
|
| 130 |
{ d: circle(6, 6.3, 1.1) },
|
| 131 |
{ d: "M2.6 10.6L6.1 7.6l2.5 2.1 2.2-1.8 2.6 2.2" },
|
| 132 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
};
|
| 134 |
|
| 135 |
/**
|
|
@@ -453,6 +471,11 @@ export const TYPE_LABELS: Record<FieldType, string> = {
|
|
| 453 |
// the word on the wire, in the viewer's raw tab and in every error the server can return, and
|
| 454 |
// a friendlier synonym would be the only place in the product using a different one.
|
| 455 |
json: "JSON",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 456 |
status: "Lifecycle status (Odoo)", // never creatable; present so the map stays total
|
| 457 |
};
|
| 458 |
|
|
|
|
| 130 |
{ d: circle(6, 6.3, 1.1) },
|
| 131 |
{ d: "M2.6 10.6L6.1 7.6l2.5 2.1 2.2-1.8 2.6 2.2" },
|
| 132 |
],
|
| 133 |
+
// β 2026-08-07 β TWO INTERLOCKING CHAIN LINKS, the one glyph everybody already reads as
|
| 134 |
+
// "this points at something else". Drawn as two rounded rectangles overlapping at the centre
|
| 135 |
+
// rather than as an arrow into a box: an arrow would mean navigation, and a link column is a
|
| 136 |
+
// relation that exists in both directions whether or not you follow it.
|
| 137 |
+
link: [
|
| 138 |
+
{ d: "M6.6 5.2H4.9a2.8 2.8 0 000 5.6h1.7" },
|
| 139 |
+
{ d: "M9.4 5.2h1.7a2.8 2.8 0 010 5.6H9.4" },
|
| 140 |
+
{ d: "M5.6 8h4.8" },
|
| 141 |
+
],
|
| 142 |
+
// β 2026-08-07 β THREE BARS FOLDING INTO ONE, read top-to-bottom: many linked values
|
| 143 |
+
// collapsing to a single aggregate. Deliberately not a sigma (too fine at 16px, and it would
|
| 144 |
+
// claim SUM when the function is chosen per column) and not a funnel (that is filtering,
|
| 145 |
+
// which is what `limit` does β a different half of the same field).
|
| 146 |
+
rollup: [
|
| 147 |
+
{ d: "M3.2 4.4h9.6" },
|
| 148 |
+
{ d: "M4.8 8h6.4" },
|
| 149 |
+
{ d: "M6.6 11.6h2.8" },
|
| 150 |
+
],
|
| 151 |
};
|
| 152 |
|
| 153 |
/**
|
|
|
|
| 471 |
// the word on the wire, in the viewer's raw tab and in every error the server can return, and
|
| 472 |
// a friendlier synonym would be the only place in the product using a different one.
|
| 473 |
json: "JSON",
|
| 474 |
+
// β 2026-08-07 β Airtable's own wording, deliberately. "Link to another record" is what a
|
| 475 |
+
// person migrating from Airtable searches this menu for, and inventing a synonym ("Relation",
|
| 476 |
+
// "Reference") would make the feature they came for look absent.
|
| 477 |
+
link: "Link to another record",
|
| 478 |
+
rollup: "Rollup",
|
| 479 |
status: "Lifecycle status (Odoo)", // never creatable; present so the map stays total
|
| 480 |
};
|
| 481 |
|
web/src/customer-grid/types.ts
CHANGED
|
@@ -52,6 +52,16 @@ export type FieldType =
|
|
| 52 |
// It is NOT in `READONLY_CELL_TYPES`: the value is editable, just never through a 200px cell
|
| 53 |
// β the same "picked, not typed" reasoning `select` and `image` carry.
|
| 54 |
| "json"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
// β Wave-19 R7 / C5 β `image` is a PICTURE on a record. The cell holds a STRING REFERENCE,
|
| 56 |
// never bytes (see `imageRef`): a SKU code, an `ed:` editorial slug, or a `rec:` upload. That
|
| 57 |
// is what lets Royal's 1,142 existing SKU masters appear with nothing uploaded, and it keeps
|
|
@@ -84,6 +94,20 @@ export const CREATABLE_TYPES: readonly FieldType[] = [
|
|
| 84 |
// `verify_fields_contract` caught it by diffing the two lists; nothing else could have, because
|
| 85 |
// every individual file was internally consistent.
|
| 86 |
"json",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
];
|
| 88 |
|
| 89 |
/**
|
|
@@ -118,7 +142,13 @@ export function imageRefKind(value: string): ImageRefKind {
|
|
| 118 |
* about the row. Distinct from permissions β these are read-only by NATURE, not by policy.
|
| 119 |
*/
|
| 120 |
export const READONLY_CELL_TYPES: ReadonlySet<FieldType> = new Set<FieldType>([
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
]);
|
| 123 |
|
| 124 |
/** Types whose value is chosen from a fixed list rather than typed. */
|
|
@@ -1020,6 +1050,11 @@ export interface Viewer {
|
|
| 1020 |
*/
|
| 1021 |
export function mayEditField(field: Field, viewer: Viewer | undefined): boolean {
|
| 1022 |
if (field.source !== "overlay" || READONLY_CELL_TYPES.has(field.type)) return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1023 |
// β OWNER ITEM 4 (2026-08-06) β a column an automation FILLS is not a column a person types
|
| 1024 |
// in. `editRole: 'admins'` already rode on every preset column and did nothing about this: it
|
| 1025 |
// governs the SCHEMA (`user_tables.py:535`), i.e. who may rename or retype the column, while
|
|
@@ -1116,8 +1151,16 @@ export function isMachineWritten(field: Field): boolean {
|
|
| 1116 |
* by the lock-step gate rather than by an import.
|
| 1117 |
*/
|
| 1118 |
export function isNumericFieldType(t: FieldType): boolean {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1119 |
return t === "currency" || t === "int" || t === "pct" || t === "rating" || t === "formula"
|
| 1120 |
-
|| t === "metric";
|
| 1121 |
}
|
| 1122 |
|
| 1123 |
export function isDateFamilyType(t: FieldType): boolean {
|
|
@@ -1374,6 +1417,85 @@ export interface Field {
|
|
| 1374 |
* `isMachineOwned` β a person types here, so it must NOT take the machine wash.
|
| 1375 |
*/
|
| 1376 |
profile?: { source?: string };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1377 |
}
|
| 1378 |
|
| 1379 |
/**
|
|
|
|
| 52 |
// It is NOT in `READONLY_CELL_TYPES`: the value is editable, just never through a 200px cell
|
| 53 |
// β the same "picked, not typed" reasoning `select` and `image` carry.
|
| 54 |
| "json"
|
| 55 |
+
// β 2026-08-07 (owner instruction: *"adding relational database function with links and
|
| 56 |
+
// rollupsβ¦ exactly like how Airtable does it"*) β THE RELATIONAL PAIR.
|
| 57 |
+
// `link` points at rows of another `ut_*` database. The cell holds a COMMA-JOINED list of
|
| 58 |
+
// linked row ids (a scalar β Airtable's array cell cannot exist here, and the host
|
| 59 |
+
// refuses a non-scalar write). A link is DERIVED when its bag carries `on` (the
|
| 60 |
+
// server maintains it from a join) and ORDINARY otherwise (the user picks records).
|
| 61 |
+
// `rollup` aggregates a column of the rows a link resolves. Computed HOST-side and
|
| 62 |
+
// materialised into the cell β `formula`'s client-side path cannot reach it,
|
| 63 |
+
// because a rollup reads ANOTHER TABLE'S rows, which this client has not loaded.
|
| 64 |
+
| "link" | "rollup"
|
| 65 |
// β Wave-19 R7 / C5 β `image` is a PICTURE on a record. The cell holds a STRING REFERENCE,
|
| 66 |
// never bytes (see `imageRef`): a SKU code, an `ed:` editorial slug, or a `rec:` upload. That
|
| 67 |
// is what lets Royal's 1,142 existing SKU masters appear with nothing uploaded, and it keeps
|
|
|
|
| 94 |
// `verify_fields_contract` caught it by diffing the two lists; nothing else could have, because
|
| 95 |
// every individual file was internally consistent.
|
| 96 |
"json",
|
| 97 |
+
// β 2026-08-07 β the relational pair, landing in the SAME change that adds them to
|
| 98 |
+
// `FieldType`, `UT_FIELD_TYPES`, `CUSTOM_FIELD_TYPES` and the ColumnMenu editor, because
|
| 99 |
+
// `json` proved what happens otherwise: it reached four of the five surfaces and shipped
|
| 100 |
+
// real, documented and unreachable.
|
| 101 |
+
//
|
| 102 |
+
// β BOTH REQUIRE THEIR CONFIG BAG β `_clean_field` returns None for a `link` with no `link`
|
| 103 |
+
// bag and a `rollup` with no `rollup` bag β so `ColumnMenu.canCreate` gates on it. Listing a
|
| 104 |
+
// type here whose create call the server would refuse is the "created, named, configured,
|
| 105 |
+
// gone" failure arriving through the create button instead of through the store.
|
| 106 |
+
// β On the Odoo-backed Customer/Product grids the menu still offers them and the target
|
| 107 |
+
// picker is EMPTY, saying so in a sentence: there is no second user table to point at there.
|
| 108 |
+
// That is the honest state rather than a hidden entry β a menu whose contents change based on
|
| 109 |
+
// which page you are on is a menu people stop trusting.
|
| 110 |
+
"link", "rollup",
|
| 111 |
];
|
| 112 |
|
| 113 |
/**
|
|
|
|
| 142 |
* about the row. Distinct from permissions β these are read-only by NATURE, not by policy.
|
| 143 |
*/
|
| 144 |
export const READONLY_CELL_TYPES: ReadonlySet<FieldType> = new Set<FieldType>([
|
| 145 |
+
// β 2026-08-07 β `rollup` joins by NATURE: its value is an aggregate the host computes, so
|
| 146 |
+
// typing into it would be editing arithmetic through a value box, exactly like `formula`.
|
| 147 |
+
// β `link` is deliberately ABSENT and that asymmetry is the point: an ORDINARY link is a
|
| 148 |
+
// relation a person builds by picking records. Only a DERIVED link is read-only, which is a
|
| 149 |
+
// question about ONE FIELD's bag and not about its type β `mayEditField` asks
|
| 150 |
+
// `isDerivedLink` for exactly that reason. A type set cannot express "read-only in one mode".
|
| 151 |
+
"formula", "created_time", "automation", "metric", "rollup",
|
| 152 |
]);
|
| 153 |
|
| 154 |
/** Types whose value is chosen from a fixed list rather than typed. */
|
|
|
|
| 1050 |
*/
|
| 1051 |
export function mayEditField(field: Field, viewer: Viewer | undefined): boolean {
|
| 1052 |
if (field.source !== "overlay" || READONLY_CELL_TYPES.has(field.type)) return false;
|
| 1053 |
+
// β 2026-08-07 β the DERIVED half of `link`. Read per-field rather than by type, because the
|
| 1054 |
+
// other half of the same type is a relation a person builds by hand. The host wall is
|
| 1055 |
+
// `core.user_tables.is_computed_cell`, read by `grid_events`; this is the courtesy in front
|
| 1056 |
+
// of it, and the two are held in step by name rather than by a copied condition.
|
| 1057 |
+
if (isDerivedLink(field)) return false;
|
| 1058 |
// β OWNER ITEM 4 (2026-08-06) β a column an automation FILLS is not a column a person types
|
| 1059 |
// in. `editRole: 'admins'` already rode on every preset column and did nothing about this: it
|
| 1060 |
// governs the SCHEMA (`user_tables.py:535`), i.e. who may rename or retype the column, while
|
|
|
|
| 1151 |
* by the lock-step gate rather than by an import.
|
| 1152 |
*/
|
| 1153 |
export function isNumericFieldType(t: FieldType): boolean {
|
| 1154 |
+
// β 2026-08-07 β `rollup` joins for `metric`'s reason: its cell holds a computed NUMBER, and a
|
| 1155 |
+
// column of "average views over the last 12 posts" that cannot be filtered `> 10000`, sorted
|
| 1156 |
+
// 9β1 or charted is most of the feature missing.
|
| 1157 |
+
// β THE KNOWN IMPRECISION, stated rather than hidden: the text fns (`arrayjoin`,
|
| 1158 |
+
// `concatenate`, β¦) produce a rollup that is not a number, and this predicate takes a TYPE and
|
| 1159 |
+
// cannot see the bag. `formula` has carried exactly this imprecision since wave 5 β it can
|
| 1160 |
+
// return a string too β so the behaviour is the established one rather than a new hazard, and
|
| 1161 |
+
// the failure is benign in both: a text value simply does not satisfy a numeric comparison.
|
| 1162 |
return t === "currency" || t === "int" || t === "pct" || t === "rating" || t === "formula"
|
| 1163 |
+
|| t === "metric" || t === "rollup";
|
| 1164 |
}
|
| 1165 |
|
| 1166 |
export function isDateFamilyType(t: FieldType): boolean {
|
|
|
|
| 1417 |
* `isMachineOwned` β a person types here, so it must NOT take the machine wash.
|
| 1418 |
*/
|
| 1419 |
profile?: { source?: string };
|
| 1420 |
+
/**
|
| 1421 |
+
* β 2026-08-07 β a LINK to rows of another user database (Airtable's `multipleRecordLinks`).
|
| 1422 |
+
* The cell holds a COMMA-JOINED list of linked row ids, because a `Row` value is a scalar
|
| 1423 |
+
* everywhere in this product and the host refuses a non-scalar write.
|
| 1424 |
+
*
|
| 1425 |
+
* `on` is the mode discriminator, and the two modes behave differently at every surface:
|
| 1426 |
+
* `on` PRESENT β a DERIVED link. Linked rows are those whose `on` column equals this row's
|
| 1427 |
+
* `from` column; the SERVER maintains the cell and a human write is refused.
|
| 1428 |
+
* `on` ABSENT β an ORDINARY link. The user picks records and the cell is editable.
|
| 1429 |
+
*/
|
| 1430 |
+
link?: {
|
| 1431 |
+
/** the `ut_*` key of the database this points at */
|
| 1432 |
+
table: string;
|
| 1433 |
+
/** the column IN THE LINKED TABLE that holds this row's key β presence = derived */
|
| 1434 |
+
on?: string;
|
| 1435 |
+
/** the column on THIS table supplying the join value; defaults to the profile/pinned one */
|
| 1436 |
+
from?: string;
|
| 1437 |
+
/** Airtable's `prefersSingleRecordLink` */
|
| 1438 |
+
single?: boolean;
|
| 1439 |
+
};
|
| 1440 |
+
/**
|
| 1441 |
+
* β 2026-08-07 β an AGGREGATE over the rows a `link` column resolves (Airtable's `rollup`).
|
| 1442 |
+
* Computed HOST-side and materialised into the cell, unlike `formula`, because it reads
|
| 1443 |
+
* another table's rows.
|
| 1444 |
+
*
|
| 1445 |
+
* `limit` + `sortBy` are the deliberate SUPERSET of Airtable β its rollup conditions filter by
|
| 1446 |
+
* predicate and never by rank, so "average views over the LAST 12 posts" is not expressible
|
| 1447 |
+
* there. The host refuses a `limit` without a `sortBy`: "the last N" with no declared order is
|
| 1448 |
+
* not a measurement.
|
| 1449 |
+
*/
|
| 1450 |
+
rollup?: {
|
| 1451 |
+
/** the key of the `link` column on this table */
|
| 1452 |
+
link: string;
|
| 1453 |
+
/** the column in the linked table to aggregate; absent only for `countall` */
|
| 1454 |
+
field?: string;
|
| 1455 |
+
fn: RollupFn;
|
| 1456 |
+
limit?: number;
|
| 1457 |
+
sortBy?: string;
|
| 1458 |
+
sortDir?: "asc" | "desc";
|
| 1459 |
+
};
|
| 1460 |
+
}
|
| 1461 |
+
|
| 1462 |
+
/**
|
| 1463 |
+
* Airtable's 17 rollup functions, minus the two that are meaningless over a scalar cell.
|
| 1464 |
+
*
|
| 1465 |
+
* β `arrayflatten` and `arrayslice` are deliberately ABSENT: both fold NESTED arrays, and a cell
|
| 1466 |
+
* here is a scalar, so either could only ever return its own input. `arrayslice`'s real use β
|
| 1467 |
+
* "just the first N" β is what `limit` does, by a declared rank instead of by position.
|
| 1468 |
+
* β MIRRORED from `core.user_tables.ROLLUP_FNS` and held in step by `verify_fields_contract`,
|
| 1469 |
+
* the same discipline every other cross-language vocabulary here uses.
|
| 1470 |
+
*/
|
| 1471 |
+
export const ROLLUP_FNS = [
|
| 1472 |
+
"sum", "average", "min", "max", "count", "counta", "countall",
|
| 1473 |
+
"and", "or", "xor", "concatenate", "arrayjoin", "arraycompact", "arrayunique",
|
| 1474 |
+
] as const;
|
| 1475 |
+
export type RollupFn = (typeof ROLLUP_FNS)[number];
|
| 1476 |
+
|
| 1477 |
+
/** The rollup functions whose RESULT is a number β the render/align/sort family. */
|
| 1478 |
+
export const ROLLUP_NUMERIC_FNS: ReadonlySet<string> =
|
| 1479 |
+
new Set(["sum", "average", "min", "max", "count", "counta", "countall"]);
|
| 1480 |
+
|
| 1481 |
+
/** Human wording for each function, so a column menu never shows a bare identifier. */
|
| 1482 |
+
export const ROLLUP_FN_LABELS: Record<RollupFn, string> = {
|
| 1483 |
+
sum: "Sum", average: "Average", min: "Minimum", max: "Maximum",
|
| 1484 |
+
count: "Count of numbers", counta: "Count of filled cells", countall: "Count of records",
|
| 1485 |
+
and: "All are true", or: "Any is true", xor: "Exactly one is true",
|
| 1486 |
+
concatenate: "Join (no separator)", arrayjoin: "Join with commas",
|
| 1487 |
+
arraycompact: "Join, skipping blanks", arrayunique: "Join, unique values",
|
| 1488 |
+
};
|
| 1489 |
+
|
| 1490 |
+
/**
|
| 1491 |
+
* Is this a link whose cell the SERVER owns? Mirrors `core.user_tables.is_derived_link`.
|
| 1492 |
+
*
|
| 1493 |
+
* β ONE reading of the bag, used by the editability check and the renderer both. A derived link
|
| 1494 |
+
* is rewritten on every refresh pass, so accepting a typed value would not merely be wrong β it
|
| 1495 |
+
* would appear to work and then silently revert, which is worse than refusing it.
|
| 1496 |
+
*/
|
| 1497 |
+
export function isDerivedLink(field: Field): boolean {
|
| 1498 |
+
return field.type === "link" && !!field.link?.on;
|
| 1499 |
}
|
| 1500 |
|
| 1501 |
/**
|
web/src/settings/permsModel.ts
CHANGED
|
@@ -156,6 +156,11 @@ const FIELD_TYPE_TABLE: Record<FieldType, true> = {
|
|
| 156 |
// exception the freeze cannot cover: the alarm four lines up is a COMPILE error, so the union
|
| 157 |
// and this listing cannot land in two different changes. Posted in D's mailbox for C.)
|
| 158 |
json: true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
};
|
| 160 |
|
| 161 |
export const KNOWN_FIELD_TYPES: ReadonlySet<string> = new Set(Object.keys(FIELD_TYPE_TABLE));
|
|
|
|
| 156 |
// exception the freeze cannot cover: the alarm four lines up is a COMPILE error, so the union
|
| 157 |
// and this listing cannot land in two different changes. Posted in D's mailbox for C.)
|
| 158 |
json: true,
|
| 159 |
+
// 2026-08-07 β the relational pair, listed for the reason the alarm above states and for no
|
| 160 |
+
// other: the exhaustiveness check is a COMPILE error, so the union and this listing cannot
|
| 161 |
+
// land in two separate changes. Nothing about the permissions wall treats either kind
|
| 162 |
+
// specially β a link/rollup column is granted and hidden like any other column.
|
| 163 |
+
link: true, rollup: true,
|
| 164 |
};
|
| 165 |
|
| 166 |
export const KNOWN_FIELD_TYPES: ReadonlySet<string> = new Set(Object.keys(FIELD_TYPE_TABLE));
|
web/src/viz/seriesData.ts
CHANGED
|
@@ -45,6 +45,10 @@ export const VIZ_FIELD_TYPES: ReadonlySet<string> = new Set([
|
|
| 45 |
// a json column as `text`. Same reasoning as `image` β the type is categorical either way,
|
| 46 |
// and what listing it buys is that the surface stops mis-naming the column.
|
| 47 |
"json",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
]);
|
| 49 |
|
| 50 |
/**
|
|
|
|
| 45 |
// a json column as `text`. Same reasoning as `image` β the type is categorical either way,
|
| 46 |
// and what listing it buys is that the surface stops mis-naming the column.
|
| 47 |
"json",
|
| 48 |
+
// 2026-08-07 β the relational pair. THE BATCH LINE again: a `Set` is not a `Record`, so
|
| 49 |
+
// without this `asFields` would report a rollup column as `text` and the chart builder would
|
| 50 |
+
// refuse to plot the one column the feature exists to produce.
|
| 51 |
+
"link", "rollup",
|
| 52 |
]);
|
| 53 |
|
| 54 |
/**
|
web/src/viz/types.ts
CHANGED
|
@@ -55,7 +55,15 @@ export type FieldType =
|
|
| 55 |
// own fields to DashboardView at all β which is the alarm two rules below going off. KEEP
|
| 56 |
// THIS COMMENT FREE OF THE STATEMENT-TERMINATOR CHARACTER, exactly as the metric note above
|
| 57 |
// says: verify_ui parses this union up to the first one it meets
|
| 58 |
-
| "json"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
export type FieldSource = "odoo" | "overlay";
|
| 61 |
|
|
|
|
| 55 |
// own fields to DashboardView at all β which is the alarm two rules below going off. KEEP
|
| 56 |
// THIS COMMENT FREE OF THE STATEMENT-TERMINATOR CHARACTER, exactly as the metric note above
|
| 57 |
// says: verify_ui parses this union up to the first one it meets
|
| 58 |
+
| "json"
|
| 59 |
+
// 2026-08-07 β the relational pair, and they land on OPPOSITE sides of the numeric line.
|
| 60 |
+
// A `rollup` IS numeric for charting purposes (`isNumericFieldType` names it), so an
|
| 61 |
+
// "average views over the last 12 posts" column plots like any other measure. A `link` is a
|
| 62 |
+
// list of row ids, so it stays categorical and the shared formatter prints the stored
|
| 63 |
+
// string β the vocabulary has to know both words regardless, or the grid cannot hand its own
|
| 64 |
+
// fields to DashboardView at all, which is the alarm two rules below going off. KEEP THIS
|
| 65 |
+
// COMMENT FREE OF THE STATEMENT-TERMINATOR CHARACTER, as the two notes above say
|
| 66 |
+
| "link" | "rollup";
|
| 67 |
|
| 68 |
export type FieldSource = "odoo" | "overlay";
|
| 69 |
|