Skip to content

Standardize filter syntax to MongoDB-style and complete documentation#53

Merged
hotlong merged 6 commits intomainfrom
copilot/update-filter-documentation
Jan 21, 2026
Merged

Standardize filter syntax to MongoDB-style and complete documentation#53
hotlong merged 6 commits intomainfrom
copilot/update-filter-documentation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 21, 2026

Filter Documentation & Code Standardization - COMPLETED ✅

Issues Identified

  • Two different filter systems exist: array-based (old) vs MongoDB-style (new)
  • Documentation is incomplete and missing examples
  • All examples use the old array-based system
  • Operator naming is inconsistent
  • Report filters use a hybrid format
  • Build error fixed

Documentation Updates Completed ✅

  • Update QueryFilter documentation with comprehensive examples
  • Update NormalizedFilter documentation with usage guide
  • Update FilterCondition documentation with real-world examples
  • Update FilterOperator documentation to align with new system and migration guide
  • Update FilterNode documentation with deprecation notice

Code Updates Completed ✅

  • Update DashboardWidget schema to use FilterCondition
  • Update Report schema to use FilterCondition (removed old filter + filterItems)
  • Update all dashboard tests to use modern filter syntax
  • Update client-test.ts example to use MongoDB-style filters with correct 'filters' property
  • Update CRM dashboard filters (14 filters converted)
  • Update CRM report filters (6 reports converted)
  • Fix build error: changed 'where' to 'filters' in QueryOptions
  • All tests passing, build successful

Summary of Changes

  • 5 documentation files updated with comprehensive examples and migration guides
  • 3 schema files updated to use FilterCondition
  • 3 example files updated to modern syntax
  • Build fixed - all packages compile successfully

Migration Notes

  • Old array-based syntax: [['field', '=', 'value']] → New: { field: 'value' }
  • Old inequality: [['stage', '!=', 'won'], ['stage', '!=', 'lost']] → New: { stage: { $nin: ['won', 'lost'] } }
  • Old Report structure with filter + filterItems → New: single filter object with FilterCondition
  • Client SDK uses filters property (not where) for MongoDB-style filters
Original prompt

更新filter相关的文档,规范相关的代码相关的例子


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link
Copy Markdown

vercel bot commented Jan 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
spec Error Error Jan 21, 2026 5:55am

Request Review

… guide

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI and others added 2 commits January 21, 2026 05:18
…ters

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Update filter documentation and code examples Standardize filter syntax to MongoDB-style and complete documentation Jan 21, 2026
Copilot AI requested a review from hotlong January 21, 2026 05:22
@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 21, 2026

@copilot fix build

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 21, 2026

@copilot fix build

Fixed in 9dc055e. The issue was using where instead of filters in the QueryOptions interface for the client SDK. Build now passes successfully.

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jan 21, 2026
@hotlong hotlong marked this pull request as ready for review January 21, 2026 06:32
Copilot AI review requested due to automatic review settings January 21, 2026 06:32
@hotlong hotlong merged commit f7afab7 into main Jan 21, 2026
11 of 12 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request standardizes filter syntax across the ObjectStack spec from array-based filters to MongoDB-style FilterCondition objects. The change affects dashboard widgets, reports, and client SDK examples, providing a more intuitive and type-safe querying interface.

Changes:

  • Replaced old filter + filterItems structure in Reports with a single filter: FilterConditionSchema
  • Updated Dashboard widgets to use FilterConditionSchema instead of z.any()
  • Migrated all examples (dashboards, reports, client tests) from array-based syntax [['field', '=', 'value']] to MongoDB-style { field: value } or { field: { $op: value } }

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/spec/src/ui/report.zod.ts Replaced filter/filterItems with single FilterConditionSchema
packages/spec/src/ui/dashboard.zod.ts Changed filter from z.any() to FilterConditionSchema
packages/spec/src/ui/dashboard.test.ts Updated all 14 test filters to MongoDB-style syntax
packages/spec/json-schema/Report.json Generated JSON schema for new FilterCondition structure
packages/spec/json-schema/DashboardWidget.json Generated JSON schema with FilterCondition allOf pattern
packages/spec/json-schema/Dashboard.json Generated JSON schema with FilterCondition allOf pattern
examples/todo/src/client-test.ts Updated client example to use MongoDB-style filters with 'filters' property
examples/crm/src/ui/reports.ts Converted 6 report filters from old filterItems to FilterCondition
examples/crm/src/ui/dashboards.ts Converted 14 dashboard widget filters to MongoDB-style syntax
content/docs/references/ui/analytics/Report.mdx Updated documentation to reflect filter schema change

| **groupingsAcross** | `object[]` | optional | Column groupings (Matrix only) |
| **filter** | `string` | optional | Filter logic (e.g. "1 AND (2 OR 3)") |
| **filterItems** | `object[]` | optional | Filter criteria lines |
| **filter** | `any` | optional | Filter criteria |
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filter type documentation should reference FilterCondition instead of any for clarity. This should be consistent with the schema change that uses FilterConditionSchema. Consider updating to: **filter** | FilterCondition | optional | Filter criteria

Suggested change
| **filter** | `any` | optional | Filter criteria |
| **filter** | `FilterCondition` | optional | Filter criteria |

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation protocol:ui size/m tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants