user.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import type { IAttachment } from './attachment';
  2. import type { Ref } from './common';
  3. import type { HasObjectId } from './has-object-id';
  4. import type { Lang } from './lang';
  5. export type IUser = {
  6. name: string,
  7. username: string,
  8. email: string,
  9. password: string,
  10. image?: string, // for backward conpatibility
  11. imageAttachment?: Ref<IAttachment>,
  12. imageUrlCached: string,
  13. isGravatarEnabled: boolean,
  14. admin: boolean,
  15. apiToken?: string,
  16. isEmailPublished: boolean,
  17. isInvitationEmailSended: boolean,
  18. lang: Lang,
  19. slackMemberId?: string,
  20. createdAt: Date,
  21. lastLoginAt?: Date,
  22. introduction: string,
  23. status: IUserStatus,
  24. isQuestionnaireEnabled: boolean,
  25. }
  26. export type IUserGroupRelation = {
  27. relatedGroup: Ref<IUserGroup>,
  28. relatedUser: Ref<IUser>,
  29. createdAt: Date,
  30. }
  31. export type IUserGroup = {
  32. name: string;
  33. createdAt: Date;
  34. description: string;
  35. parent: Ref<IUserGroupHasId> | null;
  36. }
  37. export const USER_STATUS = {
  38. REGISTERED: 1,
  39. ACTIVE: 2,
  40. SUSPENDED: 3,
  41. DELETED: 4,
  42. INVITED: 5,
  43. } as const;
  44. export type IUserStatus = typeof USER_STATUS[keyof typeof USER_STATUS]
  45. export type IUserHasId = IUser & HasObjectId;
  46. export type IUserGroupHasId = IUserGroup & HasObjectId;
  47. export type IUserGroupRelationHasId = IUserGroupRelation & HasObjectId;
  48. export type IAdminExternalAccount = {
  49. _id: string,
  50. providerType: string,
  51. accountId: string,
  52. user: IUser,
  53. createdAt: Date,
  54. }