@bash-app/bash-common 30.93.1 → 30.94.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/prisma/schema.prisma +273 -48
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bash-app/bash-common",
3
- "version": "30.93.1",
3
+ "version": "30.94.1",
4
4
  "description": "Common data and scripts to use on the frontend and backend",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -218,8 +218,8 @@ model Invitation {
218
218
  phone String?
219
219
  name String?
220
220
  message String?
221
- customHeading String? // Custom heading text for the email (e.g., "You're on the guestlist" or "Welcome to AI MarCon")
222
- customLinkText String? // Custom link text for the email (e.g., "View your ticket" or "Click here for event details")
221
+ customHeading String? // Custom heading text for the email (e.g., "You're on the guestlist" or "Welcome to AI MarCon")
222
+ customLinkText String? // Custom link text for the email (e.g., "View your ticket" or "Click here for event details")
223
223
  inviteDate DateTime? @default(now())
224
224
  acceptedDate DateTime?
225
225
  rejectedDate DateTime?
@@ -357,25 +357,54 @@ model Checkout {
357
357
  }
358
358
 
359
359
  model BashCreditTransaction {
360
- id String @id @default(cuid())
361
- userId String
362
- amount Int
363
- transactionType CreditTransactionType
364
- source String
360
+ id String @id @default(cuid())
361
+ userId String
362
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
363
+
364
+ // Transaction Details
365
+ amount Int // Credits (can be negative for redemptions)
366
+ balanceAfter Int // Running balance after this transaction
367
+ type CreditTransactionType
368
+ status CreditTransactionStatus @default(Pending)
369
+
370
+ // Source Tracking (Legacy fields - keeping for backwards compatibility)
371
+ transactionType CreditTransactionType // Duplicate of 'type' for legacy compatibility
372
+ source String // Legacy source field`
365
373
  referralCode String?
366
374
  referredUserId String?
375
+ referredUser User? @relation("ReferredUser", fields: [referredUserId], references: [id])
367
376
  membershipTier MembershipTier?
368
377
  description String?
369
- metadata String?
370
- createdAt DateTime @default(now())
371
- updatedAt DateTime @updatedAt
372
- referredUser User? @relation("ReferredUser", fields: [referredUserId], references: [id])
373
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
378
+ metadata String? // JSON string for additional context
379
+
380
+ // New Source Tracking
381
+ sourceType CreditSourceType?
382
+ sourceId String? // ID of ticket, booking, membership payment, etc.
383
+ sourceMetadata Json? // Additional context as proper JSON
384
+
385
+ // Expiration
386
+ earnedAt DateTime @default(now())
387
+ expiresAt DateTime? // 12 months from earnedAt for earned credits
388
+ redeemedAt DateTime? // When credits were spent
389
+ expiredAt DateTime? // When credits expired unused
390
+
391
+ // Tax Reporting
392
+ taxYear Int? // Year credits were earned
393
+ taxReported Boolean @default(false)
394
+ tax1099Issued Boolean @default(false)
395
+
396
+ createdAt DateTime @default(now())
397
+ updatedAt DateTime @updatedAt
374
398
 
399
+ @@index([userId, status])
400
+ @@index([userId, expiresAt])
401
+ @@index([userId, taxYear])
375
402
  @@index([userId])
376
403
  @@index([referralCode])
377
404
  @@index([transactionType])
378
405
  @@index([createdAt])
406
+ @@index([sourceType])
407
+ @@index([type])
379
408
  }
380
409
 
381
410
  model UserReferralCode {
@@ -745,19 +774,19 @@ model SocialMediaProfile {
745
774
  }
746
775
 
747
776
  model User {
748
- id String @id @default(cuid())
749
- username String? @unique
750
- email String @unique
751
- createdOn DateTime @default(now())
752
- stripeCustomerId String? @unique
753
- stripeAccountId String? @unique
754
- isSuperUser Boolean @default(false)
755
- isSuspended Boolean @default(false)
777
+ id String @id @default(cuid())
778
+ username String? @unique
779
+ email String @unique
780
+ createdOn DateTime @default(now())
781
+ stripeCustomerId String? @unique
782
+ stripeAccountId String? @unique
783
+ isSuperUser Boolean @default(false)
784
+ isSuspended Boolean @default(false)
756
785
  intent UserIntent?
757
786
  googleCalendarAccess String?
758
787
  givenName String?
759
788
  familyName String?
760
- nameChangeCount Int @default(0)
789
+ nameChangeCount Int @default(0)
761
790
  hash String?
762
791
  emailVerified DateTime?
763
792
  image String?
@@ -767,67 +796,82 @@ model User {
767
796
  sex Sex?
768
797
  organization String?
769
798
  jobTitle String?
770
- roles UserRole[] @default([User])
799
+ roles UserRole[] @default([User])
771
800
  aboutMe String?
772
801
  levelBadge String?
773
- temporaryBadges String[] @default([])
802
+ temporaryBadges String[] @default([])
774
803
  status UserStatus
775
804
  hostRating Float?
776
805
  totalRatings Int?
777
806
  magicLink String?
778
807
  magicLinkExpiration DateTime?
779
808
  hostNumber Int?
780
- foundingHostBadgeAwarded Boolean @default(false)
809
+ foundingHostBadgeAwarded Boolean @default(false)
781
810
  firstBashWithAttendeesDate DateTime?
782
- bashesCreatedCount Int @default(0)
783
- bashesPublishedCount Int @default(0)
784
- bashesApprovedCount Int @default(0)
785
- bashesCompletedCount Int @default(0)
811
+ bashesCreatedCount Int @default(0)
812
+ bashesPublishedCount Int @default(0)
813
+ bashesApprovedCount Int @default(0)
814
+ bashesCompletedCount Int @default(0)
786
815
  magicLinkUsed DateTime?
787
816
  idVerified DateTime?
788
817
  street String?
789
818
  city String?
790
819
  state String?
791
820
  zipCode String?
792
- country String? @default("US")
821
+ country String? @default("US")
793
822
  phone String?
794
- documentIDId String? @unique
795
- accepted Boolean? @default(false)
796
- boughtTicket Boolean? @default(false)
797
- noPay Boolean? @default(false)
798
- supportedEvent Boolean? @default(false)
823
+ documentIDId String? @unique
824
+ accepted Boolean? @default(false)
825
+ boughtTicket Boolean? @default(false)
826
+ noPay Boolean? @default(false)
827
+ supportedEvent Boolean? @default(false)
799
828
  suspendedUntil DateTime?
800
829
  suspendedById String?
801
- isLightweightAccount Boolean @default(false)
802
- notifyForTrendingBashes Boolean @default(false)
803
- trendingBashThreshold Int @default(10)
804
- artistsToSee String[] @default([])
830
+ isLightweightAccount Boolean @default(false)
831
+ notifyForTrendingBashes Boolean @default(false)
832
+ trendingBashThreshold Int @default(10)
833
+ artistsToSee String[] @default([])
805
834
  googleCalendarSyncSettings String?
806
- membershipTier MembershipTier @default(Basic)
835
+ membershipTier MembershipTier @default(Basic)
807
836
  membershipExpiresAt DateTime?
808
- membershipAutoRenew Boolean @default(false)
837
+ membershipAutoRenew Boolean @default(false)
809
838
  membershipBillingInterval String?
810
839
  membershipLastBilledAt DateTime?
811
- membershipFeaturedEventsUsed Int @default(0)
812
- membershipStripeSubscriptionId String? @unique
813
- isVerified Boolean @default(false)
840
+ membershipFeaturedEventsUsed Int @default(0)
841
+ membershipStripeSubscriptionId String? @unique
842
+ isVerified Boolean @default(false)
814
843
  verificationMethod String?
815
844
  verifiedAt DateTime?
816
- verificationScore Int @default(0)
845
+ verificationScore Int @default(0)
817
846
  biometricFingerprint String?
818
847
  venmoUsername String?
819
848
  venmoQRCodeUrl String?
820
849
  zelleEmail String?
821
850
  zellePhone String?
822
851
  zelleQRCodeUrl String?
823
- isAmbashador Boolean @default(false)
852
+ isAmbashador Boolean @default(false)
824
853
  ambashadorAwardedAt DateTime?
825
- isBashInsider Boolean @default(false)
854
+ isBashInsider Boolean @default(false)
826
855
  insiderAwardedAt DateTime?
827
- scoutTier ScoutTier @default(None)
856
+ scoutTier ScoutTier @default(None)
828
857
  scoutAwardedAt DateTime?
829
858
  agentAwardedAt DateTime?
830
- totalServiceReferrals Int @default(0)
859
+ totalServiceReferrals Int @default(0)
860
+
861
+ // BashCash System Fields
862
+ bashCreditsBalance Int @default(0)
863
+ bashCreditsEarnedLifetime Int @default(0)
864
+ bashCreditsSpentLifetime Int @default(0)
865
+ bashCashReferralCode String? @unique
866
+ referredById String?
867
+ referralPurchaseCredited Boolean @default(false)
868
+
869
+ // Security Fields
870
+ accountLockedUntil DateTime? // Account lockout timestamp for failed login protection
871
+ auditLogs AuditLog[] @relation("UserAuditLogs")
872
+ auditLogsPerformed AuditLog[] @relation("PerformedByUser")
873
+ consents UserConsent[]
874
+
831
875
  associatedBashes AssociatedBash[]
832
876
  associatedServices AssociatedService[]
833
877
  comment BashComment[]
@@ -921,6 +965,10 @@ model User {
921
965
  scoutReferralsMade ScoutReferral[] @relation("ScoutReferrer")
922
966
  scoutReferralsReceived ScoutReferral[] @relation("ScoutReferred")
923
967
  bookingCommissionsEarned BookingCommission[] @relation("CommissionReferrer")
968
+
969
+ // BashCash Referral Relations
970
+ referredBy User? @relation("Referrals", fields: [referredById], references: [id])
971
+ referrals User[] @relation("Referrals")
924
972
  }
925
973
 
926
974
  model UserPreferences {
@@ -4048,6 +4096,25 @@ enum CreditTransactionType {
4048
4096
  Earned
4049
4097
  Used
4050
4098
  Refund
4099
+ Redeemed // New: for redemptions
4100
+ Expired // New: for expired credits
4101
+ Reversed // New: for refunds/reversals
4102
+ }
4103
+
4104
+ enum CreditTransactionStatus {
4105
+ Pending
4106
+ Completed
4107
+ Reversed
4108
+ Expired
4109
+ }
4110
+
4111
+ enum CreditSourceType {
4112
+ MembershipReward // Monthly membership credits
4113
+ TicketPurchase // 5% cashback on ticket
4114
+ ServiceBooking // 3% cashback on service
4115
+ ReferralBonus // 10% of referee's first purchase
4116
+ AdminAdjustment // Manual credit by admin
4117
+ PromotionalBonus // Marketing campaigns
4051
4118
  }
4052
4119
 
4053
4120
  enum ReferralTier {
@@ -4062,6 +4129,164 @@ enum ScoutTier {
4062
4129
  Agent
4063
4130
  }
4064
4131
 
4132
+ // ============================================
4133
+ // Security & Audit Models
4134
+ // ============================================
4135
+
4136
+ model UserConsent {
4137
+ id String @id @default(cuid())
4138
+ userId String
4139
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
4140
+
4141
+ consentType ConsentType // Privacy policy, analytics, marketing, etc.
4142
+ consentVersion String // Version of policy accepted (e.g., "2025-01-08")
4143
+
4144
+ consented Boolean @default(true)
4145
+ consentedAt DateTime @default(now())
4146
+ withdrawnAt DateTime? // When consent was withdrawn
4147
+
4148
+ // Context
4149
+ ipAddress String?
4150
+ userAgent String?
4151
+ metadata Json? // Additional context
4152
+
4153
+ @@index([userId, consentType])
4154
+ @@index([consentType, consented])
4155
+ }
4156
+
4157
+ enum ConsentType {
4158
+ PrivacyPolicy // Required: User accepts privacy policy
4159
+ TermsOfService // Required: User accepts terms
4160
+ DataCollection // Required: Basic data collection for service
4161
+ Analytics // Optional: Google Analytics, Mixpanel, etc.
4162
+ Marketing // Optional: Promotional emails
4163
+ ThirdPartySharing // Optional: Share data with partners
4164
+ }
4165
+
4166
+ model AuditLog {
4167
+ id String @id @default(cuid())
4168
+ createdAt DateTime @default(now())
4169
+
4170
+ // Who performed the action
4171
+ performedById String?
4172
+ performedBy User? @relation("PerformedByUser", fields: [performedById], references: [id], onDelete: SetNull)
4173
+
4174
+ // Who/what was affected
4175
+ userId String?
4176
+ user User? @relation("UserAuditLogs", fields: [userId], references: [id], onDelete: SetNull)
4177
+
4178
+ // Action details
4179
+ action AuditAction // LOGIN_SUCCESS, LOGIN_FAILED, PAYMENT_PROCESSED, etc.
4180
+ category AuditCategory // Authentication, Payment, Admin, DataAccess, etc.
4181
+ severity AuditSeverity // Info, Warning, Critical
4182
+
4183
+ // Context
4184
+ ipAddress String?
4185
+ userAgent String?
4186
+ resourceType String? // "BashEvent", "Ticket", "User", etc.
4187
+ resourceId String? // ID of the affected resource
4188
+
4189
+ // Details (JSON for flexibility)
4190
+ metadata Json? // Additional context, error messages, etc.
4191
+
4192
+ // Result
4193
+ success Boolean @default(true)
4194
+ errorMessage String?
4195
+
4196
+ @@index([performedById, createdAt])
4197
+ @@index([userId, createdAt])
4198
+ @@index([action, createdAt])
4199
+ @@index([category, severity, createdAt])
4200
+ @@index([resourceType, resourceId])
4201
+ @@index([ipAddress])
4202
+ }
4203
+
4204
+ enum AuditAction {
4205
+ // Authentication
4206
+ LOGIN_SUCCESS
4207
+ LOGIN_FAILED
4208
+ LOGOUT
4209
+ PASSWORD_CHANGED
4210
+ PASSWORD_RESET_REQUESTED
4211
+ PASSWORD_RESET_COMPLETED
4212
+ EMAIL_VERIFIED
4213
+ ACCOUNT_CREATED
4214
+ ACCOUNT_LOCKED
4215
+ ACCOUNT_UNLOCKED
4216
+
4217
+ // Authorization
4218
+ ROLE_CHANGED
4219
+ PERMISSION_GRANTED
4220
+ PERMISSION_REVOKED
4221
+
4222
+ // User Management
4223
+ USER_SUSPENDED
4224
+ USER_UNSUSPENDED
4225
+ USER_DELETED
4226
+ USER_DATA_EXPORTED
4227
+ PROFILE_UPDATED
4228
+
4229
+ // Payment
4230
+ PAYMENT_INITIATED
4231
+ PAYMENT_COMPLETED
4232
+ PAYMENT_FAILED
4233
+ REFUND_ISSUED
4234
+ REFUND_FAILED
4235
+
4236
+ // BashCash
4237
+ CREDITS_EARNED
4238
+ CREDITS_REDEEMED
4239
+ CREDITS_EXPIRED
4240
+ CREDITS_ADJUSTED
4241
+
4242
+ // Events
4243
+ EVENT_CREATED
4244
+ EVENT_PUBLISHED
4245
+ EVENT_DELETED
4246
+ EVENT_TRANSFERRED
4247
+
4248
+ // Tickets
4249
+ TICKET_PURCHASED
4250
+ TICKET_TRANSFERRED
4251
+ TICKET_REFUNDED
4252
+
4253
+ // Admin Actions
4254
+ ADMIN_USER_IMPERSONATED
4255
+ ADMIN_DATA_MODIFIED
4256
+ ADMIN_SETTINGS_CHANGED
4257
+ ADMIN_REPORT_GENERATED
4258
+
4259
+ // Data Access
4260
+ DATA_EXPORTED
4261
+ DATA_IMPORTED
4262
+ SENSITIVE_DATA_ACCESSED
4263
+
4264
+ // Security
4265
+ SUSPICIOUS_ACTIVITY_DETECTED
4266
+ RATE_LIMIT_EXCEEDED
4267
+ IP_BLOCKED
4268
+ TOKEN_REVOKED
4269
+ }
4270
+
4271
+ enum AuditCategory {
4272
+ Authentication
4273
+ Authorization
4274
+ UserManagement
4275
+ Payment
4276
+ BashCash
4277
+ Events
4278
+ Tickets
4279
+ AdminAction
4280
+ DataAccess
4281
+ Security
4282
+ }
4283
+
4284
+ enum AuditSeverity {
4285
+ Info // Normal operations
4286
+ Warning // Potentially suspicious
4287
+ Critical // Security incidents
4288
+ }
4289
+
4065
4290
  enum VoucherStatus {
4066
4291
  Active
4067
4292
  Redeemed