@ibgib/core-gib 0.1.28 → 0.1.30
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/.vscode/launch.json +17 -1
- package/dist/common/meta-stone/meta-stone-helper.d.mts.map +1 -1
- package/dist/common/meta-stone/meta-stone-helper.mjs +30 -12
- package/dist/common/meta-stone/meta-stone-helper.mjs.map +1 -1
- package/dist/common/meta-stone/meta-stone-types.d.mts +5 -2
- package/dist/common/meta-stone/meta-stone-types.d.mts.map +1 -1
- package/dist/sync/strategies/conflict-optimistic.d.mts +16 -0
- package/dist/sync/strategies/conflict-optimistic.d.mts.map +1 -1
- package/dist/sync/strategies/conflict-optimistic.mjs +28 -1
- package/dist/sync/strategies/conflict-optimistic.mjs.map +1 -1
- package/dist/sync/sync-conflict.respec.mjs +5 -5
- package/dist/sync/sync-conflict.respec.mjs.map +1 -1
- package/dist/sync/sync-helpers.d.mts +4 -4
- package/dist/sync/sync-helpers.d.mts.map +1 -1
- package/dist/sync/sync-helpers.mjs +12 -8
- package/dist/sync/sync-helpers.mjs.map +1 -1
- package/dist/sync/sync-innerspace-constants.respec.mjs +36 -36
- package/dist/sync/sync-innerspace-constants.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-deep-updates.respec.mjs +3 -1
- package/dist/sync/sync-innerspace-deep-updates.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-dest-ahead.respec.mjs +62 -9
- package/dist/sync/sync-innerspace-dest-ahead.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace.respec.mjs +45 -16
- package/dist/sync/sync-innerspace.respec.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts +0 -9
- 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 +25 -43
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-v1.mjs +2 -2
- package/dist/sync/sync-peer/sync-peer-v1.mjs.map +1 -1
- package/dist/sync/sync-saga-coordinator.d.mts +15 -10
- package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
- package/dist/sync/sync-saga-coordinator.mjs +304 -163
- package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts +3 -3
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts.map +1 -1
- package/dist/sync/sync-types.d.mts +12 -18
- package/dist/sync/sync-types.d.mts.map +1 -1
- package/dist/sync/sync-types.mjs +15 -21
- package/dist/sync/sync-types.mjs.map +1 -1
- package/dist/timeline/timeline-api.d.mts +12 -0
- package/dist/timeline/timeline-api.d.mts.map +1 -1
- package/dist/timeline/timeline-api.mjs +26 -0
- package/dist/timeline/timeline-api.mjs.map +1 -1
- package/dist/witness/space/inner-space/inner-space-v1.d.mts +19 -0
- package/dist/witness/space/inner-space/inner-space-v1.d.mts.map +1 -1
- package/dist/witness/space/inner-space/inner-space-v1.mjs +189 -30
- package/dist/witness/space/inner-space/inner-space-v1.mjs.map +1 -1
- package/dist/witness/space/inner-space/inner-space-v1.respec.mjs +9 -0
- package/dist/witness/space/inner-space/inner-space-v1.respec.mjs.map +1 -1
- package/dist/witness/space/space-helper.d.mts.map +1 -1
- package/dist/witness/space/space-helper.mjs +2 -1
- package/dist/witness/space/space-helper.mjs.map +1 -1
- package/package.json +2 -1
- package/src/common/meta-stone/meta-stone-helper.mts +25 -11
- package/src/common/meta-stone/meta-stone-types.mts +5 -2
- package/src/sync/README.md +4 -4
- package/src/sync/docs/architecture.md +6 -6
- package/src/sync/strategies/conflict-optimistic.mts +41 -4
- package/src/sync/sync-conflict.respec.mts +5 -5
- package/src/sync/sync-helpers.mts +13 -9
- package/src/sync/sync-innerspace-constants.respec.mts +39 -39
- package/src/sync/sync-innerspace-deep-updates.respec.mts +5 -5
- package/src/sync/sync-innerspace-dest-ahead.respec.mts +73 -9
- package/src/sync/sync-innerspace.respec.mts +17 -16
- package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mts +23 -60
- package/src/sync/sync-peer/sync-peer-v1.mts +2 -2
- package/src/sync/sync-saga-coordinator.mts +231 -173
- package/src/sync/sync-saga-message/sync-saga-message-types.mts +3 -3
- package/src/sync/sync-types.mts +19 -26
- package/src/timeline/timeline-api.mts +51 -11
- package/src/witness/space/inner-space/inner-space-v1.mts +191 -29
- package/src/witness/space/inner-space/inner-space-v1.respec.mts +13 -0
- package/src/witness/space/space-helper.mts +3 -2
- package/test_output.log +0 -0
- package/tmp.md +170 -62
|
@@ -4,30 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
import { delay, extractErrorMsg, pretty, unique } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
6
6
|
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
7
|
-
import { IbGibAddr } from '@ibgib/ts-gib/dist/types.mjs';
|
|
8
|
-
import { IbGib_V1, IbGibData_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
9
|
-
import { isDna } from '@ibgib/ts-gib/dist/V1/transforms/transform-helper.mjs';
|
|
10
7
|
|
|
11
8
|
import { GLOBAL_LOG_A_LOT } from '../../../core-constants.mjs';
|
|
12
9
|
import { IbGibSpaceAny } from '../../../witness/space/space-base-v1.mjs';
|
|
13
10
|
import { SyncPeer_V1 } from '../sync-peer-v1.mjs';
|
|
14
|
-
import {
|
|
11
|
+
import { putInSpace, registerNewIbGib } from '../../../witness/space/space-helper.mjs';
|
|
15
12
|
import { SyncSagaContextIbGib_V1, } from '../../sync-saga-context/sync-saga-context-types.mjs';
|
|
16
13
|
import { SyncPeerInnerspaceData_V1, SyncPeerInnerspaceIbGib_V1, SyncPeerInnerspaceOptions, SyncPeerInnerspaceRel8ns_V1 } from './sync-peer-innerspace-types.mjs';
|
|
17
14
|
import { MetaspaceService } from '../../../witness/space/metaspace/metaspace-types.mjs';
|
|
18
15
|
import { SyncSagaCoordinator } from '../../sync-saga-coordinator.mjs';
|
|
19
|
-
import { IbGibSpaceResultData } from '../../../witness/space/space-types.mjs';
|
|
20
16
|
import { InitializeSyncPeerOpts } from '../sync-peer-types.mjs';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import { SyncSagaMessageAckData_V1, SyncSagaMessageCommitData_V1, SyncSagaMessageData_V1, SyncSagaMessageDeltaData_V1, SyncSagaMessageInitData_V1 } from '../../sync-saga-message/sync-saga-message-types.mjs';
|
|
24
|
-
import { getExecutionContext, getSyncSagaFrameDependencyGraph, putInSpace_dnasThenNonDnas } from '../../sync-helpers.mjs';
|
|
25
|
-
import { splitPerTjpAndOrDna, toDto } from '../../../common/other/ibgib-helper.mjs';
|
|
26
|
-
import { SyncExecutionContext } from '../../sync-types.mjs';
|
|
17
|
+
import { getSyncSagaFrameDependencyGraph, putInSpace_dnasThenNonDnas } from '../../sync-helpers.mjs';
|
|
18
|
+
import { toDto } from '../../../common/other/ibgib-helper.mjs';
|
|
27
19
|
|
|
28
20
|
|
|
29
|
-
const logalot = GLOBAL_LOG_A_LOT
|
|
30
|
-
const logalotControlDomain =
|
|
21
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
22
|
+
const logalotControlDomain = false;
|
|
31
23
|
const lcControlDomain = '[ControlDomain]';
|
|
32
24
|
|
|
33
25
|
/**
|
|
@@ -112,6 +104,8 @@ export class SyncPeerInnerspace_V1 extends SyncPeer_V1<InitializeSyncPeerInnersp
|
|
|
112
104
|
protected async sendContextRequest(context: SyncSagaContextIbGib_V1): Promise<SyncSagaContextIbGib_V1 | undefined> {
|
|
113
105
|
const lc = `${this.lc}[${this.sendContextRequest.name}]`;
|
|
114
106
|
try {
|
|
107
|
+
if (logalot) { console.log(`${lc} starting... (I: bab87f15dea77cd4892bd8a8d2e65826)`); }
|
|
108
|
+
|
|
115
109
|
if (!this.opts) { throw new Error(`(UNEXPECTED) this.opts falsy? (E: d8b1348e3233810128999596b1fa5826)`); }
|
|
116
110
|
|
|
117
111
|
const {
|
|
@@ -141,7 +135,7 @@ export class SyncPeerInnerspace_V1 extends SyncPeer_V1<InitializeSyncPeerInnersp
|
|
|
141
135
|
// let localTempSpace: IbGibSpaceAny;
|
|
142
136
|
// let remoteSpace: IbGibSpaceAny;
|
|
143
137
|
// let remoteTempSpace: IbGibSpaceAny;
|
|
144
|
-
// if (
|
|
138
|
+
// if (getSyncSagaFrameOrigin({ sagaFrame: context.sagaFrame }) === SyncSagaFrameOrigin.sender) {
|
|
145
139
|
// localSpace = senderSpace;
|
|
146
140
|
// localTempSpace = senderTempSpace;
|
|
147
141
|
// remoteSpace = receiverSpace;
|
|
@@ -173,6 +167,7 @@ export class SyncPeerInnerspace_V1 extends SyncPeer_V1<InitializeSyncPeerInnersp
|
|
|
173
167
|
const payloadIbGibsControl = [
|
|
174
168
|
...identities, msg, sagaFrame, context
|
|
175
169
|
].map(x => toDto({ ibGib: x }));
|
|
170
|
+
if (logalot) { console.log(`${lc} putting into receiverSpace: ${receiverSpace.ib} (I: 1ba18b14a26bdd0e7800da4812898826)`); }
|
|
176
171
|
await putInSpace({
|
|
177
172
|
ibGibs: payloadIbGibsControl,
|
|
178
173
|
space: receiverSpace,
|
|
@@ -187,6 +182,7 @@ export class SyncPeerInnerspace_V1 extends SyncPeer_V1<InitializeSyncPeerInnersp
|
|
|
187
182
|
}
|
|
188
183
|
|
|
189
184
|
if (context.payloadIbGibsDomain && context.payloadIbGibsDomain.length > 0) {
|
|
185
|
+
if (logalot) { console.log(`${lc} putting into receiverTempSpace: ${receiverTempSpace.ib} (I: d0cea920b818393d68118bc8a1515526)`); }
|
|
190
186
|
await putInSpace_dnasThenNonDnas({
|
|
191
187
|
ibGibs: context.payloadIbGibsDomain,
|
|
192
188
|
space: receiverTempSpace,
|
|
@@ -249,6 +245,17 @@ export class SyncPeerInnerspace_V1 extends SyncPeer_V1<InitializeSyncPeerInnersp
|
|
|
249
245
|
}
|
|
250
246
|
|
|
251
247
|
// spin off the payloads, as that may take a long time
|
|
248
|
+
if (responseCtx.payloadIbGibsDomain?.length ?? 0 > 0) {
|
|
249
|
+
// i guess this only will hit once we have conflicts, because
|
|
250
|
+
// it's the return trip, i.e., from the receiver. The initial
|
|
251
|
+
// ack frame does it through push offers?
|
|
252
|
+
await delay(2000);
|
|
253
|
+
console.warn(`${lc} this delay does hit (W: 3940d47d2a7433833837af4cef171126)`)
|
|
254
|
+
for (let i = 0; i < 100; i++) {
|
|
255
|
+
const element = 100;
|
|
256
|
+
console.log(`THIS HITS`)
|
|
257
|
+
}
|
|
258
|
+
}
|
|
252
259
|
const payloadIbGibsDomain_response = responseCtx.payloadIbGibsDomain;
|
|
253
260
|
if (payloadIbGibsDomain_response) {
|
|
254
261
|
new Promise<void>(async (resolve, reject) => {
|
|
@@ -257,13 +264,12 @@ export class SyncPeerInnerspace_V1 extends SyncPeer_V1<InitializeSyncPeerInnersp
|
|
|
257
264
|
if (logalot) { console.log(`${lcPut} starting... (I: 4133e736b4c80d2cf94448b87b206826)`); }
|
|
258
265
|
|
|
259
266
|
// 2 seconds...i want to see huge blocks of logs entries for this to see this happening
|
|
260
|
-
const delayMs =
|
|
267
|
+
const delayMs = 2000;
|
|
261
268
|
for (let i = 0; i < 10; i++) {
|
|
262
269
|
console.warn(`${lc} ARTIFICIALLY DELAYING PAYLOADS TO MIMIC TRANSFER LATENCY. REMOVE THIS DELAY!! (W: 5e7b28f1daa82d955897e9d8cdb16f26)`)
|
|
263
270
|
await delay(delayMs);
|
|
264
271
|
}
|
|
265
272
|
|
|
266
|
-
|
|
267
273
|
await putInSpace_dnasThenNonDnas({
|
|
268
274
|
ibGibs: payloadIbGibsDomain_response,
|
|
269
275
|
space: senderTempSpace,
|
|
@@ -289,52 +295,9 @@ export class SyncPeerInnerspace_V1 extends SyncPeer_V1<InitializeSyncPeerInnersp
|
|
|
289
295
|
} catch (error) {
|
|
290
296
|
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
291
297
|
throw error;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Helper to copy single ibgib from A to B.
|
|
297
|
-
*/
|
|
298
|
-
protected async transfer({
|
|
299
|
-
addrs,
|
|
300
|
-
from,
|
|
301
|
-
to
|
|
302
|
-
}: {
|
|
303
|
-
addrs: IbGibAddr[],
|
|
304
|
-
from: IbGibSpaceAny,
|
|
305
|
-
to: IbGibSpaceAny
|
|
306
|
-
}): Promise<void> {
|
|
307
|
-
const lc = `${this.lc}[${this.transfer.name}]`;
|
|
308
|
-
try {
|
|
309
|
-
if (logalot) { console.log(`${lc} starting... (I: f1145dc75a461afc885efe984f08d426)`); }
|
|
310
|
-
|
|
311
|
-
console.error(`${lc} NAG ERROR (DOES NOT THROW): This needs to be adapted to be able to pull from multiple spaces. IOW, the 'from' param should be an array of spaces. This is because we need to be checking both durable and temp spaces when querying. (E: 823f3856b8b82ece080868e85ded0826)`)
|
|
312
|
-
|
|
313
|
-
// 1. Get from Source
|
|
314
|
-
const resGet = await getFromSpace({ space: from, addrs });
|
|
315
|
-
if (!resGet.success || !resGet.ibGibs || resGet.ibGibs.length !== addrs.length) {
|
|
316
|
-
if (!resGet.rawResultIbGib) { throw new Error(`(UNEXPECTED) resGet.rawResultIbGib falsy? (E: b829f827a378890bcf7dc3d41c908826)`); }
|
|
317
|
-
if (!resGet.rawResultIbGib.data) { throw new Error(`(UNEXPECTED) resGet.rawResultIbGib.data falsy? (E: 8d15341d8fa8fc96297425e3c6e39226)`); }
|
|
318
|
-
const data = resGet.rawResultIbGib.data as IbGibSpaceResultData;
|
|
319
|
-
|
|
320
|
-
throw new Error(`${lc} Failed to get all ${addrs} from source space ${from.ib}. resGet.errorMsg: ${resGet.errorMsg}. failed info: ${JSON.stringify(data)} (E: 4ed3383573382920c80054d7c1024626)`);
|
|
321
|
-
}
|
|
322
|
-
const ibGibs = resGet.ibGibs.concat();
|
|
323
|
-
|
|
324
|
-
// 2. Put in Dest
|
|
325
|
-
// Note: putInSpace handles existence check usually, or we can check.
|
|
326
|
-
const resPut = await putInSpace({ space: to, ibGibs });
|
|
327
|
-
if (resPut.success) {
|
|
328
|
-
console.error(`${lc} NAG ERROR: (SORT OF AN ERROR, DID NOT THROW): is the sync peer responsible for calling registerNewIbGib?? I'm not sure at this point if that is true, rather, I think that it probably is NOT responsible for this. But I'm putting this error msg as a nag message until this is resolved. (E: 00086833e294ee834800046801c47826) `);
|
|
329
|
-
} else {
|
|
330
|
-
throw new Error(`ERROR: successfully got addrs (${addrs}) from space (${from.ib}), BUT failed to put into space (${to.ib}). resPut.errorMsg: ${resPut.errorMsg}. timedOut: ${resPut.timedOut}. (E: c1044e14cc1db72d28a2240819dab826)`);
|
|
331
|
-
}
|
|
332
|
-
} catch (error) {
|
|
333
|
-
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
334
|
-
throw error;
|
|
335
298
|
} finally {
|
|
336
299
|
if (logalot) { console.log(`${lc} complete.`); }
|
|
337
300
|
}
|
|
338
|
-
|
|
339
301
|
}
|
|
302
|
+
|
|
340
303
|
}
|
|
@@ -21,8 +21,8 @@ import { newupSubject } from '../../common/pubsub/subject/subject-helper.mjs';
|
|
|
21
21
|
import { authenticateContext, authorizeContext, validateContextAndSagaFrame } from '../sync-saga-context/sync-saga-context-helpers.mjs';
|
|
22
22
|
import { getFromSpace } from '../../witness/space/space-helper.mjs';
|
|
23
23
|
|
|
24
|
-
const logalot = GLOBAL_LOG_A_LOT
|
|
25
|
-
const logalotControlDomain =
|
|
24
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
25
|
+
const logalotControlDomain = false;
|
|
26
26
|
const lcControlDomain = '[ControlDomain]';
|
|
27
27
|
|
|
28
28
|
/**
|