diff --git a/apps/sim/lib/workflows/triggers.ts b/apps/sim/lib/workflows/triggers.ts index f8825a06cf..e502671774 100644 --- a/apps/sim/lib/workflows/triggers.ts +++ b/apps/sim/lib/workflows/triggers.ts @@ -1,4 +1,5 @@ import { getBlock } from '@/blocks' +import type { BlockState } from '@/stores/workflows/workflow/types' /** * Unified trigger type definitions @@ -62,14 +63,9 @@ const START_CONFLICT_TYPES: TriggerType[] = [ TRIGGER_TYPES.STARTER, // Legacy starter also conflicts with start_trigger ] -type BlockWithType = { type: string; subBlocks?: Record | undefined } +type MinimalBlock = { type: string; subBlocks?: Record | undefined } -type BlockWithMetadata = BlockWithType & { - category?: string - triggers?: { enabled?: boolean } -} - -export interface StartBlockCandidate { +export interface StartBlockCandidate { blockId: string block: T path: StartBlockPath @@ -108,20 +104,18 @@ export function classifyStartBlockType( } } -export function classifyStartBlock(block: T): StartBlockPath | null { - const blockWithMetadata = block as BlockWithMetadata +export function classifyStartBlock(block: T): StartBlockPath | null { + const blockState = block as Partial // Try to get metadata from the block itself first - let category = blockWithMetadata.category - let triggerModeEnabled = Boolean(blockWithMetadata.triggers?.enabled) + let category: string | undefined + const triggerModeEnabled = Boolean(blockState.triggerMode) // If not available on the block, fetch from registry - if (!category || triggerModeEnabled === undefined) { - const blockConfig = getBlock(block.type) - if (blockConfig) { - category = category || blockConfig.category - triggerModeEnabled = triggerModeEnabled || Boolean(blockConfig.triggers?.enabled) - } + const blockConfig = getBlock(block.type) + + if (blockConfig) { + category = blockConfig.category } return classifyStartBlockType(block.type, { category, triggerModeEnabled }) @@ -131,7 +125,7 @@ export function isLegacyStartPath(path: StartBlockPath): boolean { return path !== StartBlockPath.UNIFIED } -function toEntries(blocks: Record | T[]): Array<[string, T]> { +function toEntries(blocks: Record | T[]): Array<[string, T]> { if (Array.isArray(blocks)) { return blocks.map((block, index) => { const potentialId = (block as { id?: unknown }).id @@ -169,7 +163,7 @@ function supportsExecution(path: StartBlockPath, execution: StartExecutionKind): ) } -export function resolveStartCandidates( +export function resolveStartCandidates( blocks: Record | T[], options: ResolveStartOptions ): StartBlockCandidate[] {