@tdengine/websocket 3.0.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/example/all_type_query.d.ts +2 -0
- package/lib/example/all_type_query.d.ts.map +1 -0
- package/lib/example/all_type_query.js +89 -0
- package/lib/example/all_type_stmt.d.ts +2 -0
- package/lib/example/all_type_stmt.d.ts.map +1 -0
- package/lib/example/all_type_stmt.js +130 -0
- package/lib/example/basicBatchTmq.d.ts +2 -0
- package/lib/example/basicBatchTmq.d.ts.map +1 -0
- package/lib/example/basicBatchTmq.js +129 -0
- package/lib/example/basicSchemaless.d.ts +2 -0
- package/lib/example/basicSchemaless.d.ts.map +1 -0
- package/lib/example/basicSchemaless.js +47 -0
- package/lib/example/basicSql.d.ts +2 -0
- package/lib/example/basicSql.d.ts.map +1 -0
- package/lib/example/basicSql.js +54 -0
- package/lib/example/basicStmt.d.ts +2 -0
- package/lib/example/basicStmt.d.ts.map +1 -0
- package/lib/example/basicStmt.js +72 -0
- package/lib/example/basicTmq.d.ts +2 -0
- package/lib/example/basicTmq.d.ts.map +1 -0
- package/lib/example/basicTmq.js +73 -0
- package/lib/index.d.ts +26 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +41 -0
- package/lib/src/client/wsClient.d.ts +22 -0
- package/lib/src/client/wsClient.d.ts.map +1 -0
- package/lib/src/client/wsClient.js +256 -0
- package/lib/src/client/wsConnector.d.ts +17 -0
- package/lib/src/client/wsConnector.d.ts.map +1 -0
- package/lib/src/client/wsConnector.js +140 -0
- package/lib/src/client/wsConnectorPool.d.ts +13 -0
- package/lib/src/client/wsConnectorPool.d.ts.map +1 -0
- package/lib/src/client/wsConnectorPool.js +107 -0
- package/lib/src/client/wsEventCallback.d.ts +22 -0
- package/lib/src/client/wsEventCallback.d.ts.map +1 -0
- package/lib/src/client/wsEventCallback.js +97 -0
- package/lib/src/client/wsResponse.d.ts +74 -0
- package/lib/src/client/wsResponse.d.ts.map +1 -0
- package/lib/src/client/wsResponse.js +103 -0
- package/lib/src/common/config.d.ts +22 -0
- package/lib/src/common/config.d.ts.map +1 -0
- package/lib/src/common/config.js +45 -0
- package/lib/src/common/constant.d.ts +35 -0
- package/lib/src/common/constant.d.ts.map +1 -0
- package/lib/src/common/constant.js +78 -0
- package/lib/src/common/log.d.ts +5 -0
- package/lib/src/common/log.d.ts.map +1 -0
- package/lib/src/common/log.js +40 -0
- package/lib/src/common/reqid.d.ts +8 -0
- package/lib/src/common/reqid.d.ts.map +1 -0
- package/lib/src/common/reqid.js +59 -0
- package/lib/src/common/taosResult.d.ts +57 -0
- package/lib/src/common/taosResult.d.ts.map +1 -0
- package/lib/src/common/taosResult.js +449 -0
- package/lib/src/common/ut8Helper.d.ts +2 -0
- package/lib/src/common/ut8Helper.d.ts.map +1 -0
- package/{src/ut8Helper.ts → lib/src/common/ut8Helper.js} +22 -21
- package/lib/src/common/utils.d.ts +7 -0
- package/lib/src/common/utils.d.ts.map +1 -0
- package/lib/src/common/utils.js +66 -0
- package/lib/src/common/wsError.d.ts +29 -0
- package/lib/src/common/wsError.d.ts.map +1 -0
- package/lib/src/common/wsError.js +51 -0
- package/{src/wsOptions.ts → lib/src/common/wsOptions.d.ts} +4 -2
- package/lib/src/common/wsOptions.d.ts.map +1 -0
- package/lib/src/common/wsOptions.js +2 -0
- package/lib/src/index.d.ts +9 -0
- package/lib/src/index.d.ts.map +1 -0
- package/lib/src/index.js +58 -0
- package/lib/src/sql/wsProto.d.ts +26 -0
- package/lib/src/sql/wsProto.d.ts.map +1 -0
- package/lib/src/sql/wsProto.js +19 -0
- package/lib/src/sql/wsRows.d.ts +16 -0
- package/lib/src/sql/wsRows.d.ts.map +1 -0
- package/lib/src/sql/wsRows.js +87 -0
- package/lib/src/sql/wsSql.d.ts +24 -0
- package/lib/src/sql/wsSql.d.ts.map +1 -0
- package/lib/src/sql/wsSql.js +174 -0
- package/lib/src/stmt/wsParams.d.ts +41 -0
- package/lib/src/stmt/wsParams.d.ts.map +1 -0
- package/lib/src/stmt/wsParams.js +428 -0
- package/lib/src/stmt/wsProto.d.ts +27 -0
- package/lib/src/stmt/wsProto.d.ts.map +1 -0
- package/lib/src/stmt/wsProto.js +67 -0
- package/lib/src/stmt/wsStmt.d.ts +30 -0
- package/lib/src/stmt/wsStmt.d.ts.map +1 -0
- package/lib/src/stmt/wsStmt.js +207 -0
- package/lib/src/tmq/config.d.ts +14 -0
- package/lib/src/tmq/config.d.ts.map +1 -0
- package/lib/src/tmq/config.js +42 -0
- package/lib/src/tmq/constant.d.ts +100 -0
- package/lib/src/tmq/constant.d.ts.map +1 -0
- package/lib/src/tmq/constant.js +105 -0
- package/lib/src/tmq/tmqResponse.d.ts +92 -0
- package/lib/src/tmq/tmqResponse.d.ts.map +1 -0
- package/lib/src/tmq/tmqResponse.js +329 -0
- package/lib/src/tmq/wsTmq.d.ts +32 -0
- package/lib/src/tmq/wsTmq.d.ts.map +1 -0
- package/lib/src/tmq/wsTmq.js +319 -0
- package/lib/test/bulkPulling/log.test.d.ts +2 -0
- package/lib/test/bulkPulling/log.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/log.test.js +44 -0
- package/lib/test/bulkPulling/queryTables.test.d.ts +2 -0
- package/lib/test/bulkPulling/queryTables.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/queryTables.test.js +297 -0
- package/lib/test/bulkPulling/schemaless.test.d.ts +2 -0
- package/lib/test/bulkPulling/schemaless.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/schemaless.test.js +95 -0
- package/lib/test/bulkPulling/sql.test.d.ts +2 -0
- package/lib/test/bulkPulling/sql.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/sql.test.js +144 -0
- package/lib/test/bulkPulling/stmt.func.test.d.ts +2 -0
- package/lib/test/bulkPulling/stmt.func.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/stmt.func.test.js +397 -0
- package/lib/test/bulkPulling/stmt.type.test.d.ts +2 -0
- package/lib/test/bulkPulling/stmt.type.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/stmt.type.test.js +269 -0
- package/lib/test/bulkPulling/tmq.test.d.ts +2 -0
- package/lib/test/bulkPulling/tmq.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/tmq.test.js +178 -0
- package/lib/test/bulkPulling/wsConnectPool.test.d.ts +2 -0
- package/lib/test/bulkPulling/wsConnectPool.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/wsConnectPool.test.js +136 -0
- package/lib/test/utils.d.ts +18 -0
- package/lib/test/utils.d.ts.map +1 -0
- package/lib/test/utils.js +318 -0
- package/package.json +27 -14
- package/readme.md +302 -0
- package/README.md +0 -59
- package/dist/browser/index.js +0 -778
- package/dist/main/index.js +0 -711
- package/dist/main/index.js.map +0 -1
- package/dist/module/index.mjs +0 -704
- package/dist/module/index.mjs.map +0 -1
- package/dist/types.d.ts +0 -103
- package/dist/types.d.ts.map +0 -1
- package/example/basicUsageAsync.ts +0 -48
- package/example/basicUsagePrimse.ts +0 -43
- package/example/cloudUsage.ts +0 -55
- package/example/continousConnectAndVersion.ts +0 -16
- package/example/test.mjs +0 -51
- package/index.ts +0 -7
- package/jest.config.js +0 -8
- package/src/constant.ts +0 -74
- package/src/taosResult.ts +0 -269
- package/src/tdengineWebsocket.ts +0 -39
- package/src/wsClient.ts +0 -196
- package/src/wsError.ts +0 -5
- package/src/wsQuery.ts +0 -30
- package/src/wsQueryInterface.ts +0 -212
- package/src/wsQueryResponse.ts +0 -112
- package/tdengine-websocket-3.0.0.tgz +0 -0
- package/test/bulkPulling/connect.test.ts +0 -27
- package/test/bulkPulling/queryTables.test.ts +0 -274
- package/test/bulkPulling/version.test.ts +0 -19
- package/test/utils.ts +0 -235
- package/tsconfig.json +0 -101
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wsEventCallback.d.ts","sourceRoot":"","sources":["../../../src/client/wsEventCallback.ts"],"names":[],"mappings":"AAKA,UAAU,SAAS;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAC,MAAM,CAAA;CAClB;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,CAAiB;IAC1C,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAA4C;IAC7E,OAAO;WAGO,QAAQ,IAAG,eAAe;IAOlC,gBAAgB,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI;IAgBxF,mBAAmB,CAAC,GAAG,EAAE,SAAS,EAAE,WAAW,EAAC,aAAa,EAAE,IAAI,EAAC,GAAG;CAqDhF"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WsEventCallback = exports.OnMessageType = void 0;
|
|
7
|
+
const async_mutex_1 = require("async-mutex");
|
|
8
|
+
const wsError_1 = require("../common/wsError");
|
|
9
|
+
const log_1 = __importDefault(require("../common/log"));
|
|
10
|
+
var OnMessageType;
|
|
11
|
+
(function (OnMessageType) {
|
|
12
|
+
OnMessageType[OnMessageType["MESSAGE_TYPE_ARRAYBUFFER"] = 1] = "MESSAGE_TYPE_ARRAYBUFFER";
|
|
13
|
+
OnMessageType[OnMessageType["MESSAGE_TYPE_BLOB"] = 2] = "MESSAGE_TYPE_BLOB";
|
|
14
|
+
OnMessageType[OnMessageType["MESSAGE_TYPE_STRING"] = 3] = "MESSAGE_TYPE_STRING";
|
|
15
|
+
OnMessageType[OnMessageType["MESSAGE_TYPE_CONNECTION"] = 4] = "MESSAGE_TYPE_CONNECTION";
|
|
16
|
+
})(OnMessageType || (exports.OnMessageType = OnMessageType = {}));
|
|
17
|
+
const eventMutex = new async_mutex_1.Mutex();
|
|
18
|
+
class WsEventCallback {
|
|
19
|
+
constructor() {
|
|
20
|
+
}
|
|
21
|
+
static instance() {
|
|
22
|
+
if (!WsEventCallback._instance) {
|
|
23
|
+
WsEventCallback._instance = new WsEventCallback();
|
|
24
|
+
}
|
|
25
|
+
return WsEventCallback._instance;
|
|
26
|
+
}
|
|
27
|
+
async registerCallback(id, res, rej) {
|
|
28
|
+
let release = await eventMutex.acquire();
|
|
29
|
+
try {
|
|
30
|
+
WsEventCallback._msgActionRegister.set(id, {
|
|
31
|
+
sendTime: new Date().getTime(),
|
|
32
|
+
reject: rej,
|
|
33
|
+
resolve: res,
|
|
34
|
+
timer: setTimeout(() => rej(new wsError_1.WebSocketQueryError(wsError_1.ErrorCode.ERR_WEBSOCKET_QUERY_TIMEOUT, `action:${id.action},req_id:${id.req_id} timeout with ${id.timeout} milliseconds`)), id.timeout)
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
release();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async handleEventCallback(msg, messageType, data) {
|
|
42
|
+
let action = undefined;
|
|
43
|
+
log_1.default.debug("HandleEventCallback msg=", msg, messageType);
|
|
44
|
+
let release = await eventMutex.acquire();
|
|
45
|
+
log_1.default.debug("HandleEventCallback get lock msg=", msg, messageType);
|
|
46
|
+
log_1.default.debug(WsEventCallback._msgActionRegister);
|
|
47
|
+
try {
|
|
48
|
+
for (let [k, v] of WsEventCallback._msgActionRegister) {
|
|
49
|
+
if (messageType == OnMessageType.MESSAGE_TYPE_ARRAYBUFFER) {
|
|
50
|
+
if (k.id == msg.id || k.req_id == msg.id) {
|
|
51
|
+
action = v;
|
|
52
|
+
WsEventCallback._msgActionRegister.delete(k);
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (messageType == OnMessageType.MESSAGE_TYPE_BLOB) {
|
|
57
|
+
if (k.id == msg.id || k.req_id == msg.id) {
|
|
58
|
+
action = v;
|
|
59
|
+
WsEventCallback._msgActionRegister.delete(k);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else if (messageType == OnMessageType.MESSAGE_TYPE_STRING) {
|
|
64
|
+
if (k.req_id == msg.req_id && k.action == msg.action) {
|
|
65
|
+
action = v;
|
|
66
|
+
WsEventCallback._msgActionRegister.delete(k);
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else if (messageType == OnMessageType.MESSAGE_TYPE_CONNECTION) {
|
|
71
|
+
if (k.req_id == msg.req_id && k.action == msg.action) {
|
|
72
|
+
action = v;
|
|
73
|
+
WsEventCallback._msgActionRegister.delete(k);
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
release();
|
|
81
|
+
}
|
|
82
|
+
if (action) {
|
|
83
|
+
let currTime = new Date().getTime();
|
|
84
|
+
let resp = {
|
|
85
|
+
msg: data,
|
|
86
|
+
totalTime: Math.abs(currTime - action.sendTime),
|
|
87
|
+
};
|
|
88
|
+
action.resolve(resp);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
log_1.default.error("no find callback msg:=", msg);
|
|
92
|
+
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_WS_NO_CALLBACK, "no callback registered for fetch_block with req_id=" + msg.req_id + " action" + msg.action);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.WsEventCallback = WsEventCallback;
|
|
97
|
+
WsEventCallback._msgActionRegister = new Map();
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* define ws Response type|class, for query?
|
|
3
|
+
*/
|
|
4
|
+
import { MessageResp } from "../common/taosResult";
|
|
5
|
+
export declare class WSVersionResponse {
|
|
6
|
+
version: string;
|
|
7
|
+
code: number;
|
|
8
|
+
message: string;
|
|
9
|
+
action: string;
|
|
10
|
+
totalTime: number;
|
|
11
|
+
constructor(resp: MessageResp);
|
|
12
|
+
}
|
|
13
|
+
export declare class WSQueryResponse {
|
|
14
|
+
code?: number;
|
|
15
|
+
message?: string;
|
|
16
|
+
action?: string;
|
|
17
|
+
req_id?: number;
|
|
18
|
+
timing?: bigint | null;
|
|
19
|
+
totalTime: number;
|
|
20
|
+
id?: bigint;
|
|
21
|
+
is_update?: boolean;
|
|
22
|
+
affected_rows?: number | null;
|
|
23
|
+
fields_count?: number | null;
|
|
24
|
+
fields_names?: Array<string> | null;
|
|
25
|
+
fields_types?: Array<number> | null;
|
|
26
|
+
fields_lengths?: Array<number> | null;
|
|
27
|
+
precision?: number;
|
|
28
|
+
constructor(resp: MessageResp);
|
|
29
|
+
private initMsg;
|
|
30
|
+
}
|
|
31
|
+
export declare class WSFetchResponse {
|
|
32
|
+
code: number;
|
|
33
|
+
message: string;
|
|
34
|
+
action: string;
|
|
35
|
+
req_id: number;
|
|
36
|
+
timing: bigint;
|
|
37
|
+
id: bigint;
|
|
38
|
+
completed: boolean;
|
|
39
|
+
length: Array<number>;
|
|
40
|
+
rows: number;
|
|
41
|
+
totalTime: number;
|
|
42
|
+
constructor(resp: MessageResp);
|
|
43
|
+
}
|
|
44
|
+
export declare class WSFetchBlockResponse {
|
|
45
|
+
data: DataView | undefined;
|
|
46
|
+
action: bigint;
|
|
47
|
+
timing: bigint;
|
|
48
|
+
reqId: bigint;
|
|
49
|
+
code: number;
|
|
50
|
+
blockLen: number;
|
|
51
|
+
message: string | undefined;
|
|
52
|
+
resultId: bigint | undefined;
|
|
53
|
+
finished: number | undefined;
|
|
54
|
+
metaType: number | undefined;
|
|
55
|
+
textDecoder: TextDecoder;
|
|
56
|
+
constructor(msg: ArrayBuffer);
|
|
57
|
+
}
|
|
58
|
+
interface IWSConnResponse {
|
|
59
|
+
code: number;
|
|
60
|
+
message: string;
|
|
61
|
+
action: string;
|
|
62
|
+
req_id: number;
|
|
63
|
+
timing: bigint;
|
|
64
|
+
}
|
|
65
|
+
export declare class WSConnResponse {
|
|
66
|
+
code: number;
|
|
67
|
+
message: string;
|
|
68
|
+
action: string;
|
|
69
|
+
req_id: number;
|
|
70
|
+
timing: bigint;
|
|
71
|
+
constructor(msg: IWSConnResponse);
|
|
72
|
+
}
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=wsResponse.d.ts.map
|
|
@@ -0,0 +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,EAAC,WAAW;CAO/B;AAED,qBAAa,eAAe;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,GA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IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,cAAc;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;gBAEH,GAAG,EAAE,eAAe;CAOnC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* define ws Response type|class, for query?
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WSConnResponse = exports.WSFetchBlockResponse = exports.WSFetchResponse = exports.WSQueryResponse = exports.WSVersionResponse = void 0;
|
|
7
|
+
const taosResult_1 = require("../common/taosResult");
|
|
8
|
+
class WSVersionResponse {
|
|
9
|
+
constructor(resp) {
|
|
10
|
+
this.version = resp.msg.version;
|
|
11
|
+
this.code = resp.msg.code;
|
|
12
|
+
this.message = resp.msg.message;
|
|
13
|
+
this.action = resp.msg.action;
|
|
14
|
+
this.totalTime = resp.totalTime;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.WSVersionResponse = WSVersionResponse;
|
|
18
|
+
class WSQueryResponse {
|
|
19
|
+
constructor(resp) {
|
|
20
|
+
this.totalTime = resp.totalTime;
|
|
21
|
+
this.initMsg(resp.msg);
|
|
22
|
+
}
|
|
23
|
+
initMsg(msg) {
|
|
24
|
+
this.code = msg.code;
|
|
25
|
+
this.message = msg.message;
|
|
26
|
+
this.action = msg.action;
|
|
27
|
+
this.req_id = msg.req_id;
|
|
28
|
+
this.timing = BigInt(msg.timing);
|
|
29
|
+
if (msg.id) {
|
|
30
|
+
this.id = BigInt(msg.id);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
this.id = BigInt(0);
|
|
34
|
+
}
|
|
35
|
+
this.is_update = msg.is_update;
|
|
36
|
+
this.affected_rows = msg.affected_rows;
|
|
37
|
+
this.fields_count = msg.fields_count;
|
|
38
|
+
this.fields_names = msg.fields_names;
|
|
39
|
+
this.fields_types = msg.fields_types;
|
|
40
|
+
this.fields_lengths = msg.fields_lengths;
|
|
41
|
+
this.precision = msg.precision;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.WSQueryResponse = WSQueryResponse;
|
|
45
|
+
class WSFetchResponse {
|
|
46
|
+
constructor(resp) {
|
|
47
|
+
this.totalTime = resp.totalTime;
|
|
48
|
+
this.code = resp.msg.code;
|
|
49
|
+
this.message = resp.msg.message;
|
|
50
|
+
this.action = resp.msg.action;
|
|
51
|
+
this.req_id = resp.msg.req_id;
|
|
52
|
+
this.timing = BigInt(resp.msg.timing);
|
|
53
|
+
this.id = BigInt(resp.msg.id);
|
|
54
|
+
this.completed = resp.msg.completed;
|
|
55
|
+
this.length = resp.msg.length;
|
|
56
|
+
this.rows = resp.msg.rows;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.WSFetchResponse = WSFetchResponse;
|
|
60
|
+
class WSFetchBlockResponse {
|
|
61
|
+
constructor(msg) {
|
|
62
|
+
let dataView = new DataView(msg);
|
|
63
|
+
this.action = dataView.getBigUint64(8, true);
|
|
64
|
+
this.timing = dataView.getBigUint64(18, true);
|
|
65
|
+
this.reqId = dataView.getBigUint64(26, true);
|
|
66
|
+
this.code = dataView.getUint32(34, true);
|
|
67
|
+
this.textDecoder = new TextDecoder();
|
|
68
|
+
this.blockLen = 0;
|
|
69
|
+
if (this.code != 0) {
|
|
70
|
+
let len = dataView.getUint32(38, true);
|
|
71
|
+
this.message = (0, taosResult_1.readVarchar)(msg, 42, len, this.textDecoder);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.resultId = dataView.getBigUint64(42, true);
|
|
75
|
+
let offset = 50;
|
|
76
|
+
if (this.action == BigInt(8)) {
|
|
77
|
+
this.metaType = dataView.getUint16(50, true);
|
|
78
|
+
offset += 2;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
this.finished = dataView.getUint8(50);
|
|
82
|
+
if (this.finished == 1) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
offset += 1;
|
|
86
|
+
}
|
|
87
|
+
this.blockLen = dataView.getUint32(offset, true);
|
|
88
|
+
if (this.blockLen > 0) {
|
|
89
|
+
this.data = new DataView(msg, offset + 4);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.WSFetchBlockResponse = WSFetchBlockResponse;
|
|
94
|
+
class WSConnResponse {
|
|
95
|
+
constructor(msg) {
|
|
96
|
+
this.code = msg.code;
|
|
97
|
+
this.message = msg.message;
|
|
98
|
+
this.action = msg.action;
|
|
99
|
+
this.req_id = msg.req_id;
|
|
100
|
+
this.timing = BigInt(msg.timing);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.WSConnResponse = WSConnResponse;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare class WSConfig {
|
|
2
|
+
private _user;
|
|
3
|
+
private _password;
|
|
4
|
+
private _db;
|
|
5
|
+
private _url;
|
|
6
|
+
private _timeout;
|
|
7
|
+
private _token;
|
|
8
|
+
constructor(url: string);
|
|
9
|
+
getToken(): string | undefined | null;
|
|
10
|
+
setToken(token: string): void;
|
|
11
|
+
getUser(): string | undefined | null;
|
|
12
|
+
setUser(user: string): void;
|
|
13
|
+
getPwd(): string | undefined | null;
|
|
14
|
+
setPwd(pws: string): void;
|
|
15
|
+
getDb(): string | undefined | null;
|
|
16
|
+
setDb(db: string): void;
|
|
17
|
+
getUrl(): string;
|
|
18
|
+
setUrl(url: string): void;
|
|
19
|
+
setTimeOut(ms: number): void;
|
|
20
|
+
getTimeOut(): number | undefined | null;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +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;gBAE7B,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,MAAM;IAIhB,MAAM,IAAI,MAAM;IAIhB,MAAM,CAAC,GAAG,EAAE,MAAM;IAIlB,UAAU,CAAC,EAAE,EAAG,MAAM;IAGtB,UAAU,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI;CAKjD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WSConfig = void 0;
|
|
4
|
+
class WSConfig {
|
|
5
|
+
constructor(url) {
|
|
6
|
+
this._url = url;
|
|
7
|
+
}
|
|
8
|
+
getToken() {
|
|
9
|
+
return this._token;
|
|
10
|
+
}
|
|
11
|
+
setToken(token) {
|
|
12
|
+
this._token = token;
|
|
13
|
+
}
|
|
14
|
+
getUser() {
|
|
15
|
+
return this._user;
|
|
16
|
+
}
|
|
17
|
+
setUser(user) {
|
|
18
|
+
this._user = user;
|
|
19
|
+
}
|
|
20
|
+
getPwd() {
|
|
21
|
+
return this._password;
|
|
22
|
+
}
|
|
23
|
+
setPwd(pws) {
|
|
24
|
+
this._password = pws;
|
|
25
|
+
}
|
|
26
|
+
getDb() {
|
|
27
|
+
return this._db;
|
|
28
|
+
}
|
|
29
|
+
setDb(db) {
|
|
30
|
+
this._db = db;
|
|
31
|
+
}
|
|
32
|
+
getUrl() {
|
|
33
|
+
return this._url;
|
|
34
|
+
}
|
|
35
|
+
setUrl(url) {
|
|
36
|
+
this._url = url;
|
|
37
|
+
}
|
|
38
|
+
setTimeOut(ms) {
|
|
39
|
+
this._timeout = ms;
|
|
40
|
+
}
|
|
41
|
+
getTimeOut() {
|
|
42
|
+
return this._timeout;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.WSConfig = WSConfig;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface IndexableString {
|
|
2
|
+
[index: number]: string;
|
|
3
|
+
}
|
|
4
|
+
export interface StringIndexable {
|
|
5
|
+
[index: string]: number;
|
|
6
|
+
}
|
|
7
|
+
export declare const BinaryQueryMessage: bigint;
|
|
8
|
+
export declare const FetchRawBlockMessage: bigint;
|
|
9
|
+
export declare const TDengineTypeName: IndexableString;
|
|
10
|
+
export declare const ColumnsBlockType: StringIndexable;
|
|
11
|
+
export declare enum TDengineTypeCode {
|
|
12
|
+
NULL = 0,
|
|
13
|
+
BOOL = 1,
|
|
14
|
+
TINYINT = 2,
|
|
15
|
+
SMALLINT = 3,
|
|
16
|
+
INT = 4,
|
|
17
|
+
BIGINT = 5,
|
|
18
|
+
FLOAT = 6,
|
|
19
|
+
DOUBLE = 7,
|
|
20
|
+
BINARY = 8,
|
|
21
|
+
VARCHAR = 8,
|
|
22
|
+
TIMESTAMP = 9,
|
|
23
|
+
NCHAR = 10,
|
|
24
|
+
TINYINT_UNSIGNED = 11,
|
|
25
|
+
SMALLINT_UNSIGNED = 12,
|
|
26
|
+
INT_UNSIGNED = 13,
|
|
27
|
+
BIGINT_UNSIGNED = 14,
|
|
28
|
+
JSON = 15,
|
|
29
|
+
VARBINARY = 16,
|
|
30
|
+
GEOMETRY = 20
|
|
31
|
+
}
|
|
32
|
+
export declare const TDenginePrecision: IndexableString;
|
|
33
|
+
export declare const TDengineTypeLength: StringIndexable;
|
|
34
|
+
export declare const PrecisionLength: StringIndexable;
|
|
35
|
+
//# sourceMappingURL=constant.d.ts.map
|
|
@@ -0,0 +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,QAAQ,KAAK;CAChB;AAED,eAAO,MAAM,iBAAiB,EAAE,eAI/B,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,eAahC,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,eAI7B,CAAA"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PrecisionLength = exports.TDengineTypeLength = exports.TDenginePrecision = exports.TDengineTypeCode = exports.ColumnsBlockType = exports.TDengineTypeName = exports.FetchRawBlockMessage = exports.BinaryQueryMessage = void 0;
|
|
4
|
+
exports.BinaryQueryMessage = BigInt(6);
|
|
5
|
+
exports.FetchRawBlockMessage = BigInt(7);
|
|
6
|
+
exports.TDengineTypeName = {
|
|
7
|
+
0: 'NULL',
|
|
8
|
+
1: 'BOOL',
|
|
9
|
+
2: 'TINYINT',
|
|
10
|
+
3: 'SMALLINT',
|
|
11
|
+
4: 'INT',
|
|
12
|
+
5: 'BIGINT',
|
|
13
|
+
6: 'FLOAT',
|
|
14
|
+
7: 'DOUBLE',
|
|
15
|
+
8: 'VARCHAR',
|
|
16
|
+
9: 'TIMESTAMP',
|
|
17
|
+
10: 'NCHAR',
|
|
18
|
+
11: 'TINYINT UNSIGNED',
|
|
19
|
+
12: 'SMALLINT UNSIGNED',
|
|
20
|
+
13: 'INT UNSIGNED',
|
|
21
|
+
14: 'BIGINT UNSIGNED',
|
|
22
|
+
15: 'JSON',
|
|
23
|
+
16: 'VARBINARY',
|
|
24
|
+
20: 'GEOMETRY',
|
|
25
|
+
};
|
|
26
|
+
exports.ColumnsBlockType = {
|
|
27
|
+
'SOLID': 0,
|
|
28
|
+
'VARCHAR': 1,
|
|
29
|
+
'NCHAR': 2,
|
|
30
|
+
'GEOMETRY': 3,
|
|
31
|
+
'VARBINARY': 4,
|
|
32
|
+
};
|
|
33
|
+
var TDengineTypeCode;
|
|
34
|
+
(function (TDengineTypeCode) {
|
|
35
|
+
TDengineTypeCode[TDengineTypeCode["NULL"] = 0] = "NULL";
|
|
36
|
+
TDengineTypeCode[TDengineTypeCode["BOOL"] = 1] = "BOOL";
|
|
37
|
+
TDengineTypeCode[TDengineTypeCode["TINYINT"] = 2] = "TINYINT";
|
|
38
|
+
TDengineTypeCode[TDengineTypeCode["SMALLINT"] = 3] = "SMALLINT";
|
|
39
|
+
TDengineTypeCode[TDengineTypeCode["INT"] = 4] = "INT";
|
|
40
|
+
TDengineTypeCode[TDengineTypeCode["BIGINT"] = 5] = "BIGINT";
|
|
41
|
+
TDengineTypeCode[TDengineTypeCode["FLOAT"] = 6] = "FLOAT";
|
|
42
|
+
TDengineTypeCode[TDengineTypeCode["DOUBLE"] = 7] = "DOUBLE";
|
|
43
|
+
TDengineTypeCode[TDengineTypeCode["BINARY"] = 8] = "BINARY";
|
|
44
|
+
TDengineTypeCode[TDengineTypeCode["VARCHAR"] = 8] = "VARCHAR";
|
|
45
|
+
TDengineTypeCode[TDengineTypeCode["TIMESTAMP"] = 9] = "TIMESTAMP";
|
|
46
|
+
TDengineTypeCode[TDengineTypeCode["NCHAR"] = 10] = "NCHAR";
|
|
47
|
+
TDengineTypeCode[TDengineTypeCode["TINYINT_UNSIGNED"] = 11] = "TINYINT_UNSIGNED";
|
|
48
|
+
TDengineTypeCode[TDengineTypeCode["SMALLINT_UNSIGNED"] = 12] = "SMALLINT_UNSIGNED";
|
|
49
|
+
TDengineTypeCode[TDengineTypeCode["INT_UNSIGNED"] = 13] = "INT_UNSIGNED";
|
|
50
|
+
TDengineTypeCode[TDengineTypeCode["BIGINT_UNSIGNED"] = 14] = "BIGINT_UNSIGNED";
|
|
51
|
+
TDengineTypeCode[TDengineTypeCode["JSON"] = 15] = "JSON";
|
|
52
|
+
TDengineTypeCode[TDengineTypeCode["VARBINARY"] = 16] = "VARBINARY";
|
|
53
|
+
TDengineTypeCode[TDengineTypeCode["GEOMETRY"] = 20] = "GEOMETRY";
|
|
54
|
+
})(TDengineTypeCode || (exports.TDengineTypeCode = TDengineTypeCode = {}));
|
|
55
|
+
exports.TDenginePrecision = {
|
|
56
|
+
0: 'MILLISECOND',
|
|
57
|
+
1: "MICROSECOND",
|
|
58
|
+
2: "NANOSECOND",
|
|
59
|
+
};
|
|
60
|
+
exports.TDengineTypeLength = {
|
|
61
|
+
'BOOL': 1,
|
|
62
|
+
'TINYINT': 1,
|
|
63
|
+
'SMALLINT': 2,
|
|
64
|
+
'INT': 4,
|
|
65
|
+
'BIGINT': 8,
|
|
66
|
+
'FLOAT': 4,
|
|
67
|
+
'DOUBLE': 8,
|
|
68
|
+
'TIMESTAMP': 8,
|
|
69
|
+
'TINYINT UNSIGNED': 1,
|
|
70
|
+
'SMALLINT UNSIGNED': 2,
|
|
71
|
+
'INT UNSIGNED': 4,
|
|
72
|
+
'BIGINT UNSIGNED': 8,
|
|
73
|
+
};
|
|
74
|
+
exports.PrecisionLength = {
|
|
75
|
+
'ms': 13,
|
|
76
|
+
'us': 16,
|
|
77
|
+
'ns': 19
|
|
78
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/common/log.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAwB9B,QAAA,MAAM,MAAM,gBAGV,CAAC;AAUH,wBAAgB,QAAQ,CAAC,KAAK,EAAC,MAAM,QAEpC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.setLevel = void 0;
|
|
7
|
+
const winston_1 = __importDefault(require("winston"));
|
|
8
|
+
const winston_daily_rotate_file_1 = __importDefault(require("winston-daily-rotate-file"));
|
|
9
|
+
const moment_timezone_1 = __importDefault(require("moment-timezone"));
|
|
10
|
+
const customFormat = winston_1.default.format.printf(({ timestamp, level, message, ...meta }) => {
|
|
11
|
+
const formattedTime = (0, moment_timezone_1.default)(timestamp).tz('Asia/Shanghai').format('YYYY-MM-DD HH:mm:ss.SSS'); // 使用上海时区
|
|
12
|
+
return `${formattedTime} ${level}: ${message} ${Object.keys(meta).length ? JSON.stringify(meta, null, 2) : ''}`;
|
|
13
|
+
});
|
|
14
|
+
const transport = new winston_daily_rotate_file_1.default({
|
|
15
|
+
filename: './logs/app-%DATE%.log', // Here is the file name template
|
|
16
|
+
datePattern: 'YYYY-MM-DD', // date format
|
|
17
|
+
zippedArchive: true, // Whether to compress the archive file into gzip format
|
|
18
|
+
maxSize: '20m', // Single file size limit
|
|
19
|
+
maxFiles: '14d', // Keep log files for 14 days
|
|
20
|
+
handleExceptions: true, // Whether to handle exceptions
|
|
21
|
+
json: false, // Whether to output logs in JSON format
|
|
22
|
+
format: winston_1.default.format.combine(winston_1.default.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), customFormat),
|
|
23
|
+
level: 'info', // set log level
|
|
24
|
+
});
|
|
25
|
+
const logger = winston_1.default.createLogger({
|
|
26
|
+
transports: [transport],
|
|
27
|
+
exitOnError: false, // Do not exit the process when an error occurs
|
|
28
|
+
});
|
|
29
|
+
// 设置 BigInt 类型的序列化处理
|
|
30
|
+
transport.format = winston_1.default.format((info) => {
|
|
31
|
+
if (info && info.message && typeof info.message === 'object' && typeof info.message.toJSON === 'function') {
|
|
32
|
+
info.message = info.message.toJSON();
|
|
33
|
+
}
|
|
34
|
+
return info;
|
|
35
|
+
})();
|
|
36
|
+
function setLevel(level) {
|
|
37
|
+
transport.level = level;
|
|
38
|
+
}
|
|
39
|
+
exports.setLevel = setLevel;
|
|
40
|
+
exports.default = logger;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reqid.d.ts","sourceRoot":"","sources":["../../../src/common/reqid.ts"],"names":[],"mappings":"AA2BA,qBAAa,KAAK;IACd,OAAO,CAAC,MAAM,CAAC,KAAK,CAAK;IACzB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAI;IACvB,OAAO,CAAC,MAAM,CAAC,YAAY,CAA4B;IACvD,OAAO,CAAC,MAAM,CAAC,SAAS,CAAsC;WAahD,QAAQ,CAAC,MAAM,CAAC,EAAC,MAAM,GAAE,MAAM;CAgBhD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ReqId = void 0;
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
|
+
const uuid_1 = require("uuid");
|
|
7
|
+
const node_process_1 = require("node:process");
|
|
8
|
+
function hexStringToNumber(hexString) {
|
|
9
|
+
const number = parseInt(hexString, 16);
|
|
10
|
+
if (isNaN(number)) {
|
|
11
|
+
throw new Error(`number ${hexString} parse int fail!`);
|
|
12
|
+
}
|
|
13
|
+
return number;
|
|
14
|
+
}
|
|
15
|
+
function uuidToHash() {
|
|
16
|
+
let uuid = (0, uuid_1.v4)();
|
|
17
|
+
// create SHA-256 hash
|
|
18
|
+
const hash = (0, crypto_1.createHash)('sha256');
|
|
19
|
+
// update hash contact
|
|
20
|
+
hash.update(uuid);
|
|
21
|
+
// get hex hash code
|
|
22
|
+
const strHex = hash.digest('hex').substring(0, 8);
|
|
23
|
+
let hex = hexStringToNumber(strHex);
|
|
24
|
+
return hex & 0xff;
|
|
25
|
+
}
|
|
26
|
+
class ReqId {
|
|
27
|
+
static getReqID(req_id) {
|
|
28
|
+
if (req_id) {
|
|
29
|
+
return req_id;
|
|
30
|
+
}
|
|
31
|
+
let no = Atomics.add(_a.int32View, 0, 1);
|
|
32
|
+
const buffer = new ArrayBuffer(8);
|
|
33
|
+
const view = new DataView(buffer);
|
|
34
|
+
let ts = new Date().getTime() >> 8;
|
|
35
|
+
view.setUint8(6, this._uuid >> 4);
|
|
36
|
+
view.setUint8(5, (this._uuid & 0x0f) << 4 | this._pid);
|
|
37
|
+
view.setUint8(4, ts >> 16 & 0xff);
|
|
38
|
+
view.setUint16(2, ts & 0xffff, true);
|
|
39
|
+
view.setUint16(0, no & 0xffff, true);
|
|
40
|
+
let id = view.getBigInt64(0, true);
|
|
41
|
+
return Number(id);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.ReqId = ReqId;
|
|
45
|
+
_a = ReqId;
|
|
46
|
+
ReqId._uuid = 0;
|
|
47
|
+
ReqId._pid = 0;
|
|
48
|
+
ReqId.sharedBuffer = new SharedArrayBuffer(4);
|
|
49
|
+
ReqId.int32View = new Int32Array(_a.sharedBuffer);
|
|
50
|
+
(() => {
|
|
51
|
+
_a._uuid = uuidToHash();
|
|
52
|
+
if (node_process_1.pid) {
|
|
53
|
+
_a._pid = node_process_1.pid & 0xf;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
_a._pid = (Math.floor(Math.random() * 9000) + 1000) & 0xf;
|
|
57
|
+
}
|
|
58
|
+
Atomics.store(_a.int32View, 0, 0);
|
|
59
|
+
})();
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { WSFetchBlockResponse, WSQueryResponse } from "../client/wsResponse";
|
|
2
|
+
export interface TDengineMeta {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
length: number;
|
|
6
|
+
}
|
|
7
|
+
interface ResponseMeta {
|
|
8
|
+
name: string;
|
|
9
|
+
type: number;
|
|
10
|
+
length: number;
|
|
11
|
+
}
|
|
12
|
+
export interface MessageResp {
|
|
13
|
+
totalTime: number;
|
|
14
|
+
msg: any;
|
|
15
|
+
}
|
|
16
|
+
export declare class TaosResult {
|
|
17
|
+
private _topic?;
|
|
18
|
+
private _meta;
|
|
19
|
+
private _data;
|
|
20
|
+
private _precision;
|
|
21
|
+
protected _affectRows: number | null | undefined;
|
|
22
|
+
private _totalTime;
|
|
23
|
+
/** unit nano seconds */
|
|
24
|
+
private _timing;
|
|
25
|
+
constructor(queryResponse?: WSQueryResponse);
|
|
26
|
+
setPrecision(precision: number): void;
|
|
27
|
+
setRowsAndTime(rows: number, timing?: bigint): void;
|
|
28
|
+
getTopic(): string;
|
|
29
|
+
setTopic(topic?: string): void;
|
|
30
|
+
getMeta(): Array<TDengineMeta> | null;
|
|
31
|
+
setMeta(metaData: ResponseMeta): void;
|
|
32
|
+
getData(): Array<Array<any>> | null;
|
|
33
|
+
setData(value: Array<Array<any>> | null): void;
|
|
34
|
+
getAffectRows(): number | null | undefined;
|
|
35
|
+
getTaosMeta(): Array<ResponseMeta> | null;
|
|
36
|
+
getPrecision(): number | null | undefined;
|
|
37
|
+
getTotalTime(): number;
|
|
38
|
+
addTotalTime(totalTime: number): void;
|
|
39
|
+
setTiming(timing?: bigint): void;
|
|
40
|
+
/**
|
|
41
|
+
* Mapping the WebSocket response type code to TDengine's type name.
|
|
42
|
+
*/
|
|
43
|
+
private getTDengineMeta;
|
|
44
|
+
}
|
|
45
|
+
export declare function parseBlock(blocks: WSFetchBlockResponse, taosResult: TaosResult): TaosResult;
|
|
46
|
+
export declare function _isVarType(metaType: number): Number;
|
|
47
|
+
export declare function readSolidDataToArray(dataBuffer: DataView, colBlockHead: number, rows: number, metaType: number, bitMapArr: Uint8Array): any[];
|
|
48
|
+
export declare function readSolidData(dataBuffer: DataView, colDataHead: number, meta: ResponseMeta): Number | Boolean | BigInt;
|
|
49
|
+
export declare function readBinary(dataBuffer: ArrayBuffer, colDataHead: number, length: number): ArrayBuffer;
|
|
50
|
+
export declare function readVarchar(dataBuffer: ArrayBuffer, colDataHead: number, length: number, textDecoder: TextDecoder): string;
|
|
51
|
+
export declare function readNchar(dataBuffer: ArrayBuffer, colDataHead: number, length: number): string;
|
|
52
|
+
export declare function getString(dataBuffer: DataView, colDataHead: number, length: number, textDecoder: TextDecoder): string;
|
|
53
|
+
export declare function getCharOffset(n: number): number;
|
|
54
|
+
export declare function setBitmapNull(c: number, n: number): number;
|
|
55
|
+
export declare function bitmapLen(n: number): number;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=taosResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taosResult.d.ts","sourceRoot":"","sources":["../../../src/common/taosResult.ts"],"names":[],"mappings":"AAAA,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