@bash-app/bash-common 30.477.0 → 30.480.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 (103) hide show
  1. package/dist/__tests__/bashEventCancellationPolicy.m300.test.d.ts +2 -0
  2. package/dist/__tests__/bashEventCancellationPolicy.m300.test.d.ts.map +1 -0
  3. package/dist/__tests__/bashEventCancellationPolicy.m300.test.js +17 -0
  4. package/dist/__tests__/bashEventCancellationPolicy.m300.test.js.map +1 -0
  5. package/dist/__tests__/bashEventLocationDisplay.test.d.ts +2 -0
  6. package/dist/__tests__/bashEventLocationDisplay.test.d.ts.map +1 -0
  7. package/dist/__tests__/bashEventLocationDisplay.test.js +11 -0
  8. package/dist/__tests__/bashEventLocationDisplay.test.js.map +1 -0
  9. package/dist/__tests__/bashEventMerchCatalogValidation.m299.test.d.ts +2 -0
  10. package/dist/__tests__/bashEventMerchCatalogValidation.m299.test.d.ts.map +1 -0
  11. package/dist/__tests__/bashEventMerchCatalogValidation.m299.test.js +33 -0
  12. package/dist/__tests__/bashEventMerchCatalogValidation.m299.test.js.map +1 -0
  13. package/dist/__tests__/bashEventWriteValidation.l193.test.d.ts +2 -0
  14. package/dist/__tests__/bashEventWriteValidation.l193.test.d.ts.map +1 -0
  15. package/dist/__tests__/bashEventWriteValidation.l193.test.js +20 -0
  16. package/dist/__tests__/bashEventWriteValidation.l193.test.js.map +1 -0
  17. package/dist/__tests__/hybridSearchQuery.test.d.ts +2 -0
  18. package/dist/__tests__/hybridSearchQuery.test.d.ts.map +1 -0
  19. package/dist/__tests__/hybridSearchQuery.test.js +42 -0
  20. package/dist/__tests__/hybridSearchQuery.test.js.map +1 -0
  21. package/dist/__tests__/serviceListingText.l195.test.d.ts +2 -0
  22. package/dist/__tests__/serviceListingText.l195.test.d.ts.map +1 -0
  23. package/dist/__tests__/serviceListingText.l195.test.js +7 -0
  24. package/dist/__tests__/serviceListingText.l195.test.js.map +1 -0
  25. package/dist/__tests__/serviceWizardSave.pipNov14.test.d.ts +2 -0
  26. package/dist/__tests__/serviceWizardSave.pipNov14.test.d.ts.map +1 -0
  27. package/dist/__tests__/serviceWizardSave.pipNov14.test.js +42 -0
  28. package/dist/__tests__/serviceWizardSave.pipNov14.test.js.map +1 -0
  29. package/dist/bashEventCancellationPolicy.d.ts +8 -0
  30. package/dist/bashEventCancellationPolicy.d.ts.map +1 -1
  31. package/dist/bashEventCancellationPolicy.js +20 -0
  32. package/dist/bashEventCancellationPolicy.js.map +1 -1
  33. package/dist/bashEventMerchCatalogValidation.d.ts +9 -0
  34. package/dist/bashEventMerchCatalogValidation.d.ts.map +1 -0
  35. package/dist/bashEventMerchCatalogValidation.js +39 -0
  36. package/dist/bashEventMerchCatalogValidation.js.map +1 -0
  37. package/dist/bashEventWriteValidation.d.ts +13 -0
  38. package/dist/bashEventWriteValidation.d.ts.map +1 -0
  39. package/dist/bashEventWriteValidation.js +24 -0
  40. package/dist/bashEventWriteValidation.js.map +1 -0
  41. package/dist/extendedSchemas.d.ts +674 -215
  42. package/dist/extendedSchemas.d.ts.map +1 -1
  43. package/dist/extendedSchemas.js +115 -4
  44. package/dist/extendedSchemas.js.map +1 -1
  45. package/dist/index.d.ts +5 -0
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +5 -0
  48. package/dist/index.js.map +1 -1
  49. package/dist/serviceWizardSave.d.ts +2 -0
  50. package/dist/serviceWizardSave.d.ts.map +1 -1
  51. package/dist/serviceWizardSave.js +43 -4
  52. package/dist/serviceWizardSave.js.map +1 -1
  53. package/dist/utils/__tests__/eventTaskVolunteerRewardUtils.test.js +10 -1
  54. package/dist/utils/__tests__/eventTaskVolunteerRewardUtils.test.js.map +1 -1
  55. package/dist/utils/__tests__/webLinkValidation.test.js +11 -1
  56. package/dist/utils/__tests__/webLinkValidation.test.js.map +1 -1
  57. package/dist/utils/bashEventLocationDisplay.d.ts +3 -0
  58. package/dist/utils/bashEventLocationDisplay.d.ts.map +1 -0
  59. package/dist/utils/bashEventLocationDisplay.js +21 -0
  60. package/dist/utils/bashEventLocationDisplay.js.map +1 -0
  61. package/dist/utils/hybridSearchQuery.d.ts +29 -0
  62. package/dist/utils/hybridSearchQuery.d.ts.map +1 -0
  63. package/dist/utils/hybridSearchQuery.js +77 -0
  64. package/dist/utils/hybridSearchQuery.js.map +1 -0
  65. package/dist/utils/richTextContent.d.ts +4 -0
  66. package/dist/utils/richTextContent.d.ts.map +1 -1
  67. package/dist/utils/richTextContent.js +26 -0
  68. package/dist/utils/richTextContent.js.map +1 -1
  69. package/dist/utils/serviceListingText.d.ts +3 -0
  70. package/dist/utils/serviceListingText.d.ts.map +1 -0
  71. package/dist/utils/serviceListingText.js +6 -0
  72. package/dist/utils/serviceListingText.js.map +1 -0
  73. package/dist/utils/userUtils.d.ts +3 -0
  74. package/dist/utils/userUtils.d.ts.map +1 -1
  75. package/dist/utils/userUtils.js +10 -0
  76. package/dist/utils/userUtils.js.map +1 -1
  77. package/dist/utils/webLinkValidation.d.ts +2 -0
  78. package/dist/utils/webLinkValidation.d.ts.map +1 -1
  79. package/dist/utils/webLinkValidation.js +9 -0
  80. package/dist/utils/webLinkValidation.js.map +1 -1
  81. package/package.json +1 -1
  82. package/prisma/schema.prisma +7 -0
  83. package/src/__tests__/bashEventCancellationPolicy.m300.test.ts +20 -0
  84. package/src/__tests__/bashEventLocationDisplay.test.ts +20 -0
  85. package/src/__tests__/bashEventMerchCatalogValidation.m299.test.ts +37 -0
  86. package/src/__tests__/bashEventWriteValidation.l193.test.ts +31 -0
  87. package/src/__tests__/hybridSearchQuery.test.ts +54 -0
  88. package/src/__tests__/serviceListingText.l195.test.ts +7 -0
  89. package/src/__tests__/serviceWizardSave.pipNov14.test.ts +47 -0
  90. package/src/bashEventCancellationPolicy.ts +23 -0
  91. package/src/bashEventMerchCatalogValidation.ts +45 -0
  92. package/src/bashEventWriteValidation.ts +31 -0
  93. package/src/extendedSchemas.ts +132 -6
  94. package/src/index.ts +5 -0
  95. package/src/serviceWizardSave.ts +59 -6
  96. package/src/utils/__tests__/eventTaskVolunteerRewardUtils.test.ts +16 -0
  97. package/src/utils/__tests__/webLinkValidation.test.ts +18 -1
  98. package/src/utils/bashEventLocationDisplay.ts +24 -0
  99. package/src/utils/hybridSearchQuery.ts +93 -0
  100. package/src/utils/richTextContent.ts +26 -0
  101. package/src/utils/serviceListingText.ts +6 -0
  102. package/src/utils/userUtils.ts +13 -0
  103. package/src/utils/webLinkValidation.ts +10 -0
@@ -0,0 +1,54 @@
1
+ import {
2
+ coerceSearchQueryParam,
3
+ escapePrismaContainsPattern,
4
+ normalizeUserSearchQuery,
5
+ parseHybridSearchQueryInput,
6
+ prismaInsensitiveContains,
7
+ searchQueryHasKeyword,
8
+ } from "../utils/hybridSearchQuery";
9
+
10
+ describe("hybridSearchQuery", () => {
11
+ describe("normalizeUserSearchQuery", () => {
12
+ it("[L183] replaces lone surrogates so search URLs do not break the UI", () => {
13
+ const loneHigh = "ab\uD800cd";
14
+ expect(normalizeUserSearchQuery(loneHigh)).toBe("ab\uFFFDcd");
15
+ expect(normalizeUserSearchQuery(" jazz ")).toBe("jazz");
16
+ });
17
+ });
18
+
19
+ describe("escapePrismaContainsPattern", () => {
20
+ it("[L184] escapes LIKE wildcards so % and _ match literally", () => {
21
+ expect(escapePrismaContainsPattern("%")).toBe("\\%");
22
+ expect(escapePrismaContainsPattern("_")).toBe("\\_");
23
+ expect(escapePrismaContainsPattern("50% off")).toBe("50\\% off");
24
+ expect(escapePrismaContainsPattern("a_b")).toBe("a\\_b");
25
+ });
26
+
27
+ it("prismaInsensitiveContains wraps escaped value", () => {
28
+ expect(prismaInsensitiveContains("%")).toEqual({
29
+ contains: "\\%",
30
+ mode: "insensitive",
31
+ });
32
+ });
33
+ });
34
+
35
+ it("[L221] rejects queries with a NUL byte", () => {
36
+ const parsed = parseHybridSearchQueryInput("ba\u0000sh");
37
+ expect(parsed.ok).toBe(false);
38
+ if (!parsed.ok) {
39
+ expect(parsed.error).toMatch(/null characters/i);
40
+ }
41
+ });
42
+
43
+ it("[L220] coerces express search query params", () => {
44
+ expect(coerceSearchQueryParam(undefined)).toBeUndefined();
45
+ expect(coerceSearchQueryParam(["bash", "qa"])).toBeUndefined();
46
+ expect(coerceSearchQueryParam(" QA ")).toBe(" QA ");
47
+ });
48
+
49
+ it("[L184] treats % and _ as not a keyword query", () => {
50
+ expect(searchQueryHasKeyword("%")).toBe(false);
51
+ expect(searchQueryHasKeyword("_")).toBe(false);
52
+ expect(searchQueryHasKeyword("50%")).toBe(true);
53
+ });
54
+ });
@@ -0,0 +1,7 @@
1
+ import { normalizeServiceNameForWrite } from "../utils/serviceListingText.js";
2
+
3
+ describe("[L195] service listing name write", () => {
4
+ it("strips HTML markup from service names", () => {
5
+ expect(normalizeServiceNameForWrite("<b>x</b><script>")).toBe("x");
6
+ });
7
+ });
@@ -0,0 +1,47 @@
1
+ import type { ServiceExt } from "../extendedSchemas.js";
2
+ import {
3
+ buildServiceHighImpactConfirmMessage,
4
+ } from "../serviceWizardSave.js";
5
+
6
+ describe("service high-impact save confirm (Pip Nov 14)", () => {
7
+ it("[L173] formats rate changes as dollar amounts, not [object Object]", () => {
8
+ const committed = {
9
+ id: "svc-1",
10
+ serviceRatesAssociation: {
11
+ id: "rates-1",
12
+ serviceGeneralRates: {
13
+ id: "gen-1",
14
+ flatRateCents: 5000,
15
+ hourlyRateCents: 100,
16
+ dailyRateCents: 800,
17
+ },
18
+ packages: [],
19
+ },
20
+ } as unknown as ServiceExt;
21
+
22
+ const pending = {
23
+ serviceRatesAssociation: {
24
+ id: "rates-1",
25
+ serviceGeneralRates: {
26
+ id: "gen-1",
27
+ flatRateCents: 5000,
28
+ hourlyRateCents: 100,
29
+ dailyRateCents: 800,
30
+ },
31
+ packages: [
32
+ {
33
+ id: "pkg-1",
34
+ name: "Test package",
35
+ priceCents: 100,
36
+ description: "",
37
+ },
38
+ ],
39
+ },
40
+ };
41
+
42
+ const message = buildServiceHighImpactConfirmMessage(committed, pending);
43
+ expect(message).not.toContain("[object Object]");
44
+ expect(message).toMatch(/\$1(\.00)?/);
45
+ expect(message).toMatch(/→/);
46
+ });
47
+ });
@@ -127,6 +127,29 @@ export function defaultBashEventCancellationPolicyDisplayText(): string {
127
127
  );
128
128
  }
129
129
 
130
+ /** Host PUT must not persist blank custom policy text (M300). */
131
+ export function validateBashEventCancellationPolicyWrite(
132
+ policy: unknown,
133
+ ): { ok: true; text: string } | { ok: false; error: string } {
134
+ if (policy === undefined) {
135
+ return { ok: false, error: "cancellationPolicy is required when provided" };
136
+ }
137
+ if (typeof policy !== "string") {
138
+ return { ok: false, error: "cancellationPolicy must be a string" };
139
+ }
140
+ const trimmed = policy.trim();
141
+ if (!trimmed) {
142
+ return {
143
+ ok: false,
144
+ error: "Cancellation policy text cannot be empty",
145
+ };
146
+ }
147
+ if (trimmed.length > 4000) {
148
+ return { ok: false, error: "Cancellation policy is too long" };
149
+ }
150
+ return { ok: true, text: trimmed };
151
+ }
152
+
130
153
  /**
131
154
  * Short label for bash detail / meta UI. Named presets use the host-picker name
132
155
  * (e.g. "Anytime"); custom/legacy free text returns the stored string.
@@ -0,0 +1,45 @@
1
+ import type { BashEventHostMerchItem } from "./extendedSchemas.js";
2
+
3
+ /** Per-item merch cap ($10,000) — above this is almost always wizard mistake / abuse. */
4
+ export const BASH_EVENT_HOST_MERCH_MAX_PRICE_CENTS = 1_000_000;
5
+
6
+ function merchItemsFromRaw(raw: unknown): BashEventHostMerchItem[] {
7
+ if (Array.isArray(raw)) {
8
+ return raw as BashEventHostMerchItem[];
9
+ }
10
+ if (raw && typeof raw === "object" && Array.isArray((raw as { items?: unknown }).items)) {
11
+ return (raw as { items: BashEventHostMerchItem[] }).items;
12
+ }
13
+ return [];
14
+ }
15
+
16
+ export function validateBashEventMerchCatalogForWrite(
17
+ raw: unknown,
18
+ ): { ok: true } | { ok: false; error: string } {
19
+ if (raw === undefined || raw === null) {
20
+ return { ok: false, error: "merchandiseItems is required when provided" };
21
+ }
22
+ if (typeof raw !== "object") {
23
+ return { ok: false, error: "merchandiseItems must be an object or array" };
24
+ }
25
+ const items = merchItemsFromRaw(raw);
26
+
27
+ for (const item of items) {
28
+ if (!item || typeof item !== "object") continue;
29
+ const priceCents = item.priceCents;
30
+ if (typeof priceCents !== "number" || !Number.isFinite(priceCents)) {
31
+ return { ok: false, error: "Each merch item needs a valid priceCents" };
32
+ }
33
+ if (priceCents < 0) {
34
+ return { ok: false, error: "Merch price cannot be negative" };
35
+ }
36
+ if (priceCents > BASH_EVENT_HOST_MERCH_MAX_PRICE_CENTS) {
37
+ return {
38
+ ok: false,
39
+ error: `Merch price cannot exceed $${(BASH_EVENT_HOST_MERCH_MAX_PRICE_CENTS / 100).toLocaleString()}`,
40
+ };
41
+ }
42
+ }
43
+
44
+ return { ok: true };
45
+ }
@@ -0,0 +1,31 @@
1
+ import { plainListingHeadline } from "./utils/plainListingHeadline.js";
2
+ import { richTextVisibleLength } from "./utils/richTextContent.js";
3
+
4
+ /** Keep in sync with bash-app `constants/bashEventLimits.ts`. */
5
+ export const BASH_EVENT_TITLE_MAX_LENGTH = 100;
6
+
7
+ /** Visible characters (HTML stripped). Keep in sync with bash-app. */
8
+ export const BASH_EVENT_DESCRIPTION_MAX_LENGTH = 2000;
9
+
10
+ export const BASH_EVENT_DESCRIPTION_TOO_LONG_MESSAGE = `Description is too long. Keep it to ${BASH_EVENT_DESCRIPTION_MAX_LENGTH} visible characters or less.`;
11
+
12
+ export function normalizeBashEventTitleForWrite(
13
+ title: string
14
+ ): string {
15
+ const plain = plainListingHeadline(title).trim();
16
+ if (plain.length <= BASH_EVENT_TITLE_MAX_LENGTH) return plain;
17
+ return plain.slice(0, BASH_EVENT_TITLE_MAX_LENGTH);
18
+ }
19
+
20
+ export function validateBashEventDescriptionForWrite(
21
+ description: string | null | undefined
22
+ ): { ok: true } | { ok: false; error: string } {
23
+ if (description == null || description === "") {
24
+ return { ok: true };
25
+ }
26
+ const visible = richTextVisibleLength(description);
27
+ if (visible > BASH_EVENT_DESCRIPTION_MAX_LENGTH) {
28
+ return { ok: false, error: BASH_EVENT_DESCRIPTION_TOO_LONG_MESSAGE };
29
+ }
30
+ return { ok: true };
31
+ }
@@ -828,6 +828,15 @@ export type BashEventUpsertWireInput = Override<
828
828
  | import("@prisma/client").Prisma.JsonValue
829
829
  | null;
830
830
  advertiseRecurrence?: boolean;
831
+ /**
832
+ * updatedAt the wizard tab last loaded. The API drops a stale title,
833
+ * subtitle, or description when another tab saved a newer version.
834
+ */
835
+ baseUpdatedAt?: string | null;
836
+ /** Title, subtitle, and description this wizard tab loaded. */
837
+ baseTitle?: string | null;
838
+ baseSubtitle?: string | null;
839
+ baseDescription?: string | null;
831
840
  }
832
841
  >,
833
842
  {
@@ -1223,6 +1232,61 @@ export const SERVICE_PUBLIC_LIST_DATA_TO_INCLUDE = {
1223
1232
  },
1224
1233
  } satisfies Prisma.ServiceInclude;
1225
1234
 
1235
+ /** Full service detail for signed-out `GET /api/public-services/service/:id` (no owner/creator PII). */
1236
+ export const SERVICE_PUBLIC_DETAIL_DATA_TO_INCLUDE = {
1237
+ creator: {
1238
+ select: PUBLIC_TEASER_USER_DATA_TO_SELECT,
1239
+ },
1240
+ owner: {
1241
+ select: PUBLIC_TEASER_USER_DATA_TO_SELECT,
1242
+ },
1243
+ targetAudience: true,
1244
+ media: true,
1245
+ stripeAccount: {
1246
+ select: PUBLIC_STRIPE_ACCOUNT_DATA_TO_SELECT,
1247
+ },
1248
+ serviceLinks: {
1249
+ include: SERVICE_LINK_DATA_TO_INCLUDE,
1250
+ },
1251
+ serviceRatesAssociation: {
1252
+ include: SERVICE_RATES_ASSOCIATION_DATA_TO_INCLUDE,
1253
+ },
1254
+ bashEvent: {
1255
+ include: BASH_EVENT_DATA_TO_INCLUDE,
1256
+ },
1257
+ venue: {
1258
+ include: VENUE_DATA_TO_INCLUDE,
1259
+ },
1260
+ eventService: {
1261
+ include: EVENT_SERVICE_DATA_TO_INCLUDE,
1262
+ },
1263
+ entertainmentService: {
1264
+ include: ENTERTAINMENT_SERVICE_DATA_TO_INCLUDE,
1265
+ },
1266
+ vendor: {
1267
+ include: VENDOR_DATA_TO_INCLUDE,
1268
+ },
1269
+ exhibitor: {
1270
+ include: EXHIBITOR_DATA_TO_INCLUDE,
1271
+ },
1272
+ sponsor: {
1273
+ include: SPONSOR_DATA_TO_INCLUDE,
1274
+ },
1275
+ organization: {
1276
+ include: {
1277
+ _count: {
1278
+ select: {
1279
+ members: true,
1280
+ },
1281
+ },
1282
+ sportsProfile: true,
1283
+ },
1284
+ },
1285
+ complementaryProfiles: {
1286
+ select: { id: true, serviceType: true },
1287
+ },
1288
+ } satisfies Prisma.ServiceInclude;
1289
+
1226
1290
  export const SERVICE_DATA_TO_INCLUDE = {
1227
1291
  creator: {
1228
1292
  select: FRONT_END_USER_DATA_TO_SELECT,
@@ -2236,19 +2300,19 @@ export type PublicStripeAccount = Pick<
2236
2300
 
2237
2301
  export const BLOG_POST_DATA_TO_INCLUDE = {
2238
2302
  author: {
2239
- select: FRONT_END_USER_DATA_TO_SELECT,
2303
+ select: PUBLIC_TEASER_USER_DATA_TO_SELECT,
2240
2304
  },
2241
2305
  category: true,
2242
2306
  tags: true,
2243
2307
  comments: {
2244
2308
  include: {
2245
2309
  author: {
2246
- select: FRONT_END_USER_DATA_TO_SELECT,
2310
+ select: PUBLIC_TEASER_USER_DATA_TO_SELECT,
2247
2311
  },
2248
2312
  replies: {
2249
2313
  include: {
2250
2314
  author: {
2251
- select: FRONT_END_USER_DATA_TO_SELECT,
2315
+ select: PUBLIC_TEASER_USER_DATA_TO_SELECT,
2252
2316
  },
2253
2317
  },
2254
2318
  },
@@ -2264,7 +2328,7 @@ export const BLOG_POST_DATA_TO_INCLUDE = {
2264
2328
 
2265
2329
  export const BLOG_POST_PREVIEW_DATA_TO_INCLUDE = {
2266
2330
  author: {
2267
- select: FRONT_END_USER_DATA_TO_SELECT,
2331
+ select: PUBLIC_TEASER_USER_DATA_TO_SELECT,
2268
2332
  },
2269
2333
  category: true,
2270
2334
  tags: true,
@@ -2280,7 +2344,7 @@ export const BLOG_POST_PREVIEW_DATA_TO_INCLUDE = {
2280
2344
  } satisfies Prisma.BlogPostInclude;
2281
2345
 
2282
2346
  export interface BlogPostExt extends BlogPost {
2283
- author: PublicUser;
2347
+ author: PublicTeaserUser;
2284
2348
  category?: BlogCategory | null;
2285
2349
  tags: BlogTag[];
2286
2350
  comments?: BlogCommentExt[];
@@ -2290,7 +2354,7 @@ export interface BlogPostExt extends BlogPost {
2290
2354
  }
2291
2355
 
2292
2356
  export interface BlogCommentExt extends BlogComment {
2293
- author: PublicUser;
2357
+ author: PublicTeaserUser;
2294
2358
  replies?: BlogCommentExt[];
2295
2359
  }
2296
2360
 
@@ -2514,6 +2578,68 @@ export const ARTIST_REPRESENTATION_PUBLIC_SELECT = {
2514
2578
  artistUser: { select: FRONT_END_USER_DATA_TO_SELECT },
2515
2579
  } satisfies Prisma.OrganizationArtistRepresentationSelect;
2516
2580
 
2581
+ /**
2582
+ * Signed-out / non-member `GET /organizations/:id` and `/slug/:slug`.
2583
+ * Omits contact email and phone, street address, billing, SMS caps, SSO,
2584
+ * Stripe ids, and other workspace-admin fields (M294).
2585
+ */
2586
+ export const ORGANIZATION_PUBLIC_DETAIL_SELECT = {
2587
+ id: true,
2588
+ name: true,
2589
+ slug: true,
2590
+ organizationType: true,
2591
+ bio: true,
2592
+ mission: true,
2593
+ pocName: true,
2594
+ city: true,
2595
+ state: true,
2596
+ zipCode: true,
2597
+ country: true,
2598
+ coverPhoto: true,
2599
+ logoUrl: true,
2600
+ websiteUrl: true,
2601
+ socialLinks: true,
2602
+ goodsOrServices: true,
2603
+ venueTypes: true,
2604
+ secondaryVenueTypes: true,
2605
+ baseMembershipPriceCents: true,
2606
+ premiumMembershipPriceCents: true,
2607
+ membershipBillingInterval: true,
2608
+ allowGuestsByDefault: true,
2609
+ defaultGuestLimit: true,
2610
+ visibility: true,
2611
+ requiresApproval: true,
2612
+ memberAutoApproval: true,
2613
+ ownerId: true,
2614
+ parentOrganizationId: true,
2615
+ departmentName: true,
2616
+ hierarchyLevel: true,
2617
+ latitude: true,
2618
+ longitude: true,
2619
+ createdAt: true,
2620
+ updatedAt: true,
2621
+ accentColor: true,
2622
+ faviconUrl: true,
2623
+ secondaryBrandColor: true,
2624
+ fontPreset: true,
2625
+ coursesEnabled: true,
2626
+ communityEnabled: true,
2627
+ resourcesEnabled: true,
2628
+ removeBashBranding: true,
2629
+ isBashOfficial: true,
2630
+ customDomain: true,
2631
+ customDomainStatus: true,
2632
+ inheritBrandingFromParent: true,
2633
+ nonprofitVerifiedAt: true,
2634
+ nonprofitCountry: true,
2635
+ promotionalPackageRates: true,
2636
+ subscriptionTier: true,
2637
+ } satisfies Prisma.OrganizationSelect;
2638
+
2639
+ export type OrganizationPublicDetail = Prisma.OrganizationGetPayload<{
2640
+ select: typeof ORGANIZATION_PUBLIC_DETAIL_SELECT;
2641
+ }>;
2642
+
2517
2643
  export type ArtistRepresentationPublic =
2518
2644
  Prisma.OrganizationArtistRepresentationGetPayload<{
2519
2645
  select: typeof ARTIST_REPRESENTATION_PUBLIC_SELECT;
package/src/index.ts CHANGED
@@ -63,6 +63,7 @@ export * from "./promoCartEngine.js";
63
63
  export * from "./audienceImport.js";
64
64
  export * from "./eventStaffRoles.js";
65
65
  export * from "./bashEventCancellationPolicy.js";
66
+ export * from "./bashEventMerchCatalogValidation.js";
66
67
  export * from "./userReportTypes.js";
67
68
  export * from "./intros/index.js";
68
69
  export * from "./mirroredPrismaEnums.js";
@@ -387,6 +388,8 @@ export * from "./utils/awsS3Utils.js";
387
388
  export * from "./utils/badgeUtils.js";
388
389
  export * from "./utils/bashPointsPaymentUtils.js";
389
390
  export * from "./utils/contentFilterUtils.js";
391
+ export * from "./utils/hybridSearchQuery.js";
392
+ export * from "./utils/bashEventLocationDisplay.js";
390
393
  export * from "./utils/dateTimeUtils.js";
391
394
  export {
392
395
  getIanaTimezoneFromUsStateCode,
@@ -509,7 +512,9 @@ export * from "./utils/ticketTierValidation.js";
509
512
  export * from "./utils/organizationMembershipValidation.js";
510
513
  export * from "./utils/crowdSizeValidation.js";
511
514
  export * from "./utils/plainListingHeadline.js";
515
+ export * from "./utils/serviceListingText.js";
512
516
  export * from "./utils/webLinkValidation.js";
513
517
  export * from "./utils/listingContactValidation.js";
514
518
  export * from "./utils/p2pPaymentValidation.js";
515
519
  export * from "./utils/richTextContent.js";
520
+ export * from "./bashEventWriteValidation.js";
@@ -120,6 +120,58 @@ const SERVICE_HIGH_IMPACT_FIELD_LABELS: Record<
120
120
  cancellationPolicy: "Cancellation policy",
121
121
  };
122
122
 
123
+ function formatCentsAsDollars(cents: number): string {
124
+ return `$${(cents / 100).toFixed(2)}`;
125
+ }
126
+
127
+ /** Rates confirm copy must show dollar amounts, not "[object Object]" (L173). */
128
+ export function formatServiceRatesForConfirm(value: unknown): string {
129
+ if (!value || typeof value !== "object") return "—";
130
+ const assoc = value as {
131
+ serviceGeneralRates?: {
132
+ flatRateCents?: number | null;
133
+ hourlyRateCents?: number | null;
134
+ dailyRateCents?: number | null;
135
+ } | null;
136
+ packages?: Array<{ name?: string | null; priceCents?: number | null }>;
137
+ };
138
+ const parts: string[] = [];
139
+ const rates = assoc.serviceGeneralRates;
140
+ if (rates?.flatRateCents) {
141
+ parts.push(`flat ${formatCentsAsDollars(rates.flatRateCents)}`);
142
+ }
143
+ if (rates?.hourlyRateCents) {
144
+ parts.push(`hourly ${formatCentsAsDollars(rates.hourlyRateCents)}`);
145
+ }
146
+ if (rates?.dailyRateCents) {
147
+ parts.push(`daily ${formatCentsAsDollars(rates.dailyRateCents)}`);
148
+ }
149
+ for (const pkg of assoc.packages ?? []) {
150
+ const name = pkg.name?.trim() || "Package";
151
+ const price =
152
+ typeof pkg.priceCents === "number"
153
+ ? formatCentsAsDollars(pkg.priceCents)
154
+ : "—";
155
+ parts.push(`${name} ${price}`);
156
+ }
157
+ return parts.length > 0 ? parts.join(", ") : "—";
158
+ }
159
+
160
+ function formatServiceHighImpactValue(
161
+ key: (typeof SERVICE_HIGH_IMPACT_SAVE_KEYS)[number],
162
+ value: unknown
163
+ ): string {
164
+ if (value == null || value === "") return "—";
165
+ if (key === "serviceRatesAssociation") {
166
+ return formatServiceRatesForConfirm(value);
167
+ }
168
+ if (key === "availableHours") {
169
+ return typeof value === "string" ? value : "Updated hours";
170
+ }
171
+ if (typeof value === "object") return "Updated";
172
+ return String(value);
173
+ }
174
+
123
175
  /** High-impact Save confirm copy for published listing wizards. */
124
176
  export function buildServiceHighImpactConfirmMessage(
125
177
  committed: ServiceExt,
@@ -128,12 +180,13 @@ export function buildServiceHighImpactConfirmMessage(
128
180
  const lines = SERVICE_HIGH_IMPACT_SAVE_KEYS.filter((key) => key in pending).map(
129
181
  (key) => {
130
182
  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] ?? "—"
183
+ const before = formatServiceHighImpactValue(
184
+ key,
185
+ key in committed ? committed[key as keyof ServiceExt] : null
186
+ );
187
+ const after = formatServiceHighImpactValue(
188
+ key,
189
+ (pending as Record<string, unknown>)[key]
137
190
  );
138
191
  return `${label}: ${before} → ${after}`;
139
192
  }
@@ -1,11 +1,27 @@
1
1
  import {
2
2
  countEventTaskFilledSlots,
3
3
  eventTaskMaxBashPointsLiability,
4
+ isUserAssignedToEventTask,
4
5
  totalEventTaskBashPointsOffer,
5
6
  validateHostTaskBashPointsOffer,
6
7
  } from "../eventTaskVolunteerRewardUtils.js";
7
8
 
8
9
  describe("eventTaskVolunteerRewardUtils", () => {
10
+ it("[H7] treats the viewer as assigned when they have a row but legacy assignedToId is someone else", () => {
11
+ expect(
12
+ isUserAssignedToEventTask(
13
+ {
14
+ assignedToId: "other-volunteer",
15
+ status: "Accepted",
16
+ neededCount: 1,
17
+ bashPointsReward: 0,
18
+ assignments: [{ userId: "me", status: "Accepted", bashPointsPaidAt: null }],
19
+ },
20
+ "me"
21
+ )
22
+ ).toBe(true);
23
+ });
24
+
9
25
  it("counts legacy assignee plus assignment rows without double count", () => {
10
26
  expect(
11
27
  countEventTaskFilledSlots({
@@ -1,4 +1,21 @@
1
- import { validateOptionalWebLink } from "../webLinkValidation.js";
1
+ import {
2
+ normalizeOptionalWebLinkForStorage,
3
+ validateOptionalWebLink,
4
+ } from "../webLinkValidation.js";
5
+
6
+ describe("[L194] normalizeOptionalWebLinkForStorage", () => {
7
+ it("clears blank and whitespace links", () => {
8
+ expect(normalizeOptionalWebLinkForStorage("")).toBeNull();
9
+ expect(normalizeOptionalWebLinkForStorage(" ")).toBeNull();
10
+ expect(normalizeOptionalWebLinkForStorage(null)).toBeNull();
11
+ });
12
+
13
+ it("trims valid links", () => {
14
+ expect(normalizeOptionalWebLinkForStorage(" https://zoom.us/x ")).toBe(
15
+ "https://zoom.us/x"
16
+ );
17
+ });
18
+ });
2
19
 
3
20
  it.each([undefined, null, "", "https://meet.example.com/room?key=123", "http://example.com"])("accepts an optional web link %s", value => {
4
21
  expect(validateOptionalWebLink(value)).toBeNull();
@@ -0,0 +1,24 @@
1
+ /** City/state line for cards and search. Pipe-packed place strings are not shown raw. */
2
+ export function formatBashCardLocation(
3
+ location?: string | null,
4
+ city?: string | null,
5
+ state?: string | null
6
+ ): string | null {
7
+ const loc = readablePlace(location);
8
+ if (loc) return loc;
9
+ const parts = [city?.trim(), state?.trim()].filter(
10
+ (part): part is string => Boolean(part)
11
+ );
12
+ return parts.length ? parts.join(", ") : null;
13
+ }
14
+
15
+ function readablePlace(raw?: string | null): string | null {
16
+ const trimmed = raw?.trim();
17
+ if (!trimmed) return null;
18
+ if (!trimmed.includes("|")) return trimmed;
19
+ const parts = trimmed
20
+ .split("|")
21
+ .map((part) => part.trim())
22
+ .filter(Boolean);
23
+ return parts.length ? parts.join(", ") : null;
24
+ }
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Normalize and escape strings for Prisma `contains` / PostgreSQL ILIKE.
3
+ * Unescaped `%` and `_` act as wildcards and can match every row.
4
+ */
5
+
6
+ /** Remove lone UTF-16 surrogates (e.g. from truncated percent-encoding in URLs). */
7
+ export function normalizeUserSearchQuery(raw: string): string {
8
+ if (!raw) return "";
9
+ const trimmed = raw.trim();
10
+ if (!trimmed) return "";
11
+ return trimmed.replace(
12
+ /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,
13
+ "\uFFFD"
14
+ );
15
+ }
16
+
17
+ /** Escape `\`, `%`, and `_` for Prisma `contains` on PostgreSQL. */
18
+ export function escapePrismaContainsPattern(term: string): string {
19
+ return term.replace(/\\/g, "\\\\").replace(/%/g, "\\%").replace(/_/g, "\\_");
20
+ }
21
+
22
+ export function prismaInsensitiveContains(term: string): {
23
+ contains: string;
24
+ mode: "insensitive";
25
+ } {
26
+ return {
27
+ contains: escapePrismaContainsPattern(term),
28
+ mode: "insensitive",
29
+ };
30
+ }
31
+
32
+ /** Letter or digit. `%` and `_` alone are not keyword queries. */
33
+ export function searchQueryHasKeyword(query: string): boolean {
34
+ return /[\p{L}\p{N}]/u.test(query);
35
+ }
36
+
37
+ /** Max rows returned from POST /api/search/hybrid (per type, before merge cap). */
38
+ export const HYBRID_SEARCH_MAX_RESULTS = 100;
39
+
40
+ /** Max UTF-16 code units on the raw `query` field (DoS / oversized echo). */
41
+ export const HYBRID_SEARCH_MAX_QUERY_LENGTH = 500;
42
+
43
+ const HYBRID_SEARCH_DEFAULT_LIMIT = 20;
44
+
45
+ export function clampHybridSearchLimit(raw: unknown): number {
46
+ const n =
47
+ typeof raw === "number"
48
+ ? raw
49
+ : typeof raw === "string"
50
+ ? Number.parseInt(raw, 10)
51
+ : HYBRID_SEARCH_DEFAULT_LIMIT;
52
+ if (!Number.isFinite(n) || n < 1) {
53
+ return HYBRID_SEARCH_DEFAULT_LIMIT;
54
+ }
55
+ return Math.min(Math.floor(n), HYBRID_SEARCH_MAX_RESULTS);
56
+ }
57
+
58
+ /** Express `req.query.q` may be string, string[], or absent. */
59
+ export function coerceSearchQueryParam(raw: unknown): string | undefined {
60
+ if (raw === undefined || raw === null) {
61
+ return undefined;
62
+ }
63
+ if (Array.isArray(raw)) {
64
+ return undefined;
65
+ }
66
+ if (typeof raw !== "string") {
67
+ return undefined;
68
+ }
69
+ const trimmed = raw.trim();
70
+ return trimmed.length > 0 ? raw : undefined;
71
+ }
72
+
73
+ export function parseHybridSearchQueryInput(
74
+ raw: unknown,
75
+ ): { ok: true; query: string } | { ok: false; error: string } {
76
+ if (typeof raw !== "string") {
77
+ return { ok: false, error: "Query parameter is required" };
78
+ }
79
+ if (raw.includes("\u0000")) {
80
+ return { ok: false, error: "Query cannot contain null characters" };
81
+ }
82
+ if (raw.length > HYBRID_SEARCH_MAX_QUERY_LENGTH) {
83
+ return {
84
+ ok: false,
85
+ error: `Query must be ${HYBRID_SEARCH_MAX_QUERY_LENGTH} characters or fewer`,
86
+ };
87
+ }
88
+ const query = normalizeUserSearchQuery(raw);
89
+ if (!query) {
90
+ return { ok: false, error: "Query parameter is required" };
91
+ }
92
+ return { ok: true, query };
93
+ }