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

Function coerceArray

apps/sim/tools/whatsapp/send_interactive.ts:10–17  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

8} from '@/tools/whatsapp/utils'
9
10function coerceArray(value: unknown): unknown[] | undefined {
11 if (value == null || value === '') return undefined
12 const parsed = typeof value === 'string' ? (JSON.parse(value) as unknown) : value
13 if (!Array.isArray(parsed)) {
14 throw new Error('Interactive buttons and sections must be JSON arrays')
15 }
16 return parsed.length > 0 ? parsed : undefined
17}
18
19export const sendInteractiveTool: ToolConfig<WhatsAppSendInteractiveParams, WhatsAppSendResponse> =
20 {

Callers 1

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected