@smithy/core 3.0.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist-cjs/index.js CHANGED
@@ -197,21 +197,30 @@ var normalizeProvider = /* @__PURE__ */ __name((input) => {
197
197
  }, "normalizeProvider");
198
198
 
199
199
  // src/pagination/createPaginator.ts
200
- var makePagedClientRequest = /* @__PURE__ */ __name(async (CommandCtor, client, input, ...args) => {
201
- return await client.send(new CommandCtor(input), ...args);
200
+ var makePagedClientRequest = /* @__PURE__ */ __name(async (CommandCtor, client, input, withCommand = (_) => _, ...args) => {
201
+ let command = new CommandCtor(input);
202
+ command = withCommand(command) ?? command;
203
+ return await client.send(command, ...args);
202
204
  }, "makePagedClientRequest");
203
205
  function createPaginator(ClientCtor, CommandCtor, inputTokenName, outputTokenName, pageSizeTokenName) {
204
206
  return /* @__PURE__ */ __name(async function* paginateOperation(config, input, ...additionalArguments) {
205
- let token = config.startingToken || void 0;
207
+ const _input = input;
208
+ let token = config.startingToken ?? _input[inputTokenName];
206
209
  let hasNext = true;
207
210
  let page;
208
211
  while (hasNext) {
209
- input[inputTokenName] = token;
212
+ _input[inputTokenName] = token;
210
213
  if (pageSizeTokenName) {
211
- input[pageSizeTokenName] = input[pageSizeTokenName] ?? config.pageSize;
214
+ _input[pageSizeTokenName] = _input[pageSizeTokenName] ?? config.pageSize;
212
215
  }
213
216
  if (config.client instanceof ClientCtor) {
214
- page = await makePagedClientRequest(CommandCtor, config.client, input, ...additionalArguments);
217
+ page = await makePagedClientRequest(
218
+ CommandCtor,
219
+ config.client,
220
+ input,
221
+ config.withCommand,
222
+ ...additionalArguments
223
+ );
215
224
  } else {
216
225
  throw new Error(`Invalid client, expected instance of ${ClientCtor.name}`);
217
226
  }
@@ -1,18 +1,21 @@
1
- const makePagedClientRequest = async (CommandCtor, client, input, ...args) => {
2
- return await client.send(new CommandCtor(input), ...args);
1
+ const makePagedClientRequest = async (CommandCtor, client, input, withCommand = (_) => _, ...args) => {
2
+ let command = new CommandCtor(input);
3
+ command = withCommand(command) ?? command;
4
+ return await client.send(command, ...args);
3
5
  };
4
6
  export function createPaginator(ClientCtor, CommandCtor, inputTokenName, outputTokenName, pageSizeTokenName) {
5
7
  return async function* paginateOperation(config, input, ...additionalArguments) {
6
- let token = config.startingToken || undefined;
8
+ const _input = input;
9
+ let token = config.startingToken ?? _input[inputTokenName];
7
10
  let hasNext = true;
8
11
  let page;
9
12
  while (hasNext) {
10
- input[inputTokenName] = token;
13
+ _input[inputTokenName] = token;
11
14
  if (pageSizeTokenName) {
12
- input[pageSizeTokenName] = input[pageSizeTokenName] ?? config.pageSize;
15
+ _input[pageSizeTokenName] = _input[pageSizeTokenName] ?? config.pageSize;
13
16
  }
14
17
  if (config.client instanceof ClientCtor) {
15
- page = await makePagedClientRequest(CommandCtor, config.client, input, ...additionalArguments);
18
+ page = await makePagedClientRequest(CommandCtor, config.client, input, config.withCommand, ...additionalArguments);
16
19
  }
17
20
  else {
18
21
  throw new Error(`Invalid client, expected instance of ${ClientCtor.name}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/core",
3
- "version": "3.0.0",
3
+ "version": "3.1.1",
4
4
  "scripts": {
5
5
  "build": "yarn lint && concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
6
6
  "build:cjs": "node ../../scripts/inline core",
@@ -10,7 +10,7 @@
10
10
  "stage-release": "rimraf ./.release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz",
11
11
  "clean": "rimraf ./dist-* && rimraf *.tsbuildinfo || exit 0",
12
12
  "lint": "npx eslint -c ../../.eslintrc.js \"src/**/*.ts\" --fix && node ./scripts/lint",
13
- "format": "prettier --config ../../prettier.config.js --ignore-path ../.prettierignore --write \"**/*.{ts,md,json}\"",
13
+ "format": "prettier --config ../../prettier.config.js --ignore-path ../../.prettierignore --write \"**/*.{ts,md,json}\"",
14
14
  "test": "yarn g:vitest run",
15
15
  "test:cbor:perf": "node ./scripts/cbor-perf.mjs",
16
16
  "test:watch": "yarn g:vitest watch"
@@ -54,12 +54,12 @@
54
54
  },
55
55
  "license": "Apache-2.0",
56
56
  "dependencies": {
57
- "@smithy/middleware-serde": "^4.0.0",
58
- "@smithy/protocol-http": "^5.0.0",
59
- "@smithy/types": "^4.0.0",
57
+ "@smithy/middleware-serde": "^4.0.1",
58
+ "@smithy/protocol-http": "^5.0.1",
59
+ "@smithy/types": "^4.1.0",
60
60
  "@smithy/util-body-length-browser": "^4.0.0",
61
- "@smithy/util-middleware": "^4.0.0",
62
- "@smithy/util-stream": "^4.0.0",
61
+ "@smithy/util-middleware": "^4.0.1",
62
+ "@smithy/util-stream": "^4.0.2",
63
63
  "@smithy/util-utf8": "^4.0.0",
64
64
  "tslib": "^2.6.2"
65
65
  },