File tree Expand file tree Collapse file tree 2 files changed +26
-18
lines changed Expand file tree Collapse file tree 2 files changed +26
-18
lines changed Original file line number Diff line number Diff line change 11import { authFirst } from "./util" ;
22
3+ export interface Patch {
4+ seq : number ;
5+ time : number ;
6+ mesg : {
7+ time : number ;
8+ wall : number ;
9+ patch : string ;
10+ user_id : number ;
11+ is_snapshot ?: boolean ;
12+ parents : number [ ] ;
13+ version ?: number ;
14+ } ;
15+ }
16+
317export interface Sync {
418 history : ( opts : {
519 account_id ?: string ;
620 project_id : string ;
721 path : string ;
8- } ) => Promise < any [ ] > ;
22+ } ) => Promise < { patches : Patch [ ] } > ;
923}
1024
1125export const sync = {
Original file line number Diff line number Diff line change 11import { conat } from "@cocalc/backend/conat" ;
22import isCollaborator from "@cocalc/server/projects/is-collaborator" ;
33import { patchesStreamName } from "@cocalc/conat/sync/synctable-stream" ;
4+ import { type Patch } from "@cocalc/conat/hub/api/sync" ;
45
56export async function history ( {
67 account_id,
78 project_id,
89 path,
910 start_seq = 0 ,
11+ end_seq,
1012} : {
1113 account_id ?: string ;
1214 project_id : string ;
1315 path : string ;
14- start_seq : number ;
15- } ) : Promise < any [ ] > {
16+ start_seq ?: number ;
17+ end_seq ?: number ;
18+ } ) : Promise < { patches : Patch [ ] } > {
1619 if ( ! account_id || ! ( await isCollaborator ( { account_id, project_id } ) ) ) {
1720 throw Error ( "user must be collaborator on source project" ) ;
1821 }
@@ -24,21 +27,12 @@ export async function history({
2427 project_id,
2528 noInventory : true ,
2629 } ) ;
27- const patches : {
28- seq : number ;
29- time : number ;
30- mesg : {
31- time : number ;
32- wall : number ;
33- patch : string ;
34- user_id : number ;
35- is_snapshot ?: boolean ;
36- parents : number [ ] ;
37- version ?: number ;
38- } ;
39- } [ ] = [ ] ;
40- for await ( const patch of await astream . getAll ( { start_seq } ) ) {
41- patches . push ( patch ) ;
30+ const patches : Patch [ ] = [ ] ;
31+ for await ( const patch of await astream . getAll ( {
32+ start_seq,
33+ end_seq,
34+ } ) ) {
35+ patches . push ( patch as any ) ;
4236 }
4337 return { patches } ;
4438}
You can’t perform that action at this time.
0 commit comments