@bash-app/bash-common 30.39.0 → 30.42.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 +1 -1
- package/prisma/schema.prisma +76 -42
- package/src/extendedSchemas.ts +67 -61
- package/src/index.ts +1 -0
- package/src/utils/addressUtils.ts +34 -5
- package/src/utils/service/serviceUtils.ts +10 -0
- package/src/utils/userUtils.ts +1 -0
package/package.json
CHANGED
package/prisma/schema.prisma
CHANGED
|
@@ -94,18 +94,18 @@ model CompetitionSponsor {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
model EventTask {
|
|
97
|
-
id
|
|
98
|
-
creatorId
|
|
99
|
-
creator
|
|
100
|
-
bashEventId
|
|
101
|
-
bashEvent
|
|
102
|
-
title
|
|
103
|
-
description
|
|
104
|
-
assignedToId
|
|
105
|
-
assignedTo
|
|
106
|
-
status
|
|
107
|
-
|
|
108
|
-
createdAt
|
|
97
|
+
id String @id @default(cuid())
|
|
98
|
+
creatorId String
|
|
99
|
+
creator User @relation(fields: [creatorId], references: [id], onDelete: Cascade)
|
|
100
|
+
bashEventId String
|
|
101
|
+
bashEvent BashEvent @relation(fields: [bashEventId], references: [id], onDelete: Cascade)
|
|
102
|
+
title String
|
|
103
|
+
description String?
|
|
104
|
+
assignedToId String?
|
|
105
|
+
assignedTo User? @relation("TasksAssignedToMe", fields: [assignedToId], references: [id], onDelete: Cascade)
|
|
106
|
+
status TaskStatus?
|
|
107
|
+
notificationsReferencingMe Notification[]
|
|
108
|
+
createdAt DateTime? @default(now())
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
enum TaskStatus {
|
|
@@ -118,14 +118,14 @@ enum TaskStatus {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
model Reminder {
|
|
121
|
-
id String
|
|
121
|
+
id String @id @default(cuid())
|
|
122
122
|
creatorId String
|
|
123
|
-
creator User
|
|
123
|
+
creator User @relation("RemindersCreatedByMe", fields: [creatorId], references: [id], onDelete: Cascade)
|
|
124
124
|
remindWhoId String?
|
|
125
|
-
remindWho User?
|
|
125
|
+
remindWho User? @relation("RemindersAssignedToMe", fields: [remindWhoId], references: [id], onDelete: Cascade)
|
|
126
126
|
remindDateTime DateTime
|
|
127
127
|
notificationId String
|
|
128
|
-
notification
|
|
128
|
+
notification Notification @relation(fields: [notificationId], references: [id], onDelete: Cascade)
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
model BashEventPromoCode {
|
|
@@ -195,15 +195,18 @@ model PromoterClick {
|
|
|
195
195
|
clickedAt DateTime @default(now())
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
model
|
|
198
|
+
model Notification {
|
|
199
199
|
id String @id @default(cuid())
|
|
200
200
|
creatorId String
|
|
201
201
|
creator User @relation("NotificationsCreatedByMe", fields: [creatorId], references: [id], onDelete: Cascade)
|
|
202
202
|
email String
|
|
203
|
+
userId String? // Direct reference to recipient user
|
|
204
|
+
user User? @relation("NotificationsReceivedByMe", fields: [userId], references: [id], onDelete: Cascade)
|
|
203
205
|
createdDateTime DateTime @default(now())
|
|
204
206
|
message String
|
|
205
207
|
image String?
|
|
206
208
|
readDateTime DateTime?
|
|
209
|
+
type String // Notification type: "FOLLOW", "TASK", "EVENT", etc.
|
|
207
210
|
taskId String?
|
|
208
211
|
eventTask EventTask? @relation(fields: [taskId], references: [id], onDelete: Cascade)
|
|
209
212
|
invitationId String?
|
|
@@ -217,33 +220,41 @@ model BashNotification {
|
|
|
217
220
|
reminders Reminder[]
|
|
218
221
|
redirectUrl String?
|
|
219
222
|
|
|
223
|
+
// Additional specific fields for different notification types
|
|
224
|
+
actionTaken Boolean? // For notifications that may require action
|
|
225
|
+
actionType String? // Type of action taken (ACCEPT, REJECT, etc.)
|
|
226
|
+
priority String? // Priority level (HIGH, MEDIUM, LOW)
|
|
227
|
+
expiresAt DateTime? // For time-sensitive notifications
|
|
228
|
+
|
|
220
229
|
@@unique([creatorId, email, bashEventId, taskId])
|
|
221
230
|
@@unique([creatorId, email, invitationId])
|
|
222
231
|
@@unique([creatorId, email, serviceBookingId])
|
|
223
232
|
@@index([creatorId])
|
|
233
|
+
@@index([userId])
|
|
234
|
+
@@index([type]) // Add index for efficient filtering by notification type
|
|
224
235
|
}
|
|
225
236
|
|
|
226
237
|
model Invitation {
|
|
227
|
-
id
|
|
228
|
-
creatorId
|
|
229
|
-
creator
|
|
230
|
-
email
|
|
231
|
-
sentToId
|
|
232
|
-
sentTo
|
|
233
|
-
bashEventId
|
|
234
|
-
bashEvent
|
|
235
|
-
image
|
|
236
|
-
phone
|
|
237
|
-
name
|
|
238
|
-
message
|
|
239
|
-
inviteDate
|
|
240
|
-
acceptedDate
|
|
241
|
-
rejectedDate
|
|
242
|
-
maybeDate
|
|
243
|
-
isFreeGuest
|
|
244
|
-
tickets
|
|
245
|
-
|
|
246
|
-
associatedBash
|
|
238
|
+
id String @id @default(cuid())
|
|
239
|
+
creatorId String
|
|
240
|
+
creator User @relation("InvitationsCreatedByMe", fields: [creatorId], references: [id], onDelete: Cascade)
|
|
241
|
+
email String
|
|
242
|
+
sentToId String?
|
|
243
|
+
sentTo User? @relation("InvitationsSentToMe", fields: [sentToId], references: [id], onDelete: Cascade)
|
|
244
|
+
bashEventId String?
|
|
245
|
+
bashEvent BashEvent? @relation(fields: [bashEventId], references: [id], onDelete: Cascade)
|
|
246
|
+
image String?
|
|
247
|
+
phone String?
|
|
248
|
+
name String?
|
|
249
|
+
message String?
|
|
250
|
+
inviteDate DateTime? @default(now())
|
|
251
|
+
acceptedDate DateTime?
|
|
252
|
+
rejectedDate DateTime?
|
|
253
|
+
maybeDate DateTime?
|
|
254
|
+
isFreeGuest Boolean @default(false)
|
|
255
|
+
tickets Ticket[] @relation("TicketsForInvitation")
|
|
256
|
+
notifications Notification[]
|
|
257
|
+
associatedBash AssociatedBash?
|
|
247
258
|
|
|
248
259
|
@@index([email])
|
|
249
260
|
}
|
|
@@ -302,7 +313,7 @@ model BashEvent {
|
|
|
302
313
|
includedItems String[]
|
|
303
314
|
associatedBashesReferencingMe AssociatedBash[] // maybe rename later to AssociatedWithABash
|
|
304
315
|
associatedServicesReferencingMe Service[] // maybe rename later to AssociatedWithAService
|
|
305
|
-
|
|
316
|
+
notificationsReferencingMe Notification[]
|
|
306
317
|
checkouts Checkout[]
|
|
307
318
|
eventTasks EventTask[]
|
|
308
319
|
videoLink String?
|
|
@@ -1047,7 +1058,7 @@ model User {
|
|
|
1047
1058
|
associatedServices AssociatedService[]
|
|
1048
1059
|
invitationsCreatedByMe Invitation[] @relation("InvitationsCreatedByMe")
|
|
1049
1060
|
invitationsSentToMe Invitation[] @relation("InvitationsSentToMe")
|
|
1050
|
-
notificationsCreatedByMe
|
|
1061
|
+
notificationsCreatedByMe Notification[] @relation("NotificationsCreatedByMe")
|
|
1051
1062
|
remindersCreatedByMe Reminder[] @relation("RemindersCreatedByMe")
|
|
1052
1063
|
remindersAssignedToMe Reminder[] @relation("RemindersAssignedToMe")
|
|
1053
1064
|
eventTasksAssignedToMe EventTask[] @relation("TasksAssignedToMe")
|
|
@@ -1094,6 +1105,10 @@ model User {
|
|
|
1094
1105
|
demerits Demerit[] @relation("UserDemerits")
|
|
1095
1106
|
issuedDemerits Demerit[] @relation("IssuedDemerits")
|
|
1096
1107
|
expungedDemerits Demerit[] @relation("ExpungedDemerits")
|
|
1108
|
+
|
|
1109
|
+
notification Notification[] @relation("NotificationsReceivedByMe")
|
|
1110
|
+
followers UserFollowing[] @relation("Following")
|
|
1111
|
+
following UserFollowing[] @relation("Follower")
|
|
1097
1112
|
}
|
|
1098
1113
|
|
|
1099
1114
|
model UserPreferences {
|
|
@@ -1164,6 +1179,20 @@ model UserPreferences {
|
|
|
1164
1179
|
updatedAt DateTime @updatedAt
|
|
1165
1180
|
}
|
|
1166
1181
|
|
|
1182
|
+
model UserFollowing {
|
|
1183
|
+
id String @id @default(cuid())
|
|
1184
|
+
userId String
|
|
1185
|
+
followingId String
|
|
1186
|
+
isFollowing Boolean @default(true)
|
|
1187
|
+
followedAt DateTime?
|
|
1188
|
+
unfollowedAt DateTime?
|
|
1189
|
+
|
|
1190
|
+
user User @relation("Follower", fields: [userId], references: [id], onDelete: Cascade)
|
|
1191
|
+
following User @relation("Following", fields: [followingId], references: [id], onDelete: Cascade)
|
|
1192
|
+
|
|
1193
|
+
@@unique([userId, followingId])
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1167
1196
|
model Contact {
|
|
1168
1197
|
id String @id @default(cuid())
|
|
1169
1198
|
contactOwnerId String
|
|
@@ -1393,6 +1422,9 @@ model Service {
|
|
|
1393
1422
|
displayGoogleReviewsOnDetailPage Boolean @default(true)
|
|
1394
1423
|
displayBashReviewsOnDetailPage Boolean @default(true)
|
|
1395
1424
|
|
|
1425
|
+
serviceRating Float? @default(0)
|
|
1426
|
+
totalRatings Int? @default(0)
|
|
1427
|
+
|
|
1396
1428
|
stripeAccountId String?
|
|
1397
1429
|
stripeAccount StripeAccount? @relation(fields: [stripeAccountId], references: [id], onDelete: Restrict)
|
|
1398
1430
|
|
|
@@ -1431,7 +1463,7 @@ model Service {
|
|
|
1431
1463
|
bashEvent BashEvent[] // because a service needs to be associated with a bash to post to the bashfeed
|
|
1432
1464
|
userPromoCodeRedemption UserPromoCodeRedemption[]
|
|
1433
1465
|
bookings ServiceBooking[]
|
|
1434
|
-
|
|
1466
|
+
notification Notification[]
|
|
1435
1467
|
}
|
|
1436
1468
|
|
|
1437
1469
|
model StripeAccount {
|
|
@@ -1573,6 +1605,7 @@ model Venue {
|
|
|
1573
1605
|
secondaryVenueTypes String[] @default([])
|
|
1574
1606
|
pitch String?
|
|
1575
1607
|
capacity Int?
|
|
1608
|
+
squareFootage Int?
|
|
1576
1609
|
anticipatedAttendees Int?
|
|
1577
1610
|
trademark Boolean?
|
|
1578
1611
|
manager Boolean?
|
|
@@ -2064,8 +2097,8 @@ model ServiceBooking {
|
|
|
2064
2097
|
isFreeGuest Boolean @default(false)
|
|
2065
2098
|
allowPromiseToPay Boolean @default(false)
|
|
2066
2099
|
|
|
2067
|
-
checkout
|
|
2068
|
-
|
|
2100
|
+
checkout ServiceBookingCheckout?
|
|
2101
|
+
notification Notification[]
|
|
2069
2102
|
|
|
2070
2103
|
additionalFees ServiceBookingFee[]
|
|
2071
2104
|
|
|
@@ -2230,6 +2263,7 @@ model UserStats {
|
|
|
2230
2263
|
totalEarnings Float @default(0)
|
|
2231
2264
|
servicesBookedCount Int @default(0)
|
|
2232
2265
|
followersCount Int @default(0)
|
|
2266
|
+
followingCount Int @default(0)
|
|
2233
2267
|
|
|
2234
2268
|
// Rankings
|
|
2235
2269
|
hostRank Int? // Rank based on number of events hosted
|
package/src/extendedSchemas.ts
CHANGED
|
@@ -1,68 +1,73 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
2
|
+
AmountOfGuests,
|
|
3
|
+
AssociatedBash,
|
|
4
|
+
AssociatedService,
|
|
5
|
+
BashComment,
|
|
6
|
+
BashEvent,
|
|
7
|
+
BashEventPromoCode,
|
|
8
|
+
Checkout,
|
|
9
|
+
Contact,
|
|
10
|
+
Coordinates,
|
|
11
|
+
Demerit,
|
|
12
|
+
EntertainmentService,
|
|
13
|
+
EventService,
|
|
14
|
+
EventTask,
|
|
15
|
+
Exhibitor,
|
|
16
|
+
Invitation,
|
|
17
|
+
Link,
|
|
18
|
+
Media,
|
|
19
|
+
Notification,
|
|
20
|
+
Organization,
|
|
21
|
+
Prisma,
|
|
22
|
+
Recurrence,
|
|
23
|
+
Reminder,
|
|
24
|
+
Review,
|
|
25
|
+
Service,
|
|
26
|
+
ServiceAddon,
|
|
27
|
+
ServiceBooking,
|
|
28
|
+
ServiceBookingAddOn,
|
|
29
|
+
ServiceBookingCheckout,
|
|
30
|
+
ServiceBookingDay,
|
|
31
|
+
ServiceBookingFee,
|
|
32
|
+
ServiceBookingPackage,
|
|
33
|
+
ServiceBookingPriceBreakdown,
|
|
34
|
+
ServiceDailyRates,
|
|
35
|
+
ServiceLink,
|
|
36
|
+
ServicePackage,
|
|
37
|
+
ServiceRange,
|
|
38
|
+
ServiceRate,
|
|
39
|
+
ServiceRatesAssociation,
|
|
40
|
+
ServiceSpecialRates,
|
|
41
|
+
ServiceSubscriptionCounts,
|
|
42
|
+
SocialMediaPlatform,
|
|
43
|
+
SocialMediaProfile,
|
|
44
|
+
Sponsor,
|
|
45
|
+
SponsoredEvent,
|
|
46
|
+
StripeAccount,
|
|
47
|
+
TargetAudience,
|
|
48
|
+
Ticket,
|
|
49
|
+
TicketMetadata,
|
|
50
|
+
TicketTier,
|
|
51
|
+
TicketTransfer,
|
|
52
|
+
User,
|
|
53
|
+
UserPreferences,
|
|
54
|
+
UserStats,
|
|
55
|
+
UserSubscription,
|
|
56
|
+
Vendor,
|
|
57
|
+
Venue,
|
|
58
|
+
VolunteerService,
|
|
59
59
|
} from "@prisma/client";
|
|
60
60
|
import { SERVICE_LINK_DATA_TO_INCLUDE } from "./definitions";
|
|
61
61
|
import {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
RemoveCommonProperties,
|
|
63
|
+
UnionFromArray
|
|
64
64
|
} from "./utils/typeUtils";
|
|
65
65
|
|
|
66
|
+
export interface ApiResponse<T> {
|
|
67
|
+
data: T;
|
|
68
|
+
error?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
66
71
|
//------------------------------------------------------user subscriptions------------------------------------------------------
|
|
67
72
|
export const PUBLIC_USER_SUBSCRIPTION_DATA_TO_SELECT = {
|
|
68
73
|
type: true,
|
|
@@ -93,6 +98,7 @@ export type UserSubscriptionExt = {
|
|
|
93
98
|
|
|
94
99
|
export const FRONT_END_USER_DATA_TO_SELECT = {
|
|
95
100
|
id: true,
|
|
101
|
+
username: true,
|
|
96
102
|
email: true,
|
|
97
103
|
givenName: true,
|
|
98
104
|
familyName: true,
|
|
@@ -630,7 +636,7 @@ export interface ServiceLinkExt extends ServiceLink {
|
|
|
630
636
|
|
|
631
637
|
//-----------------------------------------
|
|
632
638
|
|
|
633
|
-
export interface
|
|
639
|
+
export interface NotificationExt extends Notification {
|
|
634
640
|
bashEvent?: BashEvent;
|
|
635
641
|
creator?: PublicUser;
|
|
636
642
|
eventTask?: EventTask;
|
|
@@ -676,7 +682,7 @@ export const BASH_NOTIFICATION_DATA_TO_INCLUDE = {
|
|
|
676
682
|
serviceBooking: {
|
|
677
683
|
include: SERVICE_BOOKING_PUBLIC_DATA_TO_INCLUDE,
|
|
678
684
|
},
|
|
679
|
-
} satisfies Prisma.
|
|
685
|
+
} satisfies Prisma.NotificationInclude;
|
|
680
686
|
|
|
681
687
|
export interface EventTaskExt extends EventTask {
|
|
682
688
|
creator: PublicUser;
|
package/src/index.ts
CHANGED
|
@@ -29,5 +29,6 @@ export * from "./utils/service/serviceBookingStatusUtils";
|
|
|
29
29
|
export * from "./utils/stripeAccountUtils";
|
|
30
30
|
export * from "./utils/entityUtils";
|
|
31
31
|
export * from "./utils/generalDateTimeUtils";
|
|
32
|
+
export * from "./utils/userUtils";
|
|
32
33
|
export * from "./utils/luxonUtils";
|
|
33
34
|
export * from "./utils/mathUtils";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {IAddress} from "../definitions";
|
|
1
|
+
import { IAddress } from "../definitions";
|
|
2
2
|
|
|
3
3
|
const ADDRESS_DELIM = '|';
|
|
4
4
|
|
|
@@ -32,21 +32,50 @@ export function databaseAddressStringToAddressValues(addressString: string | und
|
|
|
32
32
|
|
|
33
33
|
export function databaseAddressStringToOneLineString(addressString: string | undefined | null): string {
|
|
34
34
|
if (addressString) {
|
|
35
|
+
// Special handling for place-only addresses
|
|
36
|
+
if (!addressString.includes(ADDRESS_DELIM)) {
|
|
37
|
+
return addressString.trim();
|
|
38
|
+
}
|
|
39
|
+
|
|
35
40
|
const address = databaseAddressStringToAddressValues(addressString);
|
|
41
|
+
|
|
42
|
+
// If only place exists, just return it
|
|
43
|
+
if (address.place &&
|
|
44
|
+
(!address.street || address.street === 'undefined') &&
|
|
45
|
+
(!address.city || address.city === 'undefined') &&
|
|
46
|
+
(!address.state || address.state === 'undefined')) {
|
|
47
|
+
return address.place.trim();
|
|
48
|
+
}
|
|
49
|
+
|
|
36
50
|
let addressArr = address.place ? [address.place] : [];
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
51
|
+
|
|
52
|
+
// Add non-empty and non-undefined parts
|
|
53
|
+
if (address.street && address.street !== 'undefined') addressArr.push(address.street);
|
|
54
|
+
if (address.city && address.city !== 'undefined') addressArr.push(address.city);
|
|
55
|
+
if (address.state && address.state !== 'undefined') addressArr.push(address.state);
|
|
56
|
+
|
|
57
|
+
const addressStr = addressArr.filter(str => !!str && str !== 'undefined').join(', ');
|
|
58
|
+
|
|
59
|
+
// Only add zip code if it exists and isn't 'undefined'
|
|
60
|
+
return address.zipCode && address.zipCode !== 'undefined'
|
|
61
|
+
? `${addressStr} ${address.zipCode}`
|
|
62
|
+
: addressStr;
|
|
40
63
|
}
|
|
41
64
|
return '';
|
|
42
65
|
}
|
|
43
66
|
|
|
44
67
|
export function databaseAddressStringToDisplayString(addressString: string | undefined | null): string {
|
|
45
68
|
if (addressString) {
|
|
69
|
+
// Special handling for place-only addresses (no delimiters)
|
|
70
|
+
if (!addressString.includes(ADDRESS_DELIM)) {
|
|
71
|
+
return addressString.trim();
|
|
72
|
+
}
|
|
73
|
+
|
|
46
74
|
const oneLineString = databaseAddressStringToOneLineString(addressString);
|
|
47
75
|
const formatted = oneLineString.replace(/([A-Z])(?=[A-Z][a-z])/g, "$1 ") // Add space between a single uppercase letter and a capitalized word
|
|
48
76
|
.replace(/(\d)(?=[A-Z])/g, "$1 ") // Add space between numbers and letters
|
|
49
|
-
.replace(/,/g, ", ")
|
|
77
|
+
.replace(/,/g, ", ") // Add space after commas
|
|
78
|
+
.replace(/undefined/g, ""); // Remove any "undefined" strings
|
|
50
79
|
return formatted;
|
|
51
80
|
}
|
|
52
81
|
return '';
|
|
@@ -179,6 +179,16 @@ export function serviceDetailUrl(
|
|
|
179
179
|
return `/services/${serviceId}/${serviceType}/${specificId}`;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
export function serviceWizardUrl(
|
|
183
|
+
serviceId: string,
|
|
184
|
+
serviceType: string,
|
|
185
|
+
specificId: string,
|
|
186
|
+
step: number = 0,
|
|
187
|
+
substep: number = 0
|
|
188
|
+
) {
|
|
189
|
+
return `/wz/services/${serviceId}/${serviceType}/${specificId}/${step}/${substep}`;
|
|
190
|
+
}
|
|
191
|
+
|
|
182
192
|
export function serviceCheckoutUrl(
|
|
183
193
|
serviceId: string,
|
|
184
194
|
serviceType: string,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const MAX_USER_NAME_CHANGES = 3 as const;
|