Skip to content

[WIP] Add examples for currently defined protocols#157

Merged
hotlong merged 4 commits intomainfrom
copilot/add-examples-for-protocols
Jan 25, 2026
Merged

[WIP] Add examples for currently defined protocols#157
hotlong merged 4 commits intomainfrom
copilot/add-examples-for-protocols

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 25, 2026

Create Examples for Missing Protocol Categories

Analysis Complete

  • Analyze all 57 protocol schemas across 11 categories
  • Identify existing examples (only UI protocols have examples)
  • Understand example structure pattern

Protocols with Examples ✅

  • UI (8/8 protocols - COMPLETE): action, app, dashboard, page, theme, view, report, widget
    • Added report.examples.ts (12 examples)
    • Added widget.examples.ts (20 examples)
    • Fixed all filter structures to use MongoDB-style operators ($eq, $ne, $gte, $and, $or)
  • Data (8/8 protocols - COMPLETE): dataset, field, filter, hook, mapping, object, query, validation
    • Created examples/data/metadata-examples/
    • Added field.examples.ts (36 examples)
    • Added object.examples.ts (10 examples)
    • Added query.examples.ts (25 examples)
    • Added filter.examples.ts (27 examples)
    • Added validation.examples.ts (20 examples)
    • Added hook.examples.ts (20 examples)
    • Added mapping.examples.ts (10 examples)
    • Added dataset.examples.ts (10 examples)
    • Fixed mapping mode from 'replace' to 'upsert'
    • Added package.json, tsconfig.json, README.md, index.ts

Protocols Needing Examples 📝

  • AI (8 protocols): agent, conversation, cost, model-registry, nlq, orchestration, predictive, rag-pipeline
  • API (5 protocols): contract, discovery, endpoint, realtime, router
  • Auth (5 protocols): config, identity, organization, policy, role
  • Automation (3 protocols): flow, webhook, workflow
  • Driver (4 protocols): datasource, driver, mongo, postgres
  • Hub (5 protocols): composer, license, marketplace, space, tenant
  • Kernel (5 protocols): context, logger, manifest, plugin, scoped-storage
  • Permission (3 protocols): permission, sharing, territory
  • System (4 protocols): audit, events, job, translation

Plan

  • Complete UI category (8/8 protocols)
  • Create Data category examples (8/8 protocols) - 158 examples
  • Fix all code review issues
  • Create Automation category examples folder
  • Create Auth category examples folder
  • Create Permission category examples folder
  • Create AI category examples folder
  • Create API category examples folder
  • Create Driver category examples folder
  • Create Hub category examples folder
  • Create Kernel category examples folder
  • Create System category examples folder
Original prompt

显示目前协议还有哪些需要写例子二级文件夹的方式在examples中写


✨ 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 25, 2026

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

Project Deployment Review Updated (UTC)
spec Ready Ready Preview, Comment Jan 25, 2026 2:31pm

Request Review

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

@copilot 继续

@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 25, 2026

@copilot 继续

@hotlong hotlong marked this pull request as ready for review January 25, 2026 14:19
Copilot AI review requested due to automatic review settings January 25, 2026 14:19
@github-actions github-actions bot added documentation Improvements or additions to documentation dependencies Pull requests that update a dependency file tooling labels Jan 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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

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 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

Comment on lines +301 to +312
filter: {
$and: [
{ field: 'amount', operator: 'gte', value: 100000 },
{
$or: [
{ field: 'stage', operator: 'eq', value: 'Negotiation' },
{ field: 'stage', operator: 'eq', value: 'Proposal' },
],
},
],
},
};
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

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

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' } }] }] }.

Copilot uses AI. Check for mistakes.
Comment on lines +334 to +338
filter: {
field: 'stage',
operator: 'eq',
value: 'Closed Won',
},
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

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

The filter structure is incorrect. Use MongoDB-style operators: { stage: { $eq: 'Closed Won' } } instead of { field: 'stage', operator: 'eq', value: 'Closed Won' }.

Copilot uses AI. Check for mistakes.
label: 'Migrate Products from Legacy System',
sourceFormat: 'json',
targetObject: 'product',
mode: 'replace',
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
mode: 'replace',
mode: 'upsert',

Copilot uses AI. Check for mistakes.
Comment on lines +55 to +56
{ field: 'stage', operator: 'ne', value: 'Closed Won' },
{ field: 'stage', operator: 'ne', value: 'Closed Lost' },
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
{ field: 'stage', operator: 'ne', value: 'Closed Won' },
{ field: 'stage', operator: 'ne', value: 'Closed Lost' },
{ stage: { $ne: 'Closed Won' } },
{ stage: { $ne: 'Closed Lost' } },

Copilot uses AI. Check for mistakes.
Comment on lines +104 to +108
filter: {
field: 'stage',
operator: 'eq',
value: 'Closed Won',
},
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

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

The filter structure is incorrect. Use MongoDB-style operators: { stage: { $eq: 'Closed Won' } } instead of { field: 'stage', operator: 'eq', value: 'Closed Won' }.

Copilot uses AI. Check for mistakes.
Comment on lines +129 to +133
filter: {
field: 'stage',
operator: 'eq',
value: 'Closed Won',
},
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

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

The filter structure is incorrect. Use MongoDB-style operators: { stage: { $eq: 'Closed Won' } } instead of { field: 'stage', operator: 'eq', value: 'Closed Won' }.

Copilot uses AI. Check for mistakes.
Comment on lines +161 to +163
field: 'stage',
operator: 'eq',
value: 'Closed Won',
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

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

The filter structure is incorrect. Use MongoDB-style operators: { stage: { $eq: 'Closed Won' } } instead of { field: 'stage', operator: 'eq', value: 'Closed Won' }.

Suggested change
field: 'stage',
operator: 'eq',
value: 'Closed Won',
stage: { $eq: 'Closed Won' },

Copilot uses AI. Check for mistakes.
Comment on lines +240 to +242
field: 'stage',
operator: 'eq',
value: 'Closed Won',
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

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

The filter structure is incorrect. Use MongoDB-style operators: { stage: { $eq: 'Closed Won' } } instead of { field: 'stage', operator: 'eq', value: 'Closed Won' }.

Suggested change
field: 'stage',
operator: 'eq',
value: 'Closed Won',
stage: {
$eq: 'Closed Won',
},

Copilot uses AI. Check for mistakes.
@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 25, 2026

@copilot fix all

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

Copilot AI commented Jan 25, 2026

@copilot fix all

Fixed all issues in commit 3a3cb89:

  • Updated all filter structures in report.examples.ts to use MongoDB-style operators ($eq, $ne, $gte, $and, $or)
  • Changed mapping mode from 'replace' to 'upsert' in mapping.examples.ts
  • Both packages build successfully

@hotlong hotlong merged commit 5d6829b into main Jan 25, 2026
1 of 2 checks passed
Copilot AI requested a review from hotlong January 25, 2026 14:31
Copilot stopped work on behalf of hotlong due to an error January 25, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation size/xl tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants