mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +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);
|
||||
@@ -8,6 +8,8 @@ const templateMap = {
|
||||
limit_50: '/limit/50',
|
||||
limit_90: '/limit/90',
|
||||
limit_max: '/limit/max',
|
||||
invite_project: '/invite',
|
||||
invite_project_noaccount: '/invite/noaccount'
|
||||
} as const;
|
||||
|
||||
export type EmailTemplate = keyof typeof templateMap;
|
||||
@@ -22,7 +24,9 @@ type EmailData =
|
||||
| { template: 'anomaly_visits_events', data: { target: string, projectName: string, data: any[] } }
|
||||
| { template: 'limit_50', data: { target: string, projectName: string } }
|
||||
| { template: 'limit_90', data: { target: string, projectName: string } }
|
||||
| { template: 'limit_max', data: { target: string, projectName: string } };
|
||||
| { template: 'limit_max', data: { target: string, projectName: string } }
|
||||
| { template: 'invite_project', data: { target: string, projectName: string, link: string } }
|
||||
| { template: 'invite_project_noaccount', data: { target: string, projectName: string, link: string } }
|
||||
|
||||
export class EmailService {
|
||||
static getEmailServerInfo<T extends EmailTemplate>(template: T, data: Extract<EmailData, { template: T }>['data']): EmailServerInfo {
|
||||
|
||||
Reference in New Issue
Block a user