intentdataflow 0.3.10__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.
- intentdataflow-0.3.10.dist-info/METADATA +191 -0
- intentdataflow-0.3.10.dist-info/RECORD +83 -0
- intentdataflow-0.3.10.dist-info/WHEEL +5 -0
- intentdataflow-0.3.10.dist-info/entry_points.txt +2 -0
- intentdataflow-0.3.10.dist-info/licenses/LICENSE +202 -0
- intentdataflow-0.3.10.dist-info/licenses/NOTICE +4 -0
- intentdataflow-0.3.10.dist-info/top_level.txt +1 -0
- intentflow/__init__.py +2 -0
- intentflow/auth.py +30 -0
- intentflow/business_rules.py +77 -0
- intentflow/catalogs.py +100 -0
- intentflow/change_review.py +331 -0
- intentflow/checks/__init__.py +92 -0
- intentflow/checks/airflow3.py +174 -0
- intentflow/checks/business.py +27 -0
- intentflow/checks/catalog.py +43 -0
- intentflow/checks/cluster.py +81 -0
- intentflow/checks/contracts.py +79 -0
- intentflow/checks/cost.py +35 -0
- intentflow/checks/dbt_quality.py +90 -0
- intentflow/checks/dbt_run.py +83 -0
- intentflow/checks/deep.py +180 -0
- intentflow/checks/dq.py +53 -0
- intentflow/checks/elementary.py +50 -0
- intentflow/checks/external.py +91 -0
- intentflow/checks/lakehouse.py +46 -0
- intentflow/checks/lint.py +81 -0
- intentflow/checks/orchestration.py +148 -0
- intentflow/checks/probes.py +66 -0
- intentflow/checks/runtime_history.py +94 -0
- intentflow/checks/schema_drift.py +92 -0
- intentflow/checks/sql_quality.py +274 -0
- intentflow/checks/streaming.py +62 -0
- intentflow/cli.py +914 -0
- intentflow/contracts.py +107 -0
- intentflow/datadiff.py +172 -0
- intentflow/dbt_loader.py +194 -0
- intentflow/dbt_results.py +55 -0
- intentflow/dq_results.py +108 -0
- intentflow/extensions.py +51 -0
- intentflow/external.py +381 -0
- intentflow/http_utils.py +89 -0
- intentflow/i18n.py +76 -0
- intentflow/incidents.py +83 -0
- intentflow/integrations.py +139 -0
- intentflow/lakehouse.py +62 -0
- intentflow/lineage.py +336 -0
- intentflow/lineage_api.py +244 -0
- intentflow/lineage_oracle.py +374 -0
- intentflow/locale/pt.json +1300 -0
- intentflow/model.py +43 -0
- intentflow/monitoring.py +197 -0
- intentflow/notify.py +154 -0
- intentflow/ol_emit.py +93 -0
- intentflow/openlineage.py +168 -0
- intentflow/orchestrators/__init__.py +53 -0
- intentflow/orchestrators/airflow.py +69 -0
- intentflow/orchestrators/aws.py +93 -0
- intentflow/orchestrators/dagster.py +48 -0
- intentflow/orchestrators/dbtcloud.py +68 -0
- intentflow/orchestrators/extra.py +135 -0
- intentflow/orchestrators/ingestion.py +112 -0
- intentflow/orchestrators/kestra.py +27 -0
- intentflow/orchestrators/more.py +135 -0
- intentflow/orchestrators/prefect.py +53 -0
- intentflow/orchestrators/spark.py +118 -0
- intentflow/otel.py +53 -0
- intentflow/overview.py +123 -0
- intentflow/preflight.py +363 -0
- intentflow/promexport.py +39 -0
- intentflow/pyflow.py +554 -0
- intentflow/risks.py +178 -0
- intentflow/runner.py +264 -0
- intentflow/secrets_box.py +84 -0
- intentflow/sqlmesh_loader.py +134 -0
- intentflow/store.py +1006 -0
- intentflow/streaming.py +115 -0
- intentflow/totp.py +38 -0
- intentflow/warehouses/__init__.py +190 -0
- intentflow/warehouses/cloud.py +160 -0
- intentflow/warehouses/more.py +342 -0
- intentflow/web.html +878 -0
- intentflow/web.py +726 -0
intentflow/web.html
ADDED
|
@@ -0,0 +1,878 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
3
|
+
<title>IntentFlow</title>
|
|
4
|
+
<style>
|
|
5
|
+
:root{
|
|
6
|
+
--bg:#f6f7f9;--panel:#fff;--panel2:#f0f2f5;--line:#e3e6eb;--fg:#15191e;--mut:#5d6672;--faint:#8a93a0;
|
|
7
|
+
--acc:#4f46e5;--acc-fg:#fff;--acc-soft:#eef0ff;
|
|
8
|
+
--crit:#b42318;--crit-bg:#fee4e2;--high:#c4320a;--high-bg:#ffead5;--med:#a15c07;--med-bg:#fef0c7;--low:#175cd3;--low-bg:#d1e9ff;--info:#475467;--info-bg:#eaecf0;
|
|
9
|
+
--ok:#067647;--ok-bg:#d1fadf;--shadow:0 1px 2px rgba(16,24,40,.06),0 1px 3px rgba(16,24,40,.08);
|
|
10
|
+
--diff-add:#e6f6ec;--diff-del:#fdecea;--radius:12px}
|
|
11
|
+
@media (prefers-color-scheme:dark){:root{
|
|
12
|
+
--bg:#0f1216;--panel:#171b21;--panel2:#1d222a;--line:#2a313b;--fg:#e8eaee;--mut:#a3acb8;--faint:#7c8695;
|
|
13
|
+
--acc:#8b8cff;--acc-fg:#10121a;--acc-soft:#232650;
|
|
14
|
+
--crit:#ff8a80;--crit-bg:#3d1714;--high:#ffa062;--high-bg:#3d2312;--med:#f5c453;--med-bg:#382b0c;--low:#7db4ff;--low-bg:#14263f;--info:#b4bcc8;--info-bg:#262c35;
|
|
15
|
+
--ok:#5fd68e;--ok-bg:#0f2f1e;--shadow:none;--diff-add:#10301f;--diff-del:#3a1714}}
|
|
16
|
+
*{box-sizing:border-box}html,body{height:100%}
|
|
17
|
+
body{margin:0;background:var(--bg);color:var(--fg);font:14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Inter,sans-serif}
|
|
18
|
+
button{font:inherit;cursor:pointer}
|
|
19
|
+
:focus-visible{outline:2px solid var(--acc);outline-offset:2px}
|
|
20
|
+
.app{display:grid;grid-template-columns:240px 1fr;min-height:100%}
|
|
21
|
+
.app.login{grid-template-columns:minmax(0,1fr)}
|
|
22
|
+
aside{background:var(--panel);border-right:1px solid var(--line);padding:18px 14px;position:sticky;top:0;height:100vh;display:flex;flex-direction:column;gap:6px}
|
|
23
|
+
.logo{display:flex;align-items:center;gap:10px;font-weight:700;font-size:16px;padding:4px 8px 14px}
|
|
24
|
+
.logo i{width:28px;height:28px;border-radius:8px;background:linear-gradient(135deg,var(--acc),#a855f7);display:inline-block}
|
|
25
|
+
nav a{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:9px 10px;border-radius:8px;color:var(--mut);text-decoration:none;font-weight:500;cursor:pointer}
|
|
26
|
+
nav a:hover{background:var(--panel2);color:var(--fg)}nav a.on{background:var(--acc-soft);color:var(--acc)}
|
|
27
|
+
nav .cnt{font-size:12px;background:var(--panel2);padding:1px 8px;border-radius:99px;color:var(--mut)}
|
|
28
|
+
nav a.on .cnt{background:var(--panel);color:var(--acc)}nav .cnt.hot{background:var(--crit-bg);color:var(--crit)}
|
|
29
|
+
.side-foot{margin-top:auto;display:flex;flex-direction:column;gap:8px;padding:8px}
|
|
30
|
+
.side-foot small{color:var(--faint)}
|
|
31
|
+
main{padding:28px 36px 60px;max-width:1240px;width:100%;margin:0 auto}
|
|
32
|
+
h1{font-size:22px;margin:0 0 4px}h2{font-size:15px;margin:0}
|
|
33
|
+
.sub{color:var(--mut);margin:0 0 22px}
|
|
34
|
+
.btn{display:inline-block;text-decoration:none;border:1px solid var(--line);background:var(--panel);color:var(--fg);padding:7px 12px;border-radius:8px;font-weight:500}
|
|
35
|
+
.btn:hover{background:var(--panel2)}.btn.pri{background:var(--acc);border-color:var(--acc);color:var(--acc-fg)}.btn.pri:hover{filter:brightness(1.08)}
|
|
36
|
+
.btn.sm{padding:4px 9px;font-size:12.5px}.btn.ghost{border-color:transparent;background:transparent;color:var(--mut)}.btn[disabled]{opacity:.5;cursor:default}
|
|
37
|
+
.btn.danger{color:var(--crit)}
|
|
38
|
+
.grid{display:grid;gap:14px}.g4{grid-template-columns:repeat(auto-fit,minmax(min(200px,100%),1fr))}.g2{grid-template-columns:repeat(auto-fit,minmax(min(380px,100%),1fr))}
|
|
39
|
+
.card:has(table){overflow-x:auto}
|
|
40
|
+
.card{min-width:0;background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);padding:16px}
|
|
41
|
+
.head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:12px}
|
|
42
|
+
.kpi{display:flex;flex-direction:column;gap:2px;cursor:pointer}.kpi:hover{border-color:var(--acc)}
|
|
43
|
+
.kpi .n{font-size:30px;font-weight:700;letter-spacing:-.02em;line-height:1.1}.kpi .l{color:var(--mut)}.kpi .d{font-size:12.5px;color:var(--faint)}
|
|
44
|
+
.sev{display:inline-flex;align-items:center;gap:6px;padding:2px 9px;border-radius:99px;font-size:12px;font-weight:600;white-space:nowrap}
|
|
45
|
+
.sev::before{content:"";width:7px;height:7px;border-radius:50%;background:currentColor}
|
|
46
|
+
.sev.critical{color:var(--crit);background:var(--crit-bg)}.sev.high{color:var(--high);background:var(--high-bg)}.sev.medium{color:var(--med);background:var(--med-bg)}
|
|
47
|
+
.sev.low{color:var(--low);background:var(--low-bg)}.sev.info{color:var(--info);background:var(--info-bg)}
|
|
48
|
+
.pill{display:inline-flex;align-items:center;gap:6px;padding:2px 9px;border-radius:99px;font-size:12px;font-weight:600}
|
|
49
|
+
.pill.success,.pill.applied{color:var(--ok);background:var(--ok-bg)}.pill.failed,.pill.invalid{color:var(--crit);background:var(--crit-bg)}
|
|
50
|
+
.pill.running,.pill.queued,.pill.pending{color:var(--med);background:var(--med-bg)}.pill.approved{color:var(--low);background:var(--low-bg)}
|
|
51
|
+
.pill.other,.pill.rejected,.pill.rolled_back{color:var(--info);background:var(--info-bg)}
|
|
52
|
+
.stripe{border-left:4px solid var(--line)}.stripe.critical{border-left-color:var(--crit)}.stripe.high{border-left-color:var(--high)}.stripe.medium{border-left-color:var(--med)}
|
|
53
|
+
.stripe.low{border-left-color:var(--low)}.stripe.info{border-left-color:var(--faint)}
|
|
54
|
+
.list{display:flex;flex-direction:column;gap:10px}
|
|
55
|
+
.item{display:flex;gap:10px 12px;align-items:flex-start;justify-content:space-between;flex-wrap:wrap}.item>div:first-child{flex:1 1 260px;min-width:0}
|
|
56
|
+
.item .t{font-weight:600}.item .m{color:var(--mut);font-size:13px;margin-top:2px}
|
|
57
|
+
.meta{display:flex;gap:6px 14px;flex-wrap:wrap;color:var(--mut);font-size:12.5px;margin-top:6px}
|
|
58
|
+
.tag{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;background:var(--panel2);border:1px solid var(--line);padding:1px 7px;border-radius:6px;color:var(--mut)}
|
|
59
|
+
table{border-collapse:collapse;width:100%}th{font-size:12px;text-transform:uppercase;letter-spacing:.04em;color:var(--faint);text-align:left;font-weight:600;padding:8px 10px;border-bottom:1px solid var(--line)}
|
|
60
|
+
td{padding:10px;border-bottom:1px solid var(--line);vertical-align:top}tr:last-child td{border-bottom:0}
|
|
61
|
+
tr.row:hover{background:var(--panel2)}
|
|
62
|
+
.toolbar{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-bottom:14px}
|
|
63
|
+
.chip{border:1px solid var(--line);background:var(--panel);padding:5px 11px;border-radius:99px;font-weight:500;color:var(--mut)}
|
|
64
|
+
.chip.on{background:var(--acc-soft);border-color:var(--acc);color:var(--acc)}
|
|
65
|
+
input[type=text],input[type=search],input[type=password],select{font:inherit;color:var(--fg);background:var(--panel);border:1px solid var(--line);border-radius:8px;padding:8px 10px;min-width:0}
|
|
66
|
+
input:focus,select:focus{border-color:var(--acc);outline:none;box-shadow:0 0 0 3px var(--acc-soft)}
|
|
67
|
+
.bar{height:8px;border-radius:99px;background:var(--panel2);overflow:hidden}.bar i{display:block;height:100%;border-radius:99px;background:var(--ok);transition:width .4s}
|
|
68
|
+
.bar i.warn{background:var(--med)}.bar i.bad{background:var(--crit)}
|
|
69
|
+
.empty{text-align:center;padding:36px 16px;color:var(--mut)}.empty b{display:block;color:var(--fg);font-size:15px;margin-bottom:4px}
|
|
70
|
+
.detail{background:var(--panel2);border-radius:10px;padding:12px 14px;margin-top:10px;font-size:13px}
|
|
71
|
+
.detail dt{color:var(--faint);font-size:12px;text-transform:uppercase;letter-spacing:.04em;margin-top:8px}.detail dd{margin:2px 0 0}
|
|
72
|
+
pre{margin:0;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;word-break:break-word}
|
|
73
|
+
.diff{border:1px solid var(--line);border-radius:8px;overflow:hidden;margin-top:8px}
|
|
74
|
+
.diff div{padding:1px 10px;font:12px/1.6 ui-monospace,monospace;white-space:pre-wrap}.diff .a{background:var(--diff-add)}.diff .d{background:var(--diff-del)}.diff .h{color:var(--faint)}
|
|
75
|
+
.steps{display:flex;gap:6px;align-items:center;flex-wrap:wrap;margin:6px 0 10px}
|
|
76
|
+
.step{display:flex;align-items:center;gap:6px;color:var(--faint);font-size:12.5px}.step b{width:20px;height:20px;border-radius:50%;display:inline-grid;place-items:center;background:var(--panel2);font-size:11px}
|
|
77
|
+
.step.done{color:var(--ok)}.step.done b{background:var(--ok-bg)}.step.now{color:var(--acc);font-weight:600}.step.now b{background:var(--acc);color:var(--acc-fg)}
|
|
78
|
+
.step+.step::before{content:"›";margin-right:6px;color:var(--faint)}
|
|
79
|
+
.form{display:grid;gap:14px;grid-template-columns:repeat(auto-fit,minmax(320px,1fr))}
|
|
80
|
+
.field label{display:block;font-weight:600;margin-bottom:4px}.field small{display:block;color:var(--faint);margin-top:4px}.field input{width:100%}
|
|
81
|
+
.welcome{background:linear-gradient(135deg,var(--acc-soft),var(--panel));border:1px solid var(--line);border-radius:16px;padding:26px}
|
|
82
|
+
.welcome ol{margin:12px 0 18px;padding-left:20px;color:var(--mut)}.welcome li{margin:4px 0}
|
|
83
|
+
.toast{position:fixed;right:20px;bottom:20px;display:flex;flex-direction:column;gap:8px;z-index:9}
|
|
84
|
+
.toast div{background:var(--fg);color:var(--bg);padding:10px 14px;border-radius:10px;box-shadow:0 8px 24px rgba(0,0,0,.25);animation:in .2s}
|
|
85
|
+
.toast .err{background:var(--crit);color:#fff}
|
|
86
|
+
@keyframes in{from{transform:translateY(8px);opacity:0}}
|
|
87
|
+
.modal{position:fixed;inset:0;background:rgba(0,0,0,.45);display:grid;place-items:center;z-index:10}
|
|
88
|
+
.modal>div{background:var(--panel);border-radius:14px;padding:22px;max-width:460px;width:92%;box-shadow:0 20px 50px rgba(0,0,0,.35)}
|
|
89
|
+
.spin{display:inline-block;width:14px;height:14px;border:2px solid var(--line);border-top-color:var(--acc);border-radius:50%;animation:s .8s linear infinite;vertical-align:-2px}
|
|
90
|
+
@keyframes s{to{transform:rotate(360deg)}}
|
|
91
|
+
main{min-width:0}
|
|
92
|
+
input[type=search]{flex:1 1 200px;min-width:0}
|
|
93
|
+
@media(max-width:820px){
|
|
94
|
+
.app{grid-template-columns:minmax(0,1fr)}
|
|
95
|
+
aside{position:static;height:auto;flex-direction:column;align-items:stretch;padding:12px;gap:8px;border-right:0;border-bottom:1px solid var(--line)}
|
|
96
|
+
.logo{padding:0}
|
|
97
|
+
nav{display:flex;gap:4px;overflow-x:auto;padding-bottom:2px;-webkit-overflow-scrolling:touch}
|
|
98
|
+
nav a{white-space:nowrap;flex:0 0 auto}
|
|
99
|
+
.side-foot{margin:0;flex-direction:row;flex-wrap:wrap;align-items:center;justify-content:space-between;padding:0}
|
|
100
|
+
.side-foot select,.side-foot #who{flex:1 1 100%}
|
|
101
|
+
main{padding:16px 14px 40px}
|
|
102
|
+
h1{font-size:19px}
|
|
103
|
+
.kpi .n{font-size:26px}
|
|
104
|
+
.toolbar select{flex:1 1 140px}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.lin{display:grid;grid-template-columns:260px minmax(0,1fr);gap:16px;align-items:start}
|
|
108
|
+
.lin .models{max-height:calc(100vh - 150px);overflow:auto;padding:8px}
|
|
109
|
+
.lin .mrow{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:7px 9px;border-radius:8px;cursor:pointer;border:0;background:transparent;width:100%;text-align:left;color:var(--fg)}
|
|
110
|
+
.lin .mrow:hover{background:var(--panel2)}.lin .mrow.on{background:var(--acc-soft);color:var(--acc)}
|
|
111
|
+
.lin .mrow small{color:var(--faint)}
|
|
112
|
+
.tabs{display:flex;gap:4px;border-bottom:1px solid var(--line);margin:12px 0}
|
|
113
|
+
.tab{border:0;background:transparent;padding:8px 12px;color:var(--mut);border-bottom:2px solid transparent;font-weight:600}
|
|
114
|
+
.tab.on{color:var(--acc);border-bottom-color:var(--acc)}
|
|
115
|
+
.graph{overflow:auto;border:1px solid var(--line);border-radius:var(--radius);background:var(--panel);padding:8px}
|
|
116
|
+
.graph svg text{font:12px -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;fill:var(--fg)}
|
|
117
|
+
.graph svg .sub{fill:var(--faint);font-size:10.5px}
|
|
118
|
+
.graph .nd rect{fill:var(--panel2);stroke:var(--line)}.graph .nd:hover rect,.graph .nd:focus rect{stroke:var(--acc)}
|
|
119
|
+
.graph .nd.center rect{fill:var(--acc-soft);stroke:var(--acc);stroke-width:2}
|
|
120
|
+
.graph .nd.pii rect{stroke:var(--crit)}.graph .nd{cursor:pointer;outline:none}
|
|
121
|
+
.graph path.e{fill:none;stroke:var(--faint);stroke-width:1.4}.graph path.e.derived{stroke-dasharray:5 4}.graph path.e.masked{stroke:var(--ok)}
|
|
122
|
+
.legend{display:flex;gap:14px;flex-wrap:wrap;color:var(--mut);font-size:12px;margin:8px 2px}
|
|
123
|
+
.colrow{display:flex;gap:8px;align-items:center;justify-content:space-between;padding:7px 10px;border-radius:8px;border:1px solid var(--line);background:var(--panel);cursor:pointer;width:100%;text-align:left;color:var(--fg)}
|
|
124
|
+
.colrow:hover{border-color:var(--acc)}.colrow.on{border-color:var(--acc);background:var(--acc-soft)}
|
|
125
|
+
.colgrid{display:grid;grid-template-columns:290px minmax(0,1fr);gap:14px;align-items:start}
|
|
126
|
+
@media(max-width:1100px){.colgrid{grid-template-columns:minmax(0,1fr)}}
|
|
127
|
+
@media(max-width:820px){.lin{grid-template-columns:minmax(0,1fr)}.lin .models{max-height:220px}}
|
|
128
|
+
</style></head><body>
|
|
129
|
+
<div class="app">
|
|
130
|
+
<aside>
|
|
131
|
+
<div class="logo"><i></i>IntentFlow</div>
|
|
132
|
+
<nav id="nav" aria-label="Main navigation"></nav>
|
|
133
|
+
<div class="side-foot">
|
|
134
|
+
<button class="btn pri" id="runbtn">Check now</button>
|
|
135
|
+
<small id="lastrun">—</small>
|
|
136
|
+
<div id="who" style="display:none;margin-top:6px;font-size:12.5px;color:var(--mut)"></div>
|
|
137
|
+
</div>
|
|
138
|
+
</aside>
|
|
139
|
+
<main id="main" tabindex="-1"></main>
|
|
140
|
+
</div>
|
|
141
|
+
<div class="toast" id="toast" role="status" aria-live="polite"></div>
|
|
142
|
+
<script>
|
|
143
|
+
const I18N=/*I18N*/{"lang":"en","messages":{}};
|
|
144
|
+
const T=(s,v)=>{let r=I18N.messages[s]||s;if(v)r=r.replace(/\{(\w+)\}/g,(m,k)=>k in v?v[k]:m);return r};
|
|
145
|
+
document.documentElement.lang=I18N.lang==='pt'?'pt-BR':'en';
|
|
146
|
+
const setLang=l=>{document.cookie='if_lang='+l+';path=/;max-age=31536000;samesite=strict';location.reload()};
|
|
147
|
+
const $=s=>document.querySelector(s);
|
|
148
|
+
const SEV=['critical','high','medium','low','info'];
|
|
149
|
+
const SEVL={critical:T("Critical"),high:T("High"),medium:T("Medium"),low:T("Low"),info:'Info'};
|
|
150
|
+
const STL={success:T("Success"),failed:T("Failed"),running:T("Running"),queued:T("Queued"),other:'—',pending:T("Pending"),approved:T("Approved"),invalid:T("Invalid"),applied:T("Applied"),rejected:T("Rejected"),rolled_back:T("Rolled back")};
|
|
151
|
+
const S={project:(()=>{try{return localStorage.getItem('if_project')||''}catch(e){return ''}})(),me:null,team:[],mine:false,notes:{},view:'overview',data:null,cfg:null,sev:new Set(),check:'',q:'',open:new Set(),busy:null};
|
|
152
|
+
|
|
153
|
+
function h(tag,attrs,...kids){const e=document.createElement(tag);
|
|
154
|
+
for(const [k,v] of Object.entries(attrs||{})){if(k==='class')e.className=v;else if(k.startsWith('on'))e.addEventListener(k.slice(2),v);else if(v!==false&&v!=null)e.setAttribute(k,v===true?'':v)}
|
|
155
|
+
for(const c of kids.flat()){if(c==null||c===false)continue;e.append(c.nodeType?c:document.createTextNode(String(c)))}return e}
|
|
156
|
+
const fmtB=b=>{const u=['B','KB','MB','GB','TB'];let i=0;while(b>=1024&&i<4){b/=1024;i++}return b.toFixed(i?1:0)+' '+u[i]};
|
|
157
|
+
const ago=t=>{if(!t)return '—';const s=Math.max(0,Date.now()/1000-t);if(s<60)return T("just now");if(s<3600)return Math.floor(s/60)+T(" min ago");if(s<86400)return Math.floor(s/3600)+T(" h ago");return Math.floor(s/86400)+T(" d ago")};
|
|
158
|
+
const dur=s=>s==null?'—':s<90?s.toFixed(0)+' s':(s/60).toFixed(1)+' min';
|
|
159
|
+
const sev=s=>h('span',{class:'sev '+s},SEVL[s]||s);
|
|
160
|
+
const pill=s=>h('span',{class:'pill '+s},STL[s]||s);
|
|
161
|
+
|
|
162
|
+
function toast(msg,err){const t=h('div',{class:err?'err':''},msg);$('#toast').append(t);setTimeout(()=>t.remove(),err?6000:3200)}
|
|
163
|
+
async function api(path,opt){opt=opt||{};opt.headers={...(opt.headers||{}),'X-IntentFlow-Lang':I18N.lang,...(S.project?{'X-IntentFlow-Project':S.project}:{})};const r=await fetch(path,opt);const j=await r.json();
|
|
164
|
+
if(r.status===401){S.me={user:null,auth_required:true};S.data=null;render();throw new Error(T("Log in to continue"))}
|
|
165
|
+
if(!r.ok||j.error)throw new Error(j.error||('HTTP '+r.status));return j}
|
|
166
|
+
const post=(p,body)=>api(p,{method:'POST',headers:{'X-IntentFlow':'1','Content-Type':'application/json'},body:JSON.stringify(body||{})});
|
|
167
|
+
function confirmBox(title,text,okLabel,onOk){const prev=document.activeElement;
|
|
168
|
+
const close=()=>{m.remove();document.removeEventListener('keydown',esc);if(prev&&prev.focus)prev.focus()};
|
|
169
|
+
const esc=e=>{if(e.key==='Escape')close()};
|
|
170
|
+
const ok=h('button',{class:'btn pri',onclick:()=>{close();onOk()}},okLabel);
|
|
171
|
+
const m=h('div',{class:'modal',role:'dialog','aria-modal':'true','aria-label':title,onclick:e=>{if(e.target===m)close()}},
|
|
172
|
+
h('div',{},h('h2',{},title),h('p',{class:'sub',style:'margin:8px 0 16px'},text),
|
|
173
|
+
h('div',{style:'display:flex;gap:8px;justify-content:flex-end'},h('button',{class:'btn',onclick:close},T("Cancel")),ok)));
|
|
174
|
+
document.body.append(m);document.addEventListener('keydown',esc);ok.focus()}
|
|
175
|
+
|
|
176
|
+
S.ai=undefined;
|
|
177
|
+
async function aiLoad(force){if(!has('ai')){S.ai=null;return}if(S.ai===undefined||force){S.ai=S.ai||null;try{S.ai=await api('/api/llm')}catch(e){S.ai={llm:{configured:false},jev:{configured:false,enabled:false},triage:{}}}render()}}
|
|
178
|
+
async function act(label,fn,after){try{await fn();toast(label);}catch(e){toast(e.message,true)}await load();if(after)after()}
|
|
179
|
+
|
|
180
|
+
/* ---------- data ---------- */
|
|
181
|
+
async function loadMe(){try{const r=await fetch('/api/me');S.me=await r.json()}catch(e){S.me={user:null,auth_required:false}}}
|
|
182
|
+
async function load(){
|
|
183
|
+
if(!S.me)await loadMe();
|
|
184
|
+
if(S.me.auth_required&&!S.me.user){render();return}
|
|
185
|
+
try{[S.data,S.cfg]=await Promise.all([api('/api/overview'),api('/api/settings')])}catch(e){if(S.me&&S.me.user)toast(T("Failed to load: ")+e.message,true);return}
|
|
186
|
+
if(S.me.team&&!S.team.length){try{S.team=(await api('/api/team')).team}catch(e){}}
|
|
187
|
+
render()}
|
|
188
|
+
const sevCount=(f,s)=>f.filter(x=>x.severity===s).length;
|
|
189
|
+
|
|
190
|
+
/* ---------- navigation ---------- */
|
|
191
|
+
const VIEWS=[['overview',T("Overview")],['incidents',T("Incidents")],['findings',T("Findings")],['rules',T("Business rules")],['changes',T("Changes before production")],['lineage',T("Lineage and impact")],['diff',T("Data diff")],['pipelines','Pipelines'],['cluster',T("Cluster and memory")],['integrations',T("Integrations")],['fixes',T("Fixes")],['config',T("Settings")],['team',T("Team")],['audit',T("Audit")]];
|
|
192
|
+
const has=f=>!!(S.me&&S.me.features&&S.me.features.includes(f)); // Enterprise features reported by /api/me
|
|
193
|
+
function langSel(){if($('#langsel'))return;$('.side-foot').append(h('select',{id:'langsel','aria-label':'Language / Idioma',onchange:e=>setLang(e.target.value)},
|
|
194
|
+
[['en','English'],['pt','Português']].map(([v,l])=>h('option',{value:v,selected:v===I18N.lang},l))))}
|
|
195
|
+
function nav(){const d=S.data,n=$('#nav');n.replaceChildren();langSel();
|
|
196
|
+
const cnt={incidents:d.incidents.length,findings:d.findings.length,pipelines:d.pipelines.filter(p=>p.last_state==='failed').length,
|
|
197
|
+
fixes:d.proposals.filter(p=>['pending','approved','invalid'].includes(p.status)).length};
|
|
198
|
+
const hot={incidents:d.incidents.some(i=>['critical','high'].includes(i.severity)),pipelines:cnt.pipelines>0};
|
|
199
|
+
const isAdmin=S.me&&S.me.user&&S.me.user.role==='admin';
|
|
200
|
+
VIEWS.filter(([k])=>(k!=='team'||(S.me&&S.me.team&&isAdmin))&&(k!=='fixes'||has('fixes'))).forEach(([k,l])=>n.append(h('a',{class:S.view===k?'on':'',href:'#/'+k,'aria-current':S.view===k?'page':null,onclick:()=>{S.view=k}},h('span',{},l),
|
|
201
|
+
cnt[k]?h('span',{class:'cnt'+(hot[k]?' hot':'')},cnt[k]):null)));
|
|
202
|
+
const pj=document.getElementById('projsel');
|
|
203
|
+
if(pj){pj.remove()}
|
|
204
|
+
if(S.me&&S.me.projects&&S.me.projects.length>1){
|
|
205
|
+
const sel=h('select',{id:'projsel','aria-label':T("Project"),style:'width:100%;margin-bottom:8px',onchange:e=>{S.project=e.target.value;try{localStorage.setItem('if_project',S.project)}catch(_){ }
|
|
206
|
+
S.data=null;S.cfg=null;S.lin.models=null;S.lin.sel=null;S.teamAdmin=undefined;S.notes={};load()}},
|
|
207
|
+
S.me.projects.map(p=>h('option',{value:p.name,selected:p.name===(S.project||S.me.default_project)},p.name)));
|
|
208
|
+
document.querySelector('.side-foot').prepend(sel)}
|
|
209
|
+
const who=$('#who');
|
|
210
|
+
if(S.me&&S.me.team&&S.me.user){who.style.display='block';who.replaceChildren(h('b',{style:'color:var(--fg)'},S.me.user.name),' · '+({admin:'admin',engineer:T("engineer"),viewer:T("viewer")}[S.me.user.role]),' ',
|
|
211
|
+
h('a',{href:'#',style:'color:var(--acc)',onclick:async e=>{e.preventDefault();const r=await (await fetch('/api/logout',{method:'POST',headers:{'X-IntentFlow':'1'}})).json();if(r.logout_url){location.href=r.logout_url;return}S.me=null;S.data=null;await load()}},T("log out")),
|
|
212
|
+
S.me.user.via==='sso'?h('span',{style:'color:var(--faint)'},' · via SSO'):h('span',{},' · ',
|
|
213
|
+
h('a',{href:'#',style:'color:var(--acc)',onclick:e=>{e.preventDefault();mfaDialog()}},S.me.user.mfa?T("MFA on"):T("turn on MFA"))))}
|
|
214
|
+
else who.style.display='none';
|
|
215
|
+
const lc=S.cfg.last_check;$('#lastrun').textContent=S.cfg.running?T("Running…"):(lc?T("Last check ")+ago(lc.ts):T("No check yet"));
|
|
216
|
+
$('#runbtn').disabled=!!S.cfg.running;$('#runbtn').replaceChildren(S.cfg.running?h('span',{class:'spin'}):'',S.cfg.running?T(" Running"):T("Check now"))}
|
|
217
|
+
|
|
218
|
+
let LOGIN={needCode:false};
|
|
219
|
+
function loginView(){const inp=h('input',{type:'password',placeholder:T("Paste your token (if_…)"),style:'width:100%',autocomplete:'off',
|
|
220
|
+
onkeydown:e=>{if(e.key==='Enter')go()}});
|
|
221
|
+
const code=h('input',{type:'text',maxlength:'16',placeholder:T("6-digit code (or a recovery code)"),style:'width:100%;margin-top:10px',autocomplete:'one-time-code',
|
|
222
|
+
onkeydown:e=>{if(e.key==='Enter')go()}});
|
|
223
|
+
const go=async()=>{try{const r=await fetch('/api/login',{method:'POST',headers:{'X-IntentFlow':'1','X-IntentFlow-Lang':I18N.lang,'Content-Type':'application/json'},body:JSON.stringify({token:inp.value,code:code.value})});
|
|
224
|
+
const j=await r.json();
|
|
225
|
+
if(j.mfa_required&&!LOGIN.needCode){LOGIN.needCode=true;render();return}
|
|
226
|
+
if(!r.ok)throw new Error(j.error||T("login failed"));LOGIN.needCode=false;S.me=null;S.team=[];await load()}catch(e){toast(e.message,true)}};
|
|
227
|
+
const sso=S.me&&S.me.sso?h('div',{style:'margin-top:14px;padding-top:14px;border-top:1px solid var(--line)'},h('a',{class:'btn',style:'width:100%;text-align:center',href:'/auth/sso/login'},T("Log in with SSO"))):null;
|
|
228
|
+
return h('div',{style:'max-width:420px;margin:12vh auto'},h('div',{class:'logo',style:'justify-content:center;padding-bottom:6px'},h('i'),'IntentFlow'),
|
|
229
|
+
h('div',{class:'card'},h('h2',{style:'margin-bottom:4px'},T("Log in")),h('p',{class:'sub',style:'margin:0 0 14px'},LOGIN.needCode?T("This user has two-step verification."):T("Use the token your team administrator generated for you.")),
|
|
230
|
+
inp,LOGIN.needCode?code:null,h('div',{style:'margin-top:12px'},h('button',{class:'btn pri',onclick:go},T("Log in"))),sso))}
|
|
231
|
+
function render(){
|
|
232
|
+
const app=document.querySelector('.app');langSel();
|
|
233
|
+
if(S.me&&S.me.auth_required&&!S.me.user){app.classList.add('login');$('aside').style.display='none';$('#main').replaceChildren(loginView());return}
|
|
234
|
+
app.classList.remove('login');$('aside').style.display='';
|
|
235
|
+
if(!S.data)return;
|
|
236
|
+
nav();const m=$('#main');
|
|
237
|
+
if(document.activeElement&&['INPUT','SELECT'].includes(document.activeElement.tagName)&&m.contains(document.activeElement))return; // do not interrupt typing
|
|
238
|
+
const v={overview,incidents,findings,rules:rulesPage,changes:changesPage,lineage:lineageView,diff:diffPage,pipelines,cluster,integrations:integrationsPage,fixes,config,team:teamPage,audit}[S.view]||overview;
|
|
239
|
+
m.replaceChildren(v())}
|
|
240
|
+
|
|
241
|
+
/* ---------- components ---------- */
|
|
242
|
+
function empty(title,text,action){return h('div',{class:'card empty'},h('b',{},title),text,action?h('div',{style:'margin-top:14px'},action):null)}
|
|
243
|
+
function header(t,s,right){return h('div',{style:'display:flex;justify-content:space-between;align-items:flex-start;gap:12px;flex-wrap:wrap'},h('div',{},h('h1',{},t),h('p',{class:'sub'},s)),right||null)}
|
|
244
|
+
function incidentCard(i,compact){const open=S.open.has(i.id);
|
|
245
|
+
return h('div',{class:'card stripe '+i.severity},
|
|
246
|
+
h('div',{class:'item'},h('div',{},h('div',{class:'t'},i.title),
|
|
247
|
+
h('div',{class:'meta'},sev(i.severity),h('span',{},i.findings+T(" finding(s)")),h('span',{},i.impacted+T(" affected node(s)")),
|
|
248
|
+
i.owners.length?h('span',{},T("owner: ")+i.owners.join(', ')):h('span',{style:'color:var(--faint)'},T("no owner set")))),
|
|
249
|
+
compact?h('button',{class:'btn sm',onclick:()=>{S.view='incidents';location.hash='#/incidents';render()}},T("View")):
|
|
250
|
+
h('button',{class:'btn sm',onclick:()=>{open?S.open.delete(i.id):S.open.add(i.id);render()}},open?T("Hide"):T("Details"))),
|
|
251
|
+
!compact&&open?h('div',{class:'list',style:'margin-top:12px'},S.data.findings.filter(f=>f.incident===i.id||true).filter(f=>i.finding_ids.includes(f.id)).map(f=>findingRow(f,true))):null)}
|
|
252
|
+
function recommendation(f){return (f.evidence||{}).recommendation}
|
|
253
|
+
function triageChips(f){const t=(S.ai&&S.ai.triage||{})[f.id];if(!t)return null;const pc=v=>v==null?'—':Math.round(v*100)+'%';
|
|
254
|
+
const fp=t.likely_false_positive;
|
|
255
|
+
return h('div',{class:'meta',style:'margin-top:4px'},h('span',{class:'tag',title:T("Jev decision (")+(t.model||'')+')'},'Jev'),
|
|
256
|
+
fp!=null&&fp>=0.5?h('span',{class:'pill pending',title:T("probability of a false positive")},T("likely false positive ")+pc(fp)):h('span',{class:'tag'},'real '+pc(t.real_issue)),
|
|
257
|
+
t.urgency_label?h('span',{class:'tag'},T("urgency: ")+t.urgency_label):null,
|
|
258
|
+
t.fix_path?h('span',{class:'tag',title:T("suggested fix path")},T("path: ")+t.fix_path.replaceAll('_',' ')):null)}
|
|
259
|
+
function findingRow(f,inline){const open=S.open.has('f'+f.id);
|
|
260
|
+
const ev=f.evidence||{};
|
|
261
|
+
if(S.ai===undefined)aiLoad();
|
|
262
|
+
const ai=S.ai&&S.ai.llm&&S.ai.llm.configured,jv=S.ai&&S.ai.jev&&S.ai.jev.configured;
|
|
263
|
+
const actions=h('div',{style:'display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end'},
|
|
264
|
+
f.fix&&has('fixes')?h('button',{class:'btn sm pri',onclick:()=>act(T("Proposal created — see Fixes"),()=>post(`/api/findings/${encodeURIComponent(f.id)}/fix`),()=>{S.view='fixes';location.hash='#/fixes';render()})},T("Create fix")):null,
|
|
265
|
+
jv&&has('ai')?h('button',{class:'btn sm',title:T("Quick decision with Jev: real? false positive? urgency? which path?"),onclick:()=>act(T("Triage done"),()=>post(`/api/findings/${encodeURIComponent(f.id)}/triage`),()=>aiLoad(true))},T("Triage")):null,
|
|
266
|
+
has('fixes')&&(ai||f.check_id==='DBT003'||f.check_id==='DBT002')?h('button',{class:'btn sm',title:T("Shows the suggestion with the diff and asks whether you want to apply it"),onclick:()=>suggestModal(f)},T("Suggest fix")):null,
|
|
267
|
+
h('button',{class:'btn sm',onclick:()=>{open?S.open.delete('f'+f.id):S.open.add('f'+f.id);render()}},open?T("Hide"):T("Details")));
|
|
268
|
+
const head=h('div',{class:'item'},
|
|
269
|
+
h('div',{style:'min-width:0'},h('div',{class:'t'},f.title),
|
|
270
|
+
h('div',{class:'meta'},sev(f.severity),h('span',{class:'tag'},f.check_id),h('span',{},f.stage),ev.owner?h('span',{},T("owner: ")+ev.owner):null),triageChips(f)),
|
|
271
|
+
actions);
|
|
272
|
+
const detail=open?h('div',{class:'detail'},
|
|
273
|
+
h('div',{},f.detail||'—'),
|
|
274
|
+
recommendation(f)?h('dl',{},h('dt',{},T("Recommendation")),h('dd',{},recommendation(f))):null,
|
|
275
|
+
h('dl',{},h('dt',{},T("Affected nodes")),h('dd',{},f.nodes.length?f.nodes.map(n=>h('span',{class:'tag',style:'margin-right:4px'},n.split('.').slice(-1)[0])):'—')),
|
|
276
|
+
ev.suggested_sql?h('dl',{},h('dt',{},T("Suggested SQL")),h('dd',{},h('pre',{},ev.suggested_sql))):null,
|
|
277
|
+
assignBox(f),notesBox(f),
|
|
278
|
+
h('div',{style:'display:flex;gap:6px;margin-top:12px'},
|
|
279
|
+
h('button',{class:'btn sm',onclick:()=>act(T("Finding acknowledged"),()=>post(`/api/findings/${encodeURIComponent(f.id)}/ack`))},T("Acknowledge")),
|
|
280
|
+
h('button',{class:'btn sm',onclick:()=>act(T("Marked as a false positive"),()=>post(`/api/findings/${encodeURIComponent(f.id)}/false-positive`))},T("It is a false positive")))):null;
|
|
281
|
+
return h('div',{class:'card stripe '+f.severity,style:inline?'box-shadow:none':''},head,detail)}
|
|
282
|
+
|
|
283
|
+
/* ---------- views ---------- */
|
|
284
|
+
function overview(){const d=S.data,f=d.findings,c=d.cluster.filter(x=>x.ratio!=null).sort((a,b)=>b.ratio-a.ratio);
|
|
285
|
+
if(!S.cfg.settings['dbt.target'])return welcome();
|
|
286
|
+
const crit=sevCount(f,'critical')+sevCount(f,'high'),fail=d.pipelines.filter(p=>p.last_state==='failed'),run=d.pipelines.filter(p=>p.last_state==='running');
|
|
287
|
+
const worst=c[0];
|
|
288
|
+
return h('div',{},
|
|
289
|
+
header(T("Overview"),crit?T("{n} high or critical problem(s) need attention before reaching production.",{n:crit}):T("No high-severity problem open. ✅")),
|
|
290
|
+
h('div',{class:'grid g4'},
|
|
291
|
+
kpi(T("Open incidents"),d.incidents.length,T("{n} findings grouped by root cause",{n:f.length}),'incidents',crit?'high':null),
|
|
292
|
+
kpi(T("High or critical severity"),crit,T("{c} critical · {h} high",{c:sevCount(f,'critical'),h:sevCount(f,'high')}),'findings',crit?'critical':null),
|
|
293
|
+
kpi(T("Failing pipelines"),fail.length,T("{r} running · {n} monitored",{r:run.length,n:d.pipelines.length}),'pipelines',fail.length?'high':null),
|
|
294
|
+
kpi(T("Highest memory use"),worst?Math.round(worst.ratio*100)+'%':'—',worst?`${worst.scope}`:T("no samples"),'cluster',worst&&worst.ratio>=.8?'high':null),
|
|
295
|
+
kpi(T("Fixes in progress"),d.summary.fixes_pending,T("{n} applied",{n:d.summary.fixes_applied}),'fixes')),
|
|
296
|
+
h('div',{class:'grid g2',style:'margin-top:18px'},
|
|
297
|
+
h('div',{},h('div',{class:'head'},h('h2',{},T("Needs attention")),h('a',{class:'btn sm ghost',href:'#/incidents',onclick:()=>S.view='incidents'},T("View all"))),
|
|
298
|
+
d.incidents.length?h('div',{class:'list'},d.incidents.slice(0,4).map(i=>incidentCard(i,true))):empty(T("All good"),T("No open incident."))),
|
|
299
|
+
h('div',{},h('div',{class:'head'},h('h2',{},'Pipelines'),h('a',{class:'btn sm ghost',href:'#/pipelines',onclick:()=>S.view='pipelines'},T("View all"))),
|
|
300
|
+
d.pipelines.length?h('div',{class:'card',style:'padding:6px 10px'},h('table',{},h('tbody',{},d.pipelines.slice(0,6).map(p=>h('tr',{},
|
|
301
|
+
h('td',{},h('div',{class:'t'},p.pipeline),h('div',{class:'m',style:'color:var(--faint);font-size:12px'},p.system)),h('td',{},pill(p.last_state)),h('td',{style:'color:var(--mut)'},dur(p.last_duration))))))):
|
|
302
|
+
empty(T("No runs collected"),T("Set up Airflow/Kestra in Settings and click Check now.")))),
|
|
303
|
+
dbtCard(d));}
|
|
304
|
+
function dbtCard(d){const r=d.dbt_run;if(!r)return null;
|
|
305
|
+
const names={success:T("success"),pass:T("passed"),warn:T("warning"),fail:T("failed"),error:T("error"),skipped:T("skipped")};
|
|
306
|
+
const cls={success:'success',pass:'success',warn:'pending',fail:'failed',error:'failed',skipped:'other'};
|
|
307
|
+
const pills=Object.entries(r.counts).map(([k,v])=>h('span',{class:'pill '+(cls[k]||'other'),style:'margin-right:6px'},`${v} ${names[k]||k}`));
|
|
308
|
+
const bad=r.failing.slice(0,5).map(x=>h('div',{style:'margin-top:6px'},h('span',{class:'pill '+(x.status==='warn'?'pending':'failed'),style:'margin-right:6px'},names[x.status]||x.status),h('b',{},x.name),
|
|
309
|
+
x.failures?h('span',{style:'color:var(--mut)'},T(" — {n} row(s)",{n:x.failures})):null));
|
|
310
|
+
const slow=r.slowest.length?h('div',{style:'margin-top:12px;color:var(--mut);font-size:12.5px'},T("Slowest: ")+r.slowest.slice(0,3).map(x=>`${x.name} ${x.time}s`).join(' · ')):null;
|
|
311
|
+
return h('div',{class:'card',style:'margin-top:18px'},h('div',{class:'head'},h('h2',{},T("Last dbt run ({command})",{command:r.command||'?'})),h('span',{style:'color:var(--faint);font-size:12.5px'},r.elapsed!=null?r.elapsed.toFixed(1)+' s':'')),
|
|
312
|
+
h('div',{},pills),bad,slow)}
|
|
313
|
+
function kpi(label,n,d,view,tone){const go=()=>{S.view=view;location.hash='#/'+view;render()};
|
|
314
|
+
const c=h('div',{class:'card kpi',role:'link',tabindex:'0','aria-label':label+': '+n,onclick:go,onkeydown:e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();go()}}},
|
|
315
|
+
h('div',{class:'l'},label),h('div',{class:'n',style:tone?`color:var(--${tone==='critical'?'crit':tone})`:''},String(n)),h('div',{class:'d'},d));return c}
|
|
316
|
+
function welcome(){const inp=h('input',{type:'text',placeholder:T("/path/to/project/target"),style:'width:100%;max-width:520px'});
|
|
317
|
+
return h('div',{},header(T("Welcome to IntentFlow"),T("Find problems in your pipelines before they reach production.")),
|
|
318
|
+
h('div',{class:'welcome'},h('h2',{style:'font-size:18px'},T("Start in 1 minute")),
|
|
319
|
+
h('ol',{},h('li',{},T("In your dbt project run "),h('span',{class:'tag'},'dbt build && dbt docs generate')),
|
|
320
|
+
h('li',{},T("Enter the "),h('span',{class:'tag'},'target/'),T(" directory below (it has manifest.json and catalog.json)")),
|
|
321
|
+
h('li',{},T("Click "),h('b',{},T("Run the first check")))),
|
|
322
|
+
h('div',{style:'display:flex;gap:8px;flex-wrap:wrap'},inp,
|
|
323
|
+
h('button',{class:'btn pri',onclick:()=>{if(!inp.value.trim())return toast(T("Enter the target/ directory"),true);
|
|
324
|
+
act(T("Check started"),async()=>{await post('/api/settings',{key:'dbt.target',value:inp.value.trim()});await post('/api/run/check')})}},T("Run the first check"))),
|
|
325
|
+
h('p',{style:'color:var(--faint);margin:14px 0 0;font-size:12.5px'},T("Everything stays on your machine. Secrets are never stored — only environment variable names."))))}
|
|
326
|
+
function incidents(){const d=S.data;
|
|
327
|
+
return h('div',{},header(T("Incidents"),T("Findings grouped by root cause: fix the origin and the rest go away with it.")),
|
|
328
|
+
d.incidents.length?h('div',{class:'list'},d.incidents.map(i=>incidentCard(i,false))):empty(T("No open incident"),T("Click Check now to refresh.")))}
|
|
329
|
+
function findings(){const d=S.data;
|
|
330
|
+
let fl=d.findings.filter(x=>(!S.sev.size||S.sev.has(x.severity))&&(!S.check||x.check_id===S.check)&&(!S.q||(x.title+x.detail+x.check_id).toLowerCase().includes(S.q.toLowerCase())));
|
|
331
|
+
const checks=[...new Set(d.findings.map(x=>x.check_id))].sort();
|
|
332
|
+
const q=h('input',{type:'search',placeholder:T("Search by model, table or text…"),value:S.q,oninput:e=>{
|
|
333
|
+
S.q=e.target.value;clearTimeout(S.t);S.t=setTimeout(()=>{$('#main').replaceChildren(findings());const n=$('#main input[type=search]');if(n){n.focus();n.setSelectionRange(S.q.length,S.q.length)}},150)}});
|
|
334
|
+
const sel=h('select',{onchange:e=>{S.check=e.target.value;render()}},h('option',{value:''},T("All checks")),checks.map(c=>h('option',{value:c,selected:c===S.check},c)));
|
|
335
|
+
const chips=SEV.map(s=>h('button',{class:'chip'+(S.sev.has(s)?' on':''),onclick:()=>{S.sev.has(s)?S.sev.delete(s):S.sev.add(s);render()}},`${SEVL[s]} · ${sevCount(d.findings,s)}`));
|
|
336
|
+
const mine=(S.me&&S.me.team&&S.me.user)?h('button',{class:'chip'+(S.mine?' on':''),onclick:()=>{S.mine=!S.mine;render()}},T("My items")):null;
|
|
337
|
+
if(S.mine&&S.me.user)fl=fl.filter(x=>x.assignee===S.me.user.name);
|
|
338
|
+
const clear=h('button',{class:'btn',onclick:()=>{S.sev.clear();S.check='';S.q='';S.mine=false;render()}},T("Clear filters"));
|
|
339
|
+
const statRows=d.check_stats.map(c=>h('tr',{},h('td',{},h('span',{class:'tag'},c.check)),h('td',{},c.total),h('td',{},c.open),h('td',{},c.resolved),
|
|
340
|
+
h('td',{},c.false_positive),h('td',{},c.fp_rate==null?'—':Math.round(c.fp_rate*100)+'%'),
|
|
341
|
+
h('td',{},c.suggest_disable?h('span',{class:'sev high'},T("consider turning off")):'')));
|
|
342
|
+
const statsHead=h('tr',{},['Check','Total',T("Open"),T("Resolved"),T("False positives"),T("Rate"),''].map(t=>h('th',{},t)));
|
|
343
|
+
const stats=d.check_stats.length?h('div',{style:'margin-top:26px'},
|
|
344
|
+
h('div',{class:'head'},h('h2',{},T("Precision per check")),h('small',{style:'color:var(--faint)'},T("based on the \"false positives\" you marked"))),
|
|
345
|
+
h('div',{class:'card',style:'padding:6px 10px'},h('table',{},h('thead',{},statsHead),h('tbody',{},statRows)))):null;
|
|
346
|
+
return h('div',{},header(T("Findings"),T("{shown} of {total} shown. Click \"Details\" to see the recommendation.",{shown:fl.length,total:d.findings.length})),
|
|
347
|
+
h('div',{class:'toolbar'},mine,chips,sel,q),
|
|
348
|
+
fl.length?h('div',{class:'list'},fl.map(f=>findingRow(f))):empty(T("Nothing with these filters"),T("Adjust the search or clear the filters."),clear),
|
|
349
|
+
stats)}
|
|
350
|
+
function pipelines(){const d=S.data,rows=d.pipelines;
|
|
351
|
+
const collect=h('button',{class:'btn',onclick:()=>act(T("Collection started"),()=>post('/api/run/runs'))},T("Collect now"));
|
|
352
|
+
const link=p=>p.url?h('a',{href:p.url,target:'_blank',rel:'noopener',style:'color:var(--acc);font-weight:600;text-decoration:none'},p.pipeline):h('b',{},p.pipeline);
|
|
353
|
+
const trs=rows.map(p=>h('tr',{class:'row'},h('td',{},link(p)),h('td',{},p.system),h('td',{},pill(p.last_state)),h('td',{},p.runs),
|
|
354
|
+
h('td',{style:p.failed?'color:var(--crit);font-weight:600':''},p.failed),h('td',{},dur(p.last_duration)),h('td',{style:'color:var(--mut)'},ago(p.last_start))));
|
|
355
|
+
const heads=['Pipeline',T("System"),T("State"),T("Runs"),T("Failures"),T("Last duration"),T("Last start")].map(t=>h('th',{},t));
|
|
356
|
+
const table=h('div',{class:'card',style:'padding:6px 10px'},h('table',{},h('thead',{},h('tr',{},heads)),h('tbody',{},trs)));
|
|
357
|
+
const toConfig=h('a',{class:'btn pri',href:'#/config',onclick:()=>{S.view='config'}},T("Go to Settings"));
|
|
358
|
+
const tags=xs=>xs.map(x=>h('span',{class:'tag',style:'margin-right:4px'},x));
|
|
359
|
+
const olRows=d.openlineage.map(j=>h('tr',{},h('td',{},h('b',{},j.job)),h('td',{},tags(j.inputs)),h('td',{},tags(j.outputs))));
|
|
360
|
+
const ol=d.openlineage.length?h('div',{style:'margin-top:24px'},h('h2',{style:'margin-bottom:10px'},T("Jobs seen through OpenLineage")),
|
|
361
|
+
h('div',{class:'card',style:'padding:6px 10px'},h('table',{},h('thead',{},h('tr',{},['Job',T("Inputs"),T("Outputs")].map(t=>h('th',{},t)))),h('tbody',{},olRows)))):null;
|
|
362
|
+
return h('div',{},header('Pipelines',T("Runs collected from Airflow, Kestra and OpenLineage."),collect),
|
|
363
|
+
rows.length?table:empty(T("No run collected"),T("Enter the Airflow or Kestra URL in Settings, or send OpenLineage events."),toConfig),ol)}
|
|
364
|
+
function cluster(){const d=S.data,rows=d.cluster;
|
|
365
|
+
const mem=rows.filter(x=>x.metric==='memory_bytes'),other=rows.filter(x=>x.metric!=='memory_bytes');
|
|
366
|
+
const label={queued:T("queued tasks"),pool_slots_used:T("slots in use"),oom_killed:T("killed by OOM"),spilled_bytes:T("spill to disk")};
|
|
367
|
+
const gauges=mem.map(x=>{const r=x.ratio||0,cls=r>=.85?'bad':r>=.7?'warn':'';
|
|
368
|
+
const pct=h('div',{style:'font-size:20px;font-weight:700'+(cls==='bad'?';color:var(--crit)':'')},Math.round(r*100)+'%');
|
|
369
|
+
return h('div',{class:'card'},
|
|
370
|
+
h('div',{class:'head'},h('div',{},h('div',{class:'t'},x.scope),h('div',{style:'color:var(--faint);font-size:12px'},x.source)),pct),
|
|
371
|
+
h('div',{class:'bar'},h('i',{class:cls,style:`width:${Math.min(100,r*100)}%`})),
|
|
372
|
+
h('div',{style:'color:var(--mut);margin-top:8px;font-size:13px'},T("{used} of {limit}",{used:fmtB(x.value),limit:x.limit?fmtB(x.limit):'—'})))});
|
|
373
|
+
const otherRows=other.map(x=>{
|
|
374
|
+
const val=x.metric.includes('bytes')?fmtB(x.value):String(x.value)+(x.limit?` / ${x.limit}`:'');
|
|
375
|
+
return h('tr',{},h('td',{},x.source),h('td',{},h('b',{},x.scope)),h('td',{style:'color:var(--mut)'},label[x.metric]||x.metric),h('td',{},val))});
|
|
376
|
+
const otherBlock=other.length?h('div',{style:'margin-top:22px'},h('h2',{style:'margin-bottom:10px'},T("Other signals")),
|
|
377
|
+
h('div',{class:'card',style:'padding:6px 10px'},h('table',{},h('tbody',{},otherRows)))):null;
|
|
378
|
+
const collect=h('button',{class:'btn',onclick:()=>act(T("Collection started"),()=>post('/api/run/runs'))},T("Collect now"));
|
|
379
|
+
return h('div',{},header(T("Cluster and memory"),T("Current use per host, container and pool. Green up to 70%, yellow up to 85%, red above."),collect),
|
|
380
|
+
mem.length?h('div',{class:'grid g2'},gauges):empty(T("No memory samples"),T("Click \"Collect now\" to sample the host and the containers.")),
|
|
381
|
+
otherBlock)}
|
|
382
|
+
function diffView(t){return h('div',{class:'diff'},t.split('\n').map(l=>h('div',{class:l.startsWith('+')&&!l.startsWith('+++')?'a':l.startsWith('-')&&!l.startsWith('---')?'d':'h'},l||' ')))}
|
|
383
|
+
function stepsFor(p){const idx={pending:0,rejected:0,approved:1,invalid:1,applied:3,rolled_back:3}[p.status]??0,valid=!!(p.validation&&p.validation.ok&&p.validation.isolation==='docker-offline-v1');
|
|
384
|
+
return [[T("Proposed"),0],[T("Approved"),1],[T("Validated"),2],[T("Applied"),3]].map(([l,i])=>{
|
|
385
|
+
const done=i===0||(i===1&&idx>=1)||(i===2&&(valid||idx>=3))||(i===3&&p.status==='applied');
|
|
386
|
+
const now=!done&&((i===1&&idx===0)||(i===2&&idx===1&&!valid)||(i===3&&valid&&p.status==='approved'));
|
|
387
|
+
return h('span',{class:'step'+(done?' done':now?' now':'')},h('b',{},done?'✓':i+1),l)})}
|
|
388
|
+
function fixActions(p){const id=p.id,valid=!!(p.validation&&p.validation.ok&&p.validation.isolation==='docker-offline-v1'),out=[];
|
|
389
|
+
if(p.status==='pending'){
|
|
390
|
+
out.push(h('button',{class:'btn sm pri',onclick:()=>act(T("Proposal approved"),()=>post(`/api/proposals/${id}/approve`))},T("Approve")));
|
|
391
|
+
out.push(h('button',{class:'btn sm',onclick:()=>act(T("Proposal rejected"),()=>post(`/api/proposals/${id}/reject`))},T("Reject")))}
|
|
392
|
+
if(['approved','invalid'].includes(p.status)&&!valid){
|
|
393
|
+
const label=S.busy===id?h('span',{},h('span',{class:'spin'}),T(" Validating…")):T("Validate in a local container");
|
|
394
|
+
out.push(h('button',{class:'btn sm pri',onclick:()=>{S.busy=id;render();act(T("Validation finished"),()=>post(`/api/proposals/${id}/validate?mode=build`),()=>{S.busy=null})}},label))}
|
|
395
|
+
if(p.status==='approved'&&valid)
|
|
396
|
+
out.push(h('button',{class:'btn sm pri',onclick:()=>confirmBox(T("Apply the fix?"),T("The listed files will change in the project. A backup is kept and rollback stays available."),T("Apply"),()=>act(T("Fix applied"),()=>post(`/api/proposals/${id}/apply`)))},T("Apply")));
|
|
397
|
+
if(p.status==='applied')
|
|
398
|
+
out.push(h('button',{class:'btn sm danger',onclick:()=>confirmBox(T("Roll back the fix?"),T("The files go back to their content before applying."),T("Roll back"),()=>act(T("Fix rolled back"),()=>post(`/api/proposals/${id}/rollback`)))},T("Roll back")));
|
|
399
|
+
out.push(h('button',{class:'btn sm',onclick:()=>confirmBox(T("Recover an interrupted operation?"),T("An incomplete operation will be undone. If it was already committed, only the pending recovery is closed. Later edits are preserved."),T("Recover"),()=>act(T("Recovery finished"),()=>post(`/api/proposals/${id}/recover`)))},T("Recover operation")));
|
|
400
|
+
return out}
|
|
401
|
+
function aiBoxOf(p){return p.origin==='llm'?h('div',{class:'detail'},
|
|
402
|
+
h('div',{style:'display:flex;gap:6px;flex-wrap:wrap;align-items:center;margin-bottom:6px'},h('span',{class:'pill pending'},T("Suggested by AI")),
|
|
403
|
+
h('span',{class:'tag'},(p.llm&&p.llm.provider||'')+' / '+(p.llm&&p.llm.model||'')),
|
|
404
|
+
p.confidence!=null?h('span',{class:'tag',title:T("Value self-reported by the model; it is not calibrated and does not mean it is right")},T("declared confidence (not calibrated) ")+Math.round(p.confidence*100)+'%'):null,
|
|
405
|
+
p.policy?h('span',{class:'pill '+(p.policy.needs_extra_review?'failed':'success')},p.policy.needs_extra_review?T("extra review: ")+p.policy.reason:T("low risk (Jev)")):null),
|
|
406
|
+
h('div',{},p.explanation||'—'),
|
|
407
|
+
p.risk?h('div',{style:'color:var(--mut);font-size:12.5px;margin-top:6px'},T("Jev: changes semantics {sem}% · risk {risk} · unrelated logic {unrel}%",{sem:Math.round((p.risk.changes_semantics||0)*100),risk:p.risk.risk==null?'—':[T("low"),T("medium"),T("high")][Math.max(0,Math.min(2,Math.round(p.risk.risk)))],unrel:Math.round((p.risk.touches_unrelated_logic||0)*100)})):null,
|
|
408
|
+
h('div',{style:'color:var(--faint);font-size:12px;margin-top:6px'},T("Generated by a model: read the diff. Nothing is applied without your approval and the sandbox validation."))):null}
|
|
409
|
+
function fixCard(p){const valid=!!(p.validation&&p.validation.ok&&p.validation.isolation==='docker-offline-v1');
|
|
410
|
+
const top=h('div',{class:'item'},h('div',{},h('div',{class:'t'},p.summary),h('div',{class:'meta'},pill(p.status),h('span',{class:'tag'},p.id))),
|
|
411
|
+
h('div',{style:'display:flex;gap:6px;flex-wrap:wrap'},fixActions(p)));
|
|
412
|
+
const val=p.validation?h('div',{style:'margin:6px 0',class:'pill '+(valid?'success':'failed')},T("Validation ({mode}): {result}",{mode:p.validation.mode+(p.validation.adapter?' · '+p.validation.adapter+' local':''),result:valid?T("passed"):T("failed")})):null;
|
|
413
|
+
const out=p.validation&&!valid?h('div',{class:'detail'},h('pre',{},p.validation.output)):null;
|
|
414
|
+
const warn=p.warnings&&p.warnings.length?h('div',{class:'detail',style:'color:var(--med)'},p.warnings.join('\n')):null;
|
|
415
|
+
const aiBox=aiBoxOf(p);
|
|
416
|
+
const diffs=p.changes.map(c=>h('div',{},h('div',{style:'margin-top:8px;color:var(--mut);font-size:12.5px'},c.file.split('/').slice(-2).join('/')),diffView(c.diff)));
|
|
417
|
+
return h('div',{class:'card'},top,aiBox,h('div',{class:'steps'},stepsFor(p)),val,out,warn,diffs)}
|
|
418
|
+
function suggestModal(f){
|
|
419
|
+
const prev=document.activeElement;let timer=null,m;
|
|
420
|
+
const close=()=>{clearInterval(timer);m.remove();document.removeEventListener('keydown',esc);if(prev&&prev.focus)prev.focus()};
|
|
421
|
+
const esc=e=>{if(e.key==='Escape')close()};
|
|
422
|
+
const box=h('div',{style:'max-width:780px;max-height:88vh;overflow:auto'});
|
|
423
|
+
m=h('div',{class:'modal',role:'dialog','aria-modal':'true','aria-label':T("Fix suggestion"),onclick:e=>{if(e.target===m)close()}},box);
|
|
424
|
+
const set=(...k)=>box.replaceChildren(...k.filter(Boolean));
|
|
425
|
+
const btns=(...b)=>h('div',{style:'display:flex;gap:8px;justify-content:flex-end;margin-top:16px;flex-wrap:wrap'},...b);
|
|
426
|
+
const title=h('h2',{},f.title);
|
|
427
|
+
const sub=t=>h('p',{class:'sub',style:'margin:6px 0 10px'},t);
|
|
428
|
+
const errView=msg=>set(title,h('div',{class:'detail',style:'color:var(--crit,#c0392b);white-space:pre-wrap'},msg),
|
|
429
|
+
btns(h('button',{class:'btn',onclick:close},T("Close")),h('button',{class:'btn pri',onclick:start},T("Try again"))));
|
|
430
|
+
async function showProposal(res){
|
|
431
|
+
if(res.source==='skipped'||!res.proposal){set(title,sub(res.note||T("Nothing to suggest for this finding.")),btns(h('button',{class:'btn',onclick:close},T("Close")),
|
|
432
|
+
h('button',{class:'btn pri',onclick:()=>start(true)},T("Ask anyway"))));return}
|
|
433
|
+
await load();const p=(S.data.proposals||[]).find(x=>x.id===res.proposal);
|
|
434
|
+
if(!p){errView(T("The proposal was created (")+res.proposal+T(") but did not show up in the list; see Fixes."));return}
|
|
435
|
+
const status=h('div',{style:'margin-top:10px;color:var(--mut)'});
|
|
436
|
+
const apply=h('button',{class:'btn pri',onclick:async()=>{
|
|
437
|
+
apply.disabled=true;discard.disabled=true;
|
|
438
|
+
try{status.textContent=T("Approving…");await post(`/api/proposals/${p.id}/approve`);
|
|
439
|
+
const mode=p.policy&&p.policy.needs_extra_review?'build':'parse';
|
|
440
|
+
status.textContent=T("Validating in the sandbox (dbt {mode})… it may take a moment",{mode});
|
|
441
|
+
const v=await post(`/api/proposals/${p.id}/validate?mode=${mode}`);
|
|
442
|
+
if(!(v.validation&&v.validation.ok)){set(title,h('div',{class:'detail',style:'color:var(--med)'},T("The validation failed; nothing changed in the project.")),
|
|
443
|
+
h('pre',{class:'detail'},(v.validation&&v.validation.output)||''),btns(h('button',{class:'btn',onclick:()=>{close();load()}},T("Close"))));return}
|
|
444
|
+
status.textContent=T("Applying…");await post(`/api/proposals/${p.id}/apply`);await load();
|
|
445
|
+
set(title,h('div',{class:'pill success'},T("Fix applied")),sub(T("A backup was kept; you can roll back in Fixes.")),
|
|
446
|
+
btns(h('button',{class:'btn pri',onclick:close},T("Close"))))}
|
|
447
|
+
catch(e){status.textContent='';apply.disabled=false;discard.disabled=false;toast(e.message,true)}}},T("Apply fix"));
|
|
448
|
+
const discard=h('button',{class:'btn',onclick:async()=>{try{await post(`/api/proposals/${p.id}/reject`);await load();close()}catch(e){toast(e.message,true)}}},T("Discard"));
|
|
449
|
+
set(title,sub(p.summary),aiBoxOf(p)||(p.explanation?h('div',{class:'detail'},p.explanation):null),
|
|
450
|
+
p.warnings&&p.warnings.length?h('div',{class:'detail',style:'color:var(--med)'},p.warnings.join('\n')):null,
|
|
451
|
+
...p.changes.map(c=>h('div',{},h('div',{style:'margin-top:8px;color:var(--mut);font-size:12.5px'},c.file.split('/').slice(-2).join('/')),diffView(c.diff))),
|
|
452
|
+
h('p',{style:'margin-top:12px;font-weight:600'},T("Apply this fix to the project?")),status,
|
|
453
|
+
btns(h('button',{class:'btn',onclick:()=>{close();S.view='fixes';location.hash='#/fixes';render()}},T("See in Fixes")),discard,apply))}
|
|
454
|
+
async function poll(){
|
|
455
|
+
try{const j=await post(`/api/findings/${encodeURIComponent(f.id)}/ai-status`);
|
|
456
|
+
if(j.state==='done'){clearInterval(timer);showProposal(j.result)}
|
|
457
|
+
else if(j.state==='error'){clearInterval(timer);errView(j.error)}
|
|
458
|
+
}catch(e){clearInterval(timer);errView(e.message)}}
|
|
459
|
+
async function start(force){
|
|
460
|
+
const t0=Date.now(),clock=h('span',{},'0 s');
|
|
461
|
+
const model=S.ai&&S.ai.llm&&S.ai.llm.model||T("model");
|
|
462
|
+
set(title,h('div',{style:'display:flex;gap:10px;align-items:center;margin:12px 0'},h('span',{class:'spin'}),h('span',{},T("Asking for the suggestion from ")+model+'… '),clock),
|
|
463
|
+
sub(T("Local models can take a few minutes. You can close this window: the suggestion keeps being generated and shows up in Fixes.")),
|
|
464
|
+
btns(h('button',{class:'btn',onclick:close},T("Close"))));
|
|
465
|
+
clearInterval(timer);
|
|
466
|
+
timer=setInterval(()=>{clock.textContent=Math.round((Date.now()-t0)/1000)+' s';if(((Date.now()-t0)/1000|0)%2===0)poll()},1000);
|
|
467
|
+
try{const j=await post(`/api/findings/${encodeURIComponent(f.id)}/fix-ai`,{force:force===true});
|
|
468
|
+
if(j.state==='error'){clearInterval(timer);errView(j.error)}}
|
|
469
|
+
catch(e){clearInterval(timer);errView(e.message)}}
|
|
470
|
+
async function startOwner(){
|
|
471
|
+
const inp=h('input',{type:'text',value:(S.me&&S.me.user&&S.me.user.name!=='local'&&S.me.user.name)||'',placeholder:T("e.g. data-team or name@company.com"),style:'width:100%'});
|
|
472
|
+
const go=async()=>{try{const j=await post(`/api/findings/${encodeURIComponent(f.id)}/owner`,{owner:inp.value});showProposal({source:'rule',proposal:j.proposal})}catch(e){errView(e.message)}};
|
|
473
|
+
set(title,sub(T("This model has no owner. Enter who should receive alerts and proposals; the suggestion shows what will be written to the file before applying.")),
|
|
474
|
+
h('label',{style:'display:block;margin-top:8px'},T("Owner (meta.owner)"),inp),
|
|
475
|
+
btns(h('button',{class:'btn',onclick:close},T("Cancel")),h('button',{class:'btn pri',onclick:go},T("Generate suggestion"))));
|
|
476
|
+
inp.focus();inp.addEventListener('keydown',e=>{if(e.key==='Enter')go()})}
|
|
477
|
+
function startKey(){
|
|
478
|
+
const cand=(f.evidence&&f.evidence.key_candidates)||[];
|
|
479
|
+
const inp=h('input',{type:'text',value:cand[0]||'',placeholder:T("e.g. order_id or order_id,line_number"),style:'width:100%'});
|
|
480
|
+
const go=async()=>{try{const j=await post(`/api/findings/${encodeURIComponent(f.id)}/unique-key`,{key:inp.value});showProposal({source:'rule',proposal:j.proposal})}catch(e){errView(e.message)}};
|
|
481
|
+
set(title,sub(T("Incremental model without unique_key: reprocessing duplicates rows. Enter the column (or columns, comma-separated) that identifies each row; the suggestion shows what will be written before applying.")),
|
|
482
|
+
cand.length?sub(T("Candidates: ")+cand.join(', ')):null,
|
|
483
|
+
h('label',{style:'display:block;margin-top:8px'},'unique_key',inp),
|
|
484
|
+
btns(h('button',{class:'btn',onclick:close},T("Cancel")),h('button',{class:'btn pri',onclick:go},T("Generate suggestion"))));
|
|
485
|
+
inp.focus();inp.addEventListener('keydown',e=>{if(e.key==='Enter')go()})}
|
|
486
|
+
document.body.append(m);document.addEventListener('keydown',esc);
|
|
487
|
+
if(f.check_id==='DBT003')startOwner();else if(f.check_id==='DBT002')startKey();else start()}
|
|
488
|
+
function fixes(){const d=S.data;
|
|
489
|
+
return h('div',{},header(T("Fixes"),T("Validation in an isolated local DuckDB, human approval and change history. Use Recover operation after an interruption.")),
|
|
490
|
+
d.proposals.length?h('div',{class:'list'},d.proposals.map(fixCard)):
|
|
491
|
+
empty(T("No fix in progress"),T("When a finding has an automatic fix, the \"Create fix\" button shows up in Findings. With AI set up (Settings), \"Suggest fix\" creates a proposal for any finding on a model.")))}
|
|
492
|
+
const FIELDS=[
|
|
493
|
+
[T("dbt project"),[['dbt.target',T("target/ directory"),T("manifest.json and catalog.json (after dbt build && dbt docs generate)")],['dbt.root',T("Project root"),T("Optional; default: the folder above target/")],['dbt.base_target',T("target/ of the previous version"),T("Optional; enables schema diff and impact")]]],
|
|
494
|
+
[T("Orchestrators"),[['airflow.dags',T("Airflow DAG folder"),T("For static analysis")],['kestra.flows',T("Kestra flow folder"),T("For static analysis")],['airflow.url',T("Airflow URL"),T("E.g. http://airflow:8080 (credentials: AIRFLOW_USER/AIRFLOW_PASSWORD)")],['kestra.url',T("Kestra URL"),T("Credentials: KESTRA_USER/KESTRA_PASSWORD")],['prefect.url',T("Prefect URL"),T("E.g. http://prefect:4200 (token: PREFECT_API_KEY)")],['dagster.url',T("Dagster URL"),T("E.g. http://dagster:3000")],['dq.results',T("Quality results (Great Expectations / Soda)"),T("Folder, file or glob of .json; several comma-separated")],['warehouse.type',T("Warehouse type"),T("duckdb | postgres | redshift | trino | clickhouse | snowflake | bigquery | databricks (credentials through environment variables)")],['contracts.dir',T("Data contracts (folder or file)"),T("Data Contract Specification or ODCS v3 (.yaml)")],['kafka.bootstrap','Kafka (bootstrap servers)',T("host:9092[,host2:9092] — consumer lag")],['kafka.schema_registry','Schema Registry',T("E.g. http://registry:8081")],['kafka_connect.url',T("Kafka Connect URL (Debezium)"),T("E.g. http://connect:8083")],['flink.url',T("Flink URL"),T("E.g. http://flink:8081")],['luigi.url',T("Luigi URL"),T("E.g. http://luigid:8082")],['mlflow.url',T("MLflow URL"),T("E.g. http://mlflow:5000 (MLFLOW_TRACKING_TOKEN)")],['rundeck.url',T("Rundeck URL"),T("RUNDECK_TOKEN; project in rundeck.project")],['rundeck.project',T("Rundeck project"),'default'],['scan.include_packages',T("Also check models from packages (true/false)"),T("Default: only the root project; packages (dbt_utils, project-evaluator…) are left out")],['lint.enabled',T("SQL lint (SQLFluff): true/false"),T("Slower; results cached by SQL hash. pip install intentdataflow[lint]")],['lakehouse.tables',T("Delta/Iceberg tables"),T("Comma-separated paths (Delta: folder with _delta_log; Iceberg: metadata.json)")],['elementary.schema',T("Elementary schema"),T("E.g. analytics_elementary (uses the configured warehouse)")],['catalog.glue',T("Catalog: AWS Glue (true/false)"),T("Watches the table schemas of the Glue Data Catalog (uses aws.region)")],['catalog.unity',T("Catalog: Unity Catalog (host)"),T("E.g. adb-123.azuredatabricks.net (DATABRICKS_TOKEN)")],['catalog.include',T("Catalog: prefixes to watch"),T("E.g. sales., main.raw. (empty = all)")],['aws.region',T("AWS: region"),T("E.g. us-east-1 (credentials from the default boto3 chain)")],['aws.glue','AWS Glue (true/false)',T("Job runs")],['aws.stepfunctions','AWS Step Functions (true/false)',''],['aws.athena','AWS Athena (true/false)',T("Queries as runs")],['azure.data_factory',T("Azure Data Factory (resource)"),T("subscription/resourceGroup/factory — token in AZURE_TOKEN")],['kubernetes.enabled',T("Monitor Kubernetes (true/false)"),T("Uses the server's kubectl; memory needs the metrics-server")],['kubernetes.context',T("kubectl context"),T("Optional")],['kubernetes.namespace',T("Namespace (empty = all)"),T("Optional")],['prometheus.url',T("Prometheus URL"),T("E.g. http://prometheus:9090 (memory of containers and nodes)")],['dbt_cloud.account_id','dbt Cloud: account id',T("Token in DBT_CLOUD_TOKEN")],['dbt_cloud.job_id','dbt Cloud: job id',T("Job that produces manifest/catalog/run_results")],['dbt_cloud.host','dbt Cloud: host',T("cloud.getdbt.com (or your tenant's)")],['argo.url',T("Argo Workflows URL"),T("E.g. https://argo:2746 (ARGO_TOKEN)")],['argo.namespace',T("Argo namespace"),'argo'],['mage.url',T("Mage URL"),T("E.g. http://mage:6789")],['spark.url',T("Spark URL (UI/History Server)"),T("E.g. http://driver:4040")],['databricks.jobs_host',T("Databricks host (Jobs)"),T("E.g. adb-123.azuredatabricks.net (token: DATABRICKS_TOKEN)")],['airbyte.url',T("Airbyte URL"),T("E.g. http://airbyte:8000 (AIRBYTE_TOKEN or AIRBYTE_USER/AIRBYTE_PASSWORD)")],['fivetran.url',T("Fivetran API URL"),'https://api.fivetran.com (FIVETRAN_API_KEY/FIVETRAN_API_SECRET)']]],
|
|
495
|
+
[T("Warehouse (probes)"),[['warehouse.duckdb',T("DuckDB file"),T("Duplicate, volume and cost probes")],['warehouse.postgres_env',T("Variable holding the PostgreSQL URL"),T("Enter only the variable NAME, never the URL")]]],
|
|
496
|
+
[T("Policies"),[['policy.pii_allowed_models',T("Models allowed to contain PII"),T("Comma-separated")]]]];
|
|
497
|
+
function config(){const s=S.cfg.settings;const sinks=s['notify.sinks']||[],routes=s['notify.routes']||[];
|
|
498
|
+
const field=([k,l,hint])=>{let v=s[k];if(Array.isArray(v))v=v.join(', ');
|
|
499
|
+
const i=h('input',{type:'text',value:v==null?'':v,placeholder:T("not set"),onchange:e=>act(T("Saved: ")+l,()=>post('/api/settings',{key:k,value:e.target.value}))});
|
|
500
|
+
return h('div',{class:'field'},h('label',{},l),i,h('small',{},hint))};
|
|
501
|
+
const run=h('button',{class:'btn pri',disabled:!!S.cfg.running,onclick:()=>act(T("Check started"),()=>post('/api/run/check'))},T("Save and check now"));
|
|
502
|
+
const groups=FIELDS.map(([t,fs])=>h('div',{class:'card',style:'margin-bottom:14px'},h('h2',{style:'margin-bottom:12px'},t),h('div',{class:'form'},fs.map(field))));
|
|
503
|
+
const routeTags=name=>routes.filter(r=>r.sink===name).map(r=>{
|
|
504
|
+
const parts=[r.owner&&(T("owner=")+r.owner),r.min_severity&&('≥ '+r.min_severity),r.check_prefix&&(r.check_prefix+'*')].filter(Boolean);
|
|
505
|
+
return h('span',{class:'tag',style:'margin-right:4px'},parts.join(' ')||T("all"))});
|
|
506
|
+
const sinkRows=sinks.map(x=>h('tr',{},h('td',{},h('b',{},x.name)),h('td',{},x.type),h('td',{style:'color:var(--mut)'},x.url_env||x.to||x.repo||''),h('td',{},routeTags(x.name))));
|
|
507
|
+
const hint=h('p',{style:'color:var(--faint);font-size:12.5px;margin:10px 0 0'},T("Add through the CLI: "),
|
|
508
|
+
h('span',{class:'tag'},'intentflow notify add-sink dados --type slack --url-env SLACK_URL'),' e ',h('span',{class:'tag'},'intentflow notify route dados --min-severity high'));
|
|
509
|
+
const notif=h('div',{class:'card'},h('h2',{style:'margin-bottom:8px'},T("Notifications")),
|
|
510
|
+
sinks.length?h('table',{},h('tbody',{},sinkRows)):h('p',{style:'color:var(--mut);margin:0'},T("No output configured.")),hint);
|
|
511
|
+
const d=S.data;
|
|
512
|
+
const dis=new Set(s['policy.disabled_checks']||[]);
|
|
513
|
+
const toggle=c=>{const on=!dis.has(c.id);const cb=h('input',{type:'checkbox',checked:on,onchange:e=>{const nx=new Set(s['policy.disabled_checks']||[]);e.target.checked?nx.delete(c.id):nx.add(c.id);
|
|
514
|
+
act((e.target.checked?T("On: "):T("Off: "))+c.id,()=>post('/api/settings',{key:'policy.disabled_checks',value:[...nx].sort().length?[...nx].sort():null}))}});
|
|
515
|
+
return h('tr',{},h('td',{},cb),h('td',{},h('span',{class:'tag'},c.id)),h('td',{},c.title),h('td',{style:'color:var(--mut)'},c.stage),h('td',{style:'color:var(--mut)'},c.cost))};
|
|
516
|
+
const checksCard=h('div',{class:'card',style:'margin-top:14px'},h('h2',{style:'margin-bottom:6px'},'Checks'),
|
|
517
|
+
h('p',{style:'color:var(--mut);margin:0 0 8px'},T("Turn off what is noise in your context. The false positive rate shows up in Findings.")),
|
|
518
|
+
h('table',{},h('thead',{},h('tr',{},[T("On"),'Id',T("Description"),T("Stage"),T("Cost")].map(t=>h('th',{},t)))),h('tbody',{},(d.checks||[]).map(toggle))));
|
|
519
|
+
const pol=h('div',{class:'card',style:'margin-top:14px'},h('h2',{style:'margin-bottom:6px'},T("SLA and freshness per pipeline")),
|
|
520
|
+
d.pipelines.length?h('table',{},h('thead',{},h('tr',{},['Pipeline',T("SLA (minutes)"),T("No success for more than (hours)")].map(t=>h('th',{},t)))),
|
|
521
|
+
h('tbody',{},d.pipelines.map(p=>{const key=p.system+':'+p.pipeline,sla=(s['policy.sla.'+key]||{}).minutes,age=s['policy.max_age_hours.'+key];
|
|
522
|
+
const mk=(val,k,conv)=>h('input',{type:'text',value:val==null?'':val,placeholder:'—',style:'width:120px',onchange:e=>act(T("Saved"),()=>post('/api/settings',{key:k,value:e.target.value.trim()?conv(e.target.value.trim()):null}))});
|
|
523
|
+
return h('tr',{},h('td',{},h('b',{},p.pipeline),h('div',{style:'color:var(--faint);font-size:12px'},p.system)),h('td',{},mk(sla,'policy.sla.'+key,v=>({minutes:parseFloat(v)}))),h('td',{},mk(age,'policy.max_age_hours.'+key,v=>parseFloat(v))))}))):
|
|
524
|
+
h('p',{style:'color:var(--mut);margin:0'},T("Collect runs to set an SLA per pipeline.")));
|
|
525
|
+
if(S.ai===undefined)aiLoad();
|
|
526
|
+
return h('div',{},header(T("Settings"),T("Stored locally. Secrets: only environment variable names; AI keys, if stored here, are encrypted."),run),has('ai')?aiCard():null,groups,pol,checksCard,notif)}
|
|
527
|
+
S.aiDraft={};
|
|
528
|
+
function aiCard(){const a=S.ai;const D=S.aiDraft;const dv=(k,def)=>(k in D?D[k]:def);const keep=(el,k)=>{const f=()=>{D[k]=el.type==='checkbox'?el.checked:el.value};el.addEventListener('input',f);el.addEventListener('change',f);return el};
|
|
529
|
+
if(!a)return h('div',{class:'card',style:'margin-bottom:14px'},h('h2',{},T("AI to suggest fixes")),h('span',{class:'spin'}));
|
|
530
|
+
const L=a.llm,J=a.jev,P=L.providers||{};
|
|
531
|
+
const curProv=dv('ai_provider',L.provider||'');
|
|
532
|
+
const prov=keep(h('select',{id:'ai_provider',onchange:e=>{const m=(P[e.target.value]||{});$('#ai_model').value=m.default_model||'';$('#ai_base').value=m.default_base_url||'';D.ai_model=$('#ai_model').value;D.ai_base=$('#ai_base').value;$('#ai_model_list').replaceChildren()}},
|
|
533
|
+
h('option',{value:''},T("— choose —")),...Object.entries(P).map(([k,v])=>h('option',{value:k,selected:k===curProv},v.label))),'ai_provider');
|
|
534
|
+
const model=keep(h('input',{id:'ai_model',type:'text',value:dv('ai_model',L.model||''),placeholder:T("e.g. claude-sonnet-5-5, gpt-4o-mini, qwen2.5:3b"),list:'ai_model_list'}),'ai_model');
|
|
535
|
+
const base=keep(h('input',{id:'ai_base',type:'text',value:dv('ai_base',L.base_url||''),placeholder:T("provider default; for a local model e.g. http://127.0.0.1:11434/v1")}),'ai_base');
|
|
536
|
+
const key=keep(h('input',{id:'ai_key',type:'password',autocomplete:'off',value:dv('ai_key',''),placeholder:L.key_source==='env'?T("set through an environment variable"):L.key_source==='stored'?T("•••••• stored (encrypted); type to replace"):(P[L.provider]&&P[L.provider].needs_key===false?T("not needed for a local model"):T("paste the key here"))}),'ai_key');
|
|
537
|
+
const keyNote=L.key_source==='env'?T("The key comes from the server's environment variable."):L.key_source==='stored'?T("Key stored encrypted in the store. It is never shown or sent back."):
|
|
538
|
+
(L.can_store_key?T("The key will be stored encrypted. Prefer an environment variable in production."):T("Storing the key here requires INTENTFLOW_SECRET_KEY on the server; for now use the provider's environment variable."));
|
|
539
|
+
const body=()=>({provider:$('#ai_provider').value,model:$('#ai_model').value.trim(),base_url:$('#ai_base').value.trim(),...($('#ai_key').value?{api_key:$('#ai_key').value}:{})});
|
|
540
|
+
const jprov=keep(h('select',{id:'jv_provider'},h('option',{value:''},T("— off —")),...Object.entries(J.providers||{}).map(([k,v])=>h('option',{value:k,selected:k===dv('jv_provider',J.provider||'')},v.label))),'jv_provider');
|
|
541
|
+
const jmodel=keep(h('input',{id:'jv_model',type:'text',value:dv('jv_model',J.model||''),placeholder:T("provider default")}),'jv_model');
|
|
542
|
+
const jkey=keep(h('input',{id:'jv_key',type:'password',autocomplete:'off',value:dv('jv_key',''),placeholder:J.key_source==='env'?T("set through an environment variable"):J.key_source==='stored'?T("•••••• stored (encrypted)"):T("paste the key here")}),'jv_key');
|
|
543
|
+
const jon=keep(h('input',{id:'jv_on',type:'checkbox',checked:dv('jv_on',!!J.enabled)}),'jv_on');
|
|
544
|
+
const status=(ok,t)=>h('span',{class:'pill '+(ok?'success':'pending'),style:'margin-left:8px'},t);
|
|
545
|
+
const save=async()=>{try{const b=body(),jb={provider:$('#jv_provider').value,model:$('#jv_model').value.trim(),enabled:$('#jv_on').checked,...($('#jv_key').value?{api_key:$('#jv_key').value}:{})};
|
|
546
|
+
S.ai=await api('/api/llm',{method:'POST',headers:{'Content-Type':'application/json','X-IntentFlow':'1'},body:JSON.stringify({...b,jev:jb})});S.ai.triage=(S.ai.triage||{});toast(T("AI settings saved"));S.aiDraft={};await aiLoad(true)}catch(e){toast(e.message,true)}};
|
|
547
|
+
const call=async(path,b,ok)=>{try{const r=await api(path,{method:'POST',headers:{'Content-Type':'application/json','X-IntentFlow':'1'},body:JSON.stringify(b)});ok(r)}catch(e){toast(e.message,true)}};
|
|
548
|
+
return h('div',{class:'card',style:'margin-bottom:14px'},
|
|
549
|
+
h('h2',{style:'margin-bottom:4px'},T("AI to suggest fixes"),L.configured?status(true,T("configured")):status(false,T("not configured"))),
|
|
550
|
+
h('p',{style:'color:var(--mut);margin:0 0 12px'},T("An LLM proposes the edit; it becomes a proposal with a diff and goes through human approval, sandbox validation and rollback, like any fix.")),
|
|
551
|
+
h('div',{class:'form'},h('div',{class:'field'},h('label',{},T("Provider")),prov),h('div',{class:'field'},h('label',{},T("Model")),model,h('datalist',{id:'ai_model_list'})),
|
|
552
|
+
h('div',{class:'field'},h('label',{},T("Base URL (optional)")),base),h('div',{class:'field'},h('label',{},T("API key")),key,h('small',{},keyNote))),
|
|
553
|
+
h('div',{style:'display:flex;gap:8px;flex-wrap:wrap;margin-top:10px'},
|
|
554
|
+
h('button',{class:'btn',onclick:()=>call('/api/llm/models',body(),r=>{$('#ai_model_list').replaceChildren(...r.models.map(m=>h('option',{value:m})));toast(r.models.length+T(" model(s) found"))})},T("List models")),
|
|
555
|
+
h('button',{class:'btn',onclick:()=>call('/api/llm/test',body(),r=>toast(T("Connection ok ({model}, {s}s): {text}",{model:r.model,s:r.seconds,text:r.text})))},T("Test connection")),
|
|
556
|
+
L.key_source==='stored'?h('button',{class:'btn danger',onclick:()=>call('/api/llm',{clear_key:true},async()=>{toast(T("Key removed"));await aiLoad(true)})},T("Remove stored key")):null),
|
|
557
|
+
h('div',{style:'margin-top:16px;padding-top:14px;border-top:1px solid var(--line)'},
|
|
558
|
+
h('h2',{style:'margin-bottom:4px;font-size:15px'},T("Decisions with Jev"),J.configured&&J.enabled?status(true,T("on")):status(false,T("off"))),
|
|
559
|
+
h('p',{style:'color:var(--mut);margin:0 0 10px'},T("Decision model (TypeSafe): returns a choice/score with a probability, not text. Finding triage (real? false positive? urgency? which path?), ")+
|
|
560
|
+
T("avoids calling the LLM when the fix is mechanical and scores the risk of the generated edit.")),
|
|
561
|
+
h('div',{class:'form'},h('div',{class:'field'},h('label',{},T("Access")),jprov),h('div',{class:'field'},h('label',{},T("Model")),jmodel),
|
|
562
|
+
h('div',{class:'field'},h('label',{},T("Key")),jkey),h('div',{class:'field'},h('label',{},T("Use in triage and the risk gate")),jon)),
|
|
563
|
+
h('div',{style:'display:flex;gap:8px;margin-top:10px'},
|
|
564
|
+
h('button',{class:'btn',onclick:()=>call('/api/jev/test',{provider:$('#jv_provider').value,model:$('#jv_model').value.trim(),...($('#jv_key').value?{api_key:$('#jv_key').value}:{})},r=>toast(`Jev ok (${r.model}, ${r.seconds}s)`))},T("Test Jev")))),
|
|
565
|
+
h('div',{style:'margin-top:14px;display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap'},
|
|
566
|
+
h('small',{style:'color:var(--faint)'},T("Sent to the provider: the affected model's SQL, column names/types, the finding text. Never data rows.")),
|
|
567
|
+
h('button',{class:'btn pri',onclick:save},T("Save AI"))))}
|
|
568
|
+
function audit(){const a=[...S.data.audit].reverse();
|
|
569
|
+
return h('div',{},header(T("Audit"),T("Who did what: settings, approvals, applies, rollbacks and checks.")),
|
|
570
|
+
a.length?h('div',{class:'card',style:'padding:6px 10px'},h('table',{},h('thead',{},h('tr',{},[T("When"),T("Who"),T("Event"),T("Detail")].map(t=>h('th',{},t)))),
|
|
571
|
+
h('tbody',{},a.map(x=>h('tr',{},h('td',{style:'color:var(--mut);white-space:nowrap'},new Date(x.ts*1000).toLocaleString()),h('td',{},x.actor),h('td',{},h('span',{class:'tag'},x.event)),h('td',{style:'color:var(--mut);word-break:break-word'},x.detail)))))):
|
|
572
|
+
empty(T("No events yet"),T("Actions show up here.")))}
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
/* ---------- lineage and impact ---------- */
|
|
576
|
+
S.lin={models:null,sel:null,detail:null,col:null,colData:null,tab:'model',q:'',loading:false,err:null};
|
|
577
|
+
async function linLoadModels(){S.lin.loading=true;try{S.lin.models=await api('/api/lineage/models');S.lin.err=null}catch(e){S.lin.err=e.message;S.lin.models=[]}S.lin.loading=false;render()}
|
|
578
|
+
async function linSelect(name,col){S.lin.sel=name;S.lin.col=col||null;S.lin.colData=null;S.lin.detail=null;S.lin.loading=true;render();
|
|
579
|
+
try{S.lin.detail=await api('/api/lineage/model?model='+encodeURIComponent(name)+'&depth=2');
|
|
580
|
+
if(col){S.lin.tab='column';S.lin.colData=await api('/api/lineage/column?model='+encodeURIComponent(name)+'&column='+encodeURIComponent(col)+'&depth=3')}
|
|
581
|
+
S.lin.err=null}catch(e){S.lin.err=e.message}
|
|
582
|
+
S.lin.loading=false;render()}
|
|
583
|
+
async function linColumn(col){S.lin.col=col;S.lin.tab='column';S.lin.colData=null;render();
|
|
584
|
+
try{S.lin.colData=await api('/api/lineage/column?model='+encodeURIComponent(S.lin.sel)+'&column='+encodeURIComponent(col)+'&depth=3')}catch(e){toast(e.message,true)}
|
|
585
|
+
render()}
|
|
586
|
+
const SVGNS='http://www.w3.org/2000/svg';
|
|
587
|
+
function sv(tag,attrs,...kids){const e=document.createElementNS(SVGNS,tag);for(const [k,v] of Object.entries(attrs||{}))e.setAttribute(k,v);for(const c of kids)if(c!=null)e.append(c.nodeType?c:document.createTextNode(String(c)));return e}
|
|
588
|
+
function drawGraph(nodes,edges,onPick){
|
|
589
|
+
const W=210,H=46,GX=96,GY=14,PAD=14;
|
|
590
|
+
const levels=[...new Set(nodes.map(n=>n.level))].sort((a,b)=>a-b);
|
|
591
|
+
const byLv=Object.fromEntries(levels.map(l=>[l,nodes.filter(n=>n.level===l).sort((a,b)=>a.label.localeCompare(b.label))]));
|
|
592
|
+
const maxN=Math.max(...levels.map(l=>byLv[l].length));
|
|
593
|
+
const height=PAD*2+maxN*(H+GY)-GY,width=PAD*2+levels.length*W+(levels.length-1)*GX;
|
|
594
|
+
const pos={};levels.forEach((l,xi)=>{const col=byLv[l],off=(maxN-col.length)*(H+GY)/2;col.forEach((n,yi)=>{pos[n.id]={x:PAD+xi*(W+GX),y:PAD+off+yi*(H+GY)}})});
|
|
595
|
+
const svg=sv('svg',{width,height,viewBox:`0 0 ${width} ${height}`,role:'img'});
|
|
596
|
+
svg.append(sv('defs',{},sv('marker',{id:'ar',viewBox:'0 0 10 10',refX:'9',refY:'5',markerWidth:'7',markerHeight:'7',orient:'auto-start-reverse'},sv('path',{d:'M0 0L10 5L0 10z',fill:'currentColor',style:'color:var(--faint)'}))));
|
|
597
|
+
edges.forEach(e=>{const a=pos[e.src],b=pos[e.dst];if(!a||!b)return;const x1=a.x+W,y1=a.y+H/2,x2=b.x,y2=b.y+H/2,mx=(x1+x2)/2;
|
|
598
|
+
svg.append(sv('path',{d:`M${x1} ${y1}C${mx} ${y1} ${mx} ${y2} ${x2-2} ${y2}`,class:'e'+(e.kind==='derived'?' derived':'')+(e.masked?' masked':''),'marker-end':'url(#ar)'}))});
|
|
599
|
+
nodes.forEach(n=>{const p=pos[n.id];const g=sv('g',{class:'nd'+(n.center?' center':'')+(n.pii?' pii':''),transform:`translate(${p.x},${p.y})`,tabindex:'0',role:'button','aria-label':n.label});
|
|
600
|
+
g.append(sv('rect',{width:W,height:H,rx:9}),sv('text',{x:12,y:19},n.label.length>28?n.label.slice(0,27)+'…':n.label),
|
|
601
|
+
sv('text',{x:12,y:34,class:'sub'},(n.sub||'').length>34?n.sub.slice(0,33)+'…':(n.sub||'')));
|
|
602
|
+
if(n.pii)g.append(sv('text',{x:W-34,y:19,style:'fill:var(--crit);font-weight:700'},'PII'));
|
|
603
|
+
g.append(sv('title',{},n.label+(n.sub?' — '+n.sub:'')));
|
|
604
|
+
if(onPick&&!n.center){const fire=()=>onPick(n);g.addEventListener('click',fire);g.addEventListener('keydown',ev=>{if(ev.key==='Enter'||ev.key===' '){ev.preventDefault();fire()}})}
|
|
605
|
+
svg.append(g)});
|
|
606
|
+
return h('div',{class:'graph'},svg)}
|
|
607
|
+
async function linLoadDiff(){const L=S.lin;L.diff='loading';render();
|
|
608
|
+
try{L.diff=await api('/api/lineage/diff')}catch(e){L.diff={error:e.message}}render()}
|
|
609
|
+
function linDiffView(){const L=S.lin,d=L.diff;
|
|
610
|
+
if(d===undefined){linLoadDiff();return h('div',{class:'card empty'},h('span',{class:'spin'}))}
|
|
611
|
+
if(d==='loading')return h('div',{class:'card empty'},h('span',{class:'spin'}));
|
|
612
|
+
if(d.error)return empty(T("Could not load the lineage"),d.error);
|
|
613
|
+
const rows=[...d.models_added.map(m=>['+',T("model"),m,'']),...d.models_removed.map(m=>['−',T("model"),m,'']),
|
|
614
|
+
...d.added.map(e=>['+',e.kind,e.src,e.dst]),...d.removed.map(e=>['−',e.kind,e.src,e.dst]),...d.changed.map(e=>['~',e.from+' → '+e.to,e.src,e.dst])];
|
|
615
|
+
return h('div',{class:'card'},h('h2',{style:'margin-bottom:6px'},T("Lineage changes vs the previous version")),
|
|
616
|
+
h('p',{class:'sub'},T("Compared with dbt.base_target. Pick a model on the left for its details.")),
|
|
617
|
+
rows.length?h('table',{},h('tbody',{},rows.map(r=>h('tr',{},h('td',{},h('b',{style:'color:'+(r[0]==='+'?'var(--ok)':r[0]==='~'?'var(--med)':'var(--crit)')},r[0])),
|
|
618
|
+
h('td',{},h('small',{},r[1])),h('td',{},h('code',{},r[2])),h('td',{},r[3]?h('code',{},r[3]):null))))):h('p',{},T("No column-lineage change.")))}
|
|
619
|
+
function lineageView(){const L=S.lin;
|
|
620
|
+
if(!S.cfg.settings['dbt.target'])return h('div',{},header(T("Lineage and impact"),T("See where each column comes from and what breaks if it changes.")),
|
|
621
|
+
empty(T("Set up the dbt project"),T("Enter the target/ directory in Settings."),h('a',{class:'btn pri',href:'#/config'},T("Go to Settings"))));
|
|
622
|
+
if(L.models===null&&!L.loading){linLoadModels()}
|
|
623
|
+
const q=h('input',{type:'search',placeholder:T("Search model…"),value:L.q,oninput:e=>{L.q=e.target.value;clearTimeout(L.t);L.t=setTimeout(()=>{render();const n=document.querySelector('.lin input[type=search]');if(n){n.focus();n.setSelectionRange(L.q.length,L.q.length)}},120)},style:'width:100%;margin-bottom:8px'});
|
|
624
|
+
const list=(L.models||[]).filter(m=>!L.q||m.name.toLowerCase().includes(L.q.toLowerCase())).slice(0,300).map(m=>
|
|
625
|
+
h('button',{class:'mrow'+(L.sel===m.name?' on':''),onclick:()=>linSelect(m.name)},
|
|
626
|
+
h('span',{style:'min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap'},m.name,m.pii?h('span',{class:'tag',style:'margin-left:6px;color:var(--crit)'},'PII'):null),
|
|
627
|
+
m.worst?sev(m.worst):h('small',{},m.type==='model'?m.downstream+' ↓':m.type)));
|
|
628
|
+
const side=h('div',{class:'card models'},q,L.models===null||L.loading&&!L.models?h('div',{class:'empty'},h('span',{class:'spin'})):list.length?list:h('div',{class:'empty'},T("No model")));
|
|
629
|
+
let main;
|
|
630
|
+
if(L.err)main=empty(T("Could not load the lineage"),L.err);
|
|
631
|
+
else if(!L.sel)main=S.cfg.settings['dbt.base_target']?linDiffView():empty(T("Pick a model"),T("Select on the left to see dependencies, columns and impact."));
|
|
632
|
+
else if(!L.detail)main=h('div',{class:'card empty'},h('span',{class:'spin'}));
|
|
633
|
+
else main=lineageDetail();
|
|
634
|
+
return h('div',{},header(T("Lineage and impact"),T("Where each column comes from and what breaks if it changes. Click a node to navigate.")),h('div',{class:'lin'},side,main))}
|
|
635
|
+
function lineageDetail(){const L=S.lin,d=L.detail;
|
|
636
|
+
const info=h('div',{class:'card'},h('div',{class:'item'},h('div',{},h('div',{class:'t',style:'font-size:17px'},d.name),
|
|
637
|
+
h('div',{class:'meta'},h('span',{class:'tag'},d.type),d.materialized?h('span',{class:'tag'},d.materialized):null,
|
|
638
|
+
d.owner?h('span',{},T("owner: ")+d.owner):h('span',{style:'color:var(--faint)'},T("no owner")),h('span',{},d.columns.length+T(" columns")),h('span',{},d.tests.length+T(" model tests")))),
|
|
639
|
+
d.path?h('span',{class:'tag'},d.path):null),d.description?h('p',{style:'color:var(--mut);margin:8px 0 0'},d.description):null);
|
|
640
|
+
const tabs=h('div',{class:'tabs'},h('button',{class:'tab'+(L.tab==='model'?' on':''),onclick:()=>{L.tab='model';render()}},T("Models")),
|
|
641
|
+
h('button',{class:'tab'+(L.tab==='column'?' on':''),onclick:()=>{L.tab='column';render()}},T("Columns and impact")));
|
|
642
|
+
const legend=h('div',{class:'legend'},h('span',{},T("── direct")),h('span',{},T("- - derived (function/aggregation)")),h('span',{style:'color:var(--ok)'},T("── masked (hash)")),h('span',{style:'color:var(--crit)'},'PII'));
|
|
643
|
+
let body;
|
|
644
|
+
if(L.tab==='model'){
|
|
645
|
+
const g=d.graph;body=h('div',{},legend,drawGraph(g.nodes.map(n=>({id:n.id,level:n.level,label:n.name,sub:n.type+(n.owner?' · '+n.owner:''),center:n.id===g.center})),g.edges,n=>linSelect(n.label)))}
|
|
646
|
+
else{
|
|
647
|
+
const rows=d.columns.map(c=>h('button',{class:'colrow'+(L.col===c.name?' on':''),onclick:()=>linColumn(c.name)},
|
|
648
|
+
h('span',{},h('b',{},c.name),h('span',{style:'color:var(--faint);margin-left:8px'},c.type),c.pii?h('span',{class:'tag',style:'margin-left:6px;color:var(--crit)'},'PII'):null),
|
|
649
|
+
h('span',{style:'color:var(--faint);font-size:12px'},c.tests.length?c.tests.join(', '):T("no test"))));
|
|
650
|
+
const cols=h('div',{class:'list'},rows);
|
|
651
|
+
let right=h('div',{class:'card empty'},T("Pick a column to see origin and impact."));
|
|
652
|
+
if(L.col&&!L.colData)right=h('div',{class:'card empty'},h('span',{class:'spin'}));
|
|
653
|
+
if(L.col&&L.colData){const g=L.colData.graph,im=L.colData.impact;
|
|
654
|
+
const imp=h('div',{class:'card',style:'margin-top:14px'},h('div',{class:'head'},h('h2',{},T("If {column} changes",{column:d.name+'.'+L.col})),
|
|
655
|
+
h('span',{class:'sev '+(im.count?'high':'info')},im.count+T(" affected model(s)"))),
|
|
656
|
+
im.count?h('table',{},h('thead',{},h('tr',{},[T("Model"),T("Distance"),T("Columns"),T("Owner"),T("Tests")].map(t=>h('th',{},t)))),
|
|
657
|
+
h('tbody',{},im.affected.map(r=>h('tr',{},h('td',{},h('a',{href:'#',style:'color:var(--acc);font-weight:600;text-decoration:none',onclick:e=>{e.preventDefault();linSelect(r.name,r.columns[0])}},r.name)),
|
|
658
|
+
h('td',{},r.distance),h('td',{},r.columns.map(c=>h('span',{class:'tag',style:'margin-right:4px'},c))),h('td',{},r.owner||'—'),h('td',{},r.tests))))):
|
|
659
|
+
h('p',{style:'color:var(--mut);margin:0'},T("No known downstream consumer.")),
|
|
660
|
+
im.owners.length?h('p',{style:'color:var(--mut);margin:10px 0 0'},T("Notify: ")+im.owners.join(', ')):null);
|
|
661
|
+
right=h('div',{},legend,drawGraph(g.nodes.map(n=>({id:n.id,level:n.level,label:n.model+'.'+n.column,sub:n.type,pii:n.pii,center:n.id===g.center})),g.edges,
|
|
662
|
+
n=>{const i=n.label.lastIndexOf('.');linSelect(n.label.slice(0,i),n.label.slice(i+1))}),imp)}
|
|
663
|
+
body=h('div',{class:'colgrid'},cols,right)}
|
|
664
|
+
return h('div',{},info,tabs,body)}
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
/* ---------- data diff ---------- */
|
|
668
|
+
S.diff={base:'',head:'',key:'',res:null,busy:false,err:null};
|
|
669
|
+
async function runDiff(){const D=S.diff;D.busy=true;D.err=null;D.res=null;render();
|
|
670
|
+
try{D.res=await post('/api/diff',{base:D.base,head:D.head,key:D.key,sample:5})}catch(e){D.err=e.message}
|
|
671
|
+
D.busy=false;render()}
|
|
672
|
+
function diffPage(){const D=S.diff;
|
|
673
|
+
const inp=(k,ph,label)=>h('div',{class:'field'},h('label',{},label),h('input',{type:'text',value:D[k],placeholder:ph,oninput:e=>{D[k]=e.target.value}}));
|
|
674
|
+
const form=h('div',{class:'card'},h('div',{class:'form'},inp('base','prod.orders',T("Base relation (before)")),inp('head','dev.orders',T("New relation (after)")),inp('key','order_id',T("Key (comma-separated columns)"))),
|
|
675
|
+
h('div',{style:'margin-top:14px'},h('button',{class:'btn pri',disabled:D.busy,onclick:runDiff},D.busy?h('span',{},h('span',{class:'spin'}),T(" Comparing…")):T("Compare"))),
|
|
676
|
+
h('p',{style:'color:var(--faint);font-size:12.5px;margin:10px 0 0'},T("The comparison runs inside your warehouse (configured DuckDB or PostgreSQL). Only counts and a sample of rows leave it.")));
|
|
677
|
+
let out=null;
|
|
678
|
+
if(D.err)out=h('div',{class:'card',style:'margin-top:14px;border-color:var(--crit)'},h('b',{style:'color:var(--crit)'},T("Could not compare")),h('p',{style:'margin:6px 0 0'},D.err));
|
|
679
|
+
if(D.res){const r=D.res;
|
|
680
|
+
const stat=(l,v,tone)=>h('div',{class:'card kpi',style:'cursor:default'},h('div',{class:'l'},l),h('div',{class:'n',style:tone?`color:var(--${tone})`:''},String(v)));
|
|
681
|
+
const cols=Object.entries(r.changed_by_column);
|
|
682
|
+
const smp=r.samples.length?h('div',{class:'card',style:'margin-top:14px;padding:6px 10px'},h('table',{},h('thead',{},h('tr',{},Object.keys(r.samples[0]).map(k=>h('th',{},k)))),
|
|
683
|
+
h('tbody',{},r.samples.map(s=>h('tr',{},Object.values(s).map(v=>h('td',{},String(v))))))) ):null;
|
|
684
|
+
out=h('div',{style:'margin-top:14px'},
|
|
685
|
+
r.identical?h('div',{class:'card',style:'border-color:var(--ok)'},h('b',{style:'color:var(--ok)'},T("✓ No differences")),h('p',{style:'margin:6px 0 0;color:var(--mut)'},T("{n} identical rows.",{n:r.rows.base}))):
|
|
686
|
+
h('div',{class:'grid g4'},stat(T("Rows (base → new)"),`${r.rows.base} → ${r.rows.head}`),stat(T("Only in base"),r.only_in_base,r.only_in_base?'high':null),stat(T("Only in new"),r.only_in_head,r.only_in_head?'med':null),
|
|
687
|
+
stat(T("Changed rows"),r.changed_rows,r.changed_rows?'med':null),stat(T("Duplicated keys (base/new)"),`${r.duplicate_keys.base} / ${r.duplicate_keys.head}`,r.duplicate_keys.head?'high':null)),
|
|
688
|
+
r.schema.added.length||r.schema.removed.length||r.schema.type_changed.length?h('div',{class:'card',style:'margin-top:14px'},h('b',{},T("Schema changes")),
|
|
689
|
+
h('p',{style:'margin:6px 0 0;color:var(--mut)'},T("+ {added} · − {removed} · type: {changed}",{added:r.schema.added.join(', ')||'—',removed:r.schema.removed.join(', ')||'—',changed:r.schema.type_changed.map(t=>t.join(' ')).join('; ')||'—'}))):null,
|
|
690
|
+
cols.length?h('div',{class:'card',style:'margin-top:14px;padding:6px 10px'},h('table',{},h('thead',{},h('tr',{},[T("Column"),T("Changed rows")].map(t=>h('th',{},t)))),
|
|
691
|
+
h('tbody',{},cols.map(([c,n])=>h('tr',{},h('td',{},h('b',{},c)),h('td',{},n)))))):null,smp)}
|
|
692
|
+
return h('div',{},header(T("Data diff"),T("Compare two versions of a table before promoting a change: new, removed and changed rows.")),form,out)}
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
function assignBox(f){if(!(S.me&&S.me.team))return null;
|
|
696
|
+
const sel=h('select',{onchange:e=>act(T("Assigned"),()=>post(`/api/findings/${encodeURIComponent(f.id)}/assign`,{assignee:e.target.value||null}))},
|
|
697
|
+
h('option',{value:''},T("no assignee")),S.team.map(n=>h('option',{value:n,selected:n===f.assignee},n)));
|
|
698
|
+
return h('dl',{},h('dt',{},T("Assignee")),h('dd',{},sel))}
|
|
699
|
+
function notesBox(f){if(!(S.me&&S.me.team))return null;
|
|
700
|
+
if(S.notes[f.id]===undefined){S.notes[f.id]=null;api('/api/notes/'+encodeURIComponent(f.id)).then(r=>{S.notes[f.id]=r.notes;render()}).catch(()=>{S.notes[f.id]=[]})}
|
|
701
|
+
const list=S.notes[f.id]||[];
|
|
702
|
+
const ta=h('input',{type:'text',placeholder:T("Comment…"),style:'width:100%',onkeydown:e=>{if(e.key==='Enter'&&e.target.value.trim()){const t=e.target.value;
|
|
703
|
+
act(T("Comment saved"),()=>post(`/api/findings/${encodeURIComponent(f.id)}/note`,{text:t}),()=>{S.notes[f.id]=undefined;render()})}}});
|
|
704
|
+
return h('dl',{},h('dt',{},T("Comments")),h('dd',{},list.map(n=>h('div',{style:'margin:4px 0'},h('b',{},n.author),' ',h('span',{style:'color:var(--faint);font-size:12px'},ago(n.ts)),h('div',{},n.text))),ta))}
|
|
705
|
+
function teamPage(){const st=S.teamAdmin;
|
|
706
|
+
if(st===undefined){S.teamAdmin=null;api('/api/users').then(r=>{S.teamAdmin=r.users;S.teamProjects=r.projects;S.teamSso=r.sso;render()}).catch(e=>{S.teamAdmin=[];toast(e.message,true)})}
|
|
707
|
+
const users=S.teamAdmin||[];
|
|
708
|
+
const reload=()=>{S.teamAdmin=undefined;S.team=[];load()};
|
|
709
|
+
const call=(body,msg)=>act(msg,()=>post('/api/users',body),reload);
|
|
710
|
+
const rows=users.map(u=>{
|
|
711
|
+
const role=h('select',{onchange:e=>call({action:'role',name:u.name,role:e.target.value},T("Role updated"))},['viewer','engineer','admin'].map(r=>h('option',{value:r,selected:r===u.role},{admin:'admin',engineer:T("engineer"),viewer:T("viewer")}[r])));
|
|
712
|
+
return h('tr',{},h('td',{},h('b',{},u.name)),h('td',{},role),h('td',{},u.disabled?h('span',{class:'pill failed'},T("disabled")):h('span',{class:'pill success'},T("active"))),
|
|
713
|
+
h('td',{},u.mfa?h('span',{class:'pill success'},'MFA'):h('span',{style:'color:var(--faint)'},'—')),
|
|
714
|
+
h('td',{},expiryCell(u.token_expires)),
|
|
715
|
+
h('td',{style:'color:var(--mut)'},u.last_seen?ago(u.last_seen):T("never")),
|
|
716
|
+
h('td',{},h('button',{class:'btn sm',onclick:async()=>{try{const r=await post('/api/users',{action:'rotate',name:u.name});tokenModal(u.name,r.token)}catch(e){toast(e.message,true)}}},T("New token")),' ',
|
|
717
|
+
h('button',{class:'btn sm '+(u.disabled?'':'danger'),onclick:()=>call({action:u.disabled?'enable':'disable',name:u.name},u.disabled?T("Enabled"):T("Disabled"))},u.disabled?T("Enable"):T("Disable"))))});
|
|
718
|
+
const nm=h('input',{type:'text',placeholder:T("name (e.g. maria)"),style:'width:200px'}),rl=h('select',{},['viewer','engineer','admin'].map(r=>h('option',{value:r,selected:r==='engineer'},{admin:'admin',engineer:T("engineer"),viewer:T("viewer")}[r])));
|
|
719
|
+
const ex=h('select',{title:T("Token validity")},[['',T("token without expiry")],['30',T("expires in 30 days")],['90',T("expires in 90 days")],['365',T("expires in 1 year")]].map(([v,l])=>h('option',{value:v},l)));
|
|
720
|
+
const add=h('div',{style:'display:flex;gap:8px;flex-wrap:wrap;margin-top:14px'},nm,rl,ex,h('button',{class:'btn pri',onclick:async()=>{
|
|
721
|
+
try{const r=await post('/api/users',{action:'add',name:nm.value.trim(),role:rl.value,expires_days:ex.value||null});tokenModal(nm.value.trim(),r.token);reload()}catch(e){toast(e.message,true)}}},T("Add person")));
|
|
722
|
+
const projs=(S.teamProjects||[]).filter(p=>p!==S.me.default_project);
|
|
723
|
+
const projRoles=users.length&&projs.length?h('div',{class:'card',style:'margin-top:14px;padding:6px 10px'},h('h2',{style:'padding:8px 0 4px'},T("Role per project")),
|
|
724
|
+
h('table',{},h('thead',{},h('tr',{},[h('th',{},T("Person")),...projs.map(p=>h('th',{},p))])),
|
|
725
|
+
h('tbody',{},users.map(u=>h('tr',{},h('td',{},h('b',{},u.name)),...projs.map(p=>{
|
|
726
|
+
const cur=(u.project_roles||{})[p]||'inherit';
|
|
727
|
+
const sel=h('select',{onchange:e=>call({action:'project_role',name:u.name,project:p,role:e.target.value==='inherit'?null:e.target.value},T("Project role updated"))},
|
|
728
|
+
[['inherit',T("inherits (")+({admin:'admin',engineer:T("engineer"),viewer:T("viewer")}[u.role])+')'],['none',T("no access")],['viewer',T("viewer")],['engineer',T("engineer")],['admin','admin']].map(([v,l])=>h('option',{value:v,selected:v===cur},l)));
|
|
729
|
+
return h('td',{},sel)}))))) ):null;
|
|
730
|
+
const allp=S.teamProjects||[];
|
|
731
|
+
const scopeCard=users.length&&allp.length?h('div',{class:'card',style:'margin-top:14px;padding:6px 10px'},h('h2',{style:'padding:8px 0 2px'},T("Scope per folder (write)")),
|
|
732
|
+
h('p',{style:'color:var(--mut);margin:0 0 8px;font-size:12.5px'},T("Comma-separated patterns (e.g. models/marts/*, models/crm/**). Empty = no restriction. Limits who can create/approve/apply fixes and act on findings; reading stays open.")),
|
|
733
|
+
h('table',{},h('thead',{},h('tr',{},[h('th',{},T("Person")),...allp.map(p=>h('th',{},p))])),
|
|
734
|
+
h('tbody',{},users.filter(u=>u.role!=='admin').map(u=>h('tr',{},h('td',{},h('b',{},u.name)),...allp.map(p=>{
|
|
735
|
+
const cur=((u.scopes||{})[p]||[]).join(', ');
|
|
736
|
+
const i=h('input',{type:'text',value:cur,placeholder:T("no restriction"),style:'width:100%;min-width:150px',
|
|
737
|
+
onchange:e=>call({action:'scope',name:u.name,project:p,patterns:e.target.value.split(',').map(x=>x.trim()).filter(Boolean)},T("Scope updated"))});
|
|
738
|
+
return h('td',{},i)})))))):null;
|
|
739
|
+
const sso=S.teamSso||{};
|
|
740
|
+
const sf=(k,l,ph)=>{const i=h('input',{type:'text',value:Array.isArray(sso[k])?sso[k].join(', '):(sso[k]==null?'':String(sso[k])),placeholder:ph||'',style:'width:100%'});i.dataset.k=k;return h('div',{class:'field'},h('label',{},l),i)};
|
|
741
|
+
const ssoCard=h('div',{class:'card',style:'margin-top:14px'},h('h2',{style:'margin-bottom:4px'},T("Single sign-on (SSO / OpenID Connect)")),
|
|
742
|
+
h('p',{style:'color:var(--mut);margin:0 0 10px'},T("Works with OIDC providers (Keycloak, Entra ID, Okta, Google…). The client secret lives in a server environment variable.")),
|
|
743
|
+
h('div',{class:'form',id:'ssoform'},sf('issuer','Issuer',T("https://login.example.com/realms/data")),sf('client_id','Client ID','intentflow'),
|
|
744
|
+
sf('client_secret_env',T("Variable holding the client secret"),'INTENTFLOW_SSO_SECRET'),sf('default_role',T("Role of first-time users"),'viewer'),
|
|
745
|
+
sf('allowed_domains',T("Allowed e-mail domains"),T("example.com, other.com")),sf('auto_provision',T("Create the user on first login? (true/false)"),'false'),
|
|
746
|
+
sf('group_claim',T("Claim with the groups"),'groups'),sf('require_group',T("Deny people without a mapped group? (true/false)"),'false'),sf('sync_roles',T("Apply groups to users added by hand? (true/false)"),'false')),
|
|
747
|
+
h('div',{class:'field',style:'margin-top:10px'},h('label',{},T("Groups → roles (one rule per line)")),
|
|
748
|
+
(()=>{const t=h('textarea',{id:'gmap',rows:'4',style:'width:100%;font:13px ui-monospace,monospace',placeholder:'dados-admin=admin\ncrm-eng=engineer@crm\ndados-leitura=viewer'},((sso.group_map||[]).map(m=>`${m.group}=${m.role}${m.project?'@'+m.project:''}`).join('\n')));return t})()),
|
|
749
|
+
h('div',{style:'margin-top:12px'},h('button',{class:'btn pri',onclick:async()=>{const body={};document.querySelectorAll('#ssoform input').forEach(i=>{let v=i.value.trim();
|
|
750
|
+
if(['auto_provision','require_group','sync_roles'].includes(i.dataset.k))v=v==='true'?true:(v===''?'':false);body[i.dataset.k]=v});
|
|
751
|
+
body.group_map=document.getElementById('gmap').value.trim();
|
|
752
|
+
try{await post('/api/sso',body);toast(T("SSO saved"));S.teamAdmin=undefined;load()}catch(e){toast(e.message,true)}}},T("Save SSO"))));
|
|
753
|
+
const roles=h('div',{class:'card',style:'margin-top:14px'},h('h2',{style:'margin-bottom:6px'},T("What each role can do")),
|
|
754
|
+
h('table',{},h('tbody',{},[[T("Viewer"),T("See everything: findings, lineage, pipelines, audit.")],[T("Engineer"),T("Everything a viewer can + acknowledge, false positive, assign, comment, create/validate/approve/apply fixes, run checks and diffs.")],
|
|
755
|
+
['Admin',T("Everything + settings, policies and team management.")]].map(([a,b])=>h('tr',{},h('td',{},h('b',{},a)),h('td',{style:'color:var(--mut)'},b))))),
|
|
756
|
+
h('p',{style:'color:var(--faint);font-size:12.5px;margin:10px 0 0'},T("Whoever creates a fix cannot approve it (separation of duties). Each action is in the Audit log with the name of who did it.")));
|
|
757
|
+
return h('div',{},header(T("Team"),T("People with access and what each one can do.")),
|
|
758
|
+
h('div',{class:'card',style:'padding:6px 10px'},users.length?h('table',{},h('thead',{},h('tr',{},[T("Name"),T("Role"),T("State"),'MFA',T("Token expires"),T("Last access"),''].map(t=>h('th',{},t)))),h('tbody',{},rows)):h('div',{class:'empty'},h('span',{class:'spin'}))),
|
|
759
|
+
add,has('project_roles')?projRoles:null,has('project_roles')?scopeCard:null,has('sso')?ssoCard:null,roles)}
|
|
760
|
+
function expiryCell(t){if(!t)return h('span',{style:'color:var(--faint)'},T("never"));
|
|
761
|
+
const d=Math.ceil((t-Date.now()/1000)/86400);
|
|
762
|
+
return d<0?h('span',{class:'pill failed'},T("expired")):h('span',{class:'pill '+(d<=7?'pending':'success')},d===0?T("today"):T("in {n} d",{n:d}))}
|
|
763
|
+
function recoveryModal(codes,after){const txt=codes.join('\n');
|
|
764
|
+
const m=h('div',{class:'modal',role:'dialog','aria-modal':'true'},h('div',{},h('h2',{},T("Recovery codes")),
|
|
765
|
+
h('p',{class:'sub',style:'margin:8px 0'},T("Each code works once and replaces the app if you lose your phone. Keep them in a password manager: they will not be shown again.")),
|
|
766
|
+
h('pre',{style:'padding:10px;background:var(--panel2);border-radius:8px;user-select:all;columns:2'},txt),
|
|
767
|
+
h('div',{style:'display:flex;gap:8px;justify-content:flex-end;margin-top:14px'},
|
|
768
|
+
h('button',{class:'btn',onclick:()=>{try{navigator.clipboard.writeText(txt);toast(T("Copied"))}catch(e){toast(T("Select and copy by hand"),true)}}},T("Copy")),
|
|
769
|
+
h('button',{class:'btn pri',onclick:()=>{m.remove();if(after)after()}},T("I saved the codes")))));document.body.append(m)}
|
|
770
|
+
function tokenModal(name,token){const m=h('div',{class:'modal',role:'dialog','aria-modal':'true'},h('div',{},h('h2',{},T("Token for ")+name),
|
|
771
|
+
h('p',{class:'sub',style:'margin:8px 0'},T("Copy it now and send it to the person through a secure channel. It will not be shown again.")),
|
|
772
|
+
h('pre',{style:'padding:10px;background:var(--panel2);border-radius:8px;user-select:all'},token),
|
|
773
|
+
h('div',{style:'display:flex;justify-content:flex-end;margin-top:14px'},h('button',{class:'btn pri',onclick:()=>m.remove()},T("I copied it")))));document.body.append(m)}
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
function mfaDialog(){
|
|
777
|
+
if(S.me.user.mfa){const code=h('input',{type:'text',placeholder:T("Current code"),maxlength:'6',style:'width:100%'});
|
|
778
|
+
const m=h('div',{class:'modal',role:'dialog','aria-modal':'true',onclick:e=>{if(e.target===m)m.remove()}},h('div',{},h('h2',{},T("Two-step verification on")),
|
|
779
|
+
h('p',{class:'sub',style:'margin:8px 0'},T("To turn it off or generate new recovery codes (the old ones stop working), enter the current authenticator code.")),code,
|
|
780
|
+
h('div',{style:'display:flex;gap:8px;justify-content:flex-end;margin-top:14px'},h('button',{class:'btn',onclick:()=>m.remove()},T("Close")),
|
|
781
|
+
h('button',{class:'btn',onclick:async()=>{try{const r=await post('/api/mfa',{action:'recovery',code:code.value});m.remove();recoveryModal(r.recovery_codes)}catch(e){toast(e.message,true)}}},T("Generate new codes")),
|
|
782
|
+
h('button',{class:'btn danger',onclick:async()=>{try{await post('/api/mfa',{action:'disable',code:code.value});m.remove();S.me=null;await load();toast(T("MFA disabled"))}catch(e){toast(e.message,true)}}},T("Disable")))));
|
|
783
|
+
document.body.append(m);return}
|
|
784
|
+
post('/api/mfa',{action:'begin'}).then(r=>{const code=h('input',{type:'text',placeholder:T("6-digit code"),maxlength:'6',style:'width:100%;margin-top:10px'});
|
|
785
|
+
const m=h('div',{class:'modal',role:'dialog','aria-modal':'true'},h('div',{},h('h2',{},T("Turn on two-step verification")),
|
|
786
|
+
h('p',{class:'sub',style:'margin:8px 0'},T("In the authenticator app (Google Authenticator, Authy, 1Password…) add a manual account with the key below, then enter the generated code.")),
|
|
787
|
+
h('pre',{style:'padding:10px;background:var(--panel2);border-radius:8px;user-select:all'},r.secret),code,
|
|
788
|
+
h('div',{style:'display:flex;gap:8px;justify-content:flex-end;margin-top:14px'},h('button',{class:'btn',onclick:()=>m.remove()},T("Cancel")),
|
|
789
|
+
h('button',{class:'btn pri',onclick:async()=>{try{const r=await post('/api/mfa',{action:'confirm',code:code.value});m.remove();S.me=null;await load();recoveryModal(r.recovery_codes||[],()=>toast(T("MFA on: use the code at your next login")))}catch(e){toast(e.message,true)}}},T("Confirm")))));
|
|
790
|
+
document.body.append(m)}).catch(e=>toast(e.message,true))}
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
/* ---------- integrations ---------- */
|
|
794
|
+
function integrationsPage(){const st=S.integ;
|
|
795
|
+
if(st===undefined){S.integ=null;api('/api/integrations').then(r=>{S.integ=r;render()}).catch(e=>{S.integ={groups:[],error:e.message};render()})}
|
|
796
|
+
if(!st)return h('div',{},header(T("Integrations"),T("Everything IntentFlow reads and sends, and whether it works.")),h('div',{class:'card empty'},h('span',{class:'spin'})));
|
|
797
|
+
if(st.error)return h('div',{},header(T("Integrations"),''),empty(T("Could not load"),st.error));
|
|
798
|
+
const pill=c=>h('span',{class:'pill '+({ok:'success',warn:'pending'}[c.state]||'')},{ok:T("live"),warn:T("attention")}[c.state]||'');
|
|
799
|
+
const goCfg=()=>{location.hash='#/config'};
|
|
800
|
+
const all=st.groups.flatMap(g=>g.cards.map(c=>({...c,group:g.name})));
|
|
801
|
+
const active=all.filter(c=>c.configured),off=all.filter(c=>!c.configured);
|
|
802
|
+
const grid=cards=>h('div',{style:'display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:10px'},cards.map(c=>
|
|
803
|
+
h('div',{class:'card stripe '+(c.state==='warn'?'medium':'low'),style:'padding:12px 14px'},
|
|
804
|
+
h('div',{style:'display:flex;justify-content:space-between;align-items:center;gap:8px'},h('b',{},c.name),pill(c)),
|
|
805
|
+
h('div',{style:'color:var(--faint);font-size:11.5px;margin-top:2px'},c.group),
|
|
806
|
+
h('div',{style:'color:var(--mut);font-size:13px;margin-top:6px'},c.summary),
|
|
807
|
+
c.state==='warn'?h('div',{style:'margin-top:8px'},h('button',{class:'btn sm',onclick:goCfg},T("Adjust"))):null)));
|
|
808
|
+
const groups=[...new Set(off.map(c=>c.group))];
|
|
809
|
+
const avail=groups.map(g=>h('div',{style:'margin-top:10px'},h('div',{style:'font-weight:600;font-size:12.5px;color:var(--mut);margin-bottom:6px'},g),
|
|
810
|
+
h('div',{style:'display:flex;flex-wrap:wrap;gap:6px'},off.filter(c=>c.group===g).map(c=>
|
|
811
|
+
h('button',{class:'btn sm',title:c.summary+(c.keys.length?' — configure: '+c.keys.join(', '):''),onclick:goCfg},'+ '+c.name)))));
|
|
812
|
+
return h('div',{},header(T("Integrations"),T("{on} of {total} on",{on:st.configured,total:st.total})+(st.warnings?T(" · {n} need attention",{n:st.warnings}):'')+'.',
|
|
813
|
+
h('button',{class:'btn',onclick:()=>{S.integ=undefined;render()}},T("Refresh"))),
|
|
814
|
+
h('h2',{style:'margin:18px 0 8px'},T("Active")),active.length?grid(active):empty(T("No integration on yet"),T("Pick one below and fill it in Settings.")),
|
|
815
|
+
h('div',{class:'card',style:'margin-top:18px'},h('h2',{style:'margin:0 0 2px'},T("Available to turn on")),
|
|
816
|
+
h('p',{class:'sub',style:'margin:0'},T("Click to open Settings; hover to see the keys of each one.")),...avail))}
|
|
817
|
+
|
|
818
|
+
/* ---------- business rules ---------- */
|
|
819
|
+
function rulesPage(){
|
|
820
|
+
const key=(S.project||'main')+'|'+(S.cfg.last_check?.ts||'');
|
|
821
|
+
if(!S.rules||S.rules.key!==key){
|
|
822
|
+
S.rules={key,loading:true};
|
|
823
|
+
api('/api/rules').then(data=>{if(S.rules?.key===key){S.rules={key,...data};render()}})
|
|
824
|
+
.catch(e=>{if(S.rules?.key===key){S.rules={key,error:e.message};render()}});
|
|
825
|
+
}
|
|
826
|
+
const data=S.rules;
|
|
827
|
+
const head=header(T("Business rules"),T("Business expectations, their latest results and affected models."),
|
|
828
|
+
h('button',{class:'btn',onclick:()=>{S.rules=null;render()}},T("Refresh")));
|
|
829
|
+
if(data.loading)return h('div',{},head,h('div',{class:'card empty'},h('span',{class:'spin'})));
|
|
830
|
+
if(data.error)return h('div',{},head,empty(T("Could not load"),data.error));
|
|
831
|
+
if(!data.rules.length)return h('div',{},head,empty(T("No business rules declared"),T("Tag dbt tests with business_rule and set meta.owner. Run dbt build, then Check now.")));
|
|
832
|
+
const labels={pass:T("Passed"),success:T("Passed"),fail:T("Failed"),error:T("Error"),warn:T("Warning"),skipped:T("Not executed"),not_run:T("Not executed"),stale:T("Outdated result")};
|
|
833
|
+
const pill=status=>h('span',{class:'pill '+(['pass','success'].includes(status)?'success':['fail','error'].includes(status)?'failed':'pending')},labels[status]||status);
|
|
834
|
+
return h('div',{},head,h('p',{class:'sub'},T("Missing or outdated results do not mean a rule passed.")),data.rules.map(rule=>
|
|
835
|
+
h('div',{class:'card',style:'padding:14px;margin-bottom:10px'},
|
|
836
|
+
h('div',{style:'display:flex;justify-content:space-between;gap:10px'},h('b',{},rule.name),pill(rule.status)),
|
|
837
|
+
rule.description?h('p',{},rule.description):null,
|
|
838
|
+
h('p',{class:'sub'},T("Owner")+': '+(rule.owner||T("no owner set"))+' · '+T("Models")+': '+rule.models.join(', ')),
|
|
839
|
+
h('p',{class:'sub'},T("Affected downstream")+': '+(rule.downstream.join(', ')||'—')),
|
|
840
|
+
h('p',{class:'sub'},T("Failing rows")+': '+(rule.failures??'—')+' · '+T("Last result")+': '+(rule.generated_at?new Date(rule.generated_at).toLocaleString():'—')),
|
|
841
|
+
h('details',{},h('summary',{},T("Recent executions")+' ('+rule.history.length+')'),
|
|
842
|
+
rule.history.length?h('table',{},h('thead',{},h('tr',{},[T("Last result"),T("State"),T("Failing rows")].map(label=>h('th',{},label)))),
|
|
843
|
+
h('tbody',{},[...rule.history].reverse().map(run=>h('tr',{},h('td',{},run.generated_at?new Date(run.generated_at).toLocaleString():'—'),h('td',{},pill(run.status)),h('td',{},run.failures??'—'))))):h('p',{class:'sub'},T("History is recorded when checks run."))))));
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/* ---------- candidate change review ---------- */
|
|
847
|
+
function changesPage(){
|
|
848
|
+
const key=(S.project||'main')+'|'+(S.cfg.settings?.['dbt.target']||'')+'|'+(S.cfg.settings?.['dbt.base_target']||'')+'|'+(S.cfg.settings?.['dbt.base_revision']||'')+'|'+(S.cfg.last_check?.ts||'');
|
|
849
|
+
if(!S.changes||S.changes.key!==key){
|
|
850
|
+
S.changes={key,loading:true};
|
|
851
|
+
api('/api/changes').then(data=>{if(S.changes?.key===key){S.changes={key,...data};render()}})
|
|
852
|
+
.catch(e=>{if(S.changes?.key===key){S.changes={key,error:e.message};render()}});
|
|
853
|
+
}
|
|
854
|
+
const data=S.changes;
|
|
855
|
+
const head=header(T("Changes before production"),T("Compare the candidate with an approved baseline and inspect the known impact."),
|
|
856
|
+
h('button',{class:'btn',onclick:()=>{S.changes=null;render()}},T("Refresh")));
|
|
857
|
+
if(data.loading)return h('div',{},head,h('div',{class:'card empty'},h('span',{class:'spin'})));
|
|
858
|
+
if(data.error)return h('div',{},head,empty(T("Comparison unavailable"),data.error),h('p',{class:'sub'},T("Configure dbt.target and dbt.base_target for this project. The candidate must not be its own baseline.")));
|
|
859
|
+
return h('div',{},head,
|
|
860
|
+
data.gaps.length?empty(T("Comparison incomplete"),T("Some catalog columns are unavailable; no complete schema comparison can be claimed.")):null,
|
|
861
|
+
h('p',{class:'sub'},T("{total} change(s); {reviews} require review.",{total:data.summary.total,reviews:data.summary.review_required})),
|
|
862
|
+
data.changes.length?data.changes.slice(0,100).map(change=>h('div',{class:'card',style:'padding:14px;margin-bottom:10px'},
|
|
863
|
+
h('div',{style:'display:flex;justify-content:space-between;gap:10px'},h('b',{},change.name),
|
|
864
|
+
h('span',{class:'pill '+(change.requires_review?'pending':'')},change.requires_review?T("Review required"):T("Informational"))),
|
|
865
|
+
h('p',{},change.message),h('p',{class:'sub'},T("Owner")+': '+(change.owner||T("no owner set"))),
|
|
866
|
+
h('p',{class:'sub'},T("Known impact")+': '+(change.impact.map(node=>node.name).join(', ')||'—')),
|
|
867
|
+
change.impact_truncated?h('p',{class:'sub'},T("Impact preview is limited; inspect lineage for the remaining dependencies.")):null,
|
|
868
|
+
h('code',{},change.id))):empty(T("No declared changes found"),T("This does not replace a full build, business tests or a data diff.")),
|
|
869
|
+
data.changes.length>100?h('p',{class:'sub'},T("Showing the first 100 changes. Use the changes CLI JSON report for the full list.")):null,
|
|
870
|
+
h('p',{class:'sub'},data.note));
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
/* ---------- boot ---------- */
|
|
874
|
+
$('#runbtn').addEventListener('click',()=>act(T("Check started"),()=>post('/api/run/check')));
|
|
875
|
+
function route(){const v=(location.hash.replace('#/','')||'overview');S.view=VIEWS.some(x=>x[0]===v)?v:'overview';if(S.data)render()}
|
|
876
|
+
window.addEventListener('hashchange',route);
|
|
877
|
+
route();load();setInterval(load,5000);
|
|
878
|
+
</script></body></html>
|