Add missing Field.phone() helper and factory methods for Action/Dashboard/Report#15
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Add phone field type helper to Field factory - Update Field.select/multiselect to support both array and object signatures - Add factory methods (Action.create, Dashboard.create, Report.create) - Use z.input and parse for factory methods to support default values Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes TypeScript compilation errors in the CRM example by enhancing the Field factory API and adding factory helper methods for UI components. The changes enable both legacy string-array syntax and new object-based configuration for select fields, while adding missing field type helpers and runtime factory methods.
Changes:
- Added
phonefield type helper and dual-signature support forselect/multiselectfields (backward compatible) - Added factory helper methods (
Action.create,Dashboard.create,Report.create) with proper type inference usingz.input - Restructured documentation metadata hierarchy by moving
root: truefrom parent to child sections
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/spec/src/data/field.zod.ts | Added phone helper and refactored select/multiselect to accept both string arrays and SelectOption objects |
| packages/spec/src/ui/action.zod.ts | Added Action.create() factory method with additional exported types |
| packages/spec/src/ui/dashboard.zod.ts | Added Dashboard.create() factory method with exported widget type |
| packages/spec/src/ui/report.zod.ts | Added Report.create() factory method with additional exported types |
| content/docs/references/meta.json | Removed root: true from parent metadata |
| content/docs/references/data/meta.json | Added root: true to Data Protocol section |
| content/docs/references/ui/meta.json | Added root: true to UI Protocol section |
| content/docs/references/system/meta.json | Added root: true to System Protocol section |
| content/docs/references/ai/meta.json | Added root: true to AI Protocol section |
| finalConfig = optionsOrConfig; | ||
| } | ||
|
|
||
| return { type: 'select', ...finalConfig, options } as const; |
There was a problem hiding this comment.
The spread order ...finalConfig, options means that if finalConfig contains an options property, it will be overwritten by the options variable. Consider using options, ...finalConfig to ensure the parsed options take precedence, or explicitly handle the options property separately to avoid confusion.
There was a problem hiding this comment.
Fixed in 49030d1. Now extracting options from config object and placing processed options first in spread order to ensure they always take precedence.
| finalConfig = optionsOrConfig; | ||
| } | ||
|
|
||
| return { type: 'multiselect', ...finalConfig, options } as const; |
There was a problem hiding this comment.
The spread order ...finalConfig, options means that if finalConfig contains an options property, it will be overwritten by the options variable. Consider using options, ...finalConfig to ensure the parsed options take precedence, or explicitly handle the options property separately to avoid confusion.
There was a problem hiding this comment.
Fixed in 49030d1. Now extracting options from config object and placing processed options first in spread order to ensure they always take precedence.
|
@copilot fix |
- Add tests for Field.phone() helper - Add tests for Field.select() backward compatibility (old and new API) - Add tests for Field.multiselect() backward compatibility - Add tests for Action.create() with default value handling - Add tests for Dashboard.create() with default value handling - All 279 tests passing Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Document backward-compatible API with examples for both old and new signatures Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
- Extract options from config object to avoid confusion - Change spread order to options first, then finalConfig - Ensures processed options always take precedence Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
8beab63
into
copilot/add-crm-functionality-example
Fix CRM Example TypeScript Build Errors ✅
Problem: The CRM example has multiple TypeScript compilation errors preventing CI from passing.
Root Causes:
Field.select()signature mismatch - expectsstring[]but code passesSelectOption[]objectsphonefield type helper in Field factoryAction,Dashboard, andReportare only types, not runtime objects with.create()methodsSolution:
phonefield type helper to Field factoryField.select()/Field.multiselect()to support both old and new API signatures (backward compatible)Action.create,Dashboard.create,Report.create) usingz.inputfor proper default handlingBackward Compatibility:
Test Results: ✅ All 279 tests passing
Build Status: ✅ All packages build successfully (CRM, TODO, docs)
Security: ✅ No vulnerabilities detected
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.