@amboras-dev/storefront-core 2026.11.11-rc.2 → 2026.11.11
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/CHANGELOG.md +3 -106
- package/README.md +3 -29
- package/bin/amboras-check.mjs +1 -2
- package/bin/checks/check-redirect-boundaries.mjs +2 -10
- package/core-manifest.json +1 -6
- package/dist/edge/hosted-checkout.d.ts +2 -5
- package/dist/edge/hosted-checkout.d.ts.map +1 -1
- package/dist/edge/hosted-checkout.js +6 -8
- package/dist/edge/hosted-checkout.js.map +1 -1
- package/dist/edge/proxy.d.ts +2 -27
- package/dist/edge/proxy.d.ts.map +1 -1
- package/dist/edge/proxy.js +56 -206
- package/dist/edge/proxy.js.map +1 -1
- package/dist/hooks/use-auth.d.ts.map +1 -1
- package/dist/hooks/use-auth.js +2 -5
- package/dist/hooks/use-auth.js.map +1 -1
- package/dist/hooks/use-variant-selection.d.ts.map +1 -1
- package/dist/hooks/use-variant-selection.js +12 -1
- package/dist/hooks/use-variant-selection.js.map +1 -1
- package/dist/lib/medusa-client.d.ts.map +1 -1
- package/dist/lib/medusa-client.js +1 -30
- package/dist/lib/medusa-client.js.map +1 -1
- package/dist/lib/redirects.d.ts +5 -13
- package/dist/lib/redirects.d.ts.map +1 -1
- package/dist/lib/redirects.js +9 -68
- package/dist/lib/redirects.js.map +1 -1
- package/dist/lib/seo.d.ts +7 -20
- package/dist/lib/seo.d.ts.map +1 -1
- package/dist/lib/seo.js +29 -156
- package/dist/lib/seo.js.map +1 -1
- package/dist/lib/site-url.d.ts +0 -14
- package/dist/lib/site-url.d.ts.map +1 -1
- package/dist/lib/site-url.js +0 -26
- package/dist/lib/site-url.js.map +1 -1
- package/dist/lib/variant-selection.d.ts +7 -3
- package/dist/lib/variant-selection.d.ts.map +1 -1
- package/dist/lib/variant-selection.js +10 -5
- package/dist/lib/variant-selection.js.map +1 -1
- package/dist/next-config/index.d.ts +0 -31
- package/dist/next-config/index.d.ts.map +1 -1
- package/dist/next-config/index.js +1 -32
- package/dist/next-config/index.js.map +1 -1
- package/package.json +1 -5
- package/bin/checks/check-market-routes.mjs +0 -184
- package/dist/edge/market.d.ts +0 -45
- package/dist/edge/market.d.ts.map +0 -1
- package/dist/edge/market.js +0 -74
- package/dist/edge/market.js.map +0 -1
- package/dist/edge/url-map.d.ts +0 -57
- package/dist/edge/url-map.d.ts.map +0 -1
- package/dist/edge/url-map.js +0 -140
- package/dist/edge/url-map.js.map +0 -1
- package/dist/lib/market.d.ts +0 -176
- package/dist/lib/market.d.ts.map +0 -1
- package/dist/lib/market.js +0 -228
- package/dist/lib/market.js.map +0 -1
- package/dist/lib/visitor-free-routes.d.ts +0 -17
- package/dist/lib/visitor-free-routes.d.ts.map +0 -1
- package/dist/lib/visitor-free-routes.js +0 -31
- package/dist/lib/visitor-free-routes.js.map +0 -1
- package/dist/shell/market-link.d.ts +0 -18
- package/dist/shell/market-link.d.ts.map +0 -1
- package/dist/shell/market-link.js +0 -39
- package/dist/shell/market-link.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,112 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
### Added
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
first path segment and rewrites every page to `/{key}{path}` (`_` root, `en-ca` subfolder, `_<marketId>` host).
|
|
13
|
-
The host is the request's Host header, read exactly as the sitemaps and robots read it (`requestHostOf` in
|
|
14
|
-
`lib/site-url`: `x-forwarded-host`, else `host`; first value, lowercase, port dropped), so routing and canonicals
|
|
15
|
-
never see two hosts; the URL's hostname only when neither header is there (under `next start` it is the listen
|
|
16
|
-
host).
|
|
17
|
-
A previous path (the map's `previousPaths`) and a former default language's path (`languagePaths`: `/de-ca`, and
|
|
18
|
-
`/en-can` after en→de and can→ca, each computed by Medusa) 301 to the current URL only while that URL is
|
|
19
|
-
announced (active and turned on); to a pending host, an inactive market or a passive URL they 302 to the root
|
|
20
|
-
instead (`unserved`), so no indexed link is moved for good to a URL that does not serve. A language that is only
|
|
21
|
-
enabled is never a redirect (`/fr-ca` is the root's), and an older map without `languagePaths` has none. An
|
|
22
|
-
inactive presence 302s to the root when Medusa
|
|
23
|
-
says so in `inactiveRedirect` (`temporary`: a draft market, market URLs off, a market now the primary; null or an
|
|
24
|
-
unknown value: no redirect); `/en-ca/checkout*` 302s to the root checkout. Every market redirect is `no-store`. A
|
|
25
|
-
copy of the map older than 10 minutes routes but never redirects, except to the root checkout.
|
|
26
|
-
- Paths in `OUTSIDE_MARKET_TREE` are never rewritten: files (`public/`, `/llms.txt`, `/pinterest/feed.xml`, robots,
|
|
27
|
-
sitemaps, the manifest), `/api`, `.well-known` and the root metadata images. A file path that no file or route
|
|
28
|
-
answers goes to `/_/<path>` through `marketFallbackRewrites()` (`/next-config`, a store's `afterFiles` rewrites,
|
|
29
|
-
one rule), so the catch-all answers the merchant's redirect for it, as on the old tree. A subfolder's file keeps
|
|
30
|
-
its market: `marketProxy` names the market key in `x-amb-market-key` (`MARKET_KEY_HEADER`), and the catch-all's
|
|
31
|
-
lookup accepts a subfolder key that the URL map holds as an active market and that is the path's own prefix, so
|
|
32
|
-
`/en-ca/catalog.pdf` inherits the root's `/catalog.pdf` redirect, prefixed (308 `/en-ca/new`). Any other key is
|
|
33
|
-
the root's lookup. The key comes from a copy of the map younger than 10 minutes only; on a cold instance the read
|
|
34
|
-
starts in the background, so a later request has it. A file never waits for the map, never 503s, never redirects
|
|
35
|
-
and sends no beacon. A real file in `public/` is served first. A dotted path on a market host
|
|
36
|
-
(`ca.store.com/products/a.b`) is the root's: Medusa's product handles carry no `.`.
|
|
37
|
-
- Market URLs exist only on a build that opted in (`marketTreeEnv()`, `isMarketTreeBuild()`): without it neither
|
|
38
|
-
`proxy` nor `marketProxy` reads the URL map, and `proxy` (a store on the old route tree) sets no `x-amb-market`,
|
|
39
|
-
sends no market redirect and adds no market canonical, exactly as before. Both delete client copies of
|
|
40
|
-
`x-amb-market`, `x-amb-market-hop` and `x-amb-market-key`. With the opt-in, `marketProxy` sets `x-amb-market` to the
|
|
41
|
-
resolved market (none on the root); `proxy` never rewrites a path.
|
|
42
|
-
- A/B on the `app/[m]/` tree: the control signs the internal path it resolved into `x-amb-market-hop`
|
|
43
|
-
(`MARKET_HOP_HEADER`, the `amb_theme` HMAC, valid 60 s), and the variant's `marketProxy` serves that path as it is.
|
|
44
|
-
A variant that cannot verify it (no secret yet, an old one) still serves an internal key the map holds (`/_/x`, a
|
|
45
|
-
market host's `/_<marketId>/x`) as it is on a host that is not the store's, without a market header, and counts
|
|
46
|
-
`hop_unverified` (as for any hop header that fails verification). On such a host a subfolder resolves as on the primary (draft 302, previous-suffix 301 included),
|
|
47
|
-
so subfolder pages keep rendering there with or without a verified hop.
|
|
48
|
-
- The edge keeps the map in memory: refreshed every 30 s with `If-None-Match`, in the background once a copy exists,
|
|
49
|
-
one fetch in flight, a 1.5 s timeout, the last good copy when Medusa fails. A 404 or 410 before any good copy (an
|
|
50
|
-
older Medusa) means no map: the root everywhere, retried in 30 s; any other 4xx, or a 4xx after a good copy, keeps
|
|
51
|
-
the copy, marked stale. A cold instance (its first page request) waits for that read, up to 1.5 s, even on a store
|
|
52
|
-
with no market URL: the map is how it knows there is none. One that cannot read it tries
|
|
53
|
-
again after 5 s and, on the primary host, answers a first segment that starts like a market URL (a language subtag
|
|
54
|
-
and a hyphen, `en-ca`; not a template page such as `/kit-gallery`) with a 503 (`Retry-After: 5`, `no-store`) that
|
|
55
|
-
crawlers retry, where a 404 would drop the page; every other path is the
|
|
56
|
-
root's; after 10 minutes without a map (a revoked key, a WAF block) it stops answering 503 and serves the root,
|
|
57
|
-
still retrying. A change to a market URL reaches the edge within about 90 s (Medusa's 30 s memo, 30 s at
|
|
58
|
-
CloudFront, the copy's 30 s refresh) and a page's canonical and the sitemaps 30 s after that (the data cache). Market redirects run only on the store's own hosts: a preview or variant deployment keeps its
|
|
59
|
-
password gate first and never sends a visitor to the live checkout. It counts `map_stale`, `map_unavailable`, `inactive_redirect` and `hop_unverified` through
|
|
60
|
-
`POST /store/market-signals` (kind only), at most once a minute per kind.
|
|
61
|
-
- `lib/market` (new shim `lib/market.ts`): `StoreUrlMap`, `parseStoreUrlMap` (a presence of an unknown kind or status
|
|
62
|
-
is left out, not the whole map), `MARKET_HEADER`, `OUTSIDE_MARKET_TREE`, `isOutsideMarketTree`, `prefixOfKey`,
|
|
63
|
-
`isMarketKey` (an internal key, or one safe lowercase segment the proxy rewrites; a segment of
|
|
64
|
-
`OUTSIDE_MARKET_TREE` such as `api` is not one), `assertMarketKey(m, notFound)` (the `[m]` layout's guard),
|
|
65
|
-
`marketHref`, `getStoreUrlMap` (null only on a 404 or 410, a store API without the map; any other answer that is
|
|
66
|
-
not a map throws `StoreUrlMapUnavailableError`, as the edge copy reads it). The `m` param is request input: a key or
|
|
67
|
-
prefix that is not one safe lowercase segment (`isMarketPrefix`: no slash, backslash, `_` or `.`) prefixes nothing,
|
|
68
|
-
and a redirect lookup given one answers none. Core never re-checks the market URL rule itself (language and
|
|
69
|
-
suffix): that is Medusa's alone, and the map carries only what it allowed.
|
|
70
|
-
- `/visitor-free-routes`: `VISITOR_FREE_ROUTES`, the store routes whose GET/HEAD answer never depends on the visitor
|
|
71
|
-
(`/store/content/blogs/:blog/articles`, …). The server fetch shim reads it, and Medusa's mirror spec imports it, so
|
|
72
|
-
the list has one owner.
|
|
73
|
-
- `shell/market-link`: `useMarketHref`, `MarketLink`, `useMarketPathname` (the public path on the server and in the
|
|
74
|
-
browser alike). `useAuth().logout` goes to the market's home.
|
|
75
|
-
- `lib/site-url`: `marketMetadataBase(key, map)`, the `metadataBase` of an `app/[m]/` page (`https://store.com/en-ca`,
|
|
76
|
-
`https://store.ca`); the root origin for a passive (backfilled, not turned on) presence.
|
|
77
|
-
- `lib/seo`: the sitemap index lists the root plus each announced subfolder on the primary host, and a market's own
|
|
78
|
-
host lists its market; child ids are `slot * 100000 + page`, the slot being Medusa's stable presence `ordinal`
|
|
79
|
-
(the root's slot is 0, so its ids are unchanged). Every URL carries hreflang alternates (`en-CA`, …, `x-default`) when the store's
|
|
80
|
-
hreflang setting is on and a market URL is announced. A market's sitemap (a subfolder's slot, or its own host's)
|
|
81
|
-
lists what its region sells (`/store/products?region_id=`, the map's `regionId`; a market without one lists no
|
|
82
|
-
product), and a product URL names as alternates only the markets that sell it (read in at most one
|
|
83
|
-
`region_id` + `id` lookup per market per 100 products of the child, cached like it). The sitemap is the only place
|
|
84
|
-
hreflang is written: no page `<head>` carries it, so the two can never disagree. `robots.txt` names a market host's own sitemap there and
|
|
85
|
-
disallows the private pages under each announced subfolder too. All of it only on the `app/[m]/` tree
|
|
86
|
-
(`marketTreeEnv()`, `isMarketTreeBuild()`): a store on the old route tree never reads the map there and gets
|
|
87
|
-
byte-for-byte today's sitemaps and robots, as does a store with no announced market URL.
|
|
88
|
-
- `lib/redirects`: `resolveRedirect`, `resolveHandleRedirect` and `resolveUnmatchedPathRedirect` take a
|
|
89
|
-
`marketPrefix` (`prefixOfKey(params.m)`). Under a prefix the full path is tried first (`/en-ca/old-page`), then
|
|
90
|
-
the inner path, whose relative target stays in the market. With no prefix, on the `app/[m]/` tree,
|
|
91
|
-
`resolveUnmatchedPathRedirect` takes a market file path's prefix from `x-amb-market-key` as above (it reads
|
|
92
|
-
`headers()`; a map that cannot be read is the root's lookup, never a 500, logged as `redirect_lookup_failed`).
|
|
93
|
-
- `amboras-check market-routes`: on a store with `app/[m]/` or a `marketProxy` export, fails a route file on the wrong
|
|
94
|
-
side of `OUTSIDE_MARKET_TREE` (and a metadata image anywhere but the app root) with the move to make, an
|
|
95
|
-
`app/[m]/layout` without `assertMarketKey`, and a `next.config` that does not spread `marketTreeEnv()` into its
|
|
96
|
-
`env` or return `marketFallbackRewrites()` in its `rewrites()` `afterFiles` (alone, or spread anywhere in an array).
|
|
97
|
-
`amboras-check redirect-boundaries` guards the same folders under
|
|
98
|
-
`app/[m]/`, and `app/[m]/loading.*`.
|
|
99
|
-
|
|
100
|
-
### Fixed
|
|
101
|
-
|
|
102
|
-
- Static rendering, on a store that opts in (`env: { ...marketTreeEnv() }` in next.config, `/next-config`: the
|
|
103
|
-
`app/[m]/` template): the server fetch shim (`lib/medusa-client`) read `cookies()` / `headers()` for every request to
|
|
104
|
-
Medusa, so a statically rendered page (`/about`, `/checkout`, `/account`) threw "static to dynamic" on every
|
|
105
|
-
revalidation and stayed stale, and an `app/[m]/` page's first render under a market key answered 500. With the
|
|
106
|
-
opt-in it skips that read for a GET of the exact store routes core calls that Medusa answers the same for every
|
|
107
|
-
visitor: `/store/url-map`, `/store/url-redirects`, `/store/content/blogs`, `/store/content/blogs/:blog/articles`,
|
|
108
|
-
`/store/content/blogs/:blog/articles/:handle`, `/store/content/blogs/:blog/articles/:handle/comments`,
|
|
109
|
-
`/store/metaobjects/:type`, `/store/metaobjects/:type/:handle`, `/store/config`, `/store/brand`,
|
|
110
|
-
`/store/integrations/active`, `/store/policies`, `/store/checkout-settings` (matched on the normalised path).
|
|
111
|
-
Every other route keeps the visitor's `x-amb-vid` / `x-amb-country`, and a store without the opt-in (every store on
|
|
112
|
-
the old tree) is exactly as before.
|
|
113
|
-
- `edge/proxy.ts` no longer claims to be generated from the orchestrator's `middleware-template.ts`: core stores run
|
|
114
|
-
this file, legacy stores run the template.
|
|
9
|
+
- The product page starts on the variant named by `?variant=<id>` when the product sells it (the link a product feed
|
|
10
|
+
sends for each variant, as on Shopify), so the price and options a shopper lands on match the feed item.
|
|
11
|
+
`useVariantSelection` reads it; `initialSelectedOptions` and `initialVariant` take an optional `preferredVariantId`.
|
|
115
12
|
|
|
116
13
|
## 2026.11.10
|
|
117
14
|
|
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ from it and its version-floor check makes sure each shim exists.
|
|
|
57
57
|
| `types/index.ts` | `@amboras-dev/storefront-core/types` |
|
|
58
58
|
| `components/ClientPluginSlot.tsx` | `@amboras-dev/storefront-core/shell/client-plugin-slot` |
|
|
59
59
|
| `components/PluginSlot.tsx` | `createPluginSlot` from `@amboras-dev/storefront-core/server/plugin-slot` |
|
|
60
|
-
| `proxy.ts` | `proxy`
|
|
60
|
+
| `proxy.ts` | `proxy` from `@amboras-dev/storefront-core/edge` |
|
|
61
61
|
|
|
62
62
|
### 3. The registry and payment UI are injected
|
|
63
63
|
|
|
@@ -184,31 +184,6 @@ export const config = {
|
|
|
184
184
|
|
|
185
185
|
`amboras-check proxy-matcher` fails when the copy differs from the installed core's matcher.
|
|
186
186
|
|
|
187
|
-
**Market URLs (AMB-2174).** A store whose routes live under `app/[m]/` exports `marketProxy as proxy` instead. It
|
|
188
|
-
reads the store's URL map (`GET /store/url-map`), resolves the market from the host (`ca.store.com`, `store.ca`) or the
|
|
189
|
-
first path segment (`/en-ca`), rewrites every page to `/{market key}{path}` and sets the `x-amb-market` request header
|
|
190
|
-
(any client copy is deleted first). A store on the old tree keeps `proxy`, which reads no URL map and never rewrites
|
|
191
|
-
a path, so it is unchanged by a core bump. Links go through `MarketLink` / `useMarketHref` (`/shell/market-link`) or
|
|
192
|
-
`marketHref` (`/lib/market`); the current path through `useMarketPathname` (never `usePathname`, which differs between
|
|
193
|
-
the server and the browser on a rewritten page). The `[m]` layout guards its key with `assertMarketKey(m, notFound)`
|
|
194
|
-
and sets `metadataBase` with `marketMetadataBase(m, map)`. `next.config` (both from `/next-config`) spreads
|
|
195
|
-
`...marketTreeEnv()` into its `env`, the opt-in that lets the visitor-independent store reads skip the visitor
|
|
196
|
-
cookies so static pages stay static (without it the store is an old tree: no market URL anywhere), and returns
|
|
197
|
-
`afterFiles: marketFallbackRewrites()` from `rewrites()`: a file path no file or route answered goes to `/_/<path>`,
|
|
198
|
-
where the catch-all answers the merchant's redirect, as on the old tree (`/en-ca/old.pdf` in the `en-ca` market, from
|
|
199
|
-
the key `marketProxy` names in `x-amb-market-key`). `OUTSIDE_MARKET_TREE`
|
|
200
|
-
(`/lib/market`, `/edge`) is the one list of paths served outside `app/[m]/`: files, `/api`, `.well-known`, the sitemaps
|
|
201
|
-
and the root metadata images. `amboras-check market-routes` fails a route file on the wrong side of it, a layout
|
|
202
|
-
without `assertMarketKey` and a `next.config` without either of the two.
|
|
203
|
-
|
|
204
|
-
What a market URL is (its language and suffix) is Medusa's rule alone: the map holds only what it allowed, with each
|
|
205
|
-
moved URL's old paths (`previousPaths`, and `languagePaths` for a former default language). An old path 301s only to
|
|
206
|
-
an announced URL; to one that is not serving yet it 302s to the root. The edge keeps the map in memory, so a page
|
|
207
|
-
request makes no Medusa call except on a cold instance's first request, which waits up to 1.5 s for it (even on a
|
|
208
|
-
store without market URLs). With no map at all, a path that starts like a market URL (`/en-ca`) answers 503 for up
|
|
209
|
-
to 10 minutes, which crawlers retry. A change reaches the edge within about 90 s and a page's canonical and the
|
|
210
|
-
sitemaps about 30 s after that.
|
|
211
|
-
|
|
212
187
|
### 6. Feature switches: unknown is not off
|
|
213
188
|
|
|
214
189
|
`useStoreConfig()` (client) and `getStoreConfig()` (server) read Medusa's `GET /store/config`. Each
|
|
@@ -222,7 +197,7 @@ then falls back to `/store/checkout-settings`.
|
|
|
222
197
|
### 7. Build gates
|
|
223
198
|
|
|
224
199
|
```bash
|
|
225
|
-
npx amboras-check # plugin slots, store quirks, redirect boundaries, consent scroll, proxy matcher
|
|
200
|
+
npx amboras-check # plugin slots, store quirks, redirect boundaries, consent scroll, proxy matcher
|
|
226
201
|
npx amboras-check slots # one gate
|
|
227
202
|
```
|
|
228
203
|
|
|
@@ -234,8 +209,7 @@ npx amboras-check slots # one gate
|
|
|
234
209
|
| `/client/<hook>` | one hook file, same exports as the template's | per file |
|
|
235
210
|
| `/server` | `createPluginSlot`, `PluginSlot`, `getPluginConfigs`, `medusaFetch`, `getStoreConfig`, config | no |
|
|
236
211
|
| `/lib/<path>` | logic modules (checkout, cart, payment providers, analytics, consent…) | per file |
|
|
237
|
-
| `/edge` | `proxy`, `
|
|
238
|
-
| `/visitor-free-routes` | `VISITOR_FREE_ROUTES`, the store routes that never vary by visitor (Medusa's spec imports it) | no |
|
|
212
|
+
| `/edge` | `proxy`, `proxyConfig` | no |
|
|
239
213
|
| `/next-config` | `withAmborasCore`, `resolveAmborasImageHosts` | no |
|
|
240
214
|
| `/config` | `configureCore`, `getCoreConfig` | no |
|
|
241
215
|
| `/types`, `/types/plugins` | shared types, slot types | no |
|
package/bin/amboras-check.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// amboras-check [gate…] [--root <dir>]
|
|
5
5
|
//
|
|
6
|
-
// Gates: slots, quirks, redirect-boundaries, consent-scroll, proxy-matcher
|
|
6
|
+
// Gates: slots, quirks, redirect-boundaries, consent-scroll, proxy-matcher (default: all).
|
|
7
7
|
// The store root defaults to the current directory. Each gate is a separate
|
|
8
8
|
// node process, so a failing gate's exit code and output are its own.
|
|
9
9
|
import { spawnSync } from 'node:child_process'
|
|
@@ -17,7 +17,6 @@ const GATES = {
|
|
|
17
17
|
'redirect-boundaries': 'check-redirect-boundaries.mjs',
|
|
18
18
|
'consent-scroll': 'check-consent-scroll.mjs',
|
|
19
19
|
'proxy-matcher': 'check-proxy-matcher.mjs',
|
|
20
|
-
'market-routes': 'check-market-routes.mjs',
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
const args = process.argv.slice(2)
|
|
@@ -19,16 +19,12 @@
|
|
|
19
19
|
* The same holds for the catch-all `app/[...slug]/page.tsx` (a merchant URL redirect for any path):
|
|
20
20
|
* a `loading.tsx` next to it would turn its 308 into a 200 with a client redirect.
|
|
21
21
|
*
|
|
22
|
-
* On the `app/[m]/` tree (AMB-2174) the same folders sit under `app/[m]/`, and a `loading.tsx` in `app/[m]/` itself
|
|
23
|
-
* wraps every one of them, so it fails too.
|
|
24
|
-
*
|
|
25
22
|
* Usage: `node scripts/check-redirect-boundaries.mjs [storefrontRoot]`.
|
|
26
23
|
* Exit 1 with the offending paths, exit 0 otherwise.
|
|
27
24
|
*/
|
|
28
25
|
import { existsSync, readFileSync } from 'node:fs'
|
|
29
26
|
import { join, resolve } from 'node:path'
|
|
30
27
|
import { fileURLToPath } from 'node:url'
|
|
31
|
-
import { isMarketTree } from './check-market-routes.mjs'
|
|
32
28
|
|
|
33
29
|
// app/pages: a metaobject entry's web page (app/pages/[handle]/[entry]) 308s to a merchant URL redirect when
|
|
34
30
|
// the entry is gone, so a loading.tsx in either parent would turn that into a 200 (content module).
|
|
@@ -40,13 +36,10 @@ export const CORE_BLOG_DIRS = ['app/blogs', 'app/blogs/[blog]']
|
|
|
40
36
|
const CORE_BLOG_MARKER = '@/lib/store-blog'
|
|
41
37
|
const LOADING_FILES = ['loading.tsx', 'loading.ts', 'loading.jsx', 'loading.js']
|
|
42
38
|
|
|
43
|
-
/** `app/x` → `app/[m]/x` on the market tree. */
|
|
44
|
-
const inTree = (root, dir) => (isMarketTree(root) ? dir.replace(/^app\//, 'app/[m]/') : dir)
|
|
45
|
-
|
|
46
39
|
function hasCoreBlogPages(root) {
|
|
47
40
|
return ['app/blogs/[blog]/page.tsx', 'app/blogs/[blog]/[article]/page.tsx'].some((file) => {
|
|
48
41
|
try {
|
|
49
|
-
return readFileSync(join(root,
|
|
42
|
+
return readFileSync(join(root, file), 'utf8').includes(CORE_BLOG_MARKER)
|
|
50
43
|
} catch {
|
|
51
44
|
return false
|
|
52
45
|
}
|
|
@@ -56,8 +49,7 @@ function hasCoreBlogPages(root) {
|
|
|
56
49
|
/** Offending files (relative paths) under `root`. */
|
|
57
50
|
export function findRedirectBoundaryViolations(root) {
|
|
58
51
|
const found = []
|
|
59
|
-
const
|
|
60
|
-
for (const dir of isMarketTree(root) ? ['app/[m]', ...dirs] : dirs) {
|
|
52
|
+
for (const dir of hasCoreBlogPages(root) ? [...GUARDED_DIRS, ...CORE_BLOG_DIRS] : GUARDED_DIRS) {
|
|
61
53
|
for (const file of LOADING_FILES) {
|
|
62
54
|
if (existsSync(join(root, dir, file))) found.push(`${dir}/${file}`)
|
|
63
55
|
}
|
package/core-manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$comment": "Generated by scripts/build-manifest.mjs. Paths are relative to the storefront app root.",
|
|
3
3
|
"package": "@amboras-dev/storefront-core",
|
|
4
|
-
"version": "2026.11.11
|
|
4
|
+
"version": "2026.11.11",
|
|
5
5
|
"shims": [
|
|
6
6
|
{
|
|
7
7
|
"path": "hooks/use-auth.ts",
|
|
@@ -383,11 +383,6 @@
|
|
|
383
383
|
"import": "@amboras-dev/storefront-core/lib/logger",
|
|
384
384
|
"kind": "reexport"
|
|
385
385
|
},
|
|
386
|
-
{
|
|
387
|
-
"path": "lib/market.ts",
|
|
388
|
-
"import": "@amboras-dev/storefront-core/lib/market",
|
|
389
|
-
"kind": "reexport"
|
|
390
|
-
},
|
|
391
386
|
{
|
|
392
387
|
"path": "lib/medusa-client.ts",
|
|
393
388
|
"import": "@amboras-dev/storefront-core/lib/medusa-client",
|
|
@@ -50,11 +50,8 @@ export interface HostedCheckoutEnv {
|
|
|
50
50
|
preview?: boolean;
|
|
51
51
|
}
|
|
52
52
|
export declare function hostedCheckoutEnv(): HostedCheckoutEnv;
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
* headers forwarded to the checkout app (the proxy's, with the client's `x-amb-market` already replaced).
|
|
56
|
-
*/
|
|
57
|
-
export declare function hostedCheckout(req: NextRequest, env?: HostedCheckoutEnv, now?: number, requestHeaders?: Headers): Promise<NextResponse | null>;
|
|
53
|
+
/** The rewrite to the hosted checkout, or null to let the store serve /checkout itself. */
|
|
54
|
+
export declare function hostedCheckout(req: NextRequest, env?: HostedCheckoutEnv, now?: number): Promise<NextResponse | null>;
|
|
58
55
|
/** True for a rewrite to the hosted app: its own security headers must reach the browser untouched. */
|
|
59
56
|
export declare function isHostedCheckoutResponse(res: Response): boolean;
|
|
60
57
|
/** Test seam: forget the cached health document. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-checkout.d.ts","sourceRoot":"","sources":["../../src/edge/hosted-checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"hosted-checkout.d.ts","sourceRoot":"","sources":["../../src/edge/hosted-checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAE5D;;;;;;;;;GASG;AAEH,eAAO,MAAM,kBAAkB,oBAAoB,CAAA;AAEnD,MAAM,WAAW,iBAAiB;IAChC,CAAC,EAAE,CAAC,CAAA;IACJ,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,CAAC,EAAE,CAAC,CAAA;IACL,CAAC,EAAE,MAAM,CAAA;IACT,6FAA6F;IAC7F,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,gGAAgG;IAChG,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAkBD,wGAAwG;AACxG,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAKlG;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,0FAA0F;AAC1F,eAAO,MAAM,wBAAwB,qCAAqC,CAAA;AAC1E,wGAAwG;AACxG,eAAO,MAAM,yBAAyB,8CAA8C,CAAA;AAEpF,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE5D;AA4BD,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,iBAAiB,IAAI,iBAAiB,CAerD;AAED,2FAA2F;AAC3F,wBAAsB,cAAc,CAClC,GAAG,EAAE,WAAW,EAChB,GAAG,GAAE,iBAAuC,EAC5C,GAAG,GAAE,MAAmB,GACvB,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAoC9B;AAID,uGAAuG;AACvG,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAE/D;AAED,oDAAoD;AACpD,wBAAgB,yBAAyB,SAExC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server';
|
|
2
|
-
import { edgeStoreEnv } from './url-map.js';
|
|
3
2
|
/**
|
|
4
3
|
* Hosted checkout: /checkout on the store's own domain is served by the platform's checkout app
|
|
5
4
|
* (amboras-checkout) through a rewrite, so the shopper never leaves the store's origin.
|
|
@@ -70,7 +69,9 @@ export function hostedCheckoutEnv() {
|
|
|
70
69
|
checkoutKey: process.env.AMBORAS_CHECKOUT_KEY,
|
|
71
70
|
checkoutKeyId: process.env.AMBORAS_CHECKOUT_KEY_ID,
|
|
72
71
|
healthUrl: process.env.AMBORAS_CHECKOUT_HEALTH_URL,
|
|
73
|
-
|
|
72
|
+
storeId: process.env.NEXT_PUBLIC_STORE_ID,
|
|
73
|
+
medusaUrl: process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL,
|
|
74
|
+
publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
|
74
75
|
analyticsEndpoint: process.env.NEXT_PUBLIC_ANALYTICS_ENDPOINT,
|
|
75
76
|
analyticsIngestUrl: process.env.NEXT_PUBLIC_ANALYTICS_INGEST_URL,
|
|
76
77
|
analyticsKey: process.env.NEXT_PUBLIC_ANALYTICS_KEY,
|
|
@@ -78,11 +79,8 @@ export function hostedCheckoutEnv() {
|
|
|
78
79
|
preview: process.env.VERCEL_ENV !== undefined && process.env.VERCEL_ENV !== 'production',
|
|
79
80
|
};
|
|
80
81
|
}
|
|
81
|
-
/**
|
|
82
|
-
|
|
83
|
-
* headers forwarded to the checkout app (the proxy's, with the client's `x-amb-market` already replaced).
|
|
84
|
-
*/
|
|
85
|
-
export async function hostedCheckout(req, env = hostedCheckoutEnv(), now = Date.now(), requestHeaders = req.headers) {
|
|
82
|
+
/** The rewrite to the hosted checkout, or null to let the store serve /checkout itself. */
|
|
83
|
+
export async function hostedCheckout(req, env = hostedCheckoutEnv(), now = Date.now()) {
|
|
86
84
|
const { pathname: requested, search } = req.nextUrl;
|
|
87
85
|
const pathname = requested === STORE_PAYMENT_RELAY_PATH ? HOSTED_PAYMENT_RELAY_PATH : requested;
|
|
88
86
|
if (!isCheckoutPath(pathname))
|
|
@@ -114,7 +112,7 @@ export async function hostedCheckout(req, env = hostedCheckoutEnv(), now = Date.
|
|
|
114
112
|
...(env.analyticsKey ? { ak: env.analyticsKey } : {}),
|
|
115
113
|
...(env.googleMapsApiKey ? { g: env.googleMapsApiKey } : {}),
|
|
116
114
|
};
|
|
117
|
-
const headers = new Headers(
|
|
115
|
+
const headers = new Headers(req.headers);
|
|
118
116
|
headers.set(STORE_TOKEN_HEADER, await signStoreToken(checkoutKey, payload));
|
|
119
117
|
const target = new URL(`${pathname}${search}`, checkoutUrl);
|
|
120
118
|
const res = NextResponse.rewrite(target, { request: { headers } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-checkout.js","sourceRoot":"","sources":["../../src/edge/hosted-checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAoB,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"hosted-checkout.js","sourceRoot":"","sources":["../../src/edge/hosted-checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAoB,MAAM,aAAa,CAAA;AAE5D;;;;;;;;;GASG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAA;AAoBnD,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAA;AAE7B,SAAS,MAAM,CAAC,KAAiB;IAC/B,IAAI,CAAC,GAAG,EAAE,CAAA;IACV,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,CAAC,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;IAClD,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;AAC3E,CAAC;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAA;IACpE,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,CAAA;IAC/D,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,CA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C"}
|
package/dist/edge/proxy.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NextRequest, NextResponse
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
2
2
|
/**
|
|
3
3
|
* The matcher the store's proxy.ts must declare. Next reads `config` statically
|
|
4
4
|
* from the proxy file itself, so it cannot be re-exported from a package: the
|
|
@@ -7,30 +7,5 @@ import { NextRequest, NextResponse, type NextFetchEvent } from 'next/server';
|
|
|
7
7
|
export declare const proxyConfig: {
|
|
8
8
|
matcher: string[];
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
export { OUTSIDE_MARKET_TREE } from '../lib/market.js';
|
|
12
|
-
/**
|
|
13
|
-
* Edge entrypoint for a store tree without `app/[m]/`: today's proxy. It never rewrites the path, so a core bump never
|
|
14
|
-
* moves a store's routes, and it reads no URL map, sets no `x-amb-market`, sends no market redirect and adds no market
|
|
15
|
-
* canonical: market URLs exist only on a build that opted in (`marketTreeEnv()`, `isMarketTreeBuild()`).
|
|
16
|
-
*/
|
|
17
|
-
export declare function proxy(req: NextRequest, event?: NextFetchEvent): Promise<NextResponse<unknown>>;
|
|
18
|
-
/**
|
|
19
|
-
* Edge entrypoint for the `app/[m]/` tree (AMB-2174): resolves hosts and subfolders and rewrites every page to
|
|
20
|
-
* `/{internalKey}{innerPath}`, so each market renders and caches under its own `[m]` key.
|
|
21
|
-
*/
|
|
22
|
-
export declare function marketProxy(req: NextRequest, event?: NextFetchEvent): Promise<NextResponse<unknown>>;
|
|
23
|
-
/**
|
|
24
|
-
* The A/B hop (AMB-2174): a control deployment that rewrites a page to a variant deployment sends the internal path
|
|
25
|
-
* it resolved (`/_/products/x`), signed with the router secret (the `amb_theme` cookie's HMAC). The variant's
|
|
26
|
-
* `marketProxy` serves that path as it is instead of resolving it again (which would give `/_/_/products/x`). A
|
|
27
|
-
* client copy is deleted. A variant on the old route tree never gets one: the Orchestrator refuses an A/B group that
|
|
28
|
-
* mixes the `app/[m]/` tree with the old one. A token lives 60 s and names the one path it was signed for.
|
|
29
|
-
*
|
|
30
|
-
* A variant that cannot verify it (no secret yet: a first launch builds variants before the env is written; an old
|
|
31
|
-
* one after a rotation) still never resolves an internal path again: on a host that is not one of the store's, a
|
|
32
|
-
* first segment that is an internal key (`_`, `_<marketId>`, never in a public URL) is served as it is, without a
|
|
33
|
-
* market header, and counted as `hop_unverified`.
|
|
34
|
-
*/
|
|
35
|
-
export declare const MARKET_HOP_HEADER = "x-amb-market-hop";
|
|
10
|
+
export declare function proxy(req: NextRequest): Promise<NextResponse<unknown>>;
|
|
36
11
|
//# sourceMappingURL=proxy.d.ts.map
|
package/dist/edge/proxy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/edge/proxy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/edge/proxy.ts"],"names":[],"mappings":"AAsCA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AA+GvD;;;;GAIG;AACH,eAAO,MAAM,WAAW;;CAiCvB,CAAA;AAsOD,wBAAsB,KAAK,CAAC,GAAG,EAAE,WAAW,kCAO3C"}
|