import { Schema } from "mongoose";

//#region src/schemas/discussion.schema.ts
const discussionSchema = new Schema({
	discussionId: {
		type: String,
		required: true,
		unique: true
	},
	messages: [{
		role: {
			type: String,
			required: true,
			enum: [
				"user",
				"assistant",
				"system"
			]
		},
		content: {
			type: String,
			required: true
		},
		timestamp: {
			type: Date,
			default: Date.now
		},
		relatedFiles: { type: [String] }
	}],
	userId: {
		type: Schema.Types.ObjectId,
		ref: "user",
		required: true
	},
	projectId: {
		type: Schema.Types.ObjectId,
		ref: "project",
		required: true
	},
	organizationId: {
		type: Schema.Types.ObjectId,
		ref: "organization",
		required: true
	},
	title: {
		type: String,
		required: false
	},
	isArchived: {
		type: Boolean,
		default: 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
export { discussionSchema };
//# sourceMappingURL=discussion.schema.mjs.map