import { Schema } from "mongoose";

//#region src/schemas/plans.schema.ts
const planSchema = new Schema({
	type: {
		type: String,
		required: true,
		enum: ["PREMIUM", "ENTERPRISE"]
	},
	period: {
		type: String,
		required: true,
		enum: ["MONTHLY", "YEARLY"],
		default: "MONTHLY"
	},
	creatorId: {
		type: Schema.Types.ObjectId,
		ref: "User",
		required: true
	},
	subscriptionId: {
		type: String,
		required: true
	},
	customerId: {
		type: String,
		required: true
	},
	priceId: {
		type: String,
		required: true
	},
	status: {
		type: String,
		required: true,
		enum: [
			"active",
			"canceled",
			"past_due",
			"unpaid",
			"incomplete",
			"incomplete_expired",
			"paused",
			"trialing"
		]
	}
}, {
	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 { planSchema };
//# sourceMappingURL=plans.schema.mjs.map