@bash-app/bash-common 1.0.7 → 1.0.8

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 CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
2
  "name": "@bash-app/bash-common",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Common data and scripts to use on the frontend and backend",
5
5
  "type": "module",
6
- "main": "./dist/index.js",
7
- "module": "./dist/index.esm.js",
8
- "typings": "./dist/index.d.ts",
6
+ "main": "src/index.ts",
9
7
  "scripts": {
10
- "build": "rollup -c",
8
+ "installSelf": "tsx scripts/installSelfInMainProject.ts",
9
+ "build": "npm run generate && npm run tsc",
11
10
  "generate": "prisma generate",
12
11
  "tsc": "tsc",
13
- "prepublishOnly": "npm run tsc"
12
+ "prepublishOnly": "npm run build"
14
13
  },
15
14
  "repository": {
16
15
  "type": "git",
@@ -22,19 +21,18 @@
22
21
  "ts-node": "^10.9.1",
23
22
  "typescript": "^5.2.2"
24
23
  },
24
+ "peerDependencies": {
25
+ "tsx": "^4.10.3"
26
+ },
25
27
  "devDependencies": {
26
28
  "@prisma/client": "^5.13.0",
27
- "@rollup/plugin-node-resolve": "^15.2.3",
28
- "@rollup/plugin-typescript": "^11.1.6",
29
29
  "@types/jest": "^29.5.5",
30
30
  "@types/node": "^20.8.4",
31
31
  "@types/react": "^18.3.2",
32
+ "@types/shelljs": "^0.8.15",
32
33
  "jest": "^29.7.0",
33
34
  "prisma": "^5.13.0",
34
- "rollup": "^4.17.2",
35
- "rollup-plugin-dts": "^6.1.0",
36
- "rollup-plugin-esbuild": "^6.1.1",
37
- "shx": "^0.3.4",
35
+ "shelljs": "^0.8.5",
38
36
  "ts-jest": "^29.1.1",
39
37
  "tslib": "^2.6.2"
40
38
  }
@@ -0,0 +1,23 @@
1
+ import shell from 'shelljs';
2
+
3
+ const BASH_COMMON_DIR = 'bash-common';
4
+ const BASH_APP_PATH = '../node_modules/@bash-app/'; // Need to get to the main project folder
5
+ const BASH_COMMON_PATH = `${BASH_APP_PATH}${BASH_COMMON_DIR}`;
6
+
7
+ shell.echo('', `Current working dir: ${shell.pwd()}`);
8
+ shell.echo('', `Deleting bash-common folder: ${BASH_COMMON_PATH}`);
9
+
10
+ shell.rm('-rf', BASH_COMMON_PATH);
11
+ shell.mkdir('-p', BASH_COMMON_PATH);
12
+
13
+ shell.echo('', `Copying bash-common folder: ${BASH_COMMON_PATH}`);
14
+ shell.cp('-rf', `../${BASH_COMMON_DIR}`,`${BASH_APP_PATH}`);
15
+
16
+ shell.echo('', `Running npm commands in bash-common folder: ${BASH_COMMON_PATH}`);
17
+ shell.exec(`npm --prefix ${BASH_COMMON_PATH} install`);
18
+ shell.exec(`npm --prefix ${BASH_COMMON_PATH} run build`);
19
+
20
+ shell.echo('', `Copying prisma folder from bash-common folder: ${BASH_COMMON_PATH}`);
21
+ shell.cp('-rf', `${BASH_COMMON_PATH}/prisma`, '../'); // Need to get to the main project folder
22
+
23
+ shell.echo('', 'Done setting up bash-common!');
@@ -0,0 +1,371 @@
1
+ import {BashEventDressTags, BashEventType, BashEventVibeTags, DayOfWeek, TicketTier, User} from "@prisma/client";
2
+
3
+ export const GOOGLE_CALLBACK_URL = '/auth/google/callback' as const;
4
+ export const CHECKOUT_RETURN_SUCCESS_URL = `/checkout-return/success/{CHECKOUT_SESSION_ID}` as const;
5
+ export const CHECKOUT_RETURN_CANCEL_URL = `/checkout-return/cancel/{CHECKOUT_SESSION_ID}` as const;
6
+ export const CHECKOUT_RETURN_SUCCESS_URL_PAGE = '/checkout-return/success/$checkoutSessionId' as const;
7
+ export const CHECKOUT_RETURN_CANCEL_URL_PAGE = '/checkout-return/cancel/$checkoutSessionId' as const;
8
+ export const VERIFICATION_RETURN_URL = `/sign-up` as const;
9
+
10
+ export const SWR_KEY_AUTH_TOKEN = "auth-token" as const;
11
+
12
+ export const PRICE_DOLLARS_AND_CENTS_RATIO = 100 as const;
13
+
14
+ export const MIN_AMOUNT_OF_TICKETS_FOR_PUBLIC_EVENT_TO_SHOW = 0 as const;
15
+ export const DEFAULT_MAX_NUMBER_OF_TICKETS = 35 as const
16
+ export const MIN_NUMBER_OF_TICKETS = 0 as const;
17
+
18
+ export const MAX_NUMBER_OF_FREE_TICKETS_PER_USER_FOR_A_BASH_EVENT = 100 as const;
19
+ export const MAX_NUMBER_OF_TICKETS_PER_REQUEST_FOR_A_BASH_EVENT = 50 as const;
20
+
21
+ export const MONTHS_PREVIOUS_THAT_STRIPE_ACCOUNTS_WILL_BE_SEARCHED_BY_EMAIL = 1 as const;
22
+
23
+ export const HTTP_CODE_OK = 200 as const;
24
+ export const HTTP_CODE_TEMPORARY_REDIRECT = 307 as const;
25
+ export const HTTP_CODE_INTERNAL_SERVER_ERR = 500 as const
26
+ export const HTTP_CODE_BAD_REQUEST = 400 as const;
27
+ export const HTTP_CODE_UNAUTHORIZED = 401 as const;
28
+ export const HTTP_CODE_NOT_FOUND = 404 as const;
29
+ export const ERR_UNAUTHORIZED_REQUEST = "Unauthorized to perform requested action. Have you logged in?" as const;
30
+
31
+ export const URL_PARAMS_BASH_EVENT_ID = 'bashEventId' as const;
32
+ export const URL_PARAMS_BASH_EVENT_TITLE = 'bashEventId' as const;
33
+ export const URL_PARAMS_BASH_EVENT_DESC = 'bashEventDesc' as const;
34
+ export const URL_PARAMS_BASH_EVENT_COVER_PHOTO = 'bashEventCoverPhoto' as const;
35
+ export const URL_PARAMS_EMAIL = 'email' as const;
36
+ export const URL_PARAMS_OTP_CODE = 'code' as const;
37
+ export const URL_PARAMS_INCLUDE = 'include' as const;
38
+ export const URL_PARAMS_REDIRECT = 'redirect' as const;
39
+ export const URL_PARAMS_GOOGLE_ACCESS_CODE = 'code' as const;
40
+ export const URL_PARAMS_LINKED_IN_CODE = 'code' as const;
41
+ export const URL_PARAMS_STATE = 'state' as const;
42
+
43
+ export const URL_INCLUDE_QUERY_PARAM_DELIM = ',' as const;
44
+ export const URL_INCLUDE_PRISMA_DATA_KEYS_DELIM = '.' as const;
45
+
46
+ export const DEFAULT_PRISMA_TTL_SECONDS = 60 as const;
47
+ export const PRISMA_MEDIA_TTL_SECONDS = 60 * 5; // 5 hours
48
+ export const PRISMA_USER_TTL_SECONDS = 60 * 7; // 7 hours
49
+ export const PRISMA_BASH_EVENT_TTL_SECONDS = 60 as const;
50
+
51
+ export const MIN_PASSWORD_LENGTH = 10 as const;
52
+
53
+ export const DEBOUNCE_WAIT = 1000 as const;
54
+
55
+ export const ASSET_KEY_DELIM = '__' as const;
56
+ export const ASSET_MAX_MD5_BYTE_LENGTH = 1024 * 100; // 100kb
57
+
58
+
59
+ export type DateTimeArgType = Date | string | undefined | null;
60
+ export type RequiredStripeInfoMissingErrorDataType = { [k in keyof User]?: { type: string, label: string } };
61
+
62
+ export type FilterFields = {
63
+ price: string[];
64
+ ageRequirement: string[];
65
+ allowed: string[];
66
+ crowd: string[];
67
+ vibe: string[];
68
+ included: string[];
69
+ };
70
+
71
+ export interface SignInEmailWithCode {
72
+ email: string;
73
+ code: string;
74
+ }
75
+
76
+ export interface MoreOptionsMenuItem {
77
+ name: string;
78
+ href?: string;
79
+ onClick?: () => void;
80
+ icon?: React.ElementType;
81
+ items: MoreOptionsMenuItem[];
82
+ }
83
+
84
+ export interface LinkedInAuthData {
85
+ accessToken: string;
86
+ }
87
+
88
+ export interface NumberOfTicketsForDate {
89
+ numberOfTickets: number;
90
+ ticketDateTime: DateTimeArgType;
91
+ }
92
+
93
+ export interface AvailableTicketsForTicketTier {
94
+ ticketTier: TicketTier;
95
+ availableTickets: NumberOfTicketsForDate[];
96
+ }
97
+
98
+ export interface AvailableTicketsForTicketTierForDate {
99
+ ticketTier: TicketTier,
100
+ availableTicketsForDate: NumberOfTicketsForDate;
101
+ }
102
+
103
+ export interface AvailableTicketsForTicketTier {
104
+ ticketTier: TicketTier;
105
+ availableTickets: NumberOfTicketsForDate[];
106
+ }
107
+
108
+ export interface SignInEmailWithCode {
109
+ email: string;
110
+ code: string;
111
+ }
112
+
113
+ export enum ApiErrorType {
114
+ Unknown = 1,
115
+ UserAlreadyHasMaximumAllowedFreeTicketsForBashEvent,
116
+ BashHasNoMoreTicketsAvailable,
117
+ NotEnoughTicketsAvailable,
118
+ UserExceededMaxTicketNumberForOneRequest,
119
+ UserDoesNotExist,
120
+ StripeCreateCheckoutSessionFailed,
121
+ StripeUserInfoIncomplete,
122
+ TicketsAlreadyPurchasedUsingThisCheckoutSession,
123
+ StripeAccountHasNotSetupTaxData,
124
+ StripeCheckoutSessionIncomplete
125
+ }
126
+
127
+ export const StripeErrorToApiErrorType = {
128
+ "stripe_tax_inactive": ApiErrorType.StripeAccountHasNotSetupTaxData
129
+ }
130
+
131
+ export type ErrorDataType = Record<RecordKey, any>;
132
+ export interface ApiResult<T, P extends ErrorDataType = ErrorDataType> {
133
+ data?: T;
134
+ token?: string;
135
+ error?: string;
136
+ errorType?: ApiErrorType;
137
+ errorData?: P;
138
+ details?: string;
139
+ message?: string;
140
+ }
141
+
142
+ export interface StripeCreateCheckoutSessionArgs {
143
+ currency: string;
144
+ paymentMethodType: string;
145
+ ticketListStr: string;
146
+ }
147
+
148
+ export interface StripeSessionRedirect {
149
+ redirectUrl: string;
150
+ }
151
+
152
+ export interface StripeConfirmPayment {
153
+ checkoutSessionId: string;
154
+ }
155
+
156
+ export interface StripeAccountLinkArgs {
157
+ userId: string;
158
+ returnUrl: string;
159
+ refreshUrl: string;
160
+ }
161
+
162
+ export interface StripeConfirmPaymentResult {
163
+ bashEventId: string;
164
+ numberOfTickets: number;
165
+ }
166
+
167
+ export interface IMediaUploadArgs {
168
+ mimetype: string;
169
+ idOfLinkedPrismaEntry: string;
170
+ assetKey: string;
171
+ }
172
+
173
+ export interface IPreSignedUrlArgs {
174
+ assetKey: string;
175
+ mimetype: string;
176
+ }
177
+
178
+ export interface IPreSignedUrlResult {
179
+ assetKey: string;
180
+ preSignedUrl: string | undefined;
181
+ }
182
+
183
+ export const ASSET_MIME_TYPES_TO_EXT = {
184
+ 'image/jpeg': '.jpeg',
185
+ 'image/png': '.png',
186
+ 'image/gif': '.gif',
187
+ 'image/bmp': '.bmp',
188
+ 'image/webp': '.webp',
189
+ 'image/svg+xml': '.svg',
190
+ 'image/tiff': '.tiff',
191
+ 'image/vnd': '.ico',
192
+ 'video/mp4': '.mp4',
193
+ // '.webm',
194
+ // '.ogg',
195
+ // '.avi',
196
+ // '.mov',
197
+ // '.mkv'
198
+ };
199
+ export const VALID_ASSET_MIME_TYPES = Object.keys(ASSET_MIME_TYPES_TO_EXT);
200
+
201
+ export const VibeTagsToString: { [key in BashEventVibeTags]: string } = {
202
+ [BashEventVibeTags.Wild]: "Wild",
203
+ [BashEventVibeTags.Calm]: "Chill",
204
+ [BashEventVibeTags.SomewhereInBetween]: "Somewhere in between"
205
+ }
206
+ export const DressTagsToString: { [key in BashEventDressTags]: string } = {
207
+ [BashEventDressTags.Casual]: "Casual",
208
+ [BashEventDressTags.BusinessCasual]: "Business casual",
209
+ [BashEventDressTags.Formal]: "Formal"
210
+ }
211
+
212
+ export const DayOfWeekToString: { [key in DayOfWeek]: string } = {
213
+ [DayOfWeek.Sunday]: 'S',
214
+ [DayOfWeek.Monday]: 'M',
215
+ [DayOfWeek.Tuesday]: 'T',
216
+ [DayOfWeek.Wednesday]: 'W',
217
+ [DayOfWeek.Thursday]: 'T',
218
+ [DayOfWeek.Friday]: 'F',
219
+ [DayOfWeek.Saturday]: 'S',
220
+ }
221
+
222
+
223
+ export type BashEventTypeToStringType = {
224
+ [key in BashEventType]: string;
225
+ };
226
+ export const BashEventTypeToString: BashEventTypeToStringType = {
227
+ [BashEventType.AfterParty]: "After-Party",
228
+ [BashEventType.AnimeAndCosplayFestival]: "Anime and Cosplay Festival",
229
+ [BashEventType.AnniversaryCelebration]: "Anniversary Celebration",
230
+ [BashEventType.ArtExhibitOpening]: "Art Exhibit Opening",
231
+ [BashEventType.ArtAndCraftNight]: "Art and Craft Night",
232
+ [BashEventType.BBQCookout]: "BBQ Cookout",
233
+ [BashEventType.BabyShower]: "Baby Shower",
234
+ [BashEventType.BachelorOrBacheloretteParty]: "Bachelor/Bachelorette Party",
235
+ [BashEventType.BeachParty]: "Beach Party",
236
+ [BashEventType.Birthday]: "Birthday",
237
+ [BashEventType.BoatPartyOrCruise]: "Boat Party or Cruise",
238
+ [BashEventType.Bonfire]: "Bonfire",
239
+ [BashEventType.BookClubMeeting]: "Book Club Meeting",
240
+ [BashEventType.BridalShower]: "Bridal Shower",
241
+ [BashEventType.BrunchGathering]: "Brunch Gathering",
242
+ [BashEventType.CarShow]: "Car Show",
243
+ [BashEventType.CarnivalAndFair]: "Carnival and Fair",
244
+ [BashEventType.CasinoNight]: "Casino Night",
245
+ [BashEventType.CasualMixer]: "Casual Mixer",
246
+ [BashEventType.CharityBall]: "Charity Ball",
247
+ [BashEventType.CharityFundraiser]: "Charity Fundraiser",
248
+ [BashEventType.ChristmasParty]: "Christmas Party",
249
+ [BashEventType.ChurchEvent]: "Church Event",
250
+ [BashEventType.CircusOrCarnivalParty]: "Circus/Carnival Party",
251
+ [BashEventType.CocktailParty]: "Cocktail Party",
252
+ [BashEventType.CollegeParty_FraternityOrSorority]: "College Party (Fraternity/Sorority)",
253
+ [BashEventType.ComedyShowOrStandUpComedyNight]: "Comedy Show Or Stand-Up Comedy Night",
254
+ [BashEventType.ComicConvention]: "Comic Convention",
255
+ [BashEventType.Competition]: "Competition",
256
+ [BashEventType.Concert]: "Concert",
257
+ [BashEventType.CookingCompetition]: "Cooking Competition",
258
+ [BashEventType.CorporateEventOrOfficeParty]: "Corporate Event/Office Party",
259
+ [BashEventType.CostumeParty_Theme_Based]: "Costume Party (Theme-Based)",
260
+ [BashEventType.CulturalFestival]: "Cultural Festival",
261
+ [BashEventType.DanceParty]: "Dance Party",
262
+ [BashEventType.DesertRave]: "Desert Rave",
263
+ [BashEventType.DiscoNight]: "Disco Night",
264
+ [BashEventType.EasterGathering]: "Easter Gathering",
265
+ [BashEventType.EngagementParty]: "Engagement Party",
266
+ [BashEventType.ESportsGamingTournament]: "E-sports Gaming Tournament",
267
+ [BashEventType.ExclusiveLuxuryRetreat]: "Exclusive Luxury Retreat",
268
+ [BashEventType.FantasyThemedParty]: "Fantasy Themed Party",
269
+ [BashEventType.FashionShow]: "Fashion Show",
270
+ [BashEventType.Fireside]: "Fireside",
271
+ [BashEventType.FitnessFestival]: "Fitness Festival",
272
+ [BashEventType.FlashMob]: "Flash Mob",
273
+ [BashEventType.Festival]: "Festival",
274
+ [BashEventType.FestivalFilm]: "Film Festival",
275
+ [BashEventType.FestivalFood]: "Food Festival",
276
+ [BashEventType.FundraisingEvent]: "Fundraising Event",
277
+ [BashEventType.GalaDinner]: "Gala Dinner",
278
+ [BashEventType.GameNight]: "Game Night",
279
+ [BashEventType.GamingEvent]: "Gaming Event",
280
+ [BashEventType.GardenParty]: "Garden Party",
281
+ [BashEventType.GoingAwayPartyOrFarewell]: "Going-away Party or Farewell",
282
+ [BashEventType.GraduationParty]: "Graduation Party",
283
+ [BashEventType.HalloweenCostumeParty]: "Halloween Costume Party",
284
+ [BashEventType.HanukkahParty]: "Hanukkah Party",
285
+ [BashEventType.HistoricalEraParty]: "Historical Era Party",
286
+ [BashEventType.HolidayParty]: "Holiday Party",
287
+ [BashEventType.HouseParty]: "House Party",
288
+ [BashEventType.HousewarmingParty]: "Housewarming Party",
289
+ [BashEventType.KaraokeNight]: "Karaoke Night",
290
+ [BashEventType.KiteFlyingFestival]: "Kite Flying Festival",
291
+ [BashEventType.LiveBandPerformanceInALocalVenue]: "Live Band Performance in a Local Venue",
292
+ [BashEventType.Luau]: "Luau",
293
+ [BashEventType.MansionParty]: "Mansion Party",
294
+ [BashEventType.MardiGras]: "Mardi Gras",
295
+ [BashEventType.MasqueradeBall]: "Masquerade Ball",
296
+ [BashEventType.MotorcycleRally]: "Motorcycle Rally",
297
+ [BashEventType.MovieNight]: "Movie Night",
298
+ [BashEventType.MoviePremiere]: "Movie Premiere",
299
+ [BashEventType.MusicFestival]: "Music Festival",
300
+ [BashEventType.NewYearsEveCelebration]: "New Year's Eve Celebration",
301
+ [BashEventType.OpenMicNight]: "Open Mic Night",
302
+ [BashEventType.OutdoorActivity]: "Outdoor Activity",
303
+ [BashEventType.OutdoorConcert]: "Outdoor Concert",
304
+ [BashEventType.OutdoorMovieNight_WithAProjector]: "Outdoor Movie Night (With a Projector)",
305
+ [BashEventType.Parade]: "Parade",
306
+ [BashEventType.Party]: "Party",
307
+ [BashEventType.PoolParty]: "Pool Party",
308
+ [BashEventType.Potluck]: "Potluck",
309
+ [BashEventType.PotluckVegan]: "Potluck (Vegan)",
310
+ [BashEventType.PreParty]: "Pre-Party",
311
+ [BashEventType.ProductLaunch]: "Product Launch",
312
+ [BashEventType.ProfessionalNetworkingEvent]: "Professional Networking Event",
313
+ [BashEventType.Rave_General]: "Rave (General)",
314
+ [BashEventType.RetirementCelebration]: "Retirement Celebration",
315
+ [BashEventType.Reunion_FamilyOrSchoolOrFriends]: "Reunion (Family/School/Friends)",
316
+ [BashEventType.SafariAdventureParty]: "Safari Adventure Party",
317
+ [BashEventType.SchoolEvent_MiddleSchoolOrHighSchoolOrCollege]: "School Event (MiddleSchool, High School, College)",
318
+ [BashEventType.ScienceFictionThemedParty]: "Science Fiction-Themed Party",
319
+ [BashEventType.SocialClubEvent]: "Social Club Event",
320
+ [BashEventType.SportsTournament]: "Sports Tournament",
321
+ [BashEventType.SportsWatchParty]: "Sports Watch Party",
322
+ [BashEventType.SuperheroThemedParty]: "Superhero Themed Party",
323
+ [BashEventType.SurfCompetition]: "Surf Competition",
324
+ [BashEventType.ThanksgivingDinner]: "Thanksgiving Dinner",
325
+ [BashEventType.ThemedCostumeParty]: "Themed Costume Party",
326
+ [BashEventType.ThemedDinnerParty]: "Themed Dinner Party",
327
+ [BashEventType.ThemedPubCrawl]: "Themed Pub Crawl",
328
+ [BashEventType.Tournament]: "Tournament",
329
+ [BashEventType.TravelAndTradeShow]: "Travel and Trade Show",
330
+ [BashEventType.TriviaNight]: "Trivia Night",
331
+ [BashEventType.ValentinesDayParty]: "Valentine's Day Party",
332
+ [BashEventType.WeddingReception]: "Wedding Reception",
333
+ [BashEventType.WelcomeHomeParty]: "Welcome Home Party",
334
+ [BashEventType.WellnessFestival]: "Wellness Festival",
335
+ [BashEventType.WineTastingEvent]: "Wine Tasting Event",
336
+ [BashEventType.Other]: "Other",
337
+ }
338
+
339
+ export type RecordKey = string | number | symbol;
340
+ export type PartialExcept<T, K extends keyof T> = Partial<T> & {[P in K]: T[P]};
341
+ type GetTypeOfArray<T> = T extends (infer U)[] ? U : never;
342
+
343
+ export type AllKeysUnionOfDescendants<T> = T extends object
344
+ ? T[keyof T] extends infer K
345
+ ? K extends string | number | symbol
346
+ ? {[K in keyof T]-?: T[K] extends any[]
347
+ ? GetTypeOfArray<T[K]> extends Record<RecordKey, any>
348
+ ? `${K & string}` | `${AllKeysUnion<GetTypeOfArray<T[K]>>}`
349
+ : never
350
+ : `${K & string}` | `${AllKeysUnion<T[K]>}`}[keyof T]
351
+ : never
352
+ : never
353
+ : never;
354
+
355
+ export type AllKeysOfDescendants<T> = AllKeysUnionOfDescendants<T>[];
356
+
357
+ type AllKeysUnion<T> = T extends object
358
+ ? T[keyof T] extends infer K
359
+ ? K extends string | number | symbol
360
+ ? {[K in keyof T]-?: T[K] extends any[]
361
+ ? GetTypeOfArray<T[K]> extends Record<RecordKey, any>
362
+ ? `${K & string}` | `${K & string}${typeof URL_INCLUDE_PRISMA_DATA_KEYS_DELIM}${AllKeysUnion<GetTypeOfArray<T[K]>> & string}`
363
+ : never
364
+ : T[K] extends Function
365
+ ? never
366
+ : `${K & string}` | `${K & string}${typeof URL_INCLUDE_PRISMA_DATA_KEYS_DELIM}${AllKeysUnion<T[K]> & string}`}[keyof T]
367
+ : never
368
+ : never
369
+ : never;
370
+
371
+ export type AllKeys<T> = AllKeysUnion<T>[];
@@ -0,0 +1,143 @@
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
+ } from "@prisma/client";
12
+ import {RecordKey} from "./definitions";
13
+
14
+ // TODO: Get this to work
15
+ type PrismaInclude<T extends Record<RecordKey, unknown>> = {[key in keyof T]: boolean | {include: T[key]}};
16
+
17
+ export interface BashEventExt extends BashEvent {
18
+ targetAudience?: TargetAudience;
19
+ amountOfGuests?: AmountOfGuests;
20
+ recurrence?: Recurrence;
21
+ creator?: User;
22
+ ticketTiers: TicketTierExt[];
23
+ media: Media[];
24
+ eventTasks: EventTask[];
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 const BASH_EVENT_DATA_TO_INCLUDE = {
31
+ targetAudience: true,
32
+ amountOfGuests: true,
33
+ recurrence: true,
34
+ ticketTiers: true,
35
+ creator: true,
36
+ eventTasks: true,
37
+ media: true
38
+ }
39
+
40
+ export const BASH_EVENT_DATA_TO_CLONE = [
41
+ 'targetAudience',
42
+ 'amountOfGuests',
43
+ 'ticketTiers',
44
+ 'media',
45
+ 'recurrence',
46
+ 'invitations',
47
+ ] as const;
48
+
49
+ type RemoveCommonProperties<T, U> = keyof (Omit<T, keyof U> & Omit<U, keyof T>);
50
+ type UnionFromArray<T extends ReadonlyArray<any>> = T[number];
51
+ type BashEventExtMinusDataToCloneType = Omit<BashEventExt, UnionFromArray<typeof BASH_EVENT_DATA_TO_CLONE>>;
52
+
53
+ export const BASH_EVENT_DATA_TO_REMOVE: RemoveCommonProperties<BashEvent, BashEventExtMinusDataToCloneType>[] = [
54
+ 'creator',
55
+ 'eventTasks',
56
+ 'tickets'
57
+ ];
58
+
59
+ export interface InvitationExt extends Invitation {
60
+ creator: User;
61
+ sentTo: User;
62
+ tickets: Ticket[];
63
+ }
64
+
65
+ export const INVITATION_DATA_TO_INCLUDE = {
66
+ creator: true,
67
+ sentTo: true,
68
+ tickets: true
69
+ }
70
+
71
+ export interface InvitationExtraData extends Invitation {
72
+ isFreeGuest?: boolean;
73
+ isOrganizer?: boolean;
74
+ }
75
+
76
+ export interface AssociatedBashExt extends AssociatedBash {
77
+ bashEvent: BashEventExt;
78
+ invitation: InvitationExt;
79
+ }
80
+
81
+
82
+ export const ASSOCIATED_BASH_DATA_TO_INCLUDE = {
83
+ bashEvent: {
84
+ include: BASH_EVENT_DATA_TO_INCLUDE
85
+ },
86
+ invitation: {
87
+ include: INVITATION_DATA_TO_INCLUDE
88
+ }
89
+ }
90
+
91
+ export interface TicketTierExt extends TicketTier {
92
+ bashEvent: BashEvent;
93
+ tickets: TicketExt[];
94
+ }
95
+
96
+ export interface TicketExt extends Ticket {
97
+ owner: User;
98
+ forUser: User;
99
+ }
100
+
101
+ export interface ReviewExt extends Review {
102
+ comments: BashComment[];
103
+ }
104
+
105
+ export interface UserExtraData extends User {
106
+ password: string;
107
+ }
108
+
109
+ export interface UserExt extends User {
110
+ services: Service[];
111
+
112
+ // Do not include in fetch as there could be thousands of these
113
+ associatedBashes?: AssociatedBash[]
114
+ reviews?: ReviewExt[];
115
+ contacts?: Contact[];
116
+ }
117
+
118
+ export const USER_DATA_TO_INCLUDE = {
119
+ services: true,
120
+ }
121
+
122
+ export const USER_DATA_SELECT_REVIEWS_COMMENTS = {
123
+ reviews: {
124
+ include: {
125
+ comments: true
126
+ }
127
+ }
128
+ }
129
+
130
+ export const PUBLIC_USER_DATA_TO_SELECT = {
131
+ id: true,
132
+ email: true,
133
+ givenName: true,
134
+ familyName: true,
135
+ fullName: true,
136
+ username: true,
137
+ image: true,
138
+ uploadedImage: true,
139
+ services: true,
140
+ }
141
+
142
+ export type Public_User = Pick<UserExt, keyof typeof PUBLIC_USER_DATA_TO_SELECT>
143
+ & Partial<Pick<UserExt, keyof typeof USER_DATA_SELECT_REVIEWS_COMMENTS>>;
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./extendedSchemas";
2
+ export * from "./definitions";
package/tsconfig.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "es2020",
3
+ "target": "es2022",
4
4
  "module": "esnext",
5
5
  "moduleResolution": "node",
6
6
  "esModuleInterop": true,