@databricks/sql 0.1.8-beta.2 → 1.1.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 +28 -1
- package/README.md +1 -3
- package/dist/DBSQLClient.d.ts +18 -7
- package/dist/DBSQLClient.js +57 -16
- 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/SchemaHelper.d.ts +4 -1
- package/dist/DBSQLOperation/SchemaHelper.js +25 -4
- package/dist/DBSQLOperation/SchemaHelper.js.map +1 -1
- package/dist/DBSQLOperation/index.d.ts +27 -6
- package/dist/DBSQLOperation/index.js +54 -16
- 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 +11 -8
- 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 +6 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/result/IOperationResult.d.ts +2 -1
- package/dist/result/JsonResult.d.ts +3 -5
- package/dist/result/JsonResult.js +6 -11
- package/dist/result/JsonResult.js.map +1 -1
- package/dist/utils/buildUserAgentString.js +2 -7
- package/dist/utils/buildUserAgentString.js.map +1 -1
- package/dist/version.d.ts +2 -0
- package/dist/version.js +4 -0
- package/dist/version.js.map +1 -0
- package/package.json +9 -3
- package/dist/DBSQLOperation/getResult.d.ts +0 -2
- package/dist/DBSQLOperation/getResult.js +0 -19
- package/dist/DBSQLOperation/getResult.js.map +0 -1
- package/dist/result/NullResult.d.ts +0 -4
- package/dist/result/NullResult.js +0 -9
- package/dist/result/NullResult.js.map +0 -1
|
@@ -12,40 +12,69 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const
|
|
16
|
-
const getResult_1 = __importDefault(require("./getResult"));
|
|
15
|
+
const uuid_1 = require("uuid");
|
|
17
16
|
const OperationStatusHelper_1 = __importDefault(require("./OperationStatusHelper"));
|
|
18
17
|
const SchemaHelper_1 = __importDefault(require("./SchemaHelper"));
|
|
19
18
|
const FetchResultsHelper_1 = __importDefault(require("./FetchResultsHelper"));
|
|
20
19
|
const CompleteOperationHelper_1 = __importDefault(require("./CompleteOperationHelper"));
|
|
20
|
+
const IDBSQLLogger_1 = require("../contracts/IDBSQLLogger");
|
|
21
|
+
const defaultMaxRows = 100000;
|
|
21
22
|
class DBSQLOperation {
|
|
22
|
-
constructor(driver, operationHandle, directResults) {
|
|
23
|
+
constructor(driver, operationHandle, logger, directResults) {
|
|
23
24
|
this.driver = driver;
|
|
24
25
|
this.operationHandle = operationHandle;
|
|
26
|
+
this.logger = logger;
|
|
25
27
|
this._status = new OperationStatusHelper_1.default(this.driver, this.operationHandle, directResults === null || directResults === void 0 ? void 0 : directResults.operationStatus);
|
|
26
28
|
this._schema = new SchemaHelper_1.default(this.driver, this.operationHandle, directResults === null || directResults === void 0 ? void 0 : directResults.resultSetMetadata);
|
|
27
29
|
this._data = new FetchResultsHelper_1.default(this.driver, this.operationHandle, [directResults === null || directResults === void 0 ? void 0 : directResults.resultSet]);
|
|
28
30
|
this._completeOperation = new CompleteOperationHelper_1.default(this.driver, this.operationHandle, directResults === null || directResults === void 0 ? void 0 : directResults.closeOperation);
|
|
31
|
+
this.logger.log(IDBSQLLogger_1.LogLevel.debug, `Operation created with id: ${this.getId()}`);
|
|
29
32
|
}
|
|
33
|
+
getId() {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
return (0, uuid_1.stringify)(((_b = (_a = this.operationHandle) === null || _a === void 0 ? void 0 : _a.operationId) === null || _b === void 0 ? void 0 : _b.guid) || (0, uuid_1.parse)(uuid_1.NIL));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Fetches all data
|
|
39
|
+
* @public
|
|
40
|
+
* @param options - maxRows property can be set to limit chunk size
|
|
41
|
+
* @returns Array of data with length equal to option.maxRows
|
|
42
|
+
* @throws {StatusError}
|
|
43
|
+
* @example
|
|
44
|
+
* const result = await queryOperation.fetchAll();
|
|
45
|
+
*/
|
|
30
46
|
fetchAll(options) {
|
|
47
|
+
var _a;
|
|
31
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
49
|
const data = [];
|
|
33
50
|
do {
|
|
34
51
|
// eslint-disable-next-line no-await-in-loop
|
|
35
52
|
const chunk = yield this.fetchChunk(options);
|
|
36
|
-
data.push(
|
|
53
|
+
data.push(chunk);
|
|
37
54
|
} while (yield this.hasMoreRows()); // eslint-disable-line no-await-in-loop
|
|
38
|
-
|
|
55
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(IDBSQLLogger_1.LogLevel.debug, `Fetched all data from operation with id: ${this.getId()}`);
|
|
56
|
+
return data.flat();
|
|
39
57
|
});
|
|
40
58
|
}
|
|
41
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Fetches chunk of data
|
|
61
|
+
* @public
|
|
62
|
+
* @param options - maxRows property sets chunk size
|
|
63
|
+
* @returns Array of data with length equal to option.maxRows
|
|
64
|
+
* @throws {StatusError}
|
|
65
|
+
* @example
|
|
66
|
+
* const result = await queryOperation.fetchChunk({maxRows: 1000});
|
|
67
|
+
*/
|
|
68
|
+
fetchChunk(options) {
|
|
42
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
70
|
if (!this._status.hasResultSet) {
|
|
44
|
-
return
|
|
71
|
+
return [];
|
|
45
72
|
}
|
|
46
|
-
yield this._status.waitUntilReady(options
|
|
47
|
-
return Promise.all([this._schema.
|
|
48
|
-
|
|
73
|
+
yield this._status.waitUntilReady(options);
|
|
74
|
+
return Promise.all([this._schema.getResultHandler(), this._data.fetch((options === null || options === void 0 ? void 0 : options.maxRows) || defaultMaxRows)]).then(([resultHandler, data]) => {
|
|
75
|
+
var _a;
|
|
76
|
+
const result = resultHandler.getValue(data ? [data] : []);
|
|
77
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(IDBSQLLogger_1.LogLevel.debug, `Fetched chunk of size: ${(options === null || options === void 0 ? void 0 : options.maxRows) || defaultMaxRows} from operation with id: ${this.getId()}`);
|
|
49
78
|
return Promise.resolve(result);
|
|
50
79
|
});
|
|
51
80
|
});
|
|
@@ -56,7 +85,9 @@ class DBSQLOperation {
|
|
|
56
85
|
* @throws {StatusError}
|
|
57
86
|
*/
|
|
58
87
|
status(progress = false) {
|
|
88
|
+
var _a;
|
|
59
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(IDBSQLLogger_1.LogLevel.debug, `Fetching status for operation with id: ${this.getId()}`);
|
|
60
91
|
return this._status.status(progress);
|
|
61
92
|
});
|
|
62
93
|
}
|
|
@@ -65,6 +96,8 @@ class DBSQLOperation {
|
|
|
65
96
|
* @throws {StatusError}
|
|
66
97
|
*/
|
|
67
98
|
cancel() {
|
|
99
|
+
var _a;
|
|
100
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(IDBSQLLogger_1.LogLevel.debug, `Operation with id: ${this.getId()} canceled.`);
|
|
68
101
|
return this._completeOperation.cancel();
|
|
69
102
|
}
|
|
70
103
|
/**
|
|
@@ -72,11 +105,13 @@ class DBSQLOperation {
|
|
|
72
105
|
* @throws {StatusError}
|
|
73
106
|
*/
|
|
74
107
|
close() {
|
|
108
|
+
var _a;
|
|
109
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(IDBSQLLogger_1.LogLevel.debug, `Closing operation with id: ${this.getId()}`);
|
|
75
110
|
return this._completeOperation.close();
|
|
76
111
|
}
|
|
77
|
-
finished() {
|
|
112
|
+
finished(options) {
|
|
78
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
yield this._status.waitUntilReady();
|
|
114
|
+
yield this._status.waitUntilReady(options);
|
|
80
115
|
});
|
|
81
116
|
}
|
|
82
117
|
hasMoreRows() {
|
|
@@ -87,12 +122,15 @@ class DBSQLOperation {
|
|
|
87
122
|
return this._data.hasMoreRows;
|
|
88
123
|
});
|
|
89
124
|
}
|
|
90
|
-
getSchema() {
|
|
125
|
+
getSchema(options) {
|
|
126
|
+
var _a;
|
|
91
127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
if (this._status.hasResultSet) {
|
|
93
|
-
return
|
|
128
|
+
if (!this._status.hasResultSet) {
|
|
129
|
+
return null;
|
|
94
130
|
}
|
|
95
|
-
|
|
131
|
+
yield this._status.waitUntilReady(options);
|
|
132
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(IDBSQLLogger_1.LogLevel.debug, `Fetching schema for operation with id: ${this.getId()}`);
|
|
133
|
+
return this._schema.fetch();
|
|
96
134
|
});
|
|
97
135
|
}
|
|
98
136
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/DBSQLOperation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/DBSQLOperation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+BAA6C;AAW7C,oFAA4D;AAC5D,kEAA0C;AAC1C,8EAAsD;AACtD,wFAAgE;AAChE,4DAAmE;AAEnE,MAAM,cAAc,GAAG,MAAM,CAAC;AAE9B,MAAqB,cAAc;IAejC,YACE,MAAkB,EAClB,eAAiC,EACjC,MAAoB,EACpB,aAAmC;QAEnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,IAAI,+BAAqB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,eAAe,CAAC,CAAC;QAC5G,IAAI,CAAC,OAAO,GAAG,IAAI,sBAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,iBAAiB,CAAC,CAAC;QACrG,IAAI,CAAC,KAAK,GAAG,IAAI,4BAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,SAAS,CAAC,CAAC,CAAC;QACnG,IAAI,CAAC,kBAAkB,GAAG,IAAI,iCAAuB,CACnD,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,eAAe,EACpB,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,cAAc,CAC9B,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,uBAAQ,CAAC,KAAK,EAAE,8BAA8B,IAAI,CAAC,KAAK,EAAE,EAAE,CAA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AAO,KAAK,CAAC;aACd;YACD,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;QAChC,CAAC;KAAA;IAEK,SAAS,CAAC,OAA0B;;;YACxC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE;gBAC9B,OAAO,IAAI,CAAC;aACb;YAED,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YAC3C,MAAA,IAAI,CAAC,MAAM,0CAAE,GAAG,CAAC,uBAAQ,CAAC,KAAK,EAAE,0CAA0C,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAE3F,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;;KAC7B;CACF;AAzID,iCAyIC"}
|
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,IAA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E,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxD,CAAC;IAED;;;;OAIG;IACH,KAAK;QACH,OAAO,IAAI,CAAC,MAAM;aACf,YAAY,CAAC;YACZ,aAAa,EAAE,IAAI,CAAC,aAAa;SAClC,CAAC;aACD,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;YACjB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,uBAAQ,CAAC,KAAK,EAAE,2BAA2B,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC3E,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,eAAe,CAAC,QAAgC;QACtD,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACnC,MAAM,MAAM,GAAG,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();
|
|
@@ -53,7 +56,7 @@ class HttpConnection {
|
|
|
53
56
|
}
|
|
54
57
|
addCookieHandler() {
|
|
55
58
|
const { responseCallback } = this.connection;
|
|
56
|
-
this.connection.responseCallback = (response) => {
|
|
59
|
+
this.connection.responseCallback = (response, ...rest) => {
|
|
57
60
|
if (Array.isArray(response.headers['set-cookie'])) {
|
|
58
61
|
const cookie = [this.connection.nodeOptions.headers.cookie];
|
|
59
62
|
this.connection.nodeOptions.headers.cookie = cookie
|
|
@@ -61,7 +64,7 @@ class HttpConnection {
|
|
|
61
64
|
.filter(Boolean)
|
|
62
65
|
.join(';');
|
|
63
66
|
}
|
|
64
|
-
responseCallback.call(this.connection, response);
|
|
67
|
+
responseCallback.call(this.connection, response, ...rest);
|
|
65
68
|
};
|
|
66
69
|
}
|
|
67
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpConnection.js","sourceRoot":"","sources":["../../../lib/connection/connections/HttpConnection.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAC5B,kDAA0B;AAE1B,gDAA6C;AAK7C,gFAAwD;AASxD,MAAqB,cAAc;IAAnC;QACU,WAAM,GAAG,gBAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"HttpConnection.js","sourceRoot":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