@tdengine/websocket 3.2.0 → 3.2.2

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 (102) 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 +0 -7
  9. package/lib/index.d.ts.map +1 -1
  10. package/lib/index.js +0 -7
  11. package/lib/src/client/wsClient.d.ts +2 -2
  12. package/lib/src/client/wsClient.d.ts.map +1 -1
  13. package/lib/src/client/wsClient.js +60 -37
  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 +2 -2
  23. package/lib/src/common/config.d.ts.map +1 -1
  24. package/lib/src/common/config.js +5 -5
  25. package/lib/src/common/constant.d.ts.map +1 -1
  26. package/lib/src/common/constant.js +27 -27
  27. package/lib/src/common/log.d.ts +1 -1
  28. package/lib/src/common/log.d.ts.map +1 -1
  29. package/lib/src/common/log.js +9 -7
  30. package/lib/src/common/reqid.d.ts.map +1 -1
  31. package/lib/src/common/reqid.js +7 -7
  32. package/lib/src/common/taosResult.d.ts.map +1 -1
  33. package/lib/src/common/taosResult.js +46 -27
  34. package/lib/src/common/ut8Helper.d.ts.map +1 -1
  35. package/lib/src/common/ut8Helper.js +8 -8
  36. package/lib/src/common/utils.d.ts.map +1 -1
  37. package/lib/src/common/utils.js +17 -16
  38. package/lib/src/common/wsError.d.ts.map +1 -1
  39. package/lib/src/common/wsError.js +3 -3
  40. package/lib/src/common/wsOptions.d.ts +1 -1
  41. package/lib/src/index.d.ts +3 -3
  42. package/lib/src/index.d.ts.map +1 -1
  43. package/lib/src/sql/wsProto.d.ts.map +1 -1
  44. package/lib/src/sql/wsRows.d.ts +3 -3
  45. package/lib/src/sql/wsRows.d.ts.map +1 -1
  46. package/lib/src/sql/wsRows.js +4 -2
  47. package/lib/src/sql/wsSql.d.ts +5 -5
  48. package/lib/src/sql/wsSql.d.ts.map +1 -1
  49. package/lib/src/sql/wsSql.js +15 -16
  50. package/lib/src/stmt/FieldBindParams.d.ts.map +1 -1
  51. package/lib/src/stmt/wsColumnInfo.d.ts.map +1 -1
  52. package/lib/src/stmt/wsParams1.d.ts.map +1 -1
  53. package/lib/src/stmt/wsParams1.js +50 -24
  54. package/lib/src/stmt/wsParams2.d.ts.map +1 -1
  55. package/lib/src/stmt/wsParams2.js +30 -15
  56. package/lib/src/stmt/wsParamsBase.d.ts.map +1 -1
  57. package/lib/src/stmt/wsParamsBase.js +5 -3
  58. package/lib/src/stmt/wsProto.d.ts.map +1 -1
  59. package/lib/src/stmt/wsProto.js +22 -11
  60. package/lib/src/stmt/wsStmt.d.ts.map +1 -1
  61. package/lib/src/stmt/wsStmt1.d.ts +5 -5
  62. package/lib/src/stmt/wsStmt1.d.ts.map +1 -1
  63. package/lib/src/stmt/wsStmt1.js +14 -14
  64. package/lib/src/stmt/wsStmt2.d.ts +1 -1
  65. package/lib/src/stmt/wsStmt2.d.ts.map +1 -1
  66. package/lib/src/stmt/wsStmt2.js +18 -14
  67. package/lib/src/stmt/wsTableInfo.d.ts.map +1 -1
  68. package/lib/src/tmq/config.d.ts.map +1 -1
  69. package/lib/src/tmq/config.js +2 -2
  70. package/lib/src/tmq/constant.d.ts.map +1 -1
  71. package/lib/src/tmq/constant.js +28 -28
  72. package/lib/src/tmq/tmqResponse.d.ts.map +1 -1
  73. package/lib/src/tmq/tmqResponse.js +30 -16
  74. package/lib/src/tmq/wsTmq.d.ts +2 -2
  75. package/lib/src/tmq/wsTmq.d.ts.map +1 -1
  76. package/lib/src/tmq/wsTmq.js +32 -30
  77. package/lib/test/bulkPulling/cloud.tmq.test.js +11 -11
  78. package/lib/test/bulkPulling/decimal.test.js +50 -26
  79. package/lib/test/bulkPulling/log.test.js +8 -8
  80. package/lib/test/bulkPulling/queryTables.test.js +255 -49
  81. package/lib/test/bulkPulling/schemaless.test.js +34 -34
  82. package/lib/test/bulkPulling/sql.test.js +108 -69
  83. package/lib/test/bulkPulling/stmt1.func.test.js +96 -96
  84. package/lib/test/bulkPulling/stmt1.type.test.js +124 -48
  85. package/lib/test/bulkPulling/stmt2.func.test.js +116 -112
  86. package/lib/test/bulkPulling/stmt2.type.test.js +124 -48
  87. package/lib/test/bulkPulling/tmq.test.js +225 -31
  88. package/lib/test/bulkPulling/utils.test.js +2 -2
  89. package/lib/test/bulkPulling/wsConnectPool.test.js +18 -18
  90. package/lib/test/utils.d.ts.map +1 -1
  91. package/lib/test/utils.js +129 -129
  92. package/package.json +1 -1
  93. package/readme.md +1 -0
  94. package/lib/src/stmt/wsParams.d.ts +0 -41
  95. package/lib/src/stmt/wsParams.d.ts.map +0 -1
  96. package/lib/src/stmt/wsParams.js +0 -428
  97. package/lib/test/bulkPulling/stmt.func.test.d.ts +0 -2
  98. package/lib/test/bulkPulling/stmt.func.test.d.ts.map +0 -1
  99. package/lib/test/bulkPulling/stmt.func.test.js +0 -493
  100. package/lib/test/bulkPulling/stmt.type.test.d.ts +0 -2
  101. package/lib/test/bulkPulling/stmt.type.test.d.ts.map +0 -1
  102. package/lib/test/bulkPulling/stmt.type.test.js +0 -316
@@ -6,18 +6,46 @@ const log_1 = require("../../src/common/log");
6
6
  const wsSql_1 = require("../../src/sql/wsSql");
7
7
  const wsStmt1_1 = require("../../src/stmt/wsStmt1");
8
8
  const utils_1 = require("../utils");
9
- const stable = 'ws_stmt_stb';
10
- const table = 'stmt_001';
11
- const db = 'ws_stmt1';
9
+ const stable = "ws_stmt_stb";
10
+ const table = "stmt_001";
11
+ const db = "ws_stmt1";
12
12
  const createDB = `create database if not exists ${db} keep 3650`;
13
13
  const useDB = `use ${db}`;
14
14
  const dropDB = `drop database if exists ${db}`;
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 = [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'];
20
- 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
+ ];
21
49
  const tableValues = [
22
50
  [1656677710000, 1656677720000, 1656677730000, 1656677740000, 1656677750000],
23
51
  [0, -1, -2, -3, -4],
@@ -30,15 +58,39 @@ const tableValues = [
30
58
  [2, 3, 4, 5, 6],
31
59
  // [0, 1, 2, 3, 4],
32
60
  [BigInt(3), BigInt(4), BigInt(5), BigInt(6), BigInt(7)],
33
- [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))],
34
- [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))],
35
- ['varchar_col_1', 'varchar_col_2', 'varchar_col_3', 'varchar_col_4', 'varchar_col_5'],
36
- ['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"],
37
83
  [true, false, true, false, true],
38
- [null, null, null, null, null]
84
+ [null, null, null, null, null],
39
85
  ];
40
86
  const tableCNValues = [
41
- [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
+ ],
42
94
  [0, -1, -2, -3, -4],
43
95
  [-1, -2, -3, -4, -5],
44
96
  [-2, -3, -4, -5, -6],
@@ -47,10 +99,28 @@ const tableCNValues = [
47
99
  [1, 2, 3, 4, 5],
48
100
  [2, 3, 4, 5, 6],
49
101
  [BigInt(3), BigInt(4), BigInt(5), BigInt(6), BigInt(7)],
50
- [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))],
51
- [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))],
52
- ['varchar_列_壹', 'varchar_列_贰', 'varchar_列_叁', 'varchar_列_肆', 'varchar_列_伍'],
53
- ['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_列_戊"],
54
124
  [true, false, true, false, true],
55
125
  [null, null, null, null, null],
56
126
  ];
@@ -58,21 +128,27 @@ let geoDataArray = [];
58
128
  let varbinary = [];
59
129
  const encoder = new TextEncoder();
60
130
  for (let i = 0; i < 5; i++) {
61
- let data = new Uint8Array([0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
62
- 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
+ ]);
63
135
  geoDataArray.push(data.buffer);
64
136
  let vdata = encoder.encode(`varchar_col_${i + 1}`);
65
137
  varbinary.push(vdata.buffer);
66
138
  }
67
- const jsonTags = ["{\"key1\":\"taos\",\"key2\":null,\"key3\":\"TDengine\",\"key4\":0,\"key5\":false}"];
68
- 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
+ ];
69
145
  const selectStable = `select * from ${stable}`;
70
146
  const selectStableCN = `select * from ${stableCN}`;
71
147
  const selectTable = `select * from ${table}`;
72
148
  const selectTableCN = `select * from ${tableCN}`;
73
149
  const selectJsonTable = `select * from ${jsonTable}`;
74
150
  const selectJsonTableCN = `select * from ${jsonTableCN}`;
75
- let dsn = 'ws://root:taosdata@localhost:6041';
151
+ let dsn = "ws://root:taosdata@localhost:6041";
76
152
  (0, log_1.setLevel)("debug");
77
153
  beforeAll(async () => {
78
154
  let conf = new config_1.WSConfig(dsn);
@@ -84,9 +160,9 @@ beforeAll(async () => {
84
160
  await ws.exec((0, utils_1.createSTableJSON)(jsonTable));
85
161
  await ws.close();
86
162
  });
87
- describe('TDWebSocket.Stmt()', () => {
163
+ describe("TDWebSocket.Stmt()", () => {
88
164
  jest.setTimeout(20 * 1000);
89
- test('normal BindParam', async () => {
165
+ test("normal BindParam", async () => {
90
166
  let wsConf = new config_1.WSConfig(dsn, "100.100.100.100");
91
167
  wsConf.setDb(db);
92
168
  let connector = await wsSql_1.WsSql.open(wsConf);
@@ -139,7 +215,7 @@ describe('TDWebSocket.Stmt()', () => {
139
215
  console.log(result);
140
216
  await connector.close();
141
217
  });
142
- test('normal CN BindParam', async () => {
218
+ test("normal CN BindParam", async () => {
143
219
  let wsConf = new config_1.WSConfig(dsn, "100.100.100.100");
144
220
  wsConf.setDb(db);
145
221
  let connector = await wsSql_1.WsSql.open(wsConf);
@@ -191,7 +267,7 @@ describe('TDWebSocket.Stmt()', () => {
191
267
  console.log(result);
192
268
  await connector.close();
193
269
  });
194
- test('normal json tag BindParam', async () => {
270
+ test("normal json tag BindParam", async () => {
195
271
  let wsConf = new config_1.WSConfig(dsn, "100.100.100.100");
196
272
  wsConf.setDb(db);
197
273
  let connector = await wsSql_1.WsSql.open(wsConf);
@@ -231,7 +307,7 @@ describe('TDWebSocket.Stmt()', () => {
231
307
  console.log(result);
232
308
  await connector.close();
233
309
  });
234
- test('normal json cn tag BindParam', async () => {
310
+ test("normal json cn tag BindParam", async () => {
235
311
  let wsConf = new config_1.WSConfig(dsn, "100.100.100.100");
236
312
  wsConf.setDb(db);
237
313
  let connector = await wsSql_1.WsSql.open(wsConf);
@@ -272,25 +348,25 @@ describe('TDWebSocket.Stmt()', () => {
272
348
  await connector.close();
273
349
  });
274
350
  });
275
- test('test bind exception cases', async () => {
351
+ test("test bind exception cases", async () => {
276
352
  let wsConf = new config_1.WSConfig(dsn, "100.100.100.100");
277
353
  let connector = await wsSql_1.WsSql.open(wsConf);
278
354
  let stmt = await connector.stmtInit();
279
355
  expect(stmt).toBeInstanceOf(wsStmt1_1.WsStmt1);
280
356
  const params = stmt.newStmtParam();
281
357
  const emptyArrayMethods = [
282
- { method: 'setBoolean', name: 'SetBooleanColumn' },
283
- { method: 'setTinyInt', name: 'SetTinyIntColumn' },
284
- { method: 'setUTinyInt', name: 'SetUTinyIntColumn' },
285
- { method: 'setSmallInt', name: 'SetSmallIntColumn' },
286
- { method: 'setUSmallInt', name: 'SetSmallIntColumn' },
287
- { method: 'setInt', name: 'SetIntColumn' },
288
- { method: 'setUInt', name: 'SetUIntColumn' },
289
- { method: 'setBigint', name: 'SetBigIntColumn' },
290
- { method: 'setUBigint', name: 'SetUBigIntColumn' },
291
- { method: 'setFloat', name: 'SetFloatColumn' },
292
- { method: 'setDouble', name: 'SetDoubleColumn' },
293
- { method: 'setTimestamp', name: 'SeTimestampColumn' }
358
+ { method: "setBoolean", name: "SetBooleanColumn" },
359
+ { method: "setTinyInt", name: "SetTinyIntColumn" },
360
+ { method: "setUTinyInt", name: "SetUTinyIntColumn" },
361
+ { method: "setSmallInt", name: "SetSmallIntColumn" },
362
+ { method: "setUSmallInt", name: "SetSmallIntColumn" },
363
+ { method: "setInt", name: "SetIntColumn" },
364
+ { method: "setUInt", name: "SetUIntColumn" },
365
+ { method: "setBigint", name: "SetBigIntColumn" },
366
+ { method: "setUBigint", name: "SetUBigIntColumn" },
367
+ { method: "setFloat", name: "SetFloatColumn" },
368
+ { method: "setDouble", name: "SetDoubleColumn" },
369
+ { method: "setTimestamp", name: "SeTimestampColumn" },
294
370
  ];
295
371
  emptyArrayMethods.forEach(({ method, name }) => {
296
372
  expect(() => {
@@ -304,14 +380,14 @@ test('test bind exception cases', async () => {
304
380
  }).toThrow(`${name} params is invalid!`);
305
381
  });
306
382
  expect(() => {
307
- params.setBoolean(['not boolean']);
308
- }).toThrow('SetTinyIntColumn params is invalid!');
383
+ params.setBoolean(["not boolean"]);
384
+ }).toThrow("SetTinyIntColumn params is invalid!");
309
385
  expect(() => {
310
- params.setTinyInt(['not number']);
311
- }).toThrow('SetTinyIntColumn params is invalid!');
386
+ params.setTinyInt(["not number"]);
387
+ }).toThrow("SetTinyIntColumn params is invalid!");
312
388
  expect(() => {
313
- params.setBigint(['not bigint']);
314
- }).toThrow('SetTinyIntColumn params is invalid!');
389
+ params.setBigint(["not bigint"]);
390
+ }).toThrow("SetTinyIntColumn params is invalid!");
315
391
  await connector.close();
316
392
  });
317
393
  afterAll(async () => {