Skip to content

Commit be572a0

Browse files
committed
chore(lib-dynamodb): codegen sync
1 parent e12befe commit be572a0

File tree

2 files changed

+14
-72
lines changed

2 files changed

+14
-72
lines changed
Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// smithy-typescript generated code
2+
import { createPaginator } from "@smithy/core";
23
import { Paginator } from "@smithy/types";
34

45
import { QueryCommand, QueryCommandInput, QueryCommandOutput } from "../commands/QueryCommand";
@@ -9,45 +10,15 @@ import { DynamoDBDocumentPaginationConfiguration } from "./Interfaces";
910
* @public
1011
*/
1112
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-
};
2313
/**
2414
* @public
25-
*
26-
* @param QueryCommandInput - {@link QueryCommandInput}
27-
* @returns {@link QueryCommandOutput}
28-
*
2915
*/
30-
export async function* paginateQuery(
16+
export const paginateQuery: (
3117
config: DynamoDBDocumentPaginationConfiguration,
3218
input: QueryCommandInput,
3319
...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");
Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// smithy-typescript generated code
2+
import { createPaginator } from "@smithy/core";
23
import { Paginator } from "@smithy/types";
34

45
import { ScanCommand, ScanCommandInput, ScanCommandOutput } from "../commands/ScanCommand";
@@ -9,45 +10,15 @@ import { DynamoDBDocumentPaginationConfiguration } from "./Interfaces";
910
* @public
1011
*/
1112
export { Paginator };
12-
/**
13-
* @internal
14-
*/
15-
const makePagedClientRequest = async (
16-
client: DynamoDBDocumentClient,
17-
input: ScanCommandInput,
18-
...args: any
19-
): Promise<ScanCommandOutput> => {
20-
// @ts-ignore
21-
return await client.send(new ScanCommand(input), ...args);
22-
};
2313
/**
2414
* @public
25-
*
26-
* @param ScanCommandInput - {@link ScanCommandInput}
27-
* @returns {@link ScanCommandOutput}
28-
*
2915
*/
30-
export async function* paginateScan(
16+
export const paginateScan: (
3117
config: DynamoDBDocumentPaginationConfiguration,
3218
input: ScanCommandInput,
3319
...additionalArguments: any
34-
): Paginator<ScanCommandOutput> {
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: ScanCommandOutput;
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<ScanCommandOutput> = createPaginator<
21+
DynamoDBDocumentPaginationConfiguration,
22+
ScanCommandInput,
23+
ScanCommandOutput
24+
>(DynamoDBDocumentClient, ScanCommand, "ExclusiveStartKey", "LastEvaluatedKey", "Limit");

0 commit comments

Comments
 (0)