user.ts 1.7 KB

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