@bash-app/bash-common 30.154.0 → 30.157.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.
Files changed (37) hide show
  1. package/dist/definitions.d.ts +19 -8
  2. package/dist/definitions.d.ts.map +1 -1
  3. package/dist/definitions.js +2 -20
  4. package/dist/definitions.js.map +1 -1
  5. package/dist/extendedSchemas.d.ts +2 -2
  6. package/dist/extendedSchemas.d.ts.map +1 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +0 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/membershipDefinitions.d.ts +7 -12
  11. package/dist/membershipDefinitions.d.ts.map +1 -1
  12. package/dist/membershipDefinitions.js.map +1 -1
  13. package/dist/utils/index.d.ts.map +1 -1
  14. package/dist/utils/index.js +0 -1
  15. package/dist/utils/index.js.map +1 -1
  16. package/dist/utils/luxonUtils.d.ts.map +1 -1
  17. package/dist/utils/luxonUtils.js +1 -73
  18. package/dist/utils/luxonUtils.js.map +1 -1
  19. package/dist/utils/service/serviceDBUtils.d.ts +2 -0
  20. package/dist/utils/service/serviceDBUtils.d.ts.map +1 -1
  21. package/dist/utils/service/serviceDBUtils.js +2 -41
  22. package/dist/utils/service/serviceDBUtils.js.map +1 -1
  23. package/package.json +1 -1
  24. package/prisma/migrations/add_bash_availability.sql +53 -0
  25. package/prisma/migrations/add_groups_and_momentum.sql +135 -0
  26. package/prisma/migrations/add_groups_momentum_phase0_4.sql +200 -0
  27. package/prisma/migrations/add_new_feature_tables.sql +140 -0
  28. package/prisma/migrations/add_tier_privacy_and_fee_handling.sql +29 -0
  29. package/prisma/schema.prisma +242 -0
  30. package/src/definitions.ts +25 -73
  31. package/src/extendedSchemas.ts +2 -2
  32. package/src/index.ts +0 -1
  33. package/src/membershipDefinitions.ts +8 -14
  34. package/src/utils/index.ts +0 -1
  35. package/src/utils/luxonUtils.ts +1 -111
  36. package/src/utils/service/serviceDBUtils.ts +2 -41
  37. package/src/utils/service/serviceRateDBUtils.ts +0 -179
@@ -295,7 +295,7 @@ export function dateRangeDurationMatch(
295
295
  ) {
296
296
  return (
297
297
  Math.abs(
298
- lhs.end.diff(lhs.start).toMillis() - rhs.end.diff(rhs.end).toMillis()
298
+ lhs.end.diff(lhs.start).toMillis() - rhs.end.diff(rhs.start).toMillis()
299
299
  ) <=
300
300
  withinSeconds * 1000
301
301
  );
@@ -508,12 +508,6 @@ export function dateTimeGetOverlappingHoursCommonHelper(
508
508
  weekHours: LuxonDayOfWeekHours,
509
509
  inputInterval: Interval
510
510
  ): LuxonDateRange | null {
511
- console.log(
512
- `dateTimeGetOverlappingHoursCommonHelper weekHours: ${JSON.stringify(
513
- weekHours
514
- )}, inputInterval: ${JSON.stringify(inputInterval)}`
515
- );
516
-
517
511
  let commonInterval: Interval | null = null;
518
512
 
519
513
  // const inputIntervalNormalized = normalizeLuxonInterval(inputInterval);
@@ -533,12 +527,6 @@ export function dateTimeGetOverlappingHoursCommonHelper(
533
527
  inputInterval
534
528
  );
535
529
 
536
- console.log(
537
- `dateTimeGetOverlappingHoursCommonHelper dayIdx: ${dayIdx}, dailyIntervals: ${JSON.stringify(
538
- dailyIntervals
539
- )}`
540
- );
541
-
542
530
  if (dailyIntervals.length === 0) {
543
531
  // No overlap for this day, so no common interval is possible
544
532
  continue;
@@ -606,12 +594,6 @@ export function dateTimeGetOverlappingHoursContinuousHelper(
606
594
  weekHours: LuxonDayOfWeekHours,
607
595
  inputInterval: Interval
608
596
  ): LuxonDateRange[] | null {
609
- console.log(
610
- `dateTimeGetOverlappingHoursContinuousHelper weekHours: ${JSON.stringify(
611
- weekHours
612
- )}, inputRange: ${JSON.stringify(inputInterval)}`
613
- );
614
-
615
597
  if (!inputInterval.start) {
616
598
  return null;
617
599
  }
@@ -628,12 +610,6 @@ export function dateTimeGetOverlappingHoursContinuousHelper(
628
610
  inputInterval
629
611
  );
630
612
 
631
- console.log(
632
- `dateTimeGetOverlappingHoursContinuousHelper startDayIdx: ${startDayIdx}, overlappingIntervals: ${JSON.stringify(
633
- overlappingIntervals
634
- )}`
635
- );
636
-
637
613
  // Convert overlapping intervals back to LuxonDateRange[]
638
614
  return overlappingIntervals
639
615
  .filter((interval) => interval.start !== null && interval.end !== null)
@@ -718,92 +694,6 @@ export interface TimeSlots {
718
694
  end: string[];
719
695
  }
720
696
 
721
- // export function generateTimeSlots(
722
- // filteredHours: LuxonDateRange[],
723
- // bookedRange: LuxonDateRange,
724
- // businessHours: LuxonDayOfWeekHours
725
- // ): TimeSlots {
726
- // const timeSlotsStart: string[] = [];
727
- // let timeSlotsEnd: string[] = [];
728
-
729
- // let currentTime = bookedRange.start;
730
- // const endTime = bookedRange.end;
731
-
732
- // while (currentTime < endTime) {
733
- // const currentDayOfWeek = currentTime.weekday as DayOfWeekIdx;
734
- // const businessDayHours = businessHours[currentDayOfWeek]?.[0];
735
-
736
- // if (!businessDayHours) {
737
- // throw new Error("No business hours found for the current day.");
738
- // }
739
-
740
- // const { start: dayStart, end: dayEnd } = businessDayHours;
741
-
742
- // // Ensure the current time is within today's business hours
743
- // if (currentTime < dayStart) {
744
- // currentTime = dayStart;
745
- // }
746
-
747
- // // If adding 30 minutes exceeds today's boundary, jump to the next day's start
748
- // if (currentTime.plus({ minutes: 30 }) > dayEnd) {
749
- // const nextDayOfWeek = currentTime.plus({ days: 1 })
750
- // .weekday as DayOfWeekIdx;
751
- // const nextDayHours = businessHours[nextDayOfWeek]?.[0];
752
-
753
- // if (!nextDayHours) {
754
- // throw new Error("No business hours for the next day.");
755
- // }
756
-
757
- // currentTime = nextDayHours.start;
758
- // } else {
759
- // timeSlotsStart.push(dateTimeFormatTime(currentTime));
760
- // currentTime = currentTime.plus({ minutes: 30 });
761
- // }
762
- // }
763
-
764
- // // The last slot should match the end time, respecting endDayOfWeek business hours
765
- // const endDayOfWeek = bookedRange.end.weekday as DayOfWeekIdx;
766
- // const endDayHours = businessHours[endDayOfWeek]?.[0];
767
-
768
- // if (!endDayHours) {
769
- // throw new Error("No business hours for the final day.");
770
- // }
771
-
772
- // const finalEndTime =
773
- // bookedRange.end > endDayHours.end ? endDayHours.end : bookedRange.end;
774
- // timeSlotsEnd = [...timeSlotsStart.slice(1), dateTimeFormatTime(finalEndTime)];
775
-
776
- // return {
777
- // start: timeSlotsStart,
778
- // end: timeSlotsEnd,
779
- // } as TimeSlots;
780
- // }
781
-
782
- // export function generateTimeSlots(filteredHours: LuxonDateRange[]): TimeSlots {
783
- // const timeSlotsStart: string[] = [];
784
- // let timeSlotsEnd: string[] = [];
785
-
786
- // filteredHours.forEach(({ start, end }) => {
787
- // let currentTime = start;
788
-
789
- // while (currentTime < end) {
790
- // timeSlotsStart.push(dateTimeFormatTime(currentTime)); // Add the time in "HH:mm" format
791
- // currentTime = currentTime.plus({ minutes: 30 }); // Increment by 30 minutes
792
- // }
793
-
794
- // const finalTime =
795
- // currentTime.hour == 0 && currentTime.minute == 0
796
- // ? currentTime.set({ hour: 23, minute: 59 })
797
- // : currentTime;
798
- // timeSlotsEnd = [...timeSlotsStart, dateTimeFormatTime(finalTime)];
799
- // });
800
-
801
- // return {
802
- // start: timeSlotsStart,
803
- // end: timeSlotsEnd,
804
- // } as TimeSlots;
805
- // }
806
-
807
697
  export function generateTimeSlots(
808
698
  filteredHours: LuxonDateRange[],
809
699
  incMin: number = 15
@@ -1,53 +1,14 @@
1
1
  import { ServiceExt } from "../../extendedSchemas";
2
2
  import { DeepPartial } from "../typeUtils";
3
- // import {
4
- // specialRateConvertToDb,
5
- // generalRatesConvertRatesToDB,
6
- // specialRateConvertFromDb,
7
- // generalRatesConvertRatesFromDB,
8
- // } from "./serviceRateDBUtils";
9
3
 
4
+ /** Converts service data for DB write. Currently a pass-through; rate conversion was removed. */
10
5
  export function serviceToDb(
11
6
  service: DeepPartial<ServiceExt>
12
7
  ): DeepPartial<ServiceExt> {
13
- if (service.serviceRatesAssociation) {
14
- // service.serviceRatesAssociation.serviceSpecialRates =
15
- // service.serviceRatesAssociation.serviceSpecialRates?.map(
16
- // (
17
- // serviceSpecialRate: Partial<ServiceSpecialRatesExt>
18
- // ): ServiceSpecialRatesExt => {
19
- // return specialRateConvertToDb(
20
- // serviceSpecialRate
21
- // ) as ServiceSpecialRatesExt;
22
- // }
23
- // );
24
- // if (service.serviceRatesAssociation.serviceGeneralRates) {
25
- // service.serviceRatesAssociation.serviceGeneralRates =
26
- // generalRatesConvertRatesToDB(
27
- // service.serviceRatesAssociation.serviceGeneralRates
28
- // ) as ServiceRate;
29
- // }
30
- }
31
8
  return service;
32
9
  }
33
10
 
11
+ /** Converts service data from DB read. Currently a pass-through; rate conversion was removed. */
34
12
  export function serviceFromDb(service: ServiceExt): ServiceExt {
35
- if (service.serviceRatesAssociation) {
36
- // service.serviceRatesAssociation.serviceSpecialRates =
37
- // service.serviceRatesAssociation.serviceSpecialRates?.map(
38
- // (
39
- // serviceSpecialRate: ServiceSpecialRatesExt
40
- // ): ServiceSpecialRatesExt => {
41
- // return specialRateConvertFromDb(serviceSpecialRate);
42
- // }
43
- // );
44
- if (service.serviceRatesAssociation.serviceGeneralRates) {
45
- // console.log("updating general rates from db");
46
- // service.serviceRatesAssociation.serviceGeneralRates =
47
- // generalRatesConvertRatesFromDB(
48
- // service.serviceRatesAssociation.serviceGeneralRates
49
- // );
50
- }
51
- }
52
13
  return service;
53
14
  }
@@ -1,179 +0,0 @@
1
- // import { ServiceRate } from "@prisma/client";
2
- // import { ApiResult } from "../../definitions";
3
- // import { ServiceSpecialRatesExt } from "../../extendedSchemas";
4
- // import { convertDollarsToCents, convertCentsToDollars } from "../paymentUtils";
5
-
6
- // export function specialRateConvertToDb(
7
- // specialRate: Partial<ServiceSpecialRatesExt>
8
- // ): Partial<ServiceSpecialRatesExt> {
9
- // return specialRateConvertRatesToDB(
10
- // specialRateConvertDateStringsToDb(structuredClone(specialRate))
11
- // );
12
- // }
13
-
14
- // export function specialRateConvertFromDb(
15
- // specialRate: ServiceSpecialRatesExt
16
- // ): ServiceSpecialRatesExt {
17
- // // console.log(`specialRateConvertFromDb`);
18
- // return specialRateConvertRatesFromDB(
19
- // specialRateConvertDateStringsFromDb(specialRate)
20
- // );
21
- // }
22
-
23
- // function specialRateConvertDateStringsToDb(
24
- // specialRate: Partial<ServiceSpecialRatesExt>
25
- // ): Partial<ServiceSpecialRatesExt> {
26
- // // const oldStart = new Date(specialRate.startDate!);
27
- // // const oldEnd = new Date(specialRate.endDate!);
28
-
29
- // // specialRate.startDate = dateTimeLocalToUTCDate(specialRate.startDate!);
30
- // // specialRate.endDate = dateTimeLocalToUTCDate(specialRate.endDate!);
31
- // // specialRate.startDate = normalizeDate(specialRate.startDate!);
32
- // // specialRate.endDate = normalizeDate(specialRate.endDate!);
33
-
34
- // // const localStart = dateTimeLocalFromUTCDate(new Date(specialRate.startDate!));
35
- // // const localEnd = dateTimeLocalFromUTCDate(new Date(specialRate.endDate!));
36
-
37
- // // console.log(
38
- // // `specialRateConvertDateStringsToDb oldStart: ${oldStart?.toString()}`
39
- // // );
40
- // // console.log(
41
- // // `specialRateConvertDateStringsToDb oldEnd: ${oldEnd?.toString()}`
42
- // // );
43
- // // console.log(
44
- // // `specialRateConvertDateStringsToDb specialRate.startDate: ${specialRate.startDate?.toString()}`
45
- // // );
46
- // // console.log(
47
- // // `specialRateConvertDateStringsToDb specialRate.endDate: ${specialRate.endDate?.toString()}`
48
- // // );
49
- // // console.log(
50
- // // `specialRateConvertDateStringsToDb localStart: ${localStart?.toString()}`
51
- // // );
52
- // // console.log(
53
- // // `specialRateConvertDateStringsToDb localEnd: ${localEnd?.toString()}`
54
- // // );
55
-
56
- // // const a = 3 + 4;
57
-
58
- // // specialRate.startDate = specialRate.startDate.toISOString();
59
- // // specialRate.endDate = specialRate.endDate.toISOString();
60
- // // return specialRate;
61
- // return specialRate;
62
- // }
63
-
64
- // function specialRateConvertDateStringsFromDb(
65
- // specialRate: ServiceSpecialRatesExt
66
- // ): ServiceSpecialRatesExt {
67
- // // specialRate.startDate = localDateToUTC(new Date(specialRate.startDate));
68
- // // specialRate.endDate = localDateToUTC(new Date(specialRate.endDate));
69
-
70
- // //this shouldnt even be necessary as javascript dates are always stored in UTC timezone (they lack timezone information)
71
- // // specialRate.startDate = ensureDateTimeIsLocalDateTime(
72
- // // new Date(specialRate.startDate)
73
- // // ).toDate();
74
- // // specialRate.endDate = ensureDateTimeIsLocalDateTime(
75
- // // new Date(specialRate.endDate)
76
- // // ).toDate();
77
-
78
- // specialRate.startDate = new Date(specialRate.startDate);
79
- // specialRate.endDate = new Date(specialRate.endDate);
80
-
81
- // // const oldStart = new Date(specialRate.startDate!);
82
- // // const oldEnd = new Date(specialRate.endDate!);
83
-
84
- // // specialRate.startDate = dateTimeLocalFromUTCDate(
85
- // // new Date(specialRate.startDate)
86
- // // );
87
- // // specialRate.endDate = dateTimeLocalFromUTCDate(new Date(specialRate.endDate));
88
-
89
- // // // specialRate.startDate = ensureDateTimeIsLocalDateTime(
90
- // // // new Date(specialRate.startDate)
91
- // // // ).toDate();
92
- // // // specialRate.endDate = ensureDateTimeIsLocalDateTime(
93
- // // // new Date(specialRate.endDate)
94
- // // // ).toDate();
95
-
96
- // // // specialRate.startDate = localDateToUTC(new Date(specialRate.startDate));
97
- // // // specialRate.endDate = localDateToUTC(new Date(specialRate.endDate));
98
-
99
- // // const date2 = normalizeDate(specialRate.startDate)!;
100
- // // const date3 = normalizeDate(specialRate.endDate)!;
101
-
102
- // // const a = 3 + 4;
103
- // return specialRate;
104
- // }
105
-
106
- // function specialRateConvertRatesToDB(
107
- // specialRate: Partial<ServiceSpecialRatesExt>
108
- // ): Partial<ServiceSpecialRatesExt> {
109
- // if (specialRate.serviceRate) {
110
- // specialRate.serviceRate = generalRatesConvertRatesToDB(
111
- // specialRate.serviceRate
112
- // ) as ServiceRate;
113
- // }
114
- // return specialRate;
115
- // }
116
-
117
- // function specialRateConvertRatesFromDB(
118
- // specialRate: ServiceSpecialRatesExt
119
- // ): ServiceSpecialRatesExt {
120
- // if (specialRate.serviceRate) {
121
- // specialRate.serviceRate = generalRatesConvertRatesFromDB(
122
- // specialRate.serviceRate
123
- // );
124
- // }
125
- // return specialRate;
126
- // }
127
-
128
- // export function generalRatesConvertRatesToDB(
129
- // generalRate: ServiceRate
130
- // ): ServiceRate {
131
- // return generalRatesConvertRatesToDBHelper(structuredClone(generalRate));
132
- // }
133
-
134
- // export function generalRatesConvertRatesToDBHelper(
135
- // generalRate: ServiceRate
136
- // ): ServiceRate {
137
- // // console.log(
138
- // // `generalRatesConvertRatesToDBHelper A: ${JSON.stringify(generalRate)}`
139
- // // );
140
- // if (generalRate?.dailyRate) {
141
- // generalRate.dailyRate = convertDollarsToCents(generalRate.dailyRate);
142
- // }
143
- // if (generalRate?.hourlyRate) {
144
- // generalRate.hourlyRate = convertDollarsToCents(generalRate.hourlyRate);
145
- // }
146
- // if (generalRate?.cleaningFeePerBooking) {
147
- // generalRate.cleaningFeePerBooking = convertDollarsToCents(
148
- // generalRate.cleaningFeePerBooking
149
- // );
150
- // }
151
- // // console.log(
152
- // // `generalRatesConvertRatesToDBHelper B: ${JSON.stringify(generalRate)}`
153
- // // );
154
- // return generalRate;
155
- // }
156
-
157
- // export function generalRatesConvertRatesFromDB(
158
- // generalRate: ServiceRate
159
- // ): ServiceRate {
160
- // // console.log(
161
- // // `generalRatesConvertRatesFromDB A: ${JSON.stringify(generalRate)}`
162
- // // );
163
- // // console.log(`specialRateConvertRatesFromDB`);
164
- // if (generalRate?.dailyRate) {
165
- // generalRate.dailyRate = convertCentsToDollars(generalRate.dailyRate);
166
- // }
167
- // if (generalRate?.hourlyRate) {
168
- // generalRate.hourlyRate = convertCentsToDollars(generalRate.hourlyRate);
169
- // }
170
- // if (generalRate?.cleaningFeePerBooking) {
171
- // generalRate.cleaningFeePerBooking = convertCentsToDollars(
172
- // generalRate.cleaningFeePerBooking
173
- // );
174
- // }
175
- // // console.log(
176
- // // `generalRatesConvertRatesFromDB B: ${JSON.stringify(generalRate)}`
177
- // // );
178
- // return generalRate;
179
- // }