import { DynamoDB } from 'aws-sdk' ; import { batchGet , BatchGetResult , buildBatchGetInput } from '../../../database-operations/batch-get' ; import { EntitySchema } from '../../../schema' ; import { Chaining , Filter , Paginate , WithAttributes } from '../../common' ; import { BatchGetChainingKind } from './' ; import { BatchGet } from './batch-get' ; function extractFromStack < KeySchema > ( stack ) { const batchGetMetadata = ( stack [ 0 ] as any ) . _batchGet ; let withAttributes ; for ( const current of stack ) { switch ( ( current as any ) . _kind ) { case 'withAttributes' : withAttributes = ( current as any ) . _withAttributes ; } } return { batchGetMetadata , withAttributes } ; } export function execute < Entity , KeySchema > ( stack ) { const { batchGetMetadata , withAttributes } = extractFromStack < KeySchema > ( stack ) ; const batchGetInput = buildBatchGetInput ( batchGetMetadata , withAttributes ) ; return batchGet < Entity , KeySchema > ( batchGetMetadata . schema . tableName , batchGetInput , batchGetMetadata . schema . dynamoPromise ) ; }