bunqueue-dashboard 0.0.16 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/agent/index.ts +8 -3
  2. package/agent/manager.ts +4 -2
  3. package/agent/server.ts +66 -2
  4. package/dist/.vite/manifest.json +63 -63
  5. package/dist/assets/{AddJob-CMIT6e17.js → AddJob-vk3jh1Zk.js} +2 -2
  6. package/dist/assets/Benchmark-CpViF2ZC.js +1 -0
  7. package/dist/assets/{CopilotPanel-BDZzDmVy.js → CopilotPanel-C9ojQ_8d.js} +3 -3
  8. package/dist/assets/{CopyButton-XT7ykzf5.js → CopyButton-BC6QECSJ.js} +1 -1
  9. package/dist/assets/{Cron-9hndZ-Z5.js → Cron-Bbf7mRaK.js} +1 -1
  10. package/dist/assets/{CronManager-BQupx6wZ.js → CronManager-CeNUeoOc.js} +1 -1
  11. package/dist/assets/Database--bK9pYZF.js +3 -0
  12. package/dist/assets/{Diagnostics-BzVDq9CH.js → Diagnostics-CGJPsWZQ.js} +1 -1
  13. package/dist/assets/Dlq-Bs1pupY2.js +1 -0
  14. package/dist/assets/{DlqControl-Cu2i1oq5.js → DlqControl-BLKVzYQC.js} +1 -1
  15. package/dist/assets/{DlqPro-HBrCftLD.js → DlqPro-D8SmIQUs.js} +1 -1
  16. package/dist/assets/{Flows-D3Bvkmd6.js → Flows-BOogljnP.js} +1 -1
  17. package/dist/assets/{JobInspector-B7zEuFhM.js → JobInspector-Cp4ZuQGI.js} +2 -2
  18. package/dist/assets/Jobs-C2HYkZXi.js +1 -0
  19. package/dist/assets/JobsPro-D0uclU0B.js +1 -0
  20. package/dist/assets/Logs-yn92V_T8.js +1 -0
  21. package/dist/assets/{LogsPro-P73LCkap.js → LogsPro-DSiV8Ajj.js} +1 -1
  22. package/dist/assets/{McpServer-CUK20-uN.js → McpServer-CNt7kssG.js} +2 -2
  23. package/dist/assets/{Metrics-BodjiKpf.js → Metrics-CbscCpvx.js} +1 -1
  24. package/dist/assets/MetricsPro-CBiFDVne.js +1 -0
  25. package/dist/assets/Overview-BOuOPWsb.js +1 -0
  26. package/dist/assets/{Pagination-Cd6lHj2E.js → Pagination-Bj1z6OlD.js} +1 -1
  27. package/dist/assets/QueueControl-Bl4l9dT6.js +1 -0
  28. package/dist/assets/QueueDetail-BSUH0Nl6.js +1 -0
  29. package/dist/assets/{Queues-LrodynCj.js → Queues-BEQlaWVc.js} +1 -1
  30. package/dist/assets/{QueuesOverview-DrYjyped.js → QueuesOverview-BBjcyzz2.js} +1 -1
  31. package/dist/assets/{S3Backup-et1PcCC0.js → S3Backup-BmRt-Z8V.js} +1 -1
  32. package/dist/assets/S3BackupPro-Dsq0erDm.js +1 -0
  33. package/dist/assets/ServerControl-Bhr9FEXF.js +3 -0
  34. package/dist/assets/Settings-46jsrfhd.js +1 -0
  35. package/dist/assets/{Usage-CHCg6VNy.js → Usage-BFLZC7pV.js} +1 -1
  36. package/dist/assets/{UsagePro-Cto9k5OI.js → UsagePro-D0k-82eG.js} +1 -1
  37. package/dist/assets/{Webhooks-Cm3vZEp7.js → Webhooks-DChTcBSv.js} +1 -1
  38. package/dist/assets/Workers-DBXrLvfS.js +1 -0
  39. package/dist/assets/{WorkersPro-BidtV_Bp.js → WorkersPro-B6I9Ilbq.js} +1 -1
  40. package/dist/assets/{connectionStore-DI-LYcct.js → connectionStore-CCopJeU7.js} +1 -1
  41. package/dist/assets/index-BFjeS9FG.js +8 -0
  42. package/dist/assets/{install-BvB40Zk0.js → install-C019EM5j.js} +2 -2
  43. package/dist/index.html +2 -2
  44. package/package.json +12 -10
  45. package/scripts/embedded.gen.ts +95 -94
  46. package/scripts/serve.ts +34 -2
  47. package/dist/assets/Benchmark-Dq1-vJ2k.js +0 -1
  48. package/dist/assets/Database-Difs7xYV.js +0 -3
  49. package/dist/assets/Dlq-BCUVh_NO.js +0 -1
  50. package/dist/assets/Jobs-ovYRwmwi.js +0 -1
  51. package/dist/assets/JobsPro-DNZivuzq.js +0 -1
  52. package/dist/assets/Logs-CjM7MNYN.js +0 -1
  53. package/dist/assets/MetricsPro-CqcH6gJp.js +0 -1
  54. package/dist/assets/Overview-AwCA3XI2.js +0 -1
  55. package/dist/assets/QueueControl-D7J1JObu.js +0 -1
  56. package/dist/assets/QueueDetail-BtiN0s3b.js +0 -1
  57. package/dist/assets/S3BackupPro-BEo_EVAO.js +0 -1
  58. package/dist/assets/ServerControl-BRLFRj7k.js +0 -3
  59. package/dist/assets/Settings-CeRZgZU6.js +0 -1
  60. package/dist/assets/Workers-CVfx3TK-.js +0 -1
  61. package/dist/assets/index-C9fPU4bV.js +0 -8
@@ -1,106 +1,107 @@
1
+ // @ts-nocheck
1
2
  // AUTO-GENERATED by scripts/gen-embed.ts — do not edit, not committed.
2
3
  import f0 from "../dist/.vite/manifest.json" with { type: 'file' };
3
4
  import f1 from "../dist/favicon.svg" with { type: 'file' };
4
- import f2 from "../dist/assets/LogsPro-P73LCkap.js" with { type: 'file' };
5
- import f3 from "../dist/assets/AddJob-CMIT6e17.js" with { type: 'file' };
6
- import f4 from "../dist/assets/DlqControl-Cu2i1oq5.js" with { type: 'file' };
5
+ import f2 from "../dist/assets/Overview-BOuOPWsb.js" with { type: 'file' };
6
+ import f3 from "../dist/assets/index-BFjeS9FG.js" with { type: 'file' };
7
+ import f4 from "../dist/assets/Workers-DBXrLvfS.js" with { type: 'file' };
7
8
  import f5 from "../dist/assets/AreaChart-DzUXW8u3.js" with { type: 'file' };
8
- import f6 from "../dist/assets/Overview-AwCA3XI2.js" with { type: 'file' };
9
- import f7 from "../dist/assets/QueuesOverview-DrYjyped.js" with { type: 'file' };
10
- import f8 from "../dist/assets/index-BWY8Yofc.css" with { type: 'file' };
11
- import f9 from "../dist/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2" with { type: 'file' };
12
- import f10 from "../dist/assets/S3Backup-et1PcCC0.js" with { type: 'file' };
13
- import f11 from "../dist/assets/Logs-CjM7MNYN.js" with { type: 'file' };
14
- import f12 from "../dist/assets/CronManager-BQupx6wZ.js" with { type: 'file' };
15
- import f13 from "../dist/assets/JobInspector-B7zEuFhM.js" with { type: 'file' };
16
- import f14 from "../dist/assets/Dlq-BCUVh_NO.js" with { type: 'file' };
17
- import f15 from "../dist/assets/form-PtDLk33Z.js" with { type: 'file' };
18
- import f16 from "../dist/assets/DlqPro-HBrCftLD.js" with { type: 'file' };
19
- import f17 from "../dist/assets/index-C9fPU4bV.js" with { type: 'file' };
20
- import f18 from "../dist/assets/Diagnostics-BzVDq9CH.js" with { type: 'file' };
21
- import f19 from "../dist/assets/Pagination-Cd6lHj2E.js" with { type: 'file' };
22
- import f20 from "../dist/assets/CopilotPanel-BDZzDmVy.js" with { type: 'file' };
23
- import f21 from "../dist/assets/Jobs-ovYRwmwi.js" with { type: 'file' };
24
- import f22 from "../dist/assets/JobsPro-DNZivuzq.js" with { type: 'file' };
25
- import f23 from "../dist/assets/Cron-9hndZ-Z5.js" with { type: 'file' };
26
- import f24 from "../dist/assets/CopyButton-XT7ykzf5.js" with { type: 'file' };
27
- import f25 from "../dist/assets/react-vendor-CHIHtdAC.js" with { type: 'file' };
28
- import f26 from "../dist/assets/WorkersPro-BidtV_Bp.js" with { type: 'file' };
29
- import f27 from "../dist/assets/MetricsPro-CqcH6gJp.js" with { type: 'file' };
30
- import f28 from "../dist/assets/jobActions-CuOdMglt.js" with { type: 'file' };
31
- import f29 from "../dist/assets/Queues-LrodynCj.js" with { type: 'file' };
32
- import f30 from "../dist/assets/connectionStore-DI-LYcct.js" with { type: 'file' };
33
- import f31 from "../dist/assets/McpServer-CUK20-uN.js" with { type: 'file' };
34
- import f32 from "../dist/assets/Usage-CHCg6VNy.js" with { type: 'file' };
35
- import f33 from "../dist/assets/Settings-CeRZgZU6.js" with { type: 'file' };
36
- import f34 from "../dist/assets/cn-CMFYpumL.js" with { type: 'file' };
37
- import f35 from "../dist/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2" with { type: 'file' };
38
- import f36 from "../dist/assets/Webhooks-Cm3vZEp7.js" with { type: 'file' };
39
- import f37 from "../dist/assets/S3BackupPro-BEo_EVAO.js" with { type: 'file' };
40
- import f38 from "../dist/assets/ServerControl-BRLFRj7k.js" with { type: 'file' };
41
- import f39 from "../dist/assets/Workers-CVfx3TK-.js" with { type: 'file' };
42
- import f40 from "../dist/assets/QueueDetail-BtiN0s3b.js" with { type: 'file' };
43
- import f41 from "../dist/assets/Database-Difs7xYV.js" with { type: 'file' };
44
- import f42 from "../dist/assets/UsagePro-Cto9k5OI.js" with { type: 'file' };
45
- import f43 from "../dist/assets/QueueControl-D7J1JObu.js" with { type: 'file' };
46
- import f44 from "../dist/assets/Metrics-BodjiKpf.js" with { type: 'file' };
47
- import f45 from "../dist/assets/inter-latin-wght-normal-Dx4kXJAl.woff2" with { type: 'file' };
48
- import f46 from "../dist/assets/install-BvB40Zk0.js" with { type: 'file' };
49
- import f47 from "../dist/assets/Flows-D3Bvkmd6.js" with { type: 'file' };
50
- import f48 from "../dist/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2" with { type: 'file' };
51
- import f49 from "../dist/assets/Benchmark-Dq1-vJ2k.js" with { type: 'file' };
9
+ import f6 from "../dist/assets/install-C019EM5j.js" with { type: 'file' };
10
+ import f7 from "../dist/assets/index-BWY8Yofc.css" with { type: 'file' };
11
+ import f8 from "../dist/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2" with { type: 'file' };
12
+ import f9 from "../dist/assets/McpServer-CNt7kssG.js" with { type: 'file' };
13
+ import f10 from "../dist/assets/QueuesOverview-BBjcyzz2.js" with { type: 'file' };
14
+ import f11 from "../dist/assets/Metrics-CbscCpvx.js" with { type: 'file' };
15
+ import f12 from "../dist/assets/AddJob-vk3jh1Zk.js" with { type: 'file' };
16
+ import f13 from "../dist/assets/DlqControl-BLKVzYQC.js" with { type: 'file' };
17
+ import f14 from "../dist/assets/form-PtDLk33Z.js" with { type: 'file' };
18
+ import f15 from "../dist/assets/Logs-yn92V_T8.js" with { type: 'file' };
19
+ import f16 from "../dist/assets/Usage-BFLZC7pV.js" with { type: 'file' };
20
+ import f17 from "../dist/assets/react-vendor-CHIHtdAC.js" with { type: 'file' };
21
+ import f18 from "../dist/assets/Webhooks-DChTcBSv.js" with { type: 'file' };
22
+ import f19 from "../dist/assets/QueueControl-Bl4l9dT6.js" with { type: 'file' };
23
+ import f20 from "../dist/assets/CopilotPanel-C9ojQ_8d.js" with { type: 'file' };
24
+ import f21 from "../dist/assets/jobActions-CuOdMglt.js" with { type: 'file' };
25
+ import f22 from "../dist/assets/Benchmark-CpViF2ZC.js" with { type: 'file' };
26
+ import f23 from "../dist/assets/connectionStore-CCopJeU7.js" with { type: 'file' };
27
+ import f24 from "../dist/assets/WorkersPro-B6I9Ilbq.js" with { type: 'file' };
28
+ import f25 from "../dist/assets/Queues-BEQlaWVc.js" with { type: 'file' };
29
+ import f26 from "../dist/assets/QueueDetail-BSUH0Nl6.js" with { type: 'file' };
30
+ import f27 from "../dist/assets/Diagnostics-CGJPsWZQ.js" with { type: 'file' };
31
+ import f28 from "../dist/assets/S3Backup-BmRt-Z8V.js" with { type: 'file' };
32
+ import f29 from "../dist/assets/ServerControl-Bhr9FEXF.js" with { type: 'file' };
33
+ import f30 from "../dist/assets/Flows-BOogljnP.js" with { type: 'file' };
34
+ import f31 from "../dist/assets/CopyButton-BC6QECSJ.js" with { type: 'file' };
35
+ import f32 from "../dist/assets/cn-CMFYpumL.js" with { type: 'file' };
36
+ import f33 from "../dist/assets/LogsPro-DSiV8Ajj.js" with { type: 'file' };
37
+ import f34 from "../dist/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2" with { type: 'file' };
38
+ import f35 from "../dist/assets/MetricsPro-CBiFDVne.js" with { type: 'file' };
39
+ import f36 from "../dist/assets/S3BackupPro-Dsq0erDm.js" with { type: 'file' };
40
+ import f37 from "../dist/assets/Cron-Bbf7mRaK.js" with { type: 'file' };
41
+ import f38 from "../dist/assets/JobsPro-D0uclU0B.js" with { type: 'file' };
42
+ import f39 from "../dist/assets/UsagePro-D0k-82eG.js" with { type: 'file' };
43
+ import f40 from "../dist/assets/Jobs-C2HYkZXi.js" with { type: 'file' };
44
+ import f41 from "../dist/assets/DlqPro-D8SmIQUs.js" with { type: 'file' };
45
+ import f42 from "../dist/assets/Pagination-Bj1z6OlD.js" with { type: 'file' };
46
+ import f43 from "../dist/assets/JobInspector-Cp4ZuQGI.js" with { type: 'file' };
47
+ import f44 from "../dist/assets/CronManager-CeNUeoOc.js" with { type: 'file' };
48
+ import f45 from "../dist/assets/Settings-46jsrfhd.js" with { type: 'file' };
49
+ import f46 from "../dist/assets/inter-latin-wght-normal-Dx4kXJAl.woff2" with { type: 'file' };
50
+ import f47 from "../dist/assets/Dlq-Bs1pupY2.js" with { type: 'file' };
51
+ import f48 from "../dist/assets/Database--bK9pYZF.js" with { type: 'file' };
52
+ import f49 from "../dist/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2" with { type: 'file' };
52
53
  import f50 from "../dist/index.html" with { type: 'file' };
53
54
 
54
55
  export const ASSETS: Record<string, string> = {
55
56
  "/.vite/manifest.json": f0,
56
57
  "/favicon.svg": f1,
57
- "/assets/LogsPro-P73LCkap.js": f2,
58
- "/assets/AddJob-CMIT6e17.js": f3,
59
- "/assets/DlqControl-Cu2i1oq5.js": f4,
58
+ "/assets/Overview-BOuOPWsb.js": f2,
59
+ "/assets/index-BFjeS9FG.js": f3,
60
+ "/assets/Workers-DBXrLvfS.js": f4,
60
61
  "/assets/AreaChart-DzUXW8u3.js": f5,
61
- "/assets/Overview-AwCA3XI2.js": f6,
62
- "/assets/QueuesOverview-DrYjyped.js": f7,
63
- "/assets/index-BWY8Yofc.css": f8,
64
- "/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2": f9,
65
- "/assets/S3Backup-et1PcCC0.js": f10,
66
- "/assets/Logs-CjM7MNYN.js": f11,
67
- "/assets/CronManager-BQupx6wZ.js": f12,
68
- "/assets/JobInspector-B7zEuFhM.js": f13,
69
- "/assets/Dlq-BCUVh_NO.js": f14,
70
- "/assets/form-PtDLk33Z.js": f15,
71
- "/assets/DlqPro-HBrCftLD.js": f16,
72
- "/assets/index-C9fPU4bV.js": f17,
73
- "/assets/Diagnostics-BzVDq9CH.js": f18,
74
- "/assets/Pagination-Cd6lHj2E.js": f19,
75
- "/assets/CopilotPanel-BDZzDmVy.js": f20,
76
- "/assets/Jobs-ovYRwmwi.js": f21,
77
- "/assets/JobsPro-DNZivuzq.js": f22,
78
- "/assets/Cron-9hndZ-Z5.js": f23,
79
- "/assets/CopyButton-XT7ykzf5.js": f24,
80
- "/assets/react-vendor-CHIHtdAC.js": f25,
81
- "/assets/WorkersPro-BidtV_Bp.js": f26,
82
- "/assets/MetricsPro-CqcH6gJp.js": f27,
83
- "/assets/jobActions-CuOdMglt.js": f28,
84
- "/assets/Queues-LrodynCj.js": f29,
85
- "/assets/connectionStore-DI-LYcct.js": f30,
86
- "/assets/McpServer-CUK20-uN.js": f31,
87
- "/assets/Usage-CHCg6VNy.js": f32,
88
- "/assets/Settings-CeRZgZU6.js": f33,
89
- "/assets/cn-CMFYpumL.js": f34,
90
- "/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2": f35,
91
- "/assets/Webhooks-Cm3vZEp7.js": f36,
92
- "/assets/S3BackupPro-BEo_EVAO.js": f37,
93
- "/assets/ServerControl-BRLFRj7k.js": f38,
94
- "/assets/Workers-CVfx3TK-.js": f39,
95
- "/assets/QueueDetail-BtiN0s3b.js": f40,
96
- "/assets/Database-Difs7xYV.js": f41,
97
- "/assets/UsagePro-Cto9k5OI.js": f42,
98
- "/assets/QueueControl-D7J1JObu.js": f43,
99
- "/assets/Metrics-BodjiKpf.js": f44,
100
- "/assets/inter-latin-wght-normal-Dx4kXJAl.woff2": f45,
101
- "/assets/install-BvB40Zk0.js": f46,
102
- "/assets/Flows-D3Bvkmd6.js": f47,
103
- "/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2": f48,
104
- "/assets/Benchmark-Dq1-vJ2k.js": f49,
62
+ "/assets/install-C019EM5j.js": f6,
63
+ "/assets/index-BWY8Yofc.css": f7,
64
+ "/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2": f8,
65
+ "/assets/McpServer-CNt7kssG.js": f9,
66
+ "/assets/QueuesOverview-BBjcyzz2.js": f10,
67
+ "/assets/Metrics-CbscCpvx.js": f11,
68
+ "/assets/AddJob-vk3jh1Zk.js": f12,
69
+ "/assets/DlqControl-BLKVzYQC.js": f13,
70
+ "/assets/form-PtDLk33Z.js": f14,
71
+ "/assets/Logs-yn92V_T8.js": f15,
72
+ "/assets/Usage-BFLZC7pV.js": f16,
73
+ "/assets/react-vendor-CHIHtdAC.js": f17,
74
+ "/assets/Webhooks-DChTcBSv.js": f18,
75
+ "/assets/QueueControl-Bl4l9dT6.js": f19,
76
+ "/assets/CopilotPanel-C9ojQ_8d.js": f20,
77
+ "/assets/jobActions-CuOdMglt.js": f21,
78
+ "/assets/Benchmark-CpViF2ZC.js": f22,
79
+ "/assets/connectionStore-CCopJeU7.js": f23,
80
+ "/assets/WorkersPro-B6I9Ilbq.js": f24,
81
+ "/assets/Queues-BEQlaWVc.js": f25,
82
+ "/assets/QueueDetail-BSUH0Nl6.js": f26,
83
+ "/assets/Diagnostics-CGJPsWZQ.js": f27,
84
+ "/assets/S3Backup-BmRt-Z8V.js": f28,
85
+ "/assets/ServerControl-Bhr9FEXF.js": f29,
86
+ "/assets/Flows-BOogljnP.js": f30,
87
+ "/assets/CopyButton-BC6QECSJ.js": f31,
88
+ "/assets/cn-CMFYpumL.js": f32,
89
+ "/assets/LogsPro-DSiV8Ajj.js": f33,
90
+ "/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2": f34,
91
+ "/assets/MetricsPro-CBiFDVne.js": f35,
92
+ "/assets/S3BackupPro-Dsq0erDm.js": f36,
93
+ "/assets/Cron-Bbf7mRaK.js": f37,
94
+ "/assets/JobsPro-D0uclU0B.js": f38,
95
+ "/assets/UsagePro-D0k-82eG.js": f39,
96
+ "/assets/Jobs-C2HYkZXi.js": f40,
97
+ "/assets/DlqPro-D8SmIQUs.js": f41,
98
+ "/assets/Pagination-Bj1z6OlD.js": f42,
99
+ "/assets/JobInspector-Cp4ZuQGI.js": f43,
100
+ "/assets/CronManager-CeNUeoOc.js": f44,
101
+ "/assets/Settings-46jsrfhd.js": f45,
102
+ "/assets/inter-latin-wght-normal-Dx4kXJAl.woff2": f46,
103
+ "/assets/Dlq-Bs1pupY2.js": f47,
104
+ "/assets/Database--bK9pYZF.js": f48,
105
+ "/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2": f49,
105
106
  "/index.html": f50,
106
107
  };
package/scripts/serve.ts CHANGED
@@ -20,7 +20,12 @@
20
20
  */
21
21
  import { logger } from '../agent/logger';
22
22
  import { ProcessManager } from '../agent/manager';
23
- import { createFetchHandler, resolveAllowedOrigins } from '../agent/server';
23
+ import {
24
+ createFetchHandler,
25
+ isHostAllowed,
26
+ resolveAllowedHosts,
27
+ resolveAllowedOrigins,
28
+ } from '../agent/server';
24
29
  import { ASSETS } from './embedded.gen';
25
30
 
26
31
  const PORT = Number(process.env.PORT) || 8080;
@@ -40,9 +45,29 @@ const allowedOrigins = Array.from(
40
45
  `http://127.0.0.1:${PORT}`,
41
46
  ])
42
47
  );
48
+
49
+ // DNS-rebinding defense (see agent/server.ts). Only enforced when bound to
50
+ // loopback — the common "looks safe" case where a rebound page could reach the
51
+ // /api proxy and /agent inspector over same-origin GETs. When the user binds a
52
+ // non-loopback interface (BIND_ADDR=0.0.0.0) they opted into network exposure,
53
+ // where a fixed host allowlist would break legitimate LAN-IP access; leave it
54
+ // off there (configure a reverse proxy / AGENT_ALLOWED_HOSTS instead).
55
+ const loopbackBind = HOST === '127.0.0.1' || HOST === '::1' || HOST === 'localhost';
56
+ const originHosts = allowedOrigins
57
+ .map((o) => {
58
+ try {
59
+ return new URL(o).hostname;
60
+ } catch {
61
+ return '';
62
+ }
63
+ })
64
+ .filter(Boolean);
65
+ const allowedHosts = loopbackBind ? resolveAllowedHosts(process.env, originHosts) : undefined;
66
+
43
67
  const mgr = new ProcessManager();
44
68
  const agentHandle = createFetchHandler(mgr, {
45
69
  allowedOrigins,
70
+ allowedHosts,
46
71
  token: process.env.AGENT_TOKEN || undefined,
47
72
  });
48
73
  Bun.serve({ port: AGENT_PORT, hostname: '127.0.0.1', fetch: agentHandle });
@@ -65,6 +90,13 @@ Bun.serve({
65
90
  async fetch(req) {
66
91
  const url = new URL(req.url);
67
92
 
93
+ // DNS-rebinding defense across every route (/api proxy, /agent, assets):
94
+ // a page rebound to this loopback port sends its own domain as Host. No-op
95
+ // on non-loopback binds (allowedHosts is undefined there).
96
+ if (!isHostAllowed(req.headers.get('host'), allowedHosts)) {
97
+ return new Response('Host not allowed', { status: 403 });
98
+ }
99
+
68
100
  // Same-origin bridge to the control agent: strip the /agent prefix and
69
101
  // hand the request to the in-process agent handler (no loopback hop).
70
102
  // The agent's own Origin allowlist + optional AGENT_TOKEN still apply —
@@ -72,7 +104,7 @@ Bun.serve({
72
104
  if (url.pathname === '/agent' || url.pathname.startsWith('/agent/')) {
73
105
  const sub = new URL(url.pathname.slice('/agent'.length) || '/', 'http://agent.internal');
74
106
  sub.search = url.search;
75
- return agentHandle(new Request(sub, req));
107
+ return agentHandle(new Request(sub.href, req));
76
108
  }
77
109
 
78
110
  // Same-origin proxy to the bunqueue server (mirrors the Vite dev proxy).
@@ -1 +0,0 @@
1
- import{r as e,t}from"./cn-CMFYpumL.js";import{m as n,t as r}from"./react-vendor-CHIHtdAC.js";import{D as i,E as a,T as o,U as s,W as c,_ as l,c as u,g as d,j as f,r as p,s as m,v as h}from"./index-C9fPU4bV.js";import{i as g,n as _,o as v,t as y}from"./form-PtDLk33Z.js";import{t as b}from"./AreaChart-DzUXW8u3.js";import{t as x}from"./CopyButton-XT7ykzf5.js";var S=e(n(),1),C={total:1e6,batch:5e3,producers:64,payload:65536,workers:64,workerBatch:1e3,processMs:6e4,durationS:600},w={queue:`benchmark`,mode:`count`,total:5e3,durationS:30,batch:100,producers:4,payload:128,workers:4,workerBatch:100,processMs:5,durable:!1,removeOnComplete:!0},T={Smoke:{mode:`count`,total:200,batch:50,producers:2,workers:1,workerBatch:50,processMs:0},Standard:{mode:`count`,total:5e3,batch:100,producers:4,workers:4,workerBatch:100,processMs:5},Stress:{mode:`count`,total:5e4,batch:500,producers:16,workers:16,workerBatch:200,processMs:0},Soak:{mode:`duration`,durationS:30,batch:100,producers:4,workers:8,workerBatch:100,processMs:10}},E=(e,t,n)=>Number.isFinite(e)?Math.max(t,Math.min(n,Math.floor(e))):t,D=(e,t)=>e.length?e[Math.min(e.length-1,Math.floor(t/100*e.length))]:0,O=(e,t,n,r,i)=>Array.from({length:t},(t,a)=>({data:{i:e+a,blob:n},durable:r,removeOnComplete:i})),k=e=>new Promise(t=>setTimeout(t,e)),A=async(e,t)=>{let n=performance.now()+e;for(;t()&&performance.now()<n;)await k(Math.min(100,Math.max(0,n-performance.now())))},j=e=>e instanceof Error?e.message:String(e),M=e=>e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:`${Math.round(e)}`,N=r();function P({history:e,onClear:t}){if(!e.length)return null;let n=JSON.stringify(e,null,2);return(0,N.jsxs)(o,{padded:!1,className:`mt-6 overflow-hidden`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between border-b border-line px-5 py-3`,children:[(0,N.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Run history`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(x,{value:n}),(0,N.jsx)(i,{size:`sm`,variant:`ghost`,onClick:()=>{let e=new Blob([n],{type:`application/json`}),t=URL.createObjectURL(e),r=document.createElement(`a`);r.href=t,r.download=`benchmark-history-${Date.now()}.json`,r.click(),URL.revokeObjectURL(t)},children:`Export JSON`}),(0,N.jsx)(i,{size:`sm`,variant:`ghost`,onClick:t,children:`Clear`})]})]}),(0,N.jsx)(`div`,{className:`overflow-x-auto`,children:(0,N.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,N.jsx)(`th`,{className:`px-5 py-2 font-medium`,children:`Mode`}),(0,N.jsx)(`th`,{className:`px-5 py-2 text-right font-medium`,children:`Prod`}),(0,N.jsx)(`th`,{className:`px-5 py-2 text-right font-medium`,children:`Wkr`}),(0,N.jsx)(`th`,{className:`px-5 py-2 text-right font-medium`,children:`Pushed`}),(0,N.jsx)(`th`,{className:`px-5 py-2 text-right font-medium`,children:`Done`}),(0,N.jsx)(`th`,{className:`px-5 py-2 text-right font-medium`,children:`Push/s`}),(0,N.jsx)(`th`,{className:`px-5 py-2 text-right font-medium`,children:`Done/s`}),(0,N.jsx)(`th`,{className:`px-5 py-2 text-right font-medium`,children:`p95`}),(0,N.jsx)(`th`,{className:`px-5 py-2 text-right font-medium`,children:`Dur`})]})}),(0,N.jsx)(`tbody`,{children:e.map(e=>(0,N.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,N.jsx)(`td`,{className:`px-5 py-2 capitalize text-muted`,children:e.mode}),(0,N.jsx)(`td`,{className:`px-5 py-2 text-right tnum text-muted`,children:e.producers}),(0,N.jsx)(`td`,{className:`px-5 py-2 text-right tnum text-muted`,children:e.workers}),(0,N.jsx)(`td`,{className:`px-5 py-2 text-right tnum text-fg`,children:u(e.pushed)}),(0,N.jsx)(`td`,{className:`px-5 py-2 text-right tnum text-success`,children:u(e.completed)}),(0,N.jsxs)(`td`,{className:`px-5 py-2 text-right tnum text-accent`,children:[M(e.pushPerSec),`/s`]}),(0,N.jsxs)(`td`,{className:`px-5 py-2 text-right tnum text-success`,children:[M(e.donePerSec),`/s`]}),(0,N.jsx)(`td`,{className:`px-5 py-2 text-right tnum text-muted`,children:m(e.p95)}),(0,N.jsx)(`td`,{className:`px-5 py-2 text-right tnum text-muted`,children:m(e.durationMs)})]},e.id))})]})})]})}var F={pushed:0,completed:0,pushFailed:0,ackFailed:0,bytes:0,elapsedMs:0,pushPerSec:0,donePerSec:0,activeWorkers:0,pushSeries:[],doneSeries:[],etaMs:null,error:null},I=()=>({pushed:0,completed:0,pushFailed:0,ackFailed:0,bytes:0,assigned:0,startedAt:0,pushLat:[],activeWorkers:0,error:null,lastAt:0,lastPushed:0,lastDone:0,pushSeries:[],doneSeries:[]}),L=0;function R(){let[e,t]=(0,S.useState)(`idle`),[n,r]=(0,S.useState)(F),[i,a]=(0,S.useState)(null),[o,s]=(0,S.useState)([]),[c,l]=(0,S.useState)(null),u=(0,S.useRef)(!1),f=(0,S.useRef)(!1),p=(0,S.useRef)(!1),m=(0,S.useRef)(null),h=(0,S.useRef)(`idle`);h.current=e;let g=(0,S.useRef)(I());return(0,S.useEffect)(()=>()=>{u.current=!0},[]),(0,S.useEffect)(()=>{if(e!==`running`&&e!==`draining`)return;let t=setInterval(()=>{let e=g.current,t=performance.now(),n=t-e.startedAt,i=(t-e.lastAt)/1e3,a=i>0?Math.max(0,(e.pushed-e.lastPushed)/i):0,o=i>0?Math.max(0,(e.completed-e.lastDone)/i):0;e.lastAt=t,e.lastPushed=e.pushed,e.lastDone=e.completed,e.pushSeries=[...e.pushSeries,a].slice(-60),e.doneSeries=[...e.doneSeries,o].slice(-60);let s=null,c=m.current;if(c&&c.mode===`count`){let t=E(c.total,1,C.total);if(h.current===`draining`){let r=e.doneSeries.slice(-10),i=r.length?r.reduce((e,t)=>e+t,0)/r.length:0;i<=0&&n>0&&(i=e.completed/(n/1e3)),i>0&&(s=Math.max(0,t-e.completed)/i*1e3)}else a>0&&(s=Math.max(0,t-e.pushed)/a*1e3)}else c&&c.mode===`duration`&&(s=Math.max(0,E(c.durationS,1,C.durationS)*1e3-n));r({pushed:e.pushed,completed:e.completed,pushFailed:e.pushFailed,ackFailed:e.ackFailed,bytes:e.bytes,elapsedMs:n,pushPerSec:a,donePerSec:o,activeWorkers:e.activeWorkers,pushSeries:e.pushSeries,doneSeries:e.doneSeries,etaMs:s,error:e.error})},200);return()=>clearInterval(t)},[e]),{phase:e,live:n,summary:i,history:o,runCfg:c,run:async e=>{if(!f.current){f.current=!0;try{a(null);let n=e.queue.trim();if(!n){r({...F,error:`Queue name is required.`}),t(`error`);return}try{await d.overview()}catch(e){r({...F,error:`Server unreachable — start it on the Server page first. (${j(e)})`}),t(`error`);return}let i=E(e.total,1,C.total),o=E(e.durationS,1,C.durationS)*1e3,c=E(e.batch,1,C.batch),f=E(e.producers,e.mode===`duration`?0:1,C.producers),_=E(e.payload,0,C.payload),v=E(e.workers,0,C.workers),y=E(e.workerBatch,1,C.workerBatch),b=E(e.processMs,0,C.processMs);u.current=!1,p.current=!1,m.current=e,l(e),g.current=I(),g.current.startedAt=performance.now(),g.current.lastAt=performance.now(),r({...F}),t(`running`);let x=`x`.repeat(_),S=performance.now()+o,w=async()=>{for(;!u.current;){let t;if(e.mode===`count`){if(g.current.assigned>=i)break;t=Math.min(c,i-g.current.assigned)}else{if(performance.now()>=S)break;t=c}let r=g.current.assigned;g.current.assigned+=t;let a=O(r,t,x,e.durable,e.removeOnComplete),o=performance.now();try{await d.addJobsBulk(n,a),g.current.pushed+=t,g.current.bytes+=t*_}catch(e){g.current.pushFailed+=t,g.current.error??=j(e)}g.current.pushLat.push(performance.now()-o)}},T=async()=>{for(;!u.current&&!(e.mode===`duration`&&performance.now()>=S||e.mode===`count`&&g.current.completed>=i);){g.current.activeWorkers++;let t=[];try{try{t=(await d.pullBatch(n,y)).jobs??[]}catch(e){g.current.error??=j(e)}if(t.length>0){b>0&&await A(b,()=>!u.current);try{await d.ackBatch(t.map(e=>e.id)),g.current.completed+=t.length}catch(e){g.current.ackFailed+=t.length,g.current.error??=j(e)}}}finally{g.current.activeWorkers--}if(t.length===0){if(e.mode===`count`&&p.current)break;await k(50)}}},M=Array.from({length:f},w),N=Array.from({length:v},T),P=Promise.all(M).then(()=>{p.current=!0,!u.current&&e.mode===`count`&&v>0&&h.current===`running`&&t(`draining`)});await Promise.all([P,...N]);let R=g.current,z=performance.now()-R.startedAt,B=z/1e3||1,V=[...R.pushLat].sort((e,t)=>e-t),H={pushed:R.pushed,completed:R.completed,pushFailed:R.pushFailed,ackFailed:R.ackFailed,bytes:R.bytes,durationMs:z,pushPerSec:R.pushed/B,donePerSec:R.completed/B,mbPerSec:R.bytes/B,avg:V.length?V.reduce((e,t)=>e+t,0)/V.length:0,p50:D(V,50),p95:D(V,95),p99:D(V,99),max:V.length?V[V.length-1]:0,error:R.error};a(H),r(e=>({...e,pushed:R.pushed,completed:R.completed,elapsedMs:z,pushPerSec:0,donePerSec:0,activeWorkers:0,etaMs:0})),s(t=>[{...H,id:++L,at:Date.now(),mode:e.mode,producers:f,workers:v},...t].slice(0,12)),t(u.current?`stopped`:`done`)}finally{f.current=!1}}},stop:()=>{u.current=!0,(h.current===`running`||h.current===`draining`)&&t(`stopping`)},reset:()=>{u.current=!0,a(null),r(F),t(`idle`)},clearHistory:()=>s([])}}var z=[`count`,`duration`],B=[`total`,`durationS`,`batch`,`producers`,`payload`,`workers`,`workerBatch`,`processMs`],V=e=>({...e,total:String(e.total),durationS:String(e.durationS),batch:String(e.batch),producers:String(e.producers),payload:String(e.payload),workers:String(e.workers),workerBatch:String(e.workerBatch),processMs:String(e.processMs)}),H=e=>({...e,total:Number(e.total),durationS:Number(e.durationS),batch:Number(e.batch),producers:Number(e.producers),payload:Number(e.payload),workers:Number(e.workers),workerBatch:Number(e.workerBatch),processMs:Number(e.processMs)});function U(){let[e,n]=(0,S.useState)(()=>V(w)),r=R(),{phase:x,live:D,summary:O,history:k}=r,A=x===`running`||x===`draining`||x===`stopping`,j=(e,t)=>n(n=>({...n,[e]:t})),F=e=>t=>j(e,t.target.value),I=e=>n(t=>{let n={...t};for(let[t,r]of Object.entries(e))n[t]=B.includes(t)?String(r):r;return n}),[L,U]=(0,S.useState)(w.queue);(0,S.useEffect)(()=>{let t=setTimeout(()=>U(e.queue.trim()||w.queue),400);return()=>clearTimeout(t)},[e.queue]);let{data:ee,error:te}=f(()=>d.counts(L),[L],{intervalMs:1e3}),K=ee?.counts??null,[q,J]=(0,S.useState)(!1),[Y,X]=(0,S.useState)(null),ne=async()=>{let t=e.queue.trim();if(!(q||!t||!window.confirm(`Remove benchmark jobs from "${t}"?`))){J(!0),X(null);try{for(let e of[`waiting`,`completed`,`failed`,`delayed`])try{await d.clean(t,{state:e,limit:C.total})}catch{}X({remaining:(await d.counts(t).catch(()=>null))?.counts?.active??0})}finally{J(!1)}}},Z=r.runCfg??H(e),Q=E(Z.total,1,C.total),$=E(Z.workers,0,C.workers),re=Z.mode===`count`&&(A||O)?Math.min(100,D.pushed/Q*100):0,ie=Z.mode===`count`&&(A||O)?Math.min(100,D.completed/Q*100):0,ae=Z.mode===`duration`?Math.min(100,D.elapsedMs/(E(Z.durationS,1,C.durationS)*1e3)*100):0,oe=x===`running`?Z.mode===`duration`?`Running…`:`Producing…`:x===`draining`?`Draining…`:x===`stopping`?`Stopping…`:x===`error`?`Error`:O?`Result`:`Ready`,se=(x===`running`||x===`draining`)&&D.etaMs!=null?D.etaMs>0?`ETA ${m(D.etaMs)}`:`finishing…`:x===`stopped`?`stopped early`:x===`done`?`complete`:``;return(0,N.jsxs)(`div`,{children:[(0,N.jsx)(h,{title:`Benchmark`,description:`Drive real load against the server — producers bulk-enqueue jobs while simulated workers pull, process and ack them. Throughput is measured client-side; the queue genuinely fills and drains.`,actions:x===`stopping`?(0,N.jsxs)(i,{variant:`warning`,size:`sm`,disabled:!0,children:[(0,N.jsx)(s,{className:`size-3.5`}),` Stopping…`]}):A?(0,N.jsxs)(i,{variant:`warning`,size:`sm`,onClick:r.stop,children:[(0,N.jsx)(s,{className:`size-3.5`}),` Stop`]}):(0,N.jsxs)(i,{variant:`success`,size:`sm`,onClick:()=>r.run(H(e)),children:[(0,N.jsx)(c,{className:`size-3.5`}),` Run benchmark`]})}),D.error&&(0,N.jsx)(`div`,{className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-danger`,children:D.error}),(0,N.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-faint`,children:`Presets`}),Object.keys(T).map(e=>(0,N.jsx)(`button`,{type:`button`,disabled:A,onClick:()=>I(T[e]),className:`rounded-md border border-line bg-surface-2 px-2.5 py-1 text-xs text-muted transition-colors hover:border-line-strong hover:text-fg disabled:opacity-40`,children:e},e))]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-3`,children:[(0,N.jsxs)(o,{className:`lg:col-span-1`,children:[(0,N.jsx)(a,{title:`Configuration`}),(0,N.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,N.jsx)(y,{label:`Queue`,hint:`Jobs are enqueued here (created on first push).`,children:(0,N.jsx)(_,{value:e.queue,disabled:A,onChange:e=>j(`queue`,e.target.value)})}),(0,N.jsx)(y,{label:`Mode`,hint:e.mode===`count`?`Push a fixed number of jobs.`:`Run producers + workers for a fixed time.`,children:(0,N.jsx)(g,{options:z,value:e.mode,onChange:e=>j(`mode`,e),disabled:A})}),e.mode===`count`?(0,N.jsx)(y,{label:`Total jobs`,hint:`max ${u(C.total)}`,children:(0,N.jsx)(_,{type:`number`,min:1,max:C.total,value:e.total,disabled:A,onChange:F(`total`)})}):(0,N.jsx)(y,{label:`Duration (s)`,hint:`max ${C.durationS}s`,children:(0,N.jsx)(_,{type:`number`,min:1,max:C.durationS,value:e.durationS,disabled:A,onChange:F(`durationS`)})}),(0,N.jsx)(`div`,{className:`mt-1 text-[11px] font-semibold uppercase tracking-wider text-faint`,children:`Producers`}),(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,N.jsx)(y,{label:`Producers`,hint:`parallel, max ${C.producers}`,children:(0,N.jsx)(_,{type:`number`,min:e.mode===`duration`?0:1,max:C.producers,value:e.producers,disabled:A,onChange:F(`producers`)})}),(0,N.jsx)(y,{label:`Push batch`,hint:`jobs/req, max ${C.batch}`,children:(0,N.jsx)(_,{type:`number`,min:1,max:C.batch,value:e.batch,disabled:A,onChange:F(`batch`)})}),(0,N.jsx)(y,{label:`Payload`,hint:`bytes/job, max ${u(C.payload)}`,children:(0,N.jsx)(_,{type:`number`,min:0,max:C.payload,value:e.payload,disabled:A,onChange:F(`payload`)})})]}),(0,N.jsx)(`div`,{className:`mt-1 text-[11px] font-semibold uppercase tracking-wider text-faint`,children:`Workers (simulated)`}),(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,N.jsx)(y,{label:`Workers`,hint:`0 = produce only, max ${C.workers}`,children:(0,N.jsx)(_,{type:`number`,min:0,max:C.workers,value:e.workers,disabled:A,onChange:F(`workers`)})}),(0,N.jsx)(y,{label:`Pull batch`,hint:`jobs/pull, max ${C.workerBatch}`,children:(0,N.jsx)(_,{type:`number`,min:1,max:C.workerBatch,value:e.workerBatch,disabled:A,onChange:F(`workerBatch`)})}),(0,N.jsx)(y,{label:`Process (ms)`,hint:`simulated work per pull`,children:(0,N.jsx)(_,{type:`number`,min:0,max:C.processMs,value:e.processMs,disabled:A,onChange:F(`processMs`)})})]}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2`,children:[(0,N.jsx)(v,{checked:e.durable,onChange:e=>j(`durable`,e),disabled:A}),(0,N.jsx)(`span`,{className:`text-sm text-muted`,children:`Durable (fsync each job)`})]}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2`,children:[(0,N.jsx)(v,{checked:e.removeOnComplete,onChange:e=>j(`removeOnComplete`,e),disabled:A}),(0,N.jsx)(`span`,{className:`text-sm text-muted`,children:`Remove on complete`})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 pt-1`,children:[(0,N.jsx)(i,{variant:`ghost`,size:`sm`,disabled:A||q,onClick:ne,children:q?`Cleaning…`:`Clean queue`}),Y&&(0,N.jsx)(`span`,{className:t(`text-xs`,Y.remaining>0?`text-warning`:`text-success`),children:Y.remaining>0?`Cleaned — ${u(Y.remaining)} active job(s) remain (requeued after the stall timeout)`:`Cleaned — 0 jobs remain`})]})]})]}),(0,N.jsxs)(`div`,{className:`flex flex-col gap-6 lg:col-span-2`,children:[(0,N.jsxs)(o,{children:[(0,N.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,N.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:oe}),(0,N.jsx)(`span`,{className:`text-xs text-faint`,children:se})]}),(0,N.jsx)(W,{label:Z.mode===`duration`?`Elapsed`:`Produced`,pct:Z.mode===`duration`?ae:re,tone:`accent`}),$>0&&Z.mode===`count`&&(0,N.jsx)(W,{label:`Completed`,pct:ie,tone:`emerald`}),(0,N.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,N.jsx)(l,{label:`Pushed`,value:u(D.pushed),tone:`accent`,compact:!0}),(0,N.jsx)(l,{label:`Completed`,value:u(D.completed),tone:`green`,compact:!0}),(0,N.jsx)(l,{label:`Push/sec`,value:M(D.pushPerSec),compact:!0}),(0,N.jsx)(l,{label:`Done/sec`,value:M(D.donePerSec),tone:`green`,compact:!0}),(0,N.jsx)(l,{label:`Elapsed`,value:m(D.elapsedMs),compact:!0}),(0,N.jsx)(l,{label:`Active workers`,value:`${D.activeWorkers}/${$}`,tone:`blue`,compact:!0}),(0,N.jsx)(l,{label:`Data`,value:p(O?.bytes??D.bytes),compact:!0}),(0,N.jsx)(l,{label:`Errors`,value:u((O?.pushFailed??D.pushFailed)+(O?.ackFailed??D.ackFailed)),tone:D.pushFailed+D.ackFailed?`red`:`default`,compact:!0})]})]}),(0,N.jsxs)(o,{children:[(0,N.jsx)(a,{title:`Throughput`}),(0,N.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Enqueue (client → server) vs completion (workers) per second`}),(0,N.jsx)(b,{series:[{label:`Push/sec`,color:`#38bdf8`,points:D.pushSeries,area:!0},{label:`Done/sec`,color:`#34d399`,points:D.doneSeries,area:!0}]}),(0,N.jsxs)(`div`,{className:`mt-2 flex items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,N.jsx)(G,{color:`#38bdf8`,label:`Push/sec`,value:D.pushPerSec}),(0,N.jsx)(G,{color:`#34d399`,label:`Done/sec`,value:D.donePerSec})]})]})]})]}),O&&(0,N.jsxs)(o,{className:`mt-6`,children:[(0,N.jsx)(a,{title:`Summary`}),(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4 xl:grid-cols-8`,children:[(0,N.jsx)(l,{label:`Pushed`,value:u(O.pushed),tone:`accent`,compact:!0}),(0,N.jsx)(l,{label:`Completed`,value:u(O.completed),tone:`green`,compact:!0}),(0,N.jsx)(l,{label:`Duration`,value:m(O.durationMs),compact:!0}),(0,N.jsx)(l,{label:`Avg push/s`,value:M(O.pushPerSec),tone:`accent`,compact:!0}),(0,N.jsx)(l,{label:`Avg done/s`,value:M(O.donePerSec),tone:`green`,compact:!0}),(0,N.jsx)(l,{label:`Data rate`,value:`${p(O.mbPerSec)}/s`,compact:!0}),(0,N.jsx)(l,{label:`Push p95`,value:m(O.p95),compact:!0}),(0,N.jsx)(l,{label:`Push p99`,value:m(O.p99),compact:!0})]}),(0,N.jsxs)(`p`,{className:`mt-3 text-xs text-faint`,children:[`Push-batch latency avg `,m(O.avg),` · p50 `,m(O.p50),` · p95`,` `,m(O.p95),` · p99 `,m(O.p99),` · max `,m(O.max),`.`,O.error?` First error: ${O.error}`:``]})]}),(0,N.jsxs)(o,{className:`mt-6`,children:[(0,N.jsx)(a,{title:`Server queue: ${L}`,action:te?(0,N.jsx)(`span`,{className:`text-xs font-medium text-warning`,children:`stale — server unreachable`}):void 0}),(0,N.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Live counts from the server (poll 1s).`}),K?(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-5`,children:[(0,N.jsx)(l,{label:`Waiting`,value:u(K.waiting??0),tone:`amber`,compact:!0}),(0,N.jsx)(l,{label:`Active`,value:u(K.active??0),tone:`blue`,compact:!0}),(0,N.jsx)(l,{label:`Completed`,value:u(K.completed??0),tone:`green`,compact:!0}),(0,N.jsx)(l,{label:`Failed`,value:u(K.failed??0),tone:K.failed?`red`:`default`,compact:!0}),(0,N.jsx)(l,{label:`Delayed`,value:u(K.delayed??0),compact:!0})]}):(0,N.jsx)(`p`,{className:`text-sm text-faint`,children:`No counts yet — waiting for the server to answer for this queue.`})]}),(0,N.jsx)(P,{history:k,onClear:r.clearHistory})]})}function W({label:e,pct:n,tone:r}){return(0,N.jsxs)(`div`,{className:`mb-2`,children:[(0,N.jsxs)(`div`,{className:`mb-1 flex items-center justify-between text-[11px] text-faint`,children:[(0,N.jsx)(`span`,{children:e}),(0,N.jsxs)(`span`,{className:`tnum`,children:[n.toFixed(0),`%`]})]}),(0,N.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-2`,children:(0,N.jsx)(`div`,{className:t(`h-full rounded-full transition-all`,r===`accent`?`bg-accent`:`bg-emerald-500`),style:{width:`${n}%`}})})]})}function G({color:e,label:t,value:n}){return(0,N.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,N.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,N.jsxs)(`span`,{className:`text-fg`,children:[M(n),`/s`]})]})}export{U as Benchmark};
@@ -1,3 +0,0 @@
1
- import{r as e,t}from"./cn-CMFYpumL.js";import{m as n,t as r}from"./react-vendor-CHIHtdAC.js";import{C as i,D as a,E as o,I as s,J as c,S as l,T as u,_ as d,c as f,g as p,j as m,m as h,r as g,v as _,w as ee}from"./index-C9fPU4bV.js";import{a as v}from"./form-PtDLk33Z.js";import{t as te}from"./Pagination-Cd6lHj2E.js";import{t as y}from"./CopyButton-XT7ykzf5.js";var b=e(n(),1),x=r(),S=50,C=500,ne=2e5,w=`bq-dash-db-history`,T=10;function E(e){let t=e==null?``:String(e);return/[",\n]/.test(t)?`"${t.replaceAll(`"`,`""`)}"`:t}function D(e,t){return[e.map(E).join(`,`),...t.map(e=>e.map(E).join(`,`))].join(`
2
- `)}function O(e,t,n){let r=URL.createObjectURL(new Blob([n],{type:t})),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),URL.revokeObjectURL(r)}function k(){try{let e=JSON.parse(localStorage.getItem(w)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function A(e){try{localStorage.setItem(w,JSON.stringify(e))}catch{}return e}function j(e){return A([e,...k().filter(t=>t!==e)].slice(0,T))}function M(e){if(e==null)return`NULL`;let t=typeof e==`string`?e:String(e);try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}function N({value:e,align:n}){if(e==null)return(0,x.jsx)(`span`,{className:`italic text-faint`,children:`NULL`});let r=typeof e==`string`?e:String(e);return(0,x.jsx)(`span`,{className:t(`block max-w-[24rem] truncate`,n===`right`&&`text-right tabular-nums`),title:r,children:r})}function P({columns:e,rows:n,truncatedCells:r,colMeta:i,sort:a,onSort:o,onRowClick:s,dimmed:c}){let l=(0,b.useMemo)(()=>e.map((e,t)=>{let r=i?.[e]?.type?.toUpperCase()??``;if(/INT|REAL|NUM|DEC|DOUB|FLOA/.test(r))return!0;let a=!1;for(let e of n){let n=e[t];if(n!=null&&(a=!0,typeof n!=`number`))return!1}return a}),[e,n,i]);return(0,x.jsx)(`div`,{className:t(`max-h-[70vh] overflow-auto rounded-xl border border-line bg-surface transition-opacity`,c&&`pointer-events-none opacity-50`),children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsx)(`tr`,{className:`text-left text-[11px] uppercase tracking-wider text-faint`,children:e.map((e,n)=>{let r=i?.[e];return(0,x.jsx)(`th`,{className:t(`sticky top-0 z-10 whitespace-nowrap border-b border-line bg-surface px-4 py-3 font-medium`,l[n]&&`text-right`),"aria-sort":a?.col===e?a.dir===`asc`?`ascending`:`descending`:void 0,children:o?(0,x.jsxs)(`button`,{type:`button`,onClick:()=>o(e),"aria-label":`Sort by ${e}`,className:`inline-flex items-center gap-1 uppercase tracking-wider hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[e,r?.primaryKey&&(0,x.jsx)(`span`,{className:`rounded bg-accent/15 px-1 py-0.5 text-[9px] font-semibold text-accent`,children:`PK`}),r?.type&&(0,x.jsx)(`span`,{className:`text-faint/70`,children:r.type.toLowerCase()}),(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`text-accent`,children:a?.col===e?a.dir===`asc`?`▲`:`▼`:``})]}):e},e)})})}),(0,x.jsx)(`tbody`,{children:n.map((e,n)=>(0,x.jsx)(`tr`,{onClick:s?()=>s(n):void 0,className:t(`border-b border-line font-mono text-xs last:border-0 hover:bg-surface-2/40`,s&&`cursor-pointer`),children:e.map((e,t)=>(0,x.jsx)(`td`,{className:`whitespace-nowrap px-4 py-2 text-muted`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(N,{value:e,align:l[t]?`right`:`left`}),r?.[n]?.[t]&&(0,x.jsx)(`span`,{title:`Value truncated — click the row to view it in full`,className:`shrink-0 rounded bg-warning/15 px-1 text-[9px] font-semibold text-warning`,children:`…`})]})},t))},n))})]})})}function F(){let[e,n]=(0,b.useState)(``),[r,o]=(0,b.useState)(0),[s,c]=(0,b.useState)(null),[v,y]=(0,b.useState)(`data`),[w,T]=(0,b.useState)(null),[E,k]=(0,b.useState)(null),[A,j]=(0,b.useState)(`SELECT name FROM sqlite_master WHERE type = 'table'`),M=(0,b.useRef)(null),{data:N,error:F,loading:re,refetch:ie}=m(()=>p.db.tables(),[],{intervalMs:1e4}),B=(0,b.useMemo)(()=>N?.tables??[],[N]),V=F instanceof h&&F.status===404,{data:H}=m(()=>V?Promise.resolve(null):p.db.info(),[V],{intervalMs:15e3}),U=e||B[0]?.name||``;(0,b.useEffect)(()=>{!e&&B[0]&&n(B[0].name)},[e,B]);let{data:W}=m(()=>U?p.db.schema(U):Promise.resolve(null),[U],{intervalMs:3e4}),ae=(0,b.useMemo)(()=>{let e={};if(W?.table===U)for(let t of W.columns)e[t.name]={type:t.type,primaryKey:t.primaryKey};return e},[W,U]),G=w?`${w.column}|${w.op}|${w.value}`:``,{data:K,error:q,loading:J}=m((0,b.useCallback)(async()=>U?{...await p.db.rows(U,S,r*S,s?.col,s?.dir,w??void 0),page:r,filterKey:G}:null,[U,r,s,w,G]),[U,r,s,G],{intervalMs:6e3}),Y=K&&K.table===U&&K.page===r&&K.orderBy===(s?.col??null)&&(!s||K.dir===s.dir)&&K.filterKey===G?K:null;(0,b.useEffect)(()=>{Y&&Y.total>0&&Y.rows.length===0&&r>0&&o(Math.max(0,Math.ceil(Y.total/S)-1))},[Y,r]);let[X,Z]=(0,b.useState)(!1),[Q,$]=(0,b.useState)(null),oe=()=>{o(0),c(null),T(null),k(null)},se=e=>{n(e),y(`data`),oe()},ce=e=>{o(0),k(null),c(t=>t?.col===e?t.dir===`asc`?{col:e,dir:`desc`}:null:{col:e,dir:`asc`})},le=()=>{Y&&O(`${Y.table}-page${r+1}.csv`,`text/csv`,D(Y.columns,Y.rows))},ue=async()=>{if(!(!U||X)){Z(!0),$(null);try{let e=[],t=[],n=0,r=!1;for(;;){let i=await p.db.rows(U,C,n,s?.col,s?.dir,w??void 0);if(t=i.columns,e.push(...i.rows),n+=C,e.length>=ne){r=!0;break}if(i.rows.length<C||n>=i.total)break}O(`${U}.csv`,`text/csv`,D(t,e)),$(r?`Exported the first ${f(e.length)} rows (export cap reached)`:`Exported ${f(e.length)} rows`)}catch(e){$(`Export failed: ${e.message}`)}finally{Z(!1)}}},de=()=>{j(`SELECT * FROM "${U.replaceAll(`"`,`""`)}" LIMIT 100`),requestAnimationFrame(()=>{M.current?.focus(),M.current?.scrollIntoView({behavior:`smooth`,block:`center`})})},fe=!!Y?.truncatedCells.some(e=>e.some(Boolean));return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(_,{title:`Database`,description:`SQLite inspector — schema, data and queries over a read-only connection.`,actions:(0,x.jsx)(`span`,{className:`rounded-full bg-emerald-500/10 px-2.5 py-1 text-[11px] font-medium text-success`,children:`read-only`})}),F&&!V&&(0,x.jsx)(ee,{message:`Could not read the database — ${F.message}`,onRetry:ie}),H&&(0,x.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-5`,children:[(0,x.jsx)(d,{label:`SQLite`,value:H.sqliteVersion,compact:!0}),(0,x.jsx)(d,{label:`On disk`,value:g(H.fileSize+H.walSize),compact:!0}),(0,x.jsx)(d,{label:`Journal`,value:H.journalMode.toUpperCase(),compact:!0}),(0,x.jsx)(d,{label:`Tables`,value:f(H.tables),compact:!0}),(0,x.jsx)(d,{label:`Indexes`,value:f(H.indexes),compact:!0})]}),V?(0,x.jsx)(l,{title:`No database yet`,hint:F.message}):re&&B.length===0?(0,x.jsx)(i,{label:`Reading database…`}):(0,x.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-4`,children:[(0,x.jsxs)(u,{padded:!1,className:`self-start overflow-hidden`,children:[(0,x.jsxs)(`div`,{className:`border-b border-line px-4 py-3 text-[11px] font-medium uppercase tracking-wider text-faint`,children:[`Tables (`,B.length,`)`]}),(0,x.jsxs)(`ul`,{className:`max-h-[28rem] overflow-y-auto`,children:[B.map(e=>(0,x.jsx)(`li`,{children:(0,x.jsxs)(`button`,{type:`button`,onClick:()=>se(e.name),className:t(`flex w-full items-center justify-between gap-2 px-4 py-2 text-left text-sm transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,U===e.name?`bg-surface-2 text-fg`:`text-muted hover:bg-surface-2/60 hover:text-fg`),children:[(0,x.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e.name}),(0,x.jsx)(`span`,{className:`shrink-0 text-[11px] text-faint tabular-nums`,children:f(e.rows)})]})},e.name)),B.length===0&&(0,x.jsx)(`li`,{className:`px-4 py-6 text-center text-xs text-faint`,children:`No tables.`})]})]}),(0,x.jsx)(`div`,{className:`min-w-0 lg:col-span-3`,children:B.length===0?(0,x.jsx)(l,{title:`No tables`,hint:`This database has no user tables yet.`}):(0,x.jsxs)(x.Fragment,{children:[U&&(0,x.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`mr-auto min-w-0 truncate font-mono text-sm text-fg`,title:U,children:U}),(0,x.jsx)(a,{size:`sm`,variant:`ghost`,onClick:de,children:`Query`}),(0,x.jsx)(`div`,{className:`inline-flex items-center gap-1 rounded-lg border border-line bg-surface p-1`,children:[`data`,`schema`].map(e=>(0,x.jsx)(`button`,{type:`button`,onClick:()=>y(e),"aria-pressed":v===e,className:t(`rounded-md px-3 py-1 text-xs font-medium capitalize transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,v===e?`bg-surface-2 text-fg`:`text-muted hover:text-fg`),children:e},e))}),v===`data`&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(a,{size:`sm`,disabled:!Y||Y.rows.length===0,title:Y?`Exports the ${Y.rows.length} rows on this page only`:void 0,onClick:le,children:[`Export page`,Y?` (${Y.rows.length})`:``]}),(0,x.jsx)(a,{size:`sm`,variant:`accent`,disabled:X||!Y||Y.total===0,onClick:ue,children:X?`Exporting…`:`Export table${Y?` (${f(Y.total)})`:``}`})]})]}),v===`data`&&U&&(0,x.jsx)(I,{columns:Y?.columns??W?.columns.map(e=>e.name)??[],filter:w,onChange:e=>{T(e),o(0),k(null)}}),Q&&(0,x.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:Q}),v===`schema`?W?.table===U?(0,x.jsx)(R,{schema:W}):(0,x.jsx)(i,{label:`Reading schema of ${U}…`}):q&&!Y?(0,x.jsx)(l,{title:`Could not read table`,hint:q.message}):J&&!Y&&K?.table!==U?(0,x.jsx)(i,{label:`Reading ${U}…`}):!Y&&!K?(0,x.jsx)(l,{title:`Select a table`,hint:`Pick a table on the left to browse its rows.`}):(Y??K)&&(Y??K)?.total===0?(0,x.jsx)(l,{title:w?`No matching rows`:`Empty table`,hint:w?`No rows match the current filter.`:`"${(Y??K)?.table}" has no rows.`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(P,{columns:(Y??K)?.columns??[],rows:(Y??K)?.rows??[],truncatedCells:(Y??K)?.truncatedCells,colMeta:ae,sort:s,onSort:ce,onRowClick:e=>k(e),dimmed:J&&!Y}),fe&&(0,x.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Cells over 2000 chars and BLOBs are abbreviated in the grid and CSV — click a row to view the full value.`}),(0,x.jsx)(te,{page:r,pageSize:S,total:(Y??K)?.total??0,onPageChange:e=>{o(e),k(null)},label:`rows`})]}),(0,x.jsx)(z,{sql:A,setSql:j,editorRef:M})]})})]}),Y&&E!=null&&Y.rows[E]&&(0,x.jsx)(L,{table:Y.table,columns:Y.columns,row:Y.rows[E],rowid:Y.rowids[E],truncated:Y.truncatedCells[E],onClose:()=>k(null)})]})}function I({columns:e,filter:t,onChange:n}){let[r,i]=(0,b.useState)(t?.column??``),[o,s]=(0,b.useState)(t?.op??`contains`),[l,u]=(0,b.useState)(t?.value??``),d=r||e[0]||``,f=()=>n(l.trim()?{column:d,op:o,value:l.trim()}:null);return e.length===0?null:(0,x.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,x.jsx)(`div`,{className:`w-40`,children:(0,x.jsx)(v,{value:d,"aria-label":`Filter column`,onChange:e=>i(e.target.value),children:e.map(e=>(0,x.jsx)(`option`,{value:e,children:e},e))})}),(0,x.jsx)(`div`,{className:`w-32`,children:(0,x.jsxs)(v,{value:o,"aria-label":`Filter operator`,onChange:e=>s(e.target.value),children:[(0,x.jsx)(`option`,{value:`contains`,children:`contains`}),(0,x.jsx)(`option`,{value:`eq`,children:`=`}),(0,x.jsx)(`option`,{value:`ne`,children:`≠`})]})}),(0,x.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,x.jsx)(c,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),(0,x.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>e.key===`Enter`&&f(),"aria-label":`Filter value`,placeholder:`value — Enter to filter`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-8 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,x.jsx)(a,{size:`sm`,onClick:f,disabled:!l.trim(),children:`Filter`}),t&&(0,x.jsx)(a,{size:`sm`,variant:`ghost`,onClick:()=>{u(``),n(null)},children:`Clear`})]})}function L({table:e,columns:t,row:n,rowid:r,truncated:i,onClose:a}){let[o,c]=(0,b.useState)({});return(0,b.useEffect)(()=>{let e=e=>e.key===`Escape`&&a();return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]),(0,b.useEffect)(()=>{if(r==null)return;let n=!1;return(async()=>{for(let a=0;a<t.length;a++)if(i[a])try{let i=await p.db.cell(e,r,t[a]);n||c(e=>({...e,[t[a]]:i.value}))}catch{}})(),()=>{n=!0}},[e,r,t,i]),(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{type:`button`,"aria-label":`Close row detail`,onClick:a,className:`fixed inset-0 z-40 bg-black/50`}),(0,x.jsxs)(`aside`,{className:`fixed inset-y-0 right-0 z-50 flex w-full max-w-xl flex-col border-l border-line bg-surface shadow-xl`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between border-b border-line px-5 py-4`,children:[(0,x.jsxs)(`h2`,{className:`font-mono text-sm text-fg`,children:[e,` · row detail`]}),(0,x.jsx)(`button`,{type:`button`,"aria-label":`Close`,onClick:a,className:`flex size-8 items-center justify-center rounded-lg text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,x.jsx)(s,{className:`size-4`})})]}),(0,x.jsx)(`div`,{className:`flex-1 overflow-y-auto p-5`,children:(0,x.jsx)(`dl`,{className:`flex flex-col gap-4`,children:t.map((e,t)=>{let r=e in o?o[e]:n[t],a=M(r),s=a.includes(`
3
- `)||a.length>80;return(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`dt`,{className:`mb-1 flex items-center gap-1.5 text-[11px] uppercase tracking-wider text-faint`,children:[e,r!=null&&(0,x.jsx)(y,{value:String(r)}),i[t]&&!(e in o)&&(0,x.jsx)(`span`,{className:`text-warning`,children:`(loading full value…)`})]}),(0,x.jsx)(`dd`,{children:r==null?(0,x.jsx)(`span`,{className:`italic text-faint`,children:`NULL`}):s?(0,x.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:a}):(0,x.jsx)(`span`,{className:`break-words font-mono text-sm text-fg`,children:a})})]},e)})})})]})]})}function R({schema:e}){return(0,x.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,x.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,x.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Column`}),(0,x.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Type`}),(0,x.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Constraints`}),(0,x.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Default`})]})}),(0,x.jsx)(`tbody`,{children:e.columns.map(e=>(0,x.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,x.jsx)(`td`,{className:`px-4 py-2 font-mono text-xs text-fg`,children:e.name}),(0,x.jsx)(`td`,{className:`px-4 py-2 font-mono text-xs text-muted`,children:e.type}),(0,x.jsxs)(`td`,{className:`px-4 py-2 text-xs`,children:[e.primaryKey&&(0,x.jsx)(`span`,{className:`mr-1 rounded-md bg-accent/15 px-1.5 py-0.5 text-[10px] font-semibold text-accent`,children:`PK`}),e.notNull&&(0,x.jsx)(`span`,{className:`rounded-md bg-surface-2 px-1.5 py-0.5 text-[10px] font-semibold text-muted`,children:`NOT NULL`})]}),(0,x.jsx)(`td`,{className:`px-4 py-2 font-mono text-xs text-faint`,children:e.defaultValue??`—`})]},e.name))})]})}),(0,x.jsxs)(u,{children:[(0,x.jsx)(o,{title:`Indexes (${e.indexes.length})`}),e.indexes.length===0?(0,x.jsx)(`p`,{className:`text-xs text-faint`,children:`No indexes on this table.`}):(0,x.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.indexes.map(e=>(0,x.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2 font-mono text-xs`,children:[(0,x.jsx)(`span`,{className:`text-fg`,children:e.name}),e.unique&&(0,x.jsx)(`span`,{className:`rounded-md bg-accent/15 px-1.5 py-0.5 text-[10px] font-semibold text-accent`,children:`UNIQUE`}),(0,x.jsxs)(`span`,{className:`text-faint`,children:[`(`,e.columns.join(`, `),`)`]})]},e.name))})]}),e.sql&&(0,x.jsxs)(u,{children:[(0,x.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,x.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`DDL`}),(0,x.jsx)(y,{value:e.sql})]}),(0,x.jsx)(`pre`,{className:`overflow-x-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:e.sql})]})]})}function z({sql:e,setSql:t,editorRef:n}){let[r,i]=(0,b.useState)(!1),[s,c]=(0,b.useState)(null),[l,d]=(0,b.useState)(k),[m,h]=(0,b.useState)(null),g=(0,b.useRef)(0);(0,b.useEffect)(()=>()=>{g.current++},[]);let _=async(t=e,n=!0)=>{if(!t.trim()||r)return;let a=++g.current;i(!0),c(null);try{let r=await p.db.query(t);if(a!==g.current)return;h(r),n&&d(j(e.trim()))}catch(e){if(a!==g.current)return;h(null),c(e.message)}finally{a===g.current&&i(!1)}};return(0,x.jsxs)(u,{className:`mt-6`,children:[(0,x.jsx)(o,{title:`Query`,action:(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsx)(a,{size:`sm`,disabled:r||!e.trim(),onClick:()=>{let t=e.trim();t&&_(`EXPLAIN QUERY PLAN ${t}`,!1)},children:`Explain`}),(0,x.jsx)(a,{size:`sm`,variant:`accent`,disabled:r||!e.trim(),onClick:()=>_(),children:r?`Running…`:`Run`})]})}),(0,x.jsx)(`textarea`,{ref:n,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&_()},rows:3,spellCheck:!1,"aria-label":`SQL query`,placeholder:`SELECT … — read-only: writes are rejected by the engine`,className:`w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),(0,x.jsx)(`p`,{className:`mt-1 text-[11px] text-faint`,children:`⌘/Ctrl+Enter runs. Connection is read-only.`}),l.length>0&&(0,x.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[(0,x.jsx)(`span`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`History`}),l.map(e=>(0,x.jsx)(`button`,{type:`button`,onClick:()=>t(e),title:e,className:`max-w-56 truncate rounded-md border border-line bg-surface-2 px-2 py-1 font-mono text-[11px] text-muted transition-colors hover:border-line-strong hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:e},e)),(0,x.jsx)(`button`,{type:`button`,onClick:()=>{A([]),d([])},className:`rounded-md px-2 py-1 text-[11px] text-faint transition-colors hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`Clear`})]}),(0,x.jsxs)(`div`,{"aria-live":`polite`,children:[s&&(0,x.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:s}),m&&!s&&(0,x.jsxs)(`div`,{className:`mt-4`,children:[(0,x.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-3`,children:[(0,x.jsxs)(`p`,{className:`text-xs text-faint`,children:[m.truncated?`≥ `:``,f(m.rowCount),` row`,m.rowCount===1?``:`s`,` ·`,` `,f(m.ms),` ms`,m.truncated&&(0,x.jsxs)(`span`,{className:`text-warning`,children:[` — showing first `,m.rows.length]})]}),m.rows.length>0&&(0,x.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,x.jsx)(a,{size:`sm`,onClick:()=>O(`query-results.csv`,`text/csv`,D(m.columns,m.rows)),children:`CSV`}),(0,x.jsx)(a,{size:`sm`,onClick:()=>O(`query-results.json`,`application/json`,JSON.stringify(m.rows.map(e=>Object.fromEntries(m.columns.map((t,n)=>[t,e[n]]))),null,2)),children:`JSON`})]})]}),m.rows.length>0?(0,x.jsx)(P,{columns:m.columns,rows:m.rows}):(0,x.jsx)(`p`,{className:`text-xs text-faint`,children:`Query returned no rows.`})]})]})]})}export{F as Database};
@@ -1 +0,0 @@
1
- import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{C as r,D as i,M as a,S as o,_ as s,c,j as l,u,v as d,w as f,z as p}from"./index-C9fPU4bV.js";import{a as m}from"./form-PtDLk33Z.js";import{t as h}from"./Pagination-Cd6lHj2E.js";var g=e(t(),1),_=n(),v=25;function y(){let[e,t]=(0,g.useState)(``),[n,y]=(0,g.useState)(0),[b,x]=(0,g.useState)(!1),[S,C]=(0,g.useState)(null),{data:w}=l(()=>a.queues(500),[],{intervalMs:3e4});(0,g.useEffect)(()=>{e||!w?.queues?.length||t((w.queues.find(e=>e.dlq>0)??w.queues[0]).name)},[w,e]);let{data:T,error:E,loading:D,refetch:O}=l((0,g.useCallback)(async()=>{if(!e)return{entries:[],total:0};let t=await a.dlq(e,v,n*v);return{entries:t.entries??[],total:t.total??t.entries?.length??0}},[e,n]),[e,n]),k=async(t,n)=>{if(window.confirm(`${t} the dead letter queue for "${e}"?`)){x(!0),C(null);try{await n(),C(`${t} done`),O()}catch(e){C(e.message)}finally{x(!1)}}},A=T?.entries??[];return(0,_.jsxs)(`div`,{children:[E&&(0,_.jsx)(f,{onRetry:O}),(0,_.jsx)(d,{title:`Dead Letter Queue`,description:`Jobs that exhausted their retries.`,live:!0,actions:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(i,{size:`sm`,disabled:!e||b,onClick:()=>k(`Retry`,()=>a.retryDlq(e)),children:`Retry all`}),(0,_.jsx)(i,{variant:`danger`,size:`sm`,disabled:!e||b,onClick:()=>k(`Purge`,()=>a.purgeDlq(e)),children:`Purge`})]})}),(0,_.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,_.jsx)(`div`,{className:`w-56`,children:(0,_.jsx)(m,{value:e,onChange:e=>{t(e.target.value),y(0)},children:(w?.queues??[]).map(e=>(0,_.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,_.jsx)(`div`,{className:`w-40`,children:(0,_.jsx)(s,{label:`DLQ Entries`,value:c(T?.total),tone:T?.total?`red`:`default`,compact:!0})}),S&&(0,_.jsx)(`span`,{className:`text-xs text-muted`,children:S})]}),D&&!T&&!E?(0,_.jsx)(r,{label:`Loading DLQ…`}):A.length===0?(0,_.jsx)(o,{icon:(0,_.jsx)(p,{}),title:`Dead letter queue is empty`,hint:`Jobs land here after exhausting their retry attempts.`}):(0,_.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,_.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Reason`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,_.jsx)(`tbody`,{children:A.map((e,t)=>(0,_.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,_.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.jobId??e.id}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name||`unknown`}),(0,_.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-red-400/90`,children:String(e.reason||e.error||`—`)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:Array.isArray(e.attempts)?e.attempts.length:e.attempts??`—`}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:u(e.failedAt??e.enteredAt)})]},e.jobId??e.id??t))})]})}),T&&(0,_.jsx)(h,{page:n,pageSize:v,total:T.total,onPageChange:y,label:`entries`})]})}export{y as Dlq};
@@ -1 +0,0 @@
1
- import{r as e}from"./cn-CMFYpumL.js";import{d as t,m as n,t as r}from"./react-vendor-CHIHtdAC.js";import{C as i,J as a,M as o,O as s,Y as c,_ as l,c as u,f as d,j as f,l as p,n as m,o as h,u as g,v as _,w as v,y}from"./index-C9fPU4bV.js";import{a as b,i as x}from"./form-PtDLk33Z.js";var S=e(n(),1),C=r(),w=`__all__`,T=[`all`,`waiting`,`active`,`completed`,`failed`];function E(){let[e]=t(),[n,r]=(0,S.useState)(e.get(`queue`)??w),[E,D]=(0,S.useState)(`all`),[O,k]=(0,S.useState)(``),{data:A}=f(()=>o.queues(500),[]),{data:j}=f(()=>o.overview(),[]),{data:M,error:N,loading:P,refetch:F}=f((0,S.useCallback)(async()=>{let e=n===w?(A?.queues??[]).map(e=>e.name).slice(0,25):[n],t=E===`all`?void 0:[E];return(await Promise.all(e.map(e=>o.jobsList(e,{states:t,limit:40}).then(t=>(t.jobs??[]).map(t=>({...t,queue:t.queue??e}))).catch(()=>[])))).flat().sort((e,t)=>(t.createdAt??0)-(e.createdAt??0))},[n,E,A]),[n,E]),I=(0,S.useMemo)(()=>{let e=M??[],t=O.trim().toLowerCase();return(t?e.filter(e=>e.id.toLowerCase().includes(t)||(e.name??``).toLowerCase().includes(t)):e).slice(0,100)},[M,O]),L=j?.stats,R=L?m(L.totalCompleted,L.totalFailed)??0:0,z=async e=>{if(window.confirm(`Cancel job ${e}?`))try{await o.cancelJob(e),F()}catch{}};return(0,C.jsxs)(`div`,{children:[N&&(0,C.jsx)(v,{onRetry:F}),(0,C.jsx)(_,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!0}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,C.jsx)(l,{label:`Total`,value:u((L?.totalCompleted??0)+(L?.totalFailed??0)+(L?.waiting??0)+(L?.active??0)),compact:!0}),(0,C.jsx)(l,{label:`Waiting`,value:u(L?.waiting),tone:`amber`,compact:!0}),(0,C.jsx)(l,{label:`Active`,value:u(L?.active),tone:`blue`,compact:!0}),(0,C.jsx)(l,{label:`Completed`,value:u(L?.totalCompleted),tone:`green`,compact:!0}),(0,C.jsx)(l,{label:`Failed`,value:u(L?.totalFailed),tone:L?.totalFailed?`red`:`default`,compact:!0}),(0,C.jsx)(l,{label:`Error Rate`,value:p(R),tone:R>.05?`red`:`green`,compact:!0})]}),(0,C.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,C.jsx)(`div`,{className:`w-48`,children:(0,C.jsxs)(b,{value:n,onChange:e=>r(e.target.value),children:[(0,C.jsx)(`option`,{value:w,children:`All Queues`}),(A?.queues??[]).map(e=>(0,C.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,C.jsx)(x,{options:T,value:E,onChange:D}),(0,C.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,C.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,C.jsx)(`input`,{value:O,onChange:e=>k(e.target.value),placeholder:`Search by ID or name…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),P&&!M&&!N?(0,C.jsx)(i,{label:`Loading jobs…`}):(0,C.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Priority`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,C.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,C.jsx)(`tbody`,{children:I.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:`No jobs found.`})}):I.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:e.id}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name||`unknown`}),(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(y,{status:String(e.state??e.status??`waiting`)})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.priority??0}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:g(e.createdAt)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:h(d(e.processedOn,e.finishedOn))}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,C.jsx)(s,{"aria-label":`Cancel job`,onClick:()=>z(e.id),children:(0,C.jsx)(c,{className:`size-3.5`})})})]},`${e.queue}:${e.id}`))})]})})]})}export{E as Jobs};
@@ -1 +0,0 @@
1
- import{r as e,t}from"./cn-CMFYpumL.js";import{d as n,m as r,r as i,t as a}from"./react-vendor-CHIHtdAC.js";import{B as o,C as ee,D as s,I as te,J as c,K as l,O as u,W as ne,Y as d,_ as f,a as re,c as ie,g as p,j as m,l as ae,n as h,o as oe,v as g,w as se,y as ce}from"./index-C9fPU4bV.js";import{a as le,i as ue}from"./form-PtDLk33Z.js";import{t as de}from"./Pagination-Cd6lHj2E.js";import{t as _}from"./jobActions-CuOdMglt.js";var v=e(r(),1),y=a(),b=[`all`,`waiting`,`active`,`completed`,`failed`],x=25;function S(e=0){return e>=10?{t:`HIGH`,c:`text-warning`}:e>=1?{t:`MEDIUM`,c:`text-blue-400`}:{t:`LOW`,c:`text-faint`}}function C(e){let t=_(e.state);return t.retryActive?p.retryJob(e.id):t.retryDlq?p.retryDlq(e.queue??``,e.id):Promise.reject(Error(`"${e.state??`unknown`}" is not retryable`))}function w(){let[e]=n(),[r,a]=(0,v.useState)(e.get(`queue`)??``),[w,fe]=(0,v.useState)(`all`),[T,pe]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),[O,k]=(0,v.useState)(new Set),[me,A]=(0,v.useState)(new Set),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(null),{data:F}=m(()=>p.queuesSummary(),[],{intervalMs:3e4}),{data:I}=m(()=>p.overview(),[],{intervalMs:1e4});(0,v.useEffect)(()=>{!r&&F?.length&&a(F[0].name)},[F,r]);let L=`${r}|${w}|${E}`,{data:R,error:z,loading:B,refetch:V}=m((0,v.useCallback)(async()=>{if(!r)return{view:L,jobs:[]};let e=w===`all`?void 0:[w];return{view:L,jobs:((await p.jobsList(r,e,x,E*x)).jobs??[]).map(e=>({...e,queue:e.queue??r}))}},[r,w,E,L]),[r,w,E]),H=R&&R.view===L?R.jobs:null,he=(H?.length??0)===x,U=(0,v.useMemo)(()=>{let e=T.trim().toLowerCase();return e?(H??[]).filter(t=>t.id.toLowerCase().includes(e)):H??[]},[H,T]),W=I?.stats,G=(0,v.useMemo)(()=>(F??[]).reduce((e,t)=>e+(t.counts?.failed??0),0),[F]),K=W?h(W.completed,G):null,q=e=>W?ie(e):`—`,J=()=>D(0);(0,v.useEffect)(()=>{k(new Set)},[r,w,E]);let ge=e=>k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Y=U.length>0&&U.every(e=>O.has(e.id)),_e=()=>k(()=>Y?new Set:new Set(U.map(e=>e.id))),X=async(e,t,n,r)=>{if(!(r&&!window.confirm(r))){A(t=>new Set(t).add(e.id)),P(null);try{await n(),P({ok:!0,text:`${t} ✓`})}catch(e){P({ok:!1,text:`${t} failed: ${e.message}`})}finally{A(t=>{let n=new Set(t);return n.delete(e.id),n}),V()}}},Z=async(e,t,n)=>{let r=U.filter(e=>O.has(e.id));if(r.length===0||n&&!window.confirm(n(r.length)))return;M(!0),P(null);let i=await Promise.allSettled(r.map(t)),a=i.filter(e=>e.status===`fulfilled`).length,o=i.length-a;P({ok:o===0,text:`${e}: ${a} succeeded${o?`, ${o} not eligible / failed`:``}`}),k(new Set),M(!1),V()},Q=U.filter(e=>O.has(e.id)),$={retry:Q.some(e=>{let t=_(e.state);return t.retryActive||t.retryDlq}),promote:Q.some(e=>_(e.state).promote),requeue:Q.some(e=>_(e.state).requeueCompleted),fail:Q.some(e=>_(e.state).fail),cancel:Q.some(e=>_(e.state).cancel)};return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(g,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!0}),(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,y.jsx)(f,{label:`Total`,value:q((W?.completed??0)+G+(W?.waiting??0)+(W?.active??0)+(W?.delayed??0)),hint:`all queues`,compact:!0}),(0,y.jsx)(f,{label:`Waiting`,value:q(W?.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(f,{label:`Active`,value:q(W?.active),tone:`blue`,compact:!0}),(0,y.jsx)(f,{label:`Completed`,value:q(W?.completed),tone:`green`,compact:!0}),(0,y.jsx)(f,{label:`Failed`,value:q(G),tone:G?`red`:`default`,compact:!0}),(0,y.jsx)(f,{label:`Error Rate`,value:K==null?`—`:ae(K),tone:K==null?`default`:K>.05?`red`:`green`,compact:!0})]}),(0,y.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-48`,children:(0,y.jsx)(le,{value:r,"aria-label":`Queue`,onChange:e=>{a(e.target.value),J()},children:(F??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,y.jsx)(ue,{options:b,value:w,onChange:e=>{fe(e),J()}}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{value:T,onChange:e=>pe(e.target.value),placeholder:`Filter this page by ID…`,"aria-label":`Filter by job ID`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),O.size>0&&(0,y.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm`,children:[(0,y.jsxs)(`span`,{className:`mr-1 text-muted`,children:[O.size,` selected`]}),$.retry&&(0,y.jsx)(s,{size:`sm`,disabled:j,onClick:()=>Z(`Retry`,C),children:`Retry selected`}),$.promote&&(0,y.jsx)(s,{size:`sm`,disabled:j,onClick:()=>Z(`Promote`,e=>_(e.state).promote?p.promoteJob(e.id):Promise.reject(Error(`"${e.state??`unknown`}" is not delayed`))),children:`Promote selected`}),$.requeue&&(0,y.jsx)(s,{size:`sm`,disabled:j,onClick:()=>Z(`Requeue`,e=>_(e.state).requeueCompleted?p.retryCompleted(e.queue??``,e.id):Promise.reject(Error(`"${e.state??`unknown`}" is not completed`))),children:`Requeue selected`}),$.fail&&(0,y.jsx)(s,{variant:`warning`,size:`sm`,disabled:j,onClick:()=>Z(`Fail`,e=>_(e.state).fail?p.failJob(e.id):Promise.reject(Error(`"${e.state??`unknown`}" is not active`)),e=>`Force-fail ${e} job(s)?`),children:`Fail selected`}),$.cancel&&(0,y.jsx)(s,{variant:`danger`,size:`sm`,disabled:j,onClick:()=>Z(`Cancel`,e=>_(e.state).cancel?p.cancelJob(e.id):Promise.reject(Error(`"${e.state??`unknown`}" cannot be cancelled`)),e=>`Cancel ${e} job(s)? This cannot be undone.`),children:`Cancel selected`}),!$.retry&&!$.promote&&!$.requeue&&!$.fail&&!$.cancel&&(0,y.jsx)(`span`,{className:`text-xs text-faint`,children:`No actions apply to the selected job states.`})]}),N&&(0,y.jsx)(`div`,{className:t(`mb-3 text-sm`,N.ok?`text-success`:`text-danger`),children:N.text}),z&&(0,y.jsx)(se,{onRetry:V}),B&&!H&&!z?(0,y.jsx)(ee,{label:`Loading jobs…`}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`w-10 px-5 py-3`,children:(0,y.jsx)(`input`,{type:`checkbox`,checked:Y,onChange:_e,"aria-label":`Select all jobs on page`,className:`accent-accent`})}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Priority`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,y.jsx)(`th`,{className:`w-28 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,y.jsx)(`tbody`,{children:U.length===0?(0,y.jsx)(`tr`,{children:(0,y.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:T.trim()?`No jobs on this page match your ID filter.`:r?`No jobs found.`:`Select a queue.`})}):U.map(e=>{let n=S(e.priority),r=_(e.state),a=me.has(e.id);return(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`input`,{type:`checkbox`,checked:O.has(e.id),onChange:()=>ge(e.id),"aria-label":`Select job ${e.id}`,className:`accent-accent`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:(0,y.jsx)(`span`,{className:`block max-w-[16rem] truncate`,title:e.id,children:e.id})}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(ce,{status:String(e.state??`waiting`)})}),(0,y.jsx)(`td`,{className:t(`px-5 py-3 text-xs font-semibold`,n.c),children:n.t}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:re(e.createdAt)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:oe(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,y.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,children:(0,y.jsx)(u,{"aria-label":`Inspect job`,children:(0,y.jsx)(o,{className:`size-3.5`})})}),r.promote&&(0,y.jsx)(u,{"aria-label":`Promote job`,disabled:a,onClick:()=>X(e,`Promote`,()=>p.promoteJob(e.id)),children:(0,y.jsx)(ne,{className:`size-3.5`})}),(r.retryActive||r.retryDlq)&&(0,y.jsx)(u,{"aria-label":`Retry job`,disabled:a,onClick:()=>X(e,`Retry`,()=>C(e)),children:(0,y.jsx)(l,{className:`size-3.5`})}),r.requeueCompleted&&(0,y.jsx)(u,{"aria-label":`Requeue job`,disabled:a,onClick:()=>X(e,`Requeue`,()=>p.retryCompleted(e.queue??``,e.id)),children:(0,y.jsx)(l,{className:`size-3.5`})}),r.fail&&(0,y.jsx)(u,{"aria-label":`Fail job`,disabled:a,onClick:()=>X(e,`Fail`,()=>p.failJob(e.id),`Force-fail this active job?`),children:(0,y.jsx)(te,{className:`size-3.5`})}),r.cancel&&(0,y.jsx)(u,{"aria-label":`Cancel job`,disabled:a,onClick:()=>X(e,`Cancel`,()=>p.cancelJob(e.id),`Cancel this job?`),children:(0,y.jsx)(d,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,y.jsx)(de,{page:E,pageSize:x,hasNext:he,onPageChange:D,label:`jobs`})]})]})}export{w as JobsPro};
@@ -1 +0,0 @@
1
- import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{H as r,J as i,M as a,S as o,_ as s,c,j as l,t as u,u as d,v as f,w as p,y as m}from"./index-C9fPU4bV.js";import{a as h,i as g}from"./form-PtDLk33Z.js";import{t as _}from"./Pagination-Cd6lHj2E.js";var v=e(t(),1),y=n(),b=`__all__`,x=[`all`,`waiting`,`active`,`completed`,`failed`],S=10;function C(){let[e,t]=(0,v.useState)(b),[n,C]=(0,v.useState)(`all`),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),{data:O}=l(()=>a.queues(500),[],{intervalMs:3e4}),{events:k,counters:A,throughput:j,connected:M}=u(e===b?void 0:e),N=(0,v.useMemo)(()=>{let e=w.trim().toLowerCase();return k.filter(t=>n!==`all`&&t.status!==n?!1:e?(t.jobId??``).toLowerCase().includes(e)||(t.name??``).toLowerCase().includes(e)||(t.queue??``).toLowerCase().includes(e):!0)},[k,n,w]);(0,v.useEffect)(()=>D(0),[e,n,w]);let P=Math.max(1,Math.ceil(N.length/S)),F=Math.min(E,P-1);return(0,y.jsxs)(`div`,{children:[!M&&k.length===0&&(0,y.jsx)(p,{}),(0,y.jsx)(f,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:M}),(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,y.jsx)(s,{label:`Total Events`,value:c(A.total),compact:!0}),(0,y.jsx)(s,{label:`Completed`,value:c(A.completed),tone:`green`,compact:!0}),(0,y.jsx)(s,{label:`Failed`,value:c(A.failed),tone:A.failed?`red`:`default`,compact:!0}),(0,y.jsx)(s,{label:`Waiting`,value:c(A.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(s,{label:`Active`,value:c(A.active),tone:`blue`,compact:!0}),(0,y.jsx)(s,{label:`Throughput`,value:`${j.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,y.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-48`,children:(0,y.jsxs)(h,{value:e,onChange:e=>t(e.target.value),children:[(0,y.jsx)(`option`,{value:b,children:`All Queues`}),(O?.queues??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,y.jsx)(g,{options:x,value:n,onChange:C}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(i,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{value:w,onChange:e=>T(e.target.value),placeholder:`Search by job name or ID…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),N.length===0?(0,y.jsx)(o,{icon:(0,y.jsx)(r,{}),title:M?`Waiting for activity…`:`Connecting to the event stream…`,hint:`Job events stream in here live as they happen on the server.`}):(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job Name`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,y.jsx)(`tbody`,{children:N.slice(F*S,F*S+S).map(e=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(m,{status:e.status})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name||`unknown`}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:d(e.timestamp)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId||`—`})]},e.seq))})]})}),(0,y.jsx)(_,{page:F,pageSize:S,total:N.length,onPageChange:D,label:`events`})]})}export{C as Logs};
@@ -1 +0,0 @@
1
- import{r as e,t}from"./cn-CMFYpumL.js";import{m as n,t as r}from"./react-vendor-CHIHtdAC.js";import{A as i,C as a,E as o,T as s,_ as c,c as l,d as u,g as d,i as f,j as p,l as m,n as h,v as g,w as _}from"./index-C9fPU4bV.js";import{t as v}from"./Pagination-Cd6lHj2E.js";import{t as y}from"./AreaChart-DzUXW8u3.js";var b=e(n(),1);function x(e=60){let[t,n]=(0,b.useState)({push:[],complete:[],fail:[],depth:[]}),[r,a]=(0,b.useState)(null),o=(0,b.useRef)(!0),s=(0,b.useRef)(!1);return(0,b.useEffect)(()=>{o.current=!0;let t=i(()=>typeof document<`u`&&document.hidden),r=async()=>{if(!s.current&&t()){s.current=!0;try{let t=await d.overview();if(!o.current)return;a(t);let r=(t.stats.waiting??0)+(t.stats.active??0)+(t.stats.delayed??0);n(n=>({push:[...n.push,t.throughput.pushPerSec].slice(-e),complete:[...n.complete,t.throughput.completePerSec].slice(-e),fail:[...n.fail,t.throughput.failPerSec].slice(-e),depth:[...n.depth,r].slice(-e)}))}catch{}finally{s.current=!1}}};r();let c=setInterval(r,1e3);return()=>{o.current=!1,clearInterval(c)}},[e]),{...t,latest:r}}function S(e){if(e.length<2)return{slope:0,label:`steady`,draining:!1};let t=e.length,n=(t-1)/2,r=e.reduce((e,t)=>e+t,0)/t,i=0,a=0;for(let o=0;o<t;o++)i+=(o-n)*(e[o]-r),a+=(o-n)**2;let o=a===0?0:i/a,s=o<-.05;return{slope:o,label:s?`draining`:o>.05?`accumulating`:`steady`,draining:s}}var C=r(),w=[`-60s`,`-45s`,`-30s`,`-15s`,`now`],T=15,E=[`push`,`pull`,`ack`],D={stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}}};function O(){let e=x(60),[n,r]=(0,b.useState)(0),{data:i,error:O,loading:M,refetch:N}=p(async()=>({details:await d.queuesSummary()}),[]),P=i?.details??[],F=Math.max(1,Math.ceil(P.length/T)),I=Math.min(n,F-1),L=(0,b.useMemo)(()=>P.slice(I*T,I*T+T),[P,I]),R=(0,b.useMemo)(()=>P.reduce((e,t)=>e+(t.counts?.failed??0),0),[P]);if(M&&!i&&!O)return(0,C.jsx)(a,{label:`Loading metrics…`});let{stats:z,throughput:B,latency:V}=e.latest??D,H=h(z.completed,R),U=S(e.depth),W=e.depth.length?e.depth[e.depth.length-1]:0;return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(g,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:!O}),O&&(0,C.jsx)(_,{onRetry:N}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,C.jsx)(c,{label:`Total Completed`,value:f(z.completed),tone:`green`,hint:`recorded jobs`}),(0,C.jsx)(c,{label:`Total Failed`,value:l(R),tone:R?`red`:`default`,hint:`recorded jobs`}),(0,C.jsx)(c,{label:`Push/sec`,value:B.pushPerSec.toFixed(1),tone:`accent`,hint:`jobs/sec`}),(0,C.jsx)(c,{label:`Pull/sec`,value:B.pullPerSec.toFixed(1),tone:`accent`,hint:`jobs/sec`})]}),(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,C.jsx)(A,{color:`#ec4899`,label:`Pushed`,value:B.pushPerSec}),(0,C.jsx)(A,{color:`#34d399`,label:`Completed`,value:B.completePerSec}),(0,C.jsx)(A,{color:`#f87171`,label:`Failed`,value:B.failPerSec})]})]}),(0,C.jsx)(y,{xLabels:w,series:[{label:`Pushed`,color:`#ec4899`,points:e.push,area:!0},{label:`Completed`,color:`#34d399`,points:e.complete},{label:`Failed`,color:`#f87171`,points:e.fail}]})]}),(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Backlog over time (waiting + active + delayed). The trend says whether you're draining or falling behind — more useful than any single gauge.`})]}),(0,C.jsxs)(`div`,{className:`text-right`,children:[(0,C.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:l(W)}),(0,C.jsx)(`div`,{className:t(`text-xs font-medium`,U.label===`draining`?`text-success`:U.label===`accumulating`?`text-danger`:`text-faint`),children:U.label===`steady`?`steady`:`${U.slope>0?`+`:``}${U.slope.toFixed(1)}/s · ${U.label}`})]})]}),(0,C.jsx)(y,{xLabels:w,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:U.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]})]}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Error Rate`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,C.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,H!=null&&H>.05?`text-danger`:`text-fg`),children:H==null?`—`:m(H)}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:`error rate`})]}),(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,H==null?`text-fg`:`text-success`),children:H==null?`—`:m(1-H)}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:`success rate`})]})]}),H==null?(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,C.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-H)*100}%`}})}),(0,C.jsxs)(`div`,{className:`mt-2 flex justify-between font-mono text-[11px] text-faint`,children:[(0,C.jsxs)(`span`,{children:[f(z.completed),` completed`]}),(0,C.jsxs)(`span`,{children:[l(R),` failed`]})]})]}),(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Server Overview`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,C.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,C.jsx)(j,{color:`bg-blue-400`,label:`Queued`,value:l(z.waiting)}),(0,C.jsx)(j,{color:`bg-accent`,label:`Processing`,value:l(z.active)}),(0,C.jsx)(j,{color:`bg-amber-400`,label:`Delayed`,value:l(z.delayed)}),(0,C.jsx)(j,{color:`bg-red-400`,label:`Dead Letter`,value:l(z.dlq)}),(0,C.jsx)(j,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:f(z.totalPushed)}),(0,C.jsx)(j,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:f(z.totalPulled)}),(0,C.jsx)(j,{color:`bg-emerald-400`,label:`Uptime`,value:u(z.uptime/1e3)})]})]})]}),(0,C.jsxs)(s,{className:`mb-6`,padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,C.jsx)(`tbody`,{children:E.map(e=>{let t=V?.percentiles?.[e],n=V?.averages?.[`${e}Ms`];return(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:e}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(n)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(t?.p50)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(t?.p95)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:k(t?.p99)})]},e)})})]})})]}),(0,C.jsxs)(s,{padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,C.jsx)(`tbody`,{children:L.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:6,className:`px-5 py-12 text-center text-sm text-faint`,children:`No queues yet.`})}):L.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:l(e.counts.waiting)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:l(e.counts.active)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:l(e.counts.completed)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:l(e.counts.failed)})]},e.name))})]})}),(0,C.jsx)(`div`,{className:`px-5 pb-4`,children:(0,C.jsx)(v,{page:I,pageSize:T,total:P.length,onPageChange:r,label:`queues`})})]})]})}function k(e){return e==null||!Number.isFinite(e)?`—`:`${e<10?e.toFixed(1):Math.round(e)}ms`}function A({color:e,label:t,value:n}){return(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,C.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}function j({color:e,label:n,value:r}){return(0,C.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,C.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,C.jsx)(`span`,{className:t(`size-2 rounded-full`,e)}),n]}),(0,C.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}export{O as MetricsPro};
@@ -1 +0,0 @@
1
- import{t as e}from"./react-vendor-CHIHtdAC.js";import{C as t,E as n,M as r,R as i,T as a,X as o,_ as s,c,d as l,j as u,l as d,n as f,r as p,v as m,w as h}from"./index-C9fPU4bV.js";var g=e(),_={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function v(){let{data:e,error:v,loading:x,refetch:S}=u(()=>r.overview(),[]);if(x&&!e&&!v)return(0,g.jsx)(t,{label:`Loading overview…`});let{stats:C,throughput:w,memory:T,workers:E,crons:D,storage:O}=e??_,k=f(C.totalCompleted,C.totalFailed)??0;return(0,g.jsxs)(`div`,{children:[v&&(0,g.jsx)(h,{onRetry:S}),(0,g.jsx)(m,{title:`Overview`,description:`Live health and throughput across all queues.`,live:!0}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,g.jsx)(s,{label:`Waiting`,value:c(C.waiting),tone:`amber`}),(0,g.jsx)(s,{label:`Active`,value:c(C.active),tone:`blue`}),(0,g.jsx)(s,{label:`Completed`,value:c(C.totalCompleted),tone:`green`}),(0,g.jsx)(s,{label:`Failed`,value:c(C.totalFailed),tone:`red`}),(0,g.jsx)(s,{label:`DLQ`,value:c(C.dlq),tone:C.dlq>0?`red`:`default`}),(0,g.jsx)(s,{label:`Error Rate`,value:d(k),tone:k>.05?`red`:`green`})]}),(0,g.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,g.jsxs)(a,{children:[(0,g.jsx)(n,{title:`Throughput`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,g.jsx)(y,{label:`Pushed`,value:w.pushPerSec,tone:`text-fg`}),(0,g.jsx)(y,{label:`Pulled`,value:w.pullPerSec,tone:`text-blue-400`}),(0,g.jsx)(y,{label:`Completed`,value:w.completePerSec,tone:`text-emerald-400`}),(0,g.jsx)(y,{label:`Failed`,value:w.failPerSec,tone:`text-red-400`})]})]}),(0,g.jsxs)(a,{children:[(0,g.jsx)(n,{title:`Resources`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,g.jsx)(b,{label:`Uptime`,value:l(C.uptime)}),(0,g.jsx)(b,{label:`Heap`,value:p(T.heapUsed*1024*1024)}),(0,g.jsx)(b,{label:`RSS`,value:p(T.rss*1024*1024)}),(0,g.jsx)(b,{label:`Storage`,value:O.diskFull?`Disk full`:`Healthy`,tone:O.diskFull?`text-red-400`:`text-emerald-400`})]})]})]}),(0,g.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,g.jsxs)(a,{children:[(0,g.jsx)(n,{title:`Workers`,icon:(0,g.jsx)(o,{className:`size-4 text-faint`}),action:(0,g.jsxs)(`span`,{className:`text-sm text-muted`,children:[(0,g.jsx)(`span`,{className:`font-semibold text-emerald-400`,children:E.active}),` /`,` `,E.total,` active`]})}),E.list.length===0?(0,g.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No workers registered.`}):(0,g.jsx)(`ul`,{className:`divide-y divide-line`,children:E.list.slice(0,6).map(e=>(0,g.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,g.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name||e.id}),(0,g.jsxs)(`span`,{className:`text-xs text-faint`,children:[e.queues.join(`, `)||`—`,` · `,c(e.processedJobs),` done`]})]},e.id))})]}),(0,g.jsxs)(a,{children:[(0,g.jsx)(n,{title:`Cron Jobs`,icon:(0,g.jsx)(i,{className:`size-4 text-faint`}),action:(0,g.jsxs)(`span`,{className:`text-sm text-muted`,children:[D.total,` scheduled`]})}),D.list.length===0?(0,g.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No cron jobs.`}):(0,g.jsx)(`ul`,{className:`divide-y divide-line`,children:D.list.slice(0,6).map(e=>(0,g.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,g.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),(0,g.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:e.schedule??(e.repeatEvery?`every ${e.repeatEvery}ms`:`—`)})]},e.name))})]})]})]})}function y({label:e,value:t,tone:n}){return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,g.jsxs)(`div`,{className:`mt-1 text-2xl font-semibold tnum ${n}`,children:[t.toFixed(1),(0,g.jsx)(`span`,{className:`ml-0.5 text-sm font-normal text-faint`,children:`/s`})]})]})}function b({label:e,value:t,tone:n=`text-fg`}){return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,g.jsx)(`div`,{className:`mt-1 text-base font-semibold ${n}`,children:t})]})}export{v as Overview};
@@ -1 +0,0 @@
1
- import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{C as r,D as i,E as a,T as o,_ as s,b as c,c as l,g as u,j as d,v as f,w as p}from"./index-C9fPU4bV.js";import{a as m,n as h,o as g,t as _}from"./form-PtDLk33Z.js";var v=e(t(),1),y=n();function b(e){let[t,n]=(0,v.useState)(e),r=(0,v.useRef)(JSON.stringify(e));return(0,v.useEffect)(()=>{let t=JSON.stringify(e);t!==r.current&&(r.current=t,n(e))},[e]),[t,n]}function x(e){let t=String(e).trim();if(t===``)return null;let n=Number(t);return Number.isFinite(n)?n:null}function S({queue:e,config:t,onSaved:n}){let[r,s]=b(t),[c,l]=(0,v.useState)(null),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(!1);return(0,y.jsxs)(o,{children:[(0,y.jsx)(a,{title:`Stall detection`}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,y.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,y.jsx)(g,{checked:r.enabled,onChange:e=>s({...r,enabled:e}),label:`enabled`}),(0,y.jsx)(`span`,{className:`text-sm text-muted`,children:`enabled`})]}),(0,y.jsx)(_,{label:`Stall interval (ms)`,children:(0,y.jsx)(h,{type:`number`,value:r.stallInterval,onChange:e=>s({...r,stallInterval:e.target.value})})}),(0,y.jsx)(_,{label:`Max stalls`,children:(0,y.jsx)(h,{type:`number`,value:r.maxStalls,onChange:e=>s({...r,maxStalls:e.target.value})})}),(0,y.jsx)(_,{label:`Grace period (ms)`,children:(0,y.jsx)(h,{type:`number`,value:r.gracePeriod,onChange:e=>s({...r,gracePeriod:e.target.value})})})]}),(0,y.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,y.jsx)(i,{variant:`accent`,size:`sm`,disabled:d,onClick:async()=>{let t=x(r.stallInterval),i=x(r.maxStalls),a=x(r.gracePeriod);if(t==null||i==null||a==null){l(`All numeric fields must be filled in`);return}f(!0),m(!1);try{l(null),await u.setStallConfig(e,{...r,stallInterval:t,maxStalls:i,gracePeriod:a}),n(),m(!0),window.setTimeout(()=>m(!1),2e3)}catch(e){l(e.message)}finally{f(!1)}},children:`Save`}),p&&(0,y.jsx)(`span`,{className:`text-xs text-success`,children:`Saved ✓`}),c&&(0,y.jsx)(`span`,{className:`text-xs text-danger`,children:c})]})]})}function C({queue:e,config:t,onSaved:n}){let[r,s]=b(t),[c,l]=(0,v.useState)(null),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(!1);return(0,y.jsxs)(o,{children:[(0,y.jsx)(a,{title:`DLQ policy`}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,y.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,y.jsx)(g,{checked:r.autoRetry,onChange:e=>s({...r,autoRetry:e}),label:`auto-retry`}),(0,y.jsx)(`span`,{className:`text-sm text-muted`,children:`auto-retry`})]}),(0,y.jsx)(_,{label:`Retry interval (ms)`,children:(0,y.jsx)(h,{type:`number`,value:r.autoRetryInterval,onChange:e=>s({...r,autoRetryInterval:e.target.value})})}),(0,y.jsx)(_,{label:`Max auto-retries`,children:(0,y.jsx)(h,{type:`number`,value:r.maxAutoRetries,onChange:e=>s({...r,maxAutoRetries:e.target.value})})}),(0,y.jsx)(_,{label:`Max age (ms)`,children:(0,y.jsx)(h,{type:`number`,value:r.maxAge??``,onChange:e=>s({...r,maxAge:e.target.value})})}),(0,y.jsx)(_,{label:`Max entries`,children:(0,y.jsx)(h,{type:`number`,value:r.maxEntries,onChange:e=>s({...r,maxEntries:e.target.value})})})]}),(0,y.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,y.jsx)(i,{variant:`accent`,size:`sm`,disabled:d,onClick:async()=>{let t=x(r.autoRetryInterval),i=x(r.maxAutoRetries),a=x(r.maxEntries),o=r.maxAge==null?null:x(r.maxAge);if(t==null||i==null||a==null){l(`All numeric fields must be filled in`);return}f(!0),m(!1);try{l(null),await u.setDlqConfig(e,{...r,autoRetryInterval:t,maxAutoRetries:i,maxAge:o,maxEntries:a}),n(),m(!0),window.setTimeout(()=>m(!1),2e3)}catch(e){l(e.message)}finally{f(!1)}},children:`Save`}),p&&(0,y.jsx)(`span`,{className:`text-xs text-success`,children:`Saved ✓`}),c&&(0,y.jsx)(`span`,{className:`text-xs text-danger`,children:c})]})]})}function w({queue:e,paused:t,busy:n,run:r}){let[s,c]=(0,v.useState)(`0`),[l,d]=(0,v.useState)(`1000`),[f,p]=(0,v.useState)(``);return(0,y.jsxs)(o,{className:`mb-6`,children:[(0,y.jsx)(a,{title:`Lifecycle`}),(0,y.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[t?(0,y.jsx)(i,{variant:`success`,size:`sm`,disabled:n,onClick:()=>r(`Resumed`,()=>u.resume(e)),children:`Resume`}):(0,y.jsx)(i,{variant:`warning`,size:`sm`,disabled:n,onClick:()=>r(`Paused`,()=>u.pause(e)),children:`Pause`}),(0,y.jsx)(i,{size:`sm`,disabled:n,onClick:()=>r(`Drained`,()=>u.drain(e),`Drain waiting jobs from "${e}"?`),children:`Drain`}),(0,y.jsx)(i,{size:`sm`,disabled:n,onClick:()=>r(`Retried completed`,()=>u.retryCompleted(e)),children:`Retry completed`}),(0,y.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,y.jsx)(`div`,{className:`w-24`,children:(0,y.jsx)(_,{label:`Promote N`,children:(0,y.jsx)(h,{type:`number`,value:f,onChange:e=>p(e.target.value),placeholder:`all`})})}),(0,y.jsx)(i,{size:`sm`,disabled:n,onClick:()=>r(`Promoted`,()=>u.promoteJobs(e,f?Number(f):void 0)),children:`Promote delayed`})]}),(0,y.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,y.jsx)(`div`,{className:`w-24`,children:(0,y.jsx)(_,{label:`Grace (ms)`,children:(0,y.jsx)(h,{type:`number`,value:s,onChange:e=>c(e.target.value)})})}),(0,y.jsx)(`div`,{className:`w-24`,children:(0,y.jsx)(_,{label:`Limit`,children:(0,y.jsx)(h,{type:`number`,value:l,onChange:e=>d(e.target.value)})})}),(0,y.jsx)(i,{variant:`danger`,size:`sm`,disabled:n,onClick:()=>r(`Cleaned`,()=>u.clean(e,{grace:Number(s),limit:Number(l)}),`Permanently delete up to ${l} completed/failed jobs older than ${s}ms from "${e}"?`),children:`Clean`})]})]})]})}function T({queue:e,busy:t,run:n}){let[r,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``);return(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,y.jsxs)(o,{children:[(0,y.jsx)(a,{title:`Rate limit`}),(0,y.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,y.jsx)(`div`,{className:`flex-1`,children:(0,y.jsx)(_,{label:`Limit`,children:(0,y.jsx)(h,{type:`number`,value:r,onChange:e=>s(e.target.value),placeholder:`max per window`})})}),(0,y.jsx)(i,{variant:`accent`,size:`sm`,disabled:t||!r,onClick:()=>n(`Rate limit set`,()=>u.setRateLimit(e,Number(r))),children:`Set`}),(0,y.jsx)(i,{size:`sm`,disabled:t,onClick:()=>n(`Rate limit cleared`,()=>u.clearRateLimit(e)),children:`Clear`})]})]}),(0,y.jsxs)(o,{children:[(0,y.jsx)(a,{title:`Concurrency`}),(0,y.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,y.jsx)(`div`,{className:`flex-1`,children:(0,y.jsx)(_,{label:`Concurrency`,children:(0,y.jsx)(h,{type:`number`,value:c,onChange:e=>l(e.target.value),placeholder:`max in-flight`})})}),(0,y.jsx)(i,{variant:`accent`,size:`sm`,disabled:t||!c,onClick:()=>n(`Concurrency set`,()=>u.setConcurrency(e,Number(c))),children:`Set`}),(0,y.jsx)(i,{size:`sm`,disabled:t,onClick:()=>n(`Concurrency cleared`,()=>u.clearConcurrency(e)),children:`Clear`})]})]})]})}var E=[`waiting`,`active`,`completed`,`failed`,`delayed`,`paused`];function D(){let[e,t]=(0,v.useState)(``),[n,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(null),{data:h}=d(()=>u.queues(),[],{intervalMs:3e4});(0,v.useEffect)(()=>{!e&&h?.queues?.length&&t(h.queues[0].name)},[h,e]);let{data:g,error:_,loading:b,refetch:x}=d((0,v.useCallback)(async()=>{if(!e)return null;let[t,n,r]=await Promise.all([u.queueDetail(e,!1),u.getStallConfig(e).catch(()=>null),u.getDlqConfig(e).catch(()=>null)]);return{queue:e,detail:t,stall:n?.config??null,dlq:r?.config??null}},[e]),[e]),D=g&&g.queue===e?g:null,O=(e,t,n)=>{n&&!window.confirm(n)||(i(!0),o(null),t().then(t=>{let n=t?.count;o({ok:!0,text:`${e}${n==null?` ✓`:`: ${n}`}`}),x()}).catch(e=>o({ok:!1,text:e.message})).finally(()=>i(!1)))};return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(f,{title:`Queue Control`,description:`Full per-queue operations and configuration.`,live:!0}),(0,y.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-56`,children:(0,y.jsx)(m,{value:e,onChange:e=>t(e.target.value),children:(h?.queues??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),D?.detail&&(0,y.jsx)(c,{label:D.detail.paused?`Paused`:`Active`,tone:D.detail.paused?`amber`:`green`}),a&&(0,y.jsx)(`span`,{className:a.ok?`text-xs text-success`:`text-xs text-danger`,children:a.text})]}),_&&(0,y.jsx)(p,{onRetry:x}),b&&!D&&!_?(0,y.jsx)(r,{}):D?.detail?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`mb-6 grid grid-cols-3 gap-3 md:grid-cols-6`,children:E.map(e=>(0,y.jsx)(s,{label:e,value:l(D.detail.counts[e]),compact:!0},e))}),(0,y.jsx)(w,{queue:e,paused:D.detail.paused,busy:n,run:O}),(0,y.jsx)(T,{queue:e,busy:n,run:O}),(0,y.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[D.stall&&(0,y.jsx)(S,{queue:e,config:D.stall,onSaved:()=>o({ok:!0,text:`Stall config saved ✓`})},e),D.dlq&&(0,y.jsx)(C,{queue:e,config:D.dlq,onSaved:()=>o({ok:!0,text:`DLQ config saved ✓`})},e)]})]}):!_&&(0,y.jsx)(`p`,{className:`text-sm text-faint`,children:`Select a queue.`})]})}export{D as QueueControl};
@@ -1 +0,0 @@
1
- import{r as e}from"./cn-CMFYpumL.js";import{l as t,m as n,r,t as i,u as a}from"./react-vendor-CHIHtdAC.js";import{C as o,D as s,F as c,M as l,N as u,O as d,T as f,U as p,V as m,W as h,X as g,_,b as v,c as y,f as b,j as x,l as S,n as C,o as w,u as T,w as E,y as D}from"./index-C9fPU4bV.js";import{n as O,t as k}from"./form-PtDLk33Z.js";var A=e(n(),1),j=i();function M({queue:e}){return(0,j.jsxs)(`div`,{className:`mt-8`,children:[(0,j.jsx)(`h2`,{className:`mb-3 text-lg font-semibold text-fg`,children:`Configuration`}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,j.jsx)(P,{queue:e}),(0,j.jsx)(F,{queue:e})]})]})}function N(){let[e,t]=(0,A.useState)(!1),[n,r]=(0,A.useState)(null),[i,a]=(0,A.useState)(!1);return{busy:e,error:n,done:i,run:async e=>{t(!0),r(null),a(!1);try{await e(),a(!0),setTimeout(()=>a(!1),2e3)}catch(e){r(e.message)}finally{t(!1)}}}}function P({queue:e}){let[t,n]=(0,A.useState)(``),{busy:r,error:i,done:a,run:o}=N();return(0,j.jsxs)(f,{children:[(0,j.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,j.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Rate Limit`}),(0,j.jsx)(m,{className:`size-4 text-faint`})]}),(0,j.jsx)(k,{label:`Max jobs / second`,children:(0,j.jsx)(O,{type:`number`,inputMode:`numeric`,placeholder:`100`,value:t,onChange:e=>n(e.target.value)})}),(0,j.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,j.jsx)(s,{variant:`accent`,size:`sm`,disabled:r||!t,onClick:()=>o(()=>l.setRateLimit(e,Number(t))),children:`Set`}),(0,j.jsx)(s,{size:`sm`,disabled:r,onClick:()=>o(()=>l.clearRateLimit(e)),children:`Clear`}),a&&(0,j.jsx)(`span`,{className:`text-xs text-emerald-400`,children:`Saved`}),i&&(0,j.jsx)(`span`,{className:`text-xs text-red-400`,children:i})]})]})}function F({queue:e}){let[t,n]=(0,A.useState)(``),{busy:r,error:i,done:a,run:o}=N();return(0,j.jsxs)(f,{children:[(0,j.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,j.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Concurrency`}),(0,j.jsx)(g,{className:`size-4 text-faint`})]}),(0,j.jsx)(k,{label:`Concurrency`,children:(0,j.jsx)(O,{type:`number`,inputMode:`numeric`,placeholder:`5`,value:t,onChange:e=>n(e.target.value)})}),(0,j.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,j.jsx)(s,{variant:`accent`,size:`sm`,disabled:r||!t,onClick:()=>o(()=>l.setConcurrency(e,Number(t))),children:`Set`}),(0,j.jsx)(s,{size:`sm`,disabled:r,onClick:()=>o(()=>l.clearConcurrency(e)),children:`Clear`}),a&&(0,j.jsx)(`span`,{className:`text-xs text-emerald-400`,children:`Saved`}),i&&(0,j.jsx)(`span`,{className:`text-xs text-red-400`,children:i})]})]})}var I=[`active`,`waiting`,`completed`,`failed`,`delayed`,`paused`],L={detail:{ok:!1,name:``,counts:{waiting:0,active:0,completed:0,failed:0,delayed:0,prioritized:0,paused:0},paused:!1,priorityCounts:{},dlqPreview:[],timestamp:0},jobs:[]};function R(){let{name:e=``}=a(),n=t(),[i,f]=(0,A.useState)(null),[m,g]=(0,A.useState)(null),{data:O,error:k,loading:N,refetch:P}=x((0,A.useCallback)(async()=>{let[t,n]=await Promise.all([l.queueDetail(e,!1),l.jobsList(e,{states:I,limit:12})]);return{detail:t,jobs:n.jobs??[]}},[e]),[e]),F=async(e,t,r)=>{if(!(r&&!window.confirm(r))){f(e),g(null);try{if(await t(),e===`obliterate`){n(`/queues`);return}await P()}catch(e){g(e.message)}finally{f(null)}}};if(N&&!O&&!k)return(0,j.jsx)(o,{label:`Loading ${e}…`});let R=O??L,{detail:z}=R,B=z.counts,V=C(B.completed??0,B.failed??0)??0,H=[...R.jobs].sort((e,t)=>(t.createdAt??0)-(e.createdAt??0));return(0,j.jsxs)(`div`,{children:[k&&(0,j.jsx)(E,{onRetry:P}),(0,j.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,j.jsx)(d,{"aria-label":`Back to queues`,onClick:()=>n(`/queues`),children:(0,j.jsx)(c,{className:`size-4`})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h1`,{className:`font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,j.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[(0,j.jsx)(v,{label:z.paused?`Paused`:`Active`,tone:z.paused?`amber`:`green`}),(0,j.jsx)(v,{label:`Live`,tone:`green`})]})]})]}),(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[z.paused?(0,j.jsxs)(s,{variant:`success`,size:`sm`,disabled:i!=null,onClick:()=>F(`resume`,()=>l.resume(e)),children:[(0,j.jsx)(h,{className:`size-3.5`}),` Resume`]}):(0,j.jsxs)(s,{variant:`warning`,size:`sm`,disabled:i!=null,onClick:()=>F(`pause`,()=>l.pause(e)),children:[(0,j.jsx)(p,{className:`size-3.5`}),` Pause`]}),(0,j.jsx)(s,{size:`sm`,disabled:i!=null,onClick:()=>F(`drain`,()=>l.drain(e),`Drain all waiting jobs from "${e}"?`),children:`Drain`}),(0,j.jsx)(s,{variant:`danger`,size:`sm`,disabled:i!=null,onClick:()=>F(`obliterate`,()=>l.obliterate(e),`Obliterate "${e}"? This removes the queue and all its jobs.`),children:`Obliterate`})]})]}),m&&(0,j.jsx)(`div`,{className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-red-400`,children:m}),(0,j.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,j.jsx)(_,{label:`Waiting`,value:y(B.waiting),tone:`amber`}),(0,j.jsx)(_,{label:`Active`,value:y(B.active),tone:`blue`}),(0,j.jsx)(_,{label:`Completed`,value:y(B.completed),tone:`green`}),(0,j.jsx)(_,{label:`Failed`,value:y(B.failed),tone:B.failed?`red`:`default`}),(0,j.jsx)(_,{label:`Delayed`,value:y(B.delayed),tone:`default`}),(0,j.jsx)(_,{label:`Error Rate`,value:S(V),tone:V>.05?`red`:`green`})]}),(0,j.jsxs)(`div`,{className:`mt-8`,children:[(0,j.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,j.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Recent Jobs`}),(0,j.jsxs)(r,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all jobs `,(0,j.jsx)(u,{className:`size-3.5`})]})]}),(0,j.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-line bg-surface`,children:(0,j.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`})]})}),(0,j.jsx)(`tbody`,{children:H.length===0?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:`No recent jobs.`})}):H.map(e=>(0,j.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.id}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.data?.name||`unknown`}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(D,{status:String(e.state??e.status??`waiting`)})}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:w(b(e.startedAt,e.completedAt))}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:T(e.createdAt)})]},e.id))})]})})]}),(0,j.jsx)(M,{queue:e})]})}export{R as QueueDetail};
@@ -1 +0,0 @@
1
- import{r as e}from"./cn-CMFYpumL.js";import{m as t,t as n}from"./react-vendor-CHIHtdAC.js";import{a as r,i}from"./connectionStore-DI-LYcct.js";import{D as a,S as o,T as s,g as c,q as l,v as u}from"./index-C9fPU4bV.js";import{a as d,n as f,r as p,t as m}from"./form-PtDLk33Z.js";var h=e(t(),1);function g(e){return{endpoint:e.endpoint,region:e.region,bucket:e.bucket,schedule:e.schedule,pathPrefix:e.pathPrefix}}var _=r()(i(e=>({endpoint:``,region:`us-east-1`,bucket:``,accessKeyId:``,secretAccessKey:``,schedule:`disabled`,pathPrefix:``,set:t=>e(t)}),{name:`bq-dash-s3`,partialize:g})),v=n();function y(){let e=_(),[t,n]=(0,h.useState)(null),[r,i]=(0,h.useState)(!1),g=e.bucket.trim()!==``;return(0,v.jsxs)(`div`,{children:[(0,v.jsx)(u,{title:`S3 Backup`,description:`Automatic backups to S3-compatible storage.`}),(0,v.jsxs)(`div`,{className:`mb-6 flex items-center justify-between rounded-xl border border-line bg-surface px-5 py-4`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,v.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg bg-surface-2 text-faint`,children:(0,v.jsx)(l,{className:`size-5`})}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`font-semibold text-fg`,children:g?`Backup configured`:`No backup configured`}),(0,v.jsx)(`div`,{className:`text-xs text-faint`,children:g?`Target: ${e.bucket}`:`Set up S3 to protect your queue data`})]})]}),(0,v.jsx)(`span`,{className:g?`rounded-full bg-emerald-500/10 px-3 py-1 text-xs font-medium text-success`:`rounded-full bg-amber-500/10 px-3 py-1 text-xs font-medium text-warning`,children:g?`Ready`:`Configure`})]}),(0,v.jsx)(`div`,{className:`mb-6 rounded-lg border border-line bg-surface/60 px-4 py-2.5 text-xs text-faint`,children:`bunqueue reads S3 backup settings from server environment variables (S3_BUCKET, S3_REGION, …). This form helps you assemble that configuration; it is stored locally in your browser.`}),(0,v.jsxs)(s,{className:`mb-6`,children:[(0,v.jsx)(`h3`,{className:`mb-1 text-base font-semibold text-fg`,children:`Connection Settings`}),(0,v.jsx)(`p`,{className:`mb-4 text-xs text-faint`,children:`Works with AWS S3, Cloudflare R2, MinIO, DigitalOcean Spaces, and any S3-compatible provider.`}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,v.jsx)(m,{label:`Endpoint`,children:(0,v.jsx)(f,{value:e.endpoint,onChange:t=>e.set({endpoint:t.target.value}),placeholder:`https://s3.amazonaws.com`})}),(0,v.jsx)(m,{label:`Region`,children:(0,v.jsx)(f,{value:e.region,onChange:t=>e.set({region:t.target.value}),placeholder:`us-east-1`})}),(0,v.jsx)(`div`,{className:`md:col-span-2`,children:(0,v.jsx)(m,{label:`Bucket name`,children:(0,v.jsx)(f,{value:e.bucket,onChange:t=>e.set({bucket:t.target.value}),placeholder:`my-bunqueue-backups`})})}),(0,v.jsx)(m,{label:`Access key ID`,children:(0,v.jsx)(f,{value:e.accessKeyId,onChange:t=>e.set({accessKeyId:t.target.value}),placeholder:`AKIA…`})}),(0,v.jsx)(m,{label:`Secret access key`,children:(0,v.jsx)(f,{type:`password`,value:e.secretAccessKey,onChange:t=>e.set({secretAccessKey:t.target.value}),placeholder:`••••••••••••••••`})}),(0,v.jsx)(`p`,{className:`-mt-2 text-xs text-faint md:col-span-2`,children:`Keys are kept in memory only and cleared on reload.`}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(p,{children:`Backup schedule`}),(0,v.jsxs)(d,{value:e.schedule,onChange:t=>e.set({schedule:t.target.value}),className:`mt-1.5`,children:[(0,v.jsx)(`option`,{value:`disabled`,children:`Disabled`}),(0,v.jsx)(`option`,{value:`6h`,children:`Every 6 hours`}),(0,v.jsx)(`option`,{value:`12h`,children:`Every 12 hours`}),(0,v.jsx)(`option`,{value:`24h`,children:`Every 24 hours`})]})]}),(0,v.jsx)(m,{label:`Path prefix (optional)`,children:(0,v.jsx)(f,{value:e.pathPrefix,onChange:t=>e.set({pathPrefix:t.target.value}),placeholder:`backups/production/`})})]}),(0,v.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-2`,children:[(0,v.jsx)(a,{variant:`accent`,onClick:()=>{i(!0),setTimeout(()=>i(!1),2e3)},children:`Save Configuration`}),(0,v.jsx)(a,{onClick:async()=>{n(null);try{let e=await c.storage();n({ok:!e.data?.diskFull,msg:e.data?.diskFull?`Server disk is full`:`Server storage reachable`})}catch(e){n({ok:!1,msg:e.message})}},children:`Test Connection`}),(0,v.jsx)(a,{disabled:!0,title:`Trigger a manual backup — requires server-side S3 config`,children:`Backup Now`}),r&&(0,v.jsx)(`span`,{className:`text-xs text-success`,children:`Saved locally (keys excluded)`}),t&&(0,v.jsx)(`span`,{className:t.ok?`text-xs text-success`:`text-xs text-danger`,children:t.msg})]})]}),(0,v.jsxs)(s,{children:[(0,v.jsx)(`h3`,{className:`mb-4 text-base font-semibold text-fg`,children:`Backup History`}),(0,v.jsx)(o,{icon:(0,v.jsx)(l,{}),title:`No backups yet`,hint:`Configure your S3 connection and run a backup to get started.`})]})]})}export{y as S3BackupPro};