Altinity / Altinity/altinity-sql-browser

[sup] ACM-mode transport adapter: cookie auth, JSON-body /query, per-format result unwrap, settings-into-SQL, fake-stream

Abierto
#353 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

enhancement sup
Lenguaje dominante
TypeScript
Estrellas
8
Forks
2
Merge medio
1 h 34 min
PR fusionados (30 d)
6

Descripción

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}/query with credentials:'same-origin' and no Authorization/X-Auth-Token header.
  • JSON body request: { node, query, ddl, user, password, timeout, swarm } (matches acm-ui's own cluster-explore/query). SQL/creds never in the URL.
  • Settings → in-SQL: rewrite otherwise-dropped query-string settings into an appended SETTINGS <k=v,…> clause; then FORMAT <fmt>. ⚠️ SQL-tail rewriter must handle existing FORMAT/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-ok Response carrying the CH error text (so parseExceptionText works); else wrap result as raw text for the requested format (do NOT blindly JSON.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 so runQuery's reader loop + grids work unchanged.
  • Explicit node required on every query (LB nondeterminism verified).

Removed vs. original

  • Map AUTHENTICATION_FAILED → synthetic 401 to reuse refresh(). 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 shared authedFetch refresh path (which latches authConfirmed after first success anyway).

Acceptance

  • Injected fetch; no changes to authedFetch/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.
  • result wrapped per-format; empty bodies + error envelopes handled.
  • Grids render via the fake stream unchanged; explicit node targeting.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Empieza en src/core y sigue el límite de ctx.fetch inyectado, dejando intactos authedFetch, queryJson y runQuery. Implementa y prueba con tests unitarios la traducción de la cola SQL para FORMAT, SETTINGS, punto y coma y comentarios; después verifica las solicitudes JSON autenticadas mediante cookies, el envoltorio de resultados por formato, las envolturas de error, la selección explícita del nodo de destino y el renderizado de la cuadrícula con fake-stream según la lista de aceptación.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
sql, typescript
Área
api, backend, databases
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
52/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.