user.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { Brand } from './helpers/brand'
  2. export type RefProviders = {
  3. mendeley?: boolean
  4. papers?: boolean
  5. zotero?: boolean
  6. }
  7. export type UserId = Brand<string, 'UserId'>
  8. export type Features = {
  9. aiErrorAssistant?: boolean
  10. collaborators?: number
  11. compileGroup?: 'standard' | 'priority'
  12. compileTimeout?: number
  13. dropbox?: boolean
  14. gitBridge?: boolean
  15. github?: boolean
  16. mendeley?: boolean
  17. papers?: boolean
  18. references?: boolean
  19. referencesSearch?: boolean
  20. symbolPalette?: boolean
  21. templates?: boolean
  22. trackChanges?: boolean
  23. versioning?: boolean
  24. zotero?: boolean
  25. }
  26. export type FeatureUsage = {
  27. [feature: string]: {
  28. remainingUsage: number
  29. resetDate: string // date string
  30. }
  31. }
  32. export type User = {
  33. id: UserId
  34. isAdmin?: boolean
  35. email: string
  36. allowedFreeTrial?: boolean
  37. hasRecurlySubscription?: boolean
  38. first_name?: string
  39. last_name?: string
  40. alphaProgram?: boolean
  41. betaProgram?: boolean
  42. labsProgram?: boolean
  43. signUpDate?: string // date string
  44. features?: Features
  45. refProviders?: RefProviders
  46. writefull?: {
  47. enabled: boolean
  48. autoCreatedAccount: boolean
  49. firstAutoLoad: boolean
  50. }
  51. aiErrorAssistant?: {
  52. enabled: boolean
  53. }
  54. featureUsage?: FeatureUsage
  55. planCode?: string
  56. planName?: string
  57. isAnnualPlan?: boolean
  58. isMemberOfGroupSubscription?: boolean
  59. hasInstitutionLicence?: boolean
  60. }
  61. export type LoggedOutUser = {
  62. id: null
  63. email?: undefined
  64. first_name?: undefined
  65. last_name?: undefined
  66. signUpDate?: undefined
  67. labsProgram?: undefined
  68. alphaProgram?: undefined
  69. betaProgram?: undefined
  70. allowedFreeTrial?: undefined
  71. features?: undefined
  72. refProviders?: undefined
  73. writefull?: undefined
  74. isAdmin?: undefined
  75. featureUsage?: undefined
  76. }
  77. export type MongoUser = Pick<User, Exclude<keyof User, 'id'>> & { _id: string }