import DeleteItemParams from '../../../interfaces/deleteItemParams'; import GetItemParams from '../../../interfaces/getItemParams'; import PaginatedJsonResponse from '../../../interfaces/paginatedJsonResponse'; import QueryParams from '../../../interfaces/queryParams'; import JSONValue from '../../../types/json'; import BatchEdit from './batchEdit'; import Deleter from './deleter'; import Getter from './getter'; import { UpdateParams } from './interfaces/updateParams'; import { UpdateUnmarshalledOutput } from './interfaces/updateUnmarshalledOutput'; import Query from './query'; import Scanner from './scanner'; import TransactEdit from './transactEdit'; import Updater from './updater'; export default class DynamoDBService { private _awsRegion; private _tableName; constructor(constants: { region: string; table: string; }); /** * Creates a Scanner to do scan operations on a Dynamo DB table. * * @param params - optional object of optional properties to generate a scan request * @returns A Scanner * * @example Only use this method to set up the Scanner in an external file * ```ts * const scanner = dynamoDBService.scan({index: 'some-index'}); * const dataFromScanOnIndex = await scanner.execute(); * ``` * * @example Use this method to set up the Scanner and then manually edit params with scanner methods * ```ts * const scanner = dynamoDBService.scan().index({index: 'some-index'}); * const dataFromScanOnIndex = await scanner.execute(); * ``` */ scan(params?: { index?: string; start?: { [key: string]: unknown; }; filter?: string; strong?: boolean; names?: { [key: string]: string; }; values?: { [key: string]: unknown; }; projection?: string | string[]; select?: 'ALL_ATTRIBUTES' | 'ALL_PROJECTED_ATTRIBUTES' | 'SPECIFIC_ATTRIBUTES' | 'COUNT'; limit?: number; segment?: number; totalSegment?: number; capacity?: 'INDEXES' | 'TOTAL' | 'NONE'; }): Scanner; /** * Gets a single item from the DynamoDB table. * * @param params - {@link GetItemParams} object of properties to generate a get item request * @returns Promise of a string, {@link JSONValue} paired object * * @example Use this to get a single item from the DynamoDb table. * ```ts * const result = dynamoDBService.getItem({key: 'pk'}); * ``` */ getItem(params: GetItemParams): Promise>; /** * Creates a Getter to do single get item or batch get item operations on a DynamoDB table. * * @param key - single object of key to get for single get item or list of objects of keys to get for batch get item * @param params - optional object of optional properties to generate a get item request * @returns A Getter * * @example Only use this method to set up the Getter in an external file * ```ts * const getter = dynamoDBService.get({'pk': {S: 'pk'}, 'sk': {S: 'sk'}}, {projection: 'valueIWant'}); * const dataFromGetValueIWant = await getter.execute(); * ``` * * @example Use this method to set up the Getter and then manually edit params with getter methods * ```ts * const getter = dynamoDBService.get({'pk': {S: 'pk'}, 'sk': {S: 'sk'}}); * const dataFromGetValueIWant = await getter.projection({projection: 'valueIWant'}).execute(); * ``` */ get(key: { [key: string]: unknown; } | { [key: string]: unknown; }[], params?: { strong?: boolean; names?: { [key: string]: string; }; projection?: string | string[]; capacity?: 'INDEXES' | 'TOTAL' | 'NONE'; }): Getter; /** * retrieves items from DynamoDB table. * * @param keys - array of keys to retrieve * @param params - optional object of optional properties to generate a get item request * @returns Promise\\> * * @example Use this method to retrieve an item from ddb by Id * ```ts * const item = await dynamoDBService.getItems([{'pk': 'pk', 'sk': 'sk'}, {'pk': 'pk2', 'sk': 'sk2'}], {projection: 'valueIWant'}); * ``` */ getItems(keys: Record[], params?: { strong?: boolean; names?: { [key: string]: string; }; projection?: string | string[]; capacity?: 'INDEXES' | 'TOTAL' | 'NONE'; }): Promise[]>; /** * Queries the DynamoDB table. * * @param params - optional object of optional properties to generate a query request * @returns Promise * * @example Use this to get paginated items from the DynamoDb table. * ```ts * const result = dynamoDBService.getPaginatedItems({sortKey: 'value', eq: {N: '5'}}); * ``` */ getPaginatedItems(params?: QueryParams): Promise; /** * Creates a Query to do query operations on a DynamoDB table. * * @param params - optional object of optional properties to generate a query request * @returns A Query * * @example Only use this method to set up the Query in an external file * ```ts * const query = dynamoDBService.query({sortKey: 'value', eq: {N: '5'}}); * const queryValueEq5 = await query.execute(); * ``` * * @example Use this method to set up the Query and then manually edit params with query methods * ```ts * const query = dynamoDBService.query(); * const queryValueEq5 = await query.sortKey('value').eq({N: '5'}).execute(); * ``` */ query(params?: QueryParams): Query; /** * Places a DDB Update call and formats the response. * * @param updateParams - {@link UpdateParams} object to pass to the update request * @returns a {@link UpdateUnmarshalledOutput} item where Attributes is unmarshalled */ updateExecuteAndFormat(updateParams: UpdateParams): Promise; /** * Creates an Updater to do update item operations on a DynamoDB table. * * @param key - object of key to update * @param params - optional object of optional properties to generate an update request * @returns A Updater * * @example Only use this method to set up the Updater in an external file * ```ts * const updater = dynamoDBService.update({'pk': {S: 'pk'}, 'sk': {S: 'sk}}, {item: {'newAttribute': {S: 'newValue'}}}); * const dataFromUpdate = await updater.execute(); * ``` * * @example Use this method to set up the Updater and then manually edit params with updater methods * ```ts * const updater = dynamoDBService.update({'pk': {S: 'pk'}, 'sk': {S: 'sk}}); * const dataFromUpdate = await updater.item({'newAttribute': {S: 'newValue'}}).execute(); * ``` */ update(updateParams: UpdateParams): Updater; /** * Deletes a single item from the DynamoDB table. * * @param params - {@link DeleteItemParams} object of properties to generate a delete item request * @returns Promise of a string, {@link JSONValue} paired object * * @example Use this to delete a single item from the DynamoDb table. * ```ts * const result = dynamoDBService.deleteItem({key: 'pk'}); * ``` */ deleteItem(params: DeleteItemParams): Promise>; /** * Creates a Deleter to do single delete item operations on a DynamoDB table. * * @param key - object of key to delete * @param params - optional object of optional properties to generate a delete request * @returns A Deleter * * @example Only use this method to set up the Deleter in an external file * ```ts * const deleter = dynamoDBService.delete({'pk': {S: 'pk'}, 'sk': {S: 'sk}}, {condition: 'attribute_not_exists(DONOTDELETE)'}); * const dataFromCondDelete = await deleter.execute(); * ``` * * @example Use this method to set up the Deleter and then manually edit params with deleter methods * ```ts * const deleter = dynamoDBService.delete({'pk': {S: 'pk'}, 'sk': {S: 'sk}}); * const dataFromCondDelete = await deleter.condition('attribute_not_exists(DONOTDELETE)').execute(); * ``` */ delete(key: { [key: string]: unknown; }, params?: { condition?: string; names?: { [key: string]: string; }; values?: { [key: string]: unknown; }; return?: 'NONE' | 'ALL_OLD'; capacity?: 'INDEXES' | 'TOTAL' | 'NONE'; metrics?: 'NONE' | 'SIZE'; }): Deleter; /** * Creates a BatchEdit to do batch write or delete operations on a DynamoDB table. * * @param params - optional object of optional properties to generate a batch edit request * @returns A BatchEdit * * @example Only use this method to set up the BatchEdit in an external file * ```ts * const batchEdit = dynamoDBService.batchEdit({addDeleteRequest: {'pk': {S: 'pk'}, 'sk': {S: 'sk'}}}); * const dataFromBatchEditSingleDelete = await batchEdit.execute(); * ``` * * @example Use this method to set up the BatchEdit and then manually edit params with batch edit methods * ```ts * const batchEdit = dynamoDBService.batchEdit(); * const dataFromBatchEditSingleDelete = await batchEdit.addDeleteRequest({'pk': {S: 'pk'}, 'sk': {S: 'sk'}}).execute(); * ``` */ batchEdit(params?: { addDeleteRequest?: { [key: string]: unknown; }; addWriteRequest?: { [key: string]: unknown; }; addDeleteRequests?: { [key: string]: unknown; }[]; addWriteRequests?: { [key: string]: unknown; }[]; }): BatchEdit; /** * Commits transactions to the table * * @param params - the items for the transaction */ commitTransaction(params?: { addPutRequests?: { item: Record>; conditionExpression?: string; expressionAttributeNames?: Record; expressionAttributeValues?: Record>; }[]; addPutItems?: Record>[]; addDeleteRequests?: Record>[]; }): Promise; /** * @deprecated Use `commitTransaction` instead * @param params - the items for the transaction * @returns A TransactEdit object */ transactEdit(params?: { addPutRequests?: { item: Record>; conditionExpression?: string; expressionAttributeNames?: Record; expressionAttributeValues?: Record>; }[]; addPutItems?: Record>[]; addDeleteRequests?: Record>[]; }): TransactEdit; /** * @returns the table name */ getTableName(): string; } //# sourceMappingURL=dynamoDBService.d.ts.map