@endora-commerce/contracts 0.107.0 → 0.109.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 (273) hide show
  1. package/dist/admin-actions.d.ts +12 -3
  2. package/dist/admin-actions.d.ts.map +1 -1
  3. package/dist/admin-actions.js +34 -3
  4. package/dist/admin-actions.js.map +1 -1
  5. package/dist/admin-contributions.d.ts +35 -6
  6. package/dist/admin-contributions.d.ts.map +1 -1
  7. package/dist/admin-contributions.js +46 -0
  8. package/dist/admin-contributions.js.map +1 -1
  9. package/dist/admin-feedback.d.ts +61 -0
  10. package/dist/admin-feedback.d.ts.map +1 -0
  11. package/dist/admin-feedback.js +71 -0
  12. package/dist/admin-feedback.js.map +1 -0
  13. package/dist/admin-name.d.ts +21 -0
  14. package/dist/admin-name.d.ts.map +1 -0
  15. package/dist/admin-name.js +30 -0
  16. package/dist/admin-name.js.map +1 -0
  17. package/dist/admin-notifications.d.ts +17 -1
  18. package/dist/admin-notifications.d.ts.map +1 -1
  19. package/dist/admin-preferences.d.ts +108 -0
  20. package/dist/admin-preferences.d.ts.map +1 -0
  21. package/dist/admin-preferences.js +133 -0
  22. package/dist/admin-preferences.js.map +1 -0
  23. package/dist/admin.d.ts +15 -1
  24. package/dist/admin.d.ts.map +1 -1
  25. package/dist/admin.js +7 -0
  26. package/dist/admin.js.map +1 -1
  27. package/dist/assets-library.d.ts +97 -3
  28. package/dist/assets-library.d.ts.map +1 -1
  29. package/dist/assets-library.js +5 -0
  30. package/dist/assets-library.js.map +1 -1
  31. package/dist/blog.d.ts +57 -0
  32. package/dist/blog.d.ts.map +1 -1
  33. package/dist/blog.js +63 -1
  34. package/dist/blog.js.map +1 -1
  35. package/dist/carts.d.ts +303 -50
  36. package/dist/carts.d.ts.map +1 -1
  37. package/dist/carts.js +95 -13
  38. package/dist/carts.js.map +1 -1
  39. package/dist/catalog.d.ts +512 -40
  40. package/dist/catalog.d.ts.map +1 -1
  41. package/dist/catalog.js +362 -23
  42. package/dist/catalog.js.map +1 -1
  43. package/dist/cms-brand.d.ts +2233 -0
  44. package/dist/cms-brand.d.ts.map +1 -0
  45. package/dist/cms-brand.js +311 -0
  46. package/dist/cms-brand.js.map +1 -0
  47. package/dist/cms-contact-form.d.ts +55 -0
  48. package/dist/cms-contact-form.d.ts.map +1 -0
  49. package/dist/cms-contact-form.js +100 -0
  50. package/dist/cms-contact-form.js.map +1 -0
  51. package/dist/cms.d.ts +537 -3
  52. package/dist/cms.d.ts.map +1 -1
  53. package/dist/cms.js +251 -0
  54. package/dist/cms.js.map +1 -1
  55. package/dist/common.d.ts +4 -0
  56. package/dist/common.d.ts.map +1 -1
  57. package/dist/common.js +14 -0
  58. package/dist/common.js.map +1 -1
  59. package/dist/comparisons.d.ts +7 -0
  60. package/dist/comparisons.d.ts.map +1 -1
  61. package/dist/comparisons.js +2 -0
  62. package/dist/comparisons.js.map +1 -1
  63. package/dist/credit-limits.d.ts.map +1 -1
  64. package/dist/credit-limits.js +3 -2
  65. package/dist/credit-limits.js.map +1 -1
  66. package/dist/crm-rich-text.d.ts +13 -0
  67. package/dist/crm-rich-text.d.ts.map +1 -0
  68. package/dist/crm-rich-text.js +13 -0
  69. package/dist/crm-rich-text.js.map +1 -0
  70. package/dist/crm.d.ts +180 -62
  71. package/dist/crm.d.ts.map +1 -1
  72. package/dist/crm.js +63 -107
  73. package/dist/crm.js.map +1 -1
  74. package/dist/custom-fields.d.ts +436 -5
  75. package/dist/custom-fields.d.ts.map +1 -1
  76. package/dist/custom-fields.js +325 -10
  77. package/dist/custom-fields.js.map +1 -1
  78. package/dist/customer-accounts.d.ts +30 -0
  79. package/dist/customer-accounts.d.ts.map +1 -1
  80. package/dist/customer-accounts.js +31 -0
  81. package/dist/customer-accounts.js.map +1 -1
  82. package/dist/document-templates.d.ts +211 -23
  83. package/dist/document-templates.d.ts.map +1 -1
  84. package/dist/document-templates.js +98 -1
  85. package/dist/document-templates.js.map +1 -1
  86. package/dist/document-values.d.ts +12 -1
  87. package/dist/document-values.d.ts.map +1 -1
  88. package/dist/document-values.js +41 -11
  89. package/dist/document-values.js.map +1 -1
  90. package/dist/email.d.ts +5 -0
  91. package/dist/email.d.ts.map +1 -1
  92. package/dist/errors.d.ts +142 -8
  93. package/dist/errors.d.ts.map +1 -1
  94. package/dist/errors.js +189 -8
  95. package/dist/errors.js.map +1 -1
  96. package/dist/index.d.ts +24 -1
  97. package/dist/index.d.ts.map +1 -1
  98. package/dist/index.js +43 -1
  99. package/dist/index.js.map +1 -1
  100. package/dist/inventory.d.ts +3 -3
  101. package/dist/invoices.d.ts +6 -2
  102. package/dist/invoices.d.ts.map +1 -1
  103. package/dist/invoices.js +10 -4
  104. package/dist/invoices.js.map +1 -1
  105. package/dist/line-groups.d.ts +80 -0
  106. package/dist/line-groups.d.ts.map +1 -0
  107. package/dist/line-groups.js +130 -0
  108. package/dist/line-groups.js.map +1 -0
  109. package/dist/localized-name.d.ts +20 -0
  110. package/dist/localized-name.d.ts.map +1 -0
  111. package/dist/localized-name.js +45 -0
  112. package/dist/localized-name.js.map +1 -0
  113. package/dist/megamenu.d.ts +674 -0
  114. package/dist/megamenu.d.ts.map +1 -1
  115. package/dist/megamenu.js +96 -3
  116. package/dist/megamenu.js.map +1 -1
  117. package/dist/mfa.d.ts +1 -0
  118. package/dist/mfa.d.ts.map +1 -1
  119. package/dist/mfa.js +8 -2
  120. package/dist/mfa.js.map +1 -1
  121. package/dist/modules.d.ts +8 -1
  122. package/dist/modules.d.ts.map +1 -1
  123. package/dist/modules.js +5 -0
  124. package/dist/modules.js.map +1 -1
  125. package/dist/money-decimal.d.ts +162 -0
  126. package/dist/money-decimal.d.ts.map +1 -0
  127. package/dist/money-decimal.js +365 -0
  128. package/dist/money-decimal.js.map +1 -0
  129. package/dist/money-input.d.ts +64 -0
  130. package/dist/money-input.d.ts.map +1 -0
  131. package/dist/money-input.js +111 -0
  132. package/dist/money-input.js.map +1 -0
  133. package/dist/newsletter.d.ts +3 -3
  134. package/dist/order-minimums.d.ts +111 -0
  135. package/dist/order-minimums.d.ts.map +1 -0
  136. package/dist/order-minimums.js +196 -0
  137. package/dist/order-minimums.js.map +1 -0
  138. package/dist/orders.d.ts +206 -2
  139. package/dist/orders.d.ts.map +1 -1
  140. package/dist/orders.js +106 -5
  141. package/dist/orders.js.map +1 -1
  142. package/dist/page-builder-props.d.ts +1401 -0
  143. package/dist/page-builder-props.d.ts.map +1 -0
  144. package/dist/page-builder-props.js +266 -0
  145. package/dist/page-builder-props.js.map +1 -0
  146. package/dist/page-builder-values.d.ts +95 -0
  147. package/dist/page-builder-values.d.ts.map +1 -0
  148. package/dist/page-builder-values.js +164 -0
  149. package/dist/page-builder-values.js.map +1 -0
  150. package/dist/payment-methods.d.ts.map +1 -1
  151. package/dist/payment-methods.js +2 -1
  152. package/dist/payment-methods.js.map +1 -1
  153. package/dist/pim-connector.d.ts +1 -1
  154. package/dist/platform-language.d.ts +9 -0
  155. package/dist/platform-language.d.ts.map +1 -1
  156. package/dist/platform-language.js +14 -0
  157. package/dist/platform-language.js.map +1 -1
  158. package/dist/price-book-decimal.d.ts +84 -0
  159. package/dist/price-book-decimal.d.ts.map +1 -0
  160. package/dist/price-book-decimal.js +175 -0
  161. package/dist/price-book-decimal.js.map +1 -0
  162. package/dist/price-books.d.ts +2206 -0
  163. package/dist/price-books.d.ts.map +1 -0
  164. package/dist/price-books.js +777 -0
  165. package/dist/price-books.js.map +1 -0
  166. package/dist/price-lists.d.ts +309 -614
  167. package/dist/price-lists.d.ts.map +1 -1
  168. package/dist/price-lists.js +113 -453
  169. package/dist/price-lists.js.map +1 -1
  170. package/dist/product-feeds.d.ts +195 -54
  171. package/dist/product-feeds.d.ts.map +1 -1
  172. package/dist/product-feeds.js +36 -1
  173. package/dist/product-feeds.js.map +1 -1
  174. package/dist/product-scopes.d.ts +628 -0
  175. package/dist/product-scopes.d.ts.map +1 -0
  176. package/dist/product-scopes.js +365 -0
  177. package/dist/product-scopes.js.map +1 -0
  178. package/dist/product-summary-text.d.ts +23 -0
  179. package/dist/product-summary-text.d.ts.map +1 -0
  180. package/dist/product-summary-text.js +64 -0
  181. package/dist/product-summary-text.js.map +1 -0
  182. package/dist/product-url-keys.d.ts +204 -0
  183. package/dist/product-url-keys.d.ts.map +1 -0
  184. package/dist/product-url-keys.js +166 -0
  185. package/dist/product-url-keys.js.map +1 -0
  186. package/dist/product-value-resolver.d.ts +6 -0
  187. package/dist/product-value-resolver.d.ts.map +1 -1
  188. package/dist/product-value-resolver.js +6 -1
  189. package/dist/product-value-resolver.js.map +1 -1
  190. package/dist/projects.d.ts +2355 -0
  191. package/dist/projects.d.ts.map +1 -0
  192. package/dist/projects.js +837 -0
  193. package/dist/projects.js.map +1 -0
  194. package/dist/promotions.d.ts +2 -2
  195. package/dist/promotions.d.ts.map +1 -1
  196. package/dist/promotions.js +8 -2
  197. package/dist/promotions.js.map +1 -1
  198. package/dist/prompt-actions.d.ts +19 -1
  199. package/dist/prompt-actions.d.ts.map +1 -1
  200. package/dist/prompt-actions.js +31 -2
  201. package/dist/prompt-actions.js.map +1 -1
  202. package/dist/quick-order.d.ts +39 -1
  203. package/dist/quick-order.d.ts.map +1 -1
  204. package/dist/quick-order.js +44 -1
  205. package/dist/quick-order.js.map +1 -1
  206. package/dist/quote-requests.d.ts +305 -1
  207. package/dist/quote-requests.d.ts.map +1 -1
  208. package/dist/quote-requests.js +173 -5
  209. package/dist/quote-requests.js.map +1 -1
  210. package/dist/record-references.d.ts +252 -0
  211. package/dist/record-references.d.ts.map +1 -0
  212. package/dist/record-references.js +179 -0
  213. package/dist/record-references.js.map +1 -0
  214. package/dist/record-rich-text.d.ts +66 -0
  215. package/dist/record-rich-text.d.ts.map +1 -0
  216. package/dist/record-rich-text.js +303 -0
  217. package/dist/record-rich-text.js.map +1 -0
  218. package/dist/returns.d.ts +81 -2
  219. package/dist/returns.d.ts.map +1 -1
  220. package/dist/returns.js +39 -4
  221. package/dist/returns.js.map +1 -1
  222. package/dist/sales-channels.d.ts +53 -7
  223. package/dist/sales-channels.d.ts.map +1 -1
  224. package/dist/sales-channels.js +40 -4
  225. package/dist/sales-channels.js.map +1 -1
  226. package/dist/saved-list-views.d.ts +28 -0
  227. package/dist/saved-list-views.d.ts.map +1 -1
  228. package/dist/saved-list-views.js +14 -1
  229. package/dist/saved-list-views.js.map +1 -1
  230. package/dist/scoped-translations.d.ts +48 -0
  231. package/dist/scoped-translations.d.ts.map +1 -0
  232. package/dist/scoped-translations.js +78 -0
  233. package/dist/scoped-translations.js.map +1 -0
  234. package/dist/search.d.ts +73 -5
  235. package/dist/search.d.ts.map +1 -1
  236. package/dist/search.js +4 -0
  237. package/dist/search.js.map +1 -1
  238. package/dist/seo.d.ts +64 -5
  239. package/dist/seo.d.ts.map +1 -1
  240. package/dist/seo.js +31 -4
  241. package/dist/seo.js.map +1 -1
  242. package/dist/settings.d.ts +32 -3
  243. package/dist/settings.d.ts.map +1 -1
  244. package/dist/settings.js +37 -3
  245. package/dist/settings.js.map +1 -1
  246. package/dist/shipping-methods.d.ts.map +1 -1
  247. package/dist/shipping-methods.js +2 -1
  248. package/dist/shipping-methods.js.map +1 -1
  249. package/dist/shopping-lists.d.ts +24 -0
  250. package/dist/shopping-lists.d.ts.map +1 -1
  251. package/dist/shopping-lists.js +20 -1
  252. package/dist/shopping-lists.js.map +1 -1
  253. package/dist/storefront-cache-tags.d.ts +29 -0
  254. package/dist/storefront-cache-tags.d.ts.map +1 -1
  255. package/dist/storefront-cache-tags.js +24 -0
  256. package/dist/storefront-cache-tags.js.map +1 -1
  257. package/dist/storefront-language-path.d.ts +77 -0
  258. package/dist/storefront-language-path.d.ts.map +1 -0
  259. package/dist/storefront-language-path.js +123 -0
  260. package/dist/storefront-language-path.js.map +1 -0
  261. package/dist/storefront-value-overrides.d.ts +67 -0
  262. package/dist/storefront-value-overrides.d.ts.map +1 -0
  263. package/dist/storefront-value-overrides.js +93 -0
  264. package/dist/storefront-value-overrides.js.map +1 -0
  265. package/dist/tasks.d.ts +2842 -0
  266. package/dist/tasks.d.ts.map +1 -0
  267. package/dist/tasks.js +901 -0
  268. package/dist/tasks.js.map +1 -0
  269. package/dist/transactional-emails.d.ts +7 -4
  270. package/dist/transactional-emails.d.ts.map +1 -1
  271. package/dist/transactional-emails.js +13 -0
  272. package/dist/transactional-emails.js.map +1 -1
  273. package/package.json +2 -2
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { uuidSchema } from './common.js';
3
3
  import { ModulePresenceSchema } from './modules.js';
4
+ import { twoDecimalAmount } from './money-input.js';
4
5
  /**
5
6
  * Localised name: a non-empty record of `lang → label`. A surface in language
6
7
  * `xx` uses `name[xx]` when present; otherwise the `default` key, otherwise the
@@ -25,7 +26,7 @@ export const deliveryMethodNameSchema = z
25
26
  export const deliveryMethodUpsertSchema = z.object({
26
27
  code: z.string().min(1).max(64).optional(),
27
28
  name: deliveryMethodNameSchema,
28
- cost: z.number().finite().nonnegative(),
29
+ cost: twoDecimalAmount(z.number().finite().nonnegative()),
29
30
  currency: z.string().length(3),
30
31
  adapter: z.string().min(1).max(64).optional(),
31
32
  status: z.enum(['active', 'inactive']).optional(),
@@ -1 +1 @@
1
- {"version":3,"file":"shipping-methods.js","sourceRoot":"","sources":["../src/shipping-methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAoBpD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC;KACtC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KACrC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GA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AAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACvC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE;IAC7C,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;CAC9D,CAAC;KACD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,iBAAiB,CAAC,EAAE;IACjF,OAAO,EAAE,yDAAyD;CACnE,CAAC,CAAC"}
@@ -84,12 +84,32 @@ export declare const conversionSkipSchema: z.ZodObject<{
84
84
  itemId: z.ZodString;
85
85
  productId: z.ZodString;
86
86
  reason: z.ZodEnum<{
87
+ below_minimum: "below_minimum";
87
88
  product_not_found: "product_not_found";
88
89
  product_archived: "product_archived";
89
90
  variant_unavailable: "variant_unavailable";
90
91
  }>;
92
+ minimum: z.ZodOptional<z.ZodNumber>;
91
93
  }, z.core.$strip>;
92
94
  export type ConversionSkip = z.infer<typeof conversionSkipSchema>;
95
+ /** One line of the carts bridge's `droppedLines`, as a shopping-list append reports it. */
96
+ export interface ShoppingListDroppedLine {
97
+ productId: string;
98
+ /** The id: a skip carries no name, and the storefront resolves it. */
99
+ productName: string;
100
+ reason: 'below_minimum' | 'not_purchasable';
101
+ minimum?: number;
102
+ }
103
+ /**
104
+ * Feature 155 (FR-011, US4 #3) — a list conversion's skipped items as the carts
105
+ * bridge's `droppedLines`, the uniform shape of the three conversions into a
106
+ * cart. A line below a minimum says so, with the minimum it missed; every other
107
+ * skip is `not_purchasable`. Pure — the one mapping both composition roots call,
108
+ * so production and the test harness cannot answer an append differently.
109
+ */
110
+ export declare function toCartDroppedLines(skipped: ReadonlyArray<Pick<ConversionSkip, 'productId' | 'minimum'> & {
111
+ reason: string;
112
+ }>): ShoppingListDroppedLine[];
93
113
  export declare const convertToCartResponseSchema: z.ZodObject<{
94
114
  shoppingListId: z.ZodString;
95
115
  added: z.ZodNumber;
@@ -97,10 +117,12 @@ export declare const convertToCartResponseSchema: z.ZodObject<{
97
117
  itemId: z.ZodString;
98
118
  productId: z.ZodString;
99
119
  reason: z.ZodEnum<{
120
+ below_minimum: "below_minimum";
100
121
  product_not_found: "product_not_found";
101
122
  product_archived: "product_archived";
102
123
  variant_unavailable: "variant_unavailable";
103
124
  }>;
125
+ minimum: z.ZodOptional<z.ZodNumber>;
104
126
  }, z.core.$strip>>;
105
127
  }, z.core.$strip>;
106
128
  export type ConvertToCartResponse = z.infer<typeof convertToCartResponseSchema>;
@@ -112,10 +134,12 @@ export declare const convertToRfqResponseSchema: z.ZodObject<{
112
134
  itemId: z.ZodString;
113
135
  productId: z.ZodString;
114
136
  reason: z.ZodEnum<{
137
+ below_minimum: "below_minimum";
115
138
  product_not_found: "product_not_found";
116
139
  product_archived: "product_archived";
117
140
  variant_unavailable: "variant_unavailable";
118
141
  }>;
142
+ minimum: z.ZodOptional<z.ZodNumber>;
119
143
  }, z.core.$strip>>;
120
144
  }, z.core.$strip>;
121
145
  export type ConvertToRfqResponse = z.infer<typeof convertToRfqResponseSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"shopping-lists.d.ts","sourceRoot":"","sources":["../src/shopping-lists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;iBASjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;iBAU7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG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AC,CAAC;AAI1F,kFAAkF;AAClF,eAAO,MAAM,oBAAoB;;;;;;;;;;iBAM/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,2FAA2F;AAC3F,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,eAAe,GAAG,iBAAiB,CAAC;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,SAAS,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,GACzF,uBAAuB,EAAE,CAW3B;AAED,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;iBAItC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;iBAKrC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
@@ -76,8 +76,27 @@ export const convertShoppingListRequestSchema = z
76
76
  export const conversionSkipSchema = z.object({
77
77
  itemId: uuidSchema,
78
78
  productId: uuidSchema,
79
- reason: z.enum(['product_archived', 'variant_unavailable', 'product_not_found']),
79
+ reason: z.enum(['product_archived', 'variant_unavailable', 'product_not_found', 'below_minimum']),
80
+ /** Feature 155 — on `below_minimum`: the minimum the line missed. */
81
+ minimum: z.number().int().positive().optional(),
80
82
  });
83
+ /**
84
+ * Feature 155 (FR-011, US4 #3) — a list conversion's skipped items as the carts
85
+ * bridge's `droppedLines`, the uniform shape of the three conversions into a
86
+ * cart. A line below a minimum says so, with the minimum it missed; every other
87
+ * skip is `not_purchasable`. Pure — the one mapping both composition roots call,
88
+ * so production and the test harness cannot answer an append differently.
89
+ */
90
+ export function toCartDroppedLines(skipped) {
91
+ return skipped.map((skip) => skip.reason === 'below_minimum'
92
+ ? {
93
+ productId: skip.productId,
94
+ productName: skip.productId,
95
+ reason: 'below_minimum',
96
+ ...(skip.minimum !== undefined ? { minimum: skip.minimum } : {}),
97
+ }
98
+ : { productId: skip.productId, productName: skip.productId, reason: 'not_purchasable' });
99
+ }
81
100
  export const convertToCartResponseSchema = z.object({
82
101
  shoppingListId: uuidSchema,
83
102
  added: z.number().int().nonnegative(),
@@ -1 +1 @@
1
- {"version":3,"file":"shopping-lists.js","sourceRoot":"","sources":["../src/shopping-lists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;;;;;;;;;;GAaG;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,EAAE,EAAE,UAAU;IACd,cAAc,EAAE,UAAU;IAC1B,SAAS,EAAE,UAAU;IACrB,SAAS,EAAE,UAAU,CAAC,QAAQ,EAAE;IAChC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACrC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;IACrC,SAAS,EAAE,iBAAiB;IAC5B,SAAS,EAAE,iBAAiB;CAC7B,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,EAAE,EAAE,UAAU;IACd,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,iBAAiB,EAAE,UAAU;IAC7B,IAAI,EAAE,CAAC,CAAC,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AC,oBAAoB,CAAC;CACvC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,cAAc,EAAE,UAAU;IAC1B,KAAK,EAAE,UAAU;IACjB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACrC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC;CACvC,CAAC,CAAC"}
@@ -32,6 +32,30 @@ export declare const CMS_STOREFRONT_CACHE_TAGS: {
32
32
  readonly hooks: "cms:hook";
33
33
  /** One hook's reads. */
34
34
  readonly hook: (code: string) => string;
35
+ /**
36
+ * The brand-token read every storefront page is styled from (feature 163,
37
+ * research R-3). One tag for every channel's set: a write to any scope can
38
+ * change what an inheriting channel resolves.
39
+ */
40
+ readonly brand: "cms:brand";
41
+ };
42
+ /**
43
+ * Feature 163 (T155 finding CACHE-1) — the storefront's product-page reads: the key
44
+ * resolve, the product detail and its links. Each carries the shared tag and the
45
+ * per-key tag of the key it was asked by — a URL key, the slug or the product id.
46
+ * `catalog` drops a product's per-key tags after every committed write that can change
47
+ * whether or where it is available. That matters more than for other content:
48
+ * Next keeps only a `200` in its Data Cache, so once a product becomes unavailable the
49
+ * time-based revalidation's `404` / `410` never replaces the cached `200`, and the
50
+ * page would go on showing it until something drops the entry by tag.
51
+ */
52
+ export declare const CATALOG_PRODUCT_STOREFRONT_CACHE_TAGS: {
53
+ /** Every product-page read. */
54
+ readonly product: "catalog:product";
55
+ /** The reads asked by one key — a URL key, a slug or a product id. */
56
+ readonly productKey: (key: string) => string;
57
+ /** Next drops a tag longer than this. */
58
+ readonly maxLength: 256;
35
59
  };
36
60
  /** The resolved megamenu of a channel and language — it inlines CMS blocks. */
37
61
  export declare const MEGAMENU_STOREFRONT_CACHE_TAG = "megamenu";
@@ -53,6 +77,11 @@ export declare const CMS_CONTENT_CHANGED_EVENT = "cms.content_changed.v1";
53
77
  export type CmsContentChange = {
54
78
  readonly kind: 'page';
55
79
  readonly slugs: readonly string[];
80
+ /**
81
+ * A nested page's public path moved (feature 163, R19D). The path is
82
+ * written into the links of *other* pages, so every page read is stale.
83
+ */
84
+ readonly addressesMoved?: true;
56
85
  } | {
57
86
  readonly kind: 'block';
58
87
  readonly codes: readonly string[];
@@ -1 +1 @@
1
- {"version":3,"file":"storefront-cache-tags.d.ts","sourceRoot":"","sources":["../src/storefront-cache-tags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,yBAAyB;IACpC,iFAAiF;;IAEjF,0EAA0E;0BAC7D,MAAM,KAAG,MAAM;IAC5B,0DAA0D;;IAE1D,gCAAgC;;IAEhC,yBAAyB;2BACX,MAAM,KAAG,MAAM;IAC7B,iFAAiF;;IAEjF,wBAAwB;0BACX,MAAM,KAAG,MAAM;CACpB,CAAC;AAEX,+EAA+E;AAC/E,eAAO,MAAM,6BAA6B,aAAa,CAAC;AAExD;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,2BAA2B,CAAC;AAElE;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAC5D;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAC7D;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC"}
1
+ {"version":3,"file":"storefront-cache-tags.d.ts","sourceRoot":"","sources":["../src/storefront-cache-tags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,yBAAyB;IACpC,iFAAiF;;IAEjF,0EAA0E;0BAC7D,MAAM,KAAG,MAAM;IAC5B,0DAA0D;;IAE1D,gCAAgC;;IAEhC,yBAAyB;2BACX,MAAM,KAAG,MAAM;IAC7B,iFAAiF;;IAEjF,wBAAwB;0BACX,MAAM,KAAG,MAAM;IAC5B;;;;OAIG;;CAEK,CAAC;AAEX;;;;;;;;;GASG;AACH,eAAO,MAAM,qCAAqC;IAChD,+BAA+B;;IAE/B,sEAAsE;+BACpD,MAAM,KAAG,MAAM;IACjC,yCAAyC;;CAEjC,CAAC;AAEX,+EAA+E;AAC/E,eAAO,MAAM,6BAA6B,aAAa,CAAC;AAExD;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,2BAA2B,CAAC;AAElE;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GACxB;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC;CAChC,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAC7D;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC"}
@@ -32,6 +32,30 @@ export const CMS_STOREFRONT_CACHE_TAGS = {
32
32
  hooks: 'cms:hook',
33
33
  /** One hook's reads. */
34
34
  hook: (code) => `cms:hook:${code}`,
35
+ /**
36
+ * The brand-token read every storefront page is styled from (feature 163,
37
+ * research R-3). One tag for every channel's set: a write to any scope can
38
+ * change what an inheriting channel resolves.
39
+ */
40
+ brand: 'cms:brand',
41
+ };
42
+ /**
43
+ * Feature 163 (T155 finding CACHE-1) — the storefront's product-page reads: the key
44
+ * resolve, the product detail and its links. Each carries the shared tag and the
45
+ * per-key tag of the key it was asked by — a URL key, the slug or the product id.
46
+ * `catalog` drops a product's per-key tags after every committed write that can change
47
+ * whether or where it is available. That matters more than for other content:
48
+ * Next keeps only a `200` in its Data Cache, so once a product becomes unavailable the
49
+ * time-based revalidation's `404` / `410` never replaces the cached `200`, and the
50
+ * page would go on showing it until something drops the entry by tag.
51
+ */
52
+ export const CATALOG_PRODUCT_STOREFRONT_CACHE_TAGS = {
53
+ /** Every product-page read. */
54
+ product: 'catalog:product',
55
+ /** The reads asked by one key — a URL key, a slug or a product id. */
56
+ productKey: (key) => `catalog:product:${key}`,
57
+ /** Next drops a tag longer than this. */
58
+ maxLength: 256,
35
59
  };
36
60
  /** The resolved megamenu of a channel and language — it inlines CMS blocks. */
37
61
  export const MEGAMENU_STOREFRONT_CACHE_TAG = 'megamenu';
@@ -1 +1 @@
1
- {"version":3,"file":"storefront-cache-tags.js","sourceRoot":"","sources":["../src/storefront-cache-tags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,iFAAiF;IACjF,KAAK,EAAE,UAAU;IACjB,0EAA0E;IAC1E,IAAI,EAAE,CAAC,IAAY,EAAU,EAAE,CAAC,YAAY,IAAI,EAAE;IAClD,0DAA0D;IAC1D,SAAS,EAAE,gBAAgB;IAC3B,gCAAgC;IAChC,MAAM,EAAE,WAAW;IACnB,yBAAyB;IACzB,KAAK,EAAE,CAAC,IAAY,EAAU,EAAE,CAAC,aAAa,IAAI,EAAE;IACpD,iFAAiF;IACjF,KAAK,EAAE,UAAU;IACjB,wBAAwB;IACxB,IAAI,EAAE,CAAC,IAAY,EAAU,EAAE,CAAC,YAAY,IAAI,EAAE;CAC1C,CAAC;AAEX,+EAA+E;AAC/E,MAAM,CAAC,MAAM,6BAA6B,GAAG,UAAU,CAAC;AAExD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,wBAAwB,CAAC"}
1
+ {"version":3,"file":"storefront-cache-tags.js","sourceRoot":"","sources":["../src/storefront-cache-tags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,iFAAiF;IACjF,KAAK,EAAE,UAAU;IACjB,0EAA0E;IAC1E,IAAI,EAAE,CAAC,IAAY,EAAU,EAAE,CAAC,YAAY,IAAI,EAAE;IAClD,0DAA0D;IAC1D,SAAS,EAAE,gBAAgB;IAC3B,gCAAgC;IAChC,MAAM,EAAE,WAAW;IACnB,yBAAyB;IACzB,KAAK,EAAE,CAAC,IAAY,EAAU,EAAE,CAAC,aAAa,IAAI,EAAE;IACpD,iFAAiF;IACjF,KAAK,EAAE,UAAU;IACjB,wBAAwB;IACxB,IAAI,EAAE,CAAC,IAAY,EAAU,EAAE,CAAC,YAAY,IAAI,EAAE;IAClD;;;;OAIG;IACH,KAAK,EAAE,WAAW;CACV,CAAC;AAEX;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG;IACnD,+BAA+B;IAC/B,OAAO,EAAE,iBAAiB;IAC1B,sEAAsE;IACtE,UAAU,EAAE,CAAC,GAAW,EAAU,EAAE,CAAC,mBAAmB,GAAG,EAAE;IAC7D,yCAAyC;IACzC,SAAS,EAAE,GAAG;CACN,CAAC;AAEX,+EAA+E;AAC/E,MAAM,CAAC,MAAM,6BAA6B,GAAG,UAAU,CAAC;AAExD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,wBAAwB,CAAC"}
@@ -0,0 +1,77 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Feature 167 (`specs/167-storefront-locale-path/`, issue #396) — the language of a
4
+ * storefront page is the first segment of its path (`/pl/p/wiertarka`, `/en/p/drill`).
5
+ *
6
+ * This module is the **one** derivation of a channel's URL language prefixes
7
+ * (`contracts/url-shape.md` §2) and the one composer of a storefront page path in a
8
+ * language. The backend answers the derived prefixes on the public channel read, so the
9
+ * storefront never re-derives them; every backend emitter composes its storefront URLs
10
+ * through {@link storefrontPagePath}. Nothing is stored: a prefix is a function of the
11
+ * channel's languages and its *prefix the default language* setting, so it cannot drift
12
+ * from them.
13
+ *
14
+ * A leaf: imports only `zod`.
15
+ */
16
+ /** What a URL composer needs to know about a channel. `CachedChannel` and `PublicSalesChannel` satisfy it. */
17
+ export interface ChannelUrlFacts {
18
+ readonly languages: readonly string[];
19
+ readonly defaultLanguage: string;
20
+ readonly prefixDefaultLanguage: boolean;
21
+ }
22
+ /** The prefix grammar of `url-shape.md` §1: a lower-case primary subtag, optionally the full lower-case tag. */
23
+ export declare const URL_LANGUAGE_PREFIX_PATTERN: RegExp;
24
+ export declare const channelUrlLanguageSchema: z.ZodObject<{
25
+ languageCode: z.ZodString;
26
+ prefix: z.ZodString;
27
+ prefixed: z.ZodBoolean;
28
+ isDefault: z.ZodBoolean;
29
+ }, z.core.$strip>;
30
+ export type ChannelUrlLanguage = z.infer<typeof channelUrlLanguageSchema>;
31
+ /**
32
+ * A primary subtag shared by several channel languages (`en` for `en-US` and `en-GB`).
33
+ * It is no language's prefix, but a request under it is answered 307 to one of its
34
+ * languages (FR-015), so links taken before the channel gained the second variant keep
35
+ * working.
36
+ */
37
+ export declare const channelUrlLanguageAliasSchema: z.ZodObject<{
38
+ alias: z.ZodString;
39
+ languageCodes: z.ZodArray<z.ZodString>;
40
+ }, z.core.$strip>;
41
+ export type ChannelUrlLanguageAlias = z.infer<typeof channelUrlLanguageAliasSchema>;
42
+ /**
43
+ * The URL language of every channel language (`url-shape.md` §2): the lower-case primary
44
+ * subtag when it is the only channel language with that subtag, else the full lower-case
45
+ * tag. Channel order, the default language included. Throws on a case-insensitive
46
+ * duplicate code, which the channel validator already refuses.
47
+ */
48
+ export declare function channelUrlLanguages(channel: ChannelUrlFacts): ChannelUrlLanguage[];
49
+ /** The split aliases of a channel (FR-015): each primary subtag shared by two or more channel languages. */
50
+ export declare function channelUrlLanguageAliases(channel: ChannelUrlFacts): ChannelUrlLanguageAlias[];
51
+ /**
52
+ * The storefront path of a page in a language. `path` is a **logical** path — today's
53
+ * route (`/`, `/c/x`, `/p/k?variant=A`); the answer is `/<prefix>` + path when the
54
+ * language is prefixed (`/<prefix>` alone for `/`), else `path`. The query and fragment
55
+ * are kept verbatim. Throws on a language the channel does not have: an emitter asking
56
+ * for one has a bug.
57
+ */
58
+ export declare function storefrontPagePath(input: {
59
+ path: string;
60
+ languageCode: string;
61
+ channel: ChannelUrlFacts;
62
+ }): string;
63
+ /** The unprefixed URL of a logical path — the `x-default` target in both setting states (`url-shape.md` §8). */
64
+ export declare function storefrontDefaultPath(path: string): string;
65
+ /**
66
+ * The storefront path of a page for a **message** (an e-mail link, a redirect a
67
+ * backend route answers) — feature 167, FR-034. The language is the one the message
68
+ * is rendered in when the channel serves it (exact tag, then primary subtag), else
69
+ * the channel's default language. With no channel known the logical path is answered
70
+ * unchanged: the storefront's redirects then choose the language.
71
+ */
72
+ export declare function storefrontPagePathFor(input: {
73
+ path: string;
74
+ channel: ChannelUrlFacts | null | undefined;
75
+ requestedLanguage?: string | null | undefined;
76
+ }): string;
77
+ //# sourceMappingURL=storefront-language-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storefront-language-path.d.ts","sourceRoot":"","sources":["../src/storefront-language-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;GAaG;AAEH,8GAA8G;AAC9G,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,qBAAqB,EAAE,OAAO,CAAC;CACzC;AAED,gHAAgH;AAChH,eAAO,MAAM,2BAA2B,QAAkC,CAAC;AAE3E,eAAO,MAAM,wBAAwB;;;;;iBAMnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B;;;iBAGxC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAoBpF;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,eAAe,GAAG,kBAAkB,EAAE,CAkBlF;AAED,4GAA4G;AAC5G,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,eAAe,GAAG,uBAAuB,EAAE,CAS7F;AAQD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,eAAe,CAAC;CAC1B,GAAG,MAAM,CAUT;AAED,gHAAgH;AAChH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG1D;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5C,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAC/C,GAAG,MAAM,CAWT"}
@@ -0,0 +1,123 @@
1
+ import { z } from 'zod';
2
+ /** The prefix grammar of `url-shape.md` §1: a lower-case primary subtag, optionally the full lower-case tag. */
3
+ export const URL_LANGUAGE_PREFIX_PATTERN = /^[a-z]{2,3}(-[a-z0-9]{1,8})*$/;
4
+ export const channelUrlLanguageSchema = z.object({
5
+ languageCode: z.string().min(1).max(16),
6
+ prefix: z.string().regex(URL_LANGUAGE_PREFIX_PATTERN),
7
+ /** `false` only for the default language with `prefixDefaultLanguage` off. */
8
+ prefixed: z.boolean(),
9
+ isDefault: z.boolean(),
10
+ });
11
+ /**
12
+ * A primary subtag shared by several channel languages (`en` for `en-US` and `en-GB`).
13
+ * It is no language's prefix, but a request under it is answered 307 to one of its
14
+ * languages (FR-015), so links taken before the channel gained the second variant keep
15
+ * working.
16
+ */
17
+ export const channelUrlLanguageAliasSchema = z.object({
18
+ alias: z.string().regex(/^[a-z]{2,3}$/),
19
+ languageCodes: z.array(z.string()).min(2),
20
+ });
21
+ function primarySubtag(code) {
22
+ return code.split('-')[0].toLowerCase();
23
+ }
24
+ /** The channel's languages in channel order, the default language included (first when absent). */
25
+ function orderedLanguages(channel) {
26
+ const list = [...channel.languages];
27
+ const hasDefault = list.some((code) => code.toLowerCase() === channel.defaultLanguage.toLowerCase());
28
+ if (!hasDefault)
29
+ list.unshift(channel.defaultLanguage);
30
+ const seen = new Set();
31
+ for (const code of list) {
32
+ const key = code.toLowerCase();
33
+ if (seen.has(key))
34
+ throw new Error(`channelUrlLanguages: duplicate language code "${code}"`);
35
+ seen.add(key);
36
+ }
37
+ return list;
38
+ }
39
+ /**
40
+ * The URL language of every channel language (`url-shape.md` §2): the lower-case primary
41
+ * subtag when it is the only channel language with that subtag, else the full lower-case
42
+ * tag. Channel order, the default language included. Throws on a case-insensitive
43
+ * duplicate code, which the channel validator already refuses.
44
+ */
45
+ export function channelUrlLanguages(channel) {
46
+ const languages = orderedLanguages(channel);
47
+ const perPrimary = new Map();
48
+ for (const code of languages) {
49
+ const primary = primarySubtag(code);
50
+ perPrimary.set(primary, (perPrimary.get(primary) ?? 0) + 1);
51
+ }
52
+ const defaultKey = channel.defaultLanguage.toLowerCase();
53
+ return languages.map((code) => {
54
+ const primary = primarySubtag(code);
55
+ const isDefault = code.toLowerCase() === defaultKey;
56
+ return {
57
+ languageCode: code,
58
+ prefix: perPrimary.get(primary) === 1 ? primary : code.toLowerCase(),
59
+ prefixed: !(isDefault && !channel.prefixDefaultLanguage),
60
+ isDefault,
61
+ };
62
+ });
63
+ }
64
+ /** The split aliases of a channel (FR-015): each primary subtag shared by two or more channel languages. */
65
+ export function channelUrlLanguageAliases(channel) {
66
+ const groups = new Map();
67
+ for (const code of orderedLanguages(channel)) {
68
+ const primary = primarySubtag(code);
69
+ groups.set(primary, [...(groups.get(primary) ?? []), code]);
70
+ }
71
+ return [...groups.entries()]
72
+ .filter(([, codes]) => codes.length >= 2)
73
+ .map(([alias, languageCodes]) => ({ alias, languageCodes }));
74
+ }
75
+ function assertLogicalPath(path) {
76
+ if (!path.startsWith('/') || path.startsWith('//')) {
77
+ throw new Error(`storefrontPagePath: "${path}" is not a root-relative storefront path`);
78
+ }
79
+ }
80
+ /**
81
+ * The storefront path of a page in a language. `path` is a **logical** path — today's
82
+ * route (`/`, `/c/x`, `/p/k?variant=A`); the answer is `/<prefix>` + path when the
83
+ * language is prefixed (`/<prefix>` alone for `/`), else `path`. The query and fragment
84
+ * are kept verbatim. Throws on a language the channel does not have: an emitter asking
85
+ * for one has a bug.
86
+ */
87
+ export function storefrontPagePath(input) {
88
+ assertLogicalPath(input.path);
89
+ const wanted = input.languageCode.toLowerCase();
90
+ const language = channelUrlLanguages(input.channel).find((l) => l.languageCode.toLowerCase() === wanted);
91
+ if (language === undefined) {
92
+ throw new Error(`storefrontPagePath: language "${input.languageCode}" is not a language of the channel`);
93
+ }
94
+ if (!language.prefixed)
95
+ return input.path;
96
+ const rest = /^\/(?=[?#]|$)/.test(input.path) ? input.path.slice(1) : input.path;
97
+ return `/${language.prefix}${rest}`;
98
+ }
99
+ /** The unprefixed URL of a logical path — the `x-default` target in both setting states (`url-shape.md` §8). */
100
+ export function storefrontDefaultPath(path) {
101
+ assertLogicalPath(path);
102
+ return path;
103
+ }
104
+ /**
105
+ * The storefront path of a page for a **message** (an e-mail link, a redirect a
106
+ * backend route answers) — feature 167, FR-034. The language is the one the message
107
+ * is rendered in when the channel serves it (exact tag, then primary subtag), else
108
+ * the channel's default language. With no channel known the logical path is answered
109
+ * unchanged: the storefront's redirects then choose the language.
110
+ */
111
+ export function storefrontPagePathFor(input) {
112
+ assertLogicalPath(input.path);
113
+ if (!input.channel)
114
+ return input.path;
115
+ const languages = channelUrlLanguages(input.channel);
116
+ const wanted = input.requestedLanguage?.trim().toLowerCase() ?? '';
117
+ const primary = wanted.split('-')[0];
118
+ const match = (wanted === '' ? undefined : languages.find((l) => l.languageCode.toLowerCase() === wanted)) ??
119
+ (wanted === '' ? undefined : languages.find((l) => l.languageCode.split('-')[0].toLowerCase() === primary)) ??
120
+ languages.find((l) => l.isDefault);
121
+ return storefrontPagePath({ path: input.path, languageCode: match.languageCode, channel: input.channel });
122
+ }
123
+ //# sourceMappingURL=storefront-language-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storefront-language-path.js","sourceRoot":"","sources":["../src/storefront-language-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAwBxB,gHAAgH;AAChH,MAAM,CAAC,MAAM,2BAA2B,GAAG,+BAA+B,CAAC;AAE3E,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;IACvC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,2BAA2B,CAAC;IACrD,8EAA8E;IAC9E,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;IACrB,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE;CACvB,CAAC,CAAC;AAGH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAAC;IACpD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC;IACvC,aAAa,EAAE,CAAC,CAA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 /**
3
+ * Issue #384 — which per-(sales channel, language) override (features 022/023)
4
+ * a storefront read shows, given the override rows it already holds.
5
+ *
6
+ * Shared by every storefront read that shows a product's name — `catalog`'s
7
+ * product page and listing cards, and `search`'s result cards — so one product
8
+ * cannot show two names depending on which module answered the page.
9
+ *
10
+ * **Only the override slots are taken from the resolver.** The fallback chain
11
+ * is {@link resolveAttribute}, and this file adds no second implementation of
12
+ * it. What it deliberately does *not* take from the resolver is the baseline
13
+ * leg: the storefront reads have always walked their own language fallback
14
+ * over the baseline JSONB (`preferred` → the channel's default language →
15
+ * `en-US` → `en` → first key), which differs from the resolver's
16
+ * (`languageCode` → primary language → first sorted key) in its edges.
17
+ * Replacing it would change what every product *without* an override shows,
18
+ * so an override answers here only when the resolver says a channel slot
19
+ * produced the value, and the caller's existing baseline pick answers
20
+ * otherwise. The baseline is still read for one thing — where that pick
21
+ * stops — so an override never answers for a later language than the one
22
+ * whose baseline text the page would show.
23
+ */
24
+ /** The request's resolution context, as the storefront reads hold it. */
25
+ export interface StorefrontOverrideContext {
26
+ channelId: string;
27
+ /**
28
+ * The language chain the caller's baseline pick walks, in order — see
29
+ * {@link overrideLanguages}. A (channel, language) override is looked up at
30
+ * each leg until the baseline has a value for one; the pick's first-key tail
31
+ * is derived from the baseline itself. Empty when nothing is known: only the
32
+ * baseline's first key and the channel-only slot can answer.
33
+ */
34
+ languages: readonly string[];
35
+ }
36
+ /**
37
+ * The ordered, de-duplicated language chain the storefront's baseline pick
38
+ * walks: the `Accept-Language` pick, the channel's default language, `en-US`,
39
+ * `en`. A caller whose pick has no channel-default leg passes `undefined` for
40
+ * it, so the override walk mirrors exactly the pick it sits on.
41
+ */
42
+ export declare function overrideLanguages(preferredLanguage: string | undefined, channelDefaultLanguage: string | undefined): string[];
43
+ /**
44
+ * The override value for one attribute in this context, or `undefined` when no
45
+ * channel slot applies and the caller's baseline should stand.
46
+ *
47
+ * The walk is the baseline pick's own, with the override slot looked at first
48
+ * at every leg: for each language L of `ctx.languages`, a (channel, L)
49
+ * override answers; else, if the baseline has a value for L, the walk stops
50
+ * there. When no leg stopped it and the baseline is a per-language record, its
51
+ * first key — the pick's tail — is the last leg. So an override for a later
52
+ * language never beats a baseline value for an earlier one. Whatever the walk
53
+ * stopped on, the channel-only slot is asked last, exactly as it always was.
54
+ *
55
+ * `baseline` is the raw value the caller's pick reads: `products.name` /
56
+ * `products.description` for the system text, `attributeValues[key]` for a
57
+ * user attribute.
58
+ */
59
+ export declare function channelOverrideFor(overrides: readonly OverrideRow[] | undefined, attributeKey: string, scope: AttributeScope, ctx: StorefrontOverrideContext, baseline: unknown): unknown;
60
+ /**
61
+ * The effective Name or Description: the channel override when one applies
62
+ * and is a non-empty string, else `baselineText` — the caller's existing
63
+ * language pick over `baseline`, the JSONB it picked from. The pick is kept
64
+ * the caller's so a product without overrides shows byte-identical text.
65
+ */
66
+ export declare function effectiveSystemText(overrides: readonly OverrideRow[] | undefined, attributeKey: 'name' | 'description', ctx: StorefrontOverrideContext, baseline: Readonly<Record<string, string>>, baselineText: string): string;
67
+ //# sourceMappingURL=storefront-value-overrides.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storefront-value-overrides.d.ts","sourceRoot":"","sources":["../src/storefront-value-overrides.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,WAAW,EACjB,MAAM,6BAA6B,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,yEAAyE;AACzE,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,iBAAiB,EAAE,MAAM,GAAG,SAAS,EACrC,sBAAsB,EAAE,MAAM,GAAG,SAAS,GACzC,MAAM,EAAE,CAIV;AAiBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,SAAS,WAAW,EAAE,GAAG,SAAS,EAC7C,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,cAAc,EACrB,GAAG,EAAE,yBAAyB,EAC9B,QAAQ,EAAE,OAAO,GAChB,OAAO,CAsCT;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,SAAS,WAAW,EAAE,GAAG,SAAS,EAC7C,YAAY,EAAE,MAAM,GAAG,aAAa,EACpC,GAAG,EAAE,yBAAyB,EAC9B,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC1C,YAAY,EAAE,MAAM,GACnB,MAAM,CASR"}
@@ -0,0 +1,93 @@
1
+ import { SYSTEM_ATTRIBUTE_SCOPES } from './catalog.js';
2
+ import { isNonEmpty, resolveAttribute, } from './product-value-resolver.js';
3
+ /**
4
+ * The ordered, de-duplicated language chain the storefront's baseline pick
5
+ * walks: the `Accept-Language` pick, the channel's default language, `en-US`,
6
+ * `en`. A caller whose pick has no channel-default leg passes `undefined` for
7
+ * it, so the override walk mirrors exactly the pick it sits on.
8
+ */
9
+ export function overrideLanguages(preferredLanguage, channelDefaultLanguage) {
10
+ return [...new Set([preferredLanguage, channelDefaultLanguage, 'en-US', 'en'])].filter((l) => typeof l === 'string' && l.length > 0);
11
+ }
12
+ function isPlainRecord(v) {
13
+ return typeof v === 'object' && v !== null && !Array.isArray(v);
14
+ }
15
+ /**
16
+ * Whether the baseline answers at `language` — where the caller's pick stops.
17
+ * A per-language record answers where it holds a value (an empty string does
18
+ * not stop the pick, as in the callers' `if (hit)`); a language-agnostic scalar
19
+ * answers at every leg; an absent baseline answers at none.
20
+ */
21
+ function baselineAnswersAt(baseline, language) {
22
+ if (isPlainRecord(baseline))
23
+ return isNonEmpty(baseline[language]);
24
+ return isNonEmpty(baseline);
25
+ }
26
+ /**
27
+ * The override value for one attribute in this context, or `undefined` when no
28
+ * channel slot applies and the caller's baseline should stand.
29
+ *
30
+ * The walk is the baseline pick's own, with the override slot looked at first
31
+ * at every leg: for each language L of `ctx.languages`, a (channel, L)
32
+ * override answers; else, if the baseline has a value for L, the walk stops
33
+ * there. When no leg stopped it and the baseline is a per-language record, its
34
+ * first key — the pick's tail — is the last leg. So an override for a later
35
+ * language never beats a baseline value for an earlier one. Whatever the walk
36
+ * stopped on, the channel-only slot is asked last, exactly as it always was.
37
+ *
38
+ * `baseline` is the raw value the caller's pick reads: `products.name` /
39
+ * `products.description` for the system text, `attributeValues[key]` for a
40
+ * user attribute.
41
+ */
42
+ export function channelOverrideFor(overrides, attributeKey, scope, ctx, baseline) {
43
+ if (!overrides || overrides.length === 0)
44
+ return undefined;
45
+ const resolve = (languageCode) => resolveAttribute({
46
+ attributeKey,
47
+ // No baseline: the baseline leg is the caller's (see the file comment).
48
+ baseline: undefined,
49
+ overrides,
50
+ scope,
51
+ ctx: {
52
+ channelId: ctx.channelId,
53
+ languageCode,
54
+ // Unused: with no baseline, the resolver's primary-language leg cannot answer.
55
+ primaryLanguage: languageCode ?? '',
56
+ },
57
+ });
58
+ const languageSlot = (languageCode) => {
59
+ const resolved = resolve(languageCode);
60
+ return resolved.source === 'channel+language' ? resolved.value : undefined;
61
+ };
62
+ let stopped = false;
63
+ for (const languageCode of ctx.languages) {
64
+ const v = languageSlot(languageCode);
65
+ if (v !== undefined)
66
+ return v;
67
+ if (baselineAnswersAt(baseline, languageCode)) {
68
+ stopped = true;
69
+ break;
70
+ }
71
+ }
72
+ if (!stopped && isPlainRecord(baseline)) {
73
+ const firstKey = Object.keys(baseline)[0];
74
+ if (firstKey !== undefined) {
75
+ const v = languageSlot(firstKey);
76
+ if (v !== undefined)
77
+ return v;
78
+ }
79
+ }
80
+ const channelOnly = resolve(null);
81
+ return channelOnly.source === 'channel' ? channelOnly.value : undefined;
82
+ }
83
+ /**
84
+ * The effective Name or Description: the channel override when one applies
85
+ * and is a non-empty string, else `baselineText` — the caller's existing
86
+ * language pick over `baseline`, the JSONB it picked from. The pick is kept
87
+ * the caller's so a product without overrides shows byte-identical text.
88
+ */
89
+ export function effectiveSystemText(overrides, attributeKey, ctx, baseline, baselineText) {
90
+ const v = channelOverrideFor(overrides, attributeKey, SYSTEM_ATTRIBUTE_SCOPES[attributeKey], ctx, baseline);
91
+ return typeof v === 'string' && v.length > 0 ? v : baselineText;
92
+ }
93
+ //# sourceMappingURL=storefront-value-overrides.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storefront-value-overrides.js","sourceRoot":"","sources":["../src/storefront-value-overrides.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EACL,UAAU,EACV,gBAAgB,GAGjB,MAAM,6BAA6B,CAAC;AAsCrC;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,iBAAqC,EACrC,sBAA0C;IAE1C,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,iBAAiB,EAAE,sBAAsB,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CACpF,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAC1D,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,CAAU;IAC/B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC;AAED;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,QAAiB,EAAE,QAAgB;IAC5D,IAAI,aAAa,CAAC,QAAQ,CAAC;QAAE,OAAO,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IACnE,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,kBAAkB,CA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