@querypanel/node-sdk 1.3.5 → 1.3.6

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.d.cts CHANGED
@@ -38,6 +38,26 @@ interface IntrospectOptions {
38
38
  }
39
39
 
40
40
  type DatabaseDialect = "bigquery" | "clickhouse" | "postgres" | "redshift" | "mysql";
41
+ /** A schema (or ClickHouse database / BigQuery dataset) in the catalog. */
42
+ interface CatalogSchema {
43
+ schema: string;
44
+ tableCount: number;
45
+ }
46
+ type CatalogTableType = "table" | "view" | "materialized_view";
47
+ /** A table or view in the catalog (no columns; cheap to list). */
48
+ interface CatalogTable {
49
+ schema: string;
50
+ name: string;
51
+ type: CatalogTableType;
52
+ }
53
+ interface ListTablesOptions {
54
+ /** Only list tables in this schema. */
55
+ schema?: string;
56
+ /** Case-insensitive substring match on the table name. */
57
+ search?: string;
58
+ /** Max rows to return. Default 500, capped at 5000. */
59
+ limit?: number;
60
+ }
41
61
  interface DatabaseExecutionResult {
42
62
  fields: string[];
43
63
  rows: Array<Record<string, unknown>>;
@@ -68,6 +88,14 @@ interface DatabaseAdapter {
68
88
  * Get the database dialect/type
69
89
  */
70
90
  getDialect(): DatabaseDialect;
91
+ /**
92
+ * Optional: List schemas with table counts (cheap catalog read for pickers).
93
+ */
94
+ listSchemas?(): Promise<CatalogSchema[]>;
95
+ /**
96
+ * Optional: List tables/views without columns (cheap catalog read for pickers).
97
+ */
98
+ listTables?(options?: ListTablesOptions): Promise<CatalogTable[]>;
71
99
  /**
72
100
  * Optional: Close/cleanup database connection
73
101
  */
@@ -108,6 +136,7 @@ interface BigQueryAdapterOptions {
108
136
  kind?: SchemaIntrospection["db"]["kind"];
109
137
  /**
110
138
  * Optional allow-list of table names (dataset.table or bare table name).
139
+ * `*` or `<dataset>.*` allows every table in the dataset (same as no filter).
111
140
  * When specified, introspection and queries are restricted to these tables only.
112
141
  */
113
142
  allowedTables?: string[];
@@ -135,6 +164,14 @@ declare class BigQueryAdapter implements DatabaseAdapter {
135
164
  * Restricts to the default dataset (or allowedTables) and returns tables/columns only.
136
165
  */
137
166
  introspect(options?: IntrospectOptions): Promise<SchemaIntrospection>;
167
+ /** The adapter is bound to one dataset, so this returns a single row. */
168
+ listSchemas(): Promise<CatalogSchema[]>;
169
+ /**
170
+ * List tables in the bound dataset. Reads the full catalog (not restricted
171
+ * by `allowedTables`). Default limit 500, max 5000.
172
+ */
173
+ listTables(options?: ListTablesOptions): Promise<CatalogTable[]>;
174
+ private informationSchema;
138
175
  private validateQueryTables;
139
176
  }
140
177
 
@@ -152,6 +189,7 @@ interface ClickHouseAdapterOptions {
152
189
  * Optional allow-list of table names.
153
190
  * When specified, introspection and queries are restricted to these tables only.
154
191
  * ClickHouse tables are not schema-qualified, so just provide table names.
192
+ * `*` or `<database>.*` allows every table (same as no filter).
155
193
  */
156
194
  allowedTables?: string[];
157
195
  }
@@ -179,6 +217,13 @@ declare class ClickHouseAdapter implements DatabaseAdapter {
179
217
  * No indexes, constraints, or statistics
180
218
  */
181
219
  introspect(options?: IntrospectOptions): Promise<SchemaIntrospection>;
220
+ /** The adapter is bound to one database, so this returns a single row. */
221
+ listSchemas(): Promise<CatalogSchema[]>;
222
+ /**
223
+ * List tables in the bound database. Reads the full catalog (not restricted
224
+ * by `allowedTables`). Default limit 500, max 5000.
225
+ */
226
+ listTables(options?: ListTablesOptions): Promise<CatalogTable[]>;
182
227
  private validateQueryTables;
183
228
  close(): Promise<void>;
184
229
  private query;
@@ -207,7 +252,9 @@ interface PostgresAdapterOptions {
207
252
  dialect?: PostgresWireDialect;
208
253
  /**
209
254
  * Optional allow-list of table names (schema-qualified or bare).
210
- * When specified, introspection and queries are restricted to these tables only.
255
+ * Use `schema.*` to allow every table in a schema (a bare `*` means the
256
+ * default schema). When specified, introspection and queries are restricted
257
+ * to these tables only.
211
258
  */
212
259
  allowedTables?: string[];
213
260
  }
@@ -233,6 +280,17 @@ declare class PostgresAdapter implements DatabaseAdapter {
233
280
  private convertNamedToPositionalParams;
234
281
  validate(sql: string, params?: Record<string, string | number | boolean | string[] | number[]>): Promise<void>;
235
282
  getDialect(): PostgresWireDialect;
283
+ /**
284
+ * List schemas with their table/view counts. Reads the full catalog (not
285
+ * restricted by `allowedTables`) so it can back an allowed-tables picker.
286
+ */
287
+ listSchemas(): Promise<CatalogSchema[]>;
288
+ /**
289
+ * List tables/views, optionally filtered by schema and a case-insensitive
290
+ * substring of the table name. Reads the full catalog (not restricted by
291
+ * `allowedTables`). Default limit 500, max 5000.
292
+ */
293
+ listTables(options?: ListTablesOptions): Promise<CatalogTable[]>;
236
294
  /**
237
295
  * Simplified introspection: only collect table/column metadata for IngestRequest
238
296
  * No indexes, constraints, or statistics
@@ -341,6 +399,17 @@ declare class QueryPipelineError extends Error {
341
399
  */
342
400
  isAiProviderError(): boolean;
343
401
  }
402
+ /**
403
+ * Thrown by stageSchemaIngest / syncSchemaInBatches when the introspected schema
404
+ * has more columns than `maxColumns`. Raised before anything is uploaded; narrow
405
+ * the sync with `allowedTables` / `tables` (e.g. `schema.*`) and retry.
406
+ */
407
+ declare class SchemaTooLargeError extends Error {
408
+ readonly tableCount: number;
409
+ readonly columnCount: number;
410
+ readonly maxColumns: number;
411
+ constructor(tableCount: number, columnCount: number, maxColumns: number);
412
+ }
344
413
 
345
414
  type ParamValue = string | number | boolean | string[] | number[];
346
415
  type ParamRecord = Record<string, ParamValue>;
@@ -548,6 +617,57 @@ interface SchemaSyncOptions {
548
617
  tables?: string[];
549
618
  forceReindex?: boolean;
550
619
  }
620
+ /** Progress events emitted by stageSchemaIngest / syncSchemaInBatches. */
621
+ type SchemaSyncProgressEvent = {
622
+ phase: "introspecting";
623
+ } | {
624
+ phase: "introspected";
625
+ tableCount: number;
626
+ columnCount: number;
627
+ } | {
628
+ phase: "uploading";
629
+ done: number;
630
+ total: number;
631
+ } | {
632
+ phase: "committing";
633
+ } | {
634
+ phase: "embedding";
635
+ done: number;
636
+ total: number;
637
+ chunks: number;
638
+ } | {
639
+ phase: "finalizing";
640
+ };
641
+ interface SchemaIngestRequestOptions {
642
+ tenantId?: string;
643
+ userId?: string;
644
+ scopes?: string[];
645
+ }
646
+ interface StageSchemaIngestOptions extends SchemaSyncOptions {
647
+ /** Max docs per batch (1 per table + 1 per column). Default 1000. */
648
+ maxBatchDocs?: number;
649
+ /** Max serialized JSON bytes per batch. Default 2_000_000. */
650
+ maxBatchBytes?: number;
651
+ /** Throw SchemaTooLargeError (before uploading) above this many columns. */
652
+ maxColumns?: number;
653
+ onProgress?: (event: SchemaSyncProgressEvent) => void;
654
+ }
655
+ type SyncSchemaInBatchesOptions = StageSchemaIngestOptions;
656
+ interface StageSchemaIngestResult {
657
+ sessionId: string;
658
+ status: "skipped" | "embedding";
659
+ totalBatches: number;
660
+ tableCount: number;
661
+ columnCount: number;
662
+ /** Present when status is "skipped" (schema unchanged). */
663
+ skippedResult?: IngestResponse;
664
+ driftDetected?: boolean;
665
+ }
666
+ interface SchemaIngestBatchEmbedResponse {
667
+ index: number;
668
+ chunks: number;
669
+ chunks_with_annotations: number;
670
+ }
551
671
 
552
672
  /**
553
673
  * VizSpec types for flexible visualization specifications
@@ -1283,6 +1403,17 @@ declare class QueryPanelSdkAPI {
1283
1403
  }): void;
1284
1404
  attachDatabase(name: string, adapter: DatabaseAdapter): void;
1285
1405
  introspect(databaseName: string, tables?: string[]): Promise<SchemaIntrospection>;
1406
+ /**
1407
+ * Lists schemas (ClickHouse: the database, BigQuery: the dataset) with table
1408
+ * counts. Cheap catalog read for building an allowed-tables picker; not
1409
+ * restricted by `allowedTables`.
1410
+ */
1411
+ listSchemas(databaseName: string): Promise<CatalogSchema[]>;
1412
+ /**
1413
+ * Lists tables/views (no columns) filtered by schema and a case-insensitive
1414
+ * name substring. Default limit 500, max 5000. Not restricted by `allowedTables`.
1415
+ */
1416
+ listTables(databaseName: string, options?: ListTablesOptions): Promise<CatalogTable[]>;
1286
1417
  /**
1287
1418
  * Syncs the database schema to QueryPanel for natural language query generation.
1288
1419
  *
@@ -1308,6 +1439,31 @@ declare class QueryPanelSdkAPI {
1308
1439
  * ```
1309
1440
  */
1310
1441
  syncSchema(databaseName: string, options: SchemaSyncOptions, signal?: AbortSignal): Promise<IngestResponse>;
1442
+ /**
1443
+ * Introspects the schema, uploads it in batches to a new ingest session and
1444
+ * commits it. Returns `status: "skipped"` (with `skippedResult`) when the schema
1445
+ * is unchanged, otherwise `status: "embedding"`: call embedSchemaIngestBatch for
1446
+ * every index in [0, totalBatches) and then finalizeSchemaIngest.
1447
+ * Throws SchemaTooLargeError before uploading if `maxColumns` is exceeded.
1448
+ */
1449
+ stageSchemaIngest(databaseName: string, options: StageSchemaIngestOptions, signal?: AbortSignal): Promise<StageSchemaIngestResult>;
1450
+ /** Embeds one batch of a staged ingest session. */
1451
+ embedSchemaIngestBatch(sessionId: string, index: number, options: SchemaIngestRequestOptions, signal?: AbortSignal): Promise<SchemaIngestBatchEmbedResponse>;
1452
+ /** Finalizes a staged ingest session after all batches are embedded. */
1453
+ finalizeSchemaIngest(sessionId: string, options: SchemaIngestRequestOptions, signal?: AbortSignal): Promise<IngestResponse>;
1454
+ /**
1455
+ * Batched alternative to syncSchema for large databases: stage, embed every
1456
+ * batch, and finalize in-process, reporting progress via `onProgress`.
1457
+ *
1458
+ * @example
1459
+ * ```typescript
1460
+ * await qp.syncSchemaInBatches("warehouse", {
1461
+ * tenantId: "tenant_123",
1462
+ * onProgress: (e) => console.log(e.phase, e),
1463
+ * });
1464
+ * ```
1465
+ */
1466
+ syncSchemaInBatches(databaseName: string, options: SyncSchemaInBatchesOptions, signal?: AbortSignal): Promise<IngestResponse>;
1311
1467
  /**
1312
1468
  * Generates SQL from a natural language question and executes it.
1313
1469
  *
@@ -2012,4 +2168,4 @@ declare class QueryPanelSdkAPI {
2012
2168
  }, signal?: AbortSignal): Promise<SdkDashboard[]>;
2013
2169
  }
2014
2170
 
2015
- export { ALL_VIZ_CHART_TYPES, type ActiveChartBulkGetResponse, type ActiveChartCreateInput, type ActiveChartListOptions, type ActiveChartUpdateInput, type AggregateOp, type AskOptions, type AskResponse, type AxisField, type AxisFieldInput, BigQueryAdapter, type BigQueryAdapterOptions, type BigQueryClientFn, type BigQueryQueryRequest, type BigQueryQueryResult, CallbackApiClient, type ChartBulkGetResponse, type ChartCreateInput, type ChartEncoding, type ChartEnvelope, type ChartListAllOptions, type ChartListOptions, type ChartModifyInput, type ChartModifyOptions, type ChartModifyResponse, type ChartSpec, type ChartType, type ChartUpdateInput, ClickHouseAdapter, type ClickHouseAdapterOptions, type ClickHouseClientFn, type ContextDocument, type DashboardCreateInput, type DashboardForkInput, type DashboardForkUpdateInput, type DashboardListOptions, type DashboardUpdateInput, type DatabaseAdapter, type DatabaseDialect, type DateRangeInput, type EncodingHints, type FieldRef, type FieldRefInput, type FieldType, type IQueryPanelApi, type IngestResponse, type IntentResult, type MetricEncoding, type MetricField, type MetricSpec, type PaginatedResponse$1 as PaginatedResponse, type PaginationInfo$1 as PaginationInfo, type PaginationQuery$1 as PaginationQuery, type ParamRecord, type ParamValue, type PipelineTrace, PostgresAdapter, type PostgresAdapterOptions, type PostgresClientFn, type PostgresWireDialect, QueryErrorCode, QueryErrorCode as QueryErrorCodeType, QueryPanelSdkAPI, type QueryPanelSdkAPIOptions, QueryPipelineError, type RequestHandler, type RequestHandlerOptions, type RequestHandlerResult, type SchemaIntrospection, type SchemaSyncOptions, type SdkActiveChart, type SdkChart, type SdkDashboard, type SdkSession, type SdkSessionTurn, type SessionGetOptions, type SessionListOptions, type SessionUpdateInput, type SqlModifications, type StackingMode, type TableColumn, type TableEncoding, type TableSpec, type TimeUnit, type ValueFormat, type VizModifications, type VizSpec, type VizSpecGenerateInput, type VizSpecGenerateOptions, type VizSpecGeneratorInput, type VizSpecKind, type VizSpecResponse, type VizSpecResult, anonymizeResults, mapGeneratedParams, normalizeSqlParamsInput, resolveQueryPipeline };
2171
+ export { ALL_VIZ_CHART_TYPES, type ActiveChartBulkGetResponse, type ActiveChartCreateInput, type ActiveChartListOptions, type ActiveChartUpdateInput, type AggregateOp, type AskOptions, type AskResponse, type AxisField, type AxisFieldInput, BigQueryAdapter, type BigQueryAdapterOptions, type BigQueryClientFn, type BigQueryQueryRequest, type BigQueryQueryResult, CallbackApiClient, type CatalogSchema, type CatalogTable, type CatalogTableType, type ChartBulkGetResponse, type ChartCreateInput, type ChartEncoding, type ChartEnvelope, type ChartListAllOptions, type ChartListOptions, type ChartModifyInput, type ChartModifyOptions, type ChartModifyResponse, type ChartSpec, type ChartType, type ChartUpdateInput, ClickHouseAdapter, type ClickHouseAdapterOptions, type ClickHouseClientFn, type ContextDocument, type DashboardCreateInput, type DashboardForkInput, type DashboardForkUpdateInput, type DashboardListOptions, type DashboardUpdateInput, type DatabaseAdapter, type DatabaseDialect, type DateRangeInput, type EncodingHints, type FieldRef, type FieldRefInput, type FieldType, type IQueryPanelApi, type IngestResponse, type IntentResult, type ListTablesOptions, type MetricEncoding, type MetricField, type MetricSpec, type PaginatedResponse$1 as PaginatedResponse, type PaginationInfo$1 as PaginationInfo, type PaginationQuery$1 as PaginationQuery, type ParamRecord, type ParamValue, type PipelineTrace, PostgresAdapter, type PostgresAdapterOptions, type PostgresClientFn, type PostgresWireDialect, QueryErrorCode, QueryErrorCode as QueryErrorCodeType, QueryPanelSdkAPI, type QueryPanelSdkAPIOptions, QueryPipelineError, type RequestHandler, type RequestHandlerOptions, type RequestHandlerResult, type SchemaIngestBatchEmbedResponse, type SchemaIngestRequestOptions, type SchemaIntrospection, type SchemaSyncOptions, type SchemaSyncProgressEvent, SchemaTooLargeError, type SdkActiveChart, type SdkChart, type SdkDashboard, type SdkSession, type SdkSessionTurn, type SessionGetOptions, type SessionListOptions, type SessionUpdateInput, type SqlModifications, type StackingMode, type StageSchemaIngestOptions, type StageSchemaIngestResult, type SyncSchemaInBatchesOptions, type TableColumn, type TableEncoding, type TableSpec, type TimeUnit, type ValueFormat, type VizModifications, type VizSpec, type VizSpecGenerateInput, type VizSpecGenerateOptions, type VizSpecGeneratorInput, type VizSpecKind, type VizSpecResponse, type VizSpecResult, anonymizeResults, mapGeneratedParams, normalizeSqlParamsInput, resolveQueryPipeline };
package/dist/index.d.ts CHANGED
@@ -38,6 +38,26 @@ interface IntrospectOptions {
38
38
  }
39
39
 
40
40
  type DatabaseDialect = "bigquery" | "clickhouse" | "postgres" | "redshift" | "mysql";
41
+ /** A schema (or ClickHouse database / BigQuery dataset) in the catalog. */
42
+ interface CatalogSchema {
43
+ schema: string;
44
+ tableCount: number;
45
+ }
46
+ type CatalogTableType = "table" | "view" | "materialized_view";
47
+ /** A table or view in the catalog (no columns; cheap to list). */
48
+ interface CatalogTable {
49
+ schema: string;
50
+ name: string;
51
+ type: CatalogTableType;
52
+ }
53
+ interface ListTablesOptions {
54
+ /** Only list tables in this schema. */
55
+ schema?: string;
56
+ /** Case-insensitive substring match on the table name. */
57
+ search?: string;
58
+ /** Max rows to return. Default 500, capped at 5000. */
59
+ limit?: number;
60
+ }
41
61
  interface DatabaseExecutionResult {
42
62
  fields: string[];
43
63
  rows: Array<Record<string, unknown>>;
@@ -68,6 +88,14 @@ interface DatabaseAdapter {
68
88
  * Get the database dialect/type
69
89
  */
70
90
  getDialect(): DatabaseDialect;
91
+ /**
92
+ * Optional: List schemas with table counts (cheap catalog read for pickers).
93
+ */
94
+ listSchemas?(): Promise<CatalogSchema[]>;
95
+ /**
96
+ * Optional: List tables/views without columns (cheap catalog read for pickers).
97
+ */
98
+ listTables?(options?: ListTablesOptions): Promise<CatalogTable[]>;
71
99
  /**
72
100
  * Optional: Close/cleanup database connection
73
101
  */
@@ -108,6 +136,7 @@ interface BigQueryAdapterOptions {
108
136
  kind?: SchemaIntrospection["db"]["kind"];
109
137
  /**
110
138
  * Optional allow-list of table names (dataset.table or bare table name).
139
+ * `*` or `<dataset>.*` allows every table in the dataset (same as no filter).
111
140
  * When specified, introspection and queries are restricted to these tables only.
112
141
  */
113
142
  allowedTables?: string[];
@@ -135,6 +164,14 @@ declare class BigQueryAdapter implements DatabaseAdapter {
135
164
  * Restricts to the default dataset (or allowedTables) and returns tables/columns only.
136
165
  */
137
166
  introspect(options?: IntrospectOptions): Promise<SchemaIntrospection>;
167
+ /** The adapter is bound to one dataset, so this returns a single row. */
168
+ listSchemas(): Promise<CatalogSchema[]>;
169
+ /**
170
+ * List tables in the bound dataset. Reads the full catalog (not restricted
171
+ * by `allowedTables`). Default limit 500, max 5000.
172
+ */
173
+ listTables(options?: ListTablesOptions): Promise<CatalogTable[]>;
174
+ private informationSchema;
138
175
  private validateQueryTables;
139
176
  }
140
177
 
@@ -152,6 +189,7 @@ interface ClickHouseAdapterOptions {
152
189
  * Optional allow-list of table names.
153
190
  * When specified, introspection and queries are restricted to these tables only.
154
191
  * ClickHouse tables are not schema-qualified, so just provide table names.
192
+ * `*` or `<database>.*` allows every table (same as no filter).
155
193
  */
156
194
  allowedTables?: string[];
157
195
  }
@@ -179,6 +217,13 @@ declare class ClickHouseAdapter implements DatabaseAdapter {
179
217
  * No indexes, constraints, or statistics
180
218
  */
181
219
  introspect(options?: IntrospectOptions): Promise<SchemaIntrospection>;
220
+ /** The adapter is bound to one database, so this returns a single row. */
221
+ listSchemas(): Promise<CatalogSchema[]>;
222
+ /**
223
+ * List tables in the bound database. Reads the full catalog (not restricted
224
+ * by `allowedTables`). Default limit 500, max 5000.
225
+ */
226
+ listTables(options?: ListTablesOptions): Promise<CatalogTable[]>;
182
227
  private validateQueryTables;
183
228
  close(): Promise<void>;
184
229
  private query;
@@ -207,7 +252,9 @@ interface PostgresAdapterOptions {
207
252
  dialect?: PostgresWireDialect;
208
253
  /**
209
254
  * Optional allow-list of table names (schema-qualified or bare).
210
- * When specified, introspection and queries are restricted to these tables only.
255
+ * Use `schema.*` to allow every table in a schema (a bare `*` means the
256
+ * default schema). When specified, introspection and queries are restricted
257
+ * to these tables only.
211
258
  */
212
259
  allowedTables?: string[];
213
260
  }
@@ -233,6 +280,17 @@ declare class PostgresAdapter implements DatabaseAdapter {
233
280
  private convertNamedToPositionalParams;
234
281
  validate(sql: string, params?: Record<string, string | number | boolean | string[] | number[]>): Promise<void>;
235
282
  getDialect(): PostgresWireDialect;
283
+ /**
284
+ * List schemas with their table/view counts. Reads the full catalog (not
285
+ * restricted by `allowedTables`) so it can back an allowed-tables picker.
286
+ */
287
+ listSchemas(): Promise<CatalogSchema[]>;
288
+ /**
289
+ * List tables/views, optionally filtered by schema and a case-insensitive
290
+ * substring of the table name. Reads the full catalog (not restricted by
291
+ * `allowedTables`). Default limit 500, max 5000.
292
+ */
293
+ listTables(options?: ListTablesOptions): Promise<CatalogTable[]>;
236
294
  /**
237
295
  * Simplified introspection: only collect table/column metadata for IngestRequest
238
296
  * No indexes, constraints, or statistics
@@ -341,6 +399,17 @@ declare class QueryPipelineError extends Error {
341
399
  */
342
400
  isAiProviderError(): boolean;
343
401
  }
402
+ /**
403
+ * Thrown by stageSchemaIngest / syncSchemaInBatches when the introspected schema
404
+ * has more columns than `maxColumns`. Raised before anything is uploaded; narrow
405
+ * the sync with `allowedTables` / `tables` (e.g. `schema.*`) and retry.
406
+ */
407
+ declare class SchemaTooLargeError extends Error {
408
+ readonly tableCount: number;
409
+ readonly columnCount: number;
410
+ readonly maxColumns: number;
411
+ constructor(tableCount: number, columnCount: number, maxColumns: number);
412
+ }
344
413
 
345
414
  type ParamValue = string | number | boolean | string[] | number[];
346
415
  type ParamRecord = Record<string, ParamValue>;
@@ -548,6 +617,57 @@ interface SchemaSyncOptions {
548
617
  tables?: string[];
549
618
  forceReindex?: boolean;
550
619
  }
620
+ /** Progress events emitted by stageSchemaIngest / syncSchemaInBatches. */
621
+ type SchemaSyncProgressEvent = {
622
+ phase: "introspecting";
623
+ } | {
624
+ phase: "introspected";
625
+ tableCount: number;
626
+ columnCount: number;
627
+ } | {
628
+ phase: "uploading";
629
+ done: number;
630
+ total: number;
631
+ } | {
632
+ phase: "committing";
633
+ } | {
634
+ phase: "embedding";
635
+ done: number;
636
+ total: number;
637
+ chunks: number;
638
+ } | {
639
+ phase: "finalizing";
640
+ };
641
+ interface SchemaIngestRequestOptions {
642
+ tenantId?: string;
643
+ userId?: string;
644
+ scopes?: string[];
645
+ }
646
+ interface StageSchemaIngestOptions extends SchemaSyncOptions {
647
+ /** Max docs per batch (1 per table + 1 per column). Default 1000. */
648
+ maxBatchDocs?: number;
649
+ /** Max serialized JSON bytes per batch. Default 2_000_000. */
650
+ maxBatchBytes?: number;
651
+ /** Throw SchemaTooLargeError (before uploading) above this many columns. */
652
+ maxColumns?: number;
653
+ onProgress?: (event: SchemaSyncProgressEvent) => void;
654
+ }
655
+ type SyncSchemaInBatchesOptions = StageSchemaIngestOptions;
656
+ interface StageSchemaIngestResult {
657
+ sessionId: string;
658
+ status: "skipped" | "embedding";
659
+ totalBatches: number;
660
+ tableCount: number;
661
+ columnCount: number;
662
+ /** Present when status is "skipped" (schema unchanged). */
663
+ skippedResult?: IngestResponse;
664
+ driftDetected?: boolean;
665
+ }
666
+ interface SchemaIngestBatchEmbedResponse {
667
+ index: number;
668
+ chunks: number;
669
+ chunks_with_annotations: number;
670
+ }
551
671
 
552
672
  /**
553
673
  * VizSpec types for flexible visualization specifications
@@ -1283,6 +1403,17 @@ declare class QueryPanelSdkAPI {
1283
1403
  }): void;
1284
1404
  attachDatabase(name: string, adapter: DatabaseAdapter): void;
1285
1405
  introspect(databaseName: string, tables?: string[]): Promise<SchemaIntrospection>;
1406
+ /**
1407
+ * Lists schemas (ClickHouse: the database, BigQuery: the dataset) with table
1408
+ * counts. Cheap catalog read for building an allowed-tables picker; not
1409
+ * restricted by `allowedTables`.
1410
+ */
1411
+ listSchemas(databaseName: string): Promise<CatalogSchema[]>;
1412
+ /**
1413
+ * Lists tables/views (no columns) filtered by schema and a case-insensitive
1414
+ * name substring. Default limit 500, max 5000. Not restricted by `allowedTables`.
1415
+ */
1416
+ listTables(databaseName: string, options?: ListTablesOptions): Promise<CatalogTable[]>;
1286
1417
  /**
1287
1418
  * Syncs the database schema to QueryPanel for natural language query generation.
1288
1419
  *
@@ -1308,6 +1439,31 @@ declare class QueryPanelSdkAPI {
1308
1439
  * ```
1309
1440
  */
1310
1441
  syncSchema(databaseName: string, options: SchemaSyncOptions, signal?: AbortSignal): Promise<IngestResponse>;
1442
+ /**
1443
+ * Introspects the schema, uploads it in batches to a new ingest session and
1444
+ * commits it. Returns `status: "skipped"` (with `skippedResult`) when the schema
1445
+ * is unchanged, otherwise `status: "embedding"`: call embedSchemaIngestBatch for
1446
+ * every index in [0, totalBatches) and then finalizeSchemaIngest.
1447
+ * Throws SchemaTooLargeError before uploading if `maxColumns` is exceeded.
1448
+ */
1449
+ stageSchemaIngest(databaseName: string, options: StageSchemaIngestOptions, signal?: AbortSignal): Promise<StageSchemaIngestResult>;
1450
+ /** Embeds one batch of a staged ingest session. */
1451
+ embedSchemaIngestBatch(sessionId: string, index: number, options: SchemaIngestRequestOptions, signal?: AbortSignal): Promise<SchemaIngestBatchEmbedResponse>;
1452
+ /** Finalizes a staged ingest session after all batches are embedded. */
1453
+ finalizeSchemaIngest(sessionId: string, options: SchemaIngestRequestOptions, signal?: AbortSignal): Promise<IngestResponse>;
1454
+ /**
1455
+ * Batched alternative to syncSchema for large databases: stage, embed every
1456
+ * batch, and finalize in-process, reporting progress via `onProgress`.
1457
+ *
1458
+ * @example
1459
+ * ```typescript
1460
+ * await qp.syncSchemaInBatches("warehouse", {
1461
+ * tenantId: "tenant_123",
1462
+ * onProgress: (e) => console.log(e.phase, e),
1463
+ * });
1464
+ * ```
1465
+ */
1466
+ syncSchemaInBatches(databaseName: string, options: SyncSchemaInBatchesOptions, signal?: AbortSignal): Promise<IngestResponse>;
1311
1467
  /**
1312
1468
  * Generates SQL from a natural language question and executes it.
1313
1469
  *
@@ -2012,4 +2168,4 @@ declare class QueryPanelSdkAPI {
2012
2168
  }, signal?: AbortSignal): Promise<SdkDashboard[]>;
2013
2169
  }
2014
2170
 
2015
- export { ALL_VIZ_CHART_TYPES, type ActiveChartBulkGetResponse, type ActiveChartCreateInput, type ActiveChartListOptions, type ActiveChartUpdateInput, type AggregateOp, type AskOptions, type AskResponse, type AxisField, type AxisFieldInput, BigQueryAdapter, type BigQueryAdapterOptions, type BigQueryClientFn, type BigQueryQueryRequest, type BigQueryQueryResult, CallbackApiClient, type ChartBulkGetResponse, type ChartCreateInput, type ChartEncoding, type ChartEnvelope, type ChartListAllOptions, type ChartListOptions, type ChartModifyInput, type ChartModifyOptions, type ChartModifyResponse, type ChartSpec, type ChartType, type ChartUpdateInput, ClickHouseAdapter, type ClickHouseAdapterOptions, type ClickHouseClientFn, type ContextDocument, type DashboardCreateInput, type DashboardForkInput, type DashboardForkUpdateInput, type DashboardListOptions, type DashboardUpdateInput, type DatabaseAdapter, type DatabaseDialect, type DateRangeInput, type EncodingHints, type FieldRef, type FieldRefInput, type FieldType, type IQueryPanelApi, type IngestResponse, type IntentResult, type MetricEncoding, type MetricField, type MetricSpec, type PaginatedResponse$1 as PaginatedResponse, type PaginationInfo$1 as PaginationInfo, type PaginationQuery$1 as PaginationQuery, type ParamRecord, type ParamValue, type PipelineTrace, PostgresAdapter, type PostgresAdapterOptions, type PostgresClientFn, type PostgresWireDialect, QueryErrorCode, QueryErrorCode as QueryErrorCodeType, QueryPanelSdkAPI, type QueryPanelSdkAPIOptions, QueryPipelineError, type RequestHandler, type RequestHandlerOptions, type RequestHandlerResult, type SchemaIntrospection, type SchemaSyncOptions, type SdkActiveChart, type SdkChart, type SdkDashboard, type SdkSession, type SdkSessionTurn, type SessionGetOptions, type SessionListOptions, type SessionUpdateInput, type SqlModifications, type StackingMode, type TableColumn, type TableEncoding, type TableSpec, type TimeUnit, type ValueFormat, type VizModifications, type VizSpec, type VizSpecGenerateInput, type VizSpecGenerateOptions, type VizSpecGeneratorInput, type VizSpecKind, type VizSpecResponse, type VizSpecResult, anonymizeResults, mapGeneratedParams, normalizeSqlParamsInput, resolveQueryPipeline };
2171
+ export { ALL_VIZ_CHART_TYPES, type ActiveChartBulkGetResponse, type ActiveChartCreateInput, type ActiveChartListOptions, type ActiveChartUpdateInput, type AggregateOp, type AskOptions, type AskResponse, type AxisField, type AxisFieldInput, BigQueryAdapter, type BigQueryAdapterOptions, type BigQueryClientFn, type BigQueryQueryRequest, type BigQueryQueryResult, CallbackApiClient, type CatalogSchema, type CatalogTable, type CatalogTableType, type ChartBulkGetResponse, type ChartCreateInput, type ChartEncoding, type ChartEnvelope, type ChartListAllOptions, type ChartListOptions, type ChartModifyInput, type ChartModifyOptions, type ChartModifyResponse, type ChartSpec, type ChartType, type ChartUpdateInput, ClickHouseAdapter, type ClickHouseAdapterOptions, type ClickHouseClientFn, type ContextDocument, type DashboardCreateInput, type DashboardForkInput, type DashboardForkUpdateInput, type DashboardListOptions, type DashboardUpdateInput, type DatabaseAdapter, type DatabaseDialect, type DateRangeInput, type EncodingHints, type FieldRef, type FieldRefInput, type FieldType, type IQueryPanelApi, type IngestResponse, type IntentResult, type ListTablesOptions, type MetricEncoding, type MetricField, type MetricSpec, type PaginatedResponse$1 as PaginatedResponse, type PaginationInfo$1 as PaginationInfo, type PaginationQuery$1 as PaginationQuery, type ParamRecord, type ParamValue, type PipelineTrace, PostgresAdapter, type PostgresAdapterOptions, type PostgresClientFn, type PostgresWireDialect, QueryErrorCode, QueryErrorCode as QueryErrorCodeType, QueryPanelSdkAPI, type QueryPanelSdkAPIOptions, QueryPipelineError, type RequestHandler, type RequestHandlerOptions, type RequestHandlerResult, type SchemaIngestBatchEmbedResponse, type SchemaIngestRequestOptions, type SchemaIntrospection, type SchemaSyncOptions, type SchemaSyncProgressEvent, SchemaTooLargeError, type SdkActiveChart, type SdkChart, type SdkDashboard, type SdkSession, type SdkSessionTurn, type SessionGetOptions, type SessionListOptions, type SessionUpdateInput, type SqlModifications, type StackingMode, type StageSchemaIngestOptions, type StageSchemaIngestResult, type SyncSchemaInBatchesOptions, type TableColumn, type TableEncoding, type TableSpec, type TimeUnit, type ValueFormat, type VizModifications, type VizSpec, type VizSpecGenerateInput, type VizSpecGenerateOptions, type VizSpecGeneratorInput, type VizSpecKind, type VizSpecResponse, type VizSpecResult, anonymizeResults, mapGeneratedParams, normalizeSqlParamsInput, resolveQueryPipeline };