MCPcopy Index your code
hub / github.com/simstudioai/sim / resolveExecutorStartBlock

Function resolveExecutorStartBlock

apps/sim/executor/utils/start-block.ts:44–86  ·  view source on GitHub ↗
(
  blocks: SerializedBlock[],
  options: ResolveExecutorStartOptions
)

Source from the content-addressed store, hash-verified

42}
43
44export function resolveExecutorStartBlock(
45 blocks: SerializedBlock[],
46 options: ResolveExecutorStartOptions
47): ExecutorStartResolution | null {
48 if (blocks.length === 0) {
49 return null
50 }
51
52 const blockMap = blocks.reduce<Record<string, StartCandidateWrapper>>((acc, block) => {
53 const type = block.metadata?.id
54 if (!type) {
55 return acc
56 }
57
58 acc[block.id] = {
59 type,
60 subBlocks: extractSubBlocks(block),
61 original: block,
62 }
63
64 return acc
65 }, {})
66
67 const candidates = resolveStartCandidates(blockMap, {
68 execution: options.execution,
69 isChildWorkflow: options.isChildWorkflow,
70 })
71
72 if (candidates.length === 0) {
73 return null
74 }
75
76 if (options.isChildWorkflow && candidates.length > 1) {
77 throw new Error('Child workflow has multiple trigger blocks. Keep only one Start block.')
78 }
79
80 const [primary] = candidates
81 return {
82 blockId: primary.blockId,
83 block: primary.block.original,
84 path: primary.path,
85 }
86}
87
88export function buildResolutionFromBlock(block: SerializedBlock): ExecutorStartResolution | null {
89 const type = block.metadata?.id

Callers 2

Calls 2

resolveStartCandidatesFunction · 0.90
extractSubBlocksFunction · 0.85

Tested by

no test coverage detected