@sixtyninecommerce/client 0.29.0 → 0.31.0

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 (358) hide show
  1. package/README.md +556 -16
  2. package/dist/admin/http.d.ts.map +1 -1
  3. package/dist/admin/http.js.map +1 -1
  4. package/dist/admin/types.d.ts.map +1 -1
  5. package/dist/build-client.d.ts +9 -0
  6. package/dist/build-client.d.ts.map +1 -0
  7. package/dist/build-client.js +58 -0
  8. package/dist/build-client.js.map +1 -0
  9. package/dist/cache-tags.d.ts +35 -1
  10. package/dist/cache-tags.d.ts.map +1 -1
  11. package/dist/cache-tags.js +39 -1
  12. package/dist/cache-tags.js.map +1 -1
  13. package/dist/client.d.ts +25 -0
  14. package/dist/client.d.ts.map +1 -1
  15. package/dist/client.js +9 -62
  16. package/dist/client.js.map +1 -1
  17. package/dist/commerce/age-verification.d.ts +7 -4
  18. package/dist/commerce/age-verification.d.ts.map +1 -1
  19. package/dist/commerce/age-verification.js +6 -4
  20. package/dist/commerce/age-verification.js.map +1 -1
  21. package/dist/commerce/arguments.d.ts +13 -0
  22. package/dist/commerce/arguments.d.ts.map +1 -0
  23. package/dist/commerce/arguments.js +19 -0
  24. package/dist/commerce/arguments.js.map +1 -0
  25. package/dist/commerce/branding.d.ts.map +1 -1
  26. package/dist/commerce/branding.js.map +1 -1
  27. package/dist/commerce/capabilities.d.ts +40 -0
  28. package/dist/commerce/capabilities.d.ts.map +1 -0
  29. package/dist/commerce/capabilities.js +41 -0
  30. package/dist/commerce/capabilities.js.map +1 -0
  31. package/dist/commerce/cart.d.ts +9 -12
  32. package/dist/commerce/cart.d.ts.map +1 -1
  33. package/dist/commerce/cart.js +6 -1
  34. package/dist/commerce/cart.js.map +1 -1
  35. package/dist/commerce/checkout.d.ts +95 -15
  36. package/dist/commerce/checkout.d.ts.map +1 -1
  37. package/dist/commerce/checkout.js +230 -10
  38. package/dist/commerce/checkout.js.map +1 -1
  39. package/dist/commerce/customer.d.ts +82 -38
  40. package/dist/commerce/customer.d.ts.map +1 -1
  41. package/dist/commerce/customer.js +146 -10
  42. package/dist/commerce/customer.js.map +1 -1
  43. package/dist/commerce/favorites.d.ts +2 -5
  44. package/dist/commerce/favorites.d.ts.map +1 -1
  45. package/dist/commerce/favorites.js.map +1 -1
  46. package/dist/commerce/index.d.ts +189 -133
  47. package/dist/commerce/index.d.ts.map +1 -1
  48. package/dist/commerce/index.js +9 -0
  49. package/dist/commerce/index.js.map +1 -1
  50. package/dist/commerce/order-states.d.ts +18 -0
  51. package/dist/commerce/order-states.d.ts.map +1 -0
  52. package/dist/commerce/order-states.js +30 -0
  53. package/dist/commerce/order-states.js.map +1 -0
  54. package/dist/commerce/parcel-pricing.d.ts +48 -0
  55. package/dist/commerce/parcel-pricing.d.ts.map +1 -0
  56. package/dist/commerce/parcel-pricing.js +39 -0
  57. package/dist/commerce/parcel-pricing.js.map +1 -0
  58. package/dist/commerce/parked-orders.d.ts +22 -0
  59. package/dist/commerce/parked-orders.d.ts.map +1 -0
  60. package/dist/commerce/parked-orders.js +47 -0
  61. package/dist/commerce/parked-orders.js.map +1 -0
  62. package/dist/commerce/payments.d.ts +12 -5
  63. package/dist/commerce/payments.d.ts.map +1 -1
  64. package/dist/commerce/payments.js +10 -1
  65. package/dist/commerce/payments.js.map +1 -1
  66. package/dist/commerce/placement-error.d.ts +17 -0
  67. package/dist/commerce/placement-error.d.ts.map +1 -1
  68. package/dist/commerce/placement-error.js.map +1 -1
  69. package/dist/commerce/products.d.ts +92 -38
  70. package/dist/commerce/products.d.ts.map +1 -1
  71. package/dist/commerce/products.js +162 -123
  72. package/dist/commerce/products.js.map +1 -1
  73. package/dist/commerce/queries.d.ts +204 -49
  74. package/dist/commerce/queries.d.ts.map +1 -1
  75. package/dist/commerce/queries.js +1296 -737
  76. package/dist/commerce/queries.js.map +1 -1
  77. package/dist/commerce/quotes.d.ts +5 -4
  78. package/dist/commerce/quotes.d.ts.map +1 -1
  79. package/dist/commerce/quotes.js +1 -36
  80. package/dist/commerce/quotes.js.map +1 -1
  81. package/dist/commerce/recommendations.d.ts +3 -3
  82. package/dist/commerce/recommendations.d.ts.map +1 -1
  83. package/dist/commerce/recommendations.js +3 -1
  84. package/dist/commerce/recommendations.js.map +1 -1
  85. package/dist/commerce/returns.d.ts +7 -6
  86. package/dist/commerce/returns.d.ts.map +1 -1
  87. package/dist/commerce/returns.js.map +1 -1
  88. package/dist/commerce/reviews.d.ts +24 -15
  89. package/dist/commerce/reviews.d.ts.map +1 -1
  90. package/dist/commerce/reviews.js +67 -50
  91. package/dist/commerce/reviews.js.map +1 -1
  92. package/dist/commerce/saved-lists.d.ts +15 -15
  93. package/dist/commerce/saved-lists.d.ts.map +1 -1
  94. package/dist/commerce/saved-lists.js +67 -55
  95. package/dist/commerce/saved-lists.js.map +1 -1
  96. package/dist/commerce/search.d.ts +3 -2
  97. package/dist/commerce/search.d.ts.map +1 -1
  98. package/dist/commerce/search.js +10 -2
  99. package/dist/commerce/search.js.map +1 -1
  100. package/dist/commerce/shipping.d.ts +11 -4
  101. package/dist/commerce/shipping.d.ts.map +1 -1
  102. package/dist/commerce/shipping.js +17 -2
  103. package/dist/commerce/shipping.js.map +1 -1
  104. package/dist/commerce/stock-notifications.d.ts +2 -0
  105. package/dist/commerce/stock-notifications.d.ts.map +1 -1
  106. package/dist/commerce/stock-notifications.js +2 -2
  107. package/dist/commerce/stock-notifications.js.map +1 -1
  108. package/dist/commerce/subscriptions.d.ts +35 -37
  109. package/dist/commerce/subscriptions.d.ts.map +1 -1
  110. package/dist/commerce/subscriptions.js +159 -120
  111. package/dist/commerce/subscriptions.js.map +1 -1
  112. package/dist/commerce/vat-validation.d.ts +6 -3
  113. package/dist/commerce/vat-validation.d.ts.map +1 -1
  114. package/dist/commerce/vat-validation.js +24 -19
  115. package/dist/commerce/vat-validation.js.map +1 -1
  116. package/dist/constants.d.ts.map +1 -1
  117. package/dist/constants.js.map +1 -1
  118. package/dist/content/assets.d.ts +5 -4
  119. package/dist/content/assets.d.ts.map +1 -1
  120. package/dist/content/assets.js.map +1 -1
  121. package/dist/content/collection-pages.d.ts +3 -2
  122. package/dist/content/collection-pages.d.ts.map +1 -1
  123. package/dist/content/collection-pages.js.map +1 -1
  124. package/dist/content/collections.d.ts +5 -4
  125. package/dist/content/collections.d.ts.map +1 -1
  126. package/dist/content/collections.js.map +1 -1
  127. package/dist/content/filtered-products.d.ts.map +1 -1
  128. package/dist/content/filtered-products.js.map +1 -1
  129. package/dist/content/form-field-types.d.ts +3 -3
  130. package/dist/content/form-field-types.d.ts.map +1 -1
  131. package/dist/content/form-field-types.js.map +1 -1
  132. package/dist/content/forms.d.ts +4 -3
  133. package/dist/content/forms.d.ts.map +1 -1
  134. package/dist/content/forms.js +3 -0
  135. package/dist/content/forms.js.map +1 -1
  136. package/dist/content/index.d.ts +18 -17
  137. package/dist/content/index.d.ts.map +1 -1
  138. package/dist/content/items.d.ts +5 -4
  139. package/dist/content/items.d.ts.map +1 -1
  140. package/dist/content/items.js +2 -0
  141. package/dist/content/items.js.map +1 -1
  142. package/dist/content/menus.d.ts +3 -2
  143. package/dist/content/menus.d.ts.map +1 -1
  144. package/dist/content/menus.js +7 -1
  145. package/dist/content/menus.js.map +1 -1
  146. package/dist/content/resolve.d.ts +3 -2
  147. package/dist/content/resolve.d.ts.map +1 -1
  148. package/dist/content/resolve.js +1 -1
  149. package/dist/content/resolve.js.map +1 -1
  150. package/dist/content/sitemap.d.ts +3 -2
  151. package/dist/content/sitemap.d.ts.map +1 -1
  152. package/dist/content/sitemap.js.map +1 -1
  153. package/dist/content/strings.d.ts +16 -2
  154. package/dist/content/strings.d.ts.map +1 -1
  155. package/dist/content/strings.js +32 -4
  156. package/dist/content/strings.js.map +1 -1
  157. package/dist/core/context.d.ts +127 -1
  158. package/dist/core/context.d.ts.map +1 -1
  159. package/dist/core/context.js +436 -45
  160. package/dist/core/context.js.map +1 -1
  161. package/dist/core/currency.d.ts +14 -0
  162. package/dist/core/currency.d.ts.map +1 -0
  163. package/dist/core/currency.js +52 -0
  164. package/dist/core/currency.js.map +1 -0
  165. package/dist/core/deprecation.d.ts +23 -0
  166. package/dist/core/deprecation.d.ts.map +1 -0
  167. package/dist/core/deprecation.js +81 -0
  168. package/dist/core/deprecation.js.map +1 -0
  169. package/dist/core/http.d.ts +15 -1
  170. package/dist/core/http.d.ts.map +1 -1
  171. package/dist/core/http.js +55 -3
  172. package/dist/core/http.js.map +1 -1
  173. package/dist/core/public-artifact.d.ts +72 -0
  174. package/dist/core/public-artifact.d.ts.map +1 -0
  175. package/dist/core/public-artifact.js +122 -0
  176. package/dist/core/public-artifact.js.map +1 -0
  177. package/dist/core/unknown-field-rejection.d.ts +18 -0
  178. package/dist/core/unknown-field-rejection.d.ts.map +1 -0
  179. package/dist/core/unknown-field-rejection.js +37 -0
  180. package/dist/core/unknown-field-rejection.js.map +1 -0
  181. package/dist/credit/credit-status.d.ts +2 -0
  182. package/dist/credit/credit-status.d.ts.map +1 -1
  183. package/dist/credit/credit-status.js +71 -19
  184. package/dist/credit/credit-status.js.map +1 -1
  185. package/dist/credit/index.d.ts +1 -1
  186. package/dist/credit/payment-terms.d.ts +3 -3
  187. package/dist/credit/payment-terms.d.ts.map +1 -1
  188. package/dist/credit/payment-terms.js +28 -24
  189. package/dist/credit/payment-terms.js.map +1 -1
  190. package/dist/currency/exchange.d.ts +7 -7
  191. package/dist/currency/exchange.d.ts.map +1 -1
  192. package/dist/currency/exchange.js +5 -1
  193. package/dist/currency/exchange.js.map +1 -1
  194. package/dist/errors.d.ts +17 -0
  195. package/dist/errors.d.ts.map +1 -1
  196. package/dist/errors.js +13 -0
  197. package/dist/errors.js.map +1 -1
  198. package/dist/events/index.d.ts +20 -7
  199. package/dist/events/index.d.ts.map +1 -1
  200. package/dist/events/index.js +17 -5
  201. package/dist/events/index.js.map +1 -1
  202. package/dist/events/payloads.d.ts +7 -4
  203. package/dist/events/payloads.d.ts.map +1 -1
  204. package/dist/events/payloads.js +6 -3
  205. package/dist/events/payloads.js.map +1 -1
  206. package/dist/feeds/index.d.ts +5 -0
  207. package/dist/feeds/index.d.ts.map +1 -0
  208. package/dist/feeds/index.js +12 -0
  209. package/dist/feeds/index.js.map +1 -0
  210. package/dist/feeds/types.d.ts +18 -0
  211. package/dist/feeds/types.d.ts.map +1 -0
  212. package/dist/feeds/types.js +8 -0
  213. package/dist/feeds/types.js.map +1 -0
  214. package/dist/generated/cms.d.ts +2136 -0
  215. package/dist/generated/cms.d.ts.map +1 -0
  216. package/dist/generated/cms.js +4 -0
  217. package/dist/generated/cms.js.map +1 -0
  218. package/dist/generated/plugins.d.ts +550 -0
  219. package/dist/generated/plugins.d.ts.map +1 -0
  220. package/dist/generated/plugins.js +4 -0
  221. package/dist/generated/plugins.js.map +1 -0
  222. package/dist/generated/shop.d.ts +5539 -0
  223. package/dist/generated/shop.d.ts.map +1 -0
  224. package/dist/generated/shop.js +5 -0
  225. package/dist/generated/shop.js.map +1 -0
  226. package/dist/graphql-document.d.ts +29 -0
  227. package/dist/graphql-document.d.ts.map +1 -0
  228. package/dist/graphql-document.js +21 -0
  229. package/dist/graphql-document.js.map +1 -0
  230. package/dist/index.d.ts +9 -4
  231. package/dist/index.d.ts.map +1 -1
  232. package/dist/index.js +4 -2
  233. package/dist/index.js.map +1 -1
  234. package/dist/media/urls.d.ts.map +1 -1
  235. package/dist/media/urls.js +12 -1
  236. package/dist/media/urls.js.map +1 -1
  237. package/dist/media/video.d.ts.map +1 -1
  238. package/dist/media/video.js.map +1 -1
  239. package/dist/multi-store.d.ts +200 -0
  240. package/dist/multi-store.d.ts.map +1 -0
  241. package/dist/multi-store.js +558 -0
  242. package/dist/multi-store.js.map +1 -0
  243. package/dist/navigation/routes.d.ts +4 -3
  244. package/dist/navigation/routes.d.ts.map +1 -1
  245. package/dist/navigation/routes.js.map +1 -1
  246. package/dist/next/artifact-handler.d.ts +21 -13
  247. package/dist/next/artifact-handler.d.ts.map +1 -1
  248. package/dist/next/artifact-handler.js +28 -66
  249. package/dist/next/artifact-handler.js.map +1 -1
  250. package/dist/next/event-revalidate-handler.d.ts +26 -6
  251. package/dist/next/event-revalidate-handler.d.ts.map +1 -1
  252. package/dist/next/event-revalidate-handler.js +126 -19
  253. package/dist/next/event-revalidate-handler.js.map +1 -1
  254. package/dist/next/feed-handler.d.ts +50 -0
  255. package/dist/next/feed-handler.d.ts.map +1 -0
  256. package/dist/next/feed-handler.js +61 -0
  257. package/dist/next/feed-handler.js.map +1 -0
  258. package/dist/next/index.d.ts +3 -1
  259. package/dist/next/index.d.ts.map +1 -1
  260. package/dist/next/index.js +1 -0
  261. package/dist/next/index.js.map +1 -1
  262. package/dist/next/metadata.d.ts.map +1 -1
  263. package/dist/next/metadata.js.map +1 -1
  264. package/dist/next/redirect-middleware.d.ts +5 -31
  265. package/dist/next/redirect-middleware.d.ts.map +1 -1
  266. package/dist/next/redirect-middleware.js +4 -46
  267. package/dist/next/redirect-middleware.js.map +1 -1
  268. package/dist/next/revalidate-handler.d.ts.map +1 -1
  269. package/dist/next/revalidate-handler.js.map +1 -1
  270. package/dist/pricing/index.d.ts +1 -1
  271. package/dist/pricing/index.d.ts.map +1 -1
  272. package/dist/pricing/index.js +5 -2
  273. package/dist/pricing/index.js.map +1 -1
  274. package/dist/pricing/tax-display.js +1 -1
  275. package/dist/pricing/tax-display.js.map +1 -1
  276. package/dist/pricing/tiers.d.ts +3 -2
  277. package/dist/pricing/tiers.d.ts.map +1 -1
  278. package/dist/pricing/tiers.js.map +1 -1
  279. package/dist/pricing/validation.d.ts +152 -13
  280. package/dist/pricing/validation.d.ts.map +1 -1
  281. package/dist/pricing/validation.js +167 -13
  282. package/dist/pricing/validation.js.map +1 -1
  283. package/dist/redirects/index.d.ts.map +1 -1
  284. package/dist/redirects/index.js +2 -1
  285. package/dist/redirects/index.js.map +1 -1
  286. package/dist/redirects/store.d.ts.map +1 -1
  287. package/dist/redirects/store.js +6 -2
  288. package/dist/redirects/store.js.map +1 -1
  289. package/dist/redirects/types.d.ts +5 -2
  290. package/dist/redirects/types.d.ts.map +1 -1
  291. package/dist/revalidation/event-plan.d.ts +55 -4
  292. package/dist/revalidation/event-plan.d.ts.map +1 -1
  293. package/dist/revalidation/event-plan.js +115 -8
  294. package/dist/revalidation/event-plan.js.map +1 -1
  295. package/dist/revalidation/event-verify.d.ts +8 -37
  296. package/dist/revalidation/event-verify.d.ts.map +1 -1
  297. package/dist/revalidation/event-verify.js +7 -97
  298. package/dist/revalidation/event-verify.js.map +1 -1
  299. package/dist/revalidation/types.d.ts.map +1 -1
  300. package/dist/revalidation/url-context.d.ts +17 -0
  301. package/dist/revalidation/url-context.d.ts.map +1 -1
  302. package/dist/revalidation/url-context.js +35 -2
  303. package/dist/revalidation/url-context.js.map +1 -1
  304. package/dist/seo/ai.d.ts.map +1 -1
  305. package/dist/seo/ai.js.map +1 -1
  306. package/dist/seo/artifacts.d.ts +86 -4
  307. package/dist/seo/artifacts.d.ts.map +1 -1
  308. package/dist/seo/artifacts.js +115 -16
  309. package/dist/seo/artifacts.js.map +1 -1
  310. package/dist/seo/availability.d.ts +95 -0
  311. package/dist/seo/availability.d.ts.map +1 -0
  312. package/dist/seo/availability.js +89 -0
  313. package/dist/seo/availability.js.map +1 -0
  314. package/dist/seo/index.d.ts +4 -0
  315. package/dist/seo/index.d.ts.map +1 -1
  316. package/dist/seo/index.js +6 -1
  317. package/dist/seo/index.js.map +1 -1
  318. package/dist/seo/json-ld.d.ts.map +1 -1
  319. package/dist/seo/json-ld.js +34 -1
  320. package/dist/seo/json-ld.js.map +1 -1
  321. package/dist/seo/meta-tags.d.ts +40 -1
  322. package/dist/seo/meta-tags.d.ts.map +1 -1
  323. package/dist/seo/meta-tags.js +8 -1
  324. package/dist/seo/meta-tags.js.map +1 -1
  325. package/dist/seo/metadata-parser.d.ts.map +1 -1
  326. package/dist/seo/metadata-parser.js.map +1 -1
  327. package/dist/seo/metadata-types.d.ts.map +1 -1
  328. package/dist/seo/robots.d.ts.map +1 -1
  329. package/dist/seo/robots.js.map +1 -1
  330. package/dist/seo/types.d.ts +20 -2
  331. package/dist/seo/types.d.ts.map +1 -1
  332. package/dist/seo/url-builder.d.ts +5 -3
  333. package/dist/seo/url-builder.d.ts.map +1 -1
  334. package/dist/seo/url-builder.js +3 -1
  335. package/dist/seo/url-builder.js.map +1 -1
  336. package/dist/types.d.ts +1306 -2429
  337. package/dist/types.d.ts.map +1 -1
  338. package/dist/web/artifact-responder.d.ts +69 -0
  339. package/dist/web/artifact-responder.d.ts.map +1 -0
  340. package/dist/web/artifact-responder.js +90 -0
  341. package/dist/web/artifact-responder.js.map +1 -0
  342. package/dist/web/feed-responder.d.ts +72 -0
  343. package/dist/web/feed-responder.d.ts.map +1 -0
  344. package/dist/web/feed-responder.js +81 -0
  345. package/dist/web/feed-responder.js.map +1 -0
  346. package/dist/web/index.d.ts +23 -0
  347. package/dist/web/index.d.ts.map +1 -0
  348. package/dist/web/index.js +19 -0
  349. package/dist/web/index.js.map +1 -0
  350. package/dist/web/redirect-middleware.d.ts +76 -0
  351. package/dist/web/redirect-middleware.d.ts.map +1 -0
  352. package/dist/web/redirect-middleware.js +94 -0
  353. package/dist/web/redirect-middleware.js.map +1 -0
  354. package/dist/web/respond.d.ts +20 -0
  355. package/dist/web/respond.d.ts.map +1 -0
  356. package/dist/web/respond.js +52 -0
  357. package/dist/web/respond.js.map +1 -0
  358. package/package.json +19 -3
@@ -1,10 +1,241 @@
1
- import { createChannelResolver, PlatformError, } from '@sixtyninecommerce/core';
1
+ import { assertConditionalReadsOption, createChannelResolver, isBrowserRuntime, PlatformError, STOREFRONT_TOKEN_PREFIX, } from '@sixtyninecommerce/core';
2
2
  import { DEFAULT_CMS_URL, DEFAULT_PLUGINS_URL, DEFAULT_VENDURE_URL, INIT_TIMEOUT_MS, } from '../constants.js';
3
3
  import { StorefrontError, toStorefrontError } from '../errors.js';
4
+ import { CURRENCY_CODE_PATTERN } from './currency.js';
5
+ import { assertDeprecationHook, endpointDeprecationHook, methodDeprecationReporter, } from './deprecation.js';
4
6
  export async function createStoreContext(config) {
7
+ // FIRST, before anything reaches the network: a private token in a page is a
8
+ // token every visitor holds, and the refusal must not depend on the CMS being
9
+ // up (spec §15.21).
10
+ assertPrivateTokenConfig(config);
5
11
  if (!config.storeCode) {
6
12
  throw new StorefrontError('storeCode is required', 'cms');
7
13
  }
14
+ const endpoints = readClientEndpoints(config);
15
+ assertCustomerToken(config.customerToken);
16
+ assertCurrencyCode(config.currencyCode);
17
+ assertHeadKey(config.head, 'head');
18
+ assertDeprecationHook(config.onDeprecation);
19
+ // One resolver for the life of the client, shared with the transport: it
20
+ // caches the channel, collapses concurrent resolutions into one request, and
21
+ // — the reason it is not just this one startup call — can go BACK to the CMS
22
+ // when a request is refused with CHANNEL_NOT_FOUND, so a channel whose token
23
+ // rotated under a running storefront heals itself instead of failing until
24
+ // the process restarts (spec §6.2, §15.1).
25
+ const resolver = createClientChannelResolver(endpoints);
26
+ // Single startup roundtrip — the CMS /channels/by-code/:code endpoint now
27
+ // also returns custom_fields (proxied from Vendure with a server-side cache).
28
+ const startup = await resolveCoreChannel(resolver, config.storeCode, endpoints.cmsUrl);
29
+ // The store's code can move under a running client (a rename keeps the old one answering for
30
+ // a while). The follower is what the context's `channel` reads, and what the transport
31
+ // resolves through, so the first answer under the new code switches everything over.
32
+ const follower = createRenameFollower(resolver, config.storeCode, startup, renameReporter(config.onStoreRenamed));
33
+ const channels = follower.channels;
34
+ const onEndpointDeprecation = endpointDeprecationHook(config.onDeprecation);
35
+ const ctx = assembleStoreContext(endpoints, follower.current(), channels, {
36
+ languageCode: config.defaultLanguageCode,
37
+ currencyCode: config.currencyCode,
38
+ authToken: config.customerToken,
39
+ privateToken: config.privateToken,
40
+ buyerIp: config.buyerIp,
41
+ orderScope: config.orderScope,
42
+ head: config.head,
43
+ onAuthToken: config.onAuthToken,
44
+ onAuthExpired: config.onAuthExpired,
45
+ onAuthCleared: config.onAuthCleared,
46
+ }, {
47
+ ...(onEndpointDeprecation ? { onDeprecation: onEndpointDeprecation } : {}),
48
+ reportDeprecatedMethod: methodDeprecationReporter(config.onDeprecation),
49
+ });
50
+ // A getter over the follower: every reader — the transport's tenant, the feed and sitemap
51
+ // URLs, the asset-path prefix, the cache tags — sees the store's CURRENT code. No setter
52
+ // (`StoreContext.channel` is readonly); configurable, so a test double can still redefine it.
53
+ Object.defineProperty(ctx, 'channel', {
54
+ get: () => follower.current(),
55
+ enumerable: true,
56
+ configurable: true,
57
+ });
58
+ return ctx;
59
+ }
60
+ /**
61
+ * Who hears that a store was renamed. A configured `onStoreRenamed` is called once per client
62
+ * for each rename and may not throw into a request; without one the client warns ONCE PER
63
+ * PROCESS for each rename (several clients of one store in one process say it once).
64
+ * `audience` picks the warning: a single-store client follows the new code, a store router
65
+ * keeps the code `resolveStore` names.
66
+ *
67
+ * `instance` tells occurrences of the same pair of codes apart. A single-store client reports
68
+ * only when it actually switches, so it passes the alias's `renamedAt` (stamped afresh on every
69
+ * alias row the CMS writes): a rename undone, submitted again and undone again is heard each
70
+ * time. A router reports on every request that reaches an old code and never switches, so it
71
+ * passes the window's end, which a rewritten row keeps. A switch-back ("no longer answers") is
72
+ * never swallowed by another client's warning: a client says it whenever IT goes back, since
73
+ * its last word must not name a dead code.
74
+ */
75
+ export function renameReporter(onStoreRenamed, audience = 'client') {
76
+ const told = new Set();
77
+ return (rename, instance) => {
78
+ const key = [
79
+ rename.previousCode,
80
+ rename.code,
81
+ rename.previousCodeGone ? 'gone' : 'renamed',
82
+ instance,
83
+ ].join('\u0000');
84
+ if (onStoreRenamed) {
85
+ if (told.has(key))
86
+ return;
87
+ told.add(key);
88
+ const failed = (error) => {
89
+ console.warn(`[@sixtyninecommerce/client] the onStoreRenamed handler threw for "${rename.previousCode}" -> "${rename.code}"`, error);
90
+ };
91
+ try {
92
+ // An async handler's rejection is caught too: left alone it is an unhandled rejection,
93
+ // which ends a Node process.
94
+ void Promise.resolve(onStoreRenamed(rename)).catch(failed);
95
+ }
96
+ catch (error) {
97
+ failed(error);
98
+ }
99
+ return;
100
+ }
101
+ const warned = `${audience}\u0000${key}`;
102
+ if (WARNED_RENAMES.has(warned) && !rename.previousCodeGone)
103
+ return;
104
+ WARNED_RENAMES.add(warned);
105
+ console.warn(renameWarning(rename, audience));
106
+ };
107
+ }
108
+ /** Process-wide: the default warning is said once per rename, however many clients see it. */
109
+ const WARNED_RENAMES = new Set();
110
+ /**
111
+ * What the default reporter says. The end is the exact instant, in UTC: the old code stops at
112
+ * the rename's time of day, and a bare date reads as "through that day" in every zone.
113
+ */
114
+ export function renameWarning(rename, audience = 'client') {
115
+ const { previousCode: from, code: to } = rename;
116
+ if (rename.previousCodeGone) {
117
+ return `[@sixtyninecommerce/client] Store code "${from}" no longer answers; this client found the store under "${to}" by itself. Configure storeCode: "${to}".`;
118
+ }
119
+ const until = rename.previousCodeUntil
120
+ ? `until ${rename.previousCodeUntil} (UTC) only`
121
+ : 'for a limited time only';
122
+ const head = `[@sixtyninecommerce/client] Store "${from}" was renamed to "${to}".`;
123
+ if (audience === 'router') {
124
+ return `${head} This router serves "${from}" as that store while "${from}" still answers, ${until}; after that "${from}" finds no store, or another store that takes the code, in this process too. Update resolveStore (and any stores / privateToken entries) to "${to}".`;
125
+ }
126
+ return `${head} This client switched to "${to}" by itself; "${from}" keeps answering ${until}. Configure storeCode: "${to}".`;
127
+ }
128
+ /** Which rename an old-code answer belongs to (see {@link renameReporter}). */
129
+ export function renameInstance(info) {
130
+ return info.renamedAt ?? info.previousCodeUntil ?? '';
131
+ }
132
+ /**
133
+ * The store's current channel, following renames.
134
+ *
135
+ * `code` is the code the client now uses; it starts as whatever the startup answer carried (the
136
+ * new code already, when the client was configured with an old one). The wrapped resolver
137
+ * watches every answer for THAT code: one that names a different code is the platform
138
+ * answering an old code for its renamed store, and from then on the client asks under the new
139
+ * code — so it keeps working after the old one stops answering. Answers for any other code
140
+ * (a call already in flight under the old one) change nothing.
141
+ *
142
+ * The record moves ONLY on such a switch, never on a TTL re-read of the same code: a re-read can
143
+ * be the CMS's degraded answer (empty custom fields while its Vendure call fails), and the
144
+ * startup snapshot is what `ctx.channel` always was. The transport does not read the token from
145
+ * here; it resolves `ctx.channel.code` through `channels`, so a rotated token still heals.
146
+ *
147
+ * A switch is undone only when the new code stops answering while the code it came from
148
+ * answers as the SAME channel (see `fallBack`).
149
+ */
150
+ function createRenameFollower(inner, configuredCode, startup, report) {
151
+ let code = configuredCode;
152
+ let record = toChannelInfo(startup);
153
+ /** The codes this client switched away from, the latest last. */
154
+ const left = [];
155
+ const observe = (asked, info) => {
156
+ if (asked !== code || info.code === asked)
157
+ return;
158
+ left.push(asked);
159
+ code = info.code;
160
+ // An alias answer is the CMS's proven one: it follows an alias only after Vendure confirmed
161
+ // a storefront, so its custom fields are real.
162
+ record = toChannelInfo(info);
163
+ report({
164
+ previousCode: asked,
165
+ code: info.code,
166
+ ...(info.previousCodeUntil ? { previousCodeUntil: info.previousCodeUntil } : {}),
167
+ }, renameInstance(info));
168
+ };
169
+ observe(configuredCode, startup);
170
+ // The code this client switched to is gone. A rename that failed after its CMS step answered
171
+ // the old code under the new one for seconds, then put the old code back: without this the
172
+ // client would ask for the dead code until restarted. Ask the code it switched from once more,
173
+ // and take the answer ONLY when it is the same channel — by now that code may name another
174
+ // store. Otherwise the original refusal stands.
175
+ const fallBack = async (dead, refusal) => {
176
+ const from = left.at(-1);
177
+ if (from === undefined)
178
+ throw refusal;
179
+ inner.invalidate(from);
180
+ const info = await inner.resolve(from).catch(() => {
181
+ throw refusal;
182
+ });
183
+ if (info.id !== record.id)
184
+ throw refusal;
185
+ // Two requests refused at once both get here: the first moved the client, the second only
186
+ // needs the answer to retry with.
187
+ if (code !== dead)
188
+ return info;
189
+ if (info.code === from)
190
+ left.pop();
191
+ // Per client, the undo of the switch the record came from.
192
+ const undone = renameInstance(record);
193
+ code = info.code;
194
+ // Only the identity moves. An exact-code answer carries no proof the CMS reached Vendure
195
+ // (its degraded answer has empty custom fields), and the store's settings did not change
196
+ // with its code.
197
+ const { previousCode: _code, renamedAt: _at, previousCodeUntil: _until, ...settings } = record;
198
+ record = {
199
+ ...settings,
200
+ code: info.code,
201
+ token: info.token,
202
+ ...(info.previousCode !== undefined ? { previousCode: info.previousCode } : {}),
203
+ ...(info.renamedAt !== undefined ? { renamedAt: info.renamedAt } : {}),
204
+ ...(info.previousCodeUntil !== undefined
205
+ ? { previousCodeUntil: info.previousCodeUntil }
206
+ : {}),
207
+ };
208
+ report({ previousCode: dead, code: info.code, previousCodeGone: true }, undone);
209
+ return info;
210
+ };
211
+ return {
212
+ channels: {
213
+ async resolve(asked) {
214
+ let info;
215
+ try {
216
+ info = await inner.resolve(asked);
217
+ }
218
+ catch (error) {
219
+ const gone = error instanceof PlatformError && error.code === 'CHANNEL_NOT_FOUND';
220
+ if (!gone || asked !== code)
221
+ throw error;
222
+ return fallBack(asked, error);
223
+ }
224
+ observe(asked, info);
225
+ return info;
226
+ },
227
+ invalidate(asked) {
228
+ inner.invalidate(asked);
229
+ },
230
+ },
231
+ current: () => record,
232
+ };
233
+ }
234
+ /**
235
+ * Validate and normalise the parts of a config every store shares. Throws the
236
+ * same refusals, in the same order, a single-store client always has.
237
+ */
238
+ export function readClientEndpoints(config) {
8
239
  if (!config.cdnUrl) {
9
240
  throw new StorefrontError('cdnUrl is required', 'cms');
10
241
  }
@@ -13,53 +244,172 @@ export async function createStoreContext(config) {
13
244
  typeof config.cacheTags !== 'function') {
14
245
  throw new StorefrontError('cacheTags must be true, false or a resolver function', 'cms');
15
246
  }
247
+ try {
248
+ assertConditionalReadsOption(config.conditionalReads);
249
+ }
250
+ catch (error) {
251
+ throw toStorefrontError(error, 'cms');
252
+ }
16
253
  const fetchFn = config.fetch ?? globalThis.fetch;
17
- const cdnUrl = config.cdnUrl.replace(/\/+$/, '');
18
- const vendureUrl = (config.vendureUrl ?? DEFAULT_VENDURE_URL).replace(/\/+$/, '');
19
- const cmsUrl = (config.cmsUrl ?? DEFAULT_CMS_URL).replace(/\/+$/, '');
20
- const pluginsUrl = (config.pluginsUrl ?? DEFAULT_PLUGINS_URL).replace(/\/+$/, '');
21
- // One resolver for the life of the client, shared with the transport: it
22
- // caches the channel, collapses concurrent resolutions into one request, and
23
- // — the reason it is not just this one startup call — can go BACK to the CMS
24
- // when a request is refused with CHANNEL_NOT_FOUND, so a channel whose token
25
- // rotated under a running storefront heals itself instead of failing until
26
- // the process restarts (spec §6.2, §15.1).
27
- const channels = staleIfError(createChannelResolver({
28
- cmsUrl,
254
+ return {
29
255
  fetch: fetchFn,
256
+ cdnUrl: config.cdnUrl.replace(/\/+$/, ''),
257
+ vendureUrl: (config.vendureUrl ?? DEFAULT_VENDURE_URL).replace(/\/+$/, ''),
258
+ cmsUrl: (config.cmsUrl ?? DEFAULT_CMS_URL).replace(/\/+$/, ''),
259
+ pluginsUrl: (config.pluginsUrl ?? DEFAULT_PLUGINS_URL).replace(/\/+$/, ''),
260
+ retry: {
261
+ attempts: config.retry?.attempts ?? 2,
262
+ baseDelayMs: config.retry?.baseDelayMs ?? 200,
263
+ },
264
+ cacheTags: config.cacheTags ?? true,
265
+ conditionalReads: config.conditionalReads ?? !isNextPatchedFetch(fetchFn),
266
+ };
267
+ }
268
+ /** The CMS channel resolver a client's transports re-resolve through. */
269
+ export function createClientChannelResolver(endpoints) {
270
+ return staleIfError(createChannelResolver({
271
+ cmsUrl: endpoints.cmsUrl,
272
+ fetch: endpoints.fetch,
30
273
  timeoutMs: INIT_TIMEOUT_MS,
31
274
  }));
32
- // Single startup roundtrip — the CMS /channels/by-code/:code endpoint now
33
- // also returns custom_fields (proxied from Vendure with a server-side cache).
34
- const channel = await resolveChannel(channels, config.storeCode, cmsUrl);
275
+ }
276
+ /** The store's own CDN when its channel names one, else the configured CDN. */
277
+ export function cdnForChannel(channel, fallbackCdnUrl) {
35
278
  const rawCdnDomain = channel.customFields.cdnDomain;
36
279
  const channelCdnDomain = typeof rawCdnDomain === 'string' && rawCdnDomain.trim() !== '' ? rawCdnDomain.trim() : null;
280
+ return {
281
+ cdnUrl: channelCdnDomain ? `https://${channelCdnDomain}` : fallbackCdnUrl,
282
+ channelCdnDomain,
283
+ };
284
+ }
285
+ /**
286
+ * One request's context: the store's shared parts plus a NEW shopper half.
287
+ * Every field the modules write (`authToken`, `languageCode`, the session
288
+ * currency, `taxDisplay`, `orderScope`) lives on the object returned here and
289
+ * nowhere else, which is what keeps two requests from seeing each other's.
290
+ */
291
+ export function assembleStoreContext(endpoints, channel, channels, shopper, options) {
292
+ const { cdnUrl, channelCdnDomain } = cdnForChannel(channel, endpoints.cdnUrl);
37
293
  return {
38
294
  channel,
39
295
  channels,
40
- cdnUrl: channelCdnDomain ? `https://${channelCdnDomain}` : cdnUrl,
296
+ cdnUrl,
41
297
  channelCdnDomain,
42
- vendureUrl,
43
- cmsUrl,
44
- pluginsUrl,
45
- languageCode: config.defaultLanguageCode ?? channel.defaultLanguageCode,
46
- currencyCode: channel.defaultCurrencyCode,
298
+ vendureUrl: endpoints.vendureUrl,
299
+ cmsUrl: endpoints.cmsUrl,
300
+ pluginsUrl: endpoints.pluginsUrl,
301
+ languageCode: shopper.languageCode ?? channel.defaultLanguageCode,
302
+ currencyCode: shopper.currencyCode ?? channel.defaultCurrencyCode,
303
+ sessionCurrencyCode: shopper.currencyCode ?? null,
47
304
  pricesIncludeTax: channel.pricesIncludeTax,
48
- authToken: null,
305
+ authToken: shopper.authToken ?? null,
306
+ privateToken: shopper.privateToken ?? null,
307
+ buyerIp: shopper.buyerIp ?? null,
49
308
  // `null`, not a default of CONSUMER: a client that never opted into scopes
50
309
  // must send no header at all, so the engine keeps its legacy behaviour.
51
- orderScope: config.orderScope ?? null,
52
- fetch: fetchFn,
53
- onAuthToken: config.onAuthToken,
54
- onAuthExpired: config.onAuthExpired,
55
- onAuthCleared: config.onAuthCleared,
56
- retry: {
57
- attempts: config.retry?.attempts ?? 2,
58
- baseDelayMs: config.retry?.baseDelayMs ?? 200,
59
- },
60
- cacheTags: config.cacheTags ?? true,
310
+ orderScope: shopper.orderScope ?? null,
311
+ head: shopper.head ?? null,
312
+ fetch: endpoints.fetch,
313
+ onAuthToken: shopper.onAuthToken,
314
+ onAuthExpired: shopper.onAuthExpired,
315
+ onAuthCleared: shopper.onAuthCleared,
316
+ retry: { attempts: endpoints.retry.attempts, baseDelayMs: endpoints.retry.baseDelayMs },
317
+ cacheTags: endpoints.cacheTags,
318
+ conditionalReads: endpoints.conditionalReads,
319
+ ...(options?.storeScopedCacheTags ? { storeScopedCacheTags: true } : {}),
320
+ ...(options?.onDeprecation ? { onDeprecation: options.onDeprecation } : {}),
321
+ ...(options?.reportDeprecatedMethod
322
+ ? { reportDeprecatedMethod: options.reportDeprecatedMethod }
323
+ : {}),
61
324
  };
62
325
  }
326
+ /**
327
+ * A customer token, refused blank. Blank would silently build an ANONYMOUS
328
+ * client — the opposite of what the caller asked for, discovered only when the
329
+ * first cart call lands elsewhere.
330
+ */
331
+ export function assertCustomerToken(token) {
332
+ if (token !== undefined && token.trim() === '') {
333
+ throw new StorefrontError('customerToken must not be blank', 'vendure');
334
+ }
335
+ }
336
+ /** A session currency: three upper-case letters (the engine's `CurrencyCode`). */
337
+ export function assertCurrencyCode(currencyCode) {
338
+ if (currencyCode !== undefined && !CURRENCY_CODE_PATTERN.test(String(currencyCode))) {
339
+ throw new StorefrontError(`currencyCode "${String(currencyCode)}" is not an ISO 4217 code (three upper-case letters, e.g. "EUR")`, 'vendure', 400, 'INVALID_ARGUMENT');
340
+ }
341
+ }
342
+ /**
343
+ * A head key (`x-head`): the server's own key rule, kebab-case and at most 64
344
+ * characters (`services/vendure/src/heads/head-validation.ts`). Refused here
345
+ * rather than sent, because the server IGNORES a key it cannot use — a typo
346
+ * would silently mail every login link to the store's default head instead.
347
+ */
348
+ const HEAD_KEY_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
349
+ const MAX_HEAD_KEY_LENGTH = 64;
350
+ export function assertHeadKey(head, label) {
351
+ if (head === undefined)
352
+ return;
353
+ if (typeof head !== 'string' ||
354
+ head.length > MAX_HEAD_KEY_LENGTH ||
355
+ !HEAD_KEY_PATTERN.test(head)) {
356
+ throw new StorefrontError(`${label} must be a head key — lowercase letters, digits and single hyphens, at most ${String(MAX_HEAD_KEY_LENGTH)} characters (e.g. "web", "trade" or "native"); got ${JSON.stringify(head)}`, 'vendure', 400, 'INVALID_ARGUMENT');
357
+ }
358
+ }
359
+ /**
360
+ * Refuse a private token in a browser: a token a page holds is a token every
361
+ * visitor holds. Runs before anything reaches the network.
362
+ */
363
+ export function assertPrivateTokenRuntime() {
364
+ if (isBrowserRuntime()) {
365
+ throw new StorefrontError('A private storefront token must never be constructed in a browser — it would ship the credential to every visitor. Build this client on the server, or drop privateToken for a browser client.', 'vendure', 400, 'CREDENTIAL_IN_BROWSER');
366
+ }
367
+ }
368
+ /** A private token's SHAPE; whether it is live is the platform's answer. */
369
+ export function assertPrivateTokenShape(token) {
370
+ if (!token.startsWith(STOREFRONT_TOKEN_PREFIX)) {
371
+ throw new StorefrontError(`privateToken must be a private storefront token (${STOREFRONT_TOKEN_PREFIX}…), issued per head with admin.heads.privateTokens.issue.`, 'vendure', 400, 'INVALID_PRIVATE_TOKEN');
372
+ }
373
+ }
374
+ /** A buyer address is honoured only beside a private token, and never blank. */
375
+ export function assertBuyerIp(buyerIp, hasPrivateToken) {
376
+ if (buyerIp === undefined)
377
+ return;
378
+ if (!hasPrivateToken) {
379
+ throw new StorefrontError('buyerIp is honoured only beside a privateToken; without one the platform ignores it.', 'vendure', 400, 'BUYER_IP_WITHOUT_PRIVATE_TOKEN');
380
+ }
381
+ if (buyerIp.trim() === '') {
382
+ throw new StorefrontError('buyerIp must not be blank', 'vendure', 400, 'INVALID_BUYER_IP');
383
+ }
384
+ }
385
+ /**
386
+ * Is this Next.js's patched `fetch`? Next sets `__nextPatched` on it for exactly
387
+ * this question (`next/dist/server/lib/patch-fetch.js`: "for external consumers
388
+ * to determine if the fetch function has been patched").
389
+ *
390
+ * Conditional reads default OFF there: Next keys its data cache on the request
391
+ * headers and stores only 200s, so an added `If-None-Match` would turn each of
392
+ * Next's zero-request cache hits into a 304 round trip. A wrapper around Next's
393
+ * fetch does not carry the marker — the TSDoc tells that caller to pass `false`.
394
+ */
395
+ function isNextPatchedFetch(fetchFn) {
396
+ return (typeof fetchFn === 'function' && fetchFn.__nextPatched === true);
397
+ }
398
+ /**
399
+ * The private storefront token's configuration, refused at construction.
400
+ *
401
+ * Only the token's SHAPE is checked here — whether it is live is the platform's
402
+ * answer, and a revoked or foreign token simply earns no storefront budget.
403
+ * The buyer address is left to the platform too (`INVALID_BUYER_IP`): parsing
404
+ * IPv6 here would need a dependency this package does not take.
405
+ */
406
+ function assertPrivateTokenConfig(config) {
407
+ if (config.privateToken !== undefined) {
408
+ assertPrivateTokenRuntime();
409
+ assertPrivateTokenShape(config.privateToken);
410
+ }
411
+ assertBuyerIp(config.buyerIp, config.privateToken !== undefined);
412
+ }
63
413
  /**
64
414
  * Keep serving the channel we last resolved when the CMS cannot be reached.
65
415
  *
@@ -95,19 +445,46 @@ function cmsUnreachable(error) {
95
445
  // upgrading — serving a stale channel past either would hide it.
96
446
  return UNREACHABLE_CODES.has(error.code) || error.status >= 500;
97
447
  }
448
+ /**
449
+ * How many codes the fallback remembers. A single-store client uses one; a
450
+ * multi-store client one per store it has served — the cap only bounds a
451
+ * process that keeps resolving codes it never sees again.
452
+ */
453
+ const MAX_LAST_GOOD_CODES = 1024;
454
+ /**
455
+ * An answer for a renamed store's OLD code whose window has ended (or whose end is unreadable):
456
+ * the code may name another store now, so an outage must not keep serving it as this one.
457
+ */
458
+ function oldCodeLapsed(info) {
459
+ if (info.previousCode === undefined)
460
+ return false;
461
+ const until = info.previousCodeUntil ? Date.parse(info.previousCodeUntil) : Number.NaN;
462
+ return Number.isNaN(until) || until <= Date.now();
463
+ }
98
464
  function staleIfError(inner) {
99
- let lastGood;
465
+ // Keyed by CODE, never one slot: a multi-store client shares this resolver
466
+ // between its stores, and a single "last good" would answer store B's
467
+ // lookup with store A's channel — its token, its id — during a CMS outage.
468
+ const lastGood = new Map();
100
469
  return {
101
470
  async resolve(code) {
102
471
  try {
103
472
  const info = await inner.resolve(code);
104
- lastGood = info;
473
+ lastGood.delete(code);
474
+ lastGood.set(code, info);
475
+ if (lastGood.size > MAX_LAST_GOOD_CODES) {
476
+ const oldest = lastGood.keys().next().value;
477
+ if (oldest !== undefined)
478
+ lastGood.delete(oldest);
479
+ }
105
480
  return info;
106
481
  }
107
482
  catch (error) {
108
- if (lastGood === undefined || !cmsUnreachable(error))
483
+ const fallback = lastGood.get(code);
484
+ if (fallback === undefined || !cmsUnreachable(error) || oldCodeLapsed(fallback)) {
109
485
  throw error;
110
- return lastGood;
486
+ }
487
+ return fallback;
111
488
  }
112
489
  },
113
490
  invalidate(code) {
@@ -123,18 +500,21 @@ function staleIfError(inner) {
123
500
  * makes by hand, usually while wiring the SDK up for the first time, so the
124
501
  * three failures they are actually going to hit name the thing to check.
125
502
  */
126
- async function resolveChannel(channels, storeCode, cmsUrl) {
503
+ export async function resolveChannel(channels, storeCode, cmsUrl) {
504
+ return toChannelInfo(await resolveCoreChannel(channels, storeCode, cmsUrl));
505
+ }
506
+ /**
507
+ * {@link resolveChannel} without the reshaping: the resolver's own object, so
508
+ * a caller can tell by identity whether the answer changed since it last asked.
509
+ */
510
+ export async function resolveCoreChannel(channels, storeCode, cmsUrl) {
127
511
  try {
128
- const resolved = await channels.resolve(storeCode);
129
- // `core` types the bag as `Record<string, unknown>`; this package's
130
- // `ChannelCustomFields` names the keys it reads out of the same JSON.
131
- return { ...resolved, customFields: resolved.customFields };
512
+ return await channels.resolve(storeCode);
132
513
  }
133
514
  catch (error) {
134
515
  if (error instanceof PlatformError) {
135
- if (error.code === 'CHANNEL_NOT_FOUND') {
136
- throw new StorefrontError(`Store code "${storeCode}" not found. Check storeCode matches a channel code in the dashboard.`, 'cms', 404, error.code);
137
- }
516
+ if (error.code === 'CHANNEL_NOT_FOUND')
517
+ throw channelNotFound(storeCode);
138
518
  if (error.code === 'CHANNEL_RESOLUTION_TIMEOUT') {
139
519
  throw new StorefrontError(`Timed out connecting to CMS at ${cmsUrl}. Is the service running?`, 'cms', undefined, error.code);
140
520
  }
@@ -142,4 +522,15 @@ async function resolveChannel(channels, storeCode, cmsUrl) {
142
522
  throw toStorefrontError(error, 'cms');
143
523
  }
144
524
  }
525
+ /**
526
+ * `core` types the bag as `Record<string, unknown>` (it only checks it is an
527
+ * object); the generated `PublicChannelDto` names the keys the CMS sends.
528
+ */
529
+ export function toChannelInfo(resolved) {
530
+ return { ...resolved, customFields: resolved.customFields };
531
+ }
532
+ /** The refusal for a code that names no store this client may serve. */
533
+ export function channelNotFound(storeCode) {
534
+ return new StorefrontError(`Store code "${storeCode}" not found. Check storeCode matches a channel code in the dashboard — if the store was renamed, its old code stops answering a while after the rename: configure the new one.`, 'cms', 404, 'CHANNEL_NOT_FOUND');
535
+ }
145
536
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/core/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,qBAAqB,EACrB,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAQlE,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,MAA8B;IACrE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,eAAe,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,IAAI,eAAe,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC;IACD,IACE,MAAM,CAAC,SA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 +1,14 @@
1
+ import { StorefrontError } from '../errors.js';
2
+ /** ISO 4217 as the engine's `CurrencyCode` enum spells it: three upper-case letters. */
3
+ export declare const CURRENCY_CODE_PATTERN: RegExp;
4
+ /** The code a currency the store does not offer is refused with. */
5
+ export declare const CURRENCY_NOT_AVAILABLE = "CURRENCY_NOT_AVAILABLE";
6
+ /**
7
+ * The request carried a session currency the channel does not offer (a stale
8
+ * restored code, or a currency the merchant removed mid-session). `undefined`
9
+ * when `error` is something else.
10
+ */
11
+ export declare function sessionCurrencyRefusal(error: StorefrontError, sessionCurrencyCode: string): StorefrontError | undefined;
12
+ /** `setOrderCurrency(currencyCode)` was refused because the store does not offer it. */
13
+ export declare function orderCurrencyRefusal(error: StorefrontError, currencyCode: string): StorefrontError | undefined;
14
+ //# sourceMappingURL=currency.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../src/core/currency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,wFAAwF;AACxF,eAAO,MAAM,qBAAqB,QAAe,CAAC;AAElD,oEAAoE;AACpE,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAqC/D;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,eAAe,EACtB,mBAAmB,EAAE,MAAM,GAC1B,eAAe,GAAG,SAAS,CAU7B;AAED,wFAAwF;AACxF,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,eAAe,EACtB,YAAY,EAAE,MAAM,GACnB,eAAe,GAAG,SAAS,CAO7B"}
@@ -0,0 +1,52 @@
1
+ import { StorefrontError } from '../errors.js';
2
+ /** ISO 4217 as the engine's `CurrencyCode` enum spells it: three upper-case letters. */
3
+ export const CURRENCY_CODE_PATTERN = /^[A-Z]{3}$/;
4
+ /** The code a currency the store does not offer is refused with. */
5
+ export const CURRENCY_NOT_AVAILABLE = 'CURRENCY_NOT_AVAILABLE';
6
+ /**
7
+ * The engine's two "not offered" refusals, as they reach the client. Both are
8
+ * `USER_INPUT_ERROR`s whose message is an i18n key or its translation, so the
9
+ * test is on the key, and on the quoted code every translation interpolates:
10
+ *
11
+ * - `error.currency-not-available-in-channel` — `?currencyCode=` names a
12
+ * currency the channel does not offer (`RequestContextService`); refuses the
13
+ * whole request, whatever it asked for. Translated (`The currency "JPY" is
14
+ * not available in the current Channel`).
15
+ * - `error.currency-not-available` — `setCurrencyCodeForOrder` to such a
16
+ * currency (`OrderService.updateOrderCurrency`). No translation exists, so
17
+ * the raw key is the message.
18
+ */
19
+ function refusesCurrency(error, currencyCode, key) {
20
+ if (error.errorCode !== 'USER_INPUT_ERROR')
21
+ return false;
22
+ return error.message.includes(key) || error.message.includes(`"${currencyCode}"`);
23
+ }
24
+ /** `error` re-labelled `CURRENCY_NOT_AVAILABLE` with `message`, keeping everything else. */
25
+ function asCurrencyNotAvailable(error, message) {
26
+ return new StorefrontError(message, 'vendure', 400, CURRENCY_NOT_AVAILABLE, error.details, undefined, {
27
+ traceId: error.traceId,
28
+ problem: error.problem,
29
+ cause: error,
30
+ });
31
+ }
32
+ /**
33
+ * The request carried a session currency the channel does not offer (a stale
34
+ * restored code, or a currency the merchant removed mid-session). `undefined`
35
+ * when `error` is something else.
36
+ */
37
+ export function sessionCurrencyRefusal(error, sessionCurrencyCode) {
38
+ if (!refusesCurrency(error, sessionCurrencyCode, 'currency-not-available-in-channel')) {
39
+ return undefined;
40
+ }
41
+ return asCurrencyNotAvailable(error, `This store does not offer ${sessionCurrencyCode}, the currency this client was pricing in. ` +
42
+ "The client has gone back to the store's default currency: drop the stored currency and " +
43
+ 'retry the request.');
44
+ }
45
+ /** `setOrderCurrency(currencyCode)` was refused because the store does not offer it. */
46
+ export function orderCurrencyRefusal(error, currencyCode) {
47
+ if (!refusesCurrency(error, currencyCode, 'error.currency-not-available'))
48
+ return undefined;
49
+ return asCurrencyNotAvailable(error, `This store does not offer ${currencyCode}. Choose one of the currencies the store lists ` +
50
+ '(getActiveChannel().availableCurrencyCodes).');
51
+ }
52
+ //# sourceMappingURL=currency.js.map