mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
Added starter block with options; added nesting ability for subblock config
This commit is contained in:
@@ -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',
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
@@ -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' },
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -81,6 +81,10 @@ export interface SubBlockConfig {
|
||||
condition?: {
|
||||
field: string
|
||||
value: string | number | boolean
|
||||
and?: {
|
||||
field: string
|
||||
value: string | number | boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user