@bash-app/bash-common 29.64.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.64.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",
@@ -191,8 +191,7 @@ model BashEvent {
191
191
  title String
192
192
  creatorId String
193
193
  creator User @relation("CreatedEvent", fields: [creatorId], references: [id], onDelete: Cascade)
194
- createdAt DateTime @default(now())
195
- isApproved Boolean? @default(false)
194
+ isApproved Boolean?
196
195
  description String?
197
196
  eventType String @default("Other")
198
197
  startDateTime DateTime? @default(now())
@@ -245,6 +244,7 @@ model BashEvent {
245
244
  venue Venue? @relation(fields: [venueId], references: [id])
246
245
  userPromoCodeRedemption UserPromoCodeRedemption[]
247
246
  averageRating Float? @default(0)
247
+ createdAt DateTime @default(now()) // Timestamp for when the review was created
248
248
  }
249
249
 
250
250
  model Coordinates {
@@ -614,9 +614,9 @@ enum Education {
614
614
 
615
615
  enum BashStatus {
616
616
  Draft
617
- Pending
618
617
  PreSale
619
618
  Published
619
+ Pending
620
620
  Finished
621
621
  }
622
622
 
@@ -630,6 +630,7 @@ enum ServiceCondition {
630
630
  Published
631
631
  Suspended
632
632
  Deactivated
633
+ Unpublished
633
634
  }
634
635
 
635
636
  enum ServiceSubscriptionStatus {
@@ -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;
@@ -349,6 +358,7 @@ export interface StripePaymentMethod {
349
358
  expMonth: number;
350
359
  expYear: number;
351
360
  country: string;
361
+ brand: string;
352
362
  }
353
363
 
354
364
  export interface StripeCreateBashEventTicketsCheckoutSessionArgs {
@@ -372,6 +382,18 @@ export interface StripeCreateSetupPaymentMethodSessionArgs {
372
382
  cancelUrl: string;
373
383
  }
374
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
+
375
397
  export interface StripeCreateAccountPortalSessionArgs {
376
398
  stripeAccountId: string;
377
399
  returnUrl: string;
@@ -435,10 +457,12 @@ export type StripeBusinessDataOwned = {
435
457
  stripeAccountDBId: string;
436
458
 
437
459
  bankAccount?: string;
438
- linkingStatus: StripeLinkingStatus;
460
+ linkingStatus?: StripeLinkingStatus;
439
461
 
440
462
  createdDate: string;
441
463
  updatedDate: string;
464
+
465
+ paymentMethods: StripePaymentMethod[];
442
466
  } & StripeBusinessDataPublic;
443
467
 
444
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];