LCOV - code coverage report
Current view: top level - dashql-app/src/session/snippets - snippet.ts Coverage Total Hit
Test: DashQL d805a4b Lines: 100.0 % 11 11
Test Date: 2026-11-09 20:22:13

            Line data    Source code
       1              : import { ConnectorType } from '../../connections/connector_info.js';
       2              : 
       3              : /// The folder of the snippets that load datasets, the browser lists it first
       4            1 : export const SNIPPET_DATASETS_FOLDER = 'datasets';
       5              : 
       6              : /// A self-contained SQL statement sequence that can replace the text of a script
       7              : export interface Snippet {
       8              :     /// The id of the snippet, `<category>/<name>`
       9              :     id: string;
      10              :     /// The category of the snippet, the path of its folder in the tree of the browser, e.g. `dates` or `d360-api/scenarios/agent-memory`
      11              :     category: string;
      12              :     /// The connectors that the snippet runs on
      13              :     connectors: ConnectorType[];
      14              :     /// The text of the snippet per connector
      15              :     bodies: ReadonlyMap<ConnectorType, string>;
      16              :     /// The path of the file of the snippet per connector, starting at its root folder, e.g. `hyper/dates/series.sql`
      17              :     paths: ReadonlyMap<ConnectorType, string>;
      18              : }
      19              : 
      20              : /// The connectors of the root folders of the snippets, `<root>/<folders>/<name>.sql`. A root is a folder of
      21              : /// examples/snippets or an extension with snippets. The snippets of a root run on all of its connectors.
      22            1 : export const SNIPPET_ROOT_CONNECTORS: ReadonlyMap<string, readonly ConnectorType[]> = new Map([
      23            1 :     ['d360', [ConnectorType.SALESFORCE_DATA_CLOUD]],
      24            1 :     ['d360-api', [ConnectorType.SALESFORCE_DATA_CLOUD]],
      25            1 :     ['hyper', [ConnectorType.HYPER, ConnectorType.DBCOM]],
      26            1 :     ['trino', [ConnectorType.TRINO]],
      27            1 : ]);
      28              : 
      29              : /// Is a root a folder of the browser? A connector with several roots shows them as top-level folders, the only root
      30              : /// of a connector stays out of the tree.
      31            1 : export function snippetRootIsFolder(root: string): boolean {
      32            1 :     const connectors = SNIPPET_ROOT_CONNECTORS.get(root) ?? [];
      33            1 :     return [...SNIPPET_ROOT_CONNECTORS].some(([other, others]) => other !== root && others.some(connector => connectors.includes(connector)));
      34            1 : }
      35              : 
        

Generated by: LCOV version 2.0-1