@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.
Files changed (121) hide show
  1. package/lib/example/all_type_query.js +26 -22
  2. package/lib/example/all_type_stmt.js +22 -20
  3. package/lib/example/basicBatchTmq.js +14 -14
  4. package/lib/example/basicSchemaless.js +11 -11
  5. package/lib/example/basicSql.js +10 -10
  6. package/lib/example/basicStmt.js +3 -3
  7. package/lib/example/basicTmq.js +8 -9
  8. package/lib/index.d.ts +1 -1
  9. package/lib/index.d.ts.map +1 -1
  10. package/lib/index.js +1 -1
  11. package/lib/src/client/wsClient.d.ts +3 -2
  12. package/lib/src/client/wsClient.d.ts.map +1 -1
  13. package/lib/src/client/wsClient.js +66 -40
  14. package/lib/src/client/wsConnector.d.ts.map +1 -1
  15. package/lib/src/client/wsConnector.js +40 -14
  16. package/lib/src/client/wsConnectorPool.d.ts.map +1 -1
  17. package/lib/src/client/wsConnectorPool.js +29 -14
  18. package/lib/src/client/wsEventCallback.d.ts.map +1 -1
  19. package/lib/src/client/wsEventCallback.js +6 -4
  20. package/lib/src/client/wsResponse.d.ts.map +1 -1
  21. package/lib/src/client/wsResponse.js +6 -2
  22. package/lib/src/common/config.d.ts +5 -3
  23. package/lib/src/common/config.d.ts.map +1 -1
  24. package/lib/src/common/config.js +15 -5
  25. package/lib/src/common/constant.d.ts +11 -1
  26. package/lib/src/common/constant.d.ts.map +1 -1
  27. package/lib/src/common/constant.js +48 -40
  28. package/lib/src/common/log.d.ts +1 -1
  29. package/lib/src/common/log.d.ts.map +1 -1
  30. package/lib/src/common/log.js +9 -7
  31. package/lib/src/common/reqid.d.ts.map +1 -1
  32. package/lib/src/common/reqid.js +7 -7
  33. package/lib/src/common/taosResult.d.ts.map +1 -1
  34. package/lib/src/common/taosResult.js +46 -27
  35. package/lib/src/common/ut8Helper.d.ts.map +1 -1
  36. package/lib/src/common/ut8Helper.js +8 -8
  37. package/lib/src/common/utils.d.ts.map +1 -1
  38. package/lib/src/common/utils.js +17 -16
  39. package/lib/src/common/wsError.d.ts.map +1 -1
  40. package/lib/src/common/wsError.js +3 -3
  41. package/lib/src/common/wsOptions.d.ts +1 -1
  42. package/lib/src/index.d.ts +3 -3
  43. package/lib/src/index.d.ts.map +1 -1
  44. package/lib/src/sql/wsProto.d.ts.map +1 -1
  45. package/lib/src/sql/wsRows.d.ts +3 -3
  46. package/lib/src/sql/wsRows.d.ts.map +1 -1
  47. package/lib/src/sql/wsRows.js +4 -2
  48. package/lib/src/sql/wsSql.d.ts +5 -5
  49. package/lib/src/sql/wsSql.d.ts.map +1 -1
  50. package/lib/src/sql/wsSql.js +23 -15
  51. package/lib/src/stmt/FieldBindParams.d.ts +9 -0
  52. package/lib/src/stmt/FieldBindParams.d.ts.map +1 -0
  53. package/lib/src/stmt/FieldBindParams.js +13 -0
  54. package/lib/src/stmt/wsColumnInfo.d.ts +12 -0
  55. package/lib/src/stmt/wsColumnInfo.d.ts.map +1 -0
  56. package/lib/src/stmt/wsColumnInfo.js +17 -0
  57. package/lib/src/stmt/wsParams1.d.ts +14 -0
  58. package/lib/src/stmt/wsParams1.d.ts.map +1 -0
  59. package/lib/src/stmt/wsParams1.js +300 -0
  60. package/lib/src/stmt/wsParams2.d.ts +14 -0
  61. package/lib/src/stmt/wsParams2.d.ts.map +1 -0
  62. package/lib/src/stmt/wsParams2.js +203 -0
  63. package/lib/src/stmt/wsParamsBase.d.ts +45 -0
  64. package/lib/src/stmt/wsParamsBase.d.ts.map +1 -0
  65. package/lib/src/stmt/wsParamsBase.js +220 -0
  66. package/lib/src/stmt/wsProto.d.ts +13 -1
  67. package/lib/src/stmt/wsProto.d.ts.map +1 -1
  68. package/lib/src/stmt/wsProto.js +206 -2
  69. package/lib/src/stmt/wsStmt.d.ts +6 -16
  70. package/lib/src/stmt/wsStmt.d.ts.map +1 -1
  71. package/lib/src/stmt/wsStmt.js +0 -201
  72. package/lib/src/stmt/wsStmt1.d.ts +30 -0
  73. package/lib/src/stmt/wsStmt1.d.ts.map +1 -0
  74. package/lib/src/stmt/wsStmt1.js +206 -0
  75. package/lib/src/stmt/wsStmt2.d.ts +37 -0
  76. package/lib/src/stmt/wsStmt2.d.ts.map +1 -0
  77. package/lib/src/stmt/wsStmt2.js +284 -0
  78. package/lib/src/stmt/wsTableInfo.d.ts +17 -0
  79. package/lib/src/stmt/wsTableInfo.d.ts.map +1 -0
  80. package/lib/src/stmt/wsTableInfo.js +54 -0
  81. package/lib/src/tmq/config.d.ts.map +1 -1
  82. package/lib/src/tmq/config.js +2 -2
  83. package/lib/src/tmq/constant.d.ts.map +1 -1
  84. package/lib/src/tmq/constant.js +28 -28
  85. package/lib/src/tmq/tmqResponse.d.ts.map +1 -1
  86. package/lib/src/tmq/tmqResponse.js +31 -17
  87. package/lib/src/tmq/wsTmq.d.ts +2 -2
  88. package/lib/src/tmq/wsTmq.d.ts.map +1 -1
  89. package/lib/src/tmq/wsTmq.js +32 -30
  90. package/lib/test/bulkPulling/cloud.tmq.test.js +11 -11
  91. package/lib/test/bulkPulling/decimal.test.js +50 -26
  92. package/lib/test/bulkPulling/log.test.js +8 -8
  93. package/lib/test/bulkPulling/queryTables.test.js +255 -49
  94. package/lib/test/bulkPulling/schemaless.test.js +34 -34
  95. package/lib/test/bulkPulling/sql.test.js +108 -66
  96. package/lib/test/bulkPulling/stmt1.func.test.d.ts +2 -0
  97. package/lib/test/bulkPulling/stmt1.func.test.d.ts.map +1 -0
  98. package/lib/test/bulkPulling/{stmt.func.test.js → stmt1.func.test.js} +128 -116
  99. package/lib/test/bulkPulling/stmt1.type.test.d.ts +2 -0
  100. package/lib/test/bulkPulling/stmt1.type.test.d.ts.map +1 -0
  101. package/lib/test/bulkPulling/stmt1.type.test.js +399 -0
  102. package/lib/test/bulkPulling/stmt2.func.test.d.ts +2 -0
  103. package/lib/test/bulkPulling/stmt2.func.test.d.ts.map +1 -0
  104. package/lib/test/bulkPulling/stmt2.func.test.js +543 -0
  105. package/lib/test/bulkPulling/stmt2.type.test.d.ts +2 -0
  106. package/lib/test/bulkPulling/stmt2.type.test.d.ts.map +1 -0
  107. package/lib/test/bulkPulling/{stmt.type.test.js → stmt2.type.test.js} +136 -49
  108. package/lib/test/bulkPulling/tmq.test.js +225 -31
  109. package/lib/test/bulkPulling/utils.test.js +2 -2
  110. package/lib/test/bulkPulling/wsConnectPool.test.js +20 -20
  111. package/lib/test/utils.d.ts.map +1 -1
  112. package/lib/test/utils.js +130 -129
  113. package/package.json +1 -1
  114. package/readme.md +1 -0
  115. package/lib/src/stmt/wsParams.d.ts +0 -41
  116. package/lib/src/stmt/wsParams.d.ts.map +0 -1
  117. package/lib/src/stmt/wsParams.js +0 -428
  118. package/lib/test/bulkPulling/stmt.func.test.d.ts +0 -2
  119. package/lib/test/bulkPulling/stmt.func.test.d.ts.map +0 -1
  120. package/lib/test/bulkPulling/stmt.type.test.d.ts +0 -2
  121. package/lib/test/bulkPulling/stmt.type.test.d.ts.map +0 -1
@@ -2,20 +2,50 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const wsConnectorPool_1 = require("../../src/client/wsConnectorPool");
4
4
  const config_1 = require("../../src/common/config");
5
+ const log_1 = require("../../src/common/log");
5
6
  const wsSql_1 = require("../../src/sql/wsSql");
7
+ const wsStmt2_1 = require("../../src/stmt/wsStmt2");
6
8
  const utils_1 = require("../utils");
7
- const stable = 'ws_stmt_stb';
8
- const table = 'stmt_001';
9
- const db = 'ws_stmt';
9
+ const stable = "ws_stmt_stb";
10
+ const table = "stmt_001";
11
+ const db = "ws_stmt2";
10
12
  const createDB = `create database if not exists ${db} keep 3650`;
11
13
  const useDB = `use ${db}`;
12
14
  const dropDB = `drop database if exists ${db}`;
13
- const tableCN = 'stmt_cn';
14
- const stableCN = 'ws_stmt_stb_cn';
15
- const jsonTable = 'stmt_json';
16
- const jsonTableCN = 'stmt_json_cn';
17
- const stableTags = [true, -1, -2, -3, -4, 1, 2, 3, 4, parseFloat(3.1415.toFixed(5)), parseFloat(3.14159265.toFixed(15)), 'varchar_tag_1', 'nchar_tag_1'];
18
- const stableCNTags = [false, -1 * 2, -2 * 2, -3 * 2, -4 * 2, 1 * 2, 2 * 2, 3 * 2, 4 * 2, parseFloat((3.1415 * 2).toFixed(5)), parseFloat((3.14159265 * 2).toFixed(15)), 'varchar_标签_壹', 'nchar_标签_贰'];
15
+ const tableCN = "stmt_cn";
16
+ const stableCN = "ws_stmt_stb_cn";
17
+ const jsonTable = "stmt_json";
18
+ const jsonTableCN = "stmt_json_cn";
19
+ const stableTags = [
20
+ true,
21
+ -1,
22
+ -2,
23
+ -3,
24
+ -4,
25
+ 1,
26
+ 2,
27
+ 3,
28
+ 4,
29
+ parseFloat((3.1415).toFixed(5)),
30
+ parseFloat((3.14159265).toFixed(15)),
31
+ "varchar_tag_1",
32
+ "nchar_tag_1",
33
+ ];
34
+ const stableCNTags = [
35
+ false,
36
+ -1 * 2,
37
+ -2 * 2,
38
+ -3 * 2,
39
+ -4 * 2,
40
+ 1 * 2,
41
+ 2 * 2,
42
+ 3 * 2,
43
+ 4 * 2,
44
+ parseFloat((3.1415 * 2).toFixed(5)),
45
+ parseFloat((3.14159265 * 2).toFixed(15)),
46
+ "varchar_标签_壹",
47
+ "nchar_标签_贰",
48
+ ];
19
49
  const tableValues = [
20
50
  [1656677710000, 1656677720000, 1656677730000, 1656677740000, 1656677750000],
21
51
  [0, -1, -2, -3, -4],
@@ -28,15 +58,39 @@ const tableValues = [
28
58
  [2, 3, 4, 5, 6],
29
59
  // [0, 1, 2, 3, 4],
30
60
  [BigInt(3), BigInt(4), BigInt(5), BigInt(6), BigInt(7)],
31
- [parseFloat(3.1415.toFixed(5)), parseFloat((3.1415 * 2).toFixed(5)), parseFloat((3.1415 * 3).toFixed(5)), parseFloat((3.1415 * 4).toFixed(5)), parseFloat((3.1415 * 5).toFixed(5))],
32
- [parseFloat(3.14159265.toFixed(15)), parseFloat((3.14159265 * 2).toFixed(15)), parseFloat((3.14159265 * 3).toFixed(15)), parseFloat((3.14159265 * 4).toFixed(15)), parseFloat((3.14159265 * 5).toFixed(15))],
33
- ['varchar_col_1', 'varchar_col_2', 'varchar_col_3', 'varchar_col_4', 'varchar_col_5'],
34
- ['nchar_col_1', 'nchar_col_2', '', 'nchar_col_4', 'nchar_col_5'],
61
+ [
62
+ parseFloat((3.1415).toFixed(5)),
63
+ parseFloat((3.1415 * 2).toFixed(5)),
64
+ parseFloat((3.1415 * 3).toFixed(5)),
65
+ parseFloat((3.1415 * 4).toFixed(5)),
66
+ parseFloat((3.1415 * 5).toFixed(5)),
67
+ ],
68
+ [
69
+ parseFloat((3.14159265).toFixed(15)),
70
+ parseFloat((3.14159265 * 2).toFixed(15)),
71
+ parseFloat((3.14159265 * 3).toFixed(15)),
72
+ parseFloat((3.14159265 * 4).toFixed(15)),
73
+ parseFloat((3.14159265 * 5).toFixed(15)),
74
+ ],
75
+ [
76
+ "varchar_col_1",
77
+ "varchar_col_2",
78
+ "varchar_col_3",
79
+ "varchar_col_4",
80
+ "varchar_col_5",
81
+ ],
82
+ ["nchar_col_1", "nchar_col_2", "", "nchar_col_4", "nchar_col_5"],
35
83
  [true, false, true, false, true],
36
- [null, null, null, null, null]
84
+ [null, null, null, null, null],
37
85
  ];
38
86
  const tableCNValues = [
39
- [BigInt(1656677760000), BigInt(1656677770000), BigInt(1656677780000), BigInt(1656677790000), BigInt(1656677100000)],
87
+ [
88
+ BigInt(1656677760000),
89
+ BigInt(1656677770000),
90
+ BigInt(1656677780000),
91
+ BigInt(1656677790000),
92
+ BigInt(1656677100000),
93
+ ],
40
94
  [0, -1, -2, -3, -4],
41
95
  [-1, -2, -3, -4, -5],
42
96
  [-2, -3, -4, -5, -6],
@@ -45,10 +99,28 @@ const tableCNValues = [
45
99
  [1, 2, 3, 4, 5],
46
100
  [2, 3, 4, 5, 6],
47
101
  [BigInt(3), BigInt(4), BigInt(5), BigInt(6), BigInt(7)],
48
- [parseFloat(3.1415.toFixed(5)), parseFloat((3.1415 * 2).toFixed(5)), parseFloat((3.1415 * 3).toFixed(5)), parseFloat((3.1415 * 4).toFixed(5)), parseFloat((3.1415 * 5).toFixed(5))],
49
- [parseFloat(3.14159265.toFixed(15)), parseFloat((3.14159265 * 2).toFixed(15)), parseFloat((3.14159265 * 3).toFixed(15)), parseFloat((3.14159265 * 4).toFixed(15)), parseFloat((3.14159265 * 5).toFixed(15))],
50
- ['varchar_列_壹', 'varchar_列_贰', 'varchar_列_叁', 'varchar_列_肆', 'varchar_列_伍'],
51
- ['nchar_列_甲', 'nchar_列_乙', 'nchar_列_丙', 'nchar_列_丁', 'nchar_列_戊'],
102
+ [
103
+ parseFloat((3.1415).toFixed(5)),
104
+ parseFloat((3.1415 * 2).toFixed(5)),
105
+ parseFloat((3.1415 * 3).toFixed(5)),
106
+ parseFloat((3.1415 * 4).toFixed(5)),
107
+ parseFloat((3.1415 * 5).toFixed(5)),
108
+ ],
109
+ [
110
+ parseFloat((3.14159265).toFixed(15)),
111
+ parseFloat((3.14159265 * 2).toFixed(15)),
112
+ parseFloat((3.14159265 * 3).toFixed(15)),
113
+ parseFloat((3.14159265 * 4).toFixed(15)),
114
+ parseFloat((3.14159265 * 5).toFixed(15)),
115
+ ],
116
+ [
117
+ "varchar_列_壹",
118
+ "varchar_列_贰",
119
+ "varchar_列_叁",
120
+ "varchar_列_肆",
121
+ "varchar_列_伍",
122
+ ],
123
+ ["nchar_列_甲", "nchar_列_乙", "nchar_列_丙", "nchar_列_丁", "nchar_列_戊"],
52
124
  [true, false, true, false, true],
53
125
  [null, null, null, null, null],
54
126
  ];
@@ -56,21 +128,28 @@ let geoDataArray = [];
56
128
  let varbinary = [];
57
129
  const encoder = new TextEncoder();
58
130
  for (let i = 0; i < 5; i++) {
59
- let data = new Uint8Array([0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
60
- 0x00, 0x00, 0x00, 0x59, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x40,]);
131
+ let data = new Uint8Array([
132
+ 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59,
133
+ 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x40,
134
+ ]);
61
135
  geoDataArray.push(data.buffer);
62
136
  let vdata = encoder.encode(`varchar_col_${i + 1}`);
63
137
  varbinary.push(vdata.buffer);
64
138
  }
65
- const jsonTags = ["{\"key1\":\"taos\",\"key2\":null,\"key3\":\"TDengine\",\"key4\":0,\"key5\":false}"];
66
- const jsonTagsCN = ["{\"key1\":\"taosdata\",\"key2\":null,\"key3\":\"TDengine涛思数据\",\"key4\":1,\"key5\":true}"];
139
+ const jsonTags = [
140
+ '{"key1":"taos","key2":null,"key3":"TDengine","key4":0,"key5":false}',
141
+ ];
142
+ const jsonTagsCN = [
143
+ '{"key1":"taosdata","key2":null,"key3":"TDengine涛思数据","key4":1,"key5":true}',
144
+ ];
67
145
  const selectStable = `select * from ${stable}`;
68
146
  const selectStableCN = `select * from ${stableCN}`;
69
147
  const selectTable = `select * from ${table}`;
70
148
  const selectTableCN = `select * from ${tableCN}`;
71
149
  const selectJsonTable = `select * from ${jsonTable}`;
72
150
  const selectJsonTableCN = `select * from ${jsonTableCN}`;
73
- let dsn = 'ws://root:taosdata@localhost:6041';
151
+ let dsn = "ws://root:taosdata@localhost:6041";
152
+ (0, log_1.setLevel)("debug");
74
153
  beforeAll(async () => {
75
154
  let conf = new config_1.WSConfig(dsn);
76
155
  let ws = await wsSql_1.WsSql.open(conf);
@@ -81,14 +160,15 @@ beforeAll(async () => {
81
160
  await ws.exec((0, utils_1.createSTableJSON)(jsonTable));
82
161
  await ws.close();
83
162
  });
84
- describe('TDWebSocket.Stmt()', () => {
163
+ describe("TDWebSocket.Stmt()", () => {
85
164
  jest.setTimeout(20 * 1000);
86
- test('normal BindParam', async () => {
165
+ test("normal BindParam", async () => {
87
166
  let wsConf = new config_1.WSConfig(dsn);
88
167
  wsConf.setDb(db);
89
168
  let connector = await wsSql_1.WsSql.open(wsConf);
90
- let stmt = await (await connector).stmtInit();
169
+ let stmt = await connector.stmtInit();
91
170
  expect(stmt).toBeTruthy();
171
+ expect(stmt).toBeInstanceOf(wsStmt2_1.WsStmt2);
92
172
  expect(connector.state()).toBeGreaterThan(0);
93
173
  await stmt.prepare((0, utils_1.getInsertBind)(tableValues.length + 2, stableTags.length, db, stable));
94
174
  await stmt.setTableName(table);
@@ -134,12 +214,13 @@ describe('TDWebSocket.Stmt()', () => {
134
214
  console.log(result);
135
215
  await connector.close();
136
216
  });
137
- test('normal CN BindParam', async () => {
217
+ test("normal CN BindParam", async () => {
138
218
  let wsConf = new config_1.WSConfig(dsn);
139
219
  wsConf.setDb(db);
140
220
  let connector = await wsSql_1.WsSql.open(wsConf);
141
221
  let stmt = await (await connector).stmtInit();
142
222
  expect(stmt).toBeTruthy();
223
+ expect(stmt).toBeInstanceOf(wsStmt2_1.WsStmt2);
143
224
  expect(connector.state()).toBeGreaterThan(0);
144
225
  await stmt.prepare((0, utils_1.getInsertBind)(tableValues.length + 2, stableTags.length, db, stable));
145
226
  await stmt.setTableName(table);
@@ -185,12 +266,13 @@ describe('TDWebSocket.Stmt()', () => {
185
266
  console.log(result);
186
267
  await connector.close();
187
268
  });
188
- test('normal json tag BindParam', async () => {
269
+ test("normal json tag BindParam", async () => {
189
270
  let wsConf = new config_1.WSConfig(dsn);
190
271
  wsConf.setDb(db);
191
272
  let connector = await wsSql_1.WsSql.open(wsConf);
192
273
  let stmt = await (await connector).stmtInit();
193
274
  expect(stmt).toBeTruthy();
275
+ expect(stmt).toBeInstanceOf(wsStmt2_1.WsStmt2);
194
276
  expect(connector.state()).toBeGreaterThan(0);
195
277
  await stmt.prepare((0, utils_1.getInsertBind)(tableValues.length + 2, jsonTags.length, db, jsonTable));
196
278
  await stmt.setTableName(`${jsonTable}_001`);
@@ -224,12 +306,13 @@ describe('TDWebSocket.Stmt()', () => {
224
306
  console.log(result);
225
307
  await connector.close();
226
308
  });
227
- test('normal json cn tag BindParam', async () => {
309
+ test("normal json cn tag BindParam", async () => {
228
310
  let wsConf = new config_1.WSConfig(dsn);
229
311
  wsConf.setDb(db);
230
312
  let connector = await wsSql_1.WsSql.open(wsConf);
231
313
  let stmt = await connector.stmtInit();
232
314
  expect(stmt).toBeTruthy();
315
+ expect(stmt).toBeInstanceOf(wsStmt2_1.WsStmt2);
233
316
  expect(connector.state()).toBeGreaterThan(0);
234
317
  await stmt.prepare((0, utils_1.getInsertBind)(tableValues.length + 2, jsonTags.length, db, jsonTable));
235
318
  await stmt.setTableName(`${jsonTable}_001`);
@@ -264,24 +347,25 @@ describe('TDWebSocket.Stmt()', () => {
264
347
  await connector.close();
265
348
  });
266
349
  });
267
- test('test bind exception cases', async () => {
350
+ test("test bind exception cases", async () => {
268
351
  let wsConf = new config_1.WSConfig(dsn);
269
352
  let connector = await wsSql_1.WsSql.open(wsConf);
270
353
  let stmt = await connector.stmtInit();
354
+ expect(stmt).toBeInstanceOf(wsStmt2_1.WsStmt2);
271
355
  const params = stmt.newStmtParam();
272
356
  const emptyArrayMethods = [
273
- { method: 'setBoolean', name: 'SetBooleanColumn' },
274
- { method: 'setTinyInt', name: 'SetTinyIntColumn' },
275
- { method: 'setUTinyInt', name: 'SetUTinyIntColumn' },
276
- { method: 'setSmallInt', name: 'SetSmallIntColumn' },
277
- { method: 'setUSmallInt', name: 'SetSmallIntColumn' },
278
- { method: 'setInt', name: 'SetIntColumn' },
279
- { method: 'setUInt', name: 'SetUIntColumn' },
280
- { method: 'setBigint', name: 'SetBigIntColumn' },
281
- { method: 'setUBigint', name: 'SetUBigIntColumn' },
282
- { method: 'setFloat', name: 'SetFloatColumn' },
283
- { method: 'setDouble', name: 'SetDoubleColumn' },
284
- { method: 'setTimestamp', name: 'SeTimestampColumn' }
357
+ { method: "setBoolean", name: "SetBooleanColumn" },
358
+ { method: "setTinyInt", name: "SetTinyIntColumn" },
359
+ { method: "setUTinyInt", name: "SetUTinyIntColumn" },
360
+ { method: "setSmallInt", name: "SetSmallIntColumn" },
361
+ { method: "setUSmallInt", name: "SetSmallIntColumn" },
362
+ { method: "setInt", name: "SetIntColumn" },
363
+ { method: "setUInt", name: "SetUIntColumn" },
364
+ { method: "setBigint", name: "SetBigIntColumn" },
365
+ { method: "setUBigint", name: "SetUBigIntColumn" },
366
+ { method: "setFloat", name: "SetFloatColumn" },
367
+ { method: "setDouble", name: "SetDoubleColumn" },
368
+ { method: "setTimestamp", name: "SeTimestampColumn" },
285
369
  ];
286
370
  emptyArrayMethods.forEach(({ method, name }) => {
287
371
  expect(() => {
@@ -295,14 +379,17 @@ test('test bind exception cases', async () => {
295
379
  }).toThrow(`${name} params is invalid!`);
296
380
  });
297
381
  expect(() => {
298
- params.setBoolean(['not boolean']);
299
- }).toThrow('SetTinyIntColumn params is invalid!');
382
+ params.setBoolean(["not boolean"]);
383
+ params.encode();
384
+ }).toThrow("SetTinyIntColumn params is invalid!");
300
385
  expect(() => {
301
- params.setTinyInt(['not number']);
302
- }).toThrow('SetTinyIntColumn params is invalid!');
386
+ params.setTinyInt(["not number"]);
387
+ params.encode();
388
+ }).toThrow("SetTinyIntColumn params is invalid!");
303
389
  expect(() => {
304
- params.setBigint(['not bigint']);
305
- }).toThrow('SetTinyIntColumn params is invalid!');
390
+ params.setBigint(["not bigint"]);
391
+ params.encode();
392
+ }).toThrow("SetTinyIntColumn params is invalid!");
306
393
  await connector.close();
307
394
  });
308
395
  afterAll(async () => {
@@ -8,36 +8,230 @@ const utils_1 = require("../utils");
8
8
  const wsConnectorPool_1 = require("../../src/client/wsConnectorPool");
9
9
  const log_1 = require("../../src/common/log");
10
10
  (0, log_1.setLevel)("debug");
11
- const stable = 'st';
12
- const db = 'ws_tmq_test';
13
- const topics = ['topic_ws_bean'];
11
+ const stable = "st";
12
+ const db = "ws_tmq_test";
13
+ const topics = ["topic_ws_bean"];
14
14
  // const topic2 = 'topic_ws_bean_2'
15
15
  // let createTopic = `create topic if not exists ${topic} as select ts, c1, c2, c3, c4, c5, t1 from ${db}.${stable}`
16
16
  // let createTopic2 = `create topic if not exists ${topic2} as select ts, c1, c4, c5, t1 from ${db}.${stable}`
17
17
  let createTopic = `create topic if not exists ${topics[0]} as select * from ${db}.${stable}`;
18
18
  let dropTopic = `DROP TOPIC IF EXISTS ${topics[0]};`;
19
19
  // let dropTopic2 = `DROP TOPIC IF EXISTS ${topic2};`
20
- let dsn = 'ws://root:taosdata@localhost:6041';
21
- let tmqDsn = 'ws://localhost:6041';
20
+ let dsn = "ws://root:taosdata@localhost:6041";
21
+ let tmqDsn = "ws://localhost:6041";
22
22
  beforeAll(async () => {
23
23
  let conf = new config_1.WSConfig(dsn);
24
24
  const createDB = `create database if not exists ${db} keep 3650`;
25
25
  const dropDB = `drop database if exists ${db}`;
26
26
  const useDB = `use ${db}`;
27
- const stableTags = [true, -1, -2, -3, BigInt(-4), 1, 2, 3, BigInt(4), parseFloat(3.1415.toFixed(5)), parseFloat(3.14159265.toFixed(15)), 'varchar_tag_1', 'nchar_tag_1'];
27
+ const stableTags = [
28
+ true,
29
+ -1,
30
+ -2,
31
+ -3,
32
+ BigInt(-4),
33
+ 1,
34
+ 2,
35
+ 3,
36
+ BigInt(4),
37
+ parseFloat((3.1415).toFixed(5)),
38
+ parseFloat((3.14159265).toFixed(15)),
39
+ "varchar_tag_1",
40
+ "nchar_tag_1",
41
+ ];
28
42
  const tableValues = [
29
- [BigInt(1656677710000), 0, -1, -2, BigInt(-3), 0, 1, 2, BigInt(3), parseFloat(3.1415.toFixed(5)), parseFloat(3.14159265.toFixed(15)), 'varchar_col_1', 'nchar_col_1', true, 'NULL', 'POINT (4.0 8.0)', '0x7661726332'],
30
- [BigInt(1656677720000), -1, -2, -3, BigInt(-4), 1, 2, 3, BigInt(4), parseFloat((3.1415 * 2).toFixed(5)), parseFloat((3.14159265 * 2).toFixed(15)), 'varchar_col_2', 'nchar_col_2', false, 'NULL', 'POINT (3.0 5.0)', '0x7661726333'],
31
- [BigInt(1656677730000), -2, -3, -4, BigInt(-5), 2, 3, 4, BigInt(5), parseFloat((3.1415 * 3).toFixed(5)), parseFloat((3.14159265 * 3).toFixed(15)), 'varchar_col_3', 'nchar_col_3', true, 'NULL', 'LINESTRING (1.000000 1.000000, 2.000000 2.000000, 5.000000 5.000000)', '0x7661726334'],
32
- [BigInt(1656677740000), -3, -4, -5, BigInt(-6), 3, 4, 5, BigInt(6), parseFloat((3.1415 * 4).toFixed(5)), parseFloat((3.14159265 * 4).toFixed(15)), 'varchar_col_4', 'nchar_col_4', false, 'NULL', 'POLYGON ((3.000000 6.000000, 5.000000 6.000000, 5.000000 8.000000, 3.000000 8.000000, 3.000000 6.000000))', '0x7661726335'],
33
- [BigInt(1656677750000), -4, -5, -6, BigInt(-7), 4, 5, 6, BigInt(7), parseFloat((3.1415 * 5).toFixed(5)), parseFloat((3.14159265 * 5).toFixed(15)), 'varchar_col_5', 'nchar_col_5', true, 'NULL', 'POINT (7.0 9.0)', '0x7661726335'],
43
+ [
44
+ BigInt(1656677710000),
45
+ 0,
46
+ -1,
47
+ -2,
48
+ BigInt(-3),
49
+ 0,
50
+ 1,
51
+ 2,
52
+ BigInt(3),
53
+ parseFloat((3.1415).toFixed(5)),
54
+ parseFloat((3.14159265).toFixed(15)),
55
+ "varchar_col_1",
56
+ "nchar_col_1",
57
+ true,
58
+ "NULL",
59
+ "POINT (4.0 8.0)",
60
+ "0x7661726332",
61
+ ],
62
+ [
63
+ BigInt(1656677720000),
64
+ -1,
65
+ -2,
66
+ -3,
67
+ BigInt(-4),
68
+ 1,
69
+ 2,
70
+ 3,
71
+ BigInt(4),
72
+ parseFloat((3.1415 * 2).toFixed(5)),
73
+ parseFloat((3.14159265 * 2).toFixed(15)),
74
+ "varchar_col_2",
75
+ "nchar_col_2",
76
+ false,
77
+ "NULL",
78
+ "POINT (3.0 5.0)",
79
+ "0x7661726333",
80
+ ],
81
+ [
82
+ BigInt(1656677730000),
83
+ -2,
84
+ -3,
85
+ -4,
86
+ BigInt(-5),
87
+ 2,
88
+ 3,
89
+ 4,
90
+ BigInt(5),
91
+ parseFloat((3.1415 * 3).toFixed(5)),
92
+ parseFloat((3.14159265 * 3).toFixed(15)),
93
+ "varchar_col_3",
94
+ "nchar_col_3",
95
+ true,
96
+ "NULL",
97
+ "LINESTRING (1.000000 1.000000, 2.000000 2.000000, 5.000000 5.000000)",
98
+ "0x7661726334",
99
+ ],
100
+ [
101
+ BigInt(1656677740000),
102
+ -3,
103
+ -4,
104
+ -5,
105
+ BigInt(-6),
106
+ 3,
107
+ 4,
108
+ 5,
109
+ BigInt(6),
110
+ parseFloat((3.1415 * 4).toFixed(5)),
111
+ parseFloat((3.14159265 * 4).toFixed(15)),
112
+ "varchar_col_4",
113
+ "nchar_col_4",
114
+ false,
115
+ "NULL",
116
+ "POLYGON ((3.000000 6.000000, 5.000000 6.000000, 5.000000 8.000000, 3.000000 8.000000, 3.000000 6.000000))",
117
+ "0x7661726335",
118
+ ],
119
+ [
120
+ BigInt(1656677750000),
121
+ -4,
122
+ -5,
123
+ -6,
124
+ BigInt(-7),
125
+ 4,
126
+ 5,
127
+ 6,
128
+ BigInt(7),
129
+ parseFloat((3.1415 * 5).toFixed(5)),
130
+ parseFloat((3.14159265 * 5).toFixed(15)),
131
+ "varchar_col_5",
132
+ "nchar_col_5",
133
+ true,
134
+ "NULL",
135
+ "POINT (7.0 9.0)",
136
+ "0x7661726335",
137
+ ],
34
138
  ];
35
139
  const tableCNValues = [
36
- [BigInt(1656677760000), 0, -1, -2, BigInt(-3), 0, 1, 2, BigInt(3), parseFloat(3.1415.toFixed(5)), parseFloat(3.14159265.toFixed(15)), 'varchar_列_壹', 'nchar_列_甲', true, 'NULL', 'POINT (4.0 8.0)', '0x7661726332'],
37
- [BigInt(1656677770000), -1, -2, -3, BigInt(-4), 1, 2, 3, BigInt(4), parseFloat((3.1415 * 2).toFixed(5)), parseFloat((3.14159265 * 2).toFixed(15)), 'varchar_列_贰', 'nchar_列_乙', false, 'NULL', 'POINT (3.0 5.0)', '0x7661726333'],
38
- [BigInt(1656677780000), -2, -3, -4, BigInt(-5), 2, 3, 4, BigInt(5), parseFloat((3.1415 * 3).toFixed(5)), parseFloat((3.14159265 * 3).toFixed(15)), 'varchar_列_叁', 'nchar_列_丙', true, 'NULL', 'LINESTRING (1.000000 1.000000, 2.000000 2.000000, 5.000000 5.000000)', '0x7661726334'],
39
- [BigInt(1656677790000), -3, -4, -5, BigInt(-6), 3, 4, 5, BigInt(6), parseFloat((3.1415 * 4).toFixed(5)), parseFloat((3.14159265 * 4).toFixed(15)), 'varchar_列_肆', 'nchar_列_丁', false, 'NULL', 'POLYGON ((3.000000 6.000000, 5.000000 6.000000, 5.000000 8.000000, 3.000000 8.000000, 3.000000 6.000000))', '0x7661726335'],
40
- [BigInt(1656677800000), -4, -5, -6, BigInt(-7), 4, 5, 6, BigInt(7), parseFloat((3.1415 * 5).toFixed(5)), parseFloat((3.14159265 * 5).toFixed(15)), 'varchar_列_伍', 'nchar_列_戊', true, 'NULL', 'POINT (7.0 9.0)', '0x7661726335'],
140
+ [
141
+ BigInt(1656677760000),
142
+ 0,
143
+ -1,
144
+ -2,
145
+ BigInt(-3),
146
+ 0,
147
+ 1,
148
+ 2,
149
+ BigInt(3),
150
+ parseFloat((3.1415).toFixed(5)),
151
+ parseFloat((3.14159265).toFixed(15)),
152
+ "varchar_列_壹",
153
+ "nchar_列_甲",
154
+ true,
155
+ "NULL",
156
+ "POINT (4.0 8.0)",
157
+ "0x7661726332",
158
+ ],
159
+ [
160
+ BigInt(1656677770000),
161
+ -1,
162
+ -2,
163
+ -3,
164
+ BigInt(-4),
165
+ 1,
166
+ 2,
167
+ 3,
168
+ BigInt(4),
169
+ parseFloat((3.1415 * 2).toFixed(5)),
170
+ parseFloat((3.14159265 * 2).toFixed(15)),
171
+ "varchar_列_贰",
172
+ "nchar_列_乙",
173
+ false,
174
+ "NULL",
175
+ "POINT (3.0 5.0)",
176
+ "0x7661726333",
177
+ ],
178
+ [
179
+ BigInt(1656677780000),
180
+ -2,
181
+ -3,
182
+ -4,
183
+ BigInt(-5),
184
+ 2,
185
+ 3,
186
+ 4,
187
+ BigInt(5),
188
+ parseFloat((3.1415 * 3).toFixed(5)),
189
+ parseFloat((3.14159265 * 3).toFixed(15)),
190
+ "varchar_列_叁",
191
+ "nchar_列_丙",
192
+ true,
193
+ "NULL",
194
+ "LINESTRING (1.000000 1.000000, 2.000000 2.000000, 5.000000 5.000000)",
195
+ "0x7661726334",
196
+ ],
197
+ [
198
+ BigInt(1656677790000),
199
+ -3,
200
+ -4,
201
+ -5,
202
+ BigInt(-6),
203
+ 3,
204
+ 4,
205
+ 5,
206
+ BigInt(6),
207
+ parseFloat((3.1415 * 4).toFixed(5)),
208
+ parseFloat((3.14159265 * 4).toFixed(15)),
209
+ "varchar_列_肆",
210
+ "nchar_列_丁",
211
+ false,
212
+ "NULL",
213
+ "POLYGON ((3.000000 6.000000, 5.000000 6.000000, 5.000000 8.000000, 3.000000 8.000000, 3.000000 6.000000))",
214
+ "0x7661726335",
215
+ ],
216
+ [
217
+ BigInt(1656677800000),
218
+ -4,
219
+ -5,
220
+ -6,
221
+ BigInt(-7),
222
+ 4,
223
+ 5,
224
+ 6,
225
+ BigInt(7),
226
+ parseFloat((3.1415 * 5).toFixed(5)),
227
+ parseFloat((3.14159265 * 5).toFixed(15)),
228
+ "varchar_列_伍",
229
+ "nchar_列_戊",
230
+ true,
231
+ "NULL",
232
+ "POINT (7.0 9.0)",
233
+ "0x7661726335",
234
+ ],
41
235
  ];
42
236
  let ws = await wsSql_1.WsSql.open(conf);
43
237
  await ws.exec(dropTopic);
@@ -54,27 +248,27 @@ beforeAll(async () => {
54
248
  insertRes = await ws.exec(insert);
55
249
  await ws.close();
56
250
  });
57
- describe('TDWebSocket.Tmq()', () => {
251
+ describe("TDWebSocket.Tmq()", () => {
58
252
  jest.setTimeout(20 * 1000);
59
253
  let configMap = new Map([
60
254
  [constant_1.TMQConstants.GROUP_ID, "gId"],
61
255
  [constant_1.TMQConstants.CONNECT_USER, "root"],
62
256
  [constant_1.TMQConstants.CONNECT_PASS, "taosdata"],
63
257
  [constant_1.TMQConstants.AUTO_OFFSET_RESET, "earliest"],
64
- [constant_1.TMQConstants.CLIENT_ID, 'test_tmq_client'],
258
+ [constant_1.TMQConstants.CLIENT_ID, "test_tmq_client"],
65
259
  [constant_1.TMQConstants.WS_URL, tmqDsn],
66
- [constant_1.TMQConstants.ENABLE_AUTO_COMMIT, 'true'],
67
- [constant_1.TMQConstants.AUTO_COMMIT_INTERVAL_MS, '1000'],
260
+ [constant_1.TMQConstants.ENABLE_AUTO_COMMIT, "true"],
261
+ [constant_1.TMQConstants.AUTO_COMMIT_INTERVAL_MS, "1000"],
68
262
  ["session.timeout.ms", "10000"],
69
263
  ["max.poll.interval.ms", "30000"],
70
- ["msg.with.table.name", "true"]
264
+ ["msg.with.table.name", "true"],
71
265
  ]);
72
266
  console.log(configMap);
73
- test('normal connect', async () => {
267
+ test("normal connect", async () => {
74
268
  let consumer = await wsTmq_1.WsConsumer.newConsumer(configMap);
75
269
  await consumer.close();
76
270
  });
77
- test('connect error', async () => {
271
+ test("connect error", async () => {
78
272
  expect.assertions(1);
79
273
  let consumer = null;
80
274
  let errConfigMap = new Map([
@@ -82,13 +276,13 @@ describe('TDWebSocket.Tmq()', () => {
82
276
  [constant_1.TMQConstants.CONNECT_USER, "root"],
83
277
  [constant_1.TMQConstants.CONNECT_PASS, "test"],
84
278
  [constant_1.TMQConstants.AUTO_OFFSET_RESET, "earliest1"],
85
- [constant_1.TMQConstants.CLIENT_ID, 'test_tmq_client'],
279
+ [constant_1.TMQConstants.CLIENT_ID, "test_tmq_client"],
86
280
  [constant_1.TMQConstants.WS_URL, tmqDsn],
87
- [constant_1.TMQConstants.ENABLE_AUTO_COMMIT, 'true'],
88
- [constant_1.TMQConstants.AUTO_COMMIT_INTERVAL_MS, '1000'],
281
+ [constant_1.TMQConstants.ENABLE_AUTO_COMMIT, "true"],
282
+ [constant_1.TMQConstants.AUTO_COMMIT_INTERVAL_MS, "1000"],
89
283
  ["session.timeout.ms", "10000"],
90
284
  ["max.poll.interval.ms", "30000"],
91
- ["msg.with.table.name", "true"]
285
+ ["msg.with.table.name", "true"],
92
286
  ]);
93
287
  try {
94
288
  consumer = await wsTmq_1.WsConsumer.newConsumer(errConfigMap);
@@ -96,7 +290,7 @@ describe('TDWebSocket.Tmq()', () => {
96
290
  }
97
291
  catch (e) {
98
292
  console.log(e);
99
- expect(e.code).toBe(65535);
293
+ expect(e.code).toBe(280);
100
294
  }
101
295
  finally {
102
296
  if (consumer) {
@@ -104,7 +298,7 @@ describe('TDWebSocket.Tmq()', () => {
104
298
  }
105
299
  }
106
300
  });
107
- test('normal Subscribe', async () => {
301
+ test("normal Subscribe", async () => {
108
302
  let consumer = await wsTmq_1.WsConsumer.newConsumer(configMap);
109
303
  await consumer.subscribe(topics);
110
304
  let assignment = await consumer.assignment();
@@ -160,7 +354,7 @@ describe('TDWebSocket.Tmq()', () => {
160
354
  console.log("------------->", counts);
161
355
  expect(counts).toEqual(10);
162
356
  });
163
- test('Topic not exist', async () => {
357
+ test("Topic not exist", async () => {
164
358
  let consumer = await wsTmq_1.WsConsumer.newConsumer(configMap);
165
359
  try {
166
360
  await consumer.subscribe(["aaa"]);
@@ -170,7 +364,7 @@ describe('TDWebSocket.Tmq()', () => {
170
364
  }
171
365
  await consumer.close();
172
366
  });
173
- test('normal seek', async () => {
367
+ test("normal seek", async () => {
174
368
  let consumer = await wsTmq_1.WsConsumer.newConsumer(configMap);
175
369
  await consumer.subscribe(topics);
176
370
  let assignment = await consumer.assignment();
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("../../src/common/utils");
4
- describe('utils test', () => {
5
- test('compare versions test', async () => {
4
+ describe("utils test", () => {
5
+ test("compare versions test", async () => {
6
6
  expect((0, utils_1.compareVersions)("3.3.6.3-alpha", "3.3.6.2")).toBe(1);
7
7
  expect((0, utils_1.compareVersions)("3.3.6.2", "3.3.6.3")).toBe(-1);
8
8
  expect((0, utils_1.compareVersions)("3.3.6.3", "3.3.6.3")).toBe(0);