@tdengine/websocket 3.1.9 → 3.2.0

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 (64) hide show
  1. package/lib/index.d.ts +8 -1
  2. package/lib/index.d.ts.map +1 -1
  3. package/lib/index.js +8 -1
  4. package/lib/src/client/wsClient.d.ts +1 -0
  5. package/lib/src/client/wsClient.d.ts.map +1 -1
  6. package/lib/src/client/wsClient.js +6 -3
  7. package/lib/src/common/config.d.ts +3 -1
  8. package/lib/src/common/config.d.ts.map +1 -1
  9. package/lib/src/common/config.js +11 -1
  10. package/lib/src/common/constant.d.ts +11 -1
  11. package/lib/src/common/constant.d.ts.map +1 -1
  12. package/lib/src/common/constant.js +21 -13
  13. package/lib/src/sql/wsSql.d.ts.map +1 -1
  14. package/lib/src/sql/wsSql.js +8 -2
  15. package/lib/src/stmt/FieldBindParams.d.ts +9 -0
  16. package/lib/src/stmt/FieldBindParams.d.ts.map +1 -0
  17. package/lib/src/stmt/FieldBindParams.js +13 -0
  18. package/lib/src/stmt/wsColumnInfo.d.ts +12 -0
  19. package/lib/src/stmt/wsColumnInfo.d.ts.map +1 -0
  20. package/lib/src/stmt/wsColumnInfo.js +17 -0
  21. package/lib/src/stmt/wsParams1.d.ts +14 -0
  22. package/lib/src/stmt/wsParams1.d.ts.map +1 -0
  23. package/lib/src/stmt/wsParams1.js +274 -0
  24. package/lib/src/stmt/wsParams2.d.ts +14 -0
  25. package/lib/src/stmt/wsParams2.d.ts.map +1 -0
  26. package/lib/src/stmt/wsParams2.js +188 -0
  27. package/lib/src/stmt/wsParamsBase.d.ts +45 -0
  28. package/lib/src/stmt/wsParamsBase.d.ts.map +1 -0
  29. package/lib/src/stmt/wsParamsBase.js +218 -0
  30. package/lib/src/stmt/wsProto.d.ts +13 -1
  31. package/lib/src/stmt/wsProto.d.ts.map +1 -1
  32. package/lib/src/stmt/wsProto.js +195 -2
  33. package/lib/src/stmt/wsStmt.d.ts +6 -16
  34. package/lib/src/stmt/wsStmt.d.ts.map +1 -1
  35. package/lib/src/stmt/wsStmt.js +0 -201
  36. package/lib/src/stmt/wsStmt1.d.ts +30 -0
  37. package/lib/src/stmt/wsStmt1.d.ts.map +1 -0
  38. package/lib/src/stmt/wsStmt1.js +206 -0
  39. package/lib/src/stmt/wsStmt2.d.ts +37 -0
  40. package/lib/src/stmt/wsStmt2.d.ts.map +1 -0
  41. package/lib/src/stmt/wsStmt2.js +280 -0
  42. package/lib/src/stmt/wsTableInfo.d.ts +17 -0
  43. package/lib/src/stmt/wsTableInfo.d.ts.map +1 -0
  44. package/lib/src/stmt/wsTableInfo.js +54 -0
  45. package/lib/src/tmq/tmqResponse.js +1 -1
  46. package/lib/test/bulkPulling/sql.test.js +3 -0
  47. package/lib/test/bulkPulling/stmt.func.test.js +99 -11
  48. package/lib/test/bulkPulling/stmt.type.test.js +8 -6
  49. package/lib/test/bulkPulling/stmt1.func.test.d.ts +2 -0
  50. package/lib/test/bulkPulling/stmt1.func.test.d.ts.map +1 -0
  51. package/lib/test/bulkPulling/stmt1.func.test.js +417 -0
  52. package/lib/test/bulkPulling/stmt1.type.test.d.ts +2 -0
  53. package/lib/test/bulkPulling/stmt1.type.test.d.ts.map +1 -0
  54. package/lib/test/bulkPulling/stmt1.type.test.js +323 -0
  55. package/lib/test/bulkPulling/stmt2.func.test.d.ts +2 -0
  56. package/lib/test/bulkPulling/stmt2.func.test.d.ts.map +1 -0
  57. package/lib/test/bulkPulling/stmt2.func.test.js +539 -0
  58. package/lib/test/bulkPulling/stmt2.type.test.d.ts +2 -0
  59. package/lib/test/bulkPulling/stmt2.type.test.d.ts.map +1 -0
  60. package/lib/test/bulkPulling/stmt2.type.test.js +325 -0
  61. package/lib/test/bulkPulling/wsConnectPool.test.js +2 -2
  62. package/lib/test/utils.d.ts.map +1 -1
  63. package/lib/test/utils.js +1 -0
  64. package/package.json +1 -1
package/lib/index.d.ts CHANGED
@@ -16,9 +16,16 @@ export * from "./src/index";
16
16
  export * from "./src/sql/wsProto";
17
17
  export * from "./src/sql/wsRows";
18
18
  export * from "./src/sql/wsSql";
19
- export * from "./src/stmt/wsParams";
19
+ export * from "./src/stmt/FieldBindParams";
20
+ export * from "./src/stmt/wsColumnInfo";
21
+ export * from "./src/stmt/wsParams1";
22
+ export * from "./src/stmt/wsParams2";
23
+ export * from "./src/stmt/wsParamsBase";
20
24
  export * from "./src/stmt/wsProto";
21
25
  export * from "./src/stmt/wsStmt";
26
+ export * from "./src/stmt/wsStmt1";
27
+ export * from "./src/stmt/wsStmt2";
28
+ export * from "./src/stmt/wsTableInfo";
22
29
  export * from "./src/tmq/config";
23
30
  export * from "./src/tmq/constant";
24
31
  export * from "./src/tmq/tmqResponse";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA;AACvC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA"}
package/lib/index.js CHANGED
@@ -32,9 +32,16 @@ __exportStar(require("./src/index"), exports);
32
32
  __exportStar(require("./src/sql/wsProto"), exports);
33
33
  __exportStar(require("./src/sql/wsRows"), exports);
34
34
  __exportStar(require("./src/sql/wsSql"), exports);
35
- __exportStar(require("./src/stmt/wsParams"), exports);
35
+ __exportStar(require("./src/stmt/FieldBindParams"), exports);
36
+ __exportStar(require("./src/stmt/wsColumnInfo"), exports);
37
+ __exportStar(require("./src/stmt/wsParams1"), exports);
38
+ __exportStar(require("./src/stmt/wsParams2"), exports);
39
+ __exportStar(require("./src/stmt/wsParamsBase"), exports);
36
40
  __exportStar(require("./src/stmt/wsProto"), exports);
37
41
  __exportStar(require("./src/stmt/wsStmt"), exports);
42
+ __exportStar(require("./src/stmt/wsStmt1"), exports);
43
+ __exportStar(require("./src/stmt/wsStmt2"), exports);
44
+ __exportStar(require("./src/stmt/wsTableInfo"), exports);
38
45
  __exportStar(require("./src/tmq/config"), exports);
39
46
  __exportStar(require("./src/tmq/constant"), exports);
40
47
  __exportStar(require("./src/tmq/tmqResponse"), exports);
@@ -6,6 +6,7 @@ export declare class WsClient {
6
6
  private _timezone?;
7
7
  private readonly _url;
8
8
  private static readonly _minVersion;
9
+ private _version?;
9
10
  constructor(url: URL, timeout?: number | undefined | null);
10
11
  connect(database?: string | undefined | null): Promise<void>;
11
12
  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":"AAIA,OAAO,EAEH,eAAe,EAClB,MAAM,cAAc,CAAC;AAKtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,qBAAa,QAAQ;IACjB,OAAO,CAAC,YAAY,CAAC,CAAqB;IAC1C,OAAO,CAAC,QAAQ,CAAC,CAA2B;IAC5C,OAAO,CAAC,SAAS,CAAC,CAA2B;IAC7C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAK;IAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAa;gBAEpC,GAAG,EAAE,GAAG,EAAE,OAAQ,CAAC,EAAC,MAAM,GAAG,SAAS,GAAG,IAAI;IAWnD,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAiC5D,mBAAmB,CAAC,MAAM,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,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AAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAiC5D,mBAAmB,CAAC,MAAM,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBxF,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;IA8B1B,KAAK,IAAG,OAAO,CAAC,IAAI,CAAC;IAQ3B,QAAQ,CAAC,GAAG,EAAE,GAAG;IASX,YAAY;CAQrB"}
@@ -188,6 +188,9 @@ class WsClient {
188
188
  });
189
189
  }
190
190
  async version() {
191
+ if (this._version) {
192
+ return this._version;
193
+ }
191
194
  let versionMsg = {
192
195
  action: 'version',
193
196
  args: {
@@ -228,10 +231,10 @@ class WsClient {
228
231
  }
229
232
  }
230
233
  async checkVersion() {
231
- let version = await this.version();
232
- let result = (0, utils_1.compareVersions)(version, WsClient._minVersion);
234
+ this._version = await this.version();
235
+ let result = (0, utils_1.compareVersions)(this._version, WsClient._minVersion);
233
236
  if (result < 0) {
234
- log_1.default.error(`TDengine version is too low, current version: ${version}, minimum required version: ${WsClient._minVersion}`);
237
+ log_1.default.error(`TDengine version is too low, current version: ${this._version}, minimum required version: ${WsClient._minVersion}`);
235
238
  throw (new wsError_1.WebSocketQueryError(wsError_1.ErrorCode.ERR_TDENIGNE_VERSION_IS_TOO_LOW, `Version mismatch. The minimum required TDengine version is ${WsClient._minVersion}`));
236
239
  }
237
240
  }
@@ -6,7 +6,8 @@ export declare class WSConfig {
6
6
  private _timeout;
7
7
  private _token;
8
8
  private _timezone;
9
- constructor(url: string);
9
+ private _minStmt2Version;
10
+ constructor(url: string, minStmt2Version?: string);
10
11
  getToken(): string | undefined | null;
11
12
  setToken(token: string): void;
12
13
  getUser(): string | undefined | null;
@@ -21,5 +22,6 @@ export declare class WSConfig {
21
22
  getTimeOut(): number | undefined | null;
22
23
  setTimezone(timezone: string): void;
23
24
  getTimezone(): string | undefined | null;
25
+ getMinStmt2Version(): string;
24
26
  }
25
27
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/common/config.ts"],"names":[],"mappings":"AAAA,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,CAA0B;IAC1C,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,SAAS,CAA2B;gBAEhC,GAAG,EAAC,MAAM;IAIf,QAAQ,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAGrC,QAAQ,CAAC,KAAK,EAAE,MAAM;IAItB,OAAO,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAGpC,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,MAAM,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAGnC,MAAM,CAAC,GAAG,EAAC,MAAM;IAIjB,KAAK,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;IAGlC,KAAK,CAAC,EAAE,EAAE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G,IAAI;IAGxC,kBAAkB;CAG5B"}
@@ -1,9 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WSConfig = void 0;
4
+ const constant_1 = require("./constant");
4
5
  class WSConfig {
5
- constructor(url) {
6
+ constructor(url, minStmt2Version) {
6
7
  this._url = url;
8
+ if (!minStmt2Version) {
9
+ this._minStmt2Version = constant_1.MinStmt2Version;
10
+ }
11
+ else {
12
+ this._minStmt2Version = minStmt2Version;
13
+ }
7
14
  }
8
15
  getToken() {
9
16
  return this._token;
@@ -47,5 +54,8 @@ class WSConfig {
47
54
  getTimezone() {
48
55
  return this._timezone;
49
56
  }
57
+ getMinStmt2Version() {
58
+ return this._minStmt2Version;
59
+ }
50
60
  }
51
61
  exports.WSConfig = WSConfig;
@@ -4,8 +4,12 @@ export interface IndexableString {
4
4
  export interface StringIndexable {
5
5
  [index: string]: number;
6
6
  }
7
+ export interface NumberIndexable {
8
+ [index: number]: number;
9
+ }
7
10
  export declare const BinaryQueryMessage: bigint;
8
11
  export declare const FetchRawBlockMessage: bigint;
12
+ export declare const MinStmt2Version: string;
9
13
  export declare const TDengineTypeName: IndexableString;
10
14
  export declare const ColumnsBlockType: StringIndexable;
11
15
  export declare enum TDengineTypeCode {
@@ -37,7 +41,13 @@ export declare enum TSDB_OPTION_CONNECTION {
37
41
  TSDB_OPTION_CONNECTION_USER_IP = 2,// user ip
38
42
  TSDB_OPTION_CONNECTION_USER_APP = 3
39
43
  }
44
+ export declare enum FieldBindType {
45
+ TAOS_FIELD_COL = 1,
46
+ TAOS_FIELD_TAG = 2,
47
+ TAOS_FIELD_QUERY = 3,
48
+ TAOS_FIELD_TBNAME = 4
49
+ }
40
50
  export declare const TDenginePrecision: IndexableString;
41
- export declare const TDengineTypeLength: StringIndexable;
51
+ export declare const TDengineTypeLength: NumberIndexable;
42
52
  export declare const PrecisionLength: StringIndexable;
43
53
  //# sourceMappingURL=constant.d.ts.map
@@ -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,CAAA;CAC1B;AAED,MAAM,WAAW,eAAe;IAC5B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAC1B;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAkB,CAAC;AACpD,eAAO,MAAM,oBAAoB,EAAE,MAAkB,CAAC;AAEtD,eAAO,MAAM,gBAAgB,EAAE,eAmB9B,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,eAM9B,CAAA;AAGD,oBAAY,gBAAgB;IACxB,IAAI,IAAI;IACR,IAAI,IAAI;IACR,OAAO,IAAI;IACX,QAAQ,IAAI;IACZ,GAAG,IAAI;IACP,MAAM,IAAI;IACV,KAAK,IAAI;IACT,MAAM,IAAI;IACV,MAAM,IAAI;IACV,OAAO,IAAI;IACX,SAAS,IAAI;IACb,KAAK,KAAK;IACV,gBAAgB,KAAK;IACrB,iBAAiB,KAAK;IACtB,YAAY,KAAK;IACjB,eAAe,KAAK;IACpB,IAAI,KAAK;IACT,SAAS,KAAK;IACd,OAAO,KAAK;IACZ,QAAQ,KAAK;IACb,SAAS,KAAK;CACjB;AAED,oBAAY,sBAAsB;IAChC,8BAA8B,IAAA,CAAS,qDAAqD;IAC5F,+BAA+B,IAAA,CAAQ,sDAAsD;IAC7F,8BAA8B,IAAA,CAAS,UAAU;IACjD,+BAA+B,IAAA;CAChC;AAED,eAAO,MAAM,iBAAiB,EAAE,eAI/B,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,eAahC,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,eAI7B,CAAA"}
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,MA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(exports, "__esModule", { value: true });
3
- exports.PrecisionLength = exports.TDengineTypeLength = exports.TDenginePrecision = exports.TSDB_OPTION_CONNECTION = exports.TDengineTypeCode = exports.ColumnsBlockType = exports.TDengineTypeName = exports.FetchRawBlockMessage = exports.BinaryQueryMessage = void 0;
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;
4
4
  exports.BinaryQueryMessage = BigInt(6);
5
5
  exports.FetchRawBlockMessage = BigInt(7);
6
+ exports.MinStmt2Version = "3.3.6.0";
6
7
  exports.TDengineTypeName = {
7
8
  0: 'NULL',
8
9
  1: 'BOOL',
@@ -61,24 +62,31 @@ var TSDB_OPTION_CONNECTION;
61
62
  TSDB_OPTION_CONNECTION[TSDB_OPTION_CONNECTION["TSDB_OPTION_CONNECTION_USER_IP"] = 2] = "TSDB_OPTION_CONNECTION_USER_IP";
62
63
  TSDB_OPTION_CONNECTION[TSDB_OPTION_CONNECTION["TSDB_OPTION_CONNECTION_USER_APP"] = 3] = "TSDB_OPTION_CONNECTION_USER_APP";
63
64
  })(TSDB_OPTION_CONNECTION || (exports.TSDB_OPTION_CONNECTION = TSDB_OPTION_CONNECTION = {}));
65
+ var FieldBindType;
66
+ (function (FieldBindType) {
67
+ FieldBindType[FieldBindType["TAOS_FIELD_COL"] = 1] = "TAOS_FIELD_COL";
68
+ FieldBindType[FieldBindType["TAOS_FIELD_TAG"] = 2] = "TAOS_FIELD_TAG";
69
+ FieldBindType[FieldBindType["TAOS_FIELD_QUERY"] = 3] = "TAOS_FIELD_QUERY";
70
+ FieldBindType[FieldBindType["TAOS_FIELD_TBNAME"] = 4] = "TAOS_FIELD_TBNAME";
71
+ })(FieldBindType || (exports.FieldBindType = FieldBindType = {}));
64
72
  exports.TDenginePrecision = {
65
73
  0: 'MILLISECOND',
66
74
  1: "MICROSECOND",
67
75
  2: "NANOSECOND",
68
76
  };
69
77
  exports.TDengineTypeLength = {
70
- 'BOOL': 1,
71
- 'TINYINT': 1,
72
- 'SMALLINT': 2,
73
- 'INT': 4,
74
- 'BIGINT': 8,
75
- 'FLOAT': 4,
76
- 'DOUBLE': 8,
77
- 'TIMESTAMP': 8,
78
- 'TINYINT UNSIGNED': 1,
79
- 'SMALLINT UNSIGNED': 2,
80
- 'INT UNSIGNED': 4,
81
- 'BIGINT UNSIGNED': 8,
78
+ [TDengineTypeCode.BOOL]: 1,
79
+ [TDengineTypeCode.TINYINT]: 1,
80
+ [TDengineTypeCode.SMALLINT]: 2,
81
+ [TDengineTypeCode.INT]: 4,
82
+ [TDengineTypeCode.BIGINT]: 8,
83
+ [TDengineTypeCode.FLOAT]: 4,
84
+ [TDengineTypeCode.DOUBLE]: 8,
85
+ [TDengineTypeCode.TIMESTAMP]: 8,
86
+ [TDengineTypeCode.TINYINT_UNSIGNED]: 1,
87
+ [TDengineTypeCode.SMALLINT_UNSIGNED]: 2,
88
+ [TDengineTypeCode.INT_UNSIGNED]: 4,
89
+ [TDengineTypeCode.BIGINT_UNSIGNED]: 8,
82
90
  };
83
91
  exports.PrecisionLength = {
84
92
  'ms': 13,
@@ -1 +1 @@
1
- {"version":3,"file":"wsSql.d.ts","sourceRoot":"","sources":["../../../src/sql/wsSql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAc,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAG7D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAG3C,OAAO,EAAE,SAAS,EAAyB,eAAe,EAAE,MAAM,WAAW,CAAA;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAKvC,qBAAa,KAAK;IACd,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,SAAS,C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O,CAAC,KAAK,CAAC;IAgCnD,KAAK;IAIL;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAI1B,KAAK,IAAG,OAAO,CAAC,IAAI,CAAC;IAIrB,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BnI,QAAQ,CAAC,KAAK,CAAC,EAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA4BxC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,GAAC,MAAuB,GAAG,OAAO,CAAC,UAAU,CAAC;YA4C9E,uBAAuB;IAa/B,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAW3D"}
@@ -10,10 +10,11 @@ const wsClient_1 = require("../client/wsClient");
10
10
  const wsError_1 = require("../common/wsError");
11
11
  const utils_1 = require("../common/utils");
12
12
  const wsResponse_1 = require("../client/wsResponse");
13
- const wsStmt_1 = require("../stmt/wsStmt");
14
13
  const reqid_1 = require("../common/reqid");
15
14
  const constant_1 = require("../common/constant");
16
15
  const log_1 = __importDefault(require("../common/log"));
16
+ const wsStmt1_1 = require("../stmt/wsStmt1");
17
+ const wsStmt2_1 = require("../stmt/wsStmt2");
17
18
  class WsSql {
18
19
  constructor(wsConfig) {
19
20
  let url = (0, utils_1.getUrl)(wsConfig);
@@ -99,7 +100,12 @@ class WsSql {
99
100
  precision = constant_1.PrecisionLength[data[0][0]];
100
101
  }
101
102
  }
102
- return await wsStmt_1.WsStmt.newStmt(this._wsClient, precision, reqId);
103
+ let version = await this.version();
104
+ let result = (0, utils_1.compareVersions)(version, this.wsConfig.getMinStmt2Version());
105
+ if (result < 0) {
106
+ return await wsStmt1_1.WsStmt1.newStmt(this._wsClient, precision, reqId);
107
+ }
108
+ return await wsStmt2_1.WsStmt2.newStmt(this._wsClient, precision, reqId);
103
109
  }
104
110
  catch (e) {
105
111
  log_1.default.error(`stmtInit failed, code: ${e.code}, message: ${e.message}`);
@@ -0,0 +1,9 @@
1
+ export declare class FieldBindParams {
2
+ params: any[];
3
+ dataType: string;
4
+ typeLen: number;
5
+ columnType: number;
6
+ bindType: number;
7
+ constructor(params: any[], dataType: string, typeLen: number, columnType: number, bindType: number);
8
+ }
9
+ //# sourceMappingURL=FieldBindParams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldBindParams.d.ts","sourceRoot":"","sources":["../../../src/stmt/FieldBindParams.ts"],"names":[],"mappings":"AACA,qBAAa,eAAe;IACxB,MAAM,EAAE,GAAG,EAAE,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;gBACL,MAAM,EAAC,GAAG,EAAE,EAAE,QAAQ,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM;CAOhG"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldBindParams = void 0;
4
+ class FieldBindParams {
5
+ constructor(params, dataType, typeLen, columnType, bindType) {
6
+ this.params = [...params];
7
+ this.dataType = dataType;
8
+ this.typeLen = typeLen;
9
+ this.columnType = columnType;
10
+ this.bindType = bindType;
11
+ }
12
+ }
13
+ exports.FieldBindParams = FieldBindParams;
@@ -0,0 +1,12 @@
1
+ export declare class ColumnInfo {
2
+ data: ArrayBuffer;
3
+ length: number;
4
+ type: number;
5
+ typeLen: number;
6
+ isNull?: number[];
7
+ _rows: number;
8
+ _haveLength: number;
9
+ _dataLengths?: number[];
10
+ constructor([length, data]: [number, ArrayBuffer], type: number, typeLen: number, rows: number, isNull?: number[], dataLengths?: number[], haveLength?: number);
11
+ }
12
+ //# sourceMappingURL=wsColumnInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wsColumnInfo.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsColumnInfo.ts"],"names":[],"mappings":"AACA,qBAAa,UAAU;IACnB,IAAI,EAAC,WAAW,CAAC;IACjB,MAAM,EAAC,MAAM,CAAC;IACd,IAAI,EAAC,MAAM,CAAC;IACZ,OAAO,EAAC,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAK;IACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;gBACZ,CAAC,MAAM,EAAC,IAAI,CAAC,EAAC,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,IAAI,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,EACrF,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,UAAU,GAAE,MAAU;CAWxE"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ColumnInfo = void 0;
4
+ class ColumnInfo {
5
+ constructor([length, data], type, typeLen, rows, isNull, dataLengths, haveLength = 0) {
6
+ this._haveLength = 0;
7
+ this.data = data;
8
+ this.type = type;
9
+ this.length = length;
10
+ this.typeLen = typeLen;
11
+ this._rows = rows;
12
+ this.isNull = isNull;
13
+ this._dataLengths = dataLengths;
14
+ this._haveLength = haveLength;
15
+ }
16
+ }
17
+ exports.ColumnInfo = ColumnInfo;
@@ -0,0 +1,14 @@
1
+ import { IDataEncoder, StmtBindParams } from "./wsParamsBase";
2
+ export declare class Stmt1BindParams extends StmtBindParams implements IDataEncoder {
3
+ constructor(precision?: number);
4
+ encode(): void;
5
+ mergeParams(bindParams: StmtBindParams): void;
6
+ addParams(params: any[], dataType: string, typeLen: number, columnType: number): void;
7
+ setTimestamp(params: any[]): void;
8
+ private encodeDigitColumns;
9
+ private encodeVarLengthColumn;
10
+ private getBinaryColumnArrayBuffer;
11
+ private encodeNcharColumn;
12
+ private countBigintDigits;
13
+ }
14
+ //# sourceMappingURL=wsParams1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wsParams1.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsParams1.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE9D,qBAAa,eAAgB,SAAQ,cAAe,YAAW,YAAY;gBAC3D,SAAS,CAAC,EAAC,MAAM;IAI7B,MAAM,IAAI,IAAI;IAId,WAAW,CAAC,UAAU,EAAE,cAAc,GAAG,IAAI;IAI7C,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAgBrF,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE;IAwE1B,OAAO,CAAC,kBAAkB;IA2B1B,OAAO,CAAC,qBAAqB;IAiD7B,OAAO,CAAC,0BAA0B;IAyBlC,OAAO,CAAC,iBAAiB;IAuDzB,OAAO,CAAC,iBAAiB;CAa5B"}
@@ -0,0 +1,274 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Stmt1BindParams = void 0;
4
+ const constant_1 = require("../common/constant");
5
+ const wsError_1 = require("../common/wsError");
6
+ const taosResult_1 = require("../common/taosResult");
7
+ const utils_1 = require("../common/utils");
8
+ const wsColumnInfo_1 = require("./wsColumnInfo");
9
+ const wsParamsBase_1 = require("./wsParamsBase");
10
+ class Stmt1BindParams extends wsParamsBase_1.StmtBindParams {
11
+ constructor(precision) {
12
+ super(precision);
13
+ }
14
+ encode() {
15
+ return;
16
+ }
17
+ mergeParams(bindParams) {
18
+ return;
19
+ }
20
+ addParams(params, dataType, typeLen, columnType) {
21
+ if (!params || params.length == 0) {
22
+ throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "StmtBindParams params is invalid!");
23
+ }
24
+ if (dataType === "number" || dataType === "bigint" || dataType === "boolean") {
25
+ this._params.push(this.encodeDigitColumns(params, dataType, typeLen, columnType));
26
+ }
27
+ else {
28
+ if (columnType === constant_1.TDengineTypeCode.NCHAR) {
29
+ this._params.push(this.encodeNcharColumn(params));
30
+ }
31
+ else {
32
+ this._params.push(this.encodeVarLengthColumn(params, columnType));
33
+ }
34
+ }
35
+ }
36
+ setTimestamp(params) {
37
+ if (!params || params.length == 0) {
38
+ throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SeTimestampColumn params is invalid!");
39
+ }
40
+ //computing bitmap length
41
+ let bitMapLen = (0, taosResult_1.bitmapLen)(params.length);
42
+ //Computing the length of data
43
+ let arrayBuffer = new ArrayBuffer(bitMapLen + constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.TIMESTAMP] * params.length);
44
+ //bitmap get data range
45
+ let bitmapBuffer = new DataView(arrayBuffer);
46
+ //skip bitmap get data range
47
+ let dataBuffer = new DataView(arrayBuffer, bitMapLen);
48
+ if (this._rows > 0) {
49
+ if (this._rows !== params.length) {
50
+ throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "wrong row length!");
51
+ }
52
+ }
53
+ else {
54
+ this._rows = params.length;
55
+ }
56
+ for (let i = 0; i < params.length; i++) {
57
+ if (!(0, utils_1.isEmpty)(params[i])) {
58
+ if (params[i] instanceof Date) {
59
+ let date = params[i];
60
+ //node only support milliseconds, need fill 0
61
+ if (this.precisionLength == constant_1.PrecisionLength['us']) {
62
+ let ms = date.getTime() * 1000;
63
+ dataBuffer.setBigInt64(i * 8, BigInt(ms), true);
64
+ }
65
+ else if (this.precisionLength == constant_1.PrecisionLength['ns']) {
66
+ let ns = date.getTime() * 1000 * 1000;
67
+ dataBuffer.setBigInt64(i * 8, BigInt(ns), true);
68
+ }
69
+ else {
70
+ dataBuffer.setBigInt64(i * 8, BigInt(date.getTime()), true);
71
+ }
72
+ }
73
+ else if (typeof params[i] == 'bigint' || typeof params[i] == 'number') {
74
+ let data;
75
+ if (typeof params[i] == 'number') {
76
+ data = BigInt(params[i]);
77
+ }
78
+ else {
79
+ data = params[i];
80
+ }
81
+ //statistical bits of digit
82
+ let digit = this.countBigintDigits(data);
83
+ //check digit same table Precision
84
+ if (this.precisionLength == constant_1.PrecisionLength['ns']) {
85
+ if (this.precisionLength <= digit) {
86
+ dataBuffer.setBigInt64(i * 8, data, true);
87
+ }
88
+ else {
89
+ throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SeTimestampColumn params precisionLength is invalid! param:=" + params[i]);
90
+ }
91
+ }
92
+ else if (this.precisionLength == digit) {
93
+ dataBuffer.setBigInt64(i * 8, data, true);
94
+ }
95
+ else {
96
+ throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SeTimestampColumn params is invalid! param:=" + params[i]);
97
+ }
98
+ }
99
+ }
100
+ else {
101
+ //set bitmap bit is null
102
+ let charOffset = (0, taosResult_1.getCharOffset)(i);
103
+ let nullVal = (0, taosResult_1.setBitmapNull)(dataBuffer.getInt8(charOffset), i);
104
+ bitmapBuffer.setInt8(charOffset, nullVal);
105
+ }
106
+ }
107
+ this._dataTotalLen += arrayBuffer.byteLength;
108
+ this._params.push(new wsColumnInfo_1.ColumnInfo([constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.TIMESTAMP] * params.length, arrayBuffer], constant_1.TDengineTypeCode.TIMESTAMP, constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.TIMESTAMP], this._rows));
109
+ }
110
+ encodeDigitColumns(params, dataType = 'number', typeLen, columnType) {
111
+ let bitMapLen = (0, taosResult_1.bitmapLen)(params.length);
112
+ let arrayBuffer = new ArrayBuffer(typeLen * params.length + bitMapLen);
113
+ let bitmapBuffer = new DataView(arrayBuffer);
114
+ let dataBuffer = new DataView(arrayBuffer, bitMapLen);
115
+ if (this._rows > 0) {
116
+ if (this._rows !== params.length) {
117
+ throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "wrong row length!");
118
+ }
119
+ }
120
+ else {
121
+ this._rows = params.length;
122
+ }
123
+ for (let i = 0; i < params.length; i++) {
124
+ if (!(0, utils_1.isEmpty)(params[i])) {
125
+ this.writeDataToBuffer(dataBuffer, params[i], dataType, typeLen, columnType, i);
126
+ }
127
+ else {
128
+ //set bitmap bit is null
129
+ let charOffset = (0, taosResult_1.getCharOffset)(i);
130
+ let nullVal = (0, taosResult_1.setBitmapNull)(bitmapBuffer.getUint8(charOffset), i);
131
+ bitmapBuffer.setInt8(charOffset, nullVal);
132
+ }
133
+ }
134
+ this._dataTotalLen += dataBuffer.buffer.byteLength;
135
+ return new wsColumnInfo_1.ColumnInfo([typeLen * params.length, dataBuffer.buffer], columnType, typeLen, this._rows);
136
+ }
137
+ encodeVarLengthColumn(params, columnType) {
138
+ let data = [];
139
+ let dataLength = 0;
140
+ //create params length buffer
141
+ let paramsLenBuffer = new ArrayBuffer(constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.INT] * params.length);
142
+ let paramsLenView = new DataView(paramsLenBuffer);
143
+ if (this._rows > 0) {
144
+ if (this._rows !== params.length) {
145
+ throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "wrong row length!");
146
+ }
147
+ }
148
+ else {
149
+ this._rows = params.length;
150
+ }
151
+ for (let i = 0; i < params.length; i++) {
152
+ //get param length offset 4byte
153
+ let offset = constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.INT] * i;
154
+ if (!(0, utils_1.isEmpty)(params[i])) {
155
+ //save param length offset 4byte
156
+ paramsLenView.setInt32(offset, dataLength, true);
157
+ if (typeof params[i] == 'string') {
158
+ //string TextEncoder
159
+ let encode = new TextEncoder();
160
+ let value = encode.encode(params[i]).buffer;
161
+ data.push(value);
162
+ //add offset length
163
+ dataLength += value.byteLength + constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.SMALLINT];
164
+ }
165
+ else if (params[i] instanceof ArrayBuffer) {
166
+ //input arraybuffer, save not need encode
167
+ let value = params[i];
168
+ dataLength += value.byteLength + constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.SMALLINT];
169
+ data.push(value);
170
+ }
171
+ else {
172
+ throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "getColumString params is invalid! param_type:=" + typeof params[i]);
173
+ }
174
+ }
175
+ else {
176
+ //set length -1, param is null
177
+ for (let j = 0; j < constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.INT]; j++) {
178
+ paramsLenView.setInt8(offset + j, 255);
179
+ }
180
+ }
181
+ }
182
+ this._dataTotalLen += paramsLenBuffer.byteLength + dataLength;
183
+ return new wsColumnInfo_1.ColumnInfo([dataLength, this.getBinaryColumnArrayBuffer(data, paramsLenView.buffer, dataLength)], columnType, 0, this._rows);
184
+ }
185
+ //splicing encode params to arraybuffer
186
+ getBinaryColumnArrayBuffer(data, paramsLenBuffer, dataLength) {
187
+ //create arraybuffer
188
+ let paramsBuffer = new ArrayBuffer(paramsLenBuffer.byteLength + dataLength);
189
+ //get length data range
190
+ const paramsUint8 = new Uint8Array(paramsBuffer);
191
+ const paramsLenView = new Uint8Array(paramsLenBuffer);
192
+ paramsUint8.set(paramsLenView, 0);
193
+ //get data range
194
+ const paramsView = new DataView(paramsBuffer, paramsLenBuffer.byteLength);
195
+ let offset = 0;
196
+ for (let i = 0; i < data.length; i++) {
197
+ //save param field length
198
+ paramsView.setInt16(offset, data[i].byteLength, true);
199
+ const dataView = new DataView(data[i]);
200
+ //save data
201
+ for (let j = 0; j < data[i].byteLength; j++) {
202
+ paramsView.setUint8(offset + 2 + j, dataView.getUint8(j));
203
+ }
204
+ offset += data[i].byteLength + 2;
205
+ }
206
+ return paramsBuffer;
207
+ }
208
+ //encode nchar type params
209
+ encodeNcharColumn(params) {
210
+ let data = [];
211
+ let dataLength = 0;
212
+ let indexBuffer = new ArrayBuffer(constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.INT] * params.length);
213
+ let indexView = new DataView(indexBuffer);
214
+ if (this._rows > 0) {
215
+ if (this._rows !== params.length) {
216
+ throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "wrong row length!");
217
+ }
218
+ }
219
+ else {
220
+ this._rows = params.length;
221
+ }
222
+ for (let i = 0; i < params.length; i++) {
223
+ let offset = constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.INT] * i;
224
+ if (!(0, utils_1.isEmpty)(params[i])) {
225
+ indexView.setInt32(offset, dataLength, true);
226
+ if (typeof params[i] == 'string') {
227
+ let codes = [];
228
+ let strNcharParams = params[i];
229
+ for (let j = 0; j < params[i].length; j++) {
230
+ //get char, cn char need 3~4 byte
231
+ codes.push(strNcharParams.charCodeAt(j));
232
+ }
233
+ let ncharBuffer = new ArrayBuffer(codes.length * 4);
234
+ let ncharView = new DataView(ncharBuffer);
235
+ for (let j = 0; j < codes.length; j++) {
236
+ //1char, save into uint32
237
+ ncharView.setUint32(j * 4, codes[j], true);
238
+ }
239
+ data.push(ncharBuffer);
240
+ dataLength += codes.length * 4 + constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.SMALLINT];
241
+ }
242
+ else if (params[i] instanceof ArrayBuffer) {
243
+ let value = params[i];
244
+ dataLength += value.byteLength + constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.SMALLINT];
245
+ data.push(value);
246
+ }
247
+ else {
248
+ throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "getColumString params is invalid! param_type:=" + typeof params[i]);
249
+ }
250
+ }
251
+ else {
252
+ //set length -1, param is null
253
+ for (let j = 0; j < constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.INT]; j++) {
254
+ indexView.setInt8(offset + j, 255);
255
+ }
256
+ }
257
+ }
258
+ this._dataTotalLen += indexBuffer.byteLength + dataLength;
259
+ return new wsColumnInfo_1.ColumnInfo([dataLength, this.getBinaryColumnArrayBuffer(data, indexView.buffer, dataLength)], constant_1.TDengineTypeCode.NCHAR, 0, this._rows);
260
+ }
261
+ countBigintDigits(numeral) {
262
+ if (numeral === 0n) {
263
+ return 1;
264
+ }
265
+ let count = 0;
266
+ let temp = numeral;
267
+ while (temp !== 0n) {
268
+ temp /= 10n;
269
+ count++;
270
+ }
271
+ return count;
272
+ }
273
+ }
274
+ exports.Stmt1BindParams = Stmt1BindParams;
@@ -0,0 +1,14 @@
1
+ import { IDataEncoder, StmtBindParams } from "./wsParamsBase";
2
+ import { StmtFieldInfo } from "./wsProto";
3
+ export declare class Stmt2BindParams extends StmtBindParams implements IDataEncoder {
4
+ private _fields;
5
+ protected paramIndex: number;
6
+ constructor(paramsCount?: number, precision?: number, fields?: Array<StmtFieldInfo>);
7
+ addParams(params: any[], dataType: string, typeLen: number, columnType: number): void;
8
+ mergeParams(bindParams: StmtBindParams): void;
9
+ encode(): void;
10
+ private encodeVarColumns;
11
+ private encodeDigitColumns;
12
+ private encodeTimestampColumn;
13
+ }
14
+ //# sourceMappingURL=wsParams2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wsParams2.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsParams2.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAI9D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,eAAgB,SAAQ,cAAe,YAAW,YAAY;IACvE,OAAO,CAAC,OAAO,CAAuB;IACtC,SAAS,CAAC,UAAU,EAAC,MAAM,CAAK;gBACpB,WAAW,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAKlF,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IA4BrF,WAAW,CAAC,UAAU,EAAE,cAAc,GAAG,IAAI;IAa7C,MAAM,IAAI,IAAI;IAgCd,OAAO,CAAC,gBAAgB;IAmCxB,OAAO,CAAC,kBAAkB;IAyB1B,OAAO,CAAC,qBAAqB;CAgChC"}