user.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. isQuestionnaireEnabled: boolean,
  26. }
  27. export type IUserGroupRelation = {
  28. relatedGroup: Ref<IUserGroup>,
  29. relatedUser: Ref<IUser>,
  30. createdAt: Date,
  31. }
  32. export type IUserGroup = {
  33. name: string;
  34. createdAt: Date;
  35. description: string;
  36. parent: Ref<IUserGroup> | null;
  37. }
  38. export const USER_STATUS = {
  39. REGISTERED: 1,
  40. ACTIVE: 2,
  41. SUSPENDED: 3,
  42. DELETED: 4,
  43. INVITED: 5,
  44. } as const;
  45. export type IUserStatus = typeof USER_STATUS[keyof typeof USER_STATUS]
  46. export type IUserHasId = IUser & HasObjectId;
  47. export type IUserGroupHasId = IUserGroup & HasObjectId;
  48. export type IUserGroupRelationHasId = IUserGroupRelation & HasObjectId;
  49. export type IAdminExternalAccount<P> = {
  50. _id: string,
  51. providerType: P,
  52. accountId: string,
  53. user: IUser,
  54. createdAt: Date,
  55. }