LCOV - code coverage report
Current view: top level - dashql-app/src/connections/trino - trino_connector_descriptor.ts Coverage Total Hit
Test: DashQL 915828b Lines: 97.6 % 42 41
Test Date: 2026-11-06 19:30:32

            Line data    Source code
       1              : import type { ConnectorDescriptor } from '../connector_descriptor.js';
       2              : import { CONNECTOR_INFOS, ConnectorType, TRINO_CONNECTOR } from '../connector_info.js';
       3              : import { createTrinoConnectionStateDetails, reduceTrinoConnectorState } from './trino_connection_state.js';
       4              : import { queryParam, requireChannel } from '../query_channel.js';
       5              : import { trinoSessionDefaults } from './trino_catalogs.js';
       6              : 
       7              : /// Trino connections
       8            1 : export const TRINO_CONNECTOR_DESCRIPTOR: ConnectorDescriptor<'trino'> = {
       9            1 :     info: CONNECTOR_INFOS[ConnectorType.TRINO],
      10            1 :     paramsKey: 'trino',
      11            1 :     detailsType: TRINO_CONNECTOR,
      12            1 :     defaultParams: () => ({ endpoint: '', catalogs: [], auth: { authType: 'AUTH_BASIC' } }),
      13            1 :     createDetails: createTrinoConnectionStateDetails,
      14            1 :     reduce: reduceTrinoConnectorState,
      15            1 :     withoutDraftRows: ({ draftRows: _rows, ...params }) => params,
      16            1 :     sanitizeForSharing(params, withLoginHint) {
      17              :         // Keep endpoint, catalogs and the basic-auth username; drop the basic-auth secret /
      18              :         // access token. OAuth params (client id + urls) carry no secret and are left as-is.
      19              :         // The basic-auth username doubles as the login hint here.
      20              :         // Arbitrary request headers may carry credentials under any name.
      21            1 :         const { metadata: _metadata, ...trino } = params;
      22            1 :         return {
      23            1 :             ...trino,
      24            1 :             auth: {
      25            1 :                 ...trino.auth,
      26            1 :                 ...(trino.auth?.basic ? { basic: { ...trino.auth.basic, secret: "", ...(withLoginHint ? {} : { username: "" }) } } : {}),
      27            1 :             },
      28            1 :         };
      29            1 :     },
      30            1 :     loginHint: params => params.auth?.basic?.username || null,
      31              :     // The credentials and the user stay out, a new token or another login reuses the cached results
      32            1 :     cacheSignature: params => ({
      33            1 :         case: "trino",
      34            1 :         endpoint: params.endpoint,
      35            1 :         auth: {
      36            1 :             authType: params.auth?.authType,
      37            1 :             oauthAuthUrl: params.auth?.oauth?.authorizationUrl,
      38            1 :             oauthTokenUrl: params.auth?.oauth?.tokenUrl,
      39            1 :             oauthRedirectUrl: params.auth?.oauth?.callbackUrl,
      40            1 :             oauthClientId: params.auth?.oauth?.clientId,
      41            1 :             oauthScopes: params.auth?.oauth?.scopes,
      42            1 :         },
      43              :         // The defaults resolve the names that statements leave out, the catalogs only decide what the catalog loader reads
      44            1 :         defaults: trinoSessionDefaults(params),
      45            1 :     }),
      46              :     // The relations of statements get the defaults of the requests
      47            1 :     catalogNameDefaults: details => {
      48            1 :         const defaults = details.proto.setupParams ? trinoSessionDefaults(details.proto.setupParams) : null;
      49            1 :         return { databaseName: defaults?.catalog ?? '', schemaName: defaults?.schema ?? '' };
      50            1 :     },
      51            1 :     executeQuery: (details, args, abort) => requireChannel(args.channelOverride?.type === 'trino' ? args.channelOverride.channel : details.channel, 'Trino')
      52            0 :         .executeQuery(queryParam(args), abort),
      53            1 :     maxConcurrentQueries: () => 1,
      54            1 :     catalogIsDurable: () => true,
      55            1 :     readsAttachments: () => false,
      56            1 : };
        

Generated by: LCOV version 2.0-1