user.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. aiWorkbench: {
  29. remainingTokens: number
  30. resetDate: string // date string
  31. }
  32. aiFeatureUsage: {
  33. remainingUsage: number
  34. resetDate: string // date string
  35. }
  36. }
  37. export type User = {
  38. id: UserId
  39. isAdmin?: boolean
  40. email: string
  41. allowedFreeTrial?: boolean
  42. hasPaidSubscription?: boolean
  43. first_name?: string
  44. last_name?: string
  45. alphaProgram?: boolean
  46. betaProgram?: boolean
  47. labsProgram?: boolean
  48. signUpDate?: string // date string
  49. features?: Features
  50. refProviders?: RefProviders
  51. writefull?: {
  52. autoCreatedAccount: boolean
  53. premiumSource: string
  54. }
  55. featureUsage?: FeatureUsage
  56. planCode?: string
  57. planName?: string
  58. isAnnualPlan?: boolean
  59. isMemberOfGroupSubscription?: boolean
  60. isProfessionalGroupPlan?: boolean
  61. hasInstitutionLicence?: boolean
  62. }
  63. export type LoggedOutUser = {
  64. id: null
  65. email?: undefined
  66. first_name?: undefined
  67. last_name?: undefined
  68. signUpDate?: undefined
  69. labsProgram?: undefined
  70. alphaProgram?: undefined
  71. betaProgram?: undefined
  72. allowedFreeTrial?: undefined
  73. features?: undefined
  74. refProviders?: undefined
  75. writefull?: undefined
  76. isAdmin?: undefined
  77. featureUsage?: undefined
  78. }
  79. export type MongoUser = Pick<User, Exclude<keyof User, 'id'>> & { _id: string }