2
0

user.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import type { IAttachment } from './attachment';
  2. import type { Ref } from './common';
  3. import type { IExternalAuthProviderType } from './external-account';
  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. isEmailPublished: boolean,
  19. isInvitationEmailSended: boolean,
  20. lang: Lang,
  21. slackMemberId?: string,
  22. createdAt: Date,
  23. lastLoginAt?: Date,
  24. introduction: string,
  25. status: IUserStatus,
  26. isQuestionnaireEnabled: boolean,
  27. }
  28. export type IUserGroupRelation = {
  29. relatedGroup: Ref<IUserGroup>,
  30. relatedUser: Ref<IUser>,
  31. createdAt: Date,
  32. }
  33. export type IUserGroup = {
  34. name: string;
  35. createdAt: Date;
  36. description: string;
  37. parent: Ref<IUserGroup> | null;
  38. }
  39. export const USER_STATUS = {
  40. REGISTERED: 1,
  41. ACTIVE: 2,
  42. SUSPENDED: 3,
  43. DELETED: 4,
  44. INVITED: 5,
  45. } as const;
  46. export type IUserStatus = typeof USER_STATUS[keyof typeof USER_STATUS]
  47. export type IUserHasId = IUser & HasObjectId;
  48. export type IUserGroupHasId = IUserGroup & HasObjectId;
  49. export type IUserGroupRelationHasId = IUserGroupRelation & HasObjectId;
  50. export type IAdminExternalAccount = {
  51. _id: string,
  52. providerType: IExternalAuthProviderType,
  53. accountId: string,
  54. user: IUser,
  55. createdAt: Date,
  56. }