@mohasinac/appkit 4.30.13 → 4.30.16

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 (54) hide show
  1. package/dist/_internal/server/functions/https.js +17 -2
  2. package/dist/_internal/server/jobs/core/listingProcessor.js +5 -1
  3. package/dist/features/addresses/repository/addresses.repository.d.ts +12 -1
  4. package/dist/features/addresses/repository/addresses.repository.js +16 -7
  5. package/dist/features/admin/components/AdminBlogView.js +8 -1
  6. package/dist/features/admin/components/AdminCouponsView.js +8 -1
  7. package/dist/features/admin/components/AdminOffersView.js +9 -1
  8. package/dist/features/admin/components/AdminPayoutsView.js +9 -1
  9. package/dist/features/admin/components/AdminReviewsView.js +14 -1
  10. package/dist/features/admin/components/AdminScammersView.js +15 -1
  11. package/dist/features/admin/components/DataListingView.d.ts +22 -1
  12. package/dist/features/admin/components/DataListingView.js +7 -0
  13. package/dist/features/admin/hooks/useAdminListing.d.ts +9 -0
  14. package/dist/features/admin/hooks/useAdminListing.js +30 -2
  15. package/dist/features/auth/repository/user.repository.d.ts +22 -1
  16. package/dist/features/auth/repository/user.repository.js +31 -28
  17. package/dist/features/cart/repository/cart.repository.d.ts +15 -2
  18. package/dist/features/cart/repository/cart.repository.js +15 -13
  19. package/dist/features/events/components/AdminEventsView.js +7 -1
  20. package/dist/features/orders/repository/orders.repository.d.ts +12 -1
  21. package/dist/features/orders/repository/orders.repository.js +14 -5
  22. package/dist/features/payments/repository/payout.repository.d.ts +19 -9
  23. package/dist/features/payments/repository/payout.repository.js +26 -20
  24. package/dist/features/products/components/ProductFilters.d.ts +19 -1
  25. package/dist/features/products/components/ProductFilters.js +11 -3
  26. package/dist/features/products/components/ProductsIndexListing.d.ts +4 -2
  27. package/dist/features/products/components/ProductsIndexListing.js +40 -27
  28. package/dist/features/reviews/repository/reviews.repository.d.ts +10 -8
  29. package/dist/features/reviews/repository/reviews.repository.js +16 -19
  30. package/dist/features/scams/repository/scammer.repository.d.ts +10 -1
  31. package/dist/features/scams/repository/scammer.repository.js +20 -2
  32. package/dist/features/scams/schemas/firestore.d.ts +10 -0
  33. package/dist/features/scams/schemas/firestore.js +1 -0
  34. package/dist/features/scams/schemas/index.d.ts +10 -10
  35. package/dist/features/seller/components/SellerCouponsView.js +7 -1
  36. package/dist/features/seller/components/SellerOffersView.js +8 -1
  37. package/dist/features/seller/components/SellerOrdersView.js +8 -1
  38. package/dist/features/tester/seed-data/tester-checklist-seed-data.js +161 -17
  39. package/dist/providers/db-firebase/base.repository.d.ts +12 -0
  40. package/dist/providers/db-firebase/base.repository.js +14 -2
  41. package/dist/react/hooks/usePendingFilters.d.ts +12 -2
  42. package/dist/react/hooks/usePendingFilters.js +2 -2
  43. package/dist/react/hooks/usePendingTable.d.ts +9 -2
  44. package/dist/schemas/registry.d.ts +8 -8
  45. package/dist/security/pii-schemas.d.ts +19 -1
  46. package/dist/security/pii-schemas.js +19 -1
  47. package/dist/seed/_helpers/search-txt-wrappers.d.ts +2 -0
  48. package/dist/seed/_helpers/search-txt-wrappers.js +4 -1
  49. package/dist/seed/scammers-seed-data.js +10 -1
  50. package/dist/styles.css +1 -1
  51. package/dist/tailwind-utilities.css +1 -1
  52. package/dist/utils/search-txt-builders.d.ts +13 -0
  53. package/dist/utils/search-txt-builders.js +20 -0
  54. package/package.json +2 -9
@@ -10,11 +10,11 @@ export declare const scammerSocialMediaSchema: z.ZodObject<{
10
10
  handle: z.ZodString;
11
11
  url: z.ZodOptional<z.ZodString>;
12
12
  }, "strip", z.ZodTypeAny, {
13
- platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "twitter" | "linkedin" | "telegram" | "olx";
13
+ platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "linkedin";
14
14
  handle: string;
15
15
  url?: string | undefined;
16
16
  }, {
17
- platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "twitter" | "linkedin" | "telegram" | "olx";
17
+ platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "linkedin";
18
18
  handle: string;
19
19
  url?: string | undefined;
20
20
  }>;
@@ -44,11 +44,11 @@ export declare const scammerFirestoreSchema: z.ZodObject<{
44
44
  handle: z.ZodString;
45
45
  url: z.ZodOptional<z.ZodString>;
46
46
  }, "strip", z.ZodTypeAny, {
47
- platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "twitter" | "linkedin" | "telegram" | "olx";
47
+ platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "linkedin";
48
48
  handle: string;
49
49
  url?: string | undefined;
50
50
  }, {
51
- platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "twitter" | "linkedin" | "telegram" | "olx";
51
+ platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "linkedin";
52
52
  handle: string;
53
53
  url?: string | undefined;
54
54
  }>, "many">;
@@ -93,7 +93,7 @@ export declare const scammerFirestoreSchema: z.ZodObject<{
93
93
  scamType: string;
94
94
  reportedBy: string;
95
95
  reportedByAnon: boolean;
96
- scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "twitter" | "telegram" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
96
+ scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
97
97
  evidence: string[];
98
98
  phones: string[];
99
99
  upiIds: string[];
@@ -102,7 +102,7 @@ export declare const scammerFirestoreSchema: z.ZodObject<{
102
102
  incidentCount: number;
103
103
  seoSlug: string;
104
104
  socialMedia: {
105
- platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "twitter" | "linkedin" | "telegram" | "olx";
105
+ platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "linkedin";
106
106
  handle: string;
107
107
  url?: string | undefined;
108
108
  }[];
@@ -133,7 +133,7 @@ export declare const scammerFirestoreSchema: z.ZodObject<{
133
133
  scamType: string;
134
134
  reportedBy: string;
135
135
  reportedByAnon: boolean;
136
- scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "twitter" | "telegram" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
136
+ scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
137
137
  evidence: string[];
138
138
  phones: string[];
139
139
  upiIds: string[];
@@ -142,7 +142,7 @@ export declare const scammerFirestoreSchema: z.ZodObject<{
142
142
  incidentCount: number;
143
143
  seoSlug: string;
144
144
  socialMedia: {
145
- platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "twitter" | "linkedin" | "telegram" | "olx";
145
+ platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "linkedin";
146
146
  handle: string;
147
147
  url?: string | undefined;
148
148
  }[];
@@ -201,7 +201,7 @@ export declare const scammerIncidentFirestoreSchema: z.ZodObject<{
201
201
  reportedBy: string;
202
202
  scammerId: string;
203
203
  reportedByAnon: boolean;
204
- scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "twitter" | "telegram" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
204
+ scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
205
205
  evidence: string[];
206
206
  verifiedBy?: string | undefined;
207
207
  amountLost?: number | undefined;
@@ -224,7 +224,7 @@ export declare const scammerIncidentFirestoreSchema: z.ZodObject<{
224
224
  reportedBy: string;
225
225
  scammerId: string;
226
226
  reportedByAnon: boolean;
227
- scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "twitter" | "telegram" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
227
+ scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
228
228
  evidence: string[];
229
229
  verifiedBy?: string | undefined;
230
230
  amountLost?: number | undefined;
@@ -50,7 +50,13 @@ export function SellerCouponsView({ onCreateClick, onEditClick, onToggle, onDele
50
50
  portal: "seller",
51
51
  title: "Coupons",
52
52
  // buildCouponSearchTxt indexes code + name + description — nothing else.
53
- searchPlaceholder: "Search by code, name or description…",
53
+ // buildCouponSearchTxt indexes exactly these three.
54
+ search: {
55
+ placeholder: "Search by code, name or description…",
56
+ mode: "partial",
57
+ fields: ["code", "name", "description"],
58
+ commit: "debounce",
59
+ },
54
60
  emptyLabel: "No coupons found — create your first coupon",
55
61
  filterKeys: ["isActive"],
56
62
  defaultSort: sortBy("createdAt", "DESC"),
@@ -24,7 +24,14 @@ export function SellerOffersView({ children, onAcceptOffer, onRejectOffer, onCou
24
24
  title: "Offers",
25
25
  // buildOfferSearchTxt indexes productTitle + productSlug + storeName — never
26
26
  // the buyer's name or email.
27
- searchPlaceholder: "Search by product or store…",
27
+ // buildOfferSearchTxt indexes productTitle + productSlug + storeName —
28
+ // never the buyer's name or email.
29
+ search: {
30
+ placeholder: "Search by product or store…",
31
+ mode: "partial",
32
+ fields: ["productTitle", "productSlug", "storeName"],
33
+ commit: "debounce",
34
+ },
28
35
  emptyLabel: "No offers received",
29
36
  filterKeys: ["status"],
30
37
  defaultSort: sortBy("createdAt", "DESC"),
@@ -297,7 +297,14 @@ export function SellerOrdersView({ orderDetailApiBase = SELLER_ENDPOINTS.ORDERS,
297
297
  // buildOrderSearchTxt indexes productTitle, storeName and trackingNumber.
298
298
  // It does NOT index the buyer's name, email or address — those are PII,
299
299
  // and the placeholder must not promise a match it will never make.
300
- searchPlaceholder: "Search by product, store or tracking number…",
300
+ // buildOrderSearchTxt indexes productTitle, storeName and trackingNumber.
301
+ // NOT the buyer's name, email or address — those are PII (D1).
302
+ search: {
303
+ placeholder: "Search by product, store or tracking number…",
304
+ mode: "partial",
305
+ fields: ["productTitle", "storeName", "trackingNumber"],
306
+ commit: "debounce",
307
+ },
301
308
  emptyLabel: "No orders yet",
302
309
  filterKeys: ["status"],
303
310
  defaultSort: DEFAULT_SORT,
@@ -220,52 +220,70 @@ const rawTesterChecklistItems = [
220
220
  description: "Verify against the seeded fixtures: \"Test Collectible — Sold Out\" (standard, hidden until \"Show sold\" is on), \"Test Auction — Already Won\" (hidden until \"Show ended\" is on), \"Test Prize Draw — Already Closed\" (hidden until \"Show closed\" is on). All three should be genuinely absent by default, not just from an unrelated broken query.",
221
221
  href: "/products",
222
222
  },
223
+ {
224
+ key: "product-type-filter-lives-in-drawer",
225
+ label: "There is NO standalone \"TYPE\" chip row on /products — the listing-type filter is a \"Listing type\" checkbox section at the TOP of the Filters drawer",
226
+ description: "Changed 2026-08-28. BEFORE: a full-width band of pill chips (Standard / Auctions / Pre-Orders / …) sat between the Available-Sold-All tabs and the product grid, and clicking one filtered instantly. AFTER: that band is gone — the availability tabs sit directly above the grid — and the same options appear as checkboxes under \"Listing type\" when you press Filters. Report it if you can still see the old chip band anywhere.",
227
+ href: "/products",
228
+ },
223
229
  {
224
230
  key: "product-type-chips-cover-all-types",
225
- label: "The TYPE chip row on /products lists ALL nine listing types — Standard, Auctions, Pre-Orders, Prize Draws, Classifieds, Digital Codes, Live Items, Art and Stickers",
226
- description: "Fixed 2026-08-21 — the row used to show only 5 chips (All / Standard / Classified / Digital Codes / Live Items), so auctions, pre-orders, prize draws, art and stickers were unreachable from the main catalogue even though items of those types existed. Count the chips: there should be nine, and none labelled \"Bundles\" (bundles are not a listing type).",
231
+ label: "The \"Listing type\" section in the /products Filters drawer lists ALL nine listing types — Standard, Auctions, Pre-Orders, Prize Draws, Classifieds, Digital Codes, Live Items, Art and Stickers",
232
+ description: "Open Filters and count the checkboxes under \"Listing type\": there should be nine, and none labelled \"Bundles\" (bundles are not a listing type). A type missing here is unreachable from the main catalogue even when items of that type exist.",
227
233
  href: "/products",
228
234
  },
229
235
  {
230
236
  key: "product-type-chips-multi-select",
231
- label: "The TYPE chips behave as CHECKBOXES, not radio buttons — several can be ticked at once, and ticking Auctions + Pre-Orders shows both types in one grid",
232
- description: "Tick Auctions, then tick Pre-Orders WITHOUT unticking Auctions. Both must stay highlighted and the grid must contain items of both types. Untick both and the grid returns to showing every type.",
237
+ label: "The \"Listing type\" boxes are CHECKBOXES, not radio buttons — ticking Auctions + Pre-Orders and pressing Apply shows both types in one grid",
238
+ description: "Tick Auctions, then tick Pre-Orders WITHOUT unticking Auctions, then press Apply. Both must stay ticked when you reopen the drawer, and the grid must contain items of both types. Untick both, Apply, and the grid returns to showing every type.",
233
239
  href: "/products",
234
240
  },
235
241
  {
236
242
  key: "product-type-chips-none-means-all",
237
- label: "With NO type chip ticked, /products shows a mix of listing types — check the coloured type badges on the cards",
243
+ label: "With NO \"Listing type\" box ticked, /products shows a mix of listing types — check the coloured type badges on the cards",
238
244
  description: "\"Nothing ticked\" means \"every type\", so you should be able to spot at least two different badges (e.g. an \"Auction\" and a \"Digital Code\") within the first page without filtering.",
239
245
  href: "/products",
240
246
  },
247
+ {
248
+ key: "product-type-filter-counts-in-badge",
249
+ label: "Ticking a \"Listing type\" box and pressing Apply increases the number on the Filters button, and \"Reset all\" in the drawer clears the type selection again",
250
+ description: "Changed 2026-08-28 — the type filter used to sit outside the drawer and was invisible to both the badge and Reset. BEFORE: pick a type, badge stays where it was, Reset all leaves the type selection in place. AFTER: the badge goes up by one, and Reset all unticks every type box and repopulates the grid with all types.",
251
+ href: "/products",
252
+ },
241
253
  {
242
254
  key: "product-type-chip-drives-sort-options",
243
- label: "Ticking exactly ONE type changes the Sort dropdown to that type's own sorts — Auctions alone offers \"Ending Soon\", Pre-Orders alone offers \"Earliest Delivery\"",
244
- description: "Tick only Auctions and open Sort: \"Ending Soon\" must be present. Untick it, tick only Pre-Orders: \"Earliest Delivery\" must be present and \"Ending Soon\" gone. With two types ticked only the sorts valid for both remain (Newest / Price / Name) — that is correct, not a bug.",
255
+ label: "Applying exactly ONE listing type changes the Sort dropdown to that type's own sorts — Auctions alone offers \"Ending Soon\", Pre-Orders alone offers \"Earliest Delivery\"",
256
+ description: "Filters → tick only Auctions → Apply, then open Sort: \"Ending Soon\" must be present. Swap to only Pre-Orders and Apply: \"Earliest Delivery\" must be present and \"Ending Soon\" gone. With two types applied only the sorts valid for both remain (Newest / Price / Name) — that is correct, not a bug.",
245
257
  href: "/products",
246
258
  },
247
259
  {
248
260
  key: "product-type-chip-sort-resets-no-empty-page",
249
261
  label: "Choosing a type-specific sort and THEN changing the type selection never leaves an empty grid or an error",
250
- description: "The important regression check. Tick Auctions, sort by \"Ending Soon\", then untick Auctions and tick Standard instead. The grid must repopulate with products. A blank page here means a stale sort leaked into the new query.",
262
+ description: "The important regression check. Apply Auctions, sort by \"Ending Soon\", then reopen Filters, untick Auctions, tick Standard, Apply. The grid must repopulate with products and the Sort dropdown must fall back to Newest. A blank page here means a stale sort leaked into the new query.",
251
263
  href: "/products",
252
264
  },
253
265
  {
254
266
  key: "product-type-toggles-follow-selection",
255
- label: "The toolbar toggles follow the type selection — \"Show ended\" appears only when a time-limited type is in play, \"Show sold\" only when a sellable type is",
256
- description: "Tick only Auctions: a \"Show ended\" toggle appears. Tick only Standard instead: \"Show ended\" disappears and \"Show sold\" remains. With nothing ticked (= all types) both may appear, which is correct.",
267
+ label: "The middle availability tab is worded for the applied types — \"Ended\" for Auctions alone, \"Sold\" for Standard alone, \"Sold & Ended\" with nothing applied",
268
+ description: "Apply only Auctions and read the middle tab above the grid; then swap to only Standard and read it again. It must re-word itself, and switching to that tab must list the unavailable items of the applied type.",
257
269
  href: "/products",
258
270
  },
259
271
  {
260
272
  key: "product-type-chip-dedicated-page-link",
261
- label: "Ticking exactly one type that has its own browse page shows a \"Full <type> filters\" link that lands on the right page",
262
- description: "Tick only Auctions — a \"Full Auctions filters\" link should appear beside the chips and open /auctions. Repeat for Pre-Orders and Prize Draws.",
273
+ label: "Ticking exactly one type that has its own browse page shows a \"Full <type> filters\" link, inside the drawer under the Listing type section, that lands on the right page",
274
+ description: "Changed 2026-08-28 — the link used to sit beside the old chip row. Open Filters, tick only Auctions: a \"Full Auctions filters →\" link appears directly under the Listing type checkboxes (before you press Apply) and opens /auctions. Repeat for Pre-Orders and Prize Draws. With two types ticked, or none, the link must NOT appear.",
263
275
  href: "/products",
264
276
  },
265
277
  {
266
278
  key: "product-type-selection-survives-reload",
267
- label: "The ticked type chips are reflected in the URL and survive a reload and the browser Back button",
268
- description: "Tick Auctions + Art, copy the URL, open it in a new tab: the same two chips must come back ticked with the same grid. Then press Back and confirm the previous selection returns.",
279
+ label: "The applied listing types are reflected in the URL and survive a reload and the browser Back button",
280
+ description: "Apply Auctions + Art, copy the URL, open it in a new tab: the grid must match and reopening Filters must show those two boxes already ticked. Then press Back and confirm the previous selection returns.",
281
+ href: "/products",
282
+ },
283
+ {
284
+ key: "product-type-pending-until-apply",
285
+ label: "Ticking a \"Listing type\" box does NOT change the grid until you press Apply — and closing the drawer with the X discards the change",
286
+ description: "Changed 2026-08-28 — the old chips filtered on every click. Tick Auctions and watch the grid behind the drawer: it must not change. Press Apply and it does. Reopen, tick Art, close the drawer with the X (not Apply), and reopen: Art must be unticked again, matching what is actually applied.",
269
287
  href: "/products",
270
288
  },
271
289
  {
@@ -282,8 +300,8 @@ const rawTesterChecklistItems = [
282
300
  },
283
301
  {
284
302
  key: "pre-orders-reachable-from-products",
285
- label: "Pre-orders are reachable from /products — tick the Pre-Orders chip and confirm real pre-order items appear with a \"Pre-Order\" badge",
286
- description: "This was the original report: pre-orders (and auctions, prize draws, art, stickers) had no chip at all, so they could only be found via their own dedicated pages.",
303
+ label: "Pre-orders are reachable from /products — Filters → Listing type → tick Pre-Orders → Apply, and confirm real pre-order items appear with a \"Pre-Order\" badge",
304
+ description: "This was the original report: pre-orders (and auctions, prize draws, art, stickers) had no entry in the type filter at all, so they could only be found via their own dedicated pages.",
287
305
  href: "/products",
288
306
  },
289
307
  {
@@ -294,7 +312,8 @@ const rawTesterChecklistItems = [
294
312
  },
295
313
  {
296
314
  key: "art-stickers-type-chips-narrow",
297
- label: "On /art, the \"Art\" and \"Stickers\" type chips each narrow the grid to only that type — neither chip nor \"All\" ever returns zero rows",
315
+ label: "On /art, the Filters drawer's \"Listing type\" section offers exactly two boxes — Art and Stickers — and each one alone narrows the grid to that type without ever returning zero rows",
316
+ description: "This page spans only two of the nine listing types, so its Listing type section must show only those two. Tick Art → Apply, then Stickers → Apply, then untick both → Apply; all three states must return rows.",
298
317
  href: "/art",
299
318
  },
300
319
  {
@@ -2338,6 +2357,131 @@ const rawTesterChecklistItems = [
2338
2357
  { key: "tabs-mobile-dropdown", label: "Tabs on category/brand/product/event detail pages collapse into a colored dropdown on mobile once there are more than 5 tabs" },
2339
2358
  ],
2340
2359
  },
2360
+ {
2361
+ pageKey: "search",
2362
+ pageLabel: "Search",
2363
+ href: "/products",
2364
+ cases: [
2365
+ {
2366
+ key: "search-typeahead-differs",
2367
+ label: "Typing \"dranzer\" and then \"dragoon\" in the header search gives DIFFERENT suggestions",
2368
+ description: "WAS: the same 5 newest rows appeared for every keystroke, because no search term reached the query at all. If both terms give an identical list, the term is still being ignored.",
2369
+ },
2370
+ {
2371
+ key: "search-typeahead-no-drafts",
2372
+ label: "Header search suggestions contain no draft or archived listings",
2373
+ description: "WAS: the suggestion query applied no status filter, so unpublished drafts were visible to the public.",
2374
+ },
2375
+ {
2376
+ key: "search-prefix-match",
2377
+ label: "Searching \"dran\" finds Dranzer products on /products",
2378
+ description: "WAS: no match at all - only whole words matched, so a partial term found nothing.",
2379
+ href: "/products",
2380
+ },
2381
+ {
2382
+ key: "search-both-words-required",
2383
+ label: "Searching \"red dranzer\" returns only items matching BOTH words, not either one",
2384
+ description: "WAS: array-contains-any made multi-word search an OR, so adding a second word made the list LONGER instead of narrower. Check the count drops versus \"dranzer\" alone.",
2385
+ href: "/products",
2386
+ },
2387
+ {
2388
+ key: "search-plus-category-filter",
2389
+ label: "A search term AND a category filter apply together on /products",
2390
+ description: "WAS: an empty if-body dropped BOTH, so the page ignored the search and the filter simultaneously and showed everything. Apply one, note the count, then add the other and confirm it narrows again.",
2391
+ href: "/products",
2392
+ },
2393
+ {
2394
+ key: "search-keeps-sort",
2395
+ label: "Changing the sort while a search term is active re-orders the results and keeps the term",
2396
+ description: "WAS: the sort was silently discarded whenever a term was present, so the dropdown said \"Oldest\" over unsorted rows.",
2397
+ href: "/products",
2398
+ },
2399
+ {
2400
+ key: "search-keeps-facets",
2401
+ label: "On /products, searching keeps the price, tag and availability facets working",
2402
+ description: "WAS: the old case-insensitive operator threw inside the query builder, and because exceptions were suppressed the throw aborted every clause AFTER it - so one search term silently disabled the rest of the filter bar.",
2403
+ href: "/products",
2404
+ },
2405
+ {
2406
+ key: "search-case-and-accents",
2407
+ label: "\"POKEMON\" with an accent, without one, and capitalised all return the same results",
2408
+ description: "WAS: matching was case- and accent-sensitive, so only the exact stored spelling matched.",
2409
+ href: "/products",
2410
+ },
2411
+ {
2412
+ key: "search-single-char-narrows",
2413
+ label: "A single-character query narrows the list instead of showing everything",
2414
+ description: "WAS: a 1-char term was discarded as too short and the unfiltered collection came back - indistinguishable from a search that matched everything.",
2415
+ href: "/products",
2416
+ },
2417
+ {
2418
+ key: "search-faqs",
2419
+ label: "Searching on /faqs returns matching questions",
2420
+ description: "WAS: this is the report that started the whole migration - 63 FAQs existed, none had search tokens, so every query returned empty.",
2421
+ href: "/faqs",
2422
+ },
2423
+ {
2424
+ key: "search-faq-category-page",
2425
+ label: "Opening a FAQ category page renders its questions",
2426
+ description: "WAS: a missing index threw FAILED_PRECONDITION, which was swallowed, leaving a blank page with no error.",
2427
+ href: "/faqs",
2428
+ },
2429
+ {
2430
+ key: "search-scams-listing",
2431
+ label: "/scams lists the verified scammer profiles",
2432
+ description: "WAS: \"No verified scammers yet\" always, because the query needed an index that did not exist.",
2433
+ href: "/scams",
2434
+ },
2435
+ {
2436
+ key: "search-scam-partial-and-upi",
2437
+ label: "On /admin/scammers, searching \"Vikram\" finds \"Vikram Mehta\", and searching a UPI id also finds its profile",
2438
+ description: "WAS: the query matched a WHOLE array element, so \"Vikram\" found nothing against a list holding \"Vikram M\" and \"Vikram Mehta\" - and phones and UPI ids were never searched at all despite the box promising them.",
2439
+ href: "/admin/scammers",
2440
+ },
2441
+ {
2442
+ key: "search-store-event-blog-review",
2443
+ label: "Store, event, blog and review searches each return matches",
2444
+ description: "WAS: never implemented for any of the four - the box existed and the endpoint ignored the term.",
2445
+ href: "/blog",
2446
+ },
2447
+ {
2448
+ key: "search-admin-exact-match",
2449
+ label: "On /admin/reviews a FULL reviewer name matches, a partial one matches nothing, and the box says \"exact match\"",
2450
+ description: "This asserts a DELIBERATE decision, not a bug: the field is encrypted, and ciphertext has no usable prefix, so it is resolved through a blind index that matches exactly. What was wrong was the placeholder - it read \"Search reviews, products, or seller names\" and matched none of those three.",
2451
+ href: "/admin/reviews",
2452
+ },
2453
+ {
2454
+ key: "search-admin-degraded-sort",
2455
+ label: "Searching on /admin/payouts shows a notice that results are not sorted while searching",
2456
+ description: "Preserving the sort would need 14 more composite indexes to order a result an exact email match bounds at one row, so the sort is dropped on purpose. WAS: dropped SILENTLY - the sort dropdown kept displaying \"Oldest\" over unsorted rows.",
2457
+ href: "/admin/payouts",
2458
+ },
2459
+ {
2460
+ key: "search-admin-team-filter-chip",
2461
+ label: "On /admin/team, applying any filter chip still returns employees",
2462
+ description: "WAS: the filter string was CONCATENATED rather than joined, producing one malformed clause that matched nothing - so the team list silently emptied the moment anyone filtered it.",
2463
+ href: "/admin/team",
2464
+ },
2465
+ {
2466
+ key: "search-no-empty-toolbar-gap",
2467
+ label: "A listing page whose search box was removed shows no empty gap in its toolbar",
2468
+ description: "31 boxes were removed because their endpoints ignored the term. The toolbar should close up, not leave a hole where the input was.",
2469
+ href: "/admin/coupons",
2470
+ },
2471
+ {
2472
+ key: "search-nonsense-term-returns-nothing",
2473
+ label: "Searching \"zzzznope\" anywhere returns ZERO results",
2474
+ description: "The single most important case here. Every bug above returned HTTP 200 with plausible-looking rows, so a real term matching something proves nothing - only a nonsense term returning nothing distinguishes \"filtering\" from \"returning everything\". Try it on /products, /faqs, /blog and /admin/scammers.",
2475
+ href: "/products",
2476
+ },
2477
+ {
2478
+ key: "search-finds-older-records",
2479
+ label: "An OLDER listing - one that existed before this feature shipped - is findable by name",
2480
+ description: "Write this one carefully. Every other case here passes on freshly seeded data while real production documents stay invisible, because search tokens are only written when a record is saved. Pick a listing that has NOT been edited recently and confirm it is findable; if it is not, the backfill did not cover it.",
2481
+ href: "/products",
2482
+ },
2483
+ ],
2484
+ },
2341
2485
  ]),
2342
2486
  ...group("community-support", "Community & Support", [
2343
2487
  {
@@ -62,6 +62,18 @@ export declare abstract class BaseRepository<T extends DocumentData> {
62
62
  update(id: string, data: Partial<T>): Promise<T>;
63
63
  delete(id: string): Promise<void>;
64
64
  exists(id: string): Promise<boolean>;
65
+ /**
66
+ * Server-side aggregation — never a full read.
67
+ *
68
+ * This used to be `getCollection().get()` then `.size`, which downloads every
69
+ * document in the collection to learn how many there are. On `products` or
70
+ * `orders` that is the entire collection billed as reads, and the payload is
71
+ * discarded immediately. Straight Rule #6 violation, and it scales with the
72
+ * data rather than staying flat.
73
+ *
74
+ * `count()` is a Firestore aggregation query: the server returns a number,
75
+ * billed at one read per 1000 documents matched rather than one per document.
76
+ */
65
77
  count(): Promise<number>;
66
78
  protected sieveQuery<TResult extends DocumentData = T>(model: SieveModel, fields: FirebaseSieveFields, options?: FirebaseSieveOptions & {
67
79
  baseQuery?: CollectionReference | Query;
@@ -218,10 +218,22 @@ export class BaseRepository {
218
218
  throw new DatabaseError(`Failed to check document existence: ${id}`, error);
219
219
  }
220
220
  }
221
+ /**
222
+ * Server-side aggregation — never a full read.
223
+ *
224
+ * This used to be `getCollection().get()` then `.size`, which downloads every
225
+ * document in the collection to learn how many there are. On `products` or
226
+ * `orders` that is the entire collection billed as reads, and the payload is
227
+ * discarded immediately. Straight Rule #6 violation, and it scales with the
228
+ * data rather than staying flat.
229
+ *
230
+ * `count()` is a Firestore aggregation query: the server returns a number,
231
+ * billed at one read per 1000 documents matched rather than one per document.
232
+ */
221
233
  async count() {
222
234
  try {
223
- const snapshot = await this.getCollection().get();
224
- return snapshot.size;
235
+ const snapshot = await this.getCollection().count().get();
236
+ return snapshot.data().count;
225
237
  }
226
238
  catch (error) {
227
239
  void normalizeError(error);
@@ -19,8 +19,18 @@ export interface UsePendingFiltersReturn {
19
19
  appliedCount: number;
20
20
  /** Update one key in pending state (does NOT write to URL) */
21
21
  set: (key: string, values: string[]) => void;
22
- /** Write all pending keys to the URL (resets page to 1) */
23
- apply: () => void;
22
+ /**
23
+ * Write all pending keys to the URL (resets page to 1).
24
+ *
25
+ * `extras` piggy-backs non-filter keys onto the SAME `router.replace` —
26
+ * the escape hatch `clearAll` already has, for the same reason. A caller
27
+ * that needs to blank `sort` alongside a filter change (a sort valid for
28
+ * one selection can be FAILED_PRECONDITION for the next) must not issue a
29
+ * second `set`: it would read stale searchParams and overwrite this update
30
+ * (Root Cause #13). Filter keys are written last, so `extras` can never
31
+ * shadow one.
32
+ */
33
+ apply: (extras?: Record<string, string>) => void;
24
34
  /** Discard pending, revert to applied (URL) state */
25
35
  reset: () => void;
26
36
  /** Clear all keys in both pending state and the URL */
@@ -47,8 +47,8 @@ export function usePendingFilters({ table, keys, }) {
47
47
  const set = useCallback((key, values) => {
48
48
  setPending((prev) => ({ ...prev, [key]: values }));
49
49
  }, []);
50
- const apply = useCallback(() => {
51
- const updates = { page: "1" };
50
+ const apply = useCallback((extras) => {
51
+ const updates = { page: "1", ...extras };
52
52
  for (const k of keys) {
53
53
  updates[k] = (pending[k] ?? []).join(",");
54
54
  }
@@ -13,8 +13,15 @@ export interface UsePendingTableReturn {
13
13
  pendingTable: PendingTable;
14
14
  /** Count of applied (URL) filter values — use for the filter badge */
15
15
  filterActiveCount: number;
16
- /** Commit all pending changes to the URL (resets page to 1) */
17
- onFilterApply: () => void;
16
+ /**
17
+ * Commit all pending changes to the URL (resets page to 1).
18
+ *
19
+ * Pass `extras` to write non-filter keys in the SAME `router.replace` —
20
+ * e.g. blanking `sort` when the applied filters invalidate it. A follow-up
21
+ * `table.set` would read stale searchParams and clobber this one
22
+ * (Root Cause #13).
23
+ */
24
+ onFilterApply: (extras?: Record<string, string>) => void;
18
25
  /** Clear all filter keys from pending state and URL */
19
26
  onFilterClear: () => void;
20
27
  /**
@@ -3281,11 +3281,11 @@ export declare const SCHEMAS: {
3281
3281
  handle: import("zod").ZodString;
3282
3282
  url: import("zod").ZodOptional<import("zod").ZodString>;
3283
3283
  }, "strip", import("zod").ZodTypeAny, {
3284
- platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "twitter" | "linkedin" | "telegram" | "olx";
3284
+ platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "linkedin";
3285
3285
  handle: string;
3286
3286
  url?: string | undefined;
3287
3287
  }, {
3288
- platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "twitter" | "linkedin" | "telegram" | "olx";
3288
+ platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "linkedin";
3289
3289
  handle: string;
3290
3290
  url?: string | undefined;
3291
3291
  }>, "many">;
@@ -3330,7 +3330,7 @@ export declare const SCHEMAS: {
3330
3330
  scamType: string;
3331
3331
  reportedBy: string;
3332
3332
  reportedByAnon: boolean;
3333
- scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "twitter" | "telegram" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
3333
+ scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
3334
3334
  evidence: string[];
3335
3335
  phones: string[];
3336
3336
  upiIds: string[];
@@ -3339,7 +3339,7 @@ export declare const SCHEMAS: {
3339
3339
  incidentCount: number;
3340
3340
  seoSlug: string;
3341
3341
  socialMedia: {
3342
- platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "twitter" | "linkedin" | "telegram" | "olx";
3342
+ platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "linkedin";
3343
3343
  handle: string;
3344
3344
  url?: string | undefined;
3345
3345
  }[];
@@ -3370,7 +3370,7 @@ export declare const SCHEMAS: {
3370
3370
  scamType: string;
3371
3371
  reportedBy: string;
3372
3372
  reportedByAnon: boolean;
3373
- scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "twitter" | "telegram" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
3373
+ scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
3374
3374
  evidence: string[];
3375
3375
  phones: string[];
3376
3376
  upiIds: string[];
@@ -3379,7 +3379,7 @@ export declare const SCHEMAS: {
3379
3379
  incidentCount: number;
3380
3380
  seoSlug: string;
3381
3381
  socialMedia: {
3382
- platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "twitter" | "linkedin" | "telegram" | "olx";
3382
+ platform: "other" | "whatsapp" | "youtube" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "linkedin";
3383
3383
  handle: string;
3384
3384
  url?: string | undefined;
3385
3385
  }[];
@@ -3438,7 +3438,7 @@ export declare const SCHEMAS: {
3438
3438
  reportedBy: string;
3439
3439
  scammerId: string;
3440
3440
  reportedByAnon: boolean;
3441
- scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "twitter" | "telegram" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
3441
+ scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
3442
3442
  evidence: string[];
3443
3443
  verifiedBy?: string | undefined;
3444
3444
  amountLost?: number | undefined;
@@ -3461,7 +3461,7 @@ export declare const SCHEMAS: {
3461
3461
  reportedBy: string;
3462
3462
  scammerId: string;
3463
3463
  reportedByAnon: boolean;
3464
- scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "twitter" | "telegram" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
3464
+ scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
3465
3465
  evidence: string[];
3466
3466
  verifiedBy?: string | undefined;
3467
3467
  amountLost?: number | undefined;
@@ -5,7 +5,25 @@
5
5
  * encrypted before storage and decrypted on read.
6
6
  */
7
7
  /** PII fields in the users collection (top-level string fields) */
8
- export declare const USER_PII_FIELDS: readonly ["email", "phoneNumber"];
8
+ /**
9
+ * `googleLinkedEmail` was added 2026-08-28, found by audit-pii-coverage.
10
+ *
11
+ * It is a real email address, written in cleartext by the Google OAuth callback
12
+ * (`api/auth/google/callback`, three write sites) and stored on the user
13
+ * document beside `email` — which has always been encrypted. So one user's two
14
+ * email addresses sat in the same document, one ciphertext and one plaintext,
15
+ * and nothing pointed at the difference.
16
+ *
17
+ * No blind index: nothing queries by it. Its only reader is the account
18
+ * holder's own profile ("Signed in as …"), which is a legitimate plaintext read.
19
+ *
20
+ * Existing rows stay plaintext until backfilled and keep reading correctly —
21
+ * `decryptValue` passes a non-`enc:v1:` string through unchanged — so new
22
+ * writes encrypt while old rows converge, never diverge. Add
23
+ * `googleLinkedEmail` to the `users` target in `backfill-pii.mjs` when that
24
+ * backfill is next run.
25
+ */
26
+ export declare const USER_PII_FIELDS: readonly ["email", "phoneNumber", "googleLinkedEmail"];
9
27
  /** Blind-index mapping for queryable user PII: source → index field name */
10
28
  export declare const USER_PII_INDEX_MAP: Record<string, string>;
11
29
  /** PII fields in the addresses subcollection */
@@ -5,7 +5,25 @@
5
5
  * encrypted before storage and decrypted on read.
6
6
  */
7
7
  /** PII fields in the users collection (top-level string fields) */
8
- export const USER_PII_FIELDS = ["email", "phoneNumber"];
8
+ /**
9
+ * `googleLinkedEmail` was added 2026-08-28, found by audit-pii-coverage.
10
+ *
11
+ * It is a real email address, written in cleartext by the Google OAuth callback
12
+ * (`api/auth/google/callback`, three write sites) and stored on the user
13
+ * document beside `email` — which has always been encrypted. So one user's two
14
+ * email addresses sat in the same document, one ciphertext and one plaintext,
15
+ * and nothing pointed at the difference.
16
+ *
17
+ * No blind index: nothing queries by it. Its only reader is the account
18
+ * holder's own profile ("Signed in as …"), which is a legitimate plaintext read.
19
+ *
20
+ * Existing rows stay plaintext until backfilled and keep reading correctly —
21
+ * `decryptValue` passes a non-`enc:v1:` string through unchanged — so new
22
+ * writes encrypt while old rows converge, never diverge. Add
23
+ * `googleLinkedEmail` to the `users` target in `backfill-pii.mjs` when that
24
+ * backfill is next run.
25
+ */
26
+ export const USER_PII_FIELDS = ["email", "phoneNumber", "googleLinkedEmail"];
9
27
  /** Blind-index mapping for queryable user PII: source → index field name */
10
28
  export const USER_PII_INDEX_MAP = {
11
29
  email: "emailIndex",
@@ -1,4 +1,5 @@
1
1
  import type { StoreDocument } from "../../features/stores/schemas/firestore";
2
+ import type { ScammerDocument } from "../../features/scams/schemas/firestore";
2
3
  import type { EventDocument } from "../../features/events/schemas/firestore";
3
4
  import type { BlogPostDocument } from "../../features/blog/schemas/firestore";
4
5
  import type { ReviewDocument } from "../../features/reviews/schemas/firestore";
@@ -12,3 +13,4 @@ export declare function withReviewSearchTxt<T extends Partial<ReviewDocument>>(p
12
13
  export declare function withOrderSearchTxt<T extends Partial<OrderDocument>>(p: T): T;
13
14
  export declare function withCouponSearchTxt<T extends Partial<CouponDocument>>(p: T): T;
14
15
  export declare function withOfferSearchTxt<T extends Partial<OfferDocument>>(p: T): T;
16
+ export declare function withScammerSearchTxt<T extends Partial<ScammerDocument>>(p: T): T;