Line data Source code
1 : import { DashQLShell, DashQLShellEnvironment, DashQLShellOptions } from '../../shell/api.js';
2 :
3 : export interface SessionShellCatalog {
4 : relationsSql: string;
5 : functionsSql: string;
6 : }
7 :
8 1 : export async function createSessionShell(
9 1 : catalog: SessionShellCatalog,
10 1 : environment: DashQLShellEnvironment,
11 1 : options: Omit<DashQLShellOptions, 'environment'> = {},
12 1 : ): Promise<DashQLShell> {
13 1 : const shell = await DashQLShell.create({ ...options, environment });
14 1 : try {
15 1 : shell.loadCatalogScript(catalog.relationsSql);
16 1 : shell.loadCatalogScript(catalog.functionsSql);
17 1 : return shell;
18 1 : } catch (error) {
19 1 : shell.destroy();
20 1 : throw error;
21 1 : }
22 1 : }
|