()
| 69 | |
| 70 | // Example 3: Workflow validation and status checking |
| 71 | async function statusExample() { |
| 72 | const client = new SimStudioClient({ |
| 73 | apiKey: process.env.SIM_API_KEY!, |
| 74 | }) |
| 75 | |
| 76 | try { |
| 77 | // Check if workflow is ready |
| 78 | const isReady = await client.validateWorkflow('your-workflow-id') |
| 79 | console.log('Workflow ready:', isReady) |
| 80 | |
| 81 | // Get detailed status |
| 82 | const status = await client.getWorkflowStatus('your-workflow-id') |
| 83 | console.log('Status:', { |
| 84 | deployed: status.isDeployed, |
| 85 | needsRedeployment: status.needsRedeployment, |
| 86 | deployedAt: status.deployedAt, |
| 87 | }) |
| 88 | |
| 89 | if (status.isDeployed) { |
| 90 | // Execute the workflow |
| 91 | const result = await client.executeWorkflow('your-workflow-id') |
| 92 | |
| 93 | if (result.success) { |
| 94 | console.log('✅ Workflow executed successfully!') |
| 95 | console.log('Output:', result.output) |
| 96 | } else { |
| 97 | console.log('❌ Workflow failed:', result.error) |
| 98 | } |
| 99 | } |
| 100 | } catch (error) { |
| 101 | if (error instanceof SimStudioError) { |
| 102 | console.error('SDK Error:', error.message, 'Code:', error.code) |
| 103 | } else { |
| 104 | console.error('Unexpected error:', error) |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | // Example 4: Workflow execution with streaming |
| 110 | async function streamingExample() { |
no test coverage detected