@syncular/server 0.0.1-96 → 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.
@@ -5,7 +5,13 @@
5
5
  * without embedding huge JSON payloads into pull responses.
6
6
  */
7
7
 
8
- import type { SyncSnapshotChunkRef } from '@syncular/core';
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: 'ndjson';
20
- compression: 'gzip';
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: 'ndjson';
32
- compression: 'gzip';
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 !== 'ndjson') {
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 !== 'gzip') {
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: 'ndjson';
121
- compression: 'gzip';
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 !== 'ndjson') {
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 !== 'gzip') {
264
+ if (row.compression !== SYNC_SNAPSHOT_CHUNK_COMPRESSION) {
259
265
  throw new Error(
260
266
  `Unexpected snapshot chunk compression: ${String(row.compression)}`
261
267
  );