@bash-app/bash-common 30.465.0 → 30.467.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/extendedSchemas.d.ts +35 -0
- package/dist/extendedSchemas.d.ts.map +1 -1
- package/dist/extendedSchemas.js +3 -0
- package/dist/extendedSchemas.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/membershipDefinitions.js +2 -2
- package/dist/membershipDefinitions.js.map +1 -1
- package/dist/utils/__tests__/addressUtils.test.js +3 -0
- package/dist/utils/__tests__/addressUtils.test.js.map +1 -1
- package/dist/utils/__tests__/crowdSizeValidation.test.js +1 -1
- package/dist/utils/__tests__/crowdSizeValidation.test.js.map +1 -1
- package/dist/utils/__tests__/eventTaskVolunteerRewardUtils.test.js +6 -0
- package/dist/utils/__tests__/eventTaskVolunteerRewardUtils.test.js.map +1 -1
- package/dist/utils/__tests__/guestSurface.test.js +24 -0
- package/dist/utils/__tests__/guestSurface.test.js.map +1 -1
- package/dist/utils/addressUtils.d.ts.map +1 -1
- package/dist/utils/addressUtils.js +28 -10
- package/dist/utils/addressUtils.js.map +1 -1
- package/dist/utils/crowdSizeValidation.d.ts.map +1 -1
- package/dist/utils/crowdSizeValidation.js +10 -0
- package/dist/utils/crowdSizeValidation.js.map +1 -1
- package/dist/utils/eventTimezoneIana.d.ts.map +1 -1
- package/dist/utils/eventTimezoneIana.js +16 -5
- package/dist/utils/eventTimezoneIana.js.map +1 -1
- package/dist/utils/guestSurface.d.ts +3 -1
- package/dist/utils/guestSurface.d.ts.map +1 -1
- package/dist/utils/guestSurface.js +26 -1
- package/dist/utils/guestSurface.js.map +1 -1
- package/dist/utils/service/__tests__/vendorPaymentWays.test.d.ts +2 -0
- package/dist/utils/service/__tests__/vendorPaymentWays.test.d.ts.map +1 -0
- package/dist/utils/service/__tests__/vendorPaymentWays.test.js +61 -0
- package/dist/utils/service/__tests__/vendorPaymentWays.test.js.map +1 -0
- package/dist/utils/service/vendorPaymentWays.d.ts +83 -0
- package/dist/utils/service/vendorPaymentWays.d.ts.map +1 -0
- package/dist/utils/service/vendorPaymentWays.js +306 -0
- package/dist/utils/service/vendorPaymentWays.js.map +1 -0
- package/package.json +1 -1
- package/prisma/schema.prisma +97 -1
- package/src/extendedSchemas.ts +3 -0
- package/src/index.ts +1 -0
- package/src/membershipDefinitions.ts +2 -2
- package/src/utils/__tests__/addressUtils.test.ts +6 -0
- package/src/utils/__tests__/crowdSizeValidation.test.ts +1 -1
- package/src/utils/__tests__/eventTaskVolunteerRewardUtils.test.ts +8 -0
- package/src/utils/__tests__/guestSurface.test.ts +29 -0
- package/src/utils/addressUtils.ts +26 -10
- package/src/utils/crowdSizeValidation.ts +14 -0
- package/src/utils/eventTimezoneIana.ts +22 -10
- package/src/utils/guestSurface.ts +33 -6
- package/src/utils/service/__tests__/vendorPaymentWays.test.ts +87 -0
- package/src/utils/service/vendorPaymentWays.ts +384 -0
|
@@ -39,12 +39,20 @@ describe("eventTaskVolunteerRewardUtils", () => {
|
|
|
39
39
|
{ id: "t2", neededCount: 1, bashPointsReward: 50 },
|
|
40
40
|
];
|
|
41
41
|
expect(totalEventTaskBashPointsOffer({ tasks })).toBe(70);
|
|
42
|
+
// 2 * 10 + 1 * 80 = 100. Matching the balance is allowed; one point over is not.
|
|
42
43
|
expect(
|
|
43
44
|
validateHostTaskBashPointsOffer({
|
|
44
45
|
hostBashPointsBalance: 100,
|
|
45
46
|
tasks,
|
|
46
47
|
patch: { taskId: "t2", bashPointsReward: 80 },
|
|
47
48
|
}).ok
|
|
49
|
+
).toBe(true);
|
|
50
|
+
expect(
|
|
51
|
+
validateHostTaskBashPointsOffer({
|
|
52
|
+
hostBashPointsBalance: 100,
|
|
53
|
+
tasks,
|
|
54
|
+
patch: { taskId: "t2", bashPointsReward: 81 },
|
|
55
|
+
}).ok
|
|
48
56
|
).toBe(false);
|
|
49
57
|
expect(
|
|
50
58
|
validateHostTaskBashPointsOffer({
|
|
@@ -50,6 +50,15 @@ describe("resolveEffectiveEventMode", () => {
|
|
|
50
50
|
resolveEffectiveEventMode({ attendeeDisplayMode: "CountOnly" })
|
|
51
51
|
).toBe("CountOnly");
|
|
52
52
|
});
|
|
53
|
+
|
|
54
|
+
it("honours Blurred ahead of the legacy show-attendees flag", () => {
|
|
55
|
+
expect(
|
|
56
|
+
resolveEffectiveEventMode({
|
|
57
|
+
attendeeDisplayMode: "Blurred",
|
|
58
|
+
showAttendees: true,
|
|
59
|
+
})
|
|
60
|
+
).toBe("Blurred");
|
|
61
|
+
});
|
|
53
62
|
});
|
|
54
63
|
|
|
55
64
|
describe("resolveGuestSurfacePolicy", () => {
|
|
@@ -64,6 +73,21 @@ describe("resolveGuestSurfacePolicy", () => {
|
|
|
64
73
|
expect(policy.showPreviewAvatars).toBe(false);
|
|
65
74
|
});
|
|
66
75
|
|
|
76
|
+
it("Blurred shows faces without a headcount or roster for guests", () => {
|
|
77
|
+
const policy = resolveGuestSurfacePolicy({
|
|
78
|
+
eventMode: "Blurred",
|
|
79
|
+
isHost: false,
|
|
80
|
+
isAuthenticated: true,
|
|
81
|
+
viewerRosterDepth: "Full",
|
|
82
|
+
});
|
|
83
|
+
expect(policy.showCount).toBe(false);
|
|
84
|
+
expect(policy.showPreviewAvatars).toBe(true);
|
|
85
|
+
expect(policy.showFeatured).toBe(false);
|
|
86
|
+
expect(policy.showNetworkSlice).toBe(false);
|
|
87
|
+
expect(policy.rosterDepth).toBe("None");
|
|
88
|
+
expect(policy.apiPreviewLimit).toBe(5);
|
|
89
|
+
});
|
|
90
|
+
|
|
67
91
|
it("CountOnly shows count but not avatars", () => {
|
|
68
92
|
const policy = resolveGuestSurfacePolicy({
|
|
69
93
|
eventMode: "CountOnly",
|
|
@@ -146,6 +170,11 @@ describe("capRosterDepthForEventMode", () => {
|
|
|
146
170
|
capRosterDepthForEventMode("Full", "NetworkOnly", false)
|
|
147
171
|
).toBe("None");
|
|
148
172
|
});
|
|
173
|
+
|
|
174
|
+
it("caps guests to None when faces are blurred", () => {
|
|
175
|
+
expect(capRosterDepthForEventMode("Full", "Blurred", false)).toBe("None");
|
|
176
|
+
expect(capRosterDepthForEventMode("Full", "Blurred", true)).toBe("Full");
|
|
177
|
+
});
|
|
149
178
|
});
|
|
150
179
|
|
|
151
180
|
describe("filterHiddenVisibilityUserIds", () => {
|
|
@@ -111,6 +111,24 @@ export function databaseAddressStringToAddressValues(addressString: string | und
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
|
|
114
|
+
/** Drop repeated place names ("Salt Lake City, Salt Lake City, UT"). */
|
|
115
|
+
function uniqueAddressParts(parts: Array<string | null | undefined>): string[] {
|
|
116
|
+
const out: string[] = [];
|
|
117
|
+
const seen = new Set<string>();
|
|
118
|
+
for (const part of parts) {
|
|
119
|
+
if (!part) continue;
|
|
120
|
+
for (const segment of part.split(",")) {
|
|
121
|
+
const trimmed = segment.trim();
|
|
122
|
+
if (!trimmed || trimmed === "undefined") continue;
|
|
123
|
+
const key = trimmed.toLowerCase();
|
|
124
|
+
if (seen.has(key)) continue;
|
|
125
|
+
seen.add(key);
|
|
126
|
+
out.push(trimmed);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
131
|
+
|
|
114
132
|
/**
|
|
115
133
|
* City, state/region, and country for compact card/list UIs (no street or full formatted address).
|
|
116
134
|
* Detail pages should use {@link databaseAddressStringToOneLineString} or full address fields.
|
|
@@ -120,10 +138,7 @@ export function formatLocalityForCardDisplay(
|
|
|
120
138
|
state?: string | null,
|
|
121
139
|
country?: string | null
|
|
122
140
|
): string {
|
|
123
|
-
|
|
124
|
-
(p): p is string => !!p && p.length > 0
|
|
125
|
-
);
|
|
126
|
-
return parts.join(", ");
|
|
141
|
+
return uniqueAddressParts([city, state, country]).join(", ");
|
|
127
142
|
}
|
|
128
143
|
|
|
129
144
|
export function databaseAddressStringToOneLineString(addressString: string | undefined | null): string {
|
|
@@ -142,13 +157,14 @@ export function databaseAddressStringToOneLineString(addressString: string | und
|
|
|
142
157
|
return address.place.trim();
|
|
143
158
|
}
|
|
144
159
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
160
|
+
const addressArr = uniqueAddressParts([
|
|
161
|
+
address.place,
|
|
162
|
+
address.street,
|
|
163
|
+
address.city,
|
|
164
|
+
address.state,
|
|
165
|
+
]);
|
|
150
166
|
|
|
151
|
-
const addressStr = addressArr.
|
|
167
|
+
const addressStr = addressArr.join(', ');
|
|
152
168
|
|
|
153
169
|
return address.zipCode && address.zipCode !== 'undefined'
|
|
154
170
|
? `${addressStr} ${address.zipCode}`
|
|
@@ -17,5 +17,19 @@ export function validateCrowdSize(values: CrowdSizeValues): string | null {
|
|
|
17
17
|
if (value != null && value > values.maximum) return `Maximum capacity cannot be lower than ${key} guests.`;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
+
if (
|
|
21
|
+
values.minimum != null &&
|
|
22
|
+
values.expected != null &&
|
|
23
|
+
values.minimum > values.expected
|
|
24
|
+
) {
|
|
25
|
+
return "Minimum guests cannot be higher than expected guests.";
|
|
26
|
+
}
|
|
27
|
+
if (
|
|
28
|
+
values.minimum != null &&
|
|
29
|
+
values.ideal != null &&
|
|
30
|
+
values.minimum > values.ideal
|
|
31
|
+
) {
|
|
32
|
+
return "Minimum guests cannot be higher than ideal guests.";
|
|
33
|
+
}
|
|
20
34
|
return null;
|
|
21
35
|
}
|
|
@@ -338,6 +338,7 @@ function eventHasLocationHint(args: InferEventTimezoneArgs): boolean {
|
|
|
338
338
|
return !!(
|
|
339
339
|
args.location?.trim() ||
|
|
340
340
|
args.city?.trim() ||
|
|
341
|
+
args.state?.trim() ||
|
|
341
342
|
(args.latitude != null && args.longitude != null)
|
|
342
343
|
);
|
|
343
344
|
}
|
|
@@ -384,17 +385,28 @@ export function formatEventTimezoneAbbrev(
|
|
|
384
385
|
const zoned = dt.setZone(zone);
|
|
385
386
|
if (!zoned.isValid) return "";
|
|
386
387
|
|
|
387
|
-
|
|
388
|
-
|
|
388
|
+
// Luxon 3: "z" is the IANA id. "ZZZZ" is the short name (EST, MDT).
|
|
389
|
+
const named = zoned.toFormat("ZZZZ");
|
|
390
|
+
if (isShortZoneLabel(named, zone)) return named;
|
|
389
391
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
);
|
|
392
|
+
const fromIntl = new Intl.DateTimeFormat("en-US", {
|
|
393
|
+
timeZone: zone,
|
|
394
|
+
timeZoneName: "short",
|
|
395
|
+
})
|
|
396
|
+
.formatToParts(zoned.toJSDate())
|
|
397
|
+
.find((part) => part.type === "timeZoneName")?.value;
|
|
398
|
+
|
|
399
|
+
if (isShortZoneLabel(fromIntl, zone)) return fromIntl;
|
|
400
|
+
return "";
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function isShortZoneLabel(
|
|
404
|
+
label: string | null | undefined,
|
|
405
|
+
zone: string
|
|
406
|
+
): label is string {
|
|
407
|
+
if (!label || label === "GMT" || label.includes("/")) return false;
|
|
408
|
+
// "z" used to return the IANA id. Keep that out of the UI, but UTC is a real label.
|
|
409
|
+
return label !== zone || zone === "UTC";
|
|
398
410
|
}
|
|
399
411
|
|
|
400
412
|
/** Curated list for the event wizard timezone picker (full IANA set is huge). */
|
|
@@ -5,11 +5,24 @@
|
|
|
5
5
|
|
|
6
6
|
import type { PublicTeaserUser } from "../extendedSchemas.js";
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
export const ATTENDEE_DISPLAY_MODES = [
|
|
9
|
+
"All",
|
|
10
|
+
"CountOnly",
|
|
11
|
+
"NetworkOnly",
|
|
12
|
+
"Blurred",
|
|
13
|
+
"Hidden",
|
|
14
|
+
] as const;
|
|
15
|
+
|
|
16
|
+
export type AttendeeDisplayMode = (typeof ATTENDEE_DISPLAY_MODES)[number];
|
|
17
|
+
|
|
18
|
+
export function isAttendeeDisplayMode(
|
|
19
|
+
value: unknown
|
|
20
|
+
): value is AttendeeDisplayMode {
|
|
21
|
+
return (
|
|
22
|
+
typeof value === "string" &&
|
|
23
|
+
(ATTENDEE_DISPLAY_MODES as readonly string[]).includes(value)
|
|
24
|
+
);
|
|
25
|
+
}
|
|
13
26
|
|
|
14
27
|
/** Public competition roster on bash detail (subset of attendee modes). */
|
|
15
28
|
export type ParticipantDisplayMode = "All" | "Hidden";
|
|
@@ -158,6 +171,7 @@ export function resolveEffectiveEventMode(
|
|
|
158
171
|
const raw = event.attendeeDisplayMode;
|
|
159
172
|
if (raw === "CountOnly") return "CountOnly";
|
|
160
173
|
if (raw === "NetworkOnly") return "NetworkOnly";
|
|
174
|
+
if (raw === "Blurred") return "Blurred";
|
|
161
175
|
if (raw === "Hidden") return "Hidden";
|
|
162
176
|
if (event.showAttendees === false) return "Hidden";
|
|
163
177
|
return "All";
|
|
@@ -186,7 +200,7 @@ export function capRosterDepthForEventMode(
|
|
|
186
200
|
isHost: boolean
|
|
187
201
|
): GuestListDepth {
|
|
188
202
|
if (isHost) return "Full";
|
|
189
|
-
if (eventMode === "Hidden") return "None";
|
|
203
|
+
if (eventMode === "Hidden" || eventMode === "Blurred") return "None";
|
|
190
204
|
if (eventMode === "NetworkOnly") return "None";
|
|
191
205
|
return viewerDepth;
|
|
192
206
|
}
|
|
@@ -211,6 +225,19 @@ export function resolveGuestSurfacePolicy(
|
|
|
211
225
|
isHost
|
|
212
226
|
);
|
|
213
227
|
|
|
228
|
+
if (eventMode === "Blurred" && !isHost) {
|
|
229
|
+
return {
|
|
230
|
+
showCount: false,
|
|
231
|
+
showPreviewAvatars: true,
|
|
232
|
+
showFeatured: false,
|
|
233
|
+
showNetworkSlice: false,
|
|
234
|
+
rosterDepth: "None",
|
|
235
|
+
previewLimit: 5,
|
|
236
|
+
apiPreviewLimit: 5,
|
|
237
|
+
effectiveMode: eventMode,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
214
241
|
if (eventMode === "Hidden" && !isHost) {
|
|
215
242
|
return {
|
|
216
243
|
showCount: false,
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { describe, expect, it } from "@jest/globals";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
computeSalesCut,
|
|
5
|
+
overlappingPaymentOptions,
|
|
6
|
+
snapshotFromBookingRequest,
|
|
7
|
+
vendorFitsHostPayment,
|
|
8
|
+
} from "../vendorPaymentWays.js";
|
|
9
|
+
|
|
10
|
+
const flat = { ways: ["flat"], amountCents: 20000 };
|
|
11
|
+
const percent = { ways: ["percentage"], percentage: 10 };
|
|
12
|
+
const both = { ways: ["flat", "percentage"], amountCents: 10000, percentage: 10 };
|
|
13
|
+
|
|
14
|
+
describe("vendor payment overlap", () => {
|
|
15
|
+
it("offers both flat and percent when the host accepts both", () => {
|
|
16
|
+
const overlap = overlappingPaymentOptions(
|
|
17
|
+
[flat, percent, both],
|
|
18
|
+
["flat", "percentage"]
|
|
19
|
+
);
|
|
20
|
+
expect(overlap).toEqual([flat, percent, both]);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("does not match a percent-only vendor to a flat-only bash", () => {
|
|
24
|
+
expect(vendorFitsHostPayment([percent], ["flat"])).toBe(false);
|
|
25
|
+
expect(overlappingPaymentOptions([percent], ["flat"])).toEqual([]);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("keeps today's requests when the host has not listed ways", () => {
|
|
29
|
+
expect(overlappingPaymentOptions([percent], [])).toBeNull();
|
|
30
|
+
expect(vendorFitsHostPayment([percent], [])).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("hides a booth-plus-percent option when the host only accepts a percent", () => {
|
|
34
|
+
expect(overlappingPaymentOptions([both, percent], ["percentage"])).toEqual([
|
|
35
|
+
percent,
|
|
36
|
+
]);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe("sales cut", () => {
|
|
41
|
+
it("takes 10 percent of $1,000", () => {
|
|
42
|
+
expect(
|
|
43
|
+
computeSalesCut({
|
|
44
|
+
confirmedSalesCents: 100_000,
|
|
45
|
+
percentage: 10,
|
|
46
|
+
boothFeeAlreadyPaidCents: 0,
|
|
47
|
+
})
|
|
48
|
+
).toEqual({ owedCents: 10_000, remainingCents: 10_000 });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("reduces what is still due by a booth fee already paid", () => {
|
|
52
|
+
expect(
|
|
53
|
+
computeSalesCut({
|
|
54
|
+
confirmedSalesCents: 100_000,
|
|
55
|
+
percentage: 10,
|
|
56
|
+
boothFeeAlreadyPaidCents: 4_000,
|
|
57
|
+
})
|
|
58
|
+
).toEqual({ owedCents: 10_000, remainingCents: 6_000 });
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("owes nothing on a $0 night", () => {
|
|
62
|
+
expect(
|
|
63
|
+
computeSalesCut({
|
|
64
|
+
confirmedSalesCents: 0,
|
|
65
|
+
percentage: 10,
|
|
66
|
+
boothFeeAlreadyPaidCents: 0,
|
|
67
|
+
})
|
|
68
|
+
).toEqual({ owedCents: 0, remainingCents: 0 });
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("does not charge before the host confirms", () => {
|
|
72
|
+
expect(
|
|
73
|
+
computeSalesCut({ confirmedSalesCents: null, percentage: 10 })
|
|
74
|
+
).toBeNull();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("keeps the percent from the booking after the listing changes", () => {
|
|
78
|
+
const booked = snapshotFromBookingRequest({
|
|
79
|
+
feeStructure: "percentage",
|
|
80
|
+
percentageRate: 10,
|
|
81
|
+
});
|
|
82
|
+
const listingPercentAfterward = 25;
|
|
83
|
+
expect(booked.paymentOptionPercentage).toBe(10);
|
|
84
|
+
expect(booked.paymentOptionBasis).toBe("ALL_SALES");
|
|
85
|
+
expect(booked.paymentOptionPercentage).not.toBe(listingPercentAfterward);
|
|
86
|
+
});
|
|
87
|
+
});
|