Altinity / Altinity/altinity-sql-browser
[sup] ACM-mode transport adapter: cookie auth, JSON-body /query, per-format result unwrap, settings-into-SQL, fake-stream
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 8
- Fork
- 2
- Merge medio
- 1h 34m
- PR unite (30g)
- 6
Descrizione
Part of #352. Updated for the same-origin / cookie-auth model.
ACM-mode transport behind the injected ctx.fetch, so authedFetch/queryJson/runQuery/loadSchema stay untouched. Pure translation logic in src/core/ at 100%.
Scope
- Cookie auth, no token. Requests go to
/api/cluster/{id}/querywithcredentials:'same-origin'and noAuthorization/X-Auth-Tokenheader. - JSON body request:
{ node, query, ddl, user, password, timeout, swarm }(matches acm-ui's owncluster-explore/query). SQL/creds never in the URL. - Settings → in-SQL: rewrite otherwise-dropped query-string settings into an appended
SETTINGS <k=v,…>clause; thenFORMAT <fmt>. ⚠️ SQL-tail rewriter must handle existingFORMAT/SETTINGS, trailing;, comments — its own pure module + tests. - Response unwrap: parse the per-node array → select the target node → on
meta.error, synthesize a non-okResponse carrying the CH error text (soparseExceptionTextworks); else wrapresultas raw text for the requested format (do NOT blindlyJSON.parse— TSV/CSV/raw and empty effect-statement bodies must pass through). - Fake progress-stream: for
Table/KPI/Filter, emit the buffered rows as synthetic progress lines sorunQuery's reader loop + grids work unchanged. - Explicit node required on every query (LB nondeterminism verified).
Removed vs. original
Map. The ACM session is browser-managed (cookie); a real session expiry is a normal login redirect. Only the temp CH password is ours to re-mint (see #354) — via an explicit single-flight remint on a CH-auth error, not by sniffing error text into the sharedAUTHENTICATION_FAILED→ synthetic 401 to reuserefresh()authedFetchrefresh path (which latchesauthConfirmedafter first success anyway).
Acceptance
- Injected
fetch; no changes toauthedFetch/queryJson/runQuery. - Cookie auth; nothing in the URL; JSON body.
- Settings effective via in-SQL
SETTINGS; SQL-tail rewriter unit-tested on FORMAT/SETTINGS/;/comment edge cases. -
resultwrapped per-format; empty bodies + error envelopes handled. - Grids render via the fake stream unchanged; explicit node targeting.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in src/core e segui il confine di ctx.fetch iniettato, lasciando invariati authedFetch, queryJson e runQuery. Implementa e sottoponi a unit test la traduzione della coda SQL per FORMAT, SETTINGS, punti e virgola e commenti, quindi verifica le richieste JSON autenticate tramite cookie, il wrapping dei risultati per formato, gli envelope degli errori, il targeting esplicito del nodo e il rendering della griglia con fake-stream rispetto alla checklist di accettazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- sql, typescript
- Ambito
- api, backend, databases
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 52/100