sam-goodwin / typesafe-dynamodb

TypeSafe type definitions for the AWS DynamoDB API
Apache License 2.0
205 stars 11 forks source link

Type-safe marshall and unmarshall #18

Closed sam-goodwin closed 2 years ago

sam-goodwin commented 2 years ago

Probide type-safe definitions for @aws-sdk/util-dynamodb's marshall and unmarshall functions:

import {
  marshallOptions,
  unmarshallOptions,
  marshall as _marshall,
  unmarshall as _unmarshall,
} from "@aws-sdk/util-dynamodb";
import { ToAttributeMap } from "./attribute-value";

export const marshall: <
  Item extends object,
  MarshallOptions extends marshallOptions
>(
  item: Item,
  options?: MarshallOptions | undefined
) => ToAttributeMap<Item> = _marshall;

export const unmarshall: <
  Item extends object,
  UnmarshallOptions extends unmarshallOptions
>(
  item: ToAttributeMap<Item>,
  options?: UnmarshallOptions | undefined
) => Item = _unmarshall as any;
sam-goodwin commented 2 years ago

image