@bash-app/bash-common 3.4.0 → 4.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.
@@ -1,167 +1,170 @@
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
-
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 ServiceExt extends Service {
70
- owner: User;
71
- media: Media[];
72
- crowdSize: ServiceRange;
73
- serviceRange: ServiceRange;
74
- }
75
-
76
- export const SERVICE_DATA_TO_INCLUDE = {
77
- owner: true,
78
- media: true,
79
- crowdSize: true,
80
- serviceRange: true,
81
- }
82
-
83
- export interface InvitationExt extends Invitation {
84
- creator: User;
85
- sentTo: User;
86
- tickets: Ticket[];
87
- }
88
-
89
- export const INVITATION_DATA_TO_INCLUDE = {
90
- creator: true,
91
- sentTo: true,
92
- tickets: true
93
- }
94
-
95
- export interface InvitationExtraData extends Invitation {
96
- isFreeGuest?: boolean;
97
- isOrganizer?: boolean;
98
- }
99
-
100
- export interface AssociatedBashExt extends AssociatedBash {
101
- bashEvent: BashEventExt;
102
- invitation: InvitationExt;
103
- }
104
-
105
-
106
- export const ASSOCIATED_BASH_DATA_TO_INCLUDE = {
107
- bashEvent: {
108
- include: BASH_EVENT_DATA_TO_INCLUDE
109
- },
110
- invitation: {
111
- include: INVITATION_DATA_TO_INCLUDE
112
- }
113
- }
114
-
115
- export interface TicketTierExt extends TicketTier {
116
- bashEvent: BashEvent;
117
- tickets: TicketExt[];
118
- }
119
-
120
- export interface TicketExt extends Ticket {
121
- owner: User;
122
- forUser: User;
123
- }
124
-
125
- export interface ReviewExt extends Review {
126
- comments: BashComment[];
127
- }
128
-
129
- export interface UserExtraData extends User {
130
- password: string;
131
- }
132
-
133
- export interface UserExt extends User {
134
- services: Service[];
135
-
136
- // Do not include in fetch as there could be thousands of these
137
- associatedBashes?: AssociatedBash[]
138
- reviews?: ReviewExt[];
139
- contacts?: Contact[];
140
- }
141
-
142
- export const USER_DATA_TO_INCLUDE = {
143
- services: true,
144
- }
145
-
146
- export const USER_DATA_SELECT_REVIEWS_COMMENTS = {
147
- reviews: {
148
- include: {
149
- comments: true
150
- }
151
- }
152
- }
153
-
154
- export const PUBLIC_USER_DATA_TO_SELECT = {
155
- id: true,
156
- email: true,
157
- givenName: true,
158
- familyName: true,
159
- fullName: true,
160
- username: true,
161
- image: true,
162
- uploadedImage: true,
163
- services: true,
164
- }
165
-
166
- export type Public_User = Pick<UserExt, keyof typeof PUBLIC_USER_DATA_TO_SELECT>
167
- & 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
+ targetAudience: TargetAudience;
86
+ }
87
+
88
+ export const SERVICE_DATA_TO_INCLUDE = {
89
+ owner: {
90
+ select: FRONT_END_USER_DATA_TO_SELECT
91
+ },
92
+ media: true,
93
+ crowdSize: true,
94
+ serviceRange: true,
95
+ }
96
+
97
+ export interface InvitationExt extends Invitation {
98
+ creator: User;
99
+ sentTo: User;
100
+ tickets: Ticket[];
101
+ }
102
+
103
+ export const INVITATION_DATA_TO_INCLUDE = {
104
+ creator: true,
105
+ sentTo: true,
106
+ tickets: true
107
+ }
108
+
109
+ export interface InvitationExtraData extends Invitation {
110
+ isFreeGuest?: boolean;
111
+ isOrganizer?: boolean;
112
+ }
113
+
114
+ export interface AssociatedBashExt extends AssociatedBash {
115
+ bashEvent: BashEventExt;
116
+ invitation: InvitationExt;
117
+ }
118
+
119
+
120
+ export const ASSOCIATED_BASH_DATA_TO_INCLUDE = {
121
+ bashEvent: {
122
+ include: BASH_EVENT_DATA_TO_INCLUDE
123
+ },
124
+ invitation: {
125
+ include: INVITATION_DATA_TO_INCLUDE
126
+ }
127
+ }
128
+
129
+ export interface TicketTierExt extends TicketTier {
130
+ bashEvent: BashEvent;
131
+ tickets: TicketExt[];
132
+ }
133
+
134
+ export interface TicketExt extends Ticket {
135
+ owner: User;
136
+ forUser: User;
137
+ }
138
+
139
+ export interface ReviewExt extends Review {
140
+ comments: BashComment[];
141
+ }
142
+
143
+ export interface UserExtraData extends User {
144
+ password: string;
145
+ }
146
+
147
+ export interface UserExt extends User {
148
+ services: Service[];
149
+
150
+ // Do not include in fetch as there could be thousands of these
151
+ associatedBashes?: AssociatedBash[]
152
+ reviews?: ReviewExt[];
153
+ contacts?: Contact[];
154
+ }
155
+
156
+ export const USER_DATA_TO_INCLUDE = {
157
+ services: true,
158
+ }
159
+
160
+ export const USER_DATA_SELECT_REVIEWS_COMMENTS = {
161
+ reviews: {
162
+ include: {
163
+ comments: true
164
+ }
165
+ }
166
+ }
167
+
168
+
169
+ export type Public_User = Pick<UserExt, keyof typeof FRONT_END_USER_DATA_TO_SELECT>
170
+ & 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";