medusa-storefront-data 2.5.3 → 2.5.5
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 +18 -11
- package/package.json +115 -155
- package/src/server/dynamic-config.ts +1 -0
- package/src/server/page-input.ts +57 -3
package/HOMEPAGE_CONFIG.md
CHANGED
|
@@ -164,32 +164,39 @@ import { heroHomepageSectionField, bannerSlide } from "medusa-ui-home-config/sec
|
|
|
164
164
|
|
|
165
165
|
Compose `options.configs` from `homepageSectionFields` or individual `*HomepageSectionField` exports. Merge API responses with `homepageConfigFromDynamicResponse` from `medusa-storefront-data/dynamic-config`.
|
|
166
166
|
|
|
167
|
-
Help page FAQs use **`helpFaqHomepageSectionField`** from `medusa-ui-home-config/sections/helpFaq` (also included in `homepageSectionFields`).
|
|
167
|
+
Help page FAQs use **`helpFaqHomepageSectionField`** from `medusa-ui-home-config/sections/helpFaq` (also included in `homepageSectionFields`).
|
|
168
|
+
|
|
169
|
+
**Split dynamic-config keys** (Medusa plugin): store FAQs under `faqs.helpFaq`; homepage sections under `homepage-sections.sections`. `homepageConfigFromDynamicResponse` assembles these automatically:
|
|
168
170
|
|
|
169
171
|
```json
|
|
170
172
|
{
|
|
171
|
-
"
|
|
173
|
+
"site-branding": { "logo": "https://…", "description": "" },
|
|
174
|
+
"contact": { "phone": "", "email": "", "whatsapp": "", "address": "" },
|
|
175
|
+
"faqs": {
|
|
172
176
|
"helpFaq": {
|
|
173
177
|
"eyebrow": "Knowledge Base",
|
|
174
178
|
"title": "Frequently Asked",
|
|
175
179
|
"titleHighlight": "Questions",
|
|
176
|
-
"subtitle": "Browse
|
|
180
|
+
"subtitle": "Browse through our most common questions…",
|
|
177
181
|
"categories": [
|
|
178
182
|
{
|
|
179
|
-
"category":
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
"category": {
|
|
184
|
+
"category": "Order & Delivery",
|
|
185
|
+
"icon": "🚚",
|
|
186
|
+
"color": "from-blue-500 to-cyan-400",
|
|
187
|
+
"items": [
|
|
188
|
+
{ "faq": { "question": "When will I receive my order?", "answer": "…" } }
|
|
189
|
+
]
|
|
190
|
+
}
|
|
185
191
|
}
|
|
186
192
|
]
|
|
187
193
|
}
|
|
188
|
-
}
|
|
194
|
+
},
|
|
195
|
+
"homepage-sections": { "sections": { "newArrivals": { "title": "New Arrivals" } } }
|
|
189
196
|
}
|
|
190
197
|
```
|
|
191
198
|
|
|
192
|
-
Legacy flat `faq
|
|
199
|
+
Legacy single `homepage-config` with `sections.helpFaq` (flat `items` or nested `category` / `faq` wrappers) still works. Legacy flat `faq-array` entries are grouped by `faq-category`.
|
|
193
200
|
|
|
194
201
|
Storefront UI still imports from `medusa-ui-home/sections/<id>`.
|
|
195
202
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "medusa-storefront-data",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Medusa storefront server data layer extracted from Next.js storefront",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,165 +53,125 @@
|
|
|
53
53
|
"import": "./src/server/index.ts",
|
|
54
54
|
"default": "./src/server/index.ts"
|
|
55
55
|
},
|
|
56
|
-
"./
|
|
57
|
-
"types": "./dist/
|
|
58
|
-
"import": "./src/
|
|
59
|
-
"default": "./src/
|
|
60
|
-
},
|
|
61
|
-
"./
|
|
62
|
-
"types": "./dist/
|
|
63
|
-
"import": "./src/
|
|
64
|
-
"default": "./src/
|
|
65
|
-
},
|
|
66
|
-
"./
|
|
67
|
-
"types": "./dist/
|
|
68
|
-
"import": "./src/
|
|
69
|
-
"default": "./src/
|
|
70
|
-
},
|
|
71
|
-
"./
|
|
72
|
-
"types": "./dist/
|
|
73
|
-
"import": "./src/
|
|
74
|
-
"default": "./src/
|
|
75
|
-
},
|
|
76
|
-
"./
|
|
77
|
-
"types": "./dist/
|
|
78
|
-
"import": "./src/
|
|
79
|
-
"default": "./src/
|
|
80
|
-
},
|
|
81
|
-
"./
|
|
82
|
-
"types": "./dist/
|
|
83
|
-
"import": "./src/
|
|
84
|
-
"default": "./src/
|
|
85
|
-
},
|
|
86
|
-
"./
|
|
87
|
-
"types": "./dist/
|
|
88
|
-
"import": "./src/
|
|
89
|
-
"default": "./src/
|
|
90
|
-
},
|
|
91
|
-
"./
|
|
92
|
-
"types": "./dist/server/
|
|
93
|
-
"import": "./src/server/
|
|
94
|
-
"default": "./src/server/
|
|
95
|
-
},
|
|
96
|
-
"./
|
|
97
|
-
"types": "./dist/server/
|
|
98
|
-
"import": "./src/server/
|
|
99
|
-
"default": "./src/server/
|
|
100
|
-
},
|
|
101
|
-
"./
|
|
102
|
-
"types": "./dist/server/
|
|
103
|
-
"import": "./src/server/
|
|
104
|
-
"default": "./src/server/
|
|
105
|
-
},
|
|
106
|
-
"./
|
|
107
|
-
"types": "./dist/server/
|
|
108
|
-
"import": "./src/server/
|
|
109
|
-
"default": "./src/server/
|
|
110
|
-
},
|
|
111
|
-
"./
|
|
112
|
-
"types": "./dist/server/
|
|
113
|
-
"import": "./src/server/
|
|
114
|
-
"default": "./src/server/
|
|
115
|
-
},
|
|
116
|
-
"./
|
|
117
|
-
"types": "./dist/server/
|
|
118
|
-
"import": "./src/server/
|
|
119
|
-
"default": "./src/server/
|
|
120
|
-
},
|
|
121
|
-
"./
|
|
122
|
-
"types": "./dist/server/
|
|
123
|
-
"import": "./src/server/
|
|
124
|
-
"default": "./src/server/
|
|
56
|
+
"./home/sections/promoAnnouncements": {
|
|
57
|
+
"types": "./dist/server/home-sections/promo-announcements.d.ts",
|
|
58
|
+
"import": "./src/server/home-sections/promo-announcements.ts",
|
|
59
|
+
"default": "./src/server/home-sections/promo-announcements.ts"
|
|
60
|
+
},
|
|
61
|
+
"./home/sections/hero": {
|
|
62
|
+
"types": "./dist/server/home-sections/hero.d.ts",
|
|
63
|
+
"import": "./src/server/home-sections/hero.ts",
|
|
64
|
+
"default": "./src/server/home-sections/hero.ts"
|
|
65
|
+
},
|
|
66
|
+
"./home/sections/categoryPills": {
|
|
67
|
+
"types": "./dist/server/home-sections/category-pills.d.ts",
|
|
68
|
+
"import": "./src/server/home-sections/category-pills.ts",
|
|
69
|
+
"default": "./src/server/home-sections/category-pills.ts"
|
|
70
|
+
},
|
|
71
|
+
"./home/sections/newArrivals": {
|
|
72
|
+
"types": "./dist/server/home-sections/new-arrivals.d.ts",
|
|
73
|
+
"import": "./src/server/home-sections/new-arrivals.ts",
|
|
74
|
+
"default": "./src/server/home-sections/new-arrivals.ts"
|
|
75
|
+
},
|
|
76
|
+
"./home/sections/newArrivalsClassic": {
|
|
77
|
+
"types": "./dist/server/home-sections/new-arrivals-classic.d.ts",
|
|
78
|
+
"import": "./src/server/home-sections/new-arrivals-classic.ts",
|
|
79
|
+
"default": "./src/server/home-sections/new-arrivals-classic.ts"
|
|
80
|
+
},
|
|
81
|
+
"./home/sections/promoCountdown": {
|
|
82
|
+
"types": "./dist/server/home-sections/promo-countdown.d.ts",
|
|
83
|
+
"import": "./src/server/home-sections/promo-countdown.ts",
|
|
84
|
+
"default": "./src/server/home-sections/promo-countdown.ts"
|
|
85
|
+
},
|
|
86
|
+
"./home/sections/celebrityTrust": {
|
|
87
|
+
"types": "./dist/server/home-sections/celebrity-trust.d.ts",
|
|
88
|
+
"import": "./src/server/home-sections/celebrity-trust.ts",
|
|
89
|
+
"default": "./src/server/home-sections/celebrity-trust.ts"
|
|
90
|
+
},
|
|
91
|
+
"./home/sections/luxeFavourites": {
|
|
92
|
+
"types": "./dist/server/home-sections/luxe-favourites.d.ts",
|
|
93
|
+
"import": "./src/server/home-sections/luxe-favourites.ts",
|
|
94
|
+
"default": "./src/server/home-sections/luxe-favourites.ts"
|
|
95
|
+
},
|
|
96
|
+
"./home/sections/shopByCategory": {
|
|
97
|
+
"types": "./dist/server/home-sections/shop-by-category.d.ts",
|
|
98
|
+
"import": "./src/server/home-sections/shop-by-category.ts",
|
|
99
|
+
"default": "./src/server/home-sections/shop-by-category.ts"
|
|
100
|
+
},
|
|
101
|
+
"./home/sections/baptism": {
|
|
102
|
+
"types": "./dist/server/home-sections/baptism.d.ts",
|
|
103
|
+
"import": "./src/server/home-sections/baptism.ts",
|
|
104
|
+
"default": "./src/server/home-sections/baptism.ts"
|
|
105
|
+
},
|
|
106
|
+
"./home/sections/baptismPicks": {
|
|
107
|
+
"types": "./dist/server/home-sections/baptism-picks.d.ts",
|
|
108
|
+
"import": "./src/server/home-sections/baptism-picks.ts",
|
|
109
|
+
"default": "./src/server/home-sections/baptism-picks.ts"
|
|
110
|
+
},
|
|
111
|
+
"./home/sections/themeDresses": {
|
|
112
|
+
"types": "./dist/server/home-sections/theme-dresses.d.ts",
|
|
113
|
+
"import": "./src/server/home-sections/theme-dresses.ts",
|
|
114
|
+
"default": "./src/server/home-sections/theme-dresses.ts"
|
|
115
|
+
},
|
|
116
|
+
"./home/sections/brandMarquee": {
|
|
117
|
+
"types": "./dist/server/home-sections/brand-marquee.d.ts",
|
|
118
|
+
"import": "./src/server/home-sections/brand-marquee.ts",
|
|
119
|
+
"default": "./src/server/home-sections/brand-marquee.ts"
|
|
120
|
+
},
|
|
121
|
+
"./home/sections/aboutBrand": {
|
|
122
|
+
"types": "./dist/server/home-sections/about-brand.d.ts",
|
|
123
|
+
"import": "./src/server/home-sections/about-brand.ts",
|
|
124
|
+
"default": "./src/server/home-sections/about-brand.ts"
|
|
125
|
+
},
|
|
126
|
+
"./home/sections/testimonials": {
|
|
127
|
+
"types": "./dist/server/home-sections/testimonials.d.ts",
|
|
128
|
+
"import": "./src/server/home-sections/testimonials.ts",
|
|
129
|
+
"default": "./src/server/home-sections/testimonials.ts"
|
|
130
|
+
},
|
|
131
|
+
"./home/sections/brandPillars": {
|
|
132
|
+
"types": "./dist/server/home-sections/brand-pillars.d.ts",
|
|
133
|
+
"import": "./src/server/home-sections/brand-pillars.ts",
|
|
134
|
+
"default": "./src/server/home-sections/brand-pillars.ts"
|
|
135
|
+
},
|
|
136
|
+
"./home/sections/instagramPosts": {
|
|
137
|
+
"types": "./dist/server/home-sections/instagram-posts.d.ts",
|
|
138
|
+
"import": "./src/server/home-sections/instagram-posts.ts",
|
|
139
|
+
"default": "./src/server/home-sections/instagram-posts.ts"
|
|
140
|
+
},
|
|
141
|
+
"./home/sections/features": {
|
|
142
|
+
"types": "./dist/server/home-sections/features.d.ts",
|
|
143
|
+
"import": "./src/server/home-sections/features.ts",
|
|
144
|
+
"default": "./src/server/home-sections/features.ts"
|
|
145
|
+
},
|
|
146
|
+
"./home/sections/shopByAge": {
|
|
147
|
+
"types": "./dist/server/home-sections/shop-by-age.d.ts",
|
|
148
|
+
"import": "./src/server/home-sections/shop-by-age.ts",
|
|
149
|
+
"default": "./src/server/home-sections/shop-by-age.ts"
|
|
150
|
+
},
|
|
151
|
+
"./home/sections/whyChooseUs": {
|
|
152
|
+
"types": "./dist/server/home-sections/why-choose-us.d.ts",
|
|
153
|
+
"import": "./src/server/home-sections/why-choose-us.ts",
|
|
154
|
+
"default": "./src/server/home-sections/why-choose-us.ts"
|
|
155
|
+
},
|
|
156
|
+
"./home/sections/lovedByMoms": {
|
|
157
|
+
"types": "./dist/server/home-sections/loved-by-moms.d.ts",
|
|
158
|
+
"import": "./src/server/home-sections/loved-by-moms.ts",
|
|
159
|
+
"default": "./src/server/home-sections/loved-by-moms.ts"
|
|
160
|
+
},
|
|
161
|
+
"./home/sections/videoStories": {
|
|
162
|
+
"types": "./dist/server/home-sections/video-stories.d.ts",
|
|
163
|
+
"import": "./src/server/home-sections/video-stories.ts",
|
|
164
|
+
"default": "./src/server/home-sections/video-stories.ts"
|
|
165
|
+
},
|
|
166
|
+
"./home/sections/blogPosts": {
|
|
167
|
+
"types": "./dist/server/home-sections/blog-posts.d.ts",
|
|
168
|
+
"import": "./src/server/home-sections/blog-posts.ts",
|
|
169
|
+
"default": "./src/server/home-sections/blog-posts.ts"
|
|
125
170
|
},
|
|
126
171
|
"./help/sections/helpFaq": {
|
|
127
172
|
"types": "./dist/server/help-sections/help-faq.d.ts",
|
|
128
173
|
"import": "./src/server/help-sections/help-faq.ts",
|
|
129
174
|
"default": "./src/server/help-sections/help-faq.ts"
|
|
130
|
-
},
|
|
131
|
-
"./fulfillment": {
|
|
132
|
-
"types": "./dist/server/fulfillment.d.ts",
|
|
133
|
-
"import": "./src/server/fulfillment.ts",
|
|
134
|
-
"default": "./src/server/fulfillment.ts"
|
|
135
|
-
},
|
|
136
|
-
"./guest": {
|
|
137
|
-
"types": "./dist/server/guest.d.ts",
|
|
138
|
-
"import": "./src/server/guest.ts",
|
|
139
|
-
"default": "./src/server/guest.ts"
|
|
140
|
-
},
|
|
141
|
-
"./home": {
|
|
142
|
-
"types": "./dist/server/home.d.ts",
|
|
143
|
-
"import": "./src/server/home.ts",
|
|
144
|
-
"default": "./src/server/home.ts"
|
|
145
|
-
},
|
|
146
|
-
"./locale-actions": {
|
|
147
|
-
"types": "./dist/server/locale-actions.d.ts",
|
|
148
|
-
"import": "./src/server/locale-actions.ts",
|
|
149
|
-
"default": "./src/server/locale-actions.ts"
|
|
150
|
-
},
|
|
151
|
-
"./locales": {
|
|
152
|
-
"types": "./dist/server/locales.d.ts",
|
|
153
|
-
"import": "./src/server/locales.ts",
|
|
154
|
-
"default": "./src/server/locales.ts"
|
|
155
|
-
},
|
|
156
|
-
"./notifications": {
|
|
157
|
-
"types": "./dist/server/notifications.d.ts",
|
|
158
|
-
"import": "./src/server/notifications.ts",
|
|
159
|
-
"default": "./src/server/notifications.ts"
|
|
160
|
-
},
|
|
161
|
-
"./onboarding": {
|
|
162
|
-
"types": "./dist/server/onboarding.d.ts",
|
|
163
|
-
"import": "./src/server/onboarding.ts",
|
|
164
|
-
"default": "./src/server/onboarding.ts"
|
|
165
|
-
},
|
|
166
|
-
"./orders": {
|
|
167
|
-
"types": "./dist/server/orders.d.ts",
|
|
168
|
-
"import": "./src/server/orders.ts",
|
|
169
|
-
"default": "./src/server/orders.ts"
|
|
170
|
-
},
|
|
171
|
-
"./payment": {
|
|
172
|
-
"types": "./dist/server/payment.d.ts",
|
|
173
|
-
"import": "./src/server/payment.ts",
|
|
174
|
-
"default": "./src/server/payment.ts"
|
|
175
|
-
},
|
|
176
|
-
"./payment-details": {
|
|
177
|
-
"types": "./dist/server/payment-details.d.ts",
|
|
178
|
-
"import": "./src/server/payment-details.ts",
|
|
179
|
-
"default": "./src/server/payment-details.ts"
|
|
180
|
-
},
|
|
181
|
-
"./pincode": {
|
|
182
|
-
"types": "./dist/server/pincode.d.ts",
|
|
183
|
-
"import": "./src/server/pincode.ts",
|
|
184
|
-
"default": "./src/server/pincode.ts"
|
|
185
|
-
},
|
|
186
|
-
"./products": {
|
|
187
|
-
"types": "./dist/server/products.d.ts",
|
|
188
|
-
"import": "./src/server/products.ts",
|
|
189
|
-
"default": "./src/server/products.ts"
|
|
190
|
-
},
|
|
191
|
-
"./regions": {
|
|
192
|
-
"types": "./dist/server/regions.d.ts",
|
|
193
|
-
"import": "./src/server/regions.ts",
|
|
194
|
-
"default": "./src/server/regions.ts"
|
|
195
|
-
},
|
|
196
|
-
"./returns": {
|
|
197
|
-
"types": "./dist/server/returns.d.ts",
|
|
198
|
-
"import": "./src/server/returns.ts",
|
|
199
|
-
"default": "./src/server/returns.ts"
|
|
200
|
-
},
|
|
201
|
-
"./swaps": {
|
|
202
|
-
"types": "./dist/server/swaps.d.ts",
|
|
203
|
-
"import": "./src/server/swaps.ts",
|
|
204
|
-
"default": "./src/server/swaps.ts"
|
|
205
|
-
},
|
|
206
|
-
"./variants": {
|
|
207
|
-
"types": "./dist/server/variants.d.ts",
|
|
208
|
-
"import": "./src/server/variants.ts",
|
|
209
|
-
"default": "./src/server/variants.ts"
|
|
210
|
-
},
|
|
211
|
-
"./wishlist": {
|
|
212
|
-
"types": "./dist/server/wishlist.d.ts",
|
|
213
|
-
"import": "./src/server/wishlist.ts",
|
|
214
|
-
"default": "./src/server/wishlist.ts"
|
|
215
175
|
}
|
|
216
176
|
},
|
|
217
177
|
"main": "./dist/server/index.js",
|
package/src/server/page-input.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import "server-only"
|
|
2
2
|
|
|
3
3
|
import defaultPageInputJson from "../../segment-data/default-page-input.json"
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
DynamicConfigResponse,
|
|
6
|
+
HomepageConfig,
|
|
7
|
+
} from "./homepage-config.types"
|
|
5
8
|
import { mergeSectionBlock } from "./config-merge"
|
|
6
9
|
import { normalizeHomepageConfig } from "./normalize-homepage-config"
|
|
7
10
|
|
|
11
|
+
type Loose = Record<string, unknown>
|
|
12
|
+
|
|
13
|
+
function asObject(v: unknown): Loose | null {
|
|
14
|
+
return v && typeof v === "object" && !Array.isArray(v) ? (v as Loose) : null
|
|
15
|
+
}
|
|
16
|
+
|
|
8
17
|
/** Full `homepage-config` blob passed from the main project into pages and layout. */
|
|
9
18
|
export type StorefrontPageInput = HomepageConfig
|
|
10
19
|
|
|
@@ -55,12 +64,57 @@ export function resolvePageInput(
|
|
|
55
64
|
return mergePageInputWithDefaults(pageInput ?? null)
|
|
56
65
|
}
|
|
57
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Medusa plugin split keys (`site-branding`, `contact`, `faqs`, `homepage-sections`)
|
|
69
|
+
* → simplified `{ site, sections }` for {@link normalizeHomepageConfig}.
|
|
70
|
+
*/
|
|
71
|
+
export function simplifiedHomepageConfigFromDynamicResponse(
|
|
72
|
+
response: DynamicConfigResponse | null | undefined
|
|
73
|
+
): HomepageConfig | null {
|
|
74
|
+
if (!response || typeof response !== "object") return null
|
|
75
|
+
|
|
76
|
+
const siteBranding = asObject(response["site-branding"])
|
|
77
|
+
const contact = asObject(response.contact)
|
|
78
|
+
const faqsRoot = asObject(response.faqs)
|
|
79
|
+
const homepageSections = asObject(response["homepage-sections"])
|
|
80
|
+
const sectionsFromCms = asObject(homepageSections?.sections)
|
|
81
|
+
|
|
82
|
+
const hasSplitKeys =
|
|
83
|
+
siteBranding || contact || faqsRoot || sectionsFromCms
|
|
84
|
+
if (!hasSplitKeys) return null
|
|
85
|
+
|
|
86
|
+
const site: Loose = {}
|
|
87
|
+
if (siteBranding) {
|
|
88
|
+
if (siteBranding.logo != null) site.logo = siteBranding.logo
|
|
89
|
+
if (siteBranding.description != null) {
|
|
90
|
+
site.description = siteBranding.description
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (contact) site.contact = contact
|
|
94
|
+
|
|
95
|
+
const sections: Loose = sectionsFromCms ? { ...sectionsFromCms } : {}
|
|
96
|
+
const helpFaq = asObject(faqsRoot?.helpFaq)
|
|
97
|
+
if (helpFaq) sections.helpFaq = helpFaq
|
|
98
|
+
|
|
99
|
+
const simplified: Loose = {}
|
|
100
|
+
if (Object.keys(site).length) simplified.site = site
|
|
101
|
+
if (Object.keys(sections).length) simplified.sections = sections
|
|
102
|
+
|
|
103
|
+
return Object.keys(simplified).length
|
|
104
|
+
? (simplified as HomepageConfig)
|
|
105
|
+
: null
|
|
106
|
+
}
|
|
107
|
+
|
|
58
108
|
/**
|
|
59
109
|
* Build `homepage-config` from Medusa `GET /store/dynamic-config` (main project only).
|
|
110
|
+
* Supports legacy `homepage-config` or split plugin keys.
|
|
60
111
|
*/
|
|
61
112
|
export function homepageConfigFromDynamicResponse(
|
|
62
|
-
response:
|
|
113
|
+
response: DynamicConfigResponse | null | undefined
|
|
63
114
|
): StorefrontPageInput {
|
|
64
|
-
const
|
|
115
|
+
const legacy = response?.["homepage-config"] ?? null
|
|
116
|
+
const fromSplit = simplifiedHomepageConfigFromDynamicResponse(response)
|
|
117
|
+
const raw = fromSplit ?? legacy
|
|
118
|
+
const normalized = normalizeHomepageConfig(raw)
|
|
65
119
|
return mergePageInputWithDefaults(normalized)
|
|
66
120
|
}
|