@mohasinac/appkit 4.30.15 → 4.30.17

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 (120) 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/_internal/shared/types/action-error-reporter.d.ts +40 -0
  4. package/dist/_internal/shared/types/action-error-reporter.js +27 -0
  5. package/dist/_internal/shared/types/action-result.d.ts +10 -0
  6. package/dist/_internal/shared/types/action-result.js +26 -0
  7. package/dist/client/api/surface-error.d.ts +6 -4
  8. package/dist/client/api/surface-error.js +19 -8
  9. package/dist/contracts/realtime-session.d.ts +27 -0
  10. package/dist/contracts/realtime-session.js +118 -0
  11. package/dist/core/unit-of-work.js +21 -13
  12. package/dist/errors/base-error.js +14 -1
  13. package/dist/errors/database-error.js +11 -1
  14. package/dist/errors/describe-cause.d.ts +5 -0
  15. package/dist/errors/describe-cause.js +76 -0
  16. package/dist/errors/error-display-map.d.ts +32 -1
  17. package/dist/errors/error-display-map.js +46 -0
  18. package/dist/errors/error-mapping.d.ts +47 -7
  19. package/dist/errors/error-mapping.js +46 -5
  20. package/dist/errors/index.d.ts +1 -0
  21. package/dist/errors/index.js +4 -0
  22. package/dist/features/about/components/PublicProfileView.js +4 -4
  23. package/dist/features/account/components/AddressBook.js +2 -2
  24. package/dist/features/account/components/AddressesIndexListing.js +2 -2
  25. package/dist/features/addresses/repository/addresses.repository.d.ts +12 -1
  26. package/dist/features/addresses/repository/addresses.repository.js +16 -7
  27. package/dist/features/admin/components/AdminAnalyticsView.js +2 -2
  28. package/dist/features/admin/components/AdminCouponsView.js +2 -2
  29. package/dist/features/admin/components/AdminGuideHubView.js +2 -2
  30. package/dist/features/admin/components/AdminMediaView.js +2 -2
  31. package/dist/features/admin/components/AdminViewCards.js +2 -2
  32. package/dist/features/auctions/components/AuctionDetailPageView.js +1 -1
  33. package/dist/features/auctions/components/MarketplaceAuctionGrid.d.ts +1 -2
  34. package/dist/features/auctions/components/MarketplaceAuctionGrid.js +8 -7
  35. package/dist/features/auctions/components/PlaceBidFormClient.js +32 -15
  36. package/dist/features/auth/repository/user.repository.d.ts +22 -1
  37. package/dist/features/auth/repository/user.repository.js +31 -28
  38. package/dist/features/before-after/components/BeforeAfterGallery.js +2 -2
  39. package/dist/features/blog/components/BlogIndexListing.js +3 -3
  40. package/dist/features/blog/components/BlogListView.js +3 -3
  41. package/dist/features/blog/components/BlogPostView.js +2 -2
  42. package/dist/features/cart/repository/cart.repository.d.ts +15 -2
  43. package/dist/features/cart/repository/cart.repository.js +15 -13
  44. package/dist/features/categories/components/BundleCollage.js +2 -2
  45. package/dist/features/categories/components/CategoriesIndexListing.js +3 -3
  46. package/dist/features/categories/components/CategoryBundlesListing.js +2 -2
  47. package/dist/features/categories/components/CategoryGrid.js +2 -2
  48. package/dist/features/categories/components/CategoryProductsListing.js +2 -2
  49. package/dist/features/categories/components/CategoryStoresListing.js +2 -2
  50. package/dist/features/collections/components/CollectionCard.js +2 -2
  51. package/dist/features/events/components/EventRafflesSection.js +2 -2
  52. package/dist/features/events/components/EventsIndexListing.js +2 -2
  53. package/dist/features/events/components/EventsListView.js +3 -3
  54. package/dist/features/homepage/components/FeaturedBundlesSection.js +2 -2
  55. package/dist/features/homepage/components/GoogleReviewsSection.js +2 -2
  56. package/dist/features/homepage/components/HomepageSkeleton.js +1 -1
  57. package/dist/features/homepage/components/SecurityHighlightsSection.js +1 -1
  58. package/dist/features/homepage/components/SocialFeedSection.js +2 -2
  59. package/dist/features/homepage/components/StatsCounterSection.js +1 -1
  60. package/dist/features/homepage/components/TrustBadges.js +2 -2
  61. package/dist/features/homepage/components/TrustFeaturesSection.js +1 -1
  62. package/dist/features/messages/hooks/useConversation.js +39 -15
  63. package/dist/features/messages/hooks/useConversations.js +36 -14
  64. package/dist/features/messages/repository/conversations.repository.d.ts +23 -0
  65. package/dist/features/messages/repository/conversations.repository.js +53 -0
  66. package/dist/features/orders/repository/orders.repository.d.ts +12 -1
  67. package/dist/features/orders/repository/orders.repository.js +14 -5
  68. package/dist/features/payments/repository/payout.repository.d.ts +19 -9
  69. package/dist/features/payments/repository/payout.repository.js +26 -20
  70. package/dist/features/pre-orders/components/PreOrdersIndexListing.js +2 -3
  71. package/dist/features/products/components/AuctionsIndexListing.js +2 -3
  72. package/dist/features/products/components/PrizeDrawCollage.js +2 -2
  73. package/dist/features/products/components/PrizeDrawsIndexListing.js +2 -3
  74. package/dist/features/products/components/PrizeDrawsSection.js +2 -2
  75. package/dist/features/products/components/ProductFilters.d.ts +19 -1
  76. package/dist/features/products/components/ProductFilters.js +11 -3
  77. package/dist/features/products/components/ProductGrid.js +2 -7
  78. package/dist/features/products/components/ProductsIndexListing.d.ts +4 -2
  79. package/dist/features/products/components/ProductsIndexListing.js +41 -28
  80. package/dist/features/products/components/RelatedProducts.js +2 -2
  81. package/dist/features/promotions/components/CouponsIndexListing.js +1 -1
  82. package/dist/features/reviews/components/ReviewDetailPageView.js +2 -2
  83. package/dist/features/reviews/components/ReviewsListingPanel.js +2 -2
  84. package/dist/features/reviews/repository/reviews.repository.d.ts +10 -8
  85. package/dist/features/reviews/repository/reviews.repository.js +16 -19
  86. package/dist/features/seller/components/SellerCouponsView.js +2 -2
  87. package/dist/features/seller/components/SellerDashboardView.js +3 -3
  88. package/dist/features/server-errors/schemas/firestore.d.ts +9 -0
  89. package/dist/features/stores/components/StoreAuctionsListing.js +2 -3
  90. package/dist/features/stores/components/StoreClassifiedsListing.js +2 -3
  91. package/dist/features/stores/components/StoreDigitalCodesListing.js +2 -3
  92. package/dist/features/stores/components/StoreGuideHubView.js +2 -2
  93. package/dist/features/stores/components/StoreLiveItemsListing.js +2 -3
  94. package/dist/features/stores/components/StorePreOrdersListing.js +2 -3
  95. package/dist/features/stores/components/StoreProductsListing.js +2 -2
  96. package/dist/features/stores/components/StoresIndexListing.js +3 -3
  97. package/dist/features/tester/seed-data/tester-checklist-seed-data.js +215 -18
  98. package/dist/next/api/routeHandler.js +27 -7
  99. package/dist/providers/db-firebase/base.repository.d.ts +12 -0
  100. package/dist/providers/db-firebase/base.repository.js +48 -20
  101. package/dist/react/hooks/usePendingFilters.d.ts +12 -2
  102. package/dist/react/hooks/usePendingFilters.js +2 -2
  103. package/dist/react/hooks/usePendingTable.d.ts +9 -2
  104. package/dist/react/hooks/useRealtimeEvent.js +22 -4
  105. package/dist/security/pii-schemas.d.ts +19 -1
  106. package/dist/security/pii-schemas.js +19 -1
  107. package/dist/server.d.ts +2 -0
  108. package/dist/server.js +5 -0
  109. package/dist/styles.css +84 -20
  110. package/dist/tailwind-utilities.css +1 -1
  111. package/dist/tokens/tokens.css +7 -2
  112. package/dist/ui/components/Layout.d.ts +31 -18
  113. package/dist/ui/components/Layout.js +30 -19
  114. package/dist/ui/components/Layout.style.css +76 -17
  115. package/dist/ui/components/ListingLayout.d.ts +2 -0
  116. package/dist/ui/components/ListingLayout.js +16 -2
  117. package/dist/ui/components/StickyToolbar.js +3 -48
  118. package/dist/ui/components/toolbar-collapse.d.ts +44 -0
  119. package/dist/ui/components/toolbar-collapse.js +93 -0
  120. package/package.json +1 -1
@@ -2,6 +2,7 @@
2
2
  import { normalizeError } from "../../errors/normalize";
3
3
  import { useCallback, useEffect, useRef, useState } from "react";
4
4
  import { getClientRealtimeProvider, } from "../../contracts/client-realtime";
5
+ import { acquireExternalRealtimeLease } from "../../contracts/realtime-session";
5
6
  import { RealtimeEventType, RealtimeEventStatus, RTDBPayloadStatus, } from "./realtime-event-constants";
6
7
  // Re-exported for existing client import paths — the canonical definitions
7
8
  // now live in realtime-event-constants.ts (a plain, non-"use client" module)
@@ -31,6 +32,8 @@ export function useRealtimeEvent(config) {
31
32
  const unsubscribeRef = useRef(null);
32
33
  const timeoutRef = useRef(null);
33
34
  const eventIdRef = useRef(null);
35
+ /** Lease on the shared realtime session — see cleanup() for why. */
36
+ const releaseSessionRef = useRef(null);
34
37
  const cleanup = useCallback(() => {
35
38
  if (unsubscribeRef.current) {
36
39
  unsubscribeRef.current();
@@ -40,10 +43,20 @@ export function useRealtimeEvent(config) {
40
43
  clearTimeout(timeoutRef.current);
41
44
  timeoutRef.current = null;
42
45
  }
43
- const provider = configRef.current.realtimeProvider ?? getClientRealtimeProvider();
44
- provider.signOut().catch(() => {
45
- // no-op
46
- });
46
+ // 🛑 Deliberately NO provider.signOut() here.
47
+ //
48
+ // `FirebaseClientRealtimeProvider` is a SINGLETON on the shared
49
+ // "letitrip-realtime" app, so signing out is a global act. When a bulk job
50
+ // finished, this line tore the session out from under any admin chat or
51
+ // conversation subscription that was still open — and in reverse, those
52
+ // channels' tokens overwrote an in-flight bulk token. Whoever finished
53
+ // last broke whoever was still working.
54
+ //
55
+ // Sessions are reference-counted now (contracts/realtime-session.ts); the
56
+ // release returned by `acquireRealtimeSession` is the only thing that may
57
+ // end one, and only once the last consumer has let go.
58
+ releaseSessionRef.current?.();
59
+ releaseSessionRef.current = null;
47
60
  }, []);
48
61
  const subscribe = useCallback((eventId, customToken) => {
49
62
  const { type, rtdbPath, realtimeProvider, timeoutMs = DEFAULT_TIMEOUT_MS, extractData, messages, onLogError, } = configRef.current;
@@ -60,6 +73,11 @@ export function useRealtimeEvent(config) {
60
73
  (async () => {
61
74
  try {
62
75
  await provider.signInWithToken(customToken);
76
+ // Hold a lease for as long as this subscription lives. This hook owns
77
+ // its own sign-in (the token carries a job-scoped `bulkJobId` claim),
78
+ // but it must still participate in the ref-count so its cleanup
79
+ // cannot end a session another channel is relying on.
80
+ releaseSessionRef.current = acquireExternalRealtimeLease();
63
81
  }
64
82
  catch (authErr) {
65
83
  void normalizeError(authErr);
@@ -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",
package/dist/server.d.ts CHANGED
@@ -6,6 +6,8 @@ export { SERVER_ERRORS_COLLECTION, SERVER_ERROR_FIELDS, SERVER_ERROR_STACK_MAX_B
6
6
  export type { ServerErrorDocument, ServerErrorSource, } from "./features/server-errors/schemas/firestore";
7
7
  export { wrapAction, isOk, unwrap, } from "./_internal/shared/types/action-result";
8
8
  export type { ActionResult } from "./_internal/shared/types/action-result";
9
+ export { setActionErrorReporter, hasActionErrorReporter, } from "./_internal/shared/types/action-error-reporter";
10
+ export type { ActionErrorReport, ActionErrorReporter, } from "./_internal/shared/types/action-error-reporter";
9
11
  export { attachPaymentProofAction, adminVerifyPaymentAction, adminRequestProofReuploadAction, adminRejectPaymentAsFraudAction, raiseOrderDisputeAction, } from "./_internal/server/features/orders/actions";
10
12
  export { wrapJobHandler, wrapScheduleHandler, wrapTriggerHandler, wrapCallableHandler, } from "./_internal/server/jobs/core/wrapJobHandler";
11
13
  export { analyzeLogs } from "./_internal/server/features/maintenance/analyze";
package/dist/server.js CHANGED
@@ -11,6 +11,11 @@ export { SERVER_ERRORS_COLLECTION, SERVER_ERROR_FIELDS, SERVER_ERROR_STACK_MAX_B
11
11
  // [SERVER-ONLY] ActionResult envelope + wrapAction helper for "use server" functions.
12
12
  // Mirrors the routeHandler envelope so client wrappers consume both surfaces uniformly.
13
13
  export { wrapAction, isOk, unwrap, } from "./_internal/shared/types/action-result";
14
+ // [SERVER-ONLY] Registration seam for recording server-action failures.
15
+ // Must be called once from src/instrumentation.ts — see the module docstring
16
+ // for why it is a hook rather than a direct import, and why it is registered
17
+ // server-side rather than from a client bootstrap.
18
+ export { setActionErrorReporter, hasActionErrorReporter, } from "./_internal/shared/types/action-error-reporter";
14
19
  // [SERVER-ONLY] P-1 manual payment proof server actions.
15
20
  export { attachPaymentProofAction, adminVerifyPaymentAction, adminRequestProofReuploadAction, adminRejectPaymentAsFraudAction, raiseOrderDisputeAction, } from "./_internal/server/features/orders/actions";
16
21
  // [SERVER-ONLY] Cloud Function handler wrappers — persist exceptions to