t18-envelope-probe.mjs 1.5 KB

12345678910111213141516171819202122232425262728293031
  1. import { fetchBaseArchives } from '../../../src/modules/cockpit/services/infrastructureApi.js'
  2. import { fetchMapSnapshot } from '../../../src/modules/cockpit/services/mapApi.js'
  3. import { requestCockpitJson } from '../../../src/modules/cockpit/services/cockpitApi.js'
  4. const base = 'http://192.168.110.96:8301/api/cockpit/v1'
  5. const config = { dataSource: 'real', api: { baseUrl: base } }
  6. const raw = await requestCockpitJson('/infrastructure/base-archives', { config })
  7. console.log('--- requestCockpitJson 原始返回 ---')
  8. console.log(JSON.stringify({
  9. ok: raw.ok, status: raw.status, mode: raw.mode,
  10. payloadTopLevelKeys: Object.keys(raw.data || {}),
  11. hasTotals: !!(raw.data && raw.data.totals),
  12. totalsFacilityCount: raw.data && raw.data.totals && raw.data.totals.facilityCount,
  13. }, null, 2))
  14. const section = await fetchBaseArchives({ config })
  15. console.log('--- fetchBaseArchives 分区结果 ---')
  16. console.log(JSON.stringify({
  17. state: section.state, reason: section.reason, mode: section.mode,
  18. facilityCount: section.data && section.data.facilityCount,
  19. dataKeys: section.data ? Object.keys(section.data) : null,
  20. missing: section.data ? section.data.missing : null,
  21. }, null, 2))
  22. const map = await fetchMapSnapshot({ config, pageSize: 1000 })
  23. console.log('--- fetchMapSnapshot 分区结果 ---')
  24. console.log(JSON.stringify({
  25. state: map.state, total: map.data && map.data.total, snapshotAt: map.data && map.data.snapshotAt,
  26. objectCount: map.data && map.data.objects ? map.data.objects.length : null,
  27. }, null, 2))