@bash-app/bash-common 29.67.0 → 29.69.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.
@@ -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,15 +198,159 @@ 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 type ServiceBookingPublicExt = Omit<ServiceBookingExt, "checkout">;
278
+
279
+ export interface ServiceBookingCheckoutExt extends ServiceBookingCheckout {
280
+ // service: ServiceExt; //we don't need service here
281
+ creator: PublicUser;
282
+ // bookingData: ServiceBookingExt;
283
+ }
284
+
285
+ export const SERVICE_BOOKING_ADDON_DATA_TO_INCLUDE = {
286
+ addOn: true,
287
+ } satisfies Prisma.ServiceBookingAddOnInclude;
288
+
289
+ export const SERVICE_BOOKING_PACKAGE_DATA_TO_INCLUDE = {
290
+ package: {
291
+ include: SERVICE_PACKAGE_DATA_TO_INCLUDE,
292
+ },
293
+ } satisfies Prisma.ServiceBookingPackageInclude;
294
+
295
+ export const SERVICE_BOOKING_DAY_DATA_TO_INCLUDE = {
296
+ addOns: {
297
+ include: SERVICE_BOOKING_ADDON_DATA_TO_INCLUDE,
298
+ },
299
+ packages: {
300
+ include: SERVICE_BOOKING_PACKAGE_DATA_TO_INCLUDE,
301
+ },
302
+ } satisfies Prisma.ServiceBookingDayInclude;
303
+
304
+ export const SERVICE_BOOKING_CHECKOUT_DATA_TO_INCLUDE = {
305
+ // bookingData: {
306
+ // include: SERVICE_BOOKING_DATA_TO_INCLUDE,
307
+ // },
308
+ creator: {
309
+ select: FRONT_END_USER_DATA_TO_SELECT,
310
+ },
311
+ } satisfies Prisma.ServiceBookingCheckoutInclude;
312
+
313
+ export const FRONT_END_SERVICE_BOOKING_CHECKOUT_DATA_SELECT = {
314
+ id: true,
315
+ creatorId: true,
316
+ creator: true,
317
+ checkoutDateTime: true,
318
+ totalAmount: true,
319
+ depositAmount: true,
320
+ paidOn: true,
321
+ refundedOn: true,
322
+ } satisfies Prisma.ServiceBookingCheckoutSelect;
323
+
324
+ export const SERVICE_BOOKING_PUBLIC_DATA_TO_INCLUDE = {
325
+ bookedDays: {
326
+ include: SERVICE_BOOKING_DAY_DATA_TO_INCLUDE,
327
+ },
328
+ } satisfies Prisma.ServiceBookingInclude;
329
+
330
+ export const SERVICE_BOOKING_PRIVATE_DATA_TO_INCLUDE = {
331
+ ...SERVICE_BOOKING_PUBLIC_DATA_TO_INCLUDE,
332
+ checkout: {
333
+ // select: FRONT_END_SERVICE_BOOKING_CHECKOUT_DATA_SELECT,
334
+ include: SERVICE_BOOKING_CHECKOUT_DATA_TO_INCLUDE,
335
+ },
336
+ creator: {
337
+ select: FRONT_END_USER_DATA_TO_SELECT,
338
+ },
339
+ forUser: {
340
+ select: FRONT_END_USER_DATA_TO_SELECT,
341
+ },
342
+ } satisfies Prisma.ServiceBookingInclude;
192
343
  export interface ServiceExt extends Service {
193
344
  owner?: PublicUser | null;
194
345
  creator?: PublicUser | null;
195
346
 
196
347
  stripeAccount?: PublicStripeAccount | null;
197
348
 
349
+ latitude?: number;
350
+ longitude?: number;
351
+
198
352
  // availableDateTimes?: Availability[];
199
353
 
200
- bookings?: Booking[];
201
354
  // rates?: Rate[];
202
355
  targetAudience?: TargetAudience | null;
203
356
  media?: Media[];
@@ -218,35 +371,10 @@ export interface ServiceExt extends Service {
218
371
  associatedServicesReferencingMe?: AssociatedService[];
219
372
 
220
373
  // googleReviews: GoogleReview[];
221
- }
222
-
223
- export interface ServiceRateExt extends ServiceRate {
224
- serviceSpecialRates?: ServiceSpecialRates;
225
- serviceDailyRates?: ServiceDailyRates;
226
- serviceRatesAssociation?: ServiceRatesAssociation;
227
- }
228
374
 
229
- export interface ServicePackageExt extends ServicePackage {
230
- serviceAddons: ServiceAddon[];
231
- }
232
-
233
- export interface ServiceDailyRatesExt extends ServiceDailyRates {
234
- serviceRate?: ServiceRate;
375
+ // bookedCheckouts: ServiceBookingCheckoutExt[]; //not necessary to include
376
+ bookings?: ServiceBookingExt[];
235
377
  }
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
-
245
- addons?: ServiceAddon[];
246
- packages?: ServicePackageExt[];
247
- media?: Media[];
248
- }
249
-
250
378
  export interface EventServiceExt extends EventService {
251
379
  service: ServiceExt;
252
380
  crowdSize?: AmountOfGuests;
@@ -299,73 +427,6 @@ export interface ServiceLinkExt extends ServiceLink {
299
427
  link: Link;
300
428
  }
301
429
 
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
430
  //------------Stripe Accounts--------------
370
431
  export const PUBLIC_STRIPE_ACCOUNT_DATA_TO_SELECT = {
371
432
  logo: true,
@@ -396,24 +457,26 @@ export const SERVICE_DATA_TO_INCLUDE = {
396
457
  select: FRONT_END_USER_DATA_TO_SELECT,
397
458
  },
398
459
  targetAudience: true,
399
- // amountOfGuests: true,
400
- // recurrence: true,
401
- // ticketTiers: {
402
- // include: TICKET_TIER_DATA_TO_INCLUDE
403
- // },
404
- // eventTasks: true,
405
460
  media: true,
406
461
  stripeAccount: {
407
462
  // ...STRIPE_ACCOUNT_DATA_TO_INCLUDE,
408
463
  select: PUBLIC_STRIPE_ACCOUNT_DATA_TO_SELECT,
409
464
  },
410
- // availableDateTimes: true,
411
465
  serviceLinks: {
412
466
  include: SERVICE_LINK_DATA_TO_INCLUDE,
413
467
  },
414
468
  serviceRatesAssociation: {
415
469
  include: SERVICE_RATES_ASSOCIATION_DATA_TO_INCLUDE,
416
470
  },
471
+ // bookings: {
472
+ // include: SERVICE_BOOKING_PRIVATE_DATA_TO_INCLUDE, //make sure only to include owned bookedDays
473
+ // },
474
+ bashEvent: {
475
+ include: BASH_EVENT_DATA_TO_INCLUDE,
476
+ },
477
+ // bookedCheckouts: {
478
+ // include: SERVICE_BOOKING_CHECKOUT_DATA_TO_INCLUDE, //make sure only to include owned checkouts
479
+ // },
417
480
  } satisfies Prisma.ServiceInclude;
418
481
 
419
482
  //full service data to include, includes specific service data
@@ -455,6 +518,8 @@ export const VENUE_DATA_TO_REMOVE: RemoveCommonProperties<
455
518
  export interface BashNotificationExt extends BashNotification {
456
519
  creator?: PublicUser;
457
520
  bashEvent?: BashEvent;
521
+ service?: ServiceExt;
522
+ serviceBooking?: ServiceBookingExt;
458
523
  eventTask?: EventTask;
459
524
  invitation?: Invitation;
460
525
  reminders?: Reminder[];
@@ -489,6 +554,12 @@ export const BASH_NOTIFICATION_DATA_TO_INCLUDE = {
489
554
  image: true,
490
555
  },
491
556
  },
557
+ service: {
558
+ include: { ...SERVICE_DATA_TO_INCLUDE, bashEvent: undefined },
559
+ },
560
+ serviceBooking: {
561
+ include: SERVICE_BOOKING_PUBLIC_DATA_TO_INCLUDE,
562
+ },
492
563
  } satisfies Prisma.BashNotificationInclude;
493
564
 
494
565
  export interface EventTaskExt extends EventTask {
package/src/index.ts CHANGED
@@ -10,11 +10,21 @@ export * from "./utils/qrCodeUtils";
10
10
  export * from "./utils/sortUtils";
11
11
  export * from "./utils/apiUtils";
12
12
  export * from "./utils/urlUtils";
13
+ export * from "./utils/stringUtils";
13
14
  export * from "./utils/promoCodesUtils";
14
15
  export * from "./utils/userPromoCodeUtils";
15
16
  export * from "./utils/userSubscriptionUtils";
16
17
  export * from "./utils/service/serviceUtils";
17
18
  export * from "./utils/service/venueUtils";
19
+ export * from "./utils/service/attendeeOptionUtils";
20
+ export * from "./utils/service/serviceRateDBUtils";
21
+ export * from "./utils/service/serviceDBUtils";
22
+ export * from "./utils/service/serviceRateUtils";
23
+ export * from "./utils/service/serviceBookingUtils";
24
+ export * from "./utils/service/serviceBookingApiUtils";
25
+ export * from "./utils/service/serviceBookingStatusUtils";
18
26
  export * from "./utils/stripeAccountUtils";
19
27
  export * from "./utils/entityUtils";
20
- // export * from "./utils/luxonUtils";
28
+ export * from "./utils/generalDateTimeUtils";
29
+ export * from "./utils/luxonUtils";
30
+ 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;