import { Paginator } from "@aws-sdk/types" ; import { GetExecutionHistoryCommand , GetExecutionHistoryCommandInput , GetExecutionHistoryCommandOutput , } from "../commands/GetExecutionHistoryCommand" ; import { SFN } from "../SFN" ; import { SFNClient } from "../SFNClient" ; import { SFNPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < GetExecutionHistoryCommandOutput > => { return await client . send ( new GetExecutionHistoryCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < GetExecutionHistoryCommandOutput > => { return await client . getExecutionHistory ( input , ... args ) ; } ; export async function * paginateGetExecutionHistory ( config , input , ... additionalArguments ) { let token = config . startingToken || undefined ; let hasNext = true ; let page ; while ( hasNext ) { input . nextToken = token ; input [ "maxResults" ] = config . pageSize ; if ( config . client instanceof SFN ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof SFNClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected SFN | SFNClient" ) ; } yield page ; token = page . nextToken ; hasNext = ! ! token ; } return undefined ; }