( blockConfig: BlockConfig, blockId: string )
| 61 | } |
| 62 | |
| 63 | function buildStartBlockState( |
| 64 | blockConfig: BlockConfig, |
| 65 | blockId: string |
| 66 | ): { blockState: BlockState; subBlockValues: Record<string, unknown> } { |
| 67 | const subBlocks: Record<string, SubBlockState> = {} |
| 68 | const subBlockValues: Record<string, unknown> = {} |
| 69 | |
| 70 | blockConfig.subBlocks.forEach((config) => { |
| 71 | const initialValue = resolveInitialValue(config) |
| 72 | |
| 73 | subBlocks[config.id] = { |
| 74 | id: config.id, |
| 75 | type: config.type, |
| 76 | value: (initialValue ?? null) as SubBlockState['value'], |
| 77 | } |
| 78 | |
| 79 | subBlockValues[config.id] = initialValue ?? null |
| 80 | }) |
| 81 | |
| 82 | const outputs = getEffectiveBlockOutputs(blockConfig.type, subBlocks, { |
| 83 | triggerMode: false, |
| 84 | preferToolOutputs: true, |
| 85 | }) |
| 86 | |
| 87 | const blockState: BlockState = { |
| 88 | id: blockId, |
| 89 | type: blockConfig.type, |
| 90 | name: blockConfig.name, |
| 91 | position: { ...DEFAULT_START_POSITION }, |
| 92 | subBlocks, |
| 93 | outputs, |
| 94 | enabled: true, |
| 95 | horizontalHandles: true, |
| 96 | advancedMode: false, |
| 97 | triggerMode: false, |
| 98 | height: 0, |
| 99 | data: {}, |
| 100 | locked: false, |
| 101 | } |
| 102 | |
| 103 | return { blockState, subBlockValues } |
| 104 | } |
| 105 | |
| 106 | export function buildDefaultWorkflowArtifacts(): DefaultWorkflowArtifacts { |
| 107 | const blockConfig = buildStartBlockConfig() |
no test coverage detected