@duckcodeailabs/dql-cli 1.6.16 → 1.6.18
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/assets/dql-notebook/assets/index-BbGJ8gZk.js +3639 -0
- package/dist/assets/dql-notebook/assets/index-C4oZK5xm.js +3612 -0
- package/dist/assets/dql-notebook/assets/index-CEMXuPm0.js +3802 -0
- package/dist/assets/dql-notebook/assets/index-CIMLd3Cb.js +3289 -0
- package/dist/assets/dql-notebook/assets/index-DISMWw19.js +3780 -0
- package/dist/assets/dql-notebook/assets/{index-BFTvljNh.js → index-DPcxWQuS.js} +204 -180
- package/dist/assets/dql-notebook/assets/index-McpLeeN0.js +3802 -0
- package/dist/assets/dql-notebook/index.html +1 -1
- package/dist/commands/notebook.d.ts +2 -0
- package/dist/commands/notebook.d.ts.map +1 -1
- package/dist/commands/notebook.js +6 -1
- package/dist/commands/notebook.js.map +1 -1
- package/dist/local-runtime.d.ts +1 -1
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +107 -56
- package/dist/local-runtime.js.map +1 -1
- package/dist/package.json +10 -10
- package/package.json +11 -11
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
8
8
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
9
9
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&family=Kalam:wght@400;700&family=Caveat:wght@400;600;700&display=swap" rel="stylesheet" />
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-DPcxWQuS.js"></script>
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/react-CRB3T2We.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/codemirror-DJYUkPr1.js">
|
|
13
13
|
<link rel="stylesheet" crossorigin href="/assets/index-RaDW1A5g.css">
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { CLIFlags } from '../args.js';
|
|
2
|
+
import type { ProjectConfig } from '../local-runtime.js';
|
|
3
|
+
export declare function resolveNotebookConnection(config: ProjectConfig, projectRoot: string): import("@duckcodeailabs/dql-connectors").ConnectionConfig | null;
|
|
2
4
|
export declare function runNotebook(targetArg: string | null, flags: CLIFlags): Promise<void>;
|
|
3
5
|
//# sourceMappingURL=notebook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notebook.d.ts","sourceRoot":"","sources":["../../src/commands/notebook.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"notebook.d.ts","sourceRoot":"","sources":["../../src/commands/notebook.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAezD,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,oEAInF;AAED,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAsC1F"}
|
|
@@ -9,6 +9,11 @@ const COMMAND_DIR = dirname(fileURLToPath(import.meta.url));
|
|
|
9
9
|
const REACT_APP_DIR = resolve(COMMAND_DIR, '../assets/dql-notebook');
|
|
10
10
|
const LEGACY_APP_DIR = resolve(COMMAND_DIR, '../assets/notebook-browser');
|
|
11
11
|
const NOTEBOOK_APP_DIR = existsSync(join(REACT_APP_DIR, 'index.html')) ? REACT_APP_DIR : LEGACY_APP_DIR;
|
|
12
|
+
export function resolveNotebookConnection(config, projectRoot) {
|
|
13
|
+
return config.defaultConnection
|
|
14
|
+
? normalizeProjectConnection(config.defaultConnection, projectRoot)
|
|
15
|
+
: null;
|
|
16
|
+
}
|
|
12
17
|
export async function runNotebook(targetArg, flags) {
|
|
13
18
|
const baseDir = resolve(targetArg ?? '.');
|
|
14
19
|
const projectRoot = findProjectRoot(baseDir);
|
|
@@ -17,7 +22,7 @@ export async function runNotebook(targetArg, flags) {
|
|
|
17
22
|
}
|
|
18
23
|
const config = loadProjectConfig(projectRoot);
|
|
19
24
|
const executor = new QueryExecutor();
|
|
20
|
-
const connection =
|
|
25
|
+
const connection = resolveNotebookConnection(config, projectRoot);
|
|
21
26
|
const host = flags.host ?? process.env.DQL_HOST ?? '127.0.0.1';
|
|
22
27
|
const port = await startLocalServer({
|
|
23
28
|
rootDir: NOTEBOOK_APP_DIR,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notebook.js","sourceRoot":"","sources":["../../src/commands/notebook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"notebook.js","sourceRoot":"","sources":["../../src/commands/notebook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAG/D,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM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CAAC;QAClC,OAAO,EAAE,gBAAgB;QACzB,WAAW;QACX,QAAQ;QACR,UAAU;QACV,aAAa,EAAE,KAAK,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,IAAI,IAAI,IAAI;QACzD,IAAI;KACL,CAAC,CAAC;IAEH,uEAAuE;IACvE,sEAAsE;IACtE,MAAM,SAAS,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1D,MAAM,GAAG,GAAG,UAAU,SAAS,IAAI,IAAI,EAAE,CAAC;IAE1C,0EAA0E;IAC1E,iDAAiD;IACjD,MAAM,UAAU,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,KAAK,WAAW,CAAC;IACxF,gBAAgB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAElC,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,EAAE,CAAC,CAAC;IAC5C,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;QACzB,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,IAAI,IAAI,uCAAuC,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC"}
|
package/dist/local-runtime.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export interface LocalServerOptions {
|
|
|
46
46
|
rootDir: string;
|
|
47
47
|
projectRoot?: string;
|
|
48
48
|
executor: QueryExecutor;
|
|
49
|
-
connection
|
|
49
|
+
connection?: ConnectionConfig | null;
|
|
50
50
|
preferredPort: number;
|
|
51
51
|
/**
|
|
52
52
|
* Host the HTTP server binds to. Defaults to `127.0.0.1` (loopback only)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-runtime.d.ts","sourceRoot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@@ const NOTEBOOK_EXECUTE_PREVIEW_ROW_LIMIT = 500;
|
|
|
25
25
|
export async function startLocalServer(opts) {
|
|
26
26
|
const { rootDir, executor, connection: rawConnection, preferredPort, projectRoot = process.cwd() } = opts;
|
|
27
27
|
const bindHost = opts.host ?? process.env.DQL_HOST ?? '127.0.0.1';
|
|
28
|
-
let connection = normalizeProjectConnection(rawConnection, projectRoot);
|
|
28
|
+
let connection = rawConnection ? normalizeProjectConnection(rawConnection, projectRoot) : null;
|
|
29
29
|
let projectConfig = loadProjectConfig(projectRoot);
|
|
30
|
+
const requireActiveConnection = (candidate = connection) => {
|
|
31
|
+
if (!candidate) {
|
|
32
|
+
throw new Error('No database connection is configured yet. Open Connections, add a warehouse or local DuckDB/file connection, then retry.');
|
|
33
|
+
}
|
|
34
|
+
return candidate;
|
|
35
|
+
};
|
|
30
36
|
// Load semantic layer via provider system (dql native, dbt, cubejs, etc.)
|
|
31
37
|
let semanticLayer;
|
|
32
38
|
let semanticLayerErrors = [];
|
|
@@ -37,8 +43,9 @@ export async function startLocalServer(opts) {
|
|
|
37
43
|
const semanticConfig = projectConfig.semanticLayer;
|
|
38
44
|
let semanticLastSyncTime = null;
|
|
39
45
|
{
|
|
40
|
-
const
|
|
41
|
-
|
|
46
|
+
const semanticConnection = connection;
|
|
47
|
+
const executeQuery = semanticConfig?.provider === 'snowflake' && semanticConnection
|
|
48
|
+
? async (sql) => { const r = await executor.executeQuery(sql, [], {}, semanticConnection); return { rows: r.rows }; }
|
|
42
49
|
: undefined;
|
|
43
50
|
const result = await resolveSemanticLayerAsync(semanticConfig, projectRoot, executeQuery);
|
|
44
51
|
semanticLayer = result.layer;
|
|
@@ -58,7 +65,7 @@ export async function startLocalServer(opts) {
|
|
|
58
65
|
await refreshLocalMetadataCatalog(projectRoot);
|
|
59
66
|
// Auto-register data/ CSV and Parquet files as DuckDB views so semantic layer
|
|
60
67
|
// queries like `FROM orders` resolve without requiring read_csv_auto() in SQL.
|
|
61
|
-
if (connection.driver === 'file' || connection.driver === 'duckdb') {
|
|
68
|
+
if (connection && (connection.driver === 'file' || connection.driver === 'duckdb')) {
|
|
62
69
|
const dataDir = projectConfig.dataDir
|
|
63
70
|
? resolve(projectRoot, projectConfig.dataDir)
|
|
64
71
|
: join(projectRoot, 'data');
|
|
@@ -81,11 +88,12 @@ export async function startLocalServer(opts) {
|
|
|
81
88
|
}
|
|
82
89
|
}
|
|
83
90
|
const executeLocalSqlForStoredResult = async (sql) => {
|
|
91
|
+
const activeConnection = requireActiveConnection();
|
|
84
92
|
const semantic = prepareSemanticSql(sql, semanticLayer);
|
|
85
93
|
if (semantic.unresolvedRefs.length > 0) {
|
|
86
94
|
throw new Error(`Unknown semantic reference${semantic.unresolvedRefs.length > 1 ? 's' : ''}: ${semantic.unresolvedRefs.join(', ')}`);
|
|
87
95
|
}
|
|
88
|
-
const prepared = prepareLocalExecution(semantic.sql,
|
|
96
|
+
const prepared = prepareLocalExecution(semantic.sql, activeConnection, projectRoot, projectConfig);
|
|
89
97
|
const result = await executor.executeQuery(prepared.sql, [], runtimeVariables({}), prepared.connection);
|
|
90
98
|
return normalizeQueryResult(result, semantic.semanticRefs);
|
|
91
99
|
};
|
|
@@ -127,13 +135,14 @@ export async function startLocalServer(opts) {
|
|
|
127
135
|
config: (sourceCell.chartConfig ?? sourceCell.config),
|
|
128
136
|
};
|
|
129
137
|
const resolved = resolveNotebookBlockReferenceCell(cell, projectRoot);
|
|
130
|
-
const
|
|
131
|
-
const
|
|
138
|
+
const activeConnection = requireActiveConnection();
|
|
139
|
+
const tableMapping = await resolveSemanticTableMapping(executor, activeConnection, semanticLayer);
|
|
140
|
+
const plan = buildExecutionPlan(resolved.cell, { semanticLayer, driver: activeConnection.driver, tableMapping });
|
|
132
141
|
if (!plan) {
|
|
133
142
|
snapshotCells.push({ cellId, status: 'idle', executionCount: 0, executedAt });
|
|
134
143
|
continue;
|
|
135
144
|
}
|
|
136
|
-
const prepared = prepareLocalExecution(plan.sql,
|
|
145
|
+
const prepared = prepareLocalExecution(plan.sql, activeConnection, projectRoot, projectConfig);
|
|
137
146
|
assertAppAccess({ app, domain: resolved.domain ?? app.domain, level: 'execute' });
|
|
138
147
|
const rawResult = await executor.executeQuery(prepared.sql, plan.sqlParams, runtimeVariables(plan.variables), prepared.connection);
|
|
139
148
|
const result = normalizeQueryResult(rawResult);
|
|
@@ -189,22 +198,23 @@ export async function startLocalServer(opts) {
|
|
|
189
198
|
}
|
|
190
199
|
const absBlockPath = join(projectRoot, block.filePath);
|
|
191
200
|
const source = readFileSync(absBlockPath, 'utf-8');
|
|
192
|
-
const
|
|
201
|
+
const activeConnection = requireActiveConnection();
|
|
202
|
+
const tableMapping = await resolveSemanticTableMapping(executor, activeConnection, semanticLayer);
|
|
193
203
|
const semanticCompose = semanticLayer
|
|
194
204
|
? composeSemanticBlockSql(source, semanticLayer, {
|
|
195
|
-
driver:
|
|
205
|
+
driver: activeConnection.driver,
|
|
196
206
|
tableMapping,
|
|
197
207
|
projectRoot,
|
|
198
208
|
projectConfig,
|
|
199
209
|
detectedProvider: semanticDetectedProvider,
|
|
200
210
|
})
|
|
201
211
|
: null;
|
|
202
|
-
const plan = buildExecutionPlan({ id: `agent-${block.name}`, type: 'dql', source, title: block.name }, { semanticLayer, driver:
|
|
212
|
+
const plan = buildExecutionPlan({ id: `agent-${block.name}`, type: 'dql', source, title: block.name }, { semanticLayer, driver: activeConnection.driver, tableMapping });
|
|
203
213
|
if (!plan && !semanticCompose?.sql) {
|
|
204
214
|
const semanticError = semanticCompose?.diagnostics.find((diagnostic) => diagnostic.severity === 'error')?.message;
|
|
205
215
|
throw new Error(semanticError ?? `Block "${block.name}" produced no executable SQL.`);
|
|
206
216
|
}
|
|
207
|
-
const prepared = prepareLocalExecution(semanticCompose?.sql ?? plan.sql,
|
|
217
|
+
const prepared = prepareLocalExecution(semanticCompose?.sql ?? plan.sql, activeConnection, projectRoot, projectConfig);
|
|
208
218
|
const app = loadRuntimeApp(projectRoot, activePersonaAppId());
|
|
209
219
|
assertAppAccess({ app, domain: block.domain ?? app?.domain, level: 'execute' });
|
|
210
220
|
const rawResult = await executor.executeQuery(prepared.sql, plan?.sqlParams ?? [], runtimeVariables(plan?.variables ?? {}), prepared.connection);
|
|
@@ -221,12 +231,13 @@ export async function startLocalServer(opts) {
|
|
|
221
231
|
};
|
|
222
232
|
};
|
|
223
233
|
const executeGeneratedSqlForAgent = async (sql) => {
|
|
234
|
+
const activeConnection = requireActiveConnection();
|
|
224
235
|
const boundedSql = buildAgentPreviewSql(sql);
|
|
225
236
|
const semantic = prepareSemanticSql(boundedSql, semanticLayer);
|
|
226
237
|
if (semantic.unresolvedRefs.length > 0) {
|
|
227
238
|
throw new Error(`Unknown semantic reference${semantic.unresolvedRefs.length > 1 ? 's' : ''}: ${semantic.unresolvedRefs.join(', ')}`);
|
|
228
239
|
}
|
|
229
|
-
const prepared = prepareLocalExecution(semantic.sql,
|
|
240
|
+
const prepared = prepareLocalExecution(semantic.sql, activeConnection, projectRoot, projectConfig);
|
|
230
241
|
const app = loadRuntimeApp(projectRoot, activePersonaAppId());
|
|
231
242
|
assertAppAccess({ app, domain: app?.domain, level: 'execute' });
|
|
232
243
|
const rawResult = await executor.executeQuery(prepared.sql, [], runtimeVariables({}), prepared.connection);
|
|
@@ -242,10 +253,14 @@ export async function startLocalServer(opts) {
|
|
|
242
253
|
const getSchemaContextForAgent = async (question) => {
|
|
243
254
|
const catalogContext = await buildAgentSchemaContextFromCatalog(projectRoot, question).catch(() => []);
|
|
244
255
|
if (catalogContext.length > 0) {
|
|
256
|
+
if (!connection)
|
|
257
|
+
return catalogContext;
|
|
245
258
|
const enriched = await enrichAgentSchemaContextWithValueMatches(question, catalogContext, executor, connection);
|
|
246
259
|
recordAgentRuntimeSchemaSnapshot(projectRoot, enriched, 'catalog enriched runtime schema');
|
|
247
260
|
return enriched;
|
|
248
261
|
}
|
|
262
|
+
if (!connection)
|
|
263
|
+
return [];
|
|
249
264
|
try {
|
|
250
265
|
const result = await executor.executeQuery(`SELECT table_schema, table_name, column_name, data_type
|
|
251
266
|
FROM information_schema.columns
|
|
@@ -339,8 +354,9 @@ export async function startLocalServer(opts) {
|
|
|
339
354
|
}
|
|
340
355
|
// Hot-reload semantic layer on change and notify frontend
|
|
341
356
|
if (dir === 'semantic-layer') {
|
|
342
|
-
const
|
|
343
|
-
|
|
357
|
+
const semanticConnection = connection;
|
|
358
|
+
const executeQuery = semanticConfig?.provider === 'snowflake' && semanticConnection
|
|
359
|
+
? async (sql) => { const r = await executor.executeQuery(sql, [], {}, semanticConnection); return { rows: r.rows }; }
|
|
344
360
|
: undefined;
|
|
345
361
|
resolveSemanticLayerAsync(semanticConfig, projectRoot, executeQuery).then((refreshed) => {
|
|
346
362
|
if (refreshed.layer) {
|
|
@@ -384,13 +400,14 @@ export async function startLocalServer(opts) {
|
|
|
384
400
|
}
|
|
385
401
|
return { candidate: validated, errors };
|
|
386
402
|
};
|
|
387
|
-
const runBlockStudioPreviewSource = async (source, targetConnection
|
|
403
|
+
const runBlockStudioPreviewSource = async (source, targetConnection) => {
|
|
404
|
+
const activeConnection = requireActiveConnection(targetConnection);
|
|
388
405
|
let tableMapping;
|
|
389
406
|
if (semanticLayer) {
|
|
390
407
|
try {
|
|
391
408
|
const tablesResult = await executor.executeQuery(`SELECT table_schema, table_name
|
|
392
409
|
FROM information_schema.tables
|
|
393
|
-
WHERE table_schema NOT IN ('information_schema', 'pg_catalog')`, [], {},
|
|
410
|
+
WHERE table_schema NOT IN ('information_schema', 'pg_catalog')`, [], {}, activeConnection);
|
|
394
411
|
tableMapping = buildSemanticTableMapping(semanticLayer, tablesResult.rows);
|
|
395
412
|
}
|
|
396
413
|
catch {
|
|
@@ -399,7 +416,7 @@ export async function startLocalServer(opts) {
|
|
|
399
416
|
}
|
|
400
417
|
const semanticCompose = semanticLayer
|
|
401
418
|
? composeSemanticBlockSql(source, semanticLayer, {
|
|
402
|
-
driver:
|
|
419
|
+
driver: activeConnection.driver,
|
|
403
420
|
tableMapping,
|
|
404
421
|
projectRoot,
|
|
405
422
|
projectConfig,
|
|
@@ -414,8 +431,8 @@ export async function startLocalServer(opts) {
|
|
|
414
431
|
?? 'No executable SQL found in block source.';
|
|
415
432
|
throw new Error(message);
|
|
416
433
|
}
|
|
417
|
-
const plan = buildExecutionPlan({ id: 'block-studio', type: 'dql', source, title: 'Block Studio' }, { semanticLayer, driver:
|
|
418
|
-
const prepared = prepareLocalExecution(semanticCompose?.sql ?? plan?.sql ?? executableSql,
|
|
434
|
+
const plan = buildExecutionPlan({ id: 'block-studio', type: 'dql', source, title: 'Block Studio' }, { semanticLayer, driver: activeConnection.driver, tableMapping });
|
|
435
|
+
const prepared = prepareLocalExecution(semanticCompose?.sql ?? plan?.sql ?? executableSql, activeConnection, projectRoot, projectConfig);
|
|
419
436
|
const result = await executor.executeQuery(prepared.sql, plan?.sqlParams ?? [], runtimeVariables(plan?.variables ?? {}), prepared.connection);
|
|
420
437
|
return {
|
|
421
438
|
sql: prepared.sql,
|
|
@@ -423,10 +440,11 @@ export async function startLocalServer(opts) {
|
|
|
423
440
|
chartConfig: plan?.chartConfig ?? validation.chartConfig ?? null,
|
|
424
441
|
};
|
|
425
442
|
};
|
|
426
|
-
const runBlockStudioTestSummary = async (source, targetConnection
|
|
443
|
+
const runBlockStudioTestSummary = async (source, targetConnection) => {
|
|
444
|
+
const activeConnection = requireActiveConnection(targetConnection);
|
|
427
445
|
const start = Date.now();
|
|
428
|
-
const tableMapping = await resolveSemanticTableMapping(executor,
|
|
429
|
-
const plan = buildExecutionPlan({ id: 'block-studio-tests', type: 'dql', source, title: 'Block Studio' }, { semanticLayer, driver:
|
|
446
|
+
const tableMapping = await resolveSemanticTableMapping(executor, activeConnection, semanticLayer);
|
|
447
|
+
const plan = buildExecutionPlan({ id: 'block-studio-tests', type: 'dql', source, title: 'Block Studio' }, { semanticLayer, driver: activeConnection.driver, tableMapping });
|
|
430
448
|
const tests = plan?.tests ?? [];
|
|
431
449
|
if (!plan || !plan.sql) {
|
|
432
450
|
return {
|
|
@@ -445,7 +463,7 @@ export async function startLocalServer(opts) {
|
|
|
445
463
|
if (tests.length === 0) {
|
|
446
464
|
return { passed: 0, failed: 0, skipped: 0, duration: Date.now() - start, assertions: [], runAt: new Date() };
|
|
447
465
|
}
|
|
448
|
-
const prepared = prepareLocalExecution(plan.sql,
|
|
466
|
+
const prepared = prepareLocalExecution(plan.sql, activeConnection, projectRoot, projectConfig);
|
|
449
467
|
const rawResult = await executor.executeQuery(prepared.sql, plan.sqlParams ?? [], runtimeVariables(plan.variables ?? {}), prepared.connection);
|
|
450
468
|
const rows = Array.isArray(rawResult?.rows) ? rawResult.rows : [];
|
|
451
469
|
const columns = Array.isArray(rawResult?.columns)
|
|
@@ -1166,7 +1184,9 @@ export async function startLocalServer(opts) {
|
|
|
1166
1184
|
if (req.method === 'GET' && path === '/api/schema') {
|
|
1167
1185
|
try {
|
|
1168
1186
|
const dataFiles = scanDataFiles(projectRoot);
|
|
1169
|
-
const { tables, columnsByPath } =
|
|
1187
|
+
const { tables, columnsByPath } = connection
|
|
1188
|
+
? await introspectSchema(executor, connection)
|
|
1189
|
+
: { tables: [], columnsByPath: new Map() };
|
|
1170
1190
|
const dbTables = tables.map((t) => ({
|
|
1171
1191
|
name: t.path,
|
|
1172
1192
|
path: t.path,
|
|
@@ -1186,8 +1206,8 @@ export async function startLocalServer(opts) {
|
|
|
1186
1206
|
const message = error instanceof Error ? error.message : String(error);
|
|
1187
1207
|
console.warn(`[dql] /api/schema introspection failed: ${message}`);
|
|
1188
1208
|
const fallback = scanDataFiles(projectRoot).map((f) => ({ ...f, source: 'file' }));
|
|
1189
|
-
res.writeHead(
|
|
1190
|
-
res.end(serializeJSON(
|
|
1209
|
+
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
1210
|
+
res.end(serializeJSON(fallback));
|
|
1191
1211
|
}
|
|
1192
1212
|
return;
|
|
1193
1213
|
}
|
|
@@ -2258,7 +2278,7 @@ export async function startLocalServer(opts) {
|
|
|
2258
2278
|
};
|
|
2259
2279
|
const executeQuery = provider === 'snowflake'
|
|
2260
2280
|
? async (sql) => {
|
|
2261
|
-
const result = await executor.executeQuery(sql, [], {},
|
|
2281
|
+
const result = await executor.executeQuery(sql, [], {}, requireActiveConnection());
|
|
2262
2282
|
return { rows: result.rows };
|
|
2263
2283
|
}
|
|
2264
2284
|
: undefined;
|
|
@@ -2297,7 +2317,7 @@ export async function startLocalServer(opts) {
|
|
|
2297
2317
|
try {
|
|
2298
2318
|
const executeQuery = semanticImportManifest?.provider === 'snowflake'
|
|
2299
2319
|
? async (sql) => {
|
|
2300
|
-
const result = await executor.executeQuery(sql, [], {},
|
|
2320
|
+
const result = await executor.executeQuery(sql, [], {}, requireActiveConnection());
|
|
2301
2321
|
return { rows: result.rows };
|
|
2302
2322
|
}
|
|
2303
2323
|
: undefined;
|
|
@@ -2354,7 +2374,7 @@ export async function startLocalServer(opts) {
|
|
|
2354
2374
|
};
|
|
2355
2375
|
const executeQuery = provider === 'snowflake'
|
|
2356
2376
|
? async (sql) => {
|
|
2357
|
-
const result = await executor.executeQuery(sql, [], {},
|
|
2377
|
+
const result = await executor.executeQuery(sql, [], {}, requireActiveConnection());
|
|
2358
2378
|
return { rows: result.rows };
|
|
2359
2379
|
}
|
|
2360
2380
|
: undefined;
|
|
@@ -2386,7 +2406,7 @@ export async function startLocalServer(opts) {
|
|
|
2386
2406
|
try {
|
|
2387
2407
|
const executeQuery = semanticImportManifest?.provider === 'snowflake'
|
|
2388
2408
|
? async (sql) => {
|
|
2389
|
-
const result = await executor.executeQuery(sql, [], {},
|
|
2409
|
+
const result = await executor.executeQuery(sql, [], {}, requireActiveConnection());
|
|
2390
2410
|
return { rows: result.rows };
|
|
2391
2411
|
}
|
|
2392
2412
|
: undefined;
|
|
@@ -2620,8 +2640,11 @@ export async function startLocalServer(opts) {
|
|
|
2620
2640
|
}
|
|
2621
2641
|
// Try connector.listColumns() first
|
|
2622
2642
|
let columns = [];
|
|
2643
|
+
const activeConnection = connection;
|
|
2623
2644
|
try {
|
|
2624
|
-
|
|
2645
|
+
if (!activeConnection)
|
|
2646
|
+
throw new Error('No active connection');
|
|
2647
|
+
const connector = await executor.getConnector(activeConnection);
|
|
2625
2648
|
if (typeof connector.listColumns === 'function') {
|
|
2626
2649
|
const rawCols = await connector.listColumns(schemaName, tablePath);
|
|
2627
2650
|
columns = rawCols.map((c) => ({ name: c.name, type: c.dataType }));
|
|
@@ -2639,7 +2662,9 @@ export async function startLocalServer(opts) {
|
|
|
2639
2662
|
const sql = isFile
|
|
2640
2663
|
? `DESCRIBE SELECT * FROM read_csv_auto('${safePath}') LIMIT 0`
|
|
2641
2664
|
: `DESCRIBE ${qualifiedIdentifier}`;
|
|
2642
|
-
|
|
2665
|
+
if (!activeConnection)
|
|
2666
|
+
throw new Error('No active connection');
|
|
2667
|
+
const result = await executor.executeQuery(sql, [], {}, activeConnection);
|
|
2643
2668
|
columns = result.rows.map((row) => ({
|
|
2644
2669
|
name: String(row['column_name'] ?? row['Field'] ?? ''),
|
|
2645
2670
|
type: String(row['column_type'] ?? row['Type'] ?? ''),
|
|
@@ -2706,6 +2731,28 @@ export async function startLocalServer(opts) {
|
|
|
2706
2731
|
res.end();
|
|
2707
2732
|
return;
|
|
2708
2733
|
}
|
|
2734
|
+
if (req.method === 'POST' && path === '/api/ai/sql-draft/preview') {
|
|
2735
|
+
try {
|
|
2736
|
+
const body = await readJSON(req);
|
|
2737
|
+
if (typeof body.sql !== 'string' || body.sql.trim().length === 0) {
|
|
2738
|
+
res.writeHead(400, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
2739
|
+
res.end(serializeJSON({ error: 'Missing SQL in request body.' }));
|
|
2740
|
+
return;
|
|
2741
|
+
}
|
|
2742
|
+
const previewSql = buildAgentPreviewSql(body.sql);
|
|
2743
|
+
const result = await executeLocalSqlForStoredResult(previewSql);
|
|
2744
|
+
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
2745
|
+
res.end(serializeJSON({ ok: true, result }));
|
|
2746
|
+
}
|
|
2747
|
+
catch (error) {
|
|
2748
|
+
res.writeHead(500, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
2749
|
+
res.end(serializeJSON({
|
|
2750
|
+
ok: false,
|
|
2751
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2752
|
+
}));
|
|
2753
|
+
}
|
|
2754
|
+
return;
|
|
2755
|
+
}
|
|
2709
2756
|
if (req.method === 'POST' && path === '/api/query') {
|
|
2710
2757
|
try {
|
|
2711
2758
|
const body = await readJSON(req);
|
|
@@ -2726,7 +2773,7 @@ export async function startLocalServer(opts) {
|
|
|
2726
2773
|
}));
|
|
2727
2774
|
return;
|
|
2728
2775
|
}
|
|
2729
|
-
const prepared = prepareLocalExecution(semantic.sql, isConnectionConfig(body.connection) ? body.connection : connection, projectRoot, projectConfig);
|
|
2776
|
+
const prepared = prepareLocalExecution(semantic.sql, requireActiveConnection(isConnectionConfig(body.connection) ? body.connection : connection), projectRoot, projectConfig);
|
|
2730
2777
|
const app = loadRuntimeApp(projectRoot, typeof body.appId === 'string' ? body.appId : activePersonaAppId());
|
|
2731
2778
|
const domain = typeof body.domain === 'string' ? body.domain : app?.domain;
|
|
2732
2779
|
assertAppAccess({ app, domain, level: 'execute' });
|
|
@@ -2770,7 +2817,7 @@ export async function startLocalServer(opts) {
|
|
|
2770
2817
|
const body = await readJSON(req);
|
|
2771
2818
|
const { metrics = [], dimensions = [], filters = [], limit, timeDimension, orderBy, savedQuery, engine } = body;
|
|
2772
2819
|
// Resolve which connection to use — request can override default
|
|
2773
|
-
const targetConnection = isConnectionConfig(body.connection) ? body.connection : connection;
|
|
2820
|
+
const targetConnection = requireActiveConnection(isConnectionConfig(body.connection) ? body.connection : connection);
|
|
2774
2821
|
const driver = targetConnection.driver;
|
|
2775
2822
|
// Build table mapping: resolve semantic model names to actual DB table names
|
|
2776
2823
|
let tableMapping;
|
|
@@ -2862,7 +2909,7 @@ export async function startLocalServer(opts) {
|
|
|
2862
2909
|
}
|
|
2863
2910
|
const body = await readJSON(req);
|
|
2864
2911
|
const { metrics = [], dimensions = [], filters = [], limit, timeDimension, orderBy, savedQuery, engine } = body;
|
|
2865
|
-
const targetConnection = isConnectionConfig(body.connection) ? body.connection : connection;
|
|
2912
|
+
const targetConnection = requireActiveConnection(isConnectionConfig(body.connection) ? body.connection : connection);
|
|
2866
2913
|
const driver = targetConnection.driver;
|
|
2867
2914
|
let tableMapping;
|
|
2868
2915
|
try {
|
|
@@ -2947,7 +2994,7 @@ export async function startLocalServer(opts) {
|
|
|
2947
2994
|
res.end(serializeJSON({ error: 'name and at least one metric are required.' }));
|
|
2948
2995
|
return;
|
|
2949
2996
|
}
|
|
2950
|
-
const targetConnection = isConnectionConfig(body.connection) ? body.connection : connection;
|
|
2997
|
+
const targetConnection = requireActiveConnection(isConnectionConfig(body.connection) ? body.connection : connection);
|
|
2951
2998
|
const composed = composeRuntimeSemanticQuery({
|
|
2952
2999
|
metrics,
|
|
2953
3000
|
dimensions,
|
|
@@ -3005,7 +3052,7 @@ export async function startLocalServer(opts) {
|
|
|
3005
3052
|
let target = connection;
|
|
3006
3053
|
try {
|
|
3007
3054
|
const body = await readJSON(req);
|
|
3008
|
-
target = normalizeProjectConnection(isConnectionConfig(body.connection) ? body.connection : connection, projectRoot);
|
|
3055
|
+
target = normalizeProjectConnection(requireActiveConnection(isConnectionConfig(body.connection) ? body.connection : connection), projectRoot);
|
|
3009
3056
|
const connector = await executor.getConnector(target);
|
|
3010
3057
|
const result = await validateConnectionForTest(connector, target);
|
|
3011
3058
|
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
@@ -3015,7 +3062,7 @@ export async function startLocalServer(opts) {
|
|
|
3015
3062
|
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
3016
3063
|
res.end(serializeJSON({
|
|
3017
3064
|
ok: false,
|
|
3018
|
-
message: formatConnectionTestError(target, error),
|
|
3065
|
+
message: target ? formatConnectionTestError(target, error) : error instanceof Error ? error.message : String(error),
|
|
3019
3066
|
}));
|
|
3020
3067
|
}
|
|
3021
3068
|
return;
|
|
@@ -3266,7 +3313,7 @@ export async function startLocalServer(opts) {
|
|
|
3266
3313
|
}
|
|
3267
3314
|
const resolved = resolveNotebookBlockReferenceCell(cell, projectRoot);
|
|
3268
3315
|
const executableCell = resolved.cell;
|
|
3269
|
-
const cellConnection = isConnectionConfig(body.connection) ? body.connection : connection;
|
|
3316
|
+
const cellConnection = requireActiveConnection(isConnectionConfig(body.connection) ? body.connection : connection);
|
|
3270
3317
|
const tableMapping = needsSemanticTableMapping(executableCell)
|
|
3271
3318
|
? await resolveSemanticTableMapping(executor, cellConnection, semanticLayer)
|
|
3272
3319
|
: undefined;
|
|
@@ -3276,7 +3323,7 @@ export async function startLocalServer(opts) {
|
|
|
3276
3323
|
res.end(serializeJSON({ cellType: cell.type, result: null }));
|
|
3277
3324
|
return;
|
|
3278
3325
|
}
|
|
3279
|
-
const prepared = prepareLocalExecution(plan.sql,
|
|
3326
|
+
const prepared = prepareLocalExecution(plan.sql, cellConnection, projectRoot, projectConfig);
|
|
3280
3327
|
const app = loadRuntimeApp(projectRoot, typeof body.appId === 'string' ? body.appId : activePersonaAppId());
|
|
3281
3328
|
assertAppAccess({ app, domain: resolved.domain ?? app?.domain, level: 'execute' });
|
|
3282
3329
|
const rawResult = await executor.executeQuery(prepared.sql, plan.sqlParams, runtimeVariables(plan.variables), prepared.connection);
|
|
@@ -4363,7 +4410,9 @@ async function introspectSchema(executor, connection) {
|
|
|
4363
4410
|
function buildDatabaseSchemaTree(projectRoot, executor, connection) {
|
|
4364
4411
|
return (async () => {
|
|
4365
4412
|
const dataFiles = scanDataFiles(projectRoot);
|
|
4366
|
-
const { tables: dbTables, columnsByPath: dbColumnsByPath } =
|
|
4413
|
+
const { tables: dbTables, columnsByPath: dbColumnsByPath } = connection
|
|
4414
|
+
? await introspectSchema(executor, connection)
|
|
4415
|
+
: { tables: [], columnsByPath: new Map() };
|
|
4367
4416
|
const schemaMap = new Map();
|
|
4368
4417
|
for (const table of dbTables) {
|
|
4369
4418
|
const schemaName = table.schema || 'default';
|
|
@@ -4399,20 +4448,22 @@ function buildDatabaseSchemaTree(projectRoot, executor, connection) {
|
|
|
4399
4448
|
const fileChildren = [];
|
|
4400
4449
|
for (const file of dataFiles) {
|
|
4401
4450
|
let columns = [];
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4451
|
+
if (connection) {
|
|
4452
|
+
try {
|
|
4453
|
+
const ext = file.name.split('.').pop()?.toLowerCase();
|
|
4454
|
+
const readFn = ext === 'parquet' ? 'read_parquet' : ext === 'json' ? 'read_json_auto' : 'read_csv_auto';
|
|
4455
|
+
const descResult = await executor.executeQuery(`DESCRIBE SELECT * FROM ${readFn}('${file.path.replace(/'/g, "''")}') LIMIT 0`, [], {}, connection);
|
|
4456
|
+
columns = descResult.rows.map((row) => ({
|
|
4457
|
+
id: `db-column:${file.path}:${String(row['column_name'] ?? '')}`,
|
|
4458
|
+
label: String(row['column_name'] ?? ''),
|
|
4459
|
+
kind: 'column',
|
|
4460
|
+
path: file.path,
|
|
4461
|
+
type: String(row['column_type'] ?? ''),
|
|
4462
|
+
}));
|
|
4463
|
+
}
|
|
4464
|
+
catch {
|
|
4465
|
+
// file column discovery failed — empty children is fine
|
|
4466
|
+
}
|
|
4416
4467
|
}
|
|
4417
4468
|
fileChildren.push({
|
|
4418
4469
|
id: `db-table:${file.path}`,
|