@@ -140,7 +140,7 @@ export default class S3Cache {
140
140
const { Body, LastModified } = await this . getS3Object ( key , "fetch" , keys ) ;
141
141
const lastModified = await this . getHasRevalidatedTags (
142
142
key ,
143
- LastModified ?. getTime ( )
143
+ LastModified ?. getTime ( ) ,
144
144
) ;
145
145
if ( lastModified === - 1 ) {
146
146
// If some tags are stale we need to force revalidation
@@ -161,7 +161,7 @@ export default class S3Cache {
161
161
162
162
async getIncrementalCache (
163
163
key : string ,
164
- keys : string [ ]
164
+ keys : string [ ] ,
165
165
) : Promise < CacheHandlerValue | null > {
166
166
if ( keys . includes ( this . buildS3Key ( key , "body" ) ) ) {
167
167
debug ( "get body cache " , { key } ) ;
@@ -203,7 +203,7 @@ export default class S3Cache {
203
203
] ) ;
204
204
const lastModified = await this . getHasRevalidatedTags (
205
205
key ,
206
- LastModified ?. getTime ( )
206
+ LastModified ?. getTime ( ) ,
207
207
) ;
208
208
if ( lastModified === - 1 ) {
209
209
// If some tags are stale we need to force revalidation
@@ -236,7 +236,7 @@ export default class S3Cache {
236
236
const { Body, LastModified } = await this . getS3Object (
237
237
key ,
238
238
"redirect" ,
239
- keys
239
+ keys ,
240
240
) ;
241
241
return {
242
242
lastModified : LastModified ?. getTime ( ) ,
@@ -270,15 +270,15 @@ export default class S3Cache {
270
270
metaPromise = this . putS3Object (
271
271
key ,
272
272
"meta" ,
273
- JSON . stringify ( { status : data . status , headers : data . headers } )
273
+ JSON . stringify ( { status : data . status , headers : data . headers } ) ,
274
274
) ;
275
275
}
276
276
await Promise . all ( [
277
277
this . putS3Object ( key , "html" , html ) ,
278
278
this . putS3Object (
279
279
key ,
280
280
isAppPath ? "rsc" : "json" ,
281
- isAppPath ? pageData : JSON . stringify ( pageData )
281
+ isAppPath ? pageData : JSON . stringify ( pageData ) ,
282
282
) ,
283
283
metaPromise ,
284
284
] ) ;
@@ -309,7 +309,7 @@ export default class S3Cache {
309
309
tagsToWrite . map ( ( tag ) => ( {
310
310
path : key ,
311
311
tag : tag ,
312
- } ) )
312
+ } ) ) ,
313
313
) ;
314
314
}
315
315
}
@@ -327,7 +327,7 @@ export default class S3Cache {
327
327
paths ?. map ( ( path ) => ( {
328
328
path : path ,
329
329
tag : tag ,
330
- } ) ) ?? [ ]
330
+ } ) ) ?? [ ] ,
331
331
) ;
332
332
}
333
333
@@ -347,7 +347,7 @@ export default class S3Cache {
347
347
ExpressionAttributeValues : {
348
348
":key" : { S : this . buildDynamoKey ( path ) } ,
349
349
} ,
350
- } )
350
+ } ) ,
351
351
) ;
352
352
const tags = result . Items ?. map ( ( item ) => item . tag . S ?? "" ) ?? [ ] ;
353
353
debug ( "tags for path" , path , tags ) ;
@@ -376,7 +376,7 @@ export default class S3Cache {
376
376
":key" : { S : this . buildDynamoKey ( key ) } ,
377
377
":lastModified" : { N : String ( lastModified ?? 0 ) } ,
378
378
} ,
379
- } )
379
+ } ) ,
380
380
) ;
381
381
const revalidatedTags = result . Items ?? [ ] ;
382
382
debug ( "revalidatedTags" , revalidatedTags ) ;
@@ -401,12 +401,12 @@ export default class S3Cache {
401
401
ExpressionAttributeValues : {
402
402
":tag" : { S : this . buildDynamoKey ( tag ) } ,
403
403
} ,
404
- } )
404
+ } ) ,
405
405
) ;
406
406
return (
407
407
// We need to remove the buildId from the path
408
408
Items ?. map (
409
- ( { path : { S : key } } ) => key ?. replace ( `${ this . buildId } /` , "" ) ?? ""
409
+ ( { path : { S : key } } ) => key ?. replace ( `${ this . buildId } /` , "" ) ?? "" ,
410
410
) ?? [ ]
411
411
) ;
412
412
} catch ( e ) {
@@ -431,9 +431,9 @@ export default class S3Cache {
431
431
} ,
432
432
} ) ) ,
433
433
} ,
434
- } )
434
+ } ) ,
435
435
) ;
436
- } )
436
+ } ) ,
437
437
) ;
438
438
} catch ( e ) {
439
439
error ( "Failed to batch write dynamo item" , e ) ;
@@ -469,7 +469,7 @@ export default class S3Cache {
469
469
CACHE_BUCKET_KEY_PREFIX ?? "" ,
470
470
extension === "fetch" ? "__fetch" : "" ,
471
471
this . buildId ,
472
- extension === "fetch" ? key : `${ key } .${ extension } `
472
+ extension === "fetch" ? key : `${ key } .${ extension } ` ,
473
473
) ;
474
474
}
475
475
@@ -484,7 +484,7 @@ export default class S3Cache {
484
484
// add a point to the key so that it only matches the key and
485
485
// not other keys starting with the same string
486
486
Prefix : `${ this . buildS3KeyPrefix ( key ) } .` ,
487
- } )
487
+ } ) ,
488
488
) ;
489
489
return ( Contents ?? [ ] ) . map ( ( { Key } ) => Key ) as string [ ] ;
490
490
}
@@ -497,7 +497,7 @@ export default class S3Cache {
497
497
new GetObjectCommand ( {
498
498
Bucket : CACHE_BUCKET_NAME ,
499
499
Key : this . buildS3Key ( key , extension ) ,
500
- } )
500
+ } ) ,
501
501
) ;
502
502
return result ;
503
503
} catch ( e ) {
@@ -509,22 +509,22 @@ export default class S3Cache {
509
509
private putS3Object (
510
510
key : string ,
511
511
extension : Extension ,
512
- value : PutObjectCommandInput [ "Body" ]
512
+ value : PutObjectCommandInput [ "Body" ] ,
513
513
) {
514
514
return this . client . send (
515
515
new PutObjectCommand ( {
516
516
Bucket : CACHE_BUCKET_NAME ,
517
517
Key : this . buildS3Key ( key , extension ) ,
518
518
Body : value ,
519
- } )
519
+ } ) ,
520
520
) ;
521
521
}
522
522
523
523
private async deleteS3Objects ( key : string ) {
524
524
try {
525
525
const regex = new RegExp ( `\.(json|rsc|html|body|meta|fetch|redirect)$` ) ;
526
526
const s3Keys = ( await this . listS3Object ( key ) ) . filter (
527
- ( key ) => key && regex . test ( key )
527
+ ( key ) => key && regex . test ( key ) ,
528
528
) ;
529
529
530
530
await this . client . send (
@@ -533,7 +533,7 @@ export default class S3Cache {
533
533
Delete : {
534
534
Objects : s3Keys . map ( ( Key ) => ( { Key } ) ) ,
535
535
} ,
536
- } )
536
+ } ) ,
537
537
) ;
538
538
} catch ( e ) {
539
539
error ( "Failed to delete cache" , e ) ;
0 commit comments