@bash-app/bash-common 10.4.0 → 10.5.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.
@@ -1,245 +1,233 @@
1
- import {
2
- AmountOfGuests,
3
- EventTask,
4
- AssociatedBash,
5
- BashEvent,
6
- Invitation,
7
- TargetAudience,
8
- Ticket,
9
- User,
10
- TicketTier, Service, Review, Media, BashComment, Recurrence, Contact,
11
- BashNotification, BashEventPromoCode,
12
- Reminder, ServiceRange,
13
- ServiceTargetAudience,
14
- Checkout,
15
- ServiceLink,
16
- Link,
17
- } from "@prisma/client";
18
-
19
- export const FRONT_END_USER_DATA_TO_SELECT = {
20
- id: true,
21
- email: true,
22
- givenName: true,
23
- familyName: true,
24
- fullName: true,
25
- username: 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?: User;
46
- ticketTiers: TicketTierExt[];
47
- media: Media[];
48
- eventTasks: EventTask[];
49
- promoCodes?: BashEventPromoCode[];
50
- tickets?: Ticket[]; // Only include tickets that the user has purchased and not all tickets (could be thousands + privacy)
51
- // Do not include in fetch. Could be hundreds of these
52
- invitations: InvitationExt[];
53
- youtubeUrl?: string;
54
- }
55
-
56
- export const BASH_EVENT_DATA_TO_INCLUDE = {
57
- targetAudience: true,
58
- amountOfGuests: true,
59
- recurrence: true,
60
- ticketTiers: true,
61
- eventTasks: true,
62
- media: true,
63
- promoCodes: true,
64
- }
65
-
66
- export const BASH_EVENT_DATA_TO_SELECT = {
67
- creator: {
68
- select: FRONT_END_USER_DATA_TO_SELECT
69
- }
70
- }
71
-
72
- export const BASH_EVENT_DATA_TO_CLONE = [
73
- 'targetAudience',
74
- 'amountOfGuests',
75
- 'ticketTiers',
76
- 'media',
77
- 'recurrence',
78
- 'invitations',
79
- 'promoCodes',
80
- ] as const;
81
-
82
- export interface BashNotificationExt extends BashNotification {
83
- creator?: User;
84
- bashEvent?: BashEvent;
85
- eventTask?: EventTask;
86
- invitation?: Invitation;
87
- reminders?: Reminder[];
88
- }
89
-
90
- export const BASH_NOTIFICATION_DATA_TO_INCLUDE = {
91
- bashEvent: {
92
- select: {
93
- coverPhoto: true,
94
- },
95
- },
96
- creator: {
97
- select: {
98
- image: true,
99
- },
100
- },
101
-
102
- }
103
-
104
- type RemoveCommonProperties<T, U> = keyof (Omit<T, keyof U> & Omit<U, keyof T>);
105
- type UnionFromArray<T extends ReadonlyArray<any>> = T[number];
106
- type BashEventExtMinusDataToCloneType = Omit<BashEventExt, UnionFromArray<typeof BASH_EVENT_DATA_TO_CLONE>>;
107
-
108
- export const BASH_EVENT_DATA_TO_REMOVE: RemoveCommonProperties<BashEvent, BashEventExtMinusDataToCloneType>[] = [
109
- 'creator',
110
- 'eventTasks',
111
- 'tickets'
112
- ];
113
-
114
- export interface ServiceExt extends Service {
115
- owner: User;
116
- media: Media[];
117
- crowdSize: ServiceRange;
118
- serviceRange: ServiceRange;
119
- targetAudience: ServiceTargetAudience;
120
- serviceLinks?: ServiceLinkExt[];
121
- }
122
-
123
- export interface ServiceLinkExt extends ServiceLink {
124
- link: Link;
125
- }
126
-
127
- export const SERVICE_LINK_DATA_TO_INCLUDE = {
128
- link: true,
129
- }
130
-
131
- export const SERVICE_DATA_TO_INCLUDE = {
132
- owner: {
133
- select: FRONT_END_USER_DATA_TO_SELECT
134
- },
135
- media: true,
136
- crowdSize: true,
137
- serviceRange: true,
138
- serviceLinks: {
139
- include: SERVICE_LINK_DATA_TO_INCLUDE
140
- }
141
- }
142
-
143
- export interface InvitationExt extends Invitation {
144
- creator: User;
145
- sentTo: User;
146
- tickets: Ticket[];
147
- associatedBash?: AssociatedBash | null;
148
- }
149
-
150
- export const INVITATION_DATA_TO_INCLUDE = {
151
- creator: true,
152
- sentTo: true,
153
- tickets: true,
154
- }
155
-
156
- export interface InvitationExtraData extends Invitation {
157
- isFreeGuest?: boolean;
158
- isOrganizer?: boolean;
159
- }
160
-
161
- export interface AssociatedBashExt extends AssociatedBash {
162
- bashEvent: BashEventExt;
163
- invitation: InvitationExt;
164
- }
165
-
166
-
167
- export const ASSOCIATED_BASH_DATA_TO_INCLUDE = {
168
- bashEvent: {
169
- include: BASH_EVENT_DATA_TO_INCLUDE
170
- },
171
- invitation: {
172
- include: INVITATION_DATA_TO_INCLUDE
173
- }
174
- }
175
-
176
- export interface TicketTierExt extends TicketTier {
177
- bashEvent: BashEvent;
178
- tickets: TicketExt[];
179
- }
180
-
181
- export interface TicketExt extends Ticket {
182
- owner: User;
183
- forUser: User;
184
- checkout?: Checkout;
185
- }
186
-
187
- export interface CheckoutExt extends Checkout {
188
- owner: User;
189
- tickets: Ticket[]
190
- }
191
-
192
- export const CHECKOUT_DATA_TO_INCLUDE = {
193
- owner: {
194
- select: FRONT_END_USER_DATA_TO_SELECT
195
- },
196
- tickets: {
197
- select: {
198
- ownerId: true
199
- }
200
- }
201
- }
202
-
203
- export interface ReviewExt extends Review {
204
- comments: BashComment[];
205
- }
206
-
207
- export interface ContactExt extends Contact {
208
- user: User;
209
- media: Media[];
210
- }
211
-
212
- export const CONTACT_DATA_TO_INCLUDE = {
213
- user: {
214
- select: FRONT_END_USER_DATA_TO_SELECT
215
- },
216
- media: true
217
- };
218
-
219
-
220
- export interface UserExtraData extends User {
221
- password?: string;
222
- otp?: string;
223
- }
224
-
225
- export interface UserExt extends User {
226
- services?: Service[];
227
-
228
- // Do not include in fetch as there could be thousands of these
229
- associatedBashes?: AssociatedBash[]
230
- reviews?: ReviewExt[];
231
- contacts?: Contact[];
232
- ticketsIOwn?: TicketExt[];
233
- }
234
-
235
- export const USER_DATA_SELECT_REVIEWS_COMMENTS = {
236
- reviews: {
237
- include: {
238
- comments: true
239
- }
240
- }
241
- }
242
-
243
-
244
- export type Public_User = Pick<UserExt, keyof typeof FRONT_END_USER_DATA_TO_SELECT>
245
- & Partial<Pick<UserExt, keyof typeof USER_DATA_SELECT_REVIEWS_COMMENTS>>;
1
+ import {
2
+ AmountOfGuests,
3
+ EventTask,
4
+ AssociatedBash,
5
+ BashEvent,
6
+ Invitation,
7
+ TargetAudience,
8
+ Ticket,
9
+ User,
10
+ TicketTier, Service, Review, Media, BashComment, Recurrence, Contact,
11
+ BashNotification, BashEventPromoCode,
12
+ Reminder, ServiceRange,
13
+ ServiceTargetAudience,
14
+ Checkout,
15
+ ServiceLink,
16
+ Link
17
+ } from "@prisma/client";
18
+
19
+ export const FRONT_END_USER_DATA_TO_SELECT = {
20
+ id: true,
21
+ email: true,
22
+ givenName: true,
23
+ familyName: true,
24
+ fullName: true,
25
+ username: 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?: User;
46
+ ticketTiers: TicketTierExt[];
47
+ media: Media[];
48
+ eventTasks: EventTask[];
49
+ promoCodes?: BashEventPromoCode[];
50
+ tickets?: Ticket[]; // Only include tickets that the user has purchased and not all tickets (could be thousands + privacy)
51
+ // Do not include in fetch. Could be hundreds of these
52
+ invitations: InvitationExt[];
53
+ youtubeUrl?: string;
54
+ }
55
+
56
+ export const BASH_EVENT_DATA_TO_SELECT = {
57
+ creator: {
58
+ select: FRONT_END_USER_DATA_TO_SELECT
59
+ }
60
+ }
61
+
62
+ export const BASH_EVENT_DATA_TO_INCLUDE = {
63
+ targetAudience: true,
64
+ amountOfGuests: true,
65
+ recurrence: true,
66
+ ticketTiers: true,
67
+ eventTasks: true,
68
+ media: true,
69
+ promoCodes: true,
70
+ ...BASH_EVENT_DATA_TO_SELECT,
71
+ }
72
+
73
+ export const BASH_EVENT_DATA_TO_CLONE = [
74
+ 'targetAudience',
75
+ 'amountOfGuests',
76
+ 'ticketTiers',
77
+ 'media',
78
+ 'recurrence',
79
+ 'invitations',
80
+ 'promoCodes',
81
+ ] as const;
82
+
83
+ export interface BashNotificationExt extends BashNotification {
84
+ creator?: User;
85
+ bashEvent?: BashEvent;
86
+ eventTask?: EventTask;
87
+ invitation?: Invitation;
88
+ reminders?: Reminder[];
89
+ }
90
+
91
+ export const BASH_NOTIFICATION_DATA_TO_INCLUDE = {
92
+ bashEvent: {
93
+ select: {
94
+ coverPhoto: true,
95
+ },
96
+ },
97
+ creator: {
98
+ select: {
99
+ image: true,
100
+ },
101
+ },
102
+
103
+ }
104
+
105
+ type RemoveCommonProperties<T, U> = keyof (Omit<T, keyof U> & Omit<U, keyof T>);
106
+ type UnionFromArray<T extends ReadonlyArray<any>> = T[number];
107
+ type BashEventExtMinusDataToCloneType = Omit<BashEventExt, UnionFromArray<typeof BASH_EVENT_DATA_TO_CLONE>>;
108
+
109
+ export const BASH_EVENT_DATA_TO_REMOVE: RemoveCommonProperties<BashEvent, BashEventExtMinusDataToCloneType>[] = [
110
+ 'creator',
111
+ 'eventTasks',
112
+ 'tickets'
113
+ ];
114
+
115
+ export interface ServiceExt extends Service {
116
+ owner: User;
117
+ media: Media[];
118
+ crowdSize: ServiceRange;
119
+ serviceRange: ServiceRange;
120
+ targetAudience: ServiceTargetAudience;
121
+ serviceLinks?: ServiceLinkExt[];
122
+ }
123
+
124
+ export interface ServiceLinkExt extends ServiceLink {
125
+ link: Link;
126
+ }
127
+
128
+ export const SERVICE_LINK_DATA_TO_INCLUDE = {
129
+ link: true,
130
+ }
131
+
132
+ export const SERVICE_DATA_TO_INCLUDE = {
133
+ owner: {
134
+ select: FRONT_END_USER_DATA_TO_SELECT
135
+ },
136
+ media: true,
137
+ crowdSize: true,
138
+ serviceRange: true,
139
+ serviceLinks: {
140
+ include: SERVICE_LINK_DATA_TO_INCLUDE
141
+ }
142
+ }
143
+
144
+ export interface InvitationExt extends Invitation {
145
+ creator: User;
146
+ sentTo: User;
147
+ tickets: Ticket[];
148
+ associatedBash?: AssociatedBash | null;
149
+ }
150
+
151
+ export const INVITATION_DATA_TO_INCLUDE = {
152
+ creator: true,
153
+ sentTo: true,
154
+ tickets: true,
155
+ }
156
+
157
+ export interface InvitationExtraData extends Invitation {
158
+ isFreeGuest?: boolean;
159
+ isOrganizer?: boolean;
160
+ }
161
+
162
+ export interface AssociatedBashExt extends AssociatedBash {
163
+ bashEvent: BashEventExt;
164
+ invitation: InvitationExt;
165
+ }
166
+
167
+
168
+ export const ASSOCIATED_BASH_DATA_TO_INCLUDE = {
169
+ bashEvent: {
170
+ include: BASH_EVENT_DATA_TO_INCLUDE
171
+ },
172
+ invitation: {
173
+ include: INVITATION_DATA_TO_INCLUDE
174
+ }
175
+ }
176
+
177
+ export interface TicketTierExt extends TicketTier {
178
+ bashEvent: BashEvent;
179
+ tickets: TicketExt[];
180
+ }
181
+
182
+ export interface TicketExt extends Ticket {
183
+ owner: User;
184
+ forUser: User;
185
+ checkout?: Checkout;
186
+ }
187
+
188
+ export interface CheckoutExt extends Checkout {
189
+ owner: User;
190
+ tickets: Ticket[]
191
+ }
192
+
193
+ export const CHECKOUT_DATA_TO_INCLUDE = {
194
+ owner: {
195
+ select: FRONT_END_USER_DATA_TO_SELECT
196
+ },
197
+ tickets: {
198
+ select: {
199
+ ownerId: true
200
+ }
201
+ }
202
+ }
203
+
204
+ export interface ReviewExt extends Review {
205
+ comments: BashComment[];
206
+ }
207
+
208
+ export interface UserExtraData extends User {
209
+ password?: string;
210
+ otp?: string;
211
+ }
212
+
213
+ export interface UserExt extends User {
214
+ services?: Service[];
215
+
216
+ // Do not include in fetch as there could be thousands of these
217
+ associatedBashes?: AssociatedBash[]
218
+ reviews?: ReviewExt[];
219
+ contacts?: Contact[];
220
+ ticketsIOwn?: TicketExt[];
221
+ }
222
+
223
+ export const USER_DATA_SELECT_REVIEWS_COMMENTS = {
224
+ reviews: {
225
+ include: {
226
+ comments: true
227
+ }
228
+ }
229
+ }
230
+
231
+
232
+ export type Public_User = Pick<UserExt, keyof typeof FRONT_END_USER_DATA_TO_SELECT>
233
+ & Partial<Pick<UserExt, keyof typeof USER_DATA_SELECT_REVIEWS_COMMENTS>>;
package/src/index.ts CHANGED
@@ -1,10 +1,10 @@
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";
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";