@ibgib/core-gib 0.1.26 → 0.1.27

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 (34) hide show
  1. package/dist/sync/sync-helpers.d.mts +16 -1
  2. package/dist/sync/sync-helpers.d.mts.map +1 -1
  3. package/dist/sync/sync-helpers.mjs +101 -4
  4. package/dist/sync/sync-helpers.mjs.map +1 -1
  5. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts.map +1 -1
  6. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs +30 -9
  7. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs.map +1 -1
  8. package/dist/sync/sync-peer/sync-peer-v1.d.mts.map +1 -1
  9. package/dist/sync/sync-peer/sync-peer-v1.mjs +1 -0
  10. package/dist/sync/sync-peer/sync-peer-v1.mjs.map +1 -1
  11. package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts.map +1 -1
  12. package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs +17 -3
  13. package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs.map +1 -1
  14. package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts +8 -0
  15. package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts.map +1 -1
  16. package/dist/sync/sync-saga-coordinator.d.mts +29 -16
  17. package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
  18. package/dist/sync/sync-saga-coordinator.mjs +378 -392
  19. package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
  20. package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts +1 -1
  21. package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts.map +1 -1
  22. package/dist/sync/sync-types.d.mts +30 -1
  23. package/dist/sync/sync-types.d.mts.map +1 -1
  24. package/dist/sync/sync-types.mjs +32 -0
  25. package/dist/sync/sync-types.mjs.map +1 -1
  26. package/package.json +2 -2
  27. package/src/sync/sync-helpers.mts +92 -4
  28. package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mts +30 -8
  29. package/src/sync/sync-peer/sync-peer-v1.mts +2 -0
  30. package/src/sync/sync-saga-context/sync-saga-context-helpers.mts +14 -2
  31. package/src/sync/sync-saga-context/sync-saga-context-types.mts +13 -5
  32. package/src/sync/sync-saga-coordinator.mts +408 -432
  33. package/src/sync/sync-saga-message/sync-saga-message-types.mts +18 -18
  34. package/src/sync/sync-types.mts +38 -1
@@ -38,7 +38,7 @@ export interface SyncSagaMessageIbGib_V1 extends IbGib_V1<SyncSagaMessageData_V1
38
38
 
39
39
  /**
40
40
  * The "Hello" of the sync protocol.
41
- *
41
+ *
42
42
  * Exchanges knowledge vectors (what I have) and identity (who I am).
43
43
  */
44
44
  export interface SyncSagaMessageInitData_V1 extends SyncSagaMessageData_V1 {
@@ -47,7 +47,7 @@ export interface SyncSagaMessageInitData_V1 extends SyncSagaMessageData_V1 {
47
47
  /**
48
48
  * Map of TJP (Temporal Joint Point) to latest known ibGibAddr.
49
49
  * Use this to calculate what is missing (Delta).
50
- *
50
+ *
51
51
  * IOW, this is a map of the starting and end points of an ibGib's timeline.
52
52
  */
53
53
  knowledgeVector: { [tjp: string]: IbGibAddr };
@@ -67,14 +67,14 @@ export interface SyncSagaMessageInitData_V1 extends SyncSagaMessageData_V1 {
67
67
 
68
68
  /**
69
69
  * This is also in the sync saga ibgib itself now...
70
- *
70
+ *
71
71
  * @see {@link SyncOptions.conflictStrategy}
72
72
  */
73
73
  conflictStrategy?: SyncConflictStrategy;
74
74
  }
75
75
 
76
76
  /**
77
- * When an endpoing doesn't have a timeline or some part of it, then this info
77
+ * When an endpoing doesn't have a timeline or some part of it, then this info
78
78
  * contains sufficient information for the other endpoint to know what addrs to
79
79
  * send.
80
80
  */
@@ -92,9 +92,9 @@ export interface SyncSagaRequestAddrInfo {
92
92
  /**
93
93
  * If this is truthy, then we already have something from this timeline and
94
94
  * this will be the latest addr in that timeline.
95
- *
95
+ *
96
96
  * If falsy, then we are requesting the entire timeline be sent.
97
- *
97
+ *
98
98
  * This is to be used to calculate the delta graph.
99
99
  * @see {@link getDeltaDependencyGraph}
100
100
  */
@@ -149,27 +149,27 @@ export interface SyncSagaMessageAckData_V1 extends SyncSagaMessageData_V1 {
149
149
  /**
150
150
  * Map of group keys (TJP addr/constant addr) to list of known addresses
151
151
  * in that timeline.
152
- *
153
- * This will be used by Sender to calculate differential payloads. So
152
+ *
153
+ * This will be used by Sender to calculate differential payloads. So
154
154
  * when the sender goes to get the dependency graph of its tip ibgib,
155
155
  * it can skip all of the addrs in this.
156
- *
157
- * For example, say sender has A^5 and receiver only has A^3. Sender
156
+ *
157
+ * For example, say sender has A^5 and receiver only has A^3. Sender
158
158
  * will see in this map { [A^0]: [A^0, A^1, A^2, A^3] } and know that
159
159
  * it needs all of the dependencies of A^5 (including A^4), but it does
160
160
  * NOT need to send A^0-A^3 (and dependencies) because receiver already has
161
161
  * these.
162
- *
162
+ *
163
163
  * ## notes
164
- *
164
+ *
165
165
  * I dislike this name in my rewrite/cleanup of this algorithm. However, I'm
166
166
  * keeping it and am using it right now in handleInitFrame for including
167
- * the receiver's latest addr/tip for the deltaReqAddrs. But really, I should
167
+ * the receiver's latest addr/tip for the deltaReqAddrs. But really, I should
168
168
  */
169
169
  // knowledgeVector?: { [tjpAddr: string]: string[] };
170
170
  /**
171
171
  * List of identified conflicts.
172
- *
172
+ *
173
173
  * If present, the Sender should use the `timelineAddrs` (Receiver's
174
174
  * history) to compute the LCA and delta requirements for merging.
175
175
  */
@@ -178,16 +178,16 @@ export interface SyncSagaMessageAckData_V1 extends SyncSagaMessageData_V1 {
178
178
 
179
179
  /**
180
180
  * The "Body" of the sync protocol. Carries the manifests of data to be
181
- * transferred.
182
- *
181
+ * transferred.
182
+ *
183
183
  * If any {@link payloadAddrsDomain} exist, then these will be populated in the
184
184
  * {@link SyncSagaContextIbGib_V1}.
185
185
  */
186
186
  export interface SyncSagaMessageDeltaData_V1 extends SyncSagaMessageData_V1 {
187
187
  stage: typeof SyncStage.delta;
188
- requests?: string[];
188
+ deltaRequestAddrInfos?: SyncSagaRequestAddrInfo[];
189
189
  /**
190
- * Flag indicating the sender has no further requests or payloads
190
+ * Flag indicating the sender has no further requests or payloads
191
191
  * and is ready to commit the transaction.
192
192
  */
193
193
  proposeCommit?: boolean;
@@ -54,6 +54,43 @@ export function isValidSyncConflictStrategy(strategy: string): strategy is SyncC
54
54
  }
55
55
  // #endregion SyncConflictStrategy
56
56
 
57
+ // #region SyncExecutionContext
58
+ export const SYNC_EXECUTION_CONTEXT_SENDER = 'sender';
59
+ export const SYNC_EXECUTION_CONTEXT_RECEIVER = 'receiver';
60
+ export type SyncExecutionContext =
61
+ | typeof SYNC_EXECUTION_CONTEXT_SENDER
62
+ | typeof SYNC_EXECUTION_CONTEXT_RECEIVER
63
+ ;
64
+ /**
65
+ * if the current code execution is executing on the original sender (the
66
+ * initiator of the sync saga operation) or the other party, the "receiver" (the
67
+ * one responding).
68
+ *
69
+ * This is driven by looking at the latest value of `sagaFrame.data.n` value.
70
+ *
71
+ * NOTE: This is not to be confused with the sync saga context ibgib, which is
72
+ * something else entirely. That is the transport wrapper ibgib around the saga.
73
+ * this is strictly the enum for where the code is executing.
74
+ */
75
+ export const SyncExecutionContext = {
76
+ /**
77
+ * The current code is executing on the initial location that started the
78
+ * sync.
79
+ */
80
+ sender: SYNC_EXECUTION_CONTEXT_SENDER,
81
+ /**
82
+ * The current code is executing on the receiving end, which is either a
83
+ * physically different location or is the logical "receiver" of an
84
+ * in-memory sync execution.
85
+ */
86
+ receiver: SYNC_EXECUTION_CONTEXT_RECEIVER,
87
+ } satisfies { [key in SyncExecutionContext]: SyncExecutionContext };
88
+ export const SYNC_EXECUTION_CONTEXT_VALID_VALUES = Object.values(SyncExecutionContext);
89
+ export function isValidSyncExecutionContext(executionContext: string): executionContext is SyncExecutionContext {
90
+ return SYNC_EXECUTION_CONTEXT_VALID_VALUES.includes(executionContext as SyncExecutionContext);
91
+ }
92
+ // #endregion SyncConflictStrategy
93
+
57
94
  export interface NextSagaFrameInfo_Frame {
58
95
  frame: SyncIbGib_V1;
59
96
  payloadIbGibsDomain?: IbGib_V1[];
@@ -61,7 +98,7 @@ export interface NextSagaFrameInfo_Frame {
61
98
  responseWasNull?: undefined;
62
99
  }
63
100
  export interface NextSagaFrameInfo_Null {
64
- frame: never;
101
+ frame?: never;
65
102
  payloadIbGibsDomain?: never;
66
103
  conflictInfos?: never;
67
104
  responseWasNull: true;