medusa-storefront-data 2.5.1 → 2.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HOMEPAGE_CONFIG.md +83 -10
- package/package.json +160 -115
- package/src/server/cart.ts +1 -1
- package/src/server/dynamic-config.ts +132 -12
- package/src/server/help-faq-section-defaults.json +92 -0
- package/src/server/help-sections/help-faq.ts +25 -0
- package/src/server/help-sections/index.ts +8 -0
- package/src/server/homepage-config.types.ts +24 -0
- package/src/server/homepage-section-defaults.ts +3 -0
- package/src/server/normalize-homepage-config.ts +39 -0
- package/dist/segment-data/default-page-input.json +0 -191
- package/dist/src/config.d.ts +0 -3
- package/dist/src/config.d.ts.map +0 -1
- package/dist/src/config.js +0 -31
- package/dist/src/cookies.d.ts +0 -23
- package/dist/src/cookies.d.ts.map +0 -1
- package/dist/src/cookies.js +0 -140
- package/dist/src/dynamic-config-schema/index.d.ts +0 -103
- package/dist/src/dynamic-config-schema/index.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/index.js +0 -172
- package/dist/src/dynamic-config-schema/sections/about-brand.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/about-brand.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/about-brand.js +0 -30
- package/dist/src/dynamic-config-schema/sections/baptism-picks.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/baptism-picks.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/baptism-picks.js +0 -17
- package/dist/src/dynamic-config-schema/sections/baptism.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/baptism.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/baptism.js +0 -4
- package/dist/src/dynamic-config-schema/sections/blog-posts.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/blog-posts.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/blog-posts.js +0 -31
- package/dist/src/dynamic-config-schema/sections/brand-marquee.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/brand-marquee.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/brand-marquee.js +0 -9
- package/dist/src/dynamic-config-schema/sections/brand-pillars.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/brand-pillars.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/brand-pillars.js +0 -29
- package/dist/src/dynamic-config-schema/sections/category-pills.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/category-pills.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/category-pills.js +0 -4
- package/dist/src/dynamic-config-schema/sections/celebrity-trust.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/celebrity-trust.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/celebrity-trust.js +0 -4
- package/dist/src/dynamic-config-schema/sections/features.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/features.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/features.js +0 -12
- package/dist/src/dynamic-config-schema/sections/hero.d.ts +0 -6
- package/dist/src/dynamic-config-schema/sections/hero.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/hero.js +0 -9
- package/dist/src/dynamic-config-schema/sections/index.d.ts +0 -24
- package/dist/src/dynamic-config-schema/sections/index.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/index.js +0 -23
- package/dist/src/dynamic-config-schema/sections/instagram-posts.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/instagram-posts.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/instagram-posts.js +0 -30
- package/dist/src/dynamic-config-schema/sections/loved-by-moms.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/loved-by-moms.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/loved-by-moms.js +0 -4
- package/dist/src/dynamic-config-schema/sections/luxe-favourites.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/luxe-favourites.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/luxe-favourites.js +0 -4
- package/dist/src/dynamic-config-schema/sections/new-arrivals-classic.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/new-arrivals-classic.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/new-arrivals-classic.js +0 -12
- package/dist/src/dynamic-config-schema/sections/new-arrivals.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/new-arrivals.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/new-arrivals.js +0 -12
- package/dist/src/dynamic-config-schema/sections/promo-announcements.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/promo-announcements.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/promo-announcements.js +0 -16
- package/dist/src/dynamic-config-schema/sections/promo-countdown.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/promo-countdown.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/promo-countdown.js +0 -16
- package/dist/src/dynamic-config-schema/sections/shop-by-age.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/shop-by-age.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/shop-by-age.js +0 -4
- package/dist/src/dynamic-config-schema/sections/shop-by-category.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/shop-by-category.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/shop-by-category.js +0 -4
- package/dist/src/dynamic-config-schema/sections/testimonials.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/testimonials.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/testimonials.js +0 -9
- package/dist/src/dynamic-config-schema/sections/theme-dresses.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/theme-dresses.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/theme-dresses.js +0 -4
- package/dist/src/dynamic-config-schema/sections/video-stories.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/video-stories.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/video-stories.js +0 -24
- package/dist/src/dynamic-config-schema/sections/why-choose-us.d.ts +0 -5
- package/dist/src/dynamic-config-schema/sections/why-choose-us.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/sections/why-choose-us.js +0 -9
- package/dist/src/dynamic-config-schema/shared.d.ts +0 -35
- package/dist/src/dynamic-config-schema/shared.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/shared.js +0 -99
- package/dist/src/dynamic-config-schema/site-configs.d.ts +0 -11
- package/dist/src/dynamic-config-schema/site-configs.d.ts.map +0 -1
- package/dist/src/dynamic-config-schema/site-configs.js +0 -70
- package/dist/src/edge.d.ts +0 -3
- package/dist/src/edge.d.ts.map +0 -1
- package/dist/src/edge.js +0 -1
- package/dist/src/middleware.d.ts +0 -3
- package/dist/src/middleware.d.ts.map +0 -1
- package/dist/src/middleware.js +0 -1
- package/dist/src/server/brand-pillars-from-categories.d.ts +0 -8
- package/dist/src/server/brand-pillars-from-categories.d.ts.map +0 -1
- package/dist/src/server/brand-pillars-from-categories.js +0 -92
- package/dist/src/server/cart.d.ts +0 -96
- package/dist/src/server/cart.d.ts.map +0 -1
- package/dist/src/server/cart.js +0 -797
- package/dist/src/server/categories.d.ts +0 -4
- package/dist/src/server/categories.d.ts.map +0 -1
- package/dist/src/server/categories.js +0 -34
- package/dist/src/server/collections.d.ts +0 -8
- package/dist/src/server/collections.d.ts.map +0 -1
- package/dist/src/server/collections.js +0 -39
- package/dist/src/server/config-merge.d.ts +0 -3
- package/dist/src/server/config-merge.d.ts.map +0 -1
- package/dist/src/server/config-merge.js +0 -31
- package/dist/src/server/contact.d.ts +0 -34
- package/dist/src/server/contact.d.ts.map +0 -1
- package/dist/src/server/contact.js +0 -57
- package/dist/src/server/customer-registration.d.ts +0 -142
- package/dist/src/server/customer-registration.d.ts.map +0 -1
- package/dist/src/server/customer-registration.js +0 -295
- package/dist/src/server/customer.d.ts +0 -48
- package/dist/src/server/customer.d.ts.map +0 -1
- package/dist/src/server/customer.js +0 -413
- package/dist/src/server/dynamic-config-api.d.ts +0 -11
- package/dist/src/server/dynamic-config-api.d.ts.map +0 -1
- package/dist/src/server/dynamic-config-api.js +0 -46
- package/dist/src/server/dynamic-config.d.ts +0 -157
- package/dist/src/server/dynamic-config.d.ts.map +0 -1
- package/dist/src/server/dynamic-config.js +0 -573
- package/dist/src/server/fulfillment.d.ts +0 -5
- package/dist/src/server/fulfillment.d.ts.map +0 -1
- package/dist/src/server/fulfillment.js +0 -47
- package/dist/src/server/guest.d.ts +0 -81
- package/dist/src/server/guest.d.ts.map +0 -1
- package/dist/src/server/guest.js +0 -183
- package/dist/src/server/home-sections/about-brand.d.ts +0 -9
- package/dist/src/server/home-sections/about-brand.d.ts.map +0 -1
- package/dist/src/server/home-sections/about-brand.js +0 -9
- package/dist/src/server/home-sections/baptism-picks.d.ts +0 -10
- package/dist/src/server/home-sections/baptism-picks.d.ts.map +0 -1
- package/dist/src/server/home-sections/baptism-picks.js +0 -27
- package/dist/src/server/home-sections/baptism.d.ts +0 -13
- package/dist/src/server/home-sections/baptism.d.ts.map +0 -1
- package/dist/src/server/home-sections/baptism.js +0 -43
- package/dist/src/server/home-sections/blog-posts.d.ts +0 -9
- package/dist/src/server/home-sections/blog-posts.d.ts.map +0 -1
- package/dist/src/server/home-sections/blog-posts.js +0 -9
- package/dist/src/server/home-sections/brand-marquee.d.ts +0 -8
- package/dist/src/server/home-sections/brand-marquee.d.ts.map +0 -1
- package/dist/src/server/home-sections/brand-marquee.js +0 -7
- package/dist/src/server/home-sections/brand-pillars.d.ts +0 -9
- package/dist/src/server/home-sections/brand-pillars.d.ts.map +0 -1
- package/dist/src/server/home-sections/brand-pillars.js +0 -9
- package/dist/src/server/home-sections/category-pills.d.ts +0 -9
- package/dist/src/server/home-sections/category-pills.d.ts.map +0 -1
- package/dist/src/server/home-sections/category-pills.js +0 -19
- package/dist/src/server/home-sections/celebrity-trust.d.ts +0 -12
- package/dist/src/server/home-sections/celebrity-trust.d.ts.map +0 -1
- package/dist/src/server/home-sections/celebrity-trust.js +0 -27
- package/dist/src/server/home-sections/features.d.ts +0 -9
- package/dist/src/server/home-sections/features.d.ts.map +0 -1
- package/dist/src/server/home-sections/features.js +0 -9
- package/dist/src/server/home-sections/hero.d.ts +0 -9
- package/dist/src/server/home-sections/hero.d.ts.map +0 -1
- package/dist/src/server/home-sections/hero.js +0 -9
- package/dist/src/server/home-sections/instagram-posts.d.ts +0 -9
- package/dist/src/server/home-sections/instagram-posts.d.ts.map +0 -1
- package/dist/src/server/home-sections/instagram-posts.js +0 -9
- package/dist/src/server/home-sections/loved-by-moms.d.ts +0 -12
- package/dist/src/server/home-sections/loved-by-moms.d.ts.map +0 -1
- package/dist/src/server/home-sections/loved-by-moms.js +0 -20
- package/dist/src/server/home-sections/luxe-favourites.d.ts +0 -11
- package/dist/src/server/home-sections/luxe-favourites.d.ts.map +0 -1
- package/dist/src/server/home-sections/luxe-favourites.js +0 -19
- package/dist/src/server/home-sections/new-arrivals-classic.d.ts +0 -8
- package/dist/src/server/home-sections/new-arrivals-classic.d.ts.map +0 -1
- package/dist/src/server/home-sections/new-arrivals-classic.js +0 -10
- package/dist/src/server/home-sections/new-arrivals.d.ts +0 -12
- package/dist/src/server/home-sections/new-arrivals.d.ts.map +0 -1
- package/dist/src/server/home-sections/new-arrivals.js +0 -28
- package/dist/src/server/home-sections/promo-announcements.d.ts +0 -7
- package/dist/src/server/home-sections/promo-announcements.d.ts.map +0 -1
- package/dist/src/server/home-sections/promo-announcements.js +0 -7
- package/dist/src/server/home-sections/promo-countdown.d.ts +0 -6
- package/dist/src/server/home-sections/promo-countdown.d.ts.map +0 -1
- package/dist/src/server/home-sections/promo-countdown.js +0 -5
- package/dist/src/server/home-sections/shared.d.ts +0 -10
- package/dist/src/server/home-sections/shared.d.ts.map +0 -1
- package/dist/src/server/home-sections/shared.js +0 -29
- package/dist/src/server/home-sections/shop-by-age.d.ts +0 -9
- package/dist/src/server/home-sections/shop-by-age.d.ts.map +0 -1
- package/dist/src/server/home-sections/shop-by-age.js +0 -17
- package/dist/src/server/home-sections/shop-by-category.d.ts +0 -10
- package/dist/src/server/home-sections/shop-by-category.d.ts.map +0 -1
- package/dist/src/server/home-sections/shop-by-category.js +0 -17
- package/dist/src/server/home-sections/testimonials.d.ts +0 -9
- package/dist/src/server/home-sections/testimonials.d.ts.map +0 -1
- package/dist/src/server/home-sections/testimonials.js +0 -9
- package/dist/src/server/home-sections/theme-dresses.d.ts +0 -12
- package/dist/src/server/home-sections/theme-dresses.d.ts.map +0 -1
- package/dist/src/server/home-sections/theme-dresses.js +0 -27
- package/dist/src/server/home-sections/video-stories.d.ts +0 -9
- package/dist/src/server/home-sections/video-stories.d.ts.map +0 -1
- package/dist/src/server/home-sections/video-stories.js +0 -9
- package/dist/src/server/home-sections/why-choose-us.d.ts +0 -9
- package/dist/src/server/home-sections/why-choose-us.d.ts.map +0 -1
- package/dist/src/server/home-sections/why-choose-us.js +0 -9
- package/dist/src/server/home.d.ts +0 -51
- package/dist/src/server/home.d.ts.map +0 -1
- package/dist/src/server/home.js +0 -1
- package/dist/src/server/homepage-config.types.d.ts +0 -274
- package/dist/src/server/homepage-config.types.d.ts.map +0 -1
- package/dist/src/server/homepage-config.types.js +0 -33
- package/dist/src/server/homepage-section-defaults.d.ts +0 -188
- package/dist/src/server/homepage-section-defaults.d.ts.map +0 -1
- package/dist/src/server/homepage-section-defaults.js +0 -188
- package/dist/src/server/index.d.ts +0 -25
- package/dist/src/server/index.d.ts.map +0 -1
- package/dist/src/server/index.js +0 -24
- package/dist/src/server/locale-actions.d.ts +0 -14
- package/dist/src/server/locale-actions.d.ts.map +0 -1
- package/dist/src/server/locale-actions.js +0 -58
- package/dist/src/server/locales.d.ts +0 -8
- package/dist/src/server/locales.d.ts.map +0 -1
- package/dist/src/server/locales.js +0 -12
- package/dist/src/server/normalize-homepage-config.d.ts +0 -7
- package/dist/src/server/normalize-homepage-config.d.ts.map +0 -1
- package/dist/src/server/normalize-homepage-config.js +0 -213
- package/dist/src/server/notifications.d.ts +0 -2
- package/dist/src/server/notifications.d.ts.map +0 -1
- package/dist/src/server/notifications.js +0 -20
- package/dist/src/server/onboarding.d.ts +0 -2
- package/dist/src/server/onboarding.d.ts.map +0 -1
- package/dist/src/server/onboarding.js +0 -8
- package/dist/src/server/orders.d.ts +0 -63
- package/dist/src/server/orders.d.ts.map +0 -1
- package/dist/src/server/orders.js +0 -230
- package/dist/src/server/page-input.d.ts +0 -19
- package/dist/src/server/page-input.d.ts.map +0 -1
- package/dist/src/server/page-input.js +0 -42
- package/dist/src/server/payment-details.d.ts +0 -5
- package/dist/src/server/payment-details.d.ts.map +0 -1
- package/dist/src/server/payment-details.js +0 -28
- package/dist/src/server/payment.d.ts +0 -3
- package/dist/src/server/payment.d.ts.map +0 -1
- package/dist/src/server/payment.js +0 -13
- package/dist/src/server/pincode.d.ts +0 -7
- package/dist/src/server/pincode.d.ts.map +0 -1
- package/dist/src/server/pincode.js +0 -30
- package/dist/src/server/products.d.ts +0 -54
- package/dist/src/server/products.d.ts.map +0 -1
- package/dist/src/server/products.js +0 -154
- package/dist/src/server/regions.d.ts +0 -5
- package/dist/src/server/regions.d.ts.map +0 -1
- package/dist/src/server/regions.js +0 -57
- package/dist/src/server/resolve-home-segment-data.d.ts +0 -25
- package/dist/src/server/resolve-home-segment-data.d.ts.map +0 -1
- package/dist/src/server/resolve-home-segment-data.js +0 -20
- package/dist/src/server/returns.d.ts +0 -29
- package/dist/src/server/returns.d.ts.map +0 -1
- package/dist/src/server/returns.js +0 -132
- package/dist/src/server/shoppable-looks.d.ts +0 -17
- package/dist/src/server/shoppable-looks.d.ts.map +0 -1
- package/dist/src/server/shoppable-looks.js +0 -136
- package/dist/src/server/swaps.d.ts +0 -15
- package/dist/src/server/swaps.d.ts.map +0 -1
- package/dist/src/server/swaps.js +0 -89
- package/dist/src/server/variants.d.ts +0 -3
- package/dist/src/server/variants.d.ts.map +0 -1
- package/dist/src/server/variants.js +0 -15
- package/dist/src/server/wishlist.d.ts +0 -11
- package/dist/src/server/wishlist.d.ts.map +0 -1
- package/dist/src/server/wishlist.js +0 -49
- package/dist/src/util/get-locale-header.d.ts +0 -4
- package/dist/src/util/get-locale-header.d.ts.map +0 -1
- package/dist/src/util/get-locale-header.js +0 -7
- package/dist/src/util/medusa-error.d.ts +0 -2
- package/dist/src/util/medusa-error.d.ts.map +0 -1
- package/dist/src/util/medusa-error.js +0 -18
- package/dist/src/util/revalidate-cart.d.ts +0 -2
- package/dist/src/util/revalidate-cart.d.ts.map +0 -1
- package/dist/src/util/revalidate-cart.js +0 -8
- package/dist/src/util/sort-products.d.ts +0 -3
- package/dist/src/util/sort-products.d.ts.map +0 -1
- package/dist/src/util/sort-products.js +0 -1
- package/dist/src/util/store-client.d.ts +0 -11
- package/dist/src/util/store-client.d.ts.map +0 -1
- package/dist/src/util/store-client.js +0 -75
package/dist/src/server/swaps.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
import { medusaSwapCreate, medusaSwapCreateGuest, medusaSwapList, medusaSwapListGuest, } from "medusa-services/swaps";
|
|
3
|
-
import { cookies } from "next/headers";
|
|
4
|
-
import { revalidateTag } from "next/cache";
|
|
5
|
-
import { getStoreClientOptions, getStoreClientOptionsWithToken } from "../util/store-client";
|
|
6
|
-
/**
|
|
7
|
-
* Create an exchange (swap) request.
|
|
8
|
-
* Supports both authenticated customers and guest users.
|
|
9
|
-
*/
|
|
10
|
-
export const createSwapRequest = async (_prevState, formData) => {
|
|
11
|
-
const orderId = formData.get("order_id");
|
|
12
|
-
const returnItemsJson = formData.get("return_items");
|
|
13
|
-
const newItemsJson = formData.get("new_items");
|
|
14
|
-
const reason = formData.get("reason");
|
|
15
|
-
const note = formData.get("note");
|
|
16
|
-
if (!orderId)
|
|
17
|
-
return { success: false, error: "Order ID is required", swap: null };
|
|
18
|
-
if (!returnItemsJson)
|
|
19
|
-
return { success: false, error: "Items to return are required", swap: null };
|
|
20
|
-
if (!newItemsJson)
|
|
21
|
-
return { success: false, error: "New items are required", swap: null };
|
|
22
|
-
let returnItems = [];
|
|
23
|
-
let newItems = [];
|
|
24
|
-
try {
|
|
25
|
-
returnItems = JSON.parse(returnItemsJson);
|
|
26
|
-
newItems = JSON.parse(newItemsJson);
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
return { success: false, error: "Invalid items data format", swap: null };
|
|
30
|
-
}
|
|
31
|
-
if (returnItems.length === 0) {
|
|
32
|
-
return { success: false, error: "At least one item must be selected for return", swap: null };
|
|
33
|
-
}
|
|
34
|
-
const options = await getStoreClientOptions();
|
|
35
|
-
try {
|
|
36
|
-
const payload = {
|
|
37
|
-
order_id: orderId,
|
|
38
|
-
return_items: returnItems,
|
|
39
|
-
new_items: newItems,
|
|
40
|
-
reason: reason || "Size exchange",
|
|
41
|
-
note: note || "Exchange requested from storefront",
|
|
42
|
-
};
|
|
43
|
-
const cookieStore = await cookies();
|
|
44
|
-
const guestToken = cookieStore.get("_medusa_guest_jwt")?.value ||
|
|
45
|
-
cookieStore.get("_medusa_guest_token")?.value;
|
|
46
|
-
const token = cookieStore.get("_medusa_jwt")?.value;
|
|
47
|
-
let swapData;
|
|
48
|
-
if (guestToken && !token) {
|
|
49
|
-
const guestOptions = await getStoreClientOptionsWithToken(guestToken);
|
|
50
|
-
swapData = await medusaSwapCreateGuest(orderId, {
|
|
51
|
-
return_items: payload.return_items,
|
|
52
|
-
new_items: payload.new_items,
|
|
53
|
-
reason: payload.reason,
|
|
54
|
-
note: payload.note,
|
|
55
|
-
}, guestOptions);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
swapData = await medusaSwapCreate(payload, options);
|
|
59
|
-
}
|
|
60
|
-
revalidateTag("orders");
|
|
61
|
-
return { success: true, error: null, swap: swapData };
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
let errorMsg = "Failed to create exchange request";
|
|
65
|
-
if (error instanceof Error && error.message) {
|
|
66
|
-
errorMsg = error.message;
|
|
67
|
-
}
|
|
68
|
-
return { success: false, error: errorMsg, swap: null };
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* List swaps for an order or customer
|
|
73
|
-
*/
|
|
74
|
-
export const listSwaps = async (orderId) => {
|
|
75
|
-
const options = await getStoreClientOptions();
|
|
76
|
-
if (options.authorization) {
|
|
77
|
-
return medusaSwapList(options, orderId ? { order_id: orderId } : undefined);
|
|
78
|
-
}
|
|
79
|
-
if (orderId) {
|
|
80
|
-
const cookieStore = await cookies();
|
|
81
|
-
const guestToken = cookieStore.get("_medusa_guest_jwt")?.value ||
|
|
82
|
-
cookieStore.get("_medusa_guest_token")?.value;
|
|
83
|
-
if (guestToken) {
|
|
84
|
-
const guestOptions = await getStoreClientOptionsWithToken(guestToken);
|
|
85
|
-
return medusaSwapListGuest(orderId, guestOptions);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return { swaps: [], count: 0 };
|
|
89
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../src/server/variants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAI3C,eAAO,MAAM,eAAe,GAC1B,YAAY,MAAM,KACjB,OAAO,CAAC,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAU9C,CAAA"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
import { medusaVariantRetrieve } from "medusa-services/variants";
|
|
3
|
-
import { getStoreClientOptions } from "../util/store-client";
|
|
4
|
-
export const retrieveVariant = async (variant_id) => {
|
|
5
|
-
try {
|
|
6
|
-
const options = await getStoreClientOptions();
|
|
7
|
-
if (!options.authorization)
|
|
8
|
-
return null;
|
|
9
|
-
const { variant } = await medusaVariantRetrieve(variant_id, options, { fields: "*images" });
|
|
10
|
-
return variant;
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/** Wishlist entries enriched with full Medusa product payloads. */
|
|
2
|
-
export declare function getWishlist(includeDetails?: boolean, countryCode?: string): Promise<{
|
|
3
|
-
success: false;
|
|
4
|
-
error: string;
|
|
5
|
-
data: unknown[];
|
|
6
|
-
} | {
|
|
7
|
-
success: true;
|
|
8
|
-
data: Record<string, unknown>[];
|
|
9
|
-
error?: undefined;
|
|
10
|
-
}>;
|
|
11
|
-
//# sourceMappingURL=wishlist.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wishlist.d.ts","sourceRoot":"","sources":["../../../src/server/wishlist.ts"],"names":[],"mappings":"AAOA,mEAAmE;AACnE,wBAAsB,WAAW,CAAC,cAAc,UAAO,EAAE,WAAW,CAAC,EAAE,MAAM;;;UAGF,OAAO,EAAE;;;;;GAoDnF"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
import { sdk } from "../config";
|
|
3
|
-
import { getRegion } from "./regions";
|
|
4
|
-
import { fetchWishlist } from "medusa-wishlist-logic/server";
|
|
5
|
-
/** Wishlist entries enriched with full Medusa product payloads. */
|
|
6
|
-
export async function getWishlist(includeDetails = true, countryCode) {
|
|
7
|
-
const result = await fetchWishlist(includeDetails);
|
|
8
|
-
if (!result.success) {
|
|
9
|
-
return { success: false, error: result.error, data: [] };
|
|
10
|
-
}
|
|
11
|
-
let wishlistItems = result.data;
|
|
12
|
-
if (!includeDetails || wishlistItems.length === 0) {
|
|
13
|
-
return { success: true, data: wishlistItems };
|
|
14
|
-
}
|
|
15
|
-
const productIds = wishlistItems
|
|
16
|
-
.map((item) => {
|
|
17
|
-
const id = item.product_id ?? item.id;
|
|
18
|
-
return typeof id === "string" ? id : null;
|
|
19
|
-
})
|
|
20
|
-
.filter((id) => Boolean(id));
|
|
21
|
-
if (productIds.length === 0) {
|
|
22
|
-
return { success: true, data: wishlistItems };
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
let regionId;
|
|
26
|
-
if (countryCode) {
|
|
27
|
-
const region = await getRegion(countryCode);
|
|
28
|
-
regionId = region?.id;
|
|
29
|
-
}
|
|
30
|
-
const productsResponse = await sdk.store.product.list({
|
|
31
|
-
id: productIds,
|
|
32
|
-
fields: "*thumbnail,*images,*variants,*variants.options,*options,*options.values,*variants.calculated_price,*variants.inventory_quantity,*variants.manage_inventory,*variants.allow_backorder",
|
|
33
|
-
...(regionId ? { region_id: regionId } : {}),
|
|
34
|
-
}, {});
|
|
35
|
-
const fullProducts = productsResponse.products;
|
|
36
|
-
wishlistItems = wishlistItems.map((item) => {
|
|
37
|
-
const itemId = (item.product_id ?? item.id);
|
|
38
|
-
const fullProduct = fullProducts.find((p) => p.id === itemId);
|
|
39
|
-
if (fullProduct) {
|
|
40
|
-
return { ...item, product: fullProduct };
|
|
41
|
-
}
|
|
42
|
-
return item;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
// Return API wishlist without enrichment
|
|
47
|
-
}
|
|
48
|
-
return { success: true, data: wishlistItems };
|
|
49
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-locale-header.d.ts","sourceRoot":"","sources":["../../../src/util/get-locale-header.ts"],"names":[],"mappings":"AAEA,wBAAsB,eAAe;;GAKpC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"medusa-error.d.ts","sourceRoot":"","sources":["../../../src/util/medusa-error.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,CAkBrD"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export default function medusaError(error) {
|
|
2
|
-
if (error.response) {
|
|
3
|
-
// The request was made and the server responded with a status code
|
|
4
|
-
// that falls out of the range of 2xx
|
|
5
|
-
const u = new URL(error.config.url, error.config.baseURL);
|
|
6
|
-
// Extracting the error message from the response data
|
|
7
|
-
const message = error.response.data.message || error.response.data;
|
|
8
|
-
throw new Error(message.charAt(0).toUpperCase() + message.slice(1) + ".");
|
|
9
|
-
}
|
|
10
|
-
else if (error.request) {
|
|
11
|
-
// The request was made but no response was received
|
|
12
|
-
throw new Error("No response received: " + error.request);
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
// Something happened in setting up the request that triggered an Error
|
|
16
|
-
throw new Error("Error setting up the request: " + error.message);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"revalidate-cart.d.ts","sourceRoot":"","sources":["../../../src/util/revalidate-cart.ts"],"names":[],"mappings":"AAGA,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAMxD"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { revalidateTag } from "next/cache";
|
|
2
|
-
import { getCacheTag } from "../cookies";
|
|
3
|
-
export async function revalidateCartTags() {
|
|
4
|
-
const cartCacheTag = await getCacheTag("carts");
|
|
5
|
-
revalidateTag(cartCacheTag);
|
|
6
|
-
const fulfillmentCacheTag = await getCacheTag("fulfillment");
|
|
7
|
-
revalidateTag(fulfillmentCacheTag);
|
|
8
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sort-products.d.ts","sourceRoot":"","sources":["../../../src/util/sort-products.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { sortProducts } from "medusa-services/product-listing";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { MedusaStoreClientOptions } from "medusa-services/store-api";
|
|
2
|
-
import { type MedusaAuthClientOptions } from "medusa-services/auth";
|
|
3
|
-
/**
|
|
4
|
-
* Builds portable Medusa store client options from Next.js cookies and env.
|
|
5
|
-
*/
|
|
6
|
-
export declare function getStoreClientOptions(): Promise<MedusaStoreClientOptions>;
|
|
7
|
-
export declare function getMedusaBackendUrl(): string;
|
|
8
|
-
export declare function getGuestStoreClientOptions(): Promise<MedusaStoreClientOptions | null>;
|
|
9
|
-
export declare function getStoreClientOptionsWithToken(token: string): Promise<MedusaStoreClientOptions>;
|
|
10
|
-
export declare function getAuthClientOptions(authorization?: string): Promise<MedusaAuthClientOptions>;
|
|
11
|
-
//# sourceMappingURL=store-client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"store-client.d.ts","sourceRoot":"","sources":["../../../src/util/store-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AACzE,OAAO,EAAuB,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAqBxF;;GAEG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAY/E;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC,CAuB3F;AAED,wBAAsB,8BAA8B,CAClD,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,wBAAwB,CAAC,CAMnC;AAED,wBAAsB,oBAAoB,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAWnG"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { getStoreAuthOptions } from "medusa-services/auth";
|
|
2
|
-
import { getAuthHeaders, getGuestAuthHeaders } from "../cookies";
|
|
3
|
-
import { getLocaleHeader } from "./get-locale-header";
|
|
4
|
-
import { cookies as nextCookies } from "next/headers";
|
|
5
|
-
function getBackendUrl() {
|
|
6
|
-
return (process.env.MEDUSA_BACKEND_URL?.replace(/\/$/, "") ||
|
|
7
|
-
process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL?.replace(/\/$/, "") ||
|
|
8
|
-
"http://localhost:9000");
|
|
9
|
-
}
|
|
10
|
-
function getPublishableApiKey() {
|
|
11
|
-
const key = process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY;
|
|
12
|
-
if (!key) {
|
|
13
|
-
throw new Error("NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY is not configured");
|
|
14
|
-
}
|
|
15
|
-
return key;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Builds portable Medusa store client options from Next.js cookies and env.
|
|
19
|
-
*/
|
|
20
|
-
export async function getStoreClientOptions() {
|
|
21
|
-
const auth = await getAuthHeaders();
|
|
22
|
-
const localeHeader = await getLocaleHeader().catch(() => ({}));
|
|
23
|
-
return {
|
|
24
|
-
backendUrl: getBackendUrl(),
|
|
25
|
-
publishableApiKey: getPublishableApiKey(),
|
|
26
|
-
authorization: "authorization" in auth ? auth.authorization : undefined,
|
|
27
|
-
headers: localeHeader["x-medusa-locale"]
|
|
28
|
-
? { "x-medusa-locale": localeHeader["x-medusa-locale"] }
|
|
29
|
-
: undefined,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
export function getMedusaBackendUrl() {
|
|
33
|
-
return getBackendUrl();
|
|
34
|
-
}
|
|
35
|
-
export async function getGuestStoreClientOptions() {
|
|
36
|
-
const guestAuth = await getGuestAuthHeaders();
|
|
37
|
-
let authorization = "authorization" in guestAuth ? guestAuth.authorization : undefined;
|
|
38
|
-
if (!authorization) {
|
|
39
|
-
try {
|
|
40
|
-
const cookieStore = await nextCookies();
|
|
41
|
-
const legacyToken = cookieStore.get("_medusa_guest_token")?.value;
|
|
42
|
-
if (legacyToken) {
|
|
43
|
-
authorization = `Bearer ${legacyToken}`;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (!authorization)
|
|
51
|
-
return null;
|
|
52
|
-
return {
|
|
53
|
-
backendUrl: getBackendUrl(),
|
|
54
|
-
publishableApiKey: getPublishableApiKey(),
|
|
55
|
-
authorization,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
export async function getStoreClientOptionsWithToken(token) {
|
|
59
|
-
return {
|
|
60
|
-
backendUrl: getBackendUrl(),
|
|
61
|
-
publishableApiKey: getPublishableApiKey(),
|
|
62
|
-
authorization: token.startsWith("Bearer ") ? token : `Bearer ${token}`,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
export async function getAuthClientOptions(authorization) {
|
|
66
|
-
if (authorization) {
|
|
67
|
-
return getStoreAuthOptions({
|
|
68
|
-
backendUrl: getBackendUrl(),
|
|
69
|
-
publishableApiKey: getPublishableApiKey(),
|
|
70
|
-
authorization,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
const storeOptions = await getStoreClientOptions();
|
|
74
|
-
return getStoreAuthOptions(storeOptions);
|
|
75
|
-
}
|