LCOV - code coverage report
Current view: top level - dashql-app/src/connections/hyper - hyper_connector_descriptor.ts Coverage Total Hit
Test: DashQL 915828b Lines: 100.0 % 37 37
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, HYPER_CONNECTOR } from '../connector_info.js';
       3              : import { DEFAULT_DATABASE_NAME } from '../catalog/catalog_sql_generator.js';
       4              : import { createHyperConnectionStateDetails, reduceHyperConnectorState } from './hyper_connection_state.js';
       5              : import { queryParam, requireChannel } from '../query_channel.js';
       6              : 
       7              : /// The default schema of Hyper
       8            1 : const HYPER_DEFAULT_SCHEMA = 'public';
       9              : 
      10              : /// Direct-to-Hyper connections
      11            1 : export const HYPER_CONNECTOR_DESCRIPTOR: ConnectorDescriptor<'hyper'> = {
      12            1 :     info: CONNECTOR_INFOS[ConnectorType.HYPER],
      13            1 :     paramsKey: 'hyper',
      14            1 :     detailsType: HYPER_CONNECTOR,
      15            1 :     defaultParams: () => ({ protocol: 'WASM', endpoint: '', tls: { clientKeyPath: '', clientCertPath: '', caCertsPath: '' } }),
      16            1 :     createDetails: createHyperConnectionStateDetails,
      17            1 :     reduce: reduceHyperConnectorState,
      18            1 :     withoutDraftRows: ({ draftRows: _rows, ...params }) => params,
      19            1 :     sanitizeForSharing(params) {
      20              :         // Arbitrary headers and query parameters may carry credentials under any name.
      21            1 :         const { metadata: _metadata, queryParameters: _queryParameters, ...hyper } = params;
      22            1 :         return { ...hyper, tls: { clientKeyPath: "", clientCertPath: "", caCertsPath: "" } };
      23            1 :     },
      24            1 :     loginHint: () => null,
      25              :     // The gRPC metadata stays out, its headers may carry credentials that change with every token.
      26              :     // The query parameters are session settings that may change the results.
      27            1 :     cacheSignature: params => ({
      28            1 :         case: "hyper",
      29            1 :         protocol: params.protocol,
      30            1 :         channelArgs: {
      31            1 :             endpoint: params.endpoint,
      32            1 :             tls: params.tls
      33            1 :         },
      34            1 :         attachedDatabases: (params.attachedDatabases || [])
      35            1 :             .map((d: any) => ({ path: d.path, alias: d.alias }))
      36            1 :             .sort((a: any, b: any) => a.path > b.path ? 1 : -1),
      37            1 :         queryParameters: params.queryParameters ? Object.entries(params.queryParameters).sort(([a,], [b]) => a > b ? 1 : -1) : []
      38            1 :     }),
      39            1 :     catalogNameDefaults(details) {
      40              :         // Unqualified names resolve against the first attached database
      41            1 :         const attached = details.proto.setupParams?.attachedDatabases ?? [];
      42            1 :         const databaseName = attached.length > 0 ? (attached[0].alias ?? '') : DEFAULT_DATABASE_NAME;
      43            1 :         return { databaseName, schemaName: HYPER_DEFAULT_SCHEMA };
      44            1 :     },
      45            1 :     executeQuery: (details, args, abort) => requireChannel(args.channelOverride?.type === 'hyper' ? args.channelOverride.channel : details.channel, 'Hyper')
      46            1 :         .executeQuery(queryParam(args), abort, { readTimeoutMs: args.readTimeoutMs }),
      47              :     // A Hyper server runs statements in parallel, the embedded HyperDB-WASM one at a time
      48            1 :     maxConcurrentQueries: details => details.proto?.setupParams?.protocol != null && details.proto.setupParams.protocol !== 'WASM' ? 4 : 1,
      49              :     // The embedded HyperDB-WASM database is created anew with every page load. Its functions are the builtins of
      50              :     // Hyper and stay persisted.
      51            1 :     catalogIsDurable: params => params.protocol !== 'WASM',
      52              :     // The embedded HyperDB-WASM database reads the attachments of a session from OPFS
      53            1 :     readsAttachments: details => details.proto.setupParams?.protocol === 'WASM',
      54            1 : };
        

Generated by: LCOV version 2.0-1