@bash-app/bash-common 29.63.0 → 29.65.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bash-app/bash-common",
3
- "version": "29.63.0",
3
+ "version": "29.65.0",
4
4
  "description": "Common data and scripts to use on the frontend and backend",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -40,6 +40,7 @@
40
40
  "@types/shelljs": "^0.8.15",
41
41
  "jest": "^29.7.0",
42
42
  "shelljs": "^0.8.5",
43
+ "stripe": "^16.12.0",
43
44
  "ts-jest": "^29.1.1",
44
45
  "ts-node": "^10.9.1",
45
46
  "tslib": "^2.6.2",
@@ -244,6 +244,7 @@ model BashEvent {
244
244
  venue Venue? @relation(fields: [venueId], references: [id])
245
245
  userPromoCodeRedemption UserPromoCodeRedemption[]
246
246
  averageRating Float? @default(0)
247
+ createdAt DateTime @default(now()) // Timestamp for when the review was created
247
248
  }
248
249
 
249
250
  model Coordinates {
@@ -615,6 +616,8 @@ enum BashStatus {
615
616
  Draft
616
617
  PreSale
617
618
  Published
619
+ Pending
620
+ Finished
618
621
  }
619
622
 
620
623
  enum ServiceStatus {
@@ -627,6 +630,7 @@ enum ServiceCondition {
627
630
  Published
628
631
  Suspended
629
632
  Deactivated
633
+ Unpublished
630
634
  }
631
635
 
632
636
  enum ServiceSubscriptionStatus {
@@ -750,19 +754,18 @@ enum PrizeType {
750
754
 
751
755
  model Review {
752
756
  id String @id @default(cuid())
753
- rating Int // Star rating, required
754
- creatorId String // ID of the user who created the review
757
+ rating Int // Star rating, required
758
+ creatorId String // ID of the user who created the review
755
759
  creator User @relation(fields: [creatorId], references: [id], onDelete: Cascade)
756
- bashEventId String // ID of the bash event being reviewed
760
+ bashEventId String // ID of the bash event being reviewed
757
761
  bashEvent BashEvent @relation(fields: [bashEventId], references: [id], onDelete: Cascade)
758
762
  comments BashComment[] // Optional comments tied to the review
759
763
  createdAt DateTime @default(now()) // Timestamp for when the review was created
760
- updatedAt DateTime @updatedAt // Auto-updated timestamp for edits
764
+ updatedAt DateTime @updatedAt // Auto-updated timestamp for edits
761
765
 
762
766
  @@unique([creatorId, bashEventId]) // Prevent duplicate reviews for the same bash by a user
763
767
  }
764
768
 
765
-
766
769
  model GoogleReview {
767
770
  id String @id @default(cuid())
768
771
  author_name String?
@@ -21,6 +21,7 @@ import {
21
21
  BashEventExt,
22
22
  } from "./extendedSchemas";
23
23
  import { ServiceSubscriptionTier } from "./utils/userSubscriptionUtils";
24
+ import Stripe from "stripe";
24
25
 
25
26
  export const PASSWORD_MIN_LENGTH = 8 as const;
26
27
  export const PASSWORD_REQUIREMENTS_REGEX = new RegExp(
@@ -113,6 +114,14 @@ export const URL_PARAMS_SETUP_PAYMENT_OPTIONS = {
113
114
  export type UrlParamsSetupPayment =
114
115
  (typeof URL_PARAMS_SETUP_PAYMENT_OPTIONS)[keyof typeof URL_PARAMS_SETUP_PAYMENT_OPTIONS];
115
116
 
117
+ export const URL_PARAMS_SETUP_STAGE = "setupStage" as const;
118
+ export const URL_PARAMS_SETUP_STAGE_OPTIONS = {
119
+ paymentMethod: "payment-method",
120
+ complete: "complete",
121
+ } as const;
122
+ export type UrlParamsSetupStage =
123
+ (typeof URL_PARAMS_SETUP_STAGE_OPTIONS)[keyof typeof URL_PARAMS_SETUP_STAGE_OPTIONS];
124
+
116
125
  export const URL_PARAMS_TICKET_LIST_DELIM = "," as const;
117
126
  export const URL_PARAMS_TICKET_TIER_ID_NUMBER_OF_TICKETS_DATE_DELIM =
118
127
  "__" as const;
@@ -310,6 +319,7 @@ export enum ApiErrorType {
310
319
  StripeCheckoutSessionIncomplete,
311
320
  CouldNotSendEmail,
312
321
  TicketTierHiddenAsAtLeastOneTicketHasAlreadyBeenPurchased,
322
+ PaymentMethodNotSetup,
313
323
  }
314
324
 
315
325
  export type ErrorDataType = Record<RecordKey, any>;
@@ -339,6 +349,18 @@ export interface UserSubscriptionData {
339
349
  subscriptionType: UserSubscriptionType;
340
350
  }
341
351
 
352
+ export interface StripePaymentMethod {
353
+ id: string;
354
+
355
+ customerName: string;
356
+
357
+ lastFour: string;
358
+ expMonth: number;
359
+ expYear: number;
360
+ country: string;
361
+ brand: string;
362
+ }
363
+
342
364
  export interface StripeCreateBashEventTicketsCheckoutSessionArgs {
343
365
  bashEventId: string;
344
366
  currency: string;
@@ -360,11 +382,35 @@ export interface StripeCreateSetupPaymentMethodSessionArgs {
360
382
  cancelUrl: string;
361
383
  }
362
384
 
385
+ export interface StripeSetDefaultPaymentMethodArgs {
386
+ paymentMethodId: string;
387
+ }
388
+
389
+ export interface StripeAddPaymentMethodArgs {
390
+ paymentMethodId: string;
391
+ }
392
+
393
+ export interface StripeDeletePaymentMethodArgs {
394
+ paymentMethodId: string;
395
+ }
396
+
363
397
  export interface StripeCreateAccountPortalSessionArgs {
364
398
  stripeAccountId: string;
365
399
  returnUrl: string;
366
400
  }
367
401
 
402
+ export interface GenericPrompt {
403
+ prompt?: string;
404
+ }
405
+
406
+ export interface GenericDescription {
407
+ description: string;
408
+ }
409
+
410
+ export interface GenericTitle {
411
+ title: string;
412
+ }
413
+
368
414
  export type StripeSessionRedirect = {
369
415
  stripeAccountIdDB: string;
370
416
  redirectUrl: string;
@@ -411,10 +457,12 @@ export type StripeBusinessDataOwned = {
411
457
  stripeAccountDBId: string;
412
458
 
413
459
  bankAccount?: string;
414
- linkingStatus: StripeLinkingStatus;
460
+ linkingStatus?: StripeLinkingStatus;
415
461
 
416
462
  createdDate: string;
417
463
  updatedDate: string;
464
+
465
+ paymentMethods: StripePaymentMethod[];
418
466
  } & StripeBusinessDataPublic;
419
467
 
420
468
  export interface StripeConfirmPayment {
@@ -0,0 +1,86 @@
1
+ // import { DayOfWeek } from "@prisma/client";
2
+ // import { DateTime, Interval } from "luxon";
3
+ // import { DayOfWeekIdx, DayOfWeekToIdx } from "../definitions";
4
+
5
+ // export function dayOfWeekToIdx(dayOfWeek: DayOfWeek | DayOfWeekIdx): number {
6
+ // if (typeof dayOfWeek === "number") {
7
+ // return dayOfWeek;
8
+ // } else if (typeof dayOfWeek === "string") {
9
+ // return DayOfWeekToIdx[dayOfWeek];
10
+ // } else {
11
+ // throw new Error(`dayOfWeekToIdx: unhandled case`);
12
+ // }
13
+ // }
14
+
15
+ // export function dateTimeFromDayTime(
16
+ // dayOfWeek: DayOfWeek | DayOfWeekIdx,
17
+ // hour: number = 0,
18
+ // minute: number = 0
19
+ // ): DateTime {
20
+ // //use date where first day of month is a known sunday
21
+ // return DateTime.fromObject({
22
+ // year: 2020,
23
+ // month: 1,
24
+ // day: dayOfWeekToIdx(dayOfWeek),
25
+ // hour: hour,
26
+ // minute: minute,
27
+ // });
28
+ // }
29
+
30
+ // export type DateTimeTime = Pick<DateTime, "hour" | "minute">;
31
+ // export type DateTimeDate = Pick<DateTime, "year" | "month" | "day">;
32
+
33
+ // export function dateTimeToTimeComponents(dateTime: DateTime): DateTimeTime {
34
+ // return {
35
+ // hour: dateTime.hour,
36
+ // minute: dateTime.minute,
37
+ // };
38
+ // }
39
+
40
+ // export function dateTimeToDateComponents(dateTime: DateTime): DateTimeDate {
41
+ // return {
42
+ // year: dateTime.year,
43
+ // month: dateTime.month,
44
+ // day: dateTime.day,
45
+ // };
46
+ // }
47
+
48
+ // export function objectHasDate(obj: object) {
49
+ // return "year" in obj;
50
+ // }
51
+
52
+ // export function objectHasTime(obj: object) {
53
+ // return "hour" in obj;
54
+ // }
55
+
56
+ // export function dateTimeSetTime(
57
+ // dateTime: DateTime,
58
+ // time: DateTimeTime | DateTime = { hour: 0, minute: 0 }
59
+ // ): DateTime {
60
+ // const timeComp = objectHasTime(time)
61
+ // ? dateTimeToTimeComponents(time as DateTime)
62
+ // : time;
63
+ // return dateTime.set(timeComp);
64
+ // }
65
+
66
+ // export function dateTimeSetDate(
67
+ // dateTime: DateTime,
68
+ // date: DateTimeDate | DateTime = { year: 2020, month: 1, day: 1 }
69
+ // ): DateTime {
70
+ // const dateComp = objectHasDate(date)
71
+ // ? dateTimeToTimeComponents(date as DateTime)
72
+ // : date;
73
+ // return dateTime.set(dateComp);
74
+ // }
75
+
76
+ // export function dateTimeLocalFromUTCDate(date: Date) {
77
+ // return DateTime.fromJSDate(date).toLocal();
78
+ // }
79
+
80
+ // export function dateTimeLocalToUTCDate(dateTime: DateTime) {
81
+ // return dateTime.toUTC().toJSDate();
82
+ // }
83
+
84
+ // export function dateTimeFormatTime(dateTime: DateTime) {
85
+ // return dateTime.toFormat("HH:MM");
86
+ // }
@@ -125,7 +125,12 @@ Object.keys(SERVICE_CANCELATION_POLICY_DATA)
125
125
  export function serviceSubscriptionIsActive(
126
126
  status: ServiceSubscriptionStatus
127
127
  ): boolean {
128
- return status in ["Trialing", "Normal"];
128
+ return (
129
+ [
130
+ ServiceSubscriptionStatus.Normal,
131
+ ServiceSubscriptionStatus.Trialing,
132
+ ] as ServiceSubscriptionStatus[]
133
+ ).includes(status);
129
134
  }
130
135
 
131
136
  export function serviceDetailUrl(
@@ -1,11 +1,13 @@
1
1
  import { StripeLinkingStatus } from "../definitions";
2
2
  import { isProduction } from "./apiUtils";
3
3
 
4
- export const stripeAccountFullyLinked = (linkingStatus: StripeLinkingStatus): boolean => {
5
- return (
6
- !linkingStatus.hasOutstandingRequirements &&
7
- linkingStatus.isOnboarded &&
8
- linkingStatus.paymentsEnabled &&
9
- (!isProduction() || linkingStatus.taxMonitoringEnabled)
10
- );
11
- }
4
+ export const stripeAccountFullyLinked = (
5
+ linkingStatus: StripeLinkingStatus
6
+ ): boolean => {
7
+ return (
8
+ !linkingStatus.hasOutstandingRequirements &&
9
+ linkingStatus.isOnboarded &&
10
+ linkingStatus.paymentsEnabled &&
11
+ (!isProduction() || linkingStatus.taxMonitoringEnabled)
12
+ );
13
+ };
@@ -0,0 +1 @@
1
+ export type ValueOf<T> = T[keyof T];