@allthings/cloud-toolkit
Version:
Standardizes the setup of aws, datadog and other things
39 lines (38 loc) • 2.04 kB
TypeScript
import { DynamoDBClientConfig, PutRequest, QueryOutput, ScanOutput } from '@aws-sdk/client-dynamodb';
import { DeleteCommandInput, DeleteCommandOutput, GetCommandInput, GetCommandOutput, PutCommandInput, QueryCommandInput, ScanCommandInput, UpdateCommandInput, UpdateCommandOutput } from '@aws-sdk/lib-dynamodb';
import { Logger } from 'winston';
export interface IDynamoDBConfig {
batchWriteMaxRetries?: number;
clientConfig?: DynamoDBClientConfig;
dockerConfig?: {
endpoint: string;
};
logger?: Logger;
queueConfig?: {
queueConcurrency?: number | undefined;
queueDelay?: number | undefined;
};
tableNamePrefix: string;
}
export interface IUnprocessedItems {
UnprocessedItems: Record<string, {
PutRequest: PutRequest;
}[]>;
}
export type TBatchWriteItems = (table: string, items: PutRequest['Item'][]) => Promise<readonly PutRequest['Item'][] | undefined>;
export type TDeleteItem = (table: string, key: string | object, options?: Partial<DeleteCommandInput>) => Promise<DeleteCommandOutput['Attributes'] | undefined>;
export type TGetItem = (table: string, key: string | object, options?: Partial<GetCommandInput>) => Promise<GetCommandOutput['Item'] | undefined>;
export type TPutItem = (table: string, item: PutCommandInput['Item']) => Promise<PutCommandInput['Item'] | undefined>;
export type TQueryTable = (table: string, options?: Partial<QueryCommandInput>) => Promise<QueryOutput | undefined>;
export type TScanTable = (table: string, options?: Partial<ScanCommandInput>) => Promise<ScanOutput | undefined>;
export type TUpdateItem = (table: string, key: string | object, options?: Partial<UpdateCommandInput>) => Promise<UpdateCommandOutput['Attributes'] | undefined>;
declare const dynamodb: (userConfig: IDynamoDBConfig) => {
batchWriteItems: TBatchWriteItems;
deleteItem: TDeleteItem;
getItem: TGetItem;
putItem: TPutItem;
queryTable: TQueryTable;
scanTable: TScanTable;
updateItem: TUpdateItem;
};
export default dynamodb;