@aws-sdk/lib-dynamodb 3.42.0 → 3.43.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.43.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.42.0...v3.43.0) (2021-11-29)
7
+
8
+
9
+ ### Features
10
+
11
+ * **lib-dynamodb:** add pagination ([#3069](https://github.com/aws/aws-sdk-js-v3/issues/3069)) ([51480df](https://github.com/aws/aws-sdk-js-v3/commit/51480df99b38d0f4893f4c6cd7020b9a6135eee9))
12
+
13
+
14
+
15
+
16
+
6
17
  # [3.42.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.41.0...v3.42.0) (2021-11-19)
7
18
 
8
19
  **Note:** Version bump only for package @aws-sdk/lib-dynamodb
package/dist-cjs/index.js CHANGED
@@ -4,3 +4,4 @@ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./DynamoDBDocument"), exports);
5
5
  tslib_1.__exportStar(require("./DynamoDBDocumentClient"), exports);
6
6
  tslib_1.__exportStar(require("./commands"), exports);
7
+ tslib_1.__exportStar(require("./pagination"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.paginateQuery = void 0;
4
+ const QueryCommand_1 = require("../commands/QueryCommand");
5
+ const DynamoDBDocument_1 = require("../DynamoDBDocument");
6
+ const DynamoDBDocumentClient_1 = require("../DynamoDBDocumentClient");
7
+ const makePagedClientRequest = async (client, input, ...args) => {
8
+ return await client.send(new QueryCommand_1.QueryCommand(input), ...args);
9
+ };
10
+ const makePagedRequest = async (client, input, ...args) => {
11
+ return await client.query(input, ...args);
12
+ };
13
+ async function* paginateQuery(config, input, ...additionalArguments) {
14
+ let token = config.startingToken || undefined;
15
+ let hasNext = true;
16
+ let page;
17
+ while (hasNext) {
18
+ input.ExclusiveStartKey = token;
19
+ input["Limit"] = config.pageSize;
20
+ if (config.client instanceof DynamoDBDocument_1.DynamoDBDocument) {
21
+ page = await makePagedRequest(config.client, input, ...additionalArguments);
22
+ }
23
+ else if (config.client instanceof DynamoDBDocumentClient_1.DynamoDBDocumentClient) {
24
+ page = await makePagedClientRequest(config.client, input, ...additionalArguments);
25
+ }
26
+ else {
27
+ throw new Error("Invalid client, expected DynamoDBDocument | DynamoDBDocumentClient");
28
+ }
29
+ yield page;
30
+ token = page.LastEvaluatedKey;
31
+ hasNext = !!token;
32
+ }
33
+ return undefined;
34
+ }
35
+ exports.paginateQuery = paginateQuery;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.paginateScan = void 0;
4
+ const ScanCommand_1 = require("../commands/ScanCommand");
5
+ const DynamoDBDocument_1 = require("../DynamoDBDocument");
6
+ const DynamoDBDocumentClient_1 = require("../DynamoDBDocumentClient");
7
+ const makePagedClientRequest = async (client, input, ...args) => {
8
+ return await client.send(new ScanCommand_1.ScanCommand(input), ...args);
9
+ };
10
+ const makePagedRequest = async (client, input, ...args) => {
11
+ return await client.scan(input, ...args);
12
+ };
13
+ async function* paginateScan(config, input, ...additionalArguments) {
14
+ let token = config.startingToken || undefined;
15
+ let hasNext = true;
16
+ let page;
17
+ while (hasNext) {
18
+ input.ExclusiveStartKey = token;
19
+ input["Limit"] = config.pageSize;
20
+ if (config.client instanceof DynamoDBDocument_1.DynamoDBDocument) {
21
+ page = await makePagedRequest(config.client, input, ...additionalArguments);
22
+ }
23
+ else if (config.client instanceof DynamoDBDocumentClient_1.DynamoDBDocumentClient) {
24
+ page = await makePagedClientRequest(config.client, input, ...additionalArguments);
25
+ }
26
+ else {
27
+ throw new Error("Invalid client, expected DynamoDBDocument | DynamoDBDocumentClient");
28
+ }
29
+ yield page;
30
+ token = page.LastEvaluatedKey;
31
+ hasNext = !!token;
32
+ }
33
+ return undefined;
34
+ }
35
+ exports.paginateScan = paginateScan;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./Interfaces"), exports);
5
+ tslib_1.__exportStar(require("./QueryPaginator"), exports);
6
+ tslib_1.__exportStar(require("./ScanPaginator"), exports);
package/dist-es/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./DynamoDBDocument";
2
2
  export * from "./DynamoDBDocumentClient";
3
3
  export * from "./commands";
4
+ export * from "./pagination";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,74 @@
1
+ import { __asyncGenerator, __await, __awaiter, __generator, __read, __spreadArray } from "tslib";
2
+ import { QueryCommand } from "../commands/QueryCommand";
3
+ import { DynamoDBDocument } from "../DynamoDBDocument";
4
+ import { DynamoDBDocumentClient } from "../DynamoDBDocumentClient";
5
+ var makePagedClientRequest = function (client, input) {
6
+ var args = [];
7
+ for (var _i = 2; _i < arguments.length; _i++) {
8
+ args[_i - 2] = arguments[_i];
9
+ }
10
+ return __awaiter(void 0, void 0, void 0, function () {
11
+ return __generator(this, function (_a) {
12
+ switch (_a.label) {
13
+ case 0: return [4, client.send.apply(client, __spreadArray([new QueryCommand(input)], __read(args)))];
14
+ case 1: return [2, _a.sent()];
15
+ }
16
+ });
17
+ });
18
+ };
19
+ var makePagedRequest = function (client, input) {
20
+ var args = [];
21
+ for (var _i = 2; _i < arguments.length; _i++) {
22
+ args[_i - 2] = arguments[_i];
23
+ }
24
+ return __awaiter(void 0, void 0, void 0, function () {
25
+ return __generator(this, function (_a) {
26
+ switch (_a.label) {
27
+ case 0: return [4, client.query.apply(client, __spreadArray([input], __read(args)))];
28
+ case 1: return [2, _a.sent()];
29
+ }
30
+ });
31
+ });
32
+ };
33
+ export function paginateQuery(config, input) {
34
+ var additionalArguments = [];
35
+ for (var _i = 2; _i < arguments.length; _i++) {
36
+ additionalArguments[_i - 2] = arguments[_i];
37
+ }
38
+ return __asyncGenerator(this, arguments, function paginateQuery_1() {
39
+ var token, hasNext, page;
40
+ return __generator(this, function (_a) {
41
+ switch (_a.label) {
42
+ case 0:
43
+ token = config.startingToken || undefined;
44
+ hasNext = true;
45
+ _a.label = 1;
46
+ case 1:
47
+ if (!hasNext) return [3, 9];
48
+ input.ExclusiveStartKey = token;
49
+ input["Limit"] = config.pageSize;
50
+ if (!(config.client instanceof DynamoDBDocument)) return [3, 3];
51
+ return [4, __await(makePagedRequest.apply(void 0, __spreadArray([config.client, input], __read(additionalArguments))))];
52
+ case 2:
53
+ page = _a.sent();
54
+ return [3, 6];
55
+ case 3:
56
+ if (!(config.client instanceof DynamoDBDocumentClient)) return [3, 5];
57
+ return [4, __await(makePagedClientRequest.apply(void 0, __spreadArray([config.client, input], __read(additionalArguments))))];
58
+ case 4:
59
+ page = _a.sent();
60
+ return [3, 6];
61
+ case 5: throw new Error("Invalid client, expected DynamoDBDocument | DynamoDBDocumentClient");
62
+ case 6: return [4, __await(page)];
63
+ case 7: return [4, _a.sent()];
64
+ case 8:
65
+ _a.sent();
66
+ token = page.LastEvaluatedKey;
67
+ hasNext = !!token;
68
+ return [3, 1];
69
+ case 9: return [4, __await(undefined)];
70
+ case 10: return [2, _a.sent()];
71
+ }
72
+ });
73
+ });
74
+ }
@@ -0,0 +1,74 @@
1
+ import { __asyncGenerator, __await, __awaiter, __generator, __read, __spreadArray } from "tslib";
2
+ import { ScanCommand } from "../commands/ScanCommand";
3
+ import { DynamoDBDocument } from "../DynamoDBDocument";
4
+ import { DynamoDBDocumentClient } from "../DynamoDBDocumentClient";
5
+ var makePagedClientRequest = function (client, input) {
6
+ var args = [];
7
+ for (var _i = 2; _i < arguments.length; _i++) {
8
+ args[_i - 2] = arguments[_i];
9
+ }
10
+ return __awaiter(void 0, void 0, void 0, function () {
11
+ return __generator(this, function (_a) {
12
+ switch (_a.label) {
13
+ case 0: return [4, client.send.apply(client, __spreadArray([new ScanCommand(input)], __read(args)))];
14
+ case 1: return [2, _a.sent()];
15
+ }
16
+ });
17
+ });
18
+ };
19
+ var makePagedRequest = function (client, input) {
20
+ var args = [];
21
+ for (var _i = 2; _i < arguments.length; _i++) {
22
+ args[_i - 2] = arguments[_i];
23
+ }
24
+ return __awaiter(void 0, void 0, void 0, function () {
25
+ return __generator(this, function (_a) {
26
+ switch (_a.label) {
27
+ case 0: return [4, client.scan.apply(client, __spreadArray([input], __read(args)))];
28
+ case 1: return [2, _a.sent()];
29
+ }
30
+ });
31
+ });
32
+ };
33
+ export function paginateScan(config, input) {
34
+ var additionalArguments = [];
35
+ for (var _i = 2; _i < arguments.length; _i++) {
36
+ additionalArguments[_i - 2] = arguments[_i];
37
+ }
38
+ return __asyncGenerator(this, arguments, function paginateScan_1() {
39
+ var token, hasNext, page;
40
+ return __generator(this, function (_a) {
41
+ switch (_a.label) {
42
+ case 0:
43
+ token = config.startingToken || undefined;
44
+ hasNext = true;
45
+ _a.label = 1;
46
+ case 1:
47
+ if (!hasNext) return [3, 9];
48
+ input.ExclusiveStartKey = token;
49
+ input["Limit"] = config.pageSize;
50
+ if (!(config.client instanceof DynamoDBDocument)) return [3, 3];
51
+ return [4, __await(makePagedRequest.apply(void 0, __spreadArray([config.client, input], __read(additionalArguments))))];
52
+ case 2:
53
+ page = _a.sent();
54
+ return [3, 6];
55
+ case 3:
56
+ if (!(config.client instanceof DynamoDBDocumentClient)) return [3, 5];
57
+ return [4, __await(makePagedClientRequest.apply(void 0, __spreadArray([config.client, input], __read(additionalArguments))))];
58
+ case 4:
59
+ page = _a.sent();
60
+ return [3, 6];
61
+ case 5: throw new Error("Invalid client, expected DynamoDBDocument | DynamoDBDocumentClient");
62
+ case 6: return [4, __await(page)];
63
+ case 7: return [4, _a.sent()];
64
+ case 8:
65
+ _a.sent();
66
+ token = page.LastEvaluatedKey;
67
+ hasNext = !!token;
68
+ return [3, 1];
69
+ case 9: return [4, __await(undefined)];
70
+ case 10: return [2, _a.sent()];
71
+ }
72
+ });
73
+ });
74
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./Interfaces";
2
+ export * from "./QueryPaginator";
3
+ export * from "./ScanPaginator";
@@ -1,3 +1,4 @@
1
1
  export * from "./DynamoDBDocument";
2
2
  export * from "./DynamoDBDocumentClient";
3
3
  export * from "./commands";
4
+ export * from "./pagination";
@@ -0,0 +1,6 @@
1
+ import { PaginationConfiguration } from "@aws-sdk/types";
2
+ import { DynamoDBDocument } from "../DynamoDBDocument";
3
+ import { DynamoDBDocumentClient } from "../DynamoDBDocumentClient";
4
+ export interface DynamoDBDocumentPaginationConfiguration extends PaginationConfiguration {
5
+ client: DynamoDBDocument | DynamoDBDocumentClient;
6
+ }
@@ -0,0 +1,4 @@
1
+ import { Paginator } from "@aws-sdk/types";
2
+ import { QueryCommandInput, QueryCommandOutput } from "../commands/QueryCommand";
3
+ import { DynamoDBDocumentPaginationConfiguration } from "./Interfaces";
4
+ export declare function paginateQuery(config: DynamoDBDocumentPaginationConfiguration, input: QueryCommandInput, ...additionalArguments: any): Paginator<QueryCommandOutput>;
@@ -0,0 +1,4 @@
1
+ import { Paginator } from "@aws-sdk/types";
2
+ import { ScanCommandInput, ScanCommandOutput } from "../commands/ScanCommand";
3
+ import { DynamoDBDocumentPaginationConfiguration } from "./Interfaces";
4
+ export declare function paginateScan(config: DynamoDBDocumentPaginationConfiguration, input: ScanCommandInput, ...additionalArguments: any): Paginator<ScanCommandOutput>;
@@ -0,0 +1,3 @@
1
+ export * from "./Interfaces";
2
+ export * from "./QueryPaginator";
3
+ export * from "./ScanPaginator";
@@ -1,3 +1,4 @@
1
1
  export * from "./DynamoDBDocument";
2
2
  export * from "./DynamoDBDocumentClient";
3
3
  export * from "./commands";
4
+ export * from "./pagination";
@@ -0,0 +1,6 @@
1
+ import { PaginationConfiguration } from "@aws-sdk/types";
2
+ import { DynamoDBDocument } from "../DynamoDBDocument";
3
+ import { DynamoDBDocumentClient } from "../DynamoDBDocumentClient";
4
+ export interface DynamoDBDocumentPaginationConfiguration extends PaginationConfiguration {
5
+ client: DynamoDBDocument | DynamoDBDocumentClient;
6
+ }
@@ -0,0 +1,4 @@
1
+ import { Paginator } from "@aws-sdk/types";
2
+ import { QueryCommandInput, QueryCommandOutput } from "../commands/QueryCommand";
3
+ import { DynamoDBDocumentPaginationConfiguration } from "./Interfaces";
4
+ export declare function paginateQuery(config: DynamoDBDocumentPaginationConfiguration, input: QueryCommandInput, ...additionalArguments: any): Paginator<QueryCommandOutput>;
@@ -0,0 +1,4 @@
1
+ import { Paginator } from "@aws-sdk/types";
2
+ import { ScanCommandInput, ScanCommandOutput } from "../commands/ScanCommand";
3
+ import { DynamoDBDocumentPaginationConfiguration } from "./Interfaces";
4
+ export declare function paginateScan(config: DynamoDBDocumentPaginationConfiguration, input: ScanCommandInput, ...additionalArguments: any): Paginator<ScanCommandOutput>;
@@ -0,0 +1,3 @@
1
+ export * from "./Interfaces";
2
+ export * from "./QueryPaginator";
3
+ export * from "./ScanPaginator";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/lib-dynamodb",
3
- "version": "3.42.0",
3
+ "version": "3.43.0",
4
4
  "description": "The document client simplifies working with items in Amazon DynamoDB by abstracting away the notion of attribute values.",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "license": "Apache-2.0",
24
24
  "dependencies": {
25
- "@aws-sdk/util-dynamodb": "3.42.0",
25
+ "@aws-sdk/util-dynamodb": "3.43.0",
26
26
  "tslib": "^2.3.0"
27
27
  },
28
28
  "peerDependencies": {
@@ -31,7 +31,7 @@
31
31
  "@aws-sdk/types": "^3.0.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@aws-sdk/client-dynamodb": "3.42.0",
34
+ "@aws-sdk/client-dynamodb": "3.43.0",
35
35
  "@aws-sdk/smithy-client": "3.41.0",
36
36
  "@aws-sdk/types": "3.40.0",
37
37
  "@types/jest": "^26.0.4",