medusa-storefront-data 2.4.0 → 2.5.1
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 +38 -4
- 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/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.js +20 -20
- package/dist/src/server/customer.js +11 -11
- 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 +1 -84
- package/dist/src/server/dynamic-config.d.ts.map +1 -1
- package/dist/src/server/dynamic-config.js +0 -130
- package/dist/src/server/fulfillment.js +3 -3
- package/dist/src/server/home.d.ts +4 -15
- package/dist/src/server/home.d.ts.map +1 -1
- package/dist/src/server/home.js +1 -122
- 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 +213 -0
- package/dist/src/server/orders.js +6 -6
- package/dist/src/server/page-input.d.ts.map +1 -1
- package/dist/src/server/page-input.js +3 -1
- package/dist/src/server/payment-details.js +5 -5
- package/dist/src/server/payment.js +2 -2
- package/dist/src/server/regions.js +2 -2
- package/dist/src/server/shoppable-looks.js +1 -1
- package/dist/src/util/store-client.d.ts +0 -2
- package/dist/src/util/store-client.d.ts.map +1 -1
- package/dist/src/util/store-client.js +0 -2
- package/package.json +1 -156
- package/src/server/brand-pillars-from-categories.ts +156 -0
- package/src/server/cart.ts +20 -20
- package/src/server/customer.ts +11 -11
- package/src/server/dynamic-config.ts +1 -172
- package/src/server/fulfillment.ts +3 -3
- package/src/server/home.ts +36 -211
- package/src/server/normalize-homepage-config.ts +240 -0
- package/src/server/orders.ts +6 -6
- package/src/server/page-input.ts +3 -1
- package/src/server/payment-details.ts +5 -5
- package/src/server/payment.ts +2 -2
- package/src/server/regions.ts +2 -2
- package/src/server/shoppable-looks.ts +1 -1
- package/src/util/store-client.ts +0 -3
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import type { HomepageConfig } from "./homepage-config.types"
|
|
2
|
+
|
|
3
|
+
type Loose = Record<string, unknown>
|
|
4
|
+
|
|
5
|
+
function asObject(v: unknown): Loose | null {
|
|
6
|
+
return v && typeof v === "object" && !Array.isArray(v) ? (v as Loose) : null
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function asArray(v: unknown): unknown[] {
|
|
10
|
+
return Array.isArray(v) ? v : []
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Map simplified banner row → legacy `homepage-banner` / `app-banner` entry. */
|
|
14
|
+
function legacyBannerEntry(
|
|
15
|
+
row: unknown,
|
|
16
|
+
prefix: "homepage-banner" | "app-banner"
|
|
17
|
+
): Loose | null {
|
|
18
|
+
const r = asObject(row)
|
|
19
|
+
if (!r) return null
|
|
20
|
+
const image = r.image ?? r[`${prefix}-image`]
|
|
21
|
+
if (!image) return null
|
|
22
|
+
return {
|
|
23
|
+
[prefix]: {
|
|
24
|
+
[`${prefix}-image`]: image,
|
|
25
|
+
[`${prefix}-title`]: r.title ?? r[`${prefix}-title`],
|
|
26
|
+
[`${prefix}-subtitle`]: r.subtitle ?? r[`${prefix}-subtitle`],
|
|
27
|
+
[`${prefix}-description`]: r.description ?? r[`${prefix}-description`],
|
|
28
|
+
[`${prefix}-button-name`]: r.buttonText ?? r.buttonName ?? r[`${prefix}-button-name`],
|
|
29
|
+
[`${prefix}-button-link`]: r.buttonLink ?? r[`${prefix}-button-link`],
|
|
30
|
+
...(prefix === "app-banner" && r.link != null
|
|
31
|
+
? { "app-banner-link": r.link }
|
|
32
|
+
: {}),
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function normalizeBanners(site: Loose | null): {
|
|
38
|
+
desktop: Loose[]
|
|
39
|
+
mobile: Loose[]
|
|
40
|
+
} {
|
|
41
|
+
const banners = asObject(site?.banners) ?? asObject(site)
|
|
42
|
+
const desktopRaw =
|
|
43
|
+
banners?.desktop ?? banners?.["homepage-banner-array"] ?? site?.["homepage-banner-array"]
|
|
44
|
+
const mobileRaw = banners?.mobile ?? banners?.["app-banner-array"] ?? site?.["app-banner-array"]
|
|
45
|
+
|
|
46
|
+
const desktop = asArray(desktopRaw)
|
|
47
|
+
.map((row) => legacyBannerEntry(row, "homepage-banner"))
|
|
48
|
+
.filter(Boolean) as Loose[]
|
|
49
|
+
|
|
50
|
+
const mobile = asArray(mobileRaw)
|
|
51
|
+
.map((row) => legacyBannerEntry(row, "app-banner"))
|
|
52
|
+
.filter(Boolean) as Loose[]
|
|
53
|
+
|
|
54
|
+
return { desktop, mobile }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function normalizeContact(site: Loose | null): Loose | undefined {
|
|
58
|
+
const c = asObject(site?.contact) ?? asObject(site?.["contact-us"])
|
|
59
|
+
if (!c) return undefined
|
|
60
|
+
return {
|
|
61
|
+
"contact-phone": c.phone ?? c["contact-phone"],
|
|
62
|
+
"contact-email": c.email ?? c["contact-email"],
|
|
63
|
+
"contact-whatsapp": c.whatsapp ?? c["contact-whatsapp"],
|
|
64
|
+
"contact-address": c.address ?? c["contact-address"],
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function normalizeSocial(site: Loose | null): Loose[] {
|
|
69
|
+
const raw = site?.social ?? site?.["social-links"]
|
|
70
|
+
return asArray(raw).map((item) => {
|
|
71
|
+
const row = asObject((item as Loose)?.["social-link"]) ?? asObject(item)
|
|
72
|
+
if (!row) return null
|
|
73
|
+
return {
|
|
74
|
+
"social-link": {
|
|
75
|
+
"social-platform-name": row.name ?? row["social-platform-name"],
|
|
76
|
+
"social-platform-url": row.url ?? row["social-platform-url"],
|
|
77
|
+
"social-platform-icon": row.icon ?? row["social-platform-icon"],
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
}).filter(Boolean) as Loose[]
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function normalizeFaqs(site: Loose | null): Loose[] {
|
|
84
|
+
const raw = site?.faqs ?? site?.["faq-array"]
|
|
85
|
+
return asArray(raw).map((item) => {
|
|
86
|
+
const f = asObject((item as Loose)?.faq) ?? asObject(item)
|
|
87
|
+
if (!f) return null
|
|
88
|
+
return {
|
|
89
|
+
faq: {
|
|
90
|
+
"faq-category": f.category ?? f["faq-category"],
|
|
91
|
+
"faq-question": f.question ?? f["faq-question"],
|
|
92
|
+
"faq-answer": f.answer ?? f["faq-answer"],
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
}).filter(Boolean) as Loose[]
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function normalizeTestimonialItem(item: unknown): Loose | null {
|
|
99
|
+
const r = asObject((item as Loose)?.testimonial) ?? asObject(item)
|
|
100
|
+
if (!r) return null
|
|
101
|
+
const text = String(r.text ?? r.description ?? "").trim()
|
|
102
|
+
const name = String(r.name ?? "").trim()
|
|
103
|
+
if (!text || !name) return null
|
|
104
|
+
return { text, name, avatar: r.avatar, rating: r.rating }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function normalizeSections(sections: Loose): Loose {
|
|
108
|
+
const out: Loose = { ...sections }
|
|
109
|
+
|
|
110
|
+
const promoAnnouncements = asObject(sections.promoAnnouncements)
|
|
111
|
+
if (promoAnnouncements?.messages) {
|
|
112
|
+
const messages = asArray(promoAnnouncements.messages)
|
|
113
|
+
.map((m) => {
|
|
114
|
+
if (typeof m === "string") return m.trim()
|
|
115
|
+
const row = asObject(m)
|
|
116
|
+
return String(row?.message ?? row?.text ?? "").trim()
|
|
117
|
+
})
|
|
118
|
+
.filter(Boolean)
|
|
119
|
+
out.promoAnnouncements = { ...promoAnnouncements, messages }
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const testimonials = asObject(sections.testimonials)
|
|
123
|
+
if (testimonials) {
|
|
124
|
+
const items =
|
|
125
|
+
testimonials.items ??
|
|
126
|
+
testimonials.testimonials ??
|
|
127
|
+
testimonials.reviews
|
|
128
|
+
if (Array.isArray(items)) {
|
|
129
|
+
out.testimonials = {
|
|
130
|
+
...testimonials,
|
|
131
|
+
items: items.map(normalizeTestimonialItem).filter(Boolean),
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const promo = asObject(sections.promoCountdown)
|
|
137
|
+
if (promo) {
|
|
138
|
+
out.promoCountdown = {
|
|
139
|
+
code: promo.code ?? promo["promo-code"],
|
|
140
|
+
text: promo.text ?? promo.message ?? promo["promo-text"],
|
|
141
|
+
"end-at": promo.endAt ?? promo["end-at"],
|
|
142
|
+
active: promo.active ?? promo["promo-active"],
|
|
143
|
+
"cta-label": promo.ctaLabel ?? promo["cta-label"],
|
|
144
|
+
"cta-href": promo.ctaHref ?? promo["cta-href"],
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const baptism = asObject(sections.baptismPicks)
|
|
149
|
+
if (baptism?.looks) {
|
|
150
|
+
out.baptismPicks = {
|
|
151
|
+
title: baptism.title,
|
|
152
|
+
looks: asArray(baptism.looks).map((look) => {
|
|
153
|
+
const L = asObject((look as Loose)?.look) ?? asObject(look)
|
|
154
|
+
if (!L) return null
|
|
155
|
+
return {
|
|
156
|
+
image: L.image,
|
|
157
|
+
"product-ids": L.productIds ?? L["product-ids"],
|
|
158
|
+
"product-handles": L.productHandles ?? L["product-handles"],
|
|
159
|
+
}
|
|
160
|
+
}).filter(Boolean),
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const ig = asObject(sections.instagramPosts)
|
|
165
|
+
if (ig) {
|
|
166
|
+
out.instagramPosts = {
|
|
167
|
+
title: ig.title,
|
|
168
|
+
handle: ig.handle,
|
|
169
|
+
"profile-url": ig.profileUrl ?? ig["profile-url"],
|
|
170
|
+
"profile-image": ig.profileImage ?? ig["profile-image"],
|
|
171
|
+
posts: asArray(ig.posts).map((p) => {
|
|
172
|
+
const row = asObject((p as Loose)?.post) ?? asObject(p)
|
|
173
|
+
return row ? { image: row.image, url: row.url ?? row.link } : null
|
|
174
|
+
}).filter(Boolean),
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const about = asObject(sections.aboutBrand)
|
|
179
|
+
if (about) {
|
|
180
|
+
out.aboutBrand = {
|
|
181
|
+
eyebrow: about.eyebrow,
|
|
182
|
+
title: about.title,
|
|
183
|
+
description: about.description ?? about.text,
|
|
184
|
+
readMoreHref: about.readMoreHref ?? about["read-more-link"],
|
|
185
|
+
stats: about.stats,
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// brandPillars: title only in simplified CMS (cards from categories in storefront)
|
|
190
|
+
const pillars = asObject(sections.brandPillars)
|
|
191
|
+
if (pillars && !pillars.pillars) {
|
|
192
|
+
out.brandPillars = {
|
|
193
|
+
title: pillars.title,
|
|
194
|
+
description: pillars.description,
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return out
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Accepts simplified `homepage-config` (site / banners / sections) or legacy shape.
|
|
203
|
+
* Storefront always receives the legacy `HomepageConfig` it already parses.
|
|
204
|
+
*/
|
|
205
|
+
export function normalizeHomepageConfig(input: unknown): HomepageConfig {
|
|
206
|
+
if (!input || typeof input !== "object") return {}
|
|
207
|
+
|
|
208
|
+
const raw = input as Loose
|
|
209
|
+
const site = asObject(raw.site)
|
|
210
|
+
const hasSimplifiedSite = Boolean(site)
|
|
211
|
+
|
|
212
|
+
if (!hasSimplifiedSite) {
|
|
213
|
+
return raw as HomepageConfig
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const { desktop, mobile } = normalizeBanners(raw)
|
|
217
|
+
const sections = normalizeSections(asObject(raw.sections) ?? {})
|
|
218
|
+
|
|
219
|
+
const legacy: HomepageConfig = {
|
|
220
|
+
logo: (site?.logo as string) ?? (raw.logo as string),
|
|
221
|
+
"website-description":
|
|
222
|
+
(site?.description as string) ??
|
|
223
|
+
(raw["website-description"] as string),
|
|
224
|
+
sections: sections as HomepageConfig["sections"],
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (desktop.length) legacy["homepage-banner-array"] = desktop as never
|
|
228
|
+
if (mobile.length) legacy["app-banner-array"] = mobile as never
|
|
229
|
+
|
|
230
|
+
const contact = normalizeContact(site)
|
|
231
|
+
if (contact) legacy["contact-us"] = contact as never
|
|
232
|
+
|
|
233
|
+
const social = normalizeSocial(site)
|
|
234
|
+
if (social.length) legacy["social-links"] = social as never
|
|
235
|
+
|
|
236
|
+
const faqs = normalizeFaqs(site)
|
|
237
|
+
if (faqs.length) legacy["faq-array"] = faqs as never
|
|
238
|
+
|
|
239
|
+
return legacy
|
|
240
|
+
}
|
package/src/server/orders.ts
CHANGED
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
} from "medusa-services/cart"
|
|
33
33
|
import {
|
|
34
34
|
getGuestStoreClientOptions,
|
|
35
|
-
|
|
35
|
+
getStoreClientOptions,
|
|
36
36
|
getStoreClientOptionsWithToken,
|
|
37
37
|
} from "../util/store-client"
|
|
38
38
|
|
|
@@ -63,7 +63,7 @@ export const retrieveOrder = async (id: string) => {
|
|
|
63
63
|
return order as unknown as HttpTypes.StoreOrder
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
const options = await
|
|
66
|
+
const options = await getStoreClientOptions()
|
|
67
67
|
const { order } = await medusaOrderRetrieve(id, options, {
|
|
68
68
|
fields: MEDUSA_ORDER_DETAIL_FIELDS,
|
|
69
69
|
})
|
|
@@ -79,7 +79,7 @@ export const listOrders = async (
|
|
|
79
79
|
filters?: Record<string, any>
|
|
80
80
|
) => {
|
|
81
81
|
try {
|
|
82
|
-
const options = await
|
|
82
|
+
const options = await getStoreClientOptions()
|
|
83
83
|
const { orders } = await medusaOrderList(options, {
|
|
84
84
|
limit,
|
|
85
85
|
offset,
|
|
@@ -111,7 +111,7 @@ export const createTransferRequest = async (
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
try {
|
|
114
|
-
const options = await
|
|
114
|
+
const options = await getStoreClientOptions()
|
|
115
115
|
const { order } = await medusaOrderRequestTransfer(id, options, {
|
|
116
116
|
fields: "id, email",
|
|
117
117
|
})
|
|
@@ -127,7 +127,7 @@ export const createTransferRequest = async (
|
|
|
127
127
|
|
|
128
128
|
export const acceptTransferRequest = async (id: string, token: string) => {
|
|
129
129
|
try {
|
|
130
|
-
const options = await
|
|
130
|
+
const options = await getStoreClientOptions()
|
|
131
131
|
const { order } = await medusaOrderAcceptTransfer(id, token, options)
|
|
132
132
|
return {
|
|
133
133
|
success: true,
|
|
@@ -141,7 +141,7 @@ export const acceptTransferRequest = async (id: string, token: string) => {
|
|
|
141
141
|
|
|
142
142
|
export const declineTransferRequest = async (id: string, token: string) => {
|
|
143
143
|
try {
|
|
144
|
-
const options = await
|
|
144
|
+
const options = await getStoreClientOptions()
|
|
145
145
|
const { order } = await medusaOrderDeclineTransfer(id, token, options)
|
|
146
146
|
return {
|
|
147
147
|
success: true,
|
package/src/server/page-input.ts
CHANGED
|
@@ -3,6 +3,7 @@ import "server-only"
|
|
|
3
3
|
import defaultPageInputJson from "../../segment-data/default-page-input.json"
|
|
4
4
|
import type { HomepageConfig } from "./homepage-config.types"
|
|
5
5
|
import { mergeSectionBlock } from "./config-merge"
|
|
6
|
+
import { normalizeHomepageConfig } from "./normalize-homepage-config"
|
|
6
7
|
|
|
7
8
|
/** Full `homepage-config` blob passed from the main project into pages and layout. */
|
|
8
9
|
export type StorefrontPageInput = HomepageConfig
|
|
@@ -60,5 +61,6 @@ export function resolvePageInput(
|
|
|
60
61
|
export function homepageConfigFromDynamicResponse(
|
|
61
62
|
response: { "homepage-config"?: HomepageConfig | null } | null | undefined
|
|
62
63
|
): StorefrontPageInput {
|
|
63
|
-
|
|
64
|
+
const normalized = normalizeHomepageConfig(response?.["homepage-config"] ?? null)
|
|
65
|
+
return mergePageInputWithDefaults(normalized)
|
|
64
66
|
}
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
medusaPaymentDetailMakeDefault,
|
|
7
7
|
medusaPaymentDetailsList,
|
|
8
8
|
} from "medusa-services/payment"
|
|
9
|
-
import {
|
|
9
|
+
import { getStoreClientOptions } from "../util/store-client"
|
|
10
10
|
|
|
11
11
|
export const listPaymentDetails = async () => {
|
|
12
12
|
try {
|
|
13
|
-
const options = await
|
|
13
|
+
const options = await getStoreClientOptions()
|
|
14
14
|
if (!options.authorization) {
|
|
15
15
|
return []
|
|
16
16
|
}
|
|
@@ -26,16 +26,16 @@ export const createPaymentDetail = async (
|
|
|
26
26
|
type: "upi" | "bank" | "card",
|
|
27
27
|
detail_json: Record<string, string>
|
|
28
28
|
) => {
|
|
29
|
-
const options = await
|
|
29
|
+
const options = await getStoreClientOptions()
|
|
30
30
|
return medusaPaymentDetailCreate(type, detail_json, options)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export const makeDefaultPaymentDetail = async (id: string) => {
|
|
34
|
-
const options = await
|
|
34
|
+
const options = await getStoreClientOptions()
|
|
35
35
|
return medusaPaymentDetailMakeDefault(id, options)
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export const deletePaymentDetail = async (id: string) => {
|
|
39
|
-
const options = await
|
|
39
|
+
const options = await getStoreClientOptions()
|
|
40
40
|
return medusaPaymentDetailDelete(id, options)
|
|
41
41
|
}
|
package/src/server/payment.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import { HttpTypes } from "@medusajs/types"
|
|
4
4
|
import { medusaPaymentProvidersList } from "medusa-services/payment"
|
|
5
|
-
import {
|
|
5
|
+
import { getStoreClientOptions } from "../util/store-client"
|
|
6
6
|
|
|
7
7
|
export const listCartPaymentMethods = async (regionId: string) => {
|
|
8
8
|
try {
|
|
9
|
-
const options = await
|
|
9
|
+
const options = await getStoreClientOptions()
|
|
10
10
|
const { payment_providers } = await medusaPaymentProvidersList(regionId, options)
|
|
11
11
|
return payment_providers.sort((a, b) => (a.id > b.id ? 1 : -1)) as HttpTypes.StorePaymentProvider[]
|
|
12
12
|
} catch {
|
package/src/server/regions.ts
CHANGED
|
@@ -6,7 +6,7 @@ import medusaError from "../util/medusa-error"
|
|
|
6
6
|
import { HttpTypes } from "@medusajs/types"
|
|
7
7
|
import { getCacheOptions } from "../cookies"
|
|
8
8
|
import { medusaRegionList } from "medusa-services/regions"
|
|
9
|
-
import {
|
|
9
|
+
import { getStoreClientOptions } from "../util/store-client"
|
|
10
10
|
|
|
11
11
|
export const listRegions = async () => {
|
|
12
12
|
const next = {
|
|
@@ -46,7 +46,7 @@ export const getRegion = async (countryCode: string) => {
|
|
|
46
46
|
return regionMap.get(countryCode)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
const options = await
|
|
49
|
+
const options = await getStoreClientOptions()
|
|
50
50
|
const { regions } = await medusaRegionList(options)
|
|
51
51
|
|
|
52
52
|
if (!regions?.length) {
|
|
@@ -116,7 +116,7 @@ async function fetchProductsForLook(
|
|
|
116
116
|
if (p) ordered.push(p)
|
|
117
117
|
}
|
|
118
118
|
for (const handle of productHandles) {
|
|
119
|
-
const p =
|
|
119
|
+
const p = Array.from(byId.values()).find((x) => x.handle === handle)
|
|
120
120
|
if (p && !ordered.some((o) => o.id === p.id)) ordered.push(p)
|
|
121
121
|
}
|
|
122
122
|
|
package/src/util/store-client.ts
CHANGED
|
@@ -37,9 +37,6 @@ export async function getStoreClientOptions(): Promise<MedusaStoreClientOptions>
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
/** @deprecated Use getStoreClientOptions */
|
|
41
|
-
export const getStoreCartClientOptions = getStoreClientOptions
|
|
42
|
-
|
|
43
40
|
export function getMedusaBackendUrl(): string {
|
|
44
41
|
return getBackendUrl()
|
|
45
42
|
}
|