@tdengine/websocket 3.2.1 → 3.2.3

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 (80) hide show
  1. package/lib/package.json +64 -0
  2. package/lib/src/client/retryConfig.d.ts +10 -0
  3. package/lib/src/client/retryConfig.d.ts.map +1 -0
  4. package/lib/src/client/retryConfig.js +46 -0
  5. package/lib/src/client/wsClient.d.ts +1 -0
  6. package/lib/src/client/wsClient.d.ts.map +1 -1
  7. package/lib/src/client/wsClient.js +31 -19
  8. package/lib/src/client/wsConnector.d.ts.map +1 -1
  9. package/lib/src/client/wsConnector.js +12 -11
  10. package/lib/src/client/wsConnectorPool.d.ts.map +1 -1
  11. package/lib/src/client/wsConnectorPool.js +13 -16
  12. package/lib/src/client/wsEventCallback.d.ts.map +1 -1
  13. package/lib/src/client/wsResponse.d.ts +0 -3
  14. package/lib/src/client/wsResponse.d.ts.map +1 -1
  15. package/lib/src/client/wsResponse.js +0 -3
  16. package/lib/src/common/config.d.ts +3 -0
  17. package/lib/src/common/config.d.ts.map +1 -1
  18. package/lib/src/common/config.js +6 -0
  19. package/lib/src/common/constant.d.ts +1 -0
  20. package/lib/src/common/constant.d.ts.map +1 -1
  21. package/lib/src/common/constant.js +6 -1
  22. package/lib/src/common/dsn.d.ts +18 -0
  23. package/lib/src/common/dsn.d.ts.map +1 -0
  24. package/lib/src/common/dsn.js +152 -0
  25. package/lib/src/common/taosResult.d.ts.map +1 -1
  26. package/lib/src/common/utils.d.ts +4 -0
  27. package/lib/src/common/utils.d.ts.map +1 -1
  28. package/lib/src/common/utils.js +54 -3
  29. package/lib/src/index.d.ts.map +1 -1
  30. package/lib/src/sql/wsSql.d.ts.map +1 -1
  31. package/lib/src/sql/wsSql.js +0 -3
  32. package/lib/src/tmq/config.d.ts +1 -0
  33. package/lib/src/tmq/config.d.ts.map +1 -1
  34. package/lib/src/tmq/config.js +18 -1
  35. package/lib/src/tmq/constant.d.ts +4 -0
  36. package/lib/src/tmq/constant.d.ts.map +1 -1
  37. package/lib/src/tmq/constant.js +4 -0
  38. package/lib/src/tmq/tmqResponse.d.ts.map +1 -1
  39. package/lib/src/tmq/tmqResponse.js +1 -4
  40. package/lib/src/tmq/wsTmq.d.ts.map +1 -1
  41. package/lib/src/tmq/wsTmq.js +10 -5
  42. package/lib/test/bulkPulling/cloud.tmq.test.js +3 -2
  43. package/lib/test/bulkPulling/decimal.test.js +8 -8
  44. package/lib/test/bulkPulling/dsn.test.d.ts +2 -0
  45. package/lib/test/bulkPulling/dsn.test.d.ts.map +1 -0
  46. package/lib/test/bulkPulling/dsn.test.js +378 -0
  47. package/lib/test/bulkPulling/queryTables.test.js +1 -1
  48. package/lib/test/bulkPulling/retryConfig.test.d.ts +2 -0
  49. package/lib/test/bulkPulling/retryConfig.test.d.ts.map +1 -0
  50. package/lib/test/bulkPulling/retryConfig.test.js +34 -0
  51. package/lib/test/bulkPulling/schemaless.test.js +15 -14
  52. package/lib/test/bulkPulling/sql.test.js +116 -44
  53. package/lib/test/bulkPulling/stmt1.func.test.js +31 -30
  54. package/lib/test/bulkPulling/stmt1.type.test.js +1 -1
  55. package/lib/test/bulkPulling/stmt2.func.test.js +37 -36
  56. package/lib/test/bulkPulling/stmt2.type.test.js +1 -1
  57. package/lib/test/bulkPulling/tmq.config.test.d.ts +2 -0
  58. package/lib/test/bulkPulling/tmq.config.test.d.ts.map +1 -0
  59. package/lib/test/bulkPulling/tmq.config.test.js +77 -0
  60. package/lib/test/bulkPulling/tmq.test.js +135 -14
  61. package/lib/test/bulkPulling/wsClient.reconnect.integration.test.d.ts +2 -0
  62. package/lib/test/bulkPulling/wsClient.reconnect.integration.test.d.ts.map +1 -0
  63. package/lib/test/bulkPulling/wsClient.reconnect.integration.test.js +184 -0
  64. package/lib/test/bulkPulling/wsConfig.dsn.test.d.ts +2 -0
  65. package/lib/test/bulkPulling/wsConfig.dsn.test.d.ts.map +1 -0
  66. package/lib/test/bulkPulling/wsConfig.dsn.test.js +37 -0
  67. package/lib/test/bulkPulling/wsConnectPool.test.js +7 -7
  68. package/lib/test/bulkPulling/wsConnector.failover.test.d.ts +2 -0
  69. package/lib/test/bulkPulling/wsConnector.failover.test.d.ts.map +1 -0
  70. package/lib/test/bulkPulling/wsConnector.failover.test.js +128 -0
  71. package/lib/test/bulkPulling/wsConnectorPool.key.test.d.ts +2 -0
  72. package/lib/test/bulkPulling/wsConnectorPool.key.test.d.ts.map +1 -0
  73. package/lib/test/bulkPulling/wsConnectorPool.key.test.js +50 -0
  74. package/lib/test/bulkPulling/wsEventCallback.test.d.ts +2 -0
  75. package/lib/test/bulkPulling/wsEventCallback.test.d.ts.map +1 -0
  76. package/lib/test/bulkPulling/wsEventCallback.test.js +54 -0
  77. package/lib/test/utils.d.ts +4 -0
  78. package/lib/test/utils.d.ts.map +1 -1
  79. package/lib/test/utils.js +11 -17
  80. package/package.json +1 -1
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@tdengine/websocket",
3
+ "version": "3.2.3",
4
+ "description": "The websocket Node.js connector for TDengine. TDengine versions 3.3.2.0 and above are recommended to use this connector.",
5
+ "source": "index.ts",
6
+ "main": "lib/index.js",
7
+ "module": "lib/index.js",
8
+ "types": "lib/index.d.ts",
9
+ "directories": {
10
+ "example": "example",
11
+ "test": "test"
12
+ },
13
+ "scripts": {
14
+ "test": "jest --coverage --coverageDirectory=../coverage",
15
+ "example": "tsc && node lib/example/basicSql.js",
16
+ "build": "tsc",
17
+ "prepublish": "node ./prepare.js"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/taosdata/taos-connector-node.git"
22
+ },
23
+ "keywords": [
24
+ "taosdata",
25
+ "taos",
26
+ "IOT",
27
+ "TypeScript",
28
+ "TDengine",
29
+ "database"
30
+ ],
31
+ "author": "TaosData Inc.",
32
+ "license": "MIT",
33
+ "bugs": {
34
+ "url": "https://github.com/taosdata/taos-connector-node/issues"
35
+ },
36
+ "files": [
37
+ "lib"
38
+ ],
39
+ "homepage": "https://github.com/taosdata/taos-connector-node#readme",
40
+ "dependencies": {
41
+ "async-mutex": "^0.5.0",
42
+ "json-bigint": "^1.0.0",
43
+ "moment-timezone": "^0.5.45",
44
+ "typescript": "^5.3.3",
45
+ "uuid": "^9.0.1",
46
+ "websocket": "^1.0.34",
47
+ "winston": "^3.17.0",
48
+ "winston-daily-rotate-file": "^5.0.0"
49
+ },
50
+ "devDependencies": {
51
+ "@parcel/packager-ts": "^2.7.0",
52
+ "@parcel/transformer-typescript-types": "^2.7.0",
53
+ "@types/jest": "^29.2.1",
54
+ "@types/json-bigint": "^1.0.1",
55
+ "@types/node": "^18.0.0",
56
+ "@types/uuid": "^9.0.8",
57
+ "@types/websocket": "^1.0",
58
+ "jest": "^29.7.0",
59
+ "parcel": "^2.7.0",
60
+ "qingwa": "^1.0.7",
61
+ "ts-jest": "^29.0.3",
62
+ "typescript": "^5.3.3"
63
+ }
64
+ }
@@ -0,0 +1,10 @@
1
+ import { Dsn } from "../common/dsn";
2
+ export declare class RetryConfig {
3
+ readonly retries: number;
4
+ readonly retryBackoffMs: number;
5
+ readonly retryBackoffMaxMs: number;
6
+ constructor(retries: number, retryBackoffMs: number, retryBackoffMaxMs: number);
7
+ getBackoffDelay(attempt: number): number;
8
+ static fromDsn(dsn: Dsn): RetryConfig;
9
+ }
10
+ //# sourceMappingURL=retryConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retryConfig.d.ts","sourceRoot":"","sources":["../../../src/client/retryConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAkCpC,qBAAa,WAAW;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;gBAEvB,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM;IAM9E,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAOxC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,WAAW;CAexC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RetryConfig = void 0;
4
+ const DEFAULT_RETRIES = 3;
5
+ const DEFAULT_BACKOFF_MS = 100;
6
+ const DEFAULT_BACKOFF_MAX_MS = 10000;
7
+ function parseNonNegativeInt(value, fallback) {
8
+ if (value === undefined || value === null || value.length === 0) {
9
+ return fallback;
10
+ }
11
+ const parsed = Number.parseInt(value, 10);
12
+ if (!Number.isFinite(parsed) || Number.isNaN(parsed) || parsed < 0) {
13
+ return fallback;
14
+ }
15
+ return parsed;
16
+ }
17
+ function parsePositiveInt(value, fallback) {
18
+ if (value === undefined || value === null || value.length === 0) {
19
+ return fallback;
20
+ }
21
+ const parsed = Number.parseInt(value, 10);
22
+ if (!Number.isFinite(parsed) || Number.isNaN(parsed) || parsed <= 0) {
23
+ return fallback;
24
+ }
25
+ return parsed;
26
+ }
27
+ class RetryConfig {
28
+ constructor(retries, retryBackoffMs, retryBackoffMaxMs) {
29
+ this.retries = retries;
30
+ this.retryBackoffMs = retryBackoffMs;
31
+ this.retryBackoffMaxMs = Math.max(retryBackoffMs, retryBackoffMaxMs);
32
+ }
33
+ getBackoffDelay(attempt) {
34
+ const safeAttempt = Math.max(0, attempt);
35
+ const rawDelay = this.retryBackoffMs * Math.pow(2, safeAttempt);
36
+ const finiteDelay = Number.isFinite(rawDelay) ? rawDelay : this.retryBackoffMaxMs;
37
+ return Math.min(finiteDelay, this.retryBackoffMaxMs);
38
+ }
39
+ static fromDsn(dsn) {
40
+ const retries = parseNonNegativeInt(dsn.params.get("retries"), DEFAULT_RETRIES);
41
+ const retryBackoffMs = parsePositiveInt(dsn.params.get("retry_backoff_ms"), DEFAULT_BACKOFF_MS);
42
+ const retryBackoffMaxMs = parsePositiveInt(dsn.params.get("retry_backoff_max_ms"), DEFAULT_BACKOFF_MAX_MS);
43
+ return new RetryConfig(retries, retryBackoffMs, retryBackoffMaxMs);
44
+ }
45
+ }
46
+ exports.RetryConfig = RetryConfig;
@@ -7,6 +7,7 @@ export declare class WsClient {
7
7
  private readonly _url;
8
8
  private static readonly _minVersion;
9
9
  private _version?;
10
+ private _bearerToken?;
10
11
  constructor(url: URL, timeout?: number | undefined | null);
11
12
  connect(database?: string | undefined | null): Promise<void>;
12
13
  setOptionConnection(option: TSDB_OPTION_CONNECTION, value: string | null): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"wsClient.d.ts","sourceRoot":"","sources":["../../../src/client/wsClient.ts"],"names":[],"mappings":"AASA,OAAO,EAAqB,eAAe,EAAE,MAAM,cAAc,CAAC;AAKlE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,qBAAa,QAAQ;IACjB,OAAO,CAAC,YAAY,CAAC,CAAqB;IAC1C,OAAO,CAAC,QAAQ,CAAC,CAA4B;IAC7C,OAAO,CAAC,SAAS,CAAC,CAA4B;IAC9C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAM;IAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAa;IAChD,OAAO,CAAC,QAAQ,CAAC,CAA4B;gBAEjC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAWnD,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IA4C5D,mBAAmB,CACrB,MAAM,EAAE,sBAAsB,EAC9B,KAAK,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC,IAAI,CAAC;IAyBV,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB3C,IAAI,CAAC,QAAQ,EAAE,MAA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,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBxF,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB3C,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAE,OAAc,GAAG,OAAO,CAAC,GAAG,CAAC;IA0C/D,aAAa,CACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,SAAS,GAAE,OAAc,EACzB,aAAa,GAAE,OAAe,GAC/B,OAAO,CAAC,GAAG,CAAC;IA0Cf,QAAQ;IAOF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAyBtB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAwBlC,UAAU,CAAC,GAAG,EAAE,eAAe;IAkC/B,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAoC1B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAS5B,QAAQ,CAAC,GAAG,EAAE,GAAG;IAYX,YAAY;CAarB"}
@@ -12,16 +12,19 @@ const reqid_1 = require("../common/reqid");
12
12
  const log_1 = __importDefault(require("../common/log"));
13
13
  const utils_1 = require("../common/utils");
14
14
  const websocket_1 = require("websocket");
15
+ const constant_1 = require("../common/constant");
15
16
  class WsClient {
16
17
  constructor(url, timeout) {
17
18
  this.checkURL(url);
18
19
  this._url = url;
19
20
  this._timeout = timeout;
20
21
  if (this._url.searchParams.has("timezone")) {
21
- this._timezone =
22
- this._url.searchParams.get("timezone") || undefined;
22
+ this._timezone = this._url.searchParams.get("timezone") || undefined;
23
23
  this._url.searchParams.delete("timezone");
24
24
  }
25
+ if (this._url.searchParams.has("bearer_token")) {
26
+ this._bearerToken = this._url.searchParams.get("bearer_token") || undefined;
27
+ }
25
28
  }
26
29
  async connect(database) {
27
30
  let connMsg = {
@@ -31,12 +34,15 @@ class WsClient {
31
34
  user: (0, utils_1.safeDecodeURIComponent)(this._url.username),
32
35
  password: (0, utils_1.safeDecodeURIComponent)(this._url.password),
33
36
  db: database,
37
+ connector: constant_1.ConnectorInfo,
34
38
  ...(this._timezone && { tz: this._timezone }),
39
+ ...(this._bearerToken && { bearer_token: this._bearerToken }),
35
40
  },
36
41
  };
37
- log_1.default.debug("[wsClient.connect.connMsg]===>" + json_bigint_1.default.stringify(connMsg));
38
- this._wsConnector =
39
- await wsConnectorPool_1.WebSocketConnectionPool.instance().getConnection(this._url, this._timeout);
42
+ if (log_1.default.isDebugEnabled()) {
43
+ log_1.default.debug("[wsClient.connect.connMsg]===>" + json_bigint_1.default.stringify(connMsg, (key, value) => (key === "password" || key === "bearer_token") ? "[REDACTED]" : value));
44
+ }
45
+ this._wsConnector = await wsConnectorPool_1.WebSocketConnectionPool.instance().getConnection(this._url, this._timeout);
40
46
  if (this._wsConnector.readyState() === websocket_1.w3cwebsocket.OPEN) {
41
47
  return;
42
48
  }
@@ -51,8 +57,9 @@ class WsClient {
51
57
  }
52
58
  catch (e) {
53
59
  await this.close();
54
- log_1.default.error(`connection creation failed, url: ${this._url}, code:${e.code}, msg:${e.message}`);
55
- throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `connection creation failed, url: ${this._url}, code:${e.code}, msg:${e.message}`);
60
+ const maskedUrl = (0, utils_1.maskUrlForLog)(this._url);
61
+ log_1.default.error(`connection creation failed, url: ${maskedUrl}, code:${e.code}, msg:${e.message}`);
62
+ throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `connection creation failed, url: ${maskedUrl}, code:${e.code}, msg:${e.message}`);
56
63
  }
57
64
  }
58
65
  async setOptionConnection(option, value) {
@@ -86,10 +93,12 @@ class WsClient {
86
93
  }
87
94
  throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_CONNECTION_CLOSED, "invalid websocket connect");
88
95
  }
89
- // need to construct Response.
96
+ // Need to construct Response
90
97
  async exec(queryMsg, bSqlQuery = true) {
91
98
  return new Promise((resolve, reject) => {
92
- log_1.default.debug("[wsQueryInterface.query.queryMsg]===>" + queryMsg);
99
+ if (log_1.default.isDebugEnabled()) {
100
+ log_1.default.debug("[wsQueryInterface.query.queryMsg]===>" + (0, utils_1.maskSensitiveForLog)(queryMsg));
101
+ }
93
102
  if (this._wsConnector &&
94
103
  this._wsConnector.readyState() === websocket_1.w3cwebsocket.OPEN) {
95
104
  this._wsConnector
@@ -156,17 +165,19 @@ class WsClient {
156
165
  }
157
166
  async ready() {
158
167
  try {
159
- this._wsConnector =
160
- await wsConnectorPool_1.WebSocketConnectionPool.instance().getConnection(this._url, this._timeout);
168
+ this._wsConnector = await wsConnectorPool_1.WebSocketConnectionPool.instance().getConnection(this._url, this._timeout);
161
169
  if (this._wsConnector.readyState() !== websocket_1.w3cwebsocket.OPEN) {
162
170
  await this._wsConnector.ready();
163
171
  }
164
- log_1.default.debug("ready status ", this._url, this._wsConnector.readyState());
172
+ if (log_1.default.isDebugEnabled()) {
173
+ log_1.default.debug("ready status ", (0, utils_1.maskUrlForLog)(this._url), this._wsConnector.readyState());
174
+ }
165
175
  return;
166
176
  }
167
177
  catch (e) {
168
- log_1.default.error(`connection creation failed, url: ${this._url}, code: ${e.code}, message: ${e.message}`);
169
- throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `connection creation failed, url: ${this._url}, code: ${e.code}, message: ${e.message}`);
178
+ const maskedUrl = (0, utils_1.maskUrlForLog)(this._url);
179
+ log_1.default.error(`connection creation failed, url: ${maskedUrl}, code: ${e.code}, message: ${e.message}`);
180
+ throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `connection creation failed, url: ${maskedUrl}, code: ${e.code}, message: ${e.message}`);
170
181
  }
171
182
  }
172
183
  async sendMsg(msg) {
@@ -233,8 +244,9 @@ class WsClient {
233
244
  throw new wsError_1.WebSocketInterfaceError(result.msg.code, result.msg.message);
234
245
  }
235
246
  catch (e) {
236
- log_1.default.error(`connection creation failed, url: ${this._url}, code: ${e.code}, message: ${e.message}`);
237
- throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `connection creation failed, url: ${this._url}, code: ${e.code}, message: ${e.message}`);
247
+ const maskedUrl = (0, utils_1.maskUrlForLog)(this._url);
248
+ log_1.default.error(`connection creation failed, url: ${maskedUrl}, code: ${e.code}, message: ${e.message}`);
249
+ throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `connection creation failed, url: ${maskedUrl}, code: ${e.code}, message: ${e.message}`);
238
250
  }
239
251
  }
240
252
  throw (wsError_1.ErrorCode.ERR_CONNECTION_CLOSED, "invalid websocket connect");
@@ -246,10 +258,10 @@ class WsClient {
246
258
  }
247
259
  }
248
260
  checkURL(url) {
249
- // Assert is cloud url
250
- if (!url.searchParams.has("token")) {
261
+ // Assert token or bearer_token exists, otherwise username and password must exist.
262
+ if (!url.searchParams.get("token") && !url.searchParams.get("bearer_token")) {
251
263
  if (!(url.username || url.password)) {
252
- throw new wsError_1.WebSocketInterfaceError(wsError_1.ErrorCode.ERR_INVALID_AUTHENTICATION, "invalid url, password or username needed.");
264
+ throw new wsError_1.WebSocketInterfaceError(wsError_1.ErrorCode.ERR_INVALID_AUTHENTICATION, `invalid url, provide non-empty "token" or "bearer_token", or provide username/password`);
253
265
  }
254
266
  }
255
267
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wsConnector.d.ts","sourceRoot":"","sources":["../../../src/client/wsConnector.ts"],"names":[],"mappings":"AAUA,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,MAAM,CAAM;IACpB,QAAQ,SAAQ;gBAGJ,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAuClD,KAAK;YA6BG,QAAQ;IAItB,OAAO,CAAC,UAAU;IA4BlB,KAAK;IAWL,UAAU,IAAI,MAAM;IAId,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsB7C,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAE,OAAc;IAqCjD,aAAa,CACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,QAAQ,GAAE,OAAc;IAkCrB,QAAQ,IAAI,GAAG;CAGzB"}
1
+ {"version":3,"file":"wsConnector.d.ts","sourceRoot":"","sources":["../../../src/client/wsConnector.ts"],"names":[],"mappings":"AAWA,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,MAAM,CAAM;IACpB,QAAQ,SAAQ;gBAEJ,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAkClD,KAAK;YA6BG,QAAQ;IAItB,OAAO,CAAC,UAAU;IA0BlB,KAAK;IAWL,UAAU,IAAI,MAAM;IAId,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsB7C,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAE,OAAc;IAsCjD,aAAa,CACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,QAAQ,GAAE,OAAc;IAkCrB,QAAQ,IAAI,GAAG;CAGzB"}
@@ -9,11 +9,10 @@ const wsError_1 = require("../common/wsError");
9
9
  const wsEventCallback_1 = require("./wsEventCallback");
10
10
  const log_1 = __importDefault(require("../common/log"));
11
11
  const reqid_1 = require("../common/reqid");
12
+ const utils_1 = require("../common/utils");
12
13
  class WebSocketConnector {
13
- // create ws
14
14
  constructor(url, timeout) {
15
15
  this._timeout = 5000;
16
- // return w3bsocket3
17
16
  if (url) {
18
17
  this._wsURL = url;
19
18
  let origin = url.origin;
@@ -27,7 +26,7 @@ class WebSocketConnector {
27
26
  maxReceivedMessageSize: 0x60000000,
28
27
  });
29
28
  this._wsConn.onerror = function (err) {
30
- log_1.default.error(`webSocket connection failed, url: ${this.url}, error: ${err.message}`);
29
+ log_1.default.error(`webSocket connection failed, url: ${(0, utils_1.maskUrlForLog)(new URL(this.url))}, error: ${err.message}`);
31
30
  };
32
31
  this._wsConn.onclose = this._onclose;
33
32
  this._wsConn.onmessage = this._onmessage;
@@ -98,12 +97,14 @@ class WebSocketConnector {
98
97
  resolve();
99
98
  }
100
99
  else {
101
- reject(new wsError_1.WebSocketQueryError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `WebSocket connection is not ready,status :${this._wsConn?.readyState}`));
100
+ reject(new wsError_1.WebSocketQueryError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `WebSocket connection is not ready, status: ${this._wsConn?.readyState}`));
102
101
  }
103
102
  });
104
103
  }
105
104
  async sendMsg(message, register = true) {
106
- log_1.default.debug("[wsClient.sendMessage()]===>" + message);
105
+ if (log_1.default.isDebugEnabled()) {
106
+ log_1.default.debug("[wsClient.sendMessage()]===>" + (0, utils_1.maskSensitiveForLog)(message));
107
+ }
107
108
  let msg = JSON.parse(message);
108
109
  if (msg.args.id !== undefined) {
109
110
  msg.args.id = BigInt(msg.args.id);
@@ -115,16 +116,16 @@ class WebSocketConnector {
115
116
  action: msg.action,
116
117
  req_id: msg.args.req_id,
117
118
  timeout: this._timeout,
118
- id: msg.args.id === undefined
119
- ? msg.args.id
120
- : BigInt(msg.args.id),
119
+ id: msg.args.id === undefined ? msg.args.id : BigInt(msg.args.id),
121
120
  }, resolve, reject);
122
121
  }
123
- log_1.default.debug(`[wsClient.sendMessage.msg]===> ${message}`);
122
+ if (log_1.default.isDebugEnabled()) {
123
+ log_1.default.debug("[wsClient.sendMessage.msg]===>" + (0, utils_1.maskSensitiveForLog)(message));
124
+ }
124
125
  this._wsConn.send(message);
125
126
  }
126
127
  else {
127
- reject(new wsError_1.WebSocketQueryError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `WebSocket connection is not ready,status :${this._wsConn?.readyState}`));
128
+ reject(new wsError_1.WebSocketQueryError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `WebSocket connection is not ready, status: ${this._wsConn?.readyState}`));
128
129
  }
129
130
  });
130
131
  }
@@ -146,7 +147,7 @@ class WebSocketConnector {
146
147
  this._wsConn.send(message);
147
148
  }
148
149
  else {
149
- reject(new wsError_1.WebSocketQueryError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `WebSocket connection is not ready,status :${this._wsConn?.readyState}`));
150
+ reject(new wsError_1.WebSocketQueryError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_FAIL, `WebSocket connection is not ready, status: ${this._wsConn?.readyState}`));
150
151
  }
151
152
  });
152
153
  }
@@ -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;AAOnD,qBAAa,uBAAuB;IAChC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAA0B;IACnD,OAAO,CAAC,IAAI,CAAgD;IAC5D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAoB;IAC/C,OAAO,CAAC,MAAM,CAAC,WAAW,CAAa;IAEvC,OAAO;WASO,QAAQ,CAClB,cAAc,GAAE,MAAW,GAC5B,uBAAuB;IASpB,aAAa,CACf,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GACnC,OAAO,CAAC,kBAAkB,CAAC;IA4DxB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmCrE,SAAS;CAmBZ"}
1
+ {"version":3,"file":"wsConnectorPool.d.ts","sourceRoot":"","sources":["../../../src/client/wsConnectorPool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAQnD,qBAAa,uBAAuB;IAChC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAA0B;IACnD,OAAO,CAAC,IAAI,CAAgD;IAC5D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAoB;IAC/C,OAAO,CAAC,MAAM,CAAC,WAAW,CAAa;IAEvC,OAAO;WAOO,QAAQ,CAAC,cAAc,GAAE,MAAW,GAAG,uBAAuB;IAOtE,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAwDxF,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IA8BrE,SAAS;CAmBZ"}
@@ -9,6 +9,7 @@ const wsConnector_1 = require("./wsConnector");
9
9
  const wsError_1 = require("../common/wsError");
10
10
  const log_1 = __importDefault(require("../common/log"));
11
11
  const websocket_1 = require("websocket");
12
+ const utils_1 = require("../common/utils");
12
13
  const mutex = new async_mutex_1.Mutex();
13
14
  class WebSocketConnectionPool {
14
15
  constructor(maxConnections = -1) {
@@ -36,15 +37,14 @@ class WebSocketConnectionPool {
36
37
  if (!candidate) {
37
38
  continue;
38
39
  }
39
- if (candidate &&
40
- candidate.readyState() === websocket_1.w3cwebsocket.OPEN) {
40
+ if (candidate && candidate.readyState() === websocket_1.w3cwebsocket.OPEN) {
41
41
  connector = candidate;
42
42
  break;
43
43
  }
44
44
  else if (candidate) {
45
45
  Atomics.add(WebSocketConnectionPool.sharedArray, 0, -1);
46
46
  candidate.close();
47
- log_1.default.error(`getConnection, current connection status fail, url: ${connectAddr}`);
47
+ log_1.default.error(`getConnection, current connection status fail, url: ${(0, utils_1.maskUrlForLog)(new URL(connectAddr))}`);
48
48
  }
49
49
  }
50
50
  }
@@ -54,16 +54,17 @@ class WebSocketConnectionPool {
54
54
  return connector;
55
55
  }
56
56
  if (this._maxConnections != -1 &&
57
- Atomics.load(WebSocketConnectionPool.sharedArray, 0) >
58
- this._maxConnections) {
57
+ Atomics.load(WebSocketConnectionPool.sharedArray, 0) > this._maxConnections) {
59
58
  throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WEBSOCKET_CONNECTION_ARRIVED_LIMIT, "websocket connect arrived limited:" +
60
59
  Atomics.load(WebSocketConnectionPool.sharedArray, 0));
61
60
  }
62
61
  Atomics.add(WebSocketConnectionPool.sharedArray, 0, 1);
63
- log_1.default.info("getConnection, new connection count:" +
64
- Atomics.load(WebSocketConnectionPool.sharedArray, 0) +
65
- ", connectAddr:" +
66
- connectAddr);
62
+ if (log_1.default.isInfoEnabled()) {
63
+ log_1.default.info("getConnection, new connection count:" +
64
+ Atomics.load(WebSocketConnectionPool.sharedArray, 0) +
65
+ ", connectAddr:" +
66
+ connectAddr.replace(/(token=)[^&]*/i, "$1[REDACTED]"));
67
+ }
67
68
  return new wsConnector_1.WebSocketConnector(url, timeout);
68
69
  }
69
70
  finally {
@@ -76,9 +77,7 @@ class WebSocketConnectionPool {
76
77
  try {
77
78
  if (connector.readyState() === websocket_1.w3cwebsocket.OPEN) {
78
79
  let url = connector.getWsURL();
79
- let connectAddr = url.origin
80
- .concat(url.pathname)
81
- .concat(url.search);
80
+ let connectAddr = url.origin.concat(url.pathname).concat(url.search);
82
81
  let connectors = this.pool.get(connectAddr);
83
82
  if (!connectors) {
84
83
  connectors = new Array();
@@ -88,8 +87,7 @@ class WebSocketConnectionPool {
88
87
  else {
89
88
  connectors.push(connector);
90
89
  }
91
- log_1.default.info("releaseConnection, current connection count:" +
92
- connectors.length);
90
+ log_1.default.info("releaseConnection, current connection count:" + connectors.length);
93
91
  }
94
92
  else {
95
93
  Atomics.add(WebSocketConnectionPool.sharedArray, 0, -1);
@@ -133,8 +131,7 @@ process.on("SIGINT", () => {
133
131
  process.exit();
134
132
  });
135
133
  process.on("SIGTERM", () => {
136
- log_1.default.info("Received SIGINT. Press Control-D to exit, begin destroy connect");
134
+ log_1.default.info("Received SIGTERM. Press Control-D to exit, begin destroy connect...");
137
135
  WebSocketConnectionPool.instance().destroyed();
138
136
  process.exit();
139
137
  });
140
- // process.kill(process.pid, 'SIGINT');
@@ -1 +1 @@
1
- {"version":3,"file":"wsEventCallback.d.ts","sourceRoot":"","sources":["../../../src/client/wsEventCallback.ts"],"names":[],"mappings":"AASA,UAAU,SAAS;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AASD,oBAAY,aAAa;IACrB,wBAAwB,IAAI;IAC5B,iBAAiB,IAAI;IACrB,mBAAmB,IAAI;IACvB,uBAAuB,IAAI;CAC9B;AAGD,qBAAa,eAAe;IACxB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAkB;IAC3C,OAAO,CAAC,MAAM,CAAC,kBAAkB,CACnB;IACd,OAAO;WAEO,QAAQ,IAAI,eAAe;IAOnC,gBAAgB,CAClB,EAAE,EAAE,SAAS,EACb,GAAG,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,EAC5B,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI;IAwBxB,mBAAmB,CACrB,GAAG,EAAE,SAAS,EACd,WAAW,EAAE,aAAa,EAC1B,IAAI,EAAE,GAAG;CA0DhB"}
1
+ {"version":3,"file":"wsEventCallback.d.ts","sourceRoot":"","sources":["../../../src/client/wsEventCallback.ts"],"names":[],"mappings":"AASA,UAAU,SAAS;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AASD,oBAAY,aAAa;IACrB,wBAAwB,IAAI;IAC5B,iBAAiB,IAAI;IACrB,mBAAmB,IAAI;IACvB,uBAAuB,IAAI;CAC9B;AAID,qBAAa,eAAe;IACxB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAkB;IAC3C,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAA4C;IAE7E,OAAO;WAEO,QAAQ,IAAI,eAAe;IAOnC,gBAAgB,CAClB,EAAE,EAAE,SAAS,EACb,GAAG,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,EAC5B,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI;IAwBxB,mBAAmB,CACrB,GAAG,EAAE,SAAS,EACd,WAAW,EAAE,aAAa,EAC1B,IAAI,EAAE,GAAG;CA0DhB"}
@@ -1,6 +1,3 @@
1
- /**
2
- * define ws Response type|class, for query?
3
- */
4
1
  import { MessageResp } from "../common/taosResult";
5
2
  export declare class WSVersionResponse {
6
3
  version: string;
@@ -1 +1 @@
1
- {"version":3,"file":"wsResponse.d.ts","sourceRoot":"","sources":["../../../src/client/wsResponse.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAe,MAAM,sBAAsB,CAAC;AAEhE,qBAAa,iBAAiB;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;gBACN,IAAI,EAAE,WAAW;CAOhC;AAED,qBAAa,eAAe;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,M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M,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,WAAW,EAAE,WAAW,CAAC;gBAEb,GAAG,EAAE,WAAW;CA+B/B"}
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
- /**
3
- * define ws Response type|class, for query?
4
- */
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.WSFetchBlockResponse = exports.WSQueryResponse = exports.WSVersionResponse = void 0;
7
4
  const taosResult_1 = require("../common/taosResult");
@@ -7,6 +7,7 @@ export declare class WSConfig {
7
7
  private _token;
8
8
  private _timezone;
9
9
  private _minStmt2Version;
10
+ private _bearerToken;
10
11
  constructor(url: string, minStmt2Version?: string);
11
12
  getToken(): string | undefined | null;
12
13
  setToken(token: string): void;
@@ -22,6 +23,8 @@ export declare class WSConfig {
22
23
  setTimeOut(ms: number): void;
23
24
  getTimezone(): string | undefined | null;
24
25
  setTimezone(timezone: string): void;
26
+ getBearerToken(): string | undefined | null;
27
+ setBearerToken(token: string): void;
25
28
  getMinStmt2Version(): string;
26
29
  }
27
30
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/common/config.ts"],"names":[],"mappings":"AAEA,qBAAa,QAAQ;IACjB,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,GAAG,CAA4B;IACvC,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,M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C,QAAQ,CAAC,KAAK,EAAE,MAAM;IAItB,OAAO,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAIpC,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,MAAM,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAInC,MAAM,CAAC,GAAG,EAAE,MAAM;IAIlB,KAAK,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAIlC,KAAK,CAAC,EAAE,EAAE,MAAM;IAIhB,MAAM,IAAI,MAAM;IAIhB,MAAM,CAAC,GAAG,EAAE,MAAM;IAIlB,UAAU,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAIvC,UAAU,CAAC,EAAE,EAAE,MAAM;IAIrB,WAAW,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAIxC,WAAW,CAAC,QAAQ,EAAE,MAAM;IAI5B,cAAc,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAI3C,cAAc,CAAC,KAAK,EAAE,MAAM;IAI5B,kBAAkB;CAG5B"}
@@ -54,6 +54,12 @@ class WSConfig {
54
54
  setTimezone(timezone) {
55
55
  this._timezone = timezone;
56
56
  }
57
+ getBearerToken() {
58
+ return this._bearerToken;
59
+ }
60
+ setBearerToken(token) {
61
+ this._bearerToken = token;
62
+ }
57
63
  getMinStmt2Version() {
58
64
  return this._minStmt2Version;
59
65
  }
@@ -7,6 +7,7 @@ export interface StringIndexable {
7
7
  export interface NumberIndexable {
8
8
  [index: number]: number;
9
9
  }
10
+ export declare const ConnectorInfo: string;
10
11
  export declare const BinaryQueryMessage: bigint;
11
12
  export declare const FetchRawBlockMessage: bigint;
12
13
  export declare const MinStmt2Version: string;
@@ -1 +1 @@
1
- {"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/common/constant.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC5B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC5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AO,MAAM,eAAe,EAAE,eAI7B,CAAC"}
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PrecisionLength = exports.TDengineTypeLength = exports.TDenginePrecision = exports.FieldBindType = exports.TSDB_OPTION_CONNECTION = exports.TDengineTypeCode = exports.ColumnsBlockType = exports.TDengineTypeName = exports.MinStmt2Version = exports.FetchRawBlockMessage = exports.BinaryQueryMessage = void 0;
6
+ exports.PrecisionLength = exports.TDengineTypeLength = exports.TDenginePrecision = exports.FieldBindType = exports.TSDB_OPTION_CONNECTION = exports.TDengineTypeCode = exports.ColumnsBlockType = exports.TDengineTypeName = exports.MinStmt2Version = exports.FetchRawBlockMessage = exports.BinaryQueryMessage = exports.ConnectorInfo = void 0;
7
+ const package_json_1 = __importDefault(require("../../package.json"));
8
+ exports.ConnectorInfo = `nodejs-ws-v${package_json_1.default.version}-ncid000`;
4
9
  exports.BinaryQueryMessage = BigInt(6);
5
10
  exports.FetchRawBlockMessage = BigInt(7);
6
11
  exports.MinStmt2Version = "3.3.6.0";
@@ -0,0 +1,18 @@
1
+ export interface Address {
2
+ host: string;
3
+ port: number;
4
+ }
5
+ export interface Dsn {
6
+ scheme: string;
7
+ username: string;
8
+ password: string;
9
+ addresses: Address[];
10
+ database: string;
11
+ params: Map<string, string>;
12
+ }
13
+ /**
14
+ * Parse a multi-host TDengine WebSocket URL.
15
+ * Format: ws://username:password@host1:port1,host2:port2,[::1]:port3/db?key=value
16
+ */
17
+ export declare function parse(url: string): Dsn;
18
+ //# sourceMappingURL=dsn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dsn.d.ts","sourceRoot":"","sources":["../../../src/common/dsn.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,OAAO;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,GAAG;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAqFtC"}