1+ import { ResolveType } from 'json-joy/lib/json-type' ;
12import type { RouteDeps , Router , RouterBase } from '../../types' ;
2- import { BlockCurRef , BlockIdRef , BlockPatchPartialRef , BlockPatchRef } from '../schema' ;
3+ import { BlockCurRef , BlockIdRef , BlockPatchPartialRef , BlockPatchPartialReturnRef } from '../schema' ;
34
45export const upd =
56 ( { t, services} : RouteDeps ) =>
@@ -9,21 +10,14 @@ export const upd =
910 title : 'Document ID' ,
1011 description : 'The ID of the document to apply the patch to.' ,
1112 } ) ,
12- t . prop ( 'cur' , BlockCurRef ) . options ( {
13- title : 'Last known sequence number' ,
14- description :
15- 'The last known sequence number of the document. ' +
16- 'If the document has changed since this sequence number, ' +
17- 'the response will contain all the necessary patches for the client to catch up.' ,
18- } ) ,
1913 t . prop ( 'patches' , t . Array ( BlockPatchPartialRef ) ) . options ( {
2014 title : 'Patches' ,
2115 description : 'The patches to apply to the document.' ,
2216 } ) ,
2317 ) ;
2418
2519 const Response = t . Object (
26- t . prop ( 'patches' , t . Array ( BlockPatchRef ) ) . options ( {
20+ t . prop ( 'patches' , t . Array ( BlockPatchPartialReturnRef ) ) . options ( {
2721 title : 'Latest patches' ,
2822 description : 'The list of patches that the client might have missed and should apply to the document.' ,
2923 } ) ,
@@ -35,10 +29,13 @@ export const upd =
3529 description : 'Applies patches to an existing document and returns the latest concurrent changes.' ,
3630 } ) ;
3731
38- return r . prop ( 'block.upd' , Func , async ( { id, cur , patches} ) => {
32+ return r . prop ( 'block.upd' , Func , async ( { id, patches} ) => {
3933 const res = await services . blocks . edit ( id , patches ) ;
34+ const patchesReturn : ResolveType < typeof BlockPatchPartialReturnRef > [ ] = res . patches . map ( patch => ( {
35+ ts : patch . created ,
36+ } ) ) ;
4037 return {
41- patches : res . patches ,
38+ patches : patchesReturn ,
4239 } ;
4340 } ) ;
4441 } ;
0 commit comments