@mohasinac/appkit 4.32.2 → 4.32.3

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.
@@ -442,6 +442,21 @@ export async function listPublicProducts(input, opts) {
442
442
  ? unavailableClausesFor(types).find((c) => c.op === "lt" && c.sortField === requestedSortField)
443
443
  : undefined;
444
444
  if (pushdown) {
445
+ /*
446
+ * 🛑 This branch keeps a POST-pagination sandbox filter, knowingly.
447
+ *
448
+ * It exists to give the ended-listing archive real, unbounded-depth
449
+ * Firestore pagination, which is incompatible with the over-fetch the
450
+ * window path uses. So an anonymous page here can come back a row or two
451
+ * SHORT when a sandbox fixture lands in it — bounded by the ~25 fixtures
452
+ * that exist, and nothing like the empty page the default view produced,
453
+ * because real ended listings dominate this scope.
454
+ *
455
+ * Falling through to Path C instead would fix the short page and cost every
456
+ * anonymous visitor the deep pagination this branch was written for. The
457
+ * short page is the better trade; it is recorded here so the next reader
458
+ * knows it was weighed rather than missed.
459
+ */
445
460
  const filters = sieveAnd(safeFilters, clauseToSieve(pushdown, now));
446
461
  const result = await runQuery(executor, {
447
462
  filters,
@@ -558,7 +573,28 @@ export async function listPublicProducts(input, opts) {
558
573
  const hasTypeFacet = Object.keys(input.typeFacets ?? {}).length > 0;
559
574
  /** Multi-value `tags`/`features` — no `array-contains-any`, so per-row. */
560
575
  const hasArrayMultiSelect = (input.tags?.length ?? 0) > 1 || (input.features?.length ?? 0) > 1;
561
- const inMemory = wantAvailable || hasTypeFacet || hasArrayMultiSelect || (hasDateRange && !canPushDate);
576
+ /*
577
+ * 🛑 The tester-sandbox filter must run BEFORE the page is sliced.
578
+ *
579
+ * It used to run only in `finish()`, which receives an already-paginated
580
+ * page — so a page whose rows were ALL sandbox fixtures came back empty with
581
+ * a non-zero `total`. That is not hypothetical: the fixtures carry
582
+ * `Date.now()`-relative dates by design (they have to re-arm on every
583
+ * reseed), so immediately after a seed load they are the newest rows in the
584
+ * collection and fill the whole first page of the default `-createdAt` sort.
585
+ * The public catalogue returned `items: []` alongside `total: 79`.
586
+ *
587
+ * So an anonymous viewer forces the bounded-window path, where the filter is
588
+ * one more per-row predicate applied before the slice. That is already the
589
+ * default for public browsing (`wantAvailable`), so this widens the window
590
+ * path only for the non-default scopes.
591
+ */
592
+ const hidesTestData = filterTestDataForViewer([{ isTestData: true }], opts?.viewer).length === 0;
593
+ const inMemory = wantAvailable ||
594
+ hasTypeFacet ||
595
+ hasArrayMultiSelect ||
596
+ hidesTestData ||
597
+ (hasDateRange && !canPushDate);
562
598
  // When a date range stays in memory, fetch in whichever direction front-loads
563
599
  // the rows that will PASS it: `dateFrom` (">=", still live) wants the most
564
600
  // future dates first; `dateTo` ("<=", ends by) wants the earliest first.
@@ -597,6 +633,10 @@ export async function listPublicProducts(input, opts) {
597
633
  return wanted.some((w) => raw.includes(w));
598
634
  };
599
635
  const filtered = items.filter((item) => {
636
+ // Before the slice — see the note on `hidesTestData` above.
637
+ if (hidesTestData && item.isTestData === true) {
638
+ return false;
639
+ }
600
640
  if (wantAvailable && !isListingRowAvailable(item, now))
601
641
  return false;
602
642
  if (hasArrayMultiSelect) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mohasinac/appkit",
3
- "version": "4.32.2",
3
+ "version": "4.32.3",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"