Fix Automation API contract type safety and complete triggerFlow schema#765
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…hance tests - Fix IAutomationService contract: replace `unknown` return types with `FlowParsed` and `ExecutionLog` - Add TriggerFlowRequestSchema/TriggerFlowResponseSchema with input/output for triggerFlow contract - Add typed contract tests for getFlow, listRuns, getRun, toggleFlow - Add triggerFlow API schema tests - Add contract completeness test (all endpoints have input/output) - Update ROADMAP to reflect type safety improvements Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR completes the Automation API contract type safety improvements by replacing unknown types with properly typed schema types (FlowParsed, ExecutionLog) and adding the missing input/output schemas for the triggerFlow endpoint. This ensures all 9 AutomationApiContracts entries have complete schema definitions for runtime validation and TypeScript type safety.
Changes:
- Updated
IAutomationServicecontract to use typed returns:getFlow→FlowParsed | null,listRuns→ExecutionLog[],getRun→ExecutionLog | null - Added
TriggerFlowRequestSchemaandTriggerFlowResponseSchemato complete the API protocol definition - Added comprehensive contract tests verifying typed returns for
getFlow,listRuns,getRun, andtoggleFlow - Updated ROADMAP to reflect completed type safety improvements and full schema coverage
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/spec/src/contracts/automation-service.ts | Added imports for FlowParsed and ExecutionLog; updated return types from unknown to properly typed schemas |
| packages/spec/src/contracts/automation-service.test.ts | Added 3 new test cases for getFlow, listRuns/getRun, and toggleFlow with typed returns |
| packages/spec/src/api/automation-api.zod.ts | Added TriggerFlowRequestSchema and TriggerFlowResponseSchema; updated triggerFlow contract entry with input/output schemas |
| packages/spec/src/api/automation-api.test.ts | Added tests for TriggerFlow request/response parsing; added assertion that all endpoints have input/output schemas |
| ROADMAP.md | Updated automation section to reflect typed returns and complete schema coverage in contract matrix |
| type: 'autolaunched', | ||
| status: 'draft', | ||
| version: 1, | ||
| enabled: true, |
There was a problem hiding this comment.
The FlowSchema does not have an enabled field. According to the FlowSchema in automation/flow.zod.ts, flows use active (boolean, deprecated) and status (enum: 'draft', 'active', 'obsolete', 'invalid') instead. This test will fail when the mock flow is validated against the actual schema. Consider using active: true or status: 'active' instead.
| enabled: true, |
IAutomationServicecontract methods returnedunknowninstead of proper schema types, andtriggerFlowwas the only endpoint inAutomationApiContractsmissinginput/outputschemas.Contract type safety
getFlow→Promise<FlowParsed | null>(wasunknown | null)listRuns→Promise<ExecutionLog[]>(wasunknown[])getRun→Promise<ExecutionLog | null>(wasunknown | null)TriggerFlow schema gap
TriggerFlowRequestSchema(name, record, object, event, userId, params)TriggerFlowResponseSchema(success, output, error, durationMs)AutomationApiContractsentries now haveinput/outputTests
FlowParsed,ExecutionLog) forgetFlow,listRuns,getRun,toggleFlowTriggerFlowRequestSchema/TriggerFlowResponseSchemaparsinginputandoutputdefinedROADMAP
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.