@bash-app/bash-common 30.95.0 → 30.96.0

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.
@@ -90,10 +90,559 @@ export const MEMBERSHIP_PRICING = {
90
90
  Legend: { monthly: 99900, yearly: 1000000 }, // $999/month, $10,000/year
91
91
  };
92
92
 
93
+ // Helper: Get monthly price in cents for a tier (for BashCash calculations)
94
+ export const MEMBERSHIP_MONTHLY_PRICE_CENTS: Record<MembershipTier, number> = {
95
+ Basic: MEMBERSHIP_PRICING.Basic.monthly,
96
+ Creator: MEMBERSHIP_PRICING.Creator.monthly,
97
+ Pro: MEMBERSHIP_PRICING.Pro.monthly,
98
+ Elite: MEMBERSHIP_PRICING.Elite.monthly,
99
+ Legend: MEMBERSHIP_PRICING.Legend.monthly,
100
+ };
101
+
93
102
  export const MEMBERSHIP_TIER_HIERARCHY: MembershipTier[] = [
94
103
  'Basic', 'Creator', 'Pro', 'Elite', 'Legend'
95
104
  ];
96
105
 
106
+ // ============================================================================
107
+ // BASHCASH REWARDS SYSTEM
108
+ // ============================================================================
109
+
110
+ /**
111
+ * BashCash rewards per membership tier
112
+ * All amounts in CENTS (1 credit = 1 cent = $0.01)
113
+ */
114
+ export const BASHCASH_REWARDS: Record<MembershipTier, {
115
+ monthlyCredits: number; // Credits earned per month
116
+ ticketCashbackRate: number; // Cashback % on ticket purchases
117
+ serviceCashbackRate: number; // Cashback % on service bookings
118
+ }> = {
119
+ Basic: {
120
+ monthlyCredits: 0,
121
+ ticketCashbackRate: 0,
122
+ serviceCashbackRate: 0,
123
+ },
124
+ Creator: {
125
+ monthlyCredits: 10000, // 10,000 credits = $100/month
126
+ ticketCashbackRate: 0.05, // 5% cashback
127
+ serviceCashbackRate: 0.03, // 3% cashback
128
+ },
129
+ Pro: {
130
+ monthlyCredits: 40000, // 40,000 credits = $400/month
131
+ ticketCashbackRate: 0.05, // 5% cashback
132
+ serviceCashbackRate: 0.03, // 3% cashback
133
+ },
134
+ Elite: {
135
+ monthlyCredits: 120000, // 120,000 credits = $1,200/month
136
+ ticketCashbackRate: 0.05, // 5% cashback
137
+ serviceCashbackRate: 0.03, // 3% cashback
138
+ },
139
+ Legend: {
140
+ monthlyCredits: 250000, // 250,000 credits = $2,500/month
141
+ ticketCashbackRate: 0.05, // 5% cashback
142
+ serviceCashbackRate: 0.03, // 3% cashback
143
+ },
144
+ } as const;
145
+
146
+ /**
147
+ * BashCash system rules and limits
148
+ */
149
+ export const BASHCASH_CONFIG = {
150
+ // Referral bonuses
151
+ referralBonusRate: 0.10, // 10% of referee's first purchase
152
+ maxReferralCredits: 10000, // $100 cap on referral bonuses
153
+
154
+ // Credit lifecycle
155
+ creditExpirationMonths: 12, // Credits expire after 12 months
156
+
157
+ // Redemption rules
158
+ minimumRedemption: 100, // $1 minimum redemption (100 credits)
159
+ membershipRedemptionCap: 0.50, // 50% max BashCash for membership fees
160
+ } as const;
161
+
162
+ // ============================================================================
163
+ // SCOUT/AGENT REFERRAL PROGRAM
164
+ // ============================================================================
165
+
166
+ /**
167
+ * Scout program configuration for service provider referrals
168
+ */
169
+ export const SCOUT_PROGRAM_CONFIG = {
170
+ creditsPerProfile: 75, // 75 credits per service profile created
171
+ maxProfilesPerScout: 3, // Max 3 profiles per scout
172
+ scoutCommissionRate: 0.03, // 3% commission on completed bookings
173
+ agentCommissionRate: 0.06, // 6% commission (upgraded status)
174
+ agentThreshold: 5, // 5+ service profiles = Agent status
175
+ } as const;
176
+
177
+ // ============================================================================
178
+ // SECURITY & ACCOUNT PROTECTION
179
+ // ============================================================================
180
+
181
+ /**
182
+ * Security configuration for account protection and rate limiting
183
+ */
184
+ export const SECURITY_CONFIG = {
185
+ // Failed login tracking
186
+ maxFailedLoginAttempts: 5, // Lock account after 5 failed attempts
187
+ lockoutDurationMinutes: 30, // Lock account for 30 minutes
188
+ trackingWindowMinutes: 15, // Track attempts within 15-minute window
189
+ suspiciousActivityThreshold: 3, // Alert if 3+ accounts locked from same IP
190
+
191
+ // Geofencing
192
+ geofenceDefaultRadiusFeet: 500, // Default geofence radius (feet)
193
+ geofenceCheckIntervalMs: 60000, // Check geofence every 60 seconds
194
+ } as const;
195
+
196
+ // ============================================================================
197
+ // PLATFORM FEES & PRICING
198
+ // ============================================================================
199
+
200
+ /**
201
+ * Platform fee structure for Bash Events (tickets/donations)
202
+ * All amounts in CENTS to align with Stripe
203
+ */
204
+ export const BASH_EVENT_FEES: Record<MembershipTier, {
205
+ percent: number; // Fee percentage (e.g., 0.10 = 10%)
206
+ minimumCents: number; // Minimum fee in cents (e.g., 50 = $0.50)
207
+ capCents: number; // Maximum fee in cents (e.g., 25000 = $250)
208
+ }> = {
209
+ Basic: {
210
+ percent: 0.10, // 10%
211
+ minimumCents: 50, // $0.50 minimum
212
+ capCents: 25000, // $250 cap
213
+ },
214
+ Creator: {
215
+ percent: 0.06, // 6% (40% discount)
216
+ minimumCents: 50, // $0.50 minimum
217
+ capCents: 15000, // $150 cap
218
+ },
219
+ Pro: {
220
+ percent: 0.08, // 8% (20% discount)
221
+ minimumCents: 50, // $0.50 minimum
222
+ capCents: 20000, // $200 cap
223
+ },
224
+ Elite: {
225
+ percent: 0.04, // 4% (60% discount)
226
+ minimumCents: 50, // $0.50 minimum
227
+ capCents: 10000, // $100 cap
228
+ },
229
+ Legend: {
230
+ percent: 0.02, // 2% (80% discount)
231
+ minimumCents: 50, // $0.50 minimum
232
+ capCents: 5000, // $50 cap
233
+ },
234
+ } as const;
235
+
236
+ /**
237
+ * Platform fee structure for Service Bookings (Allies/Patrons)
238
+ * All amounts in CENTS to align with Stripe
239
+ */
240
+ export const SERVICE_BOOKING_FEES: Record<MembershipTier, {
241
+ percent: number; // Fee percentage (e.g., 0.15 = 15%)
242
+ capCents: number; // Maximum fee in cents
243
+ }> = {
244
+ Basic: {
245
+ percent: 0.15, // 15%
246
+ capCents: 37500, // $375 cap
247
+ },
248
+ Creator: {
249
+ percent: 0.09, // 9% (40% discount)
250
+ capCents: 22500, // $225 cap
251
+ },
252
+ Pro: {
253
+ percent: 0.12, // 12% (20% discount)
254
+ capCents: 30000, // $300 cap
255
+ },
256
+ Elite: {
257
+ percent: 0.06, // 6% (60% discount)
258
+ capCents: 15000, // $150 cap
259
+ },
260
+ Legend: {
261
+ percent: 0.05, // 5% (67% discount, sustainable floor)
262
+ capCents: 7500, // $75 cap
263
+ },
264
+ } as const;
265
+
266
+ /**
267
+ * Platform fee structure for Partner Payments (Vendors/Exhibitors/Sponsors)
268
+ * All amounts in CENTS to align with Stripe
269
+ */
270
+ export const PARTNER_PAYMENT_FEES: Record<MembershipTier, {
271
+ percent: number; // Fee percentage (e.g., 0.08 = 8%)
272
+ capCents: number; // Maximum fee in cents
273
+ }> = {
274
+ Basic: {
275
+ percent: 0.08, // 8%
276
+ capCents: 20000, // $200 cap
277
+ },
278
+ Creator: {
279
+ percent: 0.05, // 5% (37.5% discount, sustainable floor)
280
+ capCents: 12500, // $125 cap
281
+ },
282
+ Pro: {
283
+ percent: 0.06, // 6% (25% discount)
284
+ capCents: 15000, // $150 cap
285
+ },
286
+ Elite: {
287
+ percent: 0.05, // 5% (same as Creator, sustainable floor)
288
+ capCents: 7500, // $75 cap
289
+ },
290
+ Legend: {
291
+ percent: 0.05, // 5% (same as Creator/Elite, sustainable floor)
292
+ capCents: 7500, // $75 cap
293
+ },
294
+ } as const;
295
+
296
+ /**
297
+ * General platform pricing rules
298
+ */
299
+ export const PLATFORM_PRICING_CONFIG = {
300
+ // Ticket pricing
301
+ minimumTicketPriceCents: 500, // $5 minimum ticket price (quality signal)
302
+ minimumPlatformFeeCents: 50, // $0.50 minimum platform fee (covers Stripe)
303
+
304
+ // Membership trial
305
+ creatorTrialDays: 30, // 30-day free trial for Creator tier
306
+ } as const;
307
+
308
+ // Legacy export for backward compatibility with existing API code
309
+ export const CREATOR_TIER_TRIAL_DAYS = PLATFORM_PRICING_CONFIG.creatorTrialDays;
310
+
311
+ // ============================================================================
312
+ // PLATFORM FEE CALCULATION UTILITIES
313
+ // ============================================================================
314
+
315
+ /**
316
+ * Calculate platform fee for a Bash Event (ticket/donation)
317
+ * @param amountCents - Transaction amount in cents
318
+ * @param membershipTier - User's membership tier
319
+ * @returns Platform fee in cents
320
+ */
321
+ export function calculateBashEventFee(amountCents: number, membershipTier: MembershipTier): number {
322
+ const config = BASH_EVENT_FEES[membershipTier];
323
+
324
+ // Calculate percentage-based fee
325
+ let fee = Math.floor(amountCents * config.percent);
326
+
327
+ // Apply minimum fee
328
+ fee = Math.max(fee, config.minimumCents);
329
+
330
+ // Apply cap
331
+ fee = Math.min(fee, config.capCents);
332
+
333
+ return fee;
334
+ }
335
+
336
+ /**
337
+ * Calculate platform fee for a Service Booking
338
+ * @param amountCents - Transaction amount in cents
339
+ * @param membershipTier - User's membership tier
340
+ * @returns Platform fee in cents
341
+ */
342
+ export function calculateServiceBookingFee(amountCents: number, membershipTier: MembershipTier): number {
343
+ const config = SERVICE_BOOKING_FEES[membershipTier];
344
+
345
+ // Calculate percentage-based fee
346
+ let fee = Math.floor(amountCents * config.percent);
347
+
348
+ // Apply cap
349
+ fee = Math.min(fee, config.capCents);
350
+
351
+ return fee;
352
+ }
353
+
354
+ /**
355
+ * Calculate platform fee for a Partner Payment
356
+ * @param amountCents - Transaction amount in cents
357
+ * @param membershipTier - User's membership tier
358
+ * @returns Platform fee in cents
359
+ */
360
+ export function calculatePartnerPaymentFee(amountCents: number, membershipTier: MembershipTier): number {
361
+ const config = PARTNER_PAYMENT_FEES[membershipTier];
362
+
363
+ // Calculate percentage-based fee
364
+ let fee = Math.floor(amountCents * config.percent);
365
+
366
+ // Apply cap
367
+ fee = Math.min(fee, config.capCents);
368
+
369
+ return fee;
370
+ }
371
+
372
+ // ============================================================================
373
+ // MEMBERSHIP TIER LIMITS & RULES
374
+ // ============================================================================
375
+
376
+ /**
377
+ * Comprehensive limits and rules per membership tier
378
+ * Defines what each tier can and cannot do on the platform
379
+ */
380
+ export const MEMBERSHIP_LIMITS: Record<MembershipTier, {
381
+ // Event Creation
382
+ canCreateEvents: boolean;
383
+ minimumTicketPriceCents: number | null; // null = no minimum (Creator+)
384
+ maxEventsPerMonth: number; // -1 = unlimited
385
+ featuredEventsPerMonth: number; // 0 = must pay, -1 = unlimited
386
+
387
+ // Analytics & Insights
388
+ analyticsAccess: boolean;
389
+ advancedAnalytics: boolean; // Conversion trends, heatmaps
390
+
391
+ // Service Provider Features
392
+ vendorDirectoryAccess: boolean; // Can list services
393
+ maxServiceListings: number; // -1 = unlimited
394
+
395
+ // Monetization Tools
396
+ canCreatePromoCodes: boolean;
397
+ canSetCustomPricing: boolean;
398
+
399
+ // Platform Perks
400
+ prioritySearchPlacement: boolean; // Priority in search results
401
+ homepageVisibility: boolean; // Featured on homepage
402
+ tierBadgeDisplay: boolean; // Show tier badge
403
+
404
+ // Support & Access
405
+ prioritySupport: boolean; // Live chat/email priority
406
+ conciergeSupport: boolean; // White-glove service
407
+ betaFeatureAccess: boolean; // Early access to new features
408
+
409
+ // Exclusive Access
410
+ accessExclusiveEvents: boolean; // Creator-only, Elite-only, Legend-only events
411
+ bashSponsoredInvites: boolean; // Free invites to Bash-sponsored events
412
+ networkingMixers: boolean; // Exclusive networking events
413
+
414
+ // Business Tools
415
+ advancedMonetization: boolean; // Revenue tracking, payouts
416
+ marketingCampaigns: boolean; // Automated email campaigns
417
+ leadGeneration: boolean; // Lead capture tools
418
+ }> = {
419
+ Basic: {
420
+ // Event Creation
421
+ canCreateEvents: true,
422
+ minimumTicketPriceCents: 500, // $5 minimum
423
+ maxEventsPerMonth: -1, // Unlimited
424
+ featuredEventsPerMonth: 0, // Must pay
425
+
426
+ // Analytics & Insights
427
+ analyticsAccess: false,
428
+ advancedAnalytics: false,
429
+
430
+ // Service Provider Features
431
+ vendorDirectoryAccess: false,
432
+ maxServiceListings: 0,
433
+
434
+ // Monetization Tools
435
+ canCreatePromoCodes: false,
436
+ canSetCustomPricing: false,
437
+
438
+ // Platform Perks
439
+ prioritySearchPlacement: false,
440
+ homepageVisibility: false,
441
+ tierBadgeDisplay: false,
442
+
443
+ // Support & Access
444
+ prioritySupport: false,
445
+ conciergeSupport: false,
446
+ betaFeatureAccess: false,
447
+
448
+ // Exclusive Access
449
+ accessExclusiveEvents: false,
450
+ bashSponsoredInvites: false,
451
+ networkingMixers: false,
452
+
453
+ // Business Tools
454
+ advancedMonetization: false,
455
+ marketingCampaigns: false,
456
+ leadGeneration: false,
457
+ },
458
+
459
+ Creator: {
460
+ // Event Creation
461
+ canCreateEvents: true,
462
+ minimumTicketPriceCents: null, // No minimum!
463
+ maxEventsPerMonth: -1, // Unlimited
464
+ featuredEventsPerMonth: 0, // Must pay (but eligible)
465
+
466
+ // Analytics & Insights
467
+ analyticsAccess: false,
468
+ advancedAnalytics: false,
469
+
470
+ // Service Provider Features
471
+ vendorDirectoryAccess: false,
472
+ maxServiceListings: 0,
473
+
474
+ // Monetization Tools
475
+ canCreatePromoCodes: true, // ✅
476
+ canSetCustomPricing: true, // ✅
477
+
478
+ // Platform Perks
479
+ prioritySearchPlacement: false,
480
+ homepageVisibility: false,
481
+ tierBadgeDisplay: false,
482
+
483
+ // Support & Access
484
+ prioritySupport: false,
485
+ conciergeSupport: false,
486
+ betaFeatureAccess: true, // ✅ Early beta access
487
+
488
+ // Exclusive Access
489
+ accessExclusiveEvents: true, // ✅ Creator-only events
490
+ bashSponsoredInvites: false,
491
+ networkingMixers: false,
492
+
493
+ // Business Tools
494
+ advancedMonetization: false,
495
+ marketingCampaigns: false,
496
+ leadGeneration: false,
497
+ },
498
+
499
+ Pro: {
500
+ // Event Creation
501
+ canCreateEvents: true,
502
+ minimumTicketPriceCents: null, // No minimum
503
+ maxEventsPerMonth: -1, // Unlimited
504
+ featuredEventsPerMonth: 1, // ✅ 1 free/month
505
+
506
+ // Analytics & Insights
507
+ analyticsAccess: true, // ✅ Basic analytics
508
+ advancedAnalytics: false,
509
+
510
+ // Service Provider Features
511
+ vendorDirectoryAccess: true, // ✅ Can list services
512
+ maxServiceListings: 3, // 3 service listings
513
+
514
+ // Monetization Tools
515
+ canCreatePromoCodes: true,
516
+ canSetCustomPricing: true,
517
+
518
+ // Platform Perks
519
+ prioritySearchPlacement: true, // ✅ Priority placement
520
+ homepageVisibility: false,
521
+ tierBadgeDisplay: true, // ✅ Show Pro badge
522
+
523
+ // Support & Access
524
+ prioritySupport: false,
525
+ conciergeSupport: false,
526
+ betaFeatureAccess: true,
527
+
528
+ // Exclusive Access
529
+ accessExclusiveEvents: true,
530
+ bashSponsoredInvites: false,
531
+ networkingMixers: false,
532
+
533
+ // Business Tools
534
+ advancedMonetization: false,
535
+ marketingCampaigns: false,
536
+ leadGeneration: false,
537
+ },
538
+
539
+ Elite: {
540
+ // Event Creation
541
+ canCreateEvents: true,
542
+ minimumTicketPriceCents: null, // No minimum
543
+ maxEventsPerMonth: -1, // Unlimited
544
+ featuredEventsPerMonth: 3, // ✅ 3 free/month
545
+
546
+ // Analytics & Insights
547
+ analyticsAccess: true,
548
+ advancedAnalytics: true, // ✅ Advanced analytics
549
+
550
+ // Service Provider Features
551
+ vendorDirectoryAccess: true,
552
+ maxServiceListings: 10, // 10 service listings
553
+
554
+ // Monetization Tools
555
+ canCreatePromoCodes: true,
556
+ canSetCustomPricing: true,
557
+
558
+ // Platform Perks
559
+ prioritySearchPlacement: true,
560
+ homepageVisibility: true, // ✅ Homepage featured
561
+ tierBadgeDisplay: true, // ✅ Gold Elite badge
562
+
563
+ // Support & Access
564
+ prioritySupport: true, // ✅ Priority support
565
+ conciergeSupport: true, // ✅ Concierge service
566
+ betaFeatureAccess: true,
567
+
568
+ // Exclusive Access
569
+ accessExclusiveEvents: true, // ✅ Elite-only events
570
+ bashSponsoredInvites: true, // ✅ Free Bash invites
571
+ networkingMixers: false,
572
+
573
+ // Business Tools
574
+ advancedMonetization: true, // ✅ Revenue tools
575
+ marketingCampaigns: true, // ✅ Email campaigns
576
+ leadGeneration: true, // ✅ Lead capture
577
+ },
578
+
579
+ Legend: {
580
+ // Event Creation
581
+ canCreateEvents: true,
582
+ minimumTicketPriceCents: null, // No minimum
583
+ maxEventsPerMonth: -1, // Unlimited
584
+ featuredEventsPerMonth: -1, // ✅ Unlimited featured events!
585
+
586
+ // Analytics & Insights
587
+ analyticsAccess: true,
588
+ advancedAnalytics: true,
589
+
590
+ // Service Provider Features
591
+ vendorDirectoryAccess: true,
592
+ maxServiceListings: -1, // ✅ Unlimited services
593
+
594
+ // Monetization Tools
595
+ canCreatePromoCodes: true,
596
+ canSetCustomPricing: true,
597
+
598
+ // Platform Perks
599
+ prioritySearchPlacement: true,
600
+ homepageVisibility: true, // ✅ Homepage rotation
601
+ tierBadgeDisplay: true, // ✅ Platinum Legend badge
602
+
603
+ // Support & Access
604
+ prioritySupport: true,
605
+ conciergeSupport: true,
606
+ betaFeatureAccess: true,
607
+
608
+ // Exclusive Access
609
+ accessExclusiveEvents: true, // ✅ All exclusive events
610
+ bashSponsoredInvites: true,
611
+ networkingMixers: true, // ✅ Exclusive networking
612
+
613
+ // Business Tools
614
+ advancedMonetization: true,
615
+ marketingCampaigns: true,
616
+ leadGeneration: true,
617
+ },
618
+ } as const;
619
+
620
+ /**
621
+ * Check if a user has access to a specific feature based on their tier
622
+ * @param userTier - User's membership tier
623
+ * @param feature - Feature to check (key from MEMBERSHIP_LIMITS)
624
+ * @returns true if user has access
625
+ */
626
+ export function hasFeatureLimit(
627
+ userTier: MembershipTier,
628
+ feature: keyof typeof MEMBERSHIP_LIMITS[MembershipTier]
629
+ ): boolean {
630
+ return Boolean(MEMBERSHIP_LIMITS[userTier][feature]);
631
+ }
632
+
633
+ /**
634
+ * Get the limit value for a specific feature
635
+ * @param userTier - User's membership tier
636
+ * @param limit - Limit to check (e.g., 'maxEventsPerMonth')
637
+ * @returns Limit value (-1 = unlimited, 0 = none, positive number = limit)
638
+ */
639
+ export function getFeatureLimit(
640
+ userTier: MembershipTier,
641
+ limit: keyof typeof MEMBERSHIP_LIMITS[MembershipTier]
642
+ ): number | boolean | null {
643
+ return MEMBERSHIP_LIMITS[userTier][limit];
644
+ }
645
+
97
646
  export const MEMBERSHIP_FEATURES = {
98
647
  // Core Creator features
99
648
  NO_MINIMUM_TICKET_PRICE: 'no_minimum_ticket_price',