const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
const require_utils_validation_validateUser = require('../utils/validation/validateUser.cjs');
let mongoose = require("mongoose");
let validator = require("validator");
validator = require_rolldown_runtime.__toESM(validator);

//#region src/schemas/user.schema.ts
const userSchema = new mongoose.Schema({
	email: {
		type: String,
		required: true,
		unique: true,
		validate: [validator.default.isEmail, "Please fill a valid email address"],
		lowercase: true,
		trim: true
	},
	name: {
		type: String,
		maxlength: require_utils_validation_validateUser.NAMES_MAX_LENGTH,
		minlength: require_utils_validation_validateUser.NAMES_MIN_LENGTH
	},
	phone: {
		type: String,
		maxlength: 20
	},
	customerId: {
		type: String,
		required: false
	},
	emailsList: {
		type: { newsLetter: {
			type: Boolean,
			default: false
		} },
		required: false
	},
	role: {
		type: String,
		enum: ["admin", "user"],
		default: "user",
		required: false
	}
}, {
	timestamps: true,
	toJSON: {
		virtuals: true,
		versionKey: false,
		transform(_doc, ret) {
			const { _id,...rest } = ret;
			return {
				...rest,
				id: _id.toString()
			};
		}
	},
	toObject: {
		virtuals: true,
		transform(_doc, ret) {
			const { _id,...rest } = ret;
			return {
				...rest,
				id: _id
			};
		}
	}
});

//#endregion
exports.userSchema = userSchema;
//# sourceMappingURL=user.schema.cjs.map