@syncular/server 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/src/storage.ts CHANGED
@@ -379,14 +379,62 @@ export interface CommitMetadata {
379
379
  readonly createdAtMs: number;
380
380
  readonly changeCount: number;
381
381
  readonly tables: readonly string[];
382
+ /** The first `changeSample` changes in commit order, when requested. */
383
+ readonly sample?: readonly CommitChangeSummary[];
384
+ }
385
+
386
+ /** One change without its payload, for commit lists. */
387
+ export interface CommitChangeSummary {
388
+ readonly table: string;
389
+ readonly rowId: string;
390
+ readonly op: 'upsert' | 'delete';
382
391
  }
383
392
 
384
393
  export interface CommitMetadataQuery {
385
- /** Window `afterSeq < commitSeq`, oldest first. */
394
+ /** Window lower bound, exclusive: `afterSeq < commitSeq`. */
386
395
  readonly afterSeq: number;
396
+ /** Window upper bound, exclusive: `commitSeq < beforeSeq` (older pages). */
397
+ readonly beforeSeq?: number;
398
+ /** Newest first, at most `limit` commits. */
387
399
  readonly limit: number;
388
400
  /** Restrict to commits that touched this table (via the change index). */
389
401
  readonly table?: string;
402
+ /** Attach the first N changes of each commit as `sample`. */
403
+ readonly changeSample?: number;
404
+ }
405
+
406
+ export interface RowListQuery {
407
+ readonly table: string;
408
+ /** Resume after this rowId (exclusive); `null` = start of table. */
409
+ readonly afterRowId: string | null;
410
+ readonly limit: number;
411
+ }
412
+
413
+ /** A stored push outcome with the client that sent it. */
414
+ export interface ClientPushResult {
415
+ readonly clientId: string;
416
+ readonly result: StoredPushResult;
417
+ }
418
+
419
+ /** One retained commit with its changes, for the admin commit drill-down. */
420
+ export interface CommitDetail extends CommitMetadata {
421
+ readonly changes: readonly StoredChange[];
422
+ }
423
+
424
+ /** One retained change to a single row, for the admin row history. */
425
+ export interface RowChangeRecord {
426
+ readonly commitSeq: number;
427
+ readonly op: 'upsert' | 'delete';
428
+ readonly rowVersion?: number;
429
+ readonly actorId: string;
430
+ readonly clientId: string;
431
+ readonly createdAtMs: number;
432
+ }
433
+
434
+ export interface RowChangesQuery {
435
+ readonly table: string;
436
+ readonly rowId: string;
437
+ readonly limit: number;
390
438
  }
391
439
 
392
440
  /** One recent commit touching a scope key, for the admin scope activity view. */
@@ -921,8 +969,16 @@ export interface ServerStorage {
921
969
  * touched tables), the newest-oriented window an operator inspects.
922
970
  * `scopeActivity`: the recent commits touching one scope key, via the
923
971
  * change scope index (never a log scan).
924
- * `getRowScopes`: the (table, rowId) row's current server_version and
925
- * stored scopes without decoding its payload — the row inspector.
972
+ * `getCommit`: one retained commit with its changes and payloads;
973
+ * `undefined` when the commit does not exist or was pruned.
974
+ * `listRowChanges`: the retained changes to one row, newest first. It
975
+ * reads the partition's retained log without a dedicated index, so the
976
+ * write path pays nothing for it and its cost is bounded by retention.
977
+ * `listRows`: one table's rows ordered by rowId, without a scope filter.
978
+ * `countRows`: one table's row count.
979
+ * `listPushResults`: every stored idempotency outcome for one
980
+ * clientCommitId across the partition's clients, scanning the retained
981
+ * outcomes without a dedicated index.
926
982
  * `listPartitions`: the partition-only compatibility view of
927
983
  * `listPartitionRegistry`, sorted.
928
984
  */
@@ -935,13 +991,20 @@ export interface ServerStorage {
935
991
  partition: string,
936
992
  query: ScopeActivityQuery,
937
993
  ): Promise<ScopeCommitActivity[]>;
938
- getRowScopes?(
994
+ getCommit?(
939
995
  partition: string,
940
- table: string,
941
- rowId: string,
942
- ): Promise<
943
- { serverVersion: number; scopes: Record<string, string> } | undefined
944
- >;
996
+ commitSeq: number,
997
+ ): Promise<CommitDetail | undefined>;
998
+ listRowChanges?(
999
+ partition: string,
1000
+ query: RowChangesQuery,
1001
+ ): Promise<RowChangeRecord[]>;
1002
+ listRows?(partition: string, query: RowListQuery): Promise<StoredRow[]>;
1003
+ countRows?(partition: string, table: string): Promise<number>;
1004
+ listPushResults?(
1005
+ partition: string,
1006
+ clientCommitId: string,
1007
+ ): Promise<ClientPushResult[]>;
945
1008
  listPartitions(): Promise<string[]>;
946
1009
  }
947
1010