@bash-app/bash-common 30.26.0 → 30.28.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bash-app/bash-common",
3
- "version": "30.26.0",
3
+ "version": "30.28.0",
4
4
  "description": "Common data and scripts to use on the frontend and backend",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -372,7 +372,7 @@ model Ticket {
372
372
  email String?
373
373
  paidOn DateTime?
374
374
  allowPromiseToPay Boolean?
375
- status TicketStatus @default(Pending)
375
+ status TicketStatus? @default(Pending)
376
376
  isFreeGuest Boolean?
377
377
  geoFenceCheckInUnnecessary Boolean?
378
378
  checkedInAt DateTime?
@@ -216,6 +216,10 @@ export type FilterFields = {
216
216
  eventFormat: string[];
217
217
  };
218
218
 
219
+ export type ApiEntityApproval = {
220
+ isApproved: boolean;
221
+ };
222
+
219
223
  export type TicketTierWherePriceIsAString = Omit<TicketTier, "price"> & {
220
224
  price: string;
221
225
  } & { cannotDelete: boolean };
@@ -1,57 +1,58 @@
1
1
  import {
2
2
  AmountOfGuests,
3
- EventTask,
4
3
  AssociatedBash,
5
4
  AssociatedService,
6
- BashEvent,
7
- Invitation,
8
- Ticket,
9
- User,
10
- TicketTier,
11
- Service,
12
- Review,
13
- Media,
14
5
  BashComment,
15
- Recurrence,
16
- Contact,
17
- BashNotification,
6
+ BashEvent,
18
7
  BashEventPromoCode,
19
- Reminder,
8
+ BashNotification,
20
9
  Checkout,
21
- ServiceLink,
22
- Link,
23
- Venue,
24
- TargetAudience,
25
- Vendor,
26
- EventService,
10
+ Contact,
11
+ Coordinates,
27
12
  EntertainmentService,
13
+ EventService,
14
+ EventTask,
28
15
  Exhibitor,
29
- Sponsor,
16
+ Invitation,
17
+ Link,
18
+ Media,
30
19
  Organization,
31
- VolunteerService,
32
20
  Prisma,
33
- ServiceRange,
34
- StripeAccount,
35
- Coordinates,
36
- ServiceRatesAssociation,
37
- ServiceRate,
38
- ServiceDailyRates,
21
+ Recurrence,
22
+ Reminder,
23
+ Review,
24
+ Service,
39
25
  ServiceAddon,
40
- ServicePackage,
41
- UserSubscription,
42
- SocialMediaProfile,
43
- SocialMediaPlatform,
44
- ServiceSubscriptionCounts,
45
- ServiceSpecialRates,
26
+ ServiceBooking,
46
27
  ServiceBookingAddOn,
28
+ ServiceBookingCheckout,
47
29
  ServiceBookingDay,
30
+ ServiceBookingFee,
48
31
  ServiceBookingPackage,
49
- ServiceBookingCheckout,
50
- ServiceBooking,
51
32
  ServiceBookingPriceBreakdown,
52
- ServiceBookingFee,
33
+ ServiceDailyRates,
34
+ ServiceLink,
35
+ ServicePackage,
36
+ ServiceRange,
37
+ ServiceRate,
38
+ ServiceRatesAssociation,
39
+ ServiceSpecialRates,
40
+ ServiceSubscriptionCounts,
41
+ SocialMediaPlatform,
42
+ SocialMediaProfile,
43
+ Sponsor,
44
+ StripeAccount,
45
+ TargetAudience,
46
+ Ticket,
47
+ TicketTier,
48
+ User,
49
+ UserSubscription,
50
+ Vendor,
51
+ Venue,
52
+ VolunteerService,
53
53
  TicketTransfer,
54
54
  TicketMetadata,
55
+ SponsoredEvent,
55
56
  } from "@prisma/client";
56
57
  import { SERVICE_LINK_DATA_TO_INCLUDE } from "./definitions";
57
58
  import { serviceKeysArray } from "./utils/service/serviceUtils";
@@ -127,6 +128,8 @@ export const PRIVATE_USER_ACCOUNT_TO_SELECT = {
127
128
  },
128
129
  } satisfies Prisma.UserSelect;
129
130
 
131
+ export interface SponsoredEventExt extends SponsoredEvent {}
132
+
130
133
  export interface BashEventExt extends BashEvent {
131
134
  targetAudience?: TargetAudience;
132
135
  amountOfGuests?: AmountOfGuests;
@@ -140,17 +143,8 @@ export interface BashEventExt extends BashEvent {
140
143
  invitations: Partial<InvitationExt>[];
141
144
  coordinates?: Coordinates[];
142
145
  venueServiceId?: string;
143
- venueOwner?: {
144
- id: string;
145
- email: string;
146
- givenName?: string;
147
- familyName?: string;
148
- };
149
- sponsorships?: Array<{
150
- sponsorId: string;
151
- sponsorEmail: string;
152
- name?: string;
153
- }>;
146
+ venueOwner?: PublicUser;
147
+ sponsorships?: SponsoredEventExt[];
154
148
  }
155
149
 
156
150
  export const TICKET_TIER_DATA_TO_INCLUDE = {
@@ -252,6 +246,56 @@ export const SERVICE_RATES_ASSOCIATION_DATA_TO_INCLUDE = {
252
246
  media: true,
253
247
  } satisfies Prisma.ServiceRatesAssociationInclude;
254
248
 
249
+ export const VENUE_DATA_TO_CLONE = [] as const;
250
+
251
+ type VenueExtMinusDataToCloneType = Omit<
252
+ Venue,
253
+ UnionFromArray<typeof VENUE_DATA_TO_CLONE>
254
+ >;
255
+ export const VENUE_DATA_TO_REMOVE: RemoveCommonProperties<
256
+ Venue,
257
+ VenueExtMinusDataToCloneType
258
+ >[] = [
259
+ // 'bashEvents',
260
+ ] as const;
261
+
262
+ export const VENDOR_DATA_TO_INCLUDE = {
263
+ crowdSize: true,
264
+ serviceRange: true,
265
+ } satisfies Prisma.VendorInclude;
266
+
267
+ export const VOLUNTEER_DATA_TO_INCLUDE = {
268
+ links: {
269
+ include: {
270
+ serviceLinks: true,
271
+ },
272
+ },
273
+ media: true,
274
+ serviceRange: true,
275
+ } satisfies Prisma.VolunteerServiceInclude;
276
+
277
+ export const VENUE_DATA_TO_INCLUDE = {} satisfies Prisma.VenueInclude;
278
+
279
+ export const EVENT_SERVICE_DATA_TO_INCLUDE = {
280
+ crowdSize: true,
281
+ serviceRange: true,
282
+ } satisfies Prisma.EventServiceInclude;
283
+
284
+ export const ENTERTAINMENT_SERVICE_DATA_TO_INCLUDE = {
285
+ crowdSize: true,
286
+ serviceRange: true,
287
+ } satisfies Prisma.EntertainmentServiceInclude;
288
+
289
+ export const SPONSOR_DATA_TO_INCLUDE = {
290
+ crowdSize: true,
291
+ serviceRange: true,
292
+ } satisfies Prisma.SponsorInclude;
293
+
294
+ export const EXHIBITOR_DATA_TO_INCLUDE = {
295
+ crowdSize: true,
296
+ serviceRange: true,
297
+ } satisfies Prisma.ExhibitorInclude;
298
+
255
299
  export const SERVICE_DATA_TO_INCLUDE = {
256
300
  creator: {
257
301
  select: FRONT_END_USER_DATA_TO_SELECT,
@@ -271,12 +315,30 @@ export const SERVICE_DATA_TO_INCLUDE = {
271
315
  serviceRatesAssociation: {
272
316
  include: SERVICE_RATES_ASSOCIATION_DATA_TO_INCLUDE,
273
317
  },
274
- // bookings: {
275
- // include: SERVICE_BOOKING_PRIVATE_DATA_TO_INCLUDE, //make sure only to include owned bookedDays
276
- // },
277
318
  bashEvent: {
278
319
  include: BASH_EVENT_DATA_TO_INCLUDE,
279
320
  },
321
+ venue: {
322
+ include: VENUE_DATA_TO_INCLUDE,
323
+ },
324
+ eventService: {
325
+ include: EVENT_SERVICE_DATA_TO_INCLUDE,
326
+ },
327
+ entertainmentService: {
328
+ include: ENTERTAINMENT_SERVICE_DATA_TO_INCLUDE,
329
+ },
330
+ vendor: {
331
+ include: VENDOR_DATA_TO_INCLUDE,
332
+ },
333
+ exhibitor: {
334
+ include: EXHIBITOR_DATA_TO_INCLUDE,
335
+ },
336
+ sponsor: {
337
+ include: SPONSOR_DATA_TO_INCLUDE,
338
+ },
339
+ // bookings: {
340
+ // include: SERVICE_BOOKING_PRIVATE_DATA_TO_INCLUDE, //make sure only to include owned bookedDays
341
+ // },
280
342
  // bookedCheckouts: {
281
343
  // include: SERVICE_BOOKING_CHECKOUT_DATA_TO_INCLUDE, //make sure only to include owned checkouts
282
344
  // },
@@ -312,19 +374,6 @@ export interface StripeAccountExt extends StripeAccount {
312
374
  logo?: Media | null;
313
375
  }
314
376
 
315
- export const VENUE_DATA_TO_CLONE = [] as const;
316
-
317
- type VenueExtMinusDataToCloneType = Omit<
318
- Venue,
319
- UnionFromArray<typeof VENUE_DATA_TO_CLONE>
320
- >;
321
- export const VENUE_DATA_TO_REMOVE: RemoveCommonProperties<
322
- Venue,
323
- VenueExtMinusDataToCloneType
324
- >[] = [
325
- // 'bashEvents',
326
- ] as const;
327
-
328
377
  export interface ServiceRateExt extends ServiceRate {
329
378
  serviceSpecialRates?: ServiceSpecialRates;
330
379
  serviceDailyRates?: ServiceDailyRates;
@@ -470,23 +519,23 @@ export interface ServiceExt extends Service {
470
519
  // availableDateTimes?: Availability[];
471
520
 
472
521
  // rates?: Rate[];
473
- targetAudience?: TargetAudience | null;
522
+ targetAudience?: TargetAudienceExt | null;
474
523
  media?: Media[];
475
524
  serviceLinks?: ServiceLinkExt[];
476
525
 
477
- eventService?: EventService;
478
- entertainmentService?: EntertainmentService;
479
- vendor?: Vendor;
480
- exhibitor?: Exhibitor;
481
- sponsor?: Sponsor;
482
- venue?: Venue;
483
- organization?: Organization;
484
- volunteerService?: VolunteerService;
485
- bashEvent: BashEvent[];
526
+ eventService?: EventServiceExt;
527
+ entertainmentService?: EntertainmentServiceExt;
528
+ vendor?: VendorExt;
529
+ exhibitor?: ExhibitorExt;
530
+ sponsor?: SponsorExt;
531
+ venue?: VenueExt;
532
+ organization?: OrganizationExt;
533
+ volunteerService?: VolunteerServiceExt;
534
+ bashEvent: BashEventExt[];
486
535
 
487
536
  serviceRatesAssociation?: ServiceRatesAssociationExt | null;
488
- associatedBashesReferencingMe?: AssociatedBash[];
489
- associatedServicesReferencingMe?: AssociatedService[];
537
+ associatedBashesReferencingMe?: AssociatedBashExt[];
538
+ associatedServicesReferencingMe?: AssociatedServiceExt[];
490
539
 
491
540
  // googleReviews: GoogleReview[];
492
541
 
@@ -494,41 +543,33 @@ export interface ServiceExt extends Service {
494
543
  // bookings?: ServiceBookingExt[];
495
544
  }
496
545
  export interface EventServiceExt extends EventService {
497
- service: ServiceExt;
498
546
  crowdSize?: AmountOfGuests;
499
547
  serviceRange?: ServiceRange;
500
548
  }
501
549
 
502
550
  export interface EntertainmentServiceExt extends EntertainmentService {
503
- service: ServiceExt;
504
551
  crowdSize?: AmountOfGuests;
505
552
  serviceRange?: ServiceRange;
506
553
  }
507
554
 
508
555
  export interface ExhibitorExt extends Exhibitor {
509
- service: ServiceExt;
510
556
  crowdSize?: AmountOfGuests;
511
557
  serviceRange?: ServiceRange;
512
558
  }
513
559
 
514
560
  export interface SponsorExt extends Sponsor {
515
- service: ServiceExt;
516
561
  crowdSize?: AmountOfGuests;
517
562
  serviceRange?: ServiceRange;
518
563
  }
519
564
 
520
565
  export interface VendorExt extends Vendor {
521
- service: ServiceExt;
522
566
  crowdSize?: AmountOfGuests;
567
+ serviceRange?: ServiceRange;
523
568
  }
524
569
 
525
- export interface VenueExt extends Venue {
526
- service: ServiceExt;
527
- // crowdSize?: AmountOfGuests;
528
- }
570
+ export interface VenueExt extends Venue {}
529
571
 
530
572
  export interface OrganizationExt extends Organization {
531
- service: ServiceExt;
532
573
  amountOfGuests?: AmountOfGuests;
533
574
  }
534
575
  //-----------------------------------------
@@ -545,25 +586,6 @@ export interface ServiceLinkExt extends ServiceLink {
545
586
  link: Link;
546
587
  }
547
588
 
548
- export const VENDOR_DATA_TO_INCLUDE = {
549
- crowdSize: true,
550
- } satisfies Prisma.VendorInclude;
551
-
552
- export const VOLUNTEER_DATA_TO_INCLUDE = {
553
- links: {
554
- include: {
555
- serviceLinks: true,
556
- },
557
- },
558
- media: true,
559
- serviceRange: true,
560
- service: {
561
- include: SERVICE_DATA_TO_INCLUDE,
562
- },
563
- } satisfies Prisma.VolunteerServiceInclude;
564
-
565
- export const VENUE_DATA_TO_INCLUDE = {} satisfies Prisma.VenueInclude;
566
-
567
589
  //-----------------------------------------
568
590
 
569
591
  export interface BashNotificationExt extends BashNotification {
@@ -1,7 +1,11 @@
1
1
  export function isObject(value: unknown): value is Record<string, unknown> {
2
- return typeof value === "object" && value !== null && !Array.isArray(value);
2
+ return (
3
+ typeof value === "object" &&
4
+ value !== null &&
5
+ !Array.isArray(value) &&
6
+ !(value instanceof Date)
7
+ );
3
8
  }
4
-
5
9
  export function deepMerge<
6
10
  T extends Record<string, any>,
7
11
  U extends Record<string, any>
@@ -10,7 +14,7 @@ export function deepMerge<
10
14
  source: U | undefined | null,
11
15
  mergeArrays: boolean = false,
12
16
  mergeCommon: boolean = false
13
- ): T & U {
17
+ ): T {
14
18
  const output = { ...(mergeCommon ? [] : target) } as T & U;
15
19
 
16
20
  for (const key in source) {
@@ -1,5 +1,5 @@
1
- import { ServiceRate } from "@prisma/client";
2
- import { ServiceExt, ServiceSpecialRatesExt } from "../../extendedSchemas";
1
+ import { ServiceExt } from "../../extendedSchemas";
2
+ import { DeepPartial } from "../typeUtils";
3
3
  // import {
4
4
  // specialRateConvertToDb,
5
5
  // generalRatesConvertRatesToDB,
@@ -7,7 +7,9 @@ import { ServiceExt, ServiceSpecialRatesExt } from "../../extendedSchemas";
7
7
  // generalRatesConvertRatesFromDB,
8
8
  // } from "./serviceRateDBUtils";
9
9
 
10
- export function serviceToDb(service: Partial<ServiceExt>): Partial<ServiceExt> {
10
+ export function serviceToDb(
11
+ service: DeepPartial<ServiceExt>
12
+ ): DeepPartial<ServiceExt> {
11
13
  if (service.serviceRatesAssociation) {
12
14
  // service.serviceRatesAssociation.serviceSpecialRates =
13
15
  // service.serviceRatesAssociation.serviceSpecialRates?.map(
@@ -157,9 +157,7 @@ export function serviceGetSpecificType<BookingType extends Service>(
157
157
  return null;
158
158
  }
159
159
 
160
- const specificId = service[
161
- `${specificFieldName}Id` as keyof BookingType
162
- ] as string;
160
+ const specificId = service[`${specificFieldName}Id`] as string;
163
161
 
164
162
  return {
165
163
  serviceId: service.id,
@@ -211,7 +209,61 @@ export const specificServiceMap: Record<ServiceTypes, ServiceSpecificName> = {
211
209
  Venues: "venue",
212
210
  Organizations: "organization",
213
211
  } as const;
214
-
215
- const serviceTypeToField = (serviceType: ServiceTypes): ServiceSpecificName => {
212
+ export const serviceTypeToField = (
213
+ serviceType: ServiceTypes
214
+ ): ServiceSpecificName => {
216
215
  return specificServiceMap[serviceType];
217
216
  };
217
+
218
+ // export type SpecificServiceMap = {
219
+ // [P in keyof T]: ServiceSpecificInfo;
220
+ // };
221
+
222
+ // type ServiceExtKeyMap = {
223
+ // EventServices: "eventService";
224
+ // EntertainmentServices: "entertainmentService";
225
+ // Vendors: "vendor";
226
+ // Exhibitors: "exhibitor";
227
+ // Sponsors: "sponsor";
228
+ // Venues: "venue";
229
+ // Organizations: "organization";
230
+ // };
231
+ // export type ServiceExtKey<T extends ServiceTypes> = ServiceExtKeyMap[T];
232
+ // export type ServiceSpecificInfo = {
233
+ // description: string;
234
+ // };
235
+
236
+ // export type ServiceSpecificInfoMap<T> = {
237
+ // [P in keyof T]: ServiceSpecificInfo;
238
+ // };
239
+ // export type SpecificServiceInfoMap = {
240
+ // [K in ServiceTypes]: ServiceSpecificInfoMap<
241
+ // ServiceExt[ServiceExtKey<K>]
242
+ // >;
243
+ // };
244
+
245
+ // export const serviceSpecificInfo = {
246
+ // EventServices:{
247
+
248
+ // },
249
+ // EntertainmentServices: {
250
+
251
+ // },
252
+ // Vendors:{
253
+
254
+ // },
255
+ // Exhibitors:{
256
+
257
+ // };
258
+ // Sponsors:{
259
+
260
+ // },
261
+ // Venues:{
262
+ // venueTypes: {
263
+ // description: `venueTypes (array of primary venue types)`
264
+ // }
265
+ // },
266
+ // Organizations: {
267
+
268
+ // },
269
+ // } as SpecificServiceInfoMap;
@@ -6,6 +6,20 @@ export type RemoveCommonProperties<T, U> = keyof (Omit<T, keyof U> &
6
6
  export type MakeOptional<T, K extends keyof T> = Omit<T, K> &
7
7
  Partial<Pick<T, K>>;
8
8
 
9
+ export type MakeRequired<T, K extends keyof T> = Omit<T, K> &
10
+ Required<Pick<T, K>>;
11
+
12
+ export type DeepPartial<T> =
13
+ | T extends Function
14
+ ? T
15
+ : T extends Array<infer U>
16
+ ? Array<DeepPartial<U>>
17
+ : T extends object
18
+ ? { [P in keyof T]?: DeepPartial<T[P]> }
19
+ : T;
20
+
21
+ export type Override<T, U> = Omit<T, keyof U> & U;
22
+
9
23
  // Create the final object dynamically
10
24
  export function createAllTrueObject<T extends string>(
11
25
  keys: T[]