@ibgib/core-gib 0.1.23 → 0.1.25
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/common/other/graph-helper.d.mts +17 -0
- package/dist/common/other/graph-helper.d.mts.map +1 -1
- package/dist/common/other/graph-helper.mjs +44 -0
- package/dist/common/other/graph-helper.mjs.map +1 -1
- package/dist/sync/graft-info/graft-info-helpers.mjs +2 -2
- package/dist/sync/graft-info/graft-info-helpers.mjs.map +1 -1
- package/dist/sync/sync-conflict.respec.mjs +10 -15
- package/dist/sync/sync-conflict.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-constants.respec.mjs +10 -12
- package/dist/sync/sync-innerspace-constants.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-deep-updates.respec.mjs +10 -12
- package/dist/sync/sync-innerspace-deep-updates.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-dest-ahead.respec.mjs +10 -12
- package/dist/sync/sync-innerspace-dest-ahead.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs +9 -12
- package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-partial-update.respec.mjs +9 -14
- package/dist/sync/sync-innerspace-partial-update.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace.respec.mjs +9 -12
- package/dist/sync/sync-innerspace.respec.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.d.mts +2 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs +4 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts +24 -11
- 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 +58 -44
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-types.d.mts +29 -6
- package/dist/sync/sync-peer/sync-peer-types.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-v1.d.mts +29 -30
- package/dist/sync/sync-peer/sync-peer-v1.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-v1.mjs +105 -198
- package/dist/sync/sync-peer/sync-peer-v1.mjs.map +1 -1
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts +19 -2
- 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 +37 -4
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs.map +1 -1
- package/dist/sync/sync-saga-coordinator.d.mts +12 -12
- package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
- package/dist/sync/sync-saga-coordinator.mjs +281 -218
- package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts +51 -6
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts.map +1 -1
- package/dist/sync/sync-types.d.mts +36 -9
- package/dist/sync/sync-types.d.mts.map +1 -1
- package/dist/sync/sync-types.mjs +1 -2
- package/dist/sync/sync-types.mjs.map +1 -1
- package/package.json +1 -1
- package/src/common/other/graph-helper.mts +53 -0
- package/src/sync/graft-info/graft-info-helpers.mts +3 -3
- package/src/sync/sync-conflict.respec.mts +10 -17
- package/src/sync/sync-helpers.mts +6 -6
- package/src/sync/sync-innerspace-constants.respec.mts +10 -12
- package/src/sync/sync-innerspace-deep-updates.respec.mts +10 -12
- package/src/sync/sync-innerspace-dest-ahead.respec.mts +10 -12
- package/src/sync/sync-innerspace-multiple-timelines.respec.mts +9 -12
- package/src/sync/sync-innerspace-partial-update.respec.mts +9 -14
- package/src/sync/sync-innerspace.respec.mts +9 -12
- package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mts +7 -0
- package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mts +75 -50
- package/src/sync/sync-peer/sync-peer-types.mts +35 -11
- package/src/sync/sync-peer/sync-peer-v1.mts +136 -196
- package/src/sync/sync-saga-context/sync-saga-context-helpers.mts +37 -8
- package/src/sync/sync-saga-coordinator.mts +318 -260
- package/src/sync/sync-saga-message/sync-saga-message-types.mts +56 -4
- package/src/sync/sync-types.mts +46 -13
|
@@ -80,7 +80,7 @@ export async function getTempSpaceName(): Promise<string> {
|
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* UNTESTED
|
|
83
|
-
*
|
|
83
|
+
*
|
|
84
84
|
* Checks if an {@link olderAddr} is the address of a past frame in the ibgib
|
|
85
85
|
* with {@link newerAddr}.
|
|
86
86
|
*/
|
|
@@ -89,8 +89,8 @@ export async function isPastFrame({
|
|
|
89
89
|
newerAddr,
|
|
90
90
|
space,
|
|
91
91
|
}: {
|
|
92
|
-
olderAddr: string,
|
|
93
|
-
newerAddr: string,
|
|
92
|
+
olderAddr: string,
|
|
93
|
+
newerAddr: string,
|
|
94
94
|
space: IbGibSpaceAny,
|
|
95
95
|
}): Promise<boolean> {
|
|
96
96
|
const lc = `[${isPastFrame.name}]`;
|
|
@@ -148,15 +148,15 @@ export async function isPastFrame({
|
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
150
|
* Gets a shallow dependency graph for a Sync Saga Frame.
|
|
151
|
-
*
|
|
151
|
+
*
|
|
152
152
|
* DOES NOT GET THE ENTIRE DEPENDENCY FRAME (INCLUDING PAST).
|
|
153
|
-
*
|
|
153
|
+
*
|
|
154
154
|
* Unlike standard `getDependencyGraph`, this does NOT traverse `ancestor` (history) or `past`.
|
|
155
155
|
* It only retrieves the *content* of the current frame:
|
|
156
156
|
* 1. The Frame itself.
|
|
157
157
|
* 2. The Message Stone(s) (`rel8ns.msg`).
|
|
158
158
|
* 3. The Identity(s) (`rel8ns.identity`).
|
|
159
|
-
*
|
|
159
|
+
*
|
|
160
160
|
* This is used for efficient transmission of the "Current Step" without re-sending the entire history.
|
|
161
161
|
*/
|
|
162
162
|
export async function getSyncSagaFrameDependencyGraph({
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
respecfully, ifWeMight, iReckon, ifWe
|
|
10
10
|
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
11
11
|
const maam = `[${import.meta.url}]`, sir = maam;
|
|
12
|
-
import { delay } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
12
|
+
import { clone, delay } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
13
13
|
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
14
14
|
import { Factory_V1 } from '@ibgib/ts-gib/dist/V1/index.mjs';
|
|
15
15
|
|
|
@@ -20,6 +20,7 @@ import { InnerSpace_V1 } from '../witness/space/inner-space/inner-space-v1.mjs';
|
|
|
20
20
|
import { DEFAULT_INNER_SPACE_DATA_V1 } from '../witness/space/inner-space/inner-space-types.mjs';
|
|
21
21
|
import { getTestKeystoneServiceHelper } from '../agent-helpers.mjs';
|
|
22
22
|
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs';
|
|
23
|
+
import { SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs';
|
|
23
24
|
|
|
24
25
|
const lc = `[sync-innerspace-constants.respec]`;
|
|
25
26
|
|
|
@@ -69,17 +70,14 @@ await respecfully(sir, `Sync Constants (No TJP)`, async () => {
|
|
|
69
70
|
const senderCoordinator = new SyncSagaCoordinator(mockKeystone);
|
|
70
71
|
const receiverCoordinator = new SyncSagaCoordinator(mockKeystone);
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// classname: SyncPeerInnerspace_V1.name,
|
|
81
|
-
// });
|
|
82
|
-
const peer = new SyncPeerInnerspace_V1(0 as any, 0 as any, 0 as any, 0 as any);
|
|
73
|
+
const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
|
|
74
|
+
await peer.initialized;
|
|
75
|
+
await peer.initializeSender({
|
|
76
|
+
senderSpace: sourceSpace, // "Client"
|
|
77
|
+
receiverSpace: destSpace, // "Server"
|
|
78
|
+
receiverCoordinator,
|
|
79
|
+
receiverMetaspace: metaspace,
|
|
80
|
+
});
|
|
83
81
|
|
|
84
82
|
// 4. Sync C1 (First Pass)
|
|
85
83
|
let resSync = await senderCoordinator.sync({
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
ifWeMight
|
|
10
10
|
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
11
11
|
const maam = `[${import.meta.url}]`, sir = maam;
|
|
12
|
-
import { delay, extractErrorMsg, pretty } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
12
|
+
import { clone, delay, extractErrorMsg, pretty } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
13
13
|
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
14
14
|
import { getDependencyGraph } from '../common/other/graph-helper.mjs';
|
|
15
15
|
|
|
@@ -22,6 +22,7 @@ import { mut8Timeline } from '../timeline/timeline-api.mjs';
|
|
|
22
22
|
import { DEFAULT_INNER_SPACE_DATA_V1 } from '../witness/space/inner-space/inner-space-types.mjs';
|
|
23
23
|
import { toDto } from '../common/other/ibgib-helper.mjs';
|
|
24
24
|
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs';
|
|
25
|
+
import { SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs';
|
|
25
26
|
|
|
26
27
|
const logalot = true;
|
|
27
28
|
const lc = `[sync-innerspace-deep-updates.respec]`;
|
|
@@ -100,17 +101,14 @@ await respecfully(sir, `Sync InnerSpaces (Deep Updates)`, async () => {
|
|
|
100
101
|
const senderCoordinator = new SyncSagaCoordinator(mockKeystone);
|
|
101
102
|
const receiverCoordinator = new SyncSagaCoordinator(mockKeystone);
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// classname: SyncPeerInnerspace_V1.name,
|
|
112
|
-
// });
|
|
113
|
-
const peer = new SyncPeerInnerspace_V1(0 as any, 0 as any, 0 as any, 0 as any);
|
|
104
|
+
const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
|
|
105
|
+
await peer.initialized;
|
|
106
|
+
await peer.initializeSender({
|
|
107
|
+
senderSpace: sourceSpace, // "Client"
|
|
108
|
+
receiverSpace: destSpace, // "Server"
|
|
109
|
+
receiverCoordinator,
|
|
110
|
+
receiverMetaspace: metaspace,
|
|
111
|
+
});
|
|
114
112
|
|
|
115
113
|
// 4. Run Sync
|
|
116
114
|
console.log(`${lc} Running Sync...`);
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
ifWeMight
|
|
10
10
|
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
11
11
|
const maam = `[${import.meta.url}]`, sir = maam;
|
|
12
|
-
import { delay, extractErrorMsg, pretty } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
12
|
+
import { clone, delay, extractErrorMsg, pretty } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
13
13
|
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
14
14
|
import { getDependencyGraph } from '../common/other/graph-helper.mjs';
|
|
15
15
|
|
|
@@ -22,6 +22,7 @@ import { mut8Timeline } from '../timeline/timeline-api.mjs';
|
|
|
22
22
|
import { DEFAULT_INNER_SPACE_DATA_V1 } from '../witness/space/inner-space/inner-space-types.mjs';
|
|
23
23
|
import { toDto } from '../common/other/ibgib-helper.mjs';
|
|
24
24
|
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs';
|
|
25
|
+
import { SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs';
|
|
25
26
|
|
|
26
27
|
const logalot = true;
|
|
27
28
|
const lc = `[sync-innerspace-dest-ahead.respec]`;
|
|
@@ -110,17 +111,14 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
|
|
|
110
111
|
const senderCoordinator = new SyncSagaCoordinator(mockKeystone);
|
|
111
112
|
const receiverCoordinator = new SyncSagaCoordinator(mockKeystone);
|
|
112
113
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
// classname: SyncPeerInnerspace_V1.name
|
|
122
|
-
// });
|
|
123
|
-
const peer = new SyncPeerInnerspace_V1(0 as any, 0 as any, 0 as any, 0 as any);
|
|
114
|
+
const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
|
|
115
|
+
await peer.initialized;
|
|
116
|
+
await peer.initializeSender({
|
|
117
|
+
senderSpace: sourceSpace, // "Client"
|
|
118
|
+
receiverSpace: destSpace, // "Server"
|
|
119
|
+
receiverCoordinator,
|
|
120
|
+
receiverMetaspace: metaspace,
|
|
121
|
+
});
|
|
124
122
|
|
|
125
123
|
// 4. Run Sync (Source Pushes V1)
|
|
126
124
|
console.log(`${lc} Running Sync...`);
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
ifWeMight
|
|
10
10
|
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
11
11
|
const maam = `[${import.meta.url}]`, sir = maam;
|
|
12
|
-
import { delay, extractErrorMsg, pretty } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
12
|
+
import { clone, delay, extractErrorMsg, pretty } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
13
13
|
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
14
14
|
import { getDependencyGraph } from '../common/other/graph-helper.mjs';
|
|
15
15
|
|
|
@@ -22,6 +22,7 @@ import { mut8Timeline } from '../timeline/timeline-api.mjs';
|
|
|
22
22
|
import { DEFAULT_INNER_SPACE_DATA_V1 } from '../witness/space/inner-space/inner-space-types.mjs';
|
|
23
23
|
import { toDto } from '../common/other/ibgib-helper.mjs';
|
|
24
24
|
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs';
|
|
25
|
+
import { SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs';
|
|
25
26
|
|
|
26
27
|
const logalot = true;
|
|
27
28
|
const lc = `[sync-innerspace-multiple-timelines.respec]`;
|
|
@@ -104,18 +105,14 @@ await respecfully(sir, `Sync InnerSpaces (Multiple Timelines)`, async () => {
|
|
|
104
105
|
const senderCoordinator = new SyncSagaCoordinator(mockKeystone);
|
|
105
106
|
const receiverCoordinator = new SyncSagaCoordinator(mockKeystone);
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
// senderSpace: sourceSpace,
|
|
109
|
-
// receiverSpace: destSpace,
|
|
110
|
-
// receiverCoordinator: receiverCoordinator,
|
|
111
|
-
// receiverMetaspace: metaspace,
|
|
112
|
-
// receiverTempSpace: 0 as any, // just to get to compile
|
|
113
|
-
// senderTempSpace: 0 as any, // just to get to compile
|
|
114
|
-
// }, {
|
|
115
|
-
// classname: SyncPeerInnerspace_V1.name,
|
|
116
|
-
// });
|
|
117
|
-
const peer = new SyncPeerInnerspace_V1(0 as any, 0 as any, 0 as any, 0 as any);
|
|
108
|
+
const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
|
|
118
109
|
await peer.initialized;
|
|
110
|
+
await peer.initializeSender({
|
|
111
|
+
senderSpace: sourceSpace, // "Client"
|
|
112
|
+
receiverSpace: destSpace, // "Server"
|
|
113
|
+
receiverCoordinator,
|
|
114
|
+
receiverMetaspace: metaspace,
|
|
115
|
+
});
|
|
119
116
|
|
|
120
117
|
// 4. Run Sync (Push Both)
|
|
121
118
|
console.log(`${lc} Running Sync...`);
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
ifWeMight
|
|
10
10
|
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
11
11
|
const maam = `[${import.meta.url}]`, sir = maam;
|
|
12
|
-
import { delay, extractErrorMsg, pretty } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
12
|
+
import { clone, delay, extractErrorMsg, pretty } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
13
13
|
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
14
14
|
import { getDependencyGraph } from '../common/other/graph-helper.mjs';
|
|
15
15
|
|
|
@@ -22,6 +22,7 @@ import { mut8Timeline } from '../timeline/timeline-api.mjs';
|
|
|
22
22
|
import { DEFAULT_INNER_SPACE_DATA_V1 } from '../witness/space/inner-space/inner-space-types.mjs';
|
|
23
23
|
import { toDto } from '../common/other/ibgib-helper.mjs';
|
|
24
24
|
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs';
|
|
25
|
+
import { SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs';
|
|
25
26
|
|
|
26
27
|
const logalot = true;
|
|
27
28
|
const lc = `[sync-innerspace-partial-update.respec]`;
|
|
@@ -112,20 +113,14 @@ await respecfully(sir, `Sync InnerSpaces (Partial Update)`, async () => {
|
|
|
112
113
|
const senderCoordinator = new SyncSagaCoordinator(mockKeystone);
|
|
113
114
|
const receiverCoordinator = new SyncSagaCoordinator(mockKeystone);
|
|
114
115
|
|
|
115
|
-
|
|
116
|
-
// senderSpace: sourceSpace,
|
|
117
|
-
// receiverSpace: destSpace,
|
|
118
|
-
// receiverCoordinator: receiverCoordinator,
|
|
119
|
-
// receiverMetaspace: metaspace,
|
|
120
|
-
// receiverTempSpace: 0 as any, // just to get to compile
|
|
121
|
-
// senderTempSpace: 0 as any, // just to get to compile
|
|
122
|
-
// },
|
|
123
|
-
// {
|
|
124
|
-
// classname: SyncPeerInnerspace_V1.name,
|
|
125
|
-
// }
|
|
126
|
-
// );
|
|
127
|
-
const peer = new SyncPeerInnerspace_V1(0 as any, 0 as any, 0 as any, 0 as any);
|
|
116
|
+
const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
|
|
128
117
|
await peer.initialized;
|
|
118
|
+
await peer.initializeSender({
|
|
119
|
+
senderSpace: sourceSpace, // "Client"
|
|
120
|
+
receiverSpace: destSpace, // "Server"
|
|
121
|
+
receiverCoordinator,
|
|
122
|
+
receiverMetaspace: metaspace,
|
|
123
|
+
});
|
|
129
124
|
|
|
130
125
|
// 4. Run Sync (Source Pushes V2)
|
|
131
126
|
console.log(`${lc} Running Sync...`);
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
ifWeMight
|
|
11
11
|
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
12
12
|
const maam = `[${import.meta.url}]`, sir = maam;
|
|
13
|
-
import { delay, extractErrorMsg, pretty } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
13
|
+
import { clone, delay, extractErrorMsg, pretty } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
14
14
|
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
15
15
|
|
|
16
16
|
import { SyncSagaCoordinator } from './sync-saga-coordinator.mjs';
|
|
@@ -23,6 +23,7 @@ import { DEFAULT_INNER_SPACE_DATA_V1 } from '../witness/space/inner-space/inner-
|
|
|
23
23
|
import { toDto } from '../common/other/ibgib-helper.mjs';
|
|
24
24
|
import { fnObs } from '../common/pubsub/observer/observer-helper.mjs';
|
|
25
25
|
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs';
|
|
26
|
+
import { SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs';
|
|
26
27
|
|
|
27
28
|
const logalot = true;
|
|
28
29
|
const lc = `[sync-innerspace.respec]`;
|
|
@@ -103,18 +104,14 @@ await respecfully(sir, `Sync InnerSpaces`, async () => {
|
|
|
103
104
|
const receiverCoordinator = new SyncSagaCoordinator(mockKeystone);
|
|
104
105
|
|
|
105
106
|
// Peer (The "Network")
|
|
106
|
-
|
|
107
|
-
// senderSpace: sourceSpace, // "Client"
|
|
108
|
-
// receiverSpace: destSpace, // "Server"
|
|
109
|
-
// receiverCoordinator: receiverCoordinator,
|
|
110
|
-
// receiverMetaspace: metaspace,
|
|
111
|
-
// senderTempSpace: 0 as any,
|
|
112
|
-
// receiverTempSpace: 0 as any,
|
|
113
|
-
// }, {
|
|
114
|
-
// classname: SyncPeerInnerspace_V1.name,
|
|
115
|
-
// });
|
|
116
|
-
const peer = new SyncPeerInnerspace_V1(0 as any, 0 as any, 0 as any, 0 as any);
|
|
107
|
+
const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
|
|
117
108
|
await peer.initialized;
|
|
109
|
+
await peer.initializeSender({
|
|
110
|
+
senderSpace: sourceSpace, // "Client"
|
|
111
|
+
receiverSpace: destSpace, // "Server"
|
|
112
|
+
receiverCoordinator,
|
|
113
|
+
receiverMetaspace: metaspace,
|
|
114
|
+
});
|
|
118
115
|
|
|
119
116
|
// 4. Run Sync
|
|
120
117
|
console.log(`${lc} Running Sync...`);
|
|
@@ -2,7 +2,14 @@
|
|
|
2
2
|
* @module sync peer innerspace constants
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import { SyncPeerInnerspaceData_V1 } from "./sync-peer-innerspace-types.mjs";
|
|
6
|
+
import { SyncPeerInnerspace_V1 } from "./sync-peer-innerspace-v1.mjs";
|
|
7
|
+
|
|
5
8
|
/**
|
|
6
9
|
* Atom for the sync peer innerspace ibgib.
|
|
7
10
|
*/
|
|
8
11
|
export const SYNC_PEER_INNERSPACE_ATOM = 'sync_peer_innerspace';
|
|
12
|
+
|
|
13
|
+
export const SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1: SyncPeerInnerspaceData_V1 = {
|
|
14
|
+
classname: SyncPeerInnerspace_V1.name,
|
|
15
|
+
}
|
|
@@ -15,6 +15,7 @@ import { SyncPeerInnerspaceData_V1, SyncPeerInnerspaceIbGib_V1, SyncPeerInnerspa
|
|
|
15
15
|
import { MetaspaceService } from '../../../witness/space/metaspace/metaspace-types.mjs';
|
|
16
16
|
import { SyncSagaCoordinator } from '../../sync-saga-coordinator.mjs';
|
|
17
17
|
import { IbGibSpaceResultData } from '../../../witness/space/space-types.mjs';
|
|
18
|
+
import { InitializeSyncPeerOpts } from '../sync-peer-types.mjs';
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
const logalot = GLOBAL_LOG_A_LOT || true;
|
|
@@ -22,68 +23,82 @@ const logalotControlDomain = true;
|
|
|
22
23
|
const lcControlDomain = '[ControlDomain]';
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* Acts as the "Network" layer, transferring data between two local spaces and
|
|
28
|
-
* executing the receiver's coordinator logic.
|
|
26
|
+
* The innerspace sync peer works with innerspaces for both sender/receiver
|
|
27
|
+
* durable/temp spaces, as well as coordinators for each.
|
|
29
28
|
*/
|
|
30
|
-
export
|
|
31
|
-
|
|
32
|
-
protected lc: string = `[${SyncPeerInnerspace_V1.name}]`;
|
|
33
|
-
|
|
29
|
+
export interface InitializeSyncPeerInnerspaceOpts extends InitializeSyncPeerOpts {
|
|
34
30
|
/**
|
|
35
31
|
* specific to innerspace
|
|
36
32
|
*/
|
|
37
|
-
|
|
33
|
+
receiverCoordinator: SyncSagaCoordinator;
|
|
38
34
|
/**
|
|
39
35
|
* specific to innerspace
|
|
40
36
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
receiverMetaspace: MetaspaceService;
|
|
38
|
+
/**
|
|
39
|
+
* specific to innerspace
|
|
40
|
+
*/
|
|
41
|
+
receiverSpace: IbGibSpaceAny;
|
|
42
|
+
/**
|
|
43
|
+
* If not available at first, this will be automatically created.
|
|
44
|
+
*/
|
|
45
|
+
receiverTempSpace?: IbGibSpaceAny;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Concrete implementation of SyncPeer for local in-memory simulation (Innerspace to Innerspace).
|
|
50
|
+
*
|
|
51
|
+
* Acts as the "Network" layer, transferring data between two local spaces and
|
|
52
|
+
* executing the receiver's coordinator logic.
|
|
53
|
+
*/
|
|
54
|
+
export class SyncPeerInnerspace_V1 extends SyncPeer_V1<InitializeSyncPeerInnerspaceOpts>
|
|
55
|
+
implements SyncPeerInnerspaceIbGib_V1 {
|
|
56
|
+
|
|
57
|
+
protected lc: string = `[${SyncPeerInnerspace_V1.name}]`;
|
|
44
58
|
|
|
45
59
|
override get classname(): string {
|
|
46
60
|
return SyncPeerInnerspace_V1.name;
|
|
47
61
|
}
|
|
48
62
|
|
|
49
63
|
constructor(
|
|
50
|
-
senderSpace: IbGibSpaceAny,
|
|
51
|
-
senderTempSpace: IbGibSpaceAny,
|
|
52
|
-
opts: SyncPeerInnerspaceOptions,
|
|
53
64
|
initialData: SyncPeerInnerspaceData_V1,
|
|
54
65
|
initialRel8ns?: SyncPeerInnerspaceRel8ns_V1,
|
|
55
66
|
) {
|
|
56
|
-
super(
|
|
57
|
-
const {
|
|
58
|
-
receiverCoordinator,
|
|
59
|
-
receiverMetaspace, receiverSpace, receiverTempSpace
|
|
60
|
-
} = opts;
|
|
61
|
-
|
|
62
|
-
this.receiverCoordinator = receiverCoordinator;
|
|
63
|
-
this.receiverMetaspace = receiverMetaspace;
|
|
64
|
-
this.receiverSpace = receiverSpace;
|
|
65
|
-
this.receiverTempSpace = receiverTempSpace;
|
|
67
|
+
super(initialData, initialRel8ns);
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
protected override async ensureReceiverTempSpace(): Promise<IbGibSpaceAny> {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
71
|
+
const lc = `${this.lc}[${this.ensureReceiverTempSpace.name}]`;
|
|
72
|
+
try {
|
|
73
|
+
if (logalot) { console.log(`${lc} starting... (I: bab87f15dea77cd4892bd8a8d2e65826)`); }
|
|
74
|
+
|
|
75
|
+
if (!this.opts) { throw new Error(`(UNEXPECTED) this.opts falsy? (E: 0f85bd4c3efdbee2a829aca860c48926)`); }
|
|
76
|
+
|
|
77
|
+
if (!this.opts.receiverTempSpace) {
|
|
78
|
+
const { receiverMetaspace } = this.opts;
|
|
79
|
+
|
|
80
|
+
const uuid = crypto.randomUUID ? crypto.randomUUID() : Math.random().toString(36);
|
|
81
|
+
const tempSpaceName = `tmp_sync_recv_${uuid.substring(0, 8)}`;
|
|
82
|
+
const receiverTempSpace = await receiverMetaspace.createNewLocalSpace({
|
|
83
|
+
opts: {
|
|
84
|
+
allowCancel: false,
|
|
85
|
+
spaceName: tempSpaceName,
|
|
86
|
+
getFnPrompt: receiverMetaspace.getFnPrompt!,
|
|
87
|
+
logalot
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
if (!receiverTempSpace) { throw new Error(`(UNEXPECTED) receiverTempSpace falsy? couldn't create a temp space? (E: a6b8f86b0f58384b884a33b82924b826)`); }
|
|
91
|
+
await receiverTempSpace.initialized;
|
|
92
|
+
this.opts.receiverTempSpace = receiverTempSpace;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return this.opts.receiverTempSpace;
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
98
|
+
throw error;
|
|
99
|
+
} finally {
|
|
100
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
85
101
|
}
|
|
86
|
-
return this.receiverTempSpace;
|
|
87
102
|
}
|
|
88
103
|
|
|
89
104
|
|
|
@@ -91,12 +106,13 @@ export class SyncPeerInnerspace_V1 extends SyncPeer_V1 implements SyncPeerInners
|
|
|
91
106
|
const lc = `${this.lc}[${this.push.name}]`;
|
|
92
107
|
try {
|
|
93
108
|
if (logalot) { console.log(`${lc} starting... (I: 07bce80be18f3259b8a311ed9c4da926)`); }
|
|
109
|
+
if (!this.opts) { throw new Error(`(UNEXPECTED) this.opts falsy? (E: e1efd1b364cc8a8d985b243878f71e26)`); }
|
|
94
110
|
|
|
95
111
|
// silly defensive checks because this has been a ridiculous development cycle
|
|
96
|
-
if (!this.senderSpace) { throw new Error(`(UNEXPECTED) this.senderSpace falsy? (E: 503e288168f5d297f4d4e028bc538826)`); }
|
|
97
|
-
if (!this.
|
|
112
|
+
if (!this.opts.senderSpace) { throw new Error(`(UNEXPECTED) this.opts.senderSpace falsy? (E: 503e288168f5d297f4d4e028bc538826)`); }
|
|
113
|
+
if (!this.opts.receiverTempSpace) { throw new Error(`(UNEXPECTED) this.opts.receiverTempSpace falsy? (E: 0bd7c1a0ba4868ac7a260e15b504e826)`); }
|
|
98
114
|
|
|
99
|
-
await this.transfer({ addrs, from: this.senderSpace, to: this.
|
|
115
|
+
await this.transfer({ addrs, from: this.opts.senderSpace, to: this.opts.receiverTempSpace });
|
|
100
116
|
} catch (error) {
|
|
101
117
|
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
102
118
|
throw error;
|
|
@@ -110,11 +126,13 @@ export class SyncPeerInnerspace_V1 extends SyncPeer_V1 implements SyncPeerInners
|
|
|
110
126
|
try {
|
|
111
127
|
if (logalot) { console.log(`${lc} starting... (I: b16a28ed0dc8f52f1838ee257d9b1126)`); }
|
|
112
128
|
|
|
129
|
+
if (!this.opts) { throw new Error(`(UNEXPECTED) this.opts falsy? (E: 5a72b83fc1a83bf0f81d19330f575626)`); }
|
|
130
|
+
|
|
113
131
|
// silly defensive checks because this has been a ridiculous development cycle
|
|
114
|
-
if (!this.receiverSpace) { throw new Error(`(UNEXPECTED) this.receiverSpace falsy? (E: bd2fdfa89ba4c89a185b68e9bb1f1c26)`); }
|
|
115
|
-
if (!this.senderTempSpace) { throw new Error(`(UNEXPECTED) this.senderTempSpace falsy? (E: b23fa55713f881493dac4a9835ac7326)`); }
|
|
132
|
+
if (!this.opts.receiverSpace) { throw new Error(`(UNEXPECTED) this.opts.receiverSpace falsy? (E: bd2fdfa89ba4c89a185b68e9bb1f1c26)`); }
|
|
133
|
+
if (!this.opts.senderTempSpace) { throw new Error(`(UNEXPECTED) this.opts.senderTempSpace falsy? (E: b23fa55713f881493dac4a9835ac7326)`); }
|
|
116
134
|
|
|
117
|
-
await this.transfer({ addrs, from: this.receiverSpace, to: this.senderTempSpace });
|
|
135
|
+
await this.transfer({ addrs, from: this.opts.receiverSpace, to: this.opts.senderTempSpace });
|
|
118
136
|
} catch (error) {
|
|
119
137
|
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
120
138
|
throw error;
|
|
@@ -125,9 +143,11 @@ export class SyncPeerInnerspace_V1 extends SyncPeer_V1 implements SyncPeerInners
|
|
|
125
143
|
|
|
126
144
|
protected async sendContextRequest(context: SyncSagaContextIbGib_V1): Promise<SyncSagaContextIbGib_V1 | undefined> {
|
|
127
145
|
const lc = `${this.lc}[${this.sendContextRequest.name}]`;
|
|
128
|
-
const { receiverSpace, receiverCoordinator, receiverMetaspace } = this;
|
|
129
|
-
|
|
130
146
|
try {
|
|
147
|
+
if (!this.opts) { throw new Error(`(UNEXPECTED) this.opts falsy? (E: d8b1348e3233810128999596b1fa5826)`); }
|
|
148
|
+
|
|
149
|
+
const { receiverSpace, receiverCoordinator, receiverMetaspace } = this.opts;
|
|
150
|
+
|
|
131
151
|
if (logalot) { console.log(`${lc} starting...Context: ${getIbGibAddr({ ibGib: context })}`); }
|
|
132
152
|
|
|
133
153
|
// 0. Validate context (naive, not business logic validation)
|
|
@@ -137,6 +157,11 @@ export class SyncPeerInnerspace_V1 extends SyncPeer_V1 implements SyncPeerInners
|
|
|
137
157
|
if (!context.sagaFrame) { throw new Error(`(UNEXPECTED) context.sagaFrame falsy? (E: 79cd98a6d9b88a591f4596c8bc58ff26)`); }
|
|
138
158
|
|
|
139
159
|
|
|
160
|
+
// if we have push offer requests, start those.
|
|
161
|
+
|
|
162
|
+
// send the context itself, then send the payload ibgibs separately.
|
|
163
|
+
|
|
164
|
+
|
|
140
165
|
|
|
141
166
|
throw new Error(`not implemented (E: 72840872e252d9f7380f1998b5a0c826)`);
|
|
142
167
|
} catch (error) {
|
|
@@ -30,11 +30,32 @@ export interface SyncPeerRel8ns_V1 extends IbGibRel8ns_V1 {
|
|
|
30
30
|
*/
|
|
31
31
|
export interface SyncPeerIbGib_V1 extends IbGib_V1<SyncPeerData_V1, SyncPeerRel8ns_V1> { }
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* base initialization opts
|
|
35
|
+
*/
|
|
36
|
+
export interface InitializeSyncPeerOpts {
|
|
37
|
+
/**
|
|
38
|
+
* sender's durable space.
|
|
39
|
+
*
|
|
40
|
+
* will store control ibgibs (context, sync saga ibgib, control msg stones)
|
|
41
|
+
* here (and in {@link senderTempSpace}) throughout the process for audit trail.
|
|
42
|
+
*/
|
|
43
|
+
senderSpace: IbGibSpaceAny;
|
|
44
|
+
/**
|
|
45
|
+
* sender's temporary space for the entire sync transaction.
|
|
46
|
+
*
|
|
47
|
+
* In addition to control ibgibs which are stored in both temp and durable
|
|
48
|
+
* spaces, this temp space will be where domain ibgibs are stored that are
|
|
49
|
+
* received/created throughout the transaction until commit.
|
|
50
|
+
*/
|
|
51
|
+
senderTempSpace?: IbGibSpaceAny;
|
|
52
|
+
}
|
|
53
|
+
|
|
33
54
|
/**
|
|
34
55
|
* The interface for the SyncPeer witness class.
|
|
35
56
|
* It witnesses a SyncSagaContext and returns a SyncSagaContext (Request -> Response).
|
|
36
57
|
*/
|
|
37
|
-
export interface SyncPeerWitness extends Witness_V1<
|
|
58
|
+
export interface SyncPeerWitness<TInitializeOpts extends InitializeSyncPeerOpts = InitializeSyncPeerOpts> extends Witness_V1<
|
|
38
59
|
SyncSagaContextData_V1,
|
|
39
60
|
SyncSagaContextRel8ns_V1,
|
|
40
61
|
SyncSagaContextIbGib_V1, // Input
|
|
@@ -44,23 +65,26 @@ export interface SyncPeerWitness extends Witness_V1<
|
|
|
44
65
|
SyncPeerData_V1,
|
|
45
66
|
SyncPeerRel8ns_V1
|
|
46
67
|
> {
|
|
47
|
-
|
|
68
|
+
get classname(): string;
|
|
48
69
|
|
|
49
70
|
/**
|
|
50
|
-
* sender
|
|
71
|
+
* sender-specific opts/config
|
|
51
72
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
73
|
+
* ## notes
|
|
74
|
+
*
|
|
75
|
+
* I'm doing this hack because I have to be able to create a peer without
|
|
76
|
+
* being able to fully configure it at construction time. So I can't place
|
|
77
|
+
* this init code in the {@link initialize} method.
|
|
54
78
|
*/
|
|
55
|
-
|
|
79
|
+
opts: TInitializeOpts | undefined;
|
|
80
|
+
|
|
56
81
|
/**
|
|
57
|
-
*
|
|
82
|
+
* use this to set the senderTempSpace and any other optional opts that need
|
|
83
|
+
* to be configured just before sending any contexts across the wire.
|
|
58
84
|
*
|
|
59
|
-
*
|
|
60
|
-
* spaces, this temp space will be where domain ibgibs are stored that are
|
|
61
|
-
* received/created throughout the transaction until commit.
|
|
85
|
+
* @see {@link opts}
|
|
62
86
|
*/
|
|
63
|
-
|
|
87
|
+
setOptionalOpts(arg: Partial<TInitializeOpts>): void;
|
|
64
88
|
|
|
65
89
|
/**
|
|
66
90
|
* Observable for streaming large domain payloads asynchronously.
|