const fs = require('fs'); async function main() { const tokenData = JSON.parse(fs.readFileSync('D:/cumin/ghaymah_dns_net_sec_tests/token.json', 'utf8')); const topology = JSON.parse(fs.readFileSync('D:/cumin/ghaymah_dns_net_sec_tests/soc_project_topology.json', 'utf8')); const resourceIds = [ topology.projectId, topology.services.redis.id, topology.services.backend.id, topology.services.gateway.id, topology.services.tester.id ]; console.log('Monitoring deployment status for project:', topology.projectName); for (let attempt = 1; attempt <= 20; attempt++) { const res = await fetch('https://graphql.ghaymah.systems/v1/graphql', { method: 'POST', headers: { 'Authorization': 'Bearer ' + tokenData.token, 'Content-Type': 'application/json' }, body: JSON.stringify({ query: `query CheckResources($ids: [uuid!]!) { ghaymah_cloud_resources(where: { id: { _in: $ids } }) { id chart_name status values message } }`, variables: { ids: resourceIds } }) }); const data = await res.json(); const list = data.data?.ghaymah_cloud_resources || []; const statusMap = {}; list.forEach(r => { const name = r.values?.name || r.chart_name; statusMap[name] = r.status; }); console.log(`[Attempt ${attempt}/20] Status:`, JSON.stringify(statusMap)); const allSynced = list.length === 5 && list.every(r => r.status === 'synced'); if (allSynced) { console.log('>>> ALL 5 RESOURCES ARE SYNCED AND READY! <<<'); return true; } const anyFailed = list.some(r => r.status === 'failed' || r.status === 'error'); if (anyFailed) { console.log('>>> Warning: Some resources failed:', list.filter(r => r.status === 'failed' || r.status === 'error')); } await new Promise(r => setTimeout(r, 4000)); } console.log('Timed out waiting for sync'); } main().catch(console.error);