dynamodb-toolbox
Version:
Lightweight and type-safe query builder for DynamoDB and TypeScript.
26 lines (25 loc) • 857 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SchemaDTO = void 0;
const index_js_1 = require("../../../schema/index.js");
const index_js_2 = require("./getSchemaDTO/index.js");
class SchemaDTO extends index_js_1.SchemaAction {
constructor(schema) {
super(schema);
this.type = 'item';
this.attributes = Object.fromEntries(Object.entries(this.schema.attributes).map(([attributeName, attribute]) => [
attributeName,
(0, index_js_2.getSchemaDTO)(attribute)
]));
}
toJSON() {
const { strict } = this.schema.props;
return {
type: this.type,
attributes: this.attributes,
...(strict !== undefined && strict ? { strict } : {})
};
}
}
exports.SchemaDTO = SchemaDTO;
SchemaDTO.actionName = 'dto';