@bash-app/bash-common 29.48.0 → 29.49.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.48.0",
3
+ "version": "29.49.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",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@prisma/client": "^5.18.0",
30
- "dayjs": "^1.11.10",
30
+ "dayjs": "^1.11.13",
31
31
  "prisma": "^5.18.0",
32
32
  "react-tailwindcss-datepicker": "^1.6.6",
33
33
  "tsx": "^4.10.3"
@@ -330,19 +330,6 @@ model ServiceCheckout {
330
330
  stripeCheckoutSessionId String? @unique
331
331
  }
332
332
 
333
- model UserSubscription {
334
- id String @id @default(cuid())
335
- ownerId String @unique
336
- owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
337
- type UserSubscriptionType
338
- }
339
-
340
- enum UserSubscriptionType {
341
- Free
342
- Premium
343
- VIP
344
- }
345
-
346
333
  enum BookingStatus {
347
334
  Cancelled
348
335
  Completed
@@ -911,10 +898,10 @@ model User {
911
898
  serviceCheckouts ServiceCheckout[]
912
899
  bookingForMe Booking[]
913
900
  userSubscription UserSubscription?
914
- serviceSubcriptions ServiceSubscription[]
901
+ // serviceSubcriptions ServiceSubscription[]
915
902
  volunteerService VolunteerService[]
916
903
  stripeAccounts StripeAccount[]
917
- ServicePromoCodeRedemption ServicePromoCodeRedemption[]
904
+ servicePromoCodeRedemption ServicePromoCodeRedemption[]
918
905
  }
919
906
 
920
907
  model Contact {
@@ -972,30 +959,52 @@ enum ServiceCancelationPolicy {
972
959
  Standard30Day
973
960
  }
974
961
 
975
- model ServiceSubscription {
976
- id String @id @default(cuid())
977
- ownerId String
978
- owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
979
- slots Int @default(0)
980
- stripeSubscriptionId String?
962
+ enum UserSubscriptionStatus {
963
+ Active
964
+ Trialing
965
+ Paused
966
+ Canceled
967
+ Incomplete
968
+ IncompleteExpired
969
+ Unpaid
970
+ PastDue
971
+ Suspended
972
+ Expired
981
973
  }
982
974
 
983
- model ServiceListingSubscription {
984
- id String @id @default(cuid())
985
- stripeAccountId String
986
- stripeAccount StripeAccount @relation(fields: [stripeAccountId], references: [id], onDelete: Restrict, onUpdate: Restrict)
987
- stripeCheckoutSessionId String? @unique
988
- stripeSubscriptionId String? @unique
975
+ enum UserSubscriptionType {
976
+ Free
977
+ Basic
978
+ Premium
979
+ VIP
980
+ }
989
981
 
990
- // lastCheckoutSessionCreatedAt DateTime
991
- // checkoutInProgress Boolean @default(false)
982
+ enum ServiceSubscriptionTier {
983
+ Basic
984
+ Premium
985
+ VIP
986
+ }
987
+
988
+ model UserSubscription {
989
+ id String @id @default(cuid())
992
990
 
993
- subscriptionStatus ServiceSubscriptionStatus @default(None)
991
+ ownerId String @unique
992
+ owner User @relation(fields: [ownerId], references: [id], onDelete: Restrict, onUpdate: Restrict)
994
993
 
995
- serviceId String @unique
996
- service Service @relation(fields: [serviceId], references: [id], onDelete: Restrict)
994
+ stripeAccountId String @unique
995
+ stripeAccount StripeAccount @relation(fields: [stripeAccountId], references: [id], onDelete: Restrict, onUpdate: Restrict)
997
996
 
998
- @@index([stripeCheckoutSessionId, stripeSubscriptionId])
997
+ stripeCheckoutSessionId String? @unique
998
+ stripeSubscriptionId String? @unique
999
+
1000
+ type UserSubscriptionType?
1001
+ status UserSubscriptionStatus?
1002
+
1003
+ //price addons
1004
+ serviceSubscriptionTier ServiceSubscriptionTier?
1005
+
1006
+ @@index([stripeCheckoutSessionId])
1007
+ @@index([stripeSubscriptionId])
999
1008
  }
1000
1009
 
1001
1010
  // Common data for all services; 1-1 relation between each individual service model such as Venue
@@ -1060,8 +1069,6 @@ model Service {
1060
1069
  stripeAccountId String?
1061
1070
  stripeAccount StripeAccount? @relation(fields: [stripeAccountId], references: [id], onDelete: Restrict)
1062
1071
 
1063
- serviceListingSubscription ServiceListingSubscription?
1064
-
1065
1072
  targetAudienceId String? @unique
1066
1073
  targetAudience TargetAudience? @relation(fields: [targetAudienceId], references: [id], onDelete: Cascade)
1067
1074
 
@@ -1105,8 +1112,8 @@ model StripeAccount {
1105
1112
  createdAt DateTime @default(now())
1106
1113
  updatedAt DateTime @updatedAt
1107
1114
 
1108
- service Service[]
1109
- ServiceListingSubscription ServiceListingSubscription[]
1115
+ service Service[]
1116
+ userSubscription UserSubscription?
1110
1117
 
1111
1118
  @@index([ownerId])
1112
1119
  }
@@ -1265,20 +1272,6 @@ enum VenuePricingPlan {
1265
1272
  Subscription
1266
1273
  }
1267
1274
 
1268
- enum ServiceSubscriptionStatus {
1269
- None
1270
- Active
1271
- Trialing
1272
- Paused
1273
- Canceled
1274
- Incomplete
1275
- IncompleteExpired
1276
- Unpaid
1277
- PastDue
1278
- Suspended
1279
- Expired
1280
- }
1281
-
1282
1275
  model Organization {
1283
1276
  id String @id @default(cuid())
1284
1277
  serviceId String @unique
@@ -36,12 +36,30 @@ import {
36
36
  ServiceSpecialRates,
37
37
  ServiceAddon,
38
38
  ServicePackage,
39
- ServiceListingSubscription,
39
+ UserSubscription,
40
40
  SocialMediaProfile,
41
41
  SocialMediaPlatform,
42
42
  } from "@prisma/client";
43
43
  import { SERVICE_LINK_DATA_TO_INCLUDE, UnionFromArray } from "./definitions";
44
44
 
45
+ //------------------------------------------------------user subscriptions------------------------------------------------------
46
+ export const PRIVATE_USER_SUBSCRIPTION_DATA_TO_SELECT = {
47
+ type: true,
48
+ status: true,
49
+ serviceSubscriptionTier: true,
50
+ ownerId: true,
51
+ stripeAccountId: true
52
+ } satisfies Prisma.UserSubscriptionSelect;
53
+
54
+ export type UserSubscriptionExt = {
55
+ stripeAccount: StripeAccountExt;
56
+ } & UserSubscription;
57
+
58
+ export const USER_SUBSCRIPTION_DATA_TO_INCLUDE = {
59
+ stripeAccount: true
60
+ } satisfies Prisma.UserSubscriptionInclude;
61
+ //-------------------------------------------------------------------------------------------------------------------------------
62
+
45
63
  export const FRONT_END_USER_DATA_TO_SELECT = {
46
64
  id: true,
47
65
  email: true,
@@ -61,6 +79,9 @@ export const PRIVATE_USER_ACCOUNT_TO_SELECT = {
61
79
  zipCode: true,
62
80
  country: true,
63
81
  phone: true,
82
+ userSubscription: {
83
+ select: PRIVATE_USER_SUBSCRIPTION_DATA_TO_SELECT
84
+ }
64
85
  } satisfies Prisma.UserSelect;
65
86
 
66
87
  export interface BashEventExt extends BashEvent {
@@ -119,7 +140,6 @@ export interface ServiceExt extends Service {
119
140
  creator?: PublicUser | null;
120
141
 
121
142
  stripeAccount?: PublicStripeAccount | null;
122
- serviceListingSubscription?: PublicServiceListingSubscription | null;
123
143
 
124
144
  // availableDateTimes?: Availability[];
125
145
 
@@ -294,13 +314,6 @@ export const SERVICE_RATES_ASSOCIATION_DATA_TO_INCLUDE = {
294
314
  } satisfies Prisma.ServiceRatesAssociationInclude;
295
315
 
296
316
  //------------Stripe Accounts--------------
297
- export const STRIPE_ACCOUNT_DATA_TO_INCLUDE = {
298
- logo: true,
299
- owner: {
300
- select: FRONT_END_USER_DATA_TO_SELECT
301
- }
302
- } satisfies Prisma.StripeAccountInclude;
303
-
304
317
  export const PUBLIC_STRIPE_ACCOUNT_DATA_TO_SELECT = {
305
318
  logo: true,
306
319
  logoId: true,
@@ -308,9 +321,15 @@ export const PUBLIC_STRIPE_ACCOUNT_DATA_TO_SELECT = {
308
321
  updatedAt: true
309
322
  } satisfies Prisma.StripeAccountSelect;
310
323
 
311
- export const PUBLIC_SERVICE_LISTING_SUBSCRIPTION_DATA_TO_SELECT = {
312
- serviceId: true
313
- } satisfies Prisma.ServiceListingSubscriptionSelect;
324
+ export const STRIPE_ACCOUNT_DATA_TO_INCLUDE = {
325
+ logo: true,
326
+ owner: {
327
+ select: FRONT_END_USER_DATA_TO_SELECT
328
+ },
329
+ userSubscription: {
330
+ select: PRIVATE_USER_SUBSCRIPTION_DATA_TO_SELECT
331
+ }
332
+ } satisfies Prisma.StripeAccountInclude;
314
333
 
315
334
  export interface StripeAccountExt extends StripeAccount {
316
335
  logo?: Media | null;
@@ -335,9 +354,6 @@ export const SERVICE_DATA_TO_INCLUDE = {
335
354
  // ...STRIPE_ACCOUNT_DATA_TO_INCLUDE,
336
355
  select: PUBLIC_STRIPE_ACCOUNT_DATA_TO_SELECT
337
356
  },
338
- serviceListingSubscription: {
339
- select: PUBLIC_SERVICE_LISTING_SUBSCRIPTION_DATA_TO_SELECT
340
- },
341
357
  // availableDateTimes: true,
342
358
  serviceLinks: {
343
359
  include: SERVICE_LINK_DATA_TO_INCLUDE
@@ -524,6 +540,7 @@ export interface UserExt extends User {
524
540
  services?: Service[] | null;
525
541
 
526
542
  // Do not include in fetch as there could be thousands of these
543
+ userSubscription?: UserSubscriptionExt | null;
527
544
  associatedBashes?: AssociatedBash[] | null;
528
545
  associatedServices?: AssociatedService[] | null;
529
546
  socialMediaProfiles?: SocialMediaProfile[] | null;
@@ -549,6 +566,4 @@ export const USER_DATA_SELECT_REVIEWS_COMMENTS = {
549
566
  export type PublicUser = Pick<UserExt, keyof typeof FRONT_END_USER_DATA_TO_SELECT>
550
567
  & Partial<Pick<UserExt, keyof typeof USER_DATA_SELECT_REVIEWS_COMMENTS>>;
551
568
 
552
- export type PublicStripeAccount = Pick<StripeAccountExt, keyof typeof PUBLIC_STRIPE_ACCOUNT_DATA_TO_SELECT>;
553
-
554
- export type PublicServiceListingSubscription = Pick<ServiceListingSubscription, keyof typeof PUBLIC_SERVICE_LISTING_SUBSCRIPTION_DATA_TO_SELECT>;
569
+ export type PublicStripeAccount = Pick<StripeAccountExt, keyof typeof PUBLIC_STRIPE_ACCOUNT_DATA_TO_SELECT>;
@@ -232,3 +232,7 @@ export function localDateToUTC(date: Date): Date {
232
232
 
233
233
  return newDate;
234
234
  }
235
+
236
+ export function timestampMinutseFromNow(minutes: number): number {
237
+ return Math.floor((new Date().getTime() / 1000) + (minutes * 60));
238
+ }