meridian-sdk 0.3.0 → 0.3.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 +12 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,9 +5,9 @@ TypeScript SDK for [Meridian](../README.md) — Effect-based, fully typed, msgpa
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
bun add meridian-sdk
|
|
8
|
+
bun add meridian-sdk
|
|
9
9
|
# or
|
|
10
|
-
npm install meridian-sdk
|
|
10
|
+
npm install meridian-sdk
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Quick start
|
|
@@ -16,7 +16,6 @@ npm install meridian-sdk effect msgpackr
|
|
|
16
16
|
import { Effect, Schema } from "effect";
|
|
17
17
|
import { MeridianClient } from "meridian-sdk";
|
|
18
18
|
|
|
19
|
-
// MeridianClient.create() parses + validates the token — returns Effect
|
|
20
19
|
const client = await Effect.runPromise(
|
|
21
20
|
MeridianClient.create({
|
|
22
21
|
url: "http://localhost:3000",
|
|
@@ -42,6 +41,11 @@ const room = client.presence("pr:room", Cursor);
|
|
|
42
41
|
room.heartbeat({ x: 100, y: 200 }, 30_000);
|
|
43
42
|
room.onChange(entries => console.log("online:", entries));
|
|
44
43
|
|
|
44
|
+
// CRDTMap — composite document with named CRDT fields
|
|
45
|
+
const doc = client.crdtmap("doc:settings");
|
|
46
|
+
doc.lwwSet("theme", "dark");
|
|
47
|
+
doc.incrementCounter("edits");
|
|
48
|
+
|
|
45
49
|
// Close WebSocket when done
|
|
46
50
|
client.close();
|
|
47
51
|
```
|
|
@@ -89,6 +93,7 @@ await Effect.runPromise(
|
|
|
89
93
|
| `client.orset(id, schema?)` | `ORSetHandle<T>` | Optional |
|
|
90
94
|
| `client.lwwregister(id, schema?)` | `LwwRegisterHandle<T>` | Optional |
|
|
91
95
|
| `client.presence(id, schema?)` | `PresenceHandle<T>` | Optional |
|
|
96
|
+
| `client.crdtmap(id)` | `CRDTMapHandle` | — |
|
|
92
97
|
|
|
93
98
|
Without a schema, `T = unknown`. With a schema, incoming deltas are validated at runtime via `Schema.decodeUnknownSync`.
|
|
94
99
|
|
|
@@ -97,10 +102,10 @@ Without a schema, `T = unknown`. With a schema, incoming deltas are validated at
|
|
|
97
102
|
All methods return `Effect<T, HttpError | NetworkError>`:
|
|
98
103
|
|
|
99
104
|
```ts
|
|
100
|
-
client.http.getCrdt(ns, id)
|
|
101
|
-
client.http.postOp(ns, id, op)
|
|
102
|
-
client.http.syncCrdt(ns, id, sinceVc)
|
|
103
|
-
client.http.issueToken(ns, opts)
|
|
105
|
+
client.http.getCrdt(ns, id) // → Effect<CrdtGetResponse, ...>
|
|
106
|
+
client.http.postOp(ns, id, op) // → Effect<CrdtOpResponse, ...>
|
|
107
|
+
client.http.syncCrdt(ns, id, sinceVc?) // → Effect<CrdtGetResponse, ...>
|
|
108
|
+
client.http.issueToken(ns, opts) // → Effect<TokenIssueResponse, ...>
|
|
104
109
|
```
|
|
105
110
|
|
|
106
111
|
## Wire protocol
|