All files / src/transactions/schema tableSchema.ts

100% Statements 6/6
100% Branches 0/0
100% Functions 2/2
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 4710x             10x                                                               10x   3x   10x   7x  
import {
  marshallItem,
  unmarshallItem,
  Schema,
} from '@aws/dynamodb-data-marshaller';
import { AttributeMap } from 'aws-sdk/clients/dynamodb';
 
const transactionTableSchema: Schema = {
  id: { type: 'String' },
  type: { type: 'String' },
  transactionUuid: { type: 'String' },
  entityUuid: { type: 'String' },
  siteUuid: { type: 'String' },
  timestamp: { type: 'String' },
  amount: { type: 'Number' },
  saleAmount: { type: 'Number' },
  taxAmounts: {
    type: 'List',
    memberType: {
      type: 'Document',
      members: { name: { type: 'String' }, amount: { type: 'Number' } },
    },
  },
  scheme: { type: 'String' },
  transactionType: { type: 'String' },
  status: { type: 'String' },
  maskedPan: { type: 'String' },
  reference: { type: 'String' },
  deviceName: { type: 'String' },
  siteName: { type: 'String' },
  tipAmount: { type: 'Number' },
  feeAmount: { type: 'Number' },
  surchargeAmount: { type: 'Number' },
  depositUuid: { type: 'String' },
  depositDate: { type: 'String' },
  panToken: { type: 'String' },
  par: { type: 'String' },
};
 
export const marshallTransaction = (data: {
  [key: string]: any;
}): AttributeMap => marshallItem(transactionTableSchema, data);
 
export const unmarshallTransaction = (
  data: AttributeMap,
): { [key: string]: any } => unmarshallItem(transactionTableSchema, data);