Skip to content

Commit 2d5535c

Browse files
committed
feat(workflow): add connector action schema and refactor workflow action types
1 parent bca5db4 commit 2d5535c

File tree

2 files changed

+25
-57
lines changed

2 files changed

+25
-57
lines changed

packages/spec/src/automation/approval.zod.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export const ApprovalActionType = z.enum([
2020
'field_update',
2121
'email_alert',
2222
'webhook',
23-
'script'
23+
'script',
24+
'connector_action' // Added for Zapier-style integrations
2425
]);
2526

2627
/**
@@ -29,7 +30,11 @@ export const ApprovalActionType = z.enum([
2930
export const ApprovalActionSchema = z.object({
3031
type: ApprovalActionType,
3132
name: z.string().describe('Action name'),
32-
config: z.record(z.string(), z.any()).describe('Action configuration')
33+
config: z.record(z.string(), z.any()).describe('Action configuration'),
34+
35+
/** For connector actions */
36+
connectorId: z.string().optional(),
37+
actionId: z.string().optional(),
3338
});
3439

3540
/**

packages/spec/src/automation/workflow.zod.ts

Lines changed: 18 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -34,69 +34,32 @@ export const EmailAlertActionSchema = z.object({
3434
});
3535

3636
/**
37-
* Schema for Workflow SMS Notification Action
38-
* Supports providers like Twilio, Vonage
37+
* Schema for Connector Action Reference
38+
* Executes a capability defined in an integration connector.
39+
* Replaces hardcoded vendor actions (Slack, Twilio, etc).
3940
*/
40-
export const SmsNotificationActionSchema = z.object({
41+
export const ConnectorActionRefSchema = z.object({
4142
name: z.string().describe('Action name'),
42-
type: z.literal('sms_notification'),
43-
provider: z.enum(['twilio', 'vonage']).describe('SMS provider'),
44-
recipients: z.array(z.string()).describe('List of phone numbers or user field references'),
45-
message: z.string().describe('SMS message text or template'),
46-
fromNumber: z.string().optional().describe('Sender phone number (provider-specific)'),
43+
type: z.literal('connector_action'),
44+
connectorId: z.string().describe('Target Connector ID (e.g. slack, twilio)'),
45+
actionId: z.string().describe('Target Action ID (e.g. send_message)'),
46+
input: z.record(z.string(), z.any()).describe('Input parameters matching the action schema'),
4747
});
4848

4949
/**
50-
* Schema for Workflow Slack Message Action
50+
* Universal Workflow Action Schema
51+
* Union of all supported action types.
5152
*/
52-
export const SlackMessageActionSchema = z.object({
53-
name: z.string().describe('Action name'),
54-
type: z.literal('slack_message'),
55-
channel: z.string().describe('Slack channel ID or name (#channel)'),
56-
message: z.string().describe('Message text with optional markdown'),
57-
mentions: z.array(z.string()).optional().describe('User IDs or @username to mention'),
58-
threadId: z.string().optional().describe('Thread ID for replies'),
59-
});
53+
export const WorkflowActionSchema = z.discriminatedUnion('type', [
54+
FieldUpdateActionSchema,
55+
EmailAlertActionSchema,
56+
HttpCallActionSchema,
57+
WebhookTriggerActionSchema,
58+
ConnectorActionRefSchema,
59+
]);
6060

61-
/**
62-
* Schema for Workflow Teams Message Action
63-
*/
64-
export const TeamsMessageActionSchema = z.object({
65-
name: z.string().describe('Action name'),
66-
type: z.literal('teams_message'),
67-
channel: z.string().describe('Teams channel ID'),
68-
message: z.string().describe('Message text with optional markdown'),
69-
mentions: z.array(z.string()).optional().describe('User IDs to mention'),
70-
teamId: z.string().optional().describe('Team ID (if not in default team)'),
71-
});
61+
export type WorkflowAction = z.infer<typeof WorkflowActionSchema>;
7262

73-
/**
74-
* Schema for Workflow HTTP Call Action
75-
* REST API integration support
76-
*/
77-
export const HttpCallActionSchema = z.object({
78-
name: z.string().describe('Action name'),
79-
type: z.literal('http_call'),
80-
url: z.string().describe('Target URL'),
81-
method: z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']).describe('HTTP method'),
82-
headers: z.record(z.string(), z.string()).optional().describe('Request headers'),
83-
body: z.any().optional().describe('Request body (object/string)'),
84-
authentication: z.object({
85-
type: z.enum(['none', 'basic', 'bearer', 'api_key', 'oauth2']),
86-
credentials: z.record(z.string(), z.string()).optional(),
87-
}).optional().describe('Authentication configuration'),
88-
timeout: z.number().optional().describe('Request timeout in milliseconds'),
89-
});
90-
91-
/**
92-
* Schema for Workflow Webhook Trigger Action
93-
* References the canonical WebhookSchema from automation/webhook.zod.ts
94-
*/
95-
export const WebhookTriggerActionSchema = z.object({
96-
name: z.string().describe('Action name'),
97-
type: z.literal('webhook_trigger'),
98-
config: WebhookSchema.describe('Webhook configuration (references canonical schema)'),
99-
});
10063

10164
/**
10265
* Schema for Workflow Task Creation Action

0 commit comments

Comments
 (0)