@bash-app/bash-common 21.0.1 → 21.1.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": "21.0.1",
3
+ "version": "21.1.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",
@@ -25,9 +25,9 @@
25
25
  "qrcode": "^1.5.3"
26
26
  },
27
27
  "peerDependencies": {
28
- "@prisma/client": "^5.16.2",
28
+ "@prisma/client": "^5.18.0",
29
29
  "dayjs": "^1.11.10",
30
- "prisma": "^5.16.2",
30
+ "prisma": "^5.18.0",
31
31
  "react-tailwindcss-datepicker": "^1.6.6",
32
32
  "tsx": "^4.10.3"
33
33
  },
@@ -14,7 +14,7 @@ datasource db {
14
14
  model Club {
15
15
  id String @id @default(cuid())
16
16
  name String
17
- address String
17
+ street String
18
18
  userId String
19
19
  price Int?
20
20
  events BashEvent[]
@@ -624,23 +624,23 @@ enum ServiceStatus {
624
624
  }
625
625
 
626
626
  model DocumentID {
627
- id String @id @default(cuid())
628
- givenName String?
629
- familyName String?
630
- middleName String?
631
- suffix String?
632
- streetAddress String?
633
- city String?
634
- state String?
635
- stateName String?
636
- postalCode String?
637
- idNumber String?
638
- expires String?
639
- dob String?
640
- issueDate String?
641
- idType String?
642
- userId String? @unique
643
- user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
627
+ id String @id @default(cuid())
628
+ givenName String?
629
+ familyName String?
630
+ middleName String?
631
+ suffix String?
632
+ street String?
633
+ city String?
634
+ state String?
635
+ stateName String?
636
+ zipCode String?
637
+ idNumber String?
638
+ expires String?
639
+ dob String?
640
+ issueDate String?
641
+ idType String?
642
+ userId String? @unique
643
+ user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
644
644
  }
645
645
 
646
646
  model EventLink {
@@ -820,10 +820,10 @@ model User {
820
820
  magicLinkExpiration DateTime?
821
821
  magicLinkUsed DateTime?
822
822
  idVerified DateTime?
823
- streetAddress String?
823
+ street String?
824
824
  city String?
825
825
  state String?
826
- postalCode String?
826
+ zipCode String?
827
827
  country String? @default("US")
828
828
  phone String?
829
829
  documentIDId String? @unique
@@ -842,7 +842,7 @@ model User {
842
842
  bashEventPromoCodesIUsed BashEventPromoCode[]
843
843
  serviceCheckouts ServiceCheckout[]
844
844
  bookingForMe Booking[]
845
- bashSubscription UserSubscription?
845
+ userSubscription UserSubscription?
846
846
  serviceSubcriptions ServiceSubscription[]
847
847
  }
848
848
 
@@ -881,11 +881,10 @@ model Business {
881
881
  owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
882
882
  dateCreated DateTime @default(now())
883
883
  email String
884
- location String?
885
- streetAddress String
884
+ street String
886
885
  city String
887
886
  state String
888
- postalCode String
887
+ zipCode String
889
888
  country String
890
889
  phone String
891
890
  name String @default("New Business")
@@ -938,10 +937,10 @@ model EventService {
938
937
  eventServiceTypes EventServiceType[]
939
938
  eventServiceSubType String?
940
939
  email String
941
- streetAddress String
940
+ street String
942
941
  city String
943
942
  state String
944
- postalCode String
943
+ zipCode String
945
944
  country String
946
945
  phone String
947
946
  coverPhoto String?
@@ -980,10 +979,10 @@ model EntertainmentService {
980
979
  entertainmentServiceSubType String?
981
980
  genre MusicGenreType?
982
981
  email String
983
- streetAddress String
982
+ street String
984
983
  city String
985
984
  state String
986
- postalCode String
985
+ zipCode String
987
986
  country String
988
987
  phone String
989
988
  coverPhoto String?
@@ -1018,10 +1017,10 @@ model Vendor {
1018
1017
  businessId String?
1019
1018
  vendorName String
1020
1019
  email String
1021
- streetAddress String
1020
+ street String
1022
1021
  city String
1023
1022
  state String
1024
- postalCode String
1023
+ zipCode String
1025
1024
  country String
1026
1025
  phone String
1027
1026
  coverPhoto String?
@@ -1057,10 +1056,10 @@ model Exhibitor {
1057
1056
  businessId String?
1058
1057
  exhibitorName String
1059
1058
  email String
1060
- streetAddress String
1059
+ street String
1061
1060
  city String
1062
1061
  state String
1063
- postalCode String
1062
+ zipCode String
1064
1063
  country String
1065
1064
  phone String
1066
1065
  coverPhoto String?
@@ -1095,10 +1094,10 @@ model Sponsor {
1095
1094
  businessId String?
1096
1095
  sponsorName String
1097
1096
  email String
1098
- streetAddress String
1097
+ street String
1099
1098
  city String
1100
1099
  state String
1101
- postalCode String
1100
+ zipCode String
1102
1101
  country String
1103
1102
  phone String
1104
1103
  coverPhoto String?
@@ -1134,10 +1133,10 @@ model Venue {
1134
1133
  businessId String
1135
1134
  venueName String
1136
1135
  email String
1137
- streetAddress String
1136
+ street String
1138
1137
  city String
1139
1138
  state String
1140
- postalCode String
1139
+ zipCode String
1141
1140
  country String
1142
1141
  phone String
1143
1142
  coverPhoto String?
@@ -1180,10 +1179,10 @@ model Organization {
1180
1179
  organizationName String
1181
1180
  organizationType OrganizationType[]
1182
1181
  email String
1183
- streetAddress String
1182
+ street String
1184
1183
  city String
1185
1184
  state String
1186
- postalCode String
1185
+ zipCode String
1187
1186
  country String
1188
1187
  phone String
1189
1188
  coverPhoto String?
@@ -88,16 +88,21 @@ export type DateTimeArgType = Date | string | undefined | null;
88
88
  export type RequiredStripeInfoMissingErrorDataType = { [k in keyof User]?: { type: string, label: string } };
89
89
  export type ContactOrUser = Contact | PublicUser;
90
90
 
91
- export const ServiceTypes: (keyof BusinessExt)[] = [
92
- 'volunteerService',
93
- 'eventServices',
94
- 'organizations',
95
- 'venues',
96
- 'vendors',
97
- 'sponsors',
98
- 'exhibitors',
99
- 'entertainmentServices',
100
- ] as const;
91
+ export type UnionFromArray<T extends ReadonlyArray<any>> = T[number];
92
+ export type ValueOf<T> = T[keyof T];
93
+
94
+ export type ValueOfServiceType = ValueOf<typeof ServiceType>;
95
+
96
+ export const ServiceType = {
97
+ 'Volunteer': 'volunteerService',
98
+ 'EventService': 'eventServices',
99
+ 'Organization': 'organizations',
100
+ 'Venue': 'venues',
101
+ 'Vendor': 'vendors',
102
+ 'Sponsor': 'sponsors',
103
+ 'Exhibitor': 'exhibitors',
104
+ 'EntertainmentService': 'entertainmentServices',
105
+ } satisfies {[key: string]: keyof BusinessExt}
101
106
 
102
107
  export type FilterFields = {
103
108
  price: string[];
@@ -305,6 +310,20 @@ export const YearsOfExperienceToString: { [key in YearsOfExperience]: string } =
305
310
  [YearsOfExperience.FivePlusYears]: 'More than five years',
306
311
  };
307
312
 
313
+ export type ServiceTypeToStringType = {
314
+ [key in ValueOf<typeof ServiceType>]: string;
315
+ };
316
+ export const ServiceTypeToString: ServiceTypeToStringType = {
317
+ [ServiceType.Volunteer]: "/servicesDefault.webp",
318
+ [ServiceType.EventService]: "/servicesDefault.webp",
319
+ [ServiceType.EntertainmentService]: "/servicesDefault.webp",
320
+ [ServiceType.Vendor]: "/servicesDefault.webp",
321
+ [ServiceType.Exhibitor]: "/servicesDefault.webp",
322
+ [ServiceType.Sponsor]: "/servicesDefault.webp",
323
+ [ServiceType.Venue]: "/servicesDefault.webp",
324
+ [ServiceType.Organization]: "/servicesDefault.webp"
325
+ }
326
+
308
327
  export type BashEventTypeToStringType = {
309
328
  [key in BashEventType]: string;
310
329
  };
@@ -454,3 +473,14 @@ type AllKeysUnion<T> = T extends object
454
473
  : never;
455
474
 
456
475
  export type AllKeys<T> = AllKeysUnion<T>[];
476
+
477
+
478
+
479
+ export interface IAddress {
480
+ place?: string;
481
+ street: string;
482
+ city: string;
483
+ state: string;
484
+ zipCode: string;
485
+ country: string;
486
+ }
@@ -8,7 +8,7 @@ import {
8
8
  User,
9
9
  TicketTier, Business, Review, Media, BashComment, Recurrence, Contact,
10
10
  BashNotification, BashEventPromoCode,
11
- Reminder, ServiceRange,
11
+ Reminder,
12
12
  Checkout,
13
13
  ServiceLink,
14
14
  Link, Venue, Availability,
@@ -21,8 +21,9 @@ import {
21
21
  Sponsor,
22
22
  Organization,
23
23
  Booking,
24
- VolunteerService,
24
+ VolunteerService, Prisma,
25
25
  } from "@prisma/client";
26
+ import {UnionFromArray} from "./definitions";
26
27
 
27
28
  export const FRONT_END_USER_DATA_TO_SELECT = {
28
29
  id: true,
@@ -31,18 +32,17 @@ export const FRONT_END_USER_DATA_TO_SELECT = {
31
32
  familyName: true,
32
33
  image: true,
33
34
  uploadedImage: true,
34
- services: true,
35
- }
35
+ } satisfies Prisma.UserSelect;
36
36
 
37
37
  export const PRIVATE_USER_ACCOUNT_TO_SELECT = {
38
38
  ...FRONT_END_USER_DATA_TO_SELECT,
39
- streetAddress: true,
39
+ street: true,
40
40
  city: true,
41
41
  state: true,
42
- postalCode: true,
42
+ zipCode: true,
43
43
  country: true,
44
44
  phone: true,
45
- }
45
+ } satisfies Prisma.UserSelect;
46
46
 
47
47
  export interface BashEventExt extends BashEvent {
48
48
  targetAudience?: TargetAudience;
@@ -59,7 +59,7 @@ export interface BashEventExt extends BashEvent {
59
59
 
60
60
  export const TICKET_TIER_DATA_TO_INCLUDE = {
61
61
  promoCodes: true,
62
- }
62
+ } satisfies Prisma.TicketTierInclude;
63
63
 
64
64
  export const BASH_EVENT_DATA_TO_INCLUDE = {
65
65
  creator: {
@@ -73,7 +73,7 @@ export const BASH_EVENT_DATA_TO_INCLUDE = {
73
73
  },
74
74
  eventTasks: true,
75
75
  media: true,
76
- }
76
+ } satisfies Prisma.BashEventInclude;
77
77
 
78
78
  export const BASH_EVENT_DATA_TO_CLONE = [
79
79
  'ticketTiers',
@@ -83,7 +83,6 @@ export const BASH_EVENT_DATA_TO_CLONE = [
83
83
  ] as const;
84
84
 
85
85
  type RemoveCommonProperties<T, U> = keyof (Omit<T, keyof U> & Omit<U, keyof T>);
86
- export type UnionFromArray<T extends ReadonlyArray<any>> = T[number];
87
86
  type BashEventExtMinusDataToCloneType = Omit<BashEventExt, UnionFromArray<typeof BASH_EVENT_DATA_TO_CLONE>>;
88
87
 
89
88
  export const BASH_EVENT_DATA_TO_REMOVE: RemoveCommonProperties<BashEvent, BashEventExtMinusDataToCloneType>[] = [
@@ -185,6 +184,10 @@ export const VENDOR_DATA_TO_INCLUDE = {
185
184
  media: true,
186
185
  }
187
186
 
187
+ export const SERVICE_LINK_DATA_TO_INCLUDE = {
188
+ link: true,
189
+ }
190
+
188
191
  export interface VenueExt extends Venue {
189
192
  business: Business;
190
193
  availableDateTimes: Availability[];
@@ -198,7 +201,9 @@ export const VENUE_DATA_TO_INCLUDE = {
198
201
  business: true,
199
202
  availableDateTimes: true,
200
203
  targetAudience: true,
201
- links: true,
204
+ links: {
205
+ include: SERVICE_LINK_DATA_TO_INCLUDE
206
+ },
202
207
  capacity: true,
203
208
  media: true,
204
209
  }
@@ -217,8 +222,8 @@ export interface OrganizationExt extends Organization {
217
222
  export interface BusinessExt extends Business {
218
223
  owner: PublicUser;
219
224
  media: Media[];
220
- targetAudience: TargetAudience;
221
- volunteerService?: VolunteerService;
225
+ targetAudience?: TargetAudience | null;
226
+ volunteerService?: VolunteerService | null;
222
227
  serviceLinks?: ServiceLinkExt[];
223
228
  venues?: Venue[];
224
229
  eventServices?: EventService[];
@@ -230,14 +235,6 @@ export interface BusinessExt extends Business {
230
235
  bookings?: Booking[];
231
236
  }
232
237
 
233
- export interface ServiceLinkExt extends ServiceLink {
234
- link: Link;
235
- }
236
-
237
- export const SERVICE_LINK_DATA_TO_INCLUDE = {
238
- link: true,
239
- }
240
-
241
238
  export const BUSINESS_DATA_TO_INCLUDE = {
242
239
  owner: {
243
240
  select: FRONT_END_USER_DATA_TO_SELECT
@@ -254,6 +251,10 @@ export const BUSINESS_DATA_TO_INCLUDE = {
254
251
  vendors: {
255
252
  include: VENDOR_DATA_TO_INCLUDE
256
253
  }
254
+ } satisfies Prisma.BusinessInclude
255
+
256
+ export interface ServiceLinkExt extends ServiceLink {
257
+ link: Link;
257
258
  }
258
259
 
259
260
  export interface InvitationExt extends Invitation {
@@ -338,7 +339,7 @@ export interface UserExtraData extends User {
338
339
  }
339
340
 
340
341
  export interface UserExt extends User {
341
- services?: Business[] | null;
342
+ businesses?: Business[] | null;
342
343
 
343
344
  // Do not include in fetch as there could be thousands of these
344
345
  associatedBashes?: AssociatedBash[] | null;
@@ -1,18 +1,10 @@
1
+ import {IAddress} from "../definitions";
1
2
 
2
3
  const ADDRESS_DELIM = '|';
3
4
 
4
5
  const googleMapsApiKey = process.env.REACT_APP_GOOGLE_MAP_API_KEY as string;
5
6
 
6
7
 
7
- export interface IAddress {
8
- place: string;
9
- street: string;
10
- city: string;
11
- state: string;
12
- zipCode: string;
13
- country: string;
14
- }
15
-
16
8
  export function addressHasEnoughDataForGeolocation(address: IAddress): boolean {
17
9
  return !!((address.place && address.city && address.state) || (address.street && address.city && address.state));
18
10
  }
@@ -60,6 +52,13 @@ export function databaseAddressStringToDisplayString(addressString: string | und
60
52
  return '';
61
53
  }
62
54
 
55
+ export function addressToDisplayString(address: IAddress): string {
56
+ let addressArr = address.place ? [address.place] : [];
57
+ addressArr = [...addressArr, address.street, address.city, address.state];
58
+ const addressStr = addressArr.filter((str) => !!str).join(', ');
59
+ return `${addressStr} ${address.zipCode}`;
60
+ }
61
+
63
62
 
64
63
  export async function getAddressFromCoordinates( lat: number, lng: number ): Promise<IAddress> {
65
64
  const apiUrl = `https://maps.googleapis.com/maps/api/geocode/json?latlng=${lat},${lng}&key=${googleMapsApiKey}&loading=async`;