@ibgib/core-gib 0.1.23 → 0.1.26

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.
Files changed (80) hide show
  1. package/dist/common/other/graph-helper.d.mts +17 -0
  2. package/dist/common/other/graph-helper.d.mts.map +1 -1
  3. package/dist/common/other/graph-helper.mjs +44 -0
  4. package/dist/common/other/graph-helper.mjs.map +1 -1
  5. package/dist/common/other/ibgib-helper.d.mts +1 -1
  6. package/dist/common/other/ibgib-helper.d.mts.map +1 -1
  7. package/dist/common/other/ibgib-helper.mjs.map +1 -1
  8. package/dist/sync/graft-info/graft-info-helpers.mjs +2 -2
  9. package/dist/sync/graft-info/graft-info-helpers.mjs.map +1 -1
  10. package/dist/sync/sync-conflict.respec.mjs +10 -15
  11. package/dist/sync/sync-conflict.respec.mjs.map +1 -1
  12. package/dist/sync/sync-constants.d.mts +1 -0
  13. package/dist/sync/sync-constants.d.mts.map +1 -1
  14. package/dist/sync/sync-constants.mjs +1 -0
  15. package/dist/sync/sync-constants.mjs.map +1 -1
  16. package/dist/sync/sync-helpers.d.mts +5 -0
  17. package/dist/sync/sync-helpers.d.mts.map +1 -1
  18. package/dist/sync/sync-helpers.mjs +37 -1
  19. package/dist/sync/sync-helpers.mjs.map +1 -1
  20. package/dist/sync/sync-innerspace-constants.respec.mjs +10 -12
  21. package/dist/sync/sync-innerspace-constants.respec.mjs.map +1 -1
  22. package/dist/sync/sync-innerspace-deep-updates.respec.mjs +10 -12
  23. package/dist/sync/sync-innerspace-deep-updates.respec.mjs.map +1 -1
  24. package/dist/sync/sync-innerspace-dest-ahead.respec.mjs +10 -12
  25. package/dist/sync/sync-innerspace-dest-ahead.respec.mjs.map +1 -1
  26. package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs +9 -12
  27. package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs.map +1 -1
  28. package/dist/sync/sync-innerspace-partial-update.respec.mjs +9 -14
  29. package/dist/sync/sync-innerspace-partial-update.respec.mjs.map +1 -1
  30. package/dist/sync/sync-innerspace.respec.mjs +9 -12
  31. package/dist/sync/sync-innerspace.respec.mjs.map +1 -1
  32. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.d.mts +2 -0
  33. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.d.mts.map +1 -1
  34. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs +4 -0
  35. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs.map +1 -1
  36. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts +24 -13
  37. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts.map +1 -1
  38. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs +176 -76
  39. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs.map +1 -1
  40. package/dist/sync/sync-peer/sync-peer-types.d.mts +29 -6
  41. package/dist/sync/sync-peer/sync-peer-types.d.mts.map +1 -1
  42. package/dist/sync/sync-peer/sync-peer-v1.d.mts +38 -55
  43. package/dist/sync/sync-peer/sync-peer-v1.d.mts.map +1 -1
  44. package/dist/sync/sync-peer/sync-peer-v1.mjs +111 -244
  45. package/dist/sync/sync-peer/sync-peer-v1.mjs.map +1 -1
  46. package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts +32 -1
  47. package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts.map +1 -1
  48. package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs +96 -7
  49. package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs.map +1 -1
  50. package/dist/sync/sync-saga-coordinator.d.mts +59 -13
  51. package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
  52. package/dist/sync/sync-saga-coordinator.mjs +446 -304
  53. package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
  54. package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts +51 -6
  55. package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts.map +1 -1
  56. package/dist/sync/sync-types.d.mts +35 -10
  57. package/dist/sync/sync-types.d.mts.map +1 -1
  58. package/dist/sync/sync-types.mjs +1 -2
  59. package/dist/sync/sync-types.mjs.map +1 -1
  60. package/package.json +1 -1
  61. package/src/common/other/graph-helper.mts +53 -0
  62. package/src/common/other/ibgib-helper.mts +1 -1
  63. package/src/sync/graft-info/graft-info-helpers.mts +3 -3
  64. package/src/sync/sync-conflict.respec.mts +10 -17
  65. package/src/sync/sync-constants.mts +1 -0
  66. package/src/sync/sync-helpers.mts +47 -7
  67. package/src/sync/sync-innerspace-constants.respec.mts +10 -12
  68. package/src/sync/sync-innerspace-deep-updates.respec.mts +10 -12
  69. package/src/sync/sync-innerspace-dest-ahead.respec.mts +10 -12
  70. package/src/sync/sync-innerspace-multiple-timelines.respec.mts +9 -12
  71. package/src/sync/sync-innerspace-partial-update.respec.mts +9 -14
  72. package/src/sync/sync-innerspace.respec.mts +9 -12
  73. package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mts +7 -0
  74. package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mts +200 -75
  75. package/src/sync/sync-peer/sync-peer-types.mts +35 -11
  76. package/src/sync/sync-peer/sync-peer-v1.mts +154 -257
  77. package/src/sync/sync-saga-context/sync-saga-context-helpers.mts +90 -13
  78. package/src/sync/sync-saga-coordinator.mts +536 -356
  79. package/src/sync/sync-saga-message/sync-saga-message-types.mts +56 -4
  80. package/src/sync/sync-types.mts +46 -13
@@ -19,6 +19,7 @@ import {
19
19
  import { IbGibSpaceAny } from '../../witness/space/space-base-v1.mjs';
20
20
  import { putInSpace, registerNewIbGib } from '../../witness/space/space-helper.mjs';
21
21
  import { SyncIbGib_V1 } from '../sync-types.mjs';
22
+ import { validateSyncSagaFrame } from '../sync-helpers.mjs';
22
23
 
23
24
  const logalot = GLOBAL_LOG_A_LOT;
24
25
 
@@ -111,13 +112,13 @@ export async function parseSyncSagaContextIb({
111
112
  /**
112
113
  * Creates new SyncSagaContext stone. Puts/registers in {@link localSpace}
113
114
  * immediately after creation.
114
- *
115
+ *
115
116
  * @returns The context ibGib.
116
- *
117
+ *
117
118
  * ## notes
118
- *
119
+ *
119
120
  * the other ibgibs that are related to this context stone should already be
120
- * put/registered in {@link localSpace}.
121
+ * put/registered in {@link localSpace}.
121
122
  */
122
123
  export async function createSyncSagaContext({
123
124
  sagaFrame,
@@ -138,7 +139,7 @@ export async function createSyncSagaContext({
138
139
  timestampMs,
139
140
  };
140
141
 
141
- // Domain Payloads
142
+ // Domain Payloads
142
143
  const payloadAddrsDomain = payloadIbGibsDomain ?
143
144
  payloadIbGibsDomain?.map(x => getIbGibAddr({ ibGib: x })) :
144
145
  undefined;
@@ -189,10 +190,19 @@ export async function createSyncSagaContext({
189
190
  }
190
191
 
191
192
  /**
192
- * move to sync-peer-helpers.mts as a pure function?
193
+ * Validates ONLY the {@link context} ibgib itself and saga frame/msg stone(s)
194
+ * ({@link SyncSagaContextIbGib_V1.sagaFrame}).
195
+ *
196
+ * Does NOT...
197
+ * * validate keystones (authn or authz)
198
+ * * validate domain payload ibgibs...
199
+ * * intrinsically
200
+ * * in relation to this context (addrs match up)
201
+ *
202
+ * @returns empty array if valid, else validation errors
193
203
  */
194
- export async function validateContext({ context }: { context: SyncSagaContextIbGib_V1 }): Promise<string[]> {
195
- const lc = `[${validateContext.name}]`;
204
+ export async function validateContextAndSagaFrame({ context }: { context: SyncSagaContextIbGib_V1 }): Promise<string[]> {
205
+ const lc = `[${validateContextAndSagaFrame.name}]`;
196
206
  try {
197
207
  if (logalot) { console.log(`${lc} starting... (I: 7797f8294bd8f7e5089cb722ad468226)`); }
198
208
 
@@ -206,20 +216,87 @@ export async function validateContext({ context }: { context: SyncSagaContextIbG
206
216
  }
207
217
 
208
218
  if (context.sagaFrame) {
209
-
219
+ const sagaFrameErrors =
220
+ await validateSyncSagaFrame({ sagaIbGib: context.sagaFrame });
221
+ sagaFrameErrors.forEach(x => errors.push(x));
210
222
  } else {
211
223
  errors.push(`context.sagaFrame is falsy. (E: b4edd88f4963f493789f83b29ba2df26)`);
212
224
  }
213
225
 
226
+ // if this is already invalid, we could have intrinsic validation errors, which are a non-starter.
227
+ if (errors.length > 0) { return errors; /* <<<< returns early */ }
228
+
214
229
  // 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)
215
230
 
231
+ // ~~ensure the non-dto properties on the context object (i.e. props
232
+ // that are not ib, gib, data, or rel8ns) match the data in the
233
+ // context object~~ NO. THIS WILL BE IN A SEPARATE FUNCTION.
234
+ // See `validateContextDomainPayloadIbGibs`
216
235
 
236
+ // throw new Error(`not implemented (E: cb639658e1183fa6c8a4ebca023ba926)`);
217
237
 
218
- // ensure the non-dto properties on the context object (i.e. props
219
- // that are not ib, gib, data, or rel8ns) match the data in the
220
- // context object
238
+ console.error(`${lc} NAG ERROR MSG (NOT THROWN): not fully implemented yet (E: d574d85cb578637648ed403857f7a826)`);
239
+ return [];
240
+ } catch (error) {
241
+ console.error(`${lc} ${extractErrorMsg(error)}`);
242
+ throw error;
243
+ } finally {
244
+ if (logalot) { console.log(`${lc} complete.`); }
245
+ }
246
+ }
247
+
248
+
249
+ /**
250
+ * validates {@link SyncSagaContextIbGib_V1.payloadIbGibsDomain} intrinsically,
251
+ * and ensures that these payloadIbGibs also match the expected addrs in
252
+ * {@link SyncSagaContextData_V1}[{@link SYNC_SAGA_PAYLOAD_ADDRS_DOMAIN}].
253
+ *
254
+ * @returns empty array if valid, else validation errors
255
+ */
256
+ export async function validateContextDomainPayloadIbGibs({ context }: { context: SyncSagaContextIbGib_V1 }): Promise<string[]> {
257
+ const lc = `[${validateContextDomainPayloadIbGibs.name}]`;
258
+ try {
259
+ if (logalot) { console.log(`${lc} starting... (I: 9f9fe835bcc80c75aa7fd6d887fc0826)`); }
260
+ console.error(`${lc} NAG MESSAGE (NOT THROWN). not implemented (E: bfe02ab36a227291a8f17ffc08f2ef26)`)
261
+ return [];
262
+ } catch (error) {
263
+ console.error(`${lc} ${extractErrorMsg(error)}`);
264
+ throw error;
265
+ } finally {
266
+ if (logalot) { console.log(`${lc} complete.`); }
267
+ }
268
+ }
269
+
270
+ /**
271
+ * move to sync-peer-helpers.mts as a pure function?
272
+ */
273
+ export async function authenticateContext({ context }: { context: SyncSagaContextIbGib_V1 }): Promise<string[]> {
274
+ const lc = `[${authenticateContext.name}]`;
275
+ try {
276
+ if (logalot) { console.log(`${lc} starting... (I: 2677a482dfa873dcd1aa04a3031ff826)`); }
277
+
278
+ console.error(`${lc} NAG ERROR (NOT THROWN): not implemented. // todo: authenticate (v1 must have this after we get merge logic workflow going) (E: bc3a78f2dab18ab64c36d055a4b50526)`);
279
+
280
+ return [];
281
+ } catch (error) {
282
+ console.error(`${lc} ${extractErrorMsg(error)}`);
283
+ throw error;
284
+ } finally {
285
+ if (logalot) { console.log(`${lc} complete.`); }
286
+ }
287
+ }
288
+
289
+ /**
290
+ * move to sync-peer-helpers.mts as a pure function?
291
+ */
292
+ export async function authorizeContext({ context }: { context: SyncSagaContextIbGib_V1 }): Promise<string[]> {
293
+ const lc = `[${authorizeContext.name}]`;
294
+ try {
295
+ if (logalot) { console.log(`${lc} starting... (I: 48c918b41ceec0cd489ca3b8819e6826)`); }
296
+
297
+ 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)`);
221
298
 
222
- throw new Error(`not implemented (E: cb639658e1183fa6c8a4ebca023ba926)`);
299
+ return [];
223
300
  } catch (error) {
224
301
  console.error(`${lc} ${extractErrorMsg(error)}`);
225
302
  throw error;