streamwright-console 0.3.0__py3-none-any.whl

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 (55) hide show
  1. streamwright/console/__init__.py +29 -0
  2. streamwright/console/api/__init__.py +20 -0
  3. streamwright/console/api/acks.py +162 -0
  4. streamwright/console/api/app.py +401 -0
  5. streamwright/console/api/login.py +139 -0
  6. streamwright/console/api/logs.py +113 -0
  7. streamwright/console/api/openapi.py +205 -0
  8. streamwright/console/api/query.py +113 -0
  9. streamwright/console/auth/__init__.py +21 -0
  10. streamwright/console/auth/access.py +99 -0
  11. streamwright/console/auth/authenticator.py +45 -0
  12. streamwright/console/auth/passwords.py +83 -0
  13. streamwright/console/auth/sessions.py +65 -0
  14. streamwright/console/auth/sso.py +186 -0
  15. streamwright/console/auth/throttle.py +60 -0
  16. streamwright/console/auth/users.py +111 -0
  17. streamwright/console/cli/__init__.py +21 -0
  18. streamwright/console/cli/admin.py +267 -0
  19. streamwright/console/cli/main.py +110 -0
  20. streamwright/console/config/__init__.py +18 -0
  21. streamwright/console/config/check.py +48 -0
  22. streamwright/console/config/console.py +289 -0
  23. streamwright/console/config/login.py +141 -0
  24. streamwright/console/config/service.py +32 -0
  25. streamwright/console/db/__init__.py +18 -0
  26. streamwright/console/db/migrations/0001_console_users.py +40 -0
  27. streamwright/console/db/migrations/__init__.py +29 -0
  28. streamwright/console/db/tables/__init__.py +34 -0
  29. streamwright/console/db/tables/base.py +24 -0
  30. streamwright/console/db/tables/migrations.py +27 -0
  31. streamwright/console/db/tables/users.py +42 -0
  32. streamwright/console/db/users.py +95 -0
  33. streamwright/console/guide.md +99 -0
  34. streamwright/console/static/app.js +2014 -0
  35. streamwright/console/static/favicon.png +0 -0
  36. streamwright/console/static/favicon.svg +1 -0
  37. streamwright/console/static/index.html +66 -0
  38. streamwright/console/static/streamwright-logo-dark.svg +1 -0
  39. streamwright/console/static/style.css +410 -0
  40. streamwright/console/views/__init__.py +21 -0
  41. streamwright/console/views/attention.py +145 -0
  42. streamwright/console/views/filters.py +62 -0
  43. streamwright/console/views/job_page.py +97 -0
  44. streamwright/console/views/job_runs.py +222 -0
  45. streamwright/console/views/job_summaries.py +123 -0
  46. streamwright/console/views/overview.py +156 -0
  47. streamwright/console/views/reads.py +354 -0
  48. streamwright/console/views/run_log.py +77 -0
  49. streamwright/console/views/stores.py +190 -0
  50. streamwright_console-0.3.0.dist-info/METADATA +109 -0
  51. streamwright_console-0.3.0.dist-info/RECORD +55 -0
  52. streamwright_console-0.3.0.dist-info/WHEEL +5 -0
  53. streamwright_console-0.3.0.dist-info/entry_points.txt +5 -0
  54. streamwright_console-0.3.0.dist-info/licenses/LICENSE +201 -0
  55. streamwright_console-0.3.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,410 @@
1
+ /* Copyright 2026 Karthick Jaganathan. Licensed under the Apache License, Version 2.0. */
2
+ :root {
3
+ --bg: #f5f7fa; --panel: #ffffff; --ink: #1f2937; --muted: #6b7280; --line: #e5e7eb; --nav: #0f1b2d;
4
+ --ok: #15803d; --ok-bg: #dcfce7; --run: #1d4ed8; --run-bg: #dbeafe; --fail: #b91c1c; --fail-bg: #fee2e2;
5
+ --held: #b45309; --held-bg: #fef3c7; --rej: #a21caf; --rej-bg: #fae8ff; --idle: #4b5563; --idle-bg: #f3f4f6;
6
+ --accent: #2563eb;
7
+ }
8
+ * { box-sizing: border-box; }
9
+ body { margin: 0; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--ink);
10
+ background: var(--bg); }
11
+ code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
12
+ a { color: var(--accent); text-decoration: none; }
13
+ /* top bar */
14
+ .top { height: 56px; background: var(--nav); color: #e5e7eb; display: flex; align-items: center; gap: 18px; padding: 0 20px;
15
+ position: relative; }
16
+ .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .2px; color: #fff; }
17
+ .brand img { display: block; height: 26px; width: auto; }
18
+ .brand span { color: #93c5fd; font-size: 17px; font-weight: 800; } /* as heavy as the logo's letters */
19
+ .picker { display: flex; align-items: center; gap: 10px; background: #1c2b44; border: 1px solid #2c3e5c; border-radius: 8px;
20
+ padding: 6px 12px; cursor: pointer; min-width: 300px; max-width: 560px; }
21
+ .picker b { white-space: nowrap; } .picker .dot { flex: none; }
22
+ .picker b { color: #fff; }
23
+ .picker .stores { color: #9ca3af; font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis;
24
+ white-space: nowrap; }
25
+ .picker .caret { margin-left: auto; color: #9ca3af; }
26
+ .top .spacer { flex: 1; }
27
+ .top .user { color: #cbd5e1; font-size: 13px; }
28
+ /* dropdown: the client list, on the picker's edges */
29
+ .picker-wrap { position: relative; }
30
+ .dropdown { display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; color: var(--ink);
31
+ border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(15,27,45,.22); z-index: 10; }
32
+ .dropdown.open { display: block; }
33
+ .dropdown input { width: calc(100% - 24px); margin: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
34
+ font-size: 14px; }
35
+ .dropdown h5 { margin: 4px 14px; font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .6px; }
36
+ .dropdown .opt { display: flex; align-items: center; gap: 10px; padding: 8px 14px; width: 100%; border: 0;
37
+ background: none; color: inherit; font: inherit; text-align: left; }
38
+ .dropdown .opt:hover, .dropdown .opt.sel { background: #eff6ff; }
39
+ .dropdown .opt small { color: var(--muted); margin-left: auto; }
40
+ #picker-list { max-height: calc(100vh - 150px); overflow-y: auto; padding-bottom: 6px; } /* scrolls near the window's foot */
41
+ .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
42
+ .dot.ok { background: var(--ok); } .dot.fail { background: var(--fail); } .dot.held { background: var(--held); }
43
+ .dot.idle { background: #9ca3af; }
44
+ /* layout */
45
+ .wrap { display: flex; min-height: calc(100vh - 56px); }
46
+ .side { width: 214px; background: #fff; border-right: 1px solid var(--line); padding: 16px 10px; }
47
+ .side a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--ink);
48
+ line-height: 20px; }
49
+ .side a.active { background: #eff6ff; color: var(--accent); font-weight: 600; }
50
+ .ico { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
51
+ stroke-linecap: round; stroke-linejoin: round; }
52
+ .ico .dots { stroke-width: 2.8; }
53
+ .side a[href]:hover:not(.active) { background: #f8fafc; }
54
+ .side a .ico { color: var(--muted); } .side a.active .ico, .side a:hover .ico { color: inherit; }
55
+ .side a .count { margin-left: auto; font-size: 11px; padding: 0 6px; border-radius: 9px; background: var(--fail-bg);
56
+ color: var(--fail); font-weight: 600; }
57
+ .side h6 { margin: 18px 10px 6px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
58
+ /* a store: its dot in the icons' 16px column (names line up with the links), its name on one line, its state
59
+ (not created yet, unreachable) on the line below */
60
+ .store { display: grid; grid-template-columns: 16px minmax(0, 1fr); column-gap: 10px; align-items: center;
61
+ padding: 4px 10px; font-size: 13px; line-height: 20px; }
62
+ .store .dot { justify-self: center; }
63
+ .store .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
64
+ .store small { grid-column: 2; margin-top: -3px; color: var(--muted); font-size: 11.5px; line-height: 15px; }
65
+ main { flex: 1; padding: 22px 28px; min-width: 0; }
66
+ h1 { font-size: 20px; margin: 0 0 4px; }
67
+ .sub { color: var(--muted); margin-bottom: 18px; }
68
+ .crumbs { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
69
+ .screen { display: none; } .screen.on { display: block; }
70
+ /* cards */
71
+ .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; margin-bottom: 20px; }
72
+ .card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; }
73
+ .card .n { font-size: 26px; font-weight: 700; } .card .l { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
74
+ .card.fail .n { color: var(--fail); } .card.held .n { color: var(--held); } .card.run .n { color: var(--run); }
75
+ .card.rej .n { color: var(--rej); }
76
+ .card.ok .n { color: var(--ok); }
77
+ a.card { display: block; color: inherit; text-decoration: none; }
78
+ a.card:hover { border-color: #cbd5e1; background: #f8fafc; }
79
+ td.num.err { color: var(--fail); font-weight: 600; }
80
+ /* long text in a list: two lines at most (the whole of it on hover and on its own page) */
81
+ .clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
82
+ overflow-wrap: anywhere; min-width: 180px; max-width: 420px; }
83
+ .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 18px;
84
+ overflow-x: auto; }
85
+ .panel > h3 { margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 14px; display: flex;
86
+ align-items: center; gap: 10px; }
87
+ .panel > h3 small { color: var(--muted); font-weight: 400; }
88
+ .panel .body { padding: 14px 16px; }
89
+ /* pills */
90
+ .pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px;
91
+ border-radius: 11px; white-space: nowrap; }
92
+ .pill.ok { color: var(--ok); background: var(--ok-bg); } .pill.run { color: var(--run); background: var(--run-bg); }
93
+ .pill.fail { color: var(--fail); background: var(--fail-bg); } .pill.held { color: var(--held); background: var(--held-bg); }
94
+ .pill.idle { color: var(--idle); background: var(--idle-bg); } .pill.rej { color: var(--rej); background: var(--rej-bg); }
95
+ /* tables */
96
+ table { width: 100%; border-collapse: collapse; }
97
+ th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line);
98
+ background: #fafbfc; white-space: nowrap; position: relative; }
99
+ th.num { text-align: right; }
100
+ th .sort { font: inherit; color: inherit; background: none; border: 0; padding: 0; text-align: inherit; max-width: 100%;
101
+ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
102
+ th .sort:hover, th[aria-sort="ascending"] .sort, th[aria-sort="descending"] .sort { color: var(--ink); }
103
+ th[aria-sort="ascending"] .sort::after { content: " ▲"; font-size: 9px; }
104
+ th[aria-sort="descending"] .sort::after { content: " ▼"; font-size: 9px; }
105
+ th .grip { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; touch-action: none; }
106
+ th .grip:hover, th .grip.active { background: linear-gradient(to right, transparent 3px, var(--accent) 3px, var(--accent) 4px,
107
+ transparent 4px); }
108
+ table.fixed { table-layout: fixed; }
109
+ table.fixed th { overflow: hidden; }
110
+ table.fixed td { overflow: hidden; overflow-wrap: anywhere; }
111
+ td { padding: 10px 12px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
112
+ tr:last-child td { border-bottom: 0; }
113
+ tr.click:hover td { background: #f8fafc; cursor: pointer; }
114
+ tr.current td { background: #eff6ff; } tr.current td:first-child { font-weight: 700; }
115
+ .history { max-height: 300px; overflow-y: auto; } /* a scope's batches: about five rows */
116
+ .history th { position: sticky; top: 0; z-index: 1; } .history td.nowrap { white-space: nowrap; }
117
+ .history td.issue { max-width: 480px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
118
+ td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
119
+ td .job { font-weight: 600; } td .scope { color: var(--muted); font-size: 12px; }
120
+ td .scope.mono, td .long { max-width: 80ch; } /* a long scope or token wraps (wrapAt), not widens its column */
121
+ .muted { color: var(--muted); }
122
+ td.mono.small { font-size: 12px; min-width: 150px; width: 150px; word-break: break-all; } td.result { font-size: 13px; min-width: 140px; }
123
+ .when { white-space: nowrap; }
124
+ .issue { color: var(--fail); font-size: 13px; } .issue.held { color: var(--held); } .issue.rej { color: var(--rej); }
125
+ .issue.ok { color: var(--muted); } /* ok: known errors an error rule ignored */
126
+ td .then { color: var(--muted); font-size: 12px; } /* a rejected row: what its error rule did */
127
+ td.issue { min-width: 220px; }
128
+ .day { white-space: nowrap; font-size: 13px; }
129
+ .bars { display: flex; gap: 2px; align-items: flex-end; height: 18px; }
130
+ .bars i { width: 5px; border-radius: 1px; background: #86efac; display: block; }
131
+ .bars i.f { background: #fca5a5; } .bars i.r { background: #93c5fd; } .bars i.e { background: #e5e7eb; }
132
+ /* filters */
133
+ .filters { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
134
+ .chip { padding: 5px 11px; border-radius: 16px; border: 1px solid var(--line); background: #fff; font: inherit;
135
+ font-size: 13px; color: inherit; line-height: 1.4; }
136
+ .chip:hover:not(.on) { border-color: #cbd5e1; background: #f8fafc; }
137
+ .chip.on { background: var(--nav); color: #fff; border-color: var(--nav); }
138
+ .filters input, .filters .menu-button, .filters .date-button { padding: 6px 10px; border: 1px solid var(--line);
139
+ border-radius: 6px; font-size: 13px; background: #fff; }
140
+ .filters .chips, .filters .range { display: contents; }
141
+ .filters .spacer { flex: 1; }
142
+ /* filterButton(): the Filter button (with the count applied), its panel of rows (a column, a comparison, a value, ×)
143
+ and Apply under it, or ending at its right edge near the window's; then the filters applied as chips */
144
+ .fwrap { position: relative; display: inline-flex; }
145
+ .fbtn { height: 32px; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border: 1px solid var(--line);
146
+ border-radius: 6px; background: #fff; font: inherit; font-size: 13px; color: var(--ink); cursor: pointer; }
147
+ .fbtn:hover { border-color: #cbd5e1; }
148
+ .fbtn .ico { width: 16px; height: 16px; stroke-width: 2; color: var(--muted); }
149
+ .fbtn.on { border-color: #93c5fd; background: #eff6ff; color: var(--accent); font-weight: 600; }
150
+ .fbtn.on .ico { color: var(--accent); }
151
+ .fbtn .n:empty { display: none; }
152
+ .fbtn .n { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff;
153
+ font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
154
+ .fpop { display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: 600px; padding: 12px;
155
+ background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(15,27,45,.18); }
156
+ .fwrap.open .fpop { display: block; }
157
+ .fwrap.end .fpop { left: auto; right: 0; }
158
+ .frow { display: grid; grid-template-columns: 140px 180px 1fr 28px; gap: 8px; align-items: center; margin-bottom: 8px; }
159
+ .frow .menu, .frow .menu-button { width: 100%; }
160
+ .frow .menu-button { justify-content: space-between; }
161
+ .fx { width: 28px; height: 28px; border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: 17px;
162
+ line-height: 1; cursor: pointer; }
163
+ .fx:hover { background: #f3f4f6; color: var(--ink); }
164
+ .ffoot { display: flex; gap: 8px; align-items: center; padding-top: 10px; border-top: 1px solid var(--line); }
165
+ .fadd { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 1px dashed #93c5fd;
166
+ border-radius: 6px; background: #fff; color: var(--accent); font: inherit; font-size: 13px; font-weight: 600;
167
+ cursor: pointer; }
168
+ .fadd:hover { background: #eff6ff; }
169
+ .fadd .ico { width: 14px; height: 14px; stroke-width: 2.4; }
170
+ .fclear { border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
171
+ .fclear:hover { color: var(--ink); }
172
+ .kept { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -6px 0 14px; }
173
+ .kept:empty { display: none; }
174
+ .fchip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 14px;
175
+ background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; font-size: 13px; }
176
+ .fchip b { font-weight: 600; white-space: pre; }
177
+ .fchip button { width: 20px; height: 20px; border: 0; border-radius: 50%; background: none; color: inherit;
178
+ font: inherit; font-size: 15px; line-height: 1; cursor: pointer; }
179
+ .fchip button:hover { background: #dbeafe; }
180
+ .kept .clear { border: 0; background: none; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; }
181
+ .filters .custom { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
182
+ .pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin: -8px 0 18px; font-size: 13px;
183
+ color: var(--muted); }
184
+ .pager > span { margin-right: 4px; font-variant-numeric: tabular-nums; }
185
+ .outside { margin: -6px 0 12px; color: var(--muted); font-size: 13px; } /* jobs the period leaves out */
186
+ .pager button { padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
187
+ font: inherit; color: var(--ink); }
188
+ .pager button:disabled { color: #9ca3af; cursor: default; }
189
+ /* every control on a filter or pager row is as tall as the refresh button */
190
+ .filters input, .filters .chip, .filters .menu-button, .filters .date-button, .pager button { height: 32px; }
191
+ /* menu(): the console's own select; the button sizes to its longest option (the labels share one grid cell) and the
192
+ list is as wide as the button: around the text both take 46px (button: borders 2, padding 20, gap 10, arrow 14;
193
+ list: borders 2, padding 8, option padding 16, check 14, gap 6) */
194
+ .menu { position: relative; display: inline-flex; }
195
+ .menu-button { display: inline-flex; align-items: center; gap: 10px; font: inherit; color: var(--ink); text-align: left; }
196
+ .menu-button > .ico { width: 14px; height: 14px; stroke-width: 2; color: var(--muted); }
197
+ .menu-button:hover, .menu.open .menu-button { border-color: #cbd5e1; }
198
+ .menu-labels { display: grid; } .menu-labels > span { grid-area: 1 / 1; white-space: nowrap; }
199
+ .menu-labels > span:not(.on) { visibility: hidden; }
200
+ .menu-list { display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20; padding: 4px;
201
+ background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(15,27,45,.18);
202
+ font-size: 13px; color: var(--ink); overflow-y: auto; }
203
+ .menu.open .menu-list { display: block; }
204
+ .menu.up .menu-list { top: auto; bottom: calc(100% + 4px); }
205
+ .menu-list [role="option"] { display: flex; align-items: center; gap: 6px; padding: 6px 10px 6px 6px; border-radius: 6px;
206
+ white-space: nowrap; cursor: pointer; outline: none; }
207
+ .menu-list [role="option"]:focus { background: #eff6ff; color: var(--accent); }
208
+ .menu-list [role="option"] .ico { width: 14px; height: 14px; stroke-width: 2.2; visibility: hidden; }
209
+ .menu-list [role="option"][aria-selected="true"] .ico { visibility: visible; }
210
+ /* datePicker(): the console's own date; the calendar opens under its button like a menu's list, or ends at its right
211
+ edge when it would leave the window */
212
+ .datepick { position: relative; display: inline-flex; }
213
+ .date-button { display: inline-flex; align-items: center; gap: 8px; min-width: 132px; font: inherit; color: var(--ink);
214
+ text-align: left; white-space: nowrap; }
215
+ .date-button > .ico { width: 15px; height: 15px; color: var(--muted); }
216
+ .date-button.empty { color: var(--muted); }
217
+ .date-button:hover, .datepick.open .date-button { border-color: #cbd5e1; }
218
+ .calendar { display: none; position: absolute; top: calc(100% + 4px); left: 0; z-index: 20; width: 256px; padding: 10px;
219
+ background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(15,27,45,.18);
220
+ font-size: 13px; color: var(--ink); outline: none; }
221
+ .datepick.open .calendar { display: block; }
222
+ .datepick.end .calendar { left: auto; right: 0; }
223
+ .cal-head { display: flex; align-items: center; gap: 2px; margin: 0 0 6px 4px; }
224
+ .cal-head b { flex: 1; font-weight: 600; }
225
+ .cal-nav { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0;
226
+ border: 0; border-radius: 6px; background: none; color: var(--muted); }
227
+ .cal-nav:hover:not(:disabled) { background: #f1f5f9; color: var(--ink); }
228
+ .cal-nav:disabled { color: #d1d5db; cursor: default; }
229
+ .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
230
+ .cal-wd { padding: 4px 0; text-align: center; font-size: 11.5px; color: var(--muted); }
231
+ .cal-day { height: 32px; padding: 0; border: 0; border-radius: 6px; background: none; font: inherit; color: inherit;
232
+ font-variant-numeric: tabular-nums; }
233
+ .cal-day:hover:not([aria-disabled]) { background: #f1f5f9; }
234
+ .cal-day.out { color: #9ca3af; }
235
+ .cal-day.today { color: var(--accent); font-weight: 600; }
236
+ .cal-day.between { background: #eff6ff; }
237
+ .cal-day.edge { box-shadow: inset 0 0 0 1.5px #93c5fd; }
238
+ .cal-day.sel, .cal-day.sel:hover { background: var(--accent); color: #fff; }
239
+ .cal-day[aria-disabled] { color: #d1d5db; cursor: default; }
240
+ .cal-day:focus-visible { outline-offset: -2px; }
241
+ .cal-foot { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid #f0f2f5; }
242
+ .cal-foot button { padding: 4px 8px; border: 0; border-radius: 6px; background: none; font: inherit; color: var(--accent); }
243
+ .cal-foot button:hover:not(:disabled) { background: #eff6ff; }
244
+ .cal-foot button:disabled { color: #d1d5db; cursor: default; }
245
+ .refresh { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 32px; padding: 0;
246
+ border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--muted); }
247
+ .refresh:hover:not(:disabled) { color: var(--ink); border-color: #cbd5e1; background: #f8fafc; }
248
+ .apply { height: 32px; padding: 0 14px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font: inherit;
249
+ font-size: 13px; color: var(--ink); }
250
+ .apply:disabled { color: #9ca3af; cursor: default; }
251
+ .apply.pending { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
252
+ .apply.pending:hover { background: #1d4ed8; border-color: #1d4ed8; }
253
+ .refresh:disabled { cursor: default; }
254
+ .refresh.failed { color: var(--fail); border-color: #fecaca; }
255
+ .refresh.turning .ico { animation: turn .8s linear infinite; }
256
+ @keyframes turn { to { transform: rotate(360deg); } }
257
+ @media (prefers-reduced-motion: reduce) { .refresh.turning .ico { animation: none; opacity: .5; } }
258
+ .titlebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
259
+ .bhead .refresh { margin-left: auto; }
260
+ .pager button:hover:not(:disabled) { border-color: #cbd5e1; background: #f8fafc; }
261
+ /* everything clickable shows the hand, and a keyboard user sees where they are */
262
+ button, [role="button"], a[href], tr.click { cursor: pointer; }
263
+ button:focus-visible, [role="button"]:focus-visible, a:focus-visible, input:focus-visible {
264
+ outline: 2px solid var(--accent); outline-offset: 2px; }
265
+ /* attention list: every badge in one column as wide as the widest (unreachable), so the items' titles, details and
266
+ commands start at one edge; long text wraps inside the panel */
267
+ .att { display: grid; grid-template-columns: 104px minmax(0, 1fr); column-gap: 14px; align-items: start;
268
+ padding: 13px 16px; border-bottom: 1px solid #f0f2f5; }
269
+ .att:last-child { border-bottom: 0; }
270
+ .att > .pill { justify-content: center; margin-top: 1px; }
271
+ .att .what { min-width: 0; } .att .what b { display: block; margin-bottom: 2px; overflow-wrap: anywhere; }
272
+ .att .what .meta { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
273
+ .cmd { background: #0f172a; color: #e2e8f0; border-radius: 6px; padding: 7px 10px; margin-top: 7px; display: flex;
274
+ align-items: flex-start; gap: 10px; min-width: 0; }
275
+ .cmd code { color: #e2e8f0; flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
276
+ .cmd button { flex: none; background: #334155; color: #e2e8f0; border: 0; border-radius: 4px; padding: 2px 8px;
277
+ font-size: 12px; }
278
+ /* batch detail */
279
+ .bhead { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
280
+ .bhead .meta { color: var(--muted); font-size: 13px; }
281
+ .timeline { display: flex; align-items: flex-start; margin: 6px 0 4px; }
282
+ .step { flex: 1; text-align: center; position: relative; }
283
+ .step:before { content: ""; position: absolute; top: 11px; left: -50%; width: 100%; height: 3px; background: #bbf7d0; z-index: 0; }
284
+ .step:first-child:before { display: none; }
285
+ .step .c { width: 24px; height: 24px; border-radius: 50%; margin: 0 auto 6px; background: var(--ok); color: #fff; font-size: 13px;
286
+ line-height: 24px; position: relative; z-index: 1; }
287
+ .step.x .c { background: var(--fail); } .step.x:before { background: #fecaca; }
288
+ .step.n .c { background: #e5e7eb; color: #6b7280; } .step.n:before { background: #e5e7eb; }
289
+ .step b { display: block; font-size: 13px; } .step small { color: var(--muted); font-size: 12px; }
290
+ .grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 18px; }
291
+ .grid2.wide-first { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
292
+ dl.kv { display: grid; grid-template-columns: fit-content(40%) minmax(0, 1fr); gap: 7px 16px; margin: 0; }
293
+ dl.kv dt { color: var(--muted); overflow-wrap: anywhere; } dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
294
+ .stack { display: flex; height: 12px; border-radius: 6px; overflow: hidden; margin: 6px 0 8px; }
295
+ .stack i { display: block; } .legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
296
+ .legend b { color: var(--ink); }
297
+ .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
298
+ .btn { padding: 7px 13px; border-radius: 6px; border: 1px solid var(--line); background: #fff; font-size: 13px; }
299
+ .btn[disabled] { color: #9ca3af; background: #f9fafb; }
300
+ .note { color: var(--muted); font-size: 12.5px; }
301
+ main > .note { margin: -4px 0 12px; }
302
+ .hidden { display: none !important; }
303
+ .signed-out #picker, .signed-out #signout, .signed-out #who { visibility: hidden; }
304
+ /* the login page: single sign-on, a console user, an API key or token (folded) */
305
+ .login { max-width: 440px; margin: 56px auto; }
306
+ .login .panel .body { padding: 26px 28px 22px; }
307
+ .login h1 { font-size: 22px; margin: 0 0 4px; }
308
+ .login .sub { margin-bottom: 20px; }
309
+ .login input { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; margin: 10px 0; font-size: 14px; }
310
+ .login button, .btn.primary { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 8px 14px; font-size: 14px; cursor: pointer; }
311
+ .login .sso { width: 100%; height: 40px; display: flex; align-items: center; justify-content: center; gap: 10px;
312
+ border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: var(--ink); font: inherit;
313
+ font-weight: 600; padding: 0; }
314
+ .login .sso .ico { width: 18px; height: 18px; color: var(--accent); }
315
+ .login .or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; margin: 18px 0 4px; }
316
+ .login .or::before, .login .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
317
+ .login label { display: block; font-size: 13px; font-weight: 600; margin-top: 12px; }
318
+ .login label input { margin: 6px 0 0; font-weight: 400; }
319
+ .login form .primary { width: 100%; height: 40px; margin-top: 16px; font-weight: 600; }
320
+ .login .err { margin: 14px 0 0; font-size: 13px; background: var(--fail-bg); color: var(--fail); padding: 8px 10px;
321
+ border-radius: 6px; }
322
+ .login details { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
323
+ .login details.alone { margin-top: 0; border-top: 0; padding-top: 0; } .login details.alone summary { display: none; }
324
+ .login summary { cursor: pointer; color: var(--accent); font-size: 13px; }
325
+ .login details .note { margin-top: 8px; }
326
+ .login .row { display: flex; gap: 8px; align-items: center; }
327
+ .login .row input { margin: 10px 0; }
328
+ .login .row button { white-space: nowrap; }
329
+ .login .foot { margin-top: 18px; color: var(--muted); font-size: 12px; text-align: center; }
330
+ .login button[disabled] { opacity: .6; cursor: default; }
331
+ /* the top bar: who signed in */
332
+ .top .who { display: inline-flex; align-items: center; gap: 8px; color: #e5e7eb; font-size: 13px; }
333
+ .top .avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex;
334
+ align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
335
+ .empty { color: var(--muted); padding: 18px 16px; }
336
+ .err { color: var(--fail); }
337
+ .ribbon { position: fixed; right: 14px; bottom: 12px; background: #fde68a; color: #78350f; font-size: 12px; padding: 4px 10px;
338
+ border-radius: 6px; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
339
+ /* tabs: a job page's (Summary, Scopes, Runs: links) and the overview's attention panel's (buttons) */
340
+ .tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 2px 0 16px; }
341
+ .tabs a, .ptabs button { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-weight: 600;
342
+ border-bottom: 2px solid transparent; margin-bottom: -1px; }
343
+ .tabs a { padding: 8px 12px 9px; }
344
+ .ptabs button { padding: 12px 10px 10px; border-top: 0; border-left: 0; border-right: 0; background: none; font: inherit;
345
+ font-weight: 600; }
346
+ .tabs a:hover, .ptabs button:hover { color: var(--ink); }
347
+ .tabs a.on, .ptabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
348
+ .tabs .n, .ptabs .n { font-size: 11.5px; line-height: 18px; padding: 0 7px; border-radius: 9px; background: var(--idle-bg);
349
+ color: var(--idle); }
350
+ .ptabs .n.fail { background: var(--fail-bg); color: var(--fail); }
351
+ .panel > h3.ptabs { padding: 0 8px; gap: 2px; }
352
+ .panel .pbar { padding: 12px 16px 0; border-bottom: 1px solid var(--line); }
353
+ .panel .pbar .filters { margin-bottom: 12px; }
354
+ .panel .pbar .kept { margin: -4px 0 12px; }
355
+ .att.job { background: #f8fafc; } /* a job's items in one go, under the list */
356
+ .att .acked { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; } .att .acked i { color: var(--ink); }
357
+ .att .what b .pill { margin-left: 6px; vertical-align: 1px; }
358
+ td .hc { display: flex; flex-wrap: wrap; gap: 4px; } /* a job's scopes by health */
359
+ td.lines div { white-space: nowrap; }
360
+ td .acked { margin-top: 4px; }
361
+ /* acknowledging from the page: an item's buttons, its note box */
362
+ .acts { display: flex; gap: 8px; align-items: center; margin-top: 9px; flex-wrap: wrap; }
363
+ .acts .note { margin: 0; } .acts .err { font-size: 12.5px; }
364
+ .btn.small { padding: 4px 12px; font-size: 13px; cursor: pointer; color: var(--ink); }
365
+ .btn.small.primary { padding: 5px 13px; color: #fff; }
366
+ .btn.small[disabled] { cursor: default; opacity: .6; }
367
+ .ackform { margin-top: 9px; padding: 10px; border: 1px solid #bfdbfe; background: #eff6ff; border-radius: 8px; }
368
+ .ackform textarea { width: 100%; min-height: 56px; resize: vertical; border: 1px solid #cbd5e1; border-radius: 6px;
369
+ padding: 7px 9px; font: inherit; font-size: 13px; background: #fff; box-sizing: border-box; }
370
+ .ackform .acts { margin-top: 8px; }
371
+ /* a run's own log (--log-dir): its toolbar, where the file is, its lines; a batch's lines, by run */
372
+ .tabs .n.fail { background: var(--fail-bg); color: var(--fail); }
373
+ .panel.log .pbar .filters input.search { width: 260px; }
374
+ .panel.log .where { display: flex; gap: 14px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line);
375
+ color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
376
+ .panel.log .where .mono { color: var(--ink); overflow-wrap: anywhere; }
377
+ .panel.log .more { display: flex; justify-content: center; padding: 8px; border-bottom: 1px solid var(--line);
378
+ background: #f8fafc; }
379
+ .logscroll { max-height: 70vh; overflow: auto; } /* the last lines in view: scrolled to its end */
380
+ .loglines { width: 100%; border-collapse: collapse; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
381
+ font-size: 12px; }
382
+ .loglines td { padding: 4px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
383
+ .loglines td.t { color: var(--muted); white-space: nowrap; width: 96px; }
384
+ .loglines td.n { color: #94a3b8; text-align: right; width: 48px; white-space: nowrap; }
385
+ .loglines td.lv { width: 64px; }
386
+ .loglines td.lg { color: #475569; white-space: nowrap; width: 150px; max-width: 220px; overflow: hidden;
387
+ text-overflow: ellipsis; }
388
+ .loglines td.msg { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
389
+ .loglines tr.ERROR td { background: #fef2f2; } .loglines tr.WARNING td { background: #fffbeb; }
390
+ .lvl { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 4px; }
391
+ .lvl.ERROR { color: var(--fail); background: var(--fail-bg); } .lvl.WARNING { color: var(--held); background: var(--held-bg); }
392
+ .lvl.INFO { color: #475569; background: #f1f5f9; } .lvl.DEBUG { color: #64748b; background: #fff; border: 1px solid #e2e8f0; }
393
+ .ctx { margin-top: 3px; display: flex; gap: 6px; flex-wrap: wrap; white-space: normal; }
394
+ .ctx span, .ctx button { font: inherit; font-size: 11px; color: #475569; background: #f1f5f9; border: 0; border-radius: 4px;
395
+ padding: 0 6px; }
396
+ .ctx button { color: var(--accent); cursor: pointer; } .ctx button:hover { background: #e0e7ff; }
397
+ .exc { margin: 6px 0 2px; padding: 8px 10px; background: #0f172a; color: #e2e8f0; border-radius: 6px; font-size: 11.5px;
398
+ white-space: pre-wrap; overflow-wrap: anywhere; }
399
+ .follow { display: flex; align-items: center; gap: 8px; padding: 10px 16px; color: var(--muted); font-size: 12.5px; }
400
+ .follow .live { width: 8px; height: 8px; border-radius: 50%; background: #16a34a; box-shadow: 0 0 0 3px #dcfce7; }
401
+ .follow .live.off { background: #9ca3af; box-shadow: 0 0 0 3px #f3f4f6; }
402
+ .notice { margin: 14px 16px; padding: 12px 14px; border: 1px solid #fde68a; background: #fffbeb; border-radius: 8px;
403
+ font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
404
+ .notice code { background: #fff; border: 1px solid #fde68a; border-radius: 4px; padding: 1px 5px; }
405
+ .notice .cmd code { background: none; border: 0; padding: 0; }
406
+ .loggroup .group { padding: 8px 16px; background: #f1f5f9; font-size: 12.5px; font-weight: 600; border-bottom: 1px solid var(--line); }
407
+ .loggroup .group .muted { font-weight: 400; }
408
+ td.logcol { white-space: nowrap; font-size: 12px; line-height: 1.5; }
409
+ td.logcol .e { color: var(--fail); font-weight: 600; } td.logcol .w { color: var(--held); font-weight: 600; }
410
+ .att .loglink { font-size: 12.5px; margin-top: 4px; }
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env python
2
+ # /*************************************************************************
3
+ # * Copyright 2026 Karthick Jaganathan
4
+ # *
5
+ # * Licensed under the Apache License, Version 2.0 (the "License");
6
+ # * you may not use this file except in compliance with the License.
7
+ # * You may obtain a copy of the License at
8
+ # *
9
+ # * https://www.apache.org/licenses/LICENSE-2.0
10
+ # *
11
+ # * Unless required by applicable law or agreed to in writing, software
12
+ # * distributed under the License is distributed on an "AS IS" BASIS,
13
+ # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # * See the License for the specific language governing permissions and
15
+ # * limitations under the License.
16
+ # **************************************************************************/
17
+ """
18
+ What the console reads of each client's state databases, for its pages: the client's open stores (stores), the jobs
19
+ and scopes, batches, leases and serve runs (reads), the overview and what needs a person (overview, attention), the
20
+ jobs once each (job_summaries), a job's page (job_page), the runs of jobs (job_runs), and the lists' filters (filters).
21
+ """
@@ -0,0 +1,145 @@
1
+ #!/usr/bin/env python
2
+ # /*************************************************************************
3
+ # * Copyright 2026 Karthick Jaganathan
4
+ # *
5
+ # * Licensed under the Apache License, Version 2.0 (the "License");
6
+ # * you may not use this file except in compliance with the License.
7
+ # * You may obtain a copy of the License at
8
+ # *
9
+ # * https://www.apache.org/licenses/LICENSE-2.0
10
+ # *
11
+ # * Unless required by applicable law or agreed to in writing, software
12
+ # * distributed under the License is distributed on an "AS IS" BASIS,
13
+ # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # * See the License for the specific language governing permissions and
15
+ # * limitations under the License.
16
+ # **************************************************************************/
17
+
18
+ """
19
+ What needs a person, on the console's Overview, as the page shows it: the chips (KINDS), the items no one acknowledges
20
+ (leases past their expiry, pending migrations, stores the console cannot reach), a light item in full, and the
21
+ `streamwright state` commands that settle each. Which jobs, scopes and runs need a person, and their
22
+ acknowledgements, are core's (streamwright.core.jobs.state.attention).
23
+ """
24
+
25
+ import shlex
26
+ from types import MappingProxyType
27
+
28
+ from streamwright.core.jobs.state.attention import ACK_GROUPS, JOB_ACKS
29
+
30
+ __all__ = ["KINDS", "ack_command", "batch_commands", "group_of", "holder_run", "item_commands", "job_commands",
31
+ "other_items", "unack_command", "with_details"]
32
+
33
+ # the overview's chips: held takes the interrupted batches, other the leases, migrations and stores down
34
+ KINDS = ("failed", "held", "rejected", "run", "other")
35
+ _STATE = 'streamwright state %s --url "$STATE_URL" %s'
36
+ _WHY = MappingProxyType({"unreachable": "could not connect: check the state url, the network and the database user",
37
+ "secrets-missing": "a secret has no value: check the client's lookups and secrets",
38
+ "secrets-failed": "a secret lookup failed: see the console log",
39
+ "not-created": "no database yet: the first run of its job creates it"})
40
+
41
+
42
+ def group_of(item):
43
+ """The chip of KINDS an item counts under."""
44
+ return ACK_GROUPS.get(item["kind"], "other")
45
+
46
+
47
+ def holder_run(owner):
48
+ """The run id of a lease's holder (`<run id>/<host>:<pid>:<random>`, core's run_owner), or None."""
49
+ run_id, slash, _ = (owner or "").partition("/")
50
+ return run_id if slash and run_id else None
51
+
52
+
53
+ def other_items(expired, stores):
54
+ """The items no one acknowledges: leases past their expiry ({store: leases}), pending migrations, stores down."""
55
+ items = []
56
+ for name, leases in expired.items():
57
+ items.extend({"kind": "lease", "store": name, "job": lease["job_name"], "token": lease["token"],
58
+ "since": lease["expires_at"], "detail": "held by %s past its expiry: the next run takes it over"
59
+ % lease["owner_id"], "holder_run": holder_run(lease["owner_id"]), "ack": None, "commands": []}
60
+ for lease in leases)
61
+ for store in stores:
62
+ if store["migrations_pending"]:
63
+ items.append({"kind": "migrations", "store": store["name"], "detail": "pending: %s" % ", ".join(
64
+ store["migrations_pending"]), "ack": None, "commands": [(_STATE % ("migrate", "")).rstrip()]})
65
+ if not store["reachable"] and store["error"] != "not-created": # an empty store needs nobody
66
+ items.append({"kind": "unreachable", "store": store["name"], "ack": None, "commands": [],
67
+ "detail": _WHY.get(store["error"], store["error"])})
68
+ return items
69
+
70
+
71
+ def with_details(item, row):
72
+ """A light batch item in full, from its job and scope's row (reads: its latest batch, issue, job key)."""
73
+ last = row["last"]
74
+ return dict(item, since=last["finished_at"] or last["created_at"], detail=row["issue"],
75
+ attempts=last["attempts"], key=row.get("key"))
76
+
77
+
78
+ def ack_command(target):
79
+ return _STATE % ("ack", target) + ' --note "..."'
80
+
81
+
82
+ def unack_command(target):
83
+ return _STATE % ("unack", target)
84
+
85
+
86
+ def _forget_key(job, key):
87
+ scope = " --scope %s" % shlex.quote(key["scope"]) if key["scope"] else ""
88
+ return _STATE % ("forget-key", "--job %s%s %s" % (shlex.quote(job), scope, shlex.quote(key["job_key"])))
89
+
90
+
91
+ def item_commands(item):
92
+ """
93
+ What to run for an item: settle it (retry a failed batch, or let an abandoned one's job key go so its work runs
94
+ again; resend or skip held rows; list rejected rows; see a run's failures), then acknowledge it; acknowledged, undo
95
+ that. Leases, migrations and stores: as they were made.
96
+ """
97
+ if item["kind"] not in ACK_GROUPS:
98
+ return item["commands"]
99
+ target = item.get("job_id") or item.get("run_id")
100
+ if item["ack"]:
101
+ return [unack_command(target)]
102
+ if item["kind"] == "failed" and item.get("status") == "abandoned":
103
+ found = [_forget_key(item["job"], item["key"])] if item.get("key") else []
104
+ else:
105
+ found = {"failed": [_STATE % ("retry", target)],
106
+ "held": [_STATE % ("resend", target), _STATE % ("skip", target)],
107
+ "rejected": [_STATE % ("show", target)], # lists the rows
108
+ "interrupted": [],
109
+ "run": [_STATE % ("runs", "--run-id %s --job %s" % (target, shlex.quote(item["job"])))]}[item["kind"]]
110
+ return [*found, ack_command(target)]
111
+
112
+
113
+ def batch_commands(job, batch_id, status, *, held, problem, ack, key):
114
+ """
115
+ A batch page's commands: retry or abandon it (failed), let its job key go (abandoned, a key it claims), resend or
116
+ skip its rows in flight (`held`); acknowledge its `problem`, or undo the `ack`.
117
+ """
118
+ found = []
119
+ if status == "failed":
120
+ found += [_STATE % ("retry", batch_id), _STATE % ("abandon", batch_id)]
121
+ if status == "abandoned" and key:
122
+ found.append(_forget_key(job, key))
123
+ if held:
124
+ found += [_STATE % ("resend", batch_id), _STATE % ("skip", batch_id)]
125
+ if ack:
126
+ found.append(unack_command(batch_id))
127
+ elif problem:
128
+ found.append(ack_command(batch_id))
129
+ return found
130
+
131
+
132
+ def job_commands(items, acked, shown):
133
+ """
134
+ Per store and job of `shown` ({(store, job)}), the command that acknowledges in one go what `state ack --job`
135
+ takes of its `items` (every item of the tab, unfiltered) - or, `acked`, that undoes every acknowledgement of it;
136
+ only for two or more.
137
+ """
138
+ counts = {}
139
+ for item in items:
140
+ if item["kind"] in (ACK_GROUPS if acked else JOB_ACKS):
141
+ counts[(item["store"], item["job"])] = counts.get((item["store"], item["job"]), 0) + 1
142
+ return [{"store": store, "job": job, "items": count,
143
+ "command": unack_command("--job %s" % shlex.quote(job)) if acked
144
+ else ack_command("--job %s" % shlex.quote(job))}
145
+ for (store, job), count in sorted(counts.items()) if count > 1 and (store, job) in shown]
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env python
2
+ # /*************************************************************************
3
+ # * Copyright 2026 Karthick Jaganathan
4
+ # *
5
+ # * Licensed under the Apache License, Version 2.0 (the "License");
6
+ # * you may not use this file except in compliance with the License.
7
+ # * You may obtain a copy of the License at
8
+ # *
9
+ # * https://www.apache.org/licenses/LICENSE-2.0
10
+ # *
11
+ # * Unless required by applicable law or agreed to in writing, software
12
+ # * distributed under the License is distributed on an "AS IS" BASIS,
13
+ # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # * See the License for the specific language governing permissions and
15
+ # * limitations under the License.
16
+
17
+ """
18
+ The lists' filters, `filter=FIELD:OP:VALUE` (repeatable, all must hold; OP: contains, not_contains, equals, not_equals,
19
+ starts_with; case aside): checked against a list's fields (ValueError otherwise), then split: the `store` conditions
20
+ pick the stores read, the others go to the list's own read (streamwright.core.jobs.state.conditions).
21
+ """
22
+
23
+ import dataclasses
24
+
25
+ from streamwright.core.jobs.state.conditions import OPS, meets
26
+
27
+ __all__ = ["ATTENTION_FIELDS", "JOB_FIELDS", "JOB_RUN_FIELDS", "JOB_SUMMARY_FIELDS", "LEASE_FIELDS", "MAX_FILTERS",
28
+ "SERVE_RUN_FIELDS", "by_store", "parse_filters"]
29
+
30
+ MAX_FILTERS = 10
31
+ JOB_FIELDS = ("job", "scope", "store")
32
+ JOB_SUMMARY_FIELDS = ("job", "store")
33
+ JOB_RUN_FIELDS = ("job", "run", "store", "error")
34
+ SERVE_RUN_FIELDS = ("job", "run", "caller", "store", "error")
35
+ LEASE_FIELDS = ("job", "token", "holder", "store")
36
+ ATTENTION_FIELDS = ("job", "scope", "store", "error")
37
+
38
+
39
+ def parse_filters(values, fields):
40
+ """The (field, op, value) conditions of `values` (FIELD:OP:VALUE texts; the value may hold `:`)."""
41
+ found = []
42
+ for text in values or ():
43
+ field, _, rest = str(text).partition(":")
44
+ op, colon, value = rest.partition(":")
45
+ if not colon or field not in fields or op not in OPS or not value:
46
+ raise ValueError("filter: FIELD:OP:VALUE, FIELD one of %s, OP one of %s (got %r)" % (
47
+ ", ".join(fields), ", ".join(OPS), text))
48
+ found.append((field, op, value))
49
+ if len(found) > MAX_FILTERS:
50
+ raise ValueError("filter: at most %d" % MAX_FILTERS)
51
+ return tuple(found)
52
+
53
+
54
+ def by_store(opened, conditions):
55
+ """(the OpenClient narrowed to the stores whose names meet the `store` conditions, the other conditions)."""
56
+ mine = [condition for condition in conditions if condition[0] == "store"]
57
+ rest = tuple(condition for condition in conditions if condition[0] != "store")
58
+ if not mine:
59
+ return opened, rest
60
+ kept = {name for name in opened.client.stores if meets(mine, {"store": name})}
61
+ return dataclasses.replace(opened, stores={name: store for name, store in opened.stores.items() if name in kept},
62
+ errors={name: error for name, error in opened.errors.items() if name in kept}), rest