Skip to content

Commit ca5f281

Browse files
Merge pull request #254 from shelfio/feraure/INT-11-fix-types
INT-11 Align types
2 parents 98e8782 + d63dd28 commit ca5f281

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/ddb.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {DescribeTableCommand} from '@aws-sdk/client-dynamodb';
22
import {BatchWriteCommand, ScanCommand} from '@aws-sdk/lib-dynamodb';
3+
import type {DynamoDBDocument} from '@aws-sdk/lib-dynamodb';
34
import type {DynamoDBClient} from '@aws-sdk/client-dynamodb';
45
import type {DynamoDBDocumentClient} from '@aws-sdk/lib-dynamodb';
56
import type {
@@ -15,7 +16,10 @@ export type Credentials = {
1516
sessionToken: string;
1617
};
1718

18-
export function scan(params: ScanCommandInput, client: DynamoDBClient): Promise<ScanCommandOutput> {
19+
export function scan(
20+
params: ScanCommandInput,
21+
client: DynamoDBClient | DynamoDBDocument
22+
): Promise<ScanCommandOutput> {
1923
const command = new ScanCommand(params);
2024

2125
// @ts-ignore
@@ -24,9 +28,10 @@ export function scan(params: ScanCommandInput, client: DynamoDBClient): Promise<
2428

2529
export async function getTableItemsCount(
2630
tableName: string,
27-
client: DynamoDBClient
31+
client: DynamoDBClient | DynamoDBDocument
2832
): Promise<number> {
2933
const command = new DescribeTableCommand({TableName: tableName});
34+
// @ts-ignore
3035
const resp = await client.send(command);
3136

3237
return resp.Table!.ItemCount!;

src/parallel-scan-stream.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import cloneDeep from 'lodash.clonedeep';
33
import times from 'lodash.times';
44
import chunk from 'lodash.chunk';
55
import getDebugger from 'debug';
6-
import type {ScanCommandInput} from '@aws-sdk/lib-dynamodb';
6+
import type {DynamoDBDocument, ScanCommandInput} from '@aws-sdk/lib-dynamodb';
77
import type {ScanCommandOutput} from '@aws-sdk/lib-dynamodb';
88
import type {DynamoDBClient} from '@aws-sdk/client-dynamodb';
99
import type {Credentials} from './ddb';
@@ -30,7 +30,7 @@ export async function parallelScanAsStream(
3030
chunkSize: number;
3131
highWaterMark?: number;
3232
credentials?: Credentials;
33-
client?: DynamoDBClient;
33+
client?: DynamoDBClient | DynamoDBDocument;
3434
}
3535
): Promise<Readable> {
3636
const ddbClient = client ?? ddbv3Client(credentials);
@@ -91,7 +91,7 @@ async function getItemsFromSegment({
9191
segmentIndex: number;
9292
chunkSize: number;
9393
blocker: Blocker;
94-
client: DynamoDBClient;
94+
client: DynamoDBClient | DynamoDBDocument;
9595
}): Promise<void> {
9696
let segmentItems: ScanCommandOutput['Items'] = [];
9797
let ExclusiveStartKey: ScanCommandInput['ExclusiveStartKey'];

src/parallel-scan.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import getDebugger from 'debug';
44
import type {ScanCommandInput, ScanCommandOutput} from '@aws-sdk/lib-dynamodb';
55
import type {Credentials} from './ddb';
66
import type {DynamoDBClient} from '@aws-sdk/client-dynamodb';
7+
import type {DynamoDBDocument} from '@aws-sdk/lib-dynamodb';
78
import {getTableItemsCount, scan} from './ddb';
89
import {ddbv3Client} from './clients';
910

@@ -19,7 +20,7 @@ export async function parallelScan(
1920
concurrency,
2021
credentials,
2122
client,
22-
}: {concurrency: number; credentials?: Credentials; client?: DynamoDBClient}
23+
}: {concurrency: number; credentials?: Credentials; client?: DynamoDBClient | DynamoDBDocument}
2324
): Promise<ScanCommandOutput['Items']> {
2425
const ddbClient = client ?? ddbv3Client(credentials);
2526
totalTableItemsCount = await getTableItemsCount(scanParams.TableName!, ddbClient);
@@ -55,7 +56,7 @@ async function getItemsFromSegment(
5556
concurrency,
5657
segmentIndex,
5758
client,
58-
}: {concurrency: number; segmentIndex: number; client: DynamoDBClient}
59+
}: {concurrency: number; segmentIndex: number; client: DynamoDBClient | DynamoDBDocument}
5960
): Promise<ScanCommandOutput['Items']> {
6061
const segmentItems: ScanCommandOutput['Items'] = [];
6162
let ExclusiveStartKey: ScanCommandInput['ExclusiveStartKey'];

0 commit comments

Comments
 (0)