@bash-app/bash-common 30.450.0 → 30.451.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/dist/bashEventWizardSave.d.ts +38 -0
- package/dist/bashEventWizardSave.d.ts.map +1 -0
- package/dist/bashEventWizardSave.js +80 -0
- package/dist/bashEventWizardSave.js.map +1 -0
- package/dist/definitions.d.ts +2 -0
- package/dist/definitions.d.ts.map +1 -1
- package/dist/definitions.js.map +1 -1
- package/dist/extendedSchemas.d.ts +4 -0
- package/dist/extendedSchemas.d.ts.map +1 -1
- package/dist/extendedSchemas.js +4 -0
- package/dist/extendedSchemas.js.map +1 -1
- package/dist/hostCrmCrowdPulse.d.ts +5 -0
- package/dist/hostCrmCrowdPulse.d.ts.map +1 -1
- package/dist/hostCrmCrowdPulse.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/serviceWizardSave.d.ts +23 -0
- package/dist/serviceWizardSave.d.ts.map +1 -0
- package/dist/serviceWizardSave.js +68 -0
- package/dist/serviceWizardSave.js.map +1 -0
- package/dist/utils/__tests__/recurrenceUtils.dst.test.d.ts +2 -0
- package/dist/utils/__tests__/recurrenceUtils.dst.test.d.ts.map +1 -0
- package/dist/utils/__tests__/recurrenceUtils.dst.test.js +60 -0
- package/dist/utils/__tests__/recurrenceUtils.dst.test.js.map +1 -0
- package/dist/utils/eventTimezoneIana.d.ts +4 -0
- package/dist/utils/eventTimezoneIana.d.ts.map +1 -1
- package/dist/utils/eventTimezoneIana.js +21 -0
- package/dist/utils/eventTimezoneIana.js.map +1 -1
- package/dist/utils/recurrenceUtils.d.ts.map +1 -1
- package/dist/utils/recurrenceUtils.js +15 -3
- package/dist/utils/recurrenceUtils.js.map +1 -1
- package/package.json +1 -1
- package/prisma/schema.prisma +46 -0
- package/src/bashEventWizardSave.ts +126 -0
- package/src/definitions.ts +2 -0
- package/src/extendedSchemas.ts +4 -0
- package/src/hostCrmCrowdPulse.ts +5 -0
- package/src/index.ts +3 -0
- package/src/serviceWizardSave.ts +104 -0
- package/src/utils/__tests__/recurrenceUtils.dst.test.ts +94 -0
- package/src/utils/eventTimezoneIana.ts +25 -0
- package/src/utils/recurrenceUtils.ts +17 -5
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
] as const;
|
|
51
|
+
|
|
52
|
+
type ServicePendingSnapshotKey = Extract<
|
|
53
|
+
(typeof SERVICE_PENDING_EDIT_SNAPSHOT_KEYS)[number],
|
|
54
|
+
keyof ServiceExt
|
|
55
|
+
>;
|
|
56
|
+
|
|
57
|
+
export function buildServicePendingBaseSnapshot(
|
|
58
|
+
service: ServiceExt
|
|
59
|
+
): Record<string, unknown> {
|
|
60
|
+
const snap: Record<string, unknown> = {};
|
|
61
|
+
for (const key of SERVICE_PENDING_EDIT_SNAPSHOT_KEYS) {
|
|
62
|
+
if (key in service) {
|
|
63
|
+
snap[key] = service[key as ServicePendingSnapshotKey];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return snap;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function countServicePendingTopLevelChanges(
|
|
70
|
+
changes: DeepPartial<ServiceExt>
|
|
71
|
+
): number {
|
|
72
|
+
return Object.keys(changes).filter((k) => k !== "id" && k !== "ownerId")
|
|
73
|
+
.length;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const SERVICE_HIGH_IMPACT_SAVE_KEYS = [
|
|
77
|
+
"serviceName",
|
|
78
|
+
"place",
|
|
79
|
+
"street",
|
|
80
|
+
"city",
|
|
81
|
+
"state",
|
|
82
|
+
"zipCode",
|
|
83
|
+
"country",
|
|
84
|
+
"latitude",
|
|
85
|
+
"longitude",
|
|
86
|
+
"availableHours",
|
|
87
|
+
"serviceRatesAssociation",
|
|
88
|
+
"cancellationPolicy",
|
|
89
|
+
] as const;
|
|
90
|
+
|
|
91
|
+
export function servicePendingHasHighImpactChanges(
|
|
92
|
+
changes: DeepPartial<ServiceExt>
|
|
93
|
+
): boolean {
|
|
94
|
+
return SERVICE_HIGH_IMPACT_SAVE_KEYS.some((key) => key in changes);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function servicePendingEditLocalStorageKey(
|
|
98
|
+
serviceId: string,
|
|
99
|
+
userId: string
|
|
100
|
+
): string {
|
|
101
|
+
return `servicePendingEdit:${serviceId}:${userId}`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
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
|
|
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
|
|
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) {
|