1
1
// smithy-typescript generated code
2
+ import { createPaginator } from "@smithy/core" ;
2
3
import { Paginator } from "@smithy/types" ;
3
4
4
5
import { QueryCommand , QueryCommandInput , QueryCommandOutput } from "../commands/QueryCommand" ;
@@ -9,45 +10,15 @@ import { DynamoDBDocumentPaginationConfiguration } from "./Interfaces";
9
10
* @public
10
11
*/
11
12
export { Paginator } ;
12
- /**
13
- * @internal
14
- */
15
- const makePagedClientRequest = async (
16
- client : DynamoDBDocumentClient ,
17
- input : QueryCommandInput ,
18
- ...args : any
19
- ) : Promise < QueryCommandOutput > => {
20
- // @ts -ignore
21
- return await client . send ( new QueryCommand ( input ) , ...args ) ;
22
- } ;
23
13
/**
24
14
* @public
25
- *
26
- * @param QueryCommandInput - {@link QueryCommandInput}
27
- * @returns {@link QueryCommandOutput }
28
- *
29
15
*/
30
- export async function * paginateQuery (
16
+ export const paginateQuery : (
31
17
config : DynamoDBDocumentPaginationConfiguration ,
32
18
input : QueryCommandInput ,
33
19
...additionalArguments : any
34
- ) : Paginator < QueryCommandOutput > {
35
- // ToDo: replace with actual type instead of typeof input.ExclusiveStartKey
36
- let token : typeof input . ExclusiveStartKey | undefined = config . startingToken || undefined ;
37
- let hasNext = true ;
38
- let page : QueryCommandOutput ;
39
- while ( hasNext ) {
40
- input . ExclusiveStartKey = token ;
41
- input [ "Limit" ] = config . pageSize ;
42
- if ( config . client instanceof DynamoDBDocumentClient ) {
43
- page = await makePagedClientRequest ( config . client , input , ...additionalArguments ) ;
44
- } else {
45
- throw new Error ( "Invalid client, expected DynamoDBDocument | DynamoDBDocumentClient" ) ;
46
- }
47
- yield page ;
48
- token = page . LastEvaluatedKey ;
49
- hasNext = ! ! token ;
50
- }
51
- // @ts -ignore
52
- return undefined ;
53
- }
20
+ ) => Paginator < QueryCommandOutput > = createPaginator <
21
+ DynamoDBDocumentPaginationConfiguration ,
22
+ QueryCommandInput ,
23
+ QueryCommandOutput
24
+ > ( DynamoDBDocumentClient , QueryCommand , "ExclusiveStartKey" , "LastEvaluatedKey" , "Limit" ) ;
0 commit comments