Skip to content

feat: enhance List and Form View protocols with detailed configuration schemas#94

Merged
hotlong merged 5 commits intomainfrom
copilot/enhance-list-form-protocols
Jan 24, 2026
Merged

feat: enhance List and Form View protocols with detailed configuration schemas#94
hotlong merged 5 commits intomainfrom
copilot/enhance-list-form-protocols

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 24, 2026

Enhanced List View and Form View Protocol

Completed

  • 1. Create ListColumnSchema for detailed column configuration
    • Add properties: field, label, width, align, hidden, sortable, resizable, wrap, type
    • Add validation: width must be positive
    • Add validation tests for negative/zero width
  • 2. Update ListViewSchema to support enhanced columns
    • Support both string[] (legacy) and ListColumnSchema[] (new)
    • Add resizable, striped, bordered features
    • Add selection configuration (type: none/single/multiple)
    • Add pagination configuration (pageSize, pageSizeOptions)
    • Add validation: pageSize and pageSizeOptions must be positive integers
    • Add validation tests for negative/zero/non-integer values
  • 3. Create FormFieldSchema for detailed form field configuration
    • Add properties: field, label, placeholder, helpText, readonly, required, hidden, colSpan
    • Add dependsOn, visibleOn for conditional logic
    • Add widget for custom component specification
    • Add validation: colSpan must be integer between 1-4
    • Add validation tests for colSpan boundary values
  • 4. Update FormSectionSchema to support mixed field types
    • Allow z.array(z.union([z.string(), FormFieldSchema]))
    • Fix documentation error: fields type corrected to (string | object)[]
  • 5. Add comprehensive tests for all new schemas
    • 86 view.test.ts tests (30 new validation tests added)
    • All 257 UI tests passing
  • 6. Validate with build and existing tests
  • 7. Address code review feedback with proper validation constraints
  • 8. Merge ViewDataSchema from PR Add ViewDataSchema for dual-mode data sourcing in Forms and Tables #95 for dual-mode support
  • 9. Fix build errors and test failures

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

The current metadata-driven frontend protocol for Forms and Tables in packages/spec/src/ui/view.zod.ts is insufficiently detailed for building robust frontend controls.

The following improvements are needed:

  1. Enhanced List View Protocol (ListViewSchema):

    • Columns: Upgrade columns from a simple string array to support a detailed configuration object (ListColumnSchema).
      • Properties: field (name), label, width, align (left/center/right), hidden, sortable, resizable, wrap, type (renderer override).
    • Features: Add resizable (columns), striped (rows), bordered.
    • Selection: Add selection configuration (type: none/single/multiple).
    • Pagination: Add pagination configuration (pageSize, pageSizeOptions).
  2. Enhanced Form View Protocol (FormViewSchema):

    • Fields: Upgrade fields in FormSectionSchema to support a detailed configuration object (FormFieldSchema).
      • Properties: field (name), label override, placeholder, helpText, readonly override, required override, hidden override, colSpan (grid width).
    • Dependencies: Add dependsOn (field name) and visibleOn (expression) to FormFieldSchema for conditional logic.
    • Controls: Add widget property to FormFieldSchema to specify custom components.
  3. Refactor FormSectionSchema:

    • Allow mixed types in fields: z.array(z.union([z.string(), FormFieldSchema])).

These changes will provide a comprehensive standard for the frontend team to implement rich, metadata-driven UI components.

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.

@vercel
Copy link
Copy Markdown

vercel bot commented Jan 24, 2026

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

Project Deployment Review Updated (UTC)
spec Error Error Jan 24, 2026 5:30am

Request Review

…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>
Copilot AI changed the title [WIP] Update metadata-driven frontend protocol for forms and tables feat: enhance List and Form View protocols with detailed configuration schemas Jan 24, 2026
Copilot AI requested a review from hotlong January 24, 2026 04:27
@github-actions github-actions bot added documentation Improvements or additions to documentation tests protocol:ui size/xl labels Jan 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR is very large. Consider breaking it into smaller PRs for easier review.

@hotlong hotlong marked this pull request as ready for review January 24, 2026 05:09
Copilot AI review requested due to automatic review settings January 24, 2026 05:09
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 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 ListViewSchema to support per-column configuration, row selection modes, pagination settings, and grid styling options (resizable, striped, bordered)
  • Enhanced FormFieldSchema to support field-level overrides (placeholder, helpText, readonly, required, hidden, colSpan), custom widget rendering, and conditional visibility logic (dependsOn, visibleOn)
  • Modified columns and fields properties 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

Comment on lines +517 to +598
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();
});
});
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

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

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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[]` | ✅ | |
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
| **fields** | `string \| object[]` || |
| **fields** | `(string \| object)[]` || |

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 84a6427. Changed from string | object[] to (string | object)[] to correctly represent an array of mixed string/object items.

@github-actions
Copy link
Copy Markdown
Contributor

This PR is very large. Consider breaking it into smaller PRs for easier review.

@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 24, 2026

@copilot fix test and build

@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 24, 2026

@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>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 24, 2026

@copilot fix test and build

Fixed in commit 84a6427:

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 24, 2026

@copilot fix all

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?

@github-actions
Copy link
Copy Markdown
Contributor

This PR is very large. Consider breaking it into smaller PRs for easier review.

@hotlong hotlong merged commit 64ae62c into main Jan 24, 2026
11 of 12 checks passed
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/xl tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants