@rljson/rljson 0.0.89 → 0.0.91
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.architecture.md +10 -0
- package/README.blog.md +1 -1
- package/README.contributors.md +4 -4
- package/README.public.md +6 -0
- package/dist/README.architecture.md +10 -0
- package/dist/README.blog.md +1 -1
- package/dist/README.contributors.md +4 -4
- package/dist/README.public.md +6 -0
- package/dist/content/cake.d.ts +0 -3
- package/dist/index.d.ts +1 -0
- package/dist/rljson.js +25 -12
- package/dist/rljson_version.d.ts +1 -1
- package/dist/sync/connector-payload.d.ts +23 -11
- package/dist/sync/route-holders.d.ts +35 -0
- package/dist/sync/sync-events.d.ts +2 -0
- package/package.json +14 -14
package/README.architecture.md
CHANGED
|
@@ -635,11 +635,19 @@ The payload transmitted on the wire between Connector and Server:
|
|
|
635
635
|
| `cksum` | `string` | Acknowledgment | Content checksum for ACK verification |
|
|
636
636
|
| `stamp` | `RefStamp` | Hub order | Where a stamping hub placed the ref |
|
|
637
637
|
| `src` | `string` | Source node | Node to read the ref's data from first |
|
|
638
|
+
| `holders` | `RouteHolders` | Holders | Which node holds which ref of the route |
|
|
638
639
|
|
|
639
640
|
`src` is set by the relaying hub, never by the sender: the node id of the
|
|
640
641
|
client it received the ref from, or nothing when it does not know that node.
|
|
641
642
|
It is a hint for readers; the hub can always serve the data.
|
|
642
643
|
|
|
644
|
+
`holders` is set by a hub on what it sends its clients — relayed refs, the
|
|
645
|
+
bootstrap, the state beacon: per node id, the newest ref that node holds
|
|
646
|
+
completely (`RouteHolders`). A node enters it as the sender of a ref, or by
|
|
647
|
+
sending a `HeldPayload` (`{ r }`) on `${route}:held`, and leaves it when its
|
|
648
|
+
last connection to the hub ends. Only nodes the receiver may read from are
|
|
649
|
+
named. A hint like `src`.
|
|
650
|
+
|
|
643
651
|
### AckPayload
|
|
644
652
|
|
|
645
653
|
Server → Client acknowledgment that all (or some) receivers successfully
|
|
@@ -701,6 +709,7 @@ Helper to generate typed socket event names from a route:
|
|
|
701
709
|
| `${route}:gapfill:res` | server → client | Supply missing refs |
|
|
702
710
|
| `${route}:bootstrap` | server → client | Latest ref on connect / heartbeat |
|
|
703
711
|
| `${route}:stamp` | server → sender | The stamp its announced ref got |
|
|
712
|
+
| `${route}:held` | client → server | Its node holds a ref completely |
|
|
704
713
|
|
|
705
714
|
### ClientId
|
|
706
715
|
|
|
@@ -776,6 +785,7 @@ src/
|
|
|
776
785
|
│ ├── client-id.ts # ClientId, clientId(), isClientId()
|
|
777
786
|
│ ├── connector-payload.ts # ConnectorPayload
|
|
778
787
|
│ ├── gap-fill.ts # GapFillRequest, GapFillResponse
|
|
788
|
+
│ ├── route-holders.ts # RouteHolders, HeldPayload
|
|
779
789
|
│ ├── sync-config.ts # SyncConfig
|
|
780
790
|
│ └── sync-events.ts # SyncEventNames, syncEvents()
|
|
781
791
|
│
|
package/README.blog.md
CHANGED
|
@@ -5,4 +5,4 @@ Add latest posts at the end.
|
|
|
5
5
|
## 2026-11-02 — ConnectorPayload names its source
|
|
6
6
|
|
|
7
7
|
- `ConnectorPayload.src`: the node a relayed ref came from, set by the relaying hub
|
|
8
|
-
- Post: [
|
|
8
|
+
- Post: [pm/en/2026-Q4/blog/2026-11-02-connector-payload-names-its-source.md](pm/en/2026-Q4/blog/2026-11-02-connector-payload-names-its-source.md), German: [pm/de/2026-Q4/blog/2026-11-02-connector-payload-names-its-source.md](pm/de/2026-Q4/blog/2026-11-02-connector-payload-names-its-source.md)
|
package/README.contributors.md
CHANGED
|
@@ -15,18 +15,18 @@ found in the LICENSE file in the root of this package.
|
|
|
15
15
|
|
|
16
16
|
## Prepare
|
|
17
17
|
|
|
18
|
-
Read [prepare.md](doc/workflows/prepare.md)
|
|
18
|
+
Read [prepare.md](doc/en/workflows/prepare.md)
|
|
19
19
|
|
|
20
20
|
<!-- ........................................................................-->
|
|
21
21
|
|
|
22
22
|
## Develop
|
|
23
23
|
|
|
24
|
-
Read [develop.md](doc/workflows/develop.md)
|
|
24
|
+
Read [develop.md](doc/en/workflows/develop.md)
|
|
25
25
|
|
|
26
26
|
## Tools
|
|
27
27
|
|
|
28
|
-
Read [tools.md](doc/workflows/tools.md)
|
|
28
|
+
Read [tools.md](doc/en/workflows/tools.md)
|
|
29
29
|
|
|
30
30
|
## Superheros
|
|
31
31
|
|
|
32
|
-
Read [super-hero.md](doc/workflows/super-hero.md)
|
|
32
|
+
Read [super-hero.md](doc/en/workflows/super-hero.md)
|
package/README.public.md
CHANGED
|
@@ -286,6 +286,7 @@ const enriched: ConnectorPayload = {
|
|
|
286
286
|
cksum: 'sha256:...', // content checksum
|
|
287
287
|
stamp: { domain: 'office', epoch: 3, hub: 'node-7', n: 12 }, // hub order
|
|
288
288
|
src: 'node-3', // set by the relaying hub: the node it came from
|
|
289
|
+
holders: { 'node-3': 'ref', 'node-5': 'prev-timeId' }, // set by the hub
|
|
289
290
|
};
|
|
290
291
|
```
|
|
291
292
|
|
|
@@ -293,6 +294,11 @@ A hub sets `src` when it relays a ref: the node id of the client it received
|
|
|
293
294
|
the ref from. A receiver may read the ref's data from that node first; the
|
|
294
295
|
field is a hint, and the hub can still serve the data.
|
|
295
296
|
|
|
297
|
+
A hub also sets `holders` on what it sends: per node, the newest ref that node
|
|
298
|
+
holds completely (`RouteHolders`). A client says its node holds a ref by
|
|
299
|
+
sending a `HeldPayload` (`{ r }`) on `syncEvents(route).held`. A reader may ask
|
|
300
|
+
these nodes for the data before the hub.
|
|
301
|
+
|
|
296
302
|
### AckPayload
|
|
297
303
|
|
|
298
304
|
Server → Client acknowledgment that all (or some) receivers got a ref.
|
|
@@ -635,11 +635,19 @@ The payload transmitted on the wire between Connector and Server:
|
|
|
635
635
|
| `cksum` | `string` | Acknowledgment | Content checksum for ACK verification |
|
|
636
636
|
| `stamp` | `RefStamp` | Hub order | Where a stamping hub placed the ref |
|
|
637
637
|
| `src` | `string` | Source node | Node to read the ref's data from first |
|
|
638
|
+
| `holders` | `RouteHolders` | Holders | Which node holds which ref of the route |
|
|
638
639
|
|
|
639
640
|
`src` is set by the relaying hub, never by the sender: the node id of the
|
|
640
641
|
client it received the ref from, or nothing when it does not know that node.
|
|
641
642
|
It is a hint for readers; the hub can always serve the data.
|
|
642
643
|
|
|
644
|
+
`holders` is set by a hub on what it sends its clients — relayed refs, the
|
|
645
|
+
bootstrap, the state beacon: per node id, the newest ref that node holds
|
|
646
|
+
completely (`RouteHolders`). A node enters it as the sender of a ref, or by
|
|
647
|
+
sending a `HeldPayload` (`{ r }`) on `${route}:held`, and leaves it when its
|
|
648
|
+
last connection to the hub ends. Only nodes the receiver may read from are
|
|
649
|
+
named. A hint like `src`.
|
|
650
|
+
|
|
643
651
|
### AckPayload
|
|
644
652
|
|
|
645
653
|
Server → Client acknowledgment that all (or some) receivers successfully
|
|
@@ -701,6 +709,7 @@ Helper to generate typed socket event names from a route:
|
|
|
701
709
|
| `${route}:gapfill:res` | server → client | Supply missing refs |
|
|
702
710
|
| `${route}:bootstrap` | server → client | Latest ref on connect / heartbeat |
|
|
703
711
|
| `${route}:stamp` | server → sender | The stamp its announced ref got |
|
|
712
|
+
| `${route}:held` | client → server | Its node holds a ref completely |
|
|
704
713
|
|
|
705
714
|
### ClientId
|
|
706
715
|
|
|
@@ -776,6 +785,7 @@ src/
|
|
|
776
785
|
│ ├── client-id.ts # ClientId, clientId(), isClientId()
|
|
777
786
|
│ ├── connector-payload.ts # ConnectorPayload
|
|
778
787
|
│ ├── gap-fill.ts # GapFillRequest, GapFillResponse
|
|
788
|
+
│ ├── route-holders.ts # RouteHolders, HeldPayload
|
|
779
789
|
│ ├── sync-config.ts # SyncConfig
|
|
780
790
|
│ └── sync-events.ts # SyncEventNames, syncEvents()
|
|
781
791
|
│
|
package/dist/README.blog.md
CHANGED
|
@@ -5,4 +5,4 @@ Add latest posts at the end.
|
|
|
5
5
|
## 2026-11-02 — ConnectorPayload names its source
|
|
6
6
|
|
|
7
7
|
- `ConnectorPayload.src`: the node a relayed ref came from, set by the relaying hub
|
|
8
|
-
- Post: [
|
|
8
|
+
- Post: [pm/en/2026-Q4/blog/2026-11-02-connector-payload-names-its-source.md](pm/en/2026-Q4/blog/2026-11-02-connector-payload-names-its-source.md), German: [pm/de/2026-Q4/blog/2026-11-02-connector-payload-names-its-source.md](pm/de/2026-Q4/blog/2026-11-02-connector-payload-names-its-source.md)
|
|
@@ -15,18 +15,18 @@ found in the LICENSE file in the root of this package.
|
|
|
15
15
|
|
|
16
16
|
## Prepare
|
|
17
17
|
|
|
18
|
-
Read [prepare.md](doc/workflows/prepare.md)
|
|
18
|
+
Read [prepare.md](doc/en/workflows/prepare.md)
|
|
19
19
|
|
|
20
20
|
<!-- ........................................................................-->
|
|
21
21
|
|
|
22
22
|
## Develop
|
|
23
23
|
|
|
24
|
-
Read [develop.md](doc/workflows/develop.md)
|
|
24
|
+
Read [develop.md](doc/en/workflows/develop.md)
|
|
25
25
|
|
|
26
26
|
## Tools
|
|
27
27
|
|
|
28
|
-
Read [tools.md](doc/workflows/tools.md)
|
|
28
|
+
Read [tools.md](doc/en/workflows/tools.md)
|
|
29
29
|
|
|
30
30
|
## Superheros
|
|
31
31
|
|
|
32
|
-
Read [super-hero.md](doc/workflows/super-hero.md)
|
|
32
|
+
Read [super-hero.md](doc/en/workflows/super-hero.md)
|
package/dist/README.public.md
CHANGED
|
@@ -286,6 +286,7 @@ const enriched: ConnectorPayload = {
|
|
|
286
286
|
cksum: 'sha256:...', // content checksum
|
|
287
287
|
stamp: { domain: 'office', epoch: 3, hub: 'node-7', n: 12 }, // hub order
|
|
288
288
|
src: 'node-3', // set by the relaying hub: the node it came from
|
|
289
|
+
holders: { 'node-3': 'ref', 'node-5': 'prev-timeId' }, // set by the hub
|
|
289
290
|
};
|
|
290
291
|
```
|
|
291
292
|
|
|
@@ -293,6 +294,11 @@ A hub sets `src` when it relays a ref: the node id of the client it received
|
|
|
293
294
|
the ref from. A receiver may read the ref's data from that node first; the
|
|
294
295
|
field is a hint, and the hub can still serve the data.
|
|
295
296
|
|
|
297
|
+
A hub also sets `holders` on what it sends: per node, the newest ref that node
|
|
298
|
+
holds completely (`RouteHolders`). A client says its node holds a ref by
|
|
299
|
+
sending a `HeldPayload` (`{ r }`) on `syncEvents(route).held`. A reader may ask
|
|
300
|
+
these nodes for the data before the hub.
|
|
301
|
+
|
|
296
302
|
### AckPayload
|
|
297
303
|
|
|
298
304
|
Server → Client acknowledgment that all (or some) receivers got a ref.
|
package/dist/content/cake.d.ts
CHANGED
|
@@ -50,9 +50,6 @@ export interface Cake extends Json {
|
|
|
50
50
|
*/
|
|
51
51
|
export type CakesTable = RljsonTable<Cake, 'cakes'>;
|
|
52
52
|
/**
|
|
53
|
-
* Sample Table as BoilerPlate for Tests and Examples
|
|
54
|
-
*/
|
|
55
|
-
/**pnpm build
|
|
56
53
|
* Sample Table as BoilerPlate for Tests and Examples
|
|
57
54
|
* @param cakeKey - the key of the cake table cfg
|
|
58
55
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export * from './sync/conflict.ts';
|
|
|
22
22
|
export * from './sync/connector-payload.ts';
|
|
23
23
|
export * from './sync/gap-fill.ts';
|
|
24
24
|
export * from './sync/ref-stamp.ts';
|
|
25
|
+
export * from './sync/route-holders.ts';
|
|
25
26
|
export * from './sync/sync-config.ts';
|
|
26
27
|
export * from './sync/sync-events.ts';
|
|
27
28
|
export * from './tables/tables.ts';
|
package/dist/rljson.js
CHANGED
|
@@ -435,9 +435,6 @@ var exampleBuffetsTable = () => bakeryExample().buffets;
|
|
|
435
435
|
// @license
|
|
436
436
|
/**
|
|
437
437
|
* Sample Table as BoilerPlate for Tests and Examples
|
|
438
|
-
*/
|
|
439
|
-
/**pnpm build
|
|
440
|
-
* Sample Table as BoilerPlate for Tests and Examples
|
|
441
438
|
* @param cakeKey - the key of the cake table cfg
|
|
442
439
|
*/
|
|
443
440
|
var createCakeTableCfg = (cakeKey) => ({
|
|
@@ -560,7 +557,7 @@ var exampleRevision = () => ({
|
|
|
560
557
|
id: "flour",
|
|
561
558
|
predecessor: "gZXFSlrl5QAs5hOVsq5sWB",
|
|
562
559
|
successor: "IqeoWJjZQNlr-NVk2QT15B",
|
|
563
|
-
timestamp:
|
|
560
|
+
timestamp: 0x67ec971b
|
|
564
561
|
});
|
|
565
562
|
// src/content/slice-ids.ts
|
|
566
563
|
// @license
|
|
@@ -1864,8 +1861,7 @@ var _isTable = (value) => {
|
|
|
1864
1861
|
*/
|
|
1865
1862
|
var iterateTablesSync = (rljson, callback) => {
|
|
1866
1863
|
for (const tableKey in rljson) {
|
|
1867
|
-
|
|
1868
|
-
if (!_isTable(value)) continue;
|
|
1864
|
+
if (!_isTable(rljson[tableKey])) continue;
|
|
1869
1865
|
callback(tableKey, rljson[tableKey]);
|
|
1870
1866
|
}
|
|
1871
1867
|
};
|
|
@@ -1881,8 +1877,7 @@ var iterateTables = async (rljson, callback) => {
|
|
|
1881
1877
|
const array = [];
|
|
1882
1878
|
const errors = [];
|
|
1883
1879
|
for (const tableKey in rljson) {
|
|
1884
|
-
|
|
1885
|
-
if (!_isTable(value)) continue;
|
|
1880
|
+
if (!_isTable(rljson[tableKey])) continue;
|
|
1886
1881
|
const promise = callback(tableKey, rljson[tableKey]).catch((error) => {
|
|
1887
1882
|
errors.push({
|
|
1888
1883
|
tableKey,
|
|
@@ -1940,6 +1935,22 @@ var isClientId = (id) => {
|
|
|
1940
1935
|
* Returns an example ClientId for documentation and testing.
|
|
1941
1936
|
*/
|
|
1942
1937
|
var clientIdExample = () => "client_ExAmPlE12345";
|
|
1938
|
+
// src/sync/route-holders.ts
|
|
1939
|
+
// @license
|
|
1940
|
+
/**
|
|
1941
|
+
* Returns an example of the holders of a route.
|
|
1942
|
+
* @returns Two nodes on the newer ref, one on an older one.
|
|
1943
|
+
*/
|
|
1944
|
+
var routeHoldersExample = () => ({
|
|
1945
|
+
node_ExAmPlE: "1700000000001:EfGh",
|
|
1946
|
+
node_OtHeR: "1700000000001:EfGh",
|
|
1947
|
+
node_BeHiNd: "1700000000000:XyZw"
|
|
1948
|
+
});
|
|
1949
|
+
/**
|
|
1950
|
+
* Returns an example held payload.
|
|
1951
|
+
* @returns The payload.
|
|
1952
|
+
*/
|
|
1953
|
+
var heldPayloadExample = () => ({ r: "1700000000001:EfGh" });
|
|
1943
1954
|
// src/sync/connector-payload.ts
|
|
1944
1955
|
// @license
|
|
1945
1956
|
/**
|
|
@@ -1956,7 +1967,7 @@ var connectorPayloadFullExample = () => ({
|
|
|
1956
1967
|
o: "1700000000000:AbCd",
|
|
1957
1968
|
r: "1700000000001:EfGh",
|
|
1958
1969
|
c: "client_ExAmPlE12345",
|
|
1959
|
-
t:
|
|
1970
|
+
t: 0x18bcfe56801,
|
|
1960
1971
|
seq: 42,
|
|
1961
1972
|
p: ["1700000000000:XyZw"],
|
|
1962
1973
|
cksum: "sha256:abc123def456",
|
|
@@ -1966,7 +1977,8 @@ var connectorPayloadFullExample = () => ({
|
|
|
1966
1977
|
hub: "hub_ExAmPlE",
|
|
1967
1978
|
n: 1
|
|
1968
1979
|
},
|
|
1969
|
-
src: "node_ExAmPlE"
|
|
1980
|
+
src: "node_ExAmPlE",
|
|
1981
|
+
holders: routeHoldersExample()
|
|
1970
1982
|
});
|
|
1971
1983
|
// src/sync/gap-fill.ts
|
|
1972
1984
|
// @license
|
|
@@ -2076,7 +2088,8 @@ var syncEvents = (route) => ({
|
|
|
2076
2088
|
gapFillReq: `${route}:gapfill:req`,
|
|
2077
2089
|
gapFillRes: `${route}:gapfill:res`,
|
|
2078
2090
|
bootstrap: `${route}:bootstrap`,
|
|
2079
|
-
stamp: `${route}:stamp
|
|
2091
|
+
stamp: `${route}:stamp`,
|
|
2092
|
+
held: `${route}:held`
|
|
2080
2093
|
});
|
|
2081
2094
|
// src/tables/tables.ts
|
|
2082
2095
|
// @license
|
|
@@ -3039,4 +3052,4 @@ var Validate = class {
|
|
|
3039
3052
|
};
|
|
3040
3053
|
// src/index.ts
|
|
3041
3054
|
// @license
|
|
3042
|
-
export { BaseValidator, Example, InsertValidator, Route, Tables, Validate, ackPayloadExample, ackPayloadPartialExample, addColumnsToTableCfg, bakeryExample, clientId, clientIdExample, compareRefStamp, connectorPayloadExample, connectorPayloadFullExample, contentTypes, createCakeTableCfg, createEditHistoryTableCfg, createEditTableCfg, createInsertHistoryTableCfg, createLayerTableCfg, createMultiEditTableCfg, createSliceIdsTableCfg, createTreesTableCfg, exampleBuffetsTable, exampleCakesTable, exampleComponentsTable, exampleInsert, exampleInsertHistoryTable, exampleLayersTable, exampleRevision, exampleRljson, exampleSliceIdsTable, exampleTableCfg, exampleTableCfgTable, exampleTreesTable, exampleTypedefs, gapFillRequestExample, gapFillResponseExample, getTimeIdTimestamp, getTimeIdUniquePart, isClientId, isRefStamp, isTimeId, isValidFieldName, iterateTables, iterateTablesSync, mergeSliceIds, ref, refStampExample, removeDuplicates, reservedFieldNames, reservedTableKeys, resolveSliceIds, routeRefSeperator, routeSliceIdIndicators, routeSliceIdSeperator, rowOf, stampPayloadExample, syncConfigCausalOnlyExample, syncConfigDefault, syncConfigFullExample, syncEvents, throwOnInvalidTableCfg, timeId, treeFromObject, validateInsert, validateRljsonAgainstTableCfg };
|
|
3055
|
+
export { BaseValidator, Example, InsertValidator, Route, Tables, Validate, ackPayloadExample, ackPayloadPartialExample, addColumnsToTableCfg, bakeryExample, clientId, clientIdExample, compareRefStamp, connectorPayloadExample, connectorPayloadFullExample, contentTypes, createCakeTableCfg, createEditHistoryTableCfg, createEditTableCfg, createInsertHistoryTableCfg, createLayerTableCfg, createMultiEditTableCfg, createSliceIdsTableCfg, createTreesTableCfg, exampleBuffetsTable, exampleCakesTable, exampleComponentsTable, exampleInsert, exampleInsertHistoryTable, exampleLayersTable, exampleRevision, exampleRljson, exampleSliceIdsTable, exampleTableCfg, exampleTableCfgTable, exampleTreesTable, exampleTypedefs, gapFillRequestExample, gapFillResponseExample, getTimeIdTimestamp, getTimeIdUniquePart, heldPayloadExample, isClientId, isRefStamp, isTimeId, isValidFieldName, iterateTables, iterateTablesSync, mergeSliceIds, ref, refStampExample, removeDuplicates, reservedFieldNames, reservedTableKeys, resolveSliceIds, routeHoldersExample, routeRefSeperator, routeSliceIdIndicators, routeSliceIdSeperator, rowOf, stampPayloadExample, syncConfigCausalOnlyExample, syncConfigDefault, syncConfigFullExample, syncEvents, throwOnInvalidTableCfg, timeId, treeFromObject, validateInsert, validateRljsonAgainstTableCfg };
|
package/dist/rljson_version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The version of the `@rljson/rljson` package. */
|
|
2
|
-
export declare const rljsonVersion = "0.0.
|
|
2
|
+
export declare const rljsonVersion = "0.0.91";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { InsertHistoryTimeId } from '../insertHistory/insertHistory.ts';
|
|
2
2
|
import { ClientId } from './client-id.ts';
|
|
3
3
|
import { RefStamp } from './ref-stamp.ts';
|
|
4
|
+
import { RouteHolders } from './route-holders.ts';
|
|
4
5
|
/**
|
|
5
6
|
* Wire-protocol payload transmitted between Connector and Server.
|
|
6
7
|
*
|
|
@@ -9,17 +10,18 @@ import { RefStamp } from './ref-stamp.ts';
|
|
|
9
10
|
* optional and activate only when the corresponding `SyncConfig`
|
|
10
11
|
* flags are set.
|
|
11
12
|
*
|
|
12
|
-
* | Field
|
|
13
|
-
*
|
|
14
|
-
* | `r`
|
|
15
|
-
* | `o`
|
|
16
|
-
* | `c`
|
|
17
|
-
* | `t`
|
|
18
|
-
* | `seq`
|
|
19
|
-
* | `p`
|
|
20
|
-
* | `cksum`
|
|
21
|
-
* | `stamp`
|
|
22
|
-
* | `src`
|
|
13
|
+
* | Field | Concept | Purpose |
|
|
14
|
+
* |-----------|-------------------|-----------------------------------------|
|
|
15
|
+
* | `r` | existing | The ref being announced |
|
|
16
|
+
* | `o` | existing | Ephemeral origin for self-echo filter |
|
|
17
|
+
* | `c` | Client identity | Stable client id across reconnections |
|
|
18
|
+
* | `t` | Client identity | Client-side wall-clock timestamp (ms) |
|
|
19
|
+
* | `seq` | Predecessor chain | Monotonic counter per (client, route) |
|
|
20
|
+
* | `p` | Predecessor chain | Causal predecessor timeIds |
|
|
21
|
+
* | `cksum` | Acknowledgment | Content checksum for ACK verification |
|
|
22
|
+
* | `stamp` | Hub order | Where a stamping hub placed the ref |
|
|
23
|
+
* | `src` | Source node | Node to read the ref's data from first |
|
|
24
|
+
* | `holders` | Holders | Which node holds which ref of the route |
|
|
23
25
|
*/
|
|
24
26
|
export type ConnectorPayload = {
|
|
25
27
|
/** The ref (InsertHistoryTimeId) being announced. */
|
|
@@ -53,6 +55,16 @@ export type ConnectorPayload = {
|
|
|
53
55
|
* may be gone or unreachable, and the hub can still serve the data.
|
|
54
56
|
*/
|
|
55
57
|
src?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Which node holds which ref of the route, as the hub knows it: per node,
|
|
60
|
+
* the newest ref it holds completely.
|
|
61
|
+
*
|
|
62
|
+
* Set by a hub on what it sends its clients — relayed refs, the bootstrap,
|
|
63
|
+
* the state beacon — never by a sender: a hub overwrites what arrives. Only
|
|
64
|
+
* nodes the receiver may read from are named. A hint, like `src`: a reader
|
|
65
|
+
* may ask these nodes for the data before the hub.
|
|
66
|
+
*/
|
|
67
|
+
holders?: RouteHolders;
|
|
56
68
|
};
|
|
57
69
|
/**
|
|
58
70
|
* Returns a minimal example ConnectorPayload (backward-compatible format).
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { InsertHistoryTimeId } from '../insertHistory/insertHistory.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Which node holds which state of a route: per node id, the newest ref the
|
|
4
|
+
* node holds completely — every row under it in its own store.
|
|
5
|
+
*
|
|
6
|
+
* A hub keeps one per route and sends it with what it sends its clients, so a
|
|
7
|
+
* reader knows which nodes it can read a ref's data from besides the hub. A
|
|
8
|
+
* node enters it as the sender of a ref, or by saying it holds one
|
|
9
|
+
* ({@link HeldPayload}), and leaves it when its last connection to the hub
|
|
10
|
+
* ends.
|
|
11
|
+
*
|
|
12
|
+
* A hint, not a promise: a node may have moved on, may be gone, or may lack a
|
|
13
|
+
* blob the rows name. The hub can still serve the data.
|
|
14
|
+
*/
|
|
15
|
+
export type RouteHolders = Record<string, InsertHistoryTimeId>;
|
|
16
|
+
/**
|
|
17
|
+
* Client → Server: the client's node holds a ref of the route completely.
|
|
18
|
+
*
|
|
19
|
+
* Sent on `${route}:held` ({@link SyncEventNames.held}). It carries no node
|
|
20
|
+
* id: the hub knows which node a connection belongs to.
|
|
21
|
+
*/
|
|
22
|
+
export type HeldPayload = {
|
|
23
|
+
/** The ref the node holds every row under. */
|
|
24
|
+
r: InsertHistoryTimeId;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Returns an example of the holders of a route.
|
|
28
|
+
* @returns Two nodes on the newer ref, one on an older one.
|
|
29
|
+
*/
|
|
30
|
+
export declare const routeHoldersExample: () => RouteHolders;
|
|
31
|
+
/**
|
|
32
|
+
* Returns an example held payload.
|
|
33
|
+
* @returns The payload.
|
|
34
|
+
*/
|
|
35
|
+
export declare const heldPayloadExample: () => HeldPayload;
|
|
@@ -25,6 +25,8 @@ export type SyncEventNames = {
|
|
|
25
25
|
bootstrap: string;
|
|
26
26
|
/** Server → Client (sender only): the stamp its announced ref received. */
|
|
27
27
|
stamp: string;
|
|
28
|
+
/** Client → Server: the client's node holds a ref completely. */
|
|
29
|
+
held: string;
|
|
28
30
|
};
|
|
29
31
|
/**
|
|
30
32
|
* Creates typed, route-specific socket event names for the sync protocol.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rljson/rljson",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.91",
|
|
4
4
|
"description": "The RLJSON data format specification",
|
|
5
5
|
"homepage": "https://github.com/rljson/rljson",
|
|
6
6
|
"bugs": "https://github.com/rljson/rljson/issues",
|
|
@@ -20,35 +20,35 @@
|
|
|
20
20
|
],
|
|
21
21
|
"type": "module",
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@rljson/dna-rljson": "^0.
|
|
24
|
-
"@tssuite/helix-js": "^0.
|
|
25
|
-
"@types/node": "^26.6.
|
|
26
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
27
|
-
"@typescript-eslint/parser": "^8.
|
|
28
|
-
"@vitest/coverage-v8": "^5.
|
|
23
|
+
"@rljson/dna-rljson": "^0.4.0",
|
|
24
|
+
"@tssuite/helix-js": "^0.9.0",
|
|
25
|
+
"@types/node": "^26.6.11",
|
|
26
|
+
"@typescript-eslint/eslint-plugin": "^8.74.0",
|
|
27
|
+
"@typescript-eslint/parser": "^8.74.0",
|
|
28
|
+
"@vitest/coverage-v8": "^5.1.2",
|
|
29
29
|
"cross-env": "^10.1.0",
|
|
30
|
-
"eslint": "^10.
|
|
31
|
-
"eslint-plugin-jsdoc": "^65.
|
|
30
|
+
"eslint": "^10.16.0",
|
|
31
|
+
"eslint-plugin-jsdoc": "^65.5.7",
|
|
32
32
|
"eslint-plugin-tsdoc": "^0.5.4",
|
|
33
33
|
"globals": "^17.14.0",
|
|
34
34
|
"jsdoc": "^4.0.5",
|
|
35
35
|
"read-pkg": "^10.1.0",
|
|
36
36
|
"typescript": "~6.0.3",
|
|
37
|
-
"typescript-eslint": "^8.
|
|
38
|
-
"vite": "^8.
|
|
37
|
+
"typescript-eslint": "^8.74.0",
|
|
38
|
+
"vite": "^8.4.0",
|
|
39
39
|
"vite-node": "^6.0.0",
|
|
40
40
|
"vite-plugin-dts": "^5.1.2",
|
|
41
41
|
"vite-tsconfig-paths": "^6.1.1",
|
|
42
|
-
"vitest": "^5.
|
|
42
|
+
"vitest": "^5.1.2",
|
|
43
43
|
"vitest-dom": "^0.1.1"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@rljson/hash": "0.0.
|
|
46
|
+
"@rljson/hash": "0.0.22",
|
|
47
47
|
"@rljson/json": "0.0.23",
|
|
48
48
|
"nanoid": "^6.0.2"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
|
-
"build": "pnpm test && vite build && tsc &&
|
|
51
|
+
"build": "pnpm test && vite build && tsc && node scripts/copy-readme-to-dist.js",
|
|
52
52
|
"test": "vitest run --coverage && npm run lint",
|
|
53
53
|
"lint": "eslint",
|
|
54
54
|
"updateGoldens": "cross-env UPDATE_GOLDENS=true npm test"
|