dignity.js 0.7.1 → 0.8.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 +48 -3
- package/dist/dignity.cjs.js +899 -8
- package/dist/dignity.cjs.js.map +4 -4
- package/dist/dignity.esm.js +899 -8
- package/dist/dignity.esm.js.map +3 -3
- package/dist/dignity.min.js +18 -18
- package/docs/assets/dignity.esm.js +899 -8
- package/docs/assets/playground-demos.js +56 -0
- package/docs/index.html +64 -10
- package/docs/openapi-like.json +61 -8
- package/package.json +2 -2
- package/src/core/dignity-p2p.js +428 -6
- package/src/cqrs/bulk-relay.js +35 -0
- package/src/cqrs/domain-events.js +285 -0
- package/src/cqrs/peer-group-tiers.js +46 -0
- package/src/cqrs/query-replica.js +213 -0
- package/src/gossip/peer-group.js +1 -1
- package/src/index.js +34 -1
package/README.md
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/dignity.js)
|
|
7
7
|
[](https://www.npmjs.com/package/dignity.js)
|
|
8
8
|
[](https://github.com/jose-compu/dignity.js/actions/workflows/ci.yml)
|
|
9
|
-

|
|
10
10
|

|
|
11
11
|

|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
The Scalable Data Layer of the Decentralized Browser Application Ecosystem.
|
|
14
14
|
|
|
15
15
|
`dignity.js` lets many browsers synchronize shared objects with ownership rules and built-in anti-abuse + privacy controls.
|
|
16
16
|
|
|
@@ -33,6 +33,10 @@ REST-like P2P object API for decentralized JavaScript applications.
|
|
|
33
33
|
- Auto `connectToPeers` on create/update/delete replication (owner + collaborators)
|
|
34
34
|
- Optional IndexedDB persistence for browser reload survival
|
|
35
35
|
- Optional React hooks via `dignity.js/react`
|
|
36
|
+
- **PeerGroup gossip** — scalable PubSub for high-fanout feeds (spectators, timelines); default `maxHops: 64`
|
|
37
|
+
- **CQRS tiers (v0.8+)** — live core (5k cap) + bulk tail per publisher; signed domain events on every write
|
|
38
|
+
- **`DignityQueryReplica`** — read-only materialized views with hash-chain verification
|
|
39
|
+
- Credential-derived keys, identity rotation, and cold-recovery co-sign (v0.7+)
|
|
36
40
|
- Browser-first: published npm package includes IIFE, ESM, and CJS builds
|
|
37
41
|
|
|
38
42
|
## Install
|
|
@@ -133,15 +137,56 @@ For high-fanout object updates (millions of subscribers per published object), u
|
|
|
133
137
|
await node.joinPeerGroup('feed:alice', {
|
|
134
138
|
bootstrapPeerIds: ['publisher-peer-id'],
|
|
135
139
|
fanout: 3,
|
|
136
|
-
maxActivePeers: 8
|
|
140
|
+
maxActivePeers: 8,
|
|
141
|
+
maxHops: 64 // default since v0.8.0
|
|
137
142
|
});
|
|
138
143
|
|
|
139
144
|
await node.publishRecordToPeerGroup('feed:alice', 'posts', 'post-1');
|
|
140
145
|
await node.leavePeerGroup('feed:alice');
|
|
141
146
|
```
|
|
142
147
|
|
|
148
|
+
Inner gossip message types: `operation`, `record:snapshot`, `domain:event`, `domain:checkpoint`, and app-defined payloads (via `peergroupmessage` events).
|
|
149
|
+
|
|
143
150
|
Small collaborations (chess players, document co-editing) should keep using direct `connectToPeers` mesh. Large read-only audiences (chess spectators, public timelines) should use PeerGroup gossip. See the [docs PeerGroup section](https://jose-compu.github.io/dignity.js/#peer-groups).
|
|
144
151
|
|
|
152
|
+
### CQRS tiers, domain events, and query replicas (v0.8+)
|
|
153
|
+
|
|
154
|
+
For audiences above ~5 000 subscribers per publisher, use the command/query split:
|
|
155
|
+
|
|
156
|
+
- **Command path** — publisher writes locally; signed domain events auto-publish on `create` / `update` / `remove`.
|
|
157
|
+
- **Live tier** — first `liveCap` subscribers (default 5 000) receive real-time gossip.
|
|
158
|
+
- **Bulk tier** — overflow subscribers receive batched updates via bulk relays.
|
|
159
|
+
- **Query path** — `DignityQueryReplica` maintains local materialized views from the event stream.
|
|
160
|
+
|
|
161
|
+
```js
|
|
162
|
+
const { DignityP2P, DignityQueryReplica } = require('dignity.js');
|
|
163
|
+
|
|
164
|
+
// Publisher
|
|
165
|
+
await publisher.joinPeerGroup('feed:alice', {
|
|
166
|
+
role: 'publisher',
|
|
167
|
+
tiered: true,
|
|
168
|
+
liveCap: 5000,
|
|
169
|
+
domainEvents: true
|
|
170
|
+
});
|
|
171
|
+
await publisher.create('posts', { text: 'hello' }, { id: 'p1', peerGroupId: 'feed:alice' });
|
|
172
|
+
|
|
173
|
+
// Read-only replica (no command capability)
|
|
174
|
+
const replica = new DignityQueryReplica(reader, {
|
|
175
|
+
groupId: 'feed:alice',
|
|
176
|
+
collections: ['posts'],
|
|
177
|
+
publisherId: 'alice'
|
|
178
|
+
});
|
|
179
|
+
await replica.start({ bootstrapPeerIds: ['alice'] });
|
|
180
|
+
replica.read('posts', 'p1');
|
|
181
|
+
replica.verifyChain(); // hash-chain consistency
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Default `maxHops` is **64** (was 6 in v0.7.x), sufficient for epidemic spread at fanout 3 without per-group tuning.
|
|
185
|
+
|
|
186
|
+
**Publisher options:** `role: 'publisher'`, `tiered: true`, `liveCap` (default 5000), `domainEvents: true`, `peerGroupId` on CRUD to auto-publish events.
|
|
187
|
+
|
|
188
|
+
**Subscriber / replica options:** `role: 'subscriber'`, `tierMode: 'auto' | 'live' | 'bulk'`, `commandCapable: false` on read-only nodes, `publisherId` to filter events.
|
|
189
|
+
|
|
145
190
|
## Room / Team Discovery
|
|
146
191
|
|
|
147
192
|
Use scoped discovery to find active peers in a room (for example `main`, `team:red`, `raid-42`).
|