@bash-app/bash-common 29.67.0 → 29.68.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.
@@ -5,6 +5,8 @@ import {
5
5
  Contact,
6
6
  DayOfWeek,
7
7
  Prisma,
8
+ ServiceBookingAddOn,
9
+ ServiceBookingDay,
8
10
  // Rate,
9
11
  ServiceTypes,
10
12
  Ticket,
@@ -21,6 +23,12 @@ import {
21
23
  BashEventExt,
22
24
  } from "./extendedSchemas";
23
25
  import { ServiceSubscriptionTier } from "./utils/userSubscriptionUtils";
26
+ import {
27
+ ServiceAddonInput,
28
+ ServiceGetPriceToBookResult,
29
+ } from "./utils/service/serviceBookingUtils";
30
+ import { LuxonDateRange } from "./utils/luxonUtils";
31
+ import { ServiceCantBookReason } from "./utils/service/serviceBookingApiUtils";
24
32
 
25
33
  export const PASSWORD_MIN_LENGTH = 8 as const;
26
34
  export const PASSWORD_REQUIREMENTS_REGEX = new RegExp(
@@ -181,7 +189,6 @@ export type RequiredStripeInfoMissingErrorDataType = {
181
189
  };
182
190
  export type ContactOrUser = Contact | PublicUser;
183
191
 
184
- export type UnionFromArray<T extends ReadonlyArray<any>> = T[number];
185
192
  export type ValueOf<T> = T[keyof T];
186
193
 
187
194
  export type FilterFields = {
@@ -201,6 +208,65 @@ export type TicketTierWherePriceIsAString = Omit<TicketTier, "price"> & {
201
208
  price: string;
202
209
  } & { cannotDelete: boolean };
203
210
 
211
+ export type ServiceAddonApiParams = {
212
+ addonId: string;
213
+ chosenQuantity: number;
214
+ };
215
+
216
+ export type ServiceBookedDayApiParams = {
217
+ serviceId: string;
218
+ forUserId: number;
219
+
220
+ startDate: string;
221
+ endDate: string;
222
+ addOns: ServiceAddonApiParams[];
223
+
224
+ isFreeGuest?: boolean;
225
+ allowPromiseToPay?: boolean;
226
+ };
227
+
228
+ export type ServiceBookedDayApiParamsLuxon = Omit<
229
+ ServiceBookedDayApiParams,
230
+ "startDate" | "endDate"
231
+ > & {
232
+ dateTimeRange: LuxonDateRange;
233
+ };
234
+
235
+ export type ServiceBookingApiParamsLuxon = Omit<
236
+ ServiceBookingApiParams,
237
+ "bookedDays"
238
+ > & {
239
+ bookedDays: ServiceBookedDayApiParamsLuxon[];
240
+ };
241
+
242
+ export type ServiceBookingApiParams = {
243
+ serviceId: string;
244
+ bookedDays: ServiceBookedDayApiParams[];
245
+ timezone: string;
246
+ };
247
+
248
+ export type ServiceCanBookApiParams = {} & ServiceBookingApiParams;
249
+
250
+ export type ServicePriceToBookApiParams = {
251
+ // stripeAccountDBId: string;
252
+ } & ServiceBookingApiParams;
253
+
254
+ export type ServicePriceToBookApiResult = {
255
+ // taxes: number;
256
+ // totalAfterTaxes: number;
257
+ // currency: string;
258
+ } & ServiceGetPriceToBookResult;
259
+
260
+ // export type ServiceBookingApiResult = {
261
+ // serviceId: string;
262
+ // bookedDays: ServiceBookingDay[];
263
+ // };
264
+
265
+ export type ServiceCanBookApiResult = {
266
+ canBook: boolean;
267
+ reason?: ServiceCantBookReason;
268
+ };
269
+
204
270
  export interface DeletedAndHiddenTiers {
205
271
  deletedTiers: TicketTier[];
206
272
  hiddenTiers: TicketTier[];
@@ -537,28 +603,6 @@ export const DressTagsToString: { [key in BashEventDressTags]: string } = {
537
603
  // [ServicesTags.AwardRecipient]: "Award recipient"
538
604
  // }
539
605
 
540
- export type DayOfWeekIdx = 1 | 2 | 3 | 4 | 5 | 6 | 7;
541
-
542
- export const DayOfWeekToString: { [key in DayOfWeek]: string } = {
543
- [DayOfWeek.Sunday]: "S",
544
- [DayOfWeek.Monday]: "M",
545
- [DayOfWeek.Tuesday]: "T",
546
- [DayOfWeek.Wednesday]: "W",
547
- [DayOfWeek.Thursday]: "T",
548
- [DayOfWeek.Friday]: "F",
549
- [DayOfWeek.Saturday]: "S",
550
- };
551
-
552
- export const DayOfWeekToIdx: { [key in DayOfWeek]: DayOfWeekIdx } = {
553
- [DayOfWeek.Sunday]: 1,
554
- [DayOfWeek.Monday]: 2,
555
- [DayOfWeek.Tuesday]: 3,
556
- [DayOfWeek.Wednesday]: 4,
557
- [DayOfWeek.Thursday]: 5,
558
- [DayOfWeek.Friday]: 6,
559
- [DayOfWeek.Saturday]: 7,
560
- };
561
-
562
606
  export const YearsOfExperienceToString: { [key in YearsOfExperience]: string } =
563
607
  {
564
608
  [YearsOfExperience.LessThanOneYear]: "Less than one year",
@@ -575,118 +619,131 @@ export const BashEventTypeToString: BashEventTypeToStringType = {
575
619
  [BashEventType.AnimeAndCosplayFestival]: "Anime and Cosplay Festival",
576
620
  [BashEventType.AnniversaryCelebration]: "Anniversary Celebration",
577
621
  [BashEventType.ArtExhibitOpening]: "Art Exhibit Opening",
578
- [BashEventType.ArtAndCraftNight]: "Art and Craft Night",
579
- [BashEventType.BBQCookout]: "BBQ Cookout",
580
- [BashEventType.BabyShower]: "Baby Shower",
581
622
  [BashEventType.BachelorOrBacheloretteParty]: "Bachelor/Bachelorette Party",
582
623
  [BashEventType.BeachParty]: "Beach Party",
583
- [BashEventType.Birthday]: "Birthday",
584
624
  [BashEventType.BoatPartyOrCruise]: "Boat Party or Cruise",
585
- [BashEventType.Bonfire]: "Bonfire",
586
- [BashEventType.BookClubMeeting]: "Book Club Meeting",
587
- [BashEventType.BridalShower]: "Bridal Shower",
588
- [BashEventType.BrunchGathering]: "Brunch Gathering",
589
625
  [BashEventType.CarShow]: "Car Show",
590
626
  [BashEventType.CarnivalAndFair]: "Carnival and Fair",
591
627
  [BashEventType.CasinoNight]: "Casino Night",
592
628
  [BashEventType.CasualMixer]: "Casual Mixer",
593
- [BashEventType.CharityBall]: "Charity Ball",
594
- [BashEventType.CharityFundraiser]: "Charity Fundraiser",
595
629
  [BashEventType.ChristmasParty]: "Christmas Party",
596
- [BashEventType.ChurchEvent]: "Church Event",
630
+ [BashEventType.CharityGala]: "Charity Gala",
597
631
  [BashEventType.CircusOrCarnivalParty]: "Circus/Carnival Party",
598
- [BashEventType.CocktailParty]: "Cocktail Party",
599
632
  [BashEventType.CollegeParty_FraternityOrSorority]:
600
633
  "College Party (Fraternity/Sorority)",
601
634
  [BashEventType.ComedyShowOrStandUpComedyNight]:
602
635
  "Comedy Show Or Stand-Up Comedy Night",
603
636
  [BashEventType.ComicConvention]: "Comic Convention",
637
+ [BashEventType.CommunityMovieNight]: "Community Movie Night",
604
638
  [BashEventType.Competition]: "Competition",
605
639
  [BashEventType.Concert]: "Concert",
606
640
  [BashEventType.CookingCompetition]: "Cooking Competition",
607
641
  [BashEventType.CorporateEventOrOfficeParty]: "Corporate Event/Office Party",
608
- [BashEventType.CostumeParty_Theme_Based]: "Costume Party (Theme-Based)",
609
642
  [BashEventType.CulturalFestival]: "Cultural Festival",
610
643
  [BashEventType.DanceParty]: "Dance Party",
644
+ [BashEventType.ESportsGamingTournament]: "E-sports Gaming Tournament",
645
+ [BashEventType.LuxuryRetreat]: "Luxury Retreat",
646
+ [BashEventType.FashionShow]: "Fashion Show",
647
+ [BashEventType.Festival]: "Festival",
648
+ [BashEventType.FestivalFilm]: "Film Festival",
649
+ [BashEventType.FestivalFood]: "Food Festival",
650
+ [BashEventType.Fundraiser]: "Fundraiser",
651
+ [BashEventType.HalloweenParty]: "Halloween Party",
652
+ [BashEventType.HolidayParty]: "Holiday Party",
653
+ [BashEventType.HouseParty]: "House Party",
654
+ [BashEventType.KaraokeNight]: "Karaoke Night",
655
+ [BashEventType.MansionParty]: "Mansion Party",
656
+ [BashEventType.MardiGras]: "Mardi Gras",
657
+ [BashEventType.MasqueradeBall]: "Masquerade Ball",
658
+ [BashEventType.Mastermind]: "Mastermind",
659
+ [BashEventType.MoviePremiere]: "Movie Premiere",
660
+ [BashEventType.MusicFestival]: "Music Festival",
661
+ [BashEventType.NewYearsEveCelebration]: "New Year's Eve Celebration",
662
+ [BashEventType.OpenMicNight]: "Open Mic Night",
663
+ [BashEventType.OutdoorConcert]: "Outdoor Concert",
664
+ [BashEventType.Parade]: "Parade",
665
+ [BashEventType.Potluck]: "Potluck",
666
+ [BashEventType.PoolParty]: "Pool Party",
667
+ [BashEventType.ProductLaunch]: "Product Launch",
668
+ [BashEventType.ProfessionalNetworkingEvent]: "Professional Networking Event",
669
+ [BashEventType.Rave]: "Rave (EDM)",
670
+ [BashEventType.Reunion]: "Reunion",
671
+ [BashEventType.SchoolEvent]: "School Event",
672
+ [BashEventType.UniversityEvent]: "University Event",
673
+ [BashEventType.SportsTournament]: "Sports Tournament",
674
+ [BashEventType.PubCrawl]: "Pub Crawl",
675
+ [BashEventType.Tournament]: "Tournament",
676
+ [BashEventType.TradeShow]: "Trade Show",
677
+ [BashEventType.ValentinesDayParty]: "Valentine's Day Party",
678
+ [BashEventType.WeddingReception]: "Wedding Reception",
679
+ [BashEventType.WellnessFestival]: "Wellness Festival",
680
+ [BashEventType.WineTastingEvent]: "Wine Tasting Event",
681
+ [BashEventType.Other]: "Other",
682
+ [BashEventType.ExclusiveLuxuryRetreat]: "Exclusive Luxury Retreat",
683
+ [BashEventType.LaunchParty]: "Launch Party",
684
+ [BashEventType.ArtAndCraftNight]: "Art and Craft Night",
685
+ [BashEventType.BBQCookout]: "BBQ Cookout",
686
+ [BashEventType.BabyShower]: "Baby Shower",
687
+ [BashEventType.Birthday]: "Birthday",
688
+ [BashEventType.Bonfire]: "Bonfire",
689
+ [BashEventType.BookClubMeeting]: "Book Club Meeting",
690
+ [BashEventType.BridalShower]: "Bridal Shower",
691
+ [BashEventType.BrunchGathering]: "Brunch Gathering",
692
+ [BashEventType.CharityFundraiser]: "Charity Fundraiser",
693
+ [BashEventType.ChurchEvent]: "Church Event",
694
+ [BashEventType.CocktailParty]: "Cocktail Party",
695
+ [BashEventType.CostumeParty_Theme_Based]: "Theme-Based Costume Party",
611
696
  [BashEventType.DesertRave]: "Desert Rave",
612
697
  [BashEventType.DiscoNight]: "Disco Night",
613
698
  [BashEventType.EasterGathering]: "Easter Gathering",
614
699
  [BashEventType.EngagementParty]: "Engagement Party",
615
- [BashEventType.ESportsGamingTournament]: "E-sports Gaming Tournament",
616
- [BashEventType.ExclusiveLuxuryRetreat]: "Exclusive Luxury Retreat",
617
700
  [BashEventType.FantasyThemedParty]: "Fantasy Themed Party",
618
- [BashEventType.FashionShow]: "Fashion Show",
619
701
  [BashEventType.Fireside]: "Fireside",
620
702
  [BashEventType.FitnessFestival]: "Fitness Festival",
621
703
  [BashEventType.FlashMob]: "Flash Mob",
622
- [BashEventType.Festival]: "Festival",
623
- [BashEventType.FestivalFilm]: "Film Festival",
624
- [BashEventType.FestivalFood]: "Food Festival",
625
704
  [BashEventType.FundraisingEvent]: "Fundraising Event",
626
705
  [BashEventType.GalaDinner]: "Gala Dinner",
627
706
  [BashEventType.GameNight]: "Game Night",
628
707
  [BashEventType.GamingEvent]: "Gaming Event",
629
708
  [BashEventType.GardenParty]: "Garden Party",
630
- [BashEventType.GoingAwayPartyOrFarewell]: "Going-away Party or Farewell",
709
+ [BashEventType.GoingAwayPartyOrFarewell]: "Going Away Party/Farewell",
631
710
  [BashEventType.GraduationParty]: "Graduation Party",
632
- [BashEventType.HalloweenCostumeParty]: "Halloween Costume Party",
633
711
  [BashEventType.HanukkahParty]: "Hanukkah Party",
634
712
  [BashEventType.HistoricalEraParty]: "Historical Era Party",
635
- [BashEventType.HolidayParty]: "Holiday Party",
636
- [BashEventType.HouseParty]: "House Party",
637
713
  [BashEventType.HousewarmingParty]: "Housewarming Party",
638
- [BashEventType.KaraokeNight]: "Karaoke Night",
639
714
  [BashEventType.KiteFlyingFestival]: "Kite Flying Festival",
640
715
  [BashEventType.LiveBandPerformanceInALocalVenue]:
641
716
  "Live Band Performance in a Local Venue",
642
717
  [BashEventType.Luau]: "Luau",
643
- [BashEventType.MansionParty]: "Mansion Party",
644
- [BashEventType.MardiGras]: "Mardi Gras",
645
- [BashEventType.MasqueradeBall]: "Masquerade Ball",
646
718
  [BashEventType.MotorcycleRally]: "Motorcycle Rally",
647
719
  [BashEventType.MovieNight]: "Movie Night",
648
- [BashEventType.MoviePremiere]: "Movie Premiere",
649
- [BashEventType.MusicFestival]: "Music Festival",
650
- [BashEventType.NewYearsEveCelebration]: "New Year's Eve Celebration",
651
- [BashEventType.OpenMicNight]: "Open Mic Night",
652
720
  [BashEventType.OutdoorActivity]: "Outdoor Activity",
653
- [BashEventType.OutdoorConcert]: "Outdoor Concert",
654
721
  [BashEventType.OutdoorMovieNight_WithAProjector]:
655
- "Outdoor Movie Night (With a Projector)",
656
- [BashEventType.Parade]: "Parade",
722
+ "Outdoor Movie Night (With Projector)",
657
723
  [BashEventType.Party]: "Party",
658
- [BashEventType.PoolParty]: "Pool Party",
659
- [BashEventType.Potluck]: "Potluck",
660
- [BashEventType.PotluckVegan]: "Potluck (Vegan)",
724
+ [BashEventType.PotluckVegan]: "Vegan Potluck",
661
725
  [BashEventType.PreParty]: "Pre-Party",
662
- [BashEventType.ProductLaunch]: "Product Launch",
663
- [BashEventType.ProfessionalNetworkingEvent]: "Professional Networking Event",
664
726
  [BashEventType.Rave_General]: "Rave (General)",
665
727
  [BashEventType.RetirementCelebration]: "Retirement Celebration",
666
728
  [BashEventType.Reunion_FamilyOrSchoolOrFriends]:
667
729
  "Reunion (Family/School/Friends)",
668
730
  [BashEventType.SafariAdventureParty]: "Safari Adventure Party",
669
731
  [BashEventType.SchoolEvent_MiddleSchoolOrHighSchoolOrCollege]:
670
- "School Event (MiddleSchool, High School, College)",
671
- [BashEventType.ScienceFictionThemedParty]: "Science Fiction-Themed Party",
732
+ "School Event (Middle School/High School/College)",
733
+ [BashEventType.ScienceFictionThemedParty]: "Science Fiction Themed Party",
672
734
  [BashEventType.SocialClubEvent]: "Social Club Event",
673
- [BashEventType.SportsTournament]: "Sports Tournament",
674
735
  [BashEventType.SportsWatchParty]: "Sports Watch Party",
675
736
  [BashEventType.SuperheroThemedParty]: "Superhero Themed Party",
676
- [BashEventType.SurfCompetition]: "Surf Competition",
677
737
  [BashEventType.ThanksgivingDinner]: "Thanksgiving Dinner",
678
738
  [BashEventType.ThemedCostumeParty]: "Themed Costume Party",
679
739
  [BashEventType.ThemedDinnerParty]: "Themed Dinner Party",
680
740
  [BashEventType.ThemedPubCrawl]: "Themed Pub Crawl",
681
- [BashEventType.Tournament]: "Tournament",
682
741
  [BashEventType.TravelAndTradeShow]: "Travel and Trade Show",
683
742
  [BashEventType.TriviaNight]: "Trivia Night",
684
- [BashEventType.ValentinesDayParty]: "Valentine's Day Party",
685
- [BashEventType.WeddingReception]: "Wedding Reception",
686
743
  [BashEventType.WelcomeHomeParty]: "Welcome Home Party",
687
- [BashEventType.WellnessFestival]: "Wellness Festival",
688
- [BashEventType.WineTastingEvent]: "Wine Tasting Event",
689
- [BashEventType.Other]: "Other",
744
+ [BashEventType.HalloweenCostumeParty]: "Halloween Costume Party",
745
+ [BashEventType.SurfCompetition]: "Surf Competition",
746
+ [BashEventType.CharityBall]: "Charity Ball",
690
747
  };
691
748
 
692
749
  export type RecordKey = string | number | symbol;
@@ -29,7 +29,6 @@ import {
29
29
  Exhibitor,
30
30
  Sponsor,
31
31
  Organization,
32
- Booking,
33
32
  VolunteerService,
34
33
  Prisma,
35
34
  ServiceRange,
@@ -50,8 +49,19 @@ import {
50
49
  SocialMediaPlatform,
51
50
  ServiceSubscriptionCounts,
52
51
  ServiceSpecialRates,
52
+ ServiceBookingAddOn,
53
+ ServiceBookingDay,
54
+ ServiceBookingPackage,
55
+ ServiceBookingCheckout,
56
+ ServiceBooking,
53
57
  } from "@prisma/client";
54
- import { SERVICE_LINK_DATA_TO_INCLUDE, UnionFromArray } from "./definitions";
58
+ import { SERVICE_LINK_DATA_TO_INCLUDE } from "./definitions";
59
+ import { serviceKeysArray } from "./utils/service/serviceUtils";
60
+ import {
61
+ createAllTrueObject,
62
+ RemoveCommonProperties,
63
+ UnionFromArray,
64
+ } from "./utils/typeUtils";
55
65
 
56
66
  //------------------------------------------------------user subscriptions------------------------------------------------------
57
67
  export const PUBLIC_USER_SUBSCRIPTION_DATA_TO_SELECT = {
@@ -177,7 +187,6 @@ export const BASH_EVENT_DATA_TO_CLONE = [
177
187
  "invitations",
178
188
  ] as const;
179
189
 
180
- type RemoveCommonProperties<T, U> = keyof (Omit<T, keyof U> & Omit<U, keyof T>);
181
190
  type BashEventExtMinusDataToCloneType = Omit<
182
191
  BashEventExt,
183
192
  UnionFromArray<typeof BASH_EVENT_DATA_TO_CLONE>
@@ -189,6 +198,143 @@ export const BASH_EVENT_DATA_TO_REMOVE: RemoveCommonProperties<
189
198
  >[] = ["creator", "eventTasks", "tickets", "targetAudience", "amountOfGuests"];
190
199
 
191
200
  //---------------Services------------------
201
+ export const SERVICE_PACKAGE_DATA_TO_INCLUDE = {
202
+ serviceAddons: true,
203
+ } satisfies Prisma.ServicePackageInclude;
204
+
205
+ export const SERVICE_DAILYRATES_DATA_TO_INCLUDE = {
206
+ serviceRate: true,
207
+ } satisfies Prisma.ServiceDailyRatesInclude;
208
+
209
+ export const SERVICE_SPECIALRATES_DATA_TO_INCLUDE = {
210
+ serviceRate: true,
211
+ } satisfies Prisma.ServiceSpecialRatesInclude;
212
+
213
+ export const SERVICE_RATES_ASSOCIATION_DATA_TO_INCLUDE = {
214
+ serviceGeneralRates: true,
215
+ serviceDailyRates: {
216
+ include: SERVICE_DAILYRATES_DATA_TO_INCLUDE,
217
+ },
218
+ serviceSpecialRates: {
219
+ include: SERVICE_SPECIALRATES_DATA_TO_INCLUDE,
220
+ },
221
+ addons: true,
222
+ packages: {
223
+ include: SERVICE_PACKAGE_DATA_TO_INCLUDE,
224
+ },
225
+ media: true,
226
+ } satisfies Prisma.ServiceRatesAssociationInclude;
227
+
228
+ export interface ServiceRateExt extends ServiceRate {
229
+ serviceSpecialRates?: ServiceSpecialRates;
230
+ serviceDailyRates?: ServiceDailyRates;
231
+ serviceRatesAssociation?: ServiceRatesAssociation;
232
+ }
233
+
234
+ export interface ServiceAddonExt extends ServiceAddon {}
235
+
236
+ export interface ServicePackageExt extends ServicePackage {
237
+ serviceAddons: ServiceAddonExt[];
238
+ }
239
+
240
+ export interface ServiceDailyRatesExt extends ServiceDailyRates {
241
+ serviceRate?: ServiceRate;
242
+ }
243
+ export interface ServiceSpecialRatesExt extends ServiceSpecialRates {
244
+ serviceRate?: ServiceRate;
245
+ }
246
+
247
+ export interface ServiceRatesAssociationExt extends ServiceRatesAssociation {
248
+ serviceGeneralRates?: ServiceRate | null;
249
+ serviceDailyRates?: ServiceDailyRatesExt[];
250
+ serviceSpecialRates?: ServiceSpecialRatesExt[];
251
+
252
+ addons?: ServiceAddonExt[];
253
+ packages?: ServicePackageExt[];
254
+ media?: Media[];
255
+ }
256
+
257
+ export interface ServiceBookingAddOnExt extends ServiceBookingAddOn {
258
+ addOn: ServiceAddonExt;
259
+ }
260
+ export interface ServiceBookingPackageExt extends ServiceBookingPackage {
261
+ package: ServicePackageExt;
262
+ }
263
+ export interface ServiceBookingDayExt extends ServiceBookingDay {
264
+ // service: ServiceExt; //we don't need service here
265
+ addOns: ServiceBookingAddOnExt[];
266
+ packages: ServiceBookingPackageExt[];
267
+ }
268
+
269
+ export interface ServiceBookingExt extends ServiceBooking {
270
+ // service: ServiceExt; //we don't need service here
271
+ bookedDays: ServiceBookingDayExt[];
272
+ checkout?: ServiceBookingCheckout | null;
273
+ creator: PublicUser;
274
+ forUser: PublicUser;
275
+ }
276
+
277
+ export interface ServiceBookingCheckoutExt extends ServiceBookingCheckout {
278
+ // service: ServiceExt; //we don't need service here
279
+ creator: PublicUser;
280
+ // bookingData: ServiceBookingExt;
281
+ }
282
+
283
+ export const SERVICE_BOOKING_ADDON_DATA_TO_INCLUDE = {
284
+ addOn: true,
285
+ } satisfies Prisma.ServiceBookingAddOnInclude;
286
+
287
+ export const SERVICE_BOOKING_PACKAGE_DATA_TO_INCLUDE = {
288
+ package: {
289
+ include: SERVICE_PACKAGE_DATA_TO_INCLUDE,
290
+ },
291
+ } satisfies Prisma.ServiceBookingPackageInclude;
292
+
293
+ export const SERVICE_BOOKING_DAY_DATA_TO_INCLUDE = {
294
+ addOns: {
295
+ include: SERVICE_BOOKING_ADDON_DATA_TO_INCLUDE,
296
+ },
297
+ packages: {
298
+ include: SERVICE_BOOKING_PACKAGE_DATA_TO_INCLUDE,
299
+ },
300
+ } satisfies Prisma.ServiceBookingDayInclude;
301
+
302
+ export const SERVICE_BOOKING_CHECKOUT_DATA_TO_INCLUDE = {
303
+ // bookingData: {
304
+ // include: SERVICE_BOOKING_DATA_TO_INCLUDE,
305
+ // },
306
+ creator: {
307
+ select: FRONT_END_USER_DATA_TO_SELECT,
308
+ },
309
+ } satisfies Prisma.ServiceBookingCheckoutInclude;
310
+
311
+ export const FRONT_END_SERVICE_BOOKING_CHECKOUT_DATA_SELECT = {
312
+ id: true,
313
+ creatorId: true,
314
+ creator: true,
315
+ checkoutDateTime: true,
316
+ totalAmount: true,
317
+ depositAmount: true,
318
+ } satisfies Prisma.ServiceBookingCheckoutSelect;
319
+
320
+ export const SERVICE_BOOKING_PUBLIC_DATA_TO_INCLUDE = {
321
+ bookedDays: {
322
+ include: SERVICE_BOOKING_DAY_DATA_TO_INCLUDE,
323
+ },
324
+ } satisfies Prisma.ServiceBookingInclude;
325
+
326
+ export const SERVICE_BOOKING_PRIVATE_DATA_TO_INCLUDE = {
327
+ ...SERVICE_BOOKING_PUBLIC_DATA_TO_INCLUDE,
328
+ checkout: {
329
+ select: FRONT_END_SERVICE_BOOKING_CHECKOUT_DATA_SELECT,
330
+ },
331
+ creator: {
332
+ select: FRONT_END_USER_DATA_TO_SELECT,
333
+ },
334
+ forUser: {
335
+ select: FRONT_END_USER_DATA_TO_SELECT,
336
+ },
337
+ } satisfies Prisma.ServiceBookingInclude;
192
338
  export interface ServiceExt extends Service {
193
339
  owner?: PublicUser | null;
194
340
  creator?: PublicUser | null;
@@ -197,7 +343,6 @@ export interface ServiceExt extends Service {
197
343
 
198
344
  // availableDateTimes?: Availability[];
199
345
 
200
- bookings?: Booking[];
201
346
  // rates?: Rate[];
202
347
  targetAudience?: TargetAudience | null;
203
348
  media?: Media[];
@@ -218,35 +363,10 @@ export interface ServiceExt extends Service {
218
363
  associatedServicesReferencingMe?: AssociatedService[];
219
364
 
220
365
  // googleReviews: GoogleReview[];
221
- }
222
-
223
- export interface ServiceRateExt extends ServiceRate {
224
- serviceSpecialRates?: ServiceSpecialRates;
225
- serviceDailyRates?: ServiceDailyRates;
226
- serviceRatesAssociation?: ServiceRatesAssociation;
227
- }
228
-
229
- export interface ServicePackageExt extends ServicePackage {
230
- serviceAddons: ServiceAddon[];
231
- }
232
-
233
- export interface ServiceDailyRatesExt extends ServiceDailyRates {
234
- serviceRate?: ServiceRate;
235
- }
236
- export interface ServiceSpecialRatesExt extends ServiceSpecialRates {
237
- serviceRate?: ServiceRate;
238
- }
239
-
240
- export interface ServiceRatesAssociationExt extends ServiceRatesAssociation {
241
- serviceGeneralRates?: ServiceRate | null;
242
- serviceDailyRates?: ServiceDailyRatesExt[];
243
- serviceSpecialRates?: ServiceSpecialRatesExt[];
244
366
 
245
- addons?: ServiceAddon[];
246
- packages?: ServicePackageExt[];
247
- media?: Media[];
367
+ // bookedCheckouts: ServiceBookingCheckoutExt[]; //not necessary to include
368
+ bookings?: ServiceBookingExt[];
248
369
  }
249
-
250
370
  export interface EventServiceExt extends EventService {
251
371
  service: ServiceExt;
252
372
  crowdSize?: AmountOfGuests;
@@ -299,73 +419,6 @@ export interface ServiceLinkExt extends ServiceLink {
299
419
  link: Link;
300
420
  }
301
421
 
302
- // Create the final object dynamically
303
- function createAllTrueObject<T extends string>(keys: T[]): Record<T, true> {
304
- return keys.reduce((acc, key) => {
305
- acc[key] = true;
306
- return acc;
307
- }, {} as Record<T, true>);
308
- }
309
-
310
- // Define the keys and values in a single object
311
- const serviceKeysObject = {
312
- eventService: true,
313
- entertainmentService: true,
314
- vendor: true,
315
- exhibitor: true,
316
- sponsor: true,
317
- venue: true,
318
- organization: true,
319
- } as const;
320
-
321
- export type ServiceSpecificName = keyof typeof serviceKeysObject;
322
-
323
- const serviceKeysArray = Object.keys(serviceKeysObject);
324
-
325
- export type ServiceSpecificType = ServiceExt[ServiceSpecificName];
326
-
327
- export const specificServiceMap: Record<ServiceTypes, ServiceSpecificName> = {
328
- EventServices: "eventService",
329
- EntertainmentServices: "entertainmentService",
330
- Vendors: "vendor",
331
- Exhibitors: "exhibitor",
332
- Sponsors: "sponsor",
333
- Venues: "venue",
334
- Organizations: "organization",
335
- } as const;
336
-
337
- export const serviceTypeToField = (
338
- serviceType: ServiceTypes
339
- ): ServiceSpecificName => {
340
- return specificServiceMap[serviceType];
341
- };
342
- export const SERVICE_PACKAGE_DATA_TO_INCLUDE = {
343
- serviceAddons: true,
344
- } satisfies Prisma.ServicePackageInclude;
345
-
346
- export const SERVICE_DAILYRATES_DATA_TO_INCLUDE = {
347
- serviceRate: true,
348
- } satisfies Prisma.ServiceDailyRatesInclude;
349
-
350
- export const SERVICE_SPECIALRATES_DATA_TO_INCLUDE = {
351
- serviceRate: true,
352
- } satisfies Prisma.ServiceSpecialRatesInclude;
353
-
354
- export const SERVICE_RATES_ASSOCIATION_DATA_TO_INCLUDE = {
355
- serviceGeneralRates: true,
356
- serviceDailyRates: {
357
- include: SERVICE_DAILYRATES_DATA_TO_INCLUDE,
358
- },
359
- serviceSpecialRates: {
360
- include: SERVICE_SPECIALRATES_DATA_TO_INCLUDE,
361
- },
362
- addons: true,
363
- packages: {
364
- include: SERVICE_PACKAGE_DATA_TO_INCLUDE,
365
- },
366
- media: true,
367
- } satisfies Prisma.ServiceRatesAssociationInclude;
368
-
369
422
  //------------Stripe Accounts--------------
370
423
  export const PUBLIC_STRIPE_ACCOUNT_DATA_TO_SELECT = {
371
424
  logo: true,
@@ -396,24 +449,26 @@ export const SERVICE_DATA_TO_INCLUDE = {
396
449
  select: FRONT_END_USER_DATA_TO_SELECT,
397
450
  },
398
451
  targetAudience: true,
399
- // amountOfGuests: true,
400
- // recurrence: true,
401
- // ticketTiers: {
402
- // include: TICKET_TIER_DATA_TO_INCLUDE
403
- // },
404
- // eventTasks: true,
405
452
  media: true,
406
453
  stripeAccount: {
407
454
  // ...STRIPE_ACCOUNT_DATA_TO_INCLUDE,
408
455
  select: PUBLIC_STRIPE_ACCOUNT_DATA_TO_SELECT,
409
456
  },
410
- // availableDateTimes: true,
411
457
  serviceLinks: {
412
458
  include: SERVICE_LINK_DATA_TO_INCLUDE,
413
459
  },
414
460
  serviceRatesAssociation: {
415
461
  include: SERVICE_RATES_ASSOCIATION_DATA_TO_INCLUDE,
416
462
  },
463
+ // bookings: {
464
+ // include: SERVICE_BOOKING_PRIVATE_DATA_TO_INCLUDE, //make sure only to include owned bookedDays
465
+ // },
466
+ bashEvent: {
467
+ include: BASH_EVENT_DATA_TO_INCLUDE,
468
+ },
469
+ // bookedCheckouts: {
470
+ // include: SERVICE_BOOKING_CHECKOUT_DATA_TO_INCLUDE, //make sure only to include owned checkouts
471
+ // },
417
472
  } satisfies Prisma.ServiceInclude;
418
473
 
419
474
  //full service data to include, includes specific service data
package/src/index.ts CHANGED
@@ -15,6 +15,14 @@ export * from "./utils/userPromoCodeUtils";
15
15
  export * from "./utils/userSubscriptionUtils";
16
16
  export * from "./utils/service/serviceUtils";
17
17
  export * from "./utils/service/venueUtils";
18
+ export * from "./utils/service/attendeeOptionUtils";
19
+ export * from "./utils/service/serviceRateDBUtils";
20
+ export * from "./utils/service/serviceDBUtils";
21
+ export * from "./utils/service/serviceRateUtils";
22
+ export * from "./utils/service/serviceBookingUtils";
23
+ export * from "./utils/service/serviceBookingApiUtils";
18
24
  export * from "./utils/stripeAccountUtils";
19
25
  export * from "./utils/entityUtils";
20
- // export * from "./utils/luxonUtils";
26
+ export * from "./utils/generalDateTimeUtils";
27
+ export * from "./utils/luxonUtils";
28
+ export * from "./utils/mathUtils";
@@ -0,0 +1,43 @@
1
+ import { DayOfWeek } from "@prisma/client";
2
+
3
+ export type DayOfWeekIdx = 1 | 2 | 3 | 4 | 5 | 6 | 7;
4
+
5
+ export const dayOfWeekToString: { [key in DayOfWeek]: string } = {
6
+ [DayOfWeek.Monday]: "M",
7
+ [DayOfWeek.Tuesday]: "T",
8
+ [DayOfWeek.Wednesday]: "W",
9
+ [DayOfWeek.Thursday]: "TR",
10
+ [DayOfWeek.Friday]: "F",
11
+ [DayOfWeek.Saturday]: "S",
12
+ [DayOfWeek.Sunday]: "S",
13
+ } as const;
14
+
15
+ export const dayOfWeekToIdx: { [key in DayOfWeek]: DayOfWeekIdx } = {
16
+ [DayOfWeek.Monday]: 1,
17
+ [DayOfWeek.Tuesday]: 2,
18
+ [DayOfWeek.Wednesday]: 3,
19
+ [DayOfWeek.Thursday]: 4,
20
+ [DayOfWeek.Friday]: 5,
21
+ [DayOfWeek.Saturday]: 6,
22
+ [DayOfWeek.Sunday]: 7,
23
+ } as const;
24
+
25
+ export const dayOfWeekIdxToDayOfWeek: { [key in DayOfWeekIdx]: DayOfWeek } = {
26
+ [1]: DayOfWeek.Monday,
27
+ [2]: DayOfWeek.Tuesday,
28
+ [3]: DayOfWeek.Wednesday,
29
+ [4]: DayOfWeek.Thursday,
30
+ [5]: DayOfWeek.Friday,
31
+ [6]: DayOfWeek.Saturday,
32
+ [7]: DayOfWeek.Sunday,
33
+ } as const;
34
+
35
+ export const dayOfWeekIdxToDay: { [key in DayOfWeekIdx]: DayOfWeekIdx } = {
36
+ [7]: 1,
37
+ [1]: 2,
38
+ [2]: 3,
39
+ [3]: 4,
40
+ [4]: 5,
41
+ [5]: 6,
42
+ [6]: 7,
43
+ } as const;