@gonvex/client 0.1.0 → 0.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/README.md +63 -0
- package/package.json +4 -3
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# @gonvex/client
|
|
2
|
+
|
|
3
|
+
Browser client for Gonvex realtime queries, mutations, actions, telemetry, and
|
|
4
|
+
local cache helpers.
|
|
5
|
+
|
|
6
|
+
Most React apps should use `@gonvex/react`, which wraps this package with hooks.
|
|
7
|
+
Use `@gonvex/client` directly when you want lower-level control.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @gonvex/client
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { GonvexClient } from "@gonvex/client";
|
|
19
|
+
|
|
20
|
+
const client = new GonvexClient("ws://localhost:8080/ws", {
|
|
21
|
+
project: "my-project",
|
|
22
|
+
tenant: "demo",
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
client.connect();
|
|
26
|
+
|
|
27
|
+
const unsubscribe = client.subscribeQuery(
|
|
28
|
+
{ kind: "query", path: "tasks.list" },
|
|
29
|
+
{ status: "open" },
|
|
30
|
+
(message) => {
|
|
31
|
+
if (message.type === "query.result") {
|
|
32
|
+
console.log(message.result);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
await client.mutation(
|
|
38
|
+
{ kind: "mutation", path: "tasks.create" },
|
|
39
|
+
{ title: "Ship Gonvex" },
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
unsubscribe();
|
|
43
|
+
client.close();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Exports
|
|
47
|
+
|
|
48
|
+
The package exports:
|
|
49
|
+
|
|
50
|
+
- `GonvexClient`
|
|
51
|
+
- `ConvexReactClient` compatibility alias
|
|
52
|
+
- cache helpers for browser and persistent query state
|
|
53
|
+
- browser capability and telemetry helpers
|
|
54
|
+
|
|
55
|
+
## Related Packages
|
|
56
|
+
|
|
57
|
+
- `@gonvex/react` - React hooks over this client
|
|
58
|
+
- `@gonvex/protocol` - protocol message and JSON types
|
|
59
|
+
- `@gonvex/cli` - development CLI
|
|
60
|
+
|
|
61
|
+
## Documentation
|
|
62
|
+
|
|
63
|
+
Full docs live at https://desarso.github.io/gonvex/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gonvex/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@gonvex/protocol": "0.1.
|
|
16
|
+
"@gonvex/protocol": "0.1.1"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"typescript": "^6.0.3",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
},
|
|
22
22
|
"main": "./dist/index.js",
|
|
23
23
|
"files": [
|
|
24
|
-
"dist"
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md"
|
|
25
26
|
],
|
|
26
27
|
"scripts": {
|
|
27
28
|
"build": "tsc -p tsconfig.json",
|