@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
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @module SyncPeer_V1 witness class
|
|
2
|
+
* @module SyncPeer_V1 witness class for base class plumbing of sync peers.
|
|
3
|
+
*
|
|
4
|
+
* You are expected to implement concrete peer classes for concrete architecture.
|
|
3
5
|
*/
|
|
4
6
|
import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
7
|
+
import { IbGibAddr } from '@ibgib/ts-gib/dist/types.mjs';
|
|
5
8
|
import { SubjectWitness } from '../../common/pubsub/subject/subject-types.mjs';
|
|
6
9
|
import { SyncSagaContextIbGib_V1 } from '../sync-saga-context/sync-saga-context-types.mjs';
|
|
7
|
-
import { SyncPeerData_V1, SyncPeerRel8ns_V1, SyncPeerWitness } from './sync-peer-types.mjs';
|
|
10
|
+
import { InitializeSyncPeerOpts, SyncPeerData_V1, SyncPeerRel8ns_V1, SyncPeerWitness } from './sync-peer-types.mjs';
|
|
8
11
|
import { LightWitnessBase_V1 } from '../../witness/light-witness-base-v1.mjs';
|
|
9
|
-
import {
|
|
12
|
+
import { IbGibSpaceAny } from '../../witness/space/space-base-v1.mjs';
|
|
10
13
|
/**
|
|
11
14
|
* Abstract witness for talking to a Sync Peer (e.g. Remote Node or Local Simulator).
|
|
12
15
|
*
|
|
@@ -17,20 +20,48 @@ import { IbGibAddr } from '@ibgib/ts-gib/dist/types.mjs';
|
|
|
17
20
|
* 2. Send Request (RPC)
|
|
18
21
|
* 3. Pull Response & Dependencies (Receiver -> Sender)
|
|
19
22
|
*/
|
|
20
|
-
export declare abstract class SyncPeer_V1 extends LightWitnessBase_V1<SyncPeerData_V1, SyncPeerRel8ns_V1> implements SyncPeerWitness {
|
|
23
|
+
export declare abstract class SyncPeer_V1<TInitializeOpts extends InitializeSyncPeerOpts = InitializeSyncPeerOpts> extends LightWitnessBase_V1<SyncPeerData_V1, SyncPeerRel8ns_V1> implements SyncPeerWitness<TInitializeOpts> {
|
|
21
24
|
protected lc: string;
|
|
22
|
-
|
|
25
|
+
opts: TInitializeOpts | undefined;
|
|
26
|
+
payloadIbGibsDomainReceived$: SubjectWitness<IbGib_V1>;
|
|
23
27
|
get classname(): string;
|
|
24
28
|
constructor(initialData: SyncPeerData_V1, initialRel8ns?: SyncPeerRel8ns_V1);
|
|
29
|
+
initialize(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* base implementation just sets the opts property.
|
|
32
|
+
*
|
|
33
|
+
* override this in concrete classes for further initialization code
|
|
34
|
+
* specific to the sender.
|
|
35
|
+
*
|
|
36
|
+
* @see {@link SyncPeerWitness.opts}
|
|
37
|
+
*/
|
|
38
|
+
initializeSender(opts: TInitializeOpts): Promise<void>;
|
|
39
|
+
setOptionalOpts(arg: Partial<TInitializeOpts>): void;
|
|
40
|
+
protected abstract ensureReceiverTempSpace(): Promise<IbGibSpaceAny>;
|
|
25
41
|
/**
|
|
26
42
|
* Witness the synchronization context (Send/Receive).
|
|
27
43
|
*
|
|
44
|
+
* At this point in code, we are sending the context OUTGOING. The {@link context} should
|
|
45
|
+
* have a fully populated {@link SyncSagaContextIbGib_V1.sagaFrame}
|
|
46
|
+
*
|
|
28
47
|
* @param arg The OUTGOING context (Request).
|
|
29
48
|
* @returns The INCOMING context (Response), or undefined if failed/empty.
|
|
30
49
|
*/
|
|
31
|
-
witness(
|
|
50
|
+
witness(context: SyncSagaContextIbGib_V1): Promise<SyncSagaContextIbGib_V1 | undefined>;
|
|
32
51
|
/**
|
|
33
|
-
*
|
|
52
|
+
* This is responsible for:
|
|
53
|
+
*
|
|
54
|
+
* * sending outgoing {@link context}, the sync saga frame and msg stone(s),
|
|
55
|
+
* and identities...
|
|
56
|
+
* * AND sending OUTGOING domain ibgibs
|
|
57
|
+
* {@link SyncSagaContextIbGib_V1.payloadIbGibsDomain}
|
|
58
|
+
* * getting back the other end's resultant context ibgib, sync saga frame
|
|
59
|
+
* and msg stone(s), and identities in their entirety...
|
|
60
|
+
* * AND stream/receiving the RESPONSE payload domain ibgibs, publishing
|
|
61
|
+
* these to this.payloadIbGibsDomainReceived$.
|
|
62
|
+
*
|
|
63
|
+
* So this returns the RESPONSE context, possibly BEFORE the RESPONSE domain
|
|
64
|
+
* ibgibs have been completely received/streamed. The coordinator is responsible
|
|
34
65
|
*/
|
|
35
66
|
protected abstract sendContextRequest(context: SyncSagaContextIbGib_V1): Promise<SyncSagaContextIbGib_V1 | undefined>;
|
|
36
67
|
/**
|
|
@@ -46,21 +77,23 @@ export declare abstract class SyncPeer_V1 extends LightWitnessBase_V1<SyncPeerDa
|
|
|
46
77
|
*/
|
|
47
78
|
protected abstract pull(addrs: IbGibAddr[]): Promise<void>;
|
|
48
79
|
/**
|
|
49
|
-
*
|
|
80
|
+
* move to sync-peer-helpers.mts as a pure function?
|
|
50
81
|
*/
|
|
51
|
-
protected
|
|
82
|
+
protected authenticateContext({ context }: {
|
|
52
83
|
context: SyncSagaContextIbGib_V1;
|
|
53
|
-
}): Promise<
|
|
84
|
+
}): Promise<string[]>;
|
|
54
85
|
/**
|
|
55
|
-
*
|
|
86
|
+
* move to sync-peer-helpers.mts as a pure function?
|
|
56
87
|
*/
|
|
57
|
-
protected
|
|
88
|
+
protected authorizeContext({ context }: {
|
|
58
89
|
context: SyncSagaContextIbGib_V1;
|
|
59
|
-
}): Promise<
|
|
90
|
+
}): Promise<string[]>;
|
|
60
91
|
/**
|
|
61
92
|
* Abstract accessor to get an IbGib from the Local space/store.
|
|
62
93
|
* Needed for inspecting rela8ns during the graph walk.
|
|
94
|
+
*
|
|
95
|
+
* Default implementation simply looks in senderSpace
|
|
63
96
|
*/
|
|
64
|
-
protected
|
|
97
|
+
protected getLocalIbGib(addr: string): Promise<IbGib_V1 | undefined>;
|
|
65
98
|
}
|
|
66
99
|
//# sourceMappingURL=sync-peer-v1.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-peer-v1.d.mts","sourceRoot":"","sources":["../../../src/sync/sync-peer/sync-peer-v1.mts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sync-peer-v1.d.mts","sourceRoot":"","sources":["../../../src/sync/sync-peer/sync-peer-v1.mts"],"names":[],"mappings":"A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AS,CAAC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC;IAErH;;;;;;OAMG;IACH,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAE1D;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1D;;OAEG;cACa,mBAAmB,CAAC,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,uBAAuB,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAgBzG;;OAEG;cACa,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,uBAAuB,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAgBtG;;;;;OAKG;cACa,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;CAuB7E"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @module SyncPeer_V1 witness class
|
|
2
|
+
* @module SyncPeer_V1 witness class for base class plumbing of sync peers.
|
|
3
|
+
*
|
|
4
|
+
* You are expected to implement concrete peer classes for concrete architecture.
|
|
3
5
|
*/
|
|
4
6
|
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
5
|
-
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
6
7
|
import { GLOBAL_LOG_A_LOT } from '../../core-constants.mjs';
|
|
7
|
-
import { SYNC_MSG_REL8N_NAME, SYNC_SAGA_PAYLOAD_ADDRS_DOMAIN } from '../sync-constants.mjs';
|
|
8
8
|
import { LightWitnessBase_V1 } from '../../witness/light-witness-base-v1.mjs';
|
|
9
|
+
import { newupSubject } from '../../common/pubsub/subject/subject-helper.mjs';
|
|
10
|
+
import { validateContextAndSagaFrame } from '../sync-saga-context/sync-saga-context-helpers.mjs';
|
|
11
|
+
import { getFromSpace } from '../../witness/space/space-helper.mjs';
|
|
9
12
|
const logalot = GLOBAL_LOG_A_LOT || true;
|
|
10
13
|
const logalotControlDomain = true;
|
|
11
14
|
const lcControlDomain = '[ControlDomain]';
|
|
@@ -21,6 +24,8 @@ const lcControlDomain = '[ControlDomain]';
|
|
|
21
24
|
*/
|
|
22
25
|
export class SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
23
26
|
lc = `[${SyncPeer_V1.name}]`;
|
|
27
|
+
opts;
|
|
28
|
+
payloadIbGibsDomainReceived$;
|
|
24
29
|
get classname() {
|
|
25
30
|
if (!this.data) {
|
|
26
31
|
throw new Error(`(UNEXPECTED) this.data falsy? (E: 1ab1841e9338b54f3aa615fa37024826)`);
|
|
@@ -33,33 +38,143 @@ export class SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
33
38
|
constructor(initialData, initialRel8ns) {
|
|
34
39
|
super(initialData, initialRel8ns);
|
|
35
40
|
}
|
|
41
|
+
async initialize() {
|
|
42
|
+
this.payloadIbGibsDomainReceived$ = await newupSubject();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* base implementation just sets the opts property.
|
|
46
|
+
*
|
|
47
|
+
* override this in concrete classes for further initialization code
|
|
48
|
+
* specific to the sender.
|
|
49
|
+
*
|
|
50
|
+
* @see {@link SyncPeerWitness.opts}
|
|
51
|
+
*/
|
|
52
|
+
async initializeSender(opts) {
|
|
53
|
+
const lc = `${this.lc}[${this.initializeSender.name}]`;
|
|
54
|
+
try {
|
|
55
|
+
if (logalot) {
|
|
56
|
+
console.log(`${lc} starting... (I: 31bd5fda37c89fa37fbaf14daf5fe726)`);
|
|
57
|
+
}
|
|
58
|
+
this.opts = opts;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
if (logalot) {
|
|
66
|
+
console.log(`${lc} complete.`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
setOptionalOpts(arg) {
|
|
71
|
+
const lc = `${this.lc}[${this.setOptionalOpts.name}]`;
|
|
72
|
+
try {
|
|
73
|
+
if (logalot) {
|
|
74
|
+
console.log(`${lc} starting... (I: ae5ddbd3577db267f84743175a736626)`);
|
|
75
|
+
}
|
|
76
|
+
if (!this.opts) {
|
|
77
|
+
throw new Error(`(UNEXPECTED) this.opts falsy? (E: 0dd4d6080a6e2f31d86cf4d86e11b826)`);
|
|
78
|
+
}
|
|
79
|
+
if (logalot) {
|
|
80
|
+
console.log(`${lc} updating opts. arg keys: ${Object.keys(arg)} (I: 452d78a558f8fc3468c8e2e68c70b226)`);
|
|
81
|
+
}
|
|
82
|
+
this.opts = { ...this.opts, ...arg };
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
if (logalot) {
|
|
90
|
+
console.log(`${lc} complete.`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
36
94
|
/**
|
|
37
95
|
* Witness the synchronization context (Send/Receive).
|
|
38
96
|
*
|
|
97
|
+
* At this point in code, we are sending the context OUTGOING. The {@link context} should
|
|
98
|
+
* have a fully populated {@link SyncSagaContextIbGib_V1.sagaFrame}
|
|
99
|
+
*
|
|
39
100
|
* @param arg The OUTGOING context (Request).
|
|
40
101
|
* @returns The INCOMING context (Response), or undefined if failed/empty.
|
|
41
102
|
*/
|
|
42
|
-
async witness(
|
|
103
|
+
async witness(context) {
|
|
43
104
|
const lc = `${this.lc}[${this.witness.name}]`;
|
|
44
105
|
try {
|
|
45
106
|
if (logalot) {
|
|
46
107
|
console.log(`${lc} starting...`);
|
|
47
108
|
}
|
|
48
|
-
if (
|
|
49
|
-
|
|
109
|
+
if (!this.opts) {
|
|
110
|
+
throw new Error(`(UNEXPECTED) this.opts falsy? Concrete class should have initialized sender opts by now. (E: 0b9e28287318fdf8bf9f5a6886a24826)`);
|
|
111
|
+
}
|
|
112
|
+
// NOTE: There are two basic types of peers:
|
|
113
|
+
// * local-only (peer)
|
|
114
|
+
// * this peer is both sender/receiver peer
|
|
115
|
+
// * for local merges and relatively fast spaces
|
|
116
|
+
// * proxy to remote space
|
|
117
|
+
// * this peer is both sender/receiver peer
|
|
118
|
+
// * works directly with remote/outerspaces
|
|
119
|
+
// * Less efficient over-the-wire xfer due to chatiness
|
|
120
|
+
// * symmetric node sender/receiver peers
|
|
121
|
+
// * separate sender/receiver classes
|
|
122
|
+
// * e.g., SyncPeerClient[Substrate]Sender_V1,
|
|
123
|
+
// SyncPeerClient[Substrate]Receiver_V1
|
|
124
|
+
// * More efficient over-the-wire xfer
|
|
125
|
+
// * Most difficult to mentally model
|
|
126
|
+
// * sender.witness does the pushing out
|
|
127
|
+
// * what the sender/initiator's coordinator has a reference to
|
|
128
|
+
// * receiver.witness does the coming in
|
|
129
|
+
// * lives on a server/remote instance with its own coordinator
|
|
130
|
+
// instance
|
|
131
|
+
// * must do its own validation/authn/authz for possible MITM
|
|
132
|
+
// issues
|
|
133
|
+
// The following is a sketch where some of these may be blurred
|
|
134
|
+
// persist the context, sagaframe, identity(s) ONLY in the receiver's durable space
|
|
135
|
+
// if sending domain ibgibs...
|
|
136
|
+
// verify the domain ibgibs intrinsically.
|
|
137
|
+
// persist the domain ibgibs in the receiver's temp space (push all addrs?)
|
|
138
|
+
// await until all domain ibgibs are in receiver's temp space
|
|
139
|
+
// process the context with the receiver's coordinator to get a new response context
|
|
140
|
+
// analyze the response context
|
|
141
|
+
// validate context intrinsically
|
|
142
|
+
// validate return identity if present
|
|
143
|
+
// persist the response context's dependency graph (context, saga frame and msg(s), identities)
|
|
144
|
+
// if response has payload domain ibgibs,
|
|
145
|
+
// spin off...
|
|
146
|
+
// pull domain ibgibs to local temp space
|
|
147
|
+
// publish domain ibgibs to observable
|
|
148
|
+
// when all domain ibgibs are pulled, publish complete to the observable
|
|
149
|
+
// return resulting context ibgib (which the caller should get BEFORE the domain ibgibs observable completes)
|
|
150
|
+
// validate, authenticate, and authorize the context, sagaFrame, and identity(s)
|
|
151
|
+
const validationErrors = await validateContextAndSagaFrame({ context });
|
|
152
|
+
if (validationErrors.length > 0) {
|
|
153
|
+
throw new Error(`invalid context received. validationErrors: ${validationErrors} (E: 8b34c875c968af29bc433138e57a7826)`);
|
|
50
154
|
}
|
|
51
|
-
|
|
52
|
-
|
|
155
|
+
const authenticationErrors = await this.authenticateContext({ context });
|
|
156
|
+
if (authenticationErrors.length > 0) {
|
|
157
|
+
throw new Error(`invalid context authentication. authenticationErrors: ${authenticationErrors} (E: da89da5ee1269aeb78952d475d607526)`);
|
|
158
|
+
}
|
|
159
|
+
const authorizationErrors = await this.authorizeContext({ context });
|
|
160
|
+
if (authorizationErrors.length > 0) {
|
|
161
|
+
throw new Error(`invalid context authorization. authorizationErrors: ${authorizationErrors} (E: 8ddc284a758cf10ba829334c1babb826)`);
|
|
162
|
+
}
|
|
163
|
+
// at this point, we have a valid, authenticated, authorized context
|
|
53
164
|
// 2. EXECUTE: Trigger Remote Processing
|
|
54
|
-
const response = await this.sendContextRequest(
|
|
165
|
+
const response = await this.sendContextRequest(context);
|
|
55
166
|
if (!response) {
|
|
56
167
|
if (logalot) {
|
|
57
168
|
console.log(`${lc} No response from peer.`);
|
|
58
169
|
}
|
|
59
170
|
return undefined;
|
|
60
171
|
}
|
|
61
|
-
//
|
|
62
|
-
|
|
172
|
+
// at this point, all outgoing payload domain ibgibs have been sent.
|
|
173
|
+
// we have received the response context, wherein the sync saga
|
|
174
|
+
// frame/msg stone(s) and any keystones should be evolved. Depending
|
|
175
|
+
// on the concrete implementation, if there are domain ibgibs to
|
|
176
|
+
// receive, they may still be transferring. These will be published
|
|
177
|
+
// to this.payloadIbGibsDomainReceived$
|
|
63
178
|
return response;
|
|
64
179
|
}
|
|
65
180
|
catch (error) {
|
|
@@ -73,153 +188,82 @@ export class SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
73
188
|
}
|
|
74
189
|
}
|
|
75
190
|
/**
|
|
76
|
-
*
|
|
191
|
+
* move to sync-peer-helpers.mts as a pure function?
|
|
77
192
|
*/
|
|
78
|
-
async
|
|
79
|
-
const lc =
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
console.log(`${lc}${lcControlDomain} PUSH Context Envelope -> ${contextAddr} (I: 3f4e5a6b7c8d9e0f)`);
|
|
84
|
-
}
|
|
85
|
-
await this.push([contextAddr]);
|
|
86
|
-
// B. Push Saga Frame & Immediate Deps (Msg, Identity)
|
|
87
|
-
const frameAddr = context.rel8ns?.sagaFrame?.[0];
|
|
88
|
-
if (frameAddr) {
|
|
89
|
-
if (logalotControlDomain) {
|
|
90
|
-
console.log(`${lc}${lcControlDomain} PUSH CONTROL: Saga Frame -> ${frameAddr} (I: 4a5b6c7d8e9f0a1b)`);
|
|
91
|
-
}
|
|
92
|
-
await this.push([frameAddr]);
|
|
93
|
-
// We inspect the local frame to find its immediate deps
|
|
94
|
-
const frame = await this.getLocalIbGib(frameAddr);
|
|
95
|
-
if (frame) {
|
|
96
|
-
// Msg Stone
|
|
97
|
-
const msgAddrs = frame.rel8ns?.[SYNC_MSG_REL8N_NAME];
|
|
98
|
-
if (msgAddrs) {
|
|
99
|
-
for (const addr of msgAddrs) {
|
|
100
|
-
if (logalotControlDomain) {
|
|
101
|
-
console.log(`${lc}${lcControlDomain} PUSH CONTROL: Msg Stone -> ${addr} (I: 5b6c7d8e9f0a1b2c)`);
|
|
102
|
-
}
|
|
103
|
-
await this.push([addr]);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
// Identity
|
|
107
|
-
const idAddrs = frame.rel8ns?.identity;
|
|
108
|
-
if (idAddrs) {
|
|
109
|
-
for (const addr of idAddrs) {
|
|
110
|
-
if (logalotControlDomain) {
|
|
111
|
-
console.log(`${lc}${lcControlDomain} PUSH CONTROL: Identity -> ${addr} (I: 6c7d8e9f0a1b2c3d)`);
|
|
112
|
-
}
|
|
113
|
-
await this.push([addr]);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
193
|
+
async authenticateContext({ context }) {
|
|
194
|
+
const lc = `${this.lc}[${this.authenticateContext.name}]`;
|
|
195
|
+
try {
|
|
196
|
+
if (logalot) {
|
|
197
|
+
console.log(`${lc} starting... (I: 2677a482dfa873dcd1aa04a3031ff826)`);
|
|
116
198
|
}
|
|
199
|
+
console.error(`${lc} NAG ERROR (NOT THROWN): not implemented. // todo: authenticate (v1 must have this after we get merge logic workflow going) (E: bc3a78f2dab18ab64c36d055a4b50526)`);
|
|
200
|
+
return [];
|
|
117
201
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
// D. Push Payloads (Deep/Soft)
|
|
127
|
-
// For payloads, the Peer is just a transport. It doesn't know the structure.
|
|
128
|
-
// It relies on "push" handling the "deep" transfer if needed, or we explicitly iterate if we had a graph.
|
|
129
|
-
// But since we are "Witnessing", we usually assume "push(addr)" acts like "copy(addr, recursive=true)"?
|
|
130
|
-
// Or do we need to be explicit?
|
|
131
|
-
// User said: "payloads should be flat... sync coordinator is the one doing the heavy lifting".
|
|
132
|
-
// So we just push the addrs listed.
|
|
133
|
-
// 1. Control Payloads
|
|
134
|
-
// const controlAddrs = context.data?.[SYNC_SAGA_PAYLOAD_ADDRS_CONTROL];
|
|
135
|
-
// if (controlAddrs && controlAddrs.length > 0) {
|
|
136
|
-
// if (logalotControlDomain) { console.log(`${lc}${lcControlDomain} PUSH CONTROL PAYLOADS (${controlAddrs.length}): ${controlAddrs.join(', ')} (I: 8e9f0a1b2c3d4e5f)`); }
|
|
137
|
-
// for (const addr of controlAddrs) {
|
|
138
|
-
// await this.push(addr);
|
|
139
|
-
// }
|
|
140
|
-
// }
|
|
141
|
-
// 2. Domain Payloads
|
|
142
|
-
const domainAddrs = context.data?.[SYNC_SAGA_PAYLOAD_ADDRS_DOMAIN];
|
|
143
|
-
if (domainAddrs && domainAddrs.length > 0) {
|
|
144
|
-
if (logalotControlDomain) {
|
|
145
|
-
console.log(`${lc}${lcControlDomain} PUSH DOMAIN PAYLOADS (${domainAddrs.length}): ${domainAddrs.join(', ')} (I: 9f0a1b2c3d4e5f6a)`);
|
|
146
|
-
}
|
|
147
|
-
for (const addr of domainAddrs) {
|
|
148
|
-
await this.push([addr]);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
if (logalotControlDomain) {
|
|
152
|
-
console.log(`${lc}${lcControlDomain} PUSH COMPLETE for context ${contextAddr} (I: a0b1c2d3e4f5a6b7)`);
|
|
202
|
+
catch (error) {
|
|
203
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
204
|
+
throw error;
|
|
205
|
+
}
|
|
206
|
+
finally {
|
|
207
|
+
if (logalot) {
|
|
208
|
+
console.log(`${lc} complete.`);
|
|
209
|
+
}
|
|
153
210
|
}
|
|
154
211
|
}
|
|
155
212
|
/**
|
|
156
|
-
*
|
|
213
|
+
* move to sync-peer-helpers.mts as a pure function?
|
|
157
214
|
*/
|
|
158
|
-
async
|
|
159
|
-
const lc =
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
console.log(`${lc}${lcControlDomain} PULL Context Envelope <- ${contextAddr} (I: b1c2d3e4f5a6b7c8)`);
|
|
164
|
-
}
|
|
165
|
-
await this.pull([contextAddr]);
|
|
166
|
-
// B. Pull Saga Frame & Immediate Deps
|
|
167
|
-
const frameAddr = context.rel8ns?.sagaFrame?.[0];
|
|
168
|
-
if (frameAddr) {
|
|
169
|
-
if (logalotControlDomain) {
|
|
170
|
-
console.log(`${lc}${lcControlDomain} PULL CONTROL: Saga Frame <- ${frameAddr} (I: c2d3e4f5a6b7c8d9)`);
|
|
171
|
-
}
|
|
172
|
-
await this.pull([frameAddr]);
|
|
173
|
-
// Inspect REMOTE frame? We need to have pulled it first.
|
|
174
|
-
const frame = await this.getLocalIbGib(frameAddr); // Should be local now
|
|
175
|
-
if (frame) {
|
|
176
|
-
const msgAddrs = frame.rel8ns?.[SYNC_MSG_REL8N_NAME];
|
|
177
|
-
if (msgAddrs) {
|
|
178
|
-
for (const addr of msgAddrs) {
|
|
179
|
-
if (logalotControlDomain) {
|
|
180
|
-
console.log(`${lc}${lcControlDomain} PULL CONTROL: Msg Stone <- ${addr} (I: d3e4f5a6b7c8d9e0)`);
|
|
181
|
-
}
|
|
182
|
-
await this.pull([addr]);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
const idAddrs = frame.rel8ns?.identity;
|
|
186
|
-
if (idAddrs) {
|
|
187
|
-
for (const addr of idAddrs) {
|
|
188
|
-
if (logalotControlDomain) {
|
|
189
|
-
console.log(`${lc}${lcControlDomain} PULL CONTROL: Identity <- ${addr} (I: e4f5a6b7c8d9e0f1)`);
|
|
190
|
-
}
|
|
191
|
-
await this.pull([addr]);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
215
|
+
async authorizeContext({ context }) {
|
|
216
|
+
const lc = `${this.lc}[${this.authorizeContext.name}]`;
|
|
217
|
+
try {
|
|
218
|
+
if (logalot) {
|
|
219
|
+
console.log(`${lc} starting... (I: 48c918b41ceec0cd489ca3b8819e6826)`);
|
|
194
220
|
}
|
|
221
|
+
console.error(`${lc} NAG ERROR (NOT THROWN): not implemented. authorize business logic (v1 must have this, but later when we are working on admin vs. student)(E: bc3a78f2dab18ab64c36d055a4b50526)`);
|
|
222
|
+
return [];
|
|
195
223
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
224
|
+
catch (error) {
|
|
225
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
226
|
+
throw error;
|
|
227
|
+
}
|
|
228
|
+
finally {
|
|
229
|
+
if (logalot) {
|
|
230
|
+
console.log(`${lc} complete.`);
|
|
201
231
|
}
|
|
202
|
-
await this.pull([sessionKeystoneAddr]);
|
|
203
232
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
if (
|
|
215
|
-
console.log(`${lc}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Abstract accessor to get an IbGib from the Local space/store.
|
|
236
|
+
* Needed for inspecting rela8ns during the graph walk.
|
|
237
|
+
*
|
|
238
|
+
* Default implementation simply looks in senderSpace
|
|
239
|
+
*/
|
|
240
|
+
async getLocalIbGib(addr) {
|
|
241
|
+
const lc = `${this.lc}[${this.getLocalIbGib.name}]`;
|
|
242
|
+
try {
|
|
243
|
+
if (logalot) {
|
|
244
|
+
console.log(`${lc} starting... (I: 27b248cb9801eeb2386b71485389a826)`);
|
|
216
245
|
}
|
|
217
|
-
|
|
218
|
-
|
|
246
|
+
console.warn(`${lc} possibly a bottleneck here, getLocalIbGib only gets a single ibgib... (W: 2fd448a435480e6b128f6b8bcbef4826)`);
|
|
247
|
+
if (!this.opts) {
|
|
248
|
+
throw new Error(`(UNEXPECTED) this.opts falsy? (E: cfb9431f2fb851f24a6c88e80c3b3326)`);
|
|
219
249
|
}
|
|
250
|
+
const resGet = await getFromSpace({ space: this.opts.senderSpace, addr });
|
|
251
|
+
if (resGet.success && resGet.ibGibs && resGet.ibGibs.length === 1) {
|
|
252
|
+
const ibGib = resGet.ibGibs[0];
|
|
253
|
+
return ibGib;
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
throw new Error(`couldn't get addr (${addr}) from local space ${this.opts.senderSpace}. reason: ${resGet.errorMsg ?? 'unknown error (E: 926ef8bf4fcc299ab89dba34ea691a26)'} (E: d8a89807e471d3f8b938ab21df44cb26)`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
261
|
+
throw error;
|
|
220
262
|
}
|
|
221
|
-
|
|
222
|
-
|
|
263
|
+
finally {
|
|
264
|
+
if (logalot) {
|
|
265
|
+
console.log(`${lc} complete.`);
|
|
266
|
+
}
|
|
223
267
|
}
|
|
224
268
|
}
|
|
225
269
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-peer-v1.mjs","sourceRoot":"","sources":["../../../src/sync/sync-peer/sync-peer-v1.mts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sync-peer-v1.mjs","sourceRoot":"","sources":["../../../src/sync/sync-peer/sync-peer-v1.mts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAMlF,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAK5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAC9E,OAAO,EAAE,2BAA2B,EAAE,MAAM,oDAAoD,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEpE,MAAM,OAAO,GAAG,gBAAgB,IAAI,IAAI,CAAC;AACzC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAE1C;;;;;;;;;GASG;AACH,MAAM,OAAgB,WAClB,SAAQ,mBAAuD;IAGrD,EAAE,GAAW,IAAI,WAAW,CAAC,IAAI,GAAG,CAAC;IAExC,IAAI,CAA8B;IAClC,4BAA4B,CAA4B;IAE/D,IAAI,SAAS;QACT,IAAI,CAAC,IAAI,CAAC,IAAI,E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CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;YAE1E,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAChE,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAC/B,OAAO,KAAK,CAAC;YACjB,CAAC;iBAAM,CAAC;gBACJ,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,sBAAsB,IAAI,CAAC,IAAI,CAAC,WAAW,aAAa,MAAM,CAAC,QAAQ,IAAI,qDAAqD,wCAAwC,CAAC,CAAC;YACxN,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACjD,MAAM,KAAK,CAAC;QAChB,CAAC;gBAAS,CAAC;YACP,IAAI,OAAO,EAAE,CAAC;gBAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;YAAC,CAAC;QACpD,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
5
5
|
import { Ib } from '@ibgib/ts-gib/dist/types.mjs';
|
|
6
6
|
import { SyncSagaContextData_V1, SyncSagaContextIbGib_V1, SyncSagaContextIb_V1 } from './sync-saga-context-types.mjs';
|
|
7
|
+
import { IbGibSpaceAny } from '../../witness/space/space-base-v1.mjs';
|
|
8
|
+
import { SyncIbGib_V1 } from '../sync-types.mjs';
|
|
7
9
|
/**
|
|
8
10
|
* Options for creating a SyncSagaContext ibgib.
|
|
9
11
|
*/
|
|
@@ -11,7 +13,7 @@ export interface CreateSyncSagaContextOptions {
|
|
|
11
13
|
/**
|
|
12
14
|
* The main saga frame (Init, Ack, etc.).
|
|
13
15
|
*/
|
|
14
|
-
sagaFrame:
|
|
16
|
+
sagaFrame: SyncIbGib_V1;
|
|
15
17
|
/**
|
|
16
18
|
* Session identity keystones.
|
|
17
19
|
*/
|
|
@@ -21,6 +23,11 @@ export interface CreateSyncSagaContextOptions {
|
|
|
21
23
|
* payloads to send, e.g., in a Delta frame.
|
|
22
24
|
*/
|
|
23
25
|
payloadIbGibsDomain?: IbGib_V1[];
|
|
26
|
+
/**
|
|
27
|
+
* we persist the context in the local/sender space (relative to our
|
|
28
|
+
* execution POV) right when we create it.
|
|
29
|
+
*/
|
|
30
|
+
localSpace: IbGibSpaceAny;
|
|
24
31
|
}
|
|
25
32
|
/**
|
|
26
33
|
* Constructs the standard 'ib' string for a Sync Saga Context stone.
|
|
@@ -35,9 +42,38 @@ export declare function parseSyncSagaContextIb({ ib, }: {
|
|
|
35
42
|
ib: Ib;
|
|
36
43
|
}): Promise<SyncSagaContextIb_V1>;
|
|
37
44
|
/**
|
|
38
|
-
* Creates
|
|
45
|
+
* Creates new SyncSagaContext stone. Puts/registers in {@link localSpace}
|
|
46
|
+
* immediately after creation.
|
|
39
47
|
*
|
|
40
48
|
* @returns The context ibGib.
|
|
49
|
+
*
|
|
50
|
+
* ## notes
|
|
51
|
+
*
|
|
52
|
+
* the other ibgibs that are related to this context stone should already be
|
|
53
|
+
* put/registered in {@link localSpace}.
|
|
54
|
+
*/
|
|
55
|
+
export declare function createSyncSagaContext({ sagaFrame, sessionKeystones, payloadIbGibsDomain, localSpace, }: CreateSyncSagaContextOptions): Promise<SyncSagaContextIbGib_V1>;
|
|
56
|
+
/**
|
|
57
|
+
* Validates ONLY the {@link context} ibgib itself and saga frame/msg stone(s)
|
|
58
|
+
* ({@link SyncSagaContextIbGib_V1.sagaFrame}).
|
|
59
|
+
*
|
|
60
|
+
* Does NOT...
|
|
61
|
+
* * validate keystones (authn or authz)
|
|
62
|
+
* * validate domain payload ibgibs...
|
|
63
|
+
* * intrinsically
|
|
64
|
+
* * in relation to this context (addrs match up)
|
|
65
|
+
*
|
|
66
|
+
* @returns empty array if valid, else validation errors
|
|
67
|
+
*/
|
|
68
|
+
export declare function validateContextAndSagaFrame({ context }: {
|
|
69
|
+
context: SyncSagaContextIbGib_V1;
|
|
70
|
+
}): Promise<string[]>;
|
|
71
|
+
/**
|
|
72
|
+
* validates the payload ibgibs ({@link SyncSagaContextIbGib_V1.payloadIbGibsDomain}) intrinsically
|
|
73
|
+
*
|
|
74
|
+
* @returns empty array if valid, else validation errors
|
|
41
75
|
*/
|
|
42
|
-
export declare function
|
|
76
|
+
export declare function validateContextDomainPayloadIbGibs({ context }: {
|
|
77
|
+
context: SyncSagaContextIbGib_V1;
|
|
78
|
+
}): Promise<string[]>;
|
|
43
79
|
//# sourceMappingURL=sync-saga-context-helpers.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-saga-context-helpers.d.mts","sourceRoot":"","sources":["../../../src/sync/sync-saga-context/sync-saga-context-helpers.mts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAAE,QAAQ,EAAG,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"sync-saga-context-helpers.d.mts","sourceRoot":"","sources":["../../../src/sync/sync-saga-context/sync-saga-context-helpers.mts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAAE,QAAQ,EAAG,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,8BAA8B,CAAC;AAMlD,OAAO,EACH,sBAAsB,EAAE,uBAAuB,EAAE,oBAAoB,EAExE,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAEtE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD;;GAEG;AACH,MAA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