import { Schema } from "mongoose";

//#region src/schemas/oAuth2.schema.ts
const accessTokenSchema = new Schema({
	accessToken: {
		type: String,
		required: true
	},
	accessTokenExpiresAt: { type: Date },
	clientId: {
		type: String,
		ref: "Project",
		required: true
	},
	userId: {
		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
			};
		}
	}
});
accessTokenSchema.index({ createdAt: 1 }, { expireAfterSeconds: 3600 * 24 * 10 });

//#endregion
export { accessTokenSchema };
//# sourceMappingURL=oAuth2.schema.mjs.map