import { KEY_MAX_LENGTH, KEY_MIN_LENGTH, NAME_MAX_LENGTH, NAME_MIN_LENGTH } from "../utils/validation/validateTag.mjs";
import { Schema } from "mongoose";

//#region src/schemas/tag.schema.ts
const tagSchema = new Schema({
	organizationId: {
		type: Schema.Types.ObjectId,
		ref: "Organization",
		required: true
	},
	projectId: {
		type: Schema.Types.ObjectId,
		ref: "Project",
		required: true
	},
	key: {
		type: String,
		required: true,
		minlength: KEY_MIN_LENGTH,
		maxlength: KEY_MAX_LENGTH
	},
	name: {
		type: String,
		minlength: NAME_MIN_LENGTH,
		maxlength: NAME_MAX_LENGTH
	},
	description: { type: String },
	instructions: { type: String },
	creatorId: {
		type: Schema.Types.ObjectId,
		ref: "User",
		required: true
	}
}, {
	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
export { tagSchema };
//# sourceMappingURL=tag.schema.mjs.map