Added starter block with options; added nesting ability for subblock config

This commit is contained in:
Emir Karabeg
2025-02-14 12:43:26 -08:00
parent deea02099b
commit 0aeeb65bc6
6 changed files with 308 additions and 59 deletions
-38
View File
@@ -1,38 +0,0 @@
import { InputIcon } from '@/components/icons'
import { BlockConfig } from '../types'
export const InputBlock: BlockConfig = {
type: 'input',
toolbar: {
title: 'Input',
description: 'Add workflow input',
bgColor: '#2FB3FF',
icon: InputIcon,
category: 'blocks',
},
tools: {
access: [],
},
workflow: {
inputs: {
code: { type: 'string', required: true },
},
outputs: {
response: {
type: {
result: 'any',
stdout: 'string',
executionTime: 'number',
},
},
},
subBlocks: [
{
title: 'Input',
id: 'input',
type: 'short-input',
layout: 'full',
},
],
},
}
+252
View File
@@ -0,0 +1,252 @@
import { StartIcon } from '@/components/icons'
import { BlockConfig } from '../types'
export const StarterBlock: BlockConfig = {
type: 'starter',
toolbar: {
title: 'Starter',
description: 'Start workflow',
bgColor: '#2FB3FF',
icon: StartIcon,
category: 'blocks',
},
tools: {
access: [],
},
workflow: {
inputs: {
code: { type: 'string', required: true },
executionMode: { type: 'string', required: true },
},
outputs: {
response: {
type: {
result: 'any',
stdout: 'string',
executionTime: 'number',
},
},
},
subBlocks: [
// Main trigger selector
{
id: 'startWorkflow',
title: 'Start Workflow',
type: 'dropdown',
layout: 'full',
options: [
{ label: 'Run manually', id: 'manual' },
{ label: 'On webhook call', id: 'webhook' },
{ label: 'On schedule', id: 'schedule' },
],
value: () => 'manual',
},
// Webhook configuration
{
id: 'webhookPath',
title: 'Webhook Path',
type: 'short-input',
layout: 'full',
placeholder: 'Enter webhook path (e.g., /my-webhook)',
condition: { field: 'startWorkflow', value: 'webhook' },
},
{
id: 'webhookSecret',
title: 'Webhook Secret',
type: 'short-input',
layout: 'full',
placeholder: 'Enter a secret key for webhook security',
password: true,
condition: { field: 'startWorkflow', value: 'webhook' },
},
// Schedule configuration
{
id: 'scheduleType',
title: 'Frequency',
type: 'dropdown',
layout: 'full',
options: [
{ label: 'Every X Minutes', id: 'minutes' },
{ label: 'Hourly', id: 'hourly' },
{ label: 'Daily', id: 'daily' },
{ label: 'Weekly', id: 'weekly' },
{ label: 'Monthly', id: 'monthly' },
{ label: 'Custom Cron', id: 'custom' },
],
value: () => 'daily',
condition: { field: 'startWorkflow', value: 'schedule' },
},
// Minutes schedule options
{
id: 'minutesInterval',
title: 'Run Every',
type: 'short-input',
layout: 'full',
placeholder: '15 minutes',
condition: {
field: 'scheduleType',
value: 'minutes',
and: {
field: 'startWorkflow',
value: 'schedule',
},
},
},
{
id: 'minutesStartingAt',
title: 'Starting At',
type: 'short-input',
layout: 'full',
placeholder: '09:00',
condition: {
field: 'scheduleType',
value: 'minutes',
and: {
field: 'startWorkflow',
value: 'schedule',
},
},
},
// Hourly schedule options
{
id: 'hourlyMinute',
title: 'Start at Minute',
type: 'short-input',
layout: 'full',
placeholder: '00',
condition: {
field: 'scheduleType',
value: 'hourly',
and: {
field: 'startWorkflow',
value: 'schedule',
},
},
},
// Daily schedule options
{
id: 'dailyTime',
title: 'Time',
type: 'short-input',
layout: 'full',
placeholder: '09:00',
condition: {
field: 'scheduleType',
value: 'daily',
and: {
field: 'startWorkflow',
value: 'schedule',
},
},
},
// Weekly schedule options
{
id: 'weeklyDay',
title: 'Day of Week',
type: 'dropdown',
layout: 'half',
options: [
{ label: 'Monday', id: 'MON' },
{ label: 'Tuesday', id: 'TUE' },
{ label: 'Wednesday', id: 'WED' },
{ label: 'Thursday', id: 'THU' },
{ label: 'Friday', id: 'FRI' },
{ label: 'Saturday', id: 'SAT' },
{ label: 'Sunday', id: 'SUN' },
],
value: () => 'MON',
condition: {
field: 'scheduleType',
value: 'weekly',
and: {
field: 'startWorkflow',
value: 'schedule',
},
},
},
{
id: 'weeklyDayTime',
title: 'Time',
type: 'short-input',
layout: 'half',
placeholder: '09:00',
condition: {
field: 'scheduleType',
value: 'weekly',
and: {
field: 'startWorkflow',
value: 'schedule',
},
},
},
// Monthly schedule options
{
id: 'monthlyDay',
title: 'Day of Month',
type: 'short-input',
layout: 'half',
placeholder: '1',
condition: {
field: 'scheduleType',
value: 'monthly',
and: {
field: 'startWorkflow',
value: 'schedule',
},
},
},
{
id: 'monthlyTime',
title: 'Time',
type: 'short-input',
layout: 'half',
placeholder: '09:00',
condition: {
field: 'scheduleType',
value: 'monthly',
and: {
field: 'startWorkflow',
value: 'schedule',
},
},
},
// Custom cron options
{
id: 'cronExpression',
title: 'Cron Expression',
type: 'short-input',
layout: 'full',
placeholder: '*/15 * * * *',
condition: {
field: 'scheduleType',
value: 'custom',
and: {
field: 'startWorkflow',
value: 'schedule',
},
},
},
// Timezone configuration (for all schedule types)
{
id: 'timezone',
title: 'Timezone',
type: 'dropdown',
layout: 'full',
options: [
{ label: 'UTC', id: 'UTC' },
{ label: 'US Eastern (UTC-4)', id: 'America/New_York' },
{ label: 'US Central (UTC-5)', id: 'America/Chicago' },
{ label: 'US Mountain (UTC-6)', id: 'America/Denver' },
{ label: 'US Pacific (UTC-7)', id: 'America/Los_Angeles' },
{ label: 'London (UTC+1)', id: 'Europe/London' },
{ label: 'Paris (UTC+2)', id: 'Europe/Paris' },
{ label: 'Singapore (UTC+8)', id: 'Asia/Singapore' },
{ label: 'Tokyo (UTC+9)', id: 'Asia/Tokyo' },
{ label: 'Sydney (UTC+10)', id: 'Australia/Sydney' },
],
value: () => 'UTC',
condition: { field: 'startWorkflow', value: 'schedule' },
},
],
},
}
+3
View File
@@ -13,6 +13,7 @@ import { NotionBlock } from './blocks/notion'
import { RouterBlock } from './blocks/router'
import { SerperBlock } from './blocks/serper'
import { SlackMessageBlock } from './blocks/slack'
import { StarterBlock } from './blocks/starter'
import { TavilyBlock } from './blocks/tavily'
import { TranslateBlock } from './blocks/translate'
import { XBlock } from './blocks/x'
@@ -39,12 +40,14 @@ export {
NotionBlock,
GmailBlock,
XBlock,
StarterBlock,
}
// Registry of all block configurations
const blocks: Record<string, BlockConfig> = {
agent: AgentBlock,
api: ApiBlock,
starter: StarterBlock,
condition: ConditionBlock,
function: FunctionBlock,
router: RouterBlock,
+4
View File
@@ -81,6 +81,10 @@ export interface SubBlockConfig {
condition?: {
field: string
value: string | number | boolean
and?: {
field: string
value: string | number | boolean
}
}
}