user.ts 1.5 KB

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