@malloydata/db-trino 0.0.359 → 0.0.360

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -31,20 +31,37 @@ var trino_executor_1 = require("./trino_executor");
31
31
  Object.defineProperty(exports, "TrinoExecutor", { enumerable: true, get: function () { return trino_executor_1.TrinoExecutor; } });
32
32
  const malloy_1 = require("@malloydata/malloy");
33
33
  const trino_connection_2 = require("./trino_connection");
34
- function configToTrinoConfig(config) {
34
+ const trinoPassThroughKeys = [
35
+ 'ssl',
36
+ 'session',
37
+ 'extraCredential',
38
+ 'extraHeaders',
39
+ ];
40
+ function configToBaseConfig(config) {
35
41
  return {
36
- name: config.name,
37
- trinoConfig: {
38
- server: typeof config['server'] === 'string' ? config['server'] : undefined,
39
- port: typeof config['port'] === 'number' ? config['port'] : undefined,
40
- catalog: typeof config['catalog'] === 'string' ? config['catalog'] : undefined,
41
- schema: typeof config['schema'] === 'string' ? config['schema'] : undefined,
42
- user: typeof config['user'] === 'string' ? config['user'] : undefined,
43
- password: typeof config['password'] === 'string' ? config['password'] : undefined,
44
- setupSQL: typeof config['setupSQL'] === 'string' ? config['setupSQL'] : undefined,
45
- },
42
+ server: typeof config['server'] === 'string' ? config['server'] : undefined,
43
+ port: typeof config['port'] === 'number' ? config['port'] : undefined,
44
+ catalog: typeof config['catalog'] === 'string' ? config['catalog'] : undefined,
45
+ schema: typeof config['schema'] === 'string' ? config['schema'] : undefined,
46
+ user: typeof config['user'] === 'string' ? config['user'] : undefined,
47
+ password: typeof config['password'] === 'string' ? config['password'] : undefined,
48
+ setupSQL: typeof config['setupSQL'] === 'string' ? config['setupSQL'] : undefined,
49
+ source: typeof config['source'] === 'string' ? config['source'] : undefined,
46
50
  };
47
51
  }
52
+ function configToTrinoConfig(config) {
53
+ const base = configToBaseConfig(config);
54
+ const extraConfig = {};
55
+ for (const key of trinoPassThroughKeys) {
56
+ if (config[key] !== undefined) {
57
+ extraConfig[key] = config[key];
58
+ }
59
+ }
60
+ if (Object.keys(extraConfig).length > 0) {
61
+ base.extraConfig = extraConfig;
62
+ }
63
+ return base;
64
+ }
48
65
  const trinoProperties = [
49
66
  { name: 'server', displayName: 'Server', type: 'string', optional: true },
50
67
  { name: 'port', displayName: 'Port', type: 'number', optional: true },
@@ -59,21 +76,69 @@ const trinoProperties = [
59
76
  optional: true,
60
77
  description: 'SQL statements to run when the connection is established',
61
78
  },
79
+ {
80
+ name: 'source',
81
+ displayName: 'Source',
82
+ type: 'string',
83
+ optional: true,
84
+ description: 'Source name for the Trino client',
85
+ },
86
+ {
87
+ name: 'ssl',
88
+ displayName: 'SSL',
89
+ type: 'json',
90
+ optional: true,
91
+ description: 'TLS/SSL configuration (e.g. {"rejectUnauthorized": false})',
92
+ },
93
+ {
94
+ name: 'session',
95
+ displayName: 'Session',
96
+ type: 'json',
97
+ optional: true,
98
+ description: 'Session properties as key-value pairs',
99
+ },
100
+ {
101
+ name: 'extraCredential',
102
+ displayName: 'Extra Credential',
103
+ type: 'json',
104
+ optional: true,
105
+ description: 'Extra credentials as key-value pairs',
106
+ },
107
+ {
108
+ name: 'extraHeaders',
109
+ displayName: 'Extra Headers',
110
+ type: 'json',
111
+ optional: true,
112
+ description: 'Additional HTTP headers as key-value pairs',
113
+ },
114
+ ];
115
+ const prestoProperties = [
116
+ { name: 'server', displayName: 'Server', type: 'string', optional: true },
117
+ { name: 'port', displayName: 'Port', type: 'number', optional: true },
118
+ { name: 'catalog', displayName: 'Catalog', type: 'string', optional: true },
119
+ { name: 'schema', displayName: 'Schema', type: 'string', optional: true },
120
+ { name: 'user', displayName: 'User', type: 'string', optional: true },
121
+ { name: 'password', displayName: 'Password', type: 'password', optional: true },
122
+ {
123
+ name: 'setupSQL',
124
+ displayName: 'Setup SQL',
125
+ type: 'text',
126
+ optional: true,
127
+ description: 'SQL statements to run when the connection is established',
128
+ },
62
129
  ];
63
130
  (0, malloy_1.registerConnectionType)('trino', {
64
131
  displayName: 'Trino',
65
132
  factory: async (config) => {
66
- const { name, trinoConfig } = configToTrinoConfig(config);
67
- return new trino_connection_2.TrinoConnection(name, undefined, trinoConfig);
133
+ return new trino_connection_2.TrinoConnection(config.name, undefined, configToTrinoConfig(config));
68
134
  },
69
135
  properties: trinoProperties,
70
136
  });
71
137
  (0, malloy_1.registerConnectionType)('presto', {
72
138
  displayName: 'Presto',
73
139
  factory: async (config) => {
74
- const { name, trinoConfig } = configToTrinoConfig(config);
75
- return new trino_connection_2.PrestoConnection(name, undefined, trinoConfig);
140
+ return new trino_connection_2.PrestoConnection(config.name, undefined, configToBaseConfig(config));
76
141
  },
77
- properties: trinoProperties,
142
+ properties: prestoProperties,
78
143
  });
79
144
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,6 @@
1
1
  import type { ConnectionConfig, MalloyQueryData, PersistSQLResults, QueryData, QueryOptionsReader, QueryRunStats, RunSQLOptions, StructDef, TableSourceDef, SQLSourceDef, AtomicTypeDef, Dialect, FieldDef, TestableConnection, SQLSourceRequest } from '@malloydata/malloy';
2
2
  import { TrinoDialect } from '@malloydata/malloy';
3
3
  import { BaseConnection } from '@malloydata/malloy/connection';
4
- import type { ConnectionOptions } from 'trino-client';
5
4
  export interface TrinoManagerOptions {
6
5
  credentials?: {
7
6
  clientId: string;
@@ -11,6 +10,7 @@ export interface TrinoManagerOptions {
11
10
  projectId?: string | undefined;
12
11
  userAgent: string;
13
12
  }
13
+ export type TrinoExtraConfigKey = 'ssl' | 'session' | 'extraCredential' | 'extraHeaders';
14
14
  export interface TrinoConnectionConfiguration {
15
15
  server?: string;
16
16
  port?: number;
@@ -19,7 +19,8 @@ export interface TrinoConnectionConfiguration {
19
19
  user?: string;
20
20
  password?: string;
21
21
  setupSQL?: string;
22
- extraConfig?: Partial<Omit<ConnectionOptions, keyof TrinoConnectionConfiguration>>;
22
+ source?: string;
23
+ extraConfig?: Partial<Record<TrinoExtraConfigKey, unknown>>;
23
24
  }
24
25
  export type TrinoConnectionOptions = ConnectionConfig;
25
26
  export interface BaseRunner {
@@ -89,6 +89,7 @@ class TrinoRunner {
89
89
  }
90
90
  this.client = trino_client_1.Trino.create({
91
91
  ...config.extraConfig,
92
+ source: config.source,
92
93
  catalog: config.catalog,
93
94
  server,
94
95
  schema: config.schema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/db-trino",
3
- "version": "0.0.359",
3
+ "version": "0.0.360",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "prepublishOnly": "npm run build"
23
23
  },
24
24
  "dependencies": {
25
- "@malloydata/malloy": "0.0.359",
25
+ "@malloydata/malloy": "0.0.360",
26
26
  "@prestodb/presto-js-client": "^1.0.0",
27
27
  "gaxios": "^4.2.0",
28
28
  "luxon": "^3.5.0",