@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
|
@@ -7,14 +7,20 @@ import { Factory_V1 } from '@ibgib/ts-gib/dist/V1/factory.mjs';
|
|
|
7
7
|
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
8
8
|
import { IbGib_V1, } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
9
9
|
import { Ib } from '@ibgib/ts-gib/dist/types.mjs';
|
|
10
|
+
import { validateIbGibIntrinsically } from '@ibgib/ts-gib/dist/V1/validate-helper.mjs';
|
|
10
11
|
|
|
12
|
+
import { GLOBAL_LOG_A_LOT } from '../../core-constants.mjs';
|
|
11
13
|
import { SYNC_SAGA_CONTEXT_ATOM } from './sync-saga-context-constants.mjs';
|
|
12
14
|
import { SYNC_SAGA_PAYLOAD_ADDRS_DOMAIN } from '../sync-constants.mjs';
|
|
13
15
|
import {
|
|
14
|
-
SyncSagaContextData_V1, SyncSagaContextIbGib_V1,
|
|
15
|
-
|
|
16
|
+
SyncSagaContextData_V1, SyncSagaContextIbGib_V1, SyncSagaContextIb_V1,
|
|
17
|
+
SyncSagaContextRel8ns_V1,
|
|
16
18
|
} from './sync-saga-context-types.mjs';
|
|
17
|
-
import {
|
|
19
|
+
import { IbGibSpaceAny } from '../../witness/space/space-base-v1.mjs';
|
|
20
|
+
import { putInSpace, registerNewIbGib } from '../../witness/space/space-helper.mjs';
|
|
21
|
+
import { SyncIbGib_V1 } from '../sync-types.mjs';
|
|
22
|
+
|
|
23
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
18
24
|
|
|
19
25
|
/**
|
|
20
26
|
* Options for creating a SyncSagaContext ibgib.
|
|
@@ -23,7 +29,7 @@ export interface CreateSyncSagaContextOptions {
|
|
|
23
29
|
/**
|
|
24
30
|
* The main saga frame (Init, Ack, etc.).
|
|
25
31
|
*/
|
|
26
|
-
sagaFrame:
|
|
32
|
+
sagaFrame: SyncIbGib_V1;
|
|
27
33
|
/**
|
|
28
34
|
* Session identity keystones.
|
|
29
35
|
*/
|
|
@@ -33,6 +39,11 @@ export interface CreateSyncSagaContextOptions {
|
|
|
33
39
|
* payloads to send, e.g., in a Delta frame.
|
|
34
40
|
*/
|
|
35
41
|
payloadIbGibsDomain?: IbGib_V1[];
|
|
42
|
+
/**
|
|
43
|
+
* we persist the context in the local/sender space (relative to our
|
|
44
|
+
* execution POV) right when we create it.
|
|
45
|
+
*/
|
|
46
|
+
localSpace: IbGibSpaceAny;
|
|
36
47
|
}
|
|
37
48
|
|
|
38
49
|
/**
|
|
@@ -98,53 +109,150 @@ export async function parseSyncSagaContextIb({
|
|
|
98
109
|
}
|
|
99
110
|
|
|
100
111
|
/**
|
|
101
|
-
* Creates
|
|
102
|
-
*
|
|
112
|
+
* Creates new SyncSagaContext stone. Puts/registers in {@link localSpace}
|
|
113
|
+
* immediately after creation.
|
|
114
|
+
*
|
|
103
115
|
* @returns The context ibGib.
|
|
116
|
+
*
|
|
117
|
+
* ## notes
|
|
118
|
+
*
|
|
119
|
+
* the other ibgibs that are related to this context stone should already be
|
|
120
|
+
* put/registered in {@link localSpace}.
|
|
104
121
|
*/
|
|
105
122
|
export async function createSyncSagaContext({
|
|
106
123
|
sagaFrame,
|
|
107
124
|
sessionKeystones,
|
|
108
125
|
payloadIbGibsDomain,
|
|
126
|
+
localSpace,
|
|
109
127
|
}: CreateSyncSagaContextOptions): Promise<SyncSagaContextIbGib_V1> {
|
|
128
|
+
const lc = `[${createSyncSagaContext.name}]`;
|
|
129
|
+
try {
|
|
130
|
+
if (logalot) { console.log(`${lc} starting... (I: 6b87bee313e811d1d2fc90e87fbec826)`); }
|
|
110
131
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
132
|
+
const date = new Date();
|
|
133
|
+
const timestamp = getTimestamp(date);
|
|
134
|
+
const timestampMs = date.getMilliseconds();
|
|
114
135
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
136
|
+
const data: SyncSagaContextData_V1 = {
|
|
137
|
+
timestamp,
|
|
138
|
+
timestampMs,
|
|
139
|
+
};
|
|
119
140
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
141
|
+
// Domain Payloads
|
|
142
|
+
const payloadAddrsDomain = payloadIbGibsDomain ?
|
|
143
|
+
payloadIbGibsDomain?.map(x => getIbGibAddr({ ibGib: x })) :
|
|
144
|
+
undefined;
|
|
145
|
+
if (payloadAddrsDomain && payloadAddrsDomain.length > 0) {
|
|
146
|
+
data[SYNC_SAGA_PAYLOAD_ADDRS_DOMAIN] = payloadAddrsDomain;
|
|
147
|
+
}
|
|
125
148
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
149
|
+
// rel8ns should always have saga frame, sometimes have keystone
|
|
150
|
+
const rel8ns: SyncSagaContextRel8ns_V1 = {
|
|
151
|
+
sagaFrame: [getIbGibAddr({ ibGib: sagaFrame })],
|
|
152
|
+
};
|
|
153
|
+
if (sessionKeystones && sessionKeystones.length > 0) {
|
|
154
|
+
rel8ns.sessionKeystone = sessionKeystones.map(x => getIbGibAddr({ ibGib: x }));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Generate standard ib
|
|
158
|
+
const ib = await getSyncSagaContextIb({ data });
|
|
133
159
|
|
|
134
|
-
|
|
135
|
-
|
|
160
|
+
const contextIbGib = await Factory_V1.stone<SyncSagaContextData_V1, SyncSagaContextRel8ns_V1>({
|
|
161
|
+
parentPrimitiveIb: SYNC_SAGA_CONTEXT_ATOM,
|
|
162
|
+
ib,
|
|
163
|
+
data,
|
|
164
|
+
rel8ns,
|
|
165
|
+
}) as SyncSagaContextIbGib_V1;
|
|
136
166
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
167
|
+
// put/register immediately. Note that contextIbGib at this point is
|
|
168
|
+
// pure DTO, i.e., only ib, gib, data, rel8ns props.
|
|
169
|
+
await putInSpace({ ibGib: contextIbGib, space: localSpace, });
|
|
170
|
+
await registerNewIbGib({
|
|
171
|
+
ibGib: contextIbGib,
|
|
172
|
+
space: localSpace,
|
|
173
|
+
fnBroadcast: undefined,
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// Attach actual ibgibs for transport (not pure DTO now)
|
|
177
|
+
contextIbGib.sagaFrame = sagaFrame;
|
|
178
|
+
if (payloadIbGibsDomain && payloadIbGibsDomain.length > 0) {
|
|
179
|
+
contextIbGib.payloadIbGibsDomain = payloadIbGibsDomain;
|
|
180
|
+
}
|
|
143
181
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
182
|
+
return contextIbGib;
|
|
183
|
+
} catch (error) {
|
|
184
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
185
|
+
throw error;
|
|
186
|
+
} finally {
|
|
187
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
147
188
|
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Validates ONLY the {@link context} ibgib itself and saga frame/msg stone(s)
|
|
193
|
+
* ({@link SyncSagaContextIbGib_V1.sagaFrame}).
|
|
194
|
+
*
|
|
195
|
+
* Does NOT...
|
|
196
|
+
* * validate keystones (authn or authz)
|
|
197
|
+
* * validate domain payload ibgibs...
|
|
198
|
+
* * intrinsically
|
|
199
|
+
* * in relation to this context (addrs match up)
|
|
200
|
+
*
|
|
201
|
+
* @returns empty array if valid, else validation errors
|
|
202
|
+
*/
|
|
203
|
+
export async function validateContextAndSagaFrame({ context }: { context: SyncSagaContextIbGib_V1 }): Promise<string[]> {
|
|
204
|
+
const lc = `[${validateContextAndSagaFrame.name}]`;
|
|
205
|
+
try {
|
|
206
|
+
if (logalot) { console.log(`${lc} starting... (I: 7797f8294bd8f7e5089cb722ad468226)`); }
|
|
207
|
+
|
|
208
|
+
const errors: string[] = [];
|
|
209
|
+
|
|
210
|
+
// validate just the context first. if this fails we return early.
|
|
211
|
+
const intrinsicErrors = await validateIbGibIntrinsically({ ibGib: context });
|
|
212
|
+
if (intrinsicErrors && intrinsicErrors.length > 0) {
|
|
213
|
+
intrinsicErrors.forEach(x => errors.push(x));
|
|
214
|
+
return errors; /* <<<< returns early */
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (context.sagaFrame) {
|
|
218
|
+
|
|
219
|
+
} else {
|
|
220
|
+
errors.push(`context.sagaFrame is falsy. (E: b4edd88f4963f493789f83b29ba2df26)`);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// validate the entire context graph intrinsically, including saga frame, stones, identity(s) (if applicable but not authentication, that will be done in a separate step)
|
|
224
|
+
|
|
148
225
|
|
|
149
|
-
|
|
226
|
+
|
|
227
|
+
// ensure the non-dto properties on the context object (i.e. props
|
|
228
|
+
// that are not ib, gib, data, or rel8ns) match the data in the
|
|
229
|
+
// context object
|
|
230
|
+
|
|
231
|
+
throw new Error(`not implemented (E: cb639658e1183fa6c8a4ebca023ba926)`);
|
|
232
|
+
} catch (error) {
|
|
233
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
234
|
+
throw error;
|
|
235
|
+
} finally {
|
|
236
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
237
|
+
}
|
|
150
238
|
}
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* validates the payload ibgibs ({@link SyncSagaContextIbGib_V1.payloadIbGibsDomain}) intrinsically
|
|
243
|
+
*
|
|
244
|
+
* @returns empty array if valid, else validation errors
|
|
245
|
+
*/
|
|
246
|
+
export async function validateContextDomainPayloadIbGibs({ context }: { context: SyncSagaContextIbGib_V1 }): Promise<string[]> {
|
|
247
|
+
const lc = `[${validateContextDomainPayloadIbGibs.name}]`;
|
|
248
|
+
try {
|
|
249
|
+
if (logalot) { console.log(`${lc} starting... (I: 9f9fe835bcc80c75aa7fd6d887fc0826)`); }
|
|
250
|
+
console.error(`${lc} NAG MESSAGE (NOT THROWN). not implemented (E: bfe02ab36a227291a8f17ffc08f2ef26)`)
|
|
251
|
+
return [];
|
|
252
|
+
} catch (error) {
|
|
253
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
254
|
+
throw error;
|
|
255
|
+
} finally {
|
|
256
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
257
|
+
}
|
|
258
|
+
}
|
|
@@ -43,6 +43,11 @@ export interface SyncSagaContextRel8ns_V1 extends IbGibRel8ns_V1 {
|
|
|
43
43
|
/**
|
|
44
44
|
* The Ephemeral Session Keystone Identity used for this saga.
|
|
45
45
|
* Required for validating the saga frame signature.
|
|
46
|
+
*
|
|
47
|
+
* ## notes
|
|
48
|
+
*
|
|
49
|
+
* This will be different for the sender and receiver, yes? hmm...
|
|
50
|
+
* I think I need to put "sender" or "receiver" in the session keystone ib.
|
|
46
51
|
*/
|
|
47
52
|
sessionKeystone?: IbGibAddr[];
|
|
48
53
|
}
|