@syncular/server 0.15.47 → 0.15.48

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 (61) hide show
  1. package/README.md +7 -1
  2. package/dist/admin.d.ts +1 -5
  3. package/dist/admin.js +2 -7
  4. package/dist/blob-handlers.js +4 -1
  5. package/dist/context.d.ts +3 -1
  6. package/dist/context.js +4 -0
  7. package/dist/d1-storage.d.ts +4 -1
  8. package/dist/d1-storage.js +75 -11
  9. package/dist/errors.js +6 -0
  10. package/dist/events.d.ts +2 -1
  11. package/dist/frame-bytes.d.ts +2 -2
  12. package/dist/frame-bytes.js +33 -14
  13. package/dist/handler.js +58 -14
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +1 -0
  16. package/dist/operations.js +2 -1
  17. package/dist/postgres-storage.d.ts +5 -2
  18. package/dist/postgres-storage.js +71 -10
  19. package/dist/pull.d.ts +1 -1
  20. package/dist/pull.js +11 -5
  21. package/dist/realtime.d.ts +4 -1
  22. package/dist/realtime.js +33 -9
  23. package/dist/restore.d.ts +13 -0
  24. package/dist/restore.js +13 -0
  25. package/dist/s3-segment-store.js +10 -1
  26. package/dist/seed.js +36 -4
  27. package/dist/segment-download.js +5 -2
  28. package/dist/segment-store.d.ts +3 -0
  29. package/dist/segment-store.js +1 -0
  30. package/dist/sqlite-bun-driver.d.ts +2 -1
  31. package/dist/sqlite-bun-driver.js +5 -2
  32. package/dist/sqlite-dialect.d.ts +1 -1
  33. package/dist/sqlite-dialect.js +7 -0
  34. package/dist/sqlite-segment-store.js +14 -5
  35. package/dist/sqlite-storage.d.ts +4 -1
  36. package/dist/sqlite-storage.js +81 -11
  37. package/dist/storage.d.ts +18 -5
  38. package/package.json +2 -2
  39. package/src/admin.ts +3 -9
  40. package/src/blob-handlers.ts +8 -1
  41. package/src/context.ts +16 -1
  42. package/src/d1-storage.ts +107 -12
  43. package/src/errors.ts +6 -0
  44. package/src/events.ts +2 -1
  45. package/src/frame-bytes.ts +40 -14
  46. package/src/handler.ts +102 -29
  47. package/src/index.ts +1 -0
  48. package/src/operations.ts +6 -1
  49. package/src/postgres-storage.ts +102 -13
  50. package/src/pull.ts +11 -0
  51. package/src/realtime.ts +46 -7
  52. package/src/restore.ts +28 -0
  53. package/src/s3-segment-store.ts +10 -1
  54. package/src/seed.ts +46 -4
  55. package/src/segment-download.ts +11 -2
  56. package/src/segment-store.ts +4 -0
  57. package/src/sqlite-bun-driver.ts +6 -2
  58. package/src/sqlite-dialect.ts +7 -0
  59. package/src/sqlite-segment-store.ts +18 -4
  60. package/src/sqlite-storage.ts +118 -12
  61. package/src/storage.ts +28 -5
package/src/storage.ts CHANGED
@@ -164,6 +164,8 @@ export interface ClientSubscription {
164
164
  export interface ClientRecord {
165
165
  readonly clientId: string;
166
166
  readonly actorId: string;
167
+ /** SSP2 version last accepted from this client; selects realtime deltas. */
168
+ readonly wireVersion: number;
167
169
  /** Minimum `nextCursor` across the last pull's active subscriptions. */
168
170
  readonly cursor: number;
169
171
  readonly updatedAtMs: number;
@@ -220,6 +222,14 @@ export interface ClientCursorInfo {
220
222
  readonly updatedAtMs: number;
221
223
  }
222
224
 
225
+ /** Durable partition identity refreshed after host authentication (§2.1). */
226
+ export interface PartitionRegistryEntry {
227
+ readonly partition: string;
228
+ readonly logEpoch: string;
229
+ readonly epochRequired: boolean;
230
+ readonly lastAuthenticatedAtMs: number;
231
+ }
232
+
223
233
  /**
224
234
  * Commit-log metadata (no change payloads) for the admin/console read
225
235
  * surface. `changeCount` is the number of changes the commit carries;
@@ -397,6 +407,21 @@ export interface ServerStorage {
397
407
  */
398
408
  ensureSchema(schema: CompiledSchema): Promise<void>;
399
409
 
410
+ /** Create or refresh the authenticated partition registry row (§2.1). */
411
+ touchPartition(
412
+ partition: string,
413
+ authenticatedAtMs: number,
414
+ initialLogEpoch: string,
415
+ ): Promise<PartitionRegistryEntry>;
416
+ /** Rotate log continuity after restore and discard stale cursor records. */
417
+ rotatePartitionLogEpoch(
418
+ partition: string,
419
+ logEpoch: string,
420
+ authenticatedAtMs: number,
421
+ ): Promise<PartitionRegistryEntry>;
422
+ /** Registry entries ordered by partition for maintenance loops. */
423
+ listPartitionRegistry(): Promise<PartitionRegistryEntry[]>;
424
+
400
425
  begin(partition: string): Promise<StorageTransaction>;
401
426
 
402
427
  getMaxCommitSeq(partition: string): Promise<number>;
@@ -551,10 +576,8 @@ export interface ServerStorage {
551
576
  * change scope index (never a log scan).
552
577
  * `getRowScopes`: the (table, rowId) row's current server_version and
553
578
  * stored scopes without decoding its payload — the row inspector.
554
- * `listPartitions`: every partition this storage holds state for — the
555
- * union of the partition registry (commit log counters) and client
556
- * records, sorted. Powers the console's fleet view / partition picker;
557
- * deliberately NOT partition-scoped (the one cross-partition read).
579
+ * `listPartitions`: the partition-only compatibility view of
580
+ * `listPartitionRegistry`, sorted.
558
581
  */
559
582
  listClientRecords?(partition: string): Promise<ClientRecord[]>;
560
583
  listCommitMetadata?(
@@ -572,7 +595,7 @@ export interface ServerStorage {
572
595
  ): Promise<
573
596
  { serverVersion: number; scopes: Record<string, string> } | undefined
574
597
  >;
575
- listPartitions?(): Promise<string[]>;
598
+ listPartitions(): Promise<string[]>;
576
599
  }
577
600
 
578
601
  /** A row referencing a blob, with the scopes needed to authorize download. */