"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypeIsJsonFixValue = exports.TypeIsJsonToSequelize = exports.TypeIsJsonToSwagger = void 0;
const sequelize_1 = require("sequelize");
const toSequelizeGenerator_1 = require("./generators/toSequelizeGenerator");
const toSwaggerGenerator_1 = require("./generators/toSwaggerGenerator");
const typeGenerator_1 = require("./generators/typeGenerator");
exports.TypeIsJsonToSwagger = (0, toSwaggerGenerator_1.toSwaggerGenerator)((options) => ({
    type: 'object',
    description: options === null || options === void 0 ? void 0 : options.comment,
}));
exports.TypeIsJsonToSequelize = (0, toSequelizeGenerator_1.toSequelizeGenerator)((options) => (Object.assign(Object.assign({}, options), { type: sequelize_1.DataTypes.JSON, comment: options === null || options === void 0 ? void 0 : options.comment })));
const TypeIsJsonFixValue = (o) => {
    try {
        if (typeof o === 'string')
            return JSON.parse(String(o));
        return o;
    }
    catch (_a) {
        return o;
    }
};
exports.TypeIsJsonFixValue = TypeIsJsonFixValue;
const TypeIsJson = (0, typeGenerator_1.typeGenerator)((options) => ({
    __name: 'json',
    toSwagger: () => (0, exports.TypeIsJsonToSwagger)(options),
    toSequelize: () => (0, exports.TypeIsJsonToSequelize)(options),
    fixValue: exports.TypeIsJsonFixValue,
}));
exports.default = TypeIsJson;
//# sourceMappingURL=json.js.map