Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 8
Add ViewDataSchema for dual-mode data sourcing in Forms and Tables#95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
7846980f122c63bb267183fee845File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,44 @@ | ||||||||||||||||||||||||||||||||||||||||
| import { z } from 'zod'; | ||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||
| * HTTP Method Enum | ||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||
| export const HttpMethodSchema = z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']); | ||||||||||||||||||||||||||||||||||||||||
CopilotAI | ||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||
| * HTTP Request Configuration for API Provider | ||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||
| export const HttpRequestSchema = z.object({ | ||||||||||||||||||||||||||||||||||||||||
| url: z.string().describe('API endpoint URL'), | ||||||||||||||||||||||||||||||||||||||||
| method: HttpMethodSchema.optional().default('GET').describe('HTTP method'), | ||||||||||||||||||||||||||||||||||||||||
| headers: z.record(z.string()).optional().describe('Custom HTTP headers'), | ||||||||||||||||||||||||||||||||||||||||
| params: z.record(z.unknown()).optional().describe('Query parameters'), | ||||||||||||||||||||||||||||||||||||||||
CopilotAI | ||||||||||||||||||||||||||||||||||||||||
| body: z.unknown().optional().describe('Request body for POST/PUT/PATCH'), | ||||||||||||||||||||||||||||||||||||||||
CopilotAI | ||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||
| * View Data Source Configuration | ||||||||||||||||||||||||||||||||||||||||
| * Supports three modes: | ||||||||||||||||||||||||||||||||||||||||
| * 1. 'object': Standard Protocol - Auto-connects to ObjectStack Metadata and Data APIs | ||||||||||||||||||||||||||||||||||||||||
| * 2. 'api': Custom API - Explicitly provided API URLs | ||||||||||||||||||||||||||||||||||||||||
| * 3. 'value': Static Data - Hardcoded data array | ||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||
| export const ViewDataSchema = z.discriminatedUnion('provider', [ | ||||||||||||||||||||||||||||||||||||||||
| z.object({ | ||||||||||||||||||||||||||||||||||||||||
| provider: z.literal('object'), | ||||||||||||||||||||||||||||||||||||||||
| object: z.string().describe('Target object name'), | ||||||||||||||||||||||||||||||||||||||||
CopilotAI | ||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||
| z.object({ | ||||||||||||||||||||||||||||||||||||||||
| provider: z.literal('api'), | ||||||||||||||||||||||||||||||||||||||||
| read: HttpRequestSchema.optional().describe('Configuration for fetching data'), | ||||||||||||||||||||||||||||||||||||||||
| write: HttpRequestSchema.optional().describe('Configuration for submitting data (for forms/editable tables)'), | ||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||
| z.object({ | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
+31
to
+36
CopilotAI | ||||||||||||||||||||||||||||||||||||||||
| z.object({ | |
| provider: z.literal('api'), | |
| read: HttpRequestSchema.optional().describe('Configuration for fetching data'), | |
| write: HttpRequestSchema.optional().describe('Configuration for submitting data (for forms/editable tables)'), | |
| }), | |
| z.object({ | |
| z | |
| .object({ | |
| provider: z.literal('api'), | |
| read: HttpRequestSchema.optional().describe('Configuration for fetching data'), | |
| write: HttpRequestSchema.optional().describe('Configuration for submitting data (for forms/editable tables)'), | |
| }) | |
| .refine( | |
| (data)=>data.read!==undefined||data.write!==undefined, | |
| { | |
| message: 'api provider requires at least one of "read" or "write"', | |
| } | |
| ), | |
| z.object({ |
CopilotAIJan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of z.unknown() is inconsistent with the rest of the codebase. Throughout this repository, z.any() is used for array items with dynamic data (as seen in packages/spec/src/data/dataset.zod.ts:56 and numerous other files). While z.unknown() is technically more type-safe, changing this pattern in isolation creates inconsistency. Consider using z.array(z.any()) for items to align with established conventions.
Uh oh!
There was an error while loading. Please reload this page.
CopilotAIJan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test coverage is missing for the edge case where an api provider has neither
readnorwriteconfigured. Consider adding a test case to verify this scenario is handled appropriately (either by validation rejection or documented as acceptable). Additionally, consider testing an api provider with onlywriteconfigured, which could be a valid use case for write-only forms.