@amboras-dev/storefront-core 2026.11.11-rc.1 → 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.
Files changed (64) hide show
  1. package/CHANGELOG.md +3 -102
  2. package/README.md +3 -29
  3. package/bin/amboras-check.mjs +1 -2
  4. package/bin/checks/check-redirect-boundaries.mjs +2 -10
  5. package/core-manifest.json +1 -6
  6. package/dist/edge/hosted-checkout.d.ts +2 -5
  7. package/dist/edge/hosted-checkout.d.ts.map +1 -1
  8. package/dist/edge/hosted-checkout.js +6 -8
  9. package/dist/edge/hosted-checkout.js.map +1 -1
  10. package/dist/edge/proxy.d.ts +2 -27
  11. package/dist/edge/proxy.d.ts.map +1 -1
  12. package/dist/edge/proxy.js +56 -204
  13. package/dist/edge/proxy.js.map +1 -1
  14. package/dist/hooks/use-auth.d.ts.map +1 -1
  15. package/dist/hooks/use-auth.js +2 -5
  16. package/dist/hooks/use-auth.js.map +1 -1
  17. package/dist/hooks/use-variant-selection.d.ts.map +1 -1
  18. package/dist/hooks/use-variant-selection.js +12 -1
  19. package/dist/hooks/use-variant-selection.js.map +1 -1
  20. package/dist/lib/medusa-client.d.ts.map +1 -1
  21. package/dist/lib/medusa-client.js +1 -30
  22. package/dist/lib/medusa-client.js.map +1 -1
  23. package/dist/lib/redirects.d.ts +5 -13
  24. package/dist/lib/redirects.d.ts.map +1 -1
  25. package/dist/lib/redirects.js +9 -68
  26. package/dist/lib/redirects.js.map +1 -1
  27. package/dist/lib/seo.d.ts +7 -20
  28. package/dist/lib/seo.d.ts.map +1 -1
  29. package/dist/lib/seo.js +29 -157
  30. package/dist/lib/seo.js.map +1 -1
  31. package/dist/lib/site-url.d.ts +0 -8
  32. package/dist/lib/site-url.d.ts.map +1 -1
  33. package/dist/lib/site-url.js +0 -18
  34. package/dist/lib/site-url.js.map +1 -1
  35. package/dist/lib/variant-selection.d.ts +7 -3
  36. package/dist/lib/variant-selection.d.ts.map +1 -1
  37. package/dist/lib/variant-selection.js +10 -5
  38. package/dist/lib/variant-selection.js.map +1 -1
  39. package/dist/next-config/index.d.ts +0 -31
  40. package/dist/next-config/index.d.ts.map +1 -1
  41. package/dist/next-config/index.js +1 -32
  42. package/dist/next-config/index.js.map +1 -1
  43. package/package.json +1 -5
  44. package/bin/checks/check-market-routes.mjs +0 -184
  45. package/dist/edge/market.d.ts +0 -45
  46. package/dist/edge/market.d.ts.map +0 -1
  47. package/dist/edge/market.js +0 -74
  48. package/dist/edge/market.js.map +0 -1
  49. package/dist/edge/url-map.d.ts +0 -57
  50. package/dist/edge/url-map.d.ts.map +0 -1
  51. package/dist/edge/url-map.js +0 -140
  52. package/dist/edge/url-map.js.map +0 -1
  53. package/dist/lib/market.d.ts +0 -176
  54. package/dist/lib/market.d.ts.map +0 -1
  55. package/dist/lib/market.js +0 -228
  56. package/dist/lib/market.js.map +0 -1
  57. package/dist/lib/visitor-free-routes.d.ts +0 -17
  58. package/dist/lib/visitor-free-routes.d.ts.map +0 -1
  59. package/dist/lib/visitor-free-routes.js +0 -31
  60. package/dist/lib/visitor-free-routes.js.map +0 -1
  61. package/dist/shell/market-link.d.ts +0 -18
  62. package/dist/shell/market-link.d.ts.map +0 -1
  63. package/dist/shell/market-link.js +0 -39
  64. package/dist/shell/market-link.js.map +0 -1
@@ -1,176 +0,0 @@
1
- /**
2
- * Market URLs (AMB-2174, Shopify's market web presences): a market can have its own URL, a subfolder of the
3
- * primary host (`/en-ca`), a subdomain (`ca.store.com`) or another domain (`store.ca`). Medusa owns the link and
4
- * serves it as the URL map (`GET /store/url-map`); the proxy resolves every request against it and rewrites a
5
- * page to the store's internal `app/[m]/` route, whose `m` segment is the market key:
6
- * - `_` for the root (no market URL),
7
- * - `en-ca` for a subfolder (its public prefix without the slash),
8
- * - `_<marketId>` for a subdomain or a domain.
9
- *
10
- * This file is pure (no I/O but `getStoreUrlMap`) and safe in the browser, the server and the edge.
11
- */
12
- /**
13
- * The request header that names the market of the URL. The proxy deletes any client copy and sets its own, on the
14
- * requests its matcher covers (`proxyConfig`): a path outside the matcher (`/api/*`, `/robots.txt`) carries whatever the
15
- * client sent, so code there never trusts it.
16
- */
17
- export declare const MARKET_HEADER = "x-amb-market";
18
- /**
19
- * The request header `marketProxy` sets on a market's file path (`/en-ca/x.pdf`, `/x.pdf` on a market host): the `[m]`
20
- * key of its market. A file no file answers reaches the catch-all under the root key (`marketFallbackRewrites`), whose
21
- * redirect lookup (`resolveUnmatchedPathRedirect`) takes the market from it. Like `MARKET_HEADER`, the proxy deletes
22
- * any client copy; a path its matcher skips can still carry one, so the lookup accepts only a key of the URL map.
23
- */
24
- export declare const MARKET_KEY_HEADER = "x-amb-market-key";
25
- /**
26
- * The build-time opt-in of a store on the `app/[m]/` tree (AMB-2174), set through `marketTreeEnv()` in its
27
- * next.config `env` (Next inlines it at build). Only such a store's server fetch shim skips the visitor read for the
28
- * visitor-independent store routes, and only its sitemaps and robots name market URLs (`lib/seo`); every other store
29
- * behaves as before.
30
- */
31
- export declare const MARKET_TREE_ENV = "AMBORAS_MARKET_TREE";
32
- /** Whether this build opted in (`MARKET_TREE_ENV`): the store's routes live under `app/[m]/`. */
33
- export declare function isMarketTreeBuild(): boolean;
34
- /** The status of a URL-map answer that means "this store API has no URL map" (an older Medusa), never a failure. */
35
- export declare function isNoUrlMapStatus(status: number): boolean;
36
- /** The `[m]` key of the root, i.e. every URL that belongs to no market. */
37
- export declare const ROOT_MARKET_KEY = "_";
38
- /** One market URL, as `GET /store/url-map` serves it. */
39
- export interface UrlMapPresence {
40
- marketId: string;
41
- kind: 'subfolder' | 'subdomain' | 'domain';
42
- /** '/en-ca' for a subfolder, null for a host. */
43
- path: string | null;
44
- /** 'ca.store.com' or 'store.ca' for a host presence, null for a subfolder. */
45
- host: string | null;
46
- status: 'active' | 'pending' | 'inactive';
47
- /** false: passive (backfilled, not turned on). It serves, but nothing points to it. */
48
- announced: boolean;
49
- /** Own countries plus those of descendant submarkets without a presence of their own. Sorted. Drives hreflang. */
50
- countries: string[];
51
- /** '/en-xx' paths that 301 to `path`. */
52
- previousPaths: string[];
53
- /**
54
- * '/<language>-<suffix>' paths that 301 here: each former default language of the store with the current and every
55
- * previous suffix (`/en-ca` and `/en-can` after en→de and can→ca). Medusa computes them; `[]` when the store never
56
- * changed its default language. A language that is only enabled is in none: `/fr-ca` is not a market URL.
57
- */
58
- languagePaths: string[];
59
- /**
60
- * How an inactive presence sends visitors to the root, decided by Medusa: `temporary` (302, whatever made it
61
- * inactive: a draft market, market URLs off, the market now the primary; each can be undone), null for no redirect
62
- * (an active or a passive presence, a draft subfolder without "send its URLs to the root"). The edge follows it.
63
- */
64
- inactiveRedirect: 'temporary' | null;
65
- /** Stable per store and never reused (1, 2, …): the presence's sitemap child slot. */
66
- ordinal: number;
67
- /**
68
- * The market's own region: `/store/products?region_id=` lists what this market sells (Medusa applies its product
69
- * exclusions), which is what its sitemap lists. null (no region, or a Medusa before the field): its sitemap lists no
70
- * product, and no product URL names it as an alternate.
71
- */
72
- regionId: string | null;
73
- }
74
- /**
75
- * `GET /store/url-map`, the fields the storefront reads. Medusa's own carry more that it does not need: `enabled`
76
- * (with market URLs off every presence comes back inactive with its `inactiveRedirect`), and per presence
77
- * `redirectWhenInactive` (folded into `inactiveRedirect`).
78
- */
79
- export interface StoreUrlMap {
80
- /** Hash of everything below; also the ETag. */
81
- version: string;
82
- hreflang: boolean;
83
- /** The store's default language, the `en` of `/en-ca`. */
84
- language: string;
85
- /** The primary market's countries, lowercase ISO 3166-1 alpha-2 (root hreflang and x-default). */
86
- rootCountries: string[];
87
- presences: UrlMapPresence[];
88
- }
89
- /**
90
- * The URL map in a body, or null when the body is not one. A presence this core cannot read (a kind or status added
91
- * after it shipped) is left out, not the whole map: a store pinned to an older core keeps every URL it knows. An
92
- * `inactiveRedirect` it does not know is no redirect; no `languagePaths` (a Medusa before them) is none, no `regionId` null.
93
- */
94
- export declare function parseStoreUrlMap(value: unknown): StoreUrlMap | null;
95
- /** The host presence (subdomain or domain, any status) serving `host`, or null. */
96
- export declare function presenceOfHost(map: StoreUrlMap | null, host: string | null): UrlMapPresence | null;
97
- /** A served market URL: the market is active and the merchant turned the URL on (a passive one points nowhere). */
98
- export declare function isAnnounced(presence: UrlMapPresence): boolean;
99
- /**
100
- * Whether `prefix` can be a market prefix (`/en-ca`). The `m` route param is request input: a path the proxy does not
101
- * rewrite (a static file) reaches `app/[m]/` with any first segment as `m` (`/%2F%2Fevil.com/x.png`), so nothing built
102
- * from it may become a protocol-relative URL. Every prefixing goes through this check.
103
- */
104
- export declare function isMarketPrefix(prefix: string): boolean;
105
- /**
106
- * The template's private pages: robots disallows them (under every announced subfolder too), and the cold-start 503
107
- * never takes their first segment for a market (`/kit-gallery` starts like one).
108
- */
109
- export declare const TEMPLATE_PRIVATE_PATHS: readonly string[];
110
- /**
111
- * Whether a cold instance (no map at all) should answer `/<segment>/…` with a 503 instead of the root's 404. A hint,
112
- * never a routing decision: with no map nothing here knows the store's market URLs, so a segment that starts like one
113
- * (`en-ca`, `fil-ph`) and is not one of the template's pages gets a 503 a crawler retries (it drops a 404).
114
- * `/kit-gallery` and `/products` are the root's; `/our-story` and `/new-in` start like one and 503 too, for those
115
- * seconds.
116
- */
117
- export declare function mayBeMarketSegment(segment: string): boolean;
118
- /** Whether `segment` is an internal key a public URL never has: `_` (the root) or `_<marketId>` (a market host). */
119
- export declare function isInternalKey(segment: string): boolean;
120
- /**
121
- * Whether `key` can be a market key: an internal key, or one safe segment the proxy rewrites (`en-ca`). A request
122
- * nothing rewrites into a market (`/api/missing.json`, a sitemap child that does not exist, `/icon/x`) can still
123
- * reach `app/[m]/` with its first segment as `m`: that segment is in `OUTSIDE_MARKET_TREE`, and the `[m]` layout
124
- * answers 404 for it. A missing file elsewhere is `marketFallbackRewrites`'s (`/_/<path>`, a merchant redirect).
125
- */
126
- export declare function isMarketKey(key: string): boolean;
127
- /**
128
- * The `[m]` layout's guard: the key when it is one, else Next's `notFound()`, passed in so this file stays free of
129
- * `next/navigation`. `const key = assertMarketKey(m, notFound)`.
130
- */
131
- export declare function assertMarketKey(key: string, notFound: () => never): string;
132
- /** '/en-ca' for 'en-ca'; '' for '_', '_<marketId>' and anything that is not a market key. */
133
- export declare function prefixOfKey(key: string): string;
134
- /** The `[m]` key a presence is served under: `en-ca` for the subfolder `/en-ca`, `_<marketId>` for a host. */
135
- export declare function keyOfPresence(presence: UrlMapPresence): string;
136
- /** The presence a `[m]` key names, or null (the root, or a key the map does not hold). */
137
- export declare function presenceOfKey(key: string, map: StoreUrlMap | null): UrlMapPresence | null;
138
- /** The `app/` folders served at the top: framework files, the public API, the sitemap children, `.well-known`. */
139
- export declare const TOP_LEVEL_FOLDERS: readonly string[];
140
- /** A file's extension at the end of a path (`.pdf`, `.webmanifest`), as a pattern. */
141
- export declare const FILE_EXTENSION = "\\.[A-Za-z0-9]{1,12}";
142
- /**
143
- * A path only a file answers (`/old.pdf`, `/en-ca/x.pdf`), as a pattern without its leading `/`: it ends in a file
144
- * extension, and its first segment neither starts with `_` (`_next`, an internal key) nor is a top-level folder, whose
145
- * routes stay theirs. What `marketFallbackRewrites` takes and `marketProxy` names the market of (`MARKET_KEY_HEADER`).
146
- */
147
- export declare const FILE_PATH: string;
148
- /**
149
- * THE list of URL paths served outside the store's `app/[m]/` tree, as patterns on the pathname. The proxy never
150
- * rewrites them into a market, `marketHref` never prefixes them and `amboras-check market-routes` keeps their route
151
- * files at the top of `app/` (and every other route file under `app/[m]/`). Everything `proxyConfig`'s matcher skips is
152
- * in it.
153
- */
154
- export declare const OUTSIDE_MARKET_TREE: readonly string[];
155
- /** Whether `pathname` is served outside `app/[m]/` (`OUTSIDE_MARKET_TREE`). */
156
- export declare function isOutsideMarketTree(pathname: string): boolean;
157
- /**
158
- * Prefixes an internal href with the market prefix (`/products/x` → `/en-ca/products/x`, `/` → `/en-ca`). Leaves
159
- * alone: an empty prefix or one that is not a market prefix (`isMarketPrefix`), absolute and protocol-relative URLs,
160
- * `#…`, `?…`, relative paths, `mailto:`/`tel:` and every other scheme, paths already under the prefix, and paths
161
- * outside the market tree (`/api/…`, static files).
162
- */
163
- export declare function marketHref(href: string, prefix: string): string;
164
- /** `getStoreUrlMap` could not read the map: Medusa failed (5xx, timeout) or answered a body that is not one. */
165
- export declare class StoreUrlMapUnavailableError extends Error {
166
- constructor(reason: string);
167
- }
168
- /**
169
- * The store's URL map, read on the server (layouts, sitemaps, robots) through the store API's data cache (30 s, as
170
- * Medusa's own memo). `null` only when the store API has no map (a 404 or 410: an older Medusa), today's behaviour,
171
- * every URL the root's. Anything else that is not a map (a 5xx, a timeout, a 401/403/429, a 2xx that is not one)
172
- * throws `StoreUrlMapUnavailableError`, as the edge copy treats it, so a sitemap or an ISR page is never cached with
173
- * root data while the map cannot be read.
174
- */
175
- export declare function getStoreUrlMap(): Promise<StoreUrlMap | null>;
176
- //# sourceMappingURL=market.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"market.d.ts","sourceRoot":"","sources":["../../src/lib/market.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH;;;;GAIG;AACH,eAAO,MAAM,aAAa,iBAAiB,CAAA;AAE3C;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,qBAAqB,CAAA;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,eAAe,wBAAwB,CAAA;AAEpD,iGAAiG;AACjG,wBAAgB,iBAAiB,IAAI,OAAO,CAG3C;AAED,oHAAoH;AACpH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,2EAA2E;AAC3E,eAAO,MAAM,eAAe,MAAM,CAAA;AAElC,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,WAAW,GAAG,WAAW,GAAG,QAAQ,CAAA;IAC1C,iDAAiD;IACjD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,8EAA8E;IAC9E,IAAI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MB-2174, Shopify's market web presences): a market can have its own URL, a subfolder of the
4
- * primary host (`/en-ca`), a subdomain (`ca.store.com`) or another domain (`store.ca`). Medusa owns the link and
5
- * serves it as the URL map (`GET /store/url-map`); the proxy resolves every request against it and rewrites a
6
- * page to the store's internal `app/[m]/` route, whose `m` segment is the market key:
7
- * - `_` for the root (no market URL),
8
- * - `en-ca` for a subfolder (its public prefix without the slash),
9
- * - `_<marketId>` for a subdomain or a domain.
10
- *
11
- * This file is pure (no I/O but `getStoreUrlMap`) and safe in the browser, the server and the edge.
12
- */
13
- /**
14
- * The request header that names the market of the URL. The proxy deletes any client copy and sets its own, on the
15
- * requests its matcher covers (`proxyConfig`): a path outside the matcher (`/api/*`, `/robots.txt`) carries whatever the
16
- * client sent, so code there never trusts it.
17
- */
18
- export const MARKET_HEADER = 'x-amb-market';
19
- /**
20
- * The request header `marketProxy` sets on a market's file path (`/en-ca/x.pdf`, `/x.pdf` on a market host): the `[m]`
21
- * key of its market. A file no file answers reaches the catch-all under the root key (`marketFallbackRewrites`), whose
22
- * redirect lookup (`resolveUnmatchedPathRedirect`) takes the market from it. Like `MARKET_HEADER`, the proxy deletes
23
- * any client copy; a path its matcher skips can still carry one, so the lookup accepts only a key of the URL map.
24
- */
25
- export const MARKET_KEY_HEADER = 'x-amb-market-key';
26
- /**
27
- * The build-time opt-in of a store on the `app/[m]/` tree (AMB-2174), set through `marketTreeEnv()` in its
28
- * next.config `env` (Next inlines it at build). Only such a store's server fetch shim skips the visitor read for the
29
- * visitor-independent store routes, and only its sitemaps and robots name market URLs (`lib/seo`); every other store
30
- * behaves as before.
31
- */
32
- export const MARKET_TREE_ENV = 'AMBORAS_MARKET_TREE';
33
- /** Whether this build opted in (`MARKET_TREE_ENV`): the store's routes live under `app/[m]/`. */
34
- export function isMarketTreeBuild() {
35
- // A literal `process.env.X` read: Next inlines the next.config `env` value at build.
36
- return process.env.AMBORAS_MARKET_TREE === '1';
37
- }
38
- /** The status of a URL-map answer that means "this store API has no URL map" (an older Medusa), never a failure. */
39
- export function isNoUrlMapStatus(status) {
40
- return status === 404 || status === 410;
41
- }
42
- /** The `[m]` key of the root, i.e. every URL that belongs to no market. */
43
- export const ROOT_MARKET_KEY = '_';
44
- const isStringArray = (value) => Array.isArray(value) && value.every((v) => typeof v === 'string');
45
- const isNullableString = (value) => value === null || typeof value === 'string';
46
- function isPresence(value) {
47
- if (!value || typeof value !== 'object')
48
- return false;
49
- const p = value;
50
- return (typeof p.marketId === 'string' &&
51
- (p.kind === 'subfolder' || p.kind === 'subdomain' || p.kind === 'domain') &&
52
- isNullableString(p.path) &&
53
- isNullableString(p.host) &&
54
- (p.status === 'active' || p.status === 'pending' || p.status === 'inactive') &&
55
- typeof p.announced === 'boolean' &&
56
- isStringArray(p.countries) &&
57
- isStringArray(p.previousPaths) &&
58
- Number.isInteger(p.ordinal));
59
- }
60
- /**
61
- * The URL map in a body, or null when the body is not one. A presence this core cannot read (a kind or status added
62
- * after it shipped) is left out, not the whole map: a store pinned to an older core keeps every URL it knows. An
63
- * `inactiveRedirect` it does not know is no redirect; no `languagePaths` (a Medusa before them) is none, no `regionId` null.
64
- */
65
- export function parseStoreUrlMap(value) {
66
- if (!value || typeof value !== 'object')
67
- return null;
68
- const m = value;
69
- if (typeof m.version !== 'string' || typeof m.hreflang !== 'boolean' || typeof m.language !== 'string')
70
- return null;
71
- if (!isStringArray(m.rootCountries) || !Array.isArray(m.presences))
72
- return null;
73
- const presences = m.presences.filter(isPresence).map((p) => ({
74
- ...p,
75
- inactiveRedirect: p.inactiveRedirect === 'temporary' ? 'temporary' : null,
76
- languagePaths: isStringArray(p.languagePaths) ? p.languagePaths : [],
77
- regionId: typeof p.regionId === 'string' && p.regionId ? p.regionId : null,
78
- }));
79
- return { version: m.version, hreflang: m.hreflang, language: m.language, rootCountries: m.rootCountries, presences };
80
- }
81
- /** The host presence (subdomain or domain, any status) serving `host`, or null. */
82
- export function presenceOfHost(map, host) {
83
- return (host && map?.presences.find((p) => p.kind !== 'subfolder' && p.host === host)) || null;
84
- }
85
- /** A served market URL: the market is active and the merchant turned the URL on (a passive one points nowhere). */
86
- export function isAnnounced(presence) {
87
- return presence.status === 'active' && presence.announced;
88
- }
89
- /**
90
- * One lowercase path segment (`en-ca`): the only shape a public market key can have here. A SAFETY check on request
91
- * input, never the market URL rule, which is Medusa's alone (the map's paths are what it allowed): no slash or
92
- * backslash, so nothing built from it becomes a protocol-relative URL, and no `_` or `.` (the internal keys, files).
93
- */
94
- const SAFE_SEGMENT_RE = /^[a-z0-9-]+$/;
95
- /**
96
- * Whether `prefix` can be a market prefix (`/en-ca`). The `m` route param is request input: a path the proxy does not
97
- * rewrite (a static file) reaches `app/[m]/` with any first segment as `m` (`/%2F%2Fevil.com/x.png`), so nothing built
98
- * from it may become a protocol-relative URL. Every prefixing goes through this check.
99
- */
100
- export function isMarketPrefix(prefix) {
101
- return prefix.startsWith('/') && SAFE_SEGMENT_RE.test(prefix.slice(1));
102
- }
103
- /**
104
- * The template's private pages: robots disallows them (under every announced subfolder too), and the cold-start 503
105
- * never takes their first segment for a market (`/kit-gallery` starts like one).
106
- */
107
- export const TEMPLATE_PRIVATE_PATHS = ['/cart', '/checkout', '/account', '/auth', '/search', '/kit-gallery'];
108
- /** A segment that starts with a BCP 47 language subtag and a hyphen (`en-`, `fil-`), as every subfolder does. */
109
- const LANGUAGE_LED_RE = /^[a-z]{2,3}-/;
110
- /**
111
- * Whether a cold instance (no map at all) should answer `/<segment>/…` with a 503 instead of the root's 404. A hint,
112
- * never a routing decision: with no map nothing here knows the store's market URLs, so a segment that starts like one
113
- * (`en-ca`, `fil-ph`) and is not one of the template's pages gets a 503 a crawler retries (it drops a 404).
114
- * `/kit-gallery` and `/products` are the root's; `/our-story` and `/new-in` start like one and 503 too, for those
115
- * seconds.
116
- */
117
- export function mayBeMarketSegment(segment) {
118
- return LANGUAGE_LED_RE.test(segment) && SAFE_SEGMENT_RE.test(segment) && !TEMPLATE_PRIVATE_PATHS.includes(`/${segment}`);
119
- }
120
- /** Whether `segment` is an internal key a public URL never has: `_` (the root) or `_<marketId>` (a market host). */
121
- export function isInternalKey(segment) {
122
- return segment === ROOT_MARKET_KEY || /^_[0-9a-z-]+$/i.test(segment);
123
- }
124
- /**
125
- * Whether `key` can be a market key: an internal key, or one safe segment the proxy rewrites (`en-ca`). A request
126
- * nothing rewrites into a market (`/api/missing.json`, a sitemap child that does not exist, `/icon/x`) can still
127
- * reach `app/[m]/` with its first segment as `m`: that segment is in `OUTSIDE_MARKET_TREE`, and the `[m]` layout
128
- * answers 404 for it. A missing file elsewhere is `marketFallbackRewrites`'s (`/_/<path>`, a merchant redirect).
129
- */
130
- export function isMarketKey(key) {
131
- return isInternalKey(key) || (SAFE_SEGMENT_RE.test(key) && !isOutsideMarketTree(`/${key}`));
132
- }
133
- /**
134
- * The `[m]` layout's guard: the key when it is one, else Next's `notFound()`, passed in so this file stays free of
135
- * `next/navigation`. `const key = assertMarketKey(m, notFound)`.
136
- */
137
- export function assertMarketKey(key, notFound) {
138
- return isMarketKey(key) ? key : notFound();
139
- }
140
- /** '/en-ca' for 'en-ca'; '' for '_', '_<marketId>' and anything that is not a market key. */
141
- export function prefixOfKey(key) {
142
- const prefix = `/${key}`;
143
- return isMarketKey(key) && isMarketPrefix(prefix) ? prefix : '';
144
- }
145
- /** The `[m]` key a presence is served under: `en-ca` for the subfolder `/en-ca`, `_<marketId>` for a host. */
146
- export function keyOfPresence(presence) {
147
- return presence.kind === 'subfolder' && presence.path ? presence.path.slice(1) : `_${presence.marketId}`;
148
- }
149
- /** The presence a `[m]` key names, or null (the root, or a key the map does not hold). */
150
- export function presenceOfKey(key, map) {
151
- return map?.presences.find((p) => keyOfPresence(p) === key) ?? null;
152
- }
153
- /** The `app/` folders served at the top: framework files, the public API, the sitemap children, `.well-known`. */
154
- export const TOP_LEVEL_FOLDERS = ['_next', 'api', 'sitemaps', '\\.well-known'];
155
- /** A file's extension at the end of a path (`.pdf`, `.webmanifest`), as a pattern. */
156
- export const FILE_EXTENSION = '\\.[A-Za-z0-9]{1,12}';
157
- /**
158
- * A path only a file answers (`/old.pdf`, `/en-ca/x.pdf`), as a pattern without its leading `/`: it ends in a file
159
- * extension, and its first segment neither starts with `_` (`_next`, an internal key) nor is a top-level folder, whose
160
- * routes stay theirs. What `marketFallbackRewrites` takes and `marketProxy` names the market of (`MARKET_KEY_HEADER`).
161
- */
162
- export const FILE_PATH = `(?!_|${TOP_LEVEL_FOLDERS.filter((folder) => !folder.startsWith('_'))
163
- .map((folder) => `${folder}/`)
164
- .join('|')})(?:[^/]+/)*[^/]*${FILE_EXTENSION}`;
165
- // OUTSIDE_MARKET_TREE stays an array of plain string literals: the orchestrator vendors it by reading
166
- // dist/lib/market.js's syntax tree (sync-storefront-core-manifest.ts). A spec checks it agrees with the two above.
167
- /**
168
- * THE list of URL paths served outside the store's `app/[m]/` tree, as patterns on the pathname. The proxy never
169
- * rewrites them into a market, `marketHref` never prefixes them and `amboras-check market-routes` keeps their route
170
- * files at the top of `app/` (and every other route file under `app/[m]/`). Everything `proxyConfig`'s matcher skips is
171
- * in it.
172
- */
173
- export const OUTSIDE_MARKET_TREE = [
174
- // Framework files, the public API, the sitemap children, `.well-known` (an Apple Pay domain file, a route there).
175
- '^/(?:_next|api|sitemaps|\\.well-known)(?:/|$)',
176
- // Metadata images at the app root: Next serves them from there only (nested under `[m]` their URL doubles the prefix).
177
- '^/(?:icon|apple-icon|opengraph-image|twitter-image)\\d*(?:\\.[A-Za-z0-9]+)?(?:/|$)',
178
- // A file: anything from `public/` (`/media/x.jpg`, `google<id>.html`, `BingSiteAuth.xml`), robots.txt, sitemap.xml,
179
- // the manifest, `/llms.txt`, a route with an extension (`/pinterest/feed.xml`).
180
- '\\.[A-Za-z0-9]{1,12}$',
181
- ];
182
- const OUTSIDE_MARKET_TREE_RE = new RegExp(OUTSIDE_MARKET_TREE.join('|'));
183
- /** Whether `pathname` is served outside `app/[m]/` (`OUTSIDE_MARKET_TREE`). */
184
- export function isOutsideMarketTree(pathname) {
185
- return OUTSIDE_MARKET_TREE_RE.test(pathname);
186
- }
187
- /**
188
- * Prefixes an internal href with the market prefix (`/products/x` → `/en-ca/products/x`, `/` → `/en-ca`). Leaves
189
- * alone: an empty prefix or one that is not a market prefix (`isMarketPrefix`), absolute and protocol-relative URLs,
190
- * `#…`, `?…`, relative paths, `mailto:`/`tel:` and every other scheme, paths already under the prefix, and paths
191
- * outside the market tree (`/api/…`, static files).
192
- */
193
- export function marketHref(href, prefix) {
194
- if (!isMarketPrefix(prefix) || !href.startsWith('/') || /^\/[/\\]/.test(href))
195
- return href;
196
- const path = href.split(/[?#]/, 1)[0];
197
- if (path === prefix || path.startsWith(`${prefix}/`) || isOutsideMarketTree(path))
198
- return href;
199
- return path === '/' ? prefix + href.slice(1) : prefix + href;
200
- }
201
- /** `getStoreUrlMap` could not read the map: Medusa failed (5xx, timeout) or answered a body that is not one. */
202
- export class StoreUrlMapUnavailableError extends Error {
203
- constructor(reason) {
204
- super(`Medusa /store/url-map failed: ${reason}`);
205
- this.name = 'StoreUrlMapUnavailableError';
206
- }
207
- }
208
- /**
209
- * The store's URL map, read on the server (layouts, sitemaps, robots) through the store API's data cache (30 s, as
210
- * Medusa's own memo). `null` only when the store API has no map (a 404 or 410: an older Medusa), today's behaviour,
211
- * every URL the root's. Anything else that is not a map (a 5xx, a timeout, a 401/403/429, a 2xx that is not one)
212
- * throws `StoreUrlMapUnavailableError`, as the edge copy treats it, so a sitemap or an ISR page is never cached with
213
- * root data while the map cannot be read.
214
- */
215
- export async function getStoreUrlMap() {
216
- const result = await storeGetJsonStrict('/store/url-map', { revalidate: 30 });
217
- if (result.kind === 'miss' && isNoUrlMapStatus(result.status))
218
- return null;
219
- if (result.kind === 'miss')
220
- throw new StoreUrlMapUnavailableError(`HTTP ${result.status}`);
221
- if (result.kind === 'failure')
222
- throw new StoreUrlMapUnavailableError(result.reason);
223
- const map = parseStoreUrlMap(result.data);
224
- if (!map)
225
- throw new StoreUrlMapUnavailableError('not a URL map');
226
- return map;
227
- }
228
- //# sourceMappingURL=market.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"market.js","sourceRoot":"","sources":["../../src/lib/market.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAEnD;;;;;;;;;;GAUG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,kBAAkB,CAAA;AAEnD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,qBAAqB,CAAA;AAEpD,iGAAiG;AACjG,MAAM,UAAU,iBAAiB;IAC/B,qFAAqF;IACrF,OAAO,OAAO,CAAC,GAAG,CAAC,mBAAmB,KAAK,GAAG,CAAA;AAChD,CAAC;AAED,oHAAoH;AACpH,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,OAAO,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,CAAA;AACzC,CAAC;AAED,2EAA2E;AAC3E,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAA;AAuDlC,MAAM,aAAa,GAAG,CAAC,KAAc,EAAqB,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAA;AAC9H,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAA0B,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAA;AAKhH,SAAS,UAAU,CAAC,KAAc;IAChC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IACrD,MAAM,CAAC,GAAG,KAAgC,CAAA;IAC1C,OAAO,CACL,OAAO,CAAC,CAAC,QAAQ,KAA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QAAE,MAAM,IAAI,2BAA2B,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACnF,MAAM,GAAG,GAAG,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACzC,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,2BAA2B,CAAC,eAAe,CAAC,CAAA;IAChE,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -1,17 +0,0 @@
1
- /**
2
- * The store routes whose GET/HEAD answer is the same for every visitor (AMB-2174): THE list, read by the server fetch
3
- * shim (`lib/medusa-client.ts`, which then forwards no visitor cookie or header for them) and imported by Medusa's
4
- * mirror spec (medusa-backend-orchestrator `src/api/store/visitor-independent-routes.spec.ts`), which proves each one
5
- * never reads the visitor. An ALLOWLIST of exactly the shapes core calls: a `:name` segment is one path segment, named
6
- * as Medusa's route folder (`[blog]`). Any route not here keeps the visitor.
7
- *
8
- * Proven by Medusa for each: the `/store/*` middlewares read visitor headers only for products, search, regions and
9
- * product extensions (carts have their own); each route here computes its answer from the store alone
10
- * (`checkout-settings` reads a `?cart_id=` cart's own country, never the visitor's). Not here, so per visitor:
11
- * products, search, regions, product extensions, carts, customers, orders, and `/store/collections`, which leaves out
12
- * products excluded in the shopper's market.
13
- *
14
- * Plain data, no imports: a CommonJS consumer can load it as it is.
15
- */
16
- export declare const VISITOR_FREE_ROUTES: readonly string[];
17
- //# sourceMappingURL=visitor-free-routes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"visitor-free-routes.d.ts","sourceRoot":"","sources":["../../src/lib/visitor-free-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAchD,CAAA"}
@@ -1,31 +0,0 @@
1
- /**
2
- * The store routes whose GET/HEAD answer is the same for every visitor (AMB-2174): THE list, read by the server fetch
3
- * shim (`lib/medusa-client.ts`, which then forwards no visitor cookie or header for them) and imported by Medusa's
4
- * mirror spec (medusa-backend-orchestrator `src/api/store/visitor-independent-routes.spec.ts`), which proves each one
5
- * never reads the visitor. An ALLOWLIST of exactly the shapes core calls: a `:name` segment is one path segment, named
6
- * as Medusa's route folder (`[blog]`). Any route not here keeps the visitor.
7
- *
8
- * Proven by Medusa for each: the `/store/*` middlewares read visitor headers only for products, search, regions and
9
- * product extensions (carts have their own); each route here computes its answer from the store alone
10
- * (`checkout-settings` reads a `?cart_id=` cart's own country, never the visitor's). Not here, so per visitor:
11
- * products, search, regions, product extensions, carts, customers, orders, and `/store/collections`, which leaves out
12
- * products excluded in the shopper's market.
13
- *
14
- * Plain data, no imports: a CommonJS consumer can load it as it is.
15
- */
16
- export const VISITOR_FREE_ROUTES = [
17
- '/store/url-map',
18
- '/store/url-redirects',
19
- '/store/content/blogs',
20
- '/store/content/blogs/:blog/articles',
21
- '/store/content/blogs/:blog/articles/:handle',
22
- '/store/content/blogs/:blog/articles/:handle/comments',
23
- '/store/metaobjects/:type',
24
- '/store/metaobjects/:type/:handle',
25
- '/store/config',
26
- '/store/brand',
27
- '/store/integrations/active',
28
- '/store/policies',
29
- '/store/checkout-settings',
30
- ];
31
- //# sourceMappingURL=visitor-free-routes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"visitor-free-routes.js","sourceRoot":"","sources":["../../src/lib/visitor-free-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsB;IACpD,gBAAgB;IAChB,sBAAsB;IACtB,sBAAsB;IACtB,qCAAqC;IACrC,6CAA6C;IAC7C,sDAAsD;IACtD,0BAA0B;IAC1B,kCAAkC;IAClC,eAAe;IACf,cAAc;IACd,4BAA4B;IAC5B,iBAAiB;IACjB,0BAA0B;CAC3B,CAAA"}
@@ -1,18 +0,0 @@
1
- import Link from 'next/link';
2
- import { type ComponentProps, type JSX } from 'react';
3
- /**
4
- * Links that stay in the visitor's market (AMB-2174). On the `app/[m]/` tree the `m` route param is the market key,
5
- * so `/products/x` on a `/en-ca` page links to `/en-ca/products/x`. A store tree without `[m]` links unchanged.
6
- */
7
- /** Client: `marketHref` bound to the page's market prefix (from `useParams().m`). */
8
- export declare function useMarketHref(): (href: string) => string;
9
- /**
10
- * Client: the PUBLIC pathname, what the address bar shows (`/checkout`, `/en-ca/products/x`), on the server and in the
11
- * browser alike. `usePathname()` gives the internal one while the server renders a rewritten page (`/_/checkout`)
12
- * and the public one in the browser, so its output differs between the two and hydration fails: use this instead
13
- * on the `app/[m]/` tree. A subfolder's prefix is kept (it is part of the public path); `prefixOfKey(m)` strips it.
14
- */
15
- export declare function useMarketPathname(): string;
16
- /** `next/link` with `marketHref` applied to its href (a string, or a URL object's `pathname`). */
17
- export declare function MarketLink(props: ComponentProps<typeof Link>): JSX.Element;
18
- //# sourceMappingURL=market-link.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"market-link.d.ts","sourceRoot":"","sources":["../../src/shell/market-link.tsx"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAe,KAAK,cAAc,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAA;AAGlE;;;GAGG;AAEH,qFAAqF;AACrF,wBAAgB,aAAa,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAIxD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAO1C;AAED,kGAAkG;AAClG,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,IAAI,CAAC,GAAG,GAAG,CAAC,OAAO,CAK1E"}
@@ -1,39 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import Link from 'next/link';
4
- import { useParams, usePathname } from 'next/navigation';
5
- import { useCallback } from 'react';
6
- import { marketHref, prefixOfKey, ROOT_MARKET_KEY } from '../lib/market.js';
7
- /**
8
- * Links that stay in the visitor's market (AMB-2174). On the `app/[m]/` tree the `m` route param is the market key,
9
- * so `/products/x` on a `/en-ca` page links to `/en-ca/products/x`. A store tree without `[m]` links unchanged.
10
- */
11
- /** Client: `marketHref` bound to the page's market prefix (from `useParams().m`). */
12
- export function useMarketHref() {
13
- const params = useParams();
14
- const prefix = prefixOfKey(typeof params?.m === 'string' ? params.m : ROOT_MARKET_KEY);
15
- return useCallback((href) => marketHref(href, prefix), [prefix]);
16
- }
17
- /**
18
- * Client: the PUBLIC pathname, what the address bar shows (`/checkout`, `/en-ca/products/x`), on the server and in the
19
- * browser alike. `usePathname()` gives the internal one while the server renders a rewritten page (`/_/checkout`)
20
- * and the public one in the browser, so its output differs between the two and hydration fails: use this instead
21
- * on the `app/[m]/` tree. A subfolder's prefix is kept (it is part of the public path); `prefixOfKey(m)` strips it.
22
- */
23
- export function useMarketPathname() {
24
- const pathname = usePathname() ?? '/';
25
- const params = useParams();
26
- const key = typeof params?.m === 'string' ? params.m : null;
27
- // Only the root and host keys (`_`, `_<marketId>`) are not in the public path.
28
- if (!key?.startsWith('_') || (pathname !== `/${key}` && !pathname.startsWith(`/${key}/`)))
29
- return pathname;
30
- return pathname.slice(key.length + 1) || '/';
31
- }
32
- /** `next/link` with `marketHref` applied to its href (a string, or a URL object's `pathname`). */
33
- export function MarketLink(props) {
34
- const toHref = useMarketHref();
35
- const { href } = props;
36
- const inMarket = typeof href === 'string' ? toHref(href) : href.pathname ? { ...href, pathname: toHref(href.pathname) } : href;
37
- return _jsx(Link, { ...props, href: inMarket });
38
- }
39
- //# sourceMappingURL=market-link.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"market-link.js","sourceRoot":"","sources":["../../src/shell/market-link.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAiC,MAAM,OAAO,CAAA;AAClE,OAAO,EAAE,UAAU,EAAE,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