@tdengine/websocket 3.1.8 → 3.2.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.
Files changed (86) hide show
  1. package/lib/index.d.ts +8 -1
  2. package/lib/index.d.ts.map +1 -1
  3. package/lib/index.js +8 -1
  4. package/lib/src/client/wsClient.d.ts +4 -0
  5. package/lib/src/client/wsClient.d.ts.map +1 -1
  6. package/lib/src/client/wsClient.js +35 -8
  7. package/lib/src/client/wsConnector.d.ts.map +1 -1
  8. package/lib/src/client/wsResponse.d.ts +2 -0
  9. package/lib/src/client/wsResponse.d.ts.map +1 -1
  10. package/lib/src/client/wsResponse.js +2 -0
  11. package/lib/src/common/config.d.ts +6 -1
  12. package/lib/src/common/config.d.ts.map +1 -1
  13. package/lib/src/common/config.js +17 -1
  14. package/lib/src/common/constant.d.ts +20 -2
  15. package/lib/src/common/constant.d.ts.map +1 -1
  16. package/lib/src/common/constant.js +30 -13
  17. package/lib/src/common/taosResult.d.ts +5 -2
  18. package/lib/src/common/taosResult.d.ts.map +1 -1
  19. package/lib/src/common/taosResult.js +59 -5
  20. package/lib/src/common/utils.d.ts +1 -0
  21. package/lib/src/common/utils.d.ts.map +1 -1
  22. package/lib/src/common/utils.js +31 -0
  23. package/lib/src/sql/wsSql.d.ts.map +1 -1
  24. package/lib/src/sql/wsSql.js +18 -2
  25. package/lib/src/stmt/FieldBindParams.d.ts +9 -0
  26. package/lib/src/stmt/FieldBindParams.d.ts.map +1 -0
  27. package/lib/src/stmt/FieldBindParams.js +13 -0
  28. package/lib/src/stmt/wsColumnInfo.d.ts +12 -0
  29. package/lib/src/stmt/wsColumnInfo.d.ts.map +1 -0
  30. package/lib/src/stmt/wsColumnInfo.js +17 -0
  31. package/lib/src/stmt/wsParams1.d.ts +14 -0
  32. package/lib/src/stmt/wsParams1.d.ts.map +1 -0
  33. package/lib/src/stmt/wsParams1.js +274 -0
  34. package/lib/src/stmt/wsParams2.d.ts +14 -0
  35. package/lib/src/stmt/wsParams2.d.ts.map +1 -0
  36. package/lib/src/stmt/wsParams2.js +188 -0
  37. package/lib/src/stmt/wsParamsBase.d.ts +45 -0
  38. package/lib/src/stmt/wsParamsBase.d.ts.map +1 -0
  39. package/lib/src/stmt/wsParamsBase.js +218 -0
  40. package/lib/src/stmt/wsProto.d.ts +16 -4
  41. package/lib/src/stmt/wsProto.d.ts.map +1 -1
  42. package/lib/src/stmt/wsProto.js +197 -4
  43. package/lib/src/stmt/wsStmt.d.ts +6 -16
  44. package/lib/src/stmt/wsStmt.d.ts.map +1 -1
  45. package/lib/src/stmt/wsStmt.js +0 -200
  46. package/lib/src/stmt/wsStmt1.d.ts +30 -0
  47. package/lib/src/stmt/wsStmt1.d.ts.map +1 -0
  48. package/lib/src/stmt/wsStmt1.js +206 -0
  49. package/lib/src/stmt/wsStmt2.d.ts +37 -0
  50. package/lib/src/stmt/wsStmt2.d.ts.map +1 -0
  51. package/lib/src/stmt/wsStmt2.js +280 -0
  52. package/lib/src/stmt/wsTableInfo.d.ts +17 -0
  53. package/lib/src/stmt/wsTableInfo.d.ts.map +1 -0
  54. package/lib/src/stmt/wsTableInfo.js +54 -0
  55. package/lib/src/tmq/constant.d.ts +2 -0
  56. package/lib/src/tmq/constant.d.ts.map +1 -1
  57. package/lib/src/tmq/constant.js +2 -0
  58. package/lib/src/tmq/tmqResponse.d.ts +5 -5
  59. package/lib/src/tmq/tmqResponse.js +8 -8
  60. package/lib/src/tmq/wsTmq.d.ts +1 -0
  61. package/lib/src/tmq/wsTmq.d.ts.map +1 -1
  62. package/lib/src/tmq/wsTmq.js +9 -5
  63. package/lib/test/bulkPulling/cloud.tmq.test.js +0 -1
  64. package/lib/test/bulkPulling/decimal.test.d.ts +2 -0
  65. package/lib/test/bulkPulling/decimal.test.d.ts.map +1 -0
  66. package/lib/test/bulkPulling/decimal.test.js +129 -0
  67. package/lib/test/bulkPulling/sql.test.js +36 -9
  68. package/lib/test/bulkPulling/stmt.func.test.js +99 -11
  69. package/lib/test/bulkPulling/stmt.type.test.js +49 -6
  70. package/lib/test/bulkPulling/stmt1.func.test.d.ts +2 -0
  71. package/lib/test/bulkPulling/stmt1.func.test.d.ts.map +1 -0
  72. package/lib/test/bulkPulling/stmt1.func.test.js +417 -0
  73. package/lib/test/bulkPulling/stmt1.type.test.d.ts +2 -0
  74. package/lib/test/bulkPulling/stmt1.type.test.d.ts.map +1 -0
  75. package/lib/test/bulkPulling/stmt1.type.test.js +323 -0
  76. package/lib/test/bulkPulling/stmt2.func.test.d.ts +2 -0
  77. package/lib/test/bulkPulling/stmt2.func.test.d.ts.map +1 -0
  78. package/lib/test/bulkPulling/stmt2.func.test.js +539 -0
  79. package/lib/test/bulkPulling/stmt2.type.test.d.ts +2 -0
  80. package/lib/test/bulkPulling/stmt2.type.test.d.ts.map +1 -0
  81. package/lib/test/bulkPulling/stmt2.type.test.js +325 -0
  82. package/lib/test/bulkPulling/tmq.test.js +2 -0
  83. package/lib/test/bulkPulling/wsConnectPool.test.js +2 -2
  84. package/lib/test/utils.d.ts.map +1 -1
  85. package/lib/test/utils.js +1 -0
  86. package/package.json +1 -1
@@ -0,0 +1,280 @@
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.WsStmt2 = void 0;
7
+ const json_bigint_1 = __importDefault(require("json-bigint"));
8
+ const constant_1 = require("../common/constant");
9
+ const log_1 = __importDefault(require("../common/log"));
10
+ const reqid_1 = require("../common/reqid");
11
+ const wsError_1 = require("../common/wsError");
12
+ const wsProto_1 = require("./wsProto");
13
+ const wsParams2_1 = require("./wsParams2");
14
+ const wsTableInfo_1 = require("./wsTableInfo");
15
+ const wsRows_1 = require("../sql/wsRows");
16
+ const FieldBindParams_1 = require("./FieldBindParams");
17
+ class WsStmt2 {
18
+ constructor(wsClient, precision) {
19
+ this._precision = constant_1.PrecisionLength['ms'];
20
+ this._isInsert = false;
21
+ this._wsClient = wsClient;
22
+ if (precision) {
23
+ this._precision = precision;
24
+ }
25
+ this._stmtTableInfo = new Map();
26
+ this._currentTableInfo = new wsTableInfo_1.TableInfo();
27
+ this._stmtTableInfoList = [];
28
+ this._toBeBindColCount = 0;
29
+ this._toBeBindTagCount = 0;
30
+ }
31
+ static async newStmt(wsClient, precision, reqId) {
32
+ try {
33
+ let wsStmt = new WsStmt2(wsClient, precision);
34
+ return await wsStmt.init(reqId);
35
+ }
36
+ catch (e) {
37
+ log_1.default.error(`WsStmt init is failed, ${e.code}, ${e.message}`);
38
+ throw (e);
39
+ }
40
+ }
41
+ async init(reqId) {
42
+ if (this._wsClient) {
43
+ try {
44
+ if (this._wsClient.getState() <= 0) {
45
+ await this._wsClient.connect();
46
+ await this._wsClient.checkVersion();
47
+ }
48
+ let queryMsg = {
49
+ action: 'stmt2_init',
50
+ args: {
51
+ req_id: reqid_1.ReqId.getReqID(reqId),
52
+ single_stb_insert: true,
53
+ single_table_bind_once: true
54
+ },
55
+ };
56
+ await this.execute(queryMsg);
57
+ return this;
58
+ }
59
+ catch (e) {
60
+ log_1.default.error(`stmt init filed, ${e.code}, ${e.message}`);
61
+ throw (e);
62
+ }
63
+ }
64
+ throw (new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_CONNECTION_CLOSED, "stmt connect closed"));
65
+ }
66
+ getStmtId() {
67
+ return this._stmt_id;
68
+ }
69
+ async prepare(sql) {
70
+ let queryMsg = {
71
+ action: 'stmt2_prepare',
72
+ args: {
73
+ req_id: reqid_1.ReqId.getReqID(),
74
+ sql: sql,
75
+ stmt_id: this._stmt_id,
76
+ get_fields: true,
77
+ },
78
+ };
79
+ let resp = await this.execute(queryMsg);
80
+ if (this._isInsert && this.fields) {
81
+ this._precision = this.fields[0].precision ? this.fields[0].precision : 0;
82
+ this._toBeBindColCount = 0;
83
+ this._toBeBindTagCount = 0;
84
+ this.fields?.forEach((field, index) => {
85
+ if (field.bind_type == constant_1.FieldBindType.TAOS_FIELD_TBNAME) {
86
+ this._toBeBindTableNameIndex = index;
87
+ }
88
+ else if (field.bind_type == constant_1.FieldBindType.TAOS_FIELD_TAG) {
89
+ this._toBeBindTagCount++;
90
+ }
91
+ else if (field.bind_type == constant_1.FieldBindType.TAOS_FIELD_COL) {
92
+ this._toBeBindColCount++;
93
+ }
94
+ });
95
+ }
96
+ else {
97
+ if (resp && resp.fields_count && resp.fields_count > 0) {
98
+ this._stmtTableInfoList = [this._currentTableInfo];
99
+ this._toBeBindColCount = resp.fields_count;
100
+ }
101
+ else {
102
+ throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "prepare No columns to bind!");
103
+ }
104
+ }
105
+ }
106
+ async setTableName(tableName) {
107
+ if (!tableName || tableName.length === 0) {
108
+ throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, 'Table name cannot be empty');
109
+ }
110
+ let tableInfo = this._stmtTableInfo.get(tableName);
111
+ if (!tableInfo) {
112
+ this._currentTableInfo = new wsTableInfo_1.TableInfo(tableName);
113
+ this._stmtTableInfo.set(tableName, this._currentTableInfo);
114
+ this._stmtTableInfoList.push(this._currentTableInfo);
115
+ }
116
+ else {
117
+ this._currentTableInfo = tableInfo;
118
+ }
119
+ return Promise.resolve();
120
+ }
121
+ async setTags(paramsArray) {
122
+ if (!paramsArray || !this._stmt_id) {
123
+ throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SetBinaryTags paramArray is invalid!");
124
+ }
125
+ if (!this._currentTableInfo) {
126
+ this._currentTableInfo = new wsTableInfo_1.TableInfo();
127
+ this._stmtTableInfoList.push(this._currentTableInfo);
128
+ }
129
+ await this._currentTableInfo.setTags(paramsArray);
130
+ return Promise.resolve();
131
+ }
132
+ newStmtParam() {
133
+ if (this._isInsert) {
134
+ if (!this.fields || this.fields.length === 0) {
135
+ throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "No columns to bind!");
136
+ }
137
+ return new wsParams2_1.Stmt2BindParams(this.fields.length, this._precision, this.fields);
138
+ }
139
+ return new wsParams2_1.Stmt2BindParams();
140
+ }
141
+ async bind(paramsArray) {
142
+ if (!paramsArray || !this._stmt_id || !paramsArray._fieldParams) {
143
+ throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "Bind paramArray is invalid!");
144
+ }
145
+ if (this._isInsert && this.fields && paramsArray.getBindCount() == this.fields.length) {
146
+ const tableNameIndex = this._toBeBindTableNameIndex;
147
+ if (tableNameIndex === null || tableNameIndex === undefined) {
148
+ throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "Table name index is null or undefined!");
149
+ }
150
+ const paramsCount = paramsArray._fieldParams[0].params.length;
151
+ for (let i = 0; i < paramsCount; i++) {
152
+ let tableName = paramsArray._fieldParams[tableNameIndex].params[i];
153
+ await this.setTableName(tableName);
154
+ for (let j = 0; j < paramsArray._fieldParams.length; j++) {
155
+ if (j == tableNameIndex) {
156
+ continue;
157
+ }
158
+ let fieldParam = paramsArray._fieldParams[j];
159
+ if (this.fields[j].bind_type == constant_1.FieldBindType.TAOS_FIELD_TAG) {
160
+ if (!this._currentTableInfo.tags) {
161
+ this._currentTableInfo.tags = new wsParams2_1.Stmt2BindParams(this._toBeBindTagCount, this._precision, this.fields);
162
+ }
163
+ this._currentTableInfo.tags.addBindFieldParams(new FieldBindParams_1.FieldBindParams([fieldParam.params[i]], fieldParam.dataType, fieldParam.typeLen, fieldParam.columnType, fieldParam.bindType));
164
+ }
165
+ else if (this.fields[j].bind_type == constant_1.FieldBindType.TAOS_FIELD_COL) {
166
+ if (!this._currentTableInfo.params) {
167
+ this._currentTableInfo.params = new wsParams2_1.Stmt2BindParams(this._toBeBindColCount, this._precision, this.fields);
168
+ }
169
+ this._currentTableInfo.params.addBindFieldParams(new FieldBindParams_1.FieldBindParams([fieldParam.params[i]], fieldParam.dataType, fieldParam.typeLen, fieldParam.columnType, fieldParam.bindType));
170
+ }
171
+ }
172
+ }
173
+ }
174
+ else {
175
+ await this._currentTableInfo.setParams(paramsArray);
176
+ }
177
+ return Promise.resolve();
178
+ }
179
+ async batch() {
180
+ Promise.resolve();
181
+ }
182
+ async exec() {
183
+ if (!this._currentTableInfo) {
184
+ throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "table info is empty!");
185
+ }
186
+ let params = this._currentTableInfo.getParams();
187
+ if (!params) {
188
+ throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "Bind params is empty!");
189
+ }
190
+ let reqId = BigInt(reqid_1.ReqId.getReqID());
191
+ let bytes = (0, wsProto_1.stmt2BinaryBlockEncode)(reqId, this._stmtTableInfoList, this._stmt_id, this._toBeBindTableNameIndex, this._toBeBindTagCount, this._toBeBindColCount);
192
+ await this.sendBinaryMsg(reqId, 'stmt2_bind', new Uint8Array(bytes));
193
+ let execMsg = {
194
+ action: 'stmt2_exec',
195
+ args: {
196
+ req_id: reqid_1.ReqId.getReqID(),
197
+ stmt_id: this._stmt_id,
198
+ },
199
+ };
200
+ await this.execute(execMsg);
201
+ this.cleanup();
202
+ }
203
+ cleanup() {
204
+ this._stmtTableInfo.clear();
205
+ this._stmtTableInfoList = [];
206
+ this._currentTableInfo = new wsTableInfo_1.TableInfo();
207
+ }
208
+ getLastAffected() {
209
+ return this.lastAffected;
210
+ }
211
+ async resultSet() {
212
+ let execMsg = {
213
+ action: 'stmt2_result',
214
+ args: {
215
+ req_id: reqid_1.ReqId.getReqID(),
216
+ stmt_id: this._stmt_id,
217
+ },
218
+ };
219
+ let resp = await this.execute(execMsg);
220
+ if (!resp) {
221
+ throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "ResultSet response is empty!");
222
+ }
223
+ return new wsRows_1.WSRows(this._wsClient, resp);
224
+ }
225
+ async close() {
226
+ let queryMsg = {
227
+ action: 'stmt2_close',
228
+ args: {
229
+ req_id: reqid_1.ReqId.getReqID(),
230
+ stmt_id: this._stmt_id,
231
+ },
232
+ };
233
+ await this.execute(queryMsg);
234
+ }
235
+ async execute(stmtMsg, register = true) {
236
+ try {
237
+ if (this._wsClient.getState() <= 0) {
238
+ throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_CONNECTION_CLOSED, "websocket connect has closed!");
239
+ }
240
+ let reqMsg = json_bigint_1.default.stringify(stmtMsg);
241
+ if (register) {
242
+ let result = await this._wsClient.exec(reqMsg, false);
243
+ let resp = new wsProto_1.WsStmtQueryResponse(result);
244
+ if (resp.stmt_id) {
245
+ this._stmt_id = resp.stmt_id;
246
+ }
247
+ if (resp.affected) {
248
+ this.lastAffected = resp.affected;
249
+ }
250
+ if (resp.fields) {
251
+ this.fields = resp.fields;
252
+ }
253
+ if (resp.is_insert) {
254
+ this._isInsert = resp.is_insert;
255
+ }
256
+ return resp;
257
+ }
258
+ await this._wsClient.execNoResp(reqMsg);
259
+ this._stmt_id = null;
260
+ this.lastAffected = null;
261
+ }
262
+ catch (e) {
263
+ throw new wsError_1.TaosResultError(e.code, e.message);
264
+ }
265
+ }
266
+ async sendBinaryMsg(reqId, action, message) {
267
+ if (this._wsClient.getState() <= 0) {
268
+ throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_CONNECTION_CLOSED, "websocket connect has closed!");
269
+ }
270
+ let result = await this._wsClient.sendBinaryMsg(reqId, action, message, false);
271
+ let resp = new wsProto_1.WsStmtQueryResponse(result);
272
+ if (resp.stmt_id) {
273
+ this._stmt_id = resp.stmt_id;
274
+ }
275
+ if (resp.affected) {
276
+ this.lastAffected = resp.affected;
277
+ }
278
+ }
279
+ }
280
+ exports.WsStmt2 = WsStmt2;
@@ -0,0 +1,17 @@
1
+ import { StmtBindParams } from "./wsParamsBase";
2
+ export declare class TableInfo {
3
+ name: Uint8Array | undefined | null;
4
+ tags: StmtBindParams | undefined | null;
5
+ params?: StmtBindParams;
6
+ length: number;
7
+ textEncoder: TextEncoder;
8
+ constructor(name?: string);
9
+ getTableName(): Uint8Array | undefined | null;
10
+ getTableNameLength(): number;
11
+ getTags(): StmtBindParams | undefined | null;
12
+ getParams(): StmtBindParams | undefined | null;
13
+ setTableName(name: string): void;
14
+ setTags(paramsArray: StmtBindParams): Promise<void>;
15
+ setParams(bindParams: StmtBindParams): Promise<void>;
16
+ }
17
+ //# sourceMappingURL=wsTableInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wsTableInfo.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsTableInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,qBAAa,SAAS;IAClB,IAAI,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI,CAAC;IACpC,IAAI,EAAE,cAAc,GAAG,SAAS,GAAG,IAAI,CAAC;IACxC,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,MAAM,CAAK;IACnB,WAAW,cAAqB;gBACpB,IAAI,CAAC,EAAE,MAAM;IAOlB,YAAY,IAAI,UAAU,GAAG,SAAS,GAAG,IAAI;IAI7C,kBAAkB,IAAI,MAAM;IAI5B,OAAO,IAAI,cAAc,GAAG,SAAS,GAAG,IAAI;IAI5C,SAAS,IAAI,cAAc,GAAG,SAAS,GAAG,IAAI;IAI9C,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAQjC,OAAO,CAAC,WAAW,EAAC,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAOlD,SAAS,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAS7D"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TableInfo = void 0;
4
+ const wsError_1 = require("../common/wsError");
5
+ class TableInfo {
6
+ constructor(name) {
7
+ this.length = 0;
8
+ this.textEncoder = new TextEncoder();
9
+ if (name && name.length > 0) {
10
+ this.name = this.textEncoder.encode(name);
11
+ this.length = this.name.length;
12
+ }
13
+ }
14
+ getTableName() {
15
+ return this.name;
16
+ }
17
+ getTableNameLength() {
18
+ return this.length;
19
+ }
20
+ getTags() {
21
+ return this.tags;
22
+ }
23
+ getParams() {
24
+ return this.params;
25
+ }
26
+ setTableName(name) {
27
+ if (name && name.length > 0) {
28
+ this.name = this.textEncoder.encode(name);
29
+ this.length = this.name.length;
30
+ }
31
+ else {
32
+ throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "Table name is invalid!");
33
+ }
34
+ }
35
+ async setTags(paramsArray) {
36
+ if (paramsArray) {
37
+ this.tags = paramsArray;
38
+ }
39
+ else {
40
+ throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "Table tags is invalid!");
41
+ }
42
+ }
43
+ async setParams(bindParams) {
44
+ if (!this.params) {
45
+ this.params = bindParams;
46
+ }
47
+ else {
48
+ if (bindParams._fieldParams) {
49
+ this.params.mergeParams(bindParams);
50
+ }
51
+ }
52
+ }
53
+ }
54
+ exports.TableInfo = TableInfo;
@@ -95,6 +95,8 @@ export declare class TMQRawDataSchema {
95
95
  bytes: bigint;
96
96
  colID: number;
97
97
  name: string;
98
+ precision: number;
99
+ scale: number;
98
100
  constructor();
99
101
  }
100
102
  //# sourceMappingURL=constant.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/tmq/constant.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAY;IACrB,OAAc,QAAQ,EAAE,MAAM,CAAc;IAE5C,OAAc,SAAS,EAAE,MAAM,CAAe;IAE9C;;OAEG;IACH,OAAc,kBAAkB,EAAE,MAAM,CAAwB;IAEhE;;OAEG;IACH,OAAc,uBAAuB,EAAE,MAAM,CAA6B;IAE1E;;OAEG;IACH,OAAc,iBAAiB,EAAE,MAAM,CAA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,cAAc;IACvB,OAAc,SAAS,EAAE,MAAM,CAAe;IAC9C,OAAc,IAAI,EAAE,MAAM,CAAU;IACpC,OAAc,QAAQ,EAAE,MAAM,CAAe;IAC7C,OAAc,aAAa,EAAE,MAAM,CAAqB;IACxD,OAAc,MAAM,EAAE,MAAM,CAAY;IACxC,OAAc,WAAW,EAAE,MAAM,CAAiB;IAClD,OAAc,kBAAkB,EAAE,MAAM,CAAgB;IACxD,OAAc,IAAI,EAAE,MAAM,CAAU;IACpC,OAAc,YAAY,EAAE,MAAM,CAAmB;IACrD,OAAc,SAAS,EAAE,MAAM,CAAe;IAC9C,OAAc,QAAQ,EAAE,MAAM,CAAc;IAC5C,OAAc,UAAU,EAAE,MAAM,CAAiB;IACjD,OAAc,WAAW,EAAE,MAAM,CAAK;CACzC;AAED,qBAAa,YAAY;IACrB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;;CAItB;AAED,qBAAa,gBAAgB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAI,MAAM,CAAC;IACf,KAAK,EAAG,MAAM,CAAC;IACf,KAAK,EAAG,MAAM,CAAA;IACd,IAAI,EAAG,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;;CAWjB"}
@@ -100,6 +100,8 @@ class TMQRawDataSchema {
100
100
  this.colType = -1;
101
101
  this.flag = -1;
102
102
  this.name = "";
103
+ this.scale = 0;
104
+ this.precision = 0;
103
105
  }
104
106
  }
105
107
  exports.TMQRawDataSchema = TMQRawDataSchema;
@@ -10,7 +10,7 @@ export declare class WsPollResponse {
10
10
  topic: string;
11
11
  database: string;
12
12
  vgroup_id: number;
13
- message_id: number;
13
+ message_id: bigint;
14
14
  id: bigint;
15
15
  message_type: number;
16
16
  totalTime: number;
@@ -74,7 +74,7 @@ export declare class PartitionsResp {
74
74
  action: string;
75
75
  totalTime: number;
76
76
  timing: bigint;
77
- positions: number[];
77
+ positions: bigint[];
78
78
  constructor(resp: MessageResp);
79
79
  setTopicPartitions(topicPartitions: TopicPartition[]): TopicPartition[];
80
80
  }
@@ -84,9 +84,9 @@ export declare class CommittedResp extends PartitionsResp {
84
84
  export declare class TopicPartition {
85
85
  topic: string;
86
86
  vgroup_id: number;
87
- offset?: number;
88
- begin?: number;
89
- end?: number;
87
+ offset?: bigint;
88
+ begin?: bigint;
89
+ end?: bigint;
90
90
  constructor(msg: any);
91
91
  }
92
92
  //# sourceMappingURL=tmqResponse.d.ts.map
@@ -22,7 +22,7 @@ class WsPollResponse {
22
22
  this.topic = resp.msg.topic;
23
23
  this.database = resp.msg.database;
24
24
  this.vgroup_id = resp.msg.vgroup_id;
25
- this.message_id = resp.msg.message_id;
25
+ this.message_id = BigInt(resp.msg.message_id);
26
26
  this.message_type = resp.msg.message_type;
27
27
  if (resp.msg.id) {
28
28
  this.id = BigInt(resp.msg.id);
@@ -209,13 +209,13 @@ class WSTmqFetchBlockInfo {
209
209
  let bitMapArr = new Uint8Array(dataView.buffer, dataView.byteOffset + bufferOffset, bitMapOffset);
210
210
  bufferOffset += bitMapOffset;
211
211
  //decode column data, data is array
212
- data = (0, taosResult_1.readSolidDataToArray)(dataView, bufferOffset, rows, this.schema[i].colType, bitMapArr);
212
+ data = (0, taosResult_1.readSolidDataToArray)(dataView, bufferOffset, rows, this.schema[i].colType, bitMapArr, startOffset, i);
213
213
  }
214
214
  else {
215
215
  //Variable length type
216
216
  let start = bufferOffset;
217
217
  let offsets = [];
218
- for (let i = 0; i < rows; i++, start += constant_1.TDengineTypeLength['INT']) {
218
+ for (let i = 0; i < rows; i++, start += constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.INT]) {
219
219
  //get data length, -1 is null
220
220
  offsets.push(dataView.getInt32(start, true));
221
221
  }
@@ -294,7 +294,7 @@ class PartitionsResp {
294
294
  this.req_id = resp.msg.req_id;
295
295
  this.action = resp.msg.action;
296
296
  this.totalTime = resp.totalTime;
297
- this.positions = resp.msg.position;
297
+ this.positions = resp.msg.position ? resp.msg.position.map((pos) => BigInt(pos)) : [];
298
298
  }
299
299
  setTopicPartitions(topicPartitions) {
300
300
  if (topicPartitions.length != this.positions.length) {
@@ -310,16 +310,16 @@ exports.PartitionsResp = PartitionsResp;
310
310
  class CommittedResp extends PartitionsResp {
311
311
  constructor(resp) {
312
312
  super(resp);
313
- this.positions = resp.msg.committed;
313
+ this.positions = resp.msg.committed ? resp.msg.committed.map((pos) => BigInt(pos)) : [];
314
314
  }
315
315
  }
316
316
  exports.CommittedResp = CommittedResp;
317
317
  class TopicPartition {
318
318
  constructor(msg) {
319
319
  this.vgroup_id = msg.vgroup_id;
320
- this.offset = msg.offset;
321
- this.begin = msg.begin;
322
- this.end = msg.end;
320
+ this.offset = BigInt(msg.offset);
321
+ this.begin = BigInt(msg.begin);
322
+ this.end = BigInt(msg.end);
323
323
  this.topic = '';
324
324
  }
325
325
  }
@@ -5,6 +5,7 @@ export declare class WsConsumer {
5
5
  private _wsConfig;
6
6
  private _topics?;
7
7
  private _commitTime?;
8
+ private _lastMessageID?;
8
9
  private constructor();
9
10
  private init;
10
11
  static newConsumer(wsConfig: Map<string, any>): Promise<WsConsumer>;
@@ -1 +1 @@
1
- {"version":3,"file":"wsTmq.d.ts","sourceRoot":"","sources":["../../../src/tmq/wsTmq.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAkF,cAAc,EAA0D,MAAM,eAAe,CAAC;AAKvL,qBAAa,UAAU;IACnB,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,OAAO,CAAC,CAAU;IAC1B,OAAO,CAAC,WAAW,CAAC,CAAQ;IAC5B,OAAO;YAWO,IAAI;WAuBL,W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CAAC;IAYlD,MAAM,CAAC,KAAK,CAAC,EAAC,MAAM,GAAE,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YAK5C,QAAQ;IAYhB,SAAS,CAAC,UAAU,EAAC,KAAK,CAAC,cAAc,CAAC,EAAE,KAAK,CAAC,EAAC,MAAM,GAAE,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IA0BzF,aAAa,CAAC,UAAU,EAAC,KAAK,CAAC,cAAc,CAAC,GAAE,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAc9E,YAAY,CAAC,SAAS,EAAC,cAAc,EAAE,KAAK,CAAC,EAAC,MAAM,GAAE,OAAO,CAAC,IAAI,CAAC;IAkBnE,SAAS,CAAC,UAAU,EAAC,KAAK,CAAC,cAAc,CAAC,EAAE,KAAK,CAAC,EAAC,MAAM,GAAE,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IA0BzF,IAAI,CAAC,SAAS,EAAC,cAAc,EAAE,KAAK,CAAC,EAAC,MAAM,GAAE,OAAO,CAAC,IAAI,CAAC;IAkB3D,eAAe,CAAC,UAAU,EAAC,KAAK,CAAC,cAAc,CAAC,GAAE,OAAO,CAAC,IAAI,CAAC;IAQ/D,SAAS,CAAC,UAAU,EAAC,KAAK,CAAC,cAAc,CAAC,GAAE,OAAO,CAAC,IAAI,CAAC;IASzD,KAAK,IAAG,OAAO,CAAC,IAAI,CAAC;YAIb,cAAc;YAuBd,QAAQ;YA6BR,iBAAiB;IAczB,UAAU,CAAC,MAAM,CAAC,EAAC,MAAM,EAAE,GAAE,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YAoBnD,gBAAgB;CA6BjC"}
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.WsConsumer = void 0;
7
+ const json_bigint_1 = __importDefault(require("json-bigint"));
7
8
  const config_1 = require("./config");
8
9
  const constant_1 = require("./constant");
9
10
  const wsClient_1 = require("../client/wsClient");
@@ -20,6 +21,7 @@ class WsConsumer {
20
21
  throw new wsError_1.WebSocketInterfaceError(wsError_1.ErrorCode.ERR_INVALID_URL, 'invalid url, password or username needed.');
21
22
  }
22
23
  this._wsClient = new wsClient_1.WsClient(this._wsConfig.url, this._wsConfig.timeout);
24
+ this._lastMessageID = BigInt(0);
23
25
  }
24
26
  async init() {
25
27
  let wsSql = null;
@@ -142,7 +144,7 @@ class WsConsumer {
142
144
  topic_vgroup_ids: offsets
143
145
  },
144
146
  };
145
- let resp = await this._wsClient.exec(JSON.stringify(queryMsg), false);
147
+ let resp = await this._wsClient.exec(json_bigint_1.default.stringify(queryMsg), false);
146
148
  return new tmqResponse_1.CommittedResp(resp).setTopicPartitions(offsets);
147
149
  }
148
150
  async commitOffsets(partitions) {
@@ -169,7 +171,7 @@ class WsConsumer {
169
171
  offset: partition.offset,
170
172
  },
171
173
  };
172
- return await this._wsClient.exec(JSON.stringify(queryMsg));
174
+ return await this._wsClient.exec(json_bigint_1.default.stringify(queryMsg));
173
175
  }
174
176
  async positions(partitions, reqId) {
175
177
  if (!partitions || partitions.length == 0) {
@@ -231,7 +233,7 @@ class WsConsumer {
231
233
  message_id: pollResp.message_id,
232
234
  },
233
235
  };
234
- let jsonStr = JSON.stringify(fetchMsg);
236
+ let jsonStr = json_bigint_1.default.stringify(fetchMsg);
235
237
  log_1.default.debug('[wsQueryInterface.fetch.fetchMsg]===>' + jsonStr);
236
238
  let result = await this._wsClient.sendMsg(jsonStr);
237
239
  let wsResponse = new wsResponse_1.WSFetchBlockResponse(result.msg);
@@ -249,10 +251,11 @@ class WsConsumer {
249
251
  action: constant_1.TMQMessageType.Poll,
250
252
  args: {
251
253
  req_id: reqid_1.ReqId.getReqID(reqId),
252
- blocking_time: timeoutMs
254
+ blocking_time: timeoutMs,
255
+ message_id: this._lastMessageID,
253
256
  },
254
257
  };
255
- let resp = await this._wsClient.exec(JSON.stringify(queryMsg), false);
258
+ let resp = await this._wsClient.exec(json_bigint_1.default.stringify(queryMsg), false);
256
259
  let pollResp = new tmqResponse_1.WsPollResponse(resp);
257
260
  let taosResult = new tmqResponse_1.TaosTmqResult(pollResp);
258
261
  var taosResults = new Map();
@@ -260,6 +263,7 @@ class WsConsumer {
260
263
  if (!pollResp.have_message || pollResp.message_type != constant_1.TMQMessageType.ResDataType) {
261
264
  return taosResults;
262
265
  }
266
+ this._lastMessageID = pollResp.message_id;
263
267
  let finish = false;
264
268
  while (!finish) {
265
269
  finish = await this.fetchBlockData(pollResp, taosResult);
@@ -35,7 +35,6 @@ describe('TDWebSocket.Tmq()', () => {
35
35
  jest.setTimeout(20 * 1000);
36
36
  test('normal connect', async () => {
37
37
  const url = `wss://${process.env.TDENGINE_CLOUD_URL}?token=${process.env.TDENGINE_CLOUD_TOKEN}`;
38
- // const TDENGINE_CLOUD_URL = 'wss://gw.cloud.taosdata.com?token=1eb78307be0681ac2fc07c2817ba8a9719641fb9';
39
38
  const topic = 'topic_meters';
40
39
  const topics = [topic];
41
40
  const groupId = 'group1';
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=decimal.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decimal.test.d.ts","sourceRoot":"","sources":["../../../test/bulkPulling/decimal.test.ts"],"names":[],"mappings":""}