@databricks/sql 1.0.0 → 1.1.1
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 +16 -1
- package/dist/DBSQLClient.d.ts +1 -1
- package/dist/DBSQLClient.js +18 -4
- package/dist/DBSQLClient.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.js +2 -3
- package/dist/DBSQLOperation/index.js.map +1 -1
- package/dist/connection/connections/HttpConnection.js +2 -2
- package/dist/connection/connections/HttpConnection.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -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/node_modules/async-limiter/.eslintignore +2 -0
- package/node_modules/async-limiter/.nycrc +10 -0
- package/node_modules/async-limiter/.travis.yml +9 -0
- package/node_modules/async-limiter/LICENSE +8 -0
- package/node_modules/async-limiter/index.js +67 -0
- package/node_modules/async-limiter/package.json +39 -0
- package/node_modules/async-limiter/readme.md +132 -0
- package/node_modules/browser-or-node/LICENSE +21 -0
- package/node_modules/browser-or-node/README.md +63 -0
- package/node_modules/browser-or-node/lib/index.js +31 -0
- package/node_modules/browser-or-node/package.json +64 -0
- package/node_modules/browser-or-node/src/index.js +26 -0
- package/node_modules/isomorphic-ws/LICENSE +21 -0
- package/node_modules/isomorphic-ws/README.md +58 -0
- package/node_modules/isomorphic-ws/browser.js +17 -0
- package/node_modules/isomorphic-ws/index.d.ts +8 -0
- package/node_modules/isomorphic-ws/node.js +3 -0
- package/node_modules/isomorphic-ws/package.json +38 -0
- package/node_modules/node-int64/.npmignore +3 -0
- package/node_modules/node-int64/Int64.js +268 -0
- package/node_modules/node-int64/LICENSE +19 -0
- package/node_modules/node-int64/README.md +78 -0
- package/node_modules/node-int64/package.json +31 -0
- package/node_modules/node-int64/test.js +120 -0
- package/node_modules/q/CHANGES.md +800 -0
- package/node_modules/q/LICENSE +18 -0
- package/node_modules/q/README.md +874 -0
- package/node_modules/q/package.json +80 -0
- package/node_modules/q/q.js +2076 -0
- package/node_modules/q/queue.js +35 -0
- package/node_modules/thrift/LICENSE +306 -0
- package/node_modules/thrift/README.md +210 -0
- package/node_modules/thrift/lib/nodejs/README.md +142 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/binary.js +168 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/binary_protocol.js +367 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/browser.js +49 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/buffered_transport.js +186 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/compact_protocol.js +915 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/connection.js +396 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/create_client.js +54 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/framed_transport.js +185 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/header_protocol.js +258 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/header_transport.js +341 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/http_connection.js +282 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/index.js +76 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/input_buffer_underrun_error.js +32 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/int64_util.js +91 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/json_parse.js +299 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/json_protocol.js +799 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/log.js +87 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/multiplexed_processor.js +63 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/multiplexed_protocol.js +73 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/protocol.js +22 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/server.js +123 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/thrift.js +241 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/transport.js +22 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/web_server.js +567 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/ws_connection.js +286 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/ws_transport.js +206 -0
- package/node_modules/thrift/lib/nodejs/lib/thrift/xhr_connection.js +280 -0
- package/node_modules/thrift/package.json +76 -0
- package/node_modules/ws/LICENSE +21 -0
- package/node_modules/ws/README.md +417 -0
- package/node_modules/ws/index.js +9 -0
- package/node_modules/ws/lib/buffer-util.js +72 -0
- package/node_modules/ws/lib/constants.js +10 -0
- package/node_modules/ws/lib/event-target.js +170 -0
- package/node_modules/ws/lib/extension.js +211 -0
- package/node_modules/ws/lib/permessage-deflate.js +516 -0
- package/node_modules/ws/lib/receiver.js +513 -0
- package/node_modules/ws/lib/sender.js +401 -0
- package/node_modules/ws/lib/validation.js +29 -0
- package/node_modules/ws/lib/websocket-server.js +369 -0
- package/node_modules/ws/lib/websocket.js +828 -0
- package/node_modules/ws/package.json +48 -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
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
# Release History
|
|
2
2
|
|
|
3
|
-
## 1.
|
|
3
|
+
## 1.x (Unreleased)
|
|
4
|
+
|
|
5
|
+
## 1.1.1
|
|
6
|
+
|
|
7
|
+
- Fix: patch needed for improved error handling wasn't applied when installing 1.1.0
|
|
8
|
+
|
|
9
|
+
## 1.1.0
|
|
10
|
+
|
|
11
|
+
- Fix: now library will not attempt to parse column names and will use ones provided by server
|
|
12
|
+
(databricks/databricks-sql-nodejs#84)
|
|
13
|
+
- Better error handling: more errors can now be handled in specific `.catch()` handlers instead of being
|
|
14
|
+
emitted as a generic `error` event (databricks/databricks-sql-nodejs#99)
|
|
15
|
+
- Fixed error logging bug (attempt to serialize circular structures) (databricks/databricks-sql-nodejs#89)
|
|
16
|
+
- Fixed some minor bugs and regressions
|
|
17
|
+
|
|
18
|
+
## 1.0.0
|
|
4
19
|
|
|
5
20
|
- `DBSQLClient.openSession` now takes a limited set of options (`OpenSessionRequest` instead of Thrift's `TOpenSessionReq`)
|
|
6
21
|
- `DBSQLClient.openSession` now uses the latest protocol version by default
|
package/dist/DBSQLClient.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient {
|
|
|
11
11
|
private authProvider;
|
|
12
12
|
private logger;
|
|
13
13
|
private thrift;
|
|
14
|
-
constructor(options
|
|
14
|
+
constructor(options?: ClientOptions);
|
|
15
15
|
private getConnectionOptions;
|
|
16
16
|
/**
|
|
17
17
|
* Connects DBSQLClient to endpoint
|
package/dist/DBSQLClient.js
CHANGED
|
@@ -38,6 +38,12 @@ const utils_1 = require("./utils");
|
|
|
38
38
|
const PlainHttpAuthentication_1 = __importDefault(require("./connection/auth/PlainHttpAuthentication"));
|
|
39
39
|
const IDBSQLLogger_1 = require("./contracts/IDBSQLLogger");
|
|
40
40
|
const DBSQLLogger_1 = __importDefault(require("./DBSQLLogger"));
|
|
41
|
+
function prependSlash(str) {
|
|
42
|
+
if (str.length > 0 && str.charAt(0) !== '/') {
|
|
43
|
+
return `/${str}`;
|
|
44
|
+
}
|
|
45
|
+
return str;
|
|
46
|
+
}
|
|
41
47
|
function getInitialNamespaceOptions(catalogName, schemaName) {
|
|
42
48
|
if (!catalogName && !schemaName) {
|
|
43
49
|
return {};
|
|
@@ -62,11 +68,11 @@ class DBSQLClient extends events_1.EventEmitter {
|
|
|
62
68
|
this.logger.log(IDBSQLLogger_1.LogLevel.info, 'Created DBSQLClient');
|
|
63
69
|
}
|
|
64
70
|
getConnectionOptions(options) {
|
|
65
|
-
const { host, port, token, clientId } = options, otherOptions = __rest(options, ["host", "port", "token", "clientId"]);
|
|
71
|
+
const { host, port, path, token, clientId } = options, otherOptions = __rest(options, ["host", "port", "path", "token", "clientId"]);
|
|
66
72
|
return {
|
|
67
73
|
host,
|
|
68
74
|
port: port || 443,
|
|
69
|
-
options: Object.assign({ https: true }, otherOptions),
|
|
75
|
+
options: Object.assign({ path: prependSlash(path), https: true }, otherOptions),
|
|
70
76
|
};
|
|
71
77
|
}
|
|
72
78
|
/**
|
|
@@ -89,8 +95,16 @@ class DBSQLClient extends events_1.EventEmitter {
|
|
|
89
95
|
this.connection = yield this.connectionProvider.connect(this.getConnectionOptions(options), this.authProvider);
|
|
90
96
|
this.client = this.thrift.createClient(TCLIService_1.default, this.connection.getConnection());
|
|
91
97
|
this.connection.getConnection().on('error', (error) => {
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
// Error.stack already contains error type and message, so log stack if available,
|
|
99
|
+
// otherwise fall back to just error type + message
|
|
100
|
+
this.logger.log(IDBSQLLogger_1.LogLevel.error, error.stack || `${error.name}: ${error.message}`);
|
|
101
|
+
try {
|
|
102
|
+
this.emit('error', error);
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
// EventEmitter will throw unhandled error when emitting 'error' event.
|
|
106
|
+
// Since we already logged it few lines above, just suppress this behaviour
|
|
107
|
+
}
|
|
94
108
|
});
|
|
95
109
|
this.connection.getConnection().on('reconnecting', (params) => {
|
|
96
110
|
this.logger.log(IDBSQLLogger_1.LogLevel.debug, `Reconnecting, params: ${JSON.stringify(params)}`);
|
package/dist/DBSQLClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DBSQLClient.js","sourceRoot":"","sources":["../lib/DBSQLClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA4B;AAE5B,mCAAsC;AACtC,wEAAgD;AAChD,mEAA+D;AAE/D,mEAA2C;AAC3C,wCAAqC;AACrC,kEAA0C;AAK1C,kGAA0E;AAC1E,6FAAqE;AAErE,4EAAoD;AACpD,+EAAuD;AACvD,mCAA+D;AAC/D,wGAAgF;AAChF,2DAAkE;AAClE,gEAAwC;AAExC,SAAS,0BAA0B,CAAC,WAAoB,EAAE,UAAmB;IAC3E,IAAI,CAAC,WAAW,IAAI,CAAC,UAAU,EAAE;QAC/B,OAAO,EAAE,CAAC;KACX;IAED,OAAO;QACL,gBAAgB,EAAE;YAChB,WAAW;YACX,UAAU;SACX;KACF,CAAC;AACJ,CAAC;AAED,MAAqB,WAAY,SAAQ,qBAAY;IAenD,YAAY,
|
|
1
|
+
{"version":3,"file":"DBSQLClient.js","sourceRoot":"","sources":["../lib/DBSQLClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA4B;AAE5B,mCAAsC;AACtC,wEAAgD;AAChD,mEAA+D;AAE/D,mEAA2C;AAC3C,wCAAqC;AACrC,kEAA0C;AAK1C,kGAA0E;AAC1E,6FAAqE;AAErE,4EAAoD;AACpD,+EAAuD;AACvD,mCAA+D;AAC/D,wGAAgF;AAChF,2DAAkE;AAClE,gEAAwC;AAExC,SAAS,YAAY,CAAC,GAAW;IAC/B,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QAC3C,OAAO,IAAI,GAAG,EAAE,CAAC;KAClB;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,0B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C,CAAC;IACP,CAAC;IAED,SAAS;QACP,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,yBAAe,CAAC,wCAAwC,CAAC,CAAC;SACrE;QAED,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC1B;QAED,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;QAEzD,IAAI,OAAO,gBAAgB,CAAC,GAAG,KAAK,UAAU,EAAE;YAC9C,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,CAAC;SACvC;QAED,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF;AA1ID,8BA0IC"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { TOperationHandle, TGetResultSetMetadataResp } from '../../thrift/TCLIService_types';
|
|
2
2
|
import HiveDriver from '../hive/HiveDriver';
|
|
3
|
+
import IOperationResult from '../result/IOperationResult';
|
|
3
4
|
export default class SchemaHelper {
|
|
4
5
|
private driver;
|
|
5
6
|
private operationHandle;
|
|
6
7
|
private statusFactory;
|
|
7
|
-
private metadata
|
|
8
|
+
private metadata?;
|
|
8
9
|
constructor(driver: HiveDriver, operationHandle: TOperationHandle, metadata?: TGetResultSetMetadataResp);
|
|
10
|
+
private fetchMetadata;
|
|
9
11
|
fetch(): Promise<import("../../thrift/TCLIService_types").TTableSchema>;
|
|
12
|
+
getResultHandler(): Promise<IOperationResult>;
|
|
10
13
|
}
|
|
@@ -12,17 +12,19 @@ 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 TCLIService_types_1 = require("../../thrift/TCLIService_types");
|
|
15
16
|
const StatusFactory_1 = __importDefault(require("../factory/StatusFactory"));
|
|
17
|
+
const JsonResult_1 = __importDefault(require("../result/JsonResult"));
|
|
18
|
+
const HiveDriverError_1 = __importDefault(require("../errors/HiveDriverError"));
|
|
16
19
|
const utils_1 = require("../utils");
|
|
17
20
|
class SchemaHelper {
|
|
18
21
|
constructor(driver, operationHandle, metadata) {
|
|
19
22
|
this.statusFactory = new StatusFactory_1.default();
|
|
20
|
-
this.metadata = null;
|
|
21
23
|
this.driver = driver;
|
|
22
24
|
this.operationHandle = operationHandle;
|
|
23
|
-
this.metadata = metadata
|
|
25
|
+
this.metadata = metadata;
|
|
24
26
|
}
|
|
25
|
-
|
|
27
|
+
fetchMetadata() {
|
|
26
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
29
|
if (!this.metadata) {
|
|
28
30
|
const metadata = yield this.driver.getResultSetMetadata({
|
|
@@ -31,7 +33,26 @@ class SchemaHelper {
|
|
|
31
33
|
this.statusFactory.create(metadata.status);
|
|
32
34
|
this.metadata = metadata;
|
|
33
35
|
}
|
|
34
|
-
return
|
|
36
|
+
return this.metadata;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
fetch() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const metadata = yield this.fetchMetadata();
|
|
42
|
+
return (0, utils_1.definedOrError)(metadata.schema);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
getResultHandler() {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const metadata = yield this.fetchMetadata();
|
|
48
|
+
const schema = (0, utils_1.definedOrError)(metadata.schema);
|
|
49
|
+
const resultFormat = (0, utils_1.definedOrError)(metadata.resultFormat);
|
|
50
|
+
switch (resultFormat) {
|
|
51
|
+
case TCLIService_types_1.TSparkRowSetType.COLUMN_BASED_SET:
|
|
52
|
+
return new JsonResult_1.default(schema);
|
|
53
|
+
default:
|
|
54
|
+
throw new HiveDriverError_1.default(`Unsupported result format: ${TCLIService_types_1.TSparkRowSetType[resultFormat]}`);
|
|
55
|
+
}
|
|
35
56
|
});
|
|
36
57
|
}
|
|
37
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaHelper.js","sourceRoot":"","sources":["../../lib/DBSQLOperation/SchemaHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"SchemaHelper.js","sourceRoot":"","sources":["../../lib/DBSQLOperation/SchemaHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sEAA+G;AAE/G,6EAAqD;AAErD,sEAA8C;AAC9C,gFAAwD;AACxD,oCAA0C;AAE1C,MAAqB,YAAY;IAS/B,YAAY,MAAkB,EAAE,eAAiC,EAAE,QAAoC;QAJ/F,kBAAa,GAAG,IAAI,uBAAa,EAAE,CAAC;QAK1C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEa,aAAa;;YACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAClB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;oBACtD,eAAe,EAAE,IAAI,CAAC,eAAe;iBACtC,CAAC,CAAC;gBACH,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;gBAC3C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;aAC1B;YAED,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;KAAA;IAEK,KAAK;;YACT,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;YAC5C,OAAO,IAAA,sBAAc,EAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACzC,CAAC;KAAA;IAEK,gBAAgB;;YACpB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;YAC5C,MAAM,MAAM,GAAG,IAAA,sBAAc,EAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC/C,MAAM,YAAY,GAAG,IAAA,sBAAc,EAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;YAE3D,QAAQ,YAAY,EAAE;gBACpB,KAAK,oCAAgB,CAAC,gBAAgB;oBACpC,OAAO,IAAI,oBAAU,CAAC,MAAM,CAAC,CAAC;gBAChC;oBACE,MAAM,IAAI,yBAAe,CAAC,8BAA8B,oCAAgB,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;aAC7F;QACH,CAAC;KAAA;CACF;AA5CD,+BA4CC"}
|
|
@@ -13,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const uuid_1 = require("uuid");
|
|
16
|
-
const getResult_1 = __importDefault(require("./getResult"));
|
|
17
16
|
const OperationStatusHelper_1 = __importDefault(require("./OperationStatusHelper"));
|
|
18
17
|
const SchemaHelper_1 = __importDefault(require("./SchemaHelper"));
|
|
19
18
|
const FetchResultsHelper_1 = __importDefault(require("./FetchResultsHelper"));
|
|
@@ -72,9 +71,9 @@ class DBSQLOperation {
|
|
|
72
71
|
return [];
|
|
73
72
|
}
|
|
74
73
|
yield this._status.waitUntilReady(options);
|
|
75
|
-
return Promise.all([this._schema.
|
|
74
|
+
return Promise.all([this._schema.getResultHandler(), this._data.fetch((options === null || options === void 0 ? void 0 : options.maxRows) || defaultMaxRows)]).then(([resultHandler, data]) => {
|
|
76
75
|
var _a;
|
|
77
|
-
const result =
|
|
76
|
+
const result = resultHandler.getValue(data ? [data] : []);
|
|
78
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()}`);
|
|
79
78
|
return Promise.resolve(result);
|
|
80
79
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/DBSQLOperation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+BAA6C;AAW7C,
|
|
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,EAC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AAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;KAAA;IAEK,WAAW;;YACf,IAAI,IAAI,CAAC,kBAAkB,CAAC,MAAM,IAAI,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE;gBACvE,OAAO,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"}
|
|
@@ -56,7 +56,7 @@ class HttpConnection {
|
|
|
56
56
|
}
|
|
57
57
|
addCookieHandler() {
|
|
58
58
|
const { responseCallback } = this.connection;
|
|
59
|
-
this.connection.responseCallback = (response) => {
|
|
59
|
+
this.connection.responseCallback = (response, ...rest) => {
|
|
60
60
|
if (Array.isArray(response.headers['set-cookie'])) {
|
|
61
61
|
const cookie = [this.connection.nodeOptions.headers.cookie];
|
|
62
62
|
this.connection.nodeOptions.headers.cookie = cookie
|
|
@@ -64,7 +64,7 @@ class HttpConnection {
|
|
|
64
64
|
.filter(Boolean)
|
|
65
65
|
.join(';');
|
|
66
66
|
}
|
|
67
|
-
responseCallback.call(this.connection, response);
|
|
67
|
+
responseCallback.call(this.connection, response, ...rest);
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpConnection.js","sourceRoot":"","sources":["../../../l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AC;IACzB,CAAC;IAED,WAAW;QACT,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,OAAO,IAAI,CAAC;SACb;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,cAAc,CAAC,OAAgB;QACrC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QACnD,MAAM,WAAW,GAAgB,EAAE,CAAC;QAEpC,IAAI,EAAE,EAAE;YACN,WAAW,CAAC,EAAE,GAAG,EAAE,CAAC;SACrB;QACD,IAAI,IAAI,EAAE;YACR,WAAW,CAAC,IAAI,GAAG,IAAI,CAAC;SACzB;QACD,IAAI,GAAG,EAAE;YACP,WAAW,CAAC,GAAG,GAAG,GAAG,CAAC;SACvB;QAED,IAAI,QAAQ,EAAE;YACZ,WAAW,CAAC,kBAAkB,GAAG,KAAK,CAAC;SACxC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAEO,gBAAgB;QACtB,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC;QAE7C,IAAI,CAAC,UAAU,CAAC,gBAAgB,GAAG,CAAC,QAAyB,EAAE,EAAE;
|
|
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;IAmF1B,CAAC;IA/EC,OAAO,CAAC,OAA2B,EAAE,YAA6B;;QAChE,MAAM,YAAY,GAAsB;YACtC,SAAS,EAAE,IAAI;YACf,UAAU,EAAE,CAAC;YACb,cAAc,EAAE,KAAK;SACtB,CAAC;QAEF,MAAM,KAAK,GAAG,CAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,KAAK;YAClC,CAAC,CAAC,IAAI,eAAK,CAA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zB;QACD,IAAI,GAAG,EAAE;YACP,WAAW,CAAC,GAAG,GAAG,GAAG,CAAC;SACvB;QAED,IAAI,QAAQ,EAAE;YACZ,WAAW,CAAC,kBAAkB,GAAG,KAAK,CAAC;SACxC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAEO,gBAAgB;QACtB,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC;QAE7C,IAAI,CAAC,UAAU,CAAC,gBAAgB,GAAG,CAAC,QAAyB,EAAE,GAAG,IAAoB,EAAE,EAAE;YACxF,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE;gBACjD,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBAE5D,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,GAAG,MAAM;qBAChD,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;qBACtC,MAAM,CAAC,OAAO,CAAC;qBACf,IAAI,CAAC,GAAG,CAAC,CAAC;aACd;YAED,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC;QAC5D,CAAC,CAAC;IACJ,CAAC;CACF;AApFD,iCAoFC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Thrift } from 'thrift';
|
|
1
2
|
import TCLIService from '../thrift/TCLIService';
|
|
2
3
|
import TCLIService_types from '../thrift/TCLIService_types';
|
|
3
4
|
import DBSQLClient from './DBSQLClient';
|
|
@@ -12,6 +13,8 @@ export declare const auth: {
|
|
|
12
13
|
NoSaslAuthentication: typeof NoSaslAuthentication;
|
|
13
14
|
PlainHttpAuthentication: typeof PlainHttpAuthentication;
|
|
14
15
|
};
|
|
16
|
+
declare const TException: typeof Thrift.TException, TApplicationException: typeof Thrift.TApplicationException, TApplicationExceptionType: typeof Thrift.TApplicationExceptionType, TProtocolException: typeof Thrift.TProtocolException, TProtocolExceptionType: typeof Thrift.TProtocolExceptionType;
|
|
17
|
+
export { TException, TApplicationException, TApplicationExceptionType, TProtocolException, TProtocolExceptionType };
|
|
15
18
|
export declare const connections: {
|
|
16
19
|
HttpConnection: typeof HttpConnection;
|
|
17
20
|
};
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.LogLevel = exports.DBSQLLogger = exports.DBSQLSession = exports.DBSQLClient = exports.utils = exports.thrift = exports.connections = exports.auth = void 0;
|
|
6
|
+
exports.LogLevel = exports.DBSQLLogger = exports.DBSQLSession = exports.DBSQLClient = exports.utils = exports.thrift = exports.connections = exports.TProtocolExceptionType = exports.TProtocolException = exports.TApplicationExceptionType = exports.TApplicationException = exports.TException = exports.auth = void 0;
|
|
7
|
+
const thrift_1 = require("thrift");
|
|
7
8
|
const TCLIService_1 = __importDefault(require("../thrift/TCLIService"));
|
|
8
9
|
const TCLIService_types_1 = __importDefault(require("../thrift/TCLIService_types"));
|
|
9
10
|
const DBSQLClient_1 = __importDefault(require("./DBSQLClient"));
|
|
@@ -22,6 +23,12 @@ exports.auth = {
|
|
|
22
23
|
NoSaslAuthentication: NoSaslAuthentication_1.default,
|
|
23
24
|
PlainHttpAuthentication: PlainHttpAuthentication_1.default,
|
|
24
25
|
};
|
|
26
|
+
const { TException, TApplicationException, TApplicationExceptionType, TProtocolException, TProtocolExceptionType } = thrift_1.Thrift;
|
|
27
|
+
exports.TException = TException;
|
|
28
|
+
exports.TApplicationException = TApplicationException;
|
|
29
|
+
exports.TApplicationExceptionType = TApplicationExceptionType;
|
|
30
|
+
exports.TProtocolException = TProtocolException;
|
|
31
|
+
exports.TProtocolExceptionType = TProtocolExceptionType;
|
|
25
32
|
exports.connections = {
|
|
26
33
|
HttpConnection: HttpConnection_1.default,
|
|
27
34
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;AAAA,wEAAgD;AAChD,oFAA4D;AAC5D,gEAAwC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAgC;AAChC,wEAAgD;AAChD,oFAA4D;AAC5D,gEAAwC;AAgC/B,sBAhCF,qBAAW,CAgCE;AA/BpB,kEAA0C;AA+BpB,uBA/Bf,sBAAY,CA+Be;AA9BlC,gEAAwC;AA8BJ,sBA9B7B,qBAAW,CA8B6B;AA7B/C,kGAA0E;AAC1E,wGAAgF;AAChF,6FAAqE;AACrE,mCAAyC;AACzC,2DAAoD;AAyBH,yFAzBxC,uBAAQ,OAyBwC;AAvB5C,QAAA,IAAI,GAAG;IAClB,oBAAoB,EAApB,8BAAoB;IACpB,uBAAuB,EAAvB,iCAAuB;CACxB,CAAC;AAEF,MAAM,EAAE,UAAU,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,GAChH,eAAM,CAAC;AAEA,gCAAU;AAAE,sDAAqB;AAAE,8DAAyB;AAAE,gDAAkB;AAAE,wDAAsB;AAEpG,QAAA,WAAW,GAAG;IACzB,cAAc,EAAd,wBAAc;CACf,CAAC;AAEW,QAAA,MAAM,GAAG;IACpB,WAAW,EAAX,qBAAW;IACX,iBAAiB,EAAjB,2BAAiB;CAClB,CAAC;AAEW,QAAA,KAAK,GAAG;IACnB,cAAc,EAAd,sBAAc;CACf,CAAC"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { TRowSet, TTableSchema } from '../../thrift/TCLIService_types';
|
|
2
2
|
import IOperationResult from './IOperationResult';
|
|
3
3
|
export default class JsonResult implements IOperationResult {
|
|
4
|
-
private readonly schema
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
getValue(): Array<object>;
|
|
4
|
+
private readonly schema?;
|
|
5
|
+
constructor(schema?: TTableSchema);
|
|
6
|
+
getValue(data?: Array<TRowSet>): Array<object>;
|
|
8
7
|
private getSchemaColumns;
|
|
9
8
|
private getRows;
|
|
10
9
|
private getSchemaValues;
|
|
11
|
-
private getColumnName;
|
|
12
10
|
private convertData;
|
|
13
11
|
private isNull;
|
|
14
12
|
private toJSON;
|
|
@@ -3,16 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const Types_1 = require("../hive/Types");
|
|
4
4
|
const TCLIService_types_1 = require("../../thrift/TCLIService_types");
|
|
5
5
|
class JsonResult {
|
|
6
|
-
constructor(schema
|
|
6
|
+
constructor(schema) {
|
|
7
7
|
this.schema = schema;
|
|
8
|
-
this.data = data;
|
|
9
8
|
}
|
|
10
|
-
getValue() {
|
|
11
|
-
if (!
|
|
9
|
+
getValue(data) {
|
|
10
|
+
if (!data) {
|
|
12
11
|
return [];
|
|
13
12
|
}
|
|
14
13
|
const descriptors = this.getSchemaColumns();
|
|
15
|
-
return
|
|
14
|
+
return data.reduce((result, rowSet) => {
|
|
16
15
|
const columns = rowSet.columns || [];
|
|
17
16
|
const rows = this.getRows(columns, descriptors);
|
|
18
17
|
return result.concat(rows);
|
|
@@ -29,8 +28,8 @@ class JsonResult {
|
|
|
29
28
|
if (!result[i]) {
|
|
30
29
|
result[i] = {};
|
|
31
30
|
}
|
|
32
|
-
const
|
|
33
|
-
result[i][
|
|
31
|
+
const { columnName } = descriptor;
|
|
32
|
+
result[i][columnName] = value;
|
|
34
33
|
return result;
|
|
35
34
|
}, rows), []);
|
|
36
35
|
}
|
|
@@ -48,10 +47,6 @@ class JsonResult {
|
|
|
48
47
|
return this.convertData(typeDescriptor, value);
|
|
49
48
|
});
|
|
50
49
|
}
|
|
51
|
-
getColumnName(column) {
|
|
52
|
-
const name = column.columnName || '';
|
|
53
|
-
return name.split('.').pop() || '';
|
|
54
|
-
}
|
|
55
50
|
convertData(typeDescriptor, value) {
|
|
56
51
|
if (!typeDescriptor) {
|
|
57
52
|
return value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonResult.js","sourceRoot":"","sources":["../../lib/result/JsonResult.ts"],"names":[],"mappings":";;AAAA,yCAAuD;AACvD,sEAOwC;AAGxC,MAAqB,UAAU;
|
|
1
|
+
{"version":3,"file":"JsonResult.js","sourceRoot":"","sources":["../../lib/result/JsonResult.ts"],"names":[],"mappings":";;AAAA,yCAAuD;AACvD,sEAOwC;AAGxC,MAAqB,UAAU;IAG7B,YAAY,MAAqB;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,QAAQ,CAAC,IAAqB;QAC5B,IAAI,CAAC,IAAI,EAAE;YACT,OAAO,EAAE,CAAC;SACX;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAE5C,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,MAAkB,EAAE,MAAe,EAAE,EAAE;YACzD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;YACrC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAEhD,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;IAEO,gBAAgB;QACtB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,OAAO,EAAE,CAAC;SACX;QAED,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,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AK,CAAC;SAChB;IACH,CAAC;IAEO,MAAM,CAAC,KAAa,EAAE,CAAS;QACrC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACtC,MAAM,GAAG,GAAG,SAAA,CAAC,EAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA,CAAC;QAEzB,OAAO,CAAC,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAEO,MAAM,CAAC,KAAU,EAAE,YAAiB;QAC1C,IAAI;YACF,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SAC1B;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,YAAY,CAAC;SACrB;IACH,CAAC;IAEO,aAAa,CAAC,KAAU;QAC9B,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;IAEO,cAAc,CAAC,MAAe;QACpC,OAAO,CACL,MAAM,CAAC,kBAAU,CAAC,SAAS,CAAC;YAC5B,MAAM,CAAC,kBAAU,CAAC,OAAO,CAAC;YAC1B,MAAM,CAAC,kBAAU,CAAC,OAAO,CAAC;YAC1B,MAAM,CAAC,kBAAU,CAAC,SAAS,CAAC;YAC5B,MAAM,CAAC,kBAAU,CAAC,MAAM,CAAC;YACzB,MAAM,CAAC,kBAAU,CAAC,MAAM,CAAC;YACzB,MAAM,CAAC,kBAAU,CAAC,MAAM,CAAC;YACzB,MAAM,CAAC,kBAAU,CAAC,SAAS,CAAC,CAC7B,CAAC;IACJ,CAAC;CACF;AArID,6BAqIC"}
|
|
@@ -3,14 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
6
|
const os_1 = __importDefault(require("os"));
|
|
7
|
+
const version_1 = __importDefault(require("../version"));
|
|
9
8
|
const productName = 'NodejsDatabricksSqlConnector';
|
|
10
|
-
function getPackageVersion() {
|
|
11
|
-
const json = JSON.parse(fs_1.default.readFileSync(path_1.default.join(__dirname, '../../package.json')).toString());
|
|
12
|
-
return json.version;
|
|
13
|
-
}
|
|
14
9
|
function getNodeVersion() {
|
|
15
10
|
return `Node.js ${process.versions.node}`;
|
|
16
11
|
}
|
|
@@ -19,7 +14,7 @@ function getOperatingSystemVersion() {
|
|
|
19
14
|
}
|
|
20
15
|
function buildUserAgentString(clientId) {
|
|
21
16
|
const extra = [clientId, getNodeVersion(), getOperatingSystemVersion()].filter(Boolean);
|
|
22
|
-
return `${productName}/${
|
|
17
|
+
return `${productName}/${version_1.default} (${extra.join('; ')})`;
|
|
23
18
|
}
|
|
24
19
|
exports.default = buildUserAgentString;
|
|
25
20
|
//# sourceMappingURL=buildUserAgentString.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUserAgentString.js","sourceRoot":"","sources":["../../lib/utils/buildUserAgentString.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,
|
|
1
|
+
{"version":3,"file":"buildUserAgentString.js","sourceRoot":"","sources":["../../lib/utils/buildUserAgentString.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,yDAAwC;AAExC,MAAM,WAAW,GAAG,8BAA8B,CAAC;AAEnD,SAAS,cAAc;IACrB,OAAO,WAAW,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AAC5C,CAAC;AAED,SAAS,yBAAyB;IAChC,OAAO,GAAG,YAAE,CAAC,IAAI,EAAE,IAAI,YAAE,CAAC,OAAO,EAAE,EAAE,CAAC;AACxC,CAAC;AAED,SAAwB,oBAAoB,CAAC,QAAiB;IAC5D,MAAM,KAAK,GAAG,CAAC,QAAQ,EAAE,cAAc,EAAE,EAAE,yBAAyB,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACxF,OAAO,GAAG,WAAW,IAAI,iBAAc,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AAClE,CAAC;AAHD,uCAGC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../lib/version.ts"],"names":[],"mappings":";;AAAA,kBAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
Copyright (c) 2017 Samuel Reed <samuel.trace.reed@gmail.com>
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
|
+
|
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function Queue(options) {
|
|
4
|
+
if (!(this instanceof Queue)) {
|
|
5
|
+
return new Queue(options);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
options = options || {};
|
|
9
|
+
this.concurrency = options.concurrency || Infinity;
|
|
10
|
+
this.pending = 0;
|
|
11
|
+
this.jobs = [];
|
|
12
|
+
this.cbs = [];
|
|
13
|
+
this._done = done.bind(this);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
var arrayAddMethods = [
|
|
17
|
+
'push',
|
|
18
|
+
'unshift',
|
|
19
|
+
'splice'
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
arrayAddMethods.forEach(function(method) {
|
|
23
|
+
Queue.prototype[method] = function() {
|
|
24
|
+
var methodResult = Array.prototype[method].apply(this.jobs, arguments);
|
|
25
|
+
this._run();
|
|
26
|
+
return methodResult;
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
Object.defineProperty(Queue.prototype, 'length', {
|
|
31
|
+
get: function() {
|
|
32
|
+
return this.pending + this.jobs.length;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
Queue.prototype._run = function() {
|
|
37
|
+
if (this.pending === this.concurrency) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (this.jobs.length) {
|
|
41
|
+
var job = this.jobs.shift();
|
|
42
|
+
this.pending++;
|
|
43
|
+
job(this._done);
|
|
44
|
+
this._run();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (this.pending === 0) {
|
|
48
|
+
while (this.cbs.length !== 0) {
|
|
49
|
+
var cb = this.cbs.pop();
|
|
50
|
+
process.nextTick(cb);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
Queue.prototype.onDone = function(cb) {
|
|
56
|
+
if (typeof cb === 'function') {
|
|
57
|
+
this.cbs.push(cb);
|
|
58
|
+
this._run();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
function done() {
|
|
63
|
+
this.pending--;
|
|
64
|
+
this._run();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = Queue;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "async-limiter",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "asynchronous function queue with adjustable concurrency",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"throttle",
|
|
7
|
+
"async",
|
|
8
|
+
"limiter",
|
|
9
|
+
"asynchronous",
|
|
10
|
+
"job",
|
|
11
|
+
"task",
|
|
12
|
+
"concurrency",
|
|
13
|
+
"concurrent"
|
|
14
|
+
],
|
|
15
|
+
"dependencies": {},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"coveralls": "^3.0.3",
|
|
18
|
+
"eslint": "^5.16.0",
|
|
19
|
+
"eslint-plugin-mocha": "^5.3.0",
|
|
20
|
+
"intelli-espower-loader": "^1.0.1",
|
|
21
|
+
"mocha": "^6.1.4",
|
|
22
|
+
"nyc": "^14.1.1",
|
|
23
|
+
"power-assert": "^1.6.1"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"test": "mocha --require intelli-espower-loader test/",
|
|
27
|
+
"travis": "npm run lint && npm run test",
|
|
28
|
+
"coverage": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
|
|
29
|
+
"example": "node example",
|
|
30
|
+
"lint": "eslint ."
|
|
31
|
+
},
|
|
32
|
+
"repository": "https://github.com/strml/async-limiter.git",
|
|
33
|
+
"author": "Samuel Reed <samuel.trace.reed@gmail.com",
|
|
34
|
+
"license": "MIT"
|
|
35
|
+
|
|
36
|
+
,"_resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz"
|
|
37
|
+
,"_integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ=="
|
|
38
|
+
,"_from": "async-limiter@1.0.1"
|
|
39
|
+
}
|