@mohasinac/appkit 4.60.0 → 4.61.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 +3 -3
- package/dist/_internal/server/features/auctions/actions.d.ts +1 -1
- package/dist/_internal/server/features/auctions/actions.js +12 -1
- package/dist/_internal/server/features/blog/actions.d.ts +1 -1
- package/dist/_internal/server/features/blog/actions.js +12 -1
- package/dist/_internal/server/features/brands/actions.d.ts +1 -1
- package/dist/_internal/server/features/brands/actions.js +12 -1
- package/dist/_internal/server/features/cart/actions.d.ts +1 -1
- package/dist/_internal/server/features/cart/actions.js +12 -1
- package/dist/_internal/server/features/checkout/actions.js +0 -1
- package/dist/_internal/server/features/events/actions.d.ts +1 -1
- package/dist/_internal/server/features/events/actions.js +12 -1
- package/dist/_internal/server/features/gateway-events/redact.js +14 -2
- package/dist/_internal/server/features/history/actions.d.ts +1 -1
- package/dist/_internal/server/features/history/actions.js +12 -1
- package/dist/_internal/server/features/lottery/actions.d.ts +1 -1
- package/dist/_internal/server/features/lottery/actions.js +12 -1
- package/dist/_internal/server/features/orders/actions.d.ts +1 -1
- package/dist/_internal/server/features/orders/actions.js +12 -1
- package/dist/_internal/server/features/orders/adapters.d.ts +20 -2
- package/dist/_internal/server/features/orders/adapters.js +18 -0
- package/dist/_internal/server/features/orders/cancellation-refund.js +0 -1
- package/dist/_internal/server/features/orders/service.js +31 -1
- package/dist/_internal/server/features/payouts/actions.d.ts +1 -1
- package/dist/_internal/server/features/payouts/actions.js +12 -1
- package/dist/_internal/server/features/points/award.js +9 -1
- package/dist/_internal/server/features/pre-orders/actions.d.ts +1 -1
- package/dist/_internal/server/features/pre-orders/actions.js +12 -1
- package/dist/_internal/server/features/prize-draws/actions.d.ts +1 -1
- package/dist/_internal/server/features/prize-draws/actions.js +12 -1
- package/dist/_internal/server/features/products/actions.d.ts +1 -1
- package/dist/_internal/server/features/products/actions.js +12 -1
- package/dist/_internal/server/features/promotions/actions.d.ts +1 -1
- package/dist/_internal/server/features/promotions/actions.js +12 -1
- package/dist/_internal/server/features/protection-claims/actions.d.ts +2 -2
- package/dist/_internal/server/features/protection-claims/actions.js +21 -12
- package/dist/_internal/server/features/raffle/actions.d.ts +1 -1
- package/dist/_internal/server/features/raffle/actions.js +12 -1
- package/dist/_internal/server/features/refunds/actions.d.ts +1 -3
- package/dist/_internal/server/features/refunds/actions.js +14 -2
- package/dist/_internal/server/features/reviews/actions.d.ts +1 -1
- package/dist/_internal/server/features/reviews/actions.js +12 -1
- package/dist/_internal/server/features/wishlist/actions.d.ts +1 -1
- package/dist/_internal/server/features/wishlist/actions.js +12 -1
- package/dist/_internal/server/jobs/core/obligationSweep.js +0 -1
- package/dist/_internal/server/jobs/core/paymentReconcile.js +84 -57
- package/dist/_internal/server/jobs/core/testDataCleanup.d.ts +1 -1
- package/dist/_internal/server/jobs/core/testDataCleanup.js +22 -1
- package/dist/_internal/server/jobs/handlers/onShipmentAllocationSync.js +16 -4
- package/dist/_internal/shared/features/promotions/schema.d.ts +66 -0
- package/dist/_internal/shared/features/promotions/schema.js +7 -0
- package/dist/_internal/shared/obligations/deadlines.js +11 -1
- package/dist/_internal/shared/tester/window.d.ts +25 -0
- package/dist/_internal/shared/tester/window.js +66 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +3 -0
- package/dist/core/unit-of-work.js +15 -1
- package/dist/errors/firestore-codes.d.ts +37 -0
- package/dist/errors/firestore-codes.js +52 -0
- package/dist/errors/index.d.ts +0 -1
- package/dist/errors/index.js +12 -2
- package/dist/features/admin/components/AdminCouponEditorView.js +8 -0
- package/dist/features/admin/components/AdminGatewayEventsView.js +2 -2
- package/dist/features/admin/components/DataListingView.js +2 -0
- package/dist/features/admin/components/analytics/AdminStatCard.js +4 -1
- package/dist/features/admin/repository/site-settings.repository.d.ts +2 -1
- package/dist/features/admin/repository/site-settings.repository.js +7 -0
- package/dist/features/auctions/components/MarketplaceAuctionCard.js +1 -1
- package/dist/features/catalogue/actions/approve-catalogue-listing.d.ts +1 -1
- package/dist/features/catalogue/actions/approve-catalogue-listing.js +12 -1
- package/dist/features/catalogue/actions/list-from-catalogue.d.ts +1 -1
- package/dist/features/catalogue/actions/list-from-catalogue.js +12 -1
- package/dist/features/catalogue/actions/submit-for-approval.d.ts +1 -1
- package/dist/features/catalogue/actions/submit-for-approval.js +12 -1
- package/dist/features/categories/repository/price-observation.repository.d.ts +19 -0
- package/dist/features/categories/repository/price-observation.repository.js +21 -2
- package/dist/features/events/actions/event-actions.js +4 -1
- package/dist/features/events/components/AdminEventEditorView.js +72 -45
- package/dist/features/events/components/EventsListPageView.js +2 -1
- package/dist/features/events/schemas/firestore.d.ts +17 -0
- package/dist/features/events/schemas/firestore.js +1 -0
- package/dist/features/events/utils/sort-pinned.d.ts +33 -0
- package/dist/features/events/utils/sort-pinned.js +46 -0
- package/dist/features/gateway-events/repository/gateway-events.repository.js +3 -40
- package/dist/features/gateway-events/schemas/index.d.ts +2 -2
- package/dist/features/inventory/components/AdminStorageBoxesView.js +55 -39
- package/dist/features/inventory/components/ReceiveStationView.js +61 -17
- package/dist/features/inventory/repository/storage-boxes.repository.d.ts +3 -1
- package/dist/features/inventory/repository/storage-boxes.repository.js +36 -3
- package/dist/features/obligations/repository/obligations.repository.js +10 -1
- package/dist/features/orders/schemas/firestore.d.ts +19 -0
- package/dist/features/orders/schemas/firestore.js +19 -0
- package/dist/features/payment-cases/repository/payment-cases.repository.d.ts +1 -0
- package/dist/features/payment-cases/repository/payment-cases.repository.js +3 -14
- package/dist/features/pre-orders/components/MarketplacePreorderCard.js +1 -1
- package/dist/features/products/components/MarketplaceBundleCard.js +1 -1
- package/dist/features/products/components/MarketplacePrizeDrawCard.js +1 -1
- package/dist/features/products/components/ProductForm.js +2 -2
- package/dist/features/products/components/ProductGrid.js +1 -1
- package/dist/features/promotions/repository/claimed-coupons.repository.js +31 -1
- package/dist/features/promotions/schemas/firestore.d.ts +22 -0
- package/dist/features/promotions/schemas/firestore.js +22 -0
- package/dist/features/promotions/schemas/index.d.ts +479 -6
- package/dist/features/promotions/schemas/index.js +153 -0
- package/dist/features/protection-claims/repository/protection-claims.repository.js +22 -15
- package/dist/features/seller/schemas/coupon-form.d.ts +5 -0
- package/dist/features/seller/schemas/coupon-form.js +18 -0
- package/dist/features/shell/SectionForm.js +31 -9
- package/dist/features/sticker-trace/server.d.ts +2 -0
- package/dist/http/api-handler.js +4 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/next/routing/route-map.d.ts +0 -2
- package/dist/next/routing/route-map.js +10 -1
- package/dist/schemas/registry.d.ts +11 -6
- package/dist/server.js +7 -0
- package/dist/styles.css +51 -0
- package/dist/ui/components/PaginatedSelect.js +0 -0
- package/package.json +1 -1
- package/scripts/seed-cli.mjs +1822 -1812
- package/dist/features/tester/utils/phases.d.ts +0 -48
- package/dist/features/tester/utils/phases.js +0 -139
package/dist/.build-stamp.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"stampVersion": 1,
|
|
3
|
-
"version": "4.
|
|
4
|
-
"head": "
|
|
3
|
+
"version": "4.61.0",
|
|
4
|
+
"head": "7fd2f6fe0a6d6314241671329d51d11d008fca95",
|
|
5
5
|
"branch": "main",
|
|
6
6
|
"dirty": false,
|
|
7
|
-
"builtAt": "2026-10-
|
|
7
|
+
"builtAt": "2026-10-22T08:29:07.009Z"
|
|
8
8
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type ActionResult } from "
|
|
1
|
+
import { type ActionResult } from "../../../shared/types/action-result";
|
|
2
2
|
export declare function placeBidAction(input: unknown): Promise<ActionResult<unknown>>;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
|
|
2
|
+
/*
|
|
3
|
+
* 🛑 From the DEFINING module, never "@mohasinac/appkit/server".
|
|
4
|
+
*
|
|
5
|
+
* appkit importing its own public server barrel is a self-reference that drags
|
|
6
|
+
* the whole server surface in behind it — `dist/server.js` reaches next/og,
|
|
7
|
+
* next/navigation, next/headers and driver.js. Twenty `actions.ts` files did
|
|
8
|
+
* this for two symbols, and because `obligationSweep` reaches one of them, the
|
|
9
|
+
* Firebase Functions tsup bundle (noExternal: appkit) had to resolve Next:
|
|
10
|
+
* it failed on two `react-server-dom-webpack/*` requires and two @vercel/og
|
|
11
|
+
* .wasm files, naming none of the responsible files. Root Cause #18.
|
|
12
|
+
*/
|
|
13
|
+
import { wrapAction } from "../../../shared/types/action-result.js";
|
|
3
14
|
import { safeRead } from "../../../../errors/safe-read.js";
|
|
4
15
|
import { bidRepository, productRepository, userRepository, siteSettingsRepository } from "../../../../repositories/index.js";
|
|
5
16
|
import { requireRoleUser } from "../../../../providers/auth-firebase/helpers.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ActionResult } from "
|
|
1
|
+
import { type ActionResult } from "../../../shared/types/action-result";
|
|
2
2
|
export declare function createBlogPostAction(input: unknown): Promise<ActionResult<unknown>>;
|
|
3
3
|
export declare function updateBlogPostAction(postId: string, input: unknown): Promise<ActionResult<unknown>>;
|
|
4
4
|
export declare function deleteBlogPostAction(postId: string): Promise<ActionResult<unknown>>;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
|
|
2
|
+
/*
|
|
3
|
+
* 🛑 From the DEFINING module, never "@mohasinac/appkit/server".
|
|
4
|
+
*
|
|
5
|
+
* appkit importing its own public server barrel is a self-reference that drags
|
|
6
|
+
* the whole server surface in behind it — `dist/server.js` reaches next/og,
|
|
7
|
+
* next/navigation, next/headers and driver.js. Twenty `actions.ts` files did
|
|
8
|
+
* this for two symbols, and because `obligationSweep` reaches one of them, the
|
|
9
|
+
* Firebase Functions tsup bundle (noExternal: appkit) had to resolve Next:
|
|
10
|
+
* it failed on two `react-server-dom-webpack/*` requires and two @vercel/og
|
|
11
|
+
* .wasm files, naming none of the responsible files. Root Cause #18.
|
|
12
|
+
*/
|
|
13
|
+
import { wrapAction } from "../../../shared/types/action-result.js";
|
|
3
14
|
import { blogRepository } from "../../../../repositories/index.js";
|
|
4
15
|
import { requireRoleUser } from "../../../../providers/auth-firebase/helpers.js";
|
|
5
16
|
import { blogPostInputSchema, blogPostUpdateSchema } from "../../../shared/features/blog/schema.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ActionResult } from "
|
|
1
|
+
import { type ActionResult } from "../../../shared/types/action-result";
|
|
2
2
|
export declare function createBrandAction(input: unknown): Promise<ActionResult<unknown>>;
|
|
3
3
|
export declare function updateBrandAction(brandId: string, input: unknown): Promise<ActionResult<unknown>>;
|
|
4
4
|
export declare function deleteBrandAction(brandId: string): Promise<ActionResult<unknown>>;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
|
|
2
|
+
/*
|
|
3
|
+
* 🛑 From the DEFINING module, never "@mohasinac/appkit/server".
|
|
4
|
+
*
|
|
5
|
+
* appkit importing its own public server barrel is a self-reference that drags
|
|
6
|
+
* the whole server surface in behind it — `dist/server.js` reaches next/og,
|
|
7
|
+
* next/navigation, next/headers and driver.js. Twenty `actions.ts` files did
|
|
8
|
+
* this for two symbols, and because `obligationSweep` reaches one of them, the
|
|
9
|
+
* Firebase Functions tsup bundle (noExternal: appkit) had to resolve Next:
|
|
10
|
+
* it failed on two `react-server-dom-webpack/*` requires and two @vercel/og
|
|
11
|
+
* .wasm files, naming none of the responsible files. Root Cause #18.
|
|
12
|
+
*/
|
|
13
|
+
import { wrapAction } from "../../../shared/types/action-result.js";
|
|
3
14
|
import { categoriesRepository } from "../../../../repositories/index.js";
|
|
4
15
|
import { requireRoleUser } from "../../../../providers/auth-firebase/helpers.js";
|
|
5
16
|
import { brandInputSchema, brandUpdateSchema } from "../../../shared/features/brands/schema.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ActionResult } from "
|
|
1
|
+
import { type ActionResult } from "../../../shared/types/action-result";
|
|
2
2
|
export declare function addToCartAction(input: unknown): Promise<ActionResult<unknown>>;
|
|
3
3
|
export declare function removeFromCartAction(input: unknown): Promise<ActionResult<unknown>>;
|
|
4
4
|
export declare function clearCartAction(): Promise<ActionResult<unknown>>;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
|
|
2
|
+
/*
|
|
3
|
+
* 🛑 From the DEFINING module, never "@mohasinac/appkit/server".
|
|
4
|
+
*
|
|
5
|
+
* appkit importing its own public server barrel is a self-reference that drags
|
|
6
|
+
* the whole server surface in behind it — `dist/server.js` reaches next/og,
|
|
7
|
+
* next/navigation, next/headers and driver.js. Twenty `actions.ts` files did
|
|
8
|
+
* this for two symbols, and because `obligationSweep` reaches one of them, the
|
|
9
|
+
* Firebase Functions tsup bundle (noExternal: appkit) had to resolve Next:
|
|
10
|
+
* it failed on two `react-server-dom-webpack/*` requires and two @vercel/og
|
|
11
|
+
* .wasm files, naming none of the responsible files. Root Cause #18.
|
|
12
|
+
*/
|
|
13
|
+
import { wrapAction } from "../../../shared/types/action-result.js";
|
|
3
14
|
import { cartRepository } from "../../../../repositories/index.js";
|
|
4
15
|
import { requireRoleUser } from "../../../../providers/auth-firebase/helpers.js";
|
|
5
16
|
import { addToCartSchema, removeFromCartSchema, mergeGuestCartSchema } from "../../../shared/features/cart/schema.js";
|
|
@@ -1833,7 +1833,6 @@ async function refundDroppedItemsForPhonePeCheckout(input) {
|
|
|
1833
1833
|
: droppedValue;
|
|
1834
1834
|
const refundResult = await processRefundAction({
|
|
1835
1835
|
orderId: primaryOrderId,
|
|
1836
|
-
type: "partial",
|
|
1837
1836
|
amount: refundAmount,
|
|
1838
1837
|
/*
|
|
1839
1838
|
* A SYSTEM refund, not a buyer claim: items the buyer paid for turned
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ActionResult } from "
|
|
1
|
+
import { type ActionResult } from "../../../shared/types/action-result";
|
|
2
2
|
export declare function createEventAction(input: unknown): Promise<ActionResult<unknown>>;
|
|
3
3
|
export declare function updateEventAction(eventId: string, input: unknown): Promise<ActionResult<unknown>>;
|
|
4
4
|
export declare function registerForEventAction(input: unknown): Promise<ActionResult<unknown>>;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
|
|
2
|
+
/*
|
|
3
|
+
* 🛑 From the DEFINING module, never "@mohasinac/appkit/server".
|
|
4
|
+
*
|
|
5
|
+
* appkit importing its own public server barrel is a self-reference that drags
|
|
6
|
+
* the whole server surface in behind it — `dist/server.js` reaches next/og,
|
|
7
|
+
* next/navigation, next/headers and driver.js. Twenty `actions.ts` files did
|
|
8
|
+
* this for two symbols, and because `obligationSweep` reaches one of them, the
|
|
9
|
+
* Firebase Functions tsup bundle (noExternal: appkit) had to resolve Next:
|
|
10
|
+
* it failed on two `react-server-dom-webpack/*` requires and two @vercel/og
|
|
11
|
+
* .wasm files, naming none of the responsible files. Root Cause #18.
|
|
12
|
+
*/
|
|
13
|
+
import { wrapAction } from "../../../shared/types/action-result.js";
|
|
3
14
|
import { eventRepository, eventEntryRepository } from "../../../../repositories/index.js";
|
|
4
15
|
import { requireRoleUser } from "../../../../providers/auth-firebase/helpers.js";
|
|
5
16
|
import { eventInputSchema, eventUpdateSchema, registerForEventSchema } from "../../../shared/features/events/schema.js";
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
* `card` key without anyone having written that path down.
|
|
38
38
|
*/
|
|
39
39
|
import { GATEWAY_EVENT_PAYLOAD_MAX_BYTES } from "../../../../features/gateway-events/schemas/firestore.js";
|
|
40
|
+
import { normalizeError } from "../../../../errors/normalize.js";
|
|
40
41
|
/**
|
|
41
42
|
* Keys dropped wherever they appear, at any depth.
|
|
42
43
|
*
|
|
@@ -130,13 +131,24 @@ export function redactGatewayPayload(body) {
|
|
|
130
131
|
try {
|
|
131
132
|
serialisedLength = JSON.stringify(redacted)?.length ?? 0;
|
|
132
133
|
}
|
|
133
|
-
catch {
|
|
134
|
+
catch (err) {
|
|
134
135
|
/*
|
|
135
136
|
* A circular structure cannot come from `JSON.parse`, which is the only
|
|
136
137
|
* producer here — but this function is exported and a future caller could
|
|
137
138
|
* hand it something else. Failing to a marker keeps the row writable.
|
|
139
|
+
*
|
|
140
|
+
* 🛑 The reason is CARRIED, not discarded. This was a bare `catch {}`, so
|
|
141
|
+
* the one case the comment above exists to anticipate — a future caller
|
|
142
|
+
* handing it something `JSON.stringify` cannot take — produced a row
|
|
143
|
+
* saying only `redactionFailed: true`, with nothing anywhere to say why.
|
|
144
|
+
* The row is a debugging record; a marker that cannot explain itself is
|
|
145
|
+
* the silent-degrade shape this codebase keeps paying for.
|
|
138
146
|
*/
|
|
139
|
-
|
|
147
|
+
const n = normalizeError(err);
|
|
148
|
+
return {
|
|
149
|
+
payload: { redactionFailed: true, reason: n.message },
|
|
150
|
+
truncated: true,
|
|
151
|
+
};
|
|
140
152
|
}
|
|
141
153
|
if (serialisedLength > GATEWAY_EVENT_PAYLOAD_MAX_BYTES) {
|
|
142
154
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ActionResult } from "
|
|
1
|
+
import { type ActionResult } from "../../../shared/types/action-result";
|
|
2
2
|
import { type UserHistoryItem, type HistoryProductType } from "../../../../repositories";
|
|
3
3
|
export declare function trackProductViewAction(productId: string, productType: HistoryProductType, productSnapshot?: UserHistoryItem["productSnapshot"]): Promise<ActionResult<unknown>>;
|
|
4
4
|
export declare function mergeGuestHistoryAction(guestItems: Array<{
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
|
|
2
|
+
/*
|
|
3
|
+
* 🛑 From the DEFINING module, never "@mohasinac/appkit/server".
|
|
4
|
+
*
|
|
5
|
+
* appkit importing its own public server barrel is a self-reference that drags
|
|
6
|
+
* the whole server surface in behind it — `dist/server.js` reaches next/og,
|
|
7
|
+
* next/navigation, next/headers and driver.js. Twenty `actions.ts` files did
|
|
8
|
+
* this for two symbols, and because `obligationSweep` reaches one of them, the
|
|
9
|
+
* Firebase Functions tsup bundle (noExternal: appkit) had to resolve Next:
|
|
10
|
+
* it failed on two `react-server-dom-webpack/*` requires and two @vercel/og
|
|
11
|
+
* .wasm files, naming none of the responsible files. Root Cause #18.
|
|
12
|
+
*/
|
|
13
|
+
import { wrapAction } from "../../../shared/types/action-result.js";
|
|
3
14
|
import { requireRoleUser } from "../../../../providers/auth-firebase/helpers.js";
|
|
4
15
|
import { historyRepository, } from "../../../../repositories/index.js";
|
|
5
16
|
export async function trackProductViewAction(productId, productType, productSnapshot) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ActionResult } from "
|
|
1
|
+
import { type ActionResult } from "../../../shared/types/action-result";
|
|
2
2
|
import type { LotteryConfig } from "../../../../features/lottery/types";
|
|
3
3
|
import type { LotteryEntryDocument } from "../../../../features/lottery/schemas/firestore";
|
|
4
4
|
/**
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
|
|
2
|
+
/*
|
|
3
|
+
* 🛑 From the DEFINING module, never "@mohasinac/appkit/server".
|
|
4
|
+
*
|
|
5
|
+
* appkit importing its own public server barrel is a self-reference that drags
|
|
6
|
+
* the whole server surface in behind it — `dist/server.js` reaches next/og,
|
|
7
|
+
* next/navigation, next/headers and driver.js. Twenty `actions.ts` files did
|
|
8
|
+
* this for two symbols, and because `obligationSweep` reaches one of them, the
|
|
9
|
+
* Firebase Functions tsup bundle (noExternal: appkit) had to resolve Next:
|
|
10
|
+
* it failed on two `react-server-dom-webpack/*` requires and two @vercel/og
|
|
11
|
+
* .wasm files, naming none of the responsible files. Root Cause #18.
|
|
12
|
+
*/
|
|
13
|
+
import { wrapAction } from "../../../shared/types/action-result.js";
|
|
3
14
|
import { getAdminDb } from "../../../../providers/db-firebase/index.js";
|
|
4
15
|
import { eventRepository, productRepository, orderRepository } from "../../../../repositories/index.js";
|
|
5
16
|
import { serverLogger } from "../../../../monitoring/index.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ActionResult } from "
|
|
1
|
+
import { type ActionResult } from "../../../shared/types/action-result";
|
|
2
2
|
export declare function createOrderAction(input: unknown): Promise<ActionResult<unknown>>;
|
|
3
3
|
/**
|
|
4
4
|
* Cancel an order, and give the money back if any was taken (D14).
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
|
|
2
|
+
/*
|
|
3
|
+
* 🛑 From the DEFINING module, never "@mohasinac/appkit/server".
|
|
4
|
+
*
|
|
5
|
+
* appkit importing its own public server barrel is a self-reference that drags
|
|
6
|
+
* the whole server surface in behind it — `dist/server.js` reaches next/og,
|
|
7
|
+
* next/navigation, next/headers and driver.js. Twenty `actions.ts` files did
|
|
8
|
+
* this for two symbols, and because `obligationSweep` reaches one of them, the
|
|
9
|
+
* Firebase Functions tsup bundle (noExternal: appkit) had to resolve Next:
|
|
10
|
+
* it failed on two `react-server-dom-webpack/*` requires and two @vercel/og
|
|
11
|
+
* .wasm files, naming none of the responsible files. Root Cause #18.
|
|
12
|
+
*/
|
|
13
|
+
import { wrapAction } from "../../../shared/types/action-result.js";
|
|
3
14
|
import { adminNotificationsRepository, orderRepository, storeRepository } from "../../../../repositories/index.js";
|
|
4
15
|
import { requireRoleUser } from "../../../../providers/auth-firebase/helpers.js";
|
|
5
16
|
import { createOrderSchema, updateOrderStatusSchema, cancelOrderSchema, returnRequestSchema, } from "../../../shared/features/orders/schema.js";
|
|
@@ -1,3 +1,21 @@
|
|
|
1
1
|
import type { Order } from "../../../../features/orders/types";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { OrderPlain } from "../../../../features/orders/schemas/firestore";
|
|
3
|
+
/**
|
|
4
|
+
* 🛑 `OrderPlain`, not `OrderDocument` — this builds the BUYER-FACING shape.
|
|
5
|
+
*
|
|
6
|
+
* `orderRepository.findById` is ciphertext-by-default, so a signature taking
|
|
7
|
+
* the raw document would invite a caller to hand over `enc:v1:` strings and
|
|
8
|
+
* have them copied straight into an API response. The one caller
|
|
9
|
+
* (`GET /api/user/orders/[id]`) already holds a revealed order; this makes the
|
|
10
|
+
* signature say so.
|
|
11
|
+
*
|
|
12
|
+
* It does not currently read any of `ORDER_PII_FIELDS` (`userName`,
|
|
13
|
+
* `userEmail`, `sellerEmail`), so nothing is leaking today — the point is that
|
|
14
|
+
* adding one of them later is correct by default rather than a new leak.
|
|
15
|
+
*
|
|
16
|
+
* Accepted residue, stated rather than hidden: `Encrypted<string>` is
|
|
17
|
+
* assignable to `string`, so a raw document still satisfies this structurally.
|
|
18
|
+
* The brand forces the choice at the REPOSITORY boundary, which is where it
|
|
19
|
+
* can actually be enforced; this parameter documents the expectation.
|
|
20
|
+
*/
|
|
21
|
+
export declare function orderDocumentToOrder(doc: OrderPlain): Order;
|
|
@@ -37,6 +37,24 @@ function toIsoOrUndefined(value) {
|
|
|
37
37
|
}
|
|
38
38
|
return undefined;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* 🛑 `OrderPlain`, not `OrderDocument` — this builds the BUYER-FACING shape.
|
|
42
|
+
*
|
|
43
|
+
* `orderRepository.findById` is ciphertext-by-default, so a signature taking
|
|
44
|
+
* the raw document would invite a caller to hand over `enc:v1:` strings and
|
|
45
|
+
* have them copied straight into an API response. The one caller
|
|
46
|
+
* (`GET /api/user/orders/[id]`) already holds a revealed order; this makes the
|
|
47
|
+
* signature say so.
|
|
48
|
+
*
|
|
49
|
+
* It does not currently read any of `ORDER_PII_FIELDS` (`userName`,
|
|
50
|
+
* `userEmail`, `sellerEmail`), so nothing is leaking today — the point is that
|
|
51
|
+
* adding one of them later is correct by default rather than a new leak.
|
|
52
|
+
*
|
|
53
|
+
* Accepted residue, stated rather than hidden: `Encrypted<string>` is
|
|
54
|
+
* assignable to `string`, so a raw document still satisfies this structurally.
|
|
55
|
+
* The brand forces the choice at the REPOSITORY boundary, which is where it
|
|
56
|
+
* can actually be enforced; this parameter documents the expectation.
|
|
57
|
+
*/
|
|
40
58
|
export function orderDocumentToOrder(doc) {
|
|
41
59
|
const items = doc.items?.length
|
|
42
60
|
? doc.items.map((item) => ({
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
import { orderRepository } from "../../../../repositories/index.js";
|
|
2
2
|
import { OrderNotFoundError, OrderCancelError, OrderOwnershipError, OrderReturnWindowError, } from "../../../shared/features/orders/errors.js";
|
|
3
3
|
import { ORDER_CANCELLABLE_STATUSES, ORDER_RETURN_WINDOW_MS, } from "../../../shared/features/orders/config.js";
|
|
4
|
+
/**
|
|
5
|
+
* The three shapes `updatedAt` really arrives in, resolved to a `Date`.
|
|
6
|
+
*
|
|
7
|
+
* A Firestore `Timestamp` is duck-typed on `toDate` rather than imported, so
|
|
8
|
+
* this file stays free of a firebase-admin import — the same trade
|
|
9
|
+
* `orders/adapters.ts` makes and for the same reason.
|
|
10
|
+
*
|
|
11
|
+
* Falls back to NOW rather than to an invalid date: the caller measures a
|
|
12
|
+
* return window against it, and `new Date(undefined)` is `NaN`, which makes
|
|
13
|
+
* every comparison false and would silently hold the window open forever.
|
|
14
|
+
*/
|
|
15
|
+
function toDateOrNow(value) {
|
|
16
|
+
if (value instanceof Date)
|
|
17
|
+
return Number.isNaN(value.getTime()) ? new Date() : value;
|
|
18
|
+
if (typeof value === "object" && value !== null && typeof value.toDate === "function") {
|
|
19
|
+
const d = value.toDate();
|
|
20
|
+
return d instanceof Date && !Number.isNaN(d.getTime()) ? d : new Date();
|
|
21
|
+
}
|
|
22
|
+
if (typeof value === "string") {
|
|
23
|
+
const d = new Date(value);
|
|
24
|
+
return Number.isNaN(d.getTime()) ? new Date() : d;
|
|
25
|
+
}
|
|
26
|
+
return new Date();
|
|
27
|
+
}
|
|
4
28
|
export async function assertOrderOwnership(orderId, userId) {
|
|
5
29
|
const order = await orderRepository.findById(orderId);
|
|
6
30
|
if (!order)
|
|
@@ -97,7 +121,13 @@ export async function assertReturnWindowOpen(orderId, userId) {
|
|
|
97
121
|
*/
|
|
98
122
|
const deliveredAt = order.deliveryDate instanceof Date
|
|
99
123
|
? order.deliveryDate
|
|
100
|
-
|
|
124
|
+
/*
|
|
125
|
+
* Typed, and the `as never` is gone with it. That cast existed only to
|
|
126
|
+
* feed an `unknown` into `new Date()` — it suppressed the one check that
|
|
127
|
+
* would have caught a wrong shape. A Firestore Timestamp is duck-typed on
|
|
128
|
+
* `toDate` rather than imported, the same way `toIsoOrUndefined` does it.
|
|
129
|
+
*/
|
|
130
|
+
: toDateOrNow(order.updatedAt);
|
|
101
131
|
if (Date.now() - deliveredAt.getTime() > ORDER_RETURN_WINDOW_MS)
|
|
102
132
|
throw new OrderReturnWindowError();
|
|
103
133
|
return order;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
|
|
2
|
+
/*
|
|
3
|
+
* 🛑 From the DEFINING module, never "@mohasinac/appkit/server".
|
|
4
|
+
*
|
|
5
|
+
* appkit importing its own public server barrel is a self-reference that drags
|
|
6
|
+
* the whole server surface in behind it — `dist/server.js` reaches next/og,
|
|
7
|
+
* next/navigation, next/headers and driver.js. Twenty `actions.ts` files did
|
|
8
|
+
* this for two symbols, and because `obligationSweep` reaches one of them, the
|
|
9
|
+
* Firebase Functions tsup bundle (noExternal: appkit) had to resolve Next:
|
|
10
|
+
* it failed on two `react-server-dom-webpack/*` requires and two @vercel/og
|
|
11
|
+
* .wasm files, naming none of the responsible files. Root Cause #18.
|
|
12
|
+
*/
|
|
13
|
+
import { wrapAction } from "../../../shared/types/action-result.js";
|
|
3
14
|
/**
|
|
4
15
|
* applyRefundDeductionAction — deduct a refund from a seller's pending payout.
|
|
5
16
|
*
|
|
@@ -91,7 +91,15 @@ export async function awardPurchasePoints(order) {
|
|
|
91
91
|
return { awarded: 0, skipped: "no-buyer" };
|
|
92
92
|
}
|
|
93
93
|
const goods = orderTaxableValue(order);
|
|
94
|
-
|
|
94
|
+
/*
|
|
95
|
+
* `goods * (PERCENT / 100)`, not `(goods * PERCENT) / 100` — the same value,
|
|
96
|
+
* written the way every fee in `fees/calculator.ts` is
|
|
97
|
+
* (`subtotal * (commissions.platformFeePercent / 100)`). The division
|
|
98
|
+
* belongs to the PERCENT, and grouping it that way is what distinguishes a
|
|
99
|
+
* percentage from the subunit-conversion `/100` that `audit-money-units`
|
|
100
|
+
* exists to catch — which read the old grouping as exactly that.
|
|
101
|
+
*/
|
|
102
|
+
const amount = roundPoints(goods * (POINTS_EARN_PERCENT / 100));
|
|
95
103
|
if (amount <= 0) {
|
|
96
104
|
/*
|
|
97
105
|
* A fully-cancelled or zero-value order. Marked as awarded anyway below so
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type ActionResult } from "
|
|
1
|
+
import { type ActionResult } from "../../../shared/types/action-result";
|
|
2
2
|
export declare function reservePreOrderAction(input: unknown): Promise<ActionResult<unknown>>;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
|
|
2
|
+
/*
|
|
3
|
+
* 🛑 From the DEFINING module, never "@mohasinac/appkit/server".
|
|
4
|
+
*
|
|
5
|
+
* appkit importing its own public server barrel is a self-reference that drags
|
|
6
|
+
* the whole server surface in behind it — `dist/server.js` reaches next/og,
|
|
7
|
+
* next/navigation, next/headers and driver.js. Twenty `actions.ts` files did
|
|
8
|
+
* this for two symbols, and because `obligationSweep` reaches one of them, the
|
|
9
|
+
* Firebase Functions tsup bundle (noExternal: appkit) had to resolve Next:
|
|
10
|
+
* it failed on two `react-server-dom-webpack/*` requires and two @vercel/og
|
|
11
|
+
* .wasm files, naming none of the responsible files. Root Cause #18.
|
|
12
|
+
*/
|
|
13
|
+
import { wrapAction } from "../../../shared/types/action-result.js";
|
|
3
14
|
import { productRepository } from "../../../../repositories/index.js";
|
|
4
15
|
import { requireRoleUser } from "../../../../providers/auth-firebase/helpers.js";
|
|
5
16
|
import { reservePreOrderSchema } from "../../../shared/features/pre-orders/schema.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type ActionResult } from "
|
|
1
|
+
import { type ActionResult } from "../../../shared/types/action-result";
|
|
2
2
|
export declare function enterPrizeDrawAction(input: unknown): Promise<ActionResult<unknown>>;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
|
|
2
|
+
/*
|
|
3
|
+
* 🛑 From the DEFINING module, never "@mohasinac/appkit/server".
|
|
4
|
+
*
|
|
5
|
+
* appkit importing its own public server barrel is a self-reference that drags
|
|
6
|
+
* the whole server surface in behind it — `dist/server.js` reaches next/og,
|
|
7
|
+
* next/navigation, next/headers and driver.js. Twenty `actions.ts` files did
|
|
8
|
+
* this for two symbols, and because `obligationSweep` reaches one of them, the
|
|
9
|
+
* Firebase Functions tsup bundle (noExternal: appkit) had to resolve Next:
|
|
10
|
+
* it failed on two `react-server-dom-webpack/*` requires and two @vercel/og
|
|
11
|
+
* .wasm files, naming none of the responsible files. Root Cause #18.
|
|
12
|
+
*/
|
|
13
|
+
import { wrapAction } from "../../../shared/types/action-result.js";
|
|
3
14
|
import { productRepository } from "../../../../repositories/index.js";
|
|
4
15
|
import { requireRoleUser } from "../../../../providers/auth-firebase/helpers.js";
|
|
5
16
|
import { assertPrizeDrawOpen } from "./service.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ActionResult } from "
|
|
1
|
+
import { type ActionResult } from "../../../shared/types/action-result";
|
|
2
2
|
export declare function createProductAction(input: unknown): Promise<ActionResult<unknown>>;
|
|
3
3
|
export declare function createAuctionAction(input: unknown): Promise<ActionResult<unknown>>;
|
|
4
4
|
export declare function createPreOrderAction(input: unknown): Promise<ActionResult<unknown>>;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
|
|
2
|
+
/*
|
|
3
|
+
* 🛑 From the DEFINING module, never "@mohasinac/appkit/server".
|
|
4
|
+
*
|
|
5
|
+
* appkit importing its own public server barrel is a self-reference that drags
|
|
6
|
+
* the whole server surface in behind it — `dist/server.js` reaches next/og,
|
|
7
|
+
* next/navigation, next/headers and driver.js. Twenty `actions.ts` files did
|
|
8
|
+
* this for two symbols, and because `obligationSweep` reaches one of them, the
|
|
9
|
+
* Firebase Functions tsup bundle (noExternal: appkit) had to resolve Next:
|
|
10
|
+
* it failed on two `react-server-dom-webpack/*` requires and two @vercel/og
|
|
11
|
+
* .wasm files, naming none of the responsible files. Root Cause #18.
|
|
12
|
+
*/
|
|
13
|
+
import { wrapAction } from "../../../shared/types/action-result.js";
|
|
3
14
|
import { productRepository } from "../../../../repositories/index.js";
|
|
4
15
|
import { requireRoleUser } from "../../../../providers/auth-firebase/helpers.js";
|
|
5
16
|
import { isAdminUser } from "../../../../features/auth/role-predicates.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ActionResult } from "
|
|
1
|
+
import { type ActionResult } from "../../../shared/types/action-result";
|
|
2
2
|
export declare function applyCouponAction(input: unknown): Promise<ActionResult<unknown>>;
|
|
3
3
|
export declare function createCouponAction(input: unknown): Promise<ActionResult<unknown>>;
|
|
4
4
|
export declare function updateCouponAction(couponId: string, input: unknown): Promise<ActionResult<unknown>>;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
|
|
2
|
+
/*
|
|
3
|
+
* 🛑 From the DEFINING module, never "@mohasinac/appkit/server".
|
|
4
|
+
*
|
|
5
|
+
* appkit importing its own public server barrel is a self-reference that drags
|
|
6
|
+
* the whole server surface in behind it — `dist/server.js` reaches next/og,
|
|
7
|
+
* next/navigation, next/headers and driver.js. Twenty `actions.ts` files did
|
|
8
|
+
* this for two symbols, and because `obligationSweep` reaches one of them, the
|
|
9
|
+
* Firebase Functions tsup bundle (noExternal: appkit) had to resolve Next:
|
|
10
|
+
* it failed on two `react-server-dom-webpack/*` requires and two @vercel/og
|
|
11
|
+
* .wasm files, naming none of the responsible files. Root Cause #18.
|
|
12
|
+
*/
|
|
13
|
+
import { wrapAction } from "../../../shared/types/action-result.js";
|
|
3
14
|
import { couponsRepository } from "../../../../repositories/index.js";
|
|
4
15
|
import { requireRoleUser } from "../../../../providers/auth-firebase/helpers.js";
|
|
5
16
|
import { applyCouponSchema, createCouponSchema, updateCouponSchema, } from "../../../shared/features/promotions/schema.js";
|
|
@@ -66,7 +66,7 @@ export declare function adjudicateProtectionClaimAction(claimId: string, finding
|
|
|
66
66
|
/** A buyer's own claims, for their order detail page. */
|
|
67
67
|
export declare function getMyProtectionClaimsAction(): Promise<ActionResult<ProtectionClaimDocument[]>>;
|
|
68
68
|
/** Whether this order can be claimed against right now, for rendering the CTA. */
|
|
69
|
-
export declare function canClaimProtection(order: Parameters<typeof deadlinesFor>[0], kind: "shipping" | "sale"): Promise<{
|
|
69
|
+
export declare function canClaimProtection(order: Parameters<typeof deadlinesFor>[0], kind: "shipping" | "sale"): Promise<ActionResult<{
|
|
70
70
|
can: boolean;
|
|
71
71
|
reason?: string;
|
|
72
|
-
}
|
|
72
|
+
}>>;
|
|
@@ -213,16 +213,25 @@ export async function getMyProtectionClaimsAction() {
|
|
|
213
213
|
}
|
|
214
214
|
/** Whether this order can be claimed against right now, for rendering the CTA. */
|
|
215
215
|
export async function canClaimProtection(order, kind) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
216
|
+
/*
|
|
217
|
+
* 🛑 Wrapped, because this file is `"use server"` — which makes EVERY export
|
|
218
|
+
* in it a client-callable RPC endpoint, read-only predicate included. So it
|
|
219
|
+
* owes the same uniform envelope as its sibling mutations: a caller cannot
|
|
220
|
+
* tell a thrown repository error from a `{can:false}` verdict otherwise, and
|
|
221
|
+
* "the claim window is closed" and "the lookup failed" are opposite answers.
|
|
222
|
+
*/
|
|
223
|
+
return wrapAction(async () => {
|
|
224
|
+
const feePaid = kind === "shipping" ? order.shipmentProtectionFee : order.saleProtectionFee;
|
|
225
|
+
if (!feePaid || feePaid <= 0)
|
|
226
|
+
return { can: false, reason: "not-covered" };
|
|
227
|
+
const existing = await protectionClaimsRepository().findById(createProtectionClaimId(order.id, kind));
|
|
228
|
+
if (existing)
|
|
229
|
+
return { can: false, reason: "already-claimed" };
|
|
230
|
+
const obligationKind = kind === "shipping" ? "claim-shipping" : "claim-sale";
|
|
231
|
+
const window = deadlinesFor(order).find((d) => d.kind === obligationKind);
|
|
232
|
+
if (order.deliveryDate && window && window.dueAt.getTime() <= Date.now()) {
|
|
233
|
+
return { can: false, reason: "window-closed" };
|
|
234
|
+
}
|
|
235
|
+
return { can: true };
|
|
236
|
+
});
|
|
228
237
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* handlers also work in a Vercel lambda (10s cap honoured by raffle pool
|
|
6
6
|
* size).
|
|
7
7
|
*/
|
|
8
|
-
import { type ActionResult } from "
|
|
8
|
+
import { type ActionResult } from "../../../shared/types/action-result";
|
|
9
9
|
import { type TriggerEventRaffleInput, type TriggerEventRaffleResult } from "../../jobs/core/triggerEventRaffle";
|
|
10
10
|
import { type AssignSpinPrizeInput, type AssignSpinPrizeResult } from "../../jobs/core/assignSpinPrize";
|
|
11
11
|
export declare function triggerEventRaffleAction(input: TriggerEventRaffleInput): Promise<ActionResult<TriggerEventRaffleResult>>;
|
|
@@ -6,7 +6,18 @@
|
|
|
6
6
|
* handlers also work in a Vercel lambda (10s cap honoured by raffle pool
|
|
7
7
|
* size).
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
/*
|
|
10
|
+
* 🛑 From the DEFINING module, never "@mohasinac/appkit/server".
|
|
11
|
+
*
|
|
12
|
+
* appkit importing its own public server barrel is a self-reference that drags
|
|
13
|
+
* the whole server surface in behind it — `dist/server.js` reaches next/og,
|
|
14
|
+
* next/navigation, next/headers and driver.js. Twenty `actions.ts` files did
|
|
15
|
+
* this for two symbols, and because `obligationSweep` reaches one of them, the
|
|
16
|
+
* Firebase Functions tsup bundle (noExternal: appkit) had to resolve Next:
|
|
17
|
+
* it failed on two `react-server-dom-webpack/*` requires and two @vercel/og
|
|
18
|
+
* .wasm files, naming none of the responsible files. Root Cause #18.
|
|
19
|
+
*/
|
|
20
|
+
import { wrapAction } from "../../../shared/types/action-result.js";
|
|
10
21
|
import { getAdminDb } from "../../../../providers/db-firebase/admin.js";
|
|
11
22
|
import { runTriggerEventRaffle, } from "../../jobs/core/triggerEventRaffle.js";
|
|
12
23
|
import { runAssignSpinPrize, } from "../../jobs/core/assignSpinPrize.js";
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { type ActionResult } from "
|
|
2
|
-
import type { RefundType } from "../../../../features/orders/schemas";
|
|
1
|
+
import { type ActionResult } from "../../../shared/types/action-result";
|
|
3
2
|
import { type ReturnReason } from "../../../shared/features/orders/return-reasons";
|
|
4
3
|
export type ProcessRefundInput = {
|
|
5
4
|
orderId: string;
|
|
6
|
-
type: RefundType;
|
|
7
5
|
/** Decimal rupees. Must be > 0 and ≤ remaining refundable amount on the order. */
|
|
8
6
|
amount: number;
|
|
9
7
|
/**
|