dynamodb-toolbox
Version:
Lightweight and type-safe query builder for DynamoDB and TypeScript.
36 lines (35 loc) • 1.16 kB
JavaScript
import { getAnySchemaDTO } from './any.js';
import { getAnyOfSchemaDTO } from './anyOf.js';
import { getItemSchemaDTO } from './item.js';
import { getListSchemaDTO } from './list.js';
import { getMapSchemaDTO } from './map.js';
import { getPrimitiveSchemaDTO } from './primitive.js';
import { getRecordSchemaDTO } from './record.js';
import { getSetSchemaDTO } from './set.js';
export const getSchemaDTO = (schema) => {
/**
* @debt feature "handle defaults, links & validators"
*/
switch (schema.type) {
case 'any':
return getAnySchemaDTO(schema);
case 'null':
case 'boolean':
case 'number':
case 'string':
case 'binary':
return getPrimitiveSchemaDTO(schema);
case 'set':
return getSetSchemaDTO(schema);
case 'list':
return getListSchemaDTO(schema);
case 'map':
return getMapSchemaDTO(schema);
case 'record':
return getRecordSchemaDTO(schema);
case 'anyOf':
return getAnyOfSchemaDTO(schema);
case 'item':
return getItemSchemaDTO(schema);
}
};