@yydb/yydb-client 0.0.2 → 0.0.4
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 +22 -42
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
# `@yydb/yydb-client`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
surface — browser, WebUI, Electron renderer, or a thin Node process.
|
|
3
|
+
TypeScript client for the YY wire protocol over WebSocket or TCP. Use when `yydb serve` already runs (from [
|
|
4
|
+
`@yydb/yydb`](https://www.npmjs.com/package/@yydb/yydb) CLI or another host) and you only need the client surface —
|
|
5
|
+
browser, WebUI, Electron renderer, or a thin Node process.
|
|
7
6
|
|
|
8
7
|
[](https://www.npmjs.com/package/@yydb/yydb-client)
|
|
9
8
|
[](https://www.npmjs.com/package/@yydb/yydb-client)
|
|
10
|
-
[](https://github.com/yy-database/yydb/actions/workflows/check-rust.yml)
|
|
11
|
-
[](https://github.com/yy-database/yydb/actions/workflows/check-typescript.yml)
|
|
12
9
|
|
|
13
|
-
##
|
|
10
|
+
## Exports
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
| Import | Transport | Typical use |
|
|
13
|
+
|--------------------------|-------------------|--------------------|
|
|
14
|
+
| `@yydb/yydb-client` | WebSocket `/wire` | Browsers and WebUI |
|
|
15
|
+
| `@yydb/yydb-client/node` | TCP or WebSocket | Node and Electron |
|
|
16
|
+
|
|
17
|
+
Frame helpers (`encodeFrame`, `MsgType`, …) are exported for tools and tests.
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Example
|
|
20
20
|
|
|
21
|
-
Start a
|
|
21
|
+
Start a host (from `@yydb/yydb` or the `yydb` CLI):
|
|
22
22
|
|
|
23
23
|
```text
|
|
24
24
|
yydb serve app.yydb --bind 127.0.0.1:7700
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
**Browser / WebSocket**
|
|
28
28
|
|
|
29
29
|
```ts
|
|
30
30
|
import {Client} from "@yydb/yydb-client";
|
|
@@ -36,9 +36,7 @@ console.log(await db.get("theme"));
|
|
|
36
36
|
db.close();
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
The `/node` entry point supports a TCP endpoint and `ws://` URLs:
|
|
39
|
+
**Node TCP**
|
|
42
40
|
|
|
43
41
|
```ts
|
|
44
42
|
import {connect} from "@yydb/yydb-client/node";
|
|
@@ -48,32 +46,14 @@ console.log(await db.info());
|
|
|
48
46
|
db.close();
|
|
49
47
|
```
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
existing host or a custom transport integration.
|
|
54
|
-
|
|
55
|
-
## Exports
|
|
56
|
-
|
|
57
|
-
| Import | Transport | Typical use |
|
|
58
|
-
|--------------------------|-------------------|--------------------|
|
|
59
|
-
| `@yydb/yydb-client` | WebSocket `/wire` | Browsers and WebUI |
|
|
60
|
-
| `@yydb/yydb-client/node` | TCP or WebSocket | Node and Electron |
|
|
61
|
-
|
|
62
|
-
The high-level client includes `info`, schema ensure/get, key/value get/put, server version, and close operations. Frame
|
|
63
|
-
helpers such as `encodeFrame` and
|
|
64
|
-
`MsgType` are exported for tools and tests.
|
|
65
|
-
|
|
66
|
-
## Compatibility and security
|
|
67
|
-
|
|
68
|
-
The client accepts hosts that announce either `YYDB` or `YYDS` on the shared wire. The reference `yydb serve` endpoint
|
|
69
|
-
has no authentication, so connect only to a host you control, normally `127.0.0.1` or `localhost`.
|
|
49
|
+
To open a local `.yydb` file without managing a server, use [`@yydb/yydb`](https://www.npmjs.com/package/@yydb/yydb)
|
|
50
|
+
instead.
|
|
70
51
|
|
|
71
|
-
|
|
72
|
-
|
|
52
|
+
The client accepts hosts that announce `YYDB` or `YYDS` on the shared wire. Connect only to hosts you control — normally
|
|
53
|
+
`127.0.0.1` or `localhost`.
|
|
73
54
|
|
|
74
|
-
|
|
55
|
+
Protocol details: [
|
|
56
|
+
`yydb-serve-protocol`](https://github.com/yy-database/yydb.rs/tree/dev/projects/packages/yydb-skills/skills/yydb-serve-protocol/SKILL.md)
|
|
57
|
+
in [`@yydb/yydb-skills`](https://www.npmjs.com/package/@yydb/yydb-skills).
|
|
75
58
|
|
|
76
|
-
- [
|
|
77
|
-
- [Local WebUI](https://github.com/yy-database/yydb.rs/tree/dev/projects/packages/yydb-webui)
|
|
78
|
-
- [YYDB user guides](https://github.com/yy-database/yydb.rs/tree/dev/projects/packages/homepage/documentation/zh-hans)
|
|
79
|
-
- [License](https://github.com/yy-database/yydb.rs/blob/dev/License.md)
|
|
59
|
+
[YYDB overview](https://github.com/yy-database/yydb.rs) · [User guides](https://github.com/yy-database/yydb.rs/tree/dev/projects/packages/homepage/documentation/zh-hans)
|