@querypanel/node-sdk 1.0.26 → 1.0.28
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.
- package/dist/index.cjs +2498 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +388 -0
- package/dist/index.d.ts +388 -0
- package/dist/index.js +2468 -0
- package/dist/index.js.map +1 -0
- package/package.json +1 -1
- package/dist/cjs/__tests__/ingest.test.d.ts +0 -5
- package/dist/cjs/__tests__/ingest.test.d.ts.map +0 -1
- package/dist/cjs/__tests__/ingest.test.js +0 -95
- package/dist/cjs/__tests__/ingest.test.js.map +0 -1
- package/dist/cjs/adapters/clickhouse.d.ts +0 -48
- package/dist/cjs/adapters/clickhouse.d.ts.map +0 -1
- package/dist/cjs/adapters/clickhouse.js +0 -284
- package/dist/cjs/adapters/clickhouse.js.map +0 -1
- package/dist/cjs/adapters/introspection.spec.d.ts +0 -2
- package/dist/cjs/adapters/introspection.spec.d.ts.map +0 -1
- package/dist/cjs/adapters/introspection.spec.js +0 -192
- package/dist/cjs/adapters/introspection.spec.js.map +0 -1
- package/dist/cjs/adapters/postgres.d.ts +0 -46
- package/dist/cjs/adapters/postgres.d.ts.map +0 -1
- package/dist/cjs/adapters/postgres.js +0 -457
- package/dist/cjs/adapters/postgres.js.map +0 -1
- package/dist/cjs/adapters/postgres.spec.d.ts +0 -2
- package/dist/cjs/adapters/postgres.spec.d.ts.map +0 -1
- package/dist/cjs/adapters/postgres.spec.js +0 -37
- package/dist/cjs/adapters/postgres.spec.js.map +0 -1
- package/dist/cjs/adapters/types.d.ts +0 -38
- package/dist/cjs/adapters/types.d.ts.map +0 -1
- package/dist/cjs/adapters/types.js +0 -3
- package/dist/cjs/adapters/types.js.map +0 -1
- package/dist/cjs/anonymize.spec.d.ts +0 -2
- package/dist/cjs/anonymize.spec.d.ts.map +0 -1
- package/dist/cjs/anonymize.spec.js +0 -78
- package/dist/cjs/anonymize.spec.js.map +0 -1
- package/dist/cjs/clickhouseClient.spec.d.ts +0 -2
- package/dist/cjs/clickhouseClient.spec.d.ts.map +0 -1
- package/dist/cjs/clickhouseClient.spec.js +0 -286
- package/dist/cjs/clickhouseClient.spec.js.map +0 -1
- package/dist/cjs/connectors/__tests__/clickhouse.introspect.test.d.ts +0 -2
- package/dist/cjs/connectors/__tests__/clickhouse.introspect.test.d.ts.map +0 -1
- package/dist/cjs/connectors/__tests__/clickhouse.introspect.test.js +0 -119
- package/dist/cjs/connectors/__tests__/clickhouse.introspect.test.js.map +0 -1
- package/dist/cjs/connectors/base.d.ts +0 -13
- package/dist/cjs/connectors/base.d.ts.map +0 -1
- package/dist/cjs/connectors/base.js +0 -3
- package/dist/cjs/connectors/base.js.map +0 -1
- package/dist/cjs/connectors/clickhouse.d.ts +0 -53
- package/dist/cjs/connectors/clickhouse.d.ts.map +0 -1
- package/dist/cjs/connectors/clickhouse.js +0 -270
- package/dist/cjs/connectors/clickhouse.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -490
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -843
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/index.test.d.ts +0 -2
- package/dist/cjs/index.test.d.ts.map +0 -1
- package/dist/cjs/index.test.js +0 -185
- package/dist/cjs/index.test.js.map +0 -1
- package/dist/cjs/introspectV3.d.ts +0 -45
- package/dist/cjs/introspectV3.d.ts.map +0 -1
- package/dist/cjs/introspectV3.js +0 -99
- package/dist/cjs/introspectV3.js.map +0 -1
- package/dist/cjs/multidb.spec.d.ts +0 -2
- package/dist/cjs/multidb.spec.d.ts.map +0 -1
- package/dist/cjs/multidb.spec.js +0 -76
- package/dist/cjs/multidb.spec.js.map +0 -1
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/schema/types.d.ts +0 -73
- package/dist/cjs/schema/types.d.ts.map +0 -1
- package/dist/cjs/schema/types.js +0 -3
- package/dist/cjs/schema/types.js.map +0 -1
- package/dist/cjs/tenant-isolation.spec.d.ts +0 -2
- package/dist/cjs/tenant-isolation.spec.d.ts.map +0 -1
- package/dist/cjs/tenant-isolation.spec.js +0 -420
- package/dist/cjs/tenant-isolation.spec.js.map +0 -1
- package/dist/cjs/utils/clickhouse.d.ts +0 -9
- package/dist/cjs/utils/clickhouse.d.ts.map +0 -1
- package/dist/cjs/utils/clickhouse.js +0 -99
- package/dist/cjs/utils/clickhouse.js.map +0 -1
- package/dist/esm/adapters/clickhouse.d.ts +0 -48
- package/dist/esm/adapters/clickhouse.d.ts.map +0 -1
- package/dist/esm/adapters/clickhouse.js +0 -280
- package/dist/esm/adapters/clickhouse.js.map +0 -1
- package/dist/esm/adapters/introspection.spec.d.ts +0 -2
- package/dist/esm/adapters/introspection.spec.d.ts.map +0 -1
- package/dist/esm/adapters/introspection.spec.js +0 -190
- package/dist/esm/adapters/introspection.spec.js.map +0 -1
- package/dist/esm/adapters/postgres.d.ts +0 -46
- package/dist/esm/adapters/postgres.d.ts.map +0 -1
- package/dist/esm/adapters/postgres.js +0 -453
- package/dist/esm/adapters/postgres.js.map +0 -1
- package/dist/esm/adapters/postgres.spec.d.ts +0 -2
- package/dist/esm/adapters/postgres.spec.d.ts.map +0 -1
- package/dist/esm/adapters/postgres.spec.js +0 -35
- package/dist/esm/adapters/postgres.spec.js.map +0 -1
- package/dist/esm/adapters/types.d.ts +0 -38
- package/dist/esm/adapters/types.d.ts.map +0 -1
- package/dist/esm/adapters/types.js +0 -2
- package/dist/esm/adapters/types.js.map +0 -1
- package/dist/esm/anonymize.spec.d.ts +0 -2
- package/dist/esm/anonymize.spec.d.ts.map +0 -1
- package/dist/esm/anonymize.spec.js +0 -76
- package/dist/esm/anonymize.spec.js.map +0 -1
- package/dist/esm/clickhouseClient.spec.d.ts +0 -2
- package/dist/esm/clickhouseClient.spec.d.ts.map +0 -1
- package/dist/esm/clickhouseClient.spec.js +0 -281
- package/dist/esm/clickhouseClient.spec.js.map +0 -1
- package/dist/esm/connectors/base.d.ts +0 -14
- package/dist/esm/connectors/base.d.ts.map +0 -1
- package/dist/esm/connectors/base.js +0 -2
- package/dist/esm/connectors/base.js.map +0 -1
- package/dist/esm/connectors/clickhouse.d.ts +0 -35
- package/dist/esm/connectors/clickhouse.d.ts.map +0 -1
- package/dist/esm/connectors/clickhouse.js +0 -281
- package/dist/esm/connectors/clickhouse.js.map +0 -1
- package/dist/esm/index.d.ts +0 -490
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -838
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.test.d.ts +0 -2
- package/dist/esm/index.test.d.ts.map +0 -1
- package/dist/esm/index.test.js +0 -183
- package/dist/esm/index.test.js.map +0 -1
- package/dist/esm/introspectV3.d.ts +0 -45
- package/dist/esm/introspectV3.d.ts.map +0 -1
- package/dist/esm/introspectV3.js +0 -96
- package/dist/esm/introspectV3.js.map +0 -1
- package/dist/esm/multidb.spec.d.ts +0 -2
- package/dist/esm/multidb.spec.d.ts.map +0 -1
- package/dist/esm/multidb.spec.js +0 -74
- package/dist/esm/multidb.spec.js.map +0 -1
- package/dist/esm/schema/types.d.ts +0 -73
- package/dist/esm/schema/types.d.ts.map +0 -1
- package/dist/esm/schema/types.js +0 -2
- package/dist/esm/schema/types.js.map +0 -1
- package/dist/esm/tenant-isolation.spec.d.ts +0 -2
- package/dist/esm/tenant-isolation.spec.d.ts.map +0 -1
- package/dist/esm/tenant-isolation.spec.js +0 -418
- package/dist/esm/tenant-isolation.spec.js.map +0 -1
- package/dist/esm/utils/clickhouse.d.ts +0 -9
- package/dist/esm/utils/clickhouse.d.ts.map +0 -1
- package/dist/esm/utils/clickhouse.js +0 -92
- package/dist/esm/utils/clickhouse.js.map +0 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { QueryParams, DataFormat } from '@clickhouse/client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Simplified schema types aligned with backend IngestRequest format
|
|
5
|
+
* Following Ousterhout's principle: "Define errors out of existence"
|
|
6
|
+
* - Removed indexes, constraints, foreign keys, statistics
|
|
7
|
+
* - Only collect what the backend needs for vectorization
|
|
8
|
+
*/
|
|
9
|
+
type DatabaseKind = "clickhouse" | "postgres" | string;
|
|
10
|
+
interface DatabaseIdentifier {
|
|
11
|
+
kind: DatabaseKind;
|
|
12
|
+
name: string;
|
|
13
|
+
schema?: string;
|
|
14
|
+
version?: string;
|
|
15
|
+
}
|
|
16
|
+
interface ColumnSchema {
|
|
17
|
+
name: string;
|
|
18
|
+
type: string;
|
|
19
|
+
rawType?: string;
|
|
20
|
+
isPrimaryKey: boolean;
|
|
21
|
+
comment?: string;
|
|
22
|
+
}
|
|
23
|
+
interface TableSchema {
|
|
24
|
+
name: string;
|
|
25
|
+
schema: string;
|
|
26
|
+
type: "table" | "view" | string;
|
|
27
|
+
comment?: string;
|
|
28
|
+
columns: ColumnSchema[];
|
|
29
|
+
}
|
|
30
|
+
interface SchemaIntrospection {
|
|
31
|
+
db: DatabaseIdentifier;
|
|
32
|
+
tables: TableSchema[];
|
|
33
|
+
introspectedAt: string;
|
|
34
|
+
}
|
|
35
|
+
interface IntrospectOptions {
|
|
36
|
+
/** Optional allow-list of table names to introspect (schema-qualified or bare). */
|
|
37
|
+
tables?: string[];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type DatabaseDialect = "clickhouse" | "postgres" | "mysql";
|
|
41
|
+
interface DatabaseExecutionResult {
|
|
42
|
+
fields: string[];
|
|
43
|
+
rows: Array<Record<string, unknown>>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Database adapter interface for abstracting database-specific operations.
|
|
47
|
+
* Allows the SDK to work with multiple database types.
|
|
48
|
+
*/
|
|
49
|
+
interface DatabaseAdapter {
|
|
50
|
+
/**
|
|
51
|
+
* Execute a SQL query and return results
|
|
52
|
+
* @param sql - The SQL query to execute
|
|
53
|
+
* @param params - Optional query parameters for parameterized queries
|
|
54
|
+
*/
|
|
55
|
+
execute(sql: string, params?: Record<string, string | number | boolean | string[] | number[]>): Promise<DatabaseExecutionResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Validate SQL query (e.g., using EXPLAIN)
|
|
58
|
+
* Throws an error if the SQL is invalid
|
|
59
|
+
* @param sql - The SQL query to validate
|
|
60
|
+
* @param params - Optional query parameters for parameterized queries
|
|
61
|
+
*/
|
|
62
|
+
validate(sql: string, params?: Record<string, string | number | boolean | string[] | number[]>): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Introspect database schema metadata
|
|
65
|
+
*/
|
|
66
|
+
introspect(options?: IntrospectOptions): Promise<SchemaIntrospection>;
|
|
67
|
+
/**
|
|
68
|
+
* Get the database dialect/type
|
|
69
|
+
*/
|
|
70
|
+
getDialect(): DatabaseDialect;
|
|
71
|
+
/**
|
|
72
|
+
* Optional: Close/cleanup database connection
|
|
73
|
+
*/
|
|
74
|
+
close?(): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface ClickHouseAdapterOptions {
|
|
78
|
+
/** Optional logical database name used in introspection metadata. */
|
|
79
|
+
database?: string;
|
|
80
|
+
/** Override the default response format used for query execution. */
|
|
81
|
+
defaultFormat?: DataFormat;
|
|
82
|
+
/**
|
|
83
|
+
* Optional database kind label. Defaults to "clickhouse" but allows
|
|
84
|
+
* sub-classing/custom branding if needed.
|
|
85
|
+
*/
|
|
86
|
+
kind?: SchemaIntrospection["db"]["kind"];
|
|
87
|
+
/**
|
|
88
|
+
* Optional allow-list of table names.
|
|
89
|
+
* When specified, introspection and queries are restricted to these tables only.
|
|
90
|
+
* ClickHouse tables are not schema-qualified, so just provide table names.
|
|
91
|
+
*/
|
|
92
|
+
allowedTables?: string[];
|
|
93
|
+
}
|
|
94
|
+
type ClickHouseQueryResult = {
|
|
95
|
+
json: () => Promise<unknown>;
|
|
96
|
+
};
|
|
97
|
+
type ClickHouseClientFn = (params: QueryParams) => Promise<ClickHouseQueryResult | Array<Record<string, unknown>> | Record<string, unknown>[]>;
|
|
98
|
+
/**
|
|
99
|
+
* Simplified ClickHouse adapter following IngestRequest format
|
|
100
|
+
* Removed: indexes, constraints, statistics
|
|
101
|
+
* Kept only: tables, columns (name, type, isPrimaryKey, comment)
|
|
102
|
+
*/
|
|
103
|
+
declare class ClickHouseAdapter implements DatabaseAdapter {
|
|
104
|
+
private readonly clientFn;
|
|
105
|
+
private readonly databaseName;
|
|
106
|
+
private readonly defaultFormat;
|
|
107
|
+
private readonly kind;
|
|
108
|
+
private readonly allowedTables?;
|
|
109
|
+
constructor(clientFn: ClickHouseClientFn, options?: ClickHouseAdapterOptions);
|
|
110
|
+
execute(sql: string, params?: Record<string, string | number | boolean | string[] | number[]>): Promise<DatabaseExecutionResult>;
|
|
111
|
+
validate(sql: string, params?: Record<string, string | number | boolean | string[] | number[]>): Promise<void>;
|
|
112
|
+
getDialect(): "clickhouse";
|
|
113
|
+
/**
|
|
114
|
+
* Simplified introspection: only collect table/column metadata for IngestRequest
|
|
115
|
+
* No indexes, constraints, or statistics
|
|
116
|
+
*/
|
|
117
|
+
introspect(options?: IntrospectOptions): Promise<SchemaIntrospection>;
|
|
118
|
+
private validateQueryTables;
|
|
119
|
+
close(): Promise<void>;
|
|
120
|
+
private query;
|
|
121
|
+
private extractRows;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
interface PostgresQueryResult {
|
|
125
|
+
rows: Array<Record<string, unknown>>;
|
|
126
|
+
fields: Array<{
|
|
127
|
+
name: string;
|
|
128
|
+
}>;
|
|
129
|
+
}
|
|
130
|
+
type PostgresClientFn = (sql: string, params?: unknown[]) => Promise<PostgresQueryResult>;
|
|
131
|
+
interface PostgresAdapterOptions {
|
|
132
|
+
/** Logical database name used in introspection metadata. */
|
|
133
|
+
database?: string;
|
|
134
|
+
/** Schema to assume when a table is provided without qualification. */
|
|
135
|
+
defaultSchema?: string;
|
|
136
|
+
/** Optional database kind label. Defaults to "postgres". */
|
|
137
|
+
kind?: SchemaIntrospection["db"]["kind"];
|
|
138
|
+
/**
|
|
139
|
+
* Optional allow-list of table names (schema-qualified or bare).
|
|
140
|
+
* When specified, introspection and queries are restricted to these tables only.
|
|
141
|
+
*/
|
|
142
|
+
allowedTables?: string[];
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Simplified PostgreSQL adapter following IngestRequest format
|
|
146
|
+
* Removed: indexes, constraints, foreign keys, statistics
|
|
147
|
+
* Kept only: tables, columns (name, type, isPrimaryKey, comment)
|
|
148
|
+
*/
|
|
149
|
+
declare class PostgresAdapter implements DatabaseAdapter {
|
|
150
|
+
private readonly clientFn;
|
|
151
|
+
private readonly databaseName;
|
|
152
|
+
private readonly defaultSchema;
|
|
153
|
+
private readonly kind;
|
|
154
|
+
private readonly allowedTables?;
|
|
155
|
+
constructor(clientFn: PostgresClientFn, options?: PostgresAdapterOptions);
|
|
156
|
+
execute(sql: string, params?: Record<string, string | number | boolean | string[] | number[]>): Promise<DatabaseExecutionResult>;
|
|
157
|
+
private validateQueryTables;
|
|
158
|
+
/**
|
|
159
|
+
* Convert named params to positional array for PostgreSQL
|
|
160
|
+
* PostgreSQL expects $1, $2, $3 in SQL and an array of values [val1, val2, val3]
|
|
161
|
+
*/
|
|
162
|
+
private convertNamedToPositionalParams;
|
|
163
|
+
validate(sql: string, params?: Record<string, string | number | boolean | string[] | number[]>): Promise<void>;
|
|
164
|
+
getDialect(): "postgres";
|
|
165
|
+
/**
|
|
166
|
+
* Simplified introspection: only collect table/column metadata for IngestRequest
|
|
167
|
+
* No indexes, constraints, or statistics
|
|
168
|
+
*/
|
|
169
|
+
introspect(options?: IntrospectOptions): Promise<SchemaIntrospection>;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
type ParamValue = string | number | boolean | string[] | number[];
|
|
173
|
+
type ParamRecord = Record<string, ParamValue>;
|
|
174
|
+
|
|
175
|
+
interface SdkChart {
|
|
176
|
+
id: string;
|
|
177
|
+
title: string;
|
|
178
|
+
description: string | null;
|
|
179
|
+
sql: string;
|
|
180
|
+
sql_params: Record<string, unknown> | null;
|
|
181
|
+
vega_lite_spec: Record<string, unknown>;
|
|
182
|
+
query_id: string | null;
|
|
183
|
+
organization_id: string | null;
|
|
184
|
+
tenant_id: string | null;
|
|
185
|
+
user_id: string | null;
|
|
186
|
+
created_at: string | null;
|
|
187
|
+
updated_at: string | null;
|
|
188
|
+
active?: boolean;
|
|
189
|
+
target_db?: string | null;
|
|
190
|
+
}
|
|
191
|
+
interface ChartCreateInput {
|
|
192
|
+
title: string;
|
|
193
|
+
description?: string;
|
|
194
|
+
sql: string;
|
|
195
|
+
sql_params?: Record<string, unknown>;
|
|
196
|
+
vega_lite_spec: Record<string, unknown>;
|
|
197
|
+
query_id?: string;
|
|
198
|
+
target_db?: string;
|
|
199
|
+
}
|
|
200
|
+
interface ChartUpdateInput {
|
|
201
|
+
title?: string;
|
|
202
|
+
description?: string;
|
|
203
|
+
sql?: string;
|
|
204
|
+
sql_params?: Record<string, unknown>;
|
|
205
|
+
vega_lite_spec?: Record<string, unknown>;
|
|
206
|
+
target_db?: string;
|
|
207
|
+
}
|
|
208
|
+
interface PaginationQuery {
|
|
209
|
+
page?: number;
|
|
210
|
+
limit?: number;
|
|
211
|
+
}
|
|
212
|
+
interface PaginationInfo {
|
|
213
|
+
page: number;
|
|
214
|
+
limit: number;
|
|
215
|
+
total: number;
|
|
216
|
+
totalPages: number;
|
|
217
|
+
hasNext: boolean;
|
|
218
|
+
hasPrev: boolean;
|
|
219
|
+
}
|
|
220
|
+
interface PaginatedResponse<T> {
|
|
221
|
+
data: T[];
|
|
222
|
+
pagination: PaginationInfo;
|
|
223
|
+
}
|
|
224
|
+
interface ChartListOptions {
|
|
225
|
+
tenantId?: string;
|
|
226
|
+
userId?: string;
|
|
227
|
+
scopes?: string[];
|
|
228
|
+
pagination?: PaginationQuery;
|
|
229
|
+
sortBy?: "title" | "user_id" | "created_at" | "updated_at";
|
|
230
|
+
sortDir?: "asc" | "desc";
|
|
231
|
+
title?: string;
|
|
232
|
+
userFilter?: string;
|
|
233
|
+
createdFrom?: string;
|
|
234
|
+
createdTo?: string;
|
|
235
|
+
updatedFrom?: string;
|
|
236
|
+
updatedTo?: string;
|
|
237
|
+
includeData?: boolean;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
interface SdkActiveChart {
|
|
241
|
+
id: string;
|
|
242
|
+
chart_id: string;
|
|
243
|
+
order: number | null;
|
|
244
|
+
meta: Record<string, unknown> | null;
|
|
245
|
+
organization_id: string | null;
|
|
246
|
+
tenant_id: string | null;
|
|
247
|
+
user_id: string | null;
|
|
248
|
+
created_at: string | null;
|
|
249
|
+
updated_at: string | null;
|
|
250
|
+
chart?: SdkChart | null;
|
|
251
|
+
}
|
|
252
|
+
interface ActiveChartCreateInput {
|
|
253
|
+
chart_id: string;
|
|
254
|
+
order?: number;
|
|
255
|
+
meta?: Record<string, unknown>;
|
|
256
|
+
}
|
|
257
|
+
interface ActiveChartUpdateInput {
|
|
258
|
+
chart_id?: string;
|
|
259
|
+
order?: number;
|
|
260
|
+
meta?: Record<string, unknown>;
|
|
261
|
+
}
|
|
262
|
+
interface ActiveChartListOptions extends ChartListOptions {
|
|
263
|
+
withData?: boolean;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
interface IngestResponse {
|
|
267
|
+
success: boolean;
|
|
268
|
+
message: string;
|
|
269
|
+
chunks: number;
|
|
270
|
+
chunks_with_annotations: number;
|
|
271
|
+
schema_id?: string;
|
|
272
|
+
schema_hash?: string;
|
|
273
|
+
drift_detected?: boolean;
|
|
274
|
+
skipped?: boolean;
|
|
275
|
+
}
|
|
276
|
+
interface SchemaSyncOptions {
|
|
277
|
+
tenantId?: string;
|
|
278
|
+
userId?: string;
|
|
279
|
+
scopes?: string[];
|
|
280
|
+
tables?: string[];
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
interface ContextDocument {
|
|
284
|
+
source?: string;
|
|
285
|
+
pageContent: string;
|
|
286
|
+
metadata?: Record<string, unknown>;
|
|
287
|
+
score?: number;
|
|
288
|
+
}
|
|
289
|
+
interface ChartEnvelope {
|
|
290
|
+
vegaLiteSpec: Record<string, unknown> | null;
|
|
291
|
+
notes: string | null;
|
|
292
|
+
}
|
|
293
|
+
interface AskOptions {
|
|
294
|
+
tenantId?: string;
|
|
295
|
+
userId?: string;
|
|
296
|
+
scopes?: string[];
|
|
297
|
+
database?: string;
|
|
298
|
+
lastError?: string;
|
|
299
|
+
previousSql?: string;
|
|
300
|
+
maxRetry?: number;
|
|
301
|
+
chartMaxRetries?: number;
|
|
302
|
+
}
|
|
303
|
+
interface AskResponse {
|
|
304
|
+
sql: string;
|
|
305
|
+
params: ParamRecord;
|
|
306
|
+
paramMetadata: Array<Record<string, unknown>>;
|
|
307
|
+
rationale?: string;
|
|
308
|
+
dialect: string;
|
|
309
|
+
queryId?: string;
|
|
310
|
+
rows: Array<Record<string, unknown>>;
|
|
311
|
+
fields: string[];
|
|
312
|
+
chart: ChartEnvelope;
|
|
313
|
+
context?: ContextDocument[];
|
|
314
|
+
attempts?: number;
|
|
315
|
+
}
|
|
316
|
+
declare function anonymizeResults(rows: Array<Record<string, unknown>>): Array<Record<string, string>>;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Main SDK class - Thin orchestrator
|
|
320
|
+
* Delegates to deep modules (ApiClient, QueryEngine, route modules)
|
|
321
|
+
* Following Ousterhout's principle: "Simple interface hiding complexity"
|
|
322
|
+
*/
|
|
323
|
+
declare class QueryPanelSdkAPI {
|
|
324
|
+
private readonly client;
|
|
325
|
+
private readonly queryEngine;
|
|
326
|
+
constructor(baseUrl: string, privateKey: string, organizationId: string, options?: {
|
|
327
|
+
defaultTenantId?: string;
|
|
328
|
+
additionalHeaders?: Record<string, string>;
|
|
329
|
+
fetch?: typeof fetch;
|
|
330
|
+
});
|
|
331
|
+
attachClickhouse(name: string, clientFn: ClickHouseClientFn, options?: ClickHouseAdapterOptions & {
|
|
332
|
+
description?: string;
|
|
333
|
+
tags?: string[];
|
|
334
|
+
tenantFieldName?: string;
|
|
335
|
+
tenantFieldType?: string;
|
|
336
|
+
enforceTenantIsolation?: boolean;
|
|
337
|
+
}): void;
|
|
338
|
+
attachPostgres(name: string, clientFn: PostgresClientFn, options?: PostgresAdapterOptions & {
|
|
339
|
+
description?: string;
|
|
340
|
+
tags?: string[];
|
|
341
|
+
tenantFieldName?: string;
|
|
342
|
+
enforceTenantIsolation?: boolean;
|
|
343
|
+
}): void;
|
|
344
|
+
attachDatabase(name: string, adapter: DatabaseAdapter): void;
|
|
345
|
+
introspect(databaseName: string, tables?: string[]): Promise<SchemaIntrospection>;
|
|
346
|
+
syncSchema(databaseName: string, options: SchemaSyncOptions, signal?: AbortSignal): Promise<IngestResponse>;
|
|
347
|
+
ask(question: string, options: AskOptions, signal?: AbortSignal): Promise<AskResponse>;
|
|
348
|
+
createChart(body: ChartCreateInput, options?: {
|
|
349
|
+
tenantId?: string;
|
|
350
|
+
userId?: string;
|
|
351
|
+
scopes?: string[];
|
|
352
|
+
}, signal?: AbortSignal): Promise<SdkChart>;
|
|
353
|
+
listCharts(options?: ChartListOptions, signal?: AbortSignal): Promise<PaginatedResponse<SdkChart>>;
|
|
354
|
+
getChart(id: string, options?: {
|
|
355
|
+
tenantId?: string;
|
|
356
|
+
userId?: string;
|
|
357
|
+
scopes?: string[];
|
|
358
|
+
}, signal?: AbortSignal): Promise<SdkChart>;
|
|
359
|
+
updateChart(id: string, body: ChartUpdateInput, options?: {
|
|
360
|
+
tenantId?: string;
|
|
361
|
+
userId?: string;
|
|
362
|
+
scopes?: string[];
|
|
363
|
+
}, signal?: AbortSignal): Promise<SdkChart>;
|
|
364
|
+
deleteChart(id: string, options?: {
|
|
365
|
+
tenantId?: string;
|
|
366
|
+
userId?: string;
|
|
367
|
+
scopes?: string[];
|
|
368
|
+
}, signal?: AbortSignal): Promise<void>;
|
|
369
|
+
createActiveChart(body: ActiveChartCreateInput, options?: {
|
|
370
|
+
tenantId?: string;
|
|
371
|
+
userId?: string;
|
|
372
|
+
scopes?: string[];
|
|
373
|
+
}, signal?: AbortSignal): Promise<SdkActiveChart>;
|
|
374
|
+
listActiveCharts(options?: ActiveChartListOptions, signal?: AbortSignal): Promise<PaginatedResponse<SdkActiveChart>>;
|
|
375
|
+
getActiveChart(id: string, options?: ActiveChartListOptions, signal?: AbortSignal): Promise<SdkActiveChart>;
|
|
376
|
+
updateActiveChart(id: string, body: ActiveChartUpdateInput, options?: {
|
|
377
|
+
tenantId?: string;
|
|
378
|
+
userId?: string;
|
|
379
|
+
scopes?: string[];
|
|
380
|
+
}, signal?: AbortSignal): Promise<SdkActiveChart>;
|
|
381
|
+
deleteActiveChart(id: string, options?: {
|
|
382
|
+
tenantId?: string;
|
|
383
|
+
userId?: string;
|
|
384
|
+
scopes?: string[];
|
|
385
|
+
}, signal?: AbortSignal): Promise<void>;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export { type ActiveChartCreateInput, type ActiveChartListOptions, type ActiveChartUpdateInput, type AskOptions, type AskResponse, type ChartCreateInput, type ChartEnvelope, type ChartListOptions, type ChartUpdateInput, ClickHouseAdapter, type ClickHouseAdapterOptions, type ClickHouseClientFn, type ContextDocument, type DatabaseAdapter, type DatabaseDialect, type IngestResponse, type PaginatedResponse, type PaginationInfo, type PaginationQuery, type ParamRecord, type ParamValue, PostgresAdapter, type PostgresAdapterOptions, type PostgresClientFn, QueryPanelSdkAPI, type SchemaIntrospection, type SchemaSyncOptions, type SdkActiveChart, type SdkChart, anonymizeResults };
|