@smithy/core
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -200,17 +200,26 @@ var __defProp = Object.defineProperty; | ||
// src/pagination/createPaginator.ts | ||
var makePagedClientRequest = /* @__PURE__ */ __name(async (CommandCtor, client, input, ...args) => { | ||
return await client.send(new CommandCtor(input), ...args); | ||
var makePagedClientRequest = /* @__PURE__ */ __name(async (CommandCtor, client, input, withCommand = (_) => _, ...args) => { | ||
let command = new CommandCtor(input); | ||
command = withCommand(command) ?? command; | ||
return await client.send(command, ...args); | ||
}, "makePagedClientRequest"); | ||
function createPaginator(ClientCtor, CommandCtor, inputTokenName, outputTokenName, pageSizeTokenName) { | ||
return /* @__PURE__ */ __name(async function* paginateOperation(config, input, ...additionalArguments) { | ||
let token = config.startingToken || void 0; | ||
const _input = input; | ||
let token = config.startingToken ?? _input[inputTokenName]; | ||
let hasNext = true; | ||
let page; | ||
while (hasNext) { | ||
input[inputTokenName] = token; | ||
_input[inputTokenName] = token; | ||
if (pageSizeTokenName) { | ||
input[pageSizeTokenName] = input[pageSizeTokenName] ?? config.pageSize; | ||
_input[pageSizeTokenName] = _input[pageSizeTokenName] ?? config.pageSize; | ||
} | ||
if (config.client instanceof ClientCtor) { | ||
page = await makePagedClientRequest(CommandCtor, config.client, input, ...additionalArguments); | ||
page = await makePagedClientRequest( | ||
CommandCtor, | ||
config.client, | ||
input, | ||
config.withCommand, | ||
...additionalArguments | ||
); | ||
} else { | ||
@@ -217,0 +226,0 @@ throw new Error(`Invalid client, expected instance of ${ClientCtor.name}`); |
@@ -1,16 +0,19 @@ | ||
const makePagedClientRequest = async (CommandCtor, client, input, ...args) => { | ||
return await client.send(new CommandCtor(input), ...args); | ||
const makePagedClientRequest = async (CommandCtor, client, input, withCommand = (_) => _, ...args) => { | ||
let command = new CommandCtor(input); | ||
command = withCommand(command) ?? command; | ||
return await client.send(command, ...args); | ||
}; | ||
export function createPaginator(ClientCtor, CommandCtor, inputTokenName, outputTokenName, pageSizeTokenName) { | ||
return async function* paginateOperation(config, input, ...additionalArguments) { | ||
let token = config.startingToken || undefined; | ||
const _input = input; | ||
let token = config.startingToken ?? _input[inputTokenName]; | ||
let hasNext = true; | ||
let page; | ||
while (hasNext) { | ||
input[inputTokenName] = token; | ||
_input[inputTokenName] = token; | ||
if (pageSizeTokenName) { | ||
input[pageSizeTokenName] = input[pageSizeTokenName] ?? config.pageSize; | ||
_input[pageSizeTokenName] = _input[pageSizeTokenName] ?? config.pageSize; | ||
} | ||
if (config.client instanceof ClientCtor) { | ||
page = await makePagedClientRequest(CommandCtor, config.client, input, ...additionalArguments); | ||
page = await makePagedClientRequest(CommandCtor, config.client, input, config.withCommand, ...additionalArguments); | ||
} | ||
@@ -17,0 +20,0 @@ else { |
{ | ||
"name": "@smithy/core", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"scripts": { | ||
@@ -57,8 +57,8 @@ "build": "yarn lint && concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'", | ||
"dependencies": { | ||
"@smithy/middleware-serde": "^4.0.0", | ||
"@smithy/protocol-http": "^5.0.0", | ||
"@smithy/types": "^4.0.0", | ||
"@smithy/middleware-serde": "^4.0.1", | ||
"@smithy/protocol-http": "^5.0.1", | ||
"@smithy/types": "^4.1.0", | ||
"@smithy/util-body-length-browser": "^4.0.0", | ||
"@smithy/util-middleware": "^4.0.0", | ||
"@smithy/util-stream": "^4.0.0", | ||
"@smithy/util-middleware": "^4.0.1", | ||
"@smithy/util-stream": "^4.0.1", | ||
"@smithy/util-utf8": "^4.0.0", | ||
@@ -65,0 +65,0 @@ "tslib": "^2.6.2" |
137961
3318
Updated@smithy/protocol-http@^5.0.1
Updated@smithy/types@^4.1.0
Updated@smithy/util-stream@^4.0.1