@databricks/sql 1.1.1 → 1.2.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/README.md +2 -2
- package/dist/DBSQLClient.d.ts +5 -4
- package/dist/DBSQLClient.js +28 -26
- package/dist/DBSQLClient.js.map +1 -1
- package/dist/DBSQLOperation/CompleteOperationHelper.d.ts +3 -3
- package/dist/DBSQLOperation/CompleteOperationHelper.js +12 -17
- package/dist/DBSQLOperation/CompleteOperationHelper.js.map +1 -1
- package/dist/DBSQLOperation/FetchResultsHelper.d.ts +4 -5
- package/dist/DBSQLOperation/FetchResultsHelper.js +16 -12
- package/dist/DBSQLOperation/FetchResultsHelper.js.map +1 -1
- package/dist/DBSQLOperation/OperationStatusHelper.d.ts +2 -3
- package/dist/DBSQLOperation/OperationStatusHelper.js +12 -12
- package/dist/DBSQLOperation/OperationStatusHelper.js.map +1 -1
- package/dist/DBSQLOperation/SchemaHelper.d.ts +3 -4
- package/dist/DBSQLOperation/SchemaHelper.js +6 -5
- package/dist/DBSQLOperation/SchemaHelper.js.map +1 -1
- package/dist/DBSQLOperation/index.d.ts +7 -7
- package/dist/DBSQLOperation/index.js +18 -11
- package/dist/DBSQLOperation/index.js.map +1 -1
- package/dist/DBSQLSession.d.ts +3 -5
- package/dist/DBSQLSession.js +82 -49
- package/dist/DBSQLSession.js.map +1 -1
- package/dist/connection/auth/NoSaslAuthentication.js +0 -1
- package/dist/connection/auth/NoSaslAuthentication.js.map +1 -1
- package/dist/connection/auth/PlainHttpAuthentication.d.ts +1 -1
- package/dist/connection/auth/PlainHttpAuthentication.js +1 -1
- package/dist/connection/auth/PlainHttpAuthentication.js.map +1 -1
- package/dist/connection/contracts/IConnectionOptions.d.ts +1 -1
- package/dist/connection/contracts/ITransport.d.ts +1 -8
- package/dist/connection/transports/HttpTransport.d.ts +0 -6
- package/dist/connection/transports/HttpTransport.js +0 -6
- package/dist/connection/transports/HttpTransport.js.map +1 -1
- package/dist/connection/types/AuthOptions.d.ts +1 -1
- package/dist/contracts/IDBSQLSession.d.ts +10 -10
- package/dist/contracts/IOperation.d.ts +1 -1
- package/dist/dto/InfoValue.d.ts +1 -1
- package/dist/dto/Status.d.ts +9 -13
- package/dist/dto/Status.js +31 -10
- package/dist/dto/Status.js.map +1 -1
- package/dist/globalConfig.d.ts +5 -0
- package/dist/globalConfig.js +7 -0
- package/dist/globalConfig.js.map +1 -0
- package/dist/hive/Types/index.d.ts +1 -1
- package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/http_connection.js +2 -0
- package/{node_modules → dist/node_modules}/thrift/package.json +1 -5
- package/dist/result/ArrowResult.d.ts +14 -0
- package/dist/result/ArrowResult.js +105 -0
- package/dist/result/ArrowResult.js.map +1 -0
- package/dist/result/JsonResult.d.ts +1 -5
- package/dist/result/JsonResult.js +8 -59
- package/dist/result/JsonResult.js.map +1 -1
- package/dist/result/utils.d.ts +3 -0
- package/dist/result/utils.js +77 -0
- package/dist/result/utils.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +10 -11
- package/CHANGELOG.md +0 -60
- package/dist/factory/StatusFactory.d.ts +0 -12
- package/dist/factory/StatusFactory.js +0 -35
- package/dist/factory/StatusFactory.js.map +0 -1
- package/node_modules/async-limiter/.eslintignore +0 -2
- package/node_modules/async-limiter/.nycrc +0 -10
- package/node_modules/async-limiter/.travis.yml +0 -9
- package/node_modules/async-limiter/LICENSE +0 -8
- package/node_modules/async-limiter/index.js +0 -67
- package/node_modules/async-limiter/package.json +0 -39
- package/node_modules/async-limiter/readme.md +0 -132
- package/node_modules/browser-or-node/LICENSE +0 -21
- package/node_modules/browser-or-node/README.md +0 -63
- package/node_modules/browser-or-node/lib/index.js +0 -31
- package/node_modules/browser-or-node/package.json +0 -64
- package/node_modules/browser-or-node/src/index.js +0 -26
- package/node_modules/isomorphic-ws/LICENSE +0 -21
- package/node_modules/isomorphic-ws/README.md +0 -58
- package/node_modules/isomorphic-ws/browser.js +0 -17
- package/node_modules/isomorphic-ws/index.d.ts +0 -8
- package/node_modules/isomorphic-ws/node.js +0 -3
- package/node_modules/isomorphic-ws/package.json +0 -38
- package/node_modules/node-int64/.npmignore +0 -3
- package/node_modules/node-int64/Int64.js +0 -268
- package/node_modules/node-int64/LICENSE +0 -19
- package/node_modules/node-int64/README.md +0 -78
- package/node_modules/node-int64/package.json +0 -31
- package/node_modules/node-int64/test.js +0 -120
- package/node_modules/q/CHANGES.md +0 -800
- package/node_modules/q/LICENSE +0 -18
- package/node_modules/q/README.md +0 -874
- package/node_modules/q/package.json +0 -80
- package/node_modules/q/q.js +0 -2076
- package/node_modules/q/queue.js +0 -35
- package/node_modules/ws/LICENSE +0 -21
- package/node_modules/ws/README.md +0 -417
- package/node_modules/ws/index.js +0 -9
- package/node_modules/ws/lib/buffer-util.js +0 -72
- package/node_modules/ws/lib/constants.js +0 -10
- package/node_modules/ws/lib/event-target.js +0 -170
- package/node_modules/ws/lib/extension.js +0 -211
- package/node_modules/ws/lib/permessage-deflate.js +0 -516
- package/node_modules/ws/lib/receiver.js +0 -513
- package/node_modules/ws/lib/sender.js +0 -401
- package/node_modules/ws/lib/validation.js +0 -29
- package/node_modules/ws/lib/websocket-server.js +0 -369
- package/node_modules/ws/lib/websocket.js +0 -828
- package/node_modules/ws/package.json +0 -48
- /package/{node_modules → dist/node_modules}/thrift/LICENSE +0 -0
- /package/{node_modules → dist/node_modules}/thrift/README.md +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/README.md +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/binary.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/binary_protocol.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/browser.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/buffered_transport.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/compact_protocol.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/connection.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/create_client.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/framed_transport.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/header_protocol.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/header_transport.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/index.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/input_buffer_underrun_error.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/int64_util.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/json_parse.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/json_protocol.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/log.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/multiplexed_processor.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/multiplexed_protocol.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/protocol.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/server.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/thrift.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/transport.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/web_server.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/ws_connection.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/ws_transport.js +0 -0
- /package/{node_modules → dist/node_modules}/thrift/lib/nodejs/lib/thrift/xhr_connection.js +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Buffer } from 'buffer';
|
|
3
|
+
import { TRowSet, TTableSchema } from '../../thrift/TCLIService_types';
|
|
4
|
+
import IOperationResult from './IOperationResult';
|
|
5
|
+
export default class ArrowResult implements IOperationResult {
|
|
6
|
+
private readonly schema;
|
|
7
|
+
private readonly arrowSchema?;
|
|
8
|
+
constructor(schema?: TTableSchema, arrowSchema?: Buffer);
|
|
9
|
+
getValue(data?: Array<TRowSet>): any[];
|
|
10
|
+
private getBatches;
|
|
11
|
+
private getRows;
|
|
12
|
+
private convertArrowTypes;
|
|
13
|
+
private convertThriftTypes;
|
|
14
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const buffer_1 = require("buffer");
|
|
4
|
+
const apache_arrow_1 = require("apache-arrow");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
const { isArrowBigNumSymbol, bignumToBigInt } = apache_arrow_1.util;
|
|
7
|
+
class ArrowResult {
|
|
8
|
+
constructor(schema, arrowSchema) {
|
|
9
|
+
this.schema = (0, utils_1.getSchemaColumns)(schema);
|
|
10
|
+
this.arrowSchema = arrowSchema;
|
|
11
|
+
}
|
|
12
|
+
getValue(data) {
|
|
13
|
+
if (this.schema.length === 0 || !this.arrowSchema || !data) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
const batches = this.getBatches(data);
|
|
17
|
+
if (batches.length === 0) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
const table = (0, apache_arrow_1.tableFromIPC)([this.arrowSchema, ...batches]);
|
|
21
|
+
return this.getRows(table.schema, table.toArray());
|
|
22
|
+
}
|
|
23
|
+
getBatches(data) {
|
|
24
|
+
const result = [];
|
|
25
|
+
data.forEach((rowSet) => {
|
|
26
|
+
var _a;
|
|
27
|
+
(_a = rowSet.arrowBatches) === null || _a === void 0 ? void 0 : _a.forEach((arrowBatch) => {
|
|
28
|
+
if (arrowBatch.batch) {
|
|
29
|
+
result.push(arrowBatch.batch);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
getRows(schema, rows) {
|
|
36
|
+
return rows.map((row) => {
|
|
37
|
+
// First, convert native Arrow values to corresponding plain JS objects
|
|
38
|
+
const record = this.convertArrowTypes(row, undefined, schema.fields);
|
|
39
|
+
// Second, cast all the values to original Thrift types
|
|
40
|
+
return this.convertThriftTypes(record);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
convertArrowTypes(value, valueType, fields = []) {
|
|
44
|
+
var _a;
|
|
45
|
+
const fieldsMap = {};
|
|
46
|
+
for (const field of fields) {
|
|
47
|
+
fieldsMap[field.name] = field;
|
|
48
|
+
}
|
|
49
|
+
// Convert structures to plain JS object and process all its fields recursively
|
|
50
|
+
if (value instanceof apache_arrow_1.StructRow) {
|
|
51
|
+
const result = value.toJSON();
|
|
52
|
+
for (const key of Object.keys(result)) {
|
|
53
|
+
const field = fieldsMap[key];
|
|
54
|
+
result[key] = this.convertArrowTypes(result[key], field === null || field === void 0 ? void 0 : field.type, (field === null || field === void 0 ? void 0 : field.type.children) || []);
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
if (value instanceof apache_arrow_1.MapRow) {
|
|
59
|
+
const result = value.toJSON();
|
|
60
|
+
// Map type consists of its key and value types. We need only value type here, key will be cast to string anyway
|
|
61
|
+
const field = (_a = fieldsMap.entries) === null || _a === void 0 ? void 0 : _a.type.children.find((item) => item.name === 'value');
|
|
62
|
+
for (const key of Object.keys(result)) {
|
|
63
|
+
result[key] = this.convertArrowTypes(result[key], field === null || field === void 0 ? void 0 : field.type, (field === null || field === void 0 ? void 0 : field.type.children) || []);
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
// Convert lists to JS array and process items recursively
|
|
68
|
+
if (value instanceof apache_arrow_1.Vector) {
|
|
69
|
+
const result = value.toJSON();
|
|
70
|
+
// Array type contains the only child which defines a type of each array's element
|
|
71
|
+
const field = fieldsMap.element;
|
|
72
|
+
return result.map((item) => this.convertArrowTypes(item, field === null || field === void 0 ? void 0 : field.type, (field === null || field === void 0 ? void 0 : field.type.children) || []));
|
|
73
|
+
}
|
|
74
|
+
if (apache_arrow_1.DataType.isTimestamp(valueType)) {
|
|
75
|
+
return new Date(value);
|
|
76
|
+
}
|
|
77
|
+
// Convert big number values to BigInt
|
|
78
|
+
// Decimals are also represented as big numbers in Arrow, so additionally process them (convert to float)
|
|
79
|
+
if (value instanceof Object && value[isArrowBigNumSymbol]) {
|
|
80
|
+
const result = bignumToBigInt(value);
|
|
81
|
+
if (apache_arrow_1.DataType.isDecimal(valueType)) {
|
|
82
|
+
return Number(result) / Math.pow(10, valueType.scale);
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
// Convert binary data to Buffer
|
|
87
|
+
if (value instanceof Uint8Array) {
|
|
88
|
+
return buffer_1.Buffer.from(value);
|
|
89
|
+
}
|
|
90
|
+
// Return other values as is
|
|
91
|
+
return typeof value === 'bigint' ? Number(value) : value;
|
|
92
|
+
}
|
|
93
|
+
convertThriftTypes(record) {
|
|
94
|
+
const result = {};
|
|
95
|
+
this.schema.forEach((column) => {
|
|
96
|
+
var _a;
|
|
97
|
+
const typeDescriptor = (_a = column.typeDesc.types[0]) === null || _a === void 0 ? void 0 : _a.primitiveEntry;
|
|
98
|
+
const field = column.columnName;
|
|
99
|
+
result[field] = (0, utils_1.convertThriftValue)(typeDescriptor, record[field]);
|
|
100
|
+
});
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.default = ArrowResult;
|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AC,SAAS,CAAC,EAAE;gBACjC,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,SAAA,EAAE,EAAI,SAAS,CAAC,KAAK,CAAA,CAAC;aAC/C;YACD,OAAO,MAAM,CAAC;SACf;QAED,gCAAgC;QAChC,IAAI,KAAK,YAAY,UAAU,EAAE;YAC/B,OAAO,eAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC3B;QAED,4BAA4B;QAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC3D,CAAC;IAEO,kBAAkB,CAAC,MAA2B;QACpD,MAAM,MAAM,GAAwB,EAAE,CAAC;QAEvC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;;YAC7B,MAAM,cAAc,GAAG,MAAA,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,0CAAE,cAAc,CAAC;YAChE,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC;YAChC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAA,0BAAkB,EAAC,cAAc,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAlHD,8BAkHC"}
|
|
@@ -1,15 +1,11 @@
|
|
|
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
|
|
4
|
+
private readonly schema;
|
|
5
5
|
constructor(schema?: TTableSchema);
|
|
6
6
|
getValue(data?: Array<TRowSet>): Array<object>;
|
|
7
|
-
private getSchemaColumns;
|
|
8
7
|
private getRows;
|
|
9
8
|
private getSchemaValues;
|
|
10
|
-
private convertData;
|
|
11
9
|
private isNull;
|
|
12
|
-
private toJSON;
|
|
13
|
-
private convertBigInt;
|
|
14
10
|
private getColumnValue;
|
|
15
11
|
}
|
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const Types_1 = require("../hive/Types");
|
|
4
|
-
const
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
5
|
class JsonResult {
|
|
6
6
|
constructor(schema) {
|
|
7
|
-
this.schema = schema;
|
|
7
|
+
this.schema = (0, utils_1.getSchemaColumns)(schema);
|
|
8
8
|
}
|
|
9
9
|
getValue(data) {
|
|
10
|
-
if (!data) {
|
|
10
|
+
if (this.schema.length === 0 || !data) {
|
|
11
11
|
return [];
|
|
12
12
|
}
|
|
13
|
-
const descriptors = this.getSchemaColumns();
|
|
14
13
|
return data.reduce((result, rowSet) => {
|
|
15
14
|
const columns = rowSet.columns || [];
|
|
16
|
-
const rows = this.getRows(columns,
|
|
15
|
+
const rows = this.getRows(columns, this.schema);
|
|
17
16
|
return result.concat(rows);
|
|
18
17
|
}, []);
|
|
19
18
|
}
|
|
20
|
-
getSchemaColumns() {
|
|
21
|
-
if (!this.schema) {
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
24
|
-
return [...this.schema.columns].sort((c1, c2) => c1.position - c2.position);
|
|
25
|
-
}
|
|
26
19
|
getRows(columns, descriptors) {
|
|
27
20
|
return descriptors.reduce((rows, descriptor) => this.getSchemaValues(descriptor, columns[descriptor.position - 1]).reduce((result, value, i) => {
|
|
28
21
|
if (!result[i]) {
|
|
@@ -44,62 +37,18 @@ class JsonResult {
|
|
|
44
37
|
if (columnValue.nulls && this.isNull(columnValue.nulls, i)) {
|
|
45
38
|
return null;
|
|
46
39
|
}
|
|
47
|
-
return
|
|
40
|
+
return (0, utils_1.convertThriftValue)(typeDescriptor, value);
|
|
48
41
|
});
|
|
49
42
|
}
|
|
50
|
-
convertData(typeDescriptor, value) {
|
|
51
|
-
if (!typeDescriptor) {
|
|
52
|
-
return value;
|
|
53
|
-
}
|
|
54
|
-
switch (typeDescriptor.type) {
|
|
55
|
-
case TCLIService_types_1.TTypeId.TIMESTAMP_TYPE:
|
|
56
|
-
case TCLIService_types_1.TTypeId.DATE_TYPE:
|
|
57
|
-
case TCLIService_types_1.TTypeId.UNION_TYPE:
|
|
58
|
-
case TCLIService_types_1.TTypeId.USER_DEFINED_TYPE:
|
|
59
|
-
return String(value);
|
|
60
|
-
case TCLIService_types_1.TTypeId.DECIMAL_TYPE:
|
|
61
|
-
return Number(value);
|
|
62
|
-
case TCLIService_types_1.TTypeId.STRUCT_TYPE:
|
|
63
|
-
case TCLIService_types_1.TTypeId.MAP_TYPE:
|
|
64
|
-
return this.toJSON(value, {});
|
|
65
|
-
case TCLIService_types_1.TTypeId.ARRAY_TYPE:
|
|
66
|
-
return this.toJSON(value, []);
|
|
67
|
-
case TCLIService_types_1.TTypeId.BIGINT_TYPE:
|
|
68
|
-
return this.convertBigInt(value);
|
|
69
|
-
case TCLIService_types_1.TTypeId.NULL_TYPE:
|
|
70
|
-
case TCLIService_types_1.TTypeId.BINARY_TYPE:
|
|
71
|
-
case TCLIService_types_1.TTypeId.INTERVAL_YEAR_MONTH_TYPE:
|
|
72
|
-
case TCLIService_types_1.TTypeId.INTERVAL_DAY_TIME_TYPE:
|
|
73
|
-
case TCLIService_types_1.TTypeId.FLOAT_TYPE:
|
|
74
|
-
case TCLIService_types_1.TTypeId.DOUBLE_TYPE:
|
|
75
|
-
case TCLIService_types_1.TTypeId.INT_TYPE:
|
|
76
|
-
case TCLIService_types_1.TTypeId.SMALLINT_TYPE:
|
|
77
|
-
case TCLIService_types_1.TTypeId.TINYINT_TYPE:
|
|
78
|
-
case TCLIService_types_1.TTypeId.BOOLEAN_TYPE:
|
|
79
|
-
case TCLIService_types_1.TTypeId.STRING_TYPE:
|
|
80
|
-
case TCLIService_types_1.TTypeId.CHAR_TYPE:
|
|
81
|
-
case TCLIService_types_1.TTypeId.VARCHAR_TYPE:
|
|
82
|
-
default:
|
|
83
|
-
return value;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
43
|
isNull(nulls, i) {
|
|
87
44
|
const byte = nulls[Math.floor(i / 8)];
|
|
88
45
|
const ofs = Math.pow(2, (i % 8));
|
|
89
46
|
return (byte & ofs) !== 0;
|
|
90
47
|
}
|
|
91
|
-
toJSON(value, defaultValue) {
|
|
92
|
-
try {
|
|
93
|
-
return JSON.parse(value);
|
|
94
|
-
}
|
|
95
|
-
catch (e) {
|
|
96
|
-
return defaultValue;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
convertBigInt(value) {
|
|
100
|
-
return value.toNumber();
|
|
101
|
-
}
|
|
102
48
|
getColumnValue(column) {
|
|
49
|
+
if (!column) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
103
52
|
return (column[Types_1.ColumnCode.binaryVal] ||
|
|
104
53
|
column[Types_1.ColumnCode.boolVal] ||
|
|
105
54
|
column[Types_1.ColumnCode.byteVal] ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonResult.js","sourceRoot":"","sources":["../../lib/result/JsonResult.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"JsonResult.js","sourceRoot":"","sources":["../../lib/result/JsonResult.ts"],"names":[],"mappings":";;AAAA,yCAA2C;AAG3C,mCAA+D;AAE/D,MAAqB,UAAU;IAG7B,YAAY,MAAqB;QAC/B,IAAI,CAAC,MAAM,GAAG,IAAA,wBAAgB,EAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,QAAQ,CAAC,IAAqB;QAC5B,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE;YACrC,OAAO,EAAE,CAAC;SACX;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,MAAkB,EAAE,MAAe,EAAE,EAAE;YACzD,MAAM,OAAO,GAAG,MAAM,CAAC,OA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C,CAAC,EAAE;gBAC1D,OAAO,IAAI,CAAC;aACb;YACD,OAAO,IAAA,0BAAkB,EAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;IACL,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,cAAc,CAAC,MAAgB;QACrC,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,SAAS,CAAC;SAClB;QACD,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;AA5ED,6BA4EC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { TTableSchema, TColumnDesc, TPrimitiveTypeEntry } from '../../thrift/TCLIService_types';
|
|
2
|
+
export declare function getSchemaColumns(schema?: TTableSchema): Array<TColumnDesc>;
|
|
3
|
+
export declare function convertThriftValue(typeDescriptor: TPrimitiveTypeEntry | undefined, value: any): any;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.convertThriftValue = exports.getSchemaColumns = void 0;
|
|
7
|
+
const node_int64_1 = __importDefault(require("node-int64"));
|
|
8
|
+
const TCLIService_types_1 = require("../../thrift/TCLIService_types");
|
|
9
|
+
function getSchemaColumns(schema) {
|
|
10
|
+
if (!schema) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
return [...schema.columns].sort((c1, c2) => c1.position - c2.position);
|
|
14
|
+
}
|
|
15
|
+
exports.getSchemaColumns = getSchemaColumns;
|
|
16
|
+
function isString(value) {
|
|
17
|
+
return typeof value === 'string' || value instanceof String;
|
|
18
|
+
}
|
|
19
|
+
function convertJSON(value, defaultValue) {
|
|
20
|
+
if (!isString(value)) {
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
return JSON.parse(value);
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
return defaultValue;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function convertBigInt(value) {
|
|
31
|
+
if (typeof value === 'bigint') {
|
|
32
|
+
return Number(value);
|
|
33
|
+
}
|
|
34
|
+
if (value instanceof node_int64_1.default) {
|
|
35
|
+
return value.toNumber();
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
function convertThriftValue(typeDescriptor, value) {
|
|
40
|
+
if (!typeDescriptor) {
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
switch (typeDescriptor.type) {
|
|
44
|
+
case TCLIService_types_1.TTypeId.DATE_TYPE:
|
|
45
|
+
case TCLIService_types_1.TTypeId.TIMESTAMP_TYPE:
|
|
46
|
+
return value;
|
|
47
|
+
case TCLIService_types_1.TTypeId.UNION_TYPE:
|
|
48
|
+
case TCLIService_types_1.TTypeId.USER_DEFINED_TYPE:
|
|
49
|
+
return String(value);
|
|
50
|
+
case TCLIService_types_1.TTypeId.DECIMAL_TYPE:
|
|
51
|
+
return Number(value);
|
|
52
|
+
case TCLIService_types_1.TTypeId.STRUCT_TYPE:
|
|
53
|
+
case TCLIService_types_1.TTypeId.MAP_TYPE:
|
|
54
|
+
return convertJSON(value, {});
|
|
55
|
+
case TCLIService_types_1.TTypeId.ARRAY_TYPE:
|
|
56
|
+
return convertJSON(value, []);
|
|
57
|
+
case TCLIService_types_1.TTypeId.BIGINT_TYPE:
|
|
58
|
+
return convertBigInt(value);
|
|
59
|
+
case TCLIService_types_1.TTypeId.NULL_TYPE:
|
|
60
|
+
case TCLIService_types_1.TTypeId.BINARY_TYPE:
|
|
61
|
+
case TCLIService_types_1.TTypeId.INTERVAL_YEAR_MONTH_TYPE:
|
|
62
|
+
case TCLIService_types_1.TTypeId.INTERVAL_DAY_TIME_TYPE:
|
|
63
|
+
case TCLIService_types_1.TTypeId.FLOAT_TYPE:
|
|
64
|
+
case TCLIService_types_1.TTypeId.DOUBLE_TYPE:
|
|
65
|
+
case TCLIService_types_1.TTypeId.INT_TYPE:
|
|
66
|
+
case TCLIService_types_1.TTypeId.SMALLINT_TYPE:
|
|
67
|
+
case TCLIService_types_1.TTypeId.TINYINT_TYPE:
|
|
68
|
+
case TCLIService_types_1.TTypeId.BOOLEAN_TYPE:
|
|
69
|
+
case TCLIService_types_1.TTypeId.STRING_TYPE:
|
|
70
|
+
case TCLIService_types_1.TTypeId.CHAR_TYPE:
|
|
71
|
+
case TCLIService_types_1.TTypeId.VARCHAR_TYPE:
|
|
72
|
+
default:
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.convertThriftValue = convertThriftValue;
|
|
77
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/result/utils.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA+B;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CAAC,KAAK,CAAC,CAAC;QACvB,KAAK,2BAAO,CAAC,YAAY;YACvB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,KAAK,2BAAO,CAAC,WAAW,CAAC;QACzB,KAAK,2BAAO,CAAC,QAAQ;YACnB,OAAO,WAAW,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAChC,KAAK,2BAAO,CAAC,UAAU;YACrB,OAAO,WAAW,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAChC,KAAK,2BAAO,CAAC,WAAW;YACtB,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;QAC9B,KAAK,2BAAO,CAAC,SAAS,CAAC;QACvB,KAAK,2BAAO,CAAC,WAAW,CAAC;QACzB,KAAK,2BAAO,CAAC,wBAAwB,CAAC;QACtC,KAAK,2BAAO,CAAC,sBAAsB,CAAC;QACpC,KAAK,2BAAO,CAAC,UAAU,CAAC;QACxB,KAAK,2BAAO,CAAC,WAAW,CAAC;QACzB,KAAK,2BAAO,CAAC,QAAQ,CAAC;QACtB,KAAK,2BAAO,CAAC,aAAa,CAAC;QAC3B,KAAK,2BAAO,CAAC,YAAY,CAAC;QAC1B,KAAK,2BAAO,CAAC,YAAY,CAAC;QAC1B,KAAK,2BAAO,CAAC,WAAW,CAAC;QACzB,KAAK,2BAAO,CAAC,SAAS,CAAC;QACvB,KAAK,2BAAO,CAAC,YAAY,CAAC;QAC1B;YACE,OAAO,KAAK,CAAC;KAChB;AACH,CAAC;AArCD,gDAqCC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "1.
|
|
1
|
+
declare const _default: "1.2.1";
|
|
2
2
|
export default _default;
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@databricks/sql",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Driver for connection to Databricks SQL via Thrift API.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"postinstall": "patch-package",
|
|
16
16
|
"prepare": "npm run build",
|
|
17
|
+
"prepack": "mkdir dist/node_modules && cp -R node_modules/thrift dist/node_modules/thrift",
|
|
17
18
|
"e2e": "nyc --reporter=lcov --report-dir=coverage_e2e mocha --config tests/e2e/.mocharc.js",
|
|
18
19
|
"test": "nyc --reporter=lcov --report-dir=coverage_unit mocha --config tests/unit/.mocharc.js",
|
|
19
20
|
"update-version": "node bin/update-version.js && prettier --write ./lib/version.ts",
|
|
@@ -48,12 +49,12 @@
|
|
|
48
49
|
],
|
|
49
50
|
"license": "Apache 2.0",
|
|
50
51
|
"devDependencies": {
|
|
51
|
-
"@types/node": "^18.
|
|
52
|
+
"@types/node": "^18.11.9",
|
|
52
53
|
"@types/node-int64": "^0.4.29",
|
|
53
54
|
"@types/thrift": "^0.10.11",
|
|
54
55
|
"@types/uuid": "^8.3.4",
|
|
55
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
56
|
-
"@typescript-eslint/parser": "^5.
|
|
56
|
+
"@typescript-eslint/eslint-plugin": "^5.44.0",
|
|
57
|
+
"@typescript-eslint/parser": "^5.44.0",
|
|
57
58
|
"chai": "^4.3.6",
|
|
58
59
|
"eslint": "^8.22.0",
|
|
59
60
|
"eslint-config-airbnb": "^19.0.4",
|
|
@@ -63,21 +64,19 @@
|
|
|
63
64
|
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
64
65
|
"eslint-plugin-react": "^7.30.1",
|
|
65
66
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
66
|
-
"mocha": "^10.
|
|
67
|
+
"mocha": "^10.2.0",
|
|
67
68
|
"nyc": "^15.1.0",
|
|
68
|
-
"prettier": "^2.
|
|
69
|
+
"prettier": "^2.8.4",
|
|
69
70
|
"sinon": "^14.0.0",
|
|
70
|
-
"typescript": "^4.
|
|
71
|
+
"typescript": "^4.9.3"
|
|
71
72
|
},
|
|
72
73
|
"dependencies": {
|
|
74
|
+
"apache-arrow": "^10.0.1",
|
|
73
75
|
"commander": "^9.3.0",
|
|
74
76
|
"node-int64": "^0.4.0",
|
|
75
77
|
"patch-package": "^6.5.0",
|
|
76
78
|
"thrift": "^0.16.0",
|
|
77
79
|
"uuid": "^9.0.0",
|
|
78
80
|
"winston": "^3.8.2"
|
|
79
|
-
}
|
|
80
|
-
"bundledDependencies": [
|
|
81
|
-
"thrift"
|
|
82
|
-
]
|
|
81
|
+
}
|
|
83
82
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
# Release History
|
|
2
|
-
|
|
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
|
|
19
|
-
|
|
20
|
-
- `DBSQLClient.openSession` now takes a limited set of options (`OpenSessionRequest` instead of Thrift's `TOpenSessionReq`)
|
|
21
|
-
- `DBSQLClient.openSession` now uses the latest protocol version by default
|
|
22
|
-
- Direct results feature is now available for all IOperation methods which support it. To enable direct results feature,
|
|
23
|
-
`maxRows` option should be used
|
|
24
|
-
- Direct results became enabled by default. If `maxRows` is omitted - it will default to `100000`. To disable direct
|
|
25
|
-
results, set `maxRows` to `null`
|
|
26
|
-
- `FunctionNameRequest` type renamed to `FunctionsRequest`
|
|
27
|
-
- `IDBSQLConnectionOptions` type renamed to `ConnectionOptions`
|
|
28
|
-
- `IFetchOptions` renamed to `FetchOptions`
|
|
29
|
-
- `DBSQLOperation.getSchema` will wait for operation completion, like `DBSQLOperation.fetchChunk`/`DBSQLOperation.fetchAll`.
|
|
30
|
-
It also supports the same progress reporting options
|
|
31
|
-
- `runAsync` option is now available for all operations that support it
|
|
32
|
-
- Added logging functionality for logging on client side and added new optional logger param for DBSQLClient constructor
|
|
33
|
-
- Turned on Direct results feature by default
|
|
34
|
-
- Removed legacy Kerberos auth APIs
|
|
35
|
-
|
|
36
|
-
## 0.1.8-beta.2 (2022-09-08)
|
|
37
|
-
|
|
38
|
-
- Operations will wait for cluster to start instead of failing
|
|
39
|
-
- Added support for DirectResults, which speeds up data fetches by reducing the number of server roundtrips when possible
|
|
40
|
-
- `DBSQLOperation` interface simplified: `HiveUtils` were removed and replaced with new methods
|
|
41
|
-
`DBSQLOperation.fetchChunk`/`DBSQLOperation.fetchAll`. New API implements all necessary waiting
|
|
42
|
-
and data conversion routines internally
|
|
43
|
-
- Better TypeScript support
|
|
44
|
-
- Thrift definitions updated to support additional Databricks features
|
|
45
|
-
- User-agent string updated; a part of user-agent string is configurable through `DBSQLClient`'s `clientId` option
|
|
46
|
-
- Connection now uses keep-alive (not configurable at this moment)
|
|
47
|
-
- `DBSQLClient` now prepends slash to path when needed
|
|
48
|
-
- `DBSQLOperation`: default chunk size for data fetching increased from 100 to 100.000
|
|
49
|
-
|
|
50
|
-
### Upgrading
|
|
51
|
-
|
|
52
|
-
`DBSQLClient.utils` was permanently removed. Code which used `utils.waitUntilReady`, `utils.fetchAll`
|
|
53
|
-
and `utils.getResult` to get data should now be replaced with the single `DBSQLOperation.fetchAll` method.
|
|
54
|
-
Progress reporting, previously supported by `utils.waitUntilReady`, is now configurable via
|
|
55
|
-
`DBSQLOperation.fetchChunk`/`DBSQLOperation.fetchAll` options. `DBSQLOperation.setMaxRows` also became
|
|
56
|
-
an option of methods mentioned above.
|
|
57
|
-
|
|
58
|
-
## 0.1.8-beta.1 (2022-06-24)
|
|
59
|
-
|
|
60
|
-
- Initial release
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { TStatus } from '../../thrift/TCLIService_types';
|
|
2
|
-
import Status from '../dto/Status';
|
|
3
|
-
export default class StatusFactory {
|
|
4
|
-
/**
|
|
5
|
-
* @param status thrift status object from API responses
|
|
6
|
-
* @throws {StatusError}
|
|
7
|
-
*/
|
|
8
|
-
create(status: TStatus): Status;
|
|
9
|
-
private isSuccess;
|
|
10
|
-
private isError;
|
|
11
|
-
private isExecuting;
|
|
12
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const TCLIService_types_1 = require("../../thrift/TCLIService_types");
|
|
7
|
-
const Status_1 = __importDefault(require("../dto/Status"));
|
|
8
|
-
const StatusError_1 = __importDefault(require("../errors/StatusError"));
|
|
9
|
-
class StatusFactory {
|
|
10
|
-
/**
|
|
11
|
-
* @param status thrift status object from API responses
|
|
12
|
-
* @throws {StatusError}
|
|
13
|
-
*/
|
|
14
|
-
create(status) {
|
|
15
|
-
if (this.isError(status)) {
|
|
16
|
-
throw new StatusError_1.default(status);
|
|
17
|
-
}
|
|
18
|
-
return new Status_1.default({
|
|
19
|
-
success: this.isSuccess(status),
|
|
20
|
-
executing: this.isExecuting(status),
|
|
21
|
-
infoMessages: status.infoMessages || [],
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
isSuccess(status) {
|
|
25
|
-
return (status.statusCode === TCLIService_types_1.TStatusCode.SUCCESS_STATUS || status.statusCode === TCLIService_types_1.TStatusCode.SUCCESS_WITH_INFO_STATUS);
|
|
26
|
-
}
|
|
27
|
-
isError(status) {
|
|
28
|
-
return status.statusCode === TCLIService_types_1.TStatusCode.ERROR_STATUS || status.statusCode === TCLIService_types_1.TStatusCode.INVALID_HANDLE_STATUS;
|
|
29
|
-
}
|
|
30
|
-
isExecuting(status) {
|
|
31
|
-
return status.statusCode === TCLIService_types_1.TStatusCode.STILL_EXECUTING_STATUS;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.default = StatusFactory;
|
|
35
|
-
//# sourceMappingURL=StatusFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StatusFactory.js","sourceRoot":"","sources":["../../lib/factory/StatusFactory.ts"],"names":[],"mappings":";;;;;AAAA,sEAAsE;AACtE,2DAAmC;AACnC,wEAAgD;AAEhD,MAAqB,aAAa;IAChC;;;OAGG;IACH,MAAM,CAAC,MAAe;QACpB,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACxB,MAAM,IAAI,qBAAW,CAAC,MAAM,CAAC,CAAC;SAC/B;QAED,OAAO,IAAI,gBAAM,CAAC;YAChB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;YAC/B,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YACnC,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,EAAE;SACxC,CAAC,CAAC;IACL,CAAC;IAEO,SAAS,CAAC,MAAe;QAC/B,OAAO,CACL,MAAM,CAAC,UAAU,KAAK,+BAAW,CAAC,cAAc,IAAI,MAAM,CAAC,UAAU,KAAK,+BAAW,CAAC,wBAAwB,CAC/G,CAAC;IACJ,CAAC;IAEO,OAAO,CAAC,MAAe;QAC7B,OAAO,MAAM,CAAC,UAAU,KAAK,+BAAW,CAAC,YAAY,IAAI,MAAM,CAAC,UAAU,KAAK,+BAAW,CAAC,qBAAqB,CAAC;IACnH,CAAC;IAEO,WAAW,CAAC,MAAe;QACjC,OAAO,MAAM,CAAC,UAAU,KAAK,+BAAW,CAAC,sBAAsB,CAAC;IAClE,CAAC;CACF;AA9BD,gCA8BC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
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.
|
|
@@ -1,67 +0,0 @@
|
|
|
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;
|