const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
const require_utils_validation_validateProject = require('../utils/validation/validateProject.cjs');
let mongoose = require("mongoose");
mongoose = require_rolldown_runtime.__toESM(mongoose);
let __intlayer_types = require("@intlayer/types");
__intlayer_types = require_rolldown_runtime.__toESM(__intlayer_types);

//#region src/schemas/project.schema.ts
const oAuth2AccessSchema = new mongoose.Schema({
	clientId: {
		type: String,
		required: true
	},
	clientSecret: {
		type: String,
		required: true
	},
	userId: {
		type: mongoose.Schema.Types.ObjectId,
		ref: "User",
		required: true
	},
	name: {
		type: String,
		required: true
	},
	expiresAt: { type: Date },
	accessToken: {
		type: [String],
		required: true,
		default: []
	},
	grants: {
		type: [String],
		required: true,
		default: []
	}
}, { timestamps: true });
const projectConfigSchema = new mongoose.Schema({
	internationalization: {
		locales: {
			type: [String],
			enum: Object.values(__intlayer_types.Locales.ALL_LOCALES),
			required: true
		},
		defaultLocale: {
			type: String,
			enum: Object.values(__intlayer_types.Locales.ALL_LOCALES)
		}
	},
	editor: {
		applicationURL: { type: String },
		cmsURL: { type: String }
	}
}, { _id: false });
const projectSchema = new mongoose.Schema({
	organizationId: {
		type: mongoose.Schema.Types.ObjectId,
		ref: "Organization",
		required: true
	},
	name: {
		type: String,
		required: true,
		minlength: require_utils_validation_validateProject.NAME_MIN_LENGTH,
		maxlength: require_utils_validation_validateProject.NAME_MAX_LENGTH
	},
	configuration: projectConfigSchema,
	oAuth2Access: [oAuth2AccessSchema],
	membersIds: {
		type: [mongoose.Schema.Types.ObjectId],
		ref: "User",
		required: true,
		minlength: require_utils_validation_validateProject.MEMBERS_MIN_LENGTH
	},
	adminsIds: {
		type: [mongoose.Schema.Types.ObjectId],
		ref: "User",
		required: true,
		minlength: require_utils_validation_validateProject.MEMBERS_MIN_LENGTH
	},
	creatorId: {
		type: mongoose.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
exports.projectSchema = projectSchema;
//# sourceMappingURL=project.schema.cjs.map