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. readOnly: boolean;
  16. apiToken?: string;
  17. isEmailPublished: boolean;
  18. isInvitationEmailSended: boolean;
  19. lang: Lang;
  20. slackMemberId?: string;
  21. createdAt: Date;
  22. lastLoginAt?: Date;
  23. introduction: string;
  24. status: IUserStatus;
  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<IUserGroup> | 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<P> = {
  49. _id: string;
  50. providerType: P;
  51. accountId: string;
  52. user: IUser;
  53. createdAt: Date;
  54. };