@bash-app/bash-common 29.50.0 → 29.52.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.
@@ -7,12 +7,20 @@ import {
7
7
  Invitation,
8
8
  Ticket,
9
9
  User,
10
- TicketTier, Service, Review, Media, BashComment, Recurrence, Contact,
11
- BashNotification, BashEventPromoCode,
10
+ TicketTier,
11
+ Service,
12
+ Review,
13
+ Media,
14
+ BashComment,
15
+ Recurrence,
16
+ Contact,
17
+ BashNotification,
18
+ BashEventPromoCode,
12
19
  Reminder,
13
20
  Checkout,
14
21
  ServiceLink,
15
- Link, Venue,
22
+ Link,
23
+ Venue,
16
24
  // Availability,
17
25
  TargetAudience,
18
26
  Vendor,
@@ -22,7 +30,9 @@ import {
22
30
  Sponsor,
23
31
  Organization,
24
32
  Booking,
25
- VolunteerService, Prisma, ServiceRange,
33
+ VolunteerService,
34
+ Prisma,
35
+ ServiceRange,
26
36
  StripeAccount,
27
37
  VisibilityPreference,
28
38
  BashEventType,
@@ -39,25 +49,37 @@ import {
39
49
  UserSubscription,
40
50
  SocialMediaProfile,
41
51
  SocialMediaPlatform,
52
+ ServiceSubscriptionCounts,
53
+ UserRating,
42
54
  } from "@prisma/client";
43
55
  import { SERVICE_LINK_DATA_TO_INCLUDE, UnionFromArray } from "./definitions";
44
56
 
45
57
  //------------------------------------------------------user subscriptions------------------------------------------------------
46
- export const PRIVATE_USER_SUBSCRIPTION_DATA_TO_SELECT = {
58
+ export const PUBLIC_USER_SUBSCRIPTION_DATA_TO_SELECT = {
47
59
  type: true,
48
60
  status: true,
49
- serviceSubscriptionTier: true,
50
61
  ownerId: true,
51
- stripeAccountId: true
62
+ subscriptionCount: true,
63
+ listedCount: true,
52
64
  } satisfies Prisma.UserSubscriptionSelect;
53
65
 
54
- export type UserSubscriptionExt = {
55
- stripeAccount: StripeAccountExt;
56
- } & UserSubscription;
66
+ export const PRIVATE_USER_SUBSCRIPTION_DATA_TO_SELECT = {
67
+ ...PUBLIC_USER_SUBSCRIPTION_DATA_TO_SELECT,
68
+ stripeAccountId: true,
69
+ stripeCheckoutSessionId: true,
70
+ } satisfies Prisma.UserSubscriptionSelect;
57
71
 
58
72
  export const USER_SUBSCRIPTION_DATA_TO_INCLUDE = {
59
- stripeAccount: true
73
+ stripeAccount: true,
74
+ subscriptionCount: true,
75
+ listedCount: true,
60
76
  } satisfies Prisma.UserSubscriptionInclude;
77
+
78
+ export type UserSubscriptionExt = {
79
+ stripeAccount?: StripeAccountExt;
80
+ subscriptionCount?: ServiceSubscriptionCounts;
81
+ listedCount?: ServiceSubscriptionCounts;
82
+ } & UserSubscription;
61
83
  //-------------------------------------------------------------------------------------------------------------------------------
62
84
 
63
85
  export const FRONT_END_USER_DATA_TO_SELECT = {
@@ -69,6 +91,21 @@ export const FRONT_END_USER_DATA_TO_SELECT = {
69
91
  uploadedImage: true,
70
92
  isSuperUser: true,
71
93
  socialMediaProfiles: true,
94
+ city: true,
95
+ state: true,
96
+ createdOn: true,
97
+ dob: true,
98
+ gender: true,
99
+ sex: true,
100
+ documentIDId: true,
101
+ // documentID: true,
102
+ reviews: true,
103
+ userRating: true,
104
+ contacts: true,
105
+ accepted: true, // Newly added field
106
+ boughtTicket: true, // Newly added field
107
+ noPay: true, // Newly added field
108
+ supportedEvent: true, // Newly added field
72
109
  } satisfies Prisma.UserSelect;
73
110
 
74
111
  export const PRIVATE_USER_ACCOUNT_TO_SELECT = {
@@ -80,8 +117,8 @@ export const PRIVATE_USER_ACCOUNT_TO_SELECT = {
80
117
  country: true,
81
118
  phone: true,
82
119
  userSubscription: {
83
- select: PRIVATE_USER_SUBSCRIPTION_DATA_TO_SELECT
84
- }
120
+ select: PRIVATE_USER_SUBSCRIPTION_DATA_TO_SELECT,
121
+ },
85
122
  } satisfies Prisma.UserSelect;
86
123
 
87
124
  export interface BashEventExt extends BashEvent {
@@ -94,45 +131,64 @@ export interface BashEventExt extends BashEvent {
94
131
  eventTasks: EventTask[];
95
132
  tickets?: Ticket[]; // Only include tickets that the user has purchased and not all tickets (could be thousands + privacy)
96
133
  // Do not include in fetch. Could be hundreds of these
97
- invitations: InvitationExt[];
134
+ invitations: Partial<InvitationExt>[];
98
135
  coordinates?: Coordinates[];
99
136
  }
100
137
 
101
138
  export const TICKET_TIER_DATA_TO_INCLUDE = {
139
+ tickets: {
140
+ include: {
141
+ owner: {
142
+ select: {
143
+ id: true,
144
+ email: true,
145
+ givenName: true,
146
+ familyName: true,
147
+ },
148
+ },
149
+ forUser: {
150
+ select: {
151
+ id: true,
152
+ email: true,
153
+ givenName: true,
154
+ familyName: true,
155
+ },
156
+ },
157
+ },
158
+ },
102
159
  promoCodes: true,
103
160
  } satisfies Prisma.TicketTierInclude;
104
161
 
105
162
  export const BASH_EVENT_DATA_TO_INCLUDE = {
106
163
  creator: {
107
- select: FRONT_END_USER_DATA_TO_SELECT
164
+ select: FRONT_END_USER_DATA_TO_SELECT,
108
165
  },
109
166
  targetAudience: true,
110
167
  amountOfGuests: true,
111
168
  recurrence: true,
112
- ticketTiers: {
113
- include: TICKET_TIER_DATA_TO_INCLUDE
114
- },
115
- eventTasks: true,
169
+ ticketTiers: true,
116
170
  media: true,
171
+ eventTasks: true,
172
+ invitations: true,
117
173
  } satisfies Prisma.BashEventInclude;
118
174
 
119
175
  export const BASH_EVENT_DATA_TO_CLONE = [
120
- 'ticketTiers',
121
- 'media',
122
- 'recurrence',
123
- 'invitations',
176
+ "ticketTiers",
177
+ "media",
178
+ "recurrence",
179
+ "invitations",
124
180
  ] as const;
125
181
 
126
182
  type RemoveCommonProperties<T, U> = keyof (Omit<T, keyof U> & Omit<U, keyof T>);
127
- type BashEventExtMinusDataToCloneType = Omit<BashEventExt, UnionFromArray<typeof BASH_EVENT_DATA_TO_CLONE>>;
183
+ type BashEventExtMinusDataToCloneType = Omit<
184
+ BashEventExt,
185
+ UnionFromArray<typeof BASH_EVENT_DATA_TO_CLONE>
186
+ >;
128
187
 
129
- export const BASH_EVENT_DATA_TO_REMOVE: RemoveCommonProperties<BashEvent, BashEventExtMinusDataToCloneType>[] = [
130
- 'creator',
131
- 'eventTasks',
132
- 'tickets',
133
- 'targetAudience',
134
- 'amountOfGuests',
135
- ];
188
+ export const BASH_EVENT_DATA_TO_REMOVE: RemoveCommonProperties<
189
+ BashEvent,
190
+ BashEventExtMinusDataToCloneType
191
+ >[] = ["creator", "eventTasks", "tickets", "targetAudience", "amountOfGuests"];
136
192
 
137
193
  //---------------Services------------------
138
194
  export interface ServiceExt extends Service {
@@ -193,7 +249,6 @@ export interface ServiceRatesAssociationExt extends ServiceRatesAssociation {
193
249
  media?: Media[];
194
250
  }
195
251
 
196
-
197
252
  export interface EventServiceExt extends EventService {
198
253
  service: ServiceExt;
199
254
  crowdSize?: AmountOfGuests;
@@ -246,7 +301,6 @@ export interface ServiceLinkExt extends ServiceLink {
246
301
  link: Link;
247
302
  }
248
303
 
249
-
250
304
  // Create the final object dynamically
251
305
  function createAllTrueObject<T extends string>(keys: T[]): Record<T, true> {
252
306
  return keys.reduce((acc, key) => {
@@ -266,51 +320,52 @@ const serviceKeysObject = {
266
320
  organization: true,
267
321
  } as const;
268
322
 
269
-
270
323
  export type ServiceSpecificName = keyof typeof serviceKeysObject;
271
324
 
272
325
  const serviceKeysArray = Object.keys(serviceKeysObject);
273
326
 
274
327
  export type ServiceSpecificType = ServiceExt[ServiceSpecificName];
275
328
 
276
- export const specificServiceMap : Record<ServiceTypes, ServiceSpecificName> = {
277
- "EventServices": "eventService",
278
- "EntertainmentServices": "entertainmentService",
279
- "Vendors": "vendor",
280
- "Exhibitors": "exhibitor",
281
- "Sponsors": "sponsor",
282
- "Venues": "venue",
283
- "Organizations": "organization"
329
+ export const specificServiceMap: Record<ServiceTypes, ServiceSpecificName> = {
330
+ EventServices: "eventService",
331
+ EntertainmentServices: "entertainmentService",
332
+ Vendors: "vendor",
333
+ Exhibitors: "exhibitor",
334
+ Sponsors: "sponsor",
335
+ Venues: "venue",
336
+ Organizations: "organization",
284
337
  } as const;
285
338
 
286
- export const serviceTypeToField = (serviceType : ServiceTypes) : ServiceSpecificName => {
339
+ export const serviceTypeToField = (
340
+ serviceType: ServiceTypes
341
+ ): ServiceSpecificName => {
287
342
  return specificServiceMap[serviceType];
288
- }
343
+ };
289
344
  export const SERVICE_PACKAGE_DATA_TO_INCLUDE = {
290
- serviceAddons: true
345
+ serviceAddons: true,
291
346
  } satisfies Prisma.ServicePackageInclude;
292
347
 
293
348
  export const SERVICE_DAILYRATES_DATA_TO_INCLUDE = {
294
- serviceRate: true
349
+ serviceRate: true,
295
350
  } satisfies Prisma.ServiceDailyRatesInclude;
296
351
 
297
352
  export const SERVICE_SPECIALRATES_DATA_TO_INCLUDE = {
298
- serviceRate: true
353
+ serviceRate: true,
299
354
  } satisfies Prisma.ServiceSpecialRatesInclude;
300
355
 
301
356
  export const SERVICE_RATES_ASSOCIATION_DATA_TO_INCLUDE = {
302
357
  serviceGeneralRates: true,
303
358
  serviceDailyRates: {
304
- include: SERVICE_DAILYRATES_DATA_TO_INCLUDE
359
+ include: SERVICE_DAILYRATES_DATA_TO_INCLUDE,
305
360
  },
306
361
  serviceSpecialRates: {
307
- include: SERVICE_SPECIALRATES_DATA_TO_INCLUDE
362
+ include: SERVICE_SPECIALRATES_DATA_TO_INCLUDE,
308
363
  },
309
364
  addons: true,
310
- packages: {
311
- include: SERVICE_PACKAGE_DATA_TO_INCLUDE
365
+ packages: {
366
+ include: SERVICE_PACKAGE_DATA_TO_INCLUDE,
312
367
  },
313
- media: true
368
+ media: true,
314
369
  } satisfies Prisma.ServiceRatesAssociationInclude;
315
370
 
316
371
  //------------Stripe Accounts--------------
@@ -318,17 +373,17 @@ export const PUBLIC_STRIPE_ACCOUNT_DATA_TO_SELECT = {
318
373
  logo: true,
319
374
  logoId: true,
320
375
  createdAt: true,
321
- updatedAt: true
376
+ updatedAt: true,
322
377
  } satisfies Prisma.StripeAccountSelect;
323
378
 
324
379
  export const STRIPE_ACCOUNT_DATA_TO_INCLUDE = {
325
380
  logo: true,
326
381
  owner: {
327
- select: FRONT_END_USER_DATA_TO_SELECT
382
+ select: FRONT_END_USER_DATA_TO_SELECT,
328
383
  },
329
384
  userSubscription: {
330
- select: PRIVATE_USER_SUBSCRIPTION_DATA_TO_SELECT
331
- }
385
+ select: PRIVATE_USER_SUBSCRIPTION_DATA_TO_SELECT,
386
+ },
332
387
  } satisfies Prisma.StripeAccountInclude;
333
388
 
334
389
  export interface StripeAccountExt extends StripeAccount {
@@ -337,10 +392,10 @@ export interface StripeAccountExt extends StripeAccount {
337
392
 
338
393
  export const SERVICE_DATA_TO_INCLUDE = {
339
394
  creator: {
340
- select: FRONT_END_USER_DATA_TO_SELECT
395
+ select: FRONT_END_USER_DATA_TO_SELECT,
341
396
  },
342
397
  owner: {
343
- select: FRONT_END_USER_DATA_TO_SELECT
398
+ select: FRONT_END_USER_DATA_TO_SELECT,
344
399
  },
345
400
  targetAudience: true,
346
401
  // amountOfGuests: true,
@@ -352,43 +407,49 @@ export const SERVICE_DATA_TO_INCLUDE = {
352
407
  media: true,
353
408
  stripeAccount: {
354
409
  // ...STRIPE_ACCOUNT_DATA_TO_INCLUDE,
355
- select: PUBLIC_STRIPE_ACCOUNT_DATA_TO_SELECT
410
+ select: PUBLIC_STRIPE_ACCOUNT_DATA_TO_SELECT,
356
411
  },
357
412
  // availableDateTimes: true,
358
413
  serviceLinks: {
359
- include: SERVICE_LINK_DATA_TO_INCLUDE
414
+ include: SERVICE_LINK_DATA_TO_INCLUDE,
360
415
  },
361
416
  serviceRatesAssociation: {
362
- include: SERVICE_RATES_ASSOCIATION_DATA_TO_INCLUDE
363
- }
417
+ include: SERVICE_RATES_ASSOCIATION_DATA_TO_INCLUDE,
418
+ },
364
419
  } satisfies Prisma.ServiceInclude;
365
420
 
366
421
  //full service data to include, includes specific service data
367
422
  export const SERVICE_FULL_DATA_TO_INCLUDE = {
368
423
  ...SERVICE_DATA_TO_INCLUDE,
369
- ...createAllTrueObject(serviceKeysArray)
424
+ ...createAllTrueObject(serviceKeysArray),
370
425
  } satisfies Prisma.ServiceInclude;
371
426
 
372
427
  export const SERVICE_FULL_DATA_TO_CLONE = [
373
- 'media',
374
- 'targetAudience',
375
- 'serviceLinks',
428
+ "media",
429
+ "targetAudience",
430
+ "serviceLinks",
376
431
  // ...Object.values(specificServiceMap)
377
432
  ] as const;
378
433
 
379
- type ServiceExtMinusDataToCloneType = Omit<ServiceExt, UnionFromArray<typeof SERVICE_FULL_DATA_TO_CLONE>>;
380
- export const SERVICE_FULL_DATA_TO_REMOVE: RemoveCommonProperties<Service, ServiceExtMinusDataToCloneType>[] = [
381
- 'creator',
382
- 'owner',
383
- 'bookings',
384
- ] as const;
385
-
386
- export const VENUE_DATA_TO_CLONE = [
387
-
388
- ] as const;
389
-
390
- type VenueExtMinusDataToCloneType = Omit<Venue, UnionFromArray<typeof VENUE_DATA_TO_CLONE>>;
391
- export const VENUE_DATA_TO_REMOVE: RemoveCommonProperties<Venue, VenueExtMinusDataToCloneType>[] = [
434
+ type ServiceExtMinusDataToCloneType = Omit<
435
+ ServiceExt,
436
+ UnionFromArray<typeof SERVICE_FULL_DATA_TO_CLONE>
437
+ >;
438
+ export const SERVICE_FULL_DATA_TO_REMOVE: RemoveCommonProperties<
439
+ Service,
440
+ ServiceExtMinusDataToCloneType
441
+ >[] = ["creator", "owner", "bookings"] as const;
442
+
443
+ export const VENUE_DATA_TO_CLONE = [] as const;
444
+
445
+ type VenueExtMinusDataToCloneType = Omit<
446
+ Venue,
447
+ UnionFromArray<typeof VENUE_DATA_TO_CLONE>
448
+ >;
449
+ export const VENUE_DATA_TO_REMOVE: RemoveCommonProperties<
450
+ Venue,
451
+ VenueExtMinusDataToCloneType
452
+ >[] = [
392
453
  // 'bashEvents',
393
454
  ] as const;
394
455
  //-----------------------------------------
@@ -419,7 +480,6 @@ export interface TargetAudienceExt extends TargetAudience {
419
480
  customAttributes?: { [key: string]: any };
420
481
  }
421
482
 
422
-
423
483
  export const BASH_NOTIFICATION_DATA_TO_INCLUDE = {
424
484
  bashEvent: {
425
485
  select: {
@@ -440,27 +500,26 @@ export interface EventTaskExt extends EventTask {
440
500
 
441
501
  export const EVENT_TASK_DATA_TO_INCLUDE = {
442
502
  creator: {
443
- select: FRONT_END_USER_DATA_TO_SELECT
503
+ select: FRONT_END_USER_DATA_TO_SELECT,
444
504
  },
445
505
  assignedTo: {
446
- select: FRONT_END_USER_DATA_TO_SELECT
447
- }
506
+ select: FRONT_END_USER_DATA_TO_SELECT,
507
+ },
448
508
  } satisfies Prisma.EventTaskInclude;
449
509
 
450
-
451
510
  export interface InvitationExt extends Invitation {
452
- creator: PublicUser;
453
- sentTo: PublicUser;
454
- tickets: Ticket[];
455
- associatedBash?: AssociatedBash | null;
511
+ creator: PublicUser; // Include full details of the creator
512
+ sentTo?: PublicUser; // Full details of the user the invitation was sent to
513
+ associatedBash?: Partial<AssociatedBashExt> | null
514
+ tickets: Ticket[]; // Tickets associated with the invitation
456
515
  }
457
516
 
458
517
  export const INVITATION_DATA_TO_INCLUDE = {
459
518
  creator: {
460
- select: FRONT_END_USER_DATA_TO_SELECT
519
+ select: FRONT_END_USER_DATA_TO_SELECT,
461
520
  },
462
521
  sentTo: {
463
- select: FRONT_END_USER_DATA_TO_SELECT
522
+ select: FRONT_END_USER_DATA_TO_SELECT,
464
523
  },
465
524
  tickets: true,
466
525
  } satisfies Prisma.InvitationInclude;
@@ -471,8 +530,8 @@ export interface InvitationExtraData extends Invitation {
471
530
  }
472
531
 
473
532
  export interface AssociatedBashExt extends AssociatedBash {
474
- bashEvent: BashEventExt;
475
- invitation: InvitationExt;
533
+ bashEvent: Partial<BashEventExt>;
534
+ invitation?: Partial<InvitationExt>;
476
535
  }
477
536
 
478
537
  export interface AssociatedServiceExt extends AssociatedService {
@@ -482,16 +541,16 @@ export interface AssociatedServiceExt extends AssociatedService {
482
541
 
483
542
  export const ASSOCIATED_BASH_DATA_TO_INCLUDE = {
484
543
  bashEvent: {
485
- include: BASH_EVENT_DATA_TO_INCLUDE
544
+ include: BASH_EVENT_DATA_TO_INCLUDE,
486
545
  },
487
546
  invitation: {
488
- include: INVITATION_DATA_TO_INCLUDE
489
- }
547
+ include: INVITATION_DATA_TO_INCLUDE,
548
+ },
490
549
  } satisfies Prisma.AssociatedBashInclude;
491
550
 
492
551
  export const ASSOCIATED_SERVICE_DATA_TO_INCLUDE = {
493
552
  service: {
494
- include: SERVICE_DATA_TO_INCLUDE
553
+ include: SERVICE_DATA_TO_INCLUDE,
495
554
  },
496
555
  // invitation: {
497
556
  // include: INVITATION_DATA_TO_INCLUDE
@@ -512,27 +571,27 @@ export interface TicketExt extends Ticket {
512
571
 
513
572
  export interface CheckoutExt extends Checkout {
514
573
  owner: PublicUser;
515
- tickets: Ticket[]
574
+ tickets: Ticket[];
516
575
  }
517
576
 
518
577
  export const CHECKOUT_DATA_TO_INCLUDE = {
519
578
  owner: {
520
- select: FRONT_END_USER_DATA_TO_SELECT
579
+ select: FRONT_END_USER_DATA_TO_SELECT,
521
580
  },
522
581
  tickets: {
523
582
  select: {
524
- ownerId: true
525
- }
526
- }
583
+ ownerId: true,
584
+ },
585
+ },
527
586
  } satisfies Prisma.CheckoutInclude;
528
587
 
529
588
  export interface ReviewExt extends Review {
530
- comments: BashComment[];
589
+ comments?: BashComment[];
531
590
  }
532
591
 
533
592
  export const CONTACT_DATA_TO_INCLUDE = {
534
593
  contactOwner: {
535
- select: FRONT_END_USER_DATA_TO_SELECT
594
+ select: FRONT_END_USER_DATA_TO_SELECT,
536
595
  },
537
596
  } satisfies Prisma.ContactInclude;
538
597
 
@@ -552,18 +611,36 @@ export interface UserExt extends User {
552
611
  createdServices?: ServiceExt[];
553
612
  password?: string;
554
613
  otp?: string;
614
+ userRating?: UserRating[];
555
615
  }
556
616
 
557
617
  export const USER_DATA_SELECT_REVIEWS_COMMENTS = {
558
618
  reviews: {
559
- include: {
560
- comments: true
561
- }
562
- }
619
+ select: {
620
+ id: true,
621
+ rating: true,
622
+ creatorId: true, // Fetches the creatorId from Review
623
+ bashEventId: true, // Fetches the bashEventId
624
+ createdAt: true,
625
+ updatedAt: true,
626
+ comments: {
627
+ // This matches the relation field in the schema
628
+ select: {
629
+ id: true,
630
+ content: true,
631
+ },
632
+ },
633
+ },
634
+ },
563
635
  } satisfies Prisma.UserSelect;
564
636
 
637
+ export type PublicUser = Pick<
638
+ UserExt,
639
+ keyof typeof FRONT_END_USER_DATA_TO_SELECT
640
+ > &
641
+ Partial<Pick<UserExt, keyof typeof USER_DATA_SELECT_REVIEWS_COMMENTS>>;
565
642
 
566
- export type PublicUser = Pick<UserExt, keyof typeof FRONT_END_USER_DATA_TO_SELECT>
567
- & Partial<Pick<UserExt, keyof typeof USER_DATA_SELECT_REVIEWS_COMMENTS>>;
568
-
569
- export type PublicStripeAccount = Pick<StripeAccountExt, keyof typeof PUBLIC_STRIPE_ACCOUNT_DATA_TO_SELECT>;
643
+ export type PublicStripeAccount = Pick<
644
+ StripeAccountExt,
645
+ keyof typeof PUBLIC_STRIPE_ACCOUNT_DATA_TO_SELECT
646
+ >;
package/src/index.ts CHANGED
@@ -11,6 +11,9 @@ export * from "./utils/sortUtils";
11
11
  export * from "./utils/apiUtils";
12
12
  export * from "./utils/urlUtils";
13
13
  export * from "./utils/promoCodesUtils";
14
+ export * from "./utils/userPromoCodeUtils";
15
+ export * from "./utils/userSubscriptionUtils";
14
16
  export * from "./utils/service/serviceUtils";
15
17
  export * from "./utils/service/venueUtils";
16
18
  export * from "./utils/stripeAccountUtils";
19
+ export * from "./utils/entityUtils";
@@ -0,0 +1,4 @@
1
+ export const ENTITIES = {
2
+ Service: "Service",
3
+ BashEvent: "BashEvent",
4
+ } as const;