@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.
- package/dist/definitions.d.ts +2 -2
- package/dist/definitions.d.ts.map +1 -1
- package/dist/definitions.js +2 -2
- package/dist/definitions.js.map +1 -1
- package/dist/extendedSchemas.d.ts +176 -1
- package/dist/extendedSchemas.d.ts.map +1 -1
- package/dist/extendedSchemas.js +11 -0
- package/dist/extendedSchemas.js.map +1 -1
- package/package.json +1 -1
- package/prisma/MIGRATION-CHECKLIST.md +198 -0
- package/prisma/manual-migration-add-missing-columns.sql +182 -0
- package/prisma/quick-migration.sql +47 -0
- package/prisma/schema.prisma +135 -63
- package/src/definitions.ts +3 -1
- package/src/extendedSchemas.ts +22 -0
package/prisma/schema.prisma
CHANGED
|
@@ -3,9 +3,8 @@ generator client {
|
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
datasource db {
|
|
6
|
-
provider
|
|
7
|
-
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
|
|
58
|
-
name
|
|
59
|
-
description
|
|
60
|
-
userId
|
|
61
|
-
bashEventId
|
|
62
|
-
numberOfPrizes
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
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
|
|
811
|
-
username
|
|
812
|
-
email
|
|
813
|
-
createdOn
|
|
814
|
-
stripeCustomerId
|
|
815
|
-
stripeAccountId
|
|
816
|
-
isSuperUser
|
|
817
|
-
isSuspended
|
|
818
|
-
intent
|
|
819
|
-
googleCalendarAccess
|
|
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
|
-
|
|
905
|
-
|
|
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
|
|
1867
|
-
creatorId
|
|
1868
|
-
forUserId
|
|
1869
|
-
daysTotalATBCents
|
|
1870
|
-
serviceId
|
|
1871
|
-
rateOption
|
|
1872
|
-
flatRateCents
|
|
1873
|
-
status
|
|
1874
|
-
bookingType
|
|
1875
|
-
timezone
|
|
1876
|
-
requestedOn
|
|
1877
|
-
requestDecisionOn
|
|
1878
|
-
bookedOn
|
|
1879
|
-
canceledOn
|
|
1880
|
-
isFreeGuest
|
|
1881
|
-
allowPromiseToPay
|
|
1882
|
-
totalATBCents
|
|
1883
|
-
subtotalATBCents
|
|
1884
|
-
bashEventId
|
|
1885
|
-
isVendorBid
|
|
1886
|
-
vendorBidAmountCents
|
|
1887
|
-
vendorEventDetails
|
|
1888
|
-
bashCashApplied
|
|
1889
|
-
bashCashTransactionId String?
|
|
1890
|
-
notification
|
|
1891
|
-
bashEvent
|
|
1892
|
-
creator
|
|
1893
|
-
forUser
|
|
1894
|
-
service
|
|
1895
|
-
addOns
|
|
1896
|
-
checkout
|
|
1897
|
-
bookedDays
|
|
1898
|
-
additionalFees
|
|
1899
|
-
messages
|
|
1900
|
-
packages
|
|
1901
|
-
commissions
|
|
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
|
|
package/src/definitions.ts
CHANGED
|
@@ -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;
|
package/src/extendedSchemas.ts
CHANGED
|
@@ -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 = [
|