import { IssueIdentifier , EditionId } from '../../../../common' ; import { Bucket , listNestedPrefixes } from '../../../utils/s3' ; export const getIssuesBy = async ( edition , bucket ) : Promise < IssueIdentifier [ ] > => { const prefixes = await listNestedPrefixes ( bucket , edition ) ; return prefixes . map ( issueDate => ( { edition , issueDate , } ) ) ; } ; export const issueWindow = ( issues , windowSize ) : IssueIdentifier [ ] => issues . sort ( ( a , b ) => new Date ( b . issueDate ) . getTime ( ) - new Date ( a . issueDate ) . getTime ( ) ) . slice ( 0 , windowSize ) ;