MCPcopy
hub / github.com/simstudioai/sim / createBlock

Function createBlock

packages/testing/src/factories/block.factory.ts:51–76  ·  view source on GitHub ↗
(options: BlockFactoryOptions = {})

Source from the content-addressed store, hash-verified

49 * ```
50 */
51export function createBlock(options: BlockFactoryOptions = {}): any {
52 const id = options.id ?? generateBlockId(options.type ?? 'block')
53
54 const data: BlockData = options.data ?? {}
55 if (options.parentId) {
56 data.parentId = options.parentId
57 data.extent = 'parent'
58 }
59
60 return {
61 id,
62 type: options.type ?? 'function',
63 name: options.name ?? `Block ${id.substring(0, 8)}`,
64 position: options.position ?? { x: 0, y: 0 },
65 subBlocks: options.subBlocks ?? {},
66 outputs: options.outputs ?? {},
67 enabled: options.enabled ?? true,
68 horizontalHandles: options.horizontalHandles ?? true,
69 height: options.height ?? 0,
70 advancedMode: options.advancedMode ?? false,
71 triggerMode: options.triggerMode ?? false,
72 locked: options.locked ?? false,
73 data: Object.keys(data).length > 0 ? data : undefined,
74 layout: {},
75 }
76}
77
78/**
79 * Creates a starter block (workflow entry point).

Callers 15

createBranchingWorkflowFunction · 0.90
createLoopWorkflowFunction · 0.90
createParallelWorkflowFunction · 0.90
addBlockMethod · 0.90
addConditionMethod · 0.90
addLoopMethod · 0.90
addLoopChildMethod · 0.90
addParallelMethod · 0.90
addParallelChildMethod · 0.90
store.test.tsFile · 0.90
utils.test.tsFile · 0.90
compare.test.tsFile · 0.90

Calls 1

generateBlockIdFunction · 0.70

Tested by

no test coverage detected