@bash-app/bash-common 30.450.0 → 30.452.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 (44) hide show
  1. package/dist/bashEventWizardSave.d.ts +38 -0
  2. package/dist/bashEventWizardSave.d.ts.map +1 -0
  3. package/dist/bashEventWizardSave.js +80 -0
  4. package/dist/bashEventWizardSave.js.map +1 -0
  5. package/dist/definitions.d.ts +2 -0
  6. package/dist/definitions.d.ts.map +1 -1
  7. package/dist/definitions.js.map +1 -1
  8. package/dist/extendedSchemas.d.ts +4 -0
  9. package/dist/extendedSchemas.d.ts.map +1 -1
  10. package/dist/extendedSchemas.js +4 -0
  11. package/dist/extendedSchemas.js.map +1 -1
  12. package/dist/hostCrmCrowdPulse.d.ts +5 -0
  13. package/dist/hostCrmCrowdPulse.d.ts.map +1 -1
  14. package/dist/hostCrmCrowdPulse.js.map +1 -1
  15. package/dist/index.d.ts +3 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +3 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/serviceWizardSave.d.ts +25 -0
  20. package/dist/serviceWizardSave.d.ts.map +1 -0
  21. package/dist/serviceWizardSave.js +105 -0
  22. package/dist/serviceWizardSave.js.map +1 -0
  23. package/dist/utils/__tests__/recurrenceUtils.dst.test.d.ts +2 -0
  24. package/dist/utils/__tests__/recurrenceUtils.dst.test.d.ts.map +1 -0
  25. package/dist/utils/__tests__/recurrenceUtils.dst.test.js +60 -0
  26. package/dist/utils/__tests__/recurrenceUtils.dst.test.js.map +1 -0
  27. package/dist/utils/eventTimezoneIana.d.ts +4 -0
  28. package/dist/utils/eventTimezoneIana.d.ts.map +1 -1
  29. package/dist/utils/eventTimezoneIana.js +21 -0
  30. package/dist/utils/eventTimezoneIana.js.map +1 -1
  31. package/dist/utils/recurrenceUtils.d.ts.map +1 -1
  32. package/dist/utils/recurrenceUtils.js +15 -3
  33. package/dist/utils/recurrenceUtils.js.map +1 -1
  34. package/package.json +1 -1
  35. package/prisma/schema.prisma +46 -0
  36. package/src/bashEventWizardSave.ts +126 -0
  37. package/src/definitions.ts +2 -0
  38. package/src/extendedSchemas.ts +4 -0
  39. package/src/hostCrmCrowdPulse.ts +5 -0
  40. package/src/index.ts +3 -0
  41. package/src/serviceWizardSave.ts +154 -0
  42. package/src/utils/__tests__/recurrenceUtils.dst.test.ts +94 -0
  43. package/src/utils/eventTimezoneIana.ts +25 -0
  44. package/src/utils/recurrenceUtils.ts +17 -5
@@ -0,0 +1,154 @@
1
+ import { ServiceCondition } from "@prisma/client";
2
+
3
+ import type { ServiceExt } from "./extendedSchemas.js";
4
+ import type { DeepPartial } from "./utils/typeUtils.js";
5
+ import { BASH_EVENT_PENDING_EDIT_TTL_MS } from "./bashEventWizardSave.js";
6
+
7
+ /** Draft / pending listings autosave; published profiles use explicit Save changes. */
8
+ export function serviceWizardUsesExplicitSave(
9
+ serviceCondition: ServiceCondition | null | undefined
10
+ ): boolean {
11
+ return serviceCondition === ServiceCondition.Published;
12
+ }
13
+
14
+ export type ServicePendingEditWire = {
15
+ serviceId: string;
16
+ userId: string;
17
+ baseVersion: number;
18
+ baseSnapshot: Record<string, unknown>;
19
+ changes: DeepPartial<ServiceExt>;
20
+ updatedAt: string;
21
+ createdAt: string;
22
+ };
23
+
24
+ export const SERVICE_PENDING_EDIT_SNAPSHOT_KEYS = [
25
+ "serviceName",
26
+ "tagline",
27
+ "description",
28
+ "place",
29
+ "googlePlaceId",
30
+ "street",
31
+ "city",
32
+ "state",
33
+ "zipCode",
34
+ "country",
35
+ "latitude",
36
+ "longitude",
37
+ "coverPhoto",
38
+ "backgroundImage",
39
+ "availableHours",
40
+ "mission",
41
+ "communityInvolvement",
42
+ "contactDetails",
43
+ "cancellationPolicy",
44
+ "allowsInstantBooking",
45
+ "showAvailabilityOnProfile",
46
+ "bookingIntent",
47
+ "visibility",
48
+ "serviceRatesAssociation",
49
+ "media",
50
+ "exhibitor",
51
+ "vendor",
52
+ "venue",
53
+ "sponsor",
54
+ "entertainmentService",
55
+ "eventService",
56
+ "organization",
57
+ "volunteerService",
58
+ ] as const;
59
+
60
+ type ServicePendingSnapshotKey = Extract<
61
+ (typeof SERVICE_PENDING_EDIT_SNAPSHOT_KEYS)[number],
62
+ keyof ServiceExt
63
+ >;
64
+
65
+ export function buildServicePendingBaseSnapshot(
66
+ service: ServiceExt
67
+ ): Record<string, unknown> {
68
+ const snap: Record<string, unknown> = {};
69
+ for (const key of SERVICE_PENDING_EDIT_SNAPSHOT_KEYS) {
70
+ if (key in service) {
71
+ snap[key] = service[key as ServicePendingSnapshotKey];
72
+ }
73
+ }
74
+ return snap;
75
+ }
76
+
77
+ export function countServicePendingTopLevelChanges(
78
+ changes: DeepPartial<ServiceExt>
79
+ ): number {
80
+ return Object.keys(changes).filter((k) => k !== "id" && k !== "ownerId")
81
+ .length;
82
+ }
83
+
84
+ export const SERVICE_HIGH_IMPACT_SAVE_KEYS = [
85
+ "serviceName",
86
+ "place",
87
+ "street",
88
+ "city",
89
+ "state",
90
+ "zipCode",
91
+ "country",
92
+ "latitude",
93
+ "longitude",
94
+ "availableHours",
95
+ "serviceRatesAssociation",
96
+ "cancellationPolicy",
97
+ ] as const;
98
+
99
+ export function servicePendingHasHighImpactChanges(
100
+ changes: DeepPartial<ServiceExt>
101
+ ): boolean {
102
+ return SERVICE_HIGH_IMPACT_SAVE_KEYS.some((key) => key in changes);
103
+ }
104
+
105
+ const SERVICE_HIGH_IMPACT_FIELD_LABELS: Record<
106
+ (typeof SERVICE_HIGH_IMPACT_SAVE_KEYS)[number],
107
+ string
108
+ > = {
109
+ serviceName: "Listing name",
110
+ place: "Location label",
111
+ street: "Street",
112
+ city: "City",
113
+ state: "State",
114
+ zipCode: "ZIP code",
115
+ country: "Country",
116
+ latitude: "Map latitude",
117
+ longitude: "Map longitude",
118
+ availableHours: "Hours",
119
+ serviceRatesAssociation: "Rates and pricing",
120
+ cancellationPolicy: "Cancellation policy",
121
+ };
122
+
123
+ /** High-impact Save confirm copy for published listing wizards. */
124
+ export function buildServiceHighImpactConfirmMessage(
125
+ committed: ServiceExt,
126
+ pending: DeepPartial<ServiceExt>
127
+ ): string {
128
+ const lines = SERVICE_HIGH_IMPACT_SAVE_KEYS.filter((key) => key in pending).map(
129
+ (key) => {
130
+ const label = SERVICE_HIGH_IMPACT_FIELD_LABELS[key];
131
+ const before =
132
+ key in committed
133
+ ? String(committed[key as keyof ServiceExt] ?? "—")
134
+ : "—";
135
+ const after = String(
136
+ (pending as Record<string, unknown>)[key] ?? "—"
137
+ );
138
+ return `${label}: ${before} → ${after}`;
139
+ }
140
+ );
141
+ return [
142
+ "These updates change what hosts and bookers see on your public listing.",
143
+ ...lines,
144
+ ].join("\n");
145
+ }
146
+
147
+ export function servicePendingEditLocalStorageKey(
148
+ serviceId: string,
149
+ userId: string
150
+ ): string {
151
+ return `servicePendingEdit:${serviceId}:${userId}`;
152
+ }
153
+
154
+ export { BASH_EVENT_PENDING_EDIT_TTL_MS as SERVICE_PENDING_EDIT_TTL_MS };
@@ -0,0 +1,94 @@
1
+ import { DateTime } from "luxon";
2
+ import {
3
+ DayOfWeek,
4
+ RecurrenceEndsType,
5
+ RecurringFrequency,
6
+ type Recurrence,
7
+ } from "@prisma/client";
8
+
9
+ import {
10
+ getRecurringBashEventPossibleLuxonTimes,
11
+ } from "../recurrenceUtils.js";
12
+
13
+ function buildWeeklyRecurrence(repeatOnDays: DayOfWeek[]): Recurrence {
14
+ return {
15
+ id: "rec-dst",
16
+ bashEventId: "evt-dst",
17
+ interval: 1,
18
+ frequency: RecurringFrequency.Weekly,
19
+ ends: null,
20
+ repeatCount: 0,
21
+ endsType: RecurrenceEndsType.NEVER,
22
+ repeatOnDays,
23
+ repeatOnDayOfMonth: null,
24
+ repeatYearlyDate: null,
25
+ createdAt: new Date(),
26
+ updatedAt: new Date(),
27
+ occurrenceOverrides: null,
28
+ excludedDates: [],
29
+ } as Recurrence;
30
+ }
31
+
32
+ describe("weekly recurrence wall clock in event timezone (DST)", () => {
33
+ const zone = "America/New_York";
34
+
35
+ it("keeps 7 PM local across US spring forward (March 2024)", () => {
36
+ // Thursday March 7, 2024 7:00 PM ET — before DST; series continues through spring forward.
37
+ const startLocal = DateTime.fromObject(
38
+ { year: 2024, month: 3, day: 7, hour: 19, minute: 0 },
39
+ { zone }
40
+ );
41
+ const startUtc = startLocal.toUTC().toJSDate();
42
+ const recurrence = buildWeeklyRecurrence([DayOfWeek.Thursday]);
43
+
44
+ const occ = getRecurringBashEventPossibleLuxonTimes(
45
+ startUtc,
46
+ recurrence,
47
+ zone
48
+ );
49
+
50
+ expect(occ.length).toBeGreaterThanOrEqual(4);
51
+
52
+ const aroundDst = occ.filter((dt) => {
53
+ const local = dt.setZone(zone);
54
+ return local.month === 3 && local.day >= 7 && local.day <= 28;
55
+ });
56
+
57
+ expect(aroundDst.length).toBeGreaterThanOrEqual(3);
58
+ for (const dt of aroundDst) {
59
+ const local = dt.setZone(zone);
60
+ expect(local.hour).toBe(19);
61
+ expect(local.minute).toBe(0);
62
+ }
63
+ });
64
+
65
+ it("keeps 7 PM local across US fall back (November 2024)", () => {
66
+ const startLocal = DateTime.fromObject(
67
+ { year: 2024, month: 10, day: 31, hour: 19, minute: 0 },
68
+ { zone }
69
+ );
70
+ const startUtc = startLocal.toUTC().toJSDate();
71
+ const recurrence = buildWeeklyRecurrence([DayOfWeek.Thursday]);
72
+
73
+ const occ = getRecurringBashEventPossibleLuxonTimes(
74
+ startUtc,
75
+ recurrence,
76
+ zone
77
+ );
78
+
79
+ const aroundFallback = occ.filter((dt) => {
80
+ const local = dt.setZone(zone);
81
+ return (
82
+ (local.month === 10 && local.day >= 31) ||
83
+ (local.month === 11 && local.day <= 14)
84
+ );
85
+ });
86
+
87
+ expect(aroundFallback.length).toBeGreaterThanOrEqual(2);
88
+ for (const dt of aroundFallback) {
89
+ const local = dt.setZone(zone);
90
+ expect(local.hour).toBe(19);
91
+ expect(local.minute).toBe(0);
92
+ }
93
+ });
94
+ });
@@ -440,3 +440,28 @@ export function resolveEventTimezoneIanaForDisplay(
440
440
 
441
441
  return "UTC";
442
442
  }
443
+
444
+ /**
445
+ * Formats a bash start time in the event zone with a short zone label (e.g. ET).
446
+ */
447
+ export function formatBashEventWhenLabel(
448
+ startDateTime: string | Date | null | undefined,
449
+ args: ResolveEventTimezoneForDisplayArgs
450
+ ): string {
451
+ if (startDateTime == null) return "Date TBD";
452
+ const parsed =
453
+ startDateTime instanceof Date ? startDateTime : new Date(startDateTime);
454
+ if (Number.isNaN(parsed.getTime())) return "Date TBD";
455
+
456
+ const zone = resolveEventTimezoneIanaForDisplay(args);
457
+ const time = new Intl.DateTimeFormat("en-US", {
458
+ timeZone: zone,
459
+ weekday: "short",
460
+ month: "short",
461
+ day: "numeric",
462
+ hour: "numeric",
463
+ minute: "2-digit",
464
+ }).format(parsed);
465
+ const abbrev = formatEventTimezoneAbbrev(zone, parsed);
466
+ return abbrev ? `${time} ${abbrev}` : time;
467
+ }
@@ -146,15 +146,24 @@ function getRecurringBashEventPossibleDatesTimesInternal(
146
146
 
147
147
  // For Monthly and Yearly, start from the event's actual date, not "today"
148
148
  // This ensures we generate dates relative to the event's schedule
149
- const shouldUseEventDate =
150
- recurrence.frequency === RecurringFrequency.Monthly ||
151
- recurrence.frequency === RecurringFrequency.Yearly;
149
+ const shouldUseEventDate =
150
+ recurrence.frequency === RecurringFrequency.Monthly ||
151
+ recurrence.frequency === RecurringFrequency.Yearly ||
152
+ (Boolean(timezone) && Boolean(startDateTime));
152
153
 
153
154
  const unzonedBeginningDate = shouldUseEventDate
154
- ? (startDateTime ? dateTimeFromDate(startDateTime) as DateTime : DateTime.local())
155
+ ? (startDateTime
156
+ ? timezone
157
+ ? (dateTimeFromDate(startDateTime, timezone) as DateTime)
158
+ : (dateTimeFromDate(startDateTime) as DateTime)
159
+ : DateTime.local())
155
160
  : findEarliestPossibleBashEventDate(startDateTime) as DateTime;
156
161
 
157
- const beginningDate = timezone ? unzonedBeginningDate.setZone(timezone) : unzonedBeginningDate;
162
+ const beginningDate = timezone
163
+ ? shouldUseEventDate
164
+ ? unzonedBeginningDate
165
+ : unzonedBeginningDate.setZone(timezone)
166
+ : unzonedBeginningDate;
158
167
 
159
168
  switch (recurrence.frequency) {
160
169
  case RecurringFrequency.Daily:
@@ -320,6 +329,9 @@ function getWeeklyRecurringDates(
320
329
  }
321
330
  // Set the time on the date so that it matches the time when the event starts
322
331
  weekday = dateTimeSetTime(weekday, beginningDateTime);
332
+ if (beginningDateTime.zoneName) {
333
+ weekday = weekday.setZone(beginningDateTime.zoneName);
334
+ }
323
335
  recurrenceDates.push(weekday);
324
336
  }
325
337
  if (weekday) {