@tdengine/websocket 3.0.0 → 3.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/lib/example/basicSchemaless.d.ts +2 -0
- package/lib/example/basicSchemaless.d.ts.map +1 -0
- package/lib/example/basicSchemaless.js +47 -0
- package/lib/example/basicSql.d.ts +2 -0
- package/lib/example/basicSql.d.ts.map +1 -0
- package/lib/example/basicSql.js +52 -0
- package/lib/example/basicStmt.d.ts +2 -0
- package/lib/example/basicStmt.d.ts.map +1 -0
- package/lib/example/basicStmt.js +58 -0
- package/lib/example/basicTmq.d.ts +2 -0
- package/lib/example/basicTmq.d.ts.map +1 -0
- package/lib/example/basicTmq.js +71 -0
- package/lib/index.d.ts +26 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +41 -0
- package/lib/src/client/wsClient.d.ts +22 -0
- package/lib/src/client/wsClient.d.ts.map +1 -0
- package/lib/src/client/wsClient.js +253 -0
- package/lib/src/client/wsConnector.d.ts +17 -0
- package/lib/src/client/wsConnector.d.ts.map +1 -0
- package/lib/src/client/wsConnector.js +140 -0
- package/lib/src/client/wsConnectorPool.d.ts +13 -0
- package/lib/src/client/wsConnectorPool.d.ts.map +1 -0
- package/lib/src/client/wsConnectorPool.js +107 -0
- package/lib/src/client/wsEventCallback.d.ts +22 -0
- package/lib/src/client/wsEventCallback.d.ts.map +1 -0
- package/lib/src/client/wsEventCallback.js +97 -0
- package/lib/src/client/wsResponse.d.ts +66 -0
- package/lib/src/client/wsResponse.d.ts.map +1 -0
- package/lib/src/client/wsResponse.js +76 -0
- package/lib/src/common/config.d.ts +22 -0
- package/lib/src/common/config.d.ts.map +1 -0
- package/lib/src/common/config.js +45 -0
- package/lib/src/common/constant.d.ts +13 -0
- package/lib/src/common/constant.d.ts.map +1 -0
- package/{src/constant.ts → lib/src/common/constant.js} +25 -24
- package/lib/src/common/log.d.ts +5 -0
- package/lib/src/common/log.d.ts.map +1 -0
- package/lib/src/common/log.js +40 -0
- package/lib/src/common/reqid.d.ts +8 -0
- package/lib/src/common/reqid.d.ts.map +1 -0
- package/lib/src/common/reqid.js +59 -0
- package/lib/src/common/taosResult.d.ts +51 -0
- package/lib/src/common/taosResult.d.ts.map +1 -0
- package/lib/src/common/taosResult.js +419 -0
- package/lib/src/common/ut8Helper.d.ts +2 -0
- package/lib/src/common/ut8Helper.d.ts.map +1 -0
- package/{src/ut8Helper.ts → lib/src/common/ut8Helper.js} +22 -21
- package/lib/src/common/utils.d.ts +5 -0
- package/lib/src/common/utils.d.ts.map +1 -0
- package/lib/src/common/utils.js +33 -0
- package/lib/src/common/wsError.d.ts +29 -0
- package/lib/src/common/wsError.d.ts.map +1 -0
- package/lib/src/common/wsError.js +51 -0
- package/{src/wsOptions.ts → lib/src/common/wsOptions.d.ts} +4 -2
- package/lib/src/common/wsOptions.d.ts.map +1 -0
- package/lib/src/common/wsOptions.js +2 -0
- package/lib/src/index.d.ts +9 -0
- package/lib/src/index.d.ts.map +1 -0
- package/lib/src/index.js +58 -0
- package/lib/src/sql/wsProto.d.ts +26 -0
- package/lib/src/sql/wsProto.d.ts.map +1 -0
- package/lib/src/sql/wsProto.js +19 -0
- package/lib/src/sql/wsRows.d.ts +16 -0
- package/lib/src/sql/wsRows.d.ts.map +1 -0
- package/lib/src/sql/wsRows.js +76 -0
- package/lib/src/sql/wsSql.d.ts +24 -0
- package/lib/src/sql/wsSql.d.ts.map +1 -0
- package/lib/src/sql/wsSql.js +164 -0
- package/lib/src/stmt/wsParams.d.ts +41 -0
- package/lib/src/stmt/wsParams.d.ts.map +1 -0
- package/lib/src/stmt/wsParams.js +428 -0
- package/lib/src/stmt/wsProto.d.ts +27 -0
- package/lib/src/stmt/wsProto.d.ts.map +1 -0
- package/lib/src/stmt/wsProto.js +67 -0
- package/lib/src/stmt/wsStmt.d.ts +30 -0
- package/lib/src/stmt/wsStmt.d.ts.map +1 -0
- package/lib/src/stmt/wsStmt.js +207 -0
- package/lib/src/tmq/config.d.ts +14 -0
- package/lib/src/tmq/config.d.ts.map +1 -0
- package/lib/src/tmq/config.js +42 -0
- package/lib/src/tmq/constant.d.ts +85 -0
- package/lib/src/tmq/constant.d.ts.map +1 -0
- package/lib/src/tmq/constant.js +89 -0
- package/lib/src/tmq/tmqResponse.d.ts +80 -0
- package/lib/src/tmq/tmqResponse.d.ts.map +1 -0
- package/lib/src/tmq/tmqResponse.js +204 -0
- package/lib/src/tmq/wsTmq.d.ts +32 -0
- package/lib/src/tmq/wsTmq.d.ts.map +1 -0
- package/lib/src/tmq/wsTmq.js +316 -0
- package/lib/test/bulkPulling/queryTables.test.d.ts +2 -0
- package/lib/test/bulkPulling/queryTables.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/queryTables.test.js +297 -0
- package/lib/test/bulkPulling/schemaless.test.d.ts +2 -0
- package/lib/test/bulkPulling/schemaless.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/schemaless.test.js +94 -0
- package/lib/test/bulkPulling/sql.test.d.ts +2 -0
- package/lib/test/bulkPulling/sql.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/sql.test.js +124 -0
- package/lib/test/bulkPulling/stmt.func.test.d.ts +2 -0
- package/lib/test/bulkPulling/stmt.func.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/stmt.func.test.js +381 -0
- package/lib/test/bulkPulling/stmt.type.test.d.ts +2 -0
- package/lib/test/bulkPulling/stmt.type.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/stmt.type.test.js +273 -0
- package/lib/test/bulkPulling/tmq.test.d.ts +2 -0
- package/lib/test/bulkPulling/tmq.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/tmq.test.js +177 -0
- package/lib/test/bulkPulling/wsConnectPool.test.d.ts +2 -0
- package/lib/test/bulkPulling/wsConnectPool.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/wsConnectPool.test.js +129 -0
- package/lib/test/utils.d.ts +18 -0
- package/lib/test/utils.d.ts.map +1 -0
- package/lib/test/utils.js +318 -0
- package/package.json +27 -14
- package/readme.md +302 -0
- package/README.md +0 -59
- package/dist/browser/index.js +0 -778
- package/dist/main/index.js +0 -711
- package/dist/main/index.js.map +0 -1
- package/dist/module/index.mjs +0 -704
- package/dist/module/index.mjs.map +0 -1
- package/dist/types.d.ts +0 -103
- package/dist/types.d.ts.map +0 -1
- package/example/basicUsageAsync.ts +0 -48
- package/example/basicUsagePrimse.ts +0 -43
- package/example/cloudUsage.ts +0 -55
- package/example/continousConnectAndVersion.ts +0 -16
- package/example/test.mjs +0 -51
- package/index.ts +0 -7
- package/jest.config.js +0 -8
- package/src/taosResult.ts +0 -269
- package/src/tdengineWebsocket.ts +0 -39
- package/src/wsClient.ts +0 -196
- package/src/wsError.ts +0 -5
- package/src/wsQuery.ts +0 -30
- package/src/wsQueryInterface.ts +0 -212
- package/src/wsQueryResponse.ts +0 -112
- package/tdengine-websocket-3.0.0.tgz +0 -0
- package/test/bulkPulling/connect.test.ts +0 -27
- package/test/bulkPulling/queryTables.test.ts +0 -274
- package/test/bulkPulling/version.test.ts +0 -19
- package/test/utils.ts +0 -235
- package/tsconfig.json +0 -101
package/dist/module/index.mjs
DELETED
|
@@ -1,704 +0,0 @@
|
|
|
1
|
-
import {Buffer as $9nax8$Buffer} from "buffer";
|
|
2
|
-
import $9nax8$jsonbigint from "json-bigint";
|
|
3
|
-
import {w3cwebsocket as $9nax8$w3cwebsocket} from "websocket";
|
|
4
|
-
|
|
5
|
-
const $06d126546cf1c802$export$7138a112355d88b8 = {
|
|
6
|
-
0: "NULL",
|
|
7
|
-
1: "BOOL",
|
|
8
|
-
2: "TINYINT",
|
|
9
|
-
3: "SMALLINT",
|
|
10
|
-
4: "INT",
|
|
11
|
-
5: "BIGINT",
|
|
12
|
-
6: "FLOAT",
|
|
13
|
-
7: "DOUBLE",
|
|
14
|
-
8: "VARCHAR",
|
|
15
|
-
9: "TIMESTAMP",
|
|
16
|
-
10: "NCHAR",
|
|
17
|
-
11: "TINYINT UNSIGNED",
|
|
18
|
-
12: "SMALLINT UNSIGNED",
|
|
19
|
-
13: "INT UNSIGNED",
|
|
20
|
-
14: "BIGINT UNSIGNED",
|
|
21
|
-
15: "JSON"
|
|
22
|
-
};
|
|
23
|
-
const $06d126546cf1c802$export$9c85ccb1eaab884c = {
|
|
24
|
-
"SOLID": 0,
|
|
25
|
-
"VARCHAR": 1,
|
|
26
|
-
"NCHAR": 2
|
|
27
|
-
};
|
|
28
|
-
const $06d126546cf1c802$export$9f025993407a7e76 = {
|
|
29
|
-
"NULL": 0,
|
|
30
|
-
"BOOL": 1,
|
|
31
|
-
"TINYINT": 2,
|
|
32
|
-
"SMALLINT": 3,
|
|
33
|
-
"INT": 4,
|
|
34
|
-
"BIGINT": 5,
|
|
35
|
-
"FLOAT": 6,
|
|
36
|
-
"DOUBLE": 7,
|
|
37
|
-
"BINARY": 8,
|
|
38
|
-
"VARCHAR": 8,
|
|
39
|
-
"TIMESTAMP": 9,
|
|
40
|
-
"NCHAR": 10,
|
|
41
|
-
"TINYINT UNSIGNED": 11,
|
|
42
|
-
"SMALLINT UNSIGNED": 12,
|
|
43
|
-
"INT UNSIGNED": 13,
|
|
44
|
-
"BIGINT UNSIGNED": 14,
|
|
45
|
-
"JSON": 15
|
|
46
|
-
};
|
|
47
|
-
const $06d126546cf1c802$export$a24993810630aa00 = {
|
|
48
|
-
0: "MILLISECOND",
|
|
49
|
-
1: "MICROSECOND",
|
|
50
|
-
2: "NANOSECOND"
|
|
51
|
-
};
|
|
52
|
-
const $06d126546cf1c802$export$60958af5d03c3d00 = {
|
|
53
|
-
"BOOL": 1,
|
|
54
|
-
"TINYINT": 1,
|
|
55
|
-
"SMALLINT": 2,
|
|
56
|
-
"INT": 4,
|
|
57
|
-
"BIGINT": 8,
|
|
58
|
-
"FLOAT": 4,
|
|
59
|
-
"DOUBLE": 8,
|
|
60
|
-
"TIMESTAMP": 8,
|
|
61
|
-
"TINYINT UNSIGNED": 1,
|
|
62
|
-
"SMALLINT UNSIGNED": 2,
|
|
63
|
-
"INT UNSIGNED": 4,
|
|
64
|
-
"BIGINT UNSIGNED": 8
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
class $35485c3d6c17b9b9$export$e04e72655114a7e extends Error {
|
|
69
|
-
}
|
|
70
|
-
class $35485c3d6c17b9b9$export$bb331b3b46269060 extends $35485c3d6c17b9b9$export$e04e72655114a7e {
|
|
71
|
-
}
|
|
72
|
-
class $35485c3d6c17b9b9$export$d45d01cc7570ed33 extends $35485c3d6c17b9b9$export$e04e72655114a7e {
|
|
73
|
-
}
|
|
74
|
-
class $35485c3d6c17b9b9$export$bef77b941ab4e130 extends $35485c3d6c17b9b9$export$d45d01cc7570ed33 {
|
|
75
|
-
}
|
|
76
|
-
class $35485c3d6c17b9b9$export$a28431cdd91982f0 extends Error {
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
var $90711649818f52dd$require$Buffer = $9nax8$Buffer;
|
|
82
|
-
// Numbers fundamental to the encoding.
|
|
83
|
-
// the "error" Rune or "Unicode replacement character"
|
|
84
|
-
const $90711649818f52dd$var$RuneError = "�";
|
|
85
|
-
// Maximum valid Unicode code point.
|
|
86
|
-
const $90711649818f52dd$var$MaxRune = "U0010FFFF";
|
|
87
|
-
// Code points in the surrogate range are not valid for UTF-8.
|
|
88
|
-
const $90711649818f52dd$var$surrogateMin = 0xD800;
|
|
89
|
-
const $90711649818f52dd$var$surrogateMax = 0xDFFF;
|
|
90
|
-
const $90711649818f52dd$var$tx = 128;
|
|
91
|
-
const $90711649818f52dd$var$t2 = 192;
|
|
92
|
-
const $90711649818f52dd$var$t3 = 224;
|
|
93
|
-
const $90711649818f52dd$var$t4 = 240;
|
|
94
|
-
const $90711649818f52dd$var$maskx = 63;
|
|
95
|
-
const $90711649818f52dd$var$rune1Max = 127;
|
|
96
|
-
const $90711649818f52dd$var$rune2Max = 2047;
|
|
97
|
-
const $90711649818f52dd$var$rune3Max = 65535;
|
|
98
|
-
function $90711649818f52dd$export$ee9b81b89b187997(r) {
|
|
99
|
-
let p = [];
|
|
100
|
-
// console.log("== AppendRun r:");
|
|
101
|
-
// console.log(r)
|
|
102
|
-
if (r <= $90711649818f52dd$var$rune1Max) {
|
|
103
|
-
p.push(r & 0xff);
|
|
104
|
-
return $90711649818f52dd$require$Buffer.from(p).toString();
|
|
105
|
-
}
|
|
106
|
-
if (r <= $90711649818f52dd$var$rune2Max) p.push($90711649818f52dd$var$t2 | r >> 6 & 0xff, $90711649818f52dd$var$tx | r & 0xff & $90711649818f52dd$var$maskx);
|
|
107
|
-
else if (r > $90711649818f52dd$var$MaxRune || $90711649818f52dd$var$surrogateMax <= r && r <= $90711649818f52dd$var$surrogateMax) p.push($90711649818f52dd$var$RuneError);
|
|
108
|
-
else if (r <= $90711649818f52dd$var$rune3Max) p.push($90711649818f52dd$var$t3 | r >> 12 & 0xff, $90711649818f52dd$var$tx | r >> 6 & 0xff & $90711649818f52dd$var$maskx, $90711649818f52dd$var$tx | r & 0xff & $90711649818f52dd$var$maskx);
|
|
109
|
-
else p.push($90711649818f52dd$var$t4 | r >> 18 & 0xff, $90711649818f52dd$var$tx | r >> 12 & 0xff & $90711649818f52dd$var$maskx, $90711649818f52dd$var$tx | r >> 6 & 0xff & $90711649818f52dd$var$maskx, $90711649818f52dd$var$tx | r & 0xff & $90711649818f52dd$var$maskx);
|
|
110
|
-
return $90711649818f52dd$require$Buffer.from(p).toString();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
var $f52c4c4d89a4f2dd$require$Buffer = $9nax8$Buffer;
|
|
116
|
-
class $f52c4c4d89a4f2dd$export$e452488413ae38a1 {
|
|
117
|
-
precision = 0;
|
|
118
|
-
affectRows = 0;
|
|
119
|
-
constructor(queryResponse){
|
|
120
|
-
if (queryResponse.is_update == true) {
|
|
121
|
-
this.meta = null;
|
|
122
|
-
this.data = null;
|
|
123
|
-
} else {
|
|
124
|
-
if (queryResponse.fields_count && queryResponse.fields_names && queryResponse.fields_types && queryResponse.fields_lengths) {
|
|
125
|
-
let _meta = [];
|
|
126
|
-
for(let i = 0; i < queryResponse.fields_count; i++)_meta.push({
|
|
127
|
-
name: queryResponse.fields_names[i],
|
|
128
|
-
type: queryResponse.fields_types[i],
|
|
129
|
-
length: queryResponse.fields_lengths[i]
|
|
130
|
-
});
|
|
131
|
-
this.meta = _meta;
|
|
132
|
-
} else throw new (0, $35485c3d6c17b9b9$export$a28431cdd91982f0)(`fields_count,fields_names,fields_types,fields_lengths of the update query response should be null`);
|
|
133
|
-
this.data = [];
|
|
134
|
-
}
|
|
135
|
-
this.affectRows = queryResponse.affected_rows;
|
|
136
|
-
this.timing = queryResponse.timing;
|
|
137
|
-
this.precision = queryResponse.precision;
|
|
138
|
-
// console.log(`typeof this.timing:${typeof this.timing}, typeof fetchResponse.timing:${typeof queryResponse.timing}`)
|
|
139
|
-
}
|
|
140
|
-
setRows(fetchResponse) {
|
|
141
|
-
this.affectRows += fetchResponse.rows;
|
|
142
|
-
// console.log(`typeof this.timing:${typeof this.timing}, typeof fetchResponse.timing:${typeof fetchResponse.timing}`)
|
|
143
|
-
this.timing = this.timing + fetchResponse.timing;
|
|
144
|
-
}
|
|
145
|
-
setData(fetchBlockResponse) {
|
|
146
|
-
if (this.data) this.data.push([]);
|
|
147
|
-
else throw new (0, $35485c3d6c17b9b9$export$a28431cdd91982f0)(`update query response cannot set data`);
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Mapping the WebSocket response type code to TDengine's type name.
|
|
151
|
-
*/ getTDengineMeta() {
|
|
152
|
-
if (this.meta) {
|
|
153
|
-
let _ = new Array();
|
|
154
|
-
this.meta.forEach((m)=>{
|
|
155
|
-
_.push({
|
|
156
|
-
name: m.name,
|
|
157
|
-
type: (0, $06d126546cf1c802$export$7138a112355d88b8)[m.type],
|
|
158
|
-
length: m.length
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
return _;
|
|
162
|
-
} else return null;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
function $f52c4c4d89a4f2dd$export$4aed668c47d45036(fetchResponse, blocks, taosResult) {
|
|
166
|
-
if (taosResult.meta && taosResult.data) {
|
|
167
|
-
let metaList = taosResult.meta;
|
|
168
|
-
// console.log(typeof taosResult.timing)
|
|
169
|
-
// console.log(typeof blocks.timing)
|
|
170
|
-
// console.log(blocks.id)
|
|
171
|
-
taosResult.timing = BigInt(taosResult.timing) + blocks.timing;
|
|
172
|
-
const INT_32_SIZE = 4;
|
|
173
|
-
// Offset num of bytes from rawBlockBuffer.
|
|
174
|
-
let bufferOffset = 28 + 5 * metaList.length;
|
|
175
|
-
let colLengthBlockSize = INT_32_SIZE * metaList.length;
|
|
176
|
-
// console.log("===colLengthBlockSize:" + colLengthBlockSize)
|
|
177
|
-
let bitMapSize = fetchResponse.rows + 8 - 1 >> 3;
|
|
178
|
-
// whole raw block ArrayBuffer
|
|
179
|
-
let dataBuffer = blocks.data.slice(bufferOffset);
|
|
180
|
-
// record the head of column in block
|
|
181
|
-
let colBlockHead = 0;
|
|
182
|
-
for(let i = 0; i < fetchResponse.rows; i++){
|
|
183
|
-
let row = [];
|
|
184
|
-
// point to the head of the column in the block
|
|
185
|
-
colBlockHead = 0 + colLengthBlockSize;
|
|
186
|
-
// point to the head of columns's data in the block (include bitMap and offsetArray)
|
|
187
|
-
let colDataHead = colBlockHead;
|
|
188
|
-
// traverse row after row.
|
|
189
|
-
for(let j = 0; j < metaList.length; j++){
|
|
190
|
-
let isVarType = $f52c4c4d89a4f2dd$var$_isVarTye(metaList[j]);
|
|
191
|
-
// console.log("== dataBuffer Length:" + dataBuffer.byteLength)
|
|
192
|
-
// console.log("== loop i:" + i + "J=" + j + "col:" + metaList[j].name + "type:" + metaList[j].type)
|
|
193
|
-
// console.log("== loop isVarType:" + isVarType);
|
|
194
|
-
if (isVarType == (0, $06d126546cf1c802$export$9c85ccb1eaab884c).SOLID) {
|
|
195
|
-
colDataHead = colBlockHead + bitMapSize + metaList[j].length * i;
|
|
196
|
-
let byteArrayIndex = i >> 3;
|
|
197
|
-
let bitwiseOffset = 7 - (i & 7);
|
|
198
|
-
let bitMapArr = dataBuffer.slice(colBlockHead, colBlockHead + bitMapSize);
|
|
199
|
-
// console.log("==i:" + i + "byteArrayIndex=" + byteArrayIndex)
|
|
200
|
-
// console.log("== loop colblockhead:" + colBlockHead)
|
|
201
|
-
// console.log("== loop bitmap:" + bitMapSize)
|
|
202
|
-
// console.log("== loop bitMap length=" + bitMapArr.byteLength)
|
|
203
|
-
// console.log("==loop bitMap bitwiseoffset:" + bitwiseOffset + "byteArrayIndex:" + byteArrayIndex)
|
|
204
|
-
let bitFlag = (new DataView(bitMapArr).getUint8(byteArrayIndex) & 1 << bitwiseOffset) >> bitwiseOffset;
|
|
205
|
-
if (bitFlag == 1) row.push("NULL");
|
|
206
|
-
else row.push($f52c4c4d89a4f2dd$var$readSolidData(dataBuffer, colDataHead, metaList[j]));
|
|
207
|
-
// console.log("=====(new DataView(dataBuffer, INT_32_SIZE * j, INT_32_SIZE).getInt32(0))=" + (new DataView(dataBuffer, INT_32_SIZE * j, INT_32_SIZE).getInt32(0, true)));
|
|
208
|
-
colBlockHead = colBlockHead + bitMapSize + new DataView(dataBuffer, INT_32_SIZE * j, INT_32_SIZE).getInt32(0, true);
|
|
209
|
-
} else {
|
|
210
|
-
// if null check
|
|
211
|
-
let varOffset = new DataView(dataBuffer, colBlockHead + INT_32_SIZE * i, INT_32_SIZE).getInt32(0, true);
|
|
212
|
-
// console.log("== var type offset:" + varOffset)
|
|
213
|
-
if (varOffset == -1) {
|
|
214
|
-
row.push("NULL");
|
|
215
|
-
colBlockHead = colBlockHead + INT_32_SIZE * fetchResponse.rows + new DataView(dataBuffer, j * INT_32_SIZE, INT_32_SIZE).getInt32(0, true);
|
|
216
|
-
} else {
|
|
217
|
-
colDataHead = colBlockHead + INT_32_SIZE * fetchResponse.rows + varOffset;
|
|
218
|
-
let dataLength = new DataView(dataBuffer, colDataHead, 2).getInt16(0, true);
|
|
219
|
-
// console.log("== loop var type length:" + dataLength)
|
|
220
|
-
if (isVarType == (0, $06d126546cf1c802$export$9c85ccb1eaab884c).VARCHAR) row.push($f52c4c4d89a4f2dd$var$readVarchar(dataBuffer, colDataHead + 2, dataLength));
|
|
221
|
-
else row.push($f52c4c4d89a4f2dd$var$readNchar(dataBuffer, colDataHead + 2, dataLength));
|
|
222
|
-
colBlockHead = colBlockHead + INT_32_SIZE * fetchResponse.rows + new DataView(dataBuffer, j * INT_32_SIZE, INT_32_SIZE).getInt32(0, true);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
taosResult.data.push(row);
|
|
227
|
-
}
|
|
228
|
-
return taosResult;
|
|
229
|
-
} else throw new (0, $35485c3d6c17b9b9$export$a28431cdd91982f0)("cannot fetch block for an update query.");
|
|
230
|
-
}
|
|
231
|
-
function $f52c4c4d89a4f2dd$var$_isVarTye(meta) {
|
|
232
|
-
switch(meta.type){
|
|
233
|
-
case (0, $06d126546cf1c802$export$9f025993407a7e76)["NCHAR"]:
|
|
234
|
-
return (0, $06d126546cf1c802$export$9c85ccb1eaab884c)["NCHAR"];
|
|
235
|
-
case (0, $06d126546cf1c802$export$9f025993407a7e76)["VARCHAR"]:
|
|
236
|
-
return (0, $06d126546cf1c802$export$9c85ccb1eaab884c)["VARCHAR"];
|
|
237
|
-
case (0, $06d126546cf1c802$export$9f025993407a7e76)["BINARY"]:
|
|
238
|
-
return (0, $06d126546cf1c802$export$9c85ccb1eaab884c)["VARCHAR"];
|
|
239
|
-
case (0, $06d126546cf1c802$export$9f025993407a7e76)["JSON"]:
|
|
240
|
-
return (0, $06d126546cf1c802$export$9c85ccb1eaab884c)["VARCHAR"];
|
|
241
|
-
default:
|
|
242
|
-
return (0, $06d126546cf1c802$export$9c85ccb1eaab884c)["SOLID"];
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
function $f52c4c4d89a4f2dd$var$readSolidData(dataBuffer, colDataHead, meta) {
|
|
246
|
-
switch(meta.type){
|
|
247
|
-
case (0, $06d126546cf1c802$export$9f025993407a7e76)["BOOL"]:
|
|
248
|
-
return Boolean(new DataView(dataBuffer, colDataHead, 1).getInt8(0));
|
|
249
|
-
case (0, $06d126546cf1c802$export$9f025993407a7e76)["TINYINT"]:
|
|
250
|
-
return new DataView(dataBuffer, colDataHead, 1).getInt8(0);
|
|
251
|
-
case (0, $06d126546cf1c802$export$9f025993407a7e76)["SMALLINT"]:
|
|
252
|
-
return new DataView(dataBuffer, colDataHead, 2).getInt16(0, true);
|
|
253
|
-
case (0, $06d126546cf1c802$export$9f025993407a7e76)["INT"]:
|
|
254
|
-
return new DataView(dataBuffer, colDataHead, 4).getInt32(0, true);
|
|
255
|
-
case (0, $06d126546cf1c802$export$9f025993407a7e76)["BIGINT"]:
|
|
256
|
-
return new DataView(dataBuffer, colDataHead, 8).getBigInt64(0, true);
|
|
257
|
-
case (0, $06d126546cf1c802$export$9f025993407a7e76)["TINYINT UNSIGNED"]:
|
|
258
|
-
return new DataView(dataBuffer, colDataHead, 1).getUint8(0);
|
|
259
|
-
case (0, $06d126546cf1c802$export$9f025993407a7e76)["SMALLINT UNSIGNED"]:
|
|
260
|
-
return new DataView(dataBuffer, colDataHead, 2).getUint16(0, true);
|
|
261
|
-
case (0, $06d126546cf1c802$export$9f025993407a7e76)["INT UNSIGNED"]:
|
|
262
|
-
return new DataView(dataBuffer, colDataHead, 4).getUint32(0, true);
|
|
263
|
-
case (0, $06d126546cf1c802$export$9f025993407a7e76)["BIGINT UNSIGNED"]:
|
|
264
|
-
return new DataView(dataBuffer, colDataHead, 8).getBigUint64(0, true);
|
|
265
|
-
case (0, $06d126546cf1c802$export$9f025993407a7e76)["FLOAT"]:
|
|
266
|
-
return parseFloat(new DataView(dataBuffer, colDataHead, 4).getFloat32(0, true).toFixed(5));
|
|
267
|
-
case (0, $06d126546cf1c802$export$9f025993407a7e76)["DOUBLE"]:
|
|
268
|
-
return parseFloat(new DataView(dataBuffer, colDataHead, 8).getFloat64(0, true).toFixed(15));
|
|
269
|
-
case (0, $06d126546cf1c802$export$9f025993407a7e76)["TIMESTAMP"]:
|
|
270
|
-
return new DataView(dataBuffer, colDataHead, 8).getBigInt64(0, true);
|
|
271
|
-
default:
|
|
272
|
-
throw new (0, $35485c3d6c17b9b9$export$bef77b941ab4e130)(`unspported type ${meta.type} for column ${meta.name}`);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
function $f52c4c4d89a4f2dd$var$readVarchar(dataBuffer, colDataHead, length) {
|
|
276
|
-
let data = "";
|
|
277
|
-
data += new TextDecoder().decode(dataBuffer.slice(colDataHead, colDataHead + length));
|
|
278
|
-
return data;
|
|
279
|
-
}
|
|
280
|
-
function $f52c4c4d89a4f2dd$var$readNchar(dataBuffer, colDataHead, length) {
|
|
281
|
-
let decoder = new TextDecoder();
|
|
282
|
-
let data = "";
|
|
283
|
-
let buff = dataBuffer.slice(colDataHead, colDataHead + length);
|
|
284
|
-
for(let i = 0; i < length / 4; i++)// console.log("== readNchar data:" + new DataView(buff, i * 4, 4).getUint32(0, true))
|
|
285
|
-
data += (0, $90711649818f52dd$export$ee9b81b89b187997)(new DataView(buff, i * 4, 4).getUint32(0, true));
|
|
286
|
-
return data;
|
|
287
|
-
}
|
|
288
|
-
function $f52c4c4d89a4f2dd$var$iteratorBuff(arr) {
|
|
289
|
-
let buf = $f52c4c4d89a4f2dd$require$Buffer.from(arr);
|
|
290
|
-
for (const value of buf)console.log(value.toString());
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
async function $b12d0de724a3a4fd$export$51396ec711da548b(sql, wsInterface) {
|
|
295
|
-
let taosResult;
|
|
296
|
-
let wsQueryResponse = await wsInterface.query(sql);
|
|
297
|
-
try {
|
|
298
|
-
taosResult = new (0, $f52c4c4d89a4f2dd$export$e452488413ae38a1)(wsQueryResponse);
|
|
299
|
-
if (wsQueryResponse.is_update == true) return taosResult;
|
|
300
|
-
else {
|
|
301
|
-
while(true){
|
|
302
|
-
let wsFetchResponse = await wsInterface.fetch(wsQueryResponse);
|
|
303
|
-
// console.log("[wsQuery.execute.wsFetchResponse]==>\n")
|
|
304
|
-
// console.log(wsFetchResponse)
|
|
305
|
-
// console.log(typeof BigInt(8))
|
|
306
|
-
// console.log(typeof wsFetchResponse.timing)
|
|
307
|
-
if (wsFetchResponse.completed == true) break;
|
|
308
|
-
else {
|
|
309
|
-
taosResult.setRows(wsFetchResponse);
|
|
310
|
-
let tmp = await wsInterface.fetchBlock(wsFetchResponse, taosResult);
|
|
311
|
-
taosResult = tmp;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
return taosResult;
|
|
315
|
-
}
|
|
316
|
-
} finally{
|
|
317
|
-
wsInterface.freeResult(wsQueryResponse);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
var $313c23b4e00a2403$var$_msgActionRegister = new Map();
|
|
326
|
-
class $313c23b4e00a2403$export$60c5222feb151075 {
|
|
327
|
-
_timeout = 5000;
|
|
328
|
-
// create ws
|
|
329
|
-
constructor(url){
|
|
330
|
-
// return w3bsocket3
|
|
331
|
-
if (url) {
|
|
332
|
-
this._wsURL = url;
|
|
333
|
-
let origin = url.origin;
|
|
334
|
-
let pathname = url.pathname;
|
|
335
|
-
let search = url.search;
|
|
336
|
-
this._wsConn = new (0, $9nax8$w3cwebsocket)(origin.concat(pathname).concat(search));
|
|
337
|
-
// this._wsConn.onopen = this._onopen
|
|
338
|
-
this._wsConn.onerror = function(err) {
|
|
339
|
-
throw err;
|
|
340
|
-
};
|
|
341
|
-
this._wsConn.onclose = this._onclose;
|
|
342
|
-
this._wsConn.onmessage = this._onmessage;
|
|
343
|
-
this._wsConn._binaryType = "arraybuffer";
|
|
344
|
-
} else throw new (0, $35485c3d6c17b9b9$export$bb331b3b46269060)("websocket URL must be defined");
|
|
345
|
-
}
|
|
346
|
-
Ready() {
|
|
347
|
-
return new Promise((resolve, reject)=>{
|
|
348
|
-
this._wsConn.onopen = ()=>{
|
|
349
|
-
// console.log("websocket connection opened")
|
|
350
|
-
resolve(this);
|
|
351
|
-
};
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
_onclose(e) {
|
|
355
|
-
return new Promise((resolve, reject)=>{
|
|
356
|
-
resolve("websocket connection closed");
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
_onmessage(event) {
|
|
360
|
-
let data = event.data;
|
|
361
|
-
// console.log("[wsClient._onMessage()._msgActionRegister]\n")
|
|
362
|
-
// console.log(_msgActionRegister)
|
|
363
|
-
// console.log("===="+ (Object.prototype.toString.call(data)))
|
|
364
|
-
if (Object.prototype.toString.call(data) === "[object ArrayBuffer]") {
|
|
365
|
-
let id = new DataView(data, 8, 8).getBigUint64(0, true);
|
|
366
|
-
// console.log("fetch block response id:" + id)
|
|
367
|
-
let action = undefined;
|
|
368
|
-
$313c23b4e00a2403$var$_msgActionRegister.forEach((v, k)=>{
|
|
369
|
-
if (k.id == id) {
|
|
370
|
-
action = v;
|
|
371
|
-
$313c23b4e00a2403$var$_msgActionRegister.delete(k);
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
if (action) action.resolve(data);
|
|
375
|
-
else {
|
|
376
|
-
$313c23b4e00a2403$var$_msgActionRegister.clear();
|
|
377
|
-
throw new (0, $35485c3d6c17b9b9$export$e04e72655114a7e)(`no callback registered for fetch_block with id=${id}`);
|
|
378
|
-
}
|
|
379
|
-
} else if (Object.prototype.toString.call(data) === "[object Blob]") data.arrayBuffer().then((d)=>{
|
|
380
|
-
let id = new DataView(d, 8, 8).getBigUint64(0, true);
|
|
381
|
-
// console.log("fetch block response id:" + id)
|
|
382
|
-
let action = undefined;
|
|
383
|
-
$313c23b4e00a2403$var$_msgActionRegister.forEach((v, k)=>{
|
|
384
|
-
if (k.id == id) {
|
|
385
|
-
action = v;
|
|
386
|
-
$313c23b4e00a2403$var$_msgActionRegister.delete(k);
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
if (action) action.resolve(d);
|
|
390
|
-
else {
|
|
391
|
-
$313c23b4e00a2403$var$_msgActionRegister.clear();
|
|
392
|
-
throw new (0, $35485c3d6c17b9b9$export$e04e72655114a7e)(`no callback registered for fetch_block with id=${id}`);
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
else if (Object.prototype.toString.call(data) === "[object String]") {
|
|
396
|
-
let msg = JSON.parse(data);
|
|
397
|
-
// console.log("[_onmessage.stringType]==>:" + data);
|
|
398
|
-
let action1 = undefined;
|
|
399
|
-
$313c23b4e00a2403$var$_msgActionRegister.forEach((v, k)=>{
|
|
400
|
-
if (k.action == "version") {
|
|
401
|
-
action1 = v;
|
|
402
|
-
$313c23b4e00a2403$var$_msgActionRegister.delete(k);
|
|
403
|
-
}
|
|
404
|
-
if (k.req_id == msg.req_id && k.action == msg.action) {
|
|
405
|
-
action1 = v;
|
|
406
|
-
$313c23b4e00a2403$var$_msgActionRegister.delete(k);
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
if (action1) action1.resolve(msg);
|
|
410
|
-
else {
|
|
411
|
-
$313c23b4e00a2403$var$_msgActionRegister.clear();
|
|
412
|
-
throw new (0, $35485c3d6c17b9b9$export$e04e72655114a7e)(`no callback registered for ${msg.action} with req_id=${msg.req_id}`);
|
|
413
|
-
}
|
|
414
|
-
} else {
|
|
415
|
-
$313c23b4e00a2403$var$_msgActionRegister.clear();
|
|
416
|
-
throw new (0, $35485c3d6c17b9b9$export$e04e72655114a7e)(`invalid message type ${Object.prototype.toString.call(data)}`);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
close() {
|
|
420
|
-
if (this._wsConn) {
|
|
421
|
-
$313c23b4e00a2403$var$_msgActionRegister.clear();
|
|
422
|
-
this._wsConn.close();
|
|
423
|
-
} else throw new (0, $35485c3d6c17b9b9$export$e04e72655114a7e)("WebSocket connection is undefined.");
|
|
424
|
-
}
|
|
425
|
-
readyState() {
|
|
426
|
-
return this._wsConn.readyState;
|
|
427
|
-
}
|
|
428
|
-
sendMsg(message, register = true) {
|
|
429
|
-
// console.log("[wsClient.sendMessage()]===>" + message)
|
|
430
|
-
let msg = JSON.parse(message);
|
|
431
|
-
// console.log(typeof msg.args.id)
|
|
432
|
-
if (msg.args.id) msg.args.id = BigInt(msg.args.id);
|
|
433
|
-
// console.log("[wsClient.sendMessage.msg]===>\n")
|
|
434
|
-
// console.log(msg)
|
|
435
|
-
return new Promise((resolve, reject)=>{
|
|
436
|
-
if (this._wsConn && this._wsConn.readyState > 0) {
|
|
437
|
-
if (register) this._registerCallback({
|
|
438
|
-
action: msg.action,
|
|
439
|
-
req_id: msg.args.req_id,
|
|
440
|
-
id: msg.args.id === undefined ? msg.args.id : BigInt(msg.args.id)
|
|
441
|
-
}, resolve, reject);
|
|
442
|
-
this._wsConn.send(message);
|
|
443
|
-
} else reject(new (0, $35485c3d6c17b9b9$export$bb331b3b46269060)(`WebSocket connection is not ready,status :${this._wsConn?.readyState}`));
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
_registerCallback(id, res, rej) {
|
|
447
|
-
// console.log("register messageId:"+ JSON.stringify(id))
|
|
448
|
-
$313c23b4e00a2403$var$_msgActionRegister.set(id, {
|
|
449
|
-
reject: rej,
|
|
450
|
-
resolve: res,
|
|
451
|
-
timer: setTimeout(()=>rej(new (0, $35485c3d6c17b9b9$export$bb331b3b46269060)(`action:${id.action},req_id:${id.req_id} timeout with ${this._timeout} milliseconds`)), this._timeout)
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
configTimeout(ms) {
|
|
455
|
-
this._timeout = ms;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
class $34ae905120c36523$export$32ebe749c88dc8fc {
|
|
462
|
-
constructor(msg){
|
|
463
|
-
this.version = msg.version;
|
|
464
|
-
this.code = msg.code;
|
|
465
|
-
this.message = msg.message;
|
|
466
|
-
this.action = msg.action;
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
class $34ae905120c36523$export$ab76f9e6bb13551a {
|
|
470
|
-
constructor(msg){
|
|
471
|
-
this.code = msg.code;
|
|
472
|
-
this.message = msg.message;
|
|
473
|
-
this.action = msg.action;
|
|
474
|
-
this.req_id = msg.req_id;
|
|
475
|
-
this.timing = BigInt(msg.timing);
|
|
476
|
-
this.id = BigInt(msg.id);
|
|
477
|
-
this.is_update = msg.is_update;
|
|
478
|
-
this.affected_rows = msg.affected_rows;
|
|
479
|
-
this.fields_count = msg.fields_count;
|
|
480
|
-
this.fields_names = msg.fields_names;
|
|
481
|
-
this.fields_types = msg.fields_types;
|
|
482
|
-
this.fields_lengths = msg.fields_lengths;
|
|
483
|
-
this.precision = msg.precision;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
class $34ae905120c36523$export$3f2f9b8b1b9adb1c {
|
|
487
|
-
constructor(msg){
|
|
488
|
-
this.code = msg.code;
|
|
489
|
-
this.message = msg.message;
|
|
490
|
-
this.action = msg.action;
|
|
491
|
-
this.req_id = msg.req_id;
|
|
492
|
-
this.timing = BigInt(msg.timing);
|
|
493
|
-
this.id = BigInt(msg.id);
|
|
494
|
-
this.completed = msg.completed;
|
|
495
|
-
this.length = msg.length;
|
|
496
|
-
this.rows = msg.rows;
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
class $34ae905120c36523$export$322bf5a2be43493 {
|
|
500
|
-
constructor(msg){
|
|
501
|
-
this.timing = new DataView(msg, 0, 8).getBigUint64(0, true);
|
|
502
|
-
this.id = new DataView(msg, 8, 8).getBigUint64(0, true);
|
|
503
|
-
this.data = msg.slice(16);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
class $34ae905120c36523$export$99f0d6683d6024ac {
|
|
507
|
-
constructor(msg){
|
|
508
|
-
this.code = msg.code;
|
|
509
|
-
this.message = msg.message;
|
|
510
|
-
this.action = msg.action;
|
|
511
|
-
this.req_id = msg.req_id;
|
|
512
|
-
this.timing = BigInt(msg.timing);
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
class $54545eae142996f0$export$84a38ced4e7f1e4e {
|
|
519
|
-
_req_id = 0;
|
|
520
|
-
constructor(url){
|
|
521
|
-
this.checkURL(url);
|
|
522
|
-
this._url = url;
|
|
523
|
-
this._wsQueryClient = new (0, $313c23b4e00a2403$export$60c5222feb151075)(this._url);
|
|
524
|
-
}
|
|
525
|
-
connect(database) {
|
|
526
|
-
let _db = this._url.pathname.split("/")[3];
|
|
527
|
-
if (database) _db = database;
|
|
528
|
-
this._reqIDIncrement();
|
|
529
|
-
let connMsg = {
|
|
530
|
-
action: "conn",
|
|
531
|
-
args: {
|
|
532
|
-
req_id: this._req_id,
|
|
533
|
-
user: this._url.username,
|
|
534
|
-
password: this._url.password,
|
|
535
|
-
db: _db
|
|
536
|
-
}
|
|
537
|
-
};
|
|
538
|
-
// console.log(connMsg)
|
|
539
|
-
return new Promise((resolve, reject)=>{
|
|
540
|
-
if (this._wsQueryClient.readyState() > 0) this._wsQueryClient.sendMsg(JSON.stringify(connMsg)).then((e)=>{
|
|
541
|
-
if (e.code == 0) resolve(e);
|
|
542
|
-
else reject(new (0, $35485c3d6c17b9b9$export$bb331b3b46269060)(`${e.message}, code ${e.code}`));
|
|
543
|
-
});
|
|
544
|
-
else this._wsQueryClient.Ready().then((ws)=>{
|
|
545
|
-
return ws.sendMsg(JSON.stringify(connMsg));
|
|
546
|
-
}).then((e)=>{
|
|
547
|
-
if (e.code == 0) resolve(e);
|
|
548
|
-
else reject(new (0, $35485c3d6c17b9b9$export$bb331b3b46269060)(`${e.message}, code ${e.code}`));
|
|
549
|
-
});
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
// need to construct Response.
|
|
553
|
-
query(sql) {
|
|
554
|
-
this._reqIDIncrement();
|
|
555
|
-
// construct msg
|
|
556
|
-
let queryMsg = {
|
|
557
|
-
action: "query",
|
|
558
|
-
args: {
|
|
559
|
-
req_id: this._req_id,
|
|
560
|
-
sql: sql
|
|
561
|
-
}
|
|
562
|
-
};
|
|
563
|
-
return new Promise((resolve, reject)=>{
|
|
564
|
-
let jsonStr = JSON.stringify(queryMsg);
|
|
565
|
-
// console.log("[wsQueryInterface.query.queryMsg]===>" + jsonStr)
|
|
566
|
-
this._wsQueryClient.sendMsg(jsonStr).then((e)=>{
|
|
567
|
-
if (e.code == 0) resolve(new (0, $34ae905120c36523$export$ab76f9e6bb13551a)(e));
|
|
568
|
-
else reject(new (0, $35485c3d6c17b9b9$export$d45d01cc7570ed33)(`${e.message},code ${e.code}`));
|
|
569
|
-
});
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
getState() {
|
|
573
|
-
return this._wsQueryClient.readyState();
|
|
574
|
-
}
|
|
575
|
-
fetch(res) {
|
|
576
|
-
this._reqIDIncrement();
|
|
577
|
-
let fetchMsg = {
|
|
578
|
-
action: "fetch",
|
|
579
|
-
args: {
|
|
580
|
-
req_id: this._req_id,
|
|
581
|
-
id: res.id
|
|
582
|
-
}
|
|
583
|
-
};
|
|
584
|
-
// console.log("[wsQueryInterface.fetch()]===>wsQueryResponse\n")
|
|
585
|
-
// console.log(res)
|
|
586
|
-
return new Promise((resolve, reject)=>{
|
|
587
|
-
let jsonStr = (0, $9nax8$jsonbigint).stringify(fetchMsg);
|
|
588
|
-
// console.log("[wsQueryInterface.fetch.fetchMsg]===>" + jsonStr)
|
|
589
|
-
this._wsQueryClient.sendMsg(jsonStr).then((e)=>{
|
|
590
|
-
if (e.code == 0) resolve(new (0, $34ae905120c36523$export$3f2f9b8b1b9adb1c)(e));
|
|
591
|
-
else reject(new (0, $35485c3d6c17b9b9$export$d45d01cc7570ed33)(`${e.message},code ${e.code}`));
|
|
592
|
-
}).catch((e)=>{
|
|
593
|
-
reject(e);
|
|
594
|
-
});
|
|
595
|
-
});
|
|
596
|
-
}
|
|
597
|
-
fetchBlock(fetchResponse, taosResult) {
|
|
598
|
-
this._reqIDIncrement();
|
|
599
|
-
let fetchBlockMsg = {
|
|
600
|
-
action: "fetch_block",
|
|
601
|
-
args: {
|
|
602
|
-
"req_id": this._req_id,
|
|
603
|
-
"id": fetchResponse.id
|
|
604
|
-
}
|
|
605
|
-
};
|
|
606
|
-
return new Promise((resolve, reject)=>{
|
|
607
|
-
let jsonStr = (0, $9nax8$jsonbigint).stringify(fetchBlockMsg);
|
|
608
|
-
// console.log("[wsQueryInterface.fetchBlock.fetchBlockMsg]===>" + jsonStr)
|
|
609
|
-
this._wsQueryClient.sendMsg(jsonStr).then((e)=>{
|
|
610
|
-
resolve((0, $f52c4c4d89a4f2dd$export$4aed668c47d45036)(fetchResponse, new (0, $34ae905120c36523$export$322bf5a2be43493)(e), taosResult));
|
|
611
|
-
// if retrieve JSON then reject with message
|
|
612
|
-
// else is binary , so parse raw block to TaosResult
|
|
613
|
-
}).catch((e)=>reject(e));
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
freeResult(res) {
|
|
617
|
-
this._reqIDIncrement();
|
|
618
|
-
let freeResultMsg = {
|
|
619
|
-
action: "free_result",
|
|
620
|
-
args: {
|
|
621
|
-
req_id: this._req_id,
|
|
622
|
-
id: res.id
|
|
623
|
-
}
|
|
624
|
-
};
|
|
625
|
-
return new Promise((resolve, reject)=>{
|
|
626
|
-
let jsonStr = (0, $9nax8$jsonbigint).stringify(freeResultMsg);
|
|
627
|
-
// console.log("[wsQueryInterface.freeResult.freeResultMsg]===>" + jsonStr)
|
|
628
|
-
this._wsQueryClient.sendMsg(jsonStr, false).then((e)=>{
|
|
629
|
-
resolve(e);
|
|
630
|
-
}).catch((e)=>reject(e));
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
version() {
|
|
634
|
-
this._reqIDIncrement();
|
|
635
|
-
let versionMsg = {
|
|
636
|
-
action: "version",
|
|
637
|
-
args: {
|
|
638
|
-
req_id: this._req_id
|
|
639
|
-
}
|
|
640
|
-
};
|
|
641
|
-
return new Promise((resolve, reject)=>{
|
|
642
|
-
if (this._wsQueryClient.readyState() > 0) this._wsQueryClient.sendMsg((0, $9nax8$jsonbigint).stringify(versionMsg)).then((e)=>{
|
|
643
|
-
// console.log(e)
|
|
644
|
-
if (e.code == 0) resolve(new (0, $34ae905120c36523$export$32ebe749c88dc8fc)(e).version);
|
|
645
|
-
else reject(new (0, $34ae905120c36523$export$32ebe749c88dc8fc)(e).message);
|
|
646
|
-
}).catch((e)=>reject(e));
|
|
647
|
-
this._wsQueryClient.Ready().then((ws)=>{
|
|
648
|
-
return ws.sendMsg((0, $9nax8$jsonbigint).stringify(versionMsg));
|
|
649
|
-
}).then((e)=>{
|
|
650
|
-
// console.log(e)
|
|
651
|
-
if (e.code == 0) resolve(new (0, $34ae905120c36523$export$32ebe749c88dc8fc)(e).version);
|
|
652
|
-
else reject(new (0, $34ae905120c36523$export$32ebe749c88dc8fc)(e).message);
|
|
653
|
-
}).catch((e)=>reject(e));
|
|
654
|
-
});
|
|
655
|
-
}
|
|
656
|
-
close() {
|
|
657
|
-
this._wsQueryClient.close();
|
|
658
|
-
}
|
|
659
|
-
checkURL(url) {
|
|
660
|
-
// Assert is cloud url
|
|
661
|
-
if (!url.searchParams.has("token")) {
|
|
662
|
-
if (!(url.username || url.password)) throw new (0, $35485c3d6c17b9b9$export$d45d01cc7570ed33)("invalid url, password or username needed.");
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
_reqIDIncrement() {
|
|
666
|
-
if (this._req_id == Number.MAX_SAFE_INTEGER) this._req_id = 0;
|
|
667
|
-
else this._req_id += 1;
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
class $f94dfcb91851ade6$export$d15bd779f38f3fbe {
|
|
673
|
-
_data = [];
|
|
674
|
-
_meta = [];
|
|
675
|
-
constructor(url){
|
|
676
|
-
this._wsInterface = new (0, $54545eae142996f0$export$84a38ced4e7f1e4e)(new URL(url));
|
|
677
|
-
}
|
|
678
|
-
connect(database) {
|
|
679
|
-
return this._wsInterface.connect(database);
|
|
680
|
-
}
|
|
681
|
-
state() {
|
|
682
|
-
return this._wsInterface.getState();
|
|
683
|
-
}
|
|
684
|
-
/**
|
|
685
|
-
* return client version.
|
|
686
|
-
*/ version() {
|
|
687
|
-
return this._wsInterface.version();
|
|
688
|
-
}
|
|
689
|
-
query(sql) {
|
|
690
|
-
return (0, $b12d0de724a3a4fd$export$51396ec711da548b)(sql, this._wsInterface);
|
|
691
|
-
}
|
|
692
|
-
close() {
|
|
693
|
-
this._wsInterface.close();
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
let $c3f6c693698dc7cd$export$64605811ab45167f = (url)=>{
|
|
699
|
-
return new (0, $f94dfcb91851ade6$export$d15bd779f38f3fbe)(url);
|
|
700
|
-
};
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
export {$c3f6c693698dc7cd$export$64605811ab45167f as connect};
|
|
704
|
-
//# sourceMappingURL=index.mjs.map
|