[WIP] Add examples for currently defined protocols#157
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
@copilot 继续 |
|
@copilot 继续 |
|
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 adds comprehensive examples for the Data protocol category (8/8 protocols with 158 total examples) and completes the UI protocol examples by adding report and widget examples. The examples follow the established pattern from existing UI examples and demonstrate real-world use cases aligned with industry standards like Salesforce and ServiceNow.
Changes:
- Added complete Data protocol examples package with 158 examples covering all 8 data protocols (field, object, query, filter, validation, hook, mapping, dataset)
- Added UI protocol examples for Report (12 examples) and Widget (20 examples)
- Included comprehensive documentation, package configuration, and TypeScript setup for the new examples package
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/data/metadata-examples/src/field.examples.ts | 36 field type examples demonstrating all field types from text to QR codes |
| examples/data/metadata-examples/src/object.examples.ts | 10 complete object definitions for CRM, e-commerce, and project management |
| examples/data/metadata-examples/src/query.examples.ts | 25 query examples from simple selects to complex joins and aggregations |
| examples/data/metadata-examples/src/filter.examples.ts | 27 filter condition examples demonstrating MongoDB-style operators |
| examples/data/metadata-examples/src/validation.examples.ts | 20 validation rule examples covering all validation types |
| examples/data/metadata-examples/src/hook.examples.ts | 20 lifecycle hook examples for data operations |
| examples/data/metadata-examples/src/mapping.examples.ts | 10 ETL mapping examples with one invalid mode value |
| examples/data/metadata-examples/src/dataset.examples.ts | 10 seed data examples for bootstrapping and testing |
| examples/data/metadata-examples/src/index.ts | Exports all Data protocol examples |
| examples/data/metadata-examples/package.json | Package configuration for the Data examples |
| examples/data/metadata-examples/tsconfig.json | TypeScript configuration matching UI examples pattern |
| examples/data/metadata-examples/README.md | Comprehensive documentation for Data protocol examples |
| examples/ui/metadata-examples/src/report.examples.ts | 12 report examples with incorrect filter format (7 instances) |
| examples/ui/metadata-examples/src/widget.examples.ts | 20 widget prop examples for various field types |
| examples/ui/metadata-examples/src/index.ts | Updated exports to include report and widget examples |
| examples/ui/metadata-examples/README.md | Updated documentation listing all UI examples |
| filter: { | ||
| $and: [ | ||
| { field: 'amount', operator: 'gte', value: 100000 }, | ||
| { | ||
| $or: [ | ||
| { field: 'stage', operator: 'eq', value: 'Negotiation' }, | ||
| { field: 'stage', operator: 'eq', value: 'Proposal' }, | ||
| ], | ||
| }, | ||
| ], | ||
| }, | ||
| }; |
There was a problem hiding this comment.
The filter structure is incorrect. Use MongoDB-style operators with $and, $or for logical combinations and field-level operators like $gte for comparisons. For example: { $and: [{ amount: { $gte: 100000 } }, { $or: [{ stage: { $eq: 'Negotiation' } }, { stage: { $eq: 'Proposal' } }] }] }.
| filter: { | ||
| field: 'stage', | ||
| operator: 'eq', | ||
| value: 'Closed Won', | ||
| }, |
There was a problem hiding this comment.
The filter structure is incorrect. Use MongoDB-style operators: { stage: { $eq: 'Closed Won' } } instead of { field: 'stage', operator: 'eq', value: 'Closed Won' }.
| label: 'Migrate Products from Legacy System', | ||
| sourceFormat: 'json', | ||
| targetObject: 'product', | ||
| mode: 'replace', |
There was a problem hiding this comment.
The mode value 'replace' is not valid for Mapping. According to the MappingSchema in packages/spec/src/data/mapping.zod.ts, the mode field only accepts 'insert', 'update', or 'upsert'. Change this to one of the valid values, likely 'upsert' based on the use case description.
| mode: 'replace', | |
| mode: 'upsert', |
| { field: 'stage', operator: 'ne', value: 'Closed Won' }, | ||
| { field: 'stage', operator: 'ne', value: 'Closed Lost' }, |
There was a problem hiding this comment.
The filter structure is incorrect. According to FilterConditionSchema in packages/spec/src/data/filter.zod.ts, filters should use MongoDB-style operators. Instead of using the format { field: 'stage', operator: 'ne', value: 'Closed Won' }, use the correct format: { stage: { $ne: 'Closed Won' } }. This applies to all filter conditions in this file.
| { field: 'stage', operator: 'ne', value: 'Closed Won' }, | |
| { field: 'stage', operator: 'ne', value: 'Closed Lost' }, | |
| { stage: { $ne: 'Closed Won' } }, | |
| { stage: { $ne: 'Closed Lost' } }, |
| filter: { | ||
| field: 'stage', | ||
| operator: 'eq', | ||
| value: 'Closed Won', | ||
| }, |
There was a problem hiding this comment.
The filter structure is incorrect. Use MongoDB-style operators: { stage: { $eq: 'Closed Won' } } instead of { field: 'stage', operator: 'eq', value: 'Closed Won' }.
| filter: { | ||
| field: 'stage', | ||
| operator: 'eq', | ||
| value: 'Closed Won', | ||
| }, |
There was a problem hiding this comment.
The filter structure is incorrect. Use MongoDB-style operators: { stage: { $eq: 'Closed Won' } } instead of { field: 'stage', operator: 'eq', value: 'Closed Won' }.
| field: 'stage', | ||
| operator: 'eq', | ||
| value: 'Closed Won', |
There was a problem hiding this comment.
The filter structure is incorrect. Use MongoDB-style operators: { stage: { $eq: 'Closed Won' } } instead of { field: 'stage', operator: 'eq', value: 'Closed Won' }.
| field: 'stage', | |
| operator: 'eq', | |
| value: 'Closed Won', | |
| stage: { $eq: 'Closed Won' }, |
| field: 'stage', | ||
| operator: 'eq', | ||
| value: 'Closed Won', |
There was a problem hiding this comment.
The filter structure is incorrect. Use MongoDB-style operators: { stage: { $eq: 'Closed Won' } } instead of { field: 'stage', operator: 'eq', value: 'Closed Won' }.
| field: 'stage', | |
| operator: 'eq', | |
| value: 'Closed Won', | |
| stage: { | |
| $eq: 'Closed Won', | |
| }, |
|
@copilot fix all |
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Create Examples for Missing Protocol Categories
Analysis Complete
Protocols with Examples ✅
Protocols Needing Examples 📝
Plan
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.