@syncular/core 0.31.0 → 0.32.0
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/render.d.ts +5 -1
- package/dist/render.js +8 -4
- package/package.json +1 -1
- package/src/render.ts +14 -6
package/dist/render.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* fields embedded as parsed JSON.
|
|
9
9
|
*/
|
|
10
10
|
import type { SyncMessage } from './message.js';
|
|
11
|
-
import type { RowColumn, SparseRowValue } from './row-codec.js';
|
|
11
|
+
import type { RowColumn, RowValue, SparseRowValue } from './row-codec.js';
|
|
12
12
|
import type { RowsSegment } from './segment.js';
|
|
13
13
|
export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
14
14
|
[key: string]: JsonValue;
|
|
@@ -18,6 +18,10 @@ export declare function bytesToBase64(bytes: Uint8Array): string;
|
|
|
18
18
|
export declare function renderMessageValue(message: SyncMessage): JsonValue;
|
|
19
19
|
/** `render(bytes) → json` for SSP2 messages (§11). */
|
|
20
20
|
export declare function renderMessage(bytes: Uint8Array): JsonValue;
|
|
21
|
+
/** Render a decoded full row (§11) as JSON keyed by column name. */
|
|
22
|
+
export declare function renderRowValues(columns: readonly RowColumn[], values: readonly RowValue[]): {
|
|
23
|
+
[column: string]: JsonValue;
|
|
24
|
+
};
|
|
21
25
|
export declare function renderRowsSegmentValue(segment: RowsSegment): JsonValue;
|
|
22
26
|
/** `render(bytes) → json` for standalone SSG2 rows segments (§11 rule 8). */
|
|
23
27
|
export declare function renderRowsSegment(bytes: Uint8Array): JsonValue;
|
package/dist/render.js
CHANGED
|
@@ -275,6 +275,13 @@ function renderRowValue(column, value) {
|
|
|
275
275
|
}
|
|
276
276
|
return value;
|
|
277
277
|
}
|
|
278
|
+
/** Render a decoded full row (§11) as JSON keyed by column name. */
|
|
279
|
+
export function renderRowValues(columns, values) {
|
|
280
|
+
return Object.fromEntries(columns.map((column, i) => [
|
|
281
|
+
column.name,
|
|
282
|
+
renderRowValue(column, values[i] ?? null),
|
|
283
|
+
]));
|
|
284
|
+
}
|
|
278
285
|
function renderColumnTable(columns) {
|
|
279
286
|
return columns.map((column) => ({
|
|
280
287
|
name: column.name,
|
|
@@ -291,10 +298,7 @@ export function renderRowsSegmentValue(segment) {
|
|
|
291
298
|
columns: renderColumnTable(segment.columns),
|
|
292
299
|
blocks: segment.blocks.map((block) => block.map((row) => ({
|
|
293
300
|
serverVersion: row.serverVersion,
|
|
294
|
-
values:
|
|
295
|
-
column.name,
|
|
296
|
-
renderRowValue(column, row.values[i] ?? null),
|
|
297
|
-
])),
|
|
301
|
+
values: renderRowValues(segment.columns, row.values),
|
|
298
302
|
}))),
|
|
299
303
|
};
|
|
300
304
|
}
|
package/package.json
CHANGED
package/src/render.ts
CHANGED
|
@@ -322,6 +322,19 @@ function renderRowValue(column: RowColumn, value: RowValue): JsonValue {
|
|
|
322
322
|
return value;
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
+
/** Render a decoded full row (§11) as JSON keyed by column name. */
|
|
326
|
+
export function renderRowValues(
|
|
327
|
+
columns: readonly RowColumn[],
|
|
328
|
+
values: readonly RowValue[],
|
|
329
|
+
): { [column: string]: JsonValue } {
|
|
330
|
+
return Object.fromEntries(
|
|
331
|
+
columns.map((column, i) => [
|
|
332
|
+
column.name,
|
|
333
|
+
renderRowValue(column, values[i] ?? null),
|
|
334
|
+
]),
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
|
|
325
338
|
function renderColumnTable(columns: readonly RowColumn[]): JsonValue {
|
|
326
339
|
return columns.map((column) => ({
|
|
327
340
|
name: column.name,
|
|
@@ -340,12 +353,7 @@ export function renderRowsSegmentValue(segment: RowsSegment): JsonValue {
|
|
|
340
353
|
blocks: segment.blocks.map((block) =>
|
|
341
354
|
block.map((row) => ({
|
|
342
355
|
serverVersion: row.serverVersion,
|
|
343
|
-
values:
|
|
344
|
-
segment.columns.map((column, i) => [
|
|
345
|
-
column.name,
|
|
346
|
-
renderRowValue(column, row.values[i] ?? null),
|
|
347
|
-
]),
|
|
348
|
-
),
|
|
356
|
+
values: renderRowValues(segment.columns, row.values),
|
|
349
357
|
})),
|
|
350
358
|
),
|
|
351
359
|
};
|