@bash-app/bash-common 18.2.0 → 18.3.1

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.
@@ -1,278 +1,289 @@
1
- import {
2
- AmountOfGuests,
3
- EventTask,
4
- AssociatedBash,
5
- BashEvent,
6
- Invitation,
7
- Ticket,
8
- User,
9
- TicketTier, Service, Review, Media, BashComment, Recurrence, Contact,
10
- BashNotification, BashEventPromoCode,
11
- Reminder, ServiceRange,
12
- Checkout,
13
- ServiceLink,
14
- Link, Venue, Availability,
15
- TargetAudience,
16
- ServiceStatus,
17
- } from "@prisma/client";
18
- import { AttendeeOfBashEvent } from "./definitions";
19
-
20
- export const FRONT_END_USER_DATA_TO_SELECT = {
21
- id: true,
22
- email: true,
23
- givenName: true,
24
- familyName: true,
25
- image: true,
26
- uploadedImage: true,
27
- services: true,
28
- }
29
-
30
- export const PRIVATE_USER_ACCOUNT_TO_SELECT = {
31
- ...FRONT_END_USER_DATA_TO_SELECT,
32
- streetAddress: true,
33
- city: true,
34
- state: true,
35
- postalCode: true,
36
- country: true,
37
- phone: true,
38
- }
39
-
40
- export interface BashEventExt extends BashEvent {
41
- targetAudience?: TargetAudience;
42
- amountOfGuests?: AmountOfGuests;
43
- recurrence?: Recurrence;
44
- creator?: PublicUser;
45
- ticketTiers: TicketTierExt[];
46
- media: Media[];
47
- eventTasks: EventTask[];
48
- tickets?: Ticket[]; // Only include tickets that the user has purchased and not all tickets (could be thousands + privacy)
49
- // Do not include in fetch. Could be hundreds of these
50
- invitations: InvitationExt[];
51
- }
52
-
53
- export const TICKET_TIER_DATA_TO_INCLUDE = {
54
- promoCodes: true,
55
- }
56
-
57
- export const BASH_EVENT_DATA_TO_INCLUDE = {
58
- creator: {
59
- select: FRONT_END_USER_DATA_TO_SELECT
60
- },
61
- targetAudience: true,
62
- amountOfGuests: true,
63
- recurrence: true,
64
- ticketTiers: {
65
- include: TICKET_TIER_DATA_TO_INCLUDE
66
- },
67
- eventTasks: true,
68
- media: true,
69
- }
70
-
71
- export const BASH_EVENT_DATA_TO_CLONE = [
72
- 'targetAudience',
73
- 'amountOfGuests',
74
- 'ticketTiers',
75
- 'media',
76
- 'recurrence',
77
- 'invitations',
78
- ] as const;
79
-
80
- export interface BashNotificationExt extends BashNotification {
81
- creator?: PublicUser;
82
- bashEvent?: BashEvent;
83
- eventTask?: EventTask;
84
- invitation?: Invitation;
85
- reminders?: Reminder[];
86
- }
87
-
88
- export const BASH_NOTIFICATION_DATA_TO_INCLUDE = {
89
- bashEvent: {
90
- select: {
91
- coverPhoto: true,
92
- },
93
- },
94
- creator: {
95
- select: {
96
- image: true,
97
- },
98
- },
99
-
100
- }
101
-
102
- export interface EventTaskExt extends EventTask {
103
- creator: PublicUser;
104
- assignedTo?: PublicUser | null;
105
- }
106
-
107
- export const EVENT_TASK_DATA_TO_INCLUDE = {
108
- creator: {
109
- select: FRONT_END_USER_DATA_TO_SELECT
110
- },
111
- assignedTo: {
112
- select: FRONT_END_USER_DATA_TO_SELECT
113
- }
114
- }
115
-
116
- type RemoveCommonProperties<T, U> = keyof (Omit<T, keyof U> & Omit<U, keyof T>);
117
- type UnionFromArray<T extends ReadonlyArray<any>> = T[number];
118
- type BashEventExtMinusDataToCloneType = Omit<BashEventExt, UnionFromArray<typeof BASH_EVENT_DATA_TO_CLONE>>;
119
-
120
- export const BASH_EVENT_DATA_TO_REMOVE: RemoveCommonProperties<BashEvent, BashEventExtMinusDataToCloneType>[] = [
121
- 'creator',
122
- 'eventTasks',
123
- 'tickets'
124
- ];
125
-
126
- export interface VenueExt extends Venue {
127
- service: Service;
128
- availableDateTimes: Availability[];
129
- targetAudience: TargetAudience;
130
- venueLinks: ServiceLinkExt[];
131
- capacity?: AmountOfGuests;
132
- media?: Media[];
133
- status: ServiceStatus;
134
- }
135
-
136
- export const VENUE_DATA_TO_INCLUDE = {
137
- service: true,
138
- availableDateTimes: true,
139
- targetAudience: true,
140
- venueLinks: true,
141
- capacity: true,
142
- media: true,
143
- }
144
-
145
- export interface ServiceExt extends Service {
146
- owner: PublicUser;
147
- media: Media[];
148
- serviceRange: ServiceRange;
149
- targetAudience: TargetAudience;
150
- serviceLinks?: ServiceLinkExt[];
151
- venues: VenueExt[];
152
- }
153
-
154
- export interface ServiceLinkExt extends ServiceLink {
155
- link: Link;
156
- }
157
-
158
- export const SERVICE_LINK_DATA_TO_INCLUDE = {
159
- link: true,
160
- }
161
-
162
- export const SERVICE_DATA_TO_INCLUDE = {
163
- owner: {
164
- select: FRONT_END_USER_DATA_TO_SELECT
165
- },
166
- media: true,
167
- serviceRange: true,
168
- targetAudience: true,
169
- serviceLinks: {
170
- include: SERVICE_LINK_DATA_TO_INCLUDE
171
- },
172
- venues: {
173
- include: VENUE_DATA_TO_INCLUDE
174
- }
175
- }
176
-
177
- export interface InvitationExt extends Invitation {
178
- creator: PublicUser;
179
- sentTo: PublicUser;
180
- tickets: Ticket[];
181
- associatedBash?: AssociatedBash | null;
182
- }
183
-
184
- export const INVITATION_DATA_TO_INCLUDE = {
185
- creator: {
186
- select: FRONT_END_USER_DATA_TO_SELECT
187
- },
188
- sentTo: {
189
- select: FRONT_END_USER_DATA_TO_SELECT
190
- },
191
- tickets: true,
192
- }
193
-
194
- export interface InvitationExtraData extends Invitation {
195
- isFreeGuest?: boolean;
196
- isOrganizer?: boolean;
197
- }
198
-
199
- export interface AssociatedBashExt extends AssociatedBash {
200
- bashEvent: BashEventExt;
201
- invitation: InvitationExt;
202
- }
203
-
204
- export const ASSOCIATED_BASH_DATA_TO_INCLUDE = {
205
- bashEvent: {
206
- include: BASH_EVENT_DATA_TO_INCLUDE
207
- },
208
- invitation: {
209
- include: INVITATION_DATA_TO_INCLUDE
210
- }
211
- }
212
-
213
- export interface TicketTierExt extends TicketTier {
214
- bashEvent: BashEvent;
215
- tickets: TicketExt[];
216
- promoCodes: BashEventPromoCode[];
217
- }
218
-
219
- export interface TicketExt extends Ticket {
220
- owner: PublicUser;
221
- forUser: PublicUser;
222
- checkout?: Checkout;
223
- }
224
-
225
- export interface CheckoutExt extends Checkout {
226
- owner: PublicUser;
227
- tickets: Ticket[]
228
- }
229
-
230
- export const CHECKOUT_DATA_TO_INCLUDE = {
231
- owner: {
232
- select: FRONT_END_USER_DATA_TO_SELECT
233
- },
234
- tickets: {
235
- select: {
236
- ownerId: true
237
- }
238
- }
239
- }
240
-
241
- export interface ReviewExt extends Review {
242
- comments: BashComment[];
243
- }
244
-
245
- export const CONTACT_DATA_TO_INCLUDE = {
246
- user: {
247
- select: FRONT_END_USER_DATA_TO_SELECT
248
- },
249
- media: true
250
- };
251
-
252
-
253
- export interface UserExtraData extends User {
254
- password?: string;
255
- otp?: string;
256
- }
257
-
258
- export interface UserExt extends User {
259
- services?: Service[] | null;
260
-
261
- // Do not include in fetch as there could be thousands of these
262
- associatedBashes?: AssociatedBash[] | null;
263
- reviews?: ReviewExt[] | null;
264
- contacts?: Contact[] | null;
265
- ticketsIOwn?: TicketExt[] | null;
266
- }
267
-
268
- export const USER_DATA_SELECT_REVIEWS_COMMENTS = {
269
- reviews: {
270
- include: {
271
- comments: true
272
- }
273
- }
274
- }
275
-
276
-
277
- export type PublicUser = Pick<UserExt, keyof typeof FRONT_END_USER_DATA_TO_SELECT>
278
- & Partial<Pick<UserExt, keyof typeof USER_DATA_SELECT_REVIEWS_COMMENTS>>;
1
+ import {
2
+ AmountOfGuests,
3
+ EventTask,
4
+ AssociatedBash,
5
+ BashEvent,
6
+ Invitation,
7
+ Ticket,
8
+ User,
9
+ TicketTier, Service, Review, Media, BashComment, Recurrence, Contact,
10
+ BashNotification, BashEventPromoCode,
11
+ Reminder, ServiceRange,
12
+ Checkout,
13
+ ServiceLink,
14
+ Link, Venue, Availability,
15
+ TargetAudience,
16
+ ServiceStatus,
17
+ Vendor,
18
+ } from "@prisma/client";
19
+ import { AttendeeOfBashEvent } from "./definitions";
20
+
21
+ export const FRONT_END_USER_DATA_TO_SELECT = {
22
+ id: true,
23
+ email: true,
24
+ givenName: true,
25
+ familyName: true,
26
+ image: true,
27
+ uploadedImage: true,
28
+ services: true,
29
+ }
30
+
31
+ export const PRIVATE_USER_ACCOUNT_TO_SELECT = {
32
+ ...FRONT_END_USER_DATA_TO_SELECT,
33
+ streetAddress: true,
34
+ city: true,
35
+ state: true,
36
+ postalCode: true,
37
+ country: true,
38
+ phone: true,
39
+ }
40
+
41
+ export interface BashEventExt extends BashEvent {
42
+ targetAudience?: TargetAudience;
43
+ amountOfGuests?: AmountOfGuests;
44
+ recurrence?: Recurrence;
45
+ creator?: PublicUser;
46
+ ticketTiers: TicketTierExt[];
47
+ media: Media[];
48
+ eventTasks: EventTask[];
49
+ tickets?: Ticket[]; // Only include tickets that the user has purchased and not all tickets (could be thousands + privacy)
50
+ // Do not include in fetch. Could be hundreds of these
51
+ invitations: InvitationExt[];
52
+ }
53
+
54
+ export const TICKET_TIER_DATA_TO_INCLUDE = {
55
+ promoCodes: true,
56
+ }
57
+
58
+ export const BASH_EVENT_DATA_TO_INCLUDE = {
59
+ creator: {
60
+ select: FRONT_END_USER_DATA_TO_SELECT
61
+ },
62
+ targetAudience: true,
63
+ amountOfGuests: true,
64
+ recurrence: true,
65
+ ticketTiers: {
66
+ include: TICKET_TIER_DATA_TO_INCLUDE
67
+ },
68
+ eventTasks: true,
69
+ media: true,
70
+ }
71
+
72
+ export const BASH_EVENT_DATA_TO_CLONE = [
73
+ 'targetAudience',
74
+ 'amountOfGuests',
75
+ 'ticketTiers',
76
+ 'media',
77
+ 'recurrence',
78
+ 'invitations',
79
+ ] as const;
80
+
81
+ export interface BashNotificationExt extends BashNotification {
82
+ creator?: PublicUser;
83
+ bashEvent?: BashEvent;
84
+ eventTask?: EventTask;
85
+ invitation?: Invitation;
86
+ reminders?: Reminder[];
87
+ }
88
+
89
+ export const BASH_NOTIFICATION_DATA_TO_INCLUDE = {
90
+ bashEvent: {
91
+ select: {
92
+ coverPhoto: true,
93
+ },
94
+ },
95
+ creator: {
96
+ select: {
97
+ image: true,
98
+ },
99
+ },
100
+
101
+ }
102
+
103
+ export interface EventTaskExt extends EventTask {
104
+ creator: PublicUser;
105
+ assignedTo?: PublicUser | null;
106
+ }
107
+
108
+ export const EVENT_TASK_DATA_TO_INCLUDE = {
109
+ creator: {
110
+ select: FRONT_END_USER_DATA_TO_SELECT
111
+ },
112
+ assignedTo: {
113
+ select: FRONT_END_USER_DATA_TO_SELECT
114
+ }
115
+ }
116
+
117
+ type RemoveCommonProperties<T, U> = keyof (Omit<T, keyof U> & Omit<U, keyof T>);
118
+ type UnionFromArray<T extends ReadonlyArray<any>> = T[number];
119
+ type BashEventExtMinusDataToCloneType = Omit<BashEventExt, UnionFromArray<typeof BASH_EVENT_DATA_TO_CLONE>>;
120
+
121
+ export const BASH_EVENT_DATA_TO_REMOVE: RemoveCommonProperties<BashEvent, BashEventExtMinusDataToCloneType>[] = [
122
+ 'creator',
123
+ 'eventTasks',
124
+ 'tickets'
125
+ ];
126
+
127
+ export interface VendorExt extends Vendor {
128
+ service: Service;
129
+ availableDateTimes: Availability[];
130
+ targetAudience: TargetAudience;
131
+ vendorLinks: ServiceLinkExt[];
132
+ capacity?: AmountOfGuests;
133
+ media?: Media[];
134
+ status: ServiceStatus;
135
+ }
136
+
137
+ export interface VenueExt extends Venue {
138
+ service: Service;
139
+ availableDateTimes: Availability[];
140
+ targetAudience: TargetAudience;
141
+ links: ServiceLinkExt[];
142
+ capacity?: AmountOfGuests;
143
+ media?: Media[];
144
+ status: ServiceStatus;
145
+ }
146
+
147
+ export const VENUE_DATA_TO_INCLUDE = {
148
+ service: true,
149
+ availableDateTimes: true,
150
+ targetAudience: true,
151
+ links: true,
152
+ capacity: true,
153
+ media: true,
154
+ }
155
+
156
+ export interface ServiceExt extends Service {
157
+ owner: PublicUser;
158
+ media: Media[];
159
+ serviceRange: ServiceRange;
160
+ targetAudience: TargetAudience;
161
+ serviceLinks?: ServiceLinkExt[];
162
+ venues: VenueExt[];
163
+ }
164
+
165
+ export interface ServiceLinkExt extends ServiceLink {
166
+ link: Link;
167
+ }
168
+
169
+ export const SERVICE_LINK_DATA_TO_INCLUDE = {
170
+ link: true,
171
+ }
172
+
173
+ export const SERVICE_DATA_TO_INCLUDE = {
174
+ owner: {
175
+ select: FRONT_END_USER_DATA_TO_SELECT
176
+ },
177
+ media: true,
178
+ serviceRange: true,
179
+ targetAudience: true,
180
+ serviceLinks: {
181
+ include: SERVICE_LINK_DATA_TO_INCLUDE
182
+ },
183
+ venues: {
184
+ include: VENUE_DATA_TO_INCLUDE
185
+ }
186
+ }
187
+
188
+ export interface InvitationExt extends Invitation {
189
+ creator: PublicUser;
190
+ sentTo: PublicUser;
191
+ tickets: Ticket[];
192
+ associatedBash?: AssociatedBash | null;
193
+ }
194
+
195
+ export const INVITATION_DATA_TO_INCLUDE = {
196
+ creator: {
197
+ select: FRONT_END_USER_DATA_TO_SELECT
198
+ },
199
+ sentTo: {
200
+ select: FRONT_END_USER_DATA_TO_SELECT
201
+ },
202
+ tickets: true,
203
+ }
204
+
205
+ export interface InvitationExtraData extends Invitation {
206
+ isFreeGuest?: boolean;
207
+ isOrganizer?: boolean;
208
+ }
209
+
210
+ export interface AssociatedBashExt extends AssociatedBash {
211
+ bashEvent: BashEventExt;
212
+ invitation: InvitationExt;
213
+ }
214
+
215
+ export const ASSOCIATED_BASH_DATA_TO_INCLUDE = {
216
+ bashEvent: {
217
+ include: BASH_EVENT_DATA_TO_INCLUDE
218
+ },
219
+ invitation: {
220
+ include: INVITATION_DATA_TO_INCLUDE
221
+ }
222
+ }
223
+
224
+ export interface TicketTierExt extends TicketTier {
225
+ bashEvent: BashEvent;
226
+ tickets: TicketExt[];
227
+ promoCodes: BashEventPromoCode[];
228
+ }
229
+
230
+ export interface TicketExt extends Ticket {
231
+ owner: PublicUser;
232
+ forUser: PublicUser;
233
+ checkout?: Checkout;
234
+ }
235
+
236
+ export interface CheckoutExt extends Checkout {
237
+ owner: PublicUser;
238
+ tickets: Ticket[]
239
+ }
240
+
241
+ export const CHECKOUT_DATA_TO_INCLUDE = {
242
+ owner: {
243
+ select: FRONT_END_USER_DATA_TO_SELECT
244
+ },
245
+ tickets: {
246
+ select: {
247
+ ownerId: true
248
+ }
249
+ }
250
+ }
251
+
252
+ export interface ReviewExt extends Review {
253
+ comments: BashComment[];
254
+ }
255
+
256
+ export const CONTACT_DATA_TO_INCLUDE = {
257
+ user: {
258
+ select: FRONT_END_USER_DATA_TO_SELECT
259
+ },
260
+ media: true
261
+ };
262
+
263
+
264
+ export interface UserExtraData extends User {
265
+ password?: string;
266
+ otp?: string;
267
+ }
268
+
269
+ export interface UserExt extends User {
270
+ services?: Service[] | null;
271
+
272
+ // Do not include in fetch as there could be thousands of these
273
+ associatedBashes?: AssociatedBash[] | null;
274
+ reviews?: ReviewExt[] | null;
275
+ contacts?: Contact[] | null;
276
+ ticketsIOwn?: TicketExt[] | null;
277
+ }
278
+
279
+ export const USER_DATA_SELECT_REVIEWS_COMMENTS = {
280
+ reviews: {
281
+ include: {
282
+ comments: true
283
+ }
284
+ }
285
+ }
286
+
287
+
288
+ export type PublicUser = Pick<UserExt, keyof typeof FRONT_END_USER_DATA_TO_SELECT>
289
+ & Partial<Pick<UserExt, keyof typeof USER_DATA_SELECT_REVIEWS_COMMENTS>>;
package/src/index.ts CHANGED
@@ -1,13 +1,13 @@
1
- export * from "./extendedSchemas";
2
- export * from "./definitions";
3
- export * from "./utils/ticketListUtils";
4
- export * from "./utils/dateTimeUtils";
5
- export * from "./utils/recurrenceUtils";
6
- export * from "./utils/addressUtils";
7
- export * from "./utils/paymentUtils";
8
- export * from "./utils/awsS3Utils";
9
- export * from "./utils/qrCodeUtils";
10
- export * from "./utils/sortUtils";
11
- export * from "./utils/apiUtils";
12
- export * from "./utils/urlUtils";
13
- export * from "./utils/promoCodesUtils";
1
+ export * from "./extendedSchemas";
2
+ export * from "./definitions";
3
+ export * from "./utils/ticketListUtils";
4
+ export * from "./utils/dateTimeUtils";
5
+ export * from "./utils/recurrenceUtils";
6
+ export * from "./utils/addressUtils";
7
+ export * from "./utils/paymentUtils";
8
+ export * from "./utils/awsS3Utils";
9
+ export * from "./utils/qrCodeUtils";
10
+ export * from "./utils/sortUtils";
11
+ export * from "./utils/apiUtils";
12
+ export * from "./utils/urlUtils";
13
+ export * from "./utils/promoCodesUtils";