@tdengine/websocket 3.1.3 → 3.1.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"wsClient.d.ts","sourceRoot":"","sources":["../../../src/client/wsClient.ts"],"names":[],"mappings":"AAIA,OAAO,EAEH,eAAe,EAClB,MAAM,cAAc,CAAC;AAKtB,qBAAa,QAAQ;IACjB,OAAO,CAAC,YAAY,CAAC,CAAqB;IAC1C,OAAO,CAAC,QAAQ,CAAC,CAA2B;IAC5C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAK;gBAEd,GAAG,EAAE,GAAG,EAAE,OAAQ,CAAC,EAAC,MAAM,GAAG,SAAS,GAAG,IAAI;IAOnD,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAqC5D,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3C,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAC,OAAc,GAAG,OAAO,CAAC,GAAG,CAAC;IAuB9D,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,GAAC,OAAc,EAAE,aAAa,GAAE,OAAe,GAAG,OAAO,CAAC,GAAG,CAAC;IA0B/I,QAAQ;IAQF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAetB,OAAO,CAAC,GAAG,EAAC,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAajC,UAAU,CAAC,GAAG,EAAE,eAAe;IAqB/B,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IA4B1B,KAAK,IAAG,OAAO,CAAC,IAAI,CAAC;IAS3B,QAAQ,CAAC,GAAG,EAAE,GAAG;CASpB"}
1
+ {"version":3,"file":"wsClient.d.ts","sourceRoot":"","sources":["../../../src/client/wsClient.ts"],"names":[],"mappings":"AAIA,OAAO,EAEH,eAAe,EAClB,MAAM,cAAc,CAAC;AAMtB,qBAAa,QAAQ;IACjB,OAAO,CAAC,YAAY,CAAC,CAAqB;IAC1C,OAAO,CAAC,QAAQ,CAAC,CAA2B;IAC5C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAK;gBAEd,GAAG,EAAE,GAAG,EAAE,OAAQ,CAAC,EAAC,MAAM,GAAG,SAAS,GAAG,IAAI;IAOnD,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAqC5D,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3C,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAC,OAAc,GAAG,OAAO,CAAC,GAAG,CAAC;IAuB9D,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,GAAC,OAAc,EAAE,aAAa,GAAE,OAAe,GAAG,OAAO,CAAC,GAAG,CAAC;IA0B/I,QAAQ;IAQF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAetB,OAAO,CAAC,GAAG,EAAC,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAajC,UAAU,CAAC,GAAG,EAAE,eAAe;IAqB/B,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IA4B1B,KAAK,IAAG,OAAO,CAAC,IAAI,CAAC;IAS3B,QAAQ,CAAC,GAAG,EAAE,GAAG;CASpB"}
@@ -10,6 +10,7 @@ const wsError_1 = require("../common/wsError");
10
10
  const wsResponse_1 = require("./wsResponse");
11
11
  const reqid_1 = require("../common/reqid");
12
12
  const log_1 = __importDefault(require("../common/log"));
13
+ const utils_1 = require("../common/utils");
13
14
  class WsClient {
14
15
  constructor(url, timeout) {
15
16
  this.checkURL(url);
@@ -25,8 +26,8 @@ class WsClient {
25
26
  action: 'conn',
26
27
  args: {
27
28
  req_id: reqid_1.ReqId.getReqID(),
28
- user: this._url.username,
29
- password: this._url.password,
29
+ user: (0, utils_1.safeDecodeURIComponent)(this._url.username),
30
+ password: (0, utils_1.safeDecodeURIComponent)(this._url.password),
30
31
  db: _db,
31
32
  },
32
33
  };
@@ -1 +1 @@
1
- {"version":3,"file":"wsConnectorPool.d.ts","sourceRoot":"","sources":["../../../src/client/wsConnectorPool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAKnD,qBAAa,uBAAuB;IAChC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAyB;IAClD,OAAO,CAAC,IAAI,CAAgD;IAC5D,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO;WAKO,QAAQ,CAAC,cAAc,GAAE,MAAW,GAAE,uBAAuB;IAOrE,aAAa,CAAC,GAAG,EAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA6BvF,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,GAAE,OAAO,CAAC,IAAI,CAAC;IA0BpE,SAAS;CAYZ"}
1
+ {"version":3,"file":"wsConnectorPool.d.ts","sourceRoot":"","sources":["../../../src/client/wsConnectorPool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAKnD,qBAAa,uBAAuB;IAChC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAyB;IAClD,OAAO,CAAC,IAAI,CAAgD;IAC5D,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO;WAKO,QAAQ,CAAC,cAAc,GAAE,MAAW,GAAE,uBAAuB;IAOrE,aAAa,CAAC,GAAG,EAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA8BvF,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,GAAE,OAAO,CAAC,IAAI,CAAC;IA0BpE,SAAS;CAYZ"}
@@ -23,6 +23,7 @@ class WebSocketConnectionPool {
23
23
  }
24
24
  async getConnection(url, timeout) {
25
25
  let connectAddr = url.origin.concat(url.pathname).concat(url.search);
26
+ log_1.default.info("url:" + url);
26
27
  let connector;
27
28
  const unlock = await mutex.acquire();
28
29
  try {
@@ -35,7 +36,7 @@ class WebSocketConnectionPool {
35
36
  }
36
37
  }
37
38
  if (connector) {
38
- log_1.default.debug("get connection success:", this._connectionCount);
39
+ log_1.default.debug("get connection success:" + this._connectionCount);
39
40
  return connector;
40
41
  }
41
42
  if (this._maxConnections != -1 && this._connectionCount > this._maxConnections) {
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.setLevel = void 0;
6
+ exports.setLevel = setLevel;
7
7
  const winston_1 = __importDefault(require("winston"));
8
8
  const winston_daily_rotate_file_1 = __importDefault(require("winston-daily-rotate-file"));
9
9
  const customFormat = winston_1.default.format.printf(({ level, message, label, timestamp }) => {
@@ -30,5 +30,4 @@ const logger = winston_1.default.createLogger({
30
30
  function setLevel(level) {
31
31
  transport.level = level;
32
32
  }
33
- exports.setLevel = setLevel;
34
33
  exports.default = logger;
@@ -3,7 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.bitmapLen = exports.setBitmapNull = exports.getCharOffset = exports.getString = exports.readNchar = exports.readVarchar = exports.readBinary = exports.readSolidData = exports.readSolidDataToArray = exports._isVarType = exports.parseBlock = exports.TaosResult = void 0;
6
+ exports.TaosResult = void 0;
7
+ exports.parseBlock = parseBlock;
8
+ exports._isVarType = _isVarType;
9
+ exports.readSolidDataToArray = readSolidDataToArray;
10
+ exports.readSolidData = readSolidData;
11
+ exports.readBinary = readBinary;
12
+ exports.readVarchar = readVarchar;
13
+ exports.readNchar = readNchar;
14
+ exports.getString = getString;
15
+ exports.getCharOffset = getCharOffset;
16
+ exports.setBitmapNull = setBitmapNull;
17
+ exports.bitmapLen = bitmapLen;
7
18
  const constant_1 = require("./constant");
8
19
  const wsError_1 = require("./wsError");
9
20
  const ut8Helper_1 = require("./ut8Helper");
@@ -199,7 +210,6 @@ function parseBlock(blocks, taosResult) {
199
210
  throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_FETCH_MESSAGE_DATA, "cannot fetch block for an update query.");
200
211
  }
201
212
  }
202
- exports.parseBlock = parseBlock;
203
213
  function _isVarType(metaType) {
204
214
  switch (metaType) {
205
215
  case constant_1.TDengineTypeCode.NCHAR: {
@@ -225,7 +235,6 @@ function _isVarType(metaType) {
225
235
  }
226
236
  }
227
237
  }
228
- exports._isVarType = _isVarType;
229
238
  function readSolidDataToArray(dataBuffer, colBlockHead, rows, metaType, bitMapArr) {
230
239
  let result = [];
231
240
  switch (metaType) {
@@ -347,7 +356,6 @@ function readSolidDataToArray(dataBuffer, colBlockHead, rows, metaType, bitMapAr
347
356
  }
348
357
  return result;
349
358
  }
350
- exports.readSolidDataToArray = readSolidDataToArray;
351
359
  function readSolidData(dataBuffer, colDataHead, meta) {
352
360
  switch (meta.type) {
353
361
  case constant_1.TDengineTypeCode.BOOL: {
@@ -392,18 +400,15 @@ function readSolidData(dataBuffer, colDataHead, meta) {
392
400
  }
393
401
  }
394
402
  }
395
- exports.readSolidData = readSolidData;
396
403
  function readBinary(dataBuffer, colDataHead, length) {
397
404
  let buff = dataBuffer.slice(colDataHead, colDataHead + length);
398
405
  return buff;
399
406
  }
400
- exports.readBinary = readBinary;
401
407
  function readVarchar(dataBuffer, colDataHead, length, textDecoder) {
402
408
  // let buff = dataBuffer.slice(colDataHead, colDataHead + length)
403
409
  let dataView = new DataView(dataBuffer, colDataHead, length);
404
410
  return textDecoder.decode(dataView);
405
411
  }
406
- exports.readVarchar = readVarchar;
407
412
  function readNchar(dataBuffer, colDataHead, length) {
408
413
  let data = [];
409
414
  // let buff: ArrayBuffer = dataBuffer.slice(colDataHead, colDataHead + length);
@@ -413,13 +418,11 @@ function readNchar(dataBuffer, colDataHead, length) {
413
418
  }
414
419
  return data.join('');
415
420
  }
416
- exports.readNchar = readNchar;
417
421
  function getString(dataBuffer, colDataHead, length, textDecoder) {
418
422
  // let buff = dataBuffer.slice(colDataHead, colDataHead + length - 1)
419
423
  let dataView = new Uint8Array(dataBuffer.buffer, dataBuffer.byteOffset + colDataHead, length - 1);
420
424
  return textDecoder.decode(dataView);
421
425
  }
422
- exports.getString = getString;
423
426
  function iteratorBuff(arr) {
424
427
  let buf = Buffer.from(arr);
425
428
  for (const value of buf) {
@@ -435,15 +438,12 @@ function isNull(bitMapArr, n) {
435
438
  function getCharOffset(n) {
436
439
  return n >> 3;
437
440
  }
438
- exports.getCharOffset = getCharOffset;
439
441
  function setBitmapNull(c, n) {
440
442
  return c + (1 << (7 - bitPos(n)));
441
443
  }
442
- exports.setBitmapNull = setBitmapNull;
443
444
  function bitPos(n) {
444
445
  return n & ((1 << 3) - 1);
445
446
  }
446
447
  function bitmapLen(n) {
447
448
  return ((n) + ((1 << 3) - 1)) >> 3;
448
449
  }
449
- exports.bitmapLen = bitmapLen;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.appendRune = void 0;
3
+ exports.appendRune = appendRune;
4
4
  // Numbers fundamental to the encoding.
5
5
  // the "error" Rune or "Unicode replacement character"
6
6
  const RuneError = '\uFFFD';
@@ -40,4 +40,3 @@ function appendRune(r) {
40
40
  }
41
41
  return Buffer.from(p).toString();
42
42
  }
43
- exports.appendRune = appendRune;
@@ -1,7 +1,7 @@
1
1
  import { WSConfig } from "./config";
2
2
  export declare function getUrl(wsConfig: WSConfig): URL;
3
- export declare function sleep(ms: number): Promise<void>;
4
3
  export declare function isEmpty(value: any): boolean;
5
4
  export declare function getBinarySql(action: bigint, reqId: bigint, resultId: bigint, sql?: string): ArrayBuffer;
6
5
  export declare function zigzagDecode(n: number): number;
6
+ export declare function safeDecodeURIComponent(str: string): string;
7
7
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/common/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,wBAAgB,MAAM,CAAC,QAAQ,EAAC,QAAQ,GAAE,GAAG,CAe5C;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAGD,wBAAgB,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAM3C;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,EAAE,GAAG,CAAC,EAAC,MAAM,GAAG,WAAW,CA6BnG;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE9C"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/common/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,wBAAgB,MAAM,CAAC,QAAQ,EAAC,QAAQ,GAAE,GAAG,CAe5C;AAGD,wBAAgB,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAM3C;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,EAAE,GAAG,CAAC,EAAC,MAAM,GAAG,WAAW,CA6BnG;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,UAQjD"}
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.zigzagDecode = exports.getBinarySql = exports.isEmpty = exports.sleep = exports.getUrl = void 0;
3
+ exports.getUrl = getUrl;
4
+ exports.isEmpty = isEmpty;
5
+ exports.getBinarySql = getBinarySql;
6
+ exports.zigzagDecode = zigzagDecode;
7
+ exports.safeDecodeURIComponent = safeDecodeURIComponent;
8
+ const wsError_1 = require("./wsError");
4
9
  function getUrl(wsConfig) {
5
10
  let url = new URL(wsConfig.getUrl());
6
11
  if (wsConfig.getUser()) {
@@ -16,11 +21,6 @@ function getUrl(wsConfig) {
16
21
  url.pathname = '/ws';
17
22
  return url;
18
23
  }
19
- exports.getUrl = getUrl;
20
- function sleep(ms) {
21
- return new Promise(resolve => setTimeout(resolve, ms));
22
- }
23
- exports.sleep = sleep;
24
24
  function isEmpty(value) {
25
25
  if (value === null || value === undefined)
26
26
  return true;
@@ -30,7 +30,6 @@ function isEmpty(value) {
30
30
  // if (typeof value === 'object' && Object.keys(value).length === 0) return true;
31
31
  return false;
32
32
  }
33
- exports.isEmpty = isEmpty;
34
33
  function getBinarySql(action, reqId, resultId, sql) {
35
34
  // construct msg
36
35
  if (sql) {
@@ -59,8 +58,16 @@ function getBinarySql(action, reqId, resultId, sql) {
59
58
  sqlView.setInt16(24, 1, true);
60
59
  return sqlBuffer;
61
60
  }
62
- exports.getBinarySql = getBinarySql;
63
61
  function zigzagDecode(n) {
64
62
  return (n >> 1) ^ (-(n & 1));
65
63
  }
66
- exports.zigzagDecode = zigzagDecode;
64
+ function safeDecodeURIComponent(str) {
65
+ // Replace invalid "%" not followed by two hex characters with "%25"
66
+ const cleaned = str.replace(/%(?![0-9A-Fa-f]{2})/g, '%25');
67
+ try {
68
+ return decodeURIComponent(cleaned);
69
+ }
70
+ catch (e) {
71
+ throw (new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_INVALID_URL, `Decoding ${str} error: ${e}`));
72
+ }
73
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKzC,QAAA,IAAI,UAAU,SAAgB,QAAQ,mBAQrC,CAAC;AAEF,QAAA,IAAI,UAAU,cAAqB,IAAI,MAAM,EAAE,MAAM,CAAC,wBAOrD,CAAC;AAEF,QAAA,IAAI,WAAW,UAAW,MAAM,SAE/B,CAAC;AAEF,QAAA,IAAI,OAAO,YAEV,CAAC;AACF,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKzC,QAAA,IAAI,UAAU,SAAgB,QAAQ,mBAQrC,CAAC;AAEF,QAAA,IAAI,UAAU,cAAqB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,wBAOrD,CAAC;AAEF,QAAA,IAAI,WAAW,UAAW,MAAM,SAE/B,CAAC;AAEF,QAAA,IAAI,OAAO,YAEV,CAAC;AACF,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC"}
package/lib/src/index.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.destroy = exports.setLogLevel = exports.tmqConnect = exports.sqlConnect = void 0;
27
37
  const wsSql_1 = require("./sql/wsSql");
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.binaryBlockEncode = exports.WsStmtQueryResponse = void 0;
3
+ exports.WsStmtQueryResponse = void 0;
4
+ exports.binaryBlockEncode = binaryBlockEncode;
4
5
  const wsResponse_1 = require("../client/wsResponse");
5
6
  const constant_1 = require("../common/constant");
6
7
  class WsStmtQueryResponse extends wsResponse_1.WSQueryResponse {
@@ -64,4 +65,3 @@ function binaryBlockEncode(bindParams, bindType, stmtId, reqId, row) {
64
65
  }
65
66
  return arrayBuffer;
66
67
  }
67
- exports.binaryBlockEncode = binaryBlockEncode;
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  const log_1 = __importStar(require("../../src/common/log"));
27
37
  describe('log level print', () => {
@@ -292,6 +292,9 @@ describe('ws.query(jsonTable)', () => {
292
292
  });
293
293
  });
294
294
  afterAll(async () => {
295
+ let ws = await wsSql_1.WsSql.open(conf);
296
+ await ws.exec(dropDB);
297
+ await ws.close();
295
298
  wsConnectorPool_1.WebSocketConnectionPool.instance().destroyed();
296
299
  });
297
300
  //--detectOpenHandles --maxConcurrency=1 --forceExit
@@ -91,5 +91,11 @@ describe('TDWebSocket.WsSchemaless()', () => {
91
91
  });
92
92
  });
93
93
  afterAll(async () => {
94
+ let conf = new config_1.WSConfig(dns);
95
+ conf.setUser('root');
96
+ conf.setPwd('taosdata');
97
+ let wsSql = await wsSql_1.WsSql.open(conf);
98
+ await wsSql.exec('drop database if exists power_schemaless;');
99
+ await wsSql.close();
94
100
  wsConnectorPool_1.WebSocketConnectionPool.instance().destroyed();
95
101
  });
@@ -3,15 +3,21 @@ 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
5
  const wsSql_1 = require("../../src/sql/wsSql");
6
+ const utils_1 = require("../utils");
6
7
  let dns = 'ws://localhost:6041';
8
+ let password1 = 'Ab1!@#$%,.:?<>;~';
9
+ let password2 = 'Bc%^&*()-_+=[]{}';
7
10
  beforeAll(async () => {
8
11
  let conf = new config_1.WSConfig(dns);
9
12
  conf.setUser('root');
10
13
  conf.setPwd('taosdata');
11
14
  let wsSql = await wsSql_1.WsSql.open(conf);
15
+ await wsSql.exec(`CREATE USER user1 PASS '${password1}'`);
16
+ await wsSql.exec(`CREATE USER user2 PASS '${password2}'`);
12
17
  await wsSql.exec('create database if not exists power KEEP 3650 DURATION 10 BUFFER 16 WAL_LEVEL 1;');
18
+ await (0, utils_1.Sleep)(100);
13
19
  await wsSql.exec('use power');
14
- await wsSql.exec('CREATE STABLE if not exists power.meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int);');
20
+ await wsSql.exec('CREATE STABLE if not exists meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int);');
15
21
  await wsSql.close();
16
22
  });
17
23
  describe('TDWebSocket.WsSql()', () => {
@@ -26,6 +32,30 @@ describe('TDWebSocket.WsSql()', () => {
26
32
  expect(wsSql.state()).toBeGreaterThan(0);
27
33
  await wsSql.close();
28
34
  });
35
+ test('special characters connect1', async () => {
36
+ let wsSql = null;
37
+ let conf = new config_1.WSConfig(dns);
38
+ conf.setUser('user1');
39
+ conf.setPwd(password1);
40
+ wsSql = await wsSql_1.WsSql.open(conf);
41
+ expect(wsSql.state()).toBeGreaterThan(0);
42
+ let version = await wsSql.version();
43
+ expect(version).not.toBeNull();
44
+ expect(version).not.toBeUndefined();
45
+ await wsSql.close();
46
+ });
47
+ test('special characters connect2', async () => {
48
+ let wsSql = null;
49
+ let conf = new config_1.WSConfig(dns);
50
+ conf.setUser('user2');
51
+ conf.setPwd(password2);
52
+ wsSql = await wsSql_1.WsSql.open(conf);
53
+ expect(wsSql.state()).toBeGreaterThan(0);
54
+ let version = await wsSql.version();
55
+ expect(version).not.toBeNull();
56
+ expect(version).not.toBeUndefined();
57
+ await wsSql.close();
58
+ });
29
59
  test('connect db with error', async () => {
30
60
  expect.assertions(1);
31
61
  let wsSql = null;
@@ -140,5 +170,13 @@ describe('TDWebSocket.WsSql()', () => {
140
170
  });
141
171
  });
142
172
  afterAll(async () => {
173
+ let conf = new config_1.WSConfig(dns);
174
+ conf.setUser('root');
175
+ conf.setPwd('taosdata');
176
+ let wsSql = await wsSql_1.WsSql.open(conf);
177
+ await wsSql.exec('drop database power');
178
+ await wsSql.exec('DROP USER user1;');
179
+ await wsSql.exec('DROP USER user2;');
180
+ await wsSql.close();
143
181
  wsConnectorPool_1.WebSocketConnectionPool.instance().destroyed();
144
182
  });
@@ -9,8 +9,8 @@ beforeAll(async () => {
9
9
  conf.setUser('root');
10
10
  conf.setPwd('taosdata');
11
11
  let wsSql = await wsSql_1.WsSql.open(conf);
12
- await wsSql.exec('create database if not exists power KEEP 3650 DURATION 10 BUFFER 16 WAL_LEVEL 1;');
13
- await wsSql.exec('CREATE STABLE if not exists power.meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int);');
12
+ await wsSql.exec('create database if not exists power_stmt KEEP 3650 DURATION 10 BUFFER 16 WAL_LEVEL 1;');
13
+ await wsSql.exec('CREATE STABLE if not exists power_stmt.meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int);');
14
14
  await wsSql.close();
15
15
  });
16
16
  describe('TDWebSocket.Stmt()', () => {
@@ -30,7 +30,7 @@ describe('TDWebSocket.Stmt()', () => {
30
30
  let conf = new config_1.WSConfig(dns);
31
31
  conf.setUser('root');
32
32
  conf.setPwd('taosdata');
33
- conf.setDb('power');
33
+ conf.setDb('power_stmt');
34
34
  let connector = await wsSql_1.WsSql.open(conf);
35
35
  let stmt = await connector.stmtInit();
36
36
  expect(stmt).toBeTruthy();
@@ -64,12 +64,12 @@ describe('TDWebSocket.Stmt()', () => {
64
64
  let conf = new config_1.WSConfig(dns);
65
65
  conf.setUser('root');
66
66
  conf.setPwd('taosdata');
67
- conf.setDb('power');
67
+ conf.setDb('power_stmt');
68
68
  let connector = await wsSql_1.WsSql.open(conf);
69
69
  let stmt = await connector.stmtInit();
70
70
  expect(stmt).toBeTruthy();
71
71
  expect(connector.state()).toBeGreaterThan(0);
72
- await stmt.prepare('INSERT INTO ? USING power.meters (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)');
72
+ await stmt.prepare('INSERT INTO ? USING meters (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)');
73
73
  await stmt.setTableName('d1001');
74
74
  let params = stmt.newStmtParam();
75
75
  params.setVarchar([tags[0]]);
@@ -82,12 +82,12 @@ describe('TDWebSocket.Stmt()', () => {
82
82
  let conf = new config_1.WSConfig(dns);
83
83
  conf.setUser('root');
84
84
  conf.setPwd('taosdata');
85
- conf.setDb('power');
85
+ conf.setDb('power_stmt');
86
86
  let connector = await wsSql_1.WsSql.open(conf);
87
87
  let stmt = await connector.stmtInit();
88
88
  expect(stmt).toBeTruthy();
89
89
  expect(connector.state()).toBeGreaterThan(0);
90
- await stmt.prepare('INSERT INTO ? USING power.meters (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)');
90
+ await stmt.prepare('INSERT INTO ? USING meters (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)');
91
91
  await stmt.setTableName('d1001');
92
92
  let params = stmt.newStmtParam();
93
93
  params.setVarchar([tags[0]]);
@@ -104,18 +104,18 @@ describe('TDWebSocket.Stmt()', () => {
104
104
  let conf = new config_1.WSConfig(dns);
105
105
  conf.setUser('root');
106
106
  conf.setPwd('taosdata');
107
- conf.setDb('power');
107
+ conf.setDb('power_stmt');
108
108
  let connector = await wsSql_1.WsSql.open(conf);
109
109
  let stmt = await connector.stmtInit();
110
110
  expect(stmt).toBeTruthy();
111
111
  expect(connector.state()).toBeGreaterThan(0);
112
112
  try {
113
- await stmt.prepare('INSERT ? INTO ? USING powr.meters TAGS (?, ?) VALUES (?, ?, ?, ?)');
113
+ await stmt.prepare('INSERT ? INTO ? USING meters TAGS (?, ?) VALUES (?, ?, ?, ?)');
114
114
  await stmt.setTableName('d1001');
115
115
  }
116
116
  catch (e) {
117
117
  let err = e;
118
- expect(err.message).toMatch("syntax error near '? into ? using powr.meters tags (?, ?) values (?, ?, ?, ?)' (keyword INTO is expected)");
118
+ expect(err.message).toMatch("syntax error near '? into ? using meters tags (?, ?) values (?, ?, ?, ?)' (keyword INTO is expected)");
119
119
  }
120
120
  await stmt.close();
121
121
  await connector.close();
@@ -124,18 +124,18 @@ describe('TDWebSocket.Stmt()', () => {
124
124
  let conf = new config_1.WSConfig(dns);
125
125
  conf.setUser('root');
126
126
  conf.setPwd('taosdata');
127
- conf.setDb('power');
127
+ conf.setDb('power_stmt');
128
128
  let connector = await wsSql_1.WsSql.open(conf);
129
129
  let stmt = await connector.stmtInit();
130
130
  expect(stmt).toBeTruthy();
131
131
  expect(connector.state()).toBeGreaterThan(0);
132
132
  try {
133
- await stmt.prepare('INSERT INTO ? USING powr.meters TAGS (?, ?, ?) VALUES (?, ?, ?, ?)');
133
+ await stmt.prepare('INSERT INTO ? USING meters TAGS (?, ?, ?) VALUES (?, ?, ?, ?)');
134
134
  await stmt.setTableName('d1001');
135
135
  }
136
136
  catch (e) {
137
137
  let err = e;
138
- expect(err.message).toMatch("Database not exist");
138
+ expect(err.message).toMatch("Tags number not matched");
139
139
  }
140
140
  await stmt.close();
141
141
  await connector.close();
@@ -144,11 +144,11 @@ describe('TDWebSocket.Stmt()', () => {
144
144
  let conf = new config_1.WSConfig(dns);
145
145
  conf.setUser('root');
146
146
  conf.setPwd('taosdata');
147
- conf.setDb('power');
147
+ conf.setDb('power_stmt');
148
148
  let connector = await wsSql_1.WsSql.open(conf);
149
149
  let stmt = await connector.stmtInit();
150
150
  expect(stmt).toBeTruthy();
151
- await stmt.prepare('INSERT INTO ? USING power.meters (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)');
151
+ await stmt.prepare('INSERT INTO ? USING meters (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)');
152
152
  await stmt.setTableName('d1001');
153
153
  let params = stmt.newStmtParam();
154
154
  params.setVarchar(['SanFrancisco']);
@@ -180,12 +180,12 @@ describe('TDWebSocket.Stmt()', () => {
180
180
  let conf = new config_1.WSConfig(dns);
181
181
  conf.setUser('root');
182
182
  conf.setPwd('taosdata');
183
- conf.setDb('power');
183
+ conf.setDb('power_stmt');
184
184
  let connector = await wsSql_1.WsSql.open(conf);
185
185
  let stmt = await connector.stmtInit();
186
186
  expect(stmt).toBeTruthy();
187
187
  expect(connector.state()).toBeGreaterThan(0);
188
- await stmt.prepare('INSERT INTO ? USING power.meters (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)');
188
+ await stmt.prepare('INSERT INTO ? USING meters (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)');
189
189
  await stmt.setTableName('d1001');
190
190
  let params = stmt.newStmtParam();
191
191
  params.setVarchar(['SanFrancisco']);
@@ -218,12 +218,12 @@ describe('TDWebSocket.Stmt()', () => {
218
218
  let conf = new config_1.WSConfig(dns);
219
219
  conf.setUser('root');
220
220
  conf.setPwd('taosdata');
221
- conf.setDb('power');
221
+ conf.setDb('power_stmt');
222
222
  let connector = await wsSql_1.WsSql.open(conf);
223
223
  let stmt = await connector.stmtInit();
224
224
  expect(stmt).toBeTruthy();
225
225
  expect(connector.state()).toBeGreaterThan(0);
226
- await stmt.prepare('INSERT INTO ? USING power.meters (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)');
226
+ await stmt.prepare('INSERT INTO ? USING meters (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)');
227
227
  await stmt.setTableName('d1001');
228
228
  let params = stmt.newStmtParam();
229
229
  params.setVarchar(['SanFrancisco']);
@@ -255,12 +255,12 @@ describe('TDWebSocket.Stmt()', () => {
255
255
  let conf = new config_1.WSConfig(dns);
256
256
  conf.setUser('root');
257
257
  conf.setPwd('taosdata');
258
- conf.setDb('power');
258
+ conf.setDb('power_stmt');
259
259
  let connector = await wsSql_1.WsSql.open(conf);
260
260
  let stmt = await connector.stmtInit();
261
261
  expect(stmt).toBeTruthy();
262
262
  expect(connector.state()).toBeGreaterThan(0);
263
- await stmt.prepare('INSERT INTO ? USING power.meters (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)');
263
+ await stmt.prepare('INSERT INTO ? USING meters (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)');
264
264
  await stmt.setTableName('d1001');
265
265
  let params = stmt.newStmtParam();
266
266
  params.setVarchar(['SanFrancisco']);
@@ -306,12 +306,12 @@ describe('TDWebSocket.Stmt()', () => {
306
306
  let conf = new config_1.WSConfig(dns);
307
307
  conf.setUser('root');
308
308
  conf.setPwd('taosdata');
309
- conf.setDb('power');
309
+ conf.setDb('power_stmt');
310
310
  let connector = await wsSql_1.WsSql.open(conf);
311
311
  let stmt = await connector.stmtInit();
312
312
  expect(stmt).toBeTruthy();
313
313
  expect(connector.state()).toBeGreaterThan(0);
314
- await stmt.prepare('INSERT INTO ? USING power.meters (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)');
314
+ await stmt.prepare('INSERT INTO ? USING meters (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)');
315
315
  await stmt.setTableName('d1001');
316
316
  // await stmt.SetTags(tags)
317
317
  try {
@@ -335,12 +335,12 @@ describe('TDWebSocket.Stmt()', () => {
335
335
  let conf = new config_1.WSConfig(dns);
336
336
  conf.setUser('root');
337
337
  conf.setPwd('taosdata');
338
- conf.setDb('power');
338
+ conf.setDb('power_stmt');
339
339
  let connector = await wsSql_1.WsSql.open(conf);
340
340
  let stmt = await connector.stmtInit();
341
341
  expect(stmt).toBeTruthy();
342
342
  expect(connector.state()).toBeGreaterThan(0);
343
- await stmt.prepare('INSERT INTO ? USING power.meters (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)');
343
+ await stmt.prepare('INSERT INTO ? USING meters (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)');
344
344
  await stmt.setTableName('d1002');
345
345
  let params = stmt.newStmtParam();
346
346
  params.setVarchar(['SanFrancisco']);
@@ -354,7 +354,7 @@ describe('TDWebSocket.Stmt()', () => {
354
354
  await stmt.bind(dataParams);
355
355
  await stmt.batch();
356
356
  await stmt.exec();
357
- let result = await connector.exec("select * from power.meters");
357
+ let result = await connector.exec("select * from power_stmt.meters");
358
358
  console.log(result);
359
359
  await stmt.close();
360
360
  await connector.close();
@@ -363,12 +363,12 @@ describe('TDWebSocket.Stmt()', () => {
363
363
  let conf = new config_1.WSConfig(dns);
364
364
  conf.setUser('root');
365
365
  conf.setPwd('taosdata');
366
- conf.setDb('power');
366
+ conf.setDb('power_stmt');
367
367
  let connector = await wsSql_1.WsSql.open(conf);
368
368
  let stmt = await connector.stmtInit();
369
369
  expect(stmt).toBeTruthy();
370
370
  expect(connector.state()).toBeGreaterThan(0);
371
- await stmt.prepare('INSERT INTO ? USING power.meters (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)');
371
+ await stmt.prepare('INSERT INTO ? USING meters (location, groupId) TAGS (?, ?) VALUES (?, ?, ?, ?)');
372
372
  await stmt.setTableName('d1001');
373
373
  let params = stmt.newStmtParam();
374
374
  params.setVarchar(['SanFrancisco']);
@@ -393,5 +393,11 @@ describe('TDWebSocket.Stmt()', () => {
393
393
  });
394
394
  });
395
395
  afterAll(async () => {
396
+ let conf = new config_1.WSConfig(dns);
397
+ conf.setUser('root');
398
+ conf.setPwd('taosdata');
399
+ let wsSql = await wsSql_1.WsSql.open(conf);
400
+ await wsSql.exec('drop database power_stmt');
401
+ await wsSql.close();
396
402
  wsConnectorPool_1.WebSocketConnectionPool.instance().destroyed();
397
403
  });
@@ -265,5 +265,9 @@ describe('TDWebSocket.Stmt()', () => {
265
265
  });
266
266
  });
267
267
  afterAll(async () => {
268
+ let conf = new config_1.WSConfig(dsn);
269
+ let ws = await wsSql_1.WsSql.open(conf);
270
+ await ws.exec(dropDB);
271
+ await ws.close();
268
272
  wsConnectorPool_1.WebSocketConnectionPool.instance().destroyed();
269
273
  });
@@ -180,5 +180,11 @@ describe('TDWebSocket.Tmq()', () => {
180
180
  });
181
181
  });
182
182
  afterAll(async () => {
183
+ const dropDB = `drop database if exists ${db}`;
184
+ let conf = new config_1.WSConfig(dsn);
185
+ let ws = await wsSql_1.WsSql.open(conf);
186
+ await ws.exec(dropTopic);
187
+ await ws.exec(dropDB);
188
+ await ws.close();
183
189
  wsConnectorPool_1.WebSocketConnectionPool.instance().destroyed();
184
190
  });