@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/README.md +124 -74
- package/dist/admin.d.ts +394 -50
- package/dist/admin.js +714 -82
- package/dist/d1-storage.d.ts +6 -5
- package/dist/d1-storage.js +128 -19
- package/dist/events-ring.d.ts +12 -2
- package/dist/events-ring.js +27 -2
- package/dist/events.d.ts +21 -3
- package/dist/handler.js +19 -6
- package/dist/postgres-storage.d.ts +6 -5
- package/dist/postgres-storage.js +102 -18
- package/dist/realtime.d.ts +15 -0
- package/dist/realtime.js +24 -0
- package/dist/sqlite-storage.d.ts +6 -5
- package/dist/sqlite-storage.js +115 -18
- package/dist/storage.d.ts +58 -7
- package/package.json +2 -2
- package/src/admin.ts +1215 -120
- package/src/d1-storage.ts +187 -23
- package/src/events-ring.ts +31 -2
- package/src/events.ts +27 -4
- package/src/handler.ts +20 -6
- package/src/postgres-storage.ts +173 -28
- package/src/realtime.ts +35 -1
- package/src/sqlite-storage.ts +181 -26
- package/src/storage.ts +72 -9
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
|
|
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
|
-
* `
|
|
925
|
-
*
|
|
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
|
-
|
|
994
|
+
getCommit?(
|
|
939
995
|
partition: string,
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
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
|
|