Skip to content

Commit

Permalink
chore(lib-dynamodb): codegen sync
Browse files Browse the repository at this point in the history
  • Loading branch information
pasoevi committed Aug 1, 2024
1 parent db8eef8 commit 671f12c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 72 deletions.
43 changes: 7 additions & 36 deletions lib/lib-dynamodb/src/pagination/QueryPaginator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// smithy-typescript generated code
import { createPaginator } from "@smithy/core";
import { Paginator } from "@smithy/types";

import { QueryCommand, QueryCommandInput, QueryCommandOutput } from "../commands/QueryCommand";
Expand All @@ -9,45 +10,15 @@ import { DynamoDBDocumentPaginationConfiguration } from "./Interfaces";
* @public
*/
export { Paginator };
/**
* @internal
*/
const makePagedClientRequest = async (
client: DynamoDBDocumentClient,
input: QueryCommandInput,
...args: any
): Promise<QueryCommandOutput> => {
// @ts-ignore
return await client.send(new QueryCommand(input), ...args);
};
/**
* @public
*
* @param QueryCommandInput - {@link QueryCommandInput}
* @returns {@link QueryCommandOutput}
*
*/
export async function* paginateQuery(
export const paginateQuery: (
config: DynamoDBDocumentPaginationConfiguration,
input: QueryCommandInput,
...additionalArguments: any
): Paginator<QueryCommandOutput> {
// ToDo: replace with actual type instead of typeof input.ExclusiveStartKey
let token: typeof input.ExclusiveStartKey | undefined = config.startingToken || undefined;
let hasNext = true;
let page: QueryCommandOutput;
while (hasNext) {
input.ExclusiveStartKey = token;
input["Limit"] = config.pageSize;
if (config.client instanceof DynamoDBDocumentClient) {
page = await makePagedClientRequest(config.client, input, ...additionalArguments);
} else {
throw new Error("Invalid client, expected DynamoDBDocument | DynamoDBDocumentClient");
}
yield page;
token = page.LastEvaluatedKey;
hasNext = !!token;
}
// @ts-ignore
return undefined;
}
) => Paginator<QueryCommandOutput> = createPaginator<
DynamoDBDocumentPaginationConfiguration,
QueryCommandInput,
QueryCommandOutput
>(DynamoDBDocumentClient, QueryCommand, "ExclusiveStartKey", "LastEvaluatedKey", "Limit");
43 changes: 7 additions & 36 deletions lib/lib-dynamodb/src/pagination/ScanPaginator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// smithy-typescript generated code
import { createPaginator } from "@smithy/core";
import { Paginator } from "@smithy/types";

import { ScanCommand, ScanCommandInput, ScanCommandOutput } from "../commands/ScanCommand";
Expand All @@ -9,45 +10,15 @@ import { DynamoDBDocumentPaginationConfiguration } from "./Interfaces";
* @public
*/
export { Paginator };
/**
* @internal
*/
const makePagedClientRequest = async (
client: DynamoDBDocumentClient,
input: ScanCommandInput,
...args: any
): Promise<ScanCommandOutput> => {
// @ts-ignore
return await client.send(new ScanCommand(input), ...args);
};
/**
* @public
*
* @param ScanCommandInput - {@link ScanCommandInput}
* @returns {@link ScanCommandOutput}
*
*/
export async function* paginateScan(
export const paginateScan: (
config: DynamoDBDocumentPaginationConfiguration,
input: ScanCommandInput,
...additionalArguments: any
): Paginator<ScanCommandOutput> {
// ToDo: replace with actual type instead of typeof input.ExclusiveStartKey
let token: typeof input.ExclusiveStartKey | undefined = config.startingToken || undefined;
let hasNext = true;
let page: ScanCommandOutput;
while (hasNext) {
input.ExclusiveStartKey = token;
input["Limit"] = config.pageSize;
if (config.client instanceof DynamoDBDocumentClient) {
page = await makePagedClientRequest(config.client, input, ...additionalArguments);
} else {
throw new Error("Invalid client, expected DynamoDBDocument | DynamoDBDocumentClient");
}
yield page;
token = page.LastEvaluatedKey;
hasNext = !!token;
}
// @ts-ignore
return undefined;
}
) => Paginator<ScanCommandOutput> = createPaginator<
DynamoDBDocumentPaginationConfiguration,
ScanCommandInput,
ScanCommandOutput
>(DynamoDBDocumentClient, ScanCommand, "ExclusiveStartKey", "LastEvaluatedKey", "Limit");

0 comments on commit 671f12c

Please sign in to comment.