@mohasinac/appkit 4.52.5 → 4.53.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.
- package/dist/.build-stamp.json +4 -4
- package/dist/_internal/client/features/sticker-trace/canvas-codec.d.ts +2 -0
- package/dist/_internal/client/features/sticker-trace/canvas-codec.js +148 -0
- package/dist/_internal/server/features/auctions/actions.js +1 -1
- package/dist/_internal/server/features/categories/data.js +23 -7
- package/dist/_internal/server/features/checkout/actions.js +10 -3
- package/dist/_internal/server/features/checkout/data.d.ts +15 -0
- package/dist/_internal/server/features/checkout/data.js +20 -3
- package/dist/_internal/server/features/lottery/actions.js +9 -1
- package/dist/_internal/server/features/lottery/og.d.ts +40 -0
- package/dist/_internal/server/features/lottery/og.js +79 -0
- package/dist/_internal/server/features/messages/actions.js +4 -0
- package/dist/_internal/server/features/offers/adapters.js +17 -3
- package/dist/_internal/server/features/orders/actions.js +7 -2
- package/dist/_internal/server/features/raffle/actions.d.ts +19 -0
- package/dist/_internal/server/features/raffle/actions.js +25 -0
- package/dist/_internal/server/features/reviews/actions.js +1 -1
- package/dist/_internal/server/features/reviews/data.d.ts +1 -1
- package/dist/_internal/server/features/search/index-build/artifact-store.d.ts +89 -0
- package/dist/_internal/server/features/search/index-build/artifact-store.js +208 -0
- package/dist/_internal/server/features/search/index-build/build.d.ts +57 -0
- package/dist/_internal/server/features/search/index-build/build.js +285 -0
- package/dist/_internal/server/features/search/index-build/sources.d.ts +53 -0
- package/dist/_internal/server/features/search/index-build/sources.js +385 -0
- package/dist/_internal/server/features/search/search-sources.d.ts +0 -15
- package/dist/_internal/server/features/search/search-sources.js +142 -7
- package/dist/_internal/server/features/seo/robots.js +21 -1
- package/dist/_internal/server/features/seo/sitemap.js +1 -1
- package/dist/_internal/server/features/shared/listing-data-factory.js +16 -4
- package/dist/_internal/server/features/site-settings/adapters.d.ts +1 -1
- package/dist/_internal/server/features/site-settings/adapters.js +26 -0
- package/dist/_internal/server/features/sticker-trace/actions.d.ts +109 -0
- package/dist/_internal/server/features/sticker-trace/actions.js +172 -0
- package/dist/_internal/server/features/sticker-trace/adapters.d.ts +80 -0
- package/dist/_internal/server/features/sticker-trace/adapters.js +174 -0
- package/dist/_internal/server/features/sticker-trace/build-cut-file.d.ts +26 -0
- package/dist/_internal/server/features/sticker-trace/build-cut-file.js +127 -0
- package/dist/_internal/server/features/sticker-trace/coordinator.d.ts +27 -0
- package/dist/_internal/server/features/sticker-trace/coordinator.js +169 -0
- package/dist/_internal/server/features/sticker-trace/fanout.d.ts +43 -0
- package/dist/_internal/server/features/sticker-trace/fanout.js +180 -0
- package/dist/_internal/server/features/sticker-trace/finalizer.d.ts +25 -0
- package/dist/_internal/server/features/sticker-trace/finalizer.js +123 -0
- package/dist/_internal/server/features/sticker-trace/mosaic-inputs.d.ts +30 -0
- package/dist/_internal/server/features/sticker-trace/mosaic-inputs.js +112 -0
- package/dist/_internal/server/features/sticker-trace/progress.d.ts +81 -0
- package/dist/_internal/server/features/sticker-trace/progress.js +198 -0
- package/dist/_internal/server/features/sticker-trace/promote.d.ts +23 -0
- package/dist/_internal/server/features/sticker-trace/promote.js +193 -0
- package/dist/_internal/server/features/sticker-trace/shard.d.ts +50 -0
- package/dist/_internal/server/features/sticker-trace/shard.js +174 -0
- package/dist/_internal/server/features/sticker-trace/sheet-actions.d.ts +141 -0
- package/dist/_internal/server/features/sticker-trace/sheet-actions.js +279 -0
- package/dist/_internal/server/features/sticker-trace/storage.d.ts +135 -0
- package/dist/_internal/server/features/sticker-trace/storage.js +282 -0
- package/dist/_internal/server/functions/scheduled.d.ts +2 -1
- package/dist/_internal/server/functions/scheduled.js +25 -1
- package/dist/_internal/server/jobs/core/_event-ref.d.ts +51 -0
- package/dist/_internal/server/jobs/core/_event-ref.js +63 -0
- package/dist/_internal/server/jobs/core/assignSpinPrize.d.ts +18 -0
- package/dist/_internal/server/jobs/core/assignSpinPrize.js +77 -16
- package/dist/_internal/server/jobs/core/auctionSettlement.js +13 -4
- package/dist/_internal/server/jobs/core/autoPayoutEligibility.js +44 -15
- package/dist/_internal/server/jobs/core/bundleStockSync.js +3 -4
- package/dist/_internal/server/jobs/core/cleanupRtdbEvents.js +44 -0
- package/dist/_internal/server/jobs/core/event-draw-reasons.d.ts +78 -0
- package/dist/_internal/server/jobs/core/event-draw-reasons.js +133 -0
- package/dist/_internal/server/jobs/core/listingProcessor.js +28 -8
- package/dist/_internal/server/jobs/core/onOrderCreate.js +12 -1
- package/dist/_internal/server/jobs/core/onScamReportCreate.js +13 -2
- package/dist/_internal/server/jobs/core/onScamReportRejected.js +8 -2
- package/dist/_internal/server/jobs/core/onScamReportVerified.js +8 -2
- package/dist/_internal/server/jobs/core/onStoreWrite.js +11 -4
- package/dist/_internal/server/jobs/core/prizeDrawAssignWinner.js +5 -4
- package/dist/_internal/server/jobs/core/prizeDrawExpiryReveal.js +1 -4
- package/dist/_internal/server/jobs/core/prizeDrawSoldOutReveal.js +1 -2
- package/dist/_internal/server/jobs/core/promotions.js +7 -4
- package/dist/_internal/server/jobs/core/searchIndexBuild.d.ts +7 -0
- package/dist/_internal/server/jobs/core/searchIndexBuild.js +211 -0
- package/dist/_internal/server/jobs/core/triggerEventRaffle.d.ts +35 -0
- package/dist/_internal/server/jobs/core/triggerEventRaffle.js +213 -31
- package/dist/_internal/server/jobs/core/weeklyPayoutEligibility.js +20 -14
- package/dist/_internal/server/jobs/handlers/assignSpinPrize.d.ts +8 -0
- package/dist/_internal/server/jobs/handlers/assignSpinPrize.js +15 -15
- package/dist/_internal/server/jobs/handlers/index.d.ts +1 -0
- package/dist/_internal/server/jobs/handlers/index.js +1 -0
- package/dist/_internal/server/jobs/handlers/onCategoryWrite.js +18 -0
- package/dist/_internal/server/jobs/handlers/onProductWrite.js +18 -0
- package/dist/_internal/server/jobs/handlers/onReviewWrite.js +18 -0
- package/dist/_internal/server/jobs/handlers/onScamReportUpdate.js +18 -0
- package/dist/_internal/server/jobs/handlers/onStoreWrite.js +18 -0
- package/dist/_internal/server/jobs/handlers/searchIndexBuild.d.ts +2 -0
- package/dist/_internal/server/jobs/handlers/searchIndexBuild.js +2 -0
- package/dist/_internal/server/jobs/handlers/triggerEventRaffle.d.ts +8 -0
- package/dist/_internal/server/jobs/handlers/triggerEventRaffle.js +15 -6
- package/dist/_internal/shared/actions/action-registry.js +29 -0
- package/dist/_internal/shared/cache/revalidate-targets.d.ts +0 -1
- package/dist/_internal/shared/cache/revalidate-targets.js +10 -8
- package/dist/_internal/shared/features/events/config.d.ts +14 -0
- package/dist/_internal/shared/features/events/config.js +14 -0
- package/dist/_internal/shared/features/notifications/action-url.js +8 -0
- package/dist/_internal/shared/features/site-settings/types.d.ts +11 -0
- package/dist/_internal/shared/features/sticker-trace/codec.d.ts +81 -0
- package/dist/_internal/shared/features/sticker-trace/codec.js +30 -0
- package/dist/_internal/shared/features/sticker-trace/config.d.ts +81 -0
- package/dist/_internal/shared/features/sticker-trace/config.js +177 -0
- package/dist/_internal/shared/features/sticker-trace/cut-contour.d.ts +20 -0
- package/dist/_internal/shared/features/sticker-trace/cut-contour.js +60 -0
- package/dist/_internal/shared/features/sticker-trace/export/build-export-set.d.ts +65 -0
- package/dist/_internal/shared/features/sticker-trace/export/build-export-set.js +176 -0
- package/dist/_internal/shared/features/sticker-trace/export/cut-svg.d.ts +56 -0
- package/dist/_internal/shared/features/sticker-trace/export/cut-svg.js +120 -0
- package/dist/_internal/shared/features/sticker-trace/export/machine-profiles.d.ts +92 -0
- package/dist/_internal/shared/features/sticker-trace/export/machine-profiles.js +153 -0
- package/dist/_internal/shared/features/sticker-trace/export/nesting.d.ts +51 -0
- package/dist/_internal/shared/features/sticker-trace/export/nesting.js +110 -0
- package/dist/_internal/shared/features/sticker-trace/export/page-sizes.d.ts +68 -0
- package/dist/_internal/shared/features/sticker-trace/export/page-sizes.js +223 -0
- package/dist/_internal/shared/features/sticker-trace/export/part-tiling.d.ts +51 -0
- package/dist/_internal/shared/features/sticker-trace/export/part-tiling.js +178 -0
- package/dist/_internal/shared/features/sticker-trace/export/simplify-budget.d.ts +26 -0
- package/dist/_internal/shared/features/sticker-trace/export/simplify-budget.js +134 -0
- package/dist/_internal/shared/features/sticker-trace/export/vectorise-art.d.ts +40 -0
- package/dist/_internal/shared/features/sticker-trace/export/vectorise-art.js +195 -0
- package/dist/_internal/shared/features/sticker-trace/index.d.ts +2 -0
- package/dist/_internal/shared/features/sticker-trace/index.js +59 -0
- package/dist/_internal/shared/features/sticker-trace/math/catmull-rom.d.ts +11 -0
- package/dist/_internal/shared/features/sticker-trace/math/catmull-rom.js +66 -0
- package/dist/_internal/shared/features/sticker-trace/math/edt.d.ts +27 -0
- package/dist/_internal/shared/features/sticker-trace/math/edt.js +165 -0
- package/dist/_internal/shared/features/sticker-trace/math/label.d.ts +15 -0
- package/dist/_internal/shared/features/sticker-trace/math/label.js +156 -0
- package/dist/_internal/shared/features/sticker-trace/math/marching-squares.d.ts +16 -0
- package/dist/_internal/shared/features/sticker-trace/math/marching-squares.js +242 -0
- package/dist/_internal/shared/features/sticker-trace/math/morphology.d.ts +46 -0
- package/dist/_internal/shared/features/sticker-trace/math/morphology.js +168 -0
- package/dist/_internal/shared/features/sticker-trace/math/rasterize-path.d.ts +88 -0
- package/dist/_internal/shared/features/sticker-trace/math/rasterize-path.js +286 -0
- package/dist/_internal/shared/features/sticker-trace/math/rdp.d.ts +10 -0
- package/dist/_internal/shared/features/sticker-trace/math/rdp.js +74 -0
- package/dist/_internal/shared/features/sticker-trace/resume.d.ts +50 -0
- package/dist/_internal/shared/features/sticker-trace/resume.js +160 -0
- package/dist/_internal/shared/features/sticker-trace/trace/cluster.d.ts +20 -0
- package/dist/_internal/shared/features/sticker-trace/trace/cluster.js +132 -0
- package/dist/_internal/shared/features/sticker-trace/trace/cross-profile.d.ts +28 -0
- package/dist/_internal/shared/features/sticker-trace/trace/cross-profile.js +120 -0
- package/dist/_internal/shared/features/sticker-trace/trace/flood.d.ts +21 -0
- package/dist/_internal/shared/features/sticker-trace/trace/flood.js +104 -0
- package/dist/_internal/shared/features/sticker-trace/trace/geometry.d.ts +3 -0
- package/dist/_internal/shared/features/sticker-trace/trace/geometry.js +140 -0
- package/dist/_internal/shared/features/sticker-trace/trace/line-filter.d.ts +15 -0
- package/dist/_internal/shared/features/sticker-trace/trace/line-filter.js +138 -0
- package/dist/_internal/shared/features/sticker-trace/trace/merge.d.ts +27 -0
- package/dist/_internal/shared/features/sticker-trace/trace/merge.js +187 -0
- package/dist/_internal/shared/features/sticker-trace/trace/paper.d.ts +32 -0
- package/dist/_internal/shared/features/sticker-trace/trace/paper.js +147 -0
- package/dist/_internal/shared/features/sticker-trace/trace/prefilter.d.ts +30 -0
- package/dist/_internal/shared/features/sticker-trace/trace/prefilter.js +125 -0
- package/dist/_internal/shared/features/sticker-trace/trace/quantise.d.ts +10 -0
- package/dist/_internal/shared/features/sticker-trace/trace/quantise.js +153 -0
- package/dist/_internal/shared/features/sticker-trace/trace/ridge.d.ts +88 -0
- package/dist/_internal/shared/features/sticker-trace/trace/ridge.js +344 -0
- package/dist/_internal/shared/features/sticker-trace/trace/segment.d.ts +10 -0
- package/dist/_internal/shared/features/sticker-trace/trace/segment.js +251 -0
- package/dist/_internal/shared/features/sticker-trace/types.d.ts +197 -0
- package/dist/_internal/shared/features/sticker-trace/types.js +49 -0
- package/dist/_internal/shared/listing-types/_registry.d.ts +11 -0
- package/dist/_internal/shared/listing-types/art/config.d.ts +1 -0
- package/dist/_internal/shared/listing-types/art/config.js +1 -0
- package/dist/_internal/shared/listing-types/auction/config.d.ts +1 -0
- package/dist/_internal/shared/listing-types/auction/config.js +1 -0
- package/dist/_internal/shared/listing-types/classified/config.d.ts +1 -0
- package/dist/_internal/shared/listing-types/classified/config.js +1 -0
- package/dist/_internal/shared/listing-types/digital-code/config.d.ts +1 -0
- package/dist/_internal/shared/listing-types/digital-code/config.js +1 -0
- package/dist/_internal/shared/listing-types/feature-flags.d.ts +7 -0
- package/dist/_internal/shared/listing-types/feature-flags.js +9 -0
- package/dist/_internal/shared/listing-types/live/config.d.ts +1 -0
- package/dist/_internal/shared/listing-types/live/config.js +1 -0
- package/dist/_internal/shared/listing-types/pre-order/config.d.ts +1 -0
- package/dist/_internal/shared/listing-types/pre-order/config.js +1 -0
- package/dist/_internal/shared/listing-types/prize-draw/config.d.ts +1 -0
- package/dist/_internal/shared/listing-types/prize-draw/config.js +1 -0
- package/dist/_internal/shared/listing-types/standard/config.d.ts +1 -0
- package/dist/_internal/shared/listing-types/standard/config.js +1 -0
- package/dist/_internal/shared/listing-types/stickers/config.d.ts +1 -0
- package/dist/_internal/shared/listing-types/stickers/config.js +1 -0
- package/dist/_internal/shared/media/limits.d.ts +12 -2
- package/dist/_internal/shared/media/limits.js +12 -2
- package/dist/_internal/shared/search/artifact-url.d.ts +35 -0
- package/dist/_internal/shared/search/artifact-url.js +119 -0
- package/dist/_internal/shared/search/index-record.d.ts +68 -0
- package/dist/_internal/shared/search/index-record.js +96 -0
- package/dist/_internal/shared/search/match.d.ts +65 -0
- package/dist/_internal/shared/search/match.js +263 -0
- package/dist/client.d.ts +8 -7
- package/dist/client.js +12 -5
- package/dist/configs/eslint.js +22 -2
- package/dist/constants/api-endpoints.d.ts +68 -0
- package/dist/constants/api-endpoints.js +32 -0
- package/dist/constants/field-names.d.ts +7 -1
- package/dist/constants/field-names.js +36 -1
- package/dist/contracts/repository.d.ts +8 -7
- package/dist/contracts/search.d.ts +2 -2
- package/dist/contracts/table.d.ts +3 -3
- package/dist/contracts/table.js +3 -3
- package/dist/core/contact-submissions.repository.js +2 -2
- package/dist/core/integration-keys.js +7 -1
- package/dist/core/newsletter.repository.js +2 -2
- package/dist/core/site-config.js +1 -1
- package/dist/errors/error-codes.d.ts +30 -0
- package/dist/errors/error-codes.js +30 -0
- package/dist/errors/error-display-map.js +40 -1
- package/dist/features/account/api/[userId]/addresses/route.js +1 -1
- package/dist/features/account/components/UserBidsView.js +1 -1
- package/dist/features/account/components/index.d.ts +0 -8
- package/dist/features/account/components/index.js +0 -4
- package/dist/features/addresses/repository/addresses.repository.d.ts +17 -6
- package/dist/features/addresses/repository/addresses.repository.js +65 -9
- package/dist/features/addresses/schemas/firestore.d.ts +17 -6
- package/dist/features/admin/actions/notification-actions.js +15 -6
- package/dist/features/admin/api/bids/route.js +1 -1
- package/dist/features/admin/api/coupons/route.js +1 -1
- package/dist/features/admin/api/products/route.js +1 -1
- package/dist/features/admin/api/reviews/route.js +1 -1
- package/dist/features/admin/components/AdminAdEditorView.js +19 -5
- package/dist/features/admin/components/AdminAuditLogView.js +1 -1
- package/dist/features/admin/components/AdminBlogEditorView.js +0 -1
- package/dist/features/admin/components/AdminBlogView.js +1 -1
- package/dist/features/admin/components/AdminBrandsView.js +17 -1
- package/dist/features/admin/components/AdminCategoryEditorView.js +0 -1
- package/dist/features/admin/components/AdminContactView.js +1 -1
- package/dist/features/admin/components/AdminEmployeeEditorView.js +1 -3
- package/dist/features/admin/components/AdminNewsletterView.js +1 -1
- package/dist/features/admin/components/AdminOrdersView.js +9 -2
- package/dist/features/admin/components/AdminPayoutsView.js +1 -1
- package/dist/features/admin/components/AdminPrizeDrawsView.js +11 -0
- package/dist/features/admin/components/AdminProductEditorView.d.ts +10 -1
- package/dist/features/admin/components/AdminProductEditorView.js +24 -37
- package/dist/features/admin/components/AdminProductsView.js +10 -3
- package/dist/features/admin/components/AdminScammersView.js +1 -1
- package/dist/features/admin/components/AdminSectionsView.js +21 -5
- package/dist/features/admin/components/AdminSessionsView.js +1 -1
- package/dist/features/admin/components/AdminSublistingCategoriesView.js +22 -1
- package/dist/features/admin/components/AdminTeamView.js +1 -1
- package/dist/features/admin/components/AdminTesterChecklistItemEditorView.js +0 -1
- package/dist/features/admin/components/AdminUsersView.js +1 -1
- package/dist/features/admin/components/DataListingView.d.ts +2 -1
- package/dist/features/admin/components/DataListingView.js +9 -4
- package/dist/features/admin/components/analytics/AdminPageViewsReportView.js +0 -2
- package/dist/features/admin/hooks/useAdminListing.d.ts +1 -1
- package/dist/features/admin/repository/site-settings.repository.js +8 -3
- package/dist/features/admin/schemas/firestore.d.ts +62 -1
- package/dist/features/admin/schemas/firestore.js +32 -0
- package/dist/features/admin/types/index.d.ts +1 -1
- package/dist/features/auctions/actions/bid-actions.d.ts +2 -2
- package/dist/features/auctions/actions/bid-actions.js +16 -4
- package/dist/features/auctions/api/route.js +1 -1
- package/dist/features/auctions/components/AuctionBottomActions.js +4 -0
- package/dist/features/auctions/repository/bid.repository.d.ts +46 -4
- package/dist/features/auctions/repository/bid.repository.js +114 -13
- package/dist/features/auctions/schemas/firestore.d.ts +24 -4
- package/dist/features/auctions/schemas/firestore.js +1 -0
- package/dist/features/auth/actions/profile-actions.js +30 -4
- package/dist/features/auth/components/index.d.ts +0 -1
- package/dist/features/auth/components/index.js +0 -1
- package/dist/features/auth/repository/session.repository.d.ts +17 -3
- package/dist/features/auth/repository/session.repository.js +46 -5
- package/dist/features/auth/repository/token.repository.d.ts +27 -4
- package/dist/features/auth/repository/token.repository.js +65 -11
- package/dist/features/auth/repository/user.repository.d.ts +33 -7
- package/dist/features/auth/repository/user.repository.js +100 -15
- package/dist/features/auth/schemas/firestore.d.ts +63 -12
- package/dist/features/auth/schemas/firestore.js +11 -0
- package/dist/features/before-after/api/route.js +1 -1
- package/dist/features/blog/components/BlogListView.js +16 -3
- package/dist/features/blog/components/BlogPostView.js +1 -1
- package/dist/features/blog/schemas/index.d.ts +2 -2
- package/dist/features/cart/api/route.js +1 -1
- package/dist/features/catalogue/repository/catalogue.repository.d.ts +7 -7
- package/dist/features/catalogue/repository/catalogue.repository.js +28 -10
- package/dist/features/catalogue/schemas/firestore.d.ts +11 -0
- package/dist/features/categories/api/route.js +10 -10
- package/dist/features/categories/components/CategoryDetailPageView.js +35 -5
- package/dist/features/categories/components/CategorySelectorCreate.js +0 -1
- package/dist/features/categories/components/index.d.ts +0 -2
- package/dist/features/categories/components/index.js +0 -1
- package/dist/features/categories/repository/categories.repository.d.ts +1 -0
- package/dist/features/categories/repository/categories.repository.js +31 -1
- package/dist/features/categories/schemas/index.d.ts +2 -2
- package/dist/features/categories/utils/taxonomy-visual.d.ts +21 -0
- package/dist/features/categories/utils/taxonomy-visual.js +58 -0
- package/dist/features/checkout/actions/checkout-value-otp-actions.js +8 -1
- package/dist/features/collections/api/[slug]/route.js +3 -3
- package/dist/features/collections/api/route.js +1 -1
- package/dist/features/consultation/api/route.js +1 -1
- package/dist/features/consultation/repository/consultations.repository.js +1 -1
- package/dist/features/consultation/types/index.d.ts +1 -1
- package/dist/features/contact/components/ContactForm.js +1 -3
- package/dist/features/corporate/api/route.js +1 -1
- package/dist/features/corporate/repository/corporate.repository.js +1 -1
- package/dist/features/corporate/types/index.d.ts +1 -1
- package/dist/features/cron/jobs/auction-expiry.job.js +1 -1
- package/dist/features/cron/jobs/preorder-reminder.job.js +1 -1
- package/dist/features/events/actions/event-actions.d.ts +14 -0
- package/dist/features/events/actions/event-actions.js +82 -3
- package/dist/features/events/api/[id]/route.js +2 -2
- package/dist/features/events/components/AdminEventEditorView.js +22 -3
- package/dist/features/events/components/AdminEventsView.js +32 -8
- package/dist/features/events/components/EventRafflesSection.d.ts +34 -1
- package/dist/features/events/components/EventRafflesSection.js +52 -3
- package/dist/features/events/components/SpinWheelView.d.ts +2 -2
- package/dist/features/events/components/SpinWheelView.js +41 -4
- package/dist/features/events/repository/event-entry.repository.d.ts +14 -2
- package/dist/features/events/repository/event-entry.repository.js +41 -7
- package/dist/features/events/schemas/firestore.d.ts +17 -4
- package/dist/features/events/types/index.d.ts +37 -0
- package/dist/features/faq/repository/faqs.repository.js +1 -1
- package/dist/features/faq/schemas/index.d.ts +5 -2
- package/dist/features/faq/schemas/index.js +6 -0
- package/dist/features/faq/types/index.d.ts +0 -1
- package/dist/features/grouped/components/GroupedListingEditorView.js +17 -2
- package/dist/features/homepage/api/carousel/[id]/route.js +1 -1
- package/dist/features/homepage/api/carousel/route.js +4 -4
- package/dist/features/homepage/api/route.js +2 -2
- package/dist/features/homepage/api/sections/route.js +1 -1
- package/dist/features/homepage/components/AnnouncementBar.d.ts +1 -9
- package/dist/features/homepage/components/AnnouncementBar.js +13 -19
- package/dist/features/homepage/components/MarketplaceHomepageView.js +6 -1
- package/dist/features/homepage/components/index.d.ts +0 -2
- package/dist/features/homepage/components/index.js +0 -1
- package/dist/features/homepage/repository/homepage.repository.js +1 -1
- package/dist/features/homepage/schemas/firestore.d.ts +6 -0
- package/dist/features/homepage/schemas/index.d.ts +10 -10
- package/dist/features/layout/AppLayoutShell.d.ts +11 -0
- package/dist/features/layout/AppLayoutShell.js +64 -12
- package/dist/features/layout/BottomActionsContext.d.ts +16 -0
- package/dist/features/layout/BottomActionsContext.js +5 -0
- package/dist/features/layout/BottomChrome.js +48 -9
- package/dist/features/layout/BottomNavbar.d.ts +14 -0
- package/dist/features/layout/BottomNavbar.js +43 -3
- package/dist/features/layout/MainNavbar.d.ts +11 -0
- package/dist/features/layout/NavbarLayout.d.ts +3 -0
- package/dist/features/layout/NavbarLayout.js +88 -11
- package/dist/features/layout/SideActionDock.d.ts +1 -0
- package/dist/features/layout/SideActionDock.js +219 -0
- package/dist/features/layout/TitleBarLayout.js +1 -1
- package/dist/features/layout/cta-anchor.d.ts +31 -0
- package/dist/features/layout/cta-anchor.js +31 -0
- package/dist/features/layout/hooks/useBottomActions.d.ts +7 -0
- package/dist/features/layout/hooks/useBottomActions.js +6 -1
- package/dist/features/layout/index.d.ts +9 -1
- package/dist/features/layout/index.js +9 -1
- package/dist/features/layout/useCtaReveal.d.ts +24 -0
- package/dist/features/layout/useCtaReveal.js +82 -0
- package/dist/features/layout/useHoldToOpen.d.ts +41 -0
- package/dist/features/layout/useHoldToOpen.js +84 -0
- package/dist/features/lottery/repository/lottery-entry.repository.d.ts +18 -3
- package/dist/features/lottery/repository/lottery-entry.repository.js +48 -6
- package/dist/features/lottery/schemas/firestore.d.ts +33 -5
- package/dist/features/loyalty/api/balance/route.js +1 -1
- package/dist/features/loyalty/api/history/route.js +1 -1
- package/dist/features/media/MediaImage.js +0 -1
- package/dist/features/media/MediaPickerModal.js +7 -1
- package/dist/features/media/modals/ImageEditor.js +5 -1
- package/dist/features/media/modals/VideoThumbnailSelector.js +17 -1
- package/dist/features/media/repository/media-assets.repository.d.ts +19 -0
- package/dist/features/media/upload/CameraCapture.js +16 -1
- package/dist/features/media/upload/ImageUpload.js +42 -4
- package/dist/features/media/upload/MediaUploadField.js +69 -13
- package/dist/features/media/upload/downscale-image.d.ts +56 -0
- package/dist/features/media/upload/downscale-image.js +150 -0
- package/dist/features/messages/components/ConversationThreadView.js +45 -2
- package/dist/features/messages/components/MessageSellerButton.d.ts +15 -1
- package/dist/features/messages/components/MessageSellerButton.js +10 -2
- package/dist/features/messages/schemas/firestore.d.ts +15 -0
- package/dist/features/orders/hooks/useOrders.js +4 -2
- package/dist/features/orders/repository/orders.repository.d.ts +15 -4
- package/dist/features/orders/repository/orders.repository.js +52 -20
- package/dist/features/orders/schemas/firestore.d.ts +15 -4
- package/dist/features/orders/schemas/index.d.ts +8 -8
- package/dist/features/orders/types/index.d.ts +2 -2
- package/dist/features/payments/repository/payments.repository.js +2 -2
- package/dist/features/payments/repository/payout.repository.d.ts +23 -6
- package/dist/features/payments/repository/payout.repository.js +63 -23
- package/dist/features/payments/repository/saved-payment-methods.repository.d.ts +17 -6
- package/dist/features/payments/repository/saved-payment-methods.repository.js +59 -11
- package/dist/features/payments/schemas/firestore.d.ts +14 -3
- package/dist/features/payments/schemas/saved-methods-firestore.d.ts +12 -1
- package/dist/features/pre-orders/api/[slug]/route.js +1 -1
- package/dist/features/pre-orders/api/admin/route.js +1 -1
- package/dist/features/pre-orders/api/route.js +1 -1
- package/dist/features/pre-orders/repository/pre-orders.repository.d.ts +3 -3
- package/dist/features/pre-orders/repository/pre-orders.repository.js +6 -6
- package/dist/features/products/api/[id]/route.js +1 -1
- package/dist/features/products/components/ListingBottomActions.js +4 -0
- package/dist/features/products/components/ProductDetailPageView.js +2 -1
- package/dist/features/products/components/ProductGalleryClient.js +2 -2
- package/dist/features/products/components/ProductGrid.js +12 -1
- package/dist/features/products/components/index.d.ts +0 -2
- package/dist/features/products/components/index.js +0 -1
- package/dist/features/products/config/listing-type-listing-config.d.ts +0 -3
- package/dist/features/products/config/listing-type-listing-config.js +27 -2
- package/dist/features/products/constants/listing-tabs.d.ts +9 -0
- package/dist/features/products/constants/listing-tabs.js +3 -2
- package/dist/features/products/hooks/useProducts.js +2 -2
- package/dist/features/products/repository/products.repository.js +13 -1
- package/dist/features/products/schemas/index.d.ts +2 -2
- package/dist/features/products/types/index.d.ts +1 -1
- package/dist/features/promotions/api/route.js +1 -1
- package/dist/features/reviews/actions/review-actions.d.ts +6 -6
- package/dist/features/reviews/actions/review-actions.js +22 -8
- package/dist/features/reviews/components/ReviewDetailPageView.js +13 -1
- package/dist/features/reviews/components/ReviewsIndexPageView.js +21 -4
- package/dist/features/reviews/repository/reviews.repository.d.ts +19 -7
- package/dist/features/reviews/repository/reviews.repository.js +63 -12
- package/dist/features/reviews/schemas/firestore.d.ts +13 -2
- package/dist/features/reviews/schemas/index.d.ts +2 -2
- package/dist/features/scams/actions/scam-actions.js +16 -4
- package/dist/features/search/components/SearchResultsPageView.js +2 -1
- package/dist/features/search/hooks/useSearchIndex.d.ts +34 -0
- package/dist/features/search/hooks/useSearchIndex.js +172 -0
- package/dist/features/search/repository/search.repository.js +2 -2
- package/dist/features/seller/actions/offer-actions.d.ts +5 -5
- package/dist/features/seller/actions/offer-actions.js +38 -8
- package/dist/features/seller/actions/seller-actions.js +34 -7
- package/dist/features/seller/api/coupons/route.js +1 -1
- package/dist/features/seller/api/products/route.js +1 -1
- package/dist/features/seller/api/store/route.js +1 -1
- package/dist/features/seller/components/SellerBidsView.js +1 -1
- package/dist/features/seller/components/SellerCouponsView.js +1 -1
- package/dist/features/seller/components/SellerListingTypeView.js +9 -1
- package/dist/features/seller/components/SellerOrdersView.js +1 -1
- package/dist/features/seller/components/SellerPayoutSettingsView.js +0 -1
- package/dist/features/seller/components/SellerPayoutsView.js +1 -1
- package/dist/features/seller/components/SellerProductShell.js +0 -1
- package/dist/features/seller/components/SellerProductsView.js +1 -1
- package/dist/features/seller/components/SellerShippingView.js +0 -1
- package/dist/features/seller/components/SellerStorefrontView.js +0 -1
- package/dist/features/seller/components/index.d.ts +0 -4
- package/dist/features/seller/components/index.js +0 -2
- package/dist/features/seller/repository/offer.repository.d.ts +15 -3
- package/dist/features/seller/repository/offer.repository.js +43 -7
- package/dist/features/seller/schemas/firestore.d.ts +14 -3
- package/dist/features/seller/schemas/index.d.ts +4 -4
- package/dist/features/seller/schemas/order-forms.d.ts +39 -0
- package/dist/features/seller/schemas/order-forms.js +37 -0
- package/dist/features/shell/FormShell.js +6 -2
- package/dist/features/shell/QuickFormDrawer.js +15 -1
- package/dist/features/shipments/components/AdminShipmentEditorView.js +0 -1
- package/dist/features/shipments/components/AdminShipmentsView.js +1 -1
- package/dist/features/sticker-trace/components/StickerCommitPanel.d.ts +30 -0
- package/dist/features/sticker-trace/components/StickerCommitPanel.js +93 -0
- package/dist/features/sticker-trace/components/StickerPrintPanel.d.ts +33 -0
- package/dist/features/sticker-trace/components/StickerPrintPanel.js +104 -0
- package/dist/features/sticker-trace/components/StickerRetryPanel.d.ts +20 -0
- package/dist/features/sticker-trace/components/StickerRetryPanel.js +128 -0
- package/dist/features/sticker-trace/components/StickerRunHistoryPanel.d.ts +45 -0
- package/dist/features/sticker-trace/components/StickerRunHistoryPanel.js +84 -0
- package/dist/features/sticker-trace/components/StickerTraceStudio.d.ts +27 -0
- package/dist/features/sticker-trace/components/StickerTraceStudio.js +171 -0
- package/dist/features/sticker-trace/constants/help-content.d.ts +23 -0
- package/dist/features/sticker-trace/constants/help-content.js +172 -0
- package/dist/features/sticker-trace/hooks/useLiveTrace.d.ts +27 -0
- package/dist/features/sticker-trace/hooks/useLiveTrace.js +160 -0
- package/dist/features/sticker-trace/hooks/useStickerTraceProgress.d.ts +22 -0
- package/dist/features/sticker-trace/hooks/useStickerTraceProgress.js +106 -0
- package/dist/features/sticker-trace/repository/sticker-sheets.repository.d.ts +113 -0
- package/dist/features/sticker-trace/repository/sticker-sheets.repository.js +146 -0
- package/dist/features/sticker-trace/repository/sticker-trace-runs.repository.d.ts +132 -0
- package/dist/features/sticker-trace/repository/sticker-trace-runs.repository.js +174 -0
- package/dist/features/sticker-trace/schemas/firestore.d.ts +248 -0
- package/dist/features/sticker-trace/schemas/firestore.js +79 -0
- package/dist/features/sticker-trace/server.d.ts +8 -0
- package/dist/features/sticker-trace/server.js +51 -0
- package/dist/features/stores/actions/store-query-actions.d.ts +2 -2
- package/dist/features/stores/actions/store-query-actions.js +7 -2
- package/dist/features/stores/api/[storeSlug]/auctions/route.js +3 -3
- package/dist/features/stores/api/[storeSlug]/products/route.js +3 -3
- package/dist/features/stores/api/[storeSlug]/reviews/route.js +1 -1
- package/dist/features/stores/api/[storeSlug]/route.js +1 -1
- package/dist/features/stores/components/StoreNavTabs.js +17 -2
- package/dist/features/stores/manifest.js +8 -4
- package/dist/features/support/repository/support.repository.d.ts +14 -3
- package/dist/features/support/repository/support.repository.js +93 -13
- package/dist/features/support/schemas/firestore.d.ts +16 -5
- package/dist/features/tester/seed-data/authored/admin__events-raffles-spin.js +61 -19
- package/dist/features/tester/seed-data/authored/buying__browsing-search.js +19 -3
- package/dist/features/tester/seed-data/authored/content-discovery__authenticity-checker.d.ts +2 -0
- package/dist/features/tester/seed-data/authored/content-discovery__authenticity-checker.js +243 -0
- package/dist/features/tester/seed-data/authored/content-discovery__events.js +36 -10
- package/dist/features/tester/seed-data/authored/content-discovery__overflowing-pill-rows.d.ts +2 -0
- package/dist/features/tester/seed-data/authored/content-discovery__overflowing-pill-rows.js +209 -0
- package/dist/features/tester/seed-data/authored/design-ux__header-brand-mark-centring.d.ts +2 -0
- package/dist/features/tester/seed-data/authored/design-ux__header-brand-mark-centring.js +90 -0
- package/dist/features/tester/seed-data/authored/index.js +8 -0
- package/dist/features/tester/seed-data/authored/selling__media-limits.js +19 -17
- package/dist/features/tester/seed-data/authored/selling__product-upload-details.js +10 -5
- package/dist/features/tester/seed-data/authored/tools__sticker-tracer.d.ts +2 -0
- package/dist/features/tester/seed-data/authored/tools__sticker-tracer.js +283 -0
- package/dist/features/tester/seed-data/tester-checklist-seed-data.js +192 -22
- package/dist/index.d.ts +10 -23
- package/dist/index.js +27 -19
- package/dist/next/api/routeHandler.js +9 -0
- package/dist/next/routing/require-record.d.ts +13 -0
- package/dist/next/routing/require-record.js +62 -0
- package/dist/next/routing/route-map.d.ts +4 -4
- package/dist/next/routing/route-map.js +25 -3
- package/dist/providers/db-firebase/base.d.ts +4 -2
- package/dist/providers/db-firebase/base.js +21 -5
- package/dist/providers/db-firebase/base.repository.d.ts +11 -9
- package/dist/providers/db-firebase/base.repository.js +19 -0
- package/dist/providers/db-firebase/rtdb-paths.d.ts +12 -0
- package/dist/providers/db-firebase/rtdb-paths.js +12 -0
- package/dist/react/ErrorBoundary.js +6 -1
- package/dist/react/hooks/realtime-event-constants.d.ts +1 -0
- package/dist/react/hooks/realtime-event-constants.js +8 -0
- package/dist/react/hooks/useEntityDelete.js +5 -1
- package/dist/react/hooks/useMessage.js +5 -1
- package/dist/repositories/index.d.ts +2 -2
- package/dist/repositories/index.js +6 -1
- package/dist/schemas/registry.d.ts +13 -20
- package/dist/schemas/registry.js +31 -14
- package/dist/schemas/webhooks/google-oauth.d.ts +2 -2
- package/dist/security/encrypted.d.ts +117 -0
- package/dist/security/encrypted.js +100 -0
- package/dist/security/index.d.ts +5 -2
- package/dist/security/index.js +16 -2
- package/dist/security/pii-accessors.d.ts +71 -0
- package/dist/security/pii-accessors.js +150 -0
- package/dist/security/pii-encrypt.d.ts +0 -8
- package/dist/security/pii-encrypt.js +22 -15
- package/dist/security/pii-mask.d.ts +18 -0
- package/dist/security/pii-mask.js +27 -0
- package/dist/seed/_helpers/search-txt-wrappers.d.ts +6 -6
- package/dist/seed/_helpers/search-txt-wrappers.js +22 -0
- package/dist/seed/addresses-seed-data.d.ts +2 -2
- package/dist/seed/authenticity-knowledge-seed-data.d.ts +34 -0
- package/dist/seed/authenticity-knowledge-seed-data.js +1277 -0
- package/dist/seed/bids-seed-data.d.ts +2 -2
- package/dist/seed/bids-seed-data.js +23 -2
- package/dist/seed/events-seed-data.d.ts +2 -2
- package/dist/seed/events-seed-data.js +5 -0
- package/dist/seed/faq-seed-data.js +175 -5
- package/dist/seed/homepage-sections-seed-data.js +39 -23
- package/dist/seed/index.d.ts +1 -0
- package/dist/seed/index.js +1 -0
- package/dist/seed/lottery-entries-seed-data.d.ts +2 -2
- package/dist/seed/offers-seed-data.d.ts +2 -2
- package/dist/seed/offers-seed-data.js +1 -1
- package/dist/seed/orders-seed-data.d.ts +2 -2
- package/dist/seed/payouts-seed-data.d.ts +2 -2
- package/dist/seed/payouts-seed-data.js +1 -1
- package/dist/seed/reviews-seed-data.d.ts +1 -2
- package/dist/seed/seed-purpose.js +7 -0
- package/dist/seed/sessions-seed-data.d.ts +2 -2
- package/dist/seed/sessions-seed-data.js +5 -0
- package/dist/seed/site-settings-seed-data.js +1 -1
- package/dist/seed/support-tickets-seed-data.d.ts +2 -2
- package/dist/seed/support-tickets-seed-data.js +1 -1
- package/dist/seed/users-seed-data.d.ts +2 -2
- package/dist/seed/users-seed-data.js +1 -1
- package/dist/seo/json-ld.js +5 -1
- package/dist/server.d.ts +18 -3
- package/dist/server.js +59 -3
- package/dist/styles.css +237 -1
- package/dist/tailwind-utilities.css +1 -1
- package/dist/ui/components/Button.js +7 -1
- package/dist/ui/components/FilterChipGroup.d.ts +11 -0
- package/dist/ui/components/FilterChipGroup.js +1 -1
- package/dist/ui/components/ImageGallery.js +6 -1
- package/dist/ui/components/ListingLayout.js +14 -8
- package/dist/ui/components/OverflowRow.d.ts +92 -0
- package/dist/ui/components/OverflowRow.js +203 -0
- package/dist/ui/components/OverflowRow.style.css +235 -0
- package/dist/ui/components/RecordDetailModal.js +14 -1
- package/dist/ui/components/RowActionMenu.js +5 -1
- package/dist/ui/components/SideDrawer.js +5 -1
- package/dist/ui/components/SideModal.js +9 -1
- package/dist/ui/components/TabBarShell.d.ts +12 -1
- package/dist/ui/components/TabBarShell.js +3 -2
- package/dist/ui/components/Tabs.js +36 -24
- package/dist/ui/components/Toast.d.ts +3 -24
- package/dist/ui/components/Toast.js +2 -19
- package/dist/ui/components/TopBannerPortal.d.ts +15 -0
- package/dist/ui/components/TopBannerPortal.js +19 -0
- package/dist/ui/components/UnsavedChangesModal.js +5 -1
- package/dist/ui/components/index.style.css +1 -0
- package/dist/ui/components/row-collapse.d.ts +15 -0
- package/dist/ui/components/row-collapse.js +127 -0
- package/dist/ui/components/toast-context.d.ts +63 -0
- package/dist/ui/components/toast-context.js +48 -0
- package/dist/ui/components/top-banner-slot.d.ts +37 -0
- package/dist/ui/components/top-banner-slot.js +45 -0
- package/dist/ui/icons/icon-registry.d.ts +6 -0
- package/dist/ui/icons/icon-registry.js +17 -1
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.js +1 -0
- package/dist/utils/array.helper.d.ts +2 -2
- package/dist/utils/array.helper.js +5 -5
- package/dist/utils/id-generators.d.ts +6 -0
- package/dist/utils/id-generators.js +10 -0
- package/dist/utils/media-url.js +0 -2
- package/dist/utils/search-txt-builders.d.ts +28 -4
- package/dist/utils/search-txt-builders.js +41 -1
- package/dist/validation/schemas.d.ts +8 -8
- package/package.json +6 -2
- package/scripts/seed-cli.mjs +3 -0
- package/dist/features/account/components/UserAddressesView.d.ts +0 -13
- package/dist/features/account/components/UserAddressesView.js +0 -5
- package/dist/features/account/components/UserNotificationsView.d.ts +0 -15
- package/dist/features/account/components/UserNotificationsView.js +0 -12
- package/dist/features/account/components/UserSettingsView.d.ts +0 -16
- package/dist/features/account/components/UserSettingsView.js +0 -13
- package/dist/features/account/components/UserSupportView.d.ts +0 -3
- package/dist/features/account/components/UserSupportView.js +0 -166
- package/dist/features/admin/components/DemoSeedView.d.ts +0 -11
- package/dist/features/admin/components/DemoSeedView.js +0 -5
- package/dist/features/auth/components/AuthStatusPanel.d.ts +0 -10
- package/dist/features/auth/components/AuthStatusPanel.js +0 -22
- package/dist/features/categories/components/CategoryProductsView.d.ts +0 -45
- package/dist/features/categories/components/CategoryProductsView.js +0 -21
- package/dist/features/homepage/components/HowItWorksInfoView.d.ts +0 -36
- package/dist/features/homepage/components/HowItWorksInfoView.js +0 -10
- package/dist/features/layout/BottomActions.d.ts +0 -1
- package/dist/features/layout/BottomActions.js +0 -311
- package/dist/features/products/components/ProductsView.d.ts +0 -6
- package/dist/features/products/components/ProductsView.js +0 -5
- package/dist/features/seller/components/SellerStoreView.d.ts +0 -8
- package/dist/features/seller/components/SellerStoreView.js +0 -8
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* WHY: Exactly one invocation gets to say a run finished, and it is the only
|
|
3
|
+
* place that can — it alone knows every shard is done.
|
|
4
|
+
* WHAT: Overlay, cut SVG, the run's terminal status, and task cleanup.
|
|
5
|
+
*
|
|
6
|
+
* 🛑 Owns the `exports` TRACE_STAGE for audit-sticker-trace-progress R2, which
|
|
7
|
+
* with coordinator.ts's nine and shard.ts's `parts` completes all 11.
|
|
8
|
+
*
|
|
9
|
+
* EXPORTS: runFinalizer, FinalizerDeps
|
|
10
|
+
*
|
|
11
|
+
* @tag domain:sticker-trace
|
|
12
|
+
* @tag layer:server
|
|
13
|
+
* @tag pattern:none
|
|
14
|
+
* @tag access:server
|
|
15
|
+
* @tag consumers:functions/consumer-functions
|
|
16
|
+
* @tag sideEffects:firestore,storage,rtdb
|
|
17
|
+
*/
|
|
18
|
+
import { normalizeError } from "../../../../errors/normalize.js";
|
|
19
|
+
import { serverLogger } from "../../../../monitoring/index.js";
|
|
20
|
+
import { getAdminDb } from "../../../../providers/db-firebase/index.js";
|
|
21
|
+
import { stickerTraceRunsRepository } from "../../../../features/sticker-trace/repository/sticker-trace-runs.repository.js";
|
|
22
|
+
import { STICKER_TRACE_TASKS_COLLECTION, } from "../../../../features/sticker-trace/schemas/firestore.js";
|
|
23
|
+
import { emitProgress, emitTerminalFailure } from "./progress.js";
|
|
24
|
+
export async function runFinalizer(task, deps) {
|
|
25
|
+
const { runId, sheetId } = task;
|
|
26
|
+
let run = null;
|
|
27
|
+
try {
|
|
28
|
+
run = await stickerTraceRunsRepository.findByIdOrFail(runId);
|
|
29
|
+
await emitProgress({ runId, stage: "exports", pct: 94, prior: run });
|
|
30
|
+
/*
|
|
31
|
+
* No exporter wired yet -> the run still SUCCEEDS, with no cutSvgPath.
|
|
32
|
+
* Writing a placeholder artifact was the alternative and is worse: a zero
|
|
33
|
+
* length cut.svg is indistinguishable from a real one that failed to
|
|
34
|
+
* generate, and the review UI would offer a download that cuts nothing.
|
|
35
|
+
* An absent field is honest and is what the UI can branch on.
|
|
36
|
+
*/
|
|
37
|
+
let cutSvgPath;
|
|
38
|
+
if (deps.buildCutSvg) {
|
|
39
|
+
const svg = await deps.buildCutSvg(runId, sheetId);
|
|
40
|
+
const cut = await deps.writeArtifact({
|
|
41
|
+
sheetId,
|
|
42
|
+
runId,
|
|
43
|
+
name: "cut.svg",
|
|
44
|
+
contentType: "image/svg+xml",
|
|
45
|
+
body: svg,
|
|
46
|
+
});
|
|
47
|
+
cutSvgPath = cut.assetPath;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
serverLogger.info("Sticker trace finished without a cut file (no exporter wired)", {
|
|
51
|
+
runId,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
run = await stickerTraceRunsRepository.markSucceeded(runId, {
|
|
55
|
+
partCount: run.partCount,
|
|
56
|
+
groupCount: run.groupCount,
|
|
57
|
+
artifacts: {
|
|
58
|
+
...run.artifacts,
|
|
59
|
+
...(cutSvgPath ? { cutSvgPath } : {}),
|
|
60
|
+
},
|
|
61
|
+
}, run);
|
|
62
|
+
await emitProgress({
|
|
63
|
+
runId,
|
|
64
|
+
stage: "done",
|
|
65
|
+
pct: 100,
|
|
66
|
+
terminal: true,
|
|
67
|
+
prior: run,
|
|
68
|
+
});
|
|
69
|
+
/*
|
|
70
|
+
* 🛑 Tasks are deleted LAST, and only after the run is terminal. Deleting
|
|
71
|
+
* them first would make a redelivered finalizer re-run against a run whose
|
|
72
|
+
* election record no longer exists — the one state where `create()` at the
|
|
73
|
+
* fixed id cannot refuse it.
|
|
74
|
+
*
|
|
75
|
+
* The counter doc goes too: it is per-run bookkeeping, and leaving it
|
|
76
|
+
* behind turns `stickerTraceTasks` into the unpruned collection the
|
|
77
|
+
* Firebase budget notes are about.
|
|
78
|
+
*/
|
|
79
|
+
await deleteRunTasks(runId);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
const n = normalizeError(err);
|
|
83
|
+
serverLogger.error("Sticker trace finalizer failed", { runId, message: n.message });
|
|
84
|
+
/*
|
|
85
|
+
* The parts ARE rendered at this point — only the export failed — so this
|
|
86
|
+
* deliberately does NOT delete the tasks. A retry can resume from
|
|
87
|
+
* `exports` rather than re-rendering everything, which is exactly what the
|
|
88
|
+
* resume clamp exists to allow.
|
|
89
|
+
*/
|
|
90
|
+
await emitTerminalFailure(runId, {
|
|
91
|
+
stage: "exports",
|
|
92
|
+
code: "FINALIZER_FAILED",
|
|
93
|
+
message: "The parts were traced but the cut file could not be written. Retry from exports.",
|
|
94
|
+
}, run);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async function deleteRunTasks(runId) {
|
|
98
|
+
const db = getAdminDb();
|
|
99
|
+
const snap = await db
|
|
100
|
+
.collection(STICKER_TRACE_TASKS_COLLECTION)
|
|
101
|
+
.where("runId", "==", runId)
|
|
102
|
+
.get();
|
|
103
|
+
if (snap.empty)
|
|
104
|
+
return;
|
|
105
|
+
/*
|
|
106
|
+
* BulkWriter rather than a hand-sized batch: it sizes and retries its own
|
|
107
|
+
* requests, so it is correct regardless of document size. A 400-doc batch is
|
|
108
|
+
* a guess that broke on `categories` with `Transaction too big`.
|
|
109
|
+
*/
|
|
110
|
+
const writer = db.bulkWriter();
|
|
111
|
+
/*
|
|
112
|
+
* `void` because `close()` is the await point, not each delete.
|
|
113
|
+
*
|
|
114
|
+
* BulkWriter returns a promise per operation and resolves them through
|
|
115
|
+
* `close()`, which also surfaces their failures — so awaiting each delete
|
|
116
|
+
* here would serialise the whole batch and defeat the reason BulkWriter was
|
|
117
|
+
* chosen. Marking them ignored is the rule's own prescribed form, and it is
|
|
118
|
+
* accurate: they are not unhandled, they are handled one line down.
|
|
119
|
+
*/
|
|
120
|
+
for (const doc of snap.docs)
|
|
121
|
+
void writer.delete(doc.ref);
|
|
122
|
+
await writer.close();
|
|
123
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type PrintPageSizeId } from "../../../shared/features/sticker-trace/export/page-sizes";
|
|
2
|
+
export interface MosaicPartInput {
|
|
3
|
+
ordinal: number;
|
|
4
|
+
name: string;
|
|
5
|
+
page: number;
|
|
6
|
+
xMm: number;
|
|
7
|
+
yMm: number;
|
|
8
|
+
widthMm: number;
|
|
9
|
+
heightMm: number;
|
|
10
|
+
rotated: boolean;
|
|
11
|
+
/** The promoted full-resolution PNG. */
|
|
12
|
+
png: Uint8Array;
|
|
13
|
+
}
|
|
14
|
+
export interface MosaicInputs {
|
|
15
|
+
title: string;
|
|
16
|
+
pageWidthMm: number;
|
|
17
|
+
pageHeightMm: number;
|
|
18
|
+
pageCount: number;
|
|
19
|
+
parts: MosaicPartInput[];
|
|
20
|
+
/** Parts that could not be placed on any page, named for the caller to report. */
|
|
21
|
+
unplaceable: Array<{
|
|
22
|
+
ordinal: number;
|
|
23
|
+
name: string;
|
|
24
|
+
}>;
|
|
25
|
+
/** Set when no mosaic can honestly be built; `parts` is then empty. */
|
|
26
|
+
refusedReason: string | null;
|
|
27
|
+
}
|
|
28
|
+
export declare function collectMosaicInputs(sheetId: string, opts?: {
|
|
29
|
+
pageSizeId?: PrintPageSizeId;
|
|
30
|
+
}): Promise<MosaicInputs>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* WHY: The PDF mosaic needs three things that live in three different places —
|
|
3
|
+
* the sheet's page and parts (Firestore), each part's promoted PNG
|
|
4
|
+
* (Storage), and a layout (the shared nester). `pdfkit` is Node-only and
|
|
5
|
+
* must stay in `functions/`, so without this the Function would reach into
|
|
6
|
+
* all three itself and re-derive the layout, which is how a preview and a
|
|
7
|
+
* printed sheet stop agreeing.
|
|
8
|
+
* WHAT: Everything the mosaic needs, assembled once, with the layout taken
|
|
9
|
+
* from the same nester the print modal uses.
|
|
10
|
+
*
|
|
11
|
+
* 🛑 IT REFUSES WITHOUT MILLIMETRES. A mosaic's entire purpose is true physical
|
|
12
|
+
* scale; one built from pixel sizes would print at whatever scale the page
|
|
13
|
+
* happened to imply, look completely correct, and yield stickers the wrong
|
|
14
|
+
* size. `bboxMm` is null exactly when the scan's dpi could not be trusted, so
|
|
15
|
+
* that null is the signal — not an inconvenience to work around.
|
|
16
|
+
*
|
|
17
|
+
* EXPORTS: MosaicPartInput, MosaicInputs, collectMosaicInputs
|
|
18
|
+
*
|
|
19
|
+
* @tag domain:sticker-trace
|
|
20
|
+
* @tag layer:server
|
|
21
|
+
* @tag pattern:none
|
|
22
|
+
* @tag access:server
|
|
23
|
+
* @tag consumers:functions/sticker-trace
|
|
24
|
+
* @tag sideEffects:storage,firestore
|
|
25
|
+
*/
|
|
26
|
+
import { stickerSheetsRepository } from "../../../../features/sticker-trace/repository/sticker-sheets.repository.js";
|
|
27
|
+
import { nestParts } from "../../../shared/features/sticker-trace/export/nesting.js";
|
|
28
|
+
import { PRINT_PAGE_SIZES, } from "../../../shared/features/sticker-trace/export/page-sizes.js";
|
|
29
|
+
import { readScanBytes } from "./storage.js";
|
|
30
|
+
export async function collectMosaicInputs(sheetId, opts = {}) {
|
|
31
|
+
const sheet = await stickerSheetsRepository.findByIdOrFail(sheetId);
|
|
32
|
+
const page = PRINT_PAGE_SIZES[opts.pageSizeId ?? "a4"];
|
|
33
|
+
const empty = {
|
|
34
|
+
title: sheet.title,
|
|
35
|
+
pageWidthMm: page.widthMm,
|
|
36
|
+
pageHeightMm: page.heightMm,
|
|
37
|
+
pageCount: 0,
|
|
38
|
+
parts: [],
|
|
39
|
+
unplaceable: [],
|
|
40
|
+
};
|
|
41
|
+
const parts = sheet.parts ?? [];
|
|
42
|
+
if (parts.length === 0) {
|
|
43
|
+
return { ...empty, refusedReason: "This sheet has no parts yet — promote a run first." };
|
|
44
|
+
}
|
|
45
|
+
/*
|
|
46
|
+
* 🛑 A promoted part has an `assetPath`; an unpromoted one does not. Building
|
|
47
|
+
* a mosaic from the subset that happens to have one would silently print a
|
|
48
|
+
* partial sheet — so the absence is reported as a refusal naming the fix.
|
|
49
|
+
*/
|
|
50
|
+
const withAssets = parts.filter((p) => Boolean(p.assetPath));
|
|
51
|
+
if (withAssets.length === 0) {
|
|
52
|
+
return {
|
|
53
|
+
...empty,
|
|
54
|
+
refusedReason: "These parts have not been rendered at full resolution yet. Promote the run and wait for it to finish.",
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const measured = withAssets.filter((p) => p.bboxMm !== null);
|
|
58
|
+
if (measured.length === 0) {
|
|
59
|
+
return {
|
|
60
|
+
...empty,
|
|
61
|
+
refusedReason: "This scan has no confirmed DPI, so its parts have no real-world size. " +
|
|
62
|
+
"A mosaic prints at true physical scale — confirm the DPI and it becomes available.",
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/*
|
|
66
|
+
* A partial measurement is reported rather than silently dropped. Mixing
|
|
67
|
+
* measured and unmeasured parts on one sheet is the shape that makes a print
|
|
68
|
+
* look complete while missing stickers nobody noticed were absent.
|
|
69
|
+
*/
|
|
70
|
+
const unmeasured = withAssets
|
|
71
|
+
.filter((p) => p.bboxMm === null)
|
|
72
|
+
.map((p) => ({ ordinal: p.ordinal, name: p.name }));
|
|
73
|
+
const nest = nestParts(measured.map((p) => ({
|
|
74
|
+
ordinal: p.ordinal,
|
|
75
|
+
name: p.name,
|
|
76
|
+
widthMm: p.bboxMm.width,
|
|
77
|
+
heightMm: p.bboxMm.height,
|
|
78
|
+
})), page);
|
|
79
|
+
/*
|
|
80
|
+
* Downloads are parallel but the list is already bounded: a sheet's parts are
|
|
81
|
+
* capped by the trace's own `maxParts`, and the minimum-area filter removes
|
|
82
|
+
* the speck storm that would otherwise reach here. Still a real cost per
|
|
83
|
+
* part, which is why the mosaic is produced on demand rather than per run.
|
|
84
|
+
*/
|
|
85
|
+
const byOrdinal = new Map(measured.map((p) => [p.ordinal, p]));
|
|
86
|
+
const placed = await Promise.all(nest.placed.map(async (pl) => {
|
|
87
|
+
const part = byOrdinal.get(pl.ordinal);
|
|
88
|
+
return {
|
|
89
|
+
ordinal: pl.ordinal,
|
|
90
|
+
name: pl.name,
|
|
91
|
+
page: pl.page,
|
|
92
|
+
xMm: pl.xMm,
|
|
93
|
+
yMm: pl.yMm,
|
|
94
|
+
widthMm: pl.widthMm,
|
|
95
|
+
heightMm: pl.heightMm,
|
|
96
|
+
rotated: pl.rotated,
|
|
97
|
+
png: await readScanBytes(part.assetPath),
|
|
98
|
+
};
|
|
99
|
+
}));
|
|
100
|
+
return {
|
|
101
|
+
title: sheet.title,
|
|
102
|
+
pageWidthMm: page.widthMm,
|
|
103
|
+
pageHeightMm: page.heightMm,
|
|
104
|
+
pageCount: nest.pageCount,
|
|
105
|
+
parts: placed,
|
|
106
|
+
unplaceable: [
|
|
107
|
+
...nest.unplaceable.map((u) => ({ ordinal: u.ordinal, name: u.name })),
|
|
108
|
+
...unmeasured,
|
|
109
|
+
],
|
|
110
|
+
refusedReason: null,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { StickerTraceRunDocument, TraceRunError } from "../../../../features/sticker-trace/schemas/firestore";
|
|
2
|
+
import type { TraceStage } from "../../../shared/features/sticker-trace/types";
|
|
3
|
+
/** Every value `TraceRunEvent.stage` can hold — the pipeline plus its two bookends. */
|
|
4
|
+
export type ProgressStage = TraceStage | "queued" | "done";
|
|
5
|
+
export declare function stickerTraceChannelPath(runId: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Mint the read token for one run's channel.
|
|
8
|
+
*
|
|
9
|
+
* One claim, `stickerTraceRunId`, matching the rule in
|
|
10
|
+
* `appkit/firebase/base/database.rules.json`. Modelled on `enqueueJob`'s
|
|
11
|
+
* `bulkJobId` mint and deliberately NOT a general-purpose token: a broad token
|
|
12
|
+
* enumerating everything a user may watch is a Firestore fan-out per refresh
|
|
13
|
+
* and a 1000-byte claims ceiling waiting to be hit — which is why
|
|
14
|
+
* `/api/realtime/token` was deleted.
|
|
15
|
+
*
|
|
16
|
+
* The uid is namespaced so it can never collide with a real account.
|
|
17
|
+
*/
|
|
18
|
+
export declare function mintStickerTraceToken(runId: string): Promise<string>;
|
|
19
|
+
export interface EmitProgressInput {
|
|
20
|
+
runId: string;
|
|
21
|
+
stage: ProgressStage;
|
|
22
|
+
/** 0..100. Clamped rather than trusted — a bar that reads 140% reads as broken. */
|
|
23
|
+
pct: number;
|
|
24
|
+
message?: string;
|
|
25
|
+
level?: "info" | "warn" | "error";
|
|
26
|
+
partsDone?: number;
|
|
27
|
+
partsTotal?: number;
|
|
28
|
+
shardsDone?: number;
|
|
29
|
+
shardsTotal?: number;
|
|
30
|
+
/** Terminal nodes stop a client polling for more. */
|
|
31
|
+
terminal?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Append to the run document too. Default TRUE — stage transitions are
|
|
34
|
+
* history. Pass `false` for per-part ticks; see the header.
|
|
35
|
+
*/
|
|
36
|
+
durable?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The run, when the caller already holds it. The coordinator and finalizer
|
|
39
|
+
* both do, so threading it makes the durable append cost ZERO extra reads
|
|
40
|
+
* (the § "Status History" discipline).
|
|
41
|
+
*/
|
|
42
|
+
prior?: StickerTraceRunDocument | null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Write one progress transition.
|
|
46
|
+
*
|
|
47
|
+
* 🛑 NEVER THROWS. Progress reporting is observability, not the work: a failed
|
|
48
|
+
* RTDB write must not fail a trace that is otherwise succeeding, and a failed
|
|
49
|
+
* trace must still be able to report that it failed. Both writes are
|
|
50
|
+
* independently guarded, so losing the live node does not lose the history.
|
|
51
|
+
*
|
|
52
|
+
* Returns what it managed to do, so a caller that genuinely cares (a test, a
|
|
53
|
+
* diagnostic) can tell rather than having to assume.
|
|
54
|
+
*/
|
|
55
|
+
export declare function emitProgress(input: EmitProgressInput): Promise<{
|
|
56
|
+
live: boolean;
|
|
57
|
+
durable: boolean;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* A per-part tick: live only.
|
|
61
|
+
*
|
|
62
|
+
* Named rather than left to a `durable: false` argument at ~60 call sites,
|
|
63
|
+
* because the one that forgets is the one that costs 6x the write budget.
|
|
64
|
+
*/
|
|
65
|
+
export declare function emitPartProgress(runId: string, partsDone: number, partsTotal: number, extra?: {
|
|
66
|
+
shardsDone?: number;
|
|
67
|
+
shardsTotal?: number;
|
|
68
|
+
}): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* The last thing a failing run does.
|
|
71
|
+
*
|
|
72
|
+
* 🛑 `error.message` must ALREADY be user-safe — resolved through
|
|
73
|
+
* `toUserMessage`, never raw server text. A Node `MODULE_NOT_FOUND` with a full
|
|
74
|
+
* require stack rendered inside a progress panel is Root Cause #86, and it
|
|
75
|
+
* reached a buyer's bid modal once already.
|
|
76
|
+
*
|
|
77
|
+
* Writes the terminal RTDB node FIRST and the run document second, so a client
|
|
78
|
+
* watching the bar stops waiting even if the Firestore write is the thing that
|
|
79
|
+
* is failing.
|
|
80
|
+
*/
|
|
81
|
+
export declare function emitTerminalFailure(runId: string, error: TraceRunError, prior?: StickerTraceRunDocument | null): Promise<void>;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* WHY: "Even if we fail we know which stage it died in." A trace has eleven
|
|
3
|
+
* stages and any of them can fail; a generic spinner that stops moving is
|
|
4
|
+
* indistinguishable from a hang, and the gap only shows up on the day
|
|
5
|
+
* something breaks inside it.
|
|
6
|
+
* WHAT: One emitter that writes BOTH the live RTDB node and the durable run
|
|
7
|
+
* document, plus the per-run token mint.
|
|
8
|
+
*
|
|
9
|
+
* 🛑 BOTH, because they answer different questions. RTDB answers "what is it
|
|
10
|
+
* doing right now" and is pruned at 60 minutes; the run document answers "what
|
|
11
|
+
* happened to run 2 last Tuesday" and is what the retry panel reads. Writing
|
|
12
|
+
* only the first loses the history the whole feature exists for; writing only
|
|
13
|
+
* the second means no live bar.
|
|
14
|
+
*
|
|
15
|
+
* 🛑 Per-part progress is RTDB-ONLY. A Firestore event per part would be ~60
|
|
16
|
+
* writes per run instead of ~10, i.e. 6x the write cost to tell the operator
|
|
17
|
+
* something the live bar already shows and the history does not need. The
|
|
18
|
+
* `durable` flag is what expresses that, and `emitPartProgress` is the named
|
|
19
|
+
* wrapper so a caller does not have to remember.
|
|
20
|
+
*
|
|
21
|
+
* EXPORTS: emitProgress, emitPartProgress, emitTerminalFailure,
|
|
22
|
+
* mintStickerTraceToken, stickerTraceChannelPath
|
|
23
|
+
*
|
|
24
|
+
* @tag domain:sticker-trace
|
|
25
|
+
* @tag layer:server
|
|
26
|
+
* @tag pattern:none
|
|
27
|
+
* @tag access:server
|
|
28
|
+
* @tag consumers:functions/sticker-trace,api/admin/sticker-sheets
|
|
29
|
+
* @tag sideEffects:rtdb,firestore
|
|
30
|
+
*/
|
|
31
|
+
import { normalizeError } from "../../../../errors/normalize.js";
|
|
32
|
+
import { serverLogger } from "../../../../monitoring/index.js";
|
|
33
|
+
import { getAdminAuth, getAdminRealtimeDb } from "../../../../providers/db-firebase/index.js";
|
|
34
|
+
import { RTDB_PATHS } from "../../../../providers/db-firebase/rtdb-paths.js";
|
|
35
|
+
import { stickerTraceRunsRepository } from "../../../../features/sticker-trace/repository/sticker-trace-runs.repository.js";
|
|
36
|
+
export function stickerTraceChannelPath(runId) {
|
|
37
|
+
return `${RTDB_PATHS.STICKER_TRACE}/${runId}`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Mint the read token for one run's channel.
|
|
41
|
+
*
|
|
42
|
+
* One claim, `stickerTraceRunId`, matching the rule in
|
|
43
|
+
* `appkit/firebase/base/database.rules.json`. Modelled on `enqueueJob`'s
|
|
44
|
+
* `bulkJobId` mint and deliberately NOT a general-purpose token: a broad token
|
|
45
|
+
* enumerating everything a user may watch is a Firestore fan-out per refresh
|
|
46
|
+
* and a 1000-byte claims ceiling waiting to be hit — which is why
|
|
47
|
+
* `/api/realtime/token` was deleted.
|
|
48
|
+
*
|
|
49
|
+
* The uid is namespaced so it can never collide with a real account.
|
|
50
|
+
*/
|
|
51
|
+
export async function mintStickerTraceToken(runId) {
|
|
52
|
+
return getAdminAuth().createCustomToken(`sticker_trace_${runId}`, {
|
|
53
|
+
stickerTraceRunId: runId,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Write one progress transition.
|
|
58
|
+
*
|
|
59
|
+
* 🛑 NEVER THROWS. Progress reporting is observability, not the work: a failed
|
|
60
|
+
* RTDB write must not fail a trace that is otherwise succeeding, and a failed
|
|
61
|
+
* trace must still be able to report that it failed. Both writes are
|
|
62
|
+
* independently guarded, so losing the live node does not lose the history.
|
|
63
|
+
*
|
|
64
|
+
* Returns what it managed to do, so a caller that genuinely cares (a test, a
|
|
65
|
+
* diagnostic) can tell rather than having to assume.
|
|
66
|
+
*/
|
|
67
|
+
export async function emitProgress(input) {
|
|
68
|
+
const pct = Math.max(0, Math.min(100, Math.round(input.pct)));
|
|
69
|
+
const result = { live: false, durable: false };
|
|
70
|
+
try {
|
|
71
|
+
await getAdminRealtimeDb()
|
|
72
|
+
.ref(stickerTraceChannelPath(input.runId))
|
|
73
|
+
.set({
|
|
74
|
+
stage: input.stage,
|
|
75
|
+
pct,
|
|
76
|
+
...(input.message ? { message: input.message } : {}),
|
|
77
|
+
level: input.level ?? "info",
|
|
78
|
+
...(input.partsDone !== undefined ? { partsDone: input.partsDone } : {}),
|
|
79
|
+
...(input.partsTotal !== undefined ? { partsTotal: input.partsTotal } : {}),
|
|
80
|
+
...(input.shardsDone !== undefined ? { shardsDone: input.shardsDone } : {}),
|
|
81
|
+
...(input.shardsTotal !== undefined ? { shardsTotal: input.shardsTotal } : {}),
|
|
82
|
+
...(input.terminal ? { terminal: true } : {}),
|
|
83
|
+
/*
|
|
84
|
+
* 🛑 Epoch MILLISECONDS, and `cleanupRtdbEvents` reads this exact key.
|
|
85
|
+
* A node with a missing or non-finite `updatedAt` is treated as stale
|
|
86
|
+
* by definition there — it can never age out on its own, so leaving it
|
|
87
|
+
* would pin the node forever.
|
|
88
|
+
*/
|
|
89
|
+
updatedAt: Date.now(),
|
|
90
|
+
});
|
|
91
|
+
result.live = true;
|
|
92
|
+
}
|
|
93
|
+
catch (liveErr) {
|
|
94
|
+
const n = normalizeError(liveErr);
|
|
95
|
+
/*
|
|
96
|
+
* Logged, not swallowed. The live bar going dark while the trace keeps
|
|
97
|
+
* working is survivable — the run document still carries the history — but
|
|
98
|
+
* it is NOT nothing: it means the operator is watching a stalled bar on a
|
|
99
|
+
* healthy run, and the only way anyone learns that is this line.
|
|
100
|
+
*/
|
|
101
|
+
serverLogger.warn("Sticker trace live progress write failed (non-fatal)", {
|
|
102
|
+
runId: input.runId,
|
|
103
|
+
stage: input.stage,
|
|
104
|
+
message: n.message,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (input.durable !== false) {
|
|
108
|
+
try {
|
|
109
|
+
const event = {
|
|
110
|
+
at: new Date(),
|
|
111
|
+
stage: input.stage,
|
|
112
|
+
pct,
|
|
113
|
+
...(input.message ? { message: input.message } : {}),
|
|
114
|
+
...(input.level ? { level: input.level } : {}),
|
|
115
|
+
};
|
|
116
|
+
await stickerTraceRunsRepository.appendEvent(input.runId, event, input.prior);
|
|
117
|
+
result.durable = true;
|
|
118
|
+
}
|
|
119
|
+
catch (durableErr) {
|
|
120
|
+
const n = normalizeError(durableErr);
|
|
121
|
+
/*
|
|
122
|
+
* This one is worse than the live failure and is logged at error: the
|
|
123
|
+
* durable append is the ONLY record a post-mortem or a retry panel can
|
|
124
|
+
* read, and the RTDB node it was mirroring is pruned within the hour.
|
|
125
|
+
* A gap here means the run's own history has a hole in it.
|
|
126
|
+
*/
|
|
127
|
+
serverLogger.error("Sticker trace durable event append failed", {
|
|
128
|
+
runId: input.runId,
|
|
129
|
+
stage: input.stage,
|
|
130
|
+
message: n.message,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* A per-part tick: live only.
|
|
138
|
+
*
|
|
139
|
+
* Named rather than left to a `durable: false` argument at ~60 call sites,
|
|
140
|
+
* because the one that forgets is the one that costs 6x the write budget.
|
|
141
|
+
*/
|
|
142
|
+
export async function emitPartProgress(runId, partsDone, partsTotal, extra) {
|
|
143
|
+
// Guard the division: a run with zero parts is a real outcome (an empty
|
|
144
|
+
// sheet, or the montage case), and 0/0 would publish NaN as the bar's width.
|
|
145
|
+
const pct = partsTotal > 0 ? (partsDone / partsTotal) * 100 : 0;
|
|
146
|
+
await emitProgress({
|
|
147
|
+
runId,
|
|
148
|
+
stage: "parts",
|
|
149
|
+
pct,
|
|
150
|
+
partsDone,
|
|
151
|
+
partsTotal,
|
|
152
|
+
...extra,
|
|
153
|
+
durable: false,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The last thing a failing run does.
|
|
158
|
+
*
|
|
159
|
+
* 🛑 `error.message` must ALREADY be user-safe — resolved through
|
|
160
|
+
* `toUserMessage`, never raw server text. A Node `MODULE_NOT_FOUND` with a full
|
|
161
|
+
* require stack rendered inside a progress panel is Root Cause #86, and it
|
|
162
|
+
* reached a buyer's bid modal once already.
|
|
163
|
+
*
|
|
164
|
+
* Writes the terminal RTDB node FIRST and the run document second, so a client
|
|
165
|
+
* watching the bar stops waiting even if the Firestore write is the thing that
|
|
166
|
+
* is failing.
|
|
167
|
+
*/
|
|
168
|
+
export async function emitTerminalFailure(runId, error, prior) {
|
|
169
|
+
await emitProgress({
|
|
170
|
+
runId,
|
|
171
|
+
stage: error.stage,
|
|
172
|
+
pct: 100,
|
|
173
|
+
message: error.message,
|
|
174
|
+
level: "error",
|
|
175
|
+
terminal: true,
|
|
176
|
+
durable: true,
|
|
177
|
+
prior,
|
|
178
|
+
});
|
|
179
|
+
try {
|
|
180
|
+
await stickerTraceRunsRepository.markFailed(runId, error, undefined, prior);
|
|
181
|
+
}
|
|
182
|
+
catch (markErr) {
|
|
183
|
+
const n = normalizeError(markErr);
|
|
184
|
+
/*
|
|
185
|
+
* 🛑 The most important log line in this file. If this write fails the run
|
|
186
|
+
* stays `running` forever: the retry panel offers nothing, the history says
|
|
187
|
+
* the trace is still going, and the RTDB node that said otherwise is gone
|
|
188
|
+
* within the hour. There is no second mechanism that notices — so the only
|
|
189
|
+
* trace of a run stuck in limbo is this.
|
|
190
|
+
*/
|
|
191
|
+
serverLogger.error("Sticker trace run could not be marked failed — run left RUNNING", {
|
|
192
|
+
runId,
|
|
193
|
+
stage: error.stage,
|
|
194
|
+
code: error.code,
|
|
195
|
+
message: n.message,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface PromoteRunInput {
|
|
2
|
+
sheetId: string;
|
|
3
|
+
runId: string;
|
|
4
|
+
promotedBy: string;
|
|
5
|
+
}
|
|
6
|
+
export interface PromoteRunResult {
|
|
7
|
+
sheetId: string;
|
|
8
|
+
runId: string;
|
|
9
|
+
/** How many shards will render full-resolution parts. */
|
|
10
|
+
shardCount: number;
|
|
11
|
+
partCount: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Accept a run and start the full-resolution render.
|
|
15
|
+
*
|
|
16
|
+
* 🛑 It refuses a run that did not SUCCEED. Promoting a failed or still-running
|
|
17
|
+
* run would copy a partial `parts[]` onto the sheet and set `activeRunId` to
|
|
18
|
+
* it — the sheet would then confidently show an incomplete result, with the
|
|
19
|
+
* run's own status the only contradiction and nothing surfacing it.
|
|
20
|
+
*/
|
|
21
|
+
export declare function promoteStickerTraceRun(input: PromoteRunInput): Promise<PromoteRunResult>;
|
|
22
|
+
/** Whether this run is already the sheet's accepted result. */
|
|
23
|
+
export declare function isRunPromoted(sheetId: string, runId: string): Promise<boolean>;
|