Save a view field and its scope view in one metadata migration

Closed
FE
2d ago
+2631-827

Server half of saving a column from the Edit column panel. Today the front saves a column and its scope as a chain of mutations (view field, scope view, filter groups, filters, sorts), each its own workspace migration: about 4.6 s of requests for a new scoped column. This PR adds one mutation that does it in a single migration (~0.4–0.5 s for the same payload, API only). The front switches to it in #30349.

Changes

  • upsertViewFieldWithScope (metadata schema, ViewFieldResolver): takes the view field (id, viewId, fieldMetadataId, optional isVisible, isCanonical, size, position, aggregateOperation, settings) and scope: { viewFilters, viewFilterGroups, viewSorts } | null. Creates the view field if missing, otherwise updates only the sent properties. An omitted scope keeps the current one; a null or empty scope removes the scope view; otherwise the scope view is created as TABLE_WIDGET on the relation's target object, or kept and its children diffed by id (the client's ids are kept). Returns { viewField, scopeView }.
  • One migration: every operation goes through a single validateBuildAndRunWorkspaceMigration, so the scope validators from #30341 check the final state.
  • Shared diff: the filter / filter group / sort diff moves out of ViewWidgetUpsertService into buildViewFiltersAndSortsUpsertFlatOperations, used by both. On update, an omitted value keeps the stored one and null clears it; a filter group is only rewritten when a value actually changes, and a filter keeps its group when an update omits it. A sort's subFieldName is now accepted and kept.
  • Behaviour change on upsertViewWidget: an explicit null for parentViewFilterGroupId, positionInViewFilterGroup, viewFilterGroupId or subFieldName used to keep the saved value and now clears it, and sorts now accept subFieldName. The in-repo front sends undefined for unchanged values, so the app is unaffected; an API or SDK client that sent null meaning "unchanged" would now clear the value. This matches what null means everywhere else in the metadata API.
  • One visibility rule: a scope view inherits its owner column's view visibility and creator through inheritScopeViewOwnerVisibility, used by ViewService.createOne and the new mutation.
  • Permissions: the view field and view-child guards already used by the chain (same declaration as updateViewField in the endpoint permission snapshot); a request whose viewId differs from the existing view field's view is rejected.
  • Lookup columns: the input also takes relationTargetFieldMetadataId (#30472), so the Edit column panel saves a lookup column with its scope in one request.
  • Client SDK and front metadata schema regenerated.

Stack

This PR targets felix/relaxed-einstein-vxil3q-base-scope-save, an integration branch merging #30339, #30341 and #30472, so the diff shows only this PR.

The work is split into short tracks that can be reviewed and merged in parallel. Each PR targets main or the one PR it builds on. Two PRs need several others; they target an integration branch (felix/relaxed-einstein-vxil3q-base-*, not a PR) that merges exactly their dependencies, so their diff shows only their own changes. A PR can merge once everything in its "Builds on" column is merged; retarget it to main at that point.

Size counts changed lines outside tests and generated files: S < 300, M 300–800, L > 800. Sizes are a snapshot and are not kept in sync with every push.

TrackPRWhat it doesSizeCodeTests / generatedBuilds on
Server: views#30339Per-column settings on view fields (label, record limit)S+300 −2+703 −152main
Server: views#30341A view can be owned by a one-to-many view field (scope view)M+584 −56+891 −4main
Server: views#30472Lookup: a view field shows one field of its related recordM+280 −38+428 −4#30339
Server: views#30466 👈upsertViewFieldWithScope: save a column with its settings, lookup and scope in one migration (~600 lines moved out of view-widget-upsert)L+1330 −567+1117 −256#30339, #30341, #30472
Server: views#30450Expose column scopes and lookups in the view AI toolsS+31+222#30339, #30341, #30472
Server: query engine#30347Honor filter / orderBy / first on nested one-to-many relationsM+462 −86+509main
Server: query engine#30473One relation-selection tree through the common query layer (refactor, no behavior change)L+663 −685+277 −46#30347
Server: query engine#30465Each alias of a nested relation gets its own arguments and rowsL+595 −237+727 −21#30473
Front#30468Query a relation under an alias with its own filter, sort and limitS+140 −19—main
Front#30469Don't recreate a saved sort that comes back under a new idS+21 −17+8main
Front#30348Extra table columns and the Edit column panel, behind IS_COLUMN_SETTINGS_ENABLEDM+718 −76+152 −30#30339
Front#30349Scope one-to-many columns from the Edit column panelL+1053 −92+316 −18#30348, #30466, #30468, #30469, #30465
Front#30439Lookup columns in the table, editable from their cells (absorbs #30440)L+805 −223+283 −30#30349
Front#30458Lookup and scoped columns on boards and calendarsM+404 −284+140 −7#30439

The longest dependency chain is #30339 → #30348 → #30349 → #30439 → #30458; everything else is one or two levels deep. #30339, #30341 and #30472 each add a 2.59 instance command, so whichever merges after another may need a fresh timestamp.

Testing

  • Integration upsert-view-field-with-scope: create, replace and clear a scope; keep the scope when the input omits it; move a nested filter group to the root with null; keep a filter in its group when an update omits it; clear a column's aggregate with null; a new scope inherits an unlisted owner view's visibility and creator; a guest is denied, including through their own view.
  • Integration upsert-view-widget, upsert-view-widget-view-settings and endpoint-permission-declarations pass.
  • Unit: buildViewFiltersAndSortsUpsertFlatOperations (create / update / delete, omitted kinds untouched, clearing a filter's group, unchanged root group not rewritten), inheritScopeViewOwnerVisibility.
  • Integration view-field-relation-target: saving and clearing a lookup through upsertViewFieldWithScope, and rejecting a relation target there.

Generated by Claude Code