@syncular/core 0.59.0 → 0.60.1

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/src/render.ts CHANGED
@@ -80,6 +80,13 @@ function renderStringMap(map: Readonly<Record<string, string>>): JsonValue {
80
80
  return { ...map };
81
81
  }
82
82
 
83
+ /** Digest fields render as lowercase hex (Conventions: hashes are hex). */
84
+ function renderDigest(digest: Uint8Array): string {
85
+ let hex = '';
86
+ for (const byte of digest) hex += byte.toString(16).padStart(2, '0');
87
+ return hex;
88
+ }
89
+
83
90
  function renderOperation(operation: PushOperation): JsonValue {
84
91
  return {
85
92
  table: operation.table,
@@ -123,9 +130,7 @@ function renderChange(change: CommitChange): JsonValue {
123
130
  tableIndex: change.tableIndex,
124
131
  rowId: change.rowId,
125
132
  op: change.op,
126
- ...(change.rowVersion !== undefined
127
- ? { rowVersion: change.rowVersion }
128
- : {}),
133
+ rowVersion: change.rowVersion,
129
134
  scopes: renderStringMap(change.scopes),
130
135
  ...(change.row !== undefined ? { row: bytesToBase64(change.row) } : {}),
131
136
  };
@@ -139,6 +144,7 @@ function renderFrame(frame: RequestFrame | ResponseFrame): JsonValue {
139
144
  clientId: frame.clientId,
140
145
  schemaVersion: frame.schemaVersion,
141
146
  ...(frame.logEpoch !== undefined ? { logEpoch: frame.logEpoch } : {}),
147
+ ...(frame.outboxId !== undefined ? { outboxId: frame.outboxId } : {}),
142
148
  };
143
149
  case 'ROUND_FAILURE':
144
150
  return { type: 'ROUND_FAILURE', code: frame.code };
@@ -146,6 +152,7 @@ function renderFrame(frame: RequestFrame | ResponseFrame): JsonValue {
146
152
  return {
147
153
  type: 'PUSH_COMMIT',
148
154
  clientCommitId: frame.clientCommitId,
155
+ clientSeq: frame.clientSeq,
149
156
  operations: frame.operations.map(renderOperation),
150
157
  };
151
158
  case 'PULL_HEADER':
@@ -155,16 +162,16 @@ function renderFrame(frame: RequestFrame | ResponseFrame): JsonValue {
155
162
  limitSnapshotRows: frame.limitSnapshotRows,
156
163
  maxSnapshotPages: frame.maxSnapshotPages,
157
164
  accept: frame.accept,
165
+ cursor: frame.cursor,
166
+ registrationDigest: renderDigest(frame.registrationDigest),
167
+ echoDigest: renderDigest(frame.echoDigest),
158
168
  };
159
- case 'SUBSCRIPTION':
169
+ case 'UNIT':
170
+ return { type: 'UNIT', scopes: renderStringMap(frame.scopes) };
171
+ case 'PROGRESS':
160
172
  return {
161
- type: 'SUBSCRIPTION',
173
+ type: 'PROGRESS',
162
174
  id: frame.id,
163
- table: frame.table,
164
- scopes: renderScopeLists(frame.scopes),
165
- ...(frame.params !== undefined
166
- ? { params: parseJson(frame.params) }
167
- : {}),
168
175
  cursor: frame.cursor,
169
176
  ...(frame.bootstrapState !== undefined
170
177
  ? { bootstrapState: parseJson(frame.bootstrapState) }
@@ -228,8 +235,24 @@ function renderFrame(frame: RequestFrame | ResponseFrame): JsonValue {
228
235
  id: frame.id,
229
236
  status: frame.status,
230
237
  reasonCode: frame.reasonCode,
231
- effectiveScopes: renderScopeLists(frame.effectiveScopes),
232
238
  bootstrap: frame.bootstrap,
239
+ fenced: frame.fenced.map((record) => ({
240
+ table: record.table,
241
+ status: record.status,
242
+ scopes: renderScopeLists(record.scopes),
243
+ })),
244
+ };
245
+ case 'LIVE_START':
246
+ return {
247
+ type: 'LIVE_START',
248
+ status: frame.status,
249
+ reasonCode: frame.reasonCode,
250
+ };
251
+ case 'LIVE_END':
252
+ return {
253
+ type: 'LIVE_END',
254
+ throughSeq: frame.throughSeq,
255
+ echoDigest: renderDigest(frame.echoDigest),
233
256
  };
234
257
  case 'COMMIT':
235
258
  return {