integration layer; merge work on indicators from forks with existing ingestion pipeline
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable, map } from 'rxjs';
|
||||
import { PreviewResponse, SourceColumn, SqlConnectionRef } from './api.types';
|
||||
|
||||
/** POST /imports/sources/sql/*. Stateless: every call carries the connection. */
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class SqlSourceApi {
|
||||
private readonly http = inject(HttpClient);
|
||||
|
||||
testConnection(connection: SqlConnectionRef): Observable<{ ok: true; dialect: string }> {
|
||||
return this.http.post<{ ok: true; dialect: string }>('/imports/sources/sql/test-connection', connection);
|
||||
}
|
||||
|
||||
schemas(connection: SqlConnectionRef): Observable<string[]> {
|
||||
return this.http.post<{ schemas: string[] }>('/imports/sources/sql/schemas', connection).pipe(map((response) => response.schemas));
|
||||
}
|
||||
|
||||
tables(connection: SqlConnectionRef, schema?: string): Observable<string[]> {
|
||||
return this.http
|
||||
.post<{ tables: string[] }>('/imports/sources/sql/tables', { ...connection, ...(schema ? { schema } : {}) })
|
||||
.pipe(map((response) => response.tables));
|
||||
}
|
||||
|
||||
columns(connection: SqlConnectionRef, table: string, schema?: string): Observable<SourceColumn[]> {
|
||||
return this.http
|
||||
.post<{ columns: SourceColumn[] }>('/imports/sources/sql/columns', { ...connection, table, ...(schema ? { schema } : {}) })
|
||||
.pipe(map((response) => response.columns));
|
||||
}
|
||||
|
||||
preview(
|
||||
connection: SqlConnectionRef,
|
||||
source: { table?: string; schema?: string; query?: string },
|
||||
target: string | null,
|
||||
): Observable<PreviewResponse> {
|
||||
return this.http.post<PreviewResponse>('/imports/sources/sql/preview', {
|
||||
...connection,
|
||||
...(source.query ? { query: source.query } : { table: source.table, ...(source.schema ? { schema: source.schema } : {}) }),
|
||||
...(target ? { target } : {}),
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user