Line data Source code
1 : import * as pb from "../../proto.js";
2 : import type * as connection from '@ankoh/dashql-jsonschema/connection.js';
3 :
4 : import type { EmbeddedClientContext } from '../../platform/database/embedded_database.js';
5 : import type { HyperDatabaseConnectionContext } from './hyperdb_grpc_client.js';
6 :
7 : /// The context of the channels of a remote Hyper connection, whose queries have a client context.
8 : /// The direct gRPC Hyper connector never changes the headers it injects.
9 1 : export function hyperConnectionContext(params: connection.HyperConnectionParams, clientContext: EmbeddedClientContext | null): HyperDatabaseConnectionContext {
10 1 : return {
11 0 : getAttachedDatabases(): pb.salesforce_hyperdb_grpc_v1.pb.AttachedDatabase[] {
12 0 : return (params.attachedDatabases ?? []) as any;
13 0 : },
14 1 : async getRequestMetadata(): Promise<Record<string, string>> {
15 1 : return params.metadata ?? {};
16 1 : },
17 0 : getQueryParameters(): Record<string, string> {
18 0 : return params.queryParameters ?? {};
19 0 : },
20 1 : getClientContext(): EmbeddedClientContext | null {
21 1 : return clientContext;
22 1 : },
23 1 : };
24 1 : }
|