@serfab/cadre-core 1.19.0 → 1.20.0
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/dist/cadre-node.d.ts +118 -16
- package/dist/cadre-node.js +210 -31
- package/dist/cadre-node.js.map +1 -1
- package/dist/control-database.d.ts +2 -1
- package/dist/control-database.js +128 -126
- package/dist/control-database.js.map +1 -1
- package/dist/control-protocol-guard.js +3 -2
- package/dist/control-protocol-guard.js.map +1 -1
- package/dist/control-read-retry.d.ts +19 -16
- package/dist/control-read-retry.js +22 -54
- package/dist/control-read-retry.js.map +1 -1
- package/dist/control-retry.d.ts +50 -6
- package/dist/control-retry.js +53 -6
- package/dist/control-retry.js.map +1 -1
- package/dist/control-stream.js +2 -1
- package/dist/control-stream.js.map +1 -1
- package/dist/control-write-retry.d.ts +24 -16
- package/dist/control-write-retry.js +58 -30
- package/dist/control-write-retry.js.map +1 -1
- package/dist/describe-thrown.d.ts +12 -0
- package/dist/describe-thrown.js +59 -0
- package/dist/describe-thrown.js.map +1 -0
- package/dist/edge-node/config.d.ts +8 -2
- package/dist/edge-node/config.js +5 -1
- package/dist/edge-node/config.js.map +1 -1
- package/dist/edge-node/dissolve.d.ts +1 -1
- package/dist/edge-node/dissolve.js +1 -1
- package/dist/edge-node/dissolve.js.map +1 -1
- package/dist/edge-node/edge-join.js +4 -1
- package/dist/edge-node/edge-join.js.map +1 -1
- package/dist/edge-node/edge-node.d.ts +10 -0
- package/dist/edge-node/edge-node.js +54 -9
- package/dist/edge-node/edge-node.js.map +1 -1
- package/dist/edge-node/options.d.ts +11 -2
- package/dist/edge-node/options.js +11 -4
- package/dist/edge-node/options.js.map +1 -1
- package/dist/edge-node/platform.d.ts +15 -3
- package/dist/edge-node/strand-move.d.ts +0 -2
- package/dist/edge-node/strand-move.js +1 -4
- package/dist/edge-node/strand-move.js.map +1 -1
- package/dist/edge-node/strands.js +5 -3
- package/dist/edge-node/strands.js.map +1 -1
- package/dist/enrollment.js +2 -1
- package/dist/enrollment.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/member-redemption.js +3 -9
- package/dist/member-redemption.js.map +1 -1
- package/dist/node-local-snapshot.js +2 -1
- package/dist/node-local-snapshot.js.map +1 -1
- package/dist/peer-dial.js +3 -2
- package/dist/peer-dial.js.map +1 -1
- package/dist/pending-join-runner.d.ts +29 -2
- package/dist/pending-join-runner.js +60 -20
- package/dist/pending-join-runner.js.map +1 -1
- package/dist/push-notifier-apns.js +8 -7
- package/dist/push-notifier-apns.js.map +1 -1
- package/dist/push-notifier-fcm.js +6 -5
- package/dist/push-notifier-fcm.js.map +1 -1
- package/dist/push-notifier-shared.d.ts +0 -2
- package/dist/push-notifier-shared.js +4 -4
- package/dist/push-notifier-shared.js.map +1 -1
- package/dist/relay-reservation.js +4 -3
- package/dist/relay-reservation.js.map +1 -1
- package/dist/strand-addr-protocol.js +2 -1
- package/dist/strand-addr-protocol.js.map +1 -1
- package/dist/strand-app-schema-report.d.ts +53 -0
- package/dist/strand-app-schema-report.js +77 -0
- package/dist/strand-app-schema-report.js.map +1 -0
- package/dist/strand-database.d.ts +60 -0
- package/dist/strand-database.js +93 -0
- package/dist/strand-database.js.map +1 -1
- package/dist/strand-first-sync-gate.js +4 -3
- package/dist/strand-first-sync-gate.js.map +1 -1
- package/dist/strand-formation-protocol.js +4 -3
- package/dist/strand-formation-protocol.js.map +1 -1
- package/dist/strand-instance-manager.d.ts +73 -2
- package/dist/strand-instance-manager.js +112 -9
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-membership-reconciler.d.ts +13 -1
- package/dist/strand-membership-reconciler.js +25 -16
- package/dist/strand-membership-reconciler.js.map +1 -1
- package/dist/strand-membership-writer.d.ts +16 -2
- package/dist/strand-membership-writer.js +54 -8
- package/dist/strand-membership-writer.js.map +1 -1
- package/dist/strand-move.js +4 -6
- package/dist/strand-move.js.map +1 -1
- package/dist/strand-offline.d.ts +102 -0
- package/dist/strand-offline.js +97 -0
- package/dist/strand-offline.js.map +1 -0
- package/dist/types.d.ts +37 -0
- package/dist/types.js.map +1 -1
- package/package.json +8 -8
- package/src/cadre-node.ts +230 -31
- package/src/control-database.ts +5594 -5592
- package/src/control-protocol-guard.ts +3 -2
- package/src/control-read-retry.ts +22 -58
- package/src/control-retry.ts +54 -6
- package/src/control-stream.ts +2 -1
- package/src/control-write-retry.ts +58 -30
- package/src/describe-thrown.ts +60 -0
- package/src/edge-node/config.ts +11 -2
- package/src/edge-node/dissolve.ts +2 -1
- package/src/edge-node/edge-join.ts +2 -1
- package/src/edge-node/edge-node.ts +57 -7
- package/src/edge-node/options.ts +20 -4
- package/src/edge-node/platform.ts +15 -3
- package/src/edge-node/strand-move.ts +1 -5
- package/src/edge-node/strands.ts +74 -72
- package/src/enrollment.ts +2 -1
- package/src/index.ts +27 -1
- package/src/member-redemption.ts +3 -9
- package/src/node-local-snapshot.ts +2 -1
- package/src/peer-dial.ts +605 -604
- package/src/pending-join-runner.ts +68 -22
- package/src/push-notifier-apns.ts +8 -7
- package/src/push-notifier-fcm.ts +6 -5
- package/src/push-notifier-shared.ts +5 -5
- package/src/relay-reservation.ts +1212 -1211
- package/src/strand-addr-protocol.ts +2 -1
- package/src/strand-app-schema-report.ts +115 -0
- package/src/strand-database.ts +123 -1
- package/src/strand-first-sync-gate.ts +600 -599
- package/src/strand-formation-protocol.ts +4 -3
- package/src/strand-instance-manager.ts +137 -10
- package/src/strand-membership-reconciler.ts +942 -928
- package/src/strand-membership-writer.ts +61 -14
- package/src/strand-move.ts +594 -597
- package/src/strand-offline.ts +178 -0
- package/src/types.ts +36 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { IKVStore } from '@optimystic/db-p2p';
|
|
2
|
+
import type { OfflineModeState, QueuedTransactionStatus, StrandOfflineController } from '@serfab/quereus-plugin-sereus';
|
|
3
|
+
/**
|
|
4
|
+
* Which acknowledgement a strand's transactions get from the moment it is set: `'offline'`, a
|
|
5
|
+
* commit resolves once the transaction is queued on this machine; `'online'`, once the strand's
|
|
6
|
+
* members have taken it.
|
|
7
|
+
*/
|
|
8
|
+
export type StrandOfflineMode = 'online' | 'offline';
|
|
9
|
+
/** `CadreNodeConfig.strandOffline`: what a node needs to offer offline mode on its strands. */
|
|
10
|
+
export interface StrandOfflineConfig {
|
|
11
|
+
/**
|
|
12
|
+
* The journal for one strand: called once per database build with the strand id (a storage scope
|
|
13
|
+
* key). Queued transactions are saved in it before their commit resolves, so they survive a
|
|
14
|
+
* restart. A throw or rejection fails the build, as a storage provider's does.
|
|
15
|
+
*
|
|
16
|
+
* Nothing in cadre-core or Optimystic closes the store, and every rebuild (a wake, a retry while
|
|
17
|
+
* no seed peer answers) calls this again, so return the same store for the same scope and close
|
|
18
|
+
* it yourself after the node stops.
|
|
19
|
+
*/
|
|
20
|
+
journal: (scope: string) => IKVStore | Promise<IKVStore>;
|
|
21
|
+
/** The mode every strand starts in until the app sets one. Default `'online'`. */
|
|
22
|
+
initialMode?: StrandOfflineMode;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* `StrandDatabase.offline`: the strand connection's offline queue, less the mode switch, which
|
|
26
|
+
* goes through `CadreNode.setStrandOfflineMode` so that it outlives the database. Listeners taken
|
|
27
|
+
* here die with the database; the `CadreNode` events do not.
|
|
28
|
+
*/
|
|
29
|
+
export type StrandOfflineQueue = Pick<StrandOfflineController, 'queueState' | 'entries' | 'status' | 'outcomes' | 'acknowledge' | 'discard' | 'whenDrained' | 'onStatus' | 'onQueueState'>;
|
|
30
|
+
/** `strand:offline-status`: one status of one queued transaction. */
|
|
31
|
+
export interface StrandOfflineStatus {
|
|
32
|
+
readonly strandId: string;
|
|
33
|
+
readonly status: QueuedTransactionStatus;
|
|
34
|
+
}
|
|
35
|
+
/** `strand:queue-state`: the queue's state, for a status line. */
|
|
36
|
+
export interface StrandQueueState {
|
|
37
|
+
readonly strandId: string;
|
|
38
|
+
readonly state: OfflineModeState;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Where a strand database reports its offline queue. Retained with the launch config and handed to
|
|
42
|
+
* every database built for the launch, so the reports outlive hibernation and every other rebuild.
|
|
43
|
+
*/
|
|
44
|
+
export interface StrandOfflineListeners {
|
|
45
|
+
onOfflineStatus?: (event: StrandOfflineStatus) => void;
|
|
46
|
+
onQueueState?: (event: StrandQueueState) => void;
|
|
47
|
+
}
|
|
48
|
+
/** Thrown by `CadreNode.setStrandOfflineMode` on a node configured without `strandOffline`. */
|
|
49
|
+
export declare class StrandOfflineUnavailableError extends Error {
|
|
50
|
+
readonly strandId: string;
|
|
51
|
+
constructor(strandId: string);
|
|
52
|
+
}
|
|
53
|
+
/** Options for leaving a strand: `CadreNode.forgetJoinedStrand` and `CadreNode.unpublishStrand`. */
|
|
54
|
+
export interface StrandLeaveOptions {
|
|
55
|
+
/**
|
|
56
|
+
* Withdraw the strand's queued offline transactions that were never sent, then leave. Without
|
|
57
|
+
* it a leave refuses with {@link StrandQueueNotEmptyError} while the queue holds any: the app was
|
|
58
|
+
* told each of them was acknowledged, so dropping them is the user's choice to make.
|
|
59
|
+
*/
|
|
60
|
+
discardQueued?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Thrown by a leave ({@link StrandLeaveOptions}) while the strand's offline queue holds
|
|
64
|
+
* transactions and `discardQueued` was not given. Nothing was left or removed.
|
|
65
|
+
*/
|
|
66
|
+
export declare class StrandQueueNotEmptyError extends Error {
|
|
67
|
+
readonly strandId: string;
|
|
68
|
+
/** The queued transactions, by the `StampId()` each one's statements returned. */
|
|
69
|
+
readonly transactionIds: readonly string[];
|
|
70
|
+
constructor(strandId: string, transactionIds: readonly string[]);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Withdraw every transaction in `queue` that was never sent, for a leave the app confirmed
|
|
74
|
+
* ({@link StrandLeaveOptions.discardQueued}). Returns the ones Optimystic refuses to withdraw
|
|
75
|
+
* (`EntryNotDiscardableError`): each was sent, or is being sent or restored, and the strand's
|
|
76
|
+
* members may already hold it, so it stays in the journal. One that settled meanwhile, or failed
|
|
77
|
+
* with a transaction it depended on, is already gone.
|
|
78
|
+
*/
|
|
79
|
+
export declare function discardQueued(queue: Pick<StrandOfflineController, 'entries' | 'discard'>): string[];
|
|
80
|
+
/**
|
|
81
|
+
* Whether a status shows the queue sending, which counts as strand activity for hibernation. A
|
|
82
|
+
* transaction waiting for its cohort (`queued`) is not, or an offline phone would never hibernate.
|
|
83
|
+
*/
|
|
84
|
+
export declare function isSendingStatus(status: QueuedTransactionStatus): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* What one strand database reports about its offline queue. Built once `connectToStrand` has
|
|
87
|
+
* returned (a restored transaction's `queued` status was delivered during its `hydrate`, before this
|
|
88
|
+
* subscribes: {@link published} reports the queue's state for that reason) and released first when
|
|
89
|
+
* the database closes, so nothing from a closing connection reaches the app.
|
|
90
|
+
*/
|
|
91
|
+
export declare class StrandOfflineReport {
|
|
92
|
+
private readonly strandId;
|
|
93
|
+
private readonly listeners;
|
|
94
|
+
private readonly queue;
|
|
95
|
+
private wasPublished;
|
|
96
|
+
private released;
|
|
97
|
+
private readonly unsubscribe;
|
|
98
|
+
constructor(strandId: string, listeners: StrandOfflineListeners, queue: StrandOfflineController | undefined);
|
|
99
|
+
/** The database was handed to the app: report the queue's state. */
|
|
100
|
+
published(): void;
|
|
101
|
+
release(): void;
|
|
102
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { EntryNotDiscardableError, UnknownEntryError } from '@optimystic/db-core';
|
|
2
|
+
/** Thrown by `CadreNode.setStrandOfflineMode` on a node configured without `strandOffline`. */
|
|
3
|
+
export class StrandOfflineUnavailableError extends Error {
|
|
4
|
+
constructor(strandId) {
|
|
5
|
+
super(`Cannot put strand ${strandId} in offline mode: this node has no offline journal ` +
|
|
6
|
+
'(CadreNodeConfig.strandOffline is not configured), and a queue lost with the process would ' +
|
|
7
|
+
'break the promise a local commit makes.');
|
|
8
|
+
this.name = 'StrandOfflineUnavailableError';
|
|
9
|
+
this.strandId = strandId;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Thrown by a leave ({@link StrandLeaveOptions}) while the strand's offline queue holds
|
|
14
|
+
* transactions and `discardQueued` was not given. Nothing was left or removed.
|
|
15
|
+
*/
|
|
16
|
+
export class StrandQueueNotEmptyError extends Error {
|
|
17
|
+
constructor(strandId, transactionIds) {
|
|
18
|
+
super(`Cannot leave strand ${strandId}: its offline queue holds ${transactionIds.length} transaction(s) its ` +
|
|
19
|
+
`members have not taken yet (${transactionIds.join(', ')}), so nothing was left or removed. Show the user ` +
|
|
20
|
+
'the unsent changes, then leave again with { discardQueued: true } to drop them, or once ' +
|
|
21
|
+
'strand.database.offline.whenDrained() resolves.');
|
|
22
|
+
this.name = 'StrandQueueNotEmptyError';
|
|
23
|
+
this.strandId = strandId;
|
|
24
|
+
this.transactionIds = transactionIds;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Withdraw every transaction in `queue` that was never sent, for a leave the app confirmed
|
|
29
|
+
* ({@link StrandLeaveOptions.discardQueued}). Returns the ones Optimystic refuses to withdraw
|
|
30
|
+
* (`EntryNotDiscardableError`): each was sent, or is being sent or restored, and the strand's
|
|
31
|
+
* members may already hold it, so it stays in the journal. One that settled meanwhile, or failed
|
|
32
|
+
* with a transaction it depended on, is already gone.
|
|
33
|
+
*/
|
|
34
|
+
export function discardQueued(queue) {
|
|
35
|
+
const kept = [];
|
|
36
|
+
for (const { transactionId } of queue.entries()) {
|
|
37
|
+
try {
|
|
38
|
+
queue.discard(transactionId);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if (error instanceof EntryNotDiscardableError) {
|
|
42
|
+
kept.push(transactionId);
|
|
43
|
+
}
|
|
44
|
+
else if (!(error instanceof UnknownEntryError)) {
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return kept;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Whether a status shows the queue sending, which counts as strand activity for hibernation. A
|
|
53
|
+
* transaction waiting for its cohort (`queued`) is not, or an offline phone would never hibernate.
|
|
54
|
+
*/
|
|
55
|
+
// NOTE: a send that keeps failing transiently while the cohort reads as reachable is re-tried at
|
|
56
|
+
// least every 60 s (Optimystic's re-check cap), so such a strand never idles. If a phone is found
|
|
57
|
+
// kept awake that way, count only `committed`, `partially-committed` and `failed`.
|
|
58
|
+
export function isSendingStatus(status) {
|
|
59
|
+
return status.kind === 'submitting' || status.kind === 'committed'
|
|
60
|
+
|| status.kind === 'partially-committed' || status.kind === 'failed';
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* What one strand database reports about its offline queue. Built once `connectToStrand` has
|
|
64
|
+
* returned (a restored transaction's `queued` status was delivered during its `hydrate`, before this
|
|
65
|
+
* subscribes: {@link published} reports the queue's state for that reason) and released first when
|
|
66
|
+
* the database closes, so nothing from a closing connection reaches the app.
|
|
67
|
+
*/
|
|
68
|
+
export class StrandOfflineReport {
|
|
69
|
+
constructor(strandId, listeners, queue) {
|
|
70
|
+
this.strandId = strandId;
|
|
71
|
+
this.listeners = listeners;
|
|
72
|
+
this.queue = queue;
|
|
73
|
+
this.wasPublished = false;
|
|
74
|
+
this.released = false;
|
|
75
|
+
const unsubscribeStatus = queue?.onStatus((status) => listeners.onOfflineStatus?.({ strandId, status }));
|
|
76
|
+
const unsubscribeState = queue?.onQueueState((state) => listeners.onQueueState?.({ strandId, state }));
|
|
77
|
+
this.unsubscribe = () => {
|
|
78
|
+
unsubscribeStatus?.();
|
|
79
|
+
unsubscribeState?.();
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** The database was handed to the app: report the queue's state. */
|
|
83
|
+
published() {
|
|
84
|
+
if (this.released || this.wasPublished) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.wasPublished = true;
|
|
88
|
+
if (this.queue) {
|
|
89
|
+
this.listeners.onQueueState?.({ strandId: this.strandId, state: this.queue.queueState() });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
release() {
|
|
93
|
+
this.released = true;
|
|
94
|
+
this.unsubscribe();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=strand-offline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strand-offline.js","sourceRoot":"","sources":["../src/strand-offline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAwDlF,+FAA+F;AAC/F,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IAGtD,YAAY,QAAgB;QAC1B,KAAK,CACH,qBAAqB,QAAQ,qDAAqD;YAClF,6FAA6F;YAC7F,yCAAyC,CAC1C,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;QAC5C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAYD;;;GAGG;AACH,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IAKjD,YAAY,QAAgB,EAAE,cAAiC;QAC7D,KAAK,CACH,uBAAuB,QAAQ,6BAA6B,cAAc,CAAC,MAAM,sBAAsB;YACvG,+BAA+B,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,mDAAmD;YAC3G,0FAA0F;YAC1F,iDAAiD,CAClD,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAA2D;IACvF,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,KAAK,M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AAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QACvG,IAAI,CAAC,WAAW,GAAG,GAAG,EAAE;YACtB,iBAAiB,EAAE,EAAE,CAAC;YACtB,gBAAgB,EAAE,EAAE,CAAC;QACvB,CAAC,CAAC;IACJ,CAAC;IAED,oEAAoE;IACpE,SAAS;QACP,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACvC,OAAO;QACT,CAAC;QACD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAC7F,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;CACF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ import type { StrandMembershipReconciliationConfig } from './strand-membership-r
|
|
|
9
9
|
import type { StrandFirstSyncConfig } from './strand-first-sync-gate.js';
|
|
10
10
|
import type { StrandDatabase } from './strand-database.js';
|
|
11
11
|
import type { StrandCommitDurability, StrandCommitHeld } from './strand-commit-durability.js';
|
|
12
|
+
import type { StrandOfflineConfig, StrandOfflineStatus, StrandQueueState } from './strand-offline.js';
|
|
13
|
+
import type { StrandAppSchemaDeferred } from './strand-app-schema-report.js';
|
|
12
14
|
import type { SeedTrustPolicy } from './seed-trust-policy.js';
|
|
13
15
|
import type { KeyStore, KeyId } from './key-store.js';
|
|
14
16
|
import type { TrustedOwnerStore, TrustSource } from './trusted-owner-store.js';
|
|
@@ -895,6 +897,15 @@ export interface CadreNodeConfig {
|
|
|
895
897
|
* holds the Header is never gated, so nothing that works today is blocked by it.
|
|
896
898
|
*/
|
|
897
899
|
strandFirstSync?: StrandFirstSyncConfig;
|
|
900
|
+
/**
|
|
901
|
+
* Offline mode on this node's strands (docs/strands.md → "Offline mode"): with it, an app can
|
|
902
|
+
* switch a strand so that a commit resolves once the transaction is queued on this machine
|
|
903
|
+
* (`CadreNode.setStrandOfflineMode`), and the queue is saved in `journal` so it survives a
|
|
904
|
+
* restart. Absent: no strand gets a queue, and `setStrandOfflineMode` throws
|
|
905
|
+
* `StrandOfflineUnavailableError`. The control database never gets one. The always-on programs
|
|
906
|
+
* configure none: a node that is always connected gains nothing from a local acknowledgement.
|
|
907
|
+
*/
|
|
908
|
+
strandOffline?: StrandOfflineConfig;
|
|
898
909
|
/** Hibernation configuration */
|
|
899
910
|
hibernation?: HibernationConfig;
|
|
900
911
|
/**
|
|
@@ -1657,6 +1668,32 @@ export interface CadreNodeEvents {
|
|
|
1657
1668
|
* because its database closed, hibernated or the node restarted.
|
|
1658
1669
|
*/
|
|
1659
1670
|
'strand:commit-held': StrandCommitHeld;
|
|
1671
|
+
/**
|
|
1672
|
+
* Emitted for every status of a transaction queued in a strand's offline queue (`queued`,
|
|
1673
|
+
* `submitting`, `committed`, …), by the `StampId()` its statement returned. Survives hibernation
|
|
1674
|
+
* and every rebuild, unlike a listener on `StrandDatabase.offline`. A restored transaction's
|
|
1675
|
+
* `queued` status after a restart is not emitted: it was delivered before anything subscribed, so
|
|
1676
|
+
* read `offline.entries()` on the `strand:queue-state` that publication emits. A drained commit
|
|
1677
|
+
* also emits `strand:commit-durability` as an online one does. See docs/strands.md, "Offline mode".
|
|
1678
|
+
*/
|
|
1679
|
+
'strand:offline-status': StrandOfflineStatus;
|
|
1680
|
+
/**
|
|
1681
|
+
* Emitted whenever a strand's offline queue or mode changes, and once each time the strand's
|
|
1682
|
+
* database is published with the queue's state at that moment.
|
|
1683
|
+
*/
|
|
1684
|
+
'strand:queue-state': StrandQueueState;
|
|
1685
|
+
/**
|
|
1686
|
+
* Emitted when a strand's database is published while its `App` schema apply is held back, by
|
|
1687
|
+
* queued offline transactions or by a strand cohort it could not reach (`waitingFor`): the database
|
|
1688
|
+
* runs the earlier schema although `StrandInstance.sAppInfo` names the new version, and
|
|
1689
|
+
* `StrandDatabase.appSchemaState()` reads `'waiting-for-queue'` or `'waiting-for-cohort'`. A retry
|
|
1690
|
+
* that fails for another reason is emitted as `strand:error`; a cancelled one emits nothing.
|
|
1691
|
+
*/
|
|
1692
|
+
'strand:app-schema-deferred': StrandAppSchemaDeferred;
|
|
1693
|
+
/** Emitted when an `App` schema apply that `strand:app-schema-deferred` reported lands. */
|
|
1694
|
+
'strand:app-schema-applied': {
|
|
1695
|
+
strandId: string;
|
|
1696
|
+
};
|
|
1660
1697
|
/**
|
|
1661
1698
|
* Emitted when this node discovers it is no longer a member of a CLOSED
|
|
1662
1699
|
* strand — its party was removed by a manager, or it left. Detected by the
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA4GA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA6C;IAC5E,QAAQ,EAAE;QACR,WAAW,EAAE,QAAQ,EAAS,aAAa;QAC3C,gBAAgB,EAAE,QAAQ,EAAI,kBAAkB;QAChD,eAAe,EAAE,QAAQ,EAAK,MAAM;QACpC,oBAAoB,EAAE,CAAC;QACvB,kBAAkB,EAAE,QAAQ,CAAE,MAAM;KACrC;IACD,WAAW,EAAE;QACX,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAI,YAAY;QAC1C,gBAAgB,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,wBAAwB;QAC1D,eAAe,EAAE,EAAE,GAAG,IAAI,EAAI,mBAAmB;QACjD,oBAAoB,EAAE,CAAC;QACvB,kBAAkB,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,2BAA2B,EAC3B,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,+BAA+B,CAAC;AAEvC;;;;;GAKG;AACH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serfab/cadre-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Core library for Sereus cadre nodes - manages control networks and strand participation",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@libp2p/logger": "^6.2.13",
|
|
91
91
|
"@libp2p/peer-store": "^12.0.28",
|
|
92
92
|
"@libp2p/webrtc": "6.0.33",
|
|
93
|
-
"@optimystic/db-p2p-storage-fs": "^1.
|
|
93
|
+
"@optimystic/db-p2p-storage-fs": "^1.23.0",
|
|
94
94
|
"@types/debug": "^4.1.12",
|
|
95
95
|
"@types/node": "^25.0.10",
|
|
96
96
|
"@vitest/coverage-v8": "^4.0.17",
|
|
@@ -111,12 +111,12 @@
|
|
|
111
111
|
"@multiformats/multiaddr": "^13.0.3",
|
|
112
112
|
"@noble/ciphers": "^2.0.1",
|
|
113
113
|
"@noble/hashes": "^2.0.0",
|
|
114
|
-
"@optimystic/db-core": "^1.
|
|
115
|
-
"@optimystic/db-p2p": "^1.
|
|
116
|
-
"@optimystic/quereus-plugin-crypto": "^1.
|
|
117
|
-
"@optimystic/quereus-plugin-optimystic": "^1.
|
|
118
|
-
"@quereus/quereus": "^4.
|
|
119
|
-
"@serfab/quereus-plugin-sereus": "^1.
|
|
114
|
+
"@optimystic/db-core": "^1.23.0",
|
|
115
|
+
"@optimystic/db-p2p": "^1.23.0",
|
|
116
|
+
"@optimystic/quereus-plugin-crypto": "^1.23.0",
|
|
117
|
+
"@optimystic/quereus-plugin-optimystic": "^1.23.0",
|
|
118
|
+
"@quereus/quereus": "^4.23.0",
|
|
119
|
+
"@serfab/quereus-plugin-sereus": "^1.20.0",
|
|
120
120
|
"debug": "^4.4.3",
|
|
121
121
|
"libp2p": "^3.3.11",
|
|
122
122
|
"uint8arrays": "^6.1.1"
|