@ibgib/core-gib 0.1.22 → 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 +25 -0
- package/dist/common/other/graph-helper.d.mts.map +1 -1
- package/dist/common/other/graph-helper.mjs +75 -1
- 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 +8 -12
- package/dist/sync/sync-conflict.respec.mjs.map +1 -1
- package/dist/sync/sync-constants.d.mts +14 -4
- package/dist/sync/sync-constants.d.mts.map +1 -1
- package/dist/sync/sync-constants.mjs +15 -3
- package/dist/sync/sync-constants.mjs.map +1 -1
- package/dist/sync/sync-helpers.d.mts +22 -15
- package/dist/sync/sync-helpers.d.mts.map +1 -1
- package/dist/sync/sync-helpers.mjs +159 -90
- package/dist/sync/sync-helpers.mjs.map +1 -1
- package/dist/sync/sync-innerspace-constants.respec.mjs +8 -9
- package/dist/sync/sync-innerspace-constants.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-deep-updates.respec.mjs +8 -9
- package/dist/sync/sync-innerspace-deep-updates.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-dest-ahead.respec.mjs +8 -9
- package/dist/sync/sync-innerspace-dest-ahead.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs +8 -9
- package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-partial-update.respec.mjs +8 -9
- package/dist/sync/sync-innerspace-partial-update.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace.respec.mjs +6 -7
- 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-types.d.mts +0 -15
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-types.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts +30 -16
- 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 +47 -79
- 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 +40 -1
- package/dist/sync/sync-peer/sync-peer-types.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-v1.d.mts +47 -14
- package/dist/sync/sync-peer/sync-peer-v1.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-v1.mjs +188 -144
- package/dist/sync/sync-peer/sync-peer-v1.mjs.map +1 -1
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts +39 -3
- 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 +137 -31
- 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 +5 -0
- package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts.map +1 -1
- package/dist/sync/sync-saga-coordinator.d.mts +81 -77
- package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
- package/dist/sync/sync-saga-coordinator.mjs +608 -597
- package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts +154 -26
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts.map +1 -1
- package/dist/sync/sync-types.d.mts +87 -92
- package/dist/sync/sync-types.d.mts.map +1 -1
- package/dist/sync/sync-types.mjs +6 -2
- package/dist/sync/sync-types.mjs.map +1 -1
- package/dist/timeline/timeline-api.d.mts.map +1 -1
- package/dist/timeline/timeline-api.mjs +15 -8
- package/dist/timeline/timeline-api.mjs.map +1 -1
- package/package.json +1 -1
- package/src/common/other/graph-helper.mts +79 -1
- package/src/sync/graft-info/graft-info-helpers.mts +3 -3
- package/src/sync/sync-conflict.respec.mts +8 -14
- package/src/sync/sync-constants.mts +15 -4
- package/src/sync/sync-helpers.mts +173 -101
- package/src/sync/sync-innerspace-constants.respec.mts +8 -9
- package/src/sync/sync-innerspace-deep-updates.respec.mts +8 -9
- package/src/sync/sync-innerspace-dest-ahead.respec.mts +8 -9
- package/src/sync/sync-innerspace-multiple-timelines.respec.mts +8 -9
- package/src/sync/sync-innerspace-partial-update.respec.mts +9 -12
- package/src/sync/sync-innerspace.respec.mts +6 -7
- 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-types.mts +0 -15
- package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mts +72 -96
- package/src/sync/sync-peer/sync-peer-types.mts +43 -2
- package/src/sync/sync-peer/sync-peer-v1.mts +215 -142
- package/src/sync/sync-saga-context/sync-saga-context-helpers.mts +145 -37
- package/src/sync/sync-saga-context/sync-saga-context-types.mts +5 -0
- package/src/sync/sync-saga-coordinator.mts +680 -714
- package/src/sync/sync-saga-message/sync-saga-message-types.mts +160 -24
- package/src/sync/sync-types.mts +96 -105
- package/src/timeline/timeline-api.mts +17 -10
|
@@ -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,15 +104,13 @@ await respecfully(sir, `Sync InnerSpaces`, async () => {
|
|
|
103
104
|
const receiverCoordinator = new SyncSagaCoordinator(mockKeystone);
|
|
104
105
|
|
|
105
106
|
// Peer (The "Network")
|
|
106
|
-
const peer = new SyncPeerInnerspace_V1(
|
|
107
|
+
const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
|
|
108
|
+
await peer.initialized;
|
|
109
|
+
await peer.initializeSender({
|
|
107
110
|
senderSpace: sourceSpace, // "Client"
|
|
108
111
|
receiverSpace: destSpace, // "Server"
|
|
109
|
-
receiverCoordinator
|
|
112
|
+
receiverCoordinator,
|
|
110
113
|
receiverMetaspace: metaspace,
|
|
111
|
-
senderTempSpace: 0 as any,
|
|
112
|
-
receiverTempSpace: 0 as any,
|
|
113
|
-
}, {
|
|
114
|
-
classname: SyncPeerInnerspace_V1.name,
|
|
115
114
|
});
|
|
116
115
|
|
|
117
116
|
// 4. Run 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
|
+
}
|
|
@@ -14,21 +14,6 @@ import { SyncPeerData_V1, SyncPeerRel8ns_V1 } from '../sync-peer-types.mjs';
|
|
|
14
14
|
* Options for creating a SyncPeerInnerspace instance.
|
|
15
15
|
*/
|
|
16
16
|
export interface SyncPeerInnerspaceOptions {
|
|
17
|
-
/**
|
|
18
|
-
* sender's durable space.
|
|
19
|
-
*
|
|
20
|
-
* will store control ibgibs (context, sync saga ibgib, control msg stones)
|
|
21
|
-
* here (and in {@link senderTempSpace}) throughout the process for audit trail.
|
|
22
|
-
*/
|
|
23
|
-
senderSpace: IbGibSpaceAny;
|
|
24
|
-
/**
|
|
25
|
-
* sender's temporary space for the entire sync transaction.
|
|
26
|
-
*
|
|
27
|
-
* In addition to control ibgibs which are stored in both temp and durable
|
|
28
|
-
* spaces, this temp space will be where domain ibgibs are stored that are
|
|
29
|
-
* received/created throughout the transaction until commit.
|
|
30
|
-
*/
|
|
31
|
-
senderTempSpace: IbGibSpaceAny;
|
|
32
17
|
/**
|
|
33
18
|
* The "receiver" durable space (not temp).
|
|
34
19
|
*
|
|
@@ -3,114 +3,96 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { extractErrorMsg, unique } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
6
|
-
import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
7
6
|
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
7
|
+
import { IbGibAddr } from '@ibgib/ts-gib/dist/types.mjs';
|
|
8
8
|
|
|
9
9
|
import { GLOBAL_LOG_A_LOT } from '../../../core-constants.mjs';
|
|
10
|
-
import { SYNC_ATOM, } from '../../sync-constants.mjs';
|
|
11
10
|
import { IbGibSpaceAny } from '../../../witness/space/space-base-v1.mjs';
|
|
12
11
|
import { SyncPeer_V1 } from '../sync-peer-v1.mjs';
|
|
13
12
|
import { getFromSpace, putInSpace } from '../../../witness/space/space-helper.mjs';
|
|
14
13
|
import { SyncSagaContextIbGib_V1, } from '../../sync-saga-context/sync-saga-context-types.mjs';
|
|
15
|
-
import { createSyncSagaContext } from '../../sync-saga-context/sync-saga-context-helpers.mjs';
|
|
16
|
-
import { SubjectWitness } from '../../../common/pubsub/subject/subject-types.mjs';
|
|
17
|
-
import { newupSubject } from '../../../common/pubsub/subject/subject-helper.mjs';
|
|
18
14
|
import { SyncPeerInnerspaceData_V1, SyncPeerInnerspaceIbGib_V1, SyncPeerInnerspaceOptions, SyncPeerInnerspaceRel8ns_V1 } from './sync-peer-innerspace-types.mjs';
|
|
19
|
-
import { SYNC_PEER_INNERSPACE_ATOM } from './sync-peer-innerspace-constants.mjs';
|
|
20
|
-
import { SyncPeerData_V1, SyncPeerRel8ns_V1 } from '../sync-peer-types.mjs';
|
|
21
15
|
import { MetaspaceService } from '../../../witness/space/metaspace/metaspace-types.mjs';
|
|
22
16
|
import { SyncSagaCoordinator } from '../../sync-saga-coordinator.mjs';
|
|
23
|
-
import { IbGibAddr } from '@ibgib/ts-gib/dist/types.mjs';
|
|
24
17
|
import { IbGibSpaceResultData } from '../../../witness/space/space-types.mjs';
|
|
25
|
-
import {
|
|
18
|
+
import { InitializeSyncPeerOpts } from '../sync-peer-types.mjs';
|
|
26
19
|
|
|
27
20
|
|
|
28
21
|
const logalot = GLOBAL_LOG_A_LOT || true;
|
|
29
22
|
const logalotControlDomain = true;
|
|
30
23
|
const lcControlDomain = '[ControlDomain]';
|
|
31
24
|
|
|
25
|
+
/**
|
|
26
|
+
* The innerspace sync peer works with innerspaces for both sender/receiver
|
|
27
|
+
* durable/temp spaces, as well as coordinators for each.
|
|
28
|
+
*/
|
|
29
|
+
export interface InitializeSyncPeerInnerspaceOpts extends InitializeSyncPeerOpts {
|
|
30
|
+
/**
|
|
31
|
+
* specific to innerspace
|
|
32
|
+
*/
|
|
33
|
+
receiverCoordinator: SyncSagaCoordinator;
|
|
34
|
+
/**
|
|
35
|
+
* specific to innerspace
|
|
36
|
+
*/
|
|
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
|
+
|
|
32
48
|
/**
|
|
33
49
|
* Concrete implementation of SyncPeer for local in-memory simulation (Innerspace to Innerspace).
|
|
34
|
-
*
|
|
35
|
-
* Acts as the "Network" layer, transferring data between two local spaces and
|
|
50
|
+
*
|
|
51
|
+
* Acts as the "Network" layer, transferring data between two local spaces and
|
|
36
52
|
* executing the receiver's coordinator logic.
|
|
37
53
|
*/
|
|
38
|
-
export class SyncPeerInnerspace_V1 extends SyncPeer_V1
|
|
54
|
+
export class SyncPeerInnerspace_V1 extends SyncPeer_V1<InitializeSyncPeerInnerspaceOpts>
|
|
55
|
+
implements SyncPeerInnerspaceIbGib_V1 {
|
|
39
56
|
|
|
40
57
|
protected lc: string = `[${SyncPeerInnerspace_V1.name}]`;
|
|
41
58
|
|
|
42
|
-
public payloadIbGibsDomainReceived$!: SubjectWitness<IbGib_V1>;
|
|
43
|
-
|
|
44
|
-
private senderSpace: IbGibSpaceAny;
|
|
45
|
-
private senderTempSpace: IbGibSpaceAny;
|
|
46
|
-
private receiverCoordinator: SyncSagaCoordinator;
|
|
47
|
-
private receiverMetaspace: MetaspaceService;
|
|
48
|
-
private receiverSpace: IbGibSpaceAny;
|
|
49
|
-
private receiverTempSpace: IbGibSpaceAny;
|
|
50
|
-
|
|
51
59
|
override get classname(): string {
|
|
52
60
|
return SyncPeerInnerspace_V1.name;
|
|
53
61
|
}
|
|
54
62
|
|
|
55
63
|
constructor(
|
|
56
|
-
opts: SyncPeerInnerspaceOptions,
|
|
57
64
|
initialData: SyncPeerInnerspaceData_V1,
|
|
58
65
|
initialRel8ns?: SyncPeerInnerspaceRel8ns_V1,
|
|
59
66
|
) {
|
|
60
67
|
super(initialData, initialRel8ns);
|
|
61
|
-
const {
|
|
62
|
-
senderSpace, senderTempSpace, receiverCoordinator,
|
|
63
|
-
receiverMetaspace, receiverSpace, receiverTempSpace
|
|
64
|
-
} = opts;
|
|
65
|
-
|
|
66
|
-
this.senderSpace = senderSpace;
|
|
67
|
-
this.senderTempSpace = senderTempSpace;
|
|
68
|
-
this.receiverCoordinator = receiverCoordinator;
|
|
69
|
-
this.receiverMetaspace = receiverMetaspace;
|
|
70
|
-
this.receiverSpace = receiverSpace;
|
|
71
|
-
this.receiverTempSpace = receiverTempSpace;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
async initialize(): Promise<void> {
|
|
75
|
-
this.payloadIbGibsDomainReceived$ = await newupSubject<IbGib_V1>();
|
|
76
68
|
}
|
|
77
69
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const { receiverMetaspace } = this;
|
|
81
|
-
|
|
82
|
-
const uuid = crypto.randomUUID ? crypto.randomUUID() : Math.random().toString(36);
|
|
83
|
-
const tempSpaceName = `tmp_sync_recv_${uuid.substring(0, 8)}`;
|
|
84
|
-
const receiverTempSpace = await this.receiverMetaspace.createNewLocalSpace({
|
|
85
|
-
opts: {
|
|
86
|
-
allowCancel: false,
|
|
87
|
-
spaceName: tempSpaceName,
|
|
88
|
-
getFnPrompt: this.receiverMetaspace.getFnPrompt!,
|
|
89
|
-
logalot
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
if (!receiverTempSpace) { throw new Error(`(UNEXPECTED) receiverTempSpace falsy? couldn't create a temp space? (E: a6b8f86b0f58384b884a33b82924b826)`); }
|
|
93
|
-
await receiverTempSpace.initialized;
|
|
94
|
-
this.receiverTempSpace = receiverTempSpace;
|
|
95
|
-
}
|
|
96
|
-
return this.receiverTempSpace;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
protected async getLocalIbGib(addr: string): Promise<IbGib_V1 | undefined> {
|
|
100
|
-
const lc = `${this.lc}[${this.getLocalIbGib.name}]`;
|
|
70
|
+
protected override async ensureReceiverTempSpace(): Promise<IbGibSpaceAny> {
|
|
71
|
+
const lc = `${this.lc}[${this.ensureReceiverTempSpace.name}]`;
|
|
101
72
|
try {
|
|
102
|
-
if (logalot) { console.log(`${lc} starting... (I:
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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;
|
|
113
93
|
}
|
|
94
|
+
|
|
95
|
+
return this.opts.receiverTempSpace;
|
|
114
96
|
} catch (error) {
|
|
115
97
|
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
116
98
|
throw error;
|
|
@@ -119,16 +101,18 @@ export class SyncPeerInnerspace_V1 extends SyncPeer_V1 implements SyncPeerInners
|
|
|
119
101
|
}
|
|
120
102
|
}
|
|
121
103
|
|
|
104
|
+
|
|
122
105
|
protected async push(addrs: IbGibAddr[]): Promise<void> {
|
|
123
106
|
const lc = `${this.lc}[${this.push.name}]`;
|
|
124
107
|
try {
|
|
125
108
|
if (logalot) { console.log(`${lc} starting... (I: 07bce80be18f3259b8a311ed9c4da926)`); }
|
|
109
|
+
if (!this.opts) { throw new Error(`(UNEXPECTED) this.opts falsy? (E: e1efd1b364cc8a8d985b243878f71e26)`); }
|
|
126
110
|
|
|
127
111
|
// silly defensive checks because this has been a ridiculous development cycle
|
|
128
|
-
if (!this.senderSpace) { throw new Error(`(UNEXPECTED) this.senderSpace falsy? (E: 503e288168f5d297f4d4e028bc538826)`); }
|
|
129
|
-
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)`); }
|
|
130
114
|
|
|
131
|
-
await this.transfer({ addrs, from: this.senderSpace, to: this.
|
|
115
|
+
await this.transfer({ addrs, from: this.opts.senderSpace, to: this.opts.receiverTempSpace });
|
|
132
116
|
} catch (error) {
|
|
133
117
|
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
134
118
|
throw error;
|
|
@@ -142,11 +126,13 @@ export class SyncPeerInnerspace_V1 extends SyncPeer_V1 implements SyncPeerInners
|
|
|
142
126
|
try {
|
|
143
127
|
if (logalot) { console.log(`${lc} starting... (I: b16a28ed0dc8f52f1838ee257d9b1126)`); }
|
|
144
128
|
|
|
129
|
+
if (!this.opts) { throw new Error(`(UNEXPECTED) this.opts falsy? (E: 5a72b83fc1a83bf0f81d19330f575626)`); }
|
|
130
|
+
|
|
145
131
|
// silly defensive checks because this has been a ridiculous development cycle
|
|
146
|
-
if (!this.receiverSpace) { throw new Error(`(UNEXPECTED) this.receiverSpace falsy? (E: bd2fdfa89ba4c89a185b68e9bb1f1c26)`); }
|
|
147
|
-
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)`); }
|
|
148
134
|
|
|
149
|
-
await this.transfer({ addrs, from: this.receiverSpace, to: this.senderTempSpace });
|
|
135
|
+
await this.transfer({ addrs, from: this.opts.receiverSpace, to: this.opts.senderTempSpace });
|
|
150
136
|
} catch (error) {
|
|
151
137
|
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
152
138
|
throw error;
|
|
@@ -157,9 +143,11 @@ export class SyncPeerInnerspace_V1 extends SyncPeer_V1 implements SyncPeerInners
|
|
|
157
143
|
|
|
158
144
|
protected async sendContextRequest(context: SyncSagaContextIbGib_V1): Promise<SyncSagaContextIbGib_V1 | undefined> {
|
|
159
145
|
const lc = `${this.lc}[${this.sendContextRequest.name}]`;
|
|
160
|
-
const { receiverSpace, receiverCoordinator, receiverMetaspace } = this;
|
|
161
|
-
|
|
162
146
|
try {
|
|
147
|
+
if (!this.opts) { throw new Error(`(UNEXPECTED) this.opts falsy? (E: d8b1348e3233810128999596b1fa5826)`); }
|
|
148
|
+
|
|
149
|
+
const { receiverSpace, receiverCoordinator, receiverMetaspace } = this.opts;
|
|
150
|
+
|
|
163
151
|
if (logalot) { console.log(`${lc} starting...Context: ${getIbGibAddr({ ibGib: context })}`); }
|
|
164
152
|
|
|
165
153
|
// 0. Validate context (naive, not business logic validation)
|
|
@@ -168,23 +156,11 @@ export class SyncPeerInnerspace_V1 extends SyncPeer_V1 implements SyncPeerInners
|
|
|
168
156
|
if (!context.rel8ns.sagaFrame) { throw new Error(`(UNEXPECTED) context.rel8ns.sagaFrame falsy? (E: ac06782ad538be406882605f0a83aa26)`); }
|
|
169
157
|
if (!context.sagaFrame) { throw new Error(`(UNEXPECTED) context.sagaFrame falsy? (E: 79cd98a6d9b88a591f4596c8bc58ff26)`); }
|
|
170
158
|
|
|
171
|
-
|
|
172
|
-
//
|
|
173
|
-
|
|
174
|
-
//
|
|
175
|
-
|
|
176
|
-
// await until all domain ibgibs are in receiver's temp space
|
|
177
|
-
// process the context with the receiver's coordinator to get a new response context
|
|
178
|
-
// analyze the response context
|
|
179
|
-
// validate context intrinsically
|
|
180
|
-
// validate return identity if present
|
|
181
|
-
// persist the response context's dependency graph (context, saga frame and msg(s), identities)
|
|
182
|
-
// if response has payload domain ibgibs,
|
|
183
|
-
// spin off...
|
|
184
|
-
// pull domain ibgibs to local temp space
|
|
185
|
-
// publish domain ibgibs to observable
|
|
186
|
-
// when all domain ibgibs are pulled, publish complete to the observable
|
|
187
|
-
// return resulting context ibgib (which the caller should get BEFORE the domain ibgibs observable completes)
|
|
159
|
+
|
|
160
|
+
// if we have push offer requests, start those.
|
|
161
|
+
|
|
162
|
+
// send the context itself, then send the payload ibgibs separately.
|
|
163
|
+
|
|
188
164
|
|
|
189
165
|
|
|
190
166
|
throw new Error(`not implemented (E: 72840872e252d9f7380f1998b5a0c826)`);
|
|
@@ -7,6 +7,7 @@ import { SubjectWitness } from '../../common/pubsub/subject/subject-types.mjs';
|
|
|
7
7
|
|
|
8
8
|
import { SyncSagaContextData_V1, SyncSagaContextIbGib_V1, SyncSagaContextRel8ns_V1 } from '../sync-saga-context/sync-saga-context-types.mjs';
|
|
9
9
|
import { Witness_V1 } from '../../witness/witness-types.mjs';
|
|
10
|
+
import { IbGibSpaceAny } from '../../witness/space/space-base-v1.mjs';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Data for the SyncPeer witness.
|
|
@@ -29,11 +30,32 @@ export interface SyncPeerRel8ns_V1 extends IbGibRel8ns_V1 {
|
|
|
29
30
|
*/
|
|
30
31
|
export interface SyncPeerIbGib_V1 extends IbGib_V1<SyncPeerData_V1, SyncPeerRel8ns_V1> { }
|
|
31
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
|
+
|
|
32
54
|
/**
|
|
33
55
|
* The interface for the SyncPeer witness class.
|
|
34
56
|
* It witnesses a SyncSagaContext and returns a SyncSagaContext (Request -> Response).
|
|
35
57
|
*/
|
|
36
|
-
export interface SyncPeerWitness extends Witness_V1<
|
|
58
|
+
export interface SyncPeerWitness<TInitializeOpts extends InitializeSyncPeerOpts = InitializeSyncPeerOpts> extends Witness_V1<
|
|
37
59
|
SyncSagaContextData_V1,
|
|
38
60
|
SyncSagaContextRel8ns_V1,
|
|
39
61
|
SyncSagaContextIbGib_V1, // Input
|
|
@@ -43,7 +65,26 @@ export interface SyncPeerWitness extends Witness_V1<
|
|
|
43
65
|
SyncPeerData_V1,
|
|
44
66
|
SyncPeerRel8ns_V1
|
|
45
67
|
> {
|
|
46
|
-
|
|
68
|
+
get classname(): string;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* sender-specific opts/config
|
|
72
|
+
*
|
|
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.
|
|
78
|
+
*/
|
|
79
|
+
opts: TInitializeOpts | undefined;
|
|
80
|
+
|
|
81
|
+
/**
|
|
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.
|
|
84
|
+
*
|
|
85
|
+
* @see {@link opts}
|
|
86
|
+
*/
|
|
87
|
+
setOptionalOpts(arg: Partial<TInitializeOpts>): void;
|
|
47
88
|
|
|
48
89
|
/**
|
|
49
90
|
* Observable for streaming large domain payloads asynchronously.
|