@endora-commerce/mod-catalog 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 (403) hide show
  1. package/dist/admin/components/AttachmentScopesDialog.d.ts +22 -0
  2. package/dist/admin/components/AttachmentScopesDialog.d.ts.map +1 -0
  3. package/dist/admin/components/AttachmentScopesDialog.js +70 -0
  4. package/dist/admin/components/AttachmentScopesDialog.js.map +1 -0
  5. package/dist/admin/components/PackagingUnitsEditor.d.ts +10 -1
  6. package/dist/admin/components/PackagingUnitsEditor.d.ts.map +1 -1
  7. package/dist/admin/components/PackagingUnitsEditor.js +127 -10
  8. package/dist/admin/components/PackagingUnitsEditor.js.map +1 -1
  9. package/dist/admin/components/ProductAttachmentsSection.d.ts +5 -0
  10. package/dist/admin/components/ProductAttachmentsSection.d.ts.map +1 -0
  11. package/dist/admin/components/ProductAttachmentsSection.js +137 -0
  12. package/dist/admin/components/ProductAttachmentsSection.js.map +1 -0
  13. package/dist/admin/components/ProductGallerySection.d.ts +14 -0
  14. package/dist/admin/components/ProductGallerySection.d.ts.map +1 -0
  15. package/dist/admin/components/ProductGallerySection.js +385 -0
  16. package/dist/admin/components/ProductGallerySection.js.map +1 -0
  17. package/dist/admin/components/ProductOrderRulesCard.d.ts +19 -0
  18. package/dist/admin/components/ProductOrderRulesCard.d.ts.map +1 -0
  19. package/dist/admin/components/ProductOrderRulesCard.js +275 -0
  20. package/dist/admin/components/ProductOrderRulesCard.js.map +1 -0
  21. package/dist/admin/components/ProductScopeControls.d.ts +31 -0
  22. package/dist/admin/components/ProductScopeControls.d.ts.map +1 -0
  23. package/dist/admin/components/ProductScopeControls.js +243 -0
  24. package/dist/admin/components/ProductScopeControls.js.map +1 -0
  25. package/dist/admin/components/ProductScopeEditor.d.ts +12 -18
  26. package/dist/admin/components/ProductScopeEditor.d.ts.map +1 -1
  27. package/dist/admin/components/ProductScopeEditor.js +5 -4
  28. package/dist/admin/components/ProductScopeEditor.js.map +1 -1
  29. package/dist/admin/components/ProductScopeOverview.d.ts +26 -0
  30. package/dist/admin/components/ProductScopeOverview.d.ts.map +1 -0
  31. package/dist/admin/components/ProductScopeOverview.js +207 -0
  32. package/dist/admin/components/ProductScopeOverview.js.map +1 -0
  33. package/dist/admin/components/ProductStatusPills.d.ts +17 -0
  34. package/dist/admin/components/ProductStatusPills.d.ts.map +1 -0
  35. package/dist/admin/components/ProductStatusPills.js +23 -0
  36. package/dist/admin/components/ProductStatusPills.js.map +1 -0
  37. package/dist/admin/components/ProductUrlKeysPanel.d.ts +17 -0
  38. package/dist/admin/components/ProductUrlKeysPanel.d.ts.map +1 -0
  39. package/dist/admin/components/ProductUrlKeysPanel.js +215 -0
  40. package/dist/admin/components/ProductUrlKeysPanel.js.map +1 -0
  41. package/dist/admin/components/ProductsBulkEditDialog.d.ts +30 -0
  42. package/dist/admin/components/ProductsBulkEditDialog.d.ts.map +1 -1
  43. package/dist/admin/components/ProductsBulkEditDialog.js +308 -125
  44. package/dist/admin/components/ProductsBulkEditDialog.js.map +1 -1
  45. package/dist/admin/components/ScopedDialogParts.d.ts +23 -0
  46. package/dist/admin/components/ScopedDialogParts.d.ts.map +1 -0
  47. package/dist/admin/components/ScopedDialogParts.js +16 -0
  48. package/dist/admin/components/ScopedDialogParts.js.map +1 -0
  49. package/dist/admin/index.d.ts +2 -2
  50. package/dist/admin/index.d.ts.map +1 -1
  51. package/dist/admin/index.js +9 -0
  52. package/dist/admin/index.js.map +1 -1
  53. package/dist/admin/lib/attribute-scope.d.ts +20 -0
  54. package/dist/admin/lib/attribute-scope.d.ts.map +1 -0
  55. package/dist/admin/lib/attribute-scope.js +18 -0
  56. package/dist/admin/lib/attribute-scope.js.map +1 -0
  57. package/dist/admin/lib/bulk-operation-log-text.d.ts +9 -0
  58. package/dist/admin/lib/bulk-operation-log-text.d.ts.map +1 -0
  59. package/dist/admin/lib/bulk-operation-log-text.js +13 -0
  60. package/dist/admin/lib/bulk-operation-log-text.js.map +1 -0
  61. package/dist/admin/lib/media-scopes.d.ts +41 -0
  62. package/dist/admin/lib/media-scopes.d.ts.map +1 -0
  63. package/dist/admin/lib/media-scopes.js +66 -0
  64. package/dist/admin/lib/media-scopes.js.map +1 -0
  65. package/dist/admin/lib/product-labels.d.ts +14 -0
  66. package/dist/admin/lib/product-labels.d.ts.map +1 -0
  67. package/dist/admin/lib/product-labels.js +27 -0
  68. package/dist/admin/lib/product-labels.js.map +1 -0
  69. package/dist/admin/lib/product-scope-drafts.d.ts +77 -0
  70. package/dist/admin/lib/product-scope-drafts.d.ts.map +1 -0
  71. package/dist/admin/lib/product-scope-drafts.js +133 -0
  72. package/dist/admin/lib/product-scope-drafts.js.map +1 -0
  73. package/dist/admin/lib/product-scopes-api.d.ts +40 -0
  74. package/dist/admin/lib/product-scopes-api.d.ts.map +1 -0
  75. package/dist/admin/lib/product-scopes-api.js +101 -0
  76. package/dist/admin/lib/product-scopes-api.js.map +1 -0
  77. package/dist/admin/lib/product-url-keys-api.d.ts +46 -0
  78. package/dist/admin/lib/product-url-keys-api.d.ts.map +1 -0
  79. package/dist/admin/lib/product-url-keys-api.js +110 -0
  80. package/dist/admin/lib/product-url-keys-api.js.map +1 -0
  81. package/dist/admin/lib/resolve-product-selection.d.ts +29 -1
  82. package/dist/admin/lib/resolve-product-selection.d.ts.map +1 -1
  83. package/dist/admin/lib/resolve-product-selection.js +42 -6
  84. package/dist/admin/lib/resolve-product-selection.js.map +1 -1
  85. package/dist/admin/lib/scope-overview.d.ts +74 -0
  86. package/dist/admin/lib/scope-overview.d.ts.map +1 -0
  87. package/dist/admin/lib/scope-overview.js +173 -0
  88. package/dist/admin/lib/scope-overview.js.map +1 -0
  89. package/dist/admin/pages/AttributesManager.d.ts.map +1 -1
  90. package/dist/admin/pages/AttributesManager.js +84 -7
  91. package/dist/admin/pages/AttributesManager.js.map +1 -1
  92. package/dist/admin/pages/BulkOperationDetailPage.d.ts.map +1 -1
  93. package/dist/admin/pages/BulkOperationDetailPage.js +4 -19
  94. package/dist/admin/pages/BulkOperationDetailPage.js.map +1 -1
  95. package/dist/admin/pages/ProductEditor.d.ts +0 -4
  96. package/dist/admin/pages/ProductEditor.d.ts.map +1 -1
  97. package/dist/admin/pages/ProductEditor.js +221 -374
  98. package/dist/admin/pages/ProductEditor.js.map +1 -1
  99. package/dist/admin/pages/ProductsList.d.ts +12 -0
  100. package/dist/admin/pages/ProductsList.d.ts.map +1 -1
  101. package/dist/admin/pages/ProductsList.js +105 -38
  102. package/dist/admin/pages/ProductsList.js.map +1 -1
  103. package/dist/backend/admin-search-provider.d.ts +1 -1
  104. package/dist/backend/admin-search-provider.d.ts.map +1 -1
  105. package/dist/backend/admin-search-provider.js +1 -2
  106. package/dist/backend/admin-search-provider.js.map +1 -1
  107. package/dist/backend/demo/reset.d.ts +1 -1
  108. package/dist/backend/demo/rows.d.ts +14 -3
  109. package/dist/backend/demo/rows.d.ts.map +1 -1
  110. package/dist/backend/demo/rows.js +24 -17
  111. package/dist/backend/demo/rows.js.map +1 -1
  112. package/dist/backend/demo/seed.d.ts.map +1 -1
  113. package/dist/backend/demo/seed.js +3 -6
  114. package/dist/backend/demo/seed.js.map +1 -1
  115. package/dist/backend/entities/bulk-operation.entity.d.ts +10 -0
  116. package/dist/backend/entities/bulk-operation.entity.d.ts.map +1 -1
  117. package/dist/backend/entities/bulk-operation.entity.js.map +1 -1
  118. package/dist/backend/entities/gallery-item-channel-hidden.entity.d.ts +14 -0
  119. package/dist/backend/entities/gallery-item-channel-hidden.entity.d.ts.map +1 -0
  120. package/dist/backend/entities/gallery-item-channel-hidden.entity.js +42 -0
  121. package/dist/backend/entities/gallery-item-channel-hidden.entity.js.map +1 -0
  122. package/dist/backend/entities/gallery-item-channel-label.entity.d.ts +18 -0
  123. package/dist/backend/entities/gallery-item-channel-label.entity.d.ts.map +1 -0
  124. package/dist/backend/entities/gallery-item-channel-label.entity.js +49 -0
  125. package/dist/backend/entities/gallery-item-channel-label.entity.js.map +1 -0
  126. package/dist/backend/entities/gallery-item.entity.d.ts +8 -1
  127. package/dist/backend/entities/gallery-item.entity.d.ts.map +1 -1
  128. package/dist/backend/entities/gallery-item.entity.js +11 -0
  129. package/dist/backend/entities/gallery-item.entity.js.map +1 -1
  130. package/dist/backend/entities/product-attachment-channel-hidden.entity.d.ts +13 -0
  131. package/dist/backend/entities/product-attachment-channel-hidden.entity.d.ts.map +1 -0
  132. package/dist/backend/entities/product-attachment-channel-hidden.entity.js +41 -0
  133. package/dist/backend/entities/product-attachment-channel-hidden.entity.js.map +1 -0
  134. package/dist/backend/entities/product-attachment.entity.d.ts +8 -1
  135. package/dist/backend/entities/product-attachment.entity.d.ts.map +1 -1
  136. package/dist/backend/entities/product-attachment.entity.js +15 -0
  137. package/dist/backend/entities/product-attachment.entity.js.map +1 -1
  138. package/dist/backend/entities/product-channel-language-scope.entity.d.ts +23 -0
  139. package/dist/backend/entities/product-channel-language-scope.entity.d.ts.map +1 -0
  140. package/dist/backend/entities/product-channel-language-scope.entity.js +61 -0
  141. package/dist/backend/entities/product-channel-language-scope.entity.js.map +1 -0
  142. package/dist/backend/entities/product-channel-scope.entity.d.ts +42 -0
  143. package/dist/backend/entities/product-channel-scope.entity.d.ts.map +1 -0
  144. package/dist/backend/entities/product-channel-scope.entity.js +104 -0
  145. package/dist/backend/entities/product-channel-scope.entity.js.map +1 -0
  146. package/dist/backend/entities/product-packaging-unit.entity.d.ts +13 -1
  147. package/dist/backend/entities/product-packaging-unit.entity.d.ts.map +1 -1
  148. package/dist/backend/entities/product-packaging-unit.entity.js +20 -0
  149. package/dist/backend/entities/product-packaging-unit.entity.js.map +1 -1
  150. package/dist/backend/entities/product-url-key.entity.d.ts +32 -0
  151. package/dist/backend/entities/product-url-key.entity.d.ts.map +1 -0
  152. package/dist/backend/entities/product-url-key.entity.js +75 -0
  153. package/dist/backend/entities/product-url-key.entity.js.map +1 -0
  154. package/dist/backend/entities/product-url-redirect.entity.d.ts +23 -0
  155. package/dist/backend/entities/product-url-redirect.entity.d.ts.map +1 -0
  156. package/dist/backend/entities/product-url-redirect.entity.js +58 -0
  157. package/dist/backend/entities/product-url-redirect.entity.js.map +1 -0
  158. package/dist/backend/entities/product-variant.entity.d.ts +1 -2
  159. package/dist/backend/entities/product-variant.entity.d.ts.map +1 -1
  160. package/dist/backend/entities/product-variant.entity.js +0 -5
  161. package/dist/backend/entities/product-variant.entity.js.map +1 -1
  162. package/dist/backend/entities/product.entity.d.ts +41 -2
  163. package/dist/backend/entities/product.entity.d.ts.map +1 -1
  164. package/dist/backend/entities/product.entity.js +84 -1
  165. package/dist/backend/entities/product.entity.js.map +1 -1
  166. package/dist/backend/index.d.ts +27 -6
  167. package/dist/backend/index.d.ts.map +1 -1
  168. package/dist/backend/index.js +209 -15
  169. package/dist/backend/index.js.map +1 -1
  170. package/dist/backend/plugin.d.ts +45 -4
  171. package/dist/backend/plugin.d.ts.map +1 -1
  172. package/dist/backend/plugin.js +67 -9
  173. package/dist/backend/plugin.js.map +1 -1
  174. package/dist/backend/prompt-tools.d.ts +10 -0
  175. package/dist/backend/prompt-tools.d.ts.map +1 -1
  176. package/dist/backend/prompt-tools.js +108 -4
  177. package/dist/backend/prompt-tools.js.map +1 -1
  178. package/dist/backend/routes.admin.d.ts +29 -0
  179. package/dist/backend/routes.admin.d.ts.map +1 -1
  180. package/dist/backend/routes.admin.js +161 -55
  181. package/dist/backend/routes.admin.js.map +1 -1
  182. package/dist/backend/routes.admin.url-keys.d.ts +23 -0
  183. package/dist/backend/routes.admin.url-keys.d.ts.map +1 -0
  184. package/dist/backend/routes.admin.url-keys.js +14 -0
  185. package/dist/backend/routes.admin.url-keys.js.map +1 -0
  186. package/dist/backend/routes.api-key.d.ts.map +1 -1
  187. package/dist/backend/routes.api-key.js +14 -1
  188. package/dist/backend/routes.api-key.js.map +1 -1
  189. package/dist/backend/routes.external.d.ts.map +1 -1
  190. package/dist/backend/routes.external.js +6 -1
  191. package/dist/backend/routes.external.js.map +1 -1
  192. package/dist/backend/routes.public.d.ts +24 -7
  193. package/dist/backend/routes.public.d.ts.map +1 -1
  194. package/dist/backend/routes.public.js +58 -29
  195. package/dist/backend/routes.public.js.map +1 -1
  196. package/dist/backend/routes.public.url-keys.d.ts +26 -0
  197. package/dist/backend/routes.public.url-keys.d.ts.map +1 -0
  198. package/dist/backend/routes.public.url-keys.js +17 -0
  199. package/dist/backend/routes.public.url-keys.js.map +1 -0
  200. package/dist/backend/services/asset-references.js +43 -30
  201. package/dist/backend/services/asset-references.js.map +1 -1
  202. package/dist/backend/services/attachment-packaging-scopes.d.ts +43 -0
  203. package/dist/backend/services/attachment-packaging-scopes.d.ts.map +1 -0
  204. package/dist/backend/services/attachment-packaging-scopes.js +115 -0
  205. package/dist/backend/services/attachment-packaging-scopes.js.map +1 -0
  206. package/dist/backend/services/attachment.service.d.ts +12 -1
  207. package/dist/backend/services/attachment.service.d.ts.map +1 -1
  208. package/dist/backend/services/attachment.service.js +119 -21
  209. package/dist/backend/services/attachment.service.js.map +1 -1
  210. package/dist/backend/services/attribute-scope-preview.d.ts +38 -0
  211. package/dist/backend/services/attribute-scope-preview.d.ts.map +1 -0
  212. package/dist/backend/services/attribute-scope-preview.js +66 -0
  213. package/dist/backend/services/attribute-scope-preview.js.map +1 -0
  214. package/dist/backend/services/bulk-operation.service.d.ts +36 -0
  215. package/dist/backend/services/bulk-operation.service.d.ts.map +1 -1
  216. package/dist/backend/services/bulk-operation.service.js +203 -36
  217. package/dist/backend/services/bulk-operation.service.js.map +1 -1
  218. package/dist/backend/services/bundle.service.d.ts +9 -1
  219. package/dist/backend/services/bundle.service.d.ts.map +1 -1
  220. package/dist/backend/services/bundle.service.js +12 -2
  221. package/dist/backend/services/bundle.service.js.map +1 -1
  222. package/dist/backend/services/catalog-admin-search.service.d.ts +1 -1
  223. package/dist/backend/services/catalog-admin-search.service.js +1 -1
  224. package/dist/backend/services/catalog-admin.service.d.ts +125 -18
  225. package/dist/backend/services/catalog-admin.service.d.ts.map +1 -1
  226. package/dist/backend/services/catalog-admin.service.js +367 -164
  227. package/dist/backend/services/catalog-admin.service.js.map +1 -1
  228. package/dist/backend/services/catalog-bulk-import.service.d.ts +24 -2
  229. package/dist/backend/services/catalog-bulk-import.service.d.ts.map +1 -1
  230. package/dist/backend/services/catalog-bulk-import.service.js +132 -6
  231. package/dist/backend/services/catalog-bulk-import.service.js.map +1 -1
  232. package/dist/backend/services/catalog-bulk-update.service.d.ts +32 -4
  233. package/dist/backend/services/catalog-bulk-update.service.d.ts.map +1 -1
  234. package/dist/backend/services/catalog-bulk-update.service.js +115 -12
  235. package/dist/backend/services/catalog-bulk-update.service.js.map +1 -1
  236. package/dist/backend/services/catalog-org-price-decorator.d.ts +18 -27
  237. package/dist/backend/services/catalog-org-price-decorator.d.ts.map +1 -1
  238. package/dist/backend/services/catalog-org-price-decorator.js +77 -33
  239. package/dist/backend/services/catalog-org-price-decorator.js.map +1 -1
  240. package/dist/backend/services/catalog-product-filter.service.d.ts +16 -2
  241. package/dist/backend/services/catalog-product-filter.service.d.ts.map +1 -1
  242. package/dist/backend/services/catalog-product-filter.service.js +80 -3
  243. package/dist/backend/services/catalog-product-filter.service.js.map +1 -1
  244. package/dist/backend/services/catalog-product-read.service.d.ts +45 -3
  245. package/dist/backend/services/catalog-product-read.service.d.ts.map +1 -1
  246. package/dist/backend/services/catalog-product-read.service.js +130 -3
  247. package/dist/backend/services/catalog-product-read.service.js.map +1 -1
  248. package/dist/backend/services/catalog-query.service.d.ts +145 -40
  249. package/dist/backend/services/catalog-query.service.d.ts.map +1 -1
  250. package/dist/backend/services/catalog-query.service.js +1048 -391
  251. package/dist/backend/services/catalog-query.service.js.map +1 -1
  252. package/dist/backend/services/catalog-quick-search.service.d.ts +18 -2
  253. package/dist/backend/services/catalog-quick-search.service.d.ts.map +1 -1
  254. package/dist/backend/services/catalog-quick-search.service.js +52 -20
  255. package/dist/backend/services/catalog-quick-search.service.js.map +1 -1
  256. package/dist/backend/services/catalog-write-ports.d.ts +18 -1
  257. package/dist/backend/services/catalog-write-ports.d.ts.map +1 -1
  258. package/dist/backend/services/catalog-write-ports.js +77 -0
  259. package/dist/backend/services/catalog-write-ports.js.map +1 -1
  260. package/dist/backend/services/category-admin.service.d.ts +12 -1
  261. package/dist/backend/services/category-admin.service.d.ts.map +1 -1
  262. package/dist/backend/services/category-admin.service.js +23 -2
  263. package/dist/backend/services/category-admin.service.js.map +1 -1
  264. package/dist/backend/services/channel-url-facts.d.ts +17 -0
  265. package/dist/backend/services/channel-url-facts.d.ts.map +1 -0
  266. package/dist/backend/services/channel-url-facts.js +20 -0
  267. package/dist/backend/services/channel-url-facts.js.map +1 -0
  268. package/dist/backend/services/effective-value.sql.d.ts +56 -0
  269. package/dist/backend/services/effective-value.sql.d.ts.map +1 -0
  270. package/dist/backend/services/effective-value.sql.js +111 -0
  271. package/dist/backend/services/effective-value.sql.js.map +1 -0
  272. package/dist/backend/services/gallery-scopes.d.ts +40 -0
  273. package/dist/backend/services/gallery-scopes.d.ts.map +1 -0
  274. package/dist/backend/services/gallery-scopes.js +151 -0
  275. package/dist/backend/services/gallery-scopes.js.map +1 -0
  276. package/dist/backend/services/gallery.service.d.ts +46 -4
  277. package/dist/backend/services/gallery.service.d.ts.map +1 -1
  278. package/dist/backend/services/gallery.service.js +308 -46
  279. package/dist/backend/services/gallery.service.js.map +1 -1
  280. package/dist/backend/services/linkable-asset.d.ts +21 -0
  281. package/dist/backend/services/linkable-asset.d.ts.map +1 -0
  282. package/dist/backend/services/linkable-asset.js +31 -0
  283. package/dist/backend/services/linkable-asset.js.map +1 -0
  284. package/dist/backend/services/packaging-unit.service.d.ts.map +1 -1
  285. package/dist/backend/services/packaging-unit.service.js +95 -29
  286. package/dist/backend/services/packaging-unit.service.js.map +1 -1
  287. package/dist/backend/services/primary-asset-url.d.ts +7 -1
  288. package/dist/backend/services/primary-asset-url.d.ts.map +1 -1
  289. package/dist/backend/services/primary-asset-url.js +45 -14
  290. package/dist/backend/services/primary-asset-url.js.map +1 -1
  291. package/dist/backend/services/product-availability.service.d.ts +79 -0
  292. package/dist/backend/services/product-availability.service.d.ts.map +1 -0
  293. package/dist/backend/services/product-availability.service.js +223 -0
  294. package/dist/backend/services/product-availability.service.js.map +1 -0
  295. package/dist/backend/services/product-availability.sql.d.ts +71 -0
  296. package/dist/backend/services/product-availability.sql.d.ts.map +1 -0
  297. package/dist/backend/services/product-availability.sql.js +77 -0
  298. package/dist/backend/services/product-availability.sql.js.map +1 -0
  299. package/dist/backend/services/product-link.service.d.ts +10 -9
  300. package/dist/backend/services/product-link.service.d.ts.map +1 -1
  301. package/dist/backend/services/product-link.service.js +48 -23
  302. package/dist/backend/services/product-link.service.js.map +1 -1
  303. package/dist/backend/services/product-overrides.service.d.ts +9 -2
  304. package/dist/backend/services/product-overrides.service.d.ts.map +1 -1
  305. package/dist/backend/services/product-overrides.service.js +13 -6
  306. package/dist/backend/services/product-overrides.service.js.map +1 -1
  307. package/dist/backend/services/product-page-revalidation.d.ts +51 -0
  308. package/dist/backend/services/product-page-revalidation.d.ts.map +1 -0
  309. package/dist/backend/services/product-page-revalidation.js +146 -0
  310. package/dist/backend/services/product-page-revalidation.js.map +1 -0
  311. package/dist/backend/services/product-scope-context.service.d.ts.map +1 -1
  312. package/dist/backend/services/product-scope-context.service.js +3 -2
  313. package/dist/backend/services/product-scope-context.service.js.map +1 -1
  314. package/dist/backend/services/product-scopes.service.d.ts +212 -0
  315. package/dist/backend/services/product-scopes.service.d.ts.map +1 -0
  316. package/dist/backend/services/product-scopes.service.js +638 -0
  317. package/dist/backend/services/product-scopes.service.js.map +1 -0
  318. package/dist/backend/services/product-summary-text.d.ts +8 -0
  319. package/dist/backend/services/product-summary-text.d.ts.map +1 -0
  320. package/dist/backend/services/product-summary-text.js +8 -0
  321. package/dist/backend/services/product-summary-text.js.map +1 -0
  322. package/dist/backend/services/product-value-resolver.service.d.ts +11 -1
  323. package/dist/backend/services/product-value-resolver.service.d.ts.map +1 -1
  324. package/dist/backend/services/product-value-resolver.service.js +29 -9
  325. package/dist/backend/services/product-value-resolver.service.js.map +1 -1
  326. package/dist/backend/services/publication-window-sweep.d.ts +77 -0
  327. package/dist/backend/services/publication-window-sweep.d.ts.map +1 -0
  328. package/dist/backend/services/publication-window-sweep.js +117 -0
  329. package/dist/backend/services/publication-window-sweep.js.map +1 -0
  330. package/dist/backend/services/scope-completeness.d.ts +107 -0
  331. package/dist/backend/services/scope-completeness.d.ts.map +1 -0
  332. package/dist/backend/services/scope-completeness.js +180 -0
  333. package/dist/backend/services/scope-completeness.js.map +1 -0
  334. package/dist/backend/services/scope-overview.service.d.ts +112 -0
  335. package/dist/backend/services/scope-overview.service.d.ts.map +1 -0
  336. package/dist/backend/services/scope-overview.service.js +372 -0
  337. package/dist/backend/services/scope-overview.service.js.map +1 -0
  338. package/dist/backend/services/sql-id-arrays.d.ts +16 -0
  339. package/dist/backend/services/sql-id-arrays.d.ts.map +1 -0
  340. package/dist/backend/services/sql-id-arrays.js +24 -0
  341. package/dist/backend/services/sql-id-arrays.js.map +1 -0
  342. package/dist/backend/services/storefront-value-overrides.d.ts +31 -0
  343. package/dist/backend/services/storefront-value-overrides.d.ts.map +1 -0
  344. package/dist/backend/services/storefront-value-overrides.js +48 -0
  345. package/dist/backend/services/storefront-value-overrides.js.map +1 -0
  346. package/dist/backend/services/url-key-resolution.service.d.ts +76 -0
  347. package/dist/backend/services/url-key-resolution.service.d.ts.map +1 -0
  348. package/dist/backend/services/url-key-resolution.service.js +179 -0
  349. package/dist/backend/services/url-key-resolution.service.js.map +1 -0
  350. package/dist/backend/services/url-key.service.d.ts +171 -0
  351. package/dist/backend/services/url-key.service.d.ts.map +1 -0
  352. package/dist/backend/services/url-key.service.js +738 -0
  353. package/dist/backend/services/url-key.service.js.map +1 -0
  354. package/dist/manifest.d.ts +3 -1
  355. package/dist/manifest.d.ts.map +1 -1
  356. package/dist/manifest.js +188 -13
  357. package/dist/manifest.js.map +1 -1
  358. package/dist/migrations/20261016T082008_catalog_order_rules.d.ts +22 -0
  359. package/dist/migrations/20261016T082008_catalog_order_rules.d.ts.map +1 -0
  360. package/dist/migrations/20261016T082008_catalog_order_rules.js +48 -0
  361. package/dist/migrations/20261016T082008_catalog_order_rules.js.map +1 -0
  362. package/dist/migrations/20261022T035133_catalog_product_scopes.d.ts +28 -0
  363. package/dist/migrations/20261022T035133_catalog_product_scopes.d.ts.map +1 -0
  364. package/dist/migrations/20261022T035133_catalog_product_scopes.js +92 -0
  365. package/dist/migrations/20261022T035133_catalog_product_scopes.js.map +1 -0
  366. package/dist/migrations/20261022T054223_catalog_product_url_keys.d.ts +32 -0
  367. package/dist/migrations/20261022T054223_catalog_product_url_keys.d.ts.map +1 -0
  368. package/dist/migrations/20261022T054223_catalog_product_url_keys.js +81 -0
  369. package/dist/migrations/20261022T054223_catalog_product_url_keys.js.map +1 -0
  370. package/dist/migrations/20261022T111811_catalog_price_fields_removed.d.ts +26 -0
  371. package/dist/migrations/20261022T111811_catalog_price_fields_removed.d.ts.map +1 -0
  372. package/dist/migrations/20261022T111811_catalog_price_fields_removed.js +32 -0
  373. package/dist/migrations/20261022T111811_catalog_price_fields_removed.js.map +1 -0
  374. package/dist/migrations/20261022T182523_catalog_admin_name_keys.d.ts +38 -0
  375. package/dist/migrations/20261022T182523_catalog_admin_name_keys.d.ts.map +1 -0
  376. package/dist/migrations/20261022T182523_catalog_admin_name_keys.js +89 -0
  377. package/dist/migrations/20261022T182523_catalog_admin_name_keys.js.map +1 -0
  378. package/dist/migrations/20261025T222634_catalog_product_status_drop_draft.d.ts +34 -0
  379. package/dist/migrations/20261025T222634_catalog_product_status_drop_draft.d.ts.map +1 -0
  380. package/dist/migrations/20261025T222634_catalog_product_status_drop_draft.js +57 -0
  381. package/dist/migrations/20261025T222634_catalog_product_status_drop_draft.js.map +1 -0
  382. package/dist/migrations/20261026T033453_catalog_product_media_scopes.d.ts +26 -0
  383. package/dist/migrations/20261026T033453_catalog_product_media_scopes.d.ts.map +1 -0
  384. package/dist/migrations/20261026T033453_catalog_product_media_scopes.js +54 -0
  385. package/dist/migrations/20261026T033453_catalog_product_media_scopes.js.map +1 -0
  386. package/dist/migrations/20261026T084533_catalog_attachment_packaging_translations.d.ts +27 -0
  387. package/dist/migrations/20261026T084533_catalog_attachment_packaging_translations.d.ts.map +1 -0
  388. package/dist/migrations/20261026T084533_catalog_attachment_packaging_translations.js +45 -0
  389. package/dist/migrations/20261026T084533_catalog_attachment_packaging_translations.js.map +1 -0
  390. package/dist/migrations/index.d.ts +9 -1
  391. package/dist/migrations/index.d.ts.map +1 -1
  392. package/dist/migrations/index.js +17 -1
  393. package/dist/migrations/index.js.map +1 -1
  394. package/docs/catalog/attachments.md +46 -4
  395. package/docs/catalog/attributes.md +11 -6
  396. package/docs/catalog/gallery-and-labels.md +63 -4
  397. package/docs/catalog/packaging-units.md +82 -8
  398. package/docs/catalog/per-channel-per-language-overrides.md +195 -10
  399. package/docs/catalog/url-keys-and-redirects.md +142 -0
  400. package/docs/catalog.md +326 -17
  401. package/i18n/en.json +931 -53
  402. package/i18n/pl.json +930 -52
  403. package/package.json +10 -10
@@ -1,41 +1,51 @@
1
1
  import { randomUUID } from 'crypto';
2
- import { UniqueConstraintViolationException } from '@mikro-orm/core';
3
- import { ERROR_CODES,
2
+ import { LockMode, UniqueConstraintViolationException } from '@mikro-orm/core';
3
+ import { ERROR_CODES, isOrderMinimumEligibleType, isValidOrderMinimum, PRICE_FIELDS_REFUSED_ON_PRODUCTS,
4
4
  // Aliased: the private method below keeps the name, so the shared function
5
5
  // needs one the class body cannot shadow.
6
- slugify as slugifyText, } from '@endora-commerce/contracts';
6
+ slugify as slugifyText, uuidSchema, } from '@endora-commerce/contracts';
7
7
  import { HttpError } from '@endora-commerce/platform/http';
8
8
  import { Category } from '../entities/category.entity.js';
9
9
  import { Product } from '../entities/product.entity.js';
10
+ import { ProductUrlRedirect } from '../entities/product-url-redirect.entity.js';
11
+ import { isUrlKeyFree, lockUrlKeys } from './url-key.service.js';
10
12
  import { ProductVariant } from '../entities/product-variant.entity.js';
13
+ import { ProductChannelScope } from '../entities/product-channel-scope.entity.js';
14
+ import { ProductChannelLanguageScope } from '../entities/product-channel-language-scope.entity.js';
15
+ import { globalScopeFields } from './product-availability.service.js';
16
+ import { toChannelRecord, toLanguageRecord } from './product-scopes.service.js';
11
17
  import { assertVirtualDownloadFields, ProductTypeValidationError, } from './product-type-validations.js';
12
18
  import { createAttributeCommand, createAttributeOptionCommand, deleteAttributeCommand, deleteAttributeOptionCommand, updateAttributeCommand, updateAttributeOptionCommand, } from '../commands/attribute-commands.js';
19
+ import { requireLinkableAsset } from './linkable-asset.js';
13
20
  // Feature 061 — the API-form mapping helpers moved next to the R7 map; the
14
21
  // re-exports keep the long-standing import site (routes, tests) stable.
15
22
  export { dbToApiAttributeType, resolveAttributeApiType } from './attribute-type-mapping.js';
16
23
  /**
17
- * Virtual attribute-value keys that are NOT bound to any AttributeSet but are
18
- * legitimately stored under `product.attributeValues`. `defaultPrice` / `price`
19
- * are the per-product base price the Details tab edits and the PriceList engine
20
- * reads (see `default-price-list-migration.ts`). They must never be rejected by
21
- * `assertAttributeValueKeysAllowed`, otherwise every save that carries a price
22
- * (i.e. nearly all of them) fails with ATTRIBUTE_VALUE_REJECTED.
24
+ * How many free-looking slug candidates `allocateUniqueSlug` locks at once (Phase 16
25
+ * review): enough that a concurrent writer winning one does not fail the allocation.
23
26
  */
24
- const VIRTUAL_ATTRIBUTE_VALUE_KEYS = new Set([
25
- 'defaultPrice',
26
- 'price',
27
- ]);
27
+ const SLUG_CANDIDATE_LOCKS = 3;
28
+ /**
29
+ * Feature 160 (FR-043) — a product has no price of its own: a price is a row of
30
+ * a price book (D-287 §5.8). The old *default price* keys of `attributeValues`
31
+ * are refused on every write rather than stored where nothing reads them, with
32
+ * a code that says where prices are set. Exported for the routes, which refuse
33
+ * the same names at the top level of an old client's body.
34
+ */
35
+ export function refusePriceFields(fields, pathPrefix = '') {
36
+ if (!fields)
37
+ return;
38
+ const named = PRICE_FIELDS_REFUSED_ON_PRODUCTS.filter((key) => Object.prototype.hasOwnProperty.call(fields, key));
39
+ if (named.length === 0)
40
+ return;
41
+ throw new HttpError(400, ERROR_CODES.PRICE_SET_IN_PRICE_BOOKS, 'Prices are set in price books, not on the product.', named.map((key) => ({ path: `${pathPrefix}${key}`, issue: 'prices are set in price books' })));
42
+ }
28
43
  /**
29
44
  * Feature 068 — the width of `products.sku` / `product_variants.sku` and the
30
45
  * cap the create and update contracts enforce. Nothing may write a longer
31
46
  * identifier, derived or otherwise.
32
47
  */
33
48
  const SKU_MAX_LENGTH = 255;
34
- /**
35
- * Catalog write-path service (admin write surface).
36
- * Every mutation emits a typed event on the shared bus so the search indexer
37
- * (T067) and webhook bridge (Phase 2 T037) can react.
38
- */
39
49
  export class CatalogAdminService {
40
50
  emFactory;
41
51
  events;
@@ -45,6 +55,8 @@ export class CatalogAdminService {
45
55
  attributeRead;
46
56
  customFields;
47
57
  copyWarehouseThresholds;
58
+ completenessGate;
59
+ assets;
48
60
  constructor(emFactory, events, auditLog,
49
61
  /**
50
62
  * Feature 005 / T027 — when injected, every newly-created Product
@@ -78,7 +90,21 @@ export class CatalogAdminService {
78
90
  * keep constructing this service, and a duplicate with no thresholds copied
79
91
  * is the module's declared degrade rather than a failure.
80
92
  */
81
- copyWarehouseThresholds) {
93
+ copyWarehouseThresholds,
94
+ /**
95
+ * Feature 163 (FR-060, FR-061) — the completeness gate for an operator's change of
96
+ * the global status. Composed into the admin routes' instance only; it runs only
97
+ * when a call passes a mode ({@link ProductUpdateGate}), so the integration ports
98
+ * and the API-key upsert, which never do, are never gated (A-6).
99
+ */
100
+ completenessGate,
101
+ /**
102
+ * Feature 166 (FR-006) — `assets_library`'s read port, asked before a
103
+ * download file is linked. Optional so fixtures without the library keep
104
+ * constructing the service; a create that names a file without it fails
105
+ * closed ({@link CatalogAdminService.#requireAssets}).
106
+ */
107
+ assets) {
82
108
  this.emFactory = emFactory;
83
109
  this.events = events;
84
110
  this.auditLog = auditLog;
@@ -87,6 +113,18 @@ export class CatalogAdminService {
87
113
  this.attributeRead = attributeRead;
88
114
  this.customFields = customFields;
89
115
  this.copyWarehouseThresholds = copyWarehouseThresholds;
116
+ this.completenessGate = completenessGate;
117
+ this.assets = assets;
118
+ }
119
+ #requireAssets() {
120
+ if (!this.assets) {
121
+ throw new Error('CatalogAdminService: the asset read port is not wired — a download file cannot be linked.');
122
+ }
123
+ return this.assets;
124
+ }
125
+ /** The gate's mode for an operator's write, read once per request; `undefined` where no gate is composed. */
126
+ async completenessMode() {
127
+ return this.completenessGate?.mode();
90
128
  }
91
129
  #requireAttributeRead() {
92
130
  if (!this.attributeRead) {
@@ -157,6 +195,7 @@ export class CatalogAdminService {
157
195
  * the actor is now derived server-side from the ambient TenantContext.
158
196
  */
159
197
  async createProduct(req, _auditCtx) {
198
+ refusePriceFields(req.attributeValues, 'attributeValues.');
160
199
  // Feature 002 (T047): cross-field validation for virtual download
161
200
  // fields. Zod's .refine() catches most cases at the boundary; the
162
201
  // service-level guard is the belt-and-braces backstop for any
@@ -174,6 +213,13 @@ export class CatalogAdminService {
174
213
  }
175
214
  throw err;
176
215
  }
216
+ // Feature 155 (FR-001, D5) — the range and the type rule hold for every
217
+ // caller, not only for the ones a route schema stands in front of.
218
+ assertOrderMinimumAllowed(req.type, req.minOrderQuantity);
219
+ // Feature 166 (FR-006) — a download file the caller may not see answers
220
+ // as a missing one, and is never linked.
221
+ if (req.downloadAssetId)
222
+ await requireLinkableAsset(this.#requireAssets(), req.downloadAssetId);
177
223
  // The id is allocated up front so the Command can name its audit target
178
224
  // before the row exists (same shape as `duplicateProduct`).
179
225
  const productId = randomUUID();
@@ -212,7 +258,8 @@ export class CatalogAdminService {
212
258
  sku: req.sku,
213
259
  slug,
214
260
  type: req.type,
215
- status: req.status ?? 'draft',
261
+ // Feature 163 (Q1-d) — a product starts switched off.
262
+ status: req.status ?? 'inactive',
216
263
  name: req.name,
217
264
  description: req.description,
218
265
  stockMode: req.stockMode ?? null,
@@ -227,6 +274,9 @@ export class CatalogAdminService {
227
274
  ? { downloadAssetId: req.downloadAssetId }
228
275
  : {}),
229
276
  ...(req.downloadUrl !== undefined ? { downloadUrl: req.downloadUrl } : {}),
277
+ // Feature 155 (FR-001, FR-003) — the order rules, when the request names them.
278
+ ...(req.minOrderQuantity !== undefined ? { minOrderQuantity: req.minOrderQuantity } : {}),
279
+ ...(req.returnable !== undefined ? { returnable: req.returnable } : {}),
230
280
  });
231
281
  // Feature 002 (T023): the keys in `attributeValues` MUST belong to
232
282
  // the Product's AttributeSet. The entity defaults `attributeSetId`
@@ -255,6 +305,8 @@ export class CatalogAdminService {
255
305
  visibility: product.visibility,
256
306
  stockMode: product.stockMode,
257
307
  categoryIds,
308
+ minOrderQuantity: product.minOrderQuantity ?? null,
309
+ returnable: product.returnable,
258
310
  },
259
311
  };
260
312
  },
@@ -269,9 +321,9 @@ export class CatalogAdminService {
269
321
  }),
270
322
  };
271
323
  }
272
- async updateProduct(id, req, auditCtx) {
324
+ async updateProduct(id, req, auditCtx, gate) {
273
325
  const em = this.emFactory();
274
- const r = await this.#applyProductUpdate(em, id, req);
326
+ const r = await this.#applyProductUpdate(em, id, req, gate);
275
327
  await em.flush();
276
328
  if (this.auditLog && auditCtx) {
277
329
  await this.auditLog.record({
@@ -289,44 +341,38 @@ export class CatalogAdminService {
289
341
  ...(auditCtx.requestId !== undefined ? { requestId: auditCtx.requestId } : {}),
290
342
  });
291
343
  }
292
- const announceUpdated = () => this.events.emit('product.updated.v1', {
344
+ // Feature 163 (FR-010) — a status write never archives, so this write has
345
+ // one announcement; `product.archived.v1` belongs to the Archive action.
346
+ this.events.emit('product.updated.v1', {
293
347
  eventId: randomUUID(),
294
348
  occurredAt: new Date().toISOString(),
295
349
  productId: r.product.id,
296
350
  changedFields: r.changedFields,
297
351
  });
298
- if (r.archived) {
299
- // Two announcements of one write, in one event scope: outside a scope the
300
- // bus starts each emit's subscribers at once and waits for none, so the
301
- // two ran side by side and a subscriber could be handed
302
- // `product.archived.v1` first. A scope dispatches in order and waits, so
303
- // every subscriber sees "updated, then archived" — the order the audited
304
- // path already had — and the search indexer's removal has finished
305
- // before this returns, which is what keeps a reactivation that follows
306
- // from being undone by a removal still on its way.
307
- await this.events.run(async () => {
308
- announceUpdated();
309
- this.#emitArchived(r.product.id);
310
- });
311
- }
312
- else {
313
- announceUpdated();
314
- }
315
352
  return r.product;
316
353
  }
354
+ /** The completeness gate for `product`'s global status going to `status` (FR-060). */
355
+ async #gateGlobalStatus(em, product, status, mode) {
356
+ const gate = this.completenessGate;
357
+ const [channelRows, languageRows, channels] = await Promise.all([
358
+ em.find(ProductChannelScope, { productId: product.id }),
359
+ em.find(ProductChannelLanguageScope, { productId: product.id }),
360
+ gate.memberChannels(product.id),
361
+ ]);
362
+ const before = {
363
+ global: globalScopeFields(product),
364
+ channelRows: channelRows.map(toChannelRecord),
365
+ languageRows: languageRows.map(toLanguageRecord),
366
+ };
367
+ const after = { ...before, global: { ...before.global, status } };
368
+ return gate.enforce(em, product, before, after, channels, mode);
369
+ }
317
370
  /**
318
- * `product.archived.v1` — the product's status moved to `inactive`.
319
- *
320
- * Emitted by the update paths themselves, after the write has committed and
321
- * after the `product.updated.v1` of the same write, inside an event scope
322
- * the path opens — see the two call sites for why. It used to be emitted
323
- * only by `archiveProduct`, which nothing calls: archiving has been "update
324
- * with `status: 'inactive'`" since feature 022, so the event the search
325
- * indexer subscribes to and outbound webhooks are offered was announced by
326
- * no path an operator, an importer or a PIM sync can take.
327
- *
328
- * Once per transition: a product that is already inactive is not archived
329
- * again by a further edit, nor by a write naming the same status.
371
+ * `product.archived.v1` — the product was archived by the Archive action
372
+ * (feature 163, FR-019). Emitted by {@link archiveProduct} alone, after the
373
+ * write has committed and after its `product.updated.v1` `['archivedAt']`,
374
+ * inside the event scope that method opens. Once per transition: archiving an
375
+ * archived product announces nothing.
330
376
  */
331
377
  #emitArchived(productId) {
332
378
  this.events.emit('product.archived.v1', {
@@ -340,42 +386,24 @@ export class CatalogAdminService {
340
386
  * Command Bus (one audit row + the event on commit, none on rollback). Falls
341
387
  * back to the legacy `updateProduct` when no bus is injected (bus-less tests).
342
388
  */
343
- async updateProductAudited(id, req) {
389
+ async updateProductAudited(id, req, gate) {
344
390
  if (!this.commandBus)
345
- return this.updateProduct(id, req);
346
- const commandBus = this.commandBus;
347
- const outcome = { archived: false };
348
- // A Command declares one event, and archiving is a second announcement of
349
- // the same write. The Command Bus opens its own event scope, which ends —
350
- // dispatching `product.updated.v1` and waiting for its subscribers — once
351
- // the write has committed; `product.archived.v1` is emitted after that,
352
- // into the scope opened here, so it is dispatched second and waited for as
353
- // well. Emitted outside any scope it was started and not waited for: this
354
- // method returned while the search indexer's removal was still on its way,
355
- // and a reactivation that followed could be undone by it.
356
- return this.events.run(async () => {
357
- const product = await commandBus.run(this.#updateProductCommand(id, req, outcome));
358
- if (outcome.archived)
359
- this.#emitArchived(product.id);
360
- return product;
361
- });
391
+ return this.updateProduct(id, req, undefined, gate);
392
+ return this.commandBus.run(this.#updateProductCommand(id, req, gate));
362
393
  }
363
- #updateProductCommand(id, req,
364
- /** Written by `run`: whether this write moved the product to `inactive`. */
365
- outcome) {
394
+ #updateProductCommand(id, req, gate) {
366
395
  let changedFields = [];
367
396
  return {
368
397
  action: 'product.update',
369
398
  objectType: 'product',
370
399
  objectId: id,
371
400
  run: async ({ em }) => {
372
- const r = await this.#applyProductUpdate(em, id, req);
401
+ const r = await this.#applyProductUpdate(em, id, req, gate);
373
402
  changedFields = r.changedFields;
374
- outcome.archived = r.archived;
375
403
  return {
376
404
  result: r.product,
377
405
  before: r.stateBefore,
378
- after: { ...r.stateAfter, changedFields },
406
+ after: { ...r.stateAfter, changedFields, ...(gate?.apiKeyId ? { apiKeyId: gate.apiKeyId } : {}) },
379
407
  };
380
408
  },
381
409
  event: (product) => ({
@@ -393,11 +421,14 @@ export class CatalogAdminService {
393
421
  * Pure product-update write on the given em — no flush, no audit, no event.
394
422
  * Shared by the legacy `updateProduct` and the audited Command path.
395
423
  */
396
- async #applyProductUpdate(em, id, req) {
424
+ async #applyProductUpdate(em, id, req, gate) {
425
+ refusePriceFields(req.attributeValues, 'attributeValues.');
397
426
  const product = await em.findOne(Product, { id });
398
427
  if (!product) {
399
428
  throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
400
429
  }
430
+ // Feature 155 (FR-001, D5) — refused before anything on the row changes.
431
+ assertOrderMinimumAllowed(product.type, req.minOrderQuantity);
401
432
  const stateBefore = {
402
433
  sku: product.sku,
403
434
  name: { ...product.name },
@@ -408,9 +439,15 @@ export class CatalogAdminService {
408
439
  archivedAt: product.archivedAt ?? null,
409
440
  attributeValues: { ...product.attributeValues },
410
441
  allowedOrganizationIds: [...product.allowedOrganizationIds],
442
+ // Feature 155 (FR-005) — always present, so a row records the value
443
+ // whether or not this write touched it.
444
+ minOrderQuantity: product.minOrderQuantity ?? null,
445
+ returnable: product.returnable,
446
+ // Feature 163 (FR-023) — the global publication window.
447
+ publishFrom: product.publishFrom?.toISOString() ?? null,
448
+ publishUntil: product.publishUntil?.toISOString() ?? null,
411
449
  };
412
450
  const changedFields = [];
413
- let archived = false;
414
451
  // Feature 012 / FR-016 — SKU is mutable. Refused with 400 sku_in_use
415
452
  // when the new SKU collides with another product. The internal UUID
416
453
  // (product.id) is the canonical reference; snapshot tables keep the
@@ -453,17 +490,19 @@ export class CatalogAdminService {
453
490
  product.visibility = req.visibility;
454
491
  changedFields.push('visibility');
455
492
  }
456
- // Feature 022 / 032 — status field. Cross-field rule: transitioning to
457
- // `inactive` sets archivedAt; transitioning away clears it.
493
+ // Feature 022 — status field. Feature 163 (FR-010, FR-019, O-5): a status
494
+ // write never sets or clears `archivedAt` — `inactive` is plain off and
495
+ // `active` does not restore. Archiving is the Archive / Restore action.
458
496
  if (req.status !== undefined && req.status !== product.status) {
459
- product.status = req.status;
460
- if (req.status === 'inactive') {
461
- product.archivedAt = new Date();
462
- archived = true;
463
- }
464
- else {
465
- product.archivedAt = null;
497
+ // Feature 163 (FR-060, US6 #3) — a change of the global switch runs the
498
+ // completeness gate over every pair it turns on, before the row changes: in
499
+ // `refuse` one failing pair refuses the whole write (N3). It reads status
500
+ // only, so an archived product set `active` is gated too.
501
+ if (gate?.completeness && this.completenessGate) {
502
+ const warnings = await this.#gateGlobalStatus(em, product, req.status, gate.completeness);
503
+ gate.warnings?.push(...warnings);
466
504
  }
505
+ product.status = req.status;
467
506
  changedFields.push('status');
468
507
  }
469
508
  // Feature 002 (T034) — attribute_set_id swap. Persist BEFORE
@@ -531,6 +570,39 @@ export class CatalogAdminService {
531
570
  product.fulfilmentStrategyWarehouseOrder = req.fulfilmentStrategyWarehouseOrder;
532
571
  changedFields.push('fulfilmentStrategyWarehouseOrder');
533
572
  }
573
+ // Feature 155 (FR-001, FR-003, D5) — the pieces minimum and the returnable flag.
574
+ if (req.minOrderQuantity !== undefined) {
575
+ product.minOrderQuantity = req.minOrderQuantity;
576
+ changedFields.push('minOrderQuantity');
577
+ }
578
+ if (req.returnable !== undefined) {
579
+ product.returnable = req.returnable;
580
+ changedFields.push('returnable');
581
+ }
582
+ // Feature 163 (FR-023) — the global publication window, written as a pair:
583
+ // an omitted bound keeps its stored value, and the pair that results must
584
+ // start before it ends. It never touches a channel's window (FR-013).
585
+ if (req.publishFrom !== undefined || req.publishUntil !== undefined) {
586
+ const from = req.publishFrom === undefined
587
+ ? (product.publishFrom ?? null)
588
+ : req.publishFrom === null
589
+ ? null
590
+ : new Date(req.publishFrom);
591
+ const until = req.publishUntil === undefined
592
+ ? (product.publishUntil ?? null)
593
+ : req.publishUntil === null
594
+ ? null
595
+ : new Date(req.publishUntil);
596
+ if (from !== null && until !== null && from.getTime() >= until.getTime()) {
597
+ throw new HttpError(422, ERROR_CODES.VALIDATION_FAILED, 'The publication window must start before it ends.', { field: 'window' });
598
+ }
599
+ if ((from?.getTime() ?? null) !== (product.publishFrom?.getTime() ?? null) ||
600
+ (until?.getTime() ?? null) !== (product.publishUntil?.getTime() ?? null)) {
601
+ product.publishFrom = from;
602
+ product.publishUntil = until;
603
+ changedFields.push('publicationWindow');
604
+ }
605
+ }
534
606
  const stateAfter = {
535
607
  name: { ...product.name },
536
608
  description: { ...product.description },
@@ -540,8 +612,12 @@ export class CatalogAdminService {
540
612
  archivedAt: product.archivedAt ?? null,
541
613
  attributeValues: { ...product.attributeValues },
542
614
  allowedOrganizationIds: [...product.allowedOrganizationIds],
615
+ minOrderQuantity: product.minOrderQuantity ?? null,
616
+ returnable: product.returnable,
617
+ publishFrom: product.publishFrom?.toISOString() ?? null,
618
+ publishUntil: product.publishUntil?.toISOString() ?? null,
543
619
  };
544
- return { product, stateBefore, stateAfter, changedFields, archived };
620
+ return { product, stateBefore, stateAfter, changedFields };
545
621
  }
546
622
  /**
547
623
  * Makes `product_categories` hold exactly `categoryIds` for one product, on
@@ -585,8 +661,9 @@ export class CatalogAdminService {
585
661
  *
586
662
  * The duplicated row gets a fresh UUID; the SKU is derived from the
587
663
  * source by appending `-copy`, then `-copy-2`, `-copy-3`, … until a
588
- * free slot is found. Status is reset to `'draft'` and `archivedAt`
589
- * is cleared so the operator can review before publishing.
664
+ * free slot is found. Status is reset to `'inactive'` and `archivedAt`
665
+ * is cleared (feature 163, Q1-d) so the operator can review before
666
+ * switching it on — also when the source is archived and `active`.
590
667
  *
591
668
  * Variants have their own globally-unique SKUs; each is suffixed in
592
669
  * the same way against the variant SKU space.
@@ -600,10 +677,13 @@ export class CatalogAdminService {
600
677
  if (this.commandBus) {
601
678
  return this.commandBus.run({ action, objectType, objectId, run: ({ em }) => write(em) });
602
679
  }
603
- const em = this.emFactory();
604
- const w = await write(em);
605
- await em.flush();
606
- return w.result;
680
+ // Unaudited without a Command Bus, but still one transaction: the URL-key
681
+ // advisory locks a write takes (`allocateUniqueSlug`) hold only inside one.
682
+ return this.emFactory().transactional(async (em) => {
683
+ const w = await write(em);
684
+ await em.flush();
685
+ return w.result;
686
+ });
607
687
  }
608
688
  async duplicateProduct(id) {
609
689
  const em = this.emFactory();
@@ -611,19 +691,22 @@ export class CatalogAdminService {
611
691
  if (!source) {
612
692
  throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
613
693
  }
614
- const newSku = await this.allocateCopySku(em, source.sku);
615
- const newSlug = await this.allocateCopySlug(em, source.slug);
616
694
  // The dup product row + its audit are co-transactional; the bridge copies
617
695
  // run AFTER on this em (matches the pre-054 two-step) — the dup FK target
618
696
  // exists once committed, and a partially-copied dup is no worse than today.
619
697
  const dupId = randomUUID();
620
698
  const dup = await this.#auditedWrite('product.duplicate', 'product', dupId, async (cem) => {
699
+ // Inside the Command's transaction (Phase 16 review): the slug's URL-key lock is
700
+ // a transaction lock, so on a bare em it was released before the insert.
701
+ const newSku = await this.allocateCopySku(cem, source.sku);
702
+ const newSlug = await this.allocateCopySlug(cem, source.slug);
621
703
  const created = cem.create(Product, {
622
704
  id: dupId,
623
705
  sku: newSku,
624
706
  slug: newSlug,
625
707
  type: source.type,
626
- status: 'draft',
708
+ status: 'inactive',
709
+ archivedAt: null,
627
710
  name: this.suffixCopyNames(source.name),
628
711
  description: { ...source.description },
629
712
  stockMode: source.stockMode ?? null,
@@ -759,7 +842,6 @@ export class CatalogAdminService {
759
842
  parentProductId: dup.id,
760
843
  sku: variantSku,
761
844
  variantAttributeValues: { ...v.variantAttributeValues },
762
- ...(v.priceOverride != null ? { priceOverride: v.priceOverride } : {}),
763
845
  ...(v.stockLevel != null ? { stockLevel: v.stockLevel } : {}),
764
846
  });
765
847
  em.persist(newVariant);
@@ -811,14 +893,35 @@ export class CatalogAdminService {
811
893
  * Feature 068 — used by the create path as well as the duplication path; a
812
894
  * name collision on create used to reach the database and be reported as a
813
895
  * SKU conflict.
896
+ *
897
+ * Feature 163 (A-11) — a new product's slug is its key in every language, so
898
+ * "free" means free as a URL key: no product's global key, and no live
899
+ * product's current or redirecting key in any language.
900
+ *
901
+ * Must run inside the caller's transaction (the Command's): the decisive check is
902
+ * made under the candidates' URL-key locks, which are transaction locks. The first
903
+ * {@link SLUG_CANDIDATE_LOCKS} candidates that look free without a lock are locked
904
+ * together, **once and in sorted order** — the order every key writer locks in, so
905
+ * the two cannot deadlock — and re-checked under the locks in index order; the first
906
+ * still free wins. A held lock is never released before the transaction ends, so
907
+ * locking candidates one at a time after a lost race would acquire them out of
908
+ * sorted order (`root-10` sorts before `root-9`). Losing every candidate of the set
909
+ * to concurrent writers is refused like an exhausted search.
814
910
  */
815
911
  async allocateUniqueSlug(em, source) {
816
912
  const root = this.slugify(source);
817
- for (let i = 0; i < 1000; i += 1) {
913
+ const probes = [];
914
+ for (let i = 0; i < 1000 && probes.length < SLUG_CANDIDATE_LOCKS; i += 1) {
818
915
  const candidate = i === 0 ? root : this.slugify(`${root}-${i + 1}`);
819
- const hit = await em.findOne(Product, { slug: candidate });
820
- if (!hit)
821
- return candidate;
916
+ if (!probes.includes(candidate) && (await isUrlKeyFree(em, candidate)))
917
+ probes.push(candidate);
918
+ }
919
+ if (probes.length > 0) {
920
+ await lockUrlKeys(em, probes);
921
+ for (const candidate of probes) {
922
+ if (await isUrlKeyFree(em, candidate))
923
+ return candidate;
924
+ }
822
925
  }
823
926
  throw new HttpError(409, ERROR_CODES.VALIDATION_FAILED, `Could not allocate a unique slug derived from "${source}".`);
824
927
  }
@@ -840,12 +943,84 @@ export class CatalogAdminService {
840
943
  return out;
841
944
  }
842
945
  /**
843
- * @deprecated Use `updateProduct` with `status: 'inactive'` instead — it is
844
- * what this method does, and it is the update that emits
845
- * `product.archived.v1` when the status actually moves.
946
+ * Feature 163 (FR-019, research R30.3) — Archive one product: the `product.archive`
947
+ * Command sets `archivedAt` and touches no status at any scope, and no
948
+ * completeness gate runs. Announces `product.updated.v1` `['archivedAt']`, then
949
+ * `product.archived.v1`, both after commit and in that order (one event scope,
950
+ * dispatched in order and waited for — the search indexer's removal has finished
951
+ * before this returns). Archiving an archived product is a no-op: no audit row,
952
+ * no event, `changed: false`.
953
+ *
954
+ * 404 `PRODUCT_NOT_FOUND` for an unknown, soft-deleted or non-UUID id.
846
955
  */
847
- async archiveProduct(id, auditCtx) {
848
- await this.updateProduct(id, { status: 'inactive' }, auditCtx);
956
+ async archiveProduct(id) {
957
+ return this.#setArchived(id, true);
958
+ }
959
+ /**
960
+ * Feature 163 (FR-019) — Restore one product: the `product.restore` Command clears
961
+ * `archivedAt`, announces `product.updated.v1` `['archivedAt']`, and leaves the
962
+ * status where it is (an `inactive` product stays off). No-op on a product that is
963
+ * not archived.
964
+ */
965
+ async restoreProduct(id) {
966
+ return this.#setArchived(id, false);
967
+ }
968
+ async #setArchived(id, archive) {
969
+ // A non-UUID id would reach PostgreSQL as an invalid `uuid` literal.
970
+ if (!uuidSchema.safeParse(id).success) {
971
+ throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
972
+ }
973
+ const outcome = { changed: false };
974
+ // The Command declares `product.updated.v1`; the Command Bus dispatches it
975
+ // when its own scope ends, after commit. `product.archived.v1` is emitted
976
+ // after that, into the scope opened here, so it is dispatched second.
977
+ return this.events.run(async () => {
978
+ const product = await this.#runCommand(this.#archiveCommand(id, archive, outcome));
979
+ if (outcome.changed && archive)
980
+ this.#emitArchived(product.id);
981
+ return { product, changed: outcome.changed };
982
+ });
983
+ }
984
+ #archiveCommand(id, archive, outcome) {
985
+ return {
986
+ action: archive ? 'product.archive' : 'product.restore',
987
+ objectType: 'product',
988
+ objectId: id,
989
+ run: async ({ em }) => {
990
+ // Checkpoint C code review (C-W1) — the row lock serialises a single and a bulk
991
+ // Archive of one product: the second reads the first's `archivedAt` and is the
992
+ // no-op, so the transition is audited and announced once.
993
+ const product = await em.findOne(Product, { id, deletedAt: null }, { lockMode: LockMode.PESSIMISTIC_WRITE });
994
+ if (!product) {
995
+ throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
996
+ }
997
+ const before = product.archivedAt ?? null;
998
+ if ((before !== null) === archive) {
999
+ outcome.changed = false;
1000
+ return { result: product, skipAudit: true };
1001
+ }
1002
+ product.archivedAt = archive ? new Date() : null;
1003
+ em.persist(product);
1004
+ await em.flush();
1005
+ outcome.changed = true;
1006
+ return {
1007
+ result: product,
1008
+ before: { archivedAt: before?.toISOString() ?? null },
1009
+ after: { archivedAt: product.archivedAt?.toISOString() ?? null },
1010
+ };
1011
+ },
1012
+ event: (product) => outcome.changed
1013
+ ? {
1014
+ eventName: 'product.updated.v1',
1015
+ payload: {
1016
+ eventId: randomUUID(),
1017
+ occurredAt: new Date().toISOString(),
1018
+ productId: product.id,
1019
+ changedFields: ['archivedAt'],
1020
+ },
1021
+ }
1022
+ : undefined,
1023
+ };
849
1024
  }
850
1025
  async assertProductDeletable(em, productId) {
851
1026
  // `em.execute`, not `em.getKnex()`: the caller is `product.delete`'s Command
@@ -888,11 +1063,19 @@ export class CatalogAdminService {
888
1063
  name: { ...product.name },
889
1064
  deletedAt: product.deletedAt ?? null,
890
1065
  };
1066
+ // Feature 163 (FR-072) — a deleted product's old URL keys stop redirecting.
1067
+ const urlRedirects = (await em.find(ProductUrlRedirect, { productId: id })).map((row) => ({
1068
+ id: row.id,
1069
+ languageCode: row.languageCode ?? null,
1070
+ key: row.key,
1071
+ }));
1072
+ if (urlRedirects.length > 0)
1073
+ await em.nativeDelete(ProductUrlRedirect, { productId: id });
891
1074
  product.deletedAt = new Date();
892
1075
  await em.flush();
893
1076
  return {
894
- result: { id: product.id },
895
- before: stateBefore,
1077
+ result: { id: product.id, formerUrlKeys: urlRedirects.map((row) => row.key) },
1078
+ before: { ...stateBefore, urlRedirects },
896
1079
  after: {
897
1080
  ...stateBefore,
898
1081
  deletedAt: product.deletedAt?.toISOString() ?? null,
@@ -905,6 +1088,7 @@ export class CatalogAdminService {
905
1088
  eventId: randomUUID(),
906
1089
  occurredAt: new Date().toISOString(),
907
1090
  productId: result.id,
1091
+ formerUrlKeys: result.formerUrlKeys,
908
1092
  },
909
1093
  }),
910
1094
  };
@@ -975,16 +1159,16 @@ export class CatalogAdminService {
975
1159
  const em = this.emFactory();
976
1160
  const page = Math.max(0, options.page ?? 0);
977
1161
  const pageSize = Math.min(Math.max(1, options.pageSize ?? 20), 500);
978
- // `status` overrides `includeArchived` — if the caller explicitly asks for
979
- // a specific status (including `inactive`), we honour it; otherwise the
980
- // legacy `includeArchived` flag controls whether inactive rows appear.
1162
+ const archivedMode = options.archived ?? 'exclude';
1163
+ // Feature 163 (R30.4) — the status and the archived mode are two independent
1164
+ // filters: `status` reads the status column, `archived` reads `archived_at`.
981
1165
  const where = { deletedAt: null };
982
- if (options.status) {
1166
+ if (options.status)
983
1167
  where['status'] = options.status;
984
- }
985
- else if (!options.includeArchived) {
986
- where['status'] = { $ne: 'inactive' };
987
- }
1168
+ if (archivedMode === 'exclude')
1169
+ where['archivedAt'] = null;
1170
+ else if (archivedMode === 'only')
1171
+ where['archivedAt'] = { $ne: null };
988
1172
  if (options.type) {
989
1173
  where['type'] = options.type;
990
1174
  }
@@ -992,23 +1176,7 @@ export class CatalogAdminService {
992
1176
  ? await this.productIdsInCategoryTree(em, options.categorySlug.trim())
993
1177
  : null;
994
1178
  if (categoryProductIds && categoryProductIds.size === 0) {
995
- // `em.execute`, not `em.getKnex()`: a knex handle takes its own pooled
996
- // connection, so the status badges would be counted from outside a
997
- // transaction the caller holds open while `em.find` above answers from
998
- // inside it — one screen, two views of `products` (issue #207).
999
- const countRowsEmpty = (await em.execute(`select status, count(*) as count from products where deleted_at is null group by status`));
1000
- const countsEmpty = { all: 0, active: 0, draft: 0, inactive: 0 };
1001
- for (const row of countRowsEmpty) {
1002
- const n = Number(row.count) || 0;
1003
- countsEmpty.all += n;
1004
- if (row.status === 'active')
1005
- countsEmpty.active = n;
1006
- else if (row.status === 'draft')
1007
- countsEmpty.draft = n;
1008
- else if (row.status === 'inactive')
1009
- countsEmpty.inactive = n;
1010
- }
1011
- return { items: [], page, pageSize, total: 0, counts: countsEmpty };
1179
+ return { items: [], page, pageSize, total: 0, counts: await this.#productListCounts(em) };
1012
1180
  }
1013
1181
  if (categoryProductIds) {
1014
1182
  where['id'] = { $in: [...categoryProductIds] };
@@ -1023,8 +1191,10 @@ export class CatalogAdminService {
1023
1191
  qb.whereNull('deleted_at');
1024
1192
  if (options.status)
1025
1193
  qb.where('status', options.status);
1026
- else if (!options.includeArchived)
1027
- qb.whereNot('status', 'inactive');
1194
+ if (archivedMode === 'exclude')
1195
+ qb.whereNull('archived_at');
1196
+ else if (archivedMode === 'only')
1197
+ qb.whereNotNull('archived_at');
1028
1198
  if (options.type)
1029
1199
  qb.where('type', options.type);
1030
1200
  if (categoryProductIds)
@@ -1069,24 +1239,37 @@ export class CatalogAdminService {
1069
1239
  limit: pageSize,
1070
1240
  });
1071
1241
  }
1072
- // Counts are computed across the *full* product set (including archived)
1073
- // so the admin's status tabs always have honest badges, regardless of
1074
- // which tab is currently active.
1075
- // `em.execute`, not `em.getKnex()` — same reason as the empty-category
1076
- // branch above.
1077
- const countRows = (await em.execute(`select status, count(*) as count from products where deleted_at is null group by status`));
1078
- const counts = { all: 0, active: 0, draft: 0, inactive: 0 };
1079
- for (const row of countRows) {
1242
+ return { items, page, pageSize, total, counts: await this.#productListCounts(em) };
1243
+ }
1244
+ /**
1245
+ * The admin list's tab badges, across the *full* product set whatever tab is
1246
+ * active, so they stay honest (feature 163, R30.4): `all`, `active` and
1247
+ * `inactive` over non-archived, non-deleted rows; `archived` over archived,
1248
+ * non-deleted rows of either status.
1249
+ *
1250
+ * `em.execute`, not `em.getKnex()`: a knex handle takes its own pooled
1251
+ * connection, so the badges would be counted from outside a transaction the
1252
+ * caller holds open while the page above answers from inside it — one screen,
1253
+ * two views of `products` (issue #207).
1254
+ */
1255
+ async #productListCounts(em) {
1256
+ const rows = (await em.execute(`select status, (archived_at is not null) as archived, count(*) as count
1257
+ from products where deleted_at is null
1258
+ group by status, (archived_at is not null)`));
1259
+ const counts = { all: 0, active: 0, inactive: 0, archived: 0 };
1260
+ for (const row of rows) {
1080
1261
  const n = Number(row.count) || 0;
1262
+ if (row.archived) {
1263
+ counts.archived += n;
1264
+ continue;
1265
+ }
1081
1266
  counts.all += n;
1082
1267
  if (row.status === 'active')
1083
- counts.active = n;
1084
- else if (row.status === 'draft')
1085
- counts.draft = n;
1268
+ counts.active += n;
1086
1269
  else if (row.status === 'inactive')
1087
- counts.inactive = n;
1270
+ counts.inactive += n;
1088
1271
  }
1089
- return { items, page, pageSize, total, counts };
1272
+ return counts;
1090
1273
  }
1091
1274
  /**
1092
1275
  * Feature 033 — return all product ids matching list filters (no pagination).
@@ -1097,16 +1280,18 @@ export class CatalogAdminService {
1097
1280
  const em = this.emFactory();
1098
1281
  const trimmedQ = options.q?.trim();
1099
1282
  const knex = em.getKnex();
1283
+ const archivedMode = options.archived ?? 'exclude';
1100
1284
  const applyListFilters = (qb) => {
1101
- // Mirror listProducts: soft-deleted rows are never selectable, and the
1102
- // withdrawn status is `inactive` (feature 032 renamed `archived`).
1285
+ // Mirror listProducts: soft-deleted rows are never selectable; the status
1286
+ // and the archived mode are independent filters (feature 163, R30.4).
1103
1287
  qb.whereNull('deleted_at');
1104
1288
  if (options.status) {
1105
1289
  qb.where('status', options.status);
1106
1290
  }
1107
- else if (!options.includeArchived) {
1108
- qb.whereNot('status', 'inactive');
1109
- }
1291
+ if (archivedMode === 'exclude')
1292
+ qb.whereNull('archived_at');
1293
+ else if (archivedMode === 'only')
1294
+ qb.whereNotNull('archived_at');
1110
1295
  if (options.type) {
1111
1296
  qb.where('type', options.type);
1112
1297
  }
@@ -1331,6 +1516,15 @@ export class CatalogAdminService {
1331
1516
  }
1332
1517
  // ------------------------------------------------------------------
1333
1518
  // ===== Feature 002 (T054 backend prereq) — Variants CRUD =================
1519
+ /**
1520
+ * Every variant of a product, by SKU — the admin's view (feature 161): no
1521
+ * channel, status or audience filter, unlike the storefront's product read.
1522
+ * A deleted or unknown product is `404`.
1523
+ */
1524
+ async listVariants(parentProductId) {
1525
+ const product = await this.getProductById(parentProductId);
1526
+ return this.emFactory().find(ProductVariant, { parentProductId: product.id }, { orderBy: { sku: 'asc' } });
1527
+ }
1334
1528
  async createVariant(parentProductId, req) {
1335
1529
  const em = this.emFactory();
1336
1530
  const parent = await em.findOne(Product, { id: parentProductId });
@@ -1352,9 +1546,6 @@ export class CatalogAdminService {
1352
1546
  parentProductId,
1353
1547
  sku: req.sku,
1354
1548
  variantAttributeValues: req.variantAttributeValues,
1355
- ...(req.priceOverride !== undefined
1356
- ? { priceOverride: String(req.priceOverride) }
1357
- : {}),
1358
1549
  ...(req.stockLevel !== undefined ? { stockLevel: req.stockLevel } : {}),
1359
1550
  });
1360
1551
  try {
@@ -1385,22 +1576,18 @@ export class CatalogAdminService {
1385
1576
  const before = {
1386
1577
  sku: v.sku,
1387
1578
  variantAttributeValues: { ...v.variantAttributeValues },
1388
- priceOverride: v.priceOverride,
1389
1579
  stockLevel: v.stockLevel,
1390
1580
  };
1391
1581
  if (req.variantAttributeValues !== undefined) {
1392
1582
  v.variantAttributeValues = req.variantAttributeValues;
1393
1583
  }
1394
- if (req.priceOverride !== undefined) {
1395
- v.priceOverride = String(req.priceOverride);
1396
- }
1397
1584
  if (req.stockLevel !== undefined) {
1398
1585
  v.stockLevel = req.stockLevel;
1399
1586
  }
1400
1587
  return {
1401
1588
  result: v,
1402
1589
  before,
1403
- after: { sku: v.sku, priceOverride: v.priceOverride, stockLevel: v.stockLevel },
1590
+ after: { sku: v.sku, stockLevel: v.stockLevel },
1404
1591
  };
1405
1592
  });
1406
1593
  this.events.emit('product.updated.v1', {
@@ -1467,8 +1654,7 @@ export class CatalogAdminService {
1467
1654
  .map((r) => keyByDefinitionId.get(r.custom_field_definition_id))
1468
1655
  .filter((k) => k !== undefined));
1469
1656
  const rejected = keys.filter((k) => !allowed.has(k) &&
1470
- !existingKeys.has(k) &&
1471
- !VIRTUAL_ATTRIBUTE_VALUE_KEYS.has(k));
1657
+ !existingKeys.has(k));
1472
1658
  if (rejected.length > 0) {
1473
1659
  throw new HttpError(400, ERROR_CODES.ATTRIBUTE_VALUE_REJECTED, `Attribute key(s) not in this Product's Attribute Set: ${rejected.join(', ')}.`, rejected.map((k) => ({
1474
1660
  path: `attributeValues.${k}`,
@@ -1596,4 +1782,21 @@ export class CatalogAdminService {
1596
1782
  return key ? (blob[key] ?? '') : '';
1597
1783
  }
1598
1784
  }
1785
+ /**
1786
+ * Feature 155 (FR-001, threat F5, D5) — a pieces minimum is an integer in
1787
+ * 1…1 000 000 and only a `simple` or `configurable` product may carry one;
1788
+ * `null` (clear) and an absent key are always allowed. Refused
1789
+ * `422 VALIDATION_FAILED` with `details.field`, the answer an in-process caller
1790
+ * gets where no route schema stood in front of it.
1791
+ */
1792
+ function assertOrderMinimumAllowed(type, value) {
1793
+ if (value === undefined || value === null)
1794
+ return;
1795
+ if (!isValidOrderMinimum(value)) {
1796
+ throw new HttpError(422, ERROR_CODES.VALIDATION_FAILED, 'The minimum order quantity must be a whole number from 1 to 1000000.', { field: 'minOrderQuantity' });
1797
+ }
1798
+ if (!isOrderMinimumEligibleType(type)) {
1799
+ throw new HttpError(422, ERROR_CODES.VALIDATION_FAILED, `A minimum order quantity applies to simple or configurable products only; got "${type}".`, { field: 'minOrderQuantity' });
1800
+ }
1801
+ }
1599
1802
  //# sourceMappingURL=catalog-admin.service.js.map