@ibgib/core-gib 0.1.26 → 0.1.28
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/sync/sync-helpers.d.mts +23 -2
- package/dist/sync/sync-helpers.d.mts.map +1 -1
- package/dist/sync/sync-helpers.mjs +121 -4
- package/dist/sync/sync-helpers.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs +30 -9
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-v1.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-v1.mjs +1 -0
- package/dist/sync/sync-peer/sync-peer-v1.mjs.map +1 -1
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts.map +1 -1
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs +17 -3
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs.map +1 -1
- package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts +8 -0
- package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts.map +1 -1
- package/dist/sync/sync-saga-coordinator.d.mts +30 -153
- package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
- package/dist/sync/sync-saga-coordinator.mjs +585 -406
- package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts +13 -18
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts.map +1 -1
- package/dist/sync/sync-types.d.mts +36 -6
- package/dist/sync/sync-types.d.mts.map +1 -1
- package/dist/sync/sync-types.mjs +32 -0
- package/dist/sync/sync-types.mjs.map +1 -1
- package/package.json +2 -2
- package/src/sync/sync-helpers.mts +113 -6
- package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mts +30 -8
- package/src/sync/sync-peer/sync-peer-v1.mts +2 -0
- package/src/sync/sync-saga-context/sync-saga-context-helpers.mts +14 -2
- package/src/sync/sync-saga-context/sync-saga-context-types.mts +13 -5
- package/src/sync/sync-saga-coordinator.mts +656 -463
- package/src/sync/sync-saga-message/sync-saga-message-types.mts +27 -32
- package/src/sync/sync-types.mts +45 -8
|
@@ -3,14 +3,9 @@ import { IbGibSpaceAny } from "../witness/space/space-base-v1.mjs";
|
|
|
3
3
|
import { KeystoneIbGib_V1 } from "../keystone/keystone-types.mjs";
|
|
4
4
|
import { KeystoneService_V1 } from "../keystone/keystone-service-v1.mjs";
|
|
5
5
|
import { MetaspaceService } from "../witness/space/metaspace/metaspace-types.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import { SyncIbGib_V1, SyncConflictStrategy, SyncOptions, DomainIbGibAnalysisInfo, NextSagaFrameInfo, HandleSagaResponseContextResult } from "./sync-types.mjs";
|
|
8
|
-
import { SyncSagaMessageData_V1, SyncSagaMessageInitData_V1 } from "./sync-saga-message/sync-saga-message-types.mjs";
|
|
6
|
+
import { SyncOptions } from "./sync-types.mjs";
|
|
9
7
|
import { SyncSagaInfo } from "./sync-types.mjs";
|
|
10
|
-
import { SyncPeerWitness } from "./sync-peer/sync-peer-types.mjs";
|
|
11
8
|
import { SyncSagaContextIbGib_V1 } from "./sync-saga-context/sync-saga-context-types.mjs";
|
|
12
|
-
import { SubjectWitness } from "../common/pubsub/subject/subject-types.mjs";
|
|
13
|
-
import { FlatIbGibGraph } from "../common/other/graph-types.mjs";
|
|
14
9
|
/**
|
|
15
10
|
* Orchestrates the synchronization process between two spaces (Source and Destination).
|
|
16
11
|
*
|
|
@@ -25,8 +20,8 @@ import { FlatIbGibGraph } from "../common/other/graph-types.mjs";
|
|
|
25
20
|
* to a specific Saga session, not fixed node identities.
|
|
26
21
|
*/
|
|
27
22
|
export declare class SyncSagaCoordinator {
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
private keystone;
|
|
24
|
+
private lc;
|
|
30
25
|
constructor(keystone: KeystoneService_V1);
|
|
31
26
|
/**
|
|
32
27
|
* Executes a synchronization saga using the Symmetric Sync Protocol.
|
|
@@ -53,7 +48,7 @@ export declare class SyncSagaCoordinator {
|
|
|
53
48
|
* @returns next context result if another round, else if commit returns
|
|
54
49
|
* null
|
|
55
50
|
*/
|
|
56
|
-
|
|
51
|
+
continueSync({ sagaContext, mySpace, myTempSpace, identity, identitySecret, metaspace, }: {
|
|
57
52
|
sagaContext: SyncSagaContextIbGib_V1;
|
|
58
53
|
/**
|
|
59
54
|
* Local space relative to the execution context's POV
|
|
@@ -67,11 +62,7 @@ export declare class SyncSagaCoordinator {
|
|
|
67
62
|
identitySecret?: string;
|
|
68
63
|
metaspace: MetaspaceService;
|
|
69
64
|
}): Promise<SyncSagaContextIbGib_V1 | null>;
|
|
70
|
-
|
|
71
|
-
sagaId: string;
|
|
72
|
-
metaspace: MetaspaceService;
|
|
73
|
-
tempSpace: IbGibSpaceAny;
|
|
74
|
-
}): Promise<KeystoneIbGib_V1>;
|
|
65
|
+
private getSessionIdentity;
|
|
75
66
|
/**
|
|
76
67
|
* Drives the FSM loop of the Saga.
|
|
77
68
|
*
|
|
@@ -87,22 +78,7 @@ export declare class SyncSagaCoordinator {
|
|
|
87
78
|
* the NEXT request context.
|
|
88
79
|
* When the Peer responds with data (in the response context), it is resolved and put into `tempSpace`.
|
|
89
80
|
*/
|
|
90
|
-
|
|
91
|
-
initFrame: SyncIbGib_V1;
|
|
92
|
-
/**
|
|
93
|
-
* This is the initial dependency graph of all domain ibgibs passed in
|
|
94
|
-
* to the original {@link sync} call.
|
|
95
|
-
*
|
|
96
|
-
* if we're executing on the sender, this will be populated
|
|
97
|
-
*/
|
|
98
|
-
initDomainGraph: FlatIbGibGraph;
|
|
99
|
-
peer: SyncPeerWitness;
|
|
100
|
-
sessionIdentity?: KeystoneIbGib_V1;
|
|
101
|
-
updates$: SubjectWitness<SyncSagaContextIbGib_V1>;
|
|
102
|
-
metaspace: MetaspaceService;
|
|
103
|
-
localSpace: IbGibSpaceAny;
|
|
104
|
-
tempSpace: IbGibSpaceAny;
|
|
105
|
-
}): Promise<void>;
|
|
81
|
+
private executeSagaLoop;
|
|
106
82
|
/**
|
|
107
83
|
* Helper to get Knowledge Vector for specific domain ibGibs or TJPs.
|
|
108
84
|
* Useful for testing and external validation.
|
|
@@ -115,10 +91,7 @@ export declare class SyncSagaCoordinator {
|
|
|
115
91
|
}): Promise<{
|
|
116
92
|
[tjp: string]: string | null;
|
|
117
93
|
}>;
|
|
118
|
-
|
|
119
|
-
domainIbGibs: IbGib_V1[];
|
|
120
|
-
space: IbGibSpaceAny;
|
|
121
|
-
}): Promise<DomainIbGibAnalysisInfo>;
|
|
94
|
+
private analyzeDomainIbGibs;
|
|
122
95
|
/**
|
|
123
96
|
* Creates the Initial Saga Frame (Init Stage).
|
|
124
97
|
*
|
|
@@ -128,32 +101,14 @@ export declare class SyncSagaCoordinator {
|
|
|
128
101
|
* Generates the first frame containing the Knowledge Vector of the Local Space.
|
|
129
102
|
* This is sent to the Receiver to begin Gap Analysis.
|
|
130
103
|
*/
|
|
131
|
-
|
|
132
|
-
sagaId: string;
|
|
133
|
-
sessionIdentity?: KeystoneIbGib_V1;
|
|
134
|
-
domainIbGibs: IbGib_V1[];
|
|
135
|
-
conflictStrategy: SyncConflictStrategy;
|
|
136
|
-
metaspace: MetaspaceService;
|
|
137
|
-
localSpace: IbGibSpaceAny;
|
|
138
|
-
tempSpace: IbGibSpaceAny;
|
|
139
|
-
}): Promise<{
|
|
140
|
-
initFrame: SyncIbGib_V1;
|
|
141
|
-
initDomainGraph: {
|
|
142
|
-
[addr: string]: IbGib_V1;
|
|
143
|
-
};
|
|
144
|
-
}>;
|
|
104
|
+
private createInitFrame;
|
|
145
105
|
/**
|
|
146
106
|
* Helper to poll for streaming domain payloads and put them in the
|
|
147
107
|
* local {@link tempSpace}.
|
|
148
108
|
*
|
|
149
109
|
* @returns when all {@link expectedAddrs} are done being transmitted.
|
|
150
110
|
*/
|
|
151
|
-
|
|
152
|
-
expectedAddrs: string[];
|
|
153
|
-
pollIntervalMs: number;
|
|
154
|
-
domainPayloadsMap: Map<string, IbGib_V1>;
|
|
155
|
-
tempSpace: IbGibSpaceAny;
|
|
156
|
-
}): Promise<IbGib_V1[]>;
|
|
111
|
+
private pollForDomainPayloads;
|
|
157
112
|
/**
|
|
158
113
|
* This is the heart of the "ping pong" transaction, where we send a context
|
|
159
114
|
*
|
|
@@ -175,27 +130,7 @@ export declare class SyncSagaCoordinator {
|
|
|
175
130
|
*
|
|
176
131
|
* This is a one-off on the receiver.
|
|
177
132
|
*/
|
|
178
|
-
handleResponseSagaContext
|
|
179
|
-
sagaContext: SyncSagaContextIbGib_V1;
|
|
180
|
-
/**
|
|
181
|
-
* This is the initial dependency graph of all domain ibgibs passed in
|
|
182
|
-
* to the original {@link sync} call.
|
|
183
|
-
*
|
|
184
|
-
* if we're executing on the sender, this will be populated
|
|
185
|
-
*/
|
|
186
|
-
initDomainGraph?: FlatIbGibGraph;
|
|
187
|
-
/**
|
|
188
|
-
* Local space relative to the execution context's POV
|
|
189
|
-
*/
|
|
190
|
-
mySpace: IbGibSpaceAny;
|
|
191
|
-
/**
|
|
192
|
-
* Local temp space relative to the execution context's POV
|
|
193
|
-
*/
|
|
194
|
-
myTempSpace: IbGibSpaceAny;
|
|
195
|
-
identity?: KeystoneIbGib_V1;
|
|
196
|
-
identitySecret?: string;
|
|
197
|
-
metaspace: MetaspaceService;
|
|
198
|
-
}): Promise<HandleSagaResponseContextResult>;
|
|
133
|
+
private handleResponseSagaContext;
|
|
199
134
|
/**
|
|
200
135
|
* Handles the `Init` frame.
|
|
201
136
|
*
|
|
@@ -205,27 +140,10 @@ export declare class SyncSagaCoordinator {
|
|
|
205
140
|
* The Receiver performs Gap Analysis here:
|
|
206
141
|
* 1. Compares Sender's Knowledge Vector (in `sagaIbGib`) vs Receiver's Local KV.
|
|
207
142
|
* 2. Identifies what Sender needs (`pushOfferAddrs`).
|
|
208
|
-
* 3. Identifies what Receiver needs (`
|
|
143
|
+
* 3. Identifies what Receiver needs (`deltaRequestAddrInfos`).
|
|
209
144
|
* 4. Returns an `Ack` frame containing these lists.
|
|
210
145
|
*/
|
|
211
|
-
|
|
212
|
-
sagaIbGib: SyncIbGib_V1;
|
|
213
|
-
messageData: SyncSagaMessageInitData_V1;
|
|
214
|
-
/**
|
|
215
|
-
* Local space relative to the execution context's POV
|
|
216
|
-
*/
|
|
217
|
-
mySpace: IbGibSpaceAny;
|
|
218
|
-
/**
|
|
219
|
-
* Local temp space relative to the execution context's POV.
|
|
220
|
-
*
|
|
221
|
-
* NOTE: Since this always executes on the receiver's end, this should
|
|
222
|
-
* be the receiver's temp space.
|
|
223
|
-
*/
|
|
224
|
-
myTempSpace: IbGibSpaceAny;
|
|
225
|
-
metaspace: MetaspaceService;
|
|
226
|
-
identity?: KeystoneIbGib_V1;
|
|
227
|
-
identitySecret?: string;
|
|
228
|
-
}): Promise<NextSagaFrameInfo>;
|
|
146
|
+
private handleInitFrame;
|
|
229
147
|
/**
|
|
230
148
|
* Handles the `Ack` frame.
|
|
231
149
|
*
|
|
@@ -233,28 +151,15 @@ export declare class SyncSagaCoordinator {
|
|
|
233
151
|
* **Execution Context**: **Sender (Local)**.
|
|
234
152
|
*
|
|
235
153
|
* The Sender reacts to the Receiver's requirements:
|
|
236
|
-
* 1.
|
|
237
|
-
*
|
|
154
|
+
* 1. `deltaRequestAddrInfos`: Receiver wants this data. Sender takes this
|
|
155
|
+
* into account, plus gathers it from `initDomainGraph` and puts them in
|
|
156
|
+
* `payloadIbGibs` (for next frame).
|
|
157
|
+
* 2. `pushOfferAddrs`: Receiver has newer data. these should have been
|
|
158
|
+
* included in the incoming context from the receiver..
|
|
238
159
|
*
|
|
239
160
|
* Returns a `Delta` frame.
|
|
240
161
|
*/
|
|
241
|
-
|
|
242
|
-
sagaIbGib: SyncIbGib_V1;
|
|
243
|
-
srcGraph: {
|
|
244
|
-
[addr: string]: IbGib_V1;
|
|
245
|
-
};
|
|
246
|
-
/**
|
|
247
|
-
* This is the initial dependency graph of all domain ibgibs passed in
|
|
248
|
-
* to the original {@link sync} call.
|
|
249
|
-
*
|
|
250
|
-
* if we're executing on the sender, this will be populated
|
|
251
|
-
*/
|
|
252
|
-
initDomainGraph: FlatIbGibGraph;
|
|
253
|
-
destSpace: IbGibSpaceAny;
|
|
254
|
-
tempSpace: IbGibSpaceAny;
|
|
255
|
-
metaspace: MetaspaceService;
|
|
256
|
-
identity?: KeystoneIbGib_V1;
|
|
257
|
-
}): Promise<NextSagaFrameInfo>;
|
|
162
|
+
private handleAckFrame;
|
|
258
163
|
/**
|
|
259
164
|
* Handles the `Delta` frame.
|
|
260
165
|
*
|
|
@@ -265,48 +170,20 @@ export declare class SyncSagaCoordinator {
|
|
|
265
170
|
* 2. **Fulfillment**: Checks `requests`. If Peer requested data, gathers it and prepares `outgoingPayload`.
|
|
266
171
|
* 3. **Completion**: If no more requests, transitions to `Commit`.
|
|
267
172
|
*/
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}): Promise<NextSagaFrameInfo>;
|
|
278
|
-
protected handleCommitFrame({ sagaIbGib, destSpace, tempSpace, metaspace, identity, }: {
|
|
279
|
-
sagaIbGib: SyncIbGib_V1;
|
|
280
|
-
destSpace: IbGibSpaceAny;
|
|
281
|
-
tempSpace: IbGibSpaceAny;
|
|
282
|
-
metaspace: MetaspaceService;
|
|
283
|
-
identity?: KeystoneIbGib_V1;
|
|
284
|
-
}): Promise<NextSagaFrameInfo>;
|
|
285
|
-
protected createSyncMsgStone<TStoneData extends SyncSagaMessageData_V1>({ data, localSpace, metaspace, }: {
|
|
286
|
-
data: TStoneData;
|
|
287
|
-
localSpace: IbGibSpaceAny;
|
|
288
|
-
metaspace: MetaspaceService;
|
|
289
|
-
}): Promise<IbGib_V1<TStoneData>>;
|
|
173
|
+
private handleDeltaFrame;
|
|
174
|
+
/**
|
|
175
|
+
* should throw if fails
|
|
176
|
+
*/
|
|
177
|
+
private executeLocalCommit;
|
|
178
|
+
private createCommitFrame;
|
|
179
|
+
private handleCommitFrame;
|
|
180
|
+
private createSyncMsgStone;
|
|
181
|
+
private getPayloadsForRequestedInfos;
|
|
290
182
|
/**
|
|
291
183
|
* Evolves the saga timeline with a new frame.
|
|
292
184
|
*/
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
msgStones: IbGib_V1[];
|
|
297
|
-
localSpace: IbGibSpaceAny;
|
|
298
|
-
metaspace: MetaspaceService;
|
|
299
|
-
sessionIdentity?: KeystoneIbGib_V1;
|
|
300
|
-
}): Promise<SyncIbGib_V1>;
|
|
301
|
-
protected getStageAndPayloadFromFrame({ sagaFrame, space }: {
|
|
302
|
-
sagaFrame: IbGib_V1;
|
|
303
|
-
space: IbGibSpaceAny;
|
|
304
|
-
}): Promise<{
|
|
305
|
-
stage: SyncStage;
|
|
306
|
-
messageData: unknown;
|
|
307
|
-
}>;
|
|
308
|
-
protected sortTimelinesTopologically(timelines: {
|
|
309
|
-
[tjp: string]: IbGib_V1[];
|
|
310
|
-
}): string[];
|
|
185
|
+
private evolveSyncSagaIbGib;
|
|
186
|
+
private getStageAndPayloadFromFrame;
|
|
187
|
+
private sortTimelinesTopologically;
|
|
311
188
|
}
|
|
312
189
|
//# sourceMappingURL=sync-saga-coordinator.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-saga-coordinator.d.mts","sourceRoot":"","sources":["../../src/sync/sync-saga-coordinator.mts"],"names":[],"mappings":"AAYA,OAAO,EAAE,QAAQ,EAAG,MAAM,iCAAiC,CAAC;AAI5D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO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