Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…ration schemas - Add ListColumnSchema with field, label, width, align, hidden, sortable, resizable, wrap, type - Add SelectionConfigSchema for row selection (none/single/multiple) - Add PaginationConfigSchema with pageSize and pageSizeOptions - Update ListViewSchema to support both string[] (legacy) and ListColumnSchema[] columns - Add resizable, striped, bordered features to ListViewSchema - Add FormFieldSchema with field, label, placeholder, helpText, readonly, required, hidden, colSpan - Add widget, dependsOn, visibleOn to FormFieldSchema for custom components and conditional logic - Update FormSectionSchema to support mixed field types (string | FormFieldSchema) - Add comprehensive test coverage for all new schemas - Generate JSON schemas and TypeScript type definitions Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
- Add .positive() validation to ListColumnSchema.width - Add .int().positive() validation to PaginationConfigSchema.pageSize and pageSizeOptions - Add .int().min(1).max(4) validation to FormFieldSchema.colSpan Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
This PR is very large. Consider breaking it into smaller PRs for easier review. |
There was a problem hiding this comment.
Pull request overview
This PR enhances the View protocol schemas to provide more granular control over List and Form view configurations. The changes upgrade from simple string arrays to detailed configuration objects while maintaining backward compatibility.
Changes:
- Added four new configuration schemas (
ListColumnSchema,FormFieldSchema,SelectionConfigSchema,PaginationConfigSchema) with comprehensive properties for fine-grained UI control - Enhanced
ListViewSchemato support per-column configuration, row selection modes, pagination settings, and grid styling options (resizable, striped, bordered) - Enhanced
FormFieldSchemato support field-level overrides (placeholder, helpText, readonly, required, hidden, colSpan), custom widget rendering, and conditional visibility logic (dependsOn, visibleOn) - Modified
columnsandfieldsproperties to accept unions of legacy string arrays and enhanced configuration objects for backward compatibility - Generated corresponding JSON Schema files and documentation
- Comprehensive test coverage for all new schemas including backward compatibility scenarios and real-world CRM/project management examples
- Version bump from 0.3.0 to 0.3.1
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/spec/src/ui/view.zod.ts | Core schema definitions for enhanced List and Form view protocols with new configuration schemas |
| packages/spec/src/ui/view.test.ts | Comprehensive test coverage for new schemas, backward compatibility, and real-world scenarios |
| packages/spec/package-lock.json | Version bump to 0.3.1 |
| packages/spec/json-schema/ui/*.json | Auto-generated JSON Schema files for new configuration types |
| content/docs/references/ui/view/*.mdx | Documentation for new schema types and updated property descriptions |
Files not reviewed (1)
- packages/spec/package-lock.json: Language not supported
| describe('ListColumnSchema', () => { | ||
| it('should accept minimal column config', () => { | ||
| const column: ListColumn = { | ||
| field: 'account_name', | ||
| }; | ||
|
|
||
| expect(() => ListColumnSchema.parse(column)).not.toThrow(); | ||
| }); | ||
|
|
||
| it('should accept full column config', () => { | ||
| const column: ListColumn = { | ||
| field: 'annual_revenue', | ||
| label: 'Annual Revenue', | ||
| width: 150, | ||
| align: 'right', | ||
| hidden: false, | ||
| sortable: true, | ||
| resizable: true, | ||
| wrap: false, | ||
| type: 'currency', | ||
| }; | ||
|
|
||
| expect(() => ListColumnSchema.parse(column)).not.toThrow(); | ||
| }); | ||
|
|
||
| it('should accept column with alignment options', () => { | ||
| const alignments = ['left', 'center', 'right'] as const; | ||
|
|
||
| alignments.forEach(align => { | ||
| const column: ListColumn = { | ||
| field: 'test_field', | ||
| align, | ||
| }; | ||
| expect(() => ListColumnSchema.parse(column)).not.toThrow(); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('SelectionConfigSchema', () => { | ||
| it('should default to none', () => { | ||
| const selection = {}; | ||
|
|
||
| const result = SelectionConfigSchema.parse(selection); | ||
| expect(result.type).toBe('none'); | ||
| }); | ||
|
|
||
| it('should accept all selection types', () => { | ||
| const types = ['none', 'single', 'multiple'] as const; | ||
|
|
||
| types.forEach(type => { | ||
| const selection = { type }; | ||
| expect(() => SelectionConfigSchema.parse(selection)).not.toThrow(); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('PaginationConfigSchema', () => { | ||
| it('should default pageSize to 25', () => { | ||
| const pagination = {}; | ||
|
|
||
| const result = PaginationConfigSchema.parse(pagination); | ||
| expect(result.pageSize).toBe(25); | ||
| }); | ||
|
|
||
| it('should accept custom page size', () => { | ||
| const pagination = { | ||
| pageSize: 50, | ||
| }; | ||
|
|
||
| const result = PaginationConfigSchema.parse(pagination); | ||
| expect(result.pageSize).toBe(50); | ||
| }); | ||
|
|
||
| it('should accept page size options', () => { | ||
| const pagination = { | ||
| pageSize: 25, | ||
| pageSizeOptions: [10, 25, 50, 100], | ||
| }; | ||
|
|
||
| expect(() => PaginationConfigSchema.parse(pagination)).not.toThrow(); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Missing validation tests for negative and boundary values. The schema uses .positive() for width and .int().positive() for pageSize/pageSizeOptions, but there are no tests to verify these constraints are enforced. Based on patterns in other test files in this codebase (e.g., packages/spec/src/system/tenant.test.ts:60-74), validation tests should be added for:
- ListColumnSchema with negative/zero width values
- PaginationConfigSchema with negative/zero pageSize values
- PaginationConfigSchema with negative/zero values in pageSizeOptions array
- FormFieldSchema with colSpan values outside the 1-4 range
There was a problem hiding this comment.
Added validation tests in commit 84a6427:
- ListColumnSchema: negative/zero width rejection
- PaginationConfigSchema: negative/zero/non-integer pageSize and pageSizeOptions rejection
- FormFieldSchema: colSpan values outside 1-4 range rejection
All boundary cases are now covered with 30 additional test cases.
| | **collapsed** | `boolean` | optional | | | ||
| | **columns** | `Enum<'1' \| '2' \| '3' \| '4'>` | optional | | | ||
| | **fields** | `string[]` | ✅ | | | ||
| | **fields** | `string \| object[]` | ✅ | | |
There was a problem hiding this comment.
Documentation error: The type for the 'fields' property is listed as "string | object[]" but should be "(string | object)[]" to correctly represent an array that can contain either strings or objects. The schema definition in view.zod.ts line 132-135 uses z.array(z.union([z.string(), FormFieldSchema])), which means an array of mixed string/object items, not a union of a string or an array of objects.
| | **fields** | `string \| object[]` | ✅ | | | |
| | **fields** | `(string \| object)[]` | ✅ | | |
There was a problem hiding this comment.
Fixed in commit 84a6427. Changed from string | object[] to (string | object)[] to correctly represent an array of mixed string/object items.
|
This PR is very large. Consider breaking it into smaller PRs for easier review. |
|
@copilot fix test and build |
|
@copilot fix all |
- Add HttpMethodSchema, HttpRequestSchema, and ViewDataSchema from merged PR - Add validation tests for negative/boundary values in ListColumnSchema.width - Add validation tests for negative/zero/non-integer values in PaginationConfigSchema - Add validation tests for colSpan outside 1-4 range in FormFieldSchema - Fix documentation error in FormSection.mdx: fields type should be (string | object)[] not string | object[] - Fix duplicate type exports - All 257 UI tests passing Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Fixed in commit 84a6427:
|
All tests passing (1,615 tests), build successful, and schemas/docs generated correctly. Could you clarify what specifically needs to be fixed? Are there any CI errors or specific issues you're seeing? |
|
This PR is very large. Consider breaking it into smaller PRs for easier review. |
Enhanced List View and Form View Protocol
Completed
ListColumnSchemafor detailed column configurationfield,label,width,align,hidden,sortable,resizable,wrap,typewidthmust be positiveListViewSchemato support enhanced columnsresizable,striped,borderedfeaturesselectionconfiguration (type: none/single/multiple)paginationconfiguration (pageSize,pageSizeOptions)pageSizeandpageSizeOptionsmust be positive integersFormFieldSchemafor detailed form field configurationfield,label,placeholder,helpText,readonly,required,hidden,colSpandependsOn,visibleOnfor conditional logicwidgetfor custom component specificationcolSpanmust be integer between 1-4FormSectionSchemato support mixed field typesz.array(z.union([z.string(), FormFieldSchema]))(string | object)[]Summary
All enhancements have been successfully implemented, tested, and merged with the latest main branch changes. The changes maintain backward compatibility while enabling rich, metadata-driven configurations for frontend teams. Added comprehensive validation tests as requested in code review.
Original prompt
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.