UNPKG

@softchef/cdk-iot-device-management

Version:

IoT device management is composed of things, thing types, thing groups, jobs, files API services. The constructs can be used independently, that are based on full-managed service to create an API Gateway & Lambda function.

36 lines (35 loc) 1.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.paginateQuery = void 0; const QueryCommand_1 = require("../commands/QueryCommand"); const DynamoDB_1 = require("../DynamoDB"); const DynamoDBClient_1 = require("../DynamoDBClient"); const makePagedClientRequest = async (client, input, ...args) => { return await client.send(new QueryCommand_1.QueryCommand(input), ...args); }; const makePagedRequest = async (client, input, ...args) => { return await client.query(input, ...args); }; async function* paginateQuery(config, input, ...additionalArguments) { let token = config.startingToken || undefined; let hasNext = true; let page; while (hasNext) { input.ExclusiveStartKey = token; input["Limit"] = config.pageSize; if (config.client instanceof DynamoDB_1.DynamoDB) { page = await makePagedRequest(config.client, input, ...additionalArguments); } else if (config.client instanceof DynamoDBClient_1.DynamoDBClient) { page = await makePagedClientRequest(config.client, input, ...additionalArguments); } else { throw new Error("Invalid client, expected DynamoDB | DynamoDBClient"); } yield page; token = page.LastEvaluatedKey; hasNext = !!token; } return undefined; } exports.paginateQuery = paginateQuery;