This commit is contained in:
Archer
2023-11-09 09:46:57 +08:00
committed by GitHub
parent 661ee79943
commit 8bb5588305
402 changed files with 9899 additions and 5967 deletions

15
packages/global/support/user/api.d.ts vendored Normal file
View File

@@ -0,0 +1,15 @@
import { OAuthEnum } from './constant';
export type PostLoginProps = {
username: string;
password: string;
tmbId?: string;
};
export type OauthLoginProps = {
type: `${OAuthEnum}`;
code: string;
callbackUrl: string;
inviterId?: string;
tmbId?: string;
};

View File

@@ -1,30 +1,4 @@
export enum InformTypeEnum {
system = 'system'
export enum OAuthEnum {
github = 'github',
google = 'google'
}
export const InformTypeMap = {
[InformTypeEnum.system]: {
label: '系统通知'
}
};
export enum TeamMemberRoleEnum {
owner = 'owner',
admin = 'admin',
member = 'member',
visitor = 'visitor'
}
export const TeamMemberRoleMap = {
[TeamMemberRoleEnum.owner]: {
label: 'user.team.role.owner'
},
[TeamMemberRoleEnum.admin]: {
label: 'user.team.role.admin'
},
[TeamMemberRoleEnum.member]: {
label: 'user.team.role.member'
},
[TeamMemberRoleEnum.visitor]: {
label: 'user.team.role.visitor'
}
};

View File

@@ -1,21 +0,0 @@
export type CreateTeamProps = {
ownerId: string;
name: string;
avatar?: string;
};
export type UpdateTeamProps = {
id: string;
name?: string;
avatar?: string;
};
export type updateTeamBalanceProps = {
id: string;
balance: number;
};
export type CreateTeamMemberProps = {
ownerId: string;
teamId: string;
userId: string;
name?: string;
};

View File

@@ -0,0 +1,9 @@
export enum InformTypeEnum {
system = 'system'
}
export const InformTypeMap = {
[InformTypeEnum.system]: {
label: '系统通知'
}
};

View File

@@ -0,0 +1,18 @@
import { InformTypeEnum } from './constant';
export type SendInformProps = {
tmbId?: string;
type: `${InformTypeEnum}`;
title: string;
content: string;
};
export type UserInformSchema = {
_id: string;
userId: string;
time: Date;
type: `${InformTypeEnum}`;
title: string;
content: string;
read: boolean;
};

View File

@@ -0,0 +1,42 @@
export const TeamCollectionName = 'teams';
export const TeamMemberCollectionName = 'team.members';
export enum TeamMemberRoleEnum {
owner = 'owner',
admin = 'admin',
visitor = 'visitor'
}
export const TeamMemberRoleMap = {
[TeamMemberRoleEnum.owner]: {
value: TeamMemberRoleEnum.owner,
label: 'user.team.role.Owner'
},
[TeamMemberRoleEnum.admin]: {
value: TeamMemberRoleEnum.admin,
label: 'user.team.role.Admin'
},
[TeamMemberRoleEnum.visitor]: {
value: TeamMemberRoleEnum.visitor,
label: 'user.team.role.Visitor'
}
};
export enum TeamMemberStatusEnum {
waiting = 'waiting',
active = 'active',
reject = 'reject'
}
export const TeamMemberStatusMap = {
[TeamMemberStatusEnum.waiting]: {
label: 'user.team.member.waiting',
color: 'orange.600'
},
[TeamMemberStatusEnum.active]: {
label: 'user.team.member.active',
color: 'green.600'
},
[TeamMemberStatusEnum.reject]: {
label: 'user.team.member.reject',
color: 'red.600'
}
};

View File

@@ -0,0 +1,40 @@
import { TeamMemberRoleEnum } from './constant';
import { TeamMemberSchema } from './type';
export type AuthTeamRoleProps = {
teamId: string;
tmbId: string;
role?: `${TeamMemberRoleEnum}`;
};
export type CreateTeamProps = {
name: string;
avatar?: string;
defaultTeam?: boolean;
};
export type UpdateTeamProps = {
teamId: string;
name?: string;
avatar?: string;
};
/* ------------- member ----------- */
export type DelMemberProps = {
teamId: string;
memberId: string;
};
export type UpdateTeamMemberProps = {
teamId: string;
memberId: string;
role?: TeamMemberSchema['role'];
status?: TeamMemberSchema['status'];
};
export type InviteMemberProps = {
teamId: string;
usernames: string[];
role: `${TeamMemberRoleEnum}`;
};
export type UpdateInviteProps = {
tmbId: string;
status: TeamMemberSchema['status'];
};
export type InviteMemberResponse = Record<'invite' | 'inValid' | 'inTeam', string[]>;

View File

@@ -0,0 +1,46 @@
import { UserModelSchema } from '../type';
import { TeamMemberRoleEnum, TeamMemberStatusEnum } from './constant';
export type TeamSchema = {
_id: string;
name: string;
ownerId: string;
avatar: string;
createTime: Date;
balance: number;
maxSize: number;
};
export type TeamMemberSchema = {
_id: string;
teamId: string;
userId: string;
createTime: Date;
role: `${TeamMemberRoleEnum}`;
status: `${TeamMemberStatusEnum}`;
defaultTeam: boolean;
};
export type TeamItemType = {
userId: string;
teamId: string;
teamName: string;
avatar: string;
balance: number;
tmbId: string;
defaultTeam: boolean;
role: `${TeamMemberRoleEnum}`;
status: `${TeamMemberStatusEnum}`;
canWrite: boolean;
maxSize: number;
};
export type TeamMemberItemType = {
userId: string;
tmbId: string;
teamId: string;
memberUsername: string;
avatar: string;
role: `${TeamMemberRoleEnum}`;
status: `${TeamMemberStatusEnum}`;
};

View File

@@ -1,4 +1,5 @@
import { InformTypeEnum, TeamMemberRoleEnum } from './constant';
import { InformTypeEnum } from './constant';
import { TeamItemType } from './team/type';
export type UserModelSchema = {
_id: string;
@@ -21,28 +22,13 @@ export type UserModelSchema = {
};
};
export type UserInformSchema = {
export type UserType = {
_id: string;
userId: string;
time: Date;
type: `${InformTypeEnum}`;
title: string;
content: string;
read: boolean;
};
export type TeamSchema = {
_id: string;
name: string;
ownerId: string;
username: string;
avatar: string;
createTime: Date;
};
export type TeamMemberSchema = {
_id: string;
name: string;
teamId: string;
userId: string;
role: `${TeamMemberRoleEnum}`;
balance: number;
timezone: string;
promotionRate: UserModelSchema['promotionRate'];
openaiAccount: UserModelSchema['openaiAccount'];
team: TeamItemType;
};