dynamodb-toolbox
Version:
Lightweight and type-safe query builder for DynamoDB and TypeScript.
19 lines (18 loc) • 616 B
JavaScript
import { item } from '../../../../schema/item/index.js';
import { fromSchemaDTO } from './attribute.js';
/**
* @debt feature "handle defaults, links & validators"
*/
export const fromItemSchemaDTO = ({ keyDefault, putDefault, updateDefault, keyLink, putLink, updateLink, strict, attributes }) => {
keyDefault;
putDefault;
updateDefault;
keyLink;
putLink;
updateLink;
const schema = item(Object.fromEntries(Object.entries(attributes).map(([attributeName, attribute]) => [
attributeName,
fromSchemaDTO(attribute)
])));
return strict ? schema.strict() : schema;
};