mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-09 23:48:36 +01:00
refactoring
This commit is contained in:
@@ -2,11 +2,21 @@ import { model, Schema, Types } from 'mongoose';
|
||||
|
||||
export type TeamMemberRole = 'ADMIN' | 'GUEST';
|
||||
|
||||
|
||||
export type TPermission = {
|
||||
webAnalytics: boolean,
|
||||
events: boolean,
|
||||
ai: boolean,
|
||||
domains: string[],
|
||||
}
|
||||
|
||||
export type TTeamMember = {
|
||||
_id: Schema.Types.ObjectId,
|
||||
project_id: Schema.Types.ObjectId,
|
||||
user_id: Schema.Types.ObjectId,
|
||||
user_id?: Schema.Types.ObjectId,
|
||||
email?: string,
|
||||
role: TeamMemberRole,
|
||||
permission: TPermission,
|
||||
pending: boolean,
|
||||
created_at: Date,
|
||||
}
|
||||
@@ -14,7 +24,9 @@ export type TTeamMember = {
|
||||
const TeamMemberSchema = new Schema<TTeamMember>({
|
||||
project_id: { type: Types.ObjectId, index: true },
|
||||
user_id: { type: Types.ObjectId, index: true },
|
||||
email: { type: String, index: true },
|
||||
role: { type: String, required: true },
|
||||
permission: { type: Schema.Types.Mixed },
|
||||
pending: { type: Boolean, required: true },
|
||||
created_at: { type: Date, required: true, default: () => Date.now() },
|
||||
});
|
||||
|
||||
19
shared_global/schema/project/ProjectLinkSchema.ts
Normal file
19
shared_global/schema/project/ProjectLinkSchema.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { model, Schema, Types } from 'mongoose';
|
||||
import { TPermission } from '../TeamMemberSchema';
|
||||
|
||||
export type TProjectLink = {
|
||||
_id: Schema.Types.ObjectId,
|
||||
project_id: Schema.Types.ObjectId,
|
||||
link_id: string,
|
||||
password: string,
|
||||
permission: TPermission
|
||||
}
|
||||
|
||||
const ProjectLinkSchema = new Schema<TProjectLink>({
|
||||
project_id: { type: Types.ObjectId, index: true, unique: true },
|
||||
link_id: { type: String, required: true },
|
||||
password: { type: String },
|
||||
permission: { type: Schema.Types.Mixed },
|
||||
});
|
||||
|
||||
export const ProjectLinkModel = model<TProjectLink>('project_links', ProjectLinkSchema);
|
||||
Reference in New Issue
Block a user