@@ -394,7 +394,40 @@ const getAPIContextId = async () => {
394
394
* Get a revision by its ID.
395
395
*/
396
396
export const getRevision = cache ( {
397
- name : 'api.getRevision.v3' ,
397
+ name : 'api.getRevision.v2' ,
398
+ tag : ( spaceId , revisionId ) =>
399
+ getCacheTag ( { tag : 'revision' , space : spaceId , revision : revisionId } ) ,
400
+ tagImmutable : true ,
401
+ getKeySuffix : getAPIContextId ,
402
+ get : async (
403
+ spaceId : string ,
404
+ revisionId : string ,
405
+ fetchOptions : GetRevisionOptions ,
406
+ options : CacheFunctionOptions
407
+ ) => {
408
+ const apiCtx = await api ( ) ;
409
+ const response = await apiCtx . client . spaces . getRevisionById (
410
+ spaceId ,
411
+ revisionId ,
412
+ {
413
+ metadata : fetchOptions . metadata ,
414
+ } ,
415
+ {
416
+ ...noCacheFetchOptions ,
417
+ signal : options . signal ,
418
+ }
419
+ ) ;
420
+
421
+ return cacheResponse ( response , fetchOptions . metadata ? cacheTtl_7days : cacheTtl_1day ) ;
422
+ } ,
423
+ getKeyArgs : ( args ) => [ args [ 0 ] , args [ 1 ] ] ,
424
+ } ) ;
425
+
426
+ /**
427
+ * Get a revision by its ID and tags.
428
+ */
429
+ export const getRevisionAndTags = cache ( {
430
+ name : 'api.getRevisionAndTags.v1' ,
398
431
tag : ( spaceId , revisionId , fetchOptions ) =>
399
432
// Temporary hack to make it work with OpenAPI on v1
400
433
fetchOptions . tags ?. [ 0 ] ??
@@ -439,7 +472,43 @@ export const getRevision = cache({
439
472
* Get all the pages in a revision of a space.
440
473
*/
441
474
export const getRevisionPages = cache ( {
442
- name : 'api.getRevisionPages.v5' ,
475
+ name : 'api.getRevisionPages.v4' ,
476
+ tag : ( spaceId , revisionId ) =>
477
+ getCacheTag ( { tag : 'revision' , space : spaceId , revision : revisionId } ) ,
478
+ tagImmutable : true ,
479
+ getKeySuffix : getAPIContextId ,
480
+ get : async (
481
+ spaceId : string ,
482
+ revisionId : string ,
483
+ fetchOptions : GetRevisionOptions ,
484
+ options : CacheFunctionOptions
485
+ ) => {
486
+ const apiCtx = await api ( ) ;
487
+ const response = await apiCtx . client . spaces . listPagesInRevisionById (
488
+ spaceId ,
489
+ revisionId ,
490
+ {
491
+ metadata : fetchOptions . metadata ,
492
+ } ,
493
+ {
494
+ ...noCacheFetchOptions ,
495
+ signal : options . signal ,
496
+ }
497
+ ) ;
498
+
499
+ return cacheResponse ( response , {
500
+ ...( fetchOptions . metadata ? cacheTtl_7days : cacheTtl_1day ) ,
501
+ data : response . data . pages ,
502
+ } ) ;
503
+ } ,
504
+ getKeyArgs : ( args ) => [ args [ 0 ] , args [ 1 ] ] ,
505
+ } ) ;
506
+
507
+ /**
508
+ * Get all the pages in a revision of a space.
509
+ */
510
+ export const getRevisionPagesAndTags = cache ( {
511
+ name : 'api.getRevisionPages.v1' ,
443
512
tag : ( spaceId , revisionId , fetchOptions ) =>
444
513
// Temporary hack to make it work with OpenAPI on v1
445
514
fetchOptions . tags ?. [ 0 ] ??
@@ -663,7 +732,7 @@ export const getRevisionFile = batch<[string, string, string], RevisionFile | nu
663
732
let files : Record < string , RevisionFile > = { } ;
664
733
665
734
if ( hasRevisionInMemory ) {
666
- const { revision } = await getRevision ( spaceId , revisionId , { metadata : false } ) ;
735
+ const revision = await getRevision ( spaceId , revisionId , { metadata : false } ) ;
667
736
files = { } ;
668
737
revision . files . forEach ( ( file ) => {
669
738
files [ file . id ] = file ;
@@ -709,7 +778,7 @@ export const getReusableContent = async (
709
778
} ) ;
710
779
711
780
if ( hasRevisionInMemory ) {
712
- const { revision } = await getRevision ( spaceId , revisionId , { metadata : false } ) ;
781
+ const revision = await getRevision ( spaceId , revisionId , { metadata : false } ) ;
713
782
return (
714
783
revision . reusableContents . find (
715
784
( reusableContent ) => reusableContent . id === reusableContentId
0 commit comments