@endora-commerce/contracts 0.109.0 → 0.111.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 (385) hide show
  1. package/dist/accept-language.d.ts +31 -0
  2. package/dist/accept-language.js +64 -0
  3. package/dist/actor.d.ts +16 -0
  4. package/dist/addresses.d.ts +35 -0
  5. package/dist/addresses.js +8 -1
  6. package/dist/admin-actions.d.ts +2 -0
  7. package/dist/admin-actions.js +18 -0
  8. package/dist/admin-contributions.d.ts +99 -12
  9. package/dist/admin-contributions.js +36 -10
  10. package/dist/admin-roles.d.ts +17 -2
  11. package/dist/admin-users.d.ts +9 -0
  12. package/dist/admin.d.ts +114 -4
  13. package/dist/admin.js +98 -3
  14. package/dist/api-keys.d.ts +22 -0
  15. package/dist/api-keys.js +4 -0
  16. package/dist/assets-library.d.ts +45 -0
  17. package/dist/assets-library.js +20 -3
  18. package/dist/audit-logs.d.ts +12 -0
  19. package/dist/audit-logs.js +12 -0
  20. package/dist/auth.d.ts +9 -0
  21. package/dist/auth.js +9 -0
  22. package/dist/blog.d.ts +382 -22
  23. package/dist/blog.js +199 -17
  24. package/dist/carts.d.ts +423 -36
  25. package/dist/carts.js +150 -12
  26. package/dist/catalog.d.ts +379 -208
  27. package/dist/catalog.js +241 -163
  28. package/dist/cms-brand.d.ts +14 -14
  29. package/dist/cms.d.ts +71 -16
  30. package/dist/cms.js +15 -0
  31. package/dist/command-hooks.d.ts +301 -0
  32. package/dist/command-hooks.js +248 -0
  33. package/dist/common.d.ts +23 -6
  34. package/dist/common.js +25 -2
  35. package/dist/comparisons.d.ts +21 -14
  36. package/dist/comparisons.js +2 -1
  37. package/dist/credit-limits.d.ts +22 -0
  38. package/dist/credit-limits.js +35 -0
  39. package/dist/crm.d.ts +134 -78
  40. package/dist/crm.js +21 -5
  41. package/dist/custom-fields.d.ts +417 -49
  42. package/dist/custom-fields.js +142 -1
  43. package/dist/customer-accounts.d.ts +324 -22
  44. package/dist/customer-accounts.js +43 -0
  45. package/dist/customer-notifications.d.ts +143 -0
  46. package/dist/customer-notifications.js +41 -0
  47. package/dist/customers.d.ts +92 -73
  48. package/dist/customers.js +98 -10
  49. package/dist/dictionary.d.ts +53 -0
  50. package/dist/dictionary.js +25 -0
  51. package/dist/document-templates.d.ts +12 -12
  52. package/dist/email.d.ts +34 -0
  53. package/dist/email.js +6 -0
  54. package/dist/errors.d.ts +431 -3
  55. package/dist/errors.js +523 -3
  56. package/dist/forms-logic.d.ts +79 -0
  57. package/dist/forms-logic.fixtures.d.ts +52 -0
  58. package/dist/forms-logic.fixtures.js +610 -0
  59. package/dist/forms-logic.js +699 -0
  60. package/dist/forms.d.ts +9833 -0
  61. package/dist/forms.js +827 -0
  62. package/dist/i18n.d.ts +34 -0
  63. package/dist/i18n.js +15 -0
  64. package/dist/import-export.d.ts +180 -0
  65. package/dist/import-export.js +60 -0
  66. package/dist/index.d.ts +16 -1
  67. package/dist/index.js +30 -1
  68. package/dist/inventory.d.ts +9 -9
  69. package/dist/invoice-ledger.d.ts +13 -13
  70. package/dist/invoices.d.ts +126 -0
  71. package/dist/invoices.js +53 -0
  72. package/dist/line-bounds.d.ts +53 -0
  73. package/dist/line-bounds.js +65 -0
  74. package/dist/megamenu.d.ts +27 -27
  75. package/dist/mfa.d.ts +210 -4
  76. package/dist/mfa.js +136 -0
  77. package/dist/modules.d.ts +56 -8
  78. package/dist/modules.js +128 -3
  79. package/dist/money-decimal.d.ts +54 -0
  80. package/dist/money-decimal.js +95 -0
  81. package/dist/newsletter.d.ts +4 -4
  82. package/dist/orders.d.ts +246 -12
  83. package/dist/orders.js +140 -7
  84. package/dist/organization-hooks.d.ts +99 -0
  85. package/dist/organization-hooks.js +22 -0
  86. package/dist/organization-registry-lookup.d.ts +362 -0
  87. package/dist/organization-registry-lookup.js +196 -0
  88. package/dist/organization-roles.d.ts +341 -0
  89. package/dist/organization-roles.js +218 -0
  90. package/dist/organizations.d.ts +1074 -103
  91. package/dist/organizations.js +293 -28
  92. package/dist/page-builder-props.d.ts +56 -56
  93. package/dist/pim-connector.d.ts +7 -3
  94. package/dist/pim-connector.js +6 -2
  95. package/dist/pim-field-path.d.ts +5 -1
  96. package/dist/pim-field-path.js +37 -81
  97. package/dist/pim-locale-mapping.d.ts +131 -0
  98. package/dist/pim-locale-mapping.js +193 -0
  99. package/dist/price-books.d.ts +215 -63
  100. package/dist/price-books.js +47 -2
  101. package/dist/price-lists.d.ts +13 -10
  102. package/dist/product-feeds.d.ts +249 -100
  103. package/dist/product-feeds.js +46 -2
  104. package/dist/product-scope-model.d.ts +161 -0
  105. package/dist/product-scope-model.js +161 -0
  106. package/dist/product-scope-overrides.d.ts +0 -103
  107. package/dist/product-scope-overrides.js +0 -54
  108. package/dist/product-scoped-values.d.ts +2610 -0
  109. package/dist/product-scoped-values.js +425 -0
  110. package/dist/product-scopes.d.ts +199 -64
  111. package/dist/product-scopes.js +120 -23
  112. package/dist/product-tax-rates.d.ts +38 -0
  113. package/dist/product-tax-rates.js +45 -0
  114. package/dist/product-url-keys.d.ts +51 -45
  115. package/dist/product-url-keys.js +73 -39
  116. package/dist/product-value-resolver.d.ts +37 -60
  117. package/dist/product-value-resolver.js +36 -96
  118. package/dist/projects.d.ts +76 -28
  119. package/dist/projects.js +53 -9
  120. package/dist/promotions.d.ts +163 -11
  121. package/dist/promotions.js +23 -1
  122. package/dist/pwa.d.ts +41 -2
  123. package/dist/quick-order.d.ts +159 -9
  124. package/dist/quick-order.js +79 -4
  125. package/dist/quote-requests.d.ts +231 -17
  126. package/dist/quote-requests.js +111 -9
  127. package/dist/record-references.d.ts +15 -15
  128. package/dist/record-references.js +2 -3
  129. package/dist/record-rich-text.js +2 -1
  130. package/dist/returns.d.ts +214 -52
  131. package/dist/returns.js +143 -28
  132. package/dist/sales-channels.d.ts +34 -3
  133. package/dist/sales-channels.js +16 -1
  134. package/dist/saved-list-views.d.ts +28 -0
  135. package/dist/saved-list-views.js +14 -1
  136. package/dist/schema-extensions.d.ts +36 -0
  137. package/dist/schema-extensions.js +29 -0
  138. package/dist/scoped-write-encoding.d.ts +100 -0
  139. package/dist/scoped-write-encoding.js +135 -0
  140. package/dist/search.d.ts +18 -16
  141. package/dist/seo.d.ts +83 -30
  142. package/dist/seo.js +8 -1
  143. package/dist/settings.d.ts +173 -2
  144. package/dist/settings.js +53 -2
  145. package/dist/shopping-lists.d.ts +63 -4
  146. package/dist/shopping-lists.js +57 -3
  147. package/dist/storefront-cache-tags.d.ts +22 -0
  148. package/dist/storefront-cache-tags.js +12 -0
  149. package/dist/storefront-value-overrides.d.ts +18 -56
  150. package/dist/storefront-value-overrides.js +11 -86
  151. package/dist/tasks.d.ts +27 -27
  152. package/dist/taxes.d.ts +27 -0
  153. package/dist/taxes.js +4 -0
  154. package/dist/transactional-emails.d.ts +48 -22
  155. package/dist/webhooks.d.ts +75 -0
  156. package/dist/webhooks.js +24 -0
  157. package/package.json +5 -3
  158. package/dist/actor.d.ts.map +0 -1
  159. package/dist/actor.js.map +0 -1
  160. package/dist/addresses.d.ts.map +0 -1
  161. package/dist/addresses.js.map +0 -1
  162. package/dist/admin-actions.d.ts.map +0 -1
  163. package/dist/admin-actions.js.map +0 -1
  164. package/dist/admin-contributions.d.ts.map +0 -1
  165. package/dist/admin-contributions.js.map +0 -1
  166. package/dist/admin-feedback.d.ts.map +0 -1
  167. package/dist/admin-feedback.js.map +0 -1
  168. package/dist/admin-i18n.d.ts.map +0 -1
  169. package/dist/admin-i18n.js.map +0 -1
  170. package/dist/admin-name.d.ts.map +0 -1
  171. package/dist/admin-name.js.map +0 -1
  172. package/dist/admin-notifications.d.ts.map +0 -1
  173. package/dist/admin-notifications.js.map +0 -1
  174. package/dist/admin-preferences.d.ts.map +0 -1
  175. package/dist/admin-preferences.js.map +0 -1
  176. package/dist/admin-roles.d.ts.map +0 -1
  177. package/dist/admin-roles.js.map +0 -1
  178. package/dist/admin-search.d.ts.map +0 -1
  179. package/dist/admin-search.js.map +0 -1
  180. package/dist/admin-users.d.ts.map +0 -1
  181. package/dist/admin-users.js.map +0 -1
  182. package/dist/admin.d.ts.map +0 -1
  183. package/dist/admin.js.map +0 -1
  184. package/dist/analytics.d.ts.map +0 -1
  185. package/dist/analytics.js.map +0 -1
  186. package/dist/api-keys.d.ts.map +0 -1
  187. package/dist/api-keys.js.map +0 -1
  188. package/dist/assets-library.d.ts.map +0 -1
  189. package/dist/assets-library.js.map +0 -1
  190. package/dist/audit-logs.d.ts.map +0 -1
  191. package/dist/audit-logs.js.map +0 -1
  192. package/dist/auth.d.ts.map +0 -1
  193. package/dist/auth.js.map +0 -1
  194. package/dist/blog.d.ts.map +0 -1
  195. package/dist/blog.js.map +0 -1
  196. package/dist/capabilities.d.ts.map +0 -1
  197. package/dist/capabilities.js.map +0 -1
  198. package/dist/carts.d.ts.map +0 -1
  199. package/dist/carts.js.map +0 -1
  200. package/dist/catalog.d.ts.map +0 -1
  201. package/dist/catalog.js.map +0 -1
  202. package/dist/cms-brand.d.ts.map +0 -1
  203. package/dist/cms-brand.js.map +0 -1
  204. package/dist/cms-contact-form.d.ts.map +0 -1
  205. package/dist/cms-contact-form.js.map +0 -1
  206. package/dist/cms.d.ts.map +0 -1
  207. package/dist/cms.js.map +0 -1
  208. package/dist/common.d.ts.map +0 -1
  209. package/dist/common.js.map +0 -1
  210. package/dist/comparisons.d.ts.map +0 -1
  211. package/dist/comparisons.js.map +0 -1
  212. package/dist/credentials.d.ts.map +0 -1
  213. package/dist/credentials.js.map +0 -1
  214. package/dist/credit-limits.d.ts.map +0 -1
  215. package/dist/credit-limits.js.map +0 -1
  216. package/dist/crm-rich-text.d.ts.map +0 -1
  217. package/dist/crm-rich-text.js.map +0 -1
  218. package/dist/crm.d.ts.map +0 -1
  219. package/dist/crm.js.map +0 -1
  220. package/dist/currencies.d.ts.map +0 -1
  221. package/dist/currencies.js.map +0 -1
  222. package/dist/custom-fields.d.ts.map +0 -1
  223. package/dist/custom-fields.js.map +0 -1
  224. package/dist/customer-accounts.d.ts.map +0 -1
  225. package/dist/customer-accounts.js.map +0 -1
  226. package/dist/customers.d.ts.map +0 -1
  227. package/dist/customers.js.map +0 -1
  228. package/dist/dictionary.d.ts.map +0 -1
  229. package/dist/dictionary.js.map +0 -1
  230. package/dist/document-templates.d.ts.map +0 -1
  231. package/dist/document-templates.js.map +0 -1
  232. package/dist/document-values.d.ts.map +0 -1
  233. package/dist/document-values.js.map +0 -1
  234. package/dist/email-address.d.ts.map +0 -1
  235. package/dist/email-address.js.map +0 -1
  236. package/dist/email.d.ts.map +0 -1
  237. package/dist/email.js.map +0 -1
  238. package/dist/envelopes.d.ts.map +0 -1
  239. package/dist/envelopes.js.map +0 -1
  240. package/dist/environment-inputs.d.ts.map +0 -1
  241. package/dist/environment-inputs.js.map +0 -1
  242. package/dist/erp-connector.d.ts.map +0 -1
  243. package/dist/erp-connector.js.map +0 -1
  244. package/dist/errors.d.ts.map +0 -1
  245. package/dist/errors.js.map +0 -1
  246. package/dist/google-analytics.d.ts.map +0 -1
  247. package/dist/google-analytics.js.map +0 -1
  248. package/dist/google-tag-manager.d.ts.map +0 -1
  249. package/dist/google-tag-manager.js.map +0 -1
  250. package/dist/i18n.d.ts.map +0 -1
  251. package/dist/i18n.js.map +0 -1
  252. package/dist/import-export.d.ts.map +0 -1
  253. package/dist/import-export.js.map +0 -1
  254. package/dist/index.d.ts.map +0 -1
  255. package/dist/index.js.map +0 -1
  256. package/dist/inventory.d.ts.map +0 -1
  257. package/dist/inventory.js.map +0 -1
  258. package/dist/invoice-ledger.d.ts.map +0 -1
  259. package/dist/invoice-ledger.js.map +0 -1
  260. package/dist/invoices.d.ts.map +0 -1
  261. package/dist/invoices.js.map +0 -1
  262. package/dist/kernel.d.ts.map +0 -1
  263. package/dist/kernel.js.map +0 -1
  264. package/dist/languages.d.ts.map +0 -1
  265. package/dist/languages.js.map +0 -1
  266. package/dist/line-groups.d.ts.map +0 -1
  267. package/dist/line-groups.js.map +0 -1
  268. package/dist/linkedin-ads.d.ts.map +0 -1
  269. package/dist/linkedin-ads.js.map +0 -1
  270. package/dist/localized-name.d.ts.map +0 -1
  271. package/dist/localized-name.js.map +0 -1
  272. package/dist/megamenu.d.ts.map +0 -1
  273. package/dist/megamenu.js.map +0 -1
  274. package/dist/meta-ads.d.ts.map +0 -1
  275. package/dist/meta-ads.js.map +0 -1
  276. package/dist/mfa.d.ts.map +0 -1
  277. package/dist/mfa.js.map +0 -1
  278. package/dist/modules.d.ts.map +0 -1
  279. package/dist/modules.js.map +0 -1
  280. package/dist/money-decimal.d.ts.map +0 -1
  281. package/dist/money-decimal.js.map +0 -1
  282. package/dist/money-input.d.ts.map +0 -1
  283. package/dist/money-input.js.map +0 -1
  284. package/dist/newsletter.d.ts.map +0 -1
  285. package/dist/newsletter.js.map +0 -1
  286. package/dist/order-minimums.d.ts.map +0 -1
  287. package/dist/order-minimums.js.map +0 -1
  288. package/dist/orders.d.ts.map +0 -1
  289. package/dist/orders.js.map +0 -1
  290. package/dist/organizations.d.ts.map +0 -1
  291. package/dist/organizations.js.map +0 -1
  292. package/dist/page-builder-props.d.ts.map +0 -1
  293. package/dist/page-builder-props.js.map +0 -1
  294. package/dist/page-builder-values.d.ts.map +0 -1
  295. package/dist/page-builder-values.js.map +0 -1
  296. package/dist/pagination.d.ts.map +0 -1
  297. package/dist/pagination.js.map +0 -1
  298. package/dist/payment-methods.d.ts.map +0 -1
  299. package/dist/payment-methods.js.map +0 -1
  300. package/dist/payment-return-url.d.ts.map +0 -1
  301. package/dist/payment-return-url.js.map +0 -1
  302. package/dist/payments.d.ts.map +0 -1
  303. package/dist/payments.js.map +0 -1
  304. package/dist/pim-connector.d.ts.map +0 -1
  305. package/dist/pim-connector.js.map +0 -1
  306. package/dist/pim-field-path.d.ts.map +0 -1
  307. package/dist/pim-field-path.js.map +0 -1
  308. package/dist/platform-info.d.ts.map +0 -1
  309. package/dist/platform-info.js.map +0 -1
  310. package/dist/platform-language.d.ts.map +0 -1
  311. package/dist/platform-language.js.map +0 -1
  312. package/dist/price-book-decimal.d.ts.map +0 -1
  313. package/dist/price-book-decimal.js.map +0 -1
  314. package/dist/price-books.d.ts.map +0 -1
  315. package/dist/price-books.js.map +0 -1
  316. package/dist/price-lists.d.ts.map +0 -1
  317. package/dist/price-lists.js.map +0 -1
  318. package/dist/product-feeds.d.ts.map +0 -1
  319. package/dist/product-feeds.js.map +0 -1
  320. package/dist/product-scope-overrides.d.ts.map +0 -1
  321. package/dist/product-scope-overrides.js.map +0 -1
  322. package/dist/product-scopes.d.ts.map +0 -1
  323. package/dist/product-scopes.js.map +0 -1
  324. package/dist/product-summary-text.d.ts.map +0 -1
  325. package/dist/product-summary-text.js.map +0 -1
  326. package/dist/product-url-keys.d.ts.map +0 -1
  327. package/dist/product-url-keys.js.map +0 -1
  328. package/dist/product-value-resolver.d.ts.map +0 -1
  329. package/dist/product-value-resolver.js.map +0 -1
  330. package/dist/projects.d.ts.map +0 -1
  331. package/dist/projects.js.map +0 -1
  332. package/dist/promotions.d.ts.map +0 -1
  333. package/dist/promotions.js.map +0 -1
  334. package/dist/prompt-actions.d.ts.map +0 -1
  335. package/dist/prompt-actions.js.map +0 -1
  336. package/dist/pwa.d.ts.map +0 -1
  337. package/dist/pwa.js.map +0 -1
  338. package/dist/quick-order.d.ts.map +0 -1
  339. package/dist/quick-order.js.map +0 -1
  340. package/dist/quote-requests.d.ts.map +0 -1
  341. package/dist/quote-requests.js.map +0 -1
  342. package/dist/record-references.d.ts.map +0 -1
  343. package/dist/record-references.js.map +0 -1
  344. package/dist/record-rich-text.d.ts.map +0 -1
  345. package/dist/record-rich-text.js.map +0 -1
  346. package/dist/returns.d.ts.map +0 -1
  347. package/dist/returns.js.map +0 -1
  348. package/dist/sales-channels.d.ts.map +0 -1
  349. package/dist/sales-channels.js.map +0 -1
  350. package/dist/saved-list-views.d.ts.map +0 -1
  351. package/dist/saved-list-views.js.map +0 -1
  352. package/dist/scope-notice.d.ts.map +0 -1
  353. package/dist/scope-notice.js.map +0 -1
  354. package/dist/scoped-translations.d.ts +0 -48
  355. package/dist/scoped-translations.d.ts.map +0 -1
  356. package/dist/scoped-translations.js +0 -78
  357. package/dist/scoped-translations.js.map +0 -1
  358. package/dist/search.d.ts.map +0 -1
  359. package/dist/search.js.map +0 -1
  360. package/dist/seo.d.ts.map +0 -1
  361. package/dist/seo.js.map +0 -1
  362. package/dist/settings.d.ts.map +0 -1
  363. package/dist/settings.js.map +0 -1
  364. package/dist/shipments.d.ts.map +0 -1
  365. package/dist/shipments.js.map +0 -1
  366. package/dist/shipping-methods.d.ts.map +0 -1
  367. package/dist/shipping-methods.js.map +0 -1
  368. package/dist/shopping-lists.d.ts.map +0 -1
  369. package/dist/shopping-lists.js.map +0 -1
  370. package/dist/storefront-cache-tags.d.ts.map +0 -1
  371. package/dist/storefront-cache-tags.js.map +0 -1
  372. package/dist/storefront-language-path.d.ts.map +0 -1
  373. package/dist/storefront-language-path.js.map +0 -1
  374. package/dist/storefront-value-overrides.d.ts.map +0 -1
  375. package/dist/storefront-value-overrides.js.map +0 -1
  376. package/dist/tasks.d.ts.map +0 -1
  377. package/dist/tasks.js.map +0 -1
  378. package/dist/taxes.d.ts.map +0 -1
  379. package/dist/taxes.js.map +0 -1
  380. package/dist/text-normalization.d.ts.map +0 -1
  381. package/dist/text-normalization.js.map +0 -1
  382. package/dist/transactional-emails.d.ts.map +0 -1
  383. package/dist/transactional-emails.js.map +0 -1
  384. package/dist/webhooks.d.ts.map +0 -1
  385. package/dist/webhooks.js.map +0 -1
@@ -0,0 +1,38 @@
1
+ import type { ProductType } from './catalog.js';
2
+ import type { OrganizationTaxProfilePort } from './organizations.js';
3
+ import type { TaxServicePort } from './taxes.js';
4
+ /**
5
+ * The VAT rate of each product tax class a buyer is charged, as a fraction —
6
+ * issue #436 (the cart) and issue #852 (the catalogue). A product's class is
7
+ * its `type`.
8
+ */
9
+ export type ProductTaxRateResolver = (input: {
10
+ organizationId: string | null;
11
+ productTypes: readonly ProductType[];
12
+ }) => Promise<Map<ProductType, number>>;
13
+ /**
14
+ * Resolves a buyer's rates the way placement resolves an order's
15
+ * (`OrderService.computeMonetaryTotals`): the product's class against the
16
+ * Organization's VAT status and country, a VAT-exempt or reverse-charge
17
+ * Organization at 0, and a deployment holding no rule that applies — the
18
+ * resolver's `none` — at 0. The checkout preview's defaults stand for what a
19
+ * read before checkout cannot know yet: a buyer with no Organization is a VAT
20
+ * payer, and the country is the Organization's registered one, `PL` without
21
+ * one; placement prefers the billing address chosen at checkout.
22
+ *
23
+ * **One rule, two readers.** It was `carts`' own (`cart-tax-rates.ts`, issue
24
+ * #436) until the catalogue needed the same answer for a product's gross price
25
+ * (issue #852). A second copy in `catalog` would be a second chance to answer
26
+ * the same buyer two rates for the same product, so the rule lives here, over
27
+ * the two contract ports both modules already resolve, and each module wires
28
+ * it with its own `lazyPort`s — no module imports the other.
29
+ *
30
+ * No `catch` (issue #84): the only errors that reach here are a failing
31
+ * database and a switched-off owner, and a rate invented for either would be a
32
+ * VAT figure no rule supports. The caller decides what a failure means.
33
+ */
34
+ export declare function createProductTaxRateResolver(ports: {
35
+ taxProfiles: OrganizationTaxProfilePort;
36
+ taxes: TaxServicePort;
37
+ }): ProductTaxRateResolver;
38
+ //# sourceMappingURL=product-tax-rates.d.ts.map
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Resolves a buyer's rates the way placement resolves an order's
3
+ * (`OrderService.computeMonetaryTotals`): the product's class against the
4
+ * Organization's VAT status and country, a VAT-exempt or reverse-charge
5
+ * Organization at 0, and a deployment holding no rule that applies — the
6
+ * resolver's `none` — at 0. The checkout preview's defaults stand for what a
7
+ * read before checkout cannot know yet: a buyer with no Organization is a VAT
8
+ * payer, and the country is the Organization's registered one, `PL` without
9
+ * one; placement prefers the billing address chosen at checkout.
10
+ *
11
+ * **One rule, two readers.** It was `carts`' own (`cart-tax-rates.ts`, issue
12
+ * #436) until the catalogue needed the same answer for a product's gross price
13
+ * (issue #852). A second copy in `catalog` would be a second chance to answer
14
+ * the same buyer two rates for the same product, so the rule lives here, over
15
+ * the two contract ports both modules already resolve, and each module wires
16
+ * it with its own `lazyPort`s — no module imports the other.
17
+ *
18
+ * No `catch` (issue #84): the only errors that reach here are a failing
19
+ * database and a switched-off owner, and a rate invented for either would be a
20
+ * VAT figure no rule supports. The caller decides what a failure means.
21
+ */
22
+ export function createProductTaxRateResolver(ports) {
23
+ return async ({ organizationId, productTypes }) => {
24
+ const rates = new Map();
25
+ const types = [...new Set(productTypes)];
26
+ if (types.length === 0)
27
+ return rates;
28
+ const profile = organizationId ? await ports.taxProfiles.taxProfileOf(organizationId) : null;
29
+ const vatStatus = profile?.vatStatus ?? 'vat_payer';
30
+ for (const productType of types) {
31
+ if (vatStatus !== 'vat_payer') {
32
+ rates.set(productType, 0);
33
+ continue;
34
+ }
35
+ const resolved = await ports.taxes.taxRateFor({
36
+ country: profile?.country ?? 'PL',
37
+ productType,
38
+ vatStatus,
39
+ });
40
+ rates.set(productType, resolved.source === 'none' ? 0 : resolved.rate);
41
+ }
42
+ return rates;
43
+ };
44
+ }
45
+ //# sourceMappingURL=product-tax-rates.js.map
@@ -1,20 +1,35 @@
1
1
  import { z } from 'zod';
2
2
  import { type ChannelUrlFacts } from './storefront-language-path.js';
3
3
  /**
4
- * Feature 163 (`specs/163-product-data-scopes/`) — product URL keys per language and
5
- * per sales channel × language, their redirects, and the one helper that composes a
6
- * product URL (`contracts/url-keys-and-redirects.md`, research R11, R12, R17, R28).
4
+ * Feature 163, rewritten by feature 174 (`specs/174-product-editor-scope-switcher/contracts/
5
+ * url-keys.md`, research R12) — product URL keys at Global (`products.slug`), Channel and
6
+ * Channel × language, their redirects per (channel, language), and the one helper that composes
7
+ * a product URL.
7
8
  *
8
- * Kept apart from `product-scopes.ts` so the URL-key work edits its own file. This
9
- * module is a leaf: it imports nothing from the catalogue contracts.
9
+ * A key text belongs to at most one product per channel across all the channel's languages,
10
+ * orphans included; the same product may repeat it (owner round 7). There is no Language-only
11
+ * key (FR-010).
12
+ *
13
+ * Kept apart from `product-scopes.ts` so the URL-key work edits its own file. This module is a
14
+ * leaf for runtime imports: it imports nothing from the catalogue contracts.
10
15
  */
11
16
  /**
12
17
  * A product URL key: the grammar of `products.slug` (lower-case kebab case, at most
13
- * 160 characters — the column width). Global, language and channel × language keys
14
- * all share it.
18
+ * 160 characters — the column width). Global, channel and channel × language keys
19
+ * all share it. Every writer normalises to NFC and lower case first ({@link normaliseUrlKey}).
15
20
  */
21
+ /** The longest URL key or slug (`varchar(160)`). */
22
+ export declare const PRODUCT_URL_KEY_MAX = 160;
16
23
  export declare const productSlugSchema: z.ZodString;
17
24
  export type ProductSlug = z.infer<typeof productSlugSchema>;
25
+ /** NFC, then lower case — what every key writer does before {@link productSlugSchema} (R12). */
26
+ export declare function normaliseUrlKey(raw: string): string;
27
+ /** The most keys a `confirmTakeover` list names (R21). */
28
+ export declare const URL_KEY_TAKEOVER_MAX = 20;
29
+ /** The most redirects kept per (product, channel); the oldest are dropped (R12). */
30
+ export declare const URL_REDIRECTS_PER_CHANNEL_MAX = 50;
31
+ /** The most new keys one import or connector run reserves; the rest are `limit_reached` (R12). */
32
+ export declare const URL_KEYS_PER_RUN_MAX = 1000;
18
33
  export interface ProductPathInput {
19
34
  /** The effective key at (channel, language). */
20
35
  key: string;
@@ -39,14 +54,16 @@ export declare function productPath(input: ProductPathInput): string;
39
54
  /** The unprefixed product path — the `x-default` target (`specs/167-storefront-locale-path/` url-shape §8). */
40
55
  export declare function productDefaultPath(key: string): string;
41
56
  export declare const productUrlKeySourceSchema: z.ZodEnum<{
42
- language: "language";
43
57
  global: "global";
58
+ channel: "channel";
44
59
  channel_language: "channel_language";
45
60
  }>;
46
61
  export type ProductUrlKeySource = z.infer<typeof productUrlKeySourceSchema>;
62
+ /** A redirect answers at one (channel, language) (feature 174, `url-keys.md` §4). */
47
63
  export declare const productUrlRedirectSchema: z.ZodObject<{
48
64
  id: z.ZodString;
49
- languageCode: z.ZodNullable<z.ZodString>;
65
+ channelId: z.ZodString;
66
+ languageCode: z.ZodString;
50
67
  key: z.ZodString;
51
68
  createdAt: z.ZodString;
52
69
  }, z.core.$strip>;
@@ -54,13 +71,9 @@ export type ProductUrlRedirect = z.infer<typeof productUrlRedirectSchema>;
54
71
  export declare const productUrlKeysResponseSchema: z.ZodObject<{
55
72
  data: z.ZodObject<{
56
73
  globalKey: z.ZodString;
57
- languageKeys: z.ZodArray<z.ZodObject<{
58
- languageCode: z.ZodString;
59
- key: z.ZodString;
60
- }, z.core.$strip>>;
61
74
  channelKeys: z.ZodArray<z.ZodObject<{
62
75
  channelId: z.ZodString;
63
- languageCode: z.ZodString;
76
+ languageCode: z.ZodNullable<z.ZodString>;
64
77
  key: z.ZodString;
65
78
  orphaned: z.ZodBoolean;
66
79
  }, z.core.$strip>>;
@@ -69,15 +82,16 @@ export declare const productUrlKeysResponseSchema: z.ZodObject<{
69
82
  languageCode: z.ZodString;
70
83
  key: z.ZodString;
71
84
  source: z.ZodEnum<{
72
- language: "language";
73
85
  global: "global";
86
+ channel: "channel";
74
87
  channel_language: "channel_language";
75
88
  }>;
76
89
  url: z.ZodString;
77
90
  }, z.core.$strip>>;
78
91
  redirects: z.ZodOptional<z.ZodArray<z.ZodObject<{
79
92
  id: z.ZodString;
80
- languageCode: z.ZodNullable<z.ZodString>;
93
+ channelId: z.ZodString;
94
+ languageCode: z.ZodString;
81
95
  key: z.ZodString;
82
96
  createdAt: z.ZodString;
83
97
  }, z.core.$strip>>>;
@@ -86,38 +100,35 @@ export declare const productUrlKeysResponseSchema: z.ZodObject<{
86
100
  export type ProductUrlKeysResponse = z.infer<typeof productUrlKeysResponseSchema>;
87
101
  export declare const putProductUrlKeysRequestSchema: z.ZodObject<{
88
102
  globalKey: z.ZodOptional<z.ZodString>;
89
- languageKeys: z.ZodOptional<z.ZodArray<z.ZodObject<{
90
- languageCode: z.ZodString;
91
- key: z.ZodNullable<z.ZodString>;
92
- }, z.core.$strip>>>;
93
103
  channelKeys: z.ZodOptional<z.ZodArray<z.ZodObject<{
94
104
  channelId: z.ZodString;
95
- languageCode: z.ZodString;
96
- key: z.ZodNullable<z.ZodString>;
97
- }, z.core.$strip>>>;
98
- confirmTakeover: z.ZodOptional<z.ZodArray<z.ZodObject<{
99
- languageCode: z.ZodNullable<z.ZodString>;
100
- key: z.ZodString;
101
- }, z.core.$strip>>>;
102
- }, z.core.$strip>;
105
+ languageCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
106
+ key: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
107
+ inherit: z.ZodLiteral<true>;
108
+ }, z.core.$strict>]>;
109
+ }, z.core.$strict>>>;
110
+ confirmTakeover: z.ZodOptional<z.ZodArray<z.ZodString>>;
111
+ }, z.core.$strict>;
103
112
  export type PutProductUrlKeysRequest = z.infer<typeof putProductUrlKeysRequestSchema>;
104
113
  /** `409 URL_KEY_TAKEN` details. */
105
114
  export declare const urlKeyTakenDetailsSchema: z.ZodObject<{
106
115
  conflicts: z.ZodArray<z.ZodObject<{
107
- languageCode: z.ZodNullable<z.ZodString>;
108
116
  key: z.ZodString;
109
117
  heldByProductId: z.ZodString;
110
118
  heldByProductName: z.ZodString;
119
+ channelId: z.ZodNullable<z.ZodString>;
120
+ languageCode: z.ZodNullable<z.ZodString>;
111
121
  }, z.core.$strip>>;
112
122
  }, z.core.$strip>;
113
123
  export type UrlKeyTakenDetails = z.infer<typeof urlKeyTakenDetailsSchema>;
114
124
  /** `409 URL_KEY_REDIRECT_TAKEOVER_REQUIRED` details. */
115
125
  export declare const urlKeyRedirectTakeoverRequiredDetailsSchema: z.ZodObject<{
116
126
  takeovers: z.ZodArray<z.ZodObject<{
117
- languageCode: z.ZodNullable<z.ZodString>;
118
127
  key: z.ZodString;
119
128
  losingProductId: z.ZodString;
120
129
  losingProductName: z.ZodString;
130
+ channelId: z.ZodNullable<z.ZodString>;
131
+ languageCode: z.ZodNullable<z.ZodString>;
121
132
  }, z.core.$strip>>;
122
133
  }, z.core.$strip>;
123
134
  export type UrlKeyRedirectTakeoverRequiredDetails = z.infer<typeof urlKeyRedirectTakeoverRequiredDetailsSchema>;
@@ -155,33 +166,28 @@ export declare const productPagePathsSchema: z.ZodObject<{
155
166
  }, z.core.$strip>;
156
167
  export type ProductPagePaths = z.infer<typeof productPagePathsSchema>;
157
168
  /**
158
- * Per key written through `catalogProductScopeWritePort.applyScopes`: written, or
159
- * not written with the reason. A connector never takes over a redirect and is never
160
- * asked to confirm one; the product keeps its previous key at that scope (FR-093).
169
+ * Per `urlKey` cell written through `catalogProductScopeWritePort.applyScopes` or a CSV import:
170
+ * written, or not written with the reason. An integration never takes over a redirect and is
171
+ * never asked to confirm one; the product keeps its previous key at that scope (163 FR-093).
172
+ * `limit_reached` — the run already reserved {@link URL_KEYS_PER_RUN_MAX} new keys (R12).
161
173
  */
162
174
  export declare const urlKeyWriteOutcomeSchema: z.ZodUnion<readonly [z.ZodObject<{
163
175
  written: z.ZodLiteral<true>;
164
176
  }, z.core.$strip>, z.ZodObject<{
165
177
  written: z.ZodLiteral<false>;
166
178
  issue: z.ZodObject<{
167
- languageCode: z.ZodString;
168
- channelId: z.ZodNullable<z.ZodString>;
169
179
  key: z.ZodString;
170
- heldByProductId: z.ZodString;
180
+ heldByProductId: z.ZodNullable<z.ZodString>;
171
181
  kind: z.ZodEnum<{
172
- current: "current";
173
182
  redirect: "redirect";
183
+ current: "current";
184
+ limit_reached: "limit_reached";
174
185
  }>;
186
+ channelId: z.ZodNullable<z.ZodString>;
187
+ languageCode: z.ZodNullable<z.ZodString>;
175
188
  }, z.core.$strip>;
176
189
  }, z.core.$strip>]>;
177
190
  export type UrlKeyWriteOutcome = z.infer<typeof urlKeyWriteOutcomeSchema>;
178
- /** A URL key written by an integration: `channelId: null` = the language key. */
179
- export interface ProductUrlKeyWrite {
180
- languageCode: string;
181
- channelId: string | null;
182
- /** `null` = use inherited. */
183
- key: string | null;
184
- }
185
191
  /**
186
192
  * Container name: `catalogProductUrlKeyReadPort`. Owner: `catalog`.
187
193
  *
@@ -191,7 +197,7 @@ export interface ProductUrlKeyWrite {
191
197
  export interface CatalogProductUrlKeyReadPort {
192
198
  /**
193
199
  * The effective key per channel language for each product: the product's
194
- * channel × language key, else its language key, else its global key. Products the
200
+ * channel × language key, else its channel key, else its global key. Products the
195
201
  * channel does not carry are absent.
196
202
  *
197
203
  * **Applies no availability beyond membership** (checkpoint C security review, I8):
@@ -2,25 +2,42 @@ import { z } from 'zod';
2
2
  import { isoDateTimeSchema, uuidSchema } from './common.js';
3
3
  import { storefrontPagePath } from './storefront-language-path.js';
4
4
  /**
5
- * Feature 163 (`specs/163-product-data-scopes/`) — product URL keys per language and
6
- * per sales channel × language, their redirects, and the one helper that composes a
7
- * product URL (`contracts/url-keys-and-redirects.md`, research R11, R12, R17, R28).
5
+ * Feature 163, rewritten by feature 174 (`specs/174-product-editor-scope-switcher/contracts/
6
+ * url-keys.md`, research R12) — product URL keys at Global (`products.slug`), Channel and
7
+ * Channel × language, their redirects per (channel, language), and the one helper that composes
8
+ * a product URL.
8
9
  *
9
- * Kept apart from `product-scopes.ts` so the URL-key work edits its own file. This
10
- * module is a leaf: it imports nothing from the catalogue contracts.
10
+ * A key text belongs to at most one product per channel across all the channel's languages,
11
+ * orphans included; the same product may repeat it (owner round 7). There is no Language-only
12
+ * key (FR-010).
13
+ *
14
+ * Kept apart from `product-scopes.ts` so the URL-key work edits its own file. This module is a
15
+ * leaf for runtime imports: it imports nothing from the catalogue contracts.
11
16
  */
12
17
  // --- Key grammar ---------------------------------------------------------------
13
18
  /**
14
19
  * A product URL key: the grammar of `products.slug` (lower-case kebab case, at most
15
- * 160 characters — the column width). Global, language and channel × language keys
16
- * all share it.
20
+ * 160 characters — the column width). Global, channel and channel × language keys
21
+ * all share it. Every writer normalises to NFC and lower case first ({@link normaliseUrlKey}).
17
22
  */
23
+ /** The longest URL key or slug (`varchar(160)`). */
24
+ export const PRODUCT_URL_KEY_MAX = 160;
18
25
  export const productSlugSchema = z
19
26
  .string()
20
27
  .min(1)
21
- .max(160)
28
+ .max(PRODUCT_URL_KEY_MAX)
22
29
  .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'must be kebab-case');
23
30
  const languageCodeSchema = z.string().min(1).max(16);
31
+ /** NFC, then lower case — what every key writer does before {@link productSlugSchema} (R12). */
32
+ export function normaliseUrlKey(raw) {
33
+ return raw.normalize('NFC').toLowerCase();
34
+ }
35
+ /** The most keys a `confirmTakeover` list names (R21). */
36
+ export const URL_KEY_TAKEOVER_MAX = 20;
37
+ /** The most redirects kept per (product, channel); the oldest are dropped (R12). */
38
+ export const URL_REDIRECTS_PER_CHANNEL_MAX = 50;
39
+ /** The most new keys one import or connector run reserves; the rest are `limit_reached` (R12). */
40
+ export const URL_KEYS_PER_RUN_MAX = 1000;
24
41
  /**
25
42
  * The storefront path of a product page: `/p/<key>` under the language's path prefix
26
43
  * (`/en/p/drill`, or `/p/wiertarka` for the default language of a channel that does
@@ -44,21 +61,27 @@ export function productPath(input) {
44
61
  export function productDefaultPath(key) {
45
62
  return `/p/${encodeURIComponent(key)}`;
46
63
  }
47
- // --- Admin read — GET /api/v1/admin/catalog/products/:id/url-keys (§1) -----------
48
- export const productUrlKeySourceSchema = z.enum(['channel_language', 'language', 'global']);
64
+ // --- Admin read — GET /api/v1/admin/catalog/products/:id/url-keys ----------------
65
+ export const productUrlKeySourceSchema = z.enum(['channel_language', 'channel', 'global']);
66
+ /** A redirect answers at one (channel, language) (feature 174, `url-keys.md` §4). */
49
67
  export const productUrlRedirectSchema = z.object({
50
68
  id: uuidSchema,
51
- /** `null` = a former global key, redirecting in every language (H1). */
52
- languageCode: languageCodeSchema.nullable(),
69
+ channelId: uuidSchema,
70
+ languageCode: languageCodeSchema,
53
71
  key: z.string(),
54
72
  createdAt: isoDateTimeSchema,
55
73
  });
56
74
  export const productUrlKeysResponseSchema = z.object({
57
75
  data: z.object({
58
- /** `products.slug`. */
76
+ /** `products.slug` — the Global key. */
59
77
  globalKey: z.string(),
60
- languageKeys: z.array(z.object({ languageCode: languageCodeSchema, key: z.string() })),
61
- channelKeys: z.array(z.object({ channelId: uuidSchema, languageCode: languageCodeSchema, key: z.string(), orphaned: z.boolean() })),
78
+ /** `languageCode: null` = the Channel key. */
79
+ channelKeys: z.array(z.object({
80
+ channelId: uuidSchema,
81
+ languageCode: languageCodeSchema.nullable(),
82
+ key: z.string(),
83
+ orphaned: z.boolean(),
84
+ })),
62
85
  effective: z.array(z.object({
63
86
  channelId: uuidSchema,
64
87
  languageCode: languageCodeSchema,
@@ -71,31 +94,41 @@ export const productUrlKeysResponseSchema = z.object({
71
94
  redirects: z.array(productUrlRedirectSchema).optional(),
72
95
  }),
73
96
  });
74
- // --- Admin write — PUT /api/v1/admin/catalog/products/:id/url-keys (§2) ----------
97
+ // --- Admin write — PUT /api/v1/admin/catalog/products/:id/url-keys ----------------
75
98
  /** The most entries one list of a URL-keys PUT carries (Phase 16 review; the scopes PATCH's bound). */
76
99
  const URL_KEY_LIST_MAX = 64;
77
- export const putProductUrlKeysRequestSchema = z.object({
100
+ /** `{ inherit: true }` — the write encoding's "remove the own key" (`write-encoding.md` §5). */
101
+ const inheritKeySchema = z.object({ inherit: z.literal(true) }).strict();
102
+ export const putProductUrlKeysRequestSchema = z
103
+ .object({
78
104
  globalKey: productSlugSchema.optional(),
79
- /** `key: null` = use inherited (deletes the language key). */
80
- languageKeys: z
81
- .array(z.object({ languageCode: languageCodeSchema, key: productSlugSchema.nullable() }))
82
- .max(URL_KEY_LIST_MAX)
83
- .optional(),
84
- /** `key: null` = use inherited (deletes the channel × language key). */
105
+ /**
106
+ * Keys at Channel (`languageCode` absent or `null`) or Channel × language. `key` is a key or
107
+ * `{ inherit: true }` (deletes the row); `null` is refused — the URL key is required (FR-062).
108
+ */
85
109
  channelKeys: z
86
- .array(z.object({ channelId: uuidSchema, languageCode: languageCodeSchema, key: productSlugSchema.nullable() }))
87
- .max(URL_KEY_LIST_MAX)
88
- .optional(),
89
- /** The operator's confirmation of taking over another product's redirect (FR-072). */
90
- confirmTakeover: z
91
- .array(z.object({ languageCode: languageCodeSchema.nullable(), key: productSlugSchema }))
110
+ .array(z
111
+ .object({
112
+ channelId: uuidSchema,
113
+ languageCode: languageCodeSchema.nullable().optional(),
114
+ key: z.union([productSlugSchema, inheritKeySchema]),
115
+ })
116
+ .strict())
92
117
  .max(URL_KEY_LIST_MAX)
93
118
  .optional(),
94
- });
119
+ /** The operator's confirmation of taking over another product's redirect (163 FR-072). */
120
+ confirmTakeover: z.array(productSlugSchema).max(URL_KEY_TAKEOVER_MAX).optional(),
121
+ })
122
+ .strict();
123
+ /**
124
+ * Where a conflict sits: `channelId` `null` = the Global key (slug); `languageCode` `null` = a
125
+ * Channel key or the slug.
126
+ */
127
+ const keyAddressSchema = { channelId: uuidSchema.nullable(), languageCode: languageCodeSchema.nullable() };
95
128
  /** `409 URL_KEY_TAKEN` details. */
96
129
  export const urlKeyTakenDetailsSchema = z.object({
97
130
  conflicts: z.array(z.object({
98
- languageCode: languageCodeSchema.nullable(),
131
+ ...keyAddressSchema,
99
132
  key: z.string(),
100
133
  heldByProductId: uuidSchema,
101
134
  heldByProductName: z.string(),
@@ -104,7 +137,7 @@ export const urlKeyTakenDetailsSchema = z.object({
104
137
  /** `409 URL_KEY_REDIRECT_TAKEOVER_REQUIRED` details. */
105
138
  export const urlKeyRedirectTakeoverRequiredDetailsSchema = z.object({
106
139
  takeovers: z.array(z.object({
107
- languageCode: languageCodeSchema.nullable(),
140
+ ...keyAddressSchema,
108
141
  key: z.string(),
109
142
  losingProductId: uuidSchema,
110
143
  losingProductName: z.string(),
@@ -146,20 +179,21 @@ export const productPagePathsSchema = z.object({
146
179
  });
147
180
  // --- Connectors and import (§5) ------------------------------------------------
148
181
  /**
149
- * Per key written through `catalogProductScopeWritePort.applyScopes`: written, or
150
- * not written with the reason. A connector never takes over a redirect and is never
151
- * asked to confirm one; the product keeps its previous key at that scope (FR-093).
182
+ * Per `urlKey` cell written through `catalogProductScopeWritePort.applyScopes` or a CSV import:
183
+ * written, or not written with the reason. An integration never takes over a redirect and is
184
+ * never asked to confirm one; the product keeps its previous key at that scope (163 FR-093).
185
+ * `limit_reached` — the run already reserved {@link URL_KEYS_PER_RUN_MAX} new keys (R12).
152
186
  */
153
187
  export const urlKeyWriteOutcomeSchema = z.union([
154
188
  z.object({ written: z.literal(true) }),
155
189
  z.object({
156
190
  written: z.literal(false),
157
191
  issue: z.object({
158
- languageCode: languageCodeSchema,
159
- channelId: uuidSchema.nullable(),
192
+ ...keyAddressSchema,
160
193
  key: z.string(),
161
- heldByProductId: uuidSchema,
162
- kind: z.enum(['current', 'redirect']),
194
+ /** `null` for `limit_reached`. */
195
+ heldByProductId: uuidSchema.nullable(),
196
+ kind: z.enum(['current', 'redirect', 'limit_reached']),
163
197
  }),
164
198
  }),
165
199
  ]);
@@ -1,94 +1,71 @@
1
1
  /**
2
- * Feature 022 — product value resolver.
2
+ * Feature 022, rewritten by feature 174 (`specs/174-product-editor-scope-switcher/`, research R1) —
3
+ * the product value resolver over `product_value_overrides` rows.
3
4
  *
4
- * Pure-function fusion of (baseline + channel-aware overrides) into an
5
- * effective value per (channelId, languageCode) context. This file
6
- * is the SINGLE source of truth for the four-scope fallback chain:
7
- * the backend imports it from `@endora-commerce/contracts` (no behavioural
8
- * duplication in `backend/src/modules/catalog/services/...`) and the
9
- * admin SPA imports it to compute its "effective-value preview"
10
- * client-side so switcher toggles do not need a network round-trip.
5
+ * The fallback chain is {@link resolveScoped}'s — C×L → C → G, restricted to the field's scope
6
+ * set, a present row winning whatever it holds and `{ "v": null }` being an empty override
7
+ * (FR-013). This file only adapts the override table's row shape to {@link ScopedRow}; it adds no
8
+ * second chain. There is no Language level and no "primary language" (FR-010, FR-014): the Global
9
+ * value is one value.
11
10
  *
12
- * The matrix below MUST stay aligned with
13
- * specs/023-product-scope-editor/contracts/resolver.contract.md §5.
11
+ * Shared by the backend and the admin SPA through `@endora-commerce/contracts`.
14
12
  */
13
+ import { type ScopeLevel, type ScopeRef, type ScopedResolution, type ScopedRow, type ScopedSource } from './product-scope-model.js';
14
+ /**
15
+ * An attribute's scope flag (feature 174, R15): a scopable attribute may carry Channel and — for
16
+ * text — Channel × language overrides. The levels derive from the flag and the value type
17
+ * (`attributeScopeSet`).
18
+ */
19
+ export type AttributeScope = {
20
+ scopable: boolean;
21
+ };
22
+ /** The context a value is resolved in: no channel → Global; a channel without a language → C. */
15
23
  export type ResolverContext = {
16
- /** `null` = "Global / no channel" — see FR-010 / FR-040. */
17
24
  channelId: string | null;
18
- /** `null` = use `primaryLanguage`. */
19
25
  languageCode: string | null;
20
- /** Platform's primary admin language (e.g. `'pl'`). */
21
- primaryLanguage: string;
22
- };
23
- export type AttributeScope = {
24
- channelScoped: boolean;
25
- languageScoped: boolean;
26
26
  };
27
27
  export type OverrideRow = {
28
28
  attributeKey: string;
29
29
  channelId: string;
30
30
  languageCode: string | null;
31
+ /** `{ v: null }` is an empty override (FR-013). */
31
32
  value: {
32
33
  v: unknown;
33
34
  };
34
35
  };
35
- export type ResolvedSource = 'channel+language' | 'channel' | 'global+language' | 'global' | 'absent';
36
- export type Resolved = {
37
- /** Effective scalar (or `null` when no slot yielded). */
38
- value: unknown;
39
- /** Which slot produced the value (or `'absent'`). */
40
- source: ResolvedSource;
41
- };
36
+ /** Where an effective value comes from — {@link ScopedSource}. */
37
+ export type ResolvedSource = ScopedSource;
38
+ export type Resolved = ScopedResolution<unknown>;
39
+ /**
40
+ * Whether a value counts as present: not `undefined` / `null`, and not an empty string, array or
41
+ * object. A helper for Global values read from a JSON column; never used to skip an override row.
42
+ */
43
+ export declare function isNonEmpty(v: unknown): boolean;
44
+ /** The scope a {@link ResolverContext} names. A language without a channel resolves at Global. */
45
+ export declare function scopeOfContext(ctx: ResolverContext): ScopeRef;
46
+ /** One override row as a {@link ScopedRow}: `{ v: null }` (or a missing `v`) is the empty override. */
47
+ export declare function overrideToScopedRow(row: Pick<OverrideRow, 'channelId' | 'languageCode' | 'value'>): ScopedRow<unknown>;
42
48
  export type ResolveAttributeArgs = {
43
- /**
44
- * Raw baseline. Either a scalar (global-only attribute) or a
45
- * `Record<lang, value>` (language-scoped attribute). For system
46
- * attributes Name and Description this is the JSONB at
47
- * `products.name` / `products.description`.
48
- */
49
+ /** The Global value: `products.name` / `.description`, or `attribute_values[key]`. */
49
50
  baseline: unknown;
50
51
  /** Overrides pre-filtered to a single product. */
51
52
  overrides: readonly OverrideRow[];
52
53
  attributeKey: string;
53
- scope: AttributeScope;
54
+ /** The field's scope set. */
55
+ levels: readonly ScopeLevel[];
54
56
  ctx: ResolverContext;
55
57
  };
56
- /**
57
- * Whether a value counts as present: not `undefined`/`null`, and not an empty
58
- * string, array or object. Shared with `storefront-value-overrides`, whose
59
- * walk stops where the baseline holds a value by this same definition.
60
- */
61
- export declare function isNonEmpty(v: unknown): boolean;
62
- /**
63
- * Resolve one attribute value for the given context using the four-step
64
- * fallback chain. The resolver is tolerant of "orphan" override rows
65
- * left behind when an attribute's scope flags were toggled after writes
66
- * happened — orphan rows are silently skipped (matrix row 12).
67
- */
58
+ /** Resolve one attribute value in `ctx`. Rows of another key, channel or language never match. */
68
59
  export declare function resolveAttribute(args: ResolveAttributeArgs): Resolved;
69
60
  export type AttributeDef = {
70
61
  attributeKey: string;
71
- scope: AttributeScope;
72
- /**
73
- * For system attributes Name and Description the baseline lives at
74
- * `products.name` / `products.description`. For user-defined
75
- * attributes the baseline is `products.attribute_values[attributeKey]`.
76
- * Resolver consumers populate this field once per (attribute, product)
77
- * pair to keep this function free of any read coupling.
78
- */
62
+ levels: readonly ScopeLevel[];
79
63
  baseline: unknown;
80
64
  };
81
65
  export type ResolveAllResult = {
82
- /** Effective scalar per attribute key. */
83
66
  values: Record<string, unknown>;
84
- /** Source per attribute key — used by the admin "inherited from X" badge. */
85
67
  sources: Record<string, ResolvedSource>;
86
68
  };
87
- /**
88
- * Bulk resolve every attribute for one product in one (ctx) pass.
89
- * Loops `attributeDefs` and applies `resolveAttribute` per entry; the
90
- * `sources` map is for the admin UI and may be ignored by the
91
- * storefront.
92
- */
69
+ /** Resolve every attribute of one product in one context. */
93
70
  export declare function resolveAll(attributeDefs: readonly AttributeDef[], overrides: readonly OverrideRow[], ctx: ResolverContext): ResolveAllResult;
94
71
  //# sourceMappingURL=product-value-resolver.d.ts.map