@syncular/server 0.0.1-97 → 0.0.1-98
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/pull.d.ts.map +1 -1
- package/dist/pull.js +74 -32
- package/dist/pull.js.map +1 -1
- package/dist/schema.d.ts +1 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/snapshot-chunks/adapters/s3.d.ts +4 -4
- package/dist/snapshot-chunks/db-metadata.d.ts +2 -2
- package/dist/snapshot-chunks/db-metadata.d.ts.map +1 -1
- package/dist/snapshot-chunks/db-metadata.js +63 -33
- package/dist/snapshot-chunks/db-metadata.js.map +1 -1
- package/dist/snapshot-chunks/types.d.ts +6 -6
- package/dist/snapshot-chunks/types.d.ts.map +1 -1
- package/dist/snapshot-chunks.d.ts +7 -7
- package/dist/snapshot-chunks.d.ts.map +1 -1
- package/dist/snapshot-chunks.js +5 -4
- package/dist/snapshot-chunks.js.map +1 -1
- package/package.json +1 -1
- package/src/pull.ts +103 -32
- package/src/schema.ts +1 -1
- package/src/snapshot-chunks/db-metadata.test.ts +2 -2
- package/src/snapshot-chunks/db-metadata.ts +86 -40
- package/src/snapshot-chunks/types.ts +10 -6
- package/src/snapshot-chunks.ts +17 -11
package/src/snapshot-chunks.ts
CHANGED
|
@@ -5,7 +5,13 @@
|
|
|
5
5
|
* without embedding huge JSON payloads into pull responses.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import {
|
|
9
|
+
SYNC_SNAPSHOT_CHUNK_COMPRESSION,
|
|
10
|
+
SYNC_SNAPSHOT_CHUNK_ENCODING,
|
|
11
|
+
type SyncSnapshotChunkCompression,
|
|
12
|
+
type SyncSnapshotChunkEncoding,
|
|
13
|
+
type SyncSnapshotChunkRef,
|
|
14
|
+
} from '@syncular/core';
|
|
9
15
|
import { type Kysely, sql } from 'kysely';
|
|
10
16
|
import type { SyncCoreDb } from './schema';
|
|
11
17
|
|
|
@@ -16,8 +22,8 @@ export interface SnapshotChunkPageKey {
|
|
|
16
22
|
asOfCommitSeq: number;
|
|
17
23
|
rowCursor: string | null;
|
|
18
24
|
rowLimit: number;
|
|
19
|
-
encoding:
|
|
20
|
-
compression:
|
|
25
|
+
encoding: SyncSnapshotChunkEncoding;
|
|
26
|
+
compression: SyncSnapshotChunkCompression;
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
export interface SnapshotChunkRow {
|
|
@@ -28,8 +34,8 @@ export interface SnapshotChunkRow {
|
|
|
28
34
|
asOfCommitSeq: number;
|
|
29
35
|
rowCursor: string;
|
|
30
36
|
rowLimit: number;
|
|
31
|
-
encoding:
|
|
32
|
-
compression:
|
|
37
|
+
encoding: SyncSnapshotChunkEncoding;
|
|
38
|
+
compression: SyncSnapshotChunkCompression;
|
|
33
39
|
sha256: string;
|
|
34
40
|
byteLength: number;
|
|
35
41
|
body: Uint8Array | ReadableStream<Uint8Array>;
|
|
@@ -87,12 +93,12 @@ export async function readSnapshotChunkRefByPageKey<DB extends SyncCoreDb>(
|
|
|
87
93
|
|
|
88
94
|
if (!row) return null;
|
|
89
95
|
|
|
90
|
-
if (row.encoding !==
|
|
96
|
+
if (row.encoding !== SYNC_SNAPSHOT_CHUNK_ENCODING) {
|
|
91
97
|
throw new Error(
|
|
92
98
|
`Unexpected snapshot chunk encoding: ${String(row.encoding)}`
|
|
93
99
|
);
|
|
94
100
|
}
|
|
95
|
-
if (row.compression !==
|
|
101
|
+
if (row.compression !== SYNC_SNAPSHOT_CHUNK_COMPRESSION) {
|
|
96
102
|
throw new Error(
|
|
97
103
|
`Unexpected snapshot chunk compression: ${String(row.compression)}`
|
|
98
104
|
);
|
|
@@ -117,8 +123,8 @@ export async function insertSnapshotChunk<DB extends SyncCoreDb>(
|
|
|
117
123
|
asOfCommitSeq: number;
|
|
118
124
|
rowCursor: string | null;
|
|
119
125
|
rowLimit: number;
|
|
120
|
-
encoding:
|
|
121
|
-
compression:
|
|
126
|
+
encoding: SyncSnapshotChunkEncoding;
|
|
127
|
+
compression: SyncSnapshotChunkCompression;
|
|
122
128
|
sha256: string;
|
|
123
129
|
body: Uint8Array;
|
|
124
130
|
expiresAt: string;
|
|
@@ -250,12 +256,12 @@ export async function readSnapshotChunk<DB extends SyncCoreDb>(
|
|
|
250
256
|
|
|
251
257
|
if (!row) return null;
|
|
252
258
|
|
|
253
|
-
if (row.encoding !==
|
|
259
|
+
if (row.encoding !== SYNC_SNAPSHOT_CHUNK_ENCODING) {
|
|
254
260
|
throw new Error(
|
|
255
261
|
`Unexpected snapshot chunk encoding: ${String(row.encoding)}`
|
|
256
262
|
);
|
|
257
263
|
}
|
|
258
|
-
if (row.compression !==
|
|
264
|
+
if (row.compression !== SYNC_SNAPSHOT_CHUNK_COMPRESSION) {
|
|
259
265
|
throw new Error(
|
|
260
266
|
`Unexpected snapshot chunk compression: ${String(row.compression)}`
|
|
261
267
|
);
|