()
| 29 | |
| 30 | // Example 2: Workflow execution with input data |
| 31 | async function withInputExample() { |
| 32 | const client = new SimStudioClient({ |
| 33 | apiKey: process.env.SIM_API_KEY!, |
| 34 | }) |
| 35 | |
| 36 | try { |
| 37 | const result = await client.executeWorkflow('your-workflow-id', { |
| 38 | input: { |
| 39 | message: 'Hello from SDK!', |
| 40 | userId: '12345', |
| 41 | data: { |
| 42 | type: 'analysis', |
| 43 | parameters: { |
| 44 | includeMetadata: true, |
| 45 | format: 'json', |
| 46 | }, |
| 47 | }, |
| 48 | }, |
| 49 | timeout: 60000, // 60 seconds |
| 50 | }) |
| 51 | |
| 52 | if (result.success) { |
| 53 | console.log('✅ Workflow executed successfully!') |
| 54 | console.log('Output:', result.output) |
| 55 | if (result.metadata?.duration) { |
| 56 | console.log('Duration:', result.metadata.duration, 'ms') |
| 57 | } |
| 58 | } else { |
| 59 | console.log('❌ Workflow failed:', result.error) |
| 60 | } |
| 61 | } catch (error) { |
| 62 | if (error instanceof SimStudioError) { |
| 63 | console.error('SDK Error:', error.message, 'Code:', error.code) |
| 64 | } else { |
| 65 | console.error('Unexpected error:', error) |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | // Example 3: Workflow validation and status checking |
| 71 | async function statusExample() { |
no test coverage detected