@bash-app/bash-common 30.97.0 → 30.97.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,9 +3,8 @@ generator client {
3
3
  }
4
4
 
5
5
  datasource db {
6
- provider = "postgresql"
7
- url = env("POSTGRES_PRISMA_URL")
8
- directUrl = env("POSTGRES_URL_NON_POOLING")
6
+ provider = "postgresql"
7
+ url = env("POSTGRES_PRISMA_URL")
9
8
  }
10
9
 
11
10
  model Club {
@@ -54,16 +53,25 @@ model BashComment {
54
53
  }
55
54
 
56
55
  model Competition {
57
- id String @id @default(cuid())
58
- name String
59
- description String
60
- userId String
61
- bashEventId String
62
- numberOfPrizes Int
63
- bashEvent BashEvent @relation(fields: [bashEventId], references: [id], onDelete: Cascade)
64
- owner User @relation(fields: [userId], references: [id], onDelete: Cascade)
65
- sponsor CompetitionSponsor[]
66
- prizes Prize[]
56
+ id String @id @default(cuid())
57
+ name String
58
+ description String @db.Text
59
+ userId String
60
+ bashEventId String
61
+ numberOfPrizes Int
62
+ competitionType CompetitionType? // Main category
63
+ subtype String? // Subcategory
64
+ rules String? @db.Text // Detailed rules/disclaimers
65
+ judgingType JudgingType? // How winner is determined
66
+ createdAt DateTime @default(now())
67
+ updatedAt DateTime @updatedAt
68
+ bashEvent BashEvent @relation(fields: [bashEventId], references: [id], onDelete: Cascade)
69
+ owner User @relation(fields: [userId], references: [id], onDelete: Cascade)
70
+ sponsor CompetitionSponsor[]
71
+ prizes Prize[]
72
+
73
+ @@index([bashEventId])
74
+ @@index([competitionType])
67
75
  }
68
76
 
69
77
  model CompetitionSponsor {
@@ -732,14 +740,20 @@ model Prize {
732
740
  id String @id @default(cuid())
733
741
  prizeWorth Float?
734
742
  prizeType PrizeType
735
- name String
743
+ name String // Prize name (e.g., "$100 Cash", "Backpack")
744
+ placeName String? // Display name (e.g., "1st Place", "Winner")
736
745
  prizeLevel Int
737
746
  description String
738
747
  competitionId String?
739
748
  paidOn String?
740
749
  winnerUserId String?
741
- competition Competition? @relation(fields: [competitionId], references: [id])
750
+ wonAt DateTime? // When the prize was awarded
751
+ claimedAt DateTime? // When the prize was claimed
752
+ competition Competition? @relation(fields: [competitionId], references: [id], onDelete: Cascade)
742
753
  winner User? @relation(fields: [winnerUserId], references: [id], onDelete: Cascade)
754
+
755
+ @@index([competitionId])
756
+ @@index([winnerUserId]) // For fetching user's wins
743
757
  }
744
758
 
745
759
  model Review {
@@ -807,16 +821,22 @@ model SocialMediaProfile {
807
821
  }
808
822
 
809
823
  model User {
810
- id String @id @default(cuid())
811
- username String? @unique
812
- email String @unique
813
- createdOn DateTime @default(now())
814
- stripeCustomerId String? @unique
815
- stripeAccountId String? @unique
816
- isSuperUser Boolean @default(false)
817
- isSuspended Boolean @default(false)
818
- intent UserIntent?
819
- googleCalendarAccess String?
824
+ id String @id @default(cuid())
825
+ username String? @unique
826
+ email String @unique
827
+ createdOn DateTime @default(now())
828
+ stripeCustomerId String? @unique
829
+ stripeAccountId String? @unique
830
+ isSuperUser Boolean @default(false)
831
+ isSuspended Boolean @default(false)
832
+ intent UserIntent?
833
+ googleCalendarAccess String?
834
+
835
+ // Google OAuth tokens for API access (Contacts, Calendar, etc.)
836
+ googleAccessToken String?
837
+ googleRefreshToken String?
838
+ googleTokenExpiry DateTime?
839
+
820
840
  givenName String?
821
841
  familyName String?
822
842
  nameChangeCount Int @default(0)
@@ -901,8 +921,9 @@ model User {
901
921
 
902
922
  // Security Fields
903
923
  accountLockedUntil DateTime? // Account lockout timestamp for failed login protection
904
- auditLogs AuditLog[] @relation("UserAuditLogs")
905
- auditLogsPerformed AuditLog[] @relation("PerformedByUser")
924
+ revokedTokens RevokedToken[] @relation("RevokedTokens") // Revoked JWT tokens
925
+ auditLogs AuditLog[] @relation("UserAuditLogs")
926
+ auditLogsPerformed AuditLog[] @relation("PerformedByUser")
906
927
  consents UserConsent[]
907
928
 
908
929
  associatedBashes AssociatedBash[]
@@ -1043,6 +1064,7 @@ model UserPreferences {
1043
1064
  showEmailPublicly Boolean @default(true)
1044
1065
  showPhonePublicly Boolean @default(false)
1045
1066
  showAddressPublicly Boolean @default(false)
1067
+ showCompetitionWins Boolean @default(true) // Display competition wins on public profile
1046
1068
  theme String @default("system")
1047
1069
  language String @default("en")
1048
1070
  timeZone String @default("America/New_York")
@@ -1863,42 +1885,42 @@ model ServiceBookingCheckout {
1863
1885
  }
1864
1886
 
1865
1887
  model ServiceBooking {
1866
- id String @id @default(cuid())
1867
- creatorId String
1868
- forUserId String
1869
- daysTotalATBCents Int
1870
- serviceId String
1871
- rateOption ServiceBookingRateOption @default(TimeBased)
1872
- flatRateCents Int?
1873
- status ServiceBookingStatus @default(Pending)
1874
- bookingType ServiceBookingType @default(Request)
1875
- timezone String
1876
- requestedOn DateTime?
1877
- requestDecisionOn DateTime?
1878
- bookedOn DateTime?
1879
- canceledOn DateTime?
1880
- isFreeGuest Boolean @default(false)
1881
- allowPromiseToPay Boolean @default(false)
1882
- totalATBCents Int
1883
- subtotalATBCents Int @default(0)
1884
- bashEventId String?
1885
- isVendorBid Boolean @default(false)
1886
- vendorBidAmountCents Int?
1887
- vendorEventDetails String?
1888
- bashCashApplied Int? // BashCash credits applied to this booking
1889
- bashCashTransactionId String? // Link to BashCreditTransaction
1890
- notification Notification[]
1891
- bashEvent BashEvent? @relation(fields: [bashEventId], references: [id])
1892
- creator User @relation("BookingCreator", fields: [creatorId], references: [id])
1893
- forUser User @relation("BookingForUser", fields: [forUserId], references: [id])
1894
- service Service @relation(fields: [serviceId], references: [id])
1895
- addOns ServiceBookingAddOn[]
1896
- checkout ServiceBookingCheckout?
1897
- bookedDays ServiceBookingDay[]
1898
- additionalFees ServiceBookingFee[]
1899
- messages ServiceBookingMessage[]
1900
- packages ServiceBookingPackage[]
1901
- commissions BookingCommission[] @relation("BookingCommissions")
1888
+ id String @id @default(cuid())
1889
+ creatorId String
1890
+ forUserId String
1891
+ daysTotalATBCents Int
1892
+ serviceId String
1893
+ rateOption ServiceBookingRateOption @default(TimeBased)
1894
+ flatRateCents Int?
1895
+ status ServiceBookingStatus @default(Pending)
1896
+ bookingType ServiceBookingType @default(Request)
1897
+ timezone String
1898
+ requestedOn DateTime?
1899
+ requestDecisionOn DateTime?
1900
+ bookedOn DateTime?
1901
+ canceledOn DateTime?
1902
+ isFreeGuest Boolean @default(false)
1903
+ allowPromiseToPay Boolean @default(false)
1904
+ totalATBCents Int
1905
+ subtotalATBCents Int @default(0)
1906
+ bashEventId String?
1907
+ isVendorBid Boolean @default(false)
1908
+ vendorBidAmountCents Int?
1909
+ vendorEventDetails String?
1910
+ bashCashApplied Int? // BashCash credits applied to this booking
1911
+ bashCashTransactionId String? // Link to BashCreditTransaction
1912
+ notification Notification[]
1913
+ bashEvent BashEvent? @relation(fields: [bashEventId], references: [id])
1914
+ creator User @relation("BookingCreator", fields: [creatorId], references: [id])
1915
+ forUser User @relation("BookingForUser", fields: [forUserId], references: [id])
1916
+ service Service @relation(fields: [serviceId], references: [id])
1917
+ addOns ServiceBookingAddOn[]
1918
+ checkout ServiceBookingCheckout?
1919
+ bookedDays ServiceBookingDay[]
1920
+ additionalFees ServiceBookingFee[]
1921
+ messages ServiceBookingMessage[]
1922
+ packages ServiceBookingPackage[]
1923
+ commissions BookingCommission[] @relation("BookingCommissions")
1902
1924
 
1903
1925
  @@index([status])
1904
1926
  @@index([creatorId])
@@ -2795,6 +2817,31 @@ enum PrizeType {
2795
2817
  Combo
2796
2818
  }
2797
2819
 
2820
+ enum CompetitionType {
2821
+ RAFFLE // Raffles & Drawings
2822
+ SKILL // Skill-Based Contests
2823
+ PHYSICAL // Physical & Outdoor
2824
+ INTERACTIVE // Interactive Audience
2825
+ SOCIAL_MEDIA // Social Media-Driven
2826
+ KIDS_FAMILY // Kids & Family
2827
+ FOOD_DRINK // Food & Drink
2828
+ VENDOR_BOOTH // Vendor Booth
2829
+ BUSINESS_PROFESSIONAL // Business / Professional
2830
+ RANDOMIZED // Randomized Participation
2831
+ SEASONAL_HOLIDAY // Seasonal or Holiday
2832
+ AUDIENCE_VOTING // Audience Voting-Based
2833
+ }
2834
+
2835
+ enum JudgingType {
2836
+ RANDOM_DRAW // Raffle-style random selection
2837
+ JUDGES // Panel of judges decides
2838
+ AUDIENCE_VOTE // Attendees vote
2839
+ METRICS // Based on measurable metrics
2840
+ HOST_CHOOSES // Host/organizer picks winner
2841
+ FIRST_COME // First X people win
2842
+ HIGHEST_BID // Auction-style
2843
+ }
2844
+
2798
2845
  enum Sex {
2799
2846
  Male
2800
2847
  Female
@@ -4240,6 +4287,25 @@ model AuditLog {
4240
4287
  @@index([ipAddress])
4241
4288
  }
4242
4289
 
4290
+ /// Token Revocation System
4291
+ /// Tracks revoked JWT tokens to prevent their reuse
4292
+ /// Required for secure logout, password changes, and account termination
4293
+ model RevokedToken {
4294
+ id String @id @default(cuid())
4295
+ userId String // Owner of the revoked token
4296
+ jti String @unique // JWT ID from token payload
4297
+ revokedAt DateTime @default(now())
4298
+ expiresAt DateTime // When the original token would have expired (for cleanup)
4299
+ reason String? // Why it was revoked: "logout", "password_change", "suspicious_activity", etc.
4300
+
4301
+ // Relation to user
4302
+ user User @relation("RevokedTokens", fields: [userId], references: [id], onDelete: Cascade)
4303
+
4304
+ @@index([jti]) // Fast lookup for token validation
4305
+ @@index([userId, revokedAt]) // User-specific revocation history
4306
+ @@index([expiresAt]) // For cleanup of old expired tokens
4307
+ }
4308
+
4243
4309
  enum AuditAction {
4244
4310
  // Authentication
4245
4311
  LOGIN_SUCCESS
@@ -4300,6 +4366,11 @@ enum AuditAction {
4300
4366
  DATA_IMPORTED
4301
4367
  SENSITIVE_DATA_ACCESSED
4302
4368
 
4369
+ // Compliance
4370
+ CONSENT_GIVEN
4371
+ CONSENT_WITHDRAWN
4372
+ POLICY_ACCEPTED
4373
+
4303
4374
  // Security
4304
4375
  SUSPICIOUS_ACTIVITY_DETECTED
4305
4376
  RATE_LIMIT_EXCEEDED
@@ -4317,6 +4388,7 @@ enum AuditCategory {
4317
4388
  Tickets
4318
4389
  AdminAction
4319
4390
  DataAccess
4391
+ Compliance
4320
4392
  Security
4321
4393
  }
4322
4394
 
@@ -2,8 +2,10 @@ import {
2
2
  BashEventDressTags,
3
3
  BashEventType,
4
4
  BashEventVibeTags,
5
+ CompetitionType,
5
6
  Contact,
6
7
  EntertainmentServiceType,
8
+ JudgingType,
7
9
  MembershipTier,
8
10
  MusicGenreType,
9
11
  Prisma,
@@ -877,7 +879,7 @@ export const YearsOfExperienceToString: { [key in YearsOfExperience]: string } =
877
879
  };
878
880
 
879
881
  // Export Prisma enums for use in frontend
880
- export { YearsOfExperience, EntertainmentServiceType, MusicGenreType, ServiceTypes };
882
+ export { YearsOfExperience, EntertainmentServiceType, MusicGenreType, ServiceTypes, CompetitionType, JudgingType };
881
883
 
882
884
  export type BashEventTypeToStringType = {
883
885
  [key in BashEventType]: string;
@@ -10,6 +10,7 @@ import {
10
10
  BlogPost,
11
11
  BlogTag,
12
12
  Checkout,
13
+ Competition,
13
14
  Contact,
14
15
  Coordinates,
15
16
  Demerit,
@@ -23,6 +24,7 @@ import {
23
24
  Notification,
24
25
  Organization,
25
26
  Prisma,
27
+ Prize,
26
28
  Recurrence,
27
29
  Reminder,
28
30
  Review,
@@ -154,6 +156,14 @@ export const PRIVATE_USER_ACCOUNT_TO_SELECT = {
154
156
 
155
157
  export interface SponsoredEventExt extends SponsoredEvent {}
156
158
 
159
+ export interface PrizeExt extends Prize {
160
+ winner?: PublicUser | null;
161
+ }
162
+
163
+ export interface CompetitionExt extends Competition {
164
+ prizes: PrizeExt[];
165
+ }
166
+
157
167
  export interface BashEventExt extends BashEvent {
158
168
  targetAudience?: TargetAudience;
159
169
  amountOfGuests?: AmountOfGuests;
@@ -169,6 +179,7 @@ export interface BashEventExt extends BashEvent {
169
179
  venueServiceId?: string;
170
180
  venueOwner?: PublicUser;
171
181
  sponsorships?: SponsoredEventExt[];
182
+ competitions?: CompetitionExt[];
172
183
  }
173
184
 
174
185
  export const TICKET_TIER_DATA_TO_INCLUDE = {
@@ -206,6 +217,17 @@ export const BASH_EVENT_DATA_TO_INCLUDE = {
206
217
  media: true,
207
218
  eventTasks: true,
208
219
  invitations: true,
220
+ competitions: {
221
+ include: {
222
+ prizes: {
223
+ include: {
224
+ winner: {
225
+ select: FRONT_END_USER_DATA_TO_SELECT,
226
+ },
227
+ },
228
+ },
229
+ },
230
+ },
209
231
  } satisfies Prisma.BashEventInclude;
210
232
 
211
233
  export const BASH_EVENT_DATA_TO_CLONE = [