@tdengine/websocket 3.0.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.
- package/README.md +59 -0
- package/dist/browser/index.js +778 -0
- package/dist/main/index.js +711 -0
- package/dist/main/index.js.map +1 -0
- package/dist/module/index.mjs +704 -0
- package/dist/module/index.mjs.map +1 -0
- package/dist/types.d.ts +103 -0
- package/dist/types.d.ts.map +1 -0
- package/example/basicUsageAsync.ts +48 -0
- package/example/basicUsagePrimse.ts +43 -0
- package/example/cloudUsage.ts +55 -0
- package/example/continousConnectAndVersion.ts +16 -0
- package/example/test.mjs +51 -0
- package/index.ts +7 -0
- package/jest.config.js +8 -0
- package/package.json +55 -0
- package/src/constant.ts +74 -0
- package/src/taosResult.ts +269 -0
- package/src/tdengineWebsocket.ts +39 -0
- package/src/ut8Helper.ts +42 -0
- package/src/wsClient.ts +196 -0
- package/src/wsError.ts +5 -0
- package/src/wsOptions.ts +14 -0
- package/src/wsQuery.ts +30 -0
- package/src/wsQueryInterface.ts +212 -0
- package/src/wsQueryResponse.ts +112 -0
- package/tdengine-websocket-3.0.0.tgz +0 -0
- package/test/bulkPulling/connect.test.ts +27 -0
- package/test/bulkPulling/queryTables.test.ts +274 -0
- package/test/bulkPulling/version.test.ts +19 -0
- package/test/utils.ts +235 -0
- package/tsconfig.json +101 -0
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# WebSocket APIs
|
|
2
|
+
|
|
3
|
+
## Bulk Pulling
|
|
4
|
+
|
|
5
|
+
### DSN
|
|
6
|
+
|
|
7
|
+
User can connect to the TDengine by passing DSN to WebSocket client. The description about the DSN like before.
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
[+<protocol>]://[[<username>:<password>@]<host>:<port>][/<database>][?<p1>=<v1>[&<p2>=<v2>]]
|
|
11
|
+
|------------|---|-----------|-----------|------|------|------------|-----------------------|
|
|
12
|
+
| protocol | | username | password | host | port | database | params |
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
- **protocol**: Display using websocket protocol to establish connection. eg. `ws://localhost:6041`
|
|
16
|
+
- **username/password**: Database's username and password.
|
|
17
|
+
- **host/port**: Declare host and port. eg. `localhost:6041`
|
|
18
|
+
- **database**: Optional, use to specify database name.
|
|
19
|
+
- **params**: Other parameters. Like cloud Token.
|
|
20
|
+
|
|
21
|
+
A complete DSN string example:
|
|
22
|
+
|
|
23
|
+
```text
|
|
24
|
+
ws://localhost:6041/test
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Basic Usage
|
|
28
|
+
|
|
29
|
+
``` typescript
|
|
30
|
+
import {connect} from '@tdengine/websocket'
|
|
31
|
+
let dsn = "ws://host:port/rest/ws/db"
|
|
32
|
+
// create an instance of taoWS, while the returned websocket connection of the returned instance 'ws' may is not in 'OPEN' status
|
|
33
|
+
var ws = connect(dsn)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
``` typescript
|
|
37
|
+
// build connect with tdengine
|
|
38
|
+
ws.connect().then(connectRes=>console.log(connectRes)).catch(e=>{/*do some thing to handle error*/})
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
``` typescript
|
|
42
|
+
//query data with SQL
|
|
43
|
+
ws.query(sql).then(taosResult=>{console.log(taosResult)}).catch(e=>{/*do some thing to handle error*/})
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
// get client version
|
|
48
|
+
ws.version().then(version=>console.log(version)).catch(e=>{/*do some thing to handle error*/})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
``` typescript
|
|
52
|
+
// get current WebSocket connection status
|
|
53
|
+
let status:number = ws.status()
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
``` typescript
|
|
57
|
+
// close current WebSocket connection
|
|
58
|
+
ws.close();
|
|
59
|
+
```
|