user.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. isMemberOfGroupSubscription?: boolean
  57. hasInstitutionLicence?: boolean
  58. }
  59. export type LoggedOutUser = {
  60. id: null
  61. email?: undefined
  62. first_name?: undefined
  63. last_name?: undefined
  64. signUpDate?: undefined
  65. labsProgram?: undefined
  66. alphaProgram?: undefined
  67. betaProgram?: undefined
  68. allowedFreeTrial?: undefined
  69. features?: undefined
  70. refProviders?: undefined
  71. writefull?: undefined
  72. isAdmin?: undefined
  73. featureUsage?: undefined
  74. }
  75. export type MongoUser = Pick<User, Exclude<keyof User, 'id'>> & { _id: string }