@bash-app/bash-common 3.3.0 → 4.0.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,153 +1,169 @@
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
13
- } from "@prisma/client";
14
-
15
-
16
- export interface BashEventExt extends BashEvent {
17
- targetAudience?: TargetAudience;
18
- amountOfGuests?: AmountOfGuests;
19
- recurrence?: Recurrence;
20
- creator?: User;
21
- ticketTiers: TicketTierExt[];
22
- media: Media[];
23
- eventTasks: EventTask[];
24
- promoCodes?: BashEventPromoCode[];
25
- tickets?: Ticket[]; // Only include tickets that the user has purchased and not all tickets (could be thousands + privacy)
26
- // Do not include in fetch. Could be hundreds of these
27
- invitations: InvitationExt[];
28
- }
29
-
30
- export interface BashNotificationsExt extends BashNotification {
31
- creator?: User;
32
- bashEvent?: BashEvent;
33
- eventTask?: EventTask;
34
- invitation?: Invitation;
35
- reminders?: Reminder[];
36
- }
37
-
38
- export const BASH_EVENT_DATA_TO_INCLUDE = {
39
- targetAudience: true,
40
- amountOfGuests: true,
41
- recurrence: true,
42
- ticketTiers: true,
43
- creator: true,
44
- eventTasks: true,
45
- media: true,
46
- promoCodes: true,
47
- }
48
-
49
- export const BASH_EVENT_DATA_TO_CLONE = [
50
- 'targetAudience',
51
- 'amountOfGuests',
52
- 'ticketTiers',
53
- 'media',
54
- 'recurrence',
55
- 'invitations',
56
- 'promoCodes',
57
- ] as const;
58
-
59
- type RemoveCommonProperties<T, U> = keyof (Omit<T, keyof U> & Omit<U, keyof T>);
60
- type UnionFromArray<T extends ReadonlyArray<any>> = T[number];
61
- type BashEventExtMinusDataToCloneType = Omit<BashEventExt, UnionFromArray<typeof BASH_EVENT_DATA_TO_CLONE>>;
62
-
63
- export const BASH_EVENT_DATA_TO_REMOVE: RemoveCommonProperties<BashEvent, BashEventExtMinusDataToCloneType>[] = [
64
- 'creator',
65
- 'eventTasks',
66
- 'tickets'
67
- ];
68
-
69
- export interface InvitationExt extends Invitation {
70
- creator: User;
71
- sentTo: User;
72
- tickets: Ticket[];
73
- }
74
-
75
- export const INVITATION_DATA_TO_INCLUDE = {
76
- creator: true,
77
- sentTo: true,
78
- tickets: true
79
- }
80
-
81
- export interface InvitationExtraData extends Invitation {
82
- isFreeGuest?: boolean;
83
- isOrganizer?: boolean;
84
- }
85
-
86
- export interface AssociatedBashExt extends AssociatedBash {
87
- bashEvent: BashEventExt;
88
- invitation: InvitationExt;
89
- }
90
-
91
-
92
- export const ASSOCIATED_BASH_DATA_TO_INCLUDE = {
93
- bashEvent: {
94
- include: BASH_EVENT_DATA_TO_INCLUDE
95
- },
96
- invitation: {
97
- include: INVITATION_DATA_TO_INCLUDE
98
- }
99
- }
100
-
101
- export interface TicketTierExt extends TicketTier {
102
- bashEvent: BashEvent;
103
- tickets: TicketExt[];
104
- }
105
-
106
- export interface TicketExt extends Ticket {
107
- owner: User;
108
- forUser: User;
109
- }
110
-
111
- export interface ReviewExt extends Review {
112
- comments: BashComment[];
113
- }
114
-
115
- export interface UserExtraData extends User {
116
- password: string;
117
- }
118
-
119
- export interface UserExt extends User {
120
- services: Service[];
121
-
122
- // Do not include in fetch as there could be thousands of these
123
- associatedBashes?: AssociatedBash[]
124
- reviews?: ReviewExt[];
125
- contacts?: Contact[];
126
- }
127
-
128
- export const USER_DATA_TO_INCLUDE = {
129
- services: true,
130
- }
131
-
132
- export const USER_DATA_SELECT_REVIEWS_COMMENTS = {
133
- reviews: {
134
- include: {
135
- comments: true
136
- }
137
- }
138
- }
139
-
140
- export const PUBLIC_USER_DATA_TO_SELECT = {
141
- id: true,
142
- email: true,
143
- givenName: true,
144
- familyName: true,
145
- fullName: true,
146
- username: true,
147
- image: true,
148
- uploadedImage: true,
149
- services: true,
150
- }
151
-
152
- export type Public_User = Pick<UserExt, keyof typeof PUBLIC_USER_DATA_TO_SELECT>
153
- & 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
+ } from "@prisma/client";
14
+
15
+ export const FRONT_END_USER_DATA_TO_SELECT = {
16
+ id: true,
17
+ email: true,
18
+ givenName: true,
19
+ familyName: true,
20
+ fullName: true,
21
+ username: true,
22
+ image: true,
23
+ uploadedImage: true,
24
+ services: true,
25
+ }
26
+
27
+ export interface BashEventExt extends BashEvent {
28
+ targetAudience?: TargetAudience;
29
+ amountOfGuests?: AmountOfGuests;
30
+ recurrence?: Recurrence;
31
+ creator?: User;
32
+ ticketTiers: TicketTierExt[];
33
+ media: Media[];
34
+ eventTasks: EventTask[];
35
+ promoCodes?: BashEventPromoCode[];
36
+ tickets?: Ticket[]; // Only include tickets that the user has purchased and not all tickets (could be thousands + privacy)
37
+ // Do not include in fetch. Could be hundreds of these
38
+ invitations: InvitationExt[];
39
+ }
40
+
41
+ export interface BashNotificationsExt extends BashNotification {
42
+ creator?: User;
43
+ bashEvent?: BashEvent;
44
+ eventTask?: EventTask;
45
+ invitation?: Invitation;
46
+ reminders?: Reminder[];
47
+ }
48
+
49
+ export const BASH_EVENT_DATA_TO_INCLUDE = {
50
+ targetAudience: true,
51
+ amountOfGuests: true,
52
+ recurrence: true,
53
+ ticketTiers: true,
54
+ creator: true,
55
+ eventTasks: true,
56
+ media: true,
57
+ promoCodes: true,
58
+ }
59
+
60
+ export const BASH_EVENT_DATA_TO_CLONE = [
61
+ 'targetAudience',
62
+ 'amountOfGuests',
63
+ 'ticketTiers',
64
+ 'media',
65
+ 'recurrence',
66
+ 'invitations',
67
+ 'promoCodes',
68
+ ] as const;
69
+
70
+ type RemoveCommonProperties<T, U> = keyof (Omit<T, keyof U> & Omit<U, keyof T>);
71
+ type UnionFromArray<T extends ReadonlyArray<any>> = T[number];
72
+ type BashEventExtMinusDataToCloneType = Omit<BashEventExt, UnionFromArray<typeof BASH_EVENT_DATA_TO_CLONE>>;
73
+
74
+ export const BASH_EVENT_DATA_TO_REMOVE: RemoveCommonProperties<BashEvent, BashEventExtMinusDataToCloneType>[] = [
75
+ 'creator',
76
+ 'eventTasks',
77
+ 'tickets'
78
+ ];
79
+
80
+ export interface ServiceExt extends Service {
81
+ owner: User;
82
+ media: Media[];
83
+ crowdSize: ServiceRange;
84
+ serviceRange: ServiceRange;
85
+ }
86
+
87
+ export const SERVICE_DATA_TO_INCLUDE = {
88
+ owner: {
89
+ select: FRONT_END_USER_DATA_TO_SELECT
90
+ },
91
+ media: true,
92
+ crowdSize: true,
93
+ serviceRange: true,
94
+ }
95
+
96
+ export interface InvitationExt extends Invitation {
97
+ creator: User;
98
+ sentTo: User;
99
+ tickets: Ticket[];
100
+ }
101
+
102
+ export const INVITATION_DATA_TO_INCLUDE = {
103
+ creator: true,
104
+ sentTo: true,
105
+ tickets: true
106
+ }
107
+
108
+ export interface InvitationExtraData extends Invitation {
109
+ isFreeGuest?: boolean;
110
+ isOrganizer?: boolean;
111
+ }
112
+
113
+ export interface AssociatedBashExt extends AssociatedBash {
114
+ bashEvent: BashEventExt;
115
+ invitation: InvitationExt;
116
+ }
117
+
118
+
119
+ export const ASSOCIATED_BASH_DATA_TO_INCLUDE = {
120
+ bashEvent: {
121
+ include: BASH_EVENT_DATA_TO_INCLUDE
122
+ },
123
+ invitation: {
124
+ include: INVITATION_DATA_TO_INCLUDE
125
+ }
126
+ }
127
+
128
+ export interface TicketTierExt extends TicketTier {
129
+ bashEvent: BashEvent;
130
+ tickets: TicketExt[];
131
+ }
132
+
133
+ export interface TicketExt extends Ticket {
134
+ owner: User;
135
+ forUser: User;
136
+ }
137
+
138
+ export interface ReviewExt extends Review {
139
+ comments: BashComment[];
140
+ }
141
+
142
+ export interface UserExtraData extends User {
143
+ password: string;
144
+ }
145
+
146
+ export interface UserExt extends User {
147
+ services: Service[];
148
+
149
+ // Do not include in fetch as there could be thousands of these
150
+ associatedBashes?: AssociatedBash[]
151
+ reviews?: ReviewExt[];
152
+ contacts?: Contact[];
153
+ }
154
+
155
+ export const USER_DATA_TO_INCLUDE = {
156
+ services: true,
157
+ }
158
+
159
+ export const USER_DATA_SELECT_REVIEWS_COMMENTS = {
160
+ reviews: {
161
+ include: {
162
+ comments: true
163
+ }
164
+ }
165
+ }
166
+
167
+
168
+ export type Public_User = Pick<UserExt, keyof typeof FRONT_END_USER_DATA_TO_SELECT>
169
+ & Partial<Pick<UserExt, keyof typeof USER_DATA_SELECT_REVIEWS_COMMENTS>>;
package/src/index.ts CHANGED
@@ -1,9 +1,9 @@
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";
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";