user.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. isLatexBeginner?: boolean
  44. signUpDate?: string // date string
  45. features?: Features
  46. refProviders?: RefProviders
  47. writefull?: {
  48. enabled: boolean
  49. autoCreatedAccount: boolean
  50. firstAutoLoad: boolean
  51. }
  52. aiErrorAssistant?: {
  53. enabled: boolean
  54. }
  55. featureUsage?: FeatureUsage
  56. planCode?: string
  57. isMemberOfGroupSubscription?: boolean
  58. hasInstitutionLicence?: boolean
  59. }
  60. export type LoggedOutUser = {
  61. id: null
  62. email?: undefined
  63. first_name?: undefined
  64. last_name?: undefined
  65. signUpDate?: undefined
  66. labsProgram?: undefined
  67. alphaProgram?: undefined
  68. betaProgram?: undefined
  69. allowedFreeTrial?: undefined
  70. features?: undefined
  71. refProviders?: undefined
  72. writefull?: undefined
  73. isAdmin?: undefined
  74. featureUsage?: undefined
  75. }
  76. export type MongoUser = Pick<User, Exclude<keyof User, 'id'>> & { _id: string }