Improvements to the Workbench UI, the Logs table is cleaner and shares the same structure as Motia Cloud.
New page: Endpoints
We added a new page to Workbench: Endpoints where developers can see their API spec and test their endpoints
New fields to ApiRouteConfig
We added a few fields to help with documentation
export const config: ApiRouteConfig = {
type: 'api',
name: 'HelloWorld',
description: 'Test Endpoint',
method: 'GET',
path: '/hello',
emits: [],
flows: ['Main'],
/**
* Definition of query params
*/
queryParams: [
{ name: 'name', description: 'The name to salute' }
],
/**
* Definition of the response body, this is also used
* to enforce type check in TypeScript
*/
responseBody: {
200: z.object({ message: z.string(), success: z.boolean() }),
400: z.object({ message: z.string({ description: 'The error message') }),
}
}Major Update: Type Checks!
We introduced type check generation based on code written in any language (JavaScript, TypeScript, or Python). Motia framework will automatically generate type checks to:
- Ensure you emit events to topics the step is defined to
- Ensure you emit events with the expected format
- Ensure the body returned from the API endpoints matches the defined responseBody
Feature Highlight
Type checking for emits
Breaking change: We previously needed to define EventConfig with a generic type
const input = z.object({ id: z.string() })
export const config: EventConfig<typeof input> = {
// ...
}and now we don’t have generics in EventConfig anymore
export const config: EventConfig = {
input: z.object({ id: z.string() }),
// ...
}Migration
Instead of defining the handler with StepHandler
export const handler: StepHandler<typeof config> = async (input, context) => {You should use Handlers
To generate the types you need to first npx motia generate-types or just start motia
npx motia generate-types
export const config: EventConfig = {
name: 'IdeatorAgent',
// ...
}
// The name should match the step name ↷
export const handler: Handlers['IdeatorAgent'] = async (input, context) => {What's Changed
- feat: workbench api definition by @sergiofilhowz in #231
- feat: auto types generation by @sergiofilhowz in #232
- chore: response schema with multiple response codes by @sergiofilhowz in #236
Full Changelog: v0.1.0-beta.30...v0.2.0-beta.31



