Skip to content

fix(spec): enforce ViewFilterRuleSchema operator enum + typed sort#3363

Closed
akarma-synetal wants to merge 1 commit into
objectstack-ai:mainfrom
akarma-synetal:fix/operator-dropdown-sort-union
Closed

fix(spec): enforce ViewFilterRuleSchema operator enum + typed sort#3363
akarma-synetal wants to merge 1 commit into
objectstack-ai:mainfrom
akarma-synetal:fix/operator-dropdown-sort-union

Conversation

@akarma-synetal

Copy link
Copy Markdown
Contributor

Summary

  • operator: z.string()z.enum([19 valid operators]) so SchemaForm auto-renders a Select dropdown
  • sort: z.union([z.string(), z.array(...)])z.array(...) so RepeaterField renders sort sub-fields correctly
  • Updated fixtures and share-link object to use valid operators
  • All 6807 spec tests pass

Test plan

  • pnpm --filter @objectstack/spec test — 6807 passed, 0 failed
  • Verify Edit View Config in ObjectUI console shows operator dropdown + smart value input (paired with objectui PR)

Made with Cursor

- `operator`: z.string() → z.enum([equals, not_equals, contains,
  not_contains, starts_with, ends_with, greater_than, less_than,
  greater_than_or_equal, less_than_or_equal, in, not_in, is_empty,
  is_not_empty, is_null, is_not_null, before, after, between])
  so the SchemaForm renderer auto-generates a Select dropdown instead
  of a generic text input.
- `sort`: z.union([z.string(), z.array(...)]) → z.array(...) only.
  The union form confused the RepeaterField, causing it to render no
  UI at all for the sort sub-field.
- Updated a test fixture (task.view.ts) and share-link object
  (sys-share-link.object.ts) to use valid operators / array sort.
- Fixed spec tests to match the new enum (this_quarter → is_empty,
  gte → greater_than_or_equal, string sort → array sort).

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown

@akarma-synetal is attempting to deploy a commit to the Object Stack Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

Thanks for tackling this — the underlying need (a real operator enum so SchemaForm can render a dropdown and invalid operators are rejected) was sound, and it shipped in a reworked form via #3373 (now merged to main), tracked by #3368.

The rework kept your enum direction but adjusted a few things that made the original approach risky:

  • Legacy-alias normalization instead of a bare strict enum. operator is now z.preprocess(normalizeFilterOperator, z.enum(VIEW_FILTER_OPERATORS)). Verified that under z.toJSONSchema({ io: 'input' }) (the mode ObjectUI uses) this still surfaces the clean canonical enum for the dropdown, while folding stored shorthand/camelCase spellings (gt, gte, isNull, notEquals, nin, …) to canonical on parse. A strict enum with no aliases would have broken already-stored view metadata and ObjectUI's own FilterBuilderWidget writes (gt/gte).
  • isNullis_null (not is_empty) to preserve null-vs-empty semantics on sys_share_link.
  • Kept the legacy string sort form (deprecation note only) and retained the objectui#2601 regression fixture — the sort removal is left to its own deprecation cycle rather than bundled here.
  • Relative-date operators (this_quarter, …) were dropped from the operator vocabulary (they're date-range presets, unimplemented at the filter-rule level); fixtures/JSDoc updated instead of the tests being edited to pass.

It also pins widget: 'filter-builder' on the list-view filter field in view.form.ts (matching dataset/page forms) so the Studio editor gets the field-type-aware builder. Paired UI work landed in objectstack-ai/objectui#2766.

Since the change is now on main via #3373, this PR can be closed as superseded. Really appreciate the initial push here.


Generated by Claude Code

@os-zhuang os-zhuang closed this Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants