@databricks/sql 0.1.8-beta.2 → 1.0.0
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/CHANGELOG.md +17 -1
- package/README.md +1 -3
- package/dist/DBSQLClient.d.ts +18 -7
- package/dist/DBSQLClient.js +40 -13
- package/dist/DBSQLClient.js.map +1 -1
- package/dist/DBSQLLogger.d.ts +12 -0
- package/dist/DBSQLLogger.js +43 -0
- package/dist/DBSQLLogger.js.map +1 -0
- package/dist/DBSQLOperation/FetchResultsHelper.d.ts +1 -1
- package/dist/DBSQLOperation/FetchResultsHelper.js +1 -1
- package/dist/DBSQLOperation/FetchResultsHelper.js.map +1 -1
- package/dist/DBSQLOperation/OperationStatusHelper.d.ts +3 -3
- package/dist/DBSQLOperation/OperationStatusHelper.js +8 -8
- package/dist/DBSQLOperation/OperationStatusHelper.js.map +1 -1
- package/dist/DBSQLOperation/index.d.ts +27 -6
- package/dist/DBSQLOperation/index.js +53 -14
- package/dist/DBSQLOperation/index.js.map +1 -1
- package/dist/DBSQLSession.d.ts +82 -12
- package/dist/DBSQLSession.js +114 -112
- package/dist/DBSQLSession.js.map +1 -1
- package/dist/connection/connections/HttpConnection.js +9 -6
- package/dist/connection/connections/HttpConnection.js.map +1 -1
- package/dist/contracts/IDBSQLClient.d.ts +11 -4
- package/dist/contracts/IDBSQLLogger.d.ts +13 -0
- package/dist/contracts/IDBSQLLogger.js +11 -0
- package/dist/contracts/IDBSQLLogger.js.map +1 -0
- package/dist/contracts/IDBSQLSession.d.ts +53 -41
- package/dist/contracts/IOperation.d.ts +15 -12
- package/dist/contracts/IOperation.js +0 -4
- package/dist/contracts/IOperation.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/dist/DBSQLSession.d.ts
CHANGED
|
@@ -1,28 +1,98 @@
|
|
|
1
1
|
import { TSessionHandle } from '../thrift/TCLIService_types';
|
|
2
2
|
import HiveDriver from './hive/HiveDriver';
|
|
3
|
-
import IDBSQLSession, { ExecuteStatementOptions, SchemasRequest, TablesRequest,
|
|
3
|
+
import IDBSQLSession, { ExecuteStatementOptions, TypeInfoRequest, CatalogsRequest, SchemasRequest, TablesRequest, TableTypesRequest, ColumnsRequest, FunctionsRequest, PrimaryKeysRequest, CrossReferenceRequest } from './contracts/IDBSQLSession';
|
|
4
4
|
import IOperation from './contracts/IOperation';
|
|
5
5
|
import Status from './dto/Status';
|
|
6
6
|
import InfoValue from './dto/InfoValue';
|
|
7
|
+
import IDBSQLLogger from './contracts/IDBSQLLogger';
|
|
7
8
|
export default class DBSQLSession implements IDBSQLSession {
|
|
8
9
|
private driver;
|
|
9
10
|
private sessionHandle;
|
|
10
11
|
private statusFactory;
|
|
11
|
-
|
|
12
|
+
private logger;
|
|
13
|
+
constructor(driver: HiveDriver, sessionHandle: TSessionHandle, logger: IDBSQLLogger);
|
|
14
|
+
getId(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Fetches info
|
|
17
|
+
* @public
|
|
18
|
+
* @param infoType - One of the values TCLIService_types.TGetInfoType
|
|
19
|
+
* @returns Value corresponding to info type requested
|
|
20
|
+
* @example
|
|
21
|
+
* const response = await session.getInfo(thrift.TCLIService_types.TGetInfoType.CLI_DBMS_VER);
|
|
22
|
+
*/
|
|
12
23
|
getInfo(infoType: number): Promise<InfoValue>;
|
|
24
|
+
/**
|
|
25
|
+
* Executes statement
|
|
26
|
+
* @public
|
|
27
|
+
* @param statement - SQL statement to be executed
|
|
28
|
+
* @param options - maxRows field is used to specify Direct Results
|
|
29
|
+
* @returns DBSQLOperation
|
|
30
|
+
* @example
|
|
31
|
+
* const operation = await session.executeStatement(query, { runAsync: true });
|
|
32
|
+
*/
|
|
13
33
|
executeStatement(statement: string, options?: ExecuteStatementOptions): Promise<IOperation>;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Information about supported data types
|
|
36
|
+
* @public
|
|
37
|
+
* @param request
|
|
38
|
+
* @returns DBSQLOperation
|
|
39
|
+
*/
|
|
40
|
+
getTypeInfo(request?: TypeInfoRequest): Promise<IOperation>;
|
|
41
|
+
/**
|
|
42
|
+
* Get list of catalogs
|
|
43
|
+
* @public
|
|
44
|
+
* @param request
|
|
45
|
+
* @returns DBSQLOperation
|
|
46
|
+
*/
|
|
47
|
+
getCatalogs(request?: CatalogsRequest): Promise<IOperation>;
|
|
48
|
+
/**
|
|
49
|
+
* Get list of schemas
|
|
50
|
+
* @public
|
|
51
|
+
* @param request
|
|
52
|
+
* @returns DBSQLOperation
|
|
53
|
+
*/
|
|
54
|
+
getSchemas(request?: SchemasRequest): Promise<IOperation>;
|
|
55
|
+
/**
|
|
56
|
+
* Get list of tables
|
|
57
|
+
* @public
|
|
58
|
+
* @param request
|
|
59
|
+
* @returns DBSQLOperation
|
|
60
|
+
*/
|
|
61
|
+
getTables(request?: TablesRequest): Promise<IOperation>;
|
|
62
|
+
/**
|
|
63
|
+
* Get list of supported table types
|
|
64
|
+
* @public
|
|
65
|
+
* @param request
|
|
66
|
+
* @returns DBSQLOperation
|
|
67
|
+
*/
|
|
68
|
+
getTableTypes(request?: TableTypesRequest): Promise<IOperation>;
|
|
69
|
+
/**
|
|
70
|
+
* Get full information about columns of the table
|
|
71
|
+
* @public
|
|
72
|
+
* @param request
|
|
73
|
+
* @returns DBSQLOperation
|
|
74
|
+
*/
|
|
75
|
+
getColumns(request?: ColumnsRequest): Promise<IOperation>;
|
|
76
|
+
/**
|
|
77
|
+
* Get information about function
|
|
78
|
+
* @public
|
|
79
|
+
* @param request
|
|
80
|
+
* @returns DBSQLOperation
|
|
81
|
+
*/
|
|
82
|
+
getFunctions(request: FunctionsRequest): Promise<IOperation>;
|
|
21
83
|
getPrimaryKeys(request: PrimaryKeysRequest): Promise<IOperation>;
|
|
84
|
+
/**
|
|
85
|
+
* Request information about foreign keys between two tables
|
|
86
|
+
* @public
|
|
87
|
+
* @param request
|
|
88
|
+
* @returns DBSQLOperation
|
|
89
|
+
*/
|
|
22
90
|
getCrossReference(request: CrossReferenceRequest): Promise<IOperation>;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Closes the session
|
|
93
|
+
* @public
|
|
94
|
+
* @returns Operation status
|
|
95
|
+
*/
|
|
26
96
|
close(): Promise<Status>;
|
|
27
97
|
private createOperation;
|
|
28
98
|
private assertStatus;
|
package/dist/DBSQLSession.js
CHANGED
|
@@ -1,30 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const uuid_1 = require("uuid");
|
|
17
7
|
const Types_1 = require("./hive/Types");
|
|
18
8
|
const DBSQLOperation_1 = __importDefault(require("./DBSQLOperation"));
|
|
19
9
|
const StatusFactory_1 = __importDefault(require("./factory/StatusFactory"));
|
|
20
10
|
const InfoValue_1 = __importDefault(require("./dto/InfoValue"));
|
|
21
11
|
const utils_1 = require("./utils");
|
|
12
|
+
const IDBSQLLogger_1 = require("./contracts/IDBSQLLogger");
|
|
13
|
+
const defaultMaxRows = 100000;
|
|
14
|
+
function getDirectResultsOptions(maxRows = defaultMaxRows) {
|
|
15
|
+
if (maxRows === null) {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
getDirectResults: {
|
|
20
|
+
maxRows: new Types_1.Int64(maxRows),
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
22
24
|
class DBSQLSession {
|
|
23
|
-
constructor(driver, sessionHandle) {
|
|
25
|
+
constructor(driver, sessionHandle, logger) {
|
|
24
26
|
this.driver = driver;
|
|
25
27
|
this.sessionHandle = sessionHandle;
|
|
26
28
|
this.statusFactory = new StatusFactory_1.default();
|
|
27
|
-
|
|
29
|
+
this.logger = logger;
|
|
30
|
+
this.logger.log(IDBSQLLogger_1.LogLevel.debug, `Session created with id: ${this.getId()}`);
|
|
31
|
+
}
|
|
32
|
+
getId() {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
return (0, uuid_1.stringify)(((_b = (_a = this.sessionHandle) === null || _a === void 0 ? void 0 : _a.sessionId) === null || _b === void 0 ? void 0 : _b.guid) || (0, uuid_1.parse)(uuid_1.NIL));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Fetches info
|
|
38
|
+
* @public
|
|
39
|
+
* @param infoType - One of the values TCLIService_types.TGetInfoType
|
|
40
|
+
* @returns Value corresponding to info type requested
|
|
41
|
+
* @example
|
|
42
|
+
* const response = await session.getInfo(thrift.TCLIService_types.TGetInfoType.CLI_DBMS_VER);
|
|
43
|
+
*/
|
|
28
44
|
getInfo(infoType) {
|
|
29
45
|
return this.driver
|
|
30
46
|
.getInfo({
|
|
@@ -36,146 +52,132 @@ class DBSQLSession {
|
|
|
36
52
|
return new InfoValue_1.default(response.infoValue);
|
|
37
53
|
});
|
|
38
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Executes statement
|
|
57
|
+
* @public
|
|
58
|
+
* @param statement - SQL statement to be executed
|
|
59
|
+
* @param options - maxRows field is used to specify Direct Results
|
|
60
|
+
* @returns DBSQLOperation
|
|
61
|
+
* @example
|
|
62
|
+
* const operation = await session.executeStatement(query, { runAsync: true });
|
|
63
|
+
*/
|
|
39
64
|
executeStatement(statement, options = {}) {
|
|
40
|
-
const { maxRows } = options, restOptions = __rest(options, ["maxRows"]);
|
|
41
|
-
const request = Object.assign(Object.assign({ runAsync: false }, restOptions), { sessionHandle: this.sessionHandle, statement });
|
|
42
|
-
if (maxRows) {
|
|
43
|
-
request.getDirectResults = {
|
|
44
|
-
maxRows: new Types_1.Int64(maxRows),
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return this.driver.executeStatement(request).then((response) => this.createOperation(response));
|
|
48
|
-
}
|
|
49
|
-
getTypeInfo() {
|
|
50
65
|
return this.driver
|
|
51
|
-
.
|
|
52
|
-
sessionHandle: this.sessionHandle,
|
|
53
|
-
})
|
|
66
|
+
.executeStatement(Object.assign({ sessionHandle: this.sessionHandle, statement, queryTimeout: options.queryTimeout, runAsync: options.runAsync || false }, getDirectResultsOptions(options.maxRows)))
|
|
54
67
|
.then((response) => this.createOperation(response));
|
|
55
68
|
}
|
|
56
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Information about supported data types
|
|
71
|
+
* @public
|
|
72
|
+
* @param request
|
|
73
|
+
* @returns DBSQLOperation
|
|
74
|
+
*/
|
|
75
|
+
getTypeInfo(request = {}) {
|
|
57
76
|
return this.driver
|
|
58
|
-
.
|
|
59
|
-
sessionHandle: this.sessionHandle,
|
|
60
|
-
})
|
|
77
|
+
.getTypeInfo(Object.assign({ sessionHandle: this.sessionHandle, runAsync: request.runAsync || false }, getDirectResultsOptions(request.maxRows)))
|
|
61
78
|
.then((response) => this.createOperation(response));
|
|
62
79
|
}
|
|
63
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Get list of catalogs
|
|
82
|
+
* @public
|
|
83
|
+
* @param request
|
|
84
|
+
* @returns DBSQLOperation
|
|
85
|
+
*/
|
|
86
|
+
getCatalogs(request = {}) {
|
|
64
87
|
return this.driver
|
|
65
|
-
.
|
|
66
|
-
sessionHandle: this.sessionHandle,
|
|
67
|
-
catalogName: request.catalogName,
|
|
68
|
-
schemaName: request.schemaName,
|
|
69
|
-
})
|
|
88
|
+
.getCatalogs(Object.assign({ sessionHandle: this.sessionHandle, runAsync: request.runAsync || false }, getDirectResultsOptions(request.maxRows)))
|
|
70
89
|
.then((response) => this.createOperation(response));
|
|
71
90
|
}
|
|
72
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Get list of schemas
|
|
93
|
+
* @public
|
|
94
|
+
* @param request
|
|
95
|
+
* @returns DBSQLOperation
|
|
96
|
+
*/
|
|
97
|
+
getSchemas(request = {}) {
|
|
73
98
|
return this.driver
|
|
74
|
-
.
|
|
75
|
-
sessionHandle: this.sessionHandle,
|
|
76
|
-
catalogName: request.catalogName,
|
|
77
|
-
schemaName: request.schemaName,
|
|
78
|
-
tableName: request.tableName,
|
|
79
|
-
tableTypes: request.tableTypes,
|
|
80
|
-
})
|
|
99
|
+
.getSchemas(Object.assign({ sessionHandle: this.sessionHandle, catalogName: request.catalogName, schemaName: request.schemaName, runAsync: request.runAsync || false }, getDirectResultsOptions(request.maxRows)))
|
|
81
100
|
.then((response) => this.createOperation(response));
|
|
82
101
|
}
|
|
83
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Get list of tables
|
|
104
|
+
* @public
|
|
105
|
+
* @param request
|
|
106
|
+
* @returns DBSQLOperation
|
|
107
|
+
*/
|
|
108
|
+
getTables(request = {}) {
|
|
84
109
|
return this.driver
|
|
85
|
-
.
|
|
86
|
-
sessionHandle: this.sessionHandle,
|
|
87
|
-
})
|
|
110
|
+
.getTables(Object.assign({ sessionHandle: this.sessionHandle, catalogName: request.catalogName, schemaName: request.schemaName, tableName: request.tableName, tableTypes: request.tableTypes, runAsync: request.runAsync || false }, getDirectResultsOptions(request.maxRows)))
|
|
88
111
|
.then((response) => this.createOperation(response));
|
|
89
112
|
}
|
|
90
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Get list of supported table types
|
|
115
|
+
* @public
|
|
116
|
+
* @param request
|
|
117
|
+
* @returns DBSQLOperation
|
|
118
|
+
*/
|
|
119
|
+
getTableTypes(request = {}) {
|
|
91
120
|
return this.driver
|
|
92
|
-
.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
121
|
+
.getTableTypes(Object.assign({ sessionHandle: this.sessionHandle, runAsync: request.runAsync || false }, getDirectResultsOptions(request.maxRows)))
|
|
122
|
+
.then((response) => this.createOperation(response));
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get full information about columns of the table
|
|
126
|
+
* @public
|
|
127
|
+
* @param request
|
|
128
|
+
* @returns DBSQLOperation
|
|
129
|
+
*/
|
|
130
|
+
getColumns(request = {}) {
|
|
131
|
+
return this.driver
|
|
132
|
+
.getColumns(Object.assign({ sessionHandle: this.sessionHandle, catalogName: request.catalogName, schemaName: request.schemaName, tableName: request.tableName, columnName: request.columnName, runAsync: request.runAsync || false }, getDirectResultsOptions(request.maxRows)))
|
|
99
133
|
.then((response) => this.createOperation(response));
|
|
100
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Get information about function
|
|
137
|
+
* @public
|
|
138
|
+
* @param request
|
|
139
|
+
* @returns DBSQLOperation
|
|
140
|
+
*/
|
|
101
141
|
getFunctions(request) {
|
|
102
142
|
return this.driver
|
|
103
|
-
.getFunctions({
|
|
104
|
-
sessionHandle: this.sessionHandle,
|
|
105
|
-
functionName: request.functionName,
|
|
106
|
-
schemaName: request.schemaName,
|
|
107
|
-
catalogName: request.catalogName,
|
|
108
|
-
})
|
|
143
|
+
.getFunctions(Object.assign({ sessionHandle: this.sessionHandle, catalogName: request.catalogName, schemaName: request.schemaName, functionName: request.functionName, runAsync: request.runAsync || false }, getDirectResultsOptions(request.maxRows)))
|
|
109
144
|
.then((response) => this.createOperation(response));
|
|
110
145
|
}
|
|
111
146
|
getPrimaryKeys(request) {
|
|
112
147
|
return this.driver
|
|
113
|
-
.getPrimaryKeys({
|
|
114
|
-
sessionHandle: this.sessionHandle,
|
|
115
|
-
catalogName: request.catalogName,
|
|
116
|
-
schemaName: request.schemaName,
|
|
117
|
-
tableName: request.tableName,
|
|
118
|
-
})
|
|
148
|
+
.getPrimaryKeys(Object.assign({ sessionHandle: this.sessionHandle, catalogName: request.catalogName, schemaName: request.schemaName, tableName: request.tableName, runAsync: request.runAsync || false }, getDirectResultsOptions(request.maxRows)))
|
|
119
149
|
.then((response) => this.createOperation(response));
|
|
120
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Request information about foreign keys between two tables
|
|
153
|
+
* @public
|
|
154
|
+
* @param request
|
|
155
|
+
* @returns DBSQLOperation
|
|
156
|
+
*/
|
|
121
157
|
getCrossReference(request) {
|
|
122
158
|
return this.driver
|
|
123
|
-
.getCrossReference({
|
|
124
|
-
sessionHandle: this.sessionHandle,
|
|
125
|
-
parentCatalogName: request.parentCatalogName,
|
|
126
|
-
parentSchemaName: request.parentSchemaName,
|
|
127
|
-
parentTableName: request.parentTableName,
|
|
128
|
-
foreignCatalogName: request.foreignCatalogName,
|
|
129
|
-
foreignSchemaName: request.foreignSchemaName,
|
|
130
|
-
foreignTableName: request.foreignTableName,
|
|
131
|
-
})
|
|
159
|
+
.getCrossReference(Object.assign({ sessionHandle: this.sessionHandle, parentCatalogName: request.parentCatalogName, parentSchemaName: request.parentSchemaName, parentTableName: request.parentTableName, foreignCatalogName: request.foreignCatalogName, foreignSchemaName: request.foreignSchemaName, foreignTableName: request.foreignTableName, runAsync: request.runAsync || false }, getDirectResultsOptions(request.maxRows)))
|
|
132
160
|
.then((response) => this.createOperation(response));
|
|
133
161
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
})
|
|
141
|
-
.then((response) => {
|
|
142
|
-
this.assertStatus(response.status);
|
|
143
|
-
return response.delegationToken || '';
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
renewDelegationToken(token) {
|
|
147
|
-
return this.driver
|
|
148
|
-
.renewDelegationToken({
|
|
149
|
-
sessionHandle: this.sessionHandle,
|
|
150
|
-
delegationToken: token,
|
|
151
|
-
})
|
|
152
|
-
.then((response) => {
|
|
153
|
-
this.assertStatus(response.status);
|
|
154
|
-
return this.statusFactory.create(response.status);
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
cancelDelegationToken(token) {
|
|
162
|
+
/**
|
|
163
|
+
* Closes the session
|
|
164
|
+
* @public
|
|
165
|
+
* @returns Operation status
|
|
166
|
+
*/
|
|
167
|
+
close() {
|
|
158
168
|
return this.driver
|
|
159
|
-
.
|
|
169
|
+
.closeSession({
|
|
160
170
|
sessionHandle: this.sessionHandle,
|
|
161
|
-
delegationToken: token,
|
|
162
171
|
})
|
|
163
172
|
.then((response) => {
|
|
164
|
-
this.
|
|
173
|
+
this.logger.log(IDBSQLLogger_1.LogLevel.debug, `Session closed with id: ${this.getId()}`);
|
|
165
174
|
return this.statusFactory.create(response.status);
|
|
166
175
|
});
|
|
167
176
|
}
|
|
168
|
-
close() {
|
|
169
|
-
return this.driver
|
|
170
|
-
.closeSession({
|
|
171
|
-
sessionHandle: this.sessionHandle,
|
|
172
|
-
})
|
|
173
|
-
.then((response) => this.statusFactory.create(response.status));
|
|
174
|
-
}
|
|
175
177
|
createOperation(response) {
|
|
176
178
|
this.assertStatus(response.status);
|
|
177
179
|
const handle = (0, utils_1.definedOrError)(response.operationHandle);
|
|
178
|
-
return new DBSQLOperation_1.default(this.driver, handle, response.directResults);
|
|
180
|
+
return new DBSQLOperation_1.default(this.driver, handle, this.logger, response.directResults);
|
|
179
181
|
}
|
|
180
182
|
assertStatus(responseStatus) {
|
|
181
183
|
this.statusFactory.create(responseStatus);
|
package/dist/DBSQLSession.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DBSQLSession.js","sourceRoot":"","sources":["../lib/DBSQLSession.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DBSQLSession.js","sourceRoot":"","sources":["../lib/DBSQLSession.ts"],"names":[],"mappings":";;;;;AAAA,+BAA6C;AAG7C,wCAAqC;AAcrC,sEAA8C;AAE9C,4EAAoD;AACpD,gEAAwC;AACxC,mCAAyC;AACzC,2DAAkE;AAElE,MAAM,cAAc,GAAG,MAAM,CAAC;AAQ9B,SAAS,uBAAuB,CAAC,UAAyB,cAAc;IACtE,IAAI,OAAO,KAAK,IAAI,EAAE;QACpB,OAAO,EAAE,CAAC;KACX;IAED,OAAO;QACL,gBAAgB,EAAE;YAChB,OAAO,EAAE,IAAI,aAAK,CAAC,OAAO,CAAC;SAC5B;KACF,CAAC;AACJ,CAAC;AAED,MAAqB,YAAY;IAS/B,YAAY,MAAkB,EAAE,aAA6B,EAAE,MAAoB;QACjF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,IAAI,uBAAa,EAAE,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,uBAAQ,CAAC,KAAK,EAAE,4BAA4B,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED,KAAK;;QACH,OAAO,IAAA,gBAAS,EAAC,CAAA,MAAA,MAAA,IAAI,CAAC,aAAa,0CAAE,SAAS,0CAAE,IAAI,KAAI,IAAA,YAAK,EAAC,UAAG,CAAC,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,QAAgB;QACtB,OAAO,IAAI,CAAC,MAAM;aACf,OAAO,CAAC;YACP,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,QAAQ;SACT,CAAC;aAC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AAG,IAAA,sBAAc,EAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QACxD,OAAO,IAAI,wBAAc,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IACtF,CAAC;IAEO,YAAY,CAAC,cAAuB;QAC1C,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAC5C,CAAC;CACF;AAxPD,+BAwPC"}
|
|
@@ -13,12 +13,15 @@ class HttpConnection {
|
|
|
13
13
|
}
|
|
14
14
|
connect(options, authProvider) {
|
|
15
15
|
var _a, _b;
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
const agentOptions = {
|
|
17
|
+
keepAlive: true,
|
|
18
|
+
maxSockets: 5,
|
|
19
|
+
keepAliveMsecs: 10000,
|
|
20
|
+
};
|
|
21
|
+
const agent = ((_a = options.options) === null || _a === void 0 ? void 0 : _a.https)
|
|
22
|
+
? new https_1.default.Agent(Object.assign(Object.assign({}, agentOptions), { minVersion: 'TLSv1.2' }))
|
|
23
|
+
: new http_1.default.Agent(agentOptions);
|
|
24
|
+
const httpTransport = new HttpTransport_1.default(Object.assign(Object.assign({ transport: thrift_1.default.TBufferedTransport, protocol: thrift_1.default.TBinaryProtocol }, options.options), { nodeOptions: Object.assign(Object.assign({ agent }, this.getNodeOptions(options.options || {})), (((_b = options.options) === null || _b === void 0 ? void 0 : _b.nodeOptions) || {})) }));
|
|
22
25
|
return authProvider.authenticate(httpTransport).then(() => {
|
|
23
26
|
this.connection = this.thrift.createHttpConnection(options.host, options.port, httpTransport.getOptions());
|
|
24
27
|
this.addCookieHandler();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpConnection.js","sourceRoot":"","sources":["../../../lib/connection/connections/HttpConnection.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;A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;qBACtC,MAAM,CAAC,OAAO,CAAC;qBACf,IAAI,CAAC,GAAG,CAAC,CAAC;aACd;YAED,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACnD,CAAC,CAAC;IACJ,CAAC;CACF;AApFD,iCAoFC"}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import IDBSQLLogger from './IDBSQLLogger';
|
|
2
2
|
import IDBSQLSession from './IDBSQLSession';
|
|
3
|
-
export interface
|
|
3
|
+
export interface ClientOptions {
|
|
4
|
+
logger?: IDBSQLLogger;
|
|
5
|
+
}
|
|
6
|
+
export interface ConnectionOptions {
|
|
4
7
|
host: string;
|
|
5
8
|
port?: number;
|
|
6
9
|
path: string;
|
|
7
10
|
token: string;
|
|
8
11
|
clientId?: string;
|
|
9
12
|
}
|
|
13
|
+
export interface OpenSessionRequest {
|
|
14
|
+
initialCatalog?: string;
|
|
15
|
+
initialSchema?: string;
|
|
16
|
+
}
|
|
10
17
|
export default interface IDBSQLClient {
|
|
11
|
-
connect(options:
|
|
12
|
-
openSession(request?:
|
|
18
|
+
connect(options: ConnectionOptions): Promise<IDBSQLClient>;
|
|
19
|
+
openSession(request?: OpenSessionRequest): Promise<IDBSQLSession>;
|
|
13
20
|
close(): Promise<void>;
|
|
14
21
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface LoggerOptions {
|
|
2
|
+
filepath?: string;
|
|
3
|
+
level?: LogLevel;
|
|
4
|
+
}
|
|
5
|
+
export default interface IDBSQLLogger {
|
|
6
|
+
log(level: LogLevel, message: string): void;
|
|
7
|
+
}
|
|
8
|
+
export declare enum LogLevel {
|
|
9
|
+
error = "error",
|
|
10
|
+
warn = "warn",
|
|
11
|
+
info = "info",
|
|
12
|
+
debug = "debug"
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogLevel = void 0;
|
|
4
|
+
var LogLevel;
|
|
5
|
+
(function (LogLevel) {
|
|
6
|
+
LogLevel["error"] = "error";
|
|
7
|
+
LogLevel["warn"] = "warn";
|
|
8
|
+
LogLevel["info"] = "info";
|
|
9
|
+
LogLevel["debug"] = "debug";
|
|
10
|
+
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
|
|
11
|
+
//# sourceMappingURL=IDBSQLLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IDBSQLLogger.js","sourceRoot":"","sources":["../../lib/contracts/IDBSQLLogger.ts"],"names":[],"mappings":";;;AASA,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,2BAAe,CAAA;IACf,yBAAa,CAAA;IACb,yBAAa,CAAA;IACb,2BAAe,CAAA;AACjB,CAAC,EALW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAKnB"}
|