@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
@@ -8,8 +8,8 @@ const constant_1 = require("../../src/tmq/constant");
8
8
  const wsTmq_1 = require("../../src/tmq/wsTmq");
9
9
  const utils_1 = require("../utils");
10
10
  const log_1 = require("../../src/common/log");
11
- let dsn = 'ws://root:taosdata@localhost:6041';
12
- let tags = ['California.SanFrancisco', 3];
11
+ let dsn = "ws://root:taosdata@localhost:6041";
12
+ let tags = ["California.SanFrancisco", 3];
13
13
  let multi = [
14
14
  [1709183268567, 1709183268568, 1709183268569],
15
15
  [10.2, 10.3, 10.4],
@@ -21,19 +21,19 @@ let configMap = new Map([
21
21
  [constant_1.TMQConstants.CONNECT_USER, "root"],
22
22
  [constant_1.TMQConstants.CONNECT_PASS, "taosdata"],
23
23
  [constant_1.TMQConstants.AUTO_OFFSET_RESET, "earliest"],
24
- [constant_1.TMQConstants.CLIENT_ID, 'test_tmq_client'],
25
- [constant_1.TMQConstants.WS_URL, 'ws://localhost:6041'],
26
- [constant_1.TMQConstants.ENABLE_AUTO_COMMIT, 'true'],
27
- [constant_1.TMQConstants.AUTO_COMMIT_INTERVAL_MS, '1000']
24
+ [constant_1.TMQConstants.CLIENT_ID, "test_tmq_client"],
25
+ [constant_1.TMQConstants.WS_URL, "ws://localhost:6041"],
26
+ [constant_1.TMQConstants.ENABLE_AUTO_COMMIT, "true"],
27
+ [constant_1.TMQConstants.AUTO_COMMIT_INTERVAL_MS, "1000"],
28
28
  ]);
29
- const stable = 'meters';
30
- const db = 'power_connect';
31
- const topics = ['pwer_meters_topic'];
29
+ const stable = "meters";
30
+ const db = "power_connect";
31
+ const topics = ["pwer_meters_topic"];
32
32
  let createTopic = `create topic if not exists ${topics[0]} as select * from ${db}.${stable}`;
33
33
  let stmtIds = [];
34
34
  (0, log_1.setLevel)("debug");
35
35
  async function connect() {
36
- let dsn = 'ws://root:taosdata@localhost:6041';
36
+ let dsn = "ws://root:taosdata@localhost:6041";
37
37
  let wsSql = null;
38
38
  let conf = new config_1.WSConfig(dsn);
39
39
  conf.setDb(db);
@@ -43,20 +43,20 @@ async function connect() {
43
43
  await wsSql.close();
44
44
  }
45
45
  async function stmtConnect() {
46
- let dsn = 'ws://root:taosdata@localhost:6041';
47
- let wsConf = new config_1.WSConfig(dsn);
46
+ let dsn = "ws://root:taosdata@localhost:6041";
47
+ let wsConf = new config_1.WSConfig(dsn, "100.100.100.100");
48
48
  wsConf.setDb(db);
49
- // let connector = WsStmtConnect.NewConnector(wsConf)
49
+ // let connector = WsStmtConnect.NewConnector(wsConf)
50
50
  // let stmt = await connector.Init()
51
51
  let connector = await wsSql_1.WsSql.open(wsConf);
52
- let stmt = await connector.stmtInit();
52
+ let stmt = (await connector.stmtInit());
53
53
  let id = stmt.getStmtId();
54
54
  if (id) {
55
55
  stmtIds.push(id);
56
56
  }
57
57
  expect(stmt).toBeTruthy();
58
58
  await stmt.prepare(`INSERT INTO ? USING ${stable} (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)`);
59
- await stmt.setTableName('d1001');
59
+ await stmt.setTableName("d1001");
60
60
  await stmt.setJsonTags(tags);
61
61
  let lastTs = 0;
62
62
  const allp = [];
@@ -117,16 +117,16 @@ beforeAll(async () => {
117
117
  await ws.exec(createTopic, reqid_1.ReqId.getReqID());
118
118
  await ws.close();
119
119
  });
120
- describe('TDWebSocket.WsSql()', () => {
120
+ describe("TDWebSocket.WsSql()", () => {
121
121
  jest.setTimeout(60 * 1000);
122
- test('ReqId', async () => {
122
+ test("ReqId", async () => {
123
123
  const allp = [];
124
124
  for (let i = 0; i < 10; i++) {
125
125
  allp.push(console.log(reqid_1.ReqId.getReqID()));
126
126
  }
127
127
  await Promise.all(allp);
128
128
  });
129
- test('normal connect', async () => {
129
+ test("normal connect", async () => {
130
130
  const allp = [];
131
131
  for (let i = 0; i < 20; i++) {
132
132
  allp.push(connect());
@@ -139,8 +139,8 @@ describe('TDWebSocket.WsSql()', () => {
139
139
  });
140
140
  afterAll(async () => {
141
141
  let conf = new config_1.WSConfig(dsn);
142
- conf.setUser('root');
143
- conf.setPwd('taosdata');
142
+ conf.setUser("root");
143
+ conf.setPwd("taosdata");
144
144
  let wsSql = await wsSql_1.WsSql.open(conf);
145
145
  await wsSql.exec(`drop topic if exists ${topics[0]};`);
146
146
  await wsSql.exec(`drop database if exists ${db};`);
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../test/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIxD,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAapG;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,MAAgB,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AAG,EAAE,MAAM,GAAG,WAAW,CAQnD;AAoBD,wBAAgB,kBAAkB,CAC9B,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,UAAU,GACjB,OAAO,CAYT;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C"}
package/lib/test/utils.js CHANGED
@@ -21,22 +21,23 @@ const log_1 = __importDefault(require("../src/common/log"));
21
21
  function getInsertBind(valuesLen, tagsLen, db, stable) {
22
22
  let sql = `insert into ? using ${db}.${stable} tags ( ?`;
23
23
  for (let i = 1; i < tagsLen; i++) {
24
- sql += ', ?';
24
+ sql += ", ?";
25
25
  }
26
- sql += ') values( ?';
26
+ sql += ") values( ?";
27
27
  for (let i = 1; i < valuesLen; i++) {
28
- sql += ', ?';
28
+ sql += ", ?";
29
29
  }
30
- sql += ')';
30
+ sql += ")";
31
+ log_1.default.debug(`Insert bind sql: ${sql}`);
31
32
  return sql;
32
33
  }
33
- function insertStable(values, tags, stable, table = 'empty') {
34
- let childTable = table == 'empty' ? stable + '_s_01' : table;
34
+ function insertStable(values, tags, stable, table = "empty") {
35
+ let childTable = table == "empty" ? stable + "_s_01" : table;
35
36
  let sql = `insert into ${childTable} using ${stable} tags (`;
36
37
  tags.forEach((tag) => {
37
- if ((typeof tag) == 'string') {
38
- if (tag == 'NULL') {
39
- sql += tag + ',';
38
+ if (typeof tag == "string") {
39
+ if (tag == "NULL") {
40
+ sql += tag + ",";
40
41
  }
41
42
  else {
42
43
  sql += `\'${tag}\',`;
@@ -44,36 +45,36 @@ function insertStable(values, tags, stable, table = 'empty') {
44
45
  }
45
46
  else {
46
47
  sql += tag;
47
- sql += ',';
48
+ sql += ",";
48
49
  }
49
50
  });
50
51
  sql = sql.slice(0, sql.length - 1);
51
- sql += ')';
52
- sql += 'values';
53
- values.forEach(value => {
54
- sql += '(';
55
- value.forEach(v => {
56
- if ((typeof v) == 'string') {
52
+ sql += ")";
53
+ sql += "values";
54
+ values.forEach((value) => {
55
+ sql += "(";
56
+ value.forEach((v) => {
57
+ if (typeof v == "string") {
57
58
  sql += `\'${v}\',`;
58
59
  }
59
60
  else {
60
61
  sql += v;
61
- sql += ',';
62
+ sql += ",";
62
63
  }
63
64
  });
64
65
  sql = sql.slice(0, sql.length - 1);
65
- sql += ')';
66
+ sql += ")";
66
67
  });
67
68
  return sql;
68
69
  }
69
70
  function insertNTable(values, table) {
70
71
  let sql = `insert into ${table} values `;
71
- values.forEach(value => {
72
- sql += '(';
73
- value.forEach(v => {
74
- if ((typeof v) == 'string') {
75
- if (v == 'NULL') {
76
- sql += v + ',';
72
+ values.forEach((value) => {
73
+ sql += "(";
74
+ value.forEach((v) => {
75
+ if (typeof v == "string") {
76
+ if (v == "NULL") {
77
+ sql += v + ",";
77
78
  }
78
79
  else {
79
80
  sql += `\'${v}\',`;
@@ -81,193 +82,193 @@ function insertNTable(values, table) {
81
82
  }
82
83
  else {
83
84
  sql += v;
84
- sql += ',';
85
+ sql += ",";
85
86
  }
86
87
  });
87
88
  sql = sql.slice(0, sql.length - 1);
88
- sql += ')';
89
+ sql += ")";
89
90
  });
90
91
  return sql;
91
92
  }
92
93
  exports.tableMeta = [
93
94
  {
94
- name: 'ts',
95
- type: 'TIMESTAMP',
96
- length: 8
95
+ name: "ts",
96
+ type: "TIMESTAMP",
97
+ length: 8,
97
98
  },
98
99
  {
99
- name: 'i1',
100
- type: 'TINYINT',
101
- length: 1
100
+ name: "i1",
101
+ type: "TINYINT",
102
+ length: 1,
102
103
  },
103
104
  {
104
- name: 'i2',
105
- type: 'SMALLINT',
106
- length: 2
105
+ name: "i2",
106
+ type: "SMALLINT",
107
+ length: 2,
107
108
  },
108
109
  {
109
- name: 'i4',
110
- type: 'INT',
111
- length: 4
110
+ name: "i4",
111
+ type: "INT",
112
+ length: 4,
112
113
  },
113
114
  {
114
- name: 'i8',
115
- type: 'BIGINT',
116
- length: 8
115
+ name: "i8",
116
+ type: "BIGINT",
117
+ length: 8,
117
118
  },
118
119
  {
119
- name: 'u1',
120
- type: 'TINYINT UNSIGNED',
121
- length: 1
120
+ name: "u1",
121
+ type: "TINYINT UNSIGNED",
122
+ length: 1,
122
123
  },
123
124
  {
124
- name: 'u2',
125
- type: 'SMALLINT UNSIGNED',
126
- length: 2
125
+ name: "u2",
126
+ type: "SMALLINT UNSIGNED",
127
+ length: 2,
127
128
  },
128
129
  {
129
- name: 'u4',
130
- type: 'INT UNSIGNED',
131
- length: 4
130
+ name: "u4",
131
+ type: "INT UNSIGNED",
132
+ length: 4,
132
133
  },
133
134
  {
134
- name: 'u8',
135
- type: 'BIGINT UNSIGNED',
136
- length: 8
135
+ name: "u8",
136
+ type: "BIGINT UNSIGNED",
137
+ length: 8,
137
138
  },
138
139
  {
139
- name: 'f4',
140
- type: 'FLOAT',
141
- length: 4
140
+ name: "f4",
141
+ type: "FLOAT",
142
+ length: 4,
142
143
  },
143
144
  {
144
- name: 'd8',
145
- type: 'DOUBLE',
146
- length: 8
145
+ name: "d8",
146
+ type: "DOUBLE",
147
+ length: 8,
147
148
  },
148
149
  {
149
- name: 'bnr',
150
- type: 'VARCHAR',
151
- length: 200
150
+ name: "bnr",
151
+ type: "VARCHAR",
152
+ length: 200,
152
153
  },
153
154
  {
154
- name: 'nchr',
155
- type: 'NCHAR',
156
- length: 200
155
+ name: "nchr",
156
+ type: "NCHAR",
157
+ length: 200,
157
158
  },
158
159
  {
159
- name: 'b',
160
- type: 'BOOL',
161
- length: 1
160
+ name: "b",
161
+ type: "BOOL",
162
+ length: 1,
162
163
  },
163
164
  {
164
- name: 'nilcol',
165
- type: 'INT',
166
- length: 4
165
+ name: "nilcol",
166
+ type: "INT",
167
+ length: 4,
167
168
  },
168
169
  {
169
- name: 'geo',
170
- type: 'GEOMETRY',
171
- length: 512
170
+ name: "geo",
171
+ type: "GEOMETRY",
172
+ length: 512,
172
173
  },
173
174
  {
174
- name: 'vbinary',
175
- type: 'VARBINARY',
176
- length: 32
175
+ name: "vbinary",
176
+ type: "VARBINARY",
177
+ length: 32,
177
178
  },
178
179
  ];
179
180
  exports.jsonMeta = [
180
181
  {
181
- name: 'json_tag',
182
- type: 'JSON',
183
- length: 4095
182
+ name: "json_tag",
183
+ type: "JSON",
184
+ length: 4095,
184
185
  },
185
186
  ];
186
187
  exports.tagMeta = [
187
188
  {
188
- name: 'tb',
189
- type: 'BOOL',
190
- length: 1
189
+ name: "tb",
190
+ type: "BOOL",
191
+ length: 1,
191
192
  },
192
193
  {
193
- name: 'ti1',
194
- type: 'TINYINT',
195
- length: 1
194
+ name: "ti1",
195
+ type: "TINYINT",
196
+ length: 1,
196
197
  },
197
198
  {
198
- name: 'ti2',
199
- type: 'SMALLINT',
200
- length: 2
199
+ name: "ti2",
200
+ type: "SMALLINT",
201
+ length: 2,
201
202
  },
202
203
  {
203
- name: 'ti4',
204
- type: 'INT',
205
- length: 4
204
+ name: "ti4",
205
+ type: "INT",
206
+ length: 4,
206
207
  },
207
208
  {
208
- name: 'ti8',
209
- type: 'BIGINT',
210
- length: 8
209
+ name: "ti8",
210
+ type: "BIGINT",
211
+ length: 8,
211
212
  },
212
213
  {
213
- name: 'tu1',
214
- type: 'TINYINT UNSIGNED',
215
- length: 1
214
+ name: "tu1",
215
+ type: "TINYINT UNSIGNED",
216
+ length: 1,
216
217
  },
217
218
  {
218
- name: 'tu2',
219
- type: 'SMALLINT UNSIGNED',
220
- length: 2
219
+ name: "tu2",
220
+ type: "SMALLINT UNSIGNED",
221
+ length: 2,
221
222
  },
222
223
  {
223
- name: 'tu4',
224
- type: 'INT UNSIGNED',
225
- length: 4
224
+ name: "tu4",
225
+ type: "INT UNSIGNED",
226
+ length: 4,
226
227
  },
227
228
  {
228
- name: 'tu8',
229
- type: 'BIGINT UNSIGNED',
230
- length: 8
229
+ name: "tu8",
230
+ type: "BIGINT UNSIGNED",
231
+ length: 8,
231
232
  },
232
233
  {
233
- name: 'tf4',
234
- type: 'FLOAT',
235
- length: 4
234
+ name: "tf4",
235
+ type: "FLOAT",
236
+ length: 4,
236
237
  },
237
238
  {
238
- name: 'td8',
239
- type: 'DOUBLE',
240
- length: 8
239
+ name: "td8",
240
+ type: "DOUBLE",
241
+ length: 8,
241
242
  },
242
243
  {
243
- name: 'tbnr',
244
- type: 'VARCHAR',
245
- length: 200
244
+ name: "tbnr",
245
+ type: "VARCHAR",
246
+ length: 200,
246
247
  },
247
248
  {
248
- name: 'tnchr',
249
- type: 'NCHAR',
250
- length: 200
249
+ name: "tnchr",
250
+ type: "NCHAR",
251
+ length: 200,
251
252
  },
252
253
  ];
253
254
  function createBaseSTable(stable) {
254
- return `create table if not exists ${stable}( ts timestamp,i1 tinyint,i2 smallint,i4 int,i8 bigint,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,f4 float,d8 double,bnr binary(200),nchr nchar(200),b bool,nilcol int, g1 geometry(512), c4 varbinary(100))` +
255
- 'tags( tb bool,ti1 tinyint,ti2 smallint,ti4 int,ti8 bigint,tu1 tinyint unsigned,tu2 smallint unsigned,tu4 int unsigned,tu8 bigint unsigned,tf4 float,td8 double,tbnr binary(200),tnchr nchar(200));';
255
+ return (`create table if not exists ${stable}( ts timestamp,i1 tinyint,i2 smallint,i4 int,i8 bigint,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,f4 float,d8 double,bnr binary(200),nchr nchar(200),b bool,nilcol int, g1 geometry(512), c4 varbinary(100))` +
256
+ "tags( tb bool,ti1 tinyint,ti2 smallint,ti4 int,ti8 bigint,tu1 tinyint unsigned,tu2 smallint unsigned,tu4 int unsigned,tu8 bigint unsigned,tf4 float,td8 double,tbnr binary(200),tnchr nchar(200));");
256
257
  }
257
258
  function createBaseSTableJSON(stable) {
258
- return `create table if not exists ${stable}(ts timestamp,i1 tinyint,i2 smallint,i4 int,i8 bigint,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,f4 float,d8 double,bnr binary(200),nchr nchar(200),b bool,nilcol int)` +
259
- 'tags(json_tag json);';
259
+ return (`create table if not exists ${stable}(ts timestamp,i1 tinyint,i2 smallint,i4 int,i8 bigint,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,f4 float,d8 double,bnr binary(200),nchr nchar(200),b bool,nilcol int)` +
260
+ "tags(json_tag json);");
260
261
  }
261
262
  function createBaseTable(table) {
262
263
  return `create table if not exists ${table}(ts timestamp,i1 tinyint,i2 smallint,i4 int,i8 bigint,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,f4 float,d8 double,bnr binary(200),nchr nchar(200),b bool,nilcol int)`;
263
264
  }
264
265
  function createSTable(stable) {
265
- return `create table if not exists ${stable}( ts timestamp,i1 tinyint,i2 smallint,i4 int,i8 bigint,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,f4 float,d8 double,bnr binary(200),nchr nchar(200),b bool,nilcol int, geo geometry(512), vbinary varbinary(32))` +
266
- 'tags( tb bool,ti1 tinyint,ti2 smallint,ti4 int,ti8 bigint,tu1 tinyint unsigned,tu2 smallint unsigned,tu4 int unsigned,tu8 bigint unsigned,tf4 float,td8 double,tbnr binary(200),tnchr nchar(200));';
266
+ return (`create table if not exists ${stable}( ts timestamp,i1 tinyint,i2 smallint,i4 int,i8 bigint,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,f4 float,d8 double,bnr binary(200),nchr nchar(200),b bool,nilcol int, geo geometry(512), vbinary varbinary(32))` +
267
+ "tags( tb bool,ti1 tinyint,ti2 smallint,ti4 int,ti8 bigint,tu1 tinyint unsigned,tu2 smallint unsigned,tu4 int unsigned,tu8 bigint unsigned,tf4 float,td8 double,tbnr binary(200),tnchr nchar(200));");
267
268
  }
268
269
  function createSTableJSON(stable) {
269
- return `create table if not exists ${stable}(ts timestamp,i1 tinyint,i2 smallint,i4 int,i8 bigint,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,f4 float,d8 double,bnr binary(200),nchr nchar(200),b bool,nilcol int, geo geometry(512), vbinary varbinary(32))` +
270
- 'tags(json_tag json);';
270
+ return (`create table if not exists ${stable}(ts timestamp,i1 tinyint,i2 smallint,i4 int,i8 bigint,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,f4 float,d8 double,bnr binary(200),nchr nchar(200),b bool,nilcol int, geo geometry(512), vbinary varbinary(32))` +
271
+ "tags(json_tag json);");
271
272
  }
272
273
  function createTable(table) {
273
274
  return `create table if not exists ${table}(ts timestamp,i1 tinyint,i2 smallint,i4 int,i8 bigint,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,f4 float,d8 double,bnr binary(200),nchr nchar(200),b bool,nilcol int, geo geometry(512), vbinary varbinary(32))`;
@@ -288,7 +289,7 @@ function hexToBytes(hex) {
288
289
  }
289
290
  return a.buffer;
290
291
  }
291
- // export function createStmtData(varbinary:string = "ab",
292
+ // export function createStmtData(varbinary:string = "ab",
292
293
  // geoHex:string = "0101000020E6100000000000000000F03F0000000000000040"):Array<Array<any>> {
293
294
  // let multi:any[][] = [
294
295
  // [1709183268567, 1709183268568, 1709183268569],
@@ -318,5 +319,5 @@ function compareUint8Arrays(arr1, arr2) {
318
319
  return true;
319
320
  }
320
321
  function Sleep(ms) {
321
- return new Promise(resolve => setTimeout(resolve, ms));
322
+ return new Promise((resolve) => setTimeout(resolve, ms));
322
323
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tdengine/websocket",
3
- "version": "3.1.9",
3
+ "version": "3.2.1",
4
4
  "description": "The websocket Node.js connector for TDengine. TDengine versions 3.3.2.0 and above are recommended to use this connector.",
5
5
  "source": "index.ts",
6
6
  "main": "lib/index.js",
package/readme.md CHANGED
@@ -14,6 +14,7 @@
14
14
  [![StackOverflow](https://img.shields.io/badge/Ask_StackOverflow--white?logo=stackoverflow&style=social&logoColor=orange)](https://stackoverflow.com/questions/tagged/tdengine)
15
15
 
16
16
  English | [简体中文](README-CN.md)
17
+
17
18
  <!-- omit in toc -->
18
19
  ## Table of Contents
19
20
  <!-- omit in toc -->
@@ -1,41 +0,0 @@
1
- export declare class ColumnInfo {
2
- data: ArrayBuffer;
3
- length: number;
4
- type: number;
5
- typeLen: number;
6
- constructor([length, data]: [number, ArrayBuffer], type: number, typeLen: number);
7
- }
8
- export declare class StmtBindParams {
9
- private readonly precisionLength;
10
- private readonly _params;
11
- private _dataTotalLen;
12
- private _rows;
13
- constructor(precision?: number);
14
- getDataRows(): number;
15
- getDataTotalLen(): number;
16
- getParams(): ColumnInfo[];
17
- setBoolean(params: any[]): void;
18
- setTinyInt(params: any[]): void;
19
- setUTinyInt(params: any[]): void;
20
- setSmallInt(params: any[]): void;
21
- setUSmallInt(params: any[]): void;
22
- setInt(params: any[]): void;
23
- setUInt(params: any[]): void;
24
- setBigint(params: any[]): void;
25
- setUBigint(params: any[]): void;
26
- setFloat(params: any[]): void;
27
- setDouble(params: any[]): void;
28
- setVarchar(params: any[]): void;
29
- setBinary(params: any[]): void;
30
- setNchar(params: any[]): void;
31
- setJson(params: any[]): void;
32
- setVarBinary(params: any[]): void;
33
- setGeometry(params: any[]): void;
34
- setTimestamp(params: any[]): void;
35
- private encodeDigitColumns;
36
- private encodeVarLengthColumn;
37
- private getBinaryColumnArrayBuffer;
38
- private encodeNcharColumn;
39
- private countBigintDigits;
40
- }
41
- //# sourceMappingURL=wsParams.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wsParams.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsParams.ts"],"names":[],"mappings":"AAKA,qBAAa,UAAU;IACnB,IAAI,EAAC,WAAW,CAAC;IACjB,MAAM,EAAC,MAAM,CAAC;IACd,IAAI,EAAC,MAAM,CAAC;IACZ,OAAO,EAAC,MAAM,CAAC;gBACH,CAAC,MAAM,EAAC,IAAI,CAAC,EAAC,CAAC,MAAM,EAAE,WAAW,CAAC,EA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