medusa-storefront-data 2.5.5 → 2.5.7
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 +2 -2
- package/dist/segment-data/default-page-input.json +191 -0
- package/dist/src/config.d.ts +3 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +31 -0
- package/dist/src/cookies.d.ts +23 -0
- package/dist/src/cookies.d.ts.map +1 -0
- package/dist/src/cookies.js +140 -0
- package/dist/src/dynamic-config-schema/index.d.ts +103 -0
- package/dist/src/dynamic-config-schema/index.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/index.js +172 -0
- package/dist/src/dynamic-config-schema/sections/about-brand.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/about-brand.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/about-brand.js +30 -0
- package/dist/src/dynamic-config-schema/sections/baptism-picks.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/baptism-picks.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/baptism-picks.js +17 -0
- package/dist/src/dynamic-config-schema/sections/baptism.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/baptism.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/baptism.js +4 -0
- package/dist/src/dynamic-config-schema/sections/blog-posts.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/blog-posts.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/blog-posts.js +31 -0
- package/dist/src/dynamic-config-schema/sections/brand-marquee.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/brand-marquee.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/brand-marquee.js +9 -0
- package/dist/src/dynamic-config-schema/sections/brand-pillars.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/brand-pillars.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/brand-pillars.js +29 -0
- package/dist/src/dynamic-config-schema/sections/category-pills.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/category-pills.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/category-pills.js +4 -0
- package/dist/src/dynamic-config-schema/sections/celebrity-trust.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/celebrity-trust.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/celebrity-trust.js +4 -0
- package/dist/src/dynamic-config-schema/sections/features.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/features.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/features.js +12 -0
- package/dist/src/dynamic-config-schema/sections/hero.d.ts +6 -0
- package/dist/src/dynamic-config-schema/sections/hero.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/hero.js +9 -0
- package/dist/src/dynamic-config-schema/sections/index.d.ts +24 -0
- package/dist/src/dynamic-config-schema/sections/index.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/index.js +23 -0
- package/dist/src/dynamic-config-schema/sections/instagram-posts.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/instagram-posts.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/instagram-posts.js +30 -0
- package/dist/src/dynamic-config-schema/sections/loved-by-moms.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/loved-by-moms.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/loved-by-moms.js +4 -0
- package/dist/src/dynamic-config-schema/sections/luxe-favourites.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/luxe-favourites.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/luxe-favourites.js +4 -0
- package/dist/src/dynamic-config-schema/sections/new-arrivals-classic.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/new-arrivals-classic.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/new-arrivals-classic.js +12 -0
- package/dist/src/dynamic-config-schema/sections/new-arrivals.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/new-arrivals.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/new-arrivals.js +12 -0
- package/dist/src/dynamic-config-schema/sections/promo-announcements.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/promo-announcements.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/promo-announcements.js +16 -0
- package/dist/src/dynamic-config-schema/sections/promo-countdown.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/promo-countdown.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/promo-countdown.js +16 -0
- package/dist/src/dynamic-config-schema/sections/shop-by-age.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/shop-by-age.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/shop-by-age.js +4 -0
- package/dist/src/dynamic-config-schema/sections/shop-by-category.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/shop-by-category.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/shop-by-category.js +4 -0
- package/dist/src/dynamic-config-schema/sections/testimonials.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/testimonials.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/testimonials.js +9 -0
- package/dist/src/dynamic-config-schema/sections/theme-dresses.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/theme-dresses.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/theme-dresses.js +4 -0
- package/dist/src/dynamic-config-schema/sections/video-stories.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/video-stories.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/video-stories.js +24 -0
- package/dist/src/dynamic-config-schema/sections/why-choose-us.d.ts +5 -0
- package/dist/src/dynamic-config-schema/sections/why-choose-us.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/sections/why-choose-us.js +9 -0
- package/dist/src/dynamic-config-schema/shared.d.ts +35 -0
- package/dist/src/dynamic-config-schema/shared.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/shared.js +99 -0
- package/dist/src/dynamic-config-schema/site-configs.d.ts +11 -0
- package/dist/src/dynamic-config-schema/site-configs.d.ts.map +1 -0
- package/dist/src/dynamic-config-schema/site-configs.js +70 -0
- package/dist/src/edge.d.ts +3 -0
- package/dist/src/edge.d.ts.map +1 -0
- package/dist/src/edge.js +1 -0
- package/dist/src/middleware.d.ts +3 -0
- package/dist/src/middleware.d.ts.map +1 -0
- package/dist/src/middleware.js +1 -0
- package/dist/src/server/brand-pillars-from-categories.d.ts +8 -0
- package/dist/src/server/brand-pillars-from-categories.d.ts.map +1 -0
- package/dist/src/server/brand-pillars-from-categories.js +92 -0
- package/dist/src/server/cart.d.ts +96 -0
- package/dist/src/server/cart.d.ts.map +1 -0
- package/dist/src/server/cart.js +797 -0
- package/dist/src/server/categories.d.ts +4 -0
- package/dist/src/server/categories.d.ts.map +1 -0
- package/dist/src/server/categories.js +34 -0
- package/dist/src/server/collections.d.ts +8 -0
- package/dist/src/server/collections.d.ts.map +1 -0
- package/dist/src/server/collections.js +39 -0
- package/dist/src/server/config-merge.d.ts +3 -0
- package/dist/src/server/config-merge.d.ts.map +1 -0
- package/dist/src/server/config-merge.js +31 -0
- package/dist/src/server/contact.d.ts +34 -0
- package/dist/src/server/contact.d.ts.map +1 -0
- package/dist/src/server/contact.js +57 -0
- package/dist/src/server/customer-registration.d.ts +142 -0
- package/dist/src/server/customer-registration.d.ts.map +1 -0
- package/dist/src/server/customer-registration.js +295 -0
- package/dist/src/server/customer.d.ts +48 -0
- package/dist/src/server/customer.d.ts.map +1 -0
- package/dist/src/server/customer.js +413 -0
- package/dist/src/server/dynamic-config-api.d.ts +11 -0
- package/dist/src/server/dynamic-config-api.d.ts.map +1 -0
- package/dist/src/server/dynamic-config-api.js +46 -0
- package/dist/src/server/dynamic-config.d.ts +186 -0
- package/dist/src/server/dynamic-config.d.ts.map +1 -0
- package/dist/src/server/dynamic-config.js +694 -0
- package/dist/src/server/fulfillment.d.ts +5 -0
- package/dist/src/server/fulfillment.d.ts.map +1 -0
- package/dist/src/server/fulfillment.js +47 -0
- package/dist/src/server/guest.d.ts +81 -0
- package/dist/src/server/guest.d.ts.map +1 -0
- package/dist/src/server/guest.js +183 -0
- package/dist/src/server/help-faq-section-defaults.json +92 -0
- package/dist/src/server/help-sections/help-faq.d.ts +11 -0
- package/dist/src/server/help-sections/help-faq.d.ts.map +1 -0
- package/dist/src/server/help-sections/help-faq.js +6 -0
- package/dist/src/server/help-sections/index.d.ts +2 -0
- package/dist/src/server/help-sections/index.d.ts.map +1 -0
- package/dist/src/server/help-sections/index.js +1 -0
- package/dist/src/server/home-sections/about-brand.d.ts +9 -0
- package/dist/src/server/home-sections/about-brand.d.ts.map +1 -0
- package/dist/src/server/home-sections/about-brand.js +9 -0
- package/dist/src/server/home-sections/baptism-picks.d.ts +10 -0
- package/dist/src/server/home-sections/baptism-picks.d.ts.map +1 -0
- package/dist/src/server/home-sections/baptism-picks.js +27 -0
- package/dist/src/server/home-sections/baptism.d.ts +13 -0
- package/dist/src/server/home-sections/baptism.d.ts.map +1 -0
- package/dist/src/server/home-sections/baptism.js +43 -0
- package/dist/src/server/home-sections/blog-posts.d.ts +9 -0
- package/dist/src/server/home-sections/blog-posts.d.ts.map +1 -0
- package/dist/src/server/home-sections/blog-posts.js +9 -0
- package/dist/src/server/home-sections/brand-marquee.d.ts +8 -0
- package/dist/src/server/home-sections/brand-marquee.d.ts.map +1 -0
- package/dist/src/server/home-sections/brand-marquee.js +7 -0
- package/dist/src/server/home-sections/brand-pillars.d.ts +9 -0
- package/dist/src/server/home-sections/brand-pillars.d.ts.map +1 -0
- package/dist/src/server/home-sections/brand-pillars.js +9 -0
- package/dist/src/server/home-sections/category-pills.d.ts +9 -0
- package/dist/src/server/home-sections/category-pills.d.ts.map +1 -0
- package/dist/src/server/home-sections/category-pills.js +19 -0
- package/dist/src/server/home-sections/celebrity-trust.d.ts +12 -0
- package/dist/src/server/home-sections/celebrity-trust.d.ts.map +1 -0
- package/dist/src/server/home-sections/celebrity-trust.js +27 -0
- package/dist/src/server/home-sections/features.d.ts +9 -0
- package/dist/src/server/home-sections/features.d.ts.map +1 -0
- package/dist/src/server/home-sections/features.js +9 -0
- package/dist/src/server/home-sections/hero.d.ts +9 -0
- package/dist/src/server/home-sections/hero.d.ts.map +1 -0
- package/dist/src/server/home-sections/hero.js +9 -0
- package/dist/src/server/home-sections/instagram-posts.d.ts +9 -0
- package/dist/src/server/home-sections/instagram-posts.d.ts.map +1 -0
- package/dist/src/server/home-sections/instagram-posts.js +9 -0
- package/dist/src/server/home-sections/loved-by-moms.d.ts +12 -0
- package/dist/src/server/home-sections/loved-by-moms.d.ts.map +1 -0
- package/dist/src/server/home-sections/loved-by-moms.js +20 -0
- package/dist/src/server/home-sections/luxe-favourites.d.ts +11 -0
- package/dist/src/server/home-sections/luxe-favourites.d.ts.map +1 -0
- package/dist/src/server/home-sections/luxe-favourites.js +19 -0
- package/dist/src/server/home-sections/new-arrivals-classic.d.ts +8 -0
- package/dist/src/server/home-sections/new-arrivals-classic.d.ts.map +1 -0
- package/dist/src/server/home-sections/new-arrivals-classic.js +10 -0
- package/dist/src/server/home-sections/new-arrivals.d.ts +12 -0
- package/dist/src/server/home-sections/new-arrivals.d.ts.map +1 -0
- package/dist/src/server/home-sections/new-arrivals.js +28 -0
- package/dist/src/server/home-sections/promo-announcements.d.ts +11 -0
- package/dist/src/server/home-sections/promo-announcements.d.ts.map +1 -0
- package/dist/src/server/home-sections/promo-announcements.js +5 -0
- package/dist/src/server/home-sections/promo-countdown.d.ts +6 -0
- package/dist/src/server/home-sections/promo-countdown.d.ts.map +1 -0
- package/dist/src/server/home-sections/promo-countdown.js +5 -0
- package/dist/src/server/home-sections/shared.d.ts +10 -0
- package/dist/src/server/home-sections/shared.d.ts.map +1 -0
- package/dist/src/server/home-sections/shared.js +29 -0
- package/dist/src/server/home-sections/shop-by-age.d.ts +9 -0
- package/dist/src/server/home-sections/shop-by-age.d.ts.map +1 -0
- package/dist/src/server/home-sections/shop-by-age.js +17 -0
- package/dist/src/server/home-sections/shop-by-category.d.ts +10 -0
- package/dist/src/server/home-sections/shop-by-category.d.ts.map +1 -0
- package/dist/src/server/home-sections/shop-by-category.js +17 -0
- package/dist/src/server/home-sections/testimonials.d.ts +9 -0
- package/dist/src/server/home-sections/testimonials.d.ts.map +1 -0
- package/dist/src/server/home-sections/testimonials.js +9 -0
- package/dist/src/server/home-sections/theme-dresses.d.ts +12 -0
- package/dist/src/server/home-sections/theme-dresses.d.ts.map +1 -0
- package/dist/src/server/home-sections/theme-dresses.js +27 -0
- package/dist/src/server/home-sections/video-stories.d.ts +9 -0
- package/dist/src/server/home-sections/video-stories.d.ts.map +1 -0
- package/dist/src/server/home-sections/video-stories.js +9 -0
- package/dist/src/server/home-sections/why-choose-us.d.ts +9 -0
- package/dist/src/server/home-sections/why-choose-us.d.ts.map +1 -0
- package/dist/src/server/home-sections/why-choose-us.js +9 -0
- package/dist/src/server/home.d.ts +54 -0
- package/dist/src/server/home.d.ts.map +1 -0
- package/dist/src/server/home.js +1 -0
- package/dist/src/server/homepage-config.types.d.ts +390 -0
- package/dist/src/server/homepage-config.types.d.ts.map +1 -0
- package/dist/src/server/homepage-config.types.js +34 -0
- package/dist/src/server/homepage-section-defaults.d.ts +189 -0
- package/dist/src/server/homepage-section-defaults.d.ts.map +1 -0
- package/dist/src/server/homepage-section-defaults.js +190 -0
- package/dist/src/server/index.d.ts +25 -0
- package/dist/src/server/index.d.ts.map +1 -0
- package/dist/src/server/index.js +24 -0
- package/dist/src/server/locale-actions.d.ts +14 -0
- package/dist/src/server/locale-actions.d.ts.map +1 -0
- package/dist/src/server/locale-actions.js +58 -0
- package/dist/src/server/locales.d.ts +8 -0
- package/dist/src/server/locales.d.ts.map +1 -0
- package/dist/src/server/locales.js +12 -0
- package/dist/src/server/normalize-homepage-config.d.ts +7 -0
- package/dist/src/server/normalize-homepage-config.d.ts.map +1 -0
- package/dist/src/server/normalize-homepage-config.js +281 -0
- package/dist/src/server/notifications.d.ts +2 -0
- package/dist/src/server/notifications.d.ts.map +1 -0
- package/dist/src/server/notifications.js +20 -0
- package/dist/src/server/onboarding.d.ts +2 -0
- package/dist/src/server/onboarding.d.ts.map +1 -0
- package/dist/src/server/onboarding.js +8 -0
- package/dist/src/server/orders.d.ts +63 -0
- package/dist/src/server/orders.d.ts.map +1 -0
- package/dist/src/server/orders.js +230 -0
- package/dist/src/server/page-input.d.ts +23 -0
- package/dist/src/server/page-input.d.ts.map +1 -0
- package/dist/src/server/page-input.js +89 -0
- package/dist/src/server/payment-details.d.ts +5 -0
- package/dist/src/server/payment-details.d.ts.map +1 -0
- package/dist/src/server/payment-details.js +28 -0
- package/dist/src/server/payment.d.ts +3 -0
- package/dist/src/server/payment.d.ts.map +1 -0
- package/dist/src/server/payment.js +13 -0
- package/dist/src/server/pincode.d.ts +7 -0
- package/dist/src/server/pincode.d.ts.map +1 -0
- package/dist/src/server/pincode.js +30 -0
- package/dist/src/server/products.d.ts +54 -0
- package/dist/src/server/products.d.ts.map +1 -0
- package/dist/src/server/products.js +154 -0
- package/dist/src/server/regions.d.ts +5 -0
- package/dist/src/server/regions.d.ts.map +1 -0
- package/dist/src/server/regions.js +57 -0
- package/dist/src/server/resolve-home-segment-data.d.ts +25 -0
- package/dist/src/server/resolve-home-segment-data.d.ts.map +1 -0
- package/dist/src/server/resolve-home-segment-data.js +20 -0
- package/dist/src/server/returns.d.ts +29 -0
- package/dist/src/server/returns.d.ts.map +1 -0
- package/dist/src/server/returns.js +132 -0
- package/dist/src/server/shoppable-looks.d.ts +17 -0
- package/dist/src/server/shoppable-looks.d.ts.map +1 -0
- package/dist/src/server/shoppable-looks.js +136 -0
- package/dist/src/server/swaps.d.ts +15 -0
- package/dist/src/server/swaps.d.ts.map +1 -0
- package/dist/src/server/swaps.js +89 -0
- package/dist/src/server/variants.d.ts +3 -0
- package/dist/src/server/variants.d.ts.map +1 -0
- package/dist/src/server/variants.js +15 -0
- package/dist/src/server/wishlist.d.ts +11 -0
- package/dist/src/server/wishlist.d.ts.map +1 -0
- package/dist/src/server/wishlist.js +49 -0
- package/dist/src/util/get-locale-header.d.ts +4 -0
- package/dist/src/util/get-locale-header.d.ts.map +1 -0
- package/dist/src/util/get-locale-header.js +7 -0
- package/dist/src/util/medusa-error.d.ts +2 -0
- package/dist/src/util/medusa-error.d.ts.map +1 -0
- package/dist/src/util/medusa-error.js +18 -0
- package/dist/src/util/revalidate-cart.d.ts +2 -0
- package/dist/src/util/revalidate-cart.d.ts.map +1 -0
- package/dist/src/util/revalidate-cart.js +8 -0
- package/dist/src/util/sort-products.d.ts +3 -0
- package/dist/src/util/sort-products.d.ts.map +1 -0
- package/dist/src/util/sort-products.js +1 -0
- package/dist/src/util/store-client.d.ts +11 -0
- package/dist/src/util/store-client.d.ts.map +1 -0
- package/dist/src/util/store-client.js +75 -0
- package/package.json +6 -1
- package/src/server/dynamic-config.ts +77 -10
- package/src/server/home-sections/promo-announcements.ts +6 -4
- package/src/server/home.ts +5 -1
- package/src/server/homepage-config.types.ts +113 -0
- package/src/server/index.ts +2 -1
- package/src/server/normalize-homepage-config.ts +38 -0
- package/src/server/page-input.ts +1 -0
- package/src/server/storefront-cms.ts +46 -0
- package/src/server/resolve-home-segment-data.ts +0 -63
|
@@ -0,0 +1,694 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { cache } from "react";
|
|
3
|
+
import { getAuthHeaders } from "../cookies";
|
|
4
|
+
import { DEFAULT_HOMEPAGE_SECTIONS, HOME_SECTION_COPY_ID_LIST, } from "./homepage-section-defaults";
|
|
5
|
+
import { mergeSectionBlock } from "./config-merge";
|
|
6
|
+
import { resolvePageInput } from "./page-input";
|
|
7
|
+
export { DEFAULT_PAGE_INPUT, mergePageInputWithDefaults, resolvePageInput, homepageConfigFromDynamicResponse, simplifiedHomepageConfigFromDynamicResponse, } from "./page-input";
|
|
8
|
+
export const getDynamicConfig = cache(async () => {
|
|
9
|
+
try {
|
|
10
|
+
const publishableKey = process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY;
|
|
11
|
+
const baseUrl = process.env.MEDUSA_BACKEND_URL || "http://localhost:9000";
|
|
12
|
+
if (!publishableKey) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const authHeaders = await getAuthHeaders();
|
|
16
|
+
const headers = {
|
|
17
|
+
"Content-Type": "application/json",
|
|
18
|
+
"Accept": "application/json",
|
|
19
|
+
"x-publishable-api-key": publishableKey,
|
|
20
|
+
};
|
|
21
|
+
if (authHeaders && "authorization" in authHeaders) {
|
|
22
|
+
headers["authorization"] = authHeaders.authorization;
|
|
23
|
+
}
|
|
24
|
+
const fetchStart = Date.now();
|
|
25
|
+
const response = await fetch(`${baseUrl}/store/dynamic-config`, {
|
|
26
|
+
method: "GET",
|
|
27
|
+
headers,
|
|
28
|
+
cache: "no-store",
|
|
29
|
+
});
|
|
30
|
+
const duration = Date.now() - fetchStart;
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const data = await response.json();
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
export function getLogoFromPageInput(pageInput) {
|
|
42
|
+
const config = resolvePageInput(pageInput);
|
|
43
|
+
return config.logo || null;
|
|
44
|
+
}
|
|
45
|
+
export function getHomeBannersFromPageInput(pageInput) {
|
|
46
|
+
const config = resolvePageInput(pageInput);
|
|
47
|
+
const bannerArray = config["homepage-banner-array"];
|
|
48
|
+
if (bannerArray && bannerArray.length > 0) {
|
|
49
|
+
return bannerArray.map((item) => {
|
|
50
|
+
const banner = item["homepage-banner"];
|
|
51
|
+
return {
|
|
52
|
+
image: banner?.["homepage-banner-image"],
|
|
53
|
+
title: normalizeCmsText(banner?.["homepage-banner-title"]),
|
|
54
|
+
subtitle: normalizeCmsText(banner?.["homepage-banner-subtitle"]),
|
|
55
|
+
description: normalizeCmsText(banner?.["homepage-banner-description"]),
|
|
56
|
+
buttonName: normalizeBannerButtonName(banner?.["homepage-banner-button-name"]),
|
|
57
|
+
buttonLink: banner?.["homepage-banner-button-link"],
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
export function getAppBannersFromPageInput(pageInput) {
|
|
64
|
+
const config = resolvePageInput(pageInput);
|
|
65
|
+
const bannerArray = config["app-banner-array"];
|
|
66
|
+
if (bannerArray && bannerArray.length > 0) {
|
|
67
|
+
return bannerArray.map((item) => {
|
|
68
|
+
const banner = item["app-banner"];
|
|
69
|
+
return {
|
|
70
|
+
image: banner?.["app-banner-image"],
|
|
71
|
+
title: normalizeCmsText(banner?.["app-banner-title"]),
|
|
72
|
+
subtitle: normalizeCmsText(banner?.["app-banner-subtitle"]),
|
|
73
|
+
description: normalizeCmsText(banner?.["app-banner-description"]),
|
|
74
|
+
buttonName: normalizeBannerButtonName(banner?.["app-banner-button-name"]),
|
|
75
|
+
buttonLink: banner?.["app-banner-button-link"],
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
// Legacy function for backward compatibility
|
|
82
|
+
export function getWebsiteDescriptionFromPageInput(pageInput) {
|
|
83
|
+
const config = resolvePageInput(pageInput);
|
|
84
|
+
const desc = config["website-description"] || config["website_description"];
|
|
85
|
+
return desc || null;
|
|
86
|
+
}
|
|
87
|
+
/** Why choose us — defaults + `sections.whyChooseUs` override. */
|
|
88
|
+
export function getFeaturesFromPageInput(pageInput) {
|
|
89
|
+
const block = getMergedSectionBlock("whyChooseUs", pageInput);
|
|
90
|
+
const copy = parseSectionCopy(block);
|
|
91
|
+
const title = copy.title ?? copy.name ?? "";
|
|
92
|
+
const featuresRaw = block.features ?? block.items ?? [];
|
|
93
|
+
const features = parseFeatureIconList(featuresRaw);
|
|
94
|
+
return { title, features };
|
|
95
|
+
}
|
|
96
|
+
function parseFeatureIconList(raw) {
|
|
97
|
+
if (!Array.isArray(raw))
|
|
98
|
+
return [];
|
|
99
|
+
return raw
|
|
100
|
+
.map((item) => {
|
|
101
|
+
if (!item || typeof item !== "object")
|
|
102
|
+
return null;
|
|
103
|
+
const feature = item.feature ?? item;
|
|
104
|
+
const row = feature;
|
|
105
|
+
const name = normalizeCmsText(row["feature-name"] ?? row.name) ?? "";
|
|
106
|
+
const icon = normalizeCmsText(row["feature-icon"] ?? row.icon) ?? "";
|
|
107
|
+
return name && icon ? { name, icon } : null;
|
|
108
|
+
})
|
|
109
|
+
.filter(Boolean);
|
|
110
|
+
}
|
|
111
|
+
const EMAIL_PATTERN = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
112
|
+
/** Fix common UTF-8 mojibake from CMS copy-paste (e.g. em dash, apostrophe). */
|
|
113
|
+
function normalizeCmsText(value) {
|
|
114
|
+
if (typeof value !== "string" || !value.trim())
|
|
115
|
+
return undefined;
|
|
116
|
+
return value
|
|
117
|
+
.trim()
|
|
118
|
+
.replace(/ΓÇö/g, "—")
|
|
119
|
+
.replace(/ΓÇÖ/g, "'")
|
|
120
|
+
.replace(/ΓÇ£|ΓÇ¥/g, '"')
|
|
121
|
+
.replace(/≡ƒÿÄ≡ƒæòΓ£¿/g, " 👕✨");
|
|
122
|
+
}
|
|
123
|
+
const EMPTY_SECTION_COPY = {
|
|
124
|
+
title: null,
|
|
125
|
+
name: null,
|
|
126
|
+
text: null,
|
|
127
|
+
description: null,
|
|
128
|
+
subtitle: null,
|
|
129
|
+
eyebrow: null,
|
|
130
|
+
variant: null,
|
|
131
|
+
layout: null,
|
|
132
|
+
};
|
|
133
|
+
export function parseSectionCopy(block) {
|
|
134
|
+
if (!block || typeof block !== "object")
|
|
135
|
+
return { ...EMPTY_SECTION_COPY };
|
|
136
|
+
const row = block;
|
|
137
|
+
return {
|
|
138
|
+
title: normalizeCmsText(row.title) ?? null,
|
|
139
|
+
name: normalizeCmsText(row.name) ?? null,
|
|
140
|
+
text: normalizeCmsText(row.text) ?? null,
|
|
141
|
+
description: normalizeCmsText(row.description) ?? null,
|
|
142
|
+
subtitle: normalizeCmsText(row.subtitle) ?? null,
|
|
143
|
+
eyebrow: normalizeCmsText(row.eyebrow) ?? null,
|
|
144
|
+
variant: normalizeCmsText(row.variant) ?? null,
|
|
145
|
+
layout: normalizeCmsText(row.layout) ?? null,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
const HOME_SECTION_COPY_IDS = new Set(HOME_SECTION_COPY_ID_LIST);
|
|
149
|
+
function sectionIdFromConfigKey(key) {
|
|
150
|
+
const id = key.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
151
|
+
return HOME_SECTION_COPY_IDS.has(id) ? id : null;
|
|
152
|
+
}
|
|
153
|
+
function getHomepageSectionsRoot(pageInput) {
|
|
154
|
+
const config = resolvePageInput(pageInput);
|
|
155
|
+
const root = config.sections;
|
|
156
|
+
return root && typeof root === "object"
|
|
157
|
+
? root
|
|
158
|
+
: {};
|
|
159
|
+
}
|
|
160
|
+
function findSectionBlock(root, id) {
|
|
161
|
+
for (const [key, value] of Object.entries(root)) {
|
|
162
|
+
if (sectionIdFromConfigKey(key) !== id)
|
|
163
|
+
continue;
|
|
164
|
+
if (value && typeof value === "object") {
|
|
165
|
+
return value;
|
|
166
|
+
}
|
|
167
|
+
if (typeof value === "string") {
|
|
168
|
+
return { text: value };
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
export { mergeSectionBlock } from "./config-merge";
|
|
174
|
+
export function getMergedSectionBlock(id, pageInput) {
|
|
175
|
+
const root = getHomepageSectionsRoot(pageInput);
|
|
176
|
+
const defaults = DEFAULT_HOMEPAGE_SECTIONS[id] ?? {};
|
|
177
|
+
const override = findSectionBlock(root, id);
|
|
178
|
+
return mergeSectionBlock({ ...defaults }, override);
|
|
179
|
+
}
|
|
180
|
+
function mergeSectionCopy(base, patch) {
|
|
181
|
+
const pick = (override, fallback) => override ?? fallback;
|
|
182
|
+
return {
|
|
183
|
+
title: pick(patch.title ?? patch.name, base.title ?? base.name),
|
|
184
|
+
name: pick(patch.name, base.name),
|
|
185
|
+
text: pick(patch.text, base.text),
|
|
186
|
+
description: pick(patch.description, base.description),
|
|
187
|
+
subtitle: pick(patch.subtitle, base.subtitle),
|
|
188
|
+
eyebrow: pick(patch.eyebrow, base.eyebrow),
|
|
189
|
+
variant: pick(patch.variant ?? patch.layout, base.variant ?? base.layout),
|
|
190
|
+
layout: pick(patch.layout ?? patch.variant, base.layout ?? base.variant),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function parseAnnouncementMessages(block) {
|
|
194
|
+
if (!block)
|
|
195
|
+
return [];
|
|
196
|
+
const raw = block.messages ?? block.items ?? block["announcement-messages"];
|
|
197
|
+
if (!Array.isArray(raw))
|
|
198
|
+
return [];
|
|
199
|
+
return raw
|
|
200
|
+
.map((item) => {
|
|
201
|
+
if (typeof item === "string")
|
|
202
|
+
return item.trim();
|
|
203
|
+
if (item && typeof item === "object") {
|
|
204
|
+
const row = item;
|
|
205
|
+
const nested = (row.message ?? row.text);
|
|
206
|
+
return typeof nested === "string" ? nested.trim() : "";
|
|
207
|
+
}
|
|
208
|
+
return "";
|
|
209
|
+
})
|
|
210
|
+
.filter(Boolean);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Merged section copy: package defaults + `homepage-config.sections` overrides.
|
|
214
|
+
*/
|
|
215
|
+
export function getHomeSectionsCopyFromPageInput(pageInput) {
|
|
216
|
+
const copy = {};
|
|
217
|
+
for (const id of HOME_SECTION_COPY_ID_LIST) {
|
|
218
|
+
const block = getMergedSectionBlock(id, pageInput);
|
|
219
|
+
copy[id] = parseSectionCopy(block);
|
|
220
|
+
}
|
|
221
|
+
return copy;
|
|
222
|
+
}
|
|
223
|
+
/** Trust badge row — defaults + `sections.features` override. */
|
|
224
|
+
export function getTrustFeaturesFromPageInput(pageInput) {
|
|
225
|
+
const block = getMergedSectionBlock("features", pageInput);
|
|
226
|
+
const copy = parseSectionCopy(block);
|
|
227
|
+
const title = copy.title ?? copy.name;
|
|
228
|
+
const description = copy.description ?? copy.text;
|
|
229
|
+
const rawList = block.features ?? block.items ?? [];
|
|
230
|
+
const features = parseFeatureIconList(rawList);
|
|
231
|
+
return { title: title ?? null, description: description ?? null, features };
|
|
232
|
+
}
|
|
233
|
+
function normalizeBannerButtonName(value) {
|
|
234
|
+
const text = normalizeCmsText(value);
|
|
235
|
+
if (!text)
|
|
236
|
+
return undefined;
|
|
237
|
+
if (/^shop\s+now\s*1$/i.test(text))
|
|
238
|
+
return "Shop Now";
|
|
239
|
+
return text;
|
|
240
|
+
}
|
|
241
|
+
function normalizeConfigEmail(value) {
|
|
242
|
+
if (typeof value !== "string")
|
|
243
|
+
return undefined;
|
|
244
|
+
const trimmed = value.trim();
|
|
245
|
+
return EMAIL_PATTERN.test(trimmed) ? trimmed : undefined;
|
|
246
|
+
}
|
|
247
|
+
export function getContactInfoFromPageInput(pageInput) {
|
|
248
|
+
const config = resolvePageInput(pageInput);
|
|
249
|
+
const contactConfig = config["contact-us"];
|
|
250
|
+
if (!contactConfig)
|
|
251
|
+
return null;
|
|
252
|
+
return {
|
|
253
|
+
phone: contactConfig["contact-phone"],
|
|
254
|
+
email: normalizeConfigEmail(contactConfig["contact-email"]),
|
|
255
|
+
address: contactConfig["contact-address"],
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function normalizeVideoStoryUrl(entry) {
|
|
259
|
+
if (typeof entry === "string" && entry.trim())
|
|
260
|
+
return entry.trim();
|
|
261
|
+
if (!entry || typeof entry !== "object")
|
|
262
|
+
return null;
|
|
263
|
+
const row = entry;
|
|
264
|
+
const nested = row["video-story"] ??
|
|
265
|
+
row["video_stories"] ??
|
|
266
|
+
row;
|
|
267
|
+
const url = nested["video-url"] ??
|
|
268
|
+
nested["video_url"] ??
|
|
269
|
+
nested.url ??
|
|
270
|
+
nested.src ??
|
|
271
|
+
nested.video;
|
|
272
|
+
return typeof url === "string" && url.trim() ? url.trim() : null;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Homepage video stories/reviews carousel (`homepage-config.video-stories`).
|
|
276
|
+
*/
|
|
277
|
+
export function getVideoStoriesFromPageInput(pageInput) {
|
|
278
|
+
const homepageConfig = resolvePageInput(pageInput);
|
|
279
|
+
const block = getMergedSectionBlock("videoStories", pageInput);
|
|
280
|
+
const copy = parseSectionCopy(block);
|
|
281
|
+
const title = copy.title ?? copy.name ?? "";
|
|
282
|
+
const raw = block["video-urls"] ??
|
|
283
|
+
block.videoUrls ??
|
|
284
|
+
block.videos ??
|
|
285
|
+
block["video-stories"] ??
|
|
286
|
+
homepageConfig["video-stories"] ??
|
|
287
|
+
homepageConfig["video-stories-array"] ??
|
|
288
|
+
homepageConfig["video_stories"] ??
|
|
289
|
+
[];
|
|
290
|
+
const list = Array.isArray(raw) ? raw : [raw];
|
|
291
|
+
const videoUrls = list
|
|
292
|
+
.map(normalizeVideoStoryUrl)
|
|
293
|
+
.filter((url) => Boolean(url));
|
|
294
|
+
return { title, videoUrls };
|
|
295
|
+
}
|
|
296
|
+
function parseTestimonialRow(item, index) {
|
|
297
|
+
if (!item || typeof item !== "object")
|
|
298
|
+
return null;
|
|
299
|
+
const row = item.testimonial ??
|
|
300
|
+
item.review ??
|
|
301
|
+
item;
|
|
302
|
+
const r = row;
|
|
303
|
+
const text = String(r.text ?? r["review-description"] ?? r.description ?? r.quote ?? "").trim();
|
|
304
|
+
const name = String(r.name ?? r["review-user-name"] ?? r.author ?? r["user-name"] ?? "").trim();
|
|
305
|
+
if (!text || !name)
|
|
306
|
+
return null;
|
|
307
|
+
const ratingRaw = r.rating ?? r["review-rating"];
|
|
308
|
+
const rating = ratingRaw != null && ratingRaw !== ""
|
|
309
|
+
? parseFloat(String(ratingRaw))
|
|
310
|
+
: undefined;
|
|
311
|
+
return {
|
|
312
|
+
id: String(r.id ?? `review-${index}`),
|
|
313
|
+
text,
|
|
314
|
+
name,
|
|
315
|
+
rating: Number.isFinite(rating) ? rating : undefined,
|
|
316
|
+
avatar: (r.avatar ?? r["review-profile-image"] ?? r.image),
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function parseTestimonialsFromBlock(block) {
|
|
320
|
+
const raw = block.items ??
|
|
321
|
+
block.testimonials ??
|
|
322
|
+
block.reviews ??
|
|
323
|
+
block["testimonial-items"] ??
|
|
324
|
+
[];
|
|
325
|
+
if (!Array.isArray(raw))
|
|
326
|
+
return [];
|
|
327
|
+
return raw
|
|
328
|
+
.map((item, index) => parseTestimonialRow(item, index))
|
|
329
|
+
.filter((t) => t !== null);
|
|
330
|
+
}
|
|
331
|
+
function parseRatingsFromHomepage(ratings) {
|
|
332
|
+
if (!Array.isArray(ratings))
|
|
333
|
+
return [];
|
|
334
|
+
return ratings
|
|
335
|
+
.map((item, index) => parseTestimonialRow(item, index))
|
|
336
|
+
.filter((t) => t !== null);
|
|
337
|
+
}
|
|
338
|
+
export function getTestimonialsFromPageInput(pageInput) {
|
|
339
|
+
const homepageConfig = resolvePageInput(pageInput);
|
|
340
|
+
const block = getMergedSectionBlock("testimonials", pageInput);
|
|
341
|
+
const copy = parseSectionCopy(block);
|
|
342
|
+
const title = copy.title ?? copy.name ?? "";
|
|
343
|
+
const subtitle = (copy.description ?? copy.text ?? null);
|
|
344
|
+
let testimonials = parseTestimonialsFromBlock(block);
|
|
345
|
+
if (testimonials.length === 0) {
|
|
346
|
+
testimonials = parseRatingsFromHomepage(homepageConfig["ratings"]);
|
|
347
|
+
}
|
|
348
|
+
if (testimonials.length === 0) {
|
|
349
|
+
testimonials = parseTestimonialsFromBlock(DEFAULT_HOMEPAGE_SECTIONS.testimonials);
|
|
350
|
+
}
|
|
351
|
+
return { title, subtitle, testimonials };
|
|
352
|
+
}
|
|
353
|
+
export function getSocialLinksFromPageInput(pageInput) {
|
|
354
|
+
const config = resolvePageInput(pageInput);
|
|
355
|
+
const socialLinksRaw = config["social-links"] || [];
|
|
356
|
+
const socialLinks = socialLinksRaw
|
|
357
|
+
.map((item) => {
|
|
358
|
+
const link = (item?.["social-link"] || item);
|
|
359
|
+
return {
|
|
360
|
+
name: String(link?.["social-platform-name"] || ""),
|
|
361
|
+
url: String(link?.["social-platform-url"] || ""),
|
|
362
|
+
icon: link?.["social-platform-icon"],
|
|
363
|
+
};
|
|
364
|
+
})
|
|
365
|
+
.filter((l) => l.name && l.url);
|
|
366
|
+
return socialLinks.length > 0 ? socialLinks : null;
|
|
367
|
+
}
|
|
368
|
+
function asConfigObject(value) {
|
|
369
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
370
|
+
return value;
|
|
371
|
+
}
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
function asConfigArray(value) {
|
|
375
|
+
return Array.isArray(value) ? value : [];
|
|
376
|
+
}
|
|
377
|
+
function parseHelpFaqItems(itemsRaw) {
|
|
378
|
+
const items = [];
|
|
379
|
+
for (const item of asConfigArray(itemsRaw)) {
|
|
380
|
+
const faq = asConfigObject(item?.faq) ?? asConfigObject(item);
|
|
381
|
+
if (!faq)
|
|
382
|
+
continue;
|
|
383
|
+
const q = String(faq.question ?? faq["faq-question"] ?? faq.q ?? "").trim();
|
|
384
|
+
const a = String(faq.answer ?? faq["faq-answer"] ?? faq.a ?? "").trim();
|
|
385
|
+
if (q && a)
|
|
386
|
+
items.push({ q, a });
|
|
387
|
+
}
|
|
388
|
+
return items;
|
|
389
|
+
}
|
|
390
|
+
function parseHelpFaqCategoriesFromBlock(block) {
|
|
391
|
+
const raw = block.categories;
|
|
392
|
+
if (!Array.isArray(raw))
|
|
393
|
+
return [];
|
|
394
|
+
const categories = [];
|
|
395
|
+
for (const row of raw) {
|
|
396
|
+
const cat = asConfigObject(row?.category) ??
|
|
397
|
+
asConfigObject(row);
|
|
398
|
+
if (!cat)
|
|
399
|
+
continue;
|
|
400
|
+
const category = String(cat.category ?? cat.name ?? "").trim();
|
|
401
|
+
const items = parseHelpFaqItems(cat.items);
|
|
402
|
+
if (!category || items.length === 0)
|
|
403
|
+
continue;
|
|
404
|
+
categories.push({
|
|
405
|
+
category,
|
|
406
|
+
icon: String(cat.icon ?? "❓").trim() || "❓",
|
|
407
|
+
color: String(cat.color ?? "from-violet-500 to-purple-400").trim() ||
|
|
408
|
+
"from-violet-500 to-purple-400",
|
|
409
|
+
items,
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
return categories;
|
|
413
|
+
}
|
|
414
|
+
function parseHelpFaqCategoriesFromLegacyArray(pageInput) {
|
|
415
|
+
const config = resolvePageInput(pageInput);
|
|
416
|
+
const faqsRaw = config["faq-array"] || [];
|
|
417
|
+
if (!Array.isArray(faqsRaw) || faqsRaw.length === 0)
|
|
418
|
+
return [];
|
|
419
|
+
const categoriesMap = {};
|
|
420
|
+
faqsRaw.forEach((item) => {
|
|
421
|
+
const faq = (item?.faq || item);
|
|
422
|
+
const displayCategory = String(faq?.["faq-category"] || faq?.category || "General Questions").trim();
|
|
423
|
+
const categoryKey = displayCategory.toLowerCase();
|
|
424
|
+
const q = String(faq?.["faq-question"] || faq?.question || "").trim();
|
|
425
|
+
const a = String(faq?.["faq-answer"] || faq?.answer || "").trim();
|
|
426
|
+
if (q && a) {
|
|
427
|
+
if (!categoriesMap[categoryKey]) {
|
|
428
|
+
categoriesMap[categoryKey] = { displayCategory, items: [] };
|
|
429
|
+
}
|
|
430
|
+
categoriesMap[categoryKey].items.push({ q, a });
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
return Object.values(categoriesMap).map((cat) => ({
|
|
434
|
+
category: cat.displayCategory,
|
|
435
|
+
icon: "❓",
|
|
436
|
+
color: "from-violet-500 to-purple-400",
|
|
437
|
+
items: cat.items,
|
|
438
|
+
}));
|
|
439
|
+
}
|
|
440
|
+
function helpFaqBlockToSectionCopy(block) {
|
|
441
|
+
const copy = parseSectionCopy(block);
|
|
442
|
+
return {
|
|
443
|
+
eyebrow: copy.eyebrow ?? undefined,
|
|
444
|
+
title: copy.title ?? copy.name ?? undefined,
|
|
445
|
+
titleHighlight: typeof block.titleHighlight === "string"
|
|
446
|
+
? block.titleHighlight
|
|
447
|
+
: undefined,
|
|
448
|
+
subtitle: copy.subtitle ?? copy.description ?? copy.text ?? undefined,
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Help page FAQ — `sections.helpFaq` (preferred) with legacy `faq-array` fallback.
|
|
453
|
+
*/
|
|
454
|
+
export function getHelpFaqFromPageInput(pageInput) {
|
|
455
|
+
const block = getMergedSectionBlock("helpFaq", pageInput);
|
|
456
|
+
const sectionCopy = helpFaqBlockToSectionCopy(block);
|
|
457
|
+
let categories = parseHelpFaqCategoriesFromBlock(block);
|
|
458
|
+
if (categories.length === 0) {
|
|
459
|
+
categories = parseHelpFaqCategoriesFromLegacyArray(pageInput);
|
|
460
|
+
}
|
|
461
|
+
return { sectionCopy, categories };
|
|
462
|
+
}
|
|
463
|
+
/** FAQ categories for the help template (null when empty). */
|
|
464
|
+
export function getFaqsFromPageInput(pageInput) {
|
|
465
|
+
const { categories } = getHelpFaqFromPageInput(pageInput);
|
|
466
|
+
return categories.length > 0 ? categories : null;
|
|
467
|
+
}
|
|
468
|
+
function parsePromoAnnouncementsUi(...sources) {
|
|
469
|
+
const pick = (key, alt) => {
|
|
470
|
+
for (const src of sources) {
|
|
471
|
+
if (!src)
|
|
472
|
+
continue;
|
|
473
|
+
const value = normalizeCmsText(src[key] ?? (alt ? src[alt] : undefined));
|
|
474
|
+
if (value)
|
|
475
|
+
return value;
|
|
476
|
+
}
|
|
477
|
+
return undefined;
|
|
478
|
+
};
|
|
479
|
+
return {
|
|
480
|
+
icon: pick("icon", "ticker-icon"),
|
|
481
|
+
iconAlt: pick("iconAlt", "icon-alt"),
|
|
482
|
+
ariaLabel: pick("ariaLabel", "aria-label") ?? "Store announcements",
|
|
483
|
+
separator: pick("separator", "message-separator"),
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
/** Promo ticker messages + UI copy (icon, aria label, separator). */
|
|
487
|
+
export function getPromoAnnouncementsFromPageInput(pageInput) {
|
|
488
|
+
const homepageConfig = resolvePageInput(pageInput);
|
|
489
|
+
const block = getMergedSectionBlock("promoAnnouncements", pageInput);
|
|
490
|
+
const promoUi = homepageConfig.promoUi ??
|
|
491
|
+
homepageConfig["promo-ui"];
|
|
492
|
+
let messages = parseAnnouncementMessages(block);
|
|
493
|
+
if (messages.length === 0) {
|
|
494
|
+
const legacy = homepageConfig["announcement-messages"] ??
|
|
495
|
+
homepageConfig["announcement-bar"];
|
|
496
|
+
if (Array.isArray(legacy)) {
|
|
497
|
+
messages = legacy
|
|
498
|
+
.map((m) => (typeof m === "string" ? m.trim() : ""))
|
|
499
|
+
.filter(Boolean);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
const ui = parsePromoAnnouncementsUi(promoUi, block);
|
|
503
|
+
return { messages, ...ui };
|
|
504
|
+
}
|
|
505
|
+
/** @deprecated Use {@link getPromoAnnouncementsFromPageInput}. */
|
|
506
|
+
export function getAnnouncementMessagesFromPageInput(pageInput) {
|
|
507
|
+
return getPromoAnnouncementsFromPageInput(pageInput).messages;
|
|
508
|
+
}
|
|
509
|
+
export function getAboutBrandFromPageInput(pageInput) {
|
|
510
|
+
const homepageConfig = resolvePageInput(pageInput);
|
|
511
|
+
const merged = getMergedSectionBlock("aboutBrand", pageInput);
|
|
512
|
+
const legacy = homepageConfig["about-brand"] ?? homepageConfig["who-we-are"];
|
|
513
|
+
const b = mergeSectionBlock(merged, legacy && typeof legacy === "object"
|
|
514
|
+
? legacy
|
|
515
|
+
: null);
|
|
516
|
+
const statsRaw = (b.stats ?? b["about-stats"] ?? []);
|
|
517
|
+
const stats = Array.isArray(statsRaw)
|
|
518
|
+
? statsRaw
|
|
519
|
+
.map((s) => {
|
|
520
|
+
if (!s || typeof s !== "object")
|
|
521
|
+
return null;
|
|
522
|
+
const row = s;
|
|
523
|
+
const label = String(row.label ?? row.name ?? "").trim();
|
|
524
|
+
const value = String(row.value ?? "").trim();
|
|
525
|
+
return label && value ? { label, value } : null;
|
|
526
|
+
})
|
|
527
|
+
.filter(Boolean)
|
|
528
|
+
: [];
|
|
529
|
+
const copy = parseSectionCopy(b);
|
|
530
|
+
return {
|
|
531
|
+
eyebrow: copy.eyebrow ?? "",
|
|
532
|
+
title: copy.title ?? copy.name ?? "",
|
|
533
|
+
description: copy.description ?? copy.text ?? "",
|
|
534
|
+
readMoreHref: String(b.readMoreHref ?? b["read-more-link"] ?? "/about"),
|
|
535
|
+
stats,
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
function parseBrandPillarsFromBlock(block) {
|
|
539
|
+
const raw = block.pillars ?? block["brand-pillars"] ?? [];
|
|
540
|
+
return (Array.isArray(raw) ? raw : [])
|
|
541
|
+
.map((item) => {
|
|
542
|
+
if (!item || typeof item !== "object")
|
|
543
|
+
return null;
|
|
544
|
+
const row = item["pillar"] ?? item;
|
|
545
|
+
const p = row;
|
|
546
|
+
const title = String(p.title ?? p.name ?? "").trim();
|
|
547
|
+
const description = String(p.description ?? p.text ?? "").trim();
|
|
548
|
+
const image = (p.image ?? p.icon);
|
|
549
|
+
const href = (p.href ?? p.link ?? p.url);
|
|
550
|
+
return title && description
|
|
551
|
+
? { title, description, image, href: href ? String(href) : undefined }
|
|
552
|
+
: null;
|
|
553
|
+
})
|
|
554
|
+
.filter(Boolean);
|
|
555
|
+
}
|
|
556
|
+
export function getBrandPillarsFromPageInput(pageInput) {
|
|
557
|
+
const block = getMergedSectionBlock("brandPillars", pageInput);
|
|
558
|
+
const copy = parseSectionCopy(block);
|
|
559
|
+
const sectionTitle = copy.title ?? copy.name ?? "";
|
|
560
|
+
let pillars = parseBrandPillarsFromBlock(block);
|
|
561
|
+
if (pillars.length === 0) {
|
|
562
|
+
pillars = parseBrandPillarsFromBlock(DEFAULT_HOMEPAGE_SECTIONS.brandPillars);
|
|
563
|
+
}
|
|
564
|
+
return { sectionTitle, pillars };
|
|
565
|
+
}
|
|
566
|
+
export function getBlogPostsFromPageInput(pageInput) {
|
|
567
|
+
const block = getMergedSectionBlock("blogPosts", pageInput);
|
|
568
|
+
const raw = block.posts ?? block["blog-posts"] ?? block["blog-array"] ?? [];
|
|
569
|
+
return (Array.isArray(raw) ? raw : [])
|
|
570
|
+
.map((item) => {
|
|
571
|
+
if (!item || typeof item !== "object")
|
|
572
|
+
return null;
|
|
573
|
+
const row = item["blog"] ?? item;
|
|
574
|
+
const b = row;
|
|
575
|
+
const title = String(b.title ?? "").trim();
|
|
576
|
+
const href = String(b.href ?? b.link ?? b.url ?? "").trim();
|
|
577
|
+
if (!title || !href)
|
|
578
|
+
return null;
|
|
579
|
+
return {
|
|
580
|
+
title,
|
|
581
|
+
href,
|
|
582
|
+
excerpt: String(b.excerpt ?? b.description ?? "").trim() || undefined,
|
|
583
|
+
category: String(b.category ?? b.tag ?? "").trim() || undefined,
|
|
584
|
+
date: String(b.date ?? "").trim() || undefined,
|
|
585
|
+
image: (b.image ?? b.thumbnail),
|
|
586
|
+
};
|
|
587
|
+
})
|
|
588
|
+
.filter(Boolean);
|
|
589
|
+
}
|
|
590
|
+
function readPromoCountdownBlock(block) {
|
|
591
|
+
if (!block || typeof block !== "object") {
|
|
592
|
+
return {
|
|
593
|
+
code: null,
|
|
594
|
+
message: null,
|
|
595
|
+
endAt: null,
|
|
596
|
+
active: undefined,
|
|
597
|
+
ctaLabel: null,
|
|
598
|
+
ctaHref: null,
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
const row = block;
|
|
602
|
+
const code = normalizeCmsText(row["promo-code"] ?? row.code ?? row["coupon-code"]) ?? null;
|
|
603
|
+
const message = normalizeCmsText(row["promo-text"] ?? row.message ?? row.text) ?? null;
|
|
604
|
+
const endAtRaw = row["end-at"] ?? row.endAt ?? row["ends-at"];
|
|
605
|
+
const endAt = typeof endAtRaw === "string" && endAtRaw.trim() ? endAtRaw.trim() : null;
|
|
606
|
+
const activeRaw = row["promo-active"] ?? row.active;
|
|
607
|
+
const active = typeof activeRaw === "boolean" ? activeRaw : undefined;
|
|
608
|
+
const ctaLabel = normalizeCmsText(row["cta-label"] ?? row.ctaLabel ?? row["button-label"]) ?? null;
|
|
609
|
+
const ctaHref = normalizeCmsText(row["cta-href"] ?? row.ctaHref ?? row["button-href"]) ?? null;
|
|
610
|
+
return { code, message, endAt, active, ctaLabel, ctaHref };
|
|
611
|
+
}
|
|
612
|
+
/** Promo countdown — defaults + `sections.promoCountdown` override. */
|
|
613
|
+
export function getPromoCountdownFromPageInput(pageInput) {
|
|
614
|
+
const block = getMergedSectionBlock("promoCountdown", pageInput);
|
|
615
|
+
const fromBlock = readPromoCountdownBlock(block);
|
|
616
|
+
const defaults = readPromoCountdownBlock(DEFAULT_HOMEPAGE_SECTIONS.promoCountdown);
|
|
617
|
+
return {
|
|
618
|
+
code: fromBlock.code ?? defaults.code,
|
|
619
|
+
message: fromBlock.message ?? defaults.message,
|
|
620
|
+
endAt: fromBlock.endAt ?? defaults.endAt,
|
|
621
|
+
active: fromBlock.active ?? defaults.active ?? false,
|
|
622
|
+
ctaLabel: fromBlock.ctaLabel ?? defaults.ctaLabel,
|
|
623
|
+
ctaHref: fromBlock.ctaHref ?? defaults.ctaHref,
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
function parseInstagramPostRow(item, index) {
|
|
627
|
+
if (!item || typeof item !== "object")
|
|
628
|
+
return null;
|
|
629
|
+
const row = item.post ??
|
|
630
|
+
item.instagram ??
|
|
631
|
+
item;
|
|
632
|
+
const p = row;
|
|
633
|
+
const image = String(p.image ?? p["post-image"] ?? p.thumbnail ?? p.src ?? "").trim();
|
|
634
|
+
if (!image)
|
|
635
|
+
return null;
|
|
636
|
+
const url = String(p.url ?? p.link ?? p.href ?? p["post-url"] ?? "").trim() || undefined;
|
|
637
|
+
return {
|
|
638
|
+
id: String(p.id ?? `ig-${index}`),
|
|
639
|
+
image,
|
|
640
|
+
url,
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
function parseInstagramPostsFromBlock(block) {
|
|
644
|
+
const raw = block.posts ??
|
|
645
|
+
block.items ??
|
|
646
|
+
block["instagram-posts"] ??
|
|
647
|
+
block["posts-array"] ??
|
|
648
|
+
[];
|
|
649
|
+
if (!Array.isArray(raw))
|
|
650
|
+
return [];
|
|
651
|
+
return raw
|
|
652
|
+
.map((item, index) => parseInstagramPostRow(item, index))
|
|
653
|
+
.filter((p) => p !== null);
|
|
654
|
+
}
|
|
655
|
+
/** Instagram feed — `sections.instagramPosts` + optional social-links fallback. */
|
|
656
|
+
export function getInstagramPostsFromPageInput(pageInput) {
|
|
657
|
+
const defaultsBlock = DEFAULT_HOMEPAGE_SECTIONS.instagramPosts;
|
|
658
|
+
const defaultCopy = parseSectionCopy(defaultsBlock);
|
|
659
|
+
const defaultPosts = parseInstagramPostsFromBlock(defaultsBlock);
|
|
660
|
+
const block = getMergedSectionBlock("instagramPosts", pageInput);
|
|
661
|
+
const copy = parseSectionCopy(block);
|
|
662
|
+
let posts = parseInstagramPostsFromBlock(block);
|
|
663
|
+
if (posts.length === 0)
|
|
664
|
+
posts = defaultPosts;
|
|
665
|
+
const handle = normalizeCmsText(block.handle ??
|
|
666
|
+
block.username ??
|
|
667
|
+
block["instagram-handle"] ??
|
|
668
|
+
defaultsBlock.handle) ?? "yourbrand";
|
|
669
|
+
const profileUrl = normalizeCmsText(block["profile-url"] ??
|
|
670
|
+
block.profileUrl ??
|
|
671
|
+
block["instagram-url"] ??
|
|
672
|
+
defaultsBlock["profile-url"]) ?? `https://www.instagram.com/${handle.replace(/^@/, "")}/`;
|
|
673
|
+
const profileImage = (block["profile-image"] ??
|
|
674
|
+
block.profileImage ??
|
|
675
|
+
defaultsBlock["profile-image"]);
|
|
676
|
+
return {
|
|
677
|
+
title: copy.title ?? copy.name ?? defaultCopy.title ?? "Follow Us on Instagram",
|
|
678
|
+
handle,
|
|
679
|
+
profileUrl,
|
|
680
|
+
profileImage,
|
|
681
|
+
posts,
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
export { DEFAULT_HOMEPAGE_SECTIONS, } from "./homepage-section-defaults";
|
|
685
|
+
export { HOMEPAGE_SECTION_IDS } from "./homepage-config.types";
|
|
686
|
+
export function getPromoBarFromPageInput(pageInput) {
|
|
687
|
+
const config = resolvePageInput(pageInput);
|
|
688
|
+
const promoConfig = config["promo-bar"];
|
|
689
|
+
const text = normalizeCmsText(promoConfig?.["promo-text"]) ?? null;
|
|
690
|
+
const code = normalizeCmsText(promoConfig?.["promo-code"]) ?? null;
|
|
691
|
+
const value = normalizeCmsText(promoConfig?.["promo-value"]) ?? null;
|
|
692
|
+
const active = Boolean(promoConfig?.["promo-active"]);
|
|
693
|
+
return { text, code, value, active };
|
|
694
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { HttpTypes } from "@medusajs/types";
|
|
2
|
+
export declare const listCartShippingMethods: (cartId: string) => Promise<HttpTypes.StoreCartShippingOptionWithServiceZone[] | null>;
|
|
3
|
+
export declare const calculatePriceForShippingOption: (optionId: string, cartId: string, data?: Record<string, unknown>) => Promise<HttpTypes.StoreCartShippingOption | null>;
|
|
4
|
+
export declare const getShiprocketServiceability: (pincode: string, variant_id: string, cod?: number) => Promise<import("medusa-services/fulfillment").ShiprocketServiceabilityResult | null>;
|
|
5
|
+
//# sourceMappingURL=fulfillment.d.ts.map
|