@bash-app/bash-common 30.455.0 → 30.461.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 (67) hide show
  1. package/dist/__tests__/fundingMeter.test.js +4 -0
  2. package/dist/__tests__/fundingMeter.test.js.map +1 -1
  3. package/dist/definitions.d.ts +2 -0
  4. package/dist/definitions.d.ts.map +1 -1
  5. package/dist/definitions.js +2 -0
  6. package/dist/definitions.js.map +1 -1
  7. package/dist/feeDisplayCopy.d.ts +10 -0
  8. package/dist/feeDisplayCopy.d.ts.map +1 -0
  9. package/dist/feeDisplayCopy.js +10 -0
  10. package/dist/feeDisplayCopy.js.map +1 -0
  11. package/dist/fundingMeter.d.ts +4 -0
  12. package/dist/fundingMeter.d.ts.map +1 -1
  13. package/dist/fundingMeter.js +3 -0
  14. package/dist/fundingMeter.js.map +1 -1
  15. package/dist/index.d.ts +4 -0
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +4 -0
  18. package/dist/index.js.map +1 -1
  19. package/dist/utils/__tests__/listingContactValidation.test.d.ts +2 -0
  20. package/dist/utils/__tests__/listingContactValidation.test.d.ts.map +1 -0
  21. package/dist/utils/__tests__/listingContactValidation.test.js +25 -0
  22. package/dist/utils/__tests__/listingContactValidation.test.js.map +1 -0
  23. package/dist/utils/__tests__/p2pPaymentValidation.test.d.ts +2 -0
  24. package/dist/utils/__tests__/p2pPaymentValidation.test.d.ts.map +1 -0
  25. package/dist/utils/__tests__/p2pPaymentValidation.test.js +28 -0
  26. package/dist/utils/__tests__/p2pPaymentValidation.test.js.map +1 -0
  27. package/dist/utils/__tests__/richTextContent.test.d.ts +2 -0
  28. package/dist/utils/__tests__/richTextContent.test.d.ts.map +1 -0
  29. package/dist/utils/__tests__/richTextContent.test.js +14 -0
  30. package/dist/utils/__tests__/richTextContent.test.js.map +1 -0
  31. package/dist/utils/__tests__/ticketTierSchedule.test.js +5 -0
  32. package/dist/utils/__tests__/ticketTierSchedule.test.js.map +1 -1
  33. package/dist/utils/listingContactValidation.d.ts +4 -0
  34. package/dist/utils/listingContactValidation.d.ts.map +1 -0
  35. package/dist/utils/listingContactValidation.js +22 -0
  36. package/dist/utils/listingContactValidation.js.map +1 -0
  37. package/dist/utils/p2pPaymentValidation.d.ts +11 -0
  38. package/dist/utils/p2pPaymentValidation.d.ts.map +1 -0
  39. package/dist/utils/p2pPaymentValidation.js +69 -0
  40. package/dist/utils/p2pPaymentValidation.js.map +1 -0
  41. package/dist/utils/richTextContent.d.ts +3 -0
  42. package/dist/utils/richTextContent.d.ts.map +1 -0
  43. package/dist/utils/richTextContent.js +16 -0
  44. package/dist/utils/richTextContent.js.map +1 -0
  45. package/dist/utils/service/frontendServiceBookingUtils.d.ts.map +1 -1
  46. package/dist/utils/service/frontendServiceBookingUtils.js +3 -2
  47. package/dist/utils/service/frontendServiceBookingUtils.js.map +1 -1
  48. package/dist/utils/ticketTierSchedule.d.ts +2 -0
  49. package/dist/utils/ticketTierSchedule.d.ts.map +1 -1
  50. package/dist/utils/ticketTierSchedule.js +12 -1
  51. package/dist/utils/ticketTierSchedule.js.map +1 -1
  52. package/package.json +1 -1
  53. package/prisma/schema.prisma +3 -3
  54. package/src/__tests__/fundingMeter.test.ts +4 -0
  55. package/src/definitions.ts +2 -0
  56. package/src/feeDisplayCopy.ts +15 -0
  57. package/src/fundingMeter.ts +7 -0
  58. package/src/index.ts +4 -0
  59. package/src/utils/__tests__/listingContactValidation.test.ts +32 -0
  60. package/src/utils/__tests__/p2pPaymentValidation.test.ts +40 -0
  61. package/src/utils/__tests__/richTextContent.test.ts +17 -0
  62. package/src/utils/__tests__/ticketTierSchedule.test.ts +9 -0
  63. package/src/utils/listingContactValidation.ts +22 -0
  64. package/src/utils/p2pPaymentValidation.ts +82 -0
  65. package/src/utils/richTextContent.ts +14 -0
  66. package/src/utils/service/frontendServiceBookingUtils.ts +6 -2
  67. package/src/utils/ticketTierSchedule.ts +16 -1
@@ -432,6 +432,8 @@ export function isUnpaidPayAtDoorTicket(ticket: {
432
432
  }
433
433
 
434
434
  export const URL_PARAMS_BASH_EVENT_ID = "bashEventId" as const;
435
+ /** Wizard + public headline cap (matches WhatTitle / Quick Bash inputs). */
436
+ export const BASH_EVENT_PUBLIC_HEADLINE_MAX_LENGTH = 100 as const;
435
437
  export const URL_PARAMS_BASH_EVENT_TITLE = "bashEventTitle" as const;
436
438
  export const URL_PARAMS_BASH_EVENT_DESC = "bashEventDesc" as const;
437
439
  export const URL_PARAMS_BASH_EVENT_COVER_PHOTO = "bashEventCoverPhoto" as const;
@@ -0,0 +1,15 @@
1
+ /** Buyer-facing fee line labels — keep checkout, donations, and booking summaries aligned. */
2
+
3
+ /** Bash platform take on tickets/bookings (currently $0). */
4
+ export const BASH_SERVICE_FEE_LABEL = "Bash service fee";
5
+
6
+ export const BASH_SERVICE_FEE_NOTE = "0% intro rate for early users.";
7
+
8
+ /** Stripe pass-through on card payments (tickets, donations, bookings). */
9
+ export const PAYMENT_PROCESSING_LABEL = "Payment processing";
10
+
11
+ /** Donation checkout uses the same wording with “fee” suffix. */
12
+ export const PAYMENT_PROCESSING_FEE_LABEL = "Payment processing fee";
13
+
14
+ export const STRIPE_PROCESSING_FEE_NOTE =
15
+ "Stripe card processing (2.9% + $0.30).";
@@ -39,6 +39,10 @@ export type FundingMeterProgress = {
39
39
  hostStripeConnected: boolean;
40
40
  goalCents: number;
41
41
  collectedCents: number;
42
+ /** Budget-line Stripe / host-entered gifts (excludes partner pitch totals). */
43
+ budgetCollectedCents: number;
44
+ /** Paid vendor / exhibitor / sponsor pitches included in collectedCents. */
45
+ partnerCollectedCents: number;
42
46
  pledgedCents: number;
43
47
  unallocatedCents: number;
44
48
  percentFunded: number;
@@ -199,6 +203,7 @@ export function computeFundingMeterProgress(input: {
199
203
  });
200
204
 
201
205
  const partnerCollected = input.partnerCollectedCents ?? 0;
206
+ const budgetCollectedCents = collectedCents;
202
207
  if (partnerCollected > 0) {
203
208
  collectedCents += partnerCollected;
204
209
  }
@@ -213,6 +218,8 @@ export function computeFundingMeterProgress(input: {
213
218
  hostStripeConnected: input.hostStripeConnected,
214
219
  goalCents,
215
220
  collectedCents,
221
+ budgetCollectedCents,
222
+ partnerCollectedCents: partnerCollected,
216
223
  pledgedCents,
217
224
  unallocatedCents,
218
225
  percentFunded,
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./definitions.js";
2
2
  export * from "./fundingMeter.js";
3
+ export * from "./feeDisplayCopy.js";
3
4
  export * from "./budgetApproval.js";
4
5
  export * from "./giveaway.js";
5
6
  export * from "./requestAuthUser.js";
@@ -504,3 +505,6 @@ export * from "./utils/ticketTierValidation.js";
504
505
  export * from "./utils/organizationMembershipValidation";
505
506
  export * from "./utils/crowdSizeValidation.js";
506
507
  export * from "./utils/webLinkValidation.js";
508
+ export * from "./utils/listingContactValidation.js";
509
+ export * from "./utils/p2pPaymentValidation.js";
510
+ export * from "./utils/richTextContent.js";
@@ -0,0 +1,32 @@
1
+ import {
2
+ isValidListingPhone,
3
+ validateOptionalListingPhone,
4
+ } from "../listingContactValidation.js";
5
+
6
+ describe("isValidListingPhone", () => {
7
+ it("accepts empty optional phone", () => {
8
+ expect(isValidListingPhone("")).toBe(true);
9
+ expect(isValidListingPhone(" ")).toBe(true);
10
+ });
11
+
12
+ it("accepts common formatted numbers", () => {
13
+ expect(isValidListingPhone("(212) 555-0100")).toBe(true);
14
+ expect(isValidListingPhone("+1 212-555-0100")).toBe(true);
15
+ });
16
+
17
+ it("rejects too few digits or invalid characters", () => {
18
+ expect(isValidListingPhone("555-0100")).toBe(false);
19
+ expect(isValidListingPhone("call me")).toBe(false);
20
+ });
21
+ });
22
+
23
+ describe("validateOptionalListingPhone", () => {
24
+ it("accepts empty values", () => {
25
+ expect(validateOptionalListingPhone(null)).toBeNull();
26
+ expect(validateOptionalListingPhone("")).toBeNull();
27
+ });
28
+
29
+ it("returns a message for invalid phones", () => {
30
+ expect(validateOptionalListingPhone("abc")).toContain("10–15");
31
+ });
32
+ });
@@ -0,0 +1,40 @@
1
+ import {
2
+ validateP2PPaymentFields,
3
+ validateVenmoUsername,
4
+ validateZelleEmail,
5
+ validateZellePhone,
6
+ } from "../p2pPaymentValidation.js";
7
+
8
+ describe("validateVenmoUsername", () => {
9
+ it("accepts empty optional venmo", () => {
10
+ expect(validateVenmoUsername("")).toBeNull();
11
+ });
12
+
13
+ it("accepts a normal handle", () => {
14
+ expect(validateVenmoUsername("host_name")).toBeNull();
15
+ });
16
+
17
+ it("rejects invalid characters", () => {
18
+ expect(validateVenmoUsername("<script>")).toContain("Venmo");
19
+ });
20
+ });
21
+
22
+ describe("validateZelleEmail", () => {
23
+ it("rejects malformed email", () => {
24
+ expect(validateZelleEmail("not-an-email")).toContain("Zelle email");
25
+ });
26
+ });
27
+
28
+ describe("validateZellePhone", () => {
29
+ it("rejects too-short phone", () => {
30
+ expect(validateZellePhone("123")).toContain("Zelle phone");
31
+ });
32
+ });
33
+
34
+ describe("validateP2PPaymentFields", () => {
35
+ it("requires venmo when method is venmo", () => {
36
+ expect(
37
+ validateP2PPaymentFields({ method: "venmo", venmoUsername: "" })
38
+ ).toContain("Venmo");
39
+ });
40
+ });
@@ -0,0 +1,17 @@
1
+ import { richTextHasVisibleContent } from "../richTextContent.js";
2
+
3
+ describe("richTextHasVisibleContent", () => {
4
+ it("rejects empty and whitespace HTML", () => {
5
+ expect(richTextHasVisibleContent(null)).toBe(false);
6
+ expect(richTextHasVisibleContent("")).toBe(false);
7
+ expect(richTextHasVisibleContent("<p></p>")).toBe(false);
8
+ expect(richTextHasVisibleContent("<p>&nbsp;</p>")).toBe(false);
9
+ });
10
+
11
+ it("accepts visible text or images", () => {
12
+ expect(richTextHasVisibleContent("<p>Hello</p>")).toBe(true);
13
+ expect(richTextHasVisibleContent('<p><img src="x" alt="" /></p>')).toBe(
14
+ true
15
+ );
16
+ });
17
+ });
@@ -84,6 +84,15 @@ describe("resolveTicketTierScheduleState", () => {
84
84
  expect(state.showWaitlistCta).toBe(true);
85
85
  });
86
86
 
87
+ it("shows waitlist CTA when sold out and event waitlist is enabled", () => {
88
+ const state = resolveTicketTierScheduleState(
89
+ { availabilityType: "Immediate" },
90
+ { now, availableInventory: 0, eventWaitlistEnabled: true }
91
+ );
92
+ expect(state.phase).toBe("SoldOut");
93
+ expect(state.showWaitlistCta).toBe(true);
94
+ });
95
+
87
96
  it("blocks EngagedUsersOnly when viewer not engaged", () => {
88
97
  const state = resolveTicketTierScheduleState(
89
98
  { availabilityType: "EngagedUsersOnly" },
@@ -0,0 +1,22 @@
1
+ /** Listing wizard phone: optional empty, otherwise 10–15 digits with common separators. */
2
+ export function isValidListingPhone(phone: string): boolean {
3
+ const trimmed = phone.trim();
4
+ if (!trimmed) {
5
+ return true;
6
+ }
7
+ if (!/^[0-9\s-+()]*$/.test(trimmed)) {
8
+ return false;
9
+ }
10
+ const digits = trimmed.replace(/\D/g, "").length;
11
+ return digits >= 10 && digits <= 15;
12
+ }
13
+
14
+ export function validateOptionalListingPhone(value: unknown): string | null {
15
+ if (value == null || (typeof value === "string" && !value.trim())) {
16
+ return null;
17
+ }
18
+ if (typeof value !== "string" || !isValidListingPhone(value)) {
19
+ return "Enter a valid phone number (10–15 digits).";
20
+ }
21
+ return null;
22
+ }
@@ -0,0 +1,82 @@
1
+ /** Venmo handle (without @), Zelle email, or Zelle phone for profile / bash P2P setup. */
2
+
3
+ export function validateVenmoUsername(value: unknown): string | null {
4
+ if (value == null || (typeof value === "string" && !value.trim())) {
5
+ return null;
6
+ }
7
+ if (typeof value !== "string") {
8
+ return "Enter a valid Venmo username (letters, numbers, . _ -), up to 30 characters after @.";
9
+ }
10
+ const venmo = value.trim();
11
+ const venmoCore = venmo.replace(/^@+/, "");
12
+ if (
13
+ venmo.length > 40 ||
14
+ /[<>]/.test(venmo) ||
15
+ (venmoCore.length > 0 && !/^[A-Za-z0-9._-]{1,30}$/.test(venmoCore))
16
+ ) {
17
+ return "Enter a valid Venmo username (letters, numbers, . _ -), up to 30 characters after @.";
18
+ }
19
+ return null;
20
+ }
21
+
22
+ export function validateZelleEmail(value: unknown): string | null {
23
+ if (value == null || (typeof value === "string" && !value.trim())) {
24
+ return null;
25
+ }
26
+ if (typeof value !== "string" || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value.trim())) {
27
+ return "Enter a valid Zelle email.";
28
+ }
29
+ return null;
30
+ }
31
+
32
+ export function validateZellePhone(value: unknown): string | null {
33
+ if (value == null || (typeof value === "string" && !value.trim())) {
34
+ return null;
35
+ }
36
+ if (typeof value !== "string" || !/^[0-9+\-().\s]{7,20}$/.test(value.trim())) {
37
+ return "Enter a valid Zelle phone number.";
38
+ }
39
+ return null;
40
+ }
41
+
42
+ export function validateP2PPaymentFields(input: {
43
+ method: "venmo" | "zelle-email" | "zelle-phone" | "";
44
+ venmoUsername?: unknown;
45
+ zelleEmail?: unknown;
46
+ zellePhone?: unknown;
47
+ }): string | null {
48
+ if (input.method === "venmo") {
49
+ const err = validateVenmoUsername(input.venmoUsername);
50
+ if (err) return err;
51
+ if (
52
+ input.venmoUsername == null ||
53
+ (typeof input.venmoUsername === "string" && !input.venmoUsername.trim())
54
+ ) {
55
+ return "Enter your Venmo username.";
56
+ }
57
+ return null;
58
+ }
59
+ if (input.method === "zelle-email") {
60
+ const err = validateZelleEmail(input.zelleEmail);
61
+ if (err) return err;
62
+ if (
63
+ input.zelleEmail == null ||
64
+ (typeof input.zelleEmail === "string" && !input.zelleEmail.trim())
65
+ ) {
66
+ return "Enter your Zelle email.";
67
+ }
68
+ return null;
69
+ }
70
+ if (input.method === "zelle-phone") {
71
+ const err = validateZellePhone(input.zellePhone);
72
+ if (err) return err;
73
+ if (
74
+ input.zellePhone == null ||
75
+ (typeof input.zellePhone === "string" && !input.zellePhone.trim())
76
+ ) {
77
+ return "Enter your Zelle phone number.";
78
+ }
79
+ return null;
80
+ }
81
+ return null;
82
+ }
@@ -0,0 +1,14 @@
1
+ /** True when HTML/rich text has visible text or an image (not `<p></p>` alone). */
2
+ export function richTextHasVisibleContent(
3
+ html: string | null | undefined
4
+ ): boolean {
5
+ if (html == null) return false;
6
+ const trimmed = html.trim();
7
+ if (!trimmed) return false;
8
+ const textOnly = trimmed
9
+ .replace(/<[^>]*>/g, "")
10
+ .replace(/&nbsp;/gi, " ")
11
+ .trim();
12
+ if (textOnly.length > 0) return true;
13
+ return /<img\b/i.test(trimmed);
14
+ }
@@ -38,6 +38,10 @@ import {
38
38
  calculateStripeProcessingFeeCents,
39
39
  convertDollarsToCents,
40
40
  } from "../paymentUtils.js";
41
+ import {
42
+ PAYMENT_PROCESSING_LABEL,
43
+ STRIPE_PROCESSING_FEE_NOTE,
44
+ } from "../../feeDisplayCopy.js";
41
45
  export interface ServiceAddonInput extends ServiceAddon {
42
46
  chosenQuantity?: number;
43
47
  }
@@ -322,8 +326,8 @@ export function frontendServiceGetPriceToBookFees(
322
326
 
323
327
  allAdditionalFees.push({
324
328
  feeType: ServiceBookingFeeType.ProcessingFee,
325
- name: "Processing Fee",
326
- description: "Stripe Payment Processing (2.9% + $0.30)",
329
+ name: PAYMENT_PROCESSING_LABEL,
330
+ description: STRIPE_PROCESSING_FEE_NOTE,
327
331
  costPQCents: processingFeeCents,
328
332
  quantity: 1,
329
333
  });
@@ -40,6 +40,8 @@ export type TicketTierScheduleContext = {
40
40
  isViewerAmbashador?: boolean;
41
41
  isViewerBashInsider?: boolean;
42
42
  isViewerPromoterForEvent?: boolean;
43
+ /** When true, sold-out tiers show a guest waitlist CTA even without isWaitlistTier. */
44
+ eventWaitlistEnabled?: boolean;
43
45
  };
44
46
 
45
47
  export type TicketTierScheduleState = {
@@ -133,6 +135,7 @@ export function resolveTicketTierScheduleState(
133
135
  ctx: TicketTierScheduleContext = {}
134
136
  ): TicketTierScheduleState {
135
137
  const now = ctx.now ?? new Date();
138
+ const eventWaitlistEnabled = ctx.eventWaitlistEnabled === true;
136
139
  const availableAt = toDate(tier.availableAt);
137
140
  const expiresAt = toDate(tier.expiresAt);
138
141
  const publicAvailableAt = toDate(tier.publicAvailableAt);
@@ -152,6 +155,7 @@ export function resolveTicketTierScheduleState(
152
155
  canPurchase: false,
153
156
  soldOut,
154
157
  isWaitlistTier: tier.isWaitlistTier,
158
+ eventWaitlistEnabled,
155
159
  availability: { available: false },
156
160
  hostPreviewLabel: "Hidden by host",
157
161
  });
@@ -165,6 +169,7 @@ export function resolveTicketTierScheduleState(
165
169
  canPurchase: false,
166
170
  soldOut,
167
171
  isWaitlistTier: tier.isWaitlistTier,
172
+ eventWaitlistEnabled,
168
173
  availability: { available: false },
169
174
  hostPreviewLabel: "Expired",
170
175
  });
@@ -181,6 +186,7 @@ export function resolveTicketTierScheduleState(
181
186
  canPurchase: false,
182
187
  soldOut,
183
188
  isWaitlistTier: tier.isWaitlistTier,
189
+ eventWaitlistEnabled,
184
190
  availability: unlockAvail,
185
191
  hostPreviewLabel: "Unlock pending",
186
192
  });
@@ -196,6 +202,7 @@ export function resolveTicketTierScheduleState(
196
202
  canPurchase: false,
197
203
  soldOut,
198
204
  isWaitlistTier: tier.isWaitlistTier,
205
+ eventWaitlistEnabled,
199
206
  availability: {
200
207
  available: false,
201
208
  reason: "OnDate",
@@ -219,6 +226,7 @@ export function resolveTicketTierScheduleState(
219
226
  canPurchase: false,
220
227
  soldOut,
221
228
  isWaitlistTier: tier.isWaitlistTier,
229
+ eventWaitlistEnabled,
222
230
  availability: {
223
231
  available: false,
224
232
  reason: "OnDate",
@@ -235,6 +243,7 @@ export function resolveTicketTierScheduleState(
235
243
  canPurchase: false,
236
244
  soldOut,
237
245
  isWaitlistTier: tier.isWaitlistTier,
246
+ eventWaitlistEnabled,
238
247
  availability: {
239
248
  available: false,
240
249
  reason: "OnDate",
@@ -253,6 +262,7 @@ export function resolveTicketTierScheduleState(
253
262
  canPurchase: false,
254
263
  soldOut,
255
264
  isWaitlistTier: tier.isWaitlistTier,
265
+ eventWaitlistEnabled,
256
266
  availability: {
257
267
  available: false,
258
268
  reason: "EngagedUsersOnly",
@@ -270,6 +280,7 @@ export function resolveTicketTierScheduleState(
270
280
  canPurchase: false,
271
281
  soldOut: true,
272
282
  isWaitlistTier: tier.isWaitlistTier,
283
+ eventWaitlistEnabled,
273
284
  availability: { available: false },
274
285
  hostPreviewLabel: manualSoldOut ? "Sold out (manual)" : "Sold out",
275
286
  });
@@ -288,6 +299,7 @@ export function resolveTicketTierScheduleState(
288
299
  canPurchase: true,
289
300
  soldOut: false,
290
301
  isWaitlistTier: tier.isWaitlistTier,
302
+ eventWaitlistEnabled,
291
303
  availability,
292
304
  hostPreviewLabel: "Live",
293
305
  });
@@ -300,6 +312,7 @@ function buildState(args: {
300
312
  canPurchase: boolean;
301
313
  soldOut: boolean;
302
314
  isWaitlistTier?: boolean | null;
315
+ eventWaitlistEnabled?: boolean;
303
316
  availability: TicketTierAvailability;
304
317
  hostPreviewLabel: string;
305
318
  }): TicketTierScheduleState {
@@ -313,7 +326,9 @@ function buildState(args: {
313
326
  expiresAt: toIso(args.expiresAt),
314
327
  canPurchase: args.canPurchase,
315
328
  soldOut: args.soldOut,
316
- showWaitlistCta: args.soldOut && args.isWaitlistTier === true,
329
+ showWaitlistCta:
330
+ args.soldOut &&
331
+ (args.isWaitlistTier === true || args.eventWaitlistEnabled === true),
317
332
  guestVisible,
318
333
  availability: args.availability,
319
334
  hostPreviewLabel: args.hostPreviewLabel,