@tdengine/websocket 3.1.9 → 3.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/lib/example/all_type_query.js +26 -22
- package/lib/example/all_type_stmt.js +22 -20
- package/lib/example/basicBatchTmq.js +14 -14
- package/lib/example/basicSchemaless.js +11 -11
- package/lib/example/basicSql.js +10 -10
- package/lib/example/basicStmt.js +3 -3
- package/lib/example/basicTmq.js +8 -9
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/src/client/wsClient.d.ts +3 -2
- package/lib/src/client/wsClient.d.ts.map +1 -1
- package/lib/src/client/wsClient.js +66 -40
- package/lib/src/client/wsConnector.d.ts.map +1 -1
- package/lib/src/client/wsConnector.js +40 -14
- package/lib/src/client/wsConnectorPool.d.ts.map +1 -1
- package/lib/src/client/wsConnectorPool.js +29 -14
- package/lib/src/client/wsEventCallback.d.ts.map +1 -1
- package/lib/src/client/wsEventCallback.js +6 -4
- package/lib/src/client/wsResponse.d.ts.map +1 -1
- package/lib/src/client/wsResponse.js +6 -2
- package/lib/src/common/config.d.ts +5 -3
- package/lib/src/common/config.d.ts.map +1 -1
- package/lib/src/common/config.js +15 -5
- package/lib/src/common/constant.d.ts +11 -1
- package/lib/src/common/constant.d.ts.map +1 -1
- package/lib/src/common/constant.js +48 -40
- package/lib/src/common/log.d.ts +1 -1
- package/lib/src/common/log.d.ts.map +1 -1
- package/lib/src/common/log.js +9 -7
- package/lib/src/common/reqid.d.ts.map +1 -1
- package/lib/src/common/reqid.js +7 -7
- package/lib/src/common/taosResult.d.ts.map +1 -1
- package/lib/src/common/taosResult.js +46 -27
- package/lib/src/common/ut8Helper.d.ts.map +1 -1
- package/lib/src/common/ut8Helper.js +8 -8
- package/lib/src/common/utils.d.ts.map +1 -1
- package/lib/src/common/utils.js +17 -16
- package/lib/src/common/wsError.d.ts.map +1 -1
- package/lib/src/common/wsError.js +3 -3
- package/lib/src/common/wsOptions.d.ts +1 -1
- package/lib/src/index.d.ts +3 -3
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/sql/wsProto.d.ts.map +1 -1
- package/lib/src/sql/wsRows.d.ts +3 -3
- package/lib/src/sql/wsRows.d.ts.map +1 -1
- package/lib/src/sql/wsRows.js +4 -2
- package/lib/src/sql/wsSql.d.ts +5 -5
- package/lib/src/sql/wsSql.d.ts.map +1 -1
- package/lib/src/sql/wsSql.js +23 -15
- package/lib/src/stmt/FieldBindParams.d.ts +9 -0
- package/lib/src/stmt/FieldBindParams.d.ts.map +1 -0
- package/lib/src/stmt/FieldBindParams.js +13 -0
- package/lib/src/stmt/wsColumnInfo.d.ts +12 -0
- package/lib/src/stmt/wsColumnInfo.d.ts.map +1 -0
- package/lib/src/stmt/wsColumnInfo.js +17 -0
- package/lib/src/stmt/wsParams1.d.ts +14 -0
- package/lib/src/stmt/wsParams1.d.ts.map +1 -0
- package/lib/src/stmt/wsParams1.js +300 -0
- package/lib/src/stmt/wsParams2.d.ts +14 -0
- package/lib/src/stmt/wsParams2.d.ts.map +1 -0
- package/lib/src/stmt/wsParams2.js +203 -0
- package/lib/src/stmt/wsParamsBase.d.ts +45 -0
- package/lib/src/stmt/wsParamsBase.d.ts.map +1 -0
- package/lib/src/stmt/wsParamsBase.js +220 -0
- package/lib/src/stmt/wsProto.d.ts +13 -1
- package/lib/src/stmt/wsProto.d.ts.map +1 -1
- package/lib/src/stmt/wsProto.js +206 -2
- package/lib/src/stmt/wsStmt.d.ts +6 -16
- package/lib/src/stmt/wsStmt.d.ts.map +1 -1
- package/lib/src/stmt/wsStmt.js +0 -201
- package/lib/src/stmt/wsStmt1.d.ts +30 -0
- package/lib/src/stmt/wsStmt1.d.ts.map +1 -0
- package/lib/src/stmt/wsStmt1.js +206 -0
- package/lib/src/stmt/wsStmt2.d.ts +37 -0
- package/lib/src/stmt/wsStmt2.d.ts.map +1 -0
- package/lib/src/stmt/wsStmt2.js +284 -0
- package/lib/src/stmt/wsTableInfo.d.ts +17 -0
- package/lib/src/stmt/wsTableInfo.d.ts.map +1 -0
- package/lib/src/stmt/wsTableInfo.js +54 -0
- package/lib/src/tmq/config.d.ts.map +1 -1
- package/lib/src/tmq/config.js +2 -2
- package/lib/src/tmq/constant.d.ts.map +1 -1
- package/lib/src/tmq/constant.js +28 -28
- package/lib/src/tmq/tmqResponse.d.ts.map +1 -1
- package/lib/src/tmq/tmqResponse.js +31 -17
- package/lib/src/tmq/wsTmq.d.ts +2 -2
- package/lib/src/tmq/wsTmq.d.ts.map +1 -1
- package/lib/src/tmq/wsTmq.js +32 -30
- package/lib/test/bulkPulling/cloud.tmq.test.js +11 -11
- package/lib/test/bulkPulling/decimal.test.js +50 -26
- package/lib/test/bulkPulling/log.test.js +8 -8
- package/lib/test/bulkPulling/queryTables.test.js +255 -49
- package/lib/test/bulkPulling/schemaless.test.js +34 -34
- package/lib/test/bulkPulling/sql.test.js +108 -66
- package/lib/test/bulkPulling/stmt1.func.test.d.ts +2 -0
- package/lib/test/bulkPulling/stmt1.func.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/{stmt.func.test.js → stmt1.func.test.js} +128 -116
- package/lib/test/bulkPulling/stmt1.type.test.d.ts +2 -0
- package/lib/test/bulkPulling/stmt1.type.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/stmt1.type.test.js +399 -0
- package/lib/test/bulkPulling/stmt2.func.test.d.ts +2 -0
- package/lib/test/bulkPulling/stmt2.func.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/stmt2.func.test.js +543 -0
- package/lib/test/bulkPulling/stmt2.type.test.d.ts +2 -0
- package/lib/test/bulkPulling/stmt2.type.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/{stmt.type.test.js → stmt2.type.test.js} +136 -49
- package/lib/test/bulkPulling/tmq.test.js +225 -31
- package/lib/test/bulkPulling/utils.test.js +2 -2
- package/lib/test/bulkPulling/wsConnectPool.test.js +20 -20
- package/lib/test/utils.d.ts.map +1 -1
- package/lib/test/utils.js +130 -129
- package/package.json +1 -1
- package/readme.md +1 -0
- package/lib/src/stmt/wsParams.d.ts +0 -41
- package/lib/src/stmt/wsParams.d.ts.map +0 -1
- package/lib/src/stmt/wsParams.js +0 -428
- package/lib/test/bulkPulling/stmt.func.test.d.ts +0 -2
- package/lib/test/bulkPulling/stmt.func.test.d.ts.map +0 -1
- package/lib/test/bulkPulling/stmt.type.test.d.ts +0 -2
- package/lib/test/bulkPulling/stmt.type.test.d.ts.map +0 -1
|
@@ -18,13 +18,14 @@ class WsClient {
|
|
|
18
18
|
this._url = url;
|
|
19
19
|
this._timeout = timeout;
|
|
20
20
|
if (this._url.searchParams.has("timezone")) {
|
|
21
|
-
this._timezone =
|
|
21
|
+
this._timezone =
|
|
22
|
+
this._url.searchParams.get("timezone") || undefined;
|
|
22
23
|
this._url.searchParams.delete("timezone");
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
async connect(database) {
|
|
26
27
|
let connMsg = {
|
|
27
|
-
action:
|
|
28
|
+
action: "conn",
|
|
28
29
|
args: {
|
|
29
30
|
req_id: reqid_1.ReqId.getReqID(),
|
|
30
31
|
user: (0, utils_1.safeDecodeURIComponent)(this._url.username),
|
|
@@ -34,7 +35,8 @@ class WsClient {
|
|
|
34
35
|
},
|
|
35
36
|
};
|
|
36
37
|
log_1.default.debug("[wsClient.connect.connMsg]===>" + json_bigint_1.default.stringify(connMsg));
|
|
37
|
-
this._wsConnector =
|
|
38
|
+
this._wsConnector =
|
|
39
|
+
await wsConnectorPool_1.WebSocketConnectionPool.instance().getConnection(this._url, this._timeout);
|
|
38
40
|
if (this._wsConnector.readyState() === websocket_1.w3cwebsocket.OPEN) {
|
|
39
41
|
return;
|
|
40
42
|
}
|
|
@@ -45,27 +47,27 @@ class WsClient {
|
|
|
45
47
|
return;
|
|
46
48
|
}
|
|
47
49
|
await this.close();
|
|
48
|
-
throw
|
|
50
|
+
throw new wsError_1.WebSocketQueryError(result.msg.code, result.msg.message);
|
|
49
51
|
}
|
|
50
52
|
catch (e) {
|
|
51
53
|
await this.close();
|
|
52
54
|
log_1.default.error(`connection creation failed, url: ${this._url}, code:${e.code}, msg:${e.message}`);
|
|
53
|
-
throw
|
|
55
|
+
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `connection creation failed, url: ${this._url}, code:${e.code}, msg:${e.message}`);
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
async setOptionConnection(option, value) {
|
|
57
59
|
log_1.default.debug("[wsClient.setOptionConnection]===>" + option + ", " + value);
|
|
58
60
|
let connMsg = {
|
|
59
|
-
action:
|
|
61
|
+
action: "options_connection",
|
|
60
62
|
args: {
|
|
61
63
|
req_id: reqid_1.ReqId.getReqID(),
|
|
62
64
|
options: [
|
|
63
65
|
{
|
|
64
66
|
option: option,
|
|
65
|
-
value: value
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
}
|
|
67
|
+
value: value,
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
69
71
|
};
|
|
70
72
|
try {
|
|
71
73
|
await this.exec(json_bigint_1.default.stringify(connMsg), false);
|
|
@@ -76,19 +78,23 @@ class WsClient {
|
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
async execNoResp(queryMsg) {
|
|
79
|
-
log_1.default.debug(
|
|
80
|
-
if (this._wsConnector &&
|
|
81
|
+
log_1.default.debug("[wsQueryInterface.query.queryMsg]===>" + queryMsg);
|
|
82
|
+
if (this._wsConnector &&
|
|
83
|
+
this._wsConnector.readyState() === websocket_1.w3cwebsocket.OPEN) {
|
|
81
84
|
await this._wsConnector.sendMsgNoResp(queryMsg);
|
|
82
85
|
return;
|
|
83
86
|
}
|
|
84
|
-
throw
|
|
87
|
+
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_CONNECTION_CLOSED, "invalid websocket connect");
|
|
85
88
|
}
|
|
86
89
|
// need to construct Response.
|
|
87
90
|
async exec(queryMsg, bSqlQuery = true) {
|
|
88
91
|
return new Promise((resolve, reject) => {
|
|
89
|
-
log_1.default.debug(
|
|
90
|
-
if (this._wsConnector &&
|
|
91
|
-
this._wsConnector.
|
|
92
|
+
log_1.default.debug("[wsQueryInterface.query.queryMsg]===>" + queryMsg);
|
|
93
|
+
if (this._wsConnector &&
|
|
94
|
+
this._wsConnector.readyState() === websocket_1.w3cwebsocket.OPEN) {
|
|
95
|
+
this._wsConnector
|
|
96
|
+
.sendMsg(queryMsg)
|
|
97
|
+
.then((e) => {
|
|
92
98
|
if (e.msg.code == 0) {
|
|
93
99
|
if (bSqlQuery) {
|
|
94
100
|
resolve(new wsResponse_1.WSQueryResponse(e));
|
|
@@ -100,7 +106,10 @@ class WsClient {
|
|
|
100
106
|
else {
|
|
101
107
|
reject(new wsError_1.WebSocketInterfaceError(e.msg.code, e.msg.message));
|
|
102
108
|
}
|
|
103
|
-
})
|
|
109
|
+
})
|
|
110
|
+
.catch((e) => {
|
|
111
|
+
reject(e);
|
|
112
|
+
});
|
|
104
113
|
}
|
|
105
114
|
else {
|
|
106
115
|
reject(new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_CONNECTION_CLOSED, "invalid websocket connect"));
|
|
@@ -110,8 +119,11 @@ class WsClient {
|
|
|
110
119
|
// need to construct Response.
|
|
111
120
|
async sendBinaryMsg(reqId, action, message, bSqlQuery = true, bResultBinary = false) {
|
|
112
121
|
return new Promise((resolve, reject) => {
|
|
113
|
-
if (this._wsConnector &&
|
|
114
|
-
this._wsConnector.
|
|
122
|
+
if (this._wsConnector &&
|
|
123
|
+
this._wsConnector.readyState() === websocket_1.w3cwebsocket.OPEN) {
|
|
124
|
+
this._wsConnector
|
|
125
|
+
.sendBinaryMsg(reqId, action, message)
|
|
126
|
+
.then((e) => {
|
|
115
127
|
if (bResultBinary) {
|
|
116
128
|
resolve(e);
|
|
117
129
|
}
|
|
@@ -126,7 +138,10 @@ class WsClient {
|
|
|
126
138
|
else {
|
|
127
139
|
reject(new wsError_1.WebSocketInterfaceError(e.msg.code, e.msg.message));
|
|
128
140
|
}
|
|
129
|
-
})
|
|
141
|
+
})
|
|
142
|
+
.catch((e) => {
|
|
143
|
+
reject(e);
|
|
144
|
+
});
|
|
130
145
|
}
|
|
131
146
|
else {
|
|
132
147
|
reject(new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_CONNECTION_CLOSED, "invalid websocket connect"));
|
|
@@ -141,7 +156,8 @@ class WsClient {
|
|
|
141
156
|
}
|
|
142
157
|
async ready() {
|
|
143
158
|
try {
|
|
144
|
-
this._wsConnector =
|
|
159
|
+
this._wsConnector =
|
|
160
|
+
await wsConnectorPool_1.WebSocketConnectionPool.instance().getConnection(this._url, this._timeout);
|
|
145
161
|
if (this._wsConnector.readyState() !== websocket_1.w3cwebsocket.OPEN) {
|
|
146
162
|
await this._wsConnector.ready();
|
|
147
163
|
}
|
|
@@ -150,16 +166,20 @@ class WsClient {
|
|
|
150
166
|
}
|
|
151
167
|
catch (e) {
|
|
152
168
|
log_1.default.error(`connection creation failed, url: ${this._url}, code: ${e.code}, message: ${e.message}`);
|
|
153
|
-
throw
|
|
169
|
+
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `connection creation failed, url: ${this._url}, code: ${e.code}, message: ${e.message}`);
|
|
154
170
|
}
|
|
155
171
|
}
|
|
156
172
|
async sendMsg(msg) {
|
|
157
173
|
return new Promise((resolve, reject) => {
|
|
158
174
|
log_1.default.debug("[wsQueryInterface.sendMsg]===>" + msg);
|
|
159
|
-
if (this._wsConnector &&
|
|
160
|
-
this._wsConnector.
|
|
175
|
+
if (this._wsConnector &&
|
|
176
|
+
this._wsConnector.readyState() === websocket_1.w3cwebsocket.OPEN) {
|
|
177
|
+
this._wsConnector
|
|
178
|
+
.sendMsg(msg)
|
|
179
|
+
.then((e) => {
|
|
161
180
|
resolve(e);
|
|
162
|
-
})
|
|
181
|
+
})
|
|
182
|
+
.catch((e) => reject(e));
|
|
163
183
|
}
|
|
164
184
|
else {
|
|
165
185
|
reject(new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_CONNECTION_CLOSED, "invalid websocket connect"));
|
|
@@ -168,7 +188,7 @@ class WsClient {
|
|
|
168
188
|
}
|
|
169
189
|
async freeResult(res) {
|
|
170
190
|
let freeResultMsg = {
|
|
171
|
-
action:
|
|
191
|
+
action: "free_result",
|
|
172
192
|
args: {
|
|
173
193
|
req_id: reqid_1.ReqId.getReqID(),
|
|
174
194
|
id: res.id,
|
|
@@ -177,9 +197,13 @@ class WsClient {
|
|
|
177
197
|
return new Promise((resolve, reject) => {
|
|
178
198
|
let jsonStr = json_bigint_1.default.stringify(freeResultMsg);
|
|
179
199
|
log_1.default.debug("[wsQueryInterface.freeResult.freeResultMsg]===>" + jsonStr);
|
|
180
|
-
if (this._wsConnector &&
|
|
181
|
-
this._wsConnector.
|
|
182
|
-
|
|
200
|
+
if (this._wsConnector &&
|
|
201
|
+
this._wsConnector.readyState() === websocket_1.w3cwebsocket.OPEN) {
|
|
202
|
+
this._wsConnector
|
|
203
|
+
.sendMsgNoResp(jsonStr)
|
|
204
|
+
.then((e) => {
|
|
205
|
+
resolve(e);
|
|
206
|
+
})
|
|
183
207
|
.catch((e) => reject(e));
|
|
184
208
|
}
|
|
185
209
|
else {
|
|
@@ -188,10 +212,13 @@ class WsClient {
|
|
|
188
212
|
});
|
|
189
213
|
}
|
|
190
214
|
async version() {
|
|
215
|
+
if (this._version) {
|
|
216
|
+
return this._version;
|
|
217
|
+
}
|
|
191
218
|
let versionMsg = {
|
|
192
|
-
action:
|
|
219
|
+
action: "version",
|
|
193
220
|
args: {
|
|
194
|
-
req_id: reqid_1.ReqId.getReqID()
|
|
221
|
+
req_id: reqid_1.ReqId.getReqID(),
|
|
195
222
|
},
|
|
196
223
|
};
|
|
197
224
|
if (this._wsConnector) {
|
|
@@ -203,11 +230,11 @@ class WsClient {
|
|
|
203
230
|
if (result.msg.code == 0) {
|
|
204
231
|
return new wsResponse_1.WSVersionResponse(result).version;
|
|
205
232
|
}
|
|
206
|
-
throw
|
|
233
|
+
throw new wsError_1.WebSocketInterfaceError(result.msg.code, result.msg.message);
|
|
207
234
|
}
|
|
208
235
|
catch (e) {
|
|
209
236
|
log_1.default.error(`connection creation failed, url: ${this._url}, code: ${e.code}, message: ${e.message}`);
|
|
210
|
-
throw
|
|
237
|
+
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `connection creation failed, url: ${this._url}, code: ${e.code}, message: ${e.message}`);
|
|
211
238
|
}
|
|
212
239
|
}
|
|
213
240
|
throw (wsError_1.ErrorCode.ERR_CONNECTION_CLOSED, "invalid websocket connect");
|
|
@@ -216,23 +243,22 @@ class WsClient {
|
|
|
216
243
|
if (this._wsConnector) {
|
|
217
244
|
await wsConnectorPool_1.WebSocketConnectionPool.instance().releaseConnection(this._wsConnector);
|
|
218
245
|
this._wsConnector = undefined;
|
|
219
|
-
// this._wsConnector.close();
|
|
220
246
|
}
|
|
221
247
|
}
|
|
222
248
|
checkURL(url) {
|
|
223
249
|
// Assert is cloud url
|
|
224
|
-
if (!url.searchParams.has(
|
|
250
|
+
if (!url.searchParams.has("token")) {
|
|
225
251
|
if (!(url.username || url.password)) {
|
|
226
|
-
throw new wsError_1.WebSocketInterfaceError(wsError_1.ErrorCode.ERR_INVALID_AUTHENTICATION,
|
|
252
|
+
throw new wsError_1.WebSocketInterfaceError(wsError_1.ErrorCode.ERR_INVALID_AUTHENTICATION, "invalid url, password or username needed.");
|
|
227
253
|
}
|
|
228
254
|
}
|
|
229
255
|
}
|
|
230
256
|
async checkVersion() {
|
|
231
|
-
|
|
232
|
-
let result = (0, utils_1.compareVersions)(
|
|
257
|
+
this._version = await this.version();
|
|
258
|
+
let result = (0, utils_1.compareVersions)(this._version, WsClient._minVersion);
|
|
233
259
|
if (result < 0) {
|
|
234
|
-
log_1.default.error(`TDengine version is too low, current version: ${
|
|
235
|
-
throw
|
|
260
|
+
log_1.default.error(`TDengine version is too low, current version: ${this._version}, minimum required version: ${WsClient._minVersion}`);
|
|
261
|
+
throw new wsError_1.WebSocketQueryError(wsError_1.ErrorCode.ERR_TDENIGNE_VERSION_IS_TOO_LOW, `Version mismatch. The minimum required TDengine version is ${WsClient._minVersion}`);
|
|
236
262
|
}
|
|
237
263
|
}
|
|
238
264
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsConnector.d.ts","sourceRoot":"","sources":["../../../src/client/wsConnector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wsConnector.d.ts","sourceRoot":"","sources":["../../../src/client/wsConnector.ts"],"names":[],"mappings":"AAUA,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,MAAM,CAAM;IACpB,QAAQ,SAAQ;gBAGJ,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAuClD,KAAK;YA6BG,QAAQ;IAItB,OAAO,CAAC,UAAU;IA4BlB,KAAK;IAWL,UAAU,IAAI,MAAM;IAId,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsB7C,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAE,OAAc;IAqCjD,aAAa,CACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,QAAQ,GAAE,OAAc;IAkCrB,QAAQ,IAAI,GAAG;CAGzB"}
|
|
@@ -22,8 +22,13 @@ class WebSocketConnector {
|
|
|
22
22
|
if (timeout) {
|
|
23
23
|
this._timeout = timeout;
|
|
24
24
|
}
|
|
25
|
-
this._wsConn = new websocket_1.w3cwebsocket(origin.concat(pathname).concat(search), undefined, undefined, undefined, undefined, {
|
|
26
|
-
|
|
25
|
+
this._wsConn = new websocket_1.w3cwebsocket(origin.concat(pathname).concat(search), undefined, undefined, undefined, undefined, {
|
|
26
|
+
maxReceivedFrameSize: 0x60000000,
|
|
27
|
+
maxReceivedMessageSize: 0x60000000,
|
|
28
|
+
});
|
|
29
|
+
this._wsConn.onerror = function (err) {
|
|
30
|
+
log_1.default.error(`webSocket connection failed, url: ${this.url}, error: ${err.message}`);
|
|
31
|
+
};
|
|
27
32
|
this._wsConn.onclose = this._onclose;
|
|
28
33
|
this._wsConn.onmessage = this._onmessage;
|
|
29
34
|
this._wsConn._binaryType = "arraybuffer";
|
|
@@ -35,11 +40,19 @@ class WebSocketConnector {
|
|
|
35
40
|
async ready() {
|
|
36
41
|
return new Promise((resolve, reject) => {
|
|
37
42
|
let reqId = reqid_1.ReqId.getReqID();
|
|
38
|
-
wsEventCallback_1.WsEventCallback.instance().registerCallback({
|
|
39
|
-
|
|
43
|
+
wsEventCallback_1.WsEventCallback.instance().registerCallback({
|
|
44
|
+
action: "websocket_connection",
|
|
45
|
+
req_id: BigInt(reqId),
|
|
46
|
+
timeout: this._timeout,
|
|
47
|
+
id: BigInt(reqId),
|
|
48
|
+
}, resolve, reject);
|
|
40
49
|
this._wsConn.onopen = () => {
|
|
41
50
|
log_1.default.debug("websocket connection opened");
|
|
42
|
-
wsEventCallback_1.WsEventCallback.instance().handleEventCallback({
|
|
51
|
+
wsEventCallback_1.WsEventCallback.instance().handleEventCallback({
|
|
52
|
+
id: BigInt(reqId),
|
|
53
|
+
action: "websocket_connection",
|
|
54
|
+
req_id: BigInt(reqId),
|
|
55
|
+
}, wsEventCallback_1.OnMessageType.MESSAGE_TYPE_CONNECTION, this);
|
|
43
56
|
};
|
|
44
57
|
});
|
|
45
58
|
}
|
|
@@ -48,12 +61,12 @@ class WebSocketConnector {
|
|
|
48
61
|
}
|
|
49
62
|
_onmessage(event) {
|
|
50
63
|
let data = event.data;
|
|
51
|
-
log_1.default.debug("wsClient._onMessage()====" +
|
|
52
|
-
if (Object.prototype.toString.call(data) ===
|
|
64
|
+
log_1.default.debug("wsClient._onMessage()====" + Object.prototype.toString.call(data));
|
|
65
|
+
if (Object.prototype.toString.call(data) === "[object ArrayBuffer]") {
|
|
53
66
|
let id = new DataView(data, 26, 8).getBigUint64(0, true);
|
|
54
|
-
wsEventCallback_1.WsEventCallback.instance().handleEventCallback({ id: id, action:
|
|
67
|
+
wsEventCallback_1.WsEventCallback.instance().handleEventCallback({ id: id, action: "", req_id: BigInt(0) }, wsEventCallback_1.OnMessageType.MESSAGE_TYPE_ARRAYBUFFER, data);
|
|
55
68
|
}
|
|
56
|
-
else if (Object.prototype.toString.call(data) ===
|
|
69
|
+
else if (Object.prototype.toString.call(data) === "[object String]") {
|
|
57
70
|
let msg = JSON.parse(data);
|
|
58
71
|
log_1.default.debug("[_onmessage.stringType]==>:" + data);
|
|
59
72
|
wsEventCallback_1.WsEventCallback.instance().handleEventCallback({ id: BigInt(0), action: msg.action, req_id: msg.req_id }, wsEventCallback_1.OnMessageType.MESSAGE_TYPE_STRING, msg);
|
|
@@ -98,8 +111,14 @@ class WebSocketConnector {
|
|
|
98
111
|
return new Promise((resolve, reject) => {
|
|
99
112
|
if (this._wsConn && this._wsConn.readyState === websocket_1.w3cwebsocket.OPEN) {
|
|
100
113
|
if (register) {
|
|
101
|
-
wsEventCallback_1.WsEventCallback.instance().registerCallback({
|
|
102
|
-
|
|
114
|
+
wsEventCallback_1.WsEventCallback.instance().registerCallback({
|
|
115
|
+
action: msg.action,
|
|
116
|
+
req_id: msg.args.req_id,
|
|
117
|
+
timeout: this._timeout,
|
|
118
|
+
id: msg.args.id === undefined
|
|
119
|
+
? msg.args.id
|
|
120
|
+
: BigInt(msg.args.id),
|
|
121
|
+
}, resolve, reject);
|
|
103
122
|
}
|
|
104
123
|
log_1.default.debug(`[wsClient.sendMessage.msg]===> ${message}`);
|
|
105
124
|
this._wsConn.send(message);
|
|
@@ -113,10 +132,17 @@ class WebSocketConnector {
|
|
|
113
132
|
return new Promise((resolve, reject) => {
|
|
114
133
|
if (this._wsConn && this._wsConn.readyState === websocket_1.w3cwebsocket.OPEN) {
|
|
115
134
|
if (register) {
|
|
116
|
-
wsEventCallback_1.WsEventCallback.instance().registerCallback({
|
|
117
|
-
|
|
135
|
+
wsEventCallback_1.WsEventCallback.instance().registerCallback({
|
|
136
|
+
action: action,
|
|
137
|
+
req_id: reqId,
|
|
138
|
+
timeout: this._timeout,
|
|
139
|
+
id: reqId,
|
|
140
|
+
}, resolve, reject);
|
|
118
141
|
}
|
|
119
|
-
log_1.default.debug("[wsClient.sendBinaryMsg()]===>" +
|
|
142
|
+
log_1.default.debug("[wsClient.sendBinaryMsg()]===>" +
|
|
143
|
+
reqId +
|
|
144
|
+
action +
|
|
145
|
+
message.byteLength);
|
|
120
146
|
this._wsConn.send(message);
|
|
121
147
|
}
|
|
122
148
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsConnectorPool.d.ts","sourceRoot":"","sources":["../../../src/client/wsConnectorPool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"wsConnectorPool.d.ts","sourceRoot":"","sources":["../../../src/client/wsConnectorPool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAOnD,qBAAa,uBAAuB;IAChC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAA0B;IACnD,OAAO,CAAC,IAAI,CAAgD;IAC5D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAoB;IAC/C,OAAO,CAAC,MAAM,CAAC,WAAW,CAAa;IAEvC,OAAO;WASO,QAAQ,CAClB,cAAc,GAAE,MAAW,GAC5B,uBAAuB;IASpB,aAAa,CACf,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GACnC,OAAO,CAAC,kBAAkB,CAAC;IA4DxB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmCrE,SAAS;CAmBZ"}
|
|
@@ -36,7 +36,8 @@ class WebSocketConnectionPool {
|
|
|
36
36
|
if (!candidate) {
|
|
37
37
|
continue;
|
|
38
38
|
}
|
|
39
|
-
if (candidate &&
|
|
39
|
+
if (candidate &&
|
|
40
|
+
candidate.readyState() === websocket_1.w3cwebsocket.OPEN) {
|
|
40
41
|
connector = candidate;
|
|
41
42
|
break;
|
|
42
43
|
}
|
|
@@ -48,14 +49,21 @@ class WebSocketConnectionPool {
|
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
if (connector) {
|
|
51
|
-
log_1.default.debug("get connection success:" +
|
|
52
|
+
log_1.default.debug("get connection success:" +
|
|
53
|
+
Atomics.load(WebSocketConnectionPool.sharedArray, 0));
|
|
52
54
|
return connector;
|
|
53
55
|
}
|
|
54
|
-
if (this._maxConnections != -1 &&
|
|
55
|
-
|
|
56
|
+
if (this._maxConnections != -1 &&
|
|
57
|
+
Atomics.load(WebSocketConnectionPool.sharedArray, 0) >
|
|
58
|
+
this._maxConnections) {
|
|
59
|
+
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_ARRIVED_LIMIT, "websocket connect arrived limited:" +
|
|
60
|
+
Atomics.load(WebSocketConnectionPool.sharedArray, 0));
|
|
56
61
|
}
|
|
57
62
|
Atomics.add(WebSocketConnectionPool.sharedArray, 0, 1);
|
|
58
|
-
log_1.default.info("getConnection, new connection count:" +
|
|
63
|
+
log_1.default.info("getConnection, new connection count:" +
|
|
64
|
+
Atomics.load(WebSocketConnectionPool.sharedArray, 0) +
|
|
65
|
+
", connectAddr:" +
|
|
66
|
+
connectAddr);
|
|
59
67
|
return new wsConnector_1.WebSocketConnector(url, timeout);
|
|
60
68
|
}
|
|
61
69
|
finally {
|
|
@@ -68,7 +76,9 @@ class WebSocketConnectionPool {
|
|
|
68
76
|
try {
|
|
69
77
|
if (connector.readyState() === websocket_1.w3cwebsocket.OPEN) {
|
|
70
78
|
let url = connector.getWsURL();
|
|
71
|
-
let connectAddr = url.origin
|
|
79
|
+
let connectAddr = url.origin
|
|
80
|
+
.concat(url.pathname)
|
|
81
|
+
.concat(url.search);
|
|
72
82
|
let connectors = this.pool.get(connectAddr);
|
|
73
83
|
if (!connectors) {
|
|
74
84
|
connectors = new Array();
|
|
@@ -78,12 +88,14 @@ class WebSocketConnectionPool {
|
|
|
78
88
|
else {
|
|
79
89
|
connectors.push(connector);
|
|
80
90
|
}
|
|
81
|
-
log_1.default.info("releaseConnection, current connection count:" +
|
|
91
|
+
log_1.default.info("releaseConnection, current connection count:" +
|
|
92
|
+
connectors.length);
|
|
82
93
|
}
|
|
83
94
|
else {
|
|
84
95
|
Atomics.add(WebSocketConnectionPool.sharedArray, 0, -1);
|
|
85
96
|
connector.close();
|
|
86
|
-
log_1.default.info("releaseConnection, current connection status fail:" +
|
|
97
|
+
log_1.default.info("releaseConnection, current connection status fail:" +
|
|
98
|
+
Atomics.load(WebSocketConnectionPool.sharedArray, 0));
|
|
87
99
|
}
|
|
88
100
|
}
|
|
89
101
|
finally {
|
|
@@ -101,24 +113,27 @@ class WebSocketConnectionPool {
|
|
|
101
113
|
}
|
|
102
114
|
}
|
|
103
115
|
}
|
|
104
|
-
log_1.default.info("destroyed connect:" +
|
|
116
|
+
log_1.default.info("destroyed connect:" +
|
|
117
|
+
Atomics.load(WebSocketConnectionPool.sharedArray, 0) +
|
|
118
|
+
" current count:" +
|
|
119
|
+
num);
|
|
105
120
|
Atomics.store(WebSocketConnectionPool.sharedArray, 0, 0);
|
|
106
121
|
this.pool = new Map();
|
|
107
122
|
}
|
|
108
123
|
}
|
|
109
124
|
exports.WebSocketConnectionPool = WebSocketConnectionPool;
|
|
110
|
-
process.on(
|
|
125
|
+
process.on("exit", (code) => {
|
|
111
126
|
log_1.default.info("begin destroy connect");
|
|
112
127
|
WebSocketConnectionPool.instance().destroyed();
|
|
113
128
|
process.exit();
|
|
114
129
|
});
|
|
115
|
-
process.on(
|
|
116
|
-
log_1.default.info(
|
|
130
|
+
process.on("SIGINT", () => {
|
|
131
|
+
log_1.default.info("Received SIGINT. Press Control-D to exit, begin destroy connect...");
|
|
117
132
|
WebSocketConnectionPool.instance().destroyed();
|
|
118
133
|
process.exit();
|
|
119
134
|
});
|
|
120
|
-
process.on(
|
|
121
|
-
log_1.default.info(
|
|
135
|
+
process.on("SIGTERM", () => {
|
|
136
|
+
log_1.default.info("Received SIGINT. Press Control-D to exit, begin destroy connect");
|
|
122
137
|
WebSocketConnectionPool.instance().destroyed();
|
|
123
138
|
process.exit();
|
|
124
139
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsEventCallback.d.ts","sourceRoot":"","sources":["../../../src/client/wsEventCallback.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wsEventCallback.d.ts","sourceRoot":"","sources":["../../../src/client/wsEventCallback.ts"],"names":[],"mappings":"AASA,UAAU,SAAS;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AASD,oBAAY,aAAa;IACrB,wBAAwB,IAAI;IAC5B,iBAAiB,IAAI;IACrB,mBAAmB,IAAI;IACvB,uBAAuB,IAAI;CAC9B;AAGD,qBAAa,eAAe;IACxB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAkB;IAC3C,OAAO,CAAC,MAAM,CAAC,kBAAkB,CACnB;IACd,OAAO;WAEO,QAAQ,IAAI,eAAe;IAOnC,gBAAgB,CAClB,EAAE,EAAE,SAAS,EACb,GAAG,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,EAC5B,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI;IAwBxB,mBAAmB,CACrB,GAAG,EAAE,SAAS,EACd,WAAW,EAAE,aAAa,EAC1B,IAAI,EAAE,GAAG;CA0DhB"}
|
|
@@ -16,8 +16,7 @@ var OnMessageType;
|
|
|
16
16
|
})(OnMessageType || (exports.OnMessageType = OnMessageType = {}));
|
|
17
17
|
const eventMutex = new async_mutex_1.Mutex();
|
|
18
18
|
class WsEventCallback {
|
|
19
|
-
constructor() {
|
|
20
|
-
}
|
|
19
|
+
constructor() { }
|
|
21
20
|
static instance() {
|
|
22
21
|
if (!WsEventCallback._instance) {
|
|
23
22
|
WsEventCallback._instance = new WsEventCallback();
|
|
@@ -31,7 +30,7 @@ class WsEventCallback {
|
|
|
31
30
|
sendTime: new Date().getTime(),
|
|
32
31
|
reject: rej,
|
|
33
32
|
resolve: res,
|
|
34
|
-
timer: setTimeout(() => rej(new wsError_1.WebSocketQueryError(wsError_1.ErrorCode.ERR_WEBSOCKET_QUERY_TIMEOUT, `action:${id.action},req_id:${id.req_id} timeout with ${id.timeout} milliseconds`)), id.timeout)
|
|
33
|
+
timer: setTimeout(() => rej(new wsError_1.WebSocketQueryError(wsError_1.ErrorCode.ERR_WEBSOCKET_QUERY_TIMEOUT, `action:${id.action},req_id:${id.req_id} timeout with ${id.timeout} milliseconds`)), id.timeout),
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
36
|
finally {
|
|
@@ -88,7 +87,10 @@ class WsEventCallback {
|
|
|
88
87
|
}
|
|
89
88
|
else {
|
|
90
89
|
log_1.default.error("no find callback msg:=", msg);
|
|
91
|
-
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WS_NO_CALLBACK, "no callback registered for fetch_block with req_id=" +
|
|
90
|
+
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WS_NO_CALLBACK, "no callback registered for fetch_block with req_id=" +
|
|
91
|
+
msg.req_id +
|
|
92
|
+
" action" +
|
|
93
|
+
msg.action);
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsResponse.d.ts","sourceRoot":"","sources":["../../../src/client/wsResponse.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAe,MAAM,sBAAsB,CAAC;AAEhE,qBAAa,iBAAiB;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;gBACN,IAAI,
|
|
1
|
+
{"version":3,"file":"wsResponse.d.ts","sourceRoot":"","sources":["../../../src/client/wsResponse.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAe,MAAM,sBAAsB,CAAC;AAEhE,qBAAa,iBAAiB;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;gBACN,IAAI,EAAE,WAAW;CAOhC;AAED,qBAAa,eAAe;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACpC,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACpC,cAAc,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACtC,iBAAiB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACzC,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;gBAEP,IAAI,EAAE,WAAW;IAI7B,OAAO,CAAC,OAAO;CA0BlB;AAED,qBAAa,oBAAoB;IAC7B,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,WAAW,EAAE,WAAW,CAAC;gBACb,GAAG,EAAE,WAAW;CA+B/B"}
|
|
@@ -39,8 +39,12 @@ class WSQueryResponse {
|
|
|
39
39
|
this.fields_types = msg.fields_types;
|
|
40
40
|
this.fields_lengths = msg.fields_lengths;
|
|
41
41
|
this.precision = msg.precision;
|
|
42
|
-
this.fields_precisions = msg.fields_precisions
|
|
43
|
-
|
|
42
|
+
this.fields_precisions = msg.fields_precisions
|
|
43
|
+
? msg.fields_precisions.map((p) => BigInt(p))
|
|
44
|
+
: [];
|
|
45
|
+
this.fields_scales = msg.fields_scales
|
|
46
|
+
? msg.fields_scales.map((s) => BigInt(s))
|
|
47
|
+
: [];
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
exports.WSQueryResponse = WSQueryResponse;
|
|
@@ -6,7 +6,8 @@ export declare class WSConfig {
|
|
|
6
6
|
private _timeout;
|
|
7
7
|
private _token;
|
|
8
8
|
private _timezone;
|
|
9
|
-
|
|
9
|
+
private _minStmt2Version;
|
|
10
|
+
constructor(url: string, minStmt2Version?: string);
|
|
10
11
|
getToken(): string | undefined | null;
|
|
11
12
|
setToken(token: string): void;
|
|
12
13
|
getUser(): string | undefined | null;
|
|
@@ -17,9 +18,10 @@ export declare class WSConfig {
|
|
|
17
18
|
setDb(db: string): void;
|
|
18
19
|
getUrl(): string;
|
|
19
20
|
setUrl(url: string): void;
|
|
20
|
-
setTimeOut(ms: number): void;
|
|
21
21
|
getTimeOut(): number | undefined | null;
|
|
22
|
-
|
|
22
|
+
setTimeOut(ms: number): void;
|
|
23
23
|
getTimezone(): string | undefined | null;
|
|
24
|
+
setTimezone(timezone: string): void;
|
|
25
|
+
getMinStmt2Version(): string;
|
|
24
26
|
}
|
|
25
27
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/common/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/common/config.ts"],"names":[],"mappings":"AAEA,qBAAa,QAAQ;IACjB,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,GAAG,CAA4B;IACvC,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,gBAAgB,CAAS;gBAErB,GAAG,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM;IAS1C,QAAQ,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAIrC,QAAQ,CAAC,KAAK,EAAE,MAAM;IAItB,OAAO,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAIpC,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,MAAM,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAInC,MAAM,CAAC,GAAG,EAAE,MAAM;IAIlB,KAAK,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAIlC,KAAK,CAAC,EAAE,EAAE,MAAM;IAIhB,MAAM,IAAI,MAAM;IAIhB,MAAM,CAAC,GAAG,EAAE,MAAM;IAIlB,UAAU,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAIvC,UAAU,CAAC,EAAE,EAAE,MAAM;IAIrB,WAAW,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAIxC,WAAW,CAAC,QAAQ,EAAE,MAAM;IAI5B,kBAAkB;CAG5B"}
|
package/lib/src/common/config.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WSConfig = void 0;
|
|
4
|
+
const constant_1 = require("./constant");
|
|
4
5
|
class WSConfig {
|
|
5
|
-
constructor(url) {
|
|
6
|
+
constructor(url, minStmt2Version) {
|
|
6
7
|
this._url = url;
|
|
8
|
+
if (!minStmt2Version) {
|
|
9
|
+
this._minStmt2Version = constant_1.MinStmt2Version;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
this._minStmt2Version = minStmt2Version;
|
|
13
|
+
}
|
|
7
14
|
}
|
|
8
15
|
getToken() {
|
|
9
16
|
return this._token;
|
|
@@ -35,17 +42,20 @@ class WSConfig {
|
|
|
35
42
|
setUrl(url) {
|
|
36
43
|
this._url = url;
|
|
37
44
|
}
|
|
45
|
+
getTimeOut() {
|
|
46
|
+
return this._timeout;
|
|
47
|
+
}
|
|
38
48
|
setTimeOut(ms) {
|
|
39
49
|
this._timeout = ms;
|
|
40
50
|
}
|
|
41
|
-
|
|
42
|
-
return this.
|
|
51
|
+
getTimezone() {
|
|
52
|
+
return this._timezone;
|
|
43
53
|
}
|
|
44
54
|
setTimezone(timezone) {
|
|
45
55
|
this._timezone = timezone;
|
|
46
56
|
}
|
|
47
|
-
|
|
48
|
-
return this.
|
|
57
|
+
getMinStmt2Version() {
|
|
58
|
+
return this._minStmt2Version;
|
|
49
59
|
}
|
|
50
60
|
}
|
|
51
61
|
exports.WSConfig = WSConfig;
|
|
@@ -4,8 +4,12 @@ export interface IndexableString {
|
|
|
4
4
|
export interface StringIndexable {
|
|
5
5
|
[index: string]: number;
|
|
6
6
|
}
|
|
7
|
+
export interface NumberIndexable {
|
|
8
|
+
[index: number]: number;
|
|
9
|
+
}
|
|
7
10
|
export declare const BinaryQueryMessage: bigint;
|
|
8
11
|
export declare const FetchRawBlockMessage: bigint;
|
|
12
|
+
export declare const MinStmt2Version: string;
|
|
9
13
|
export declare const TDengineTypeName: IndexableString;
|
|
10
14
|
export declare const ColumnsBlockType: StringIndexable;
|
|
11
15
|
export declare enum TDengineTypeCode {
|
|
@@ -37,7 +41,13 @@ export declare enum TSDB_OPTION_CONNECTION {
|
|
|
37
41
|
TSDB_OPTION_CONNECTION_USER_IP = 2,// user ip
|
|
38
42
|
TSDB_OPTION_CONNECTION_USER_APP = 3
|
|
39
43
|
}
|
|
44
|
+
export declare enum FieldBindType {
|
|
45
|
+
TAOS_FIELD_COL = 1,
|
|
46
|
+
TAOS_FIELD_TAG = 2,
|
|
47
|
+
TAOS_FIELD_QUERY = 3,
|
|
48
|
+
TAOS_FIELD_TBNAME = 4
|
|
49
|
+
}
|
|
40
50
|
export declare const TDenginePrecision: IndexableString;
|
|
41
|
-
export declare const TDengineTypeLength:
|
|
51
|
+
export declare const TDengineTypeLength: NumberIndexable;
|
|
42
52
|
export declare const PrecisionLength: StringIndexable;
|
|
43
53
|
//# sourceMappingURL=constant.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/common/constant.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC5B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/common/constant.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC5B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC5B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC5B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAkB,CAAC;AACpD,eAAO,MAAM,oBAAoB,EAAE,MAAkB,CAAC;AACtD,eAAO,MAAM,eAAe,EAAE,MAAkB,CAAC;AACjD,eAAO,MAAM,gBAAgB,EAAE,eAmB9B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,eAM9B,CAAC;AAEF,oBAAY,gBAAgB;IACxB,IAAI,IAAI;IACR,IAAI,IAAI;IACR,OAAO,IAAI;IACX,QAAQ,IAAI;IACZ,GAAG,IAAI;IACP,MAAM,IAAI;IACV,KAAK,IAAI;IACT,MAAM,IAAI;IACV,MAAM,IAAI;IACV,OAAO,IAAI;IACX,SAAS,IAAI;IACb,KAAK,KAAK;IACV,gBAAgB,KAAK;IACrB,iBAAiB,KAAK;IACtB,YAAY,KAAK;IACjB,eAAe,KAAK;IACpB,IAAI,KAAK;IACT,SAAS,KAAK;IACd,OAAO,KAAK;IACZ,QAAQ,KAAK;IACb,SAAS,KAAK;CACjB;AAED,oBAAY,sBAAsB;IAC9B,8BAA8B,IAAA,CAAG,qDAAqD;IACtF,+BAA+B,IAAA,CAAE,sDAAsD;IACvF,8BAA8B,IAAA,CAAG,UAAU;IAC3C,+BAA+B,IAAA;CAClC;AAED,oBAAY,aAAa;IACrB,cAAc,IAAI;IAClB,cAAc,IAAI;IAClB,gBAAgB,IAAI;IACpB,iBAAiB,IAAI;CACxB;AAED,eAAO,MAAM,iBAAiB,EAAE,eAI/B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,eAahC,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,eAI7B,CAAC"}
|