@endora-commerce/mod-catalog 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 (615) hide show
  1. package/dist/admin/components/CopyToChannelsDialog.d.ts +37 -0
  2. package/dist/admin/components/CopyToChannelsDialog.js +83 -0
  3. package/dist/admin/components/PackagingUnitsEditor.d.ts +13 -4
  4. package/dist/admin/components/PackagingUnitsEditor.js +21 -85
  5. package/dist/admin/components/ProductAttachmentsSection.d.ts +1 -3
  6. package/dist/admin/components/ProductAttachmentsSection.js +59 -98
  7. package/dist/admin/components/ProductAttributesTab.d.ts +1 -11
  8. package/dist/admin/components/ProductAttributesTab.js +128 -119
  9. package/dist/admin/components/ProductContentCard.d.ts +41 -0
  10. package/dist/admin/components/ProductContentCard.js +28 -0
  11. package/dist/admin/components/ProductEditorSaveAction.d.ts +22 -0
  12. package/dist/admin/components/ProductEditorSaveAction.js +23 -0
  13. package/dist/admin/components/ProductGallerySection.d.ts +2 -13
  14. package/dist/admin/components/ProductGallerySection.js +98 -354
  15. package/dist/admin/components/ProductInventoryTab.d.ts +12 -1
  16. package/dist/admin/components/ProductInventoryTab.js +52 -115
  17. package/dist/admin/components/ProductOrderRulesCard.d.ts +11 -15
  18. package/dist/admin/components/ProductOrderRulesCard.js +15 -268
  19. package/dist/admin/components/ProductScopeBar.d.ts +34 -0
  20. package/dist/admin/components/ProductScopeBar.js +70 -0
  21. package/dist/admin/components/ProductScopeOverview.d.ts +13 -1
  22. package/dist/admin/components/ProductScopeOverview.js +56 -37
  23. package/dist/admin/components/ProductUrlRedirects.d.ts +15 -0
  24. package/dist/admin/components/ProductUrlRedirects.js +70 -0
  25. package/dist/admin/components/ProductsBulkEditDialog.js +4 -3
  26. package/dist/admin/components/editor/DetailsTab.d.ts +30 -0
  27. package/dist/admin/components/editor/DetailsTab.js +60 -0
  28. package/dist/admin/components/editor/SectionHeading.d.ts +22 -0
  29. package/dist/admin/components/editor/SectionHeading.js +19 -0
  30. package/dist/admin/components/editor/confirm-removal.d.ts +13 -0
  31. package/dist/admin/components/editor/confirm-removal.js +33 -0
  32. package/dist/admin/components/editor/editor-context.d.ts +55 -0
  33. package/dist/admin/components/editor/editor-context.js +88 -0
  34. package/dist/admin/components/editor/scoped-controls.d.ts +46 -0
  35. package/dist/admin/components/editor/scoped-controls.js +64 -0
  36. package/dist/admin/index.d.ts +1 -1
  37. package/dist/admin/index.js +11 -0
  38. package/dist/admin/lib/attribute-scope.d.ts +17 -14
  39. package/dist/admin/lib/attribute-scope.js +12 -9
  40. package/dist/admin/lib/bulk-result-outcome.d.ts +14 -0
  41. package/dist/admin/lib/bulk-result-outcome.js +13 -0
  42. package/dist/admin/lib/editor-scope.d.ts +35 -0
  43. package/dist/admin/lib/editor-scope.js +114 -0
  44. package/dist/admin/lib/order-minimum-input.d.ts +13 -0
  45. package/dist/admin/lib/order-minimum-input.js +16 -0
  46. package/dist/admin/lib/product-labels.d.ts +0 -2
  47. package/dist/admin/lib/product-labels.js +1 -5
  48. package/dist/admin/lib/product-scopes-api.d.ts +5 -22
  49. package/dist/admin/lib/product-scopes-api.js +4 -48
  50. package/dist/admin/lib/product-url-keys-api.d.ts +4 -27
  51. package/dist/admin/lib/product-url-keys-api.js +1 -50
  52. package/dist/admin/lib/scope-overview.d.ts +13 -14
  53. package/dist/admin/lib/scope-overview.js +36 -31
  54. package/dist/admin/lib/scoped-editor-store.d.ts +81 -0
  55. package/dist/admin/lib/scoped-editor-store.js +198 -0
  56. package/dist/admin/lib/scoped-values-api.d.ts +14 -0
  57. package/dist/admin/lib/scoped-values-api.js +55 -0
  58. package/dist/admin/pages/AttachmentTypesPage.js +14 -4
  59. package/dist/admin/pages/AttributeSetsPage.js +11 -4
  60. package/dist/admin/pages/AttributesManager.js +130 -40
  61. package/dist/admin/pages/BulkOperationDetailPage.js +11 -4
  62. package/dist/admin/pages/CategoriesTree.d.ts +5 -0
  63. package/dist/admin/pages/CategoriesTree.js +226 -40
  64. package/dist/admin/pages/ProductContentPage.d.ts +27 -0
  65. package/dist/admin/pages/ProductContentPage.js +161 -0
  66. package/dist/admin/pages/ProductCreateForm.d.ts +3 -0
  67. package/dist/admin/pages/ProductCreateForm.js +87 -0
  68. package/dist/admin/pages/ProductEditor.js +938 -458
  69. package/dist/admin/pages/ProductsList.js +33 -38
  70. package/dist/backend/admin-search-provider.d.ts +2 -1
  71. package/dist/backend/admin-search-provider.js +1 -1
  72. package/dist/backend/commands/attribute-commands.d.ts +4 -3
  73. package/dist/backend/commands/attribute-commands.js +137 -30
  74. package/dist/backend/commands/product-content-commands.d.ts +31 -0
  75. package/dist/backend/commands/product-content-commands.js +70 -0
  76. package/dist/backend/commands/scoped-values.commands.d.ts +95 -0
  77. package/dist/backend/commands/scoped-values.commands.js +235 -0
  78. package/dist/backend/demo/reset.js +2 -1
  79. package/dist/backend/demo/rows.d.ts +18 -0
  80. package/dist/backend/demo/rows.js +18 -0
  81. package/dist/backend/demo/seed.d.ts +2 -1
  82. package/dist/backend/demo/seed.js +20 -6
  83. package/dist/backend/entities/gallery-item-scope-override.entity.d.ts +30 -0
  84. package/dist/backend/entities/gallery-item-scope-override.entity.js +80 -0
  85. package/dist/backend/entities/gallery-item.entity.d.ts +7 -6
  86. package/dist/backend/entities/gallery-item.entity.js +11 -6
  87. package/dist/backend/entities/gallery-role-scope-override.entity.d.ts +28 -0
  88. package/dist/backend/entities/gallery-role-scope-override.entity.js +75 -0
  89. package/dist/backend/entities/product-attachment-scope-override.entity.d.ts +30 -0
  90. package/dist/backend/entities/product-attachment-scope-override.entity.js +80 -0
  91. package/dist/backend/entities/product-attachment.entity.d.ts +4 -6
  92. package/dist/backend/entities/product-attachment.entity.js +6 -12
  93. package/dist/backend/entities/product-attribute.entity.d.ts +5 -9
  94. package/dist/backend/entities/product-attribute.entity.js +5 -13
  95. package/dist/backend/entities/product-channel-scope.entity.d.ts +7 -2
  96. package/dist/backend/entities/product-channel-scope.entity.js +10 -1
  97. package/dist/backend/entities/product-content-value.entity.d.ts +39 -0
  98. package/dist/backend/entities/product-content-value.entity.js +81 -0
  99. package/dist/backend/entities/product-packaging-unit-scope-override.entity.d.ts +30 -0
  100. package/dist/backend/entities/product-packaging-unit-scope-override.entity.js +80 -0
  101. package/dist/backend/entities/product-packaging-unit.entity.d.ts +1 -7
  102. package/dist/backend/entities/product-packaging-unit.entity.js +0 -10
  103. package/dist/backend/entities/product-url-key.entity.d.ts +14 -19
  104. package/dist/backend/entities/product-url-key.entity.js +17 -22
  105. package/dist/backend/entities/product-url-redirect.entity.d.ts +8 -13
  106. package/dist/backend/entities/product-url-redirect.entity.js +13 -14
  107. package/dist/backend/entities/product-variant.entity.d.ts +8 -1
  108. package/dist/backend/entities/product-variant.entity.js +13 -2
  109. package/dist/backend/entities/product.entity.d.ts +31 -14
  110. package/dist/backend/entities/product.entity.js +41 -34
  111. package/dist/backend/index.d.ts +11 -3
  112. package/dist/backend/index.js +155 -49
  113. package/dist/backend/plugin.d.ts +36 -6
  114. package/dist/backend/plugin.js +36 -13
  115. package/dist/backend/prompt-tools.d.ts +3 -2
  116. package/dist/backend/prompt-tools.js +18 -7
  117. package/dist/backend/routes.admin.d.ts +15 -16
  118. package/dist/backend/routes.admin.js +122 -103
  119. package/dist/backend/routes.api-key.js +4 -2
  120. package/dist/backend/routes.external.js +3 -2
  121. package/dist/backend/routes.public.d.ts +8 -1
  122. package/dist/backend/routes.public.js +68 -11
  123. package/dist/backend/services/asset-references.d.ts +12 -1
  124. package/dist/backend/services/asset-references.js +42 -2
  125. package/dist/backend/services/attachment-packaging-scopes.d.ts +38 -20
  126. package/dist/backend/services/attachment-packaging-scopes.js +58 -75
  127. package/dist/backend/services/attachment.service.d.ts +4 -8
  128. package/dist/backend/services/attachment.service.js +35 -49
  129. package/dist/backend/services/attribute-filter-match.d.ts +14 -0
  130. package/dist/backend/services/attribute-filter-match.js +19 -0
  131. package/dist/backend/services/attribute-scope-preview.d.ts +17 -7
  132. package/dist/backend/services/attribute-scope-preview.js +30 -20
  133. package/dist/backend/services/attribute-set.service.d.ts +10 -1
  134. package/dist/backend/services/attribute-set.service.js +30 -4
  135. package/dist/backend/services/attribute-type-mapping.d.ts +2 -2
  136. package/dist/backend/services/attribute-type-mapping.js +6 -0
  137. package/dist/backend/services/attribute-usage.d.ts +31 -0
  138. package/dist/backend/services/attribute-usage.js +29 -0
  139. package/dist/backend/services/bulk-operation.service.d.ts +1 -1
  140. package/dist/backend/services/bulk-operation.service.js +16 -6
  141. package/dist/backend/services/bundle.service.js +19 -1
  142. package/dist/backend/services/catalog-admin-search.service.d.ts +3 -2
  143. package/dist/backend/services/catalog-admin-search.service.js +6 -6
  144. package/dist/backend/services/catalog-admin.service.d.ts +63 -12
  145. package/dist/backend/services/catalog-admin.service.js +368 -195
  146. package/dist/backend/services/catalog-attribute-read.service.d.ts +14 -0
  147. package/dist/backend/services/catalog-attribute-read.service.js +9 -19
  148. package/dist/backend/services/catalog-bulk-import.service.d.ts +58 -5
  149. package/dist/backend/services/catalog-bulk-import.service.js +192 -142
  150. package/dist/backend/services/catalog-bulk-update.service.d.ts +5 -3
  151. package/dist/backend/services/catalog-bulk-update.service.js +21 -8
  152. package/dist/backend/services/catalog-product-read.service.d.ts +11 -1
  153. package/dist/backend/services/catalog-product-read.service.js +37 -17
  154. package/dist/backend/services/catalog-query.service.d.ts +48 -8
  155. package/dist/backend/services/catalog-query.service.js +180 -116
  156. package/dist/backend/services/catalog-quick-search.service.js +5 -5
  157. package/dist/backend/services/catalog-write-ports.d.ts +14 -16
  158. package/dist/backend/services/catalog-write-ports.js +11 -70
  159. package/dist/backend/services/category-admin.service.js +29 -5
  160. package/dist/backend/services/content-attribute-rules.d.ts +61 -0
  161. package/dist/backend/services/content-attribute-rules.js +102 -0
  162. package/dist/backend/services/effective-value.sql.d.ts +24 -38
  163. package/dist/backend/services/effective-value.sql.js +37 -87
  164. package/dist/backend/services/gallery-scopes.d.ts +45 -22
  165. package/dist/backend/services/gallery-scopes.js +116 -109
  166. package/dist/backend/services/gallery.service.d.ts +13 -27
  167. package/dist/backend/services/gallery.service.js +75 -199
  168. package/dist/backend/services/grouped.service.js +20 -3
  169. package/dist/backend/services/packaging-unit.service.js +7 -12
  170. package/dist/backend/services/page-builder-content.d.ts +64 -0
  171. package/dist/backend/services/page-builder-content.js +113 -0
  172. package/dist/backend/services/primary-asset-url.d.ts +6 -1
  173. package/dist/backend/services/primary-asset-url.js +9 -4
  174. package/dist/backend/services/product-availability.service.d.ts +16 -3
  175. package/dist/backend/services/product-availability.service.js +58 -21
  176. package/dist/backend/services/product-content.service.d.ts +62 -0
  177. package/dist/backend/services/product-content.service.js +122 -0
  178. package/dist/backend/services/product-editor-preferences.service.d.ts +6 -0
  179. package/dist/backend/services/product-editor-preferences.service.js +12 -0
  180. package/dist/backend/services/product-global-field-rules.d.ts +39 -0
  181. package/dist/backend/services/product-global-field-rules.js +84 -0
  182. package/dist/backend/services/product-link.service.js +14 -16
  183. package/dist/backend/services/product-list-view-service.js +5 -8
  184. package/dist/backend/services/product-page-revalidation.d.ts +9 -0
  185. package/dist/backend/services/product-page-revalidation.js +19 -0
  186. package/dist/backend/services/product-scopes.service.d.ts +18 -8
  187. package/dist/backend/services/product-scopes.service.js +91 -36
  188. package/dist/backend/services/product-value-resolver.service.d.ts +2 -2
  189. package/dist/backend/services/product-value-resolver.service.js +4 -7
  190. package/dist/backend/services/publication-window-sweep.d.ts +61 -7
  191. package/dist/backend/services/publication-window-sweep.js +106 -19
  192. package/dist/backend/services/scheduled-work-probe.d.ts +34 -0
  193. package/dist/backend/services/scheduled-work-probe.js +30 -0
  194. package/dist/backend/services/scope-completeness.d.ts +11 -11
  195. package/dist/backend/services/scope-completeness.js +26 -33
  196. package/dist/backend/services/scope-overview.service.d.ts +24 -24
  197. package/dist/backend/services/scope-overview.service.js +33 -76
  198. package/dist/backend/services/scoped-store-adapters.d.ts +58 -0
  199. package/dist/backend/services/scoped-store-adapters.js +92 -0
  200. package/dist/backend/services/scoped-values-global-only.d.ts +36 -0
  201. package/dist/backend/services/scoped-values-global-only.js +92 -0
  202. package/dist/backend/services/scoped-values-import.d.ts +86 -0
  203. package/dist/backend/services/scoped-values-import.js +320 -0
  204. package/dist/backend/services/scoped-values-read.service.d.ts +56 -0
  205. package/dist/backend/services/scoped-values-read.service.js +289 -0
  206. package/dist/backend/services/scoped-values-save.service.d.ts +79 -0
  207. package/dist/backend/services/scoped-values-save.service.js +675 -0
  208. package/dist/backend/services/scoped-values-state.d.ts +94 -0
  209. package/dist/backend/services/scoped-values-state.js +159 -0
  210. package/dist/backend/services/scoped-values.service.d.ts +36 -0
  211. package/dist/backend/services/scoped-values.service.js +92 -0
  212. package/dist/backend/services/storefront-value-overrides.d.ts +7 -8
  213. package/dist/backend/services/storefront-value-overrides.js +11 -14
  214. package/dist/backend/services/table-maintenance-queue.d.ts +78 -0
  215. package/dist/backend/services/table-maintenance-queue.js +97 -0
  216. package/dist/backend/services/url-key-resolution.service.d.ts +12 -18
  217. package/dist/backend/services/url-key-resolution.service.js +43 -43
  218. package/dist/backend/services/url-key.service.d.ts +87 -135
  219. package/dist/backend/services/url-key.service.js +447 -619
  220. package/dist/manifest.d.ts +51 -1
  221. package/dist/manifest.js +111 -7
  222. package/dist/migrations/20261030T113855_catalog_scope_model_texts.d.ts +36 -0
  223. package/dist/migrations/20261030T113855_catalog_scope_model_texts.js +225 -0
  224. package/dist/migrations/20261030T113859_catalog_scope_model_order_rules.d.ts +18 -0
  225. package/dist/migrations/20261030T113859_catalog_scope_model_order_rules.js +39 -0
  226. package/dist/migrations/20261030T113904_catalog_scope_model_url_keys.d.ts +6 -0
  227. package/dist/migrations/20261030T113904_catalog_scope_model_url_keys.js +119 -0
  228. package/dist/migrations/20261030T113908_catalog_scope_model_media.d.ts +6 -0
  229. package/dist/migrations/20261030T113908_catalog_scope_model_media.js +185 -0
  230. package/dist/migrations/20261104T121504_catalog_product_content_values.d.ts +36 -0
  231. package/dist/migrations/20261104T121504_catalog_product_content_values.js +53 -0
  232. package/dist/migrations/20261107T093126_catalog_sku_unique_among_live.d.ts +33 -0
  233. package/dist/migrations/20261107T093126_catalog_sku_unique_among_live.js +58 -0
  234. package/dist/migrations/20261107T120008_catalog_product_created_at_milliseconds.d.ts +36 -0
  235. package/dist/migrations/20261107T120008_catalog_product_created_at_milliseconds.js +40 -0
  236. package/dist/migrations/20261114T000706_catalog_category_main_image.d.ts +37 -0
  237. package/dist/migrations/20261114T000706_catalog_category_main_image.js +56 -0
  238. package/dist/migrations/index.d.ts +9 -1
  239. package/dist/migrations/index.js +17 -1
  240. package/docs/catalog/attachments.md +53 -43
  241. package/docs/catalog/attribute-sets.md +3 -2
  242. package/docs/catalog/attributes.md +99 -25
  243. package/docs/catalog/category-content.md +9 -3
  244. package/docs/catalog/composite-products.md +5 -3
  245. package/docs/catalog/editing-a-product-at-a-scope.md +151 -0
  246. package/docs/catalog/gallery-and-labels.md +61 -60
  247. package/docs/catalog/packaging-units.md +43 -34
  248. package/docs/catalog/per-channel-per-language-overrides.md +83 -410
  249. package/docs/catalog/product-content.md +184 -0
  250. package/docs/catalog/product-links.md +2 -2
  251. package/docs/catalog/url-keys-and-redirects.md +79 -79
  252. package/docs/catalog.md +113 -31
  253. package/i18n/en.json +317 -274
  254. package/i18n/pl.json +319 -276
  255. package/package.json +13 -12
  256. package/dist/admin/components/AttachmentScopesDialog.d.ts +0 -22
  257. package/dist/admin/components/AttachmentScopesDialog.d.ts.map +0 -1
  258. package/dist/admin/components/AttachmentScopesDialog.js +0 -70
  259. package/dist/admin/components/AttachmentScopesDialog.js.map +0 -1
  260. package/dist/admin/components/PackagingUnitsEditor.d.ts.map +0 -1
  261. package/dist/admin/components/PackagingUnitsEditor.js.map +0 -1
  262. package/dist/admin/components/ProductAttachmentsSection.d.ts.map +0 -1
  263. package/dist/admin/components/ProductAttachmentsSection.js.map +0 -1
  264. package/dist/admin/components/ProductAttributesTab.d.ts.map +0 -1
  265. package/dist/admin/components/ProductAttributesTab.js.map +0 -1
  266. package/dist/admin/components/ProductGallerySection.d.ts.map +0 -1
  267. package/dist/admin/components/ProductGallerySection.js.map +0 -1
  268. package/dist/admin/components/ProductInventoryTab.d.ts.map +0 -1
  269. package/dist/admin/components/ProductInventoryTab.js.map +0 -1
  270. package/dist/admin/components/ProductOrderRulesCard.d.ts.map +0 -1
  271. package/dist/admin/components/ProductOrderRulesCard.js.map +0 -1
  272. package/dist/admin/components/ProductScopeControls.d.ts +0 -31
  273. package/dist/admin/components/ProductScopeControls.d.ts.map +0 -1
  274. package/dist/admin/components/ProductScopeControls.js +0 -243
  275. package/dist/admin/components/ProductScopeControls.js.map +0 -1
  276. package/dist/admin/components/ProductScopeEditor.d.ts +0 -88
  277. package/dist/admin/components/ProductScopeEditor.d.ts.map +0 -1
  278. package/dist/admin/components/ProductScopeEditor.js +0 -396
  279. package/dist/admin/components/ProductScopeEditor.js.map +0 -1
  280. package/dist/admin/components/ProductScopeOverview.d.ts.map +0 -1
  281. package/dist/admin/components/ProductScopeOverview.js.map +0 -1
  282. package/dist/admin/components/ProductStatusPills.d.ts.map +0 -1
  283. package/dist/admin/components/ProductStatusPills.js.map +0 -1
  284. package/dist/admin/components/ProductUrlKeysPanel.d.ts +0 -17
  285. package/dist/admin/components/ProductUrlKeysPanel.d.ts.map +0 -1
  286. package/dist/admin/components/ProductUrlKeysPanel.js +0 -215
  287. package/dist/admin/components/ProductUrlKeysPanel.js.map +0 -1
  288. package/dist/admin/components/ProductsBulkEditDialog.d.ts.map +0 -1
  289. package/dist/admin/components/ProductsBulkEditDialog.js.map +0 -1
  290. package/dist/admin/components/ScopedDialogParts.d.ts +0 -23
  291. package/dist/admin/components/ScopedDialogParts.d.ts.map +0 -1
  292. package/dist/admin/components/ScopedDialogParts.js +0 -16
  293. package/dist/admin/components/ScopedDialogParts.js.map +0 -1
  294. package/dist/admin/index.d.ts.map +0 -1
  295. package/dist/admin/index.js.map +0 -1
  296. package/dist/admin/lib/attribute-scope.d.ts.map +0 -1
  297. package/dist/admin/lib/attribute-scope.js.map +0 -1
  298. package/dist/admin/lib/bulk-operation-log-text.d.ts.map +0 -1
  299. package/dist/admin/lib/bulk-operation-log-text.js.map +0 -1
  300. package/dist/admin/lib/media-scopes.d.ts +0 -41
  301. package/dist/admin/lib/media-scopes.d.ts.map +0 -1
  302. package/dist/admin/lib/media-scopes.js +0 -66
  303. package/dist/admin/lib/media-scopes.js.map +0 -1
  304. package/dist/admin/lib/product-labels.d.ts.map +0 -1
  305. package/dist/admin/lib/product-labels.js.map +0 -1
  306. package/dist/admin/lib/product-scope-drafts.d.ts +0 -77
  307. package/dist/admin/lib/product-scope-drafts.d.ts.map +0 -1
  308. package/dist/admin/lib/product-scope-drafts.js +0 -133
  309. package/dist/admin/lib/product-scope-drafts.js.map +0 -1
  310. package/dist/admin/lib/product-scopes-api.d.ts.map +0 -1
  311. package/dist/admin/lib/product-scopes-api.js.map +0 -1
  312. package/dist/admin/lib/product-url-keys-api.d.ts.map +0 -1
  313. package/dist/admin/lib/product-url-keys-api.js.map +0 -1
  314. package/dist/admin/lib/resolve-product-selection.d.ts.map +0 -1
  315. package/dist/admin/lib/resolve-product-selection.js.map +0 -1
  316. package/dist/admin/lib/scope-overview.d.ts.map +0 -1
  317. package/dist/admin/lib/scope-overview.js.map +0 -1
  318. package/dist/admin/pages/AttachmentTypesPage.d.ts.map +0 -1
  319. package/dist/admin/pages/AttachmentTypesPage.js.map +0 -1
  320. package/dist/admin/pages/AttributeSetsPage.d.ts.map +0 -1
  321. package/dist/admin/pages/AttributeSetsPage.js.map +0 -1
  322. package/dist/admin/pages/AttributesManager.d.ts.map +0 -1
  323. package/dist/admin/pages/AttributesManager.js.map +0 -1
  324. package/dist/admin/pages/BulkOperationDetailPage.d.ts.map +0 -1
  325. package/dist/admin/pages/BulkOperationDetailPage.js.map +0 -1
  326. package/dist/admin/pages/BulkOperationsPage.d.ts.map +0 -1
  327. package/dist/admin/pages/BulkOperationsPage.js.map +0 -1
  328. package/dist/admin/pages/CategoriesTree.d.ts.map +0 -1
  329. package/dist/admin/pages/CategoriesTree.js.map +0 -1
  330. package/dist/admin/pages/CategoryContentPage.d.ts.map +0 -1
  331. package/dist/admin/pages/CategoryContentPage.js.map +0 -1
  332. package/dist/admin/pages/ProductEditor.d.ts.map +0 -1
  333. package/dist/admin/pages/ProductEditor.js.map +0 -1
  334. package/dist/admin/pages/ProductsList.d.ts.map +0 -1
  335. package/dist/admin/pages/ProductsList.js.map +0 -1
  336. package/dist/backend/admin-search-provider.d.ts.map +0 -1
  337. package/dist/backend/admin-search-provider.js.map +0 -1
  338. package/dist/backend/commands/attribute-commands.d.ts.map +0 -1
  339. package/dist/backend/commands/attribute-commands.js.map +0 -1
  340. package/dist/backend/demo/reset.d.ts.map +0 -1
  341. package/dist/backend/demo/reset.js.map +0 -1
  342. package/dist/backend/demo/rows.d.ts.map +0 -1
  343. package/dist/backend/demo/rows.js.map +0 -1
  344. package/dist/backend/demo/seed.d.ts.map +0 -1
  345. package/dist/backend/demo/seed.js.map +0 -1
  346. package/dist/backend/entities/attachment-type.entity.d.ts.map +0 -1
  347. package/dist/backend/entities/attachment-type.entity.js.map +0 -1
  348. package/dist/backend/entities/attribute-set-attribute.entity.d.ts.map +0 -1
  349. package/dist/backend/entities/attribute-set-attribute.entity.js.map +0 -1
  350. package/dist/backend/entities/attribute-set.entity.d.ts.map +0 -1
  351. package/dist/backend/entities/attribute-set.entity.js.map +0 -1
  352. package/dist/backend/entities/bulk-operation.entity.d.ts.map +0 -1
  353. package/dist/backend/entities/bulk-operation.entity.js.map +0 -1
  354. package/dist/backend/entities/bundle-slot-option.entity.d.ts.map +0 -1
  355. package/dist/backend/entities/bundle-slot-option.entity.js.map +0 -1
  356. package/dist/backend/entities/bundle-slot.entity.d.ts.map +0 -1
  357. package/dist/backend/entities/bundle-slot.entity.js.map +0 -1
  358. package/dist/backend/entities/category.entity.d.ts.map +0 -1
  359. package/dist/backend/entities/category.entity.js.map +0 -1
  360. package/dist/backend/entities/gallery-item-channel-hidden.entity.d.ts +0 -14
  361. package/dist/backend/entities/gallery-item-channel-hidden.entity.d.ts.map +0 -1
  362. package/dist/backend/entities/gallery-item-channel-hidden.entity.js +0 -42
  363. package/dist/backend/entities/gallery-item-channel-hidden.entity.js.map +0 -1
  364. package/dist/backend/entities/gallery-item-channel-label.entity.d.ts +0 -18
  365. package/dist/backend/entities/gallery-item-channel-label.entity.d.ts.map +0 -1
  366. package/dist/backend/entities/gallery-item-channel-label.entity.js +0 -49
  367. package/dist/backend/entities/gallery-item-channel-label.entity.js.map +0 -1
  368. package/dist/backend/entities/gallery-item-label.entity.d.ts.map +0 -1
  369. package/dist/backend/entities/gallery-item-label.entity.js.map +0 -1
  370. package/dist/backend/entities/gallery-item.entity.d.ts.map +0 -1
  371. package/dist/backend/entities/gallery-item.entity.js.map +0 -1
  372. package/dist/backend/entities/grouped-item.entity.d.ts.map +0 -1
  373. package/dist/backend/entities/grouped-item.entity.js.map +0 -1
  374. package/dist/backend/entities/product-attachment-channel-hidden.entity.d.ts +0 -13
  375. package/dist/backend/entities/product-attachment-channel-hidden.entity.d.ts.map +0 -1
  376. package/dist/backend/entities/product-attachment-channel-hidden.entity.js +0 -41
  377. package/dist/backend/entities/product-attachment-channel-hidden.entity.js.map +0 -1
  378. package/dist/backend/entities/product-attachment.entity.d.ts.map +0 -1
  379. package/dist/backend/entities/product-attachment.entity.js.map +0 -1
  380. package/dist/backend/entities/product-attribute.entity.d.ts.map +0 -1
  381. package/dist/backend/entities/product-attribute.entity.js.map +0 -1
  382. package/dist/backend/entities/product-channel-language-scope.entity.d.ts.map +0 -1
  383. package/dist/backend/entities/product-channel-language-scope.entity.js.map +0 -1
  384. package/dist/backend/entities/product-channel-scope.entity.d.ts.map +0 -1
  385. package/dist/backend/entities/product-channel-scope.entity.js.map +0 -1
  386. package/dist/backend/entities/product-editor-preference.entity.d.ts.map +0 -1
  387. package/dist/backend/entities/product-editor-preference.entity.js.map +0 -1
  388. package/dist/backend/entities/product-link.entity.d.ts.map +0 -1
  389. package/dist/backend/entities/product-link.entity.js.map +0 -1
  390. package/dist/backend/entities/product-list-saved-view.entity.d.ts.map +0 -1
  391. package/dist/backend/entities/product-list-saved-view.entity.js.map +0 -1
  392. package/dist/backend/entities/product-packaging-unit.entity.d.ts.map +0 -1
  393. package/dist/backend/entities/product-packaging-unit.entity.js.map +0 -1
  394. package/dist/backend/entities/product-url-key.entity.d.ts.map +0 -1
  395. package/dist/backend/entities/product-url-key.entity.js.map +0 -1
  396. package/dist/backend/entities/product-url-redirect.entity.d.ts.map +0 -1
  397. package/dist/backend/entities/product-url-redirect.entity.js.map +0 -1
  398. package/dist/backend/entities/product-value-override.entity.d.ts.map +0 -1
  399. package/dist/backend/entities/product-value-override.entity.js.map +0 -1
  400. package/dist/backend/entities/product-variant.entity.d.ts.map +0 -1
  401. package/dist/backend/entities/product-variant.entity.js.map +0 -1
  402. package/dist/backend/entities/product.entity.d.ts.map +0 -1
  403. package/dist/backend/entities/product.entity.js.map +0 -1
  404. package/dist/backend/index.d.ts.map +0 -1
  405. package/dist/backend/index.js.map +0 -1
  406. package/dist/backend/plugin.d.ts.map +0 -1
  407. package/dist/backend/plugin.js.map +0 -1
  408. package/dist/backend/prompt-tools.d.ts.map +0 -1
  409. package/dist/backend/prompt-tools.js.map +0 -1
  410. package/dist/backend/routes.admin.d.ts.map +0 -1
  411. package/dist/backend/routes.admin.js.map +0 -1
  412. package/dist/backend/routes.admin.url-keys.d.ts.map +0 -1
  413. package/dist/backend/routes.admin.url-keys.js.map +0 -1
  414. package/dist/backend/routes.api-key.d.ts.map +0 -1
  415. package/dist/backend/routes.api-key.js.map +0 -1
  416. package/dist/backend/routes.external.d.ts.map +0 -1
  417. package/dist/backend/routes.external.js.map +0 -1
  418. package/dist/backend/routes.public.d.ts.map +0 -1
  419. package/dist/backend/routes.public.js.map +0 -1
  420. package/dist/backend/routes.public.url-keys.d.ts.map +0 -1
  421. package/dist/backend/routes.public.url-keys.js.map +0 -1
  422. package/dist/backend/saved-view-actor.d.ts.map +0 -1
  423. package/dist/backend/saved-view-actor.js.map +0 -1
  424. package/dist/backend/services/asset-references.d.ts.map +0 -1
  425. package/dist/backend/services/asset-references.js.map +0 -1
  426. package/dist/backend/services/attachment-packaging-scopes.d.ts.map +0 -1
  427. package/dist/backend/services/attachment-packaging-scopes.js.map +0 -1
  428. package/dist/backend/services/attachment.service.d.ts.map +0 -1
  429. package/dist/backend/services/attachment.service.js.map +0 -1
  430. package/dist/backend/services/attribute-option-validator.d.ts.map +0 -1
  431. package/dist/backend/services/attribute-option-validator.js.map +0 -1
  432. package/dist/backend/services/attribute-scope-preview.d.ts.map +0 -1
  433. package/dist/backend/services/attribute-scope-preview.js.map +0 -1
  434. package/dist/backend/services/attribute-set-validations.d.ts.map +0 -1
  435. package/dist/backend/services/attribute-set-validations.js.map +0 -1
  436. package/dist/backend/services/attribute-set.service.d.ts.map +0 -1
  437. package/dist/backend/services/attribute-set.service.js.map +0 -1
  438. package/dist/backend/services/attribute-type-mapping.d.ts.map +0 -1
  439. package/dist/backend/services/attribute-type-mapping.js.map +0 -1
  440. package/dist/backend/services/attribute-value-key.service.d.ts.map +0 -1
  441. package/dist/backend/services/attribute-value-key.service.js.map +0 -1
  442. package/dist/backend/services/audit-references.d.ts.map +0 -1
  443. package/dist/backend/services/audit-references.js.map +0 -1
  444. package/dist/backend/services/bulk-operation-queue.d.ts.map +0 -1
  445. package/dist/backend/services/bulk-operation-queue.js.map +0 -1
  446. package/dist/backend/services/bulk-operation.service.d.ts.map +0 -1
  447. package/dist/backend/services/bulk-operation.service.js.map +0 -1
  448. package/dist/backend/services/bundle.service.d.ts.map +0 -1
  449. package/dist/backend/services/bundle.service.js.map +0 -1
  450. package/dist/backend/services/catalog-admin-search.service.d.ts.map +0 -1
  451. package/dist/backend/services/catalog-admin-search.service.js.map +0 -1
  452. package/dist/backend/services/catalog-admin.service.d.ts.map +0 -1
  453. package/dist/backend/services/catalog-admin.service.js.map +0 -1
  454. package/dist/backend/services/catalog-attribute-read.service.d.ts.map +0 -1
  455. package/dist/backend/services/catalog-attribute-read.service.js.map +0 -1
  456. package/dist/backend/services/catalog-bulk-import.service.d.ts.map +0 -1
  457. package/dist/backend/services/catalog-bulk-import.service.js.map +0 -1
  458. package/dist/backend/services/catalog-bulk-update.service.d.ts.map +0 -1
  459. package/dist/backend/services/catalog-bulk-update.service.js.map +0 -1
  460. package/dist/backend/services/catalog-category-read.service.d.ts.map +0 -1
  461. package/dist/backend/services/catalog-category-read.service.js.map +0 -1
  462. package/dist/backend/services/catalog-org-price-decorator.d.ts.map +0 -1
  463. package/dist/backend/services/catalog-org-price-decorator.js.map +0 -1
  464. package/dist/backend/services/catalog-product-filter.service.d.ts.map +0 -1
  465. package/dist/backend/services/catalog-product-filter.service.js.map +0 -1
  466. package/dist/backend/services/catalog-product-read.service.d.ts.map +0 -1
  467. package/dist/backend/services/catalog-product-read.service.js.map +0 -1
  468. package/dist/backend/services/catalog-query.service.d.ts.map +0 -1
  469. package/dist/backend/services/catalog-query.service.js.map +0 -1
  470. package/dist/backend/services/catalog-quick-search.service.d.ts.map +0 -1
  471. package/dist/backend/services/catalog-quick-search.service.js.map +0 -1
  472. package/dist/backend/services/catalog-write-ports.d.ts.map +0 -1
  473. package/dist/backend/services/catalog-write-ports.js.map +0 -1
  474. package/dist/backend/services/category-admin.service.d.ts.map +0 -1
  475. package/dist/backend/services/category-admin.service.js.map +0 -1
  476. package/dist/backend/services/channel-url-facts.d.ts.map +0 -1
  477. package/dist/backend/services/channel-url-facts.js.map +0 -1
  478. package/dist/backend/services/effective-value.sql.d.ts.map +0 -1
  479. package/dist/backend/services/effective-value.sql.js.map +0 -1
  480. package/dist/backend/services/gallery-scopes.d.ts.map +0 -1
  481. package/dist/backend/services/gallery-scopes.js.map +0 -1
  482. package/dist/backend/services/gallery.service.d.ts.map +0 -1
  483. package/dist/backend/services/gallery.service.js.map +0 -1
  484. package/dist/backend/services/grouped.service.d.ts.map +0 -1
  485. package/dist/backend/services/grouped.service.js.map +0 -1
  486. package/dist/backend/services/label-resolver.d.ts.map +0 -1
  487. package/dist/backend/services/label-resolver.js.map +0 -1
  488. package/dist/backend/services/linkable-asset.d.ts.map +0 -1
  489. package/dist/backend/services/linkable-asset.js.map +0 -1
  490. package/dist/backend/services/packaging-unit.service.d.ts.map +0 -1
  491. package/dist/backend/services/packaging-unit.service.js.map +0 -1
  492. package/dist/backend/services/primary-asset-url.d.ts.map +0 -1
  493. package/dist/backend/services/primary-asset-url.js.map +0 -1
  494. package/dist/backend/services/product-availability.service.d.ts.map +0 -1
  495. package/dist/backend/services/product-availability.service.js.map +0 -1
  496. package/dist/backend/services/product-availability.sql.d.ts.map +0 -1
  497. package/dist/backend/services/product-availability.sql.js.map +0 -1
  498. package/dist/backend/services/product-editor-preferences.service.d.ts.map +0 -1
  499. package/dist/backend/services/product-editor-preferences.service.js.map +0 -1
  500. package/dist/backend/services/product-link.service.d.ts.map +0 -1
  501. package/dist/backend/services/product-link.service.js.map +0 -1
  502. package/dist/backend/services/product-list-view-service.d.ts.map +0 -1
  503. package/dist/backend/services/product-list-view-service.js.map +0 -1
  504. package/dist/backend/services/product-overrides.service.d.ts +0 -84
  505. package/dist/backend/services/product-overrides.service.d.ts.map +0 -1
  506. package/dist/backend/services/product-overrides.service.js +0 -211
  507. package/dist/backend/services/product-overrides.service.js.map +0 -1
  508. package/dist/backend/services/product-page-revalidation.d.ts.map +0 -1
  509. package/dist/backend/services/product-page-revalidation.js.map +0 -1
  510. package/dist/backend/services/product-scope-context.service.d.ts +0 -36
  511. package/dist/backend/services/product-scope-context.service.d.ts.map +0 -1
  512. package/dist/backend/services/product-scope-context.service.js +0 -107
  513. package/dist/backend/services/product-scope-context.service.js.map +0 -1
  514. package/dist/backend/services/product-scopes.service.d.ts.map +0 -1
  515. package/dist/backend/services/product-scopes.service.js.map +0 -1
  516. package/dist/backend/services/product-summary-text.d.ts.map +0 -1
  517. package/dist/backend/services/product-summary-text.js.map +0 -1
  518. package/dist/backend/services/product-type-validations.d.ts.map +0 -1
  519. package/dist/backend/services/product-type-validations.js.map +0 -1
  520. package/dist/backend/services/product-value-resolver.service.d.ts.map +0 -1
  521. package/dist/backend/services/product-value-resolver.service.js.map +0 -1
  522. package/dist/backend/services/publication-window-sweep.d.ts.map +0 -1
  523. package/dist/backend/services/publication-window-sweep.js.map +0 -1
  524. package/dist/backend/services/scope-completeness.d.ts.map +0 -1
  525. package/dist/backend/services/scope-completeness.js.map +0 -1
  526. package/dist/backend/services/scope-overview.service.d.ts.map +0 -1
  527. package/dist/backend/services/scope-overview.service.js.map +0 -1
  528. package/dist/backend/services/sql-id-arrays.d.ts.map +0 -1
  529. package/dist/backend/services/sql-id-arrays.js.map +0 -1
  530. package/dist/backend/services/storefront-value-overrides.d.ts.map +0 -1
  531. package/dist/backend/services/storefront-value-overrides.js.map +0 -1
  532. package/dist/backend/services/system-attribute-scopes.d.ts.map +0 -1
  533. package/dist/backend/services/system-attribute-scopes.js.map +0 -1
  534. package/dist/backend/services/url-key-resolution.service.d.ts.map +0 -1
  535. package/dist/backend/services/url-key-resolution.service.js.map +0 -1
  536. package/dist/backend/services/url-key.service.d.ts.map +0 -1
  537. package/dist/backend/services/url-key.service.js.map +0 -1
  538. package/dist/backend/services/viewer-organization.d.ts.map +0 -1
  539. package/dist/backend/services/viewer-organization.js.map +0 -1
  540. package/dist/manifest.d.ts.map +0 -1
  541. package/dist/manifest.js.map +0 -1
  542. package/dist/migrations/20260429T064146_catalog_attribute_sets_init.d.ts.map +0 -1
  543. package/dist/migrations/20260429T064146_catalog_attribute_sets_init.js.map +0 -1
  544. package/dist/migrations/20260429T070004_catalog_product_attribute_extensions.d.ts.map +0 -1
  545. package/dist/migrations/20260429T070004_catalog_product_attribute_extensions.js.map +0 -1
  546. package/dist/migrations/20260429T102322_catalog_product_type_and_virtual_fields.d.ts.map +0 -1
  547. package/dist/migrations/20260429T102322_catalog_product_type_and_virtual_fields.js.map +0 -1
  548. package/dist/migrations/20260429T111839_catalog_gallery_items_and_labels.d.ts.map +0 -1
  549. package/dist/migrations/20260429T111839_catalog_gallery_items_and_labels.js.map +0 -1
  550. package/dist/migrations/20260429T112543_catalog_product_attachments.d.ts.map +0 -1
  551. package/dist/migrations/20260429T112543_catalog_product_attachments.js.map +0 -1
  552. package/dist/migrations/20260429T123726_catalog_product_links.d.ts.map +0 -1
  553. package/dist/migrations/20260429T123726_catalog_product_links.js.map +0 -1
  554. package/dist/migrations/20260429T130803_catalog_grouped_and_bundle.d.ts.map +0 -1
  555. package/dist/migrations/20260429T130803_catalog_grouped_and_bundle.js.map +0 -1
  556. package/dist/migrations/20260501T185835_catalog_product_attribute_is_comparable.d.ts.map +0 -1
  557. package/dist/migrations/20260501T185835_catalog_product_attribute_is_comparable.js.map +0 -1
  558. package/dist/migrations/20260505T060113_catalog_attribute_options_and_flags.d.ts.map +0 -1
  559. package/dist/migrations/20260505T060113_catalog_attribute_options_and_flags.js.map +0 -1
  560. package/dist/migrations/20260515T082629_catalog_attribute_mass_editable.d.ts.map +0 -1
  561. package/dist/migrations/20260515T082629_catalog_attribute_mass_editable.js.map +0 -1
  562. package/dist/migrations/20260526T124736_catalog_product_status_inactive.d.ts.map +0 -1
  563. package/dist/migrations/20260526T124736_catalog_product_status_inactive.js.map +0 -1
  564. package/dist/migrations/20260611T140346_catalog_product_value_overrides_init.d.ts.map +0 -1
  565. package/dist/migrations/20260611T140346_catalog_product_value_overrides_init.js.map +0 -1
  566. package/dist/migrations/20260611T140400_catalog_attribute_quick_searchable.d.ts.map +0 -1
  567. package/dist/migrations/20260611T140400_catalog_attribute_quick_searchable.js.map +0 -1
  568. package/dist/migrations/20260611T140407_catalog_bulk_operations.d.ts.map +0 -1
  569. package/dist/migrations/20260611T140407_catalog_bulk_operations.js.map +0 -1
  570. package/dist/migrations/20260611T140408_catalog_bulk_operation_logs.d.ts.map +0 -1
  571. package/dist/migrations/20260611T140408_catalog_bulk_operation_logs.js.map +0 -1
  572. package/dist/migrations/20260611T140412_catalog_product_packaging_units.d.ts.map +0 -1
  573. package/dist/migrations/20260611T140412_catalog_product_packaging_units.js.map +0 -1
  574. package/dist/migrations/20260718T060659_catalog_bulk_operation_revert_state.d.ts.map +0 -1
  575. package/dist/migrations/20260718T060659_catalog_bulk_operation_revert_state.js.map +0 -1
  576. package/dist/migrations/20260718T200343_catalog_category_custom_field_values.d.ts.map +0 -1
  577. package/dist/migrations/20260718T200343_catalog_category_custom_field_values.js.map +0 -1
  578. package/dist/migrations/20260723T230401_catalog_attributes_on_custom_fields.d.ts.map +0 -1
  579. package/dist/migrations/20260723T230401_catalog_attributes_on_custom_fields.js.map +0 -1
  580. package/dist/migrations/20260804T152604_catalog_widen_product_sku.d.ts.map +0 -1
  581. package/dist/migrations/20260804T152604_catalog_widen_product_sku.js.map +0 -1
  582. package/dist/migrations/20260804T160244_catalog_category_activation.d.ts.map +0 -1
  583. package/dist/migrations/20260804T160244_catalog_category_activation.js.map +0 -1
  584. package/dist/migrations/20260912T094557_catalog_sales_channel_products.d.ts.map +0 -1
  585. package/dist/migrations/20260912T094557_catalog_sales_channel_products.js.map +0 -1
  586. package/dist/migrations/20260912T094623_catalog_sales_channel_categories.d.ts.map +0 -1
  587. package/dist/migrations/20260912T094623_catalog_sales_channel_categories.js.map +0 -1
  588. package/dist/migrations/20260925T125527_catalog_inventory_columns.d.ts.map +0 -1
  589. package/dist/migrations/20260925T125527_catalog_inventory_columns.js.map +0 -1
  590. package/dist/migrations/20261008T080839_catalog_product_attribute_is_price_rule.d.ts.map +0 -1
  591. package/dist/migrations/20261008T080839_catalog_product_attribute_is_price_rule.js.map +0 -1
  592. package/dist/migrations/20261008T092714_catalog_category_content.d.ts.map +0 -1
  593. package/dist/migrations/20261008T092714_catalog_category_content.js.map +0 -1
  594. package/dist/migrations/20261014T170531_catalog_product_list_saved_views.d.ts.map +0 -1
  595. package/dist/migrations/20261014T170531_catalog_product_list_saved_views.js.map +0 -1
  596. package/dist/migrations/20261016T082008_catalog_order_rules.d.ts.map +0 -1
  597. package/dist/migrations/20261016T082008_catalog_order_rules.js.map +0 -1
  598. package/dist/migrations/20261022T035133_catalog_product_scopes.d.ts.map +0 -1
  599. package/dist/migrations/20261022T035133_catalog_product_scopes.js.map +0 -1
  600. package/dist/migrations/20261022T054223_catalog_product_url_keys.d.ts.map +0 -1
  601. package/dist/migrations/20261022T054223_catalog_product_url_keys.js.map +0 -1
  602. package/dist/migrations/20261022T111811_catalog_price_fields_removed.d.ts.map +0 -1
  603. package/dist/migrations/20261022T111811_catalog_price_fields_removed.js.map +0 -1
  604. package/dist/migrations/20261022T182523_catalog_admin_name_keys.d.ts.map +0 -1
  605. package/dist/migrations/20261022T182523_catalog_admin_name_keys.js.map +0 -1
  606. package/dist/migrations/20261025T222634_catalog_product_status_drop_draft.d.ts.map +0 -1
  607. package/dist/migrations/20261025T222634_catalog_product_status_drop_draft.js.map +0 -1
  608. package/dist/migrations/20261026T033453_catalog_product_media_scopes.d.ts.map +0 -1
  609. package/dist/migrations/20261026T033453_catalog_product_media_scopes.js.map +0 -1
  610. package/dist/migrations/20261026T084533_catalog_attachment_packaging_translations.d.ts.map +0 -1
  611. package/dist/migrations/20261026T084533_catalog_attachment_packaging_translations.js.map +0 -1
  612. package/dist/migrations/index.d.ts.map +0 -1
  613. package/dist/migrations/index.js.map +0 -1
  614. package/dist/ports/index.d.ts.map +0 -1
  615. package/dist/ports/index.js.map +0 -1
@@ -3,12 +3,13 @@ import { LockMode, UniqueConstraintViolationException } from '@mikro-orm/core';
3
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, uuidSchema, } from '@endora-commerce/contracts';
6
+ slugify as slugifyText, uuidSchema, isUuidShape, } 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
10
  import { ProductUrlRedirect } from '../entities/product-url-redirect.entity.js';
11
- import { isUrlKeyFree, lockUrlKeys } from './url-key.service.js';
11
+ import { allocateFreeSlug } from './url-key.service.js';
12
+ import { bumpScopeVersion } from './scoped-values-state.js';
12
13
  import { ProductVariant } from '../entities/product-variant.entity.js';
13
14
  import { ProductChannelScope } from '../entities/product-channel-scope.entity.js';
14
15
  import { ProductChannelLanguageScope } from '../entities/product-channel-language-scope.entity.js';
@@ -17,6 +18,9 @@ import { toChannelRecord, toLanguageRecord } from './product-scopes.service.js';
17
18
  import { assertVirtualDownloadFields, ProductTypeValidationError, } from './product-type-validations.js';
18
19
  import { createAttributeCommand, createAttributeOptionCommand, deleteAttributeCommand, deleteAttributeOptionCommand, updateAttributeCommand, updateAttributeOptionCommand, } from '../commands/attribute-commands.js';
19
20
  import { requireLinkableAsset } from './linkable-asset.js';
21
+ import { attributeSetExists, findSkuHolder, missingCategoryIds, missingRequiredAttributeKeys, PRODUCT_SKU_MAX, reconcileProductCategories, } from './product-global-field-rules.js';
22
+ import { assertNoContentAttributeValues } from './content-attribute-rules.js';
23
+ import { readAttributeUsage } from './attribute-usage.js';
20
24
  // Feature 061 — the API-form mapping helpers moved next to the R7 map; the
21
25
  // re-exports keep the long-standing import site (routes, tests) stable.
22
26
  export { dbToApiAttributeType, resolveAttributeApiType } from './attribute-type-mapping.js';
@@ -46,10 +50,13 @@ export function refusePriceFields(fields, pathPrefix = '') {
46
50
  * identifier, derived or otherwise.
47
51
  */
48
52
  const SKU_MAX_LENGTH = 255;
53
+ /** Issue #241 — value equality for a product field the update compares before it writes. */
54
+ function sameValue(a, b) {
55
+ return JSON.stringify(a) === JSON.stringify(b);
56
+ }
49
57
  export class CatalogAdminService {
50
58
  emFactory;
51
59
  events;
52
- auditLog;
53
60
  salesChannelMembership;
54
61
  commandBus;
55
62
  attributeRead;
@@ -57,7 +64,14 @@ export class CatalogAdminService {
57
64
  copyWarehouseThresholds;
58
65
  completenessGate;
59
66
  assets;
60
- constructor(emFactory, events, auditLog,
67
+ copySeoProductMeta;
68
+ constructor(emFactory, events,
69
+ /**
70
+ * Unread since issue #241: the last write it recorded by hand, the bulk edit's
71
+ * `product.update`, now runs the Command. Kept so the positional signature the
72
+ * composition and the fixtures construct this service with does not move.
73
+ */
74
+ _auditLog,
61
75
  /**
62
76
  * Feature 005 / T027 — when injected, every newly-created Product
63
77
  * that does not declare explicit channel membership lands in the
@@ -104,10 +118,11 @@ export class CatalogAdminService {
104
118
  * constructing the service; a create that names a file without it fails
105
119
  * closed ({@link CatalogAdminService.#requireAssets}).
106
120
  */
107
- assets) {
121
+ assets,
122
+ /** Feature 174 (FR-119) — `seo`'s metadata copy for a duplicate, presence-decided by the wiring. */
123
+ copySeoProductMeta) {
108
124
  this.emFactory = emFactory;
109
125
  this.events = events;
110
- this.auditLog = auditLog;
111
126
  this.salesChannelMembership = salesChannelMembership;
112
127
  this.commandBus = commandBus;
113
128
  this.attributeRead = attributeRead;
@@ -115,6 +130,7 @@ export class CatalogAdminService {
115
130
  this.copyWarehouseThresholds = copyWarehouseThresholds;
116
131
  this.completenessGate = completenessGate;
117
132
  this.assets = assets;
133
+ this.copySeoProductMeta = copySeoProductMeta;
118
134
  }
119
135
  #requireAssets() {
120
136
  if (!this.assets) {
@@ -126,6 +142,16 @@ export class CatalogAdminService {
126
142
  async completenessMode() {
127
143
  return this.completenessGate?.mode();
128
144
  }
145
+ /**
146
+ * Feature 172 (FR-014) — the early refusal of a content attribute's key on a
147
+ * product write, before any row is read or a transaction opened. Reads the
148
+ * attribute model only when the write carries attribute values at all.
149
+ */
150
+ async #refuseContentAttributeValues(attributeValues) {
151
+ if (!attributeValues || Object.keys(attributeValues).length === 0)
152
+ return;
153
+ assertNoContentAttributeValues(attributeValues, await this.#requireAttributeRead().listAll());
154
+ }
129
155
  #requireAttributeRead() {
130
156
  if (!this.attributeRead) {
131
157
  throw new Error('CatalogAdminService: CatalogAttributeReadService is not wired — attribute reads are unavailable.');
@@ -196,6 +222,9 @@ export class CatalogAdminService {
196
222
  */
197
223
  async createProduct(req, _auditCtx) {
198
224
  refusePriceFields(req.attributeValues, 'attributeValues.');
225
+ // Feature 172 (FR-014) — refused before the Command opens a transaction;
226
+ // the set guard inside it refuses the same keys again for every other path.
227
+ await this.#refuseContentAttributeValues(req.attributeValues);
199
228
  // Feature 002 (T047): cross-field validation for virtual download
200
229
  // fields. Zod's .refine() catches most cases at the boundary; the
201
230
  // service-level guard is the belt-and-braces backstop for any
@@ -252,7 +281,7 @@ export class CatalogAdminService {
252
281
  // to be allocated against the live table. Without this, two products
253
282
  // sharing a name collided on the slug index and the catch above
254
283
  // mislabelled the failure `SKU_ALREADY_EXISTS`.
255
- const slug = await this.allocateUniqueSlug(em, this.anyValue(req.name) || req.sku);
284
+ const slug = await this.allocateUniqueSlug(em, req.name || req.sku);
256
285
  const product = em.create(Product, {
257
286
  id: productId,
258
287
  sku: req.sku,
@@ -300,7 +329,7 @@ export class CatalogAdminService {
300
329
  result: product,
301
330
  after: {
302
331
  sku: product.sku,
303
- name: { ...product.name },
332
+ name: product.name,
304
333
  status: product.status,
305
334
  visibility: product.visibility,
306
335
  stockMode: product.stockMode,
@@ -321,26 +350,19 @@ export class CatalogAdminService {
321
350
  }),
322
351
  };
323
352
  }
324
- async updateProduct(id, req, auditCtx, gate) {
353
+ /**
354
+ * The unaudited product update: the write, its flush and `product.updated.v1`,
355
+ * with no Command and no audit entry. Only the bus-less fallback of
356
+ * {@link updateProductAudited} and fixtures reach it; every operator, API-key and
357
+ * bulk write runs the `product.update` Command (issue #241, Principle XIII).
358
+ */
359
+ async updateProduct(id, req, gate) {
325
360
  const em = this.emFactory();
326
361
  const r = await this.#applyProductUpdate(em, id, req, gate);
327
362
  await em.flush();
328
- if (this.auditLog && auditCtx) {
329
- await this.auditLog.record({
330
- actorAdminUserId: auditCtx.actorAdminUserId,
331
- ...(auditCtx.impersonatedCustomerAccountId !== undefined
332
- ? { impersonatedCustomerAccountId: auditCtx.impersonatedCustomerAccountId }
333
- : {}),
334
- action: 'product.update',
335
- objectType: 'product',
336
- objectId: r.product.id,
337
- stateBefore: r.stateBefore,
338
- stateAfter: { ...r.stateAfter, changedFields: r.changedFields },
339
- ...(auditCtx.ipAddress !== undefined ? { ipAddress: auditCtx.ipAddress } : {}),
340
- ...(auditCtx.userAgent !== undefined ? { userAgent: auditCtx.userAgent } : {}),
341
- ...(auditCtx.requestId !== undefined ? { requestId: auditCtx.requestId } : {}),
342
- });
343
- }
363
+ // Issue #241 — a write that changed nothing announces nothing.
364
+ if (r.changedFields.length === 0)
365
+ return r.product;
344
366
  // Feature 163 (FR-010) — a status write never archives, so this write has
345
367
  // one announcement; `product.archived.v1` belongs to the Archive action.
346
368
  this.events.emit('product.updated.v1', {
@@ -383,12 +405,23 @@ export class CatalogAdminService {
383
405
  }
384
406
  /**
385
407
  * Feature 054 — admin single-update path, audited co-transactionally via the
386
- * Command Bus (one audit row + the event on commit, none on rollback). Falls
387
- * back to the legacy `updateProduct` when no bus is injected (bus-less tests).
408
+ * Command Bus (one audit row + the event on commit, none on rollback; none either
409
+ * when nothing changed, issue #241). Falls back to the unaudited `updateProduct`
410
+ * when no bus is injected (bus-less tests).
388
411
  */
412
+ /**
413
+ * Whether product writes run through the Command Bus, and so are audited. A bulk
414
+ * edit refuses to run when they do not (issue #241): its per-product writes would
415
+ * fall back to the unaudited `updateProduct`.
416
+ */
417
+ hasCommandBus() {
418
+ return this.commandBus !== undefined;
419
+ }
389
420
  async updateProductAudited(id, req, gate) {
421
+ // Feature 172 (FR-014) — before the transaction, as on create.
422
+ await this.#refuseContentAttributeValues(req.attributeValues);
390
423
  if (!this.commandBus)
391
- return this.updateProduct(id, req, undefined, gate);
424
+ return this.updateProduct(id, req, gate);
392
425
  return this.commandBus.run(this.#updateProductCommand(id, req, gate));
393
426
  }
394
427
  #updateProductCommand(id, req, gate) {
@@ -400,21 +433,27 @@ export class CatalogAdminService {
400
433
  run: async ({ em }) => {
401
434
  const r = await this.#applyProductUpdate(em, id, req, gate);
402
435
  changedFields = r.changedFields;
436
+ // Issue #241 — a write that changed nothing records no entry and announces
437
+ // nothing. The editor's version bump still commits, as on a no-op scope write.
438
+ if (changedFields.length === 0)
439
+ return { result: r.product, skipAudit: true };
403
440
  return {
404
441
  result: r.product,
405
442
  before: r.stateBefore,
406
443
  after: { ...r.stateAfter, changedFields, ...(gate?.apiKeyId ? { apiKeyId: gate.apiKeyId } : {}) },
407
444
  };
408
445
  },
409
- event: (product) => ({
410
- eventName: 'product.updated.v1',
411
- payload: {
412
- eventId: randomUUID(),
413
- occurredAt: new Date().toISOString(),
414
- productId: product.id,
415
- changedFields,
446
+ event: (product) => changedFields.length === 0
447
+ ? undefined
448
+ : {
449
+ eventName: 'product.updated.v1',
450
+ payload: {
451
+ eventId: randomUUID(),
452
+ occurredAt: new Date().toISOString(),
453
+ productId: product.id,
454
+ changedFields,
455
+ },
416
456
  },
417
- }),
418
457
  };
419
458
  }
420
459
  /**
@@ -423,16 +462,37 @@ export class CatalogAdminService {
423
462
  */
424
463
  async #applyProductUpdate(em, id, req, gate) {
425
464
  refusePriceFields(req.attributeValues, 'attributeValues.');
465
+ if (!isUuidShape(id)) {
466
+ throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
467
+ }
426
468
  const product = await em.findOne(Product, { id });
427
469
  if (!product) {
428
470
  throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
429
471
  }
430
472
  // Feature 155 (FR-001, D5) — refused before anything on the row changes.
431
473
  assertOrderMinimumAllowed(product.type, req.minOrderQuantity);
474
+ // Feature 174 (C2/C3 code review 1) — the existence rules the scoped save holds for the same
475
+ // Global-only fields (`product-global-field-rules.ts`), checked before anything is written:
476
+ // an unknown attribute set or an unknown or deleted category used to reach the foreign key
477
+ // (a 500), and a deleted category was linked silently.
478
+ if (req.attributeSetId !== undefined &&
479
+ req.attributeSetId !== product.attributeSetId &&
480
+ !(await attributeSetExists(em, req.attributeSetId))) {
481
+ throw new HttpError(400, ERROR_CODES.VALIDATION_FAILED, 'unknown_attribute_set');
482
+ }
483
+ if (req.categoryIds !== undefined) {
484
+ const missing = await missingCategoryIds(em, req.categoryIds);
485
+ if (missing.length > 0) {
486
+ throw new HttpError(400, ERROR_CODES.VALIDATION_FAILED, `unknown_category_ids: ${missing.join(', ')}`);
487
+ }
488
+ }
489
+ // Feature 174 (R7, contract §6) — a product-row write is Save-overwritable: it moves the
490
+ // editor's version, and a `version` the caller sends is compared first (stale → 409).
491
+ await bumpScopeVersion(em, id, req.version);
432
492
  const stateBefore = {
433
493
  sku: product.sku,
434
- name: { ...product.name },
435
- description: { ...product.description },
494
+ name: product.name,
495
+ description: product.description,
436
496
  stockMode: product.stockMode,
437
497
  visibility: product.visibility,
438
498
  status: product.status,
@@ -459,34 +519,37 @@ export class CatalogAdminService {
459
519
  // create contract enforces. This guard used to read 160 while the
460
520
  // column held 64, so a 100-character rename passed validation and then
461
521
  // failed at the database; all three now agree.
462
- if (trimmed.length === 0 || trimmed.length > 255) {
522
+ if (trimmed.length === 0 || trimmed.length > PRODUCT_SKU_MAX) {
463
523
  throw new HttpError(400, ERROR_CODES.VALIDATION_FAILED, 'invalid_sku');
464
524
  }
465
- const conflict = await em.findOne(Product, { sku: trimmed });
466
- if (conflict && conflict.id !== product.id) {
467
- throw new HttpError(400, ERROR_CODES.VALIDATION_FAILED, `sku_in_use { conflictingProductId: ${conflict.id}, conflictingSku: ${trimmed} }`);
468
- }
469
525
  // Feature 025 — SKUs share a global namespace with variants (see createVariant).
470
- const variantConflict = await em.findOne(ProductVariant, { sku: trimmed });
471
- if (variantConflict) {
472
- throw new HttpError(400, ERROR_CODES.VALIDATION_FAILED, `sku_in_use { conflictingVariantId: ${variantConflict.id}, conflictingSku: ${trimmed} }`);
526
+ const holder = await findSkuHolder(em, product.id, trimmed);
527
+ if (holder) {
528
+ // Issue #624 (#86) — create's code and status for the same refusal;
529
+ // the token says which kind of row holds the SKU. The SKU travels as
530
+ // `sku`: `details.code` is the envelope's token slot.
531
+ throw new HttpError(409, ERROR_CODES.SKU_ALREADY_EXISTS, `SKU "${trimmed}" is already used by another ${'productId' in holder ? 'product' : 'variant'}.`, 'productId' in holder
532
+ ? { code: 'held_by_product', sku: trimmed, conflictingProductId: holder.productId }
533
+ : { code: 'held_by_variant', sku: trimmed, conflictingVariantId: holder.variantId });
473
534
  }
474
535
  product.sku = trimmed;
475
536
  changedFields.push('sku');
476
537
  }
477
- if (req.name) {
538
+ // Issue #241 — a field is changed only when its value moves: a write that
539
+ // restates what is stored records no audit entry and announces nothing.
540
+ if (req.name && req.name !== product.name) {
478
541
  product.name = req.name;
479
542
  changedFields.push('name');
480
543
  }
481
- if (req.description) {
544
+ if (req.description && req.description !== product.description) {
482
545
  product.description = req.description;
483
546
  changedFields.push('description');
484
547
  }
485
- if (req.stockMode !== undefined) {
548
+ if (req.stockMode !== undefined && req.stockMode !== (product.stockMode ?? null)) {
486
549
  product.stockMode = req.stockMode;
487
550
  changedFields.push('stockMode');
488
551
  }
489
- if (req.visibility) {
552
+ if (req.visibility && req.visibility !== product.visibility) {
490
553
  product.visibility = req.visibility;
491
554
  changedFields.push('visibility');
492
555
  }
@@ -518,8 +581,12 @@ export class CatalogAdminService {
518
581
  // the set; we validate the incoming patch only since the existing
519
582
  // values were already validated at their time of write.
520
583
  await this.assertAttributeValueKeysAllowed(em, product.attributeSetId, req.attributeValues, new Set(Object.keys(product.attributeValues ?? {})));
521
- product.attributeValues = { ...product.attributeValues, ...req.attributeValues };
522
- changedFields.push('attributeValues');
584
+ const current = product.attributeValues ?? {};
585
+ const patch = req.attributeValues;
586
+ if (Object.keys(patch).some((key) => !sameValue(current[key], patch[key]))) {
587
+ product.attributeValues = { ...current, ...patch };
588
+ changedFields.push('attributeValues');
589
+ }
523
590
  }
524
591
  // Feature 012 / FR-013 — refuse the save if any required attribute
525
592
  // in the assigned set is left without a value. The merged map is
@@ -530,7 +597,7 @@ export class CatalogAdminService {
530
597
  req.attributeSetId !== undefined)) {
531
598
  await this.assertRequiredAttributesPresent(em, product.attributeSetId, product.attributeValues ?? {});
532
599
  }
533
- if (req.allowedOrganizationIds) {
600
+ if (req.allowedOrganizationIds && !sameValue(req.allowedOrganizationIds, product.allowedOrganizationIds)) {
534
601
  product.allowedOrganizationIds = req.allowedOrganizationIds;
535
602
  changedFields.push('allowedOrganizationIds');
536
603
  }
@@ -546,36 +613,37 @@ export class CatalogAdminService {
546
613
  }
547
614
  }
548
615
  // Feature 010 — per-product stock-management flags.
549
- if (req.manageStock !== undefined) {
616
+ if (req.manageStock !== undefined && req.manageStock !== product.manageStock) {
550
617
  product.manageStock = req.manageStock;
551
618
  changedFields.push('manageStock');
552
619
  }
553
- if (req.backorderEnabled !== undefined) {
620
+ if (req.backorderEnabled !== undefined && req.backorderEnabled !== product.backorderEnabled) {
554
621
  product.backorderEnabled = req.backorderEnabled;
555
622
  changedFields.push('backorderEnabled');
556
623
  }
557
- if (req.lowStockThreshold !== undefined) {
624
+ if (req.lowStockThreshold !== undefined && req.lowStockThreshold !== (product.lowStockThreshold ?? null)) {
558
625
  product.lowStockThreshold = req.lowStockThreshold;
559
626
  changedFields.push('lowStockThreshold');
560
627
  }
561
- if (req.lowStockThresholdMode !== undefined) {
628
+ if (req.lowStockThresholdMode !== undefined && req.lowStockThresholdMode !== product.lowStockThresholdMode) {
562
629
  product.lowStockThresholdMode = req.lowStockThresholdMode;
563
630
  changedFields.push('lowStockThresholdMode');
564
631
  }
565
- if (req.fulfilmentStrategy !== undefined) {
632
+ if (req.fulfilmentStrategy !== undefined && req.fulfilmentStrategy !== (product.fulfilmentStrategy ?? null)) {
566
633
  product.fulfilmentStrategy = req.fulfilmentStrategy;
567
634
  changedFields.push('fulfilmentStrategy');
568
635
  }
569
- if (req.fulfilmentStrategyWarehouseOrder !== undefined) {
636
+ if (req.fulfilmentStrategyWarehouseOrder !== undefined &&
637
+ !sameValue(req.fulfilmentStrategyWarehouseOrder, product.fulfilmentStrategyWarehouseOrder ?? null)) {
570
638
  product.fulfilmentStrategyWarehouseOrder = req.fulfilmentStrategyWarehouseOrder;
571
639
  changedFields.push('fulfilmentStrategyWarehouseOrder');
572
640
  }
573
641
  // Feature 155 (FR-001, FR-003, D5) — the pieces minimum and the returnable flag.
574
- if (req.minOrderQuantity !== undefined) {
642
+ if (req.minOrderQuantity !== undefined && req.minOrderQuantity !== (product.minOrderQuantity ?? null)) {
575
643
  product.minOrderQuantity = req.minOrderQuantity;
576
644
  changedFields.push('minOrderQuantity');
577
645
  }
578
- if (req.returnable !== undefined) {
646
+ if (req.returnable !== undefined && req.returnable !== product.returnable) {
579
647
  product.returnable = req.returnable;
580
648
  changedFields.push('returnable');
581
649
  }
@@ -604,8 +672,8 @@ export class CatalogAdminService {
604
672
  }
605
673
  }
606
674
  const stateAfter = {
607
- name: { ...product.name },
608
- description: { ...product.description },
675
+ name: product.name,
676
+ description: product.description,
609
677
  stockMode: product.stockMode,
610
678
  visibility: product.visibility,
611
679
  status: product.status,
@@ -632,32 +700,14 @@ export class CatalogAdminService {
632
700
  * in the request into a constraint violation.
633
701
  */
634
702
  async #reconcileProductCategories(em, productId, categoryIds) {
635
- const conn = em.getConnection();
636
- const txCtx = em.getTransactionContext();
637
- const currentRows = (await conn.execute(`select category_id from product_categories where product_id = ?`, [productId], 'all', txCtx));
638
- const current = new Set(currentRows.map((r) => r.category_id));
639
- const target = new Set(categoryIds);
640
- const toAdd = [...target].filter((id) => !current.has(id));
641
- const toRemove = [...current].filter((id) => !target.has(id));
642
- if (toRemove.length > 0) {
643
- const placeholders = toRemove.map(() => '?').join(',');
644
- await conn.execute(`delete from product_categories where product_id = ? and category_id in (${placeholders})`, [productId, ...toRemove], 'run', txCtx);
645
- }
646
- if (toAdd.length > 0) {
647
- const placeholders = toAdd.map(() => '(?,?)').join(',');
648
- const params = [];
649
- for (const cid of toAdd) {
650
- params.push(productId, cid);
651
- }
652
- await conn.execute(`insert into product_categories (product_id, category_id) values ${placeholders}`, params, 'run', txCtx);
653
- }
654
- return toAdd.length > 0 || toRemove.length > 0;
703
+ return reconcileProductCategories(em, productId, categoryIds);
655
704
  }
656
705
  /**
657
706
  * Duplicate an existing Product: copies the core row plus bridge tables
658
707
  * (categories, sales-channel memberships, gallery items + labels,
659
- * attachments, related/up-sell/cross-sell links, grouped children,
660
- * bundle slots + options, variants).
708
+ * attachments, packaging units, related/up-sell/cross-sell links, grouped
709
+ * children, bundle slots + options, variants) and, since feature 174
710
+ * (FR-119), every scoped value at Global, Channel and Channel × language.
661
711
  *
662
712
  * The duplicated row gets a fresh UUID; the SKU is derived from the
663
713
  * source by appending `-copy`, then `-copy-2`, `-copy-3`, … until a
@@ -687,13 +737,19 @@ export class CatalogAdminService {
687
737
  }
688
738
  async duplicateProduct(id) {
689
739
  const em = this.emFactory();
740
+ if (!isUuidShape(id)) {
741
+ throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
742
+ }
690
743
  const source = await em.findOne(Product, { id });
691
744
  if (!source) {
692
745
  throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
693
746
  }
694
- // The dup product row + its audit are co-transactional; the bridge copies
695
- // run AFTER on this em (matches the pre-054 two-step) — the dup FK target
696
- // exists once committed, and a partially-copied dup is no worse than today.
747
+ // Feature 174 (FR-119, T151) — the copy is ONE Command: the product row, every catalog-owned
748
+ // bridge and every scoped value at Global, Channel and Channel × language, empty overrides and
749
+ // inherit states included, commit or roll back together with the one audit entry. What other
750
+ // modules own runs through their own audited Commands after it (the channel memberships, the
751
+ // warehouse thresholds): a Command cannot nest inside another's transaction. URL keys are never
752
+ // copied beyond the fresh Global key, and status is reset at every scope (163 Q1-d).
697
753
  const dupId = randomUUID();
698
754
  const dup = await this.#auditedWrite('product.duplicate', 'product', dupId, async (cem) => {
699
755
  // Inside the Command's transaction (Phase 16 review): the slug's URL-key lock is
@@ -707,8 +763,8 @@ export class CatalogAdminService {
707
763
  type: source.type,
708
764
  status: 'inactive',
709
765
  archivedAt: null,
710
- name: this.suffixCopyNames(source.name),
711
- description: { ...source.description },
766
+ name: this.suffixCopyName(source.name),
767
+ description: source.description,
712
768
  stockMode: source.stockMode ?? null,
713
769
  visibility: source.visibility,
714
770
  attributeValues: { ...source.attributeValues },
@@ -737,17 +793,37 @@ export class CatalogAdminService {
737
793
  ],
738
794
  }
739
795
  : {}),
796
+ // Feature 174 (FR-119) — the Global order rules and publication window.
797
+ minOrderQuantity: source.minOrderQuantity ?? null,
798
+ returnable: source.returnable,
799
+ publishFrom: source.publishFrom ?? null,
800
+ publishUntil: source.publishUntil ?? null,
740
801
  });
741
802
  await cem.flush();
803
+ const copied = await this.#copyCatalogRows(cem, source, dupId);
804
+ const seo = this.copySeoProductMeta
805
+ ? await this.copySeoProductMeta(cem, { sourceProductId: source.id, targetProductId: dupId })
806
+ : 'not-present';
807
+ // Feature 172 (FR-060, research R-16) — the product's Page Builder content
808
+ // is copied in this transaction, atomic with the row it belongs to. The
809
+ // audit row counts the attributes, never the documents.
810
+ const copiedContent = (await cem.execute(`insert into product_content_values
811
+ (id, product_id, product_attribute_id, content, summary, created_at, updated_at)
812
+ select gen_random_uuid(), ?, product_attribute_id, content, summary, now(), now()
813
+ from product_content_values where product_id = ?
814
+ returning id`, [dupId, source.id]));
742
815
  return {
743
816
  result: created,
744
817
  before: null,
745
- after: { sku: newSku, slug: newSlug, sourceProductId: id },
818
+ after: {
819
+ sku: newSku,
820
+ slug: newSlug,
821
+ sourceProductId: id,
822
+ copied: { ...copied, seoScopes: seo === 'not-present' ? null : seo.copied },
823
+ contentAttributeCount: copiedContent.length,
824
+ },
746
825
  };
747
826
  });
748
- // product_categories (bridge)
749
- await em.execute(`insert into "product_categories" ("product_id", "category_id")
750
- select ?, "category_id" from "product_categories" where "product_id" = ?`, [dup.id, source.id]);
751
827
  // The channel assortment, through the kernel's membership service (issue
752
828
  // #185). This was an `insert … select` against the bridge table, which is
753
829
  // Principle XII's accessor clause and Principle XIII in one statement: the
@@ -757,46 +833,124 @@ export class CatalogAdminService {
757
833
  if (this.salesChannelMembership) {
758
834
  await this.salesChannelMembership.copyMemberships('product', source.id, dup.id);
759
835
  }
760
- // gallery_items + gallery_item_labels — we need a fresh UUID per item
761
- // and to rewrite the bridge rows to the new ids.
762
- const galleryRows = (await em.execute(`select "id", "asset_id", "position" from "gallery_items"
763
- where "product_id" = ? order by "position" asc`, [source.id]));
764
- if (galleryRows.length > 0) {
765
- const idMap = new Map();
766
- for (const row of galleryRows) {
767
- const newId = randomUUID();
768
- idMap.set(row.id, newId);
769
- await em.execute(`insert into "gallery_items"
770
- ("id", "product_id", "asset_id", "position", "created_at", "updated_at")
771
- values (?, ?, ?, ?, now(), now())`, [newId, dup.id, row.asset_id, row.position]);
772
- }
773
- const labelRows = (await em.execute(`select "gallery_item_id", "label" from "gallery_item_labels"
774
- where "product_id" = ?`, [source.id]));
775
- for (const lbl of labelRows) {
776
- const mapped = idMap.get(lbl.gallery_item_id);
777
- if (!mapped)
778
- continue;
779
- await em.execute(`insert into "gallery_item_labels"
780
- ("gallery_item_id", "product_id", "label") values (?, ?, ?)`, [mapped, dup.id, lbl.label]);
781
- }
836
+ // Per-(product, warehouse) low-stock thresholds, so the duplicate inherits
837
+ // the source's alerting profile. `inventory`'s rows and `inventory`'s
838
+ // Command since issue #185 — this used to be an `insert … select` into that
839
+ // module's table from here, which kept writing while an operator had the
840
+ // module switched off. No `catch` around it: the wiring decides presence in
841
+ // front of the gate and the degrade arrives as `'not-present'`.
842
+ if (this.copyWarehouseThresholds) {
843
+ await this.copyWarehouseThresholds({
844
+ sourceProductId: source.id,
845
+ targetProductId: dup.id,
846
+ });
782
847
  }
783
- // product_attachments
784
- await em.execute(`insert into "product_attachments"
785
- ("id", "product_id", "asset_id", "attachment_type_id", "name", "description", "position", "created_at", "updated_at")
786
- select gen_random_uuid(), ?, "asset_id", "attachment_type_id", "name", "description", "position", now(), now()
787
- from "product_attachments" where "product_id" = ?`, [dup.id, source.id]);
848
+ this.events.emit('product.created.v1', {
849
+ eventId: randomUUID(),
850
+ occurredAt: new Date().toISOString(),
851
+ productId: dup.id,
852
+ sku: dup.sku,
853
+ });
854
+ return dup;
855
+ }
856
+ /**
857
+ * Feature 174 (FR-119, T151) — every catalog-owned row of `source` copied onto `targetId`, on the
858
+ * Command's em: the bridges (categories, gallery with its Global roles, attachments, packaging
859
+ * units, links, grouped children, bundle slots, variants) and every scoped value at Channel and
860
+ * Channel × language — value overrides (texts and attributes), channel scope rows, gallery item,
861
+ * gallery role, attachment and packaging-unit overrides — verbatim, so a deliberately empty
862
+ * override stays empty and a scope holding nothing still inherits. Child-row overrides are
863
+ * re-pointed through an old → new id map passed as one JSON parameter.
864
+ *
865
+ * Not copied: URL keys and redirects (unique per channel; the copy has its fresh Global key),
866
+ * status at Channel and Channel × language (the copy starts `inactive` everywhere, 163 Q1-d).
867
+ * Orphaned rows (a scope the source no longer sells on) are copied like the rest: they keep
868
+ * what the source keeps, and come back to life in the same way when the scope does.
869
+ */
870
+ async #copyCatalogRows(em, source, targetId) {
871
+ const count = async (sql, params) => (await em.execute(sql, params)).length;
872
+ const idMap = async (table) => {
873
+ const rows = (await em.execute(`select "id" from "${table}" where "product_id" = ?`, [source.id]));
874
+ return Object.fromEntries(rows.map((row) => [row.id, randomUUID()]));
875
+ };
876
+ const remap = (column) => `(?::jsonb ->> o."${column}"::text)::uuid`;
877
+ // product_categories (bridge)
878
+ await em.execute(`insert into "product_categories" ("product_id", "category_id")
879
+ select ?, "category_id" from "product_categories" where "product_id" = ?`, [targetId, source.id]);
880
+ // Texts and attributes at C and C×L.
881
+ const valueOverrides = await count(`insert into "product_value_overrides"
882
+ ("id", "product_id", "attribute_key", "channel_id", "language_code", "value", "created_at", "updated_at")
883
+ select gen_random_uuid(), ?, o."attribute_key", o."channel_id", o."language_code", o."value", now(), now()
884
+ from "product_value_overrides" o where o."product_id" = ?
885
+ returning "id"`, [targetId, source.id]);
886
+ // Window, audience, MOQ and returnable at C; status inherits (the copy is reviewed first).
887
+ const channelScopes = await count(`insert into "product_channel_scopes"
888
+ ("product_id", "sales_channel_id", "status", "window_overridden", "publish_from", "publish_until",
889
+ "visibility", "allowed_organization_ids", "min_order_quantity_overridden", "min_order_quantity",
890
+ "returnable", "created_at", "updated_at")
891
+ select ?, o."sales_channel_id", null, o."window_overridden", o."publish_from", o."publish_until",
892
+ o."visibility", o."allowed_organization_ids", o."min_order_quantity_overridden",
893
+ o."min_order_quantity", o."returnable", now(), now()
894
+ from "product_channel_scopes" o where o."product_id" = ?
895
+ returning "product_id"`, [targetId, source.id]);
896
+ // Gallery: the items with their Global alt text and hidden flag, the Global roles, the overrides.
897
+ const items = await idMap('gallery_items');
898
+ const itemsJson = JSON.stringify(items);
899
+ const galleryItems = await count(`insert into "gallery_items" ("id", "product_id", "asset_id", "position", "alt_text", "hidden", "created_at", "updated_at")
900
+ select ${remap('id')}, ?, o."asset_id", o."position", o."alt_text", o."hidden", now(), now()
901
+ from "gallery_items" o where o."product_id" = ?
902
+ returning "id"`, [itemsJson, targetId, source.id]);
903
+ const galleryRoles = await count(`insert into "gallery_item_labels" ("gallery_item_id", "product_id", "label")
904
+ select ${remap('gallery_item_id')}, ?, o."label"
905
+ from "gallery_item_labels" o where o."product_id" = ?
906
+ returning "label"`, [itemsJson, targetId, source.id]);
907
+ const galleryItemOverrides = await count(`insert into "gallery_item_scope_overrides"
908
+ ("id", "gallery_item_id", "product_id", "sales_channel_id", "language_code", "field", "value", "created_at", "updated_at")
909
+ select gen_random_uuid(), ${remap('gallery_item_id')}, ?, o."sales_channel_id", o."language_code", o."field", o."value", now(), now()
910
+ from "gallery_item_scope_overrides" o where o."product_id" = ?
911
+ returning "id"`, [itemsJson, targetId, source.id]);
912
+ // An empty role (no holder) keeps its `null`: `->>` of a null key is null.
913
+ const galleryRoleOverrides = await count(`insert into "gallery_role_scope_overrides"
914
+ ("id", "product_id", "sales_channel_id", "language_code", "label", "gallery_item_id", "created_at", "updated_at")
915
+ select gen_random_uuid(), ?, o."sales_channel_id", o."language_code", o."label", ${remap('gallery_item_id')}, now(), now()
916
+ from "gallery_role_scope_overrides" o where o."product_id" = ?
917
+ returning "id"`, [targetId, itemsJson, source.id]);
918
+ // Attachments with their Global hidden flag, then their overrides.
919
+ const attachmentIds = JSON.stringify(await idMap('product_attachments'));
920
+ const attachments = await count(`insert into "product_attachments"
921
+ ("id", "product_id", "asset_id", "attachment_type_id", "name", "description", "position", "hidden", "created_at", "updated_at")
922
+ select ${remap('id')}, ?, o."asset_id", o."attachment_type_id", o."name", o."description", o."position", o."hidden", now(), now()
923
+ from "product_attachments" o where o."product_id" = ?
924
+ returning "id"`, [attachmentIds, targetId, source.id]);
925
+ const attachmentOverrides = await count(`insert into "product_attachment_scope_overrides"
926
+ ("id", "attachment_id", "product_id", "sales_channel_id", "language_code", "field", "value", "created_at", "updated_at")
927
+ select gen_random_uuid(), ${remap('attachment_id')}, ?, o."sales_channel_id", o."language_code", o."field", o."value", now(), now()
928
+ from "product_attachment_scope_overrides" o where o."product_id" = ?
929
+ returning "id"`, [attachmentIds, targetId, source.id]);
930
+ // Packaging units, then their name overrides.
931
+ const unitIds = JSON.stringify(await idMap('product_packaging_units'));
932
+ const packagingUnits = await count(`insert into "product_packaging_units"
933
+ ("id", "product_id", "name", "base_quantity", "position", "is_default", "min_order_units", "created_at", "updated_at")
934
+ select ${remap('id')}, ?, o."name", o."base_quantity", o."position", o."is_default", o."min_order_units", now(), now()
935
+ from "product_packaging_units" o where o."product_id" = ?
936
+ returning "id"`, [unitIds, targetId, source.id]);
937
+ const packagingUnitOverrides = await count(`insert into "product_packaging_unit_scope_overrides"
938
+ ("id", "packaging_unit_id", "product_id", "sales_channel_id", "language_code", "field", "value", "created_at", "updated_at")
939
+ select gen_random_uuid(), ${remap('packaging_unit_id')}, ?, o."sales_channel_id", o."language_code", o."field", o."value", now(), now()
940
+ from "product_packaging_unit_scope_overrides" o where o."product_id" = ?
941
+ returning "id"`, [unitIds, targetId, source.id]);
788
942
  // product_links (only outgoing links are copied — incoming links from
789
943
  // other products toward the source product stay attached to the source)
790
944
  await em.execute(`insert into "product_links"
791
945
  ("id", "source_product_id", "target_product_id", "kind", "position", "created_at", "updated_at")
792
946
  select gen_random_uuid(), ?, "target_product_id", "kind", "position", now(), now()
793
- from "product_links" where "source_product_id" = ?`, [dup.id, source.id]);
947
+ from "product_links" where "source_product_id" = ?`, [targetId, source.id]);
794
948
  // grouped_items (children of a grouped product)
795
949
  if (source.type === 'grouped') {
796
950
  await em.execute(`insert into "grouped_items"
797
951
  ("id", "parent_product_id", "child_product_id", "quantity", "position", "created_at", "updated_at")
798
952
  select gen_random_uuid(), ?, "child_product_id", "quantity", "position", now(), now()
799
- from "grouped_items" where "parent_product_id" = ?`, [dup.id, source.id]);
953
+ from "grouped_items" where "parent_product_id" = ?`, [targetId, source.id]);
800
954
  }
801
955
  // bundle_slots + bundle_slot_options
802
956
  if (source.type === 'bundle') {
@@ -808,7 +962,7 @@ export class CatalogAdminService {
808
962
  ("id", "parent_product_id", "name", "min_quantity", "max_quantity", "position", "created_at", "updated_at")
809
963
  values (?, ?, ?::jsonb, ?, ?, ?, now(), now())`, [
810
964
  newSlotId,
811
- dup.id,
965
+ targetId,
812
966
  JSON.stringify(slot.name),
813
967
  slot.min_quantity,
814
968
  slot.max_quantity,
@@ -820,18 +974,6 @@ export class CatalogAdminService {
820
974
  from "bundle_slot_options" where "slot_id" = ?`, [newSlotId, slot.id]);
821
975
  }
822
976
  }
823
- // Per-(product, warehouse) low-stock thresholds, so the duplicate inherits
824
- // the source's alerting profile. `inventory`'s rows and `inventory`'s
825
- // Command since issue #185 — this used to be an `insert … select` into that
826
- // module's table from here, which kept writing while an operator had the
827
- // module switched off. No `catch` around it: the wiring decides presence in
828
- // front of the gate and the degrade arrives as `'not-present'`.
829
- if (this.copyWarehouseThresholds) {
830
- await this.copyWarehouseThresholds({
831
- sourceProductId: source.id,
832
- targetProductId: dup.id,
833
- });
834
- }
835
977
  // product_variants (configurable products) — each variant has its own
836
978
  // unique SKU; we allocate copies the same way as the parent SKU.
837
979
  if (source.type === 'configurable') {
@@ -839,7 +981,7 @@ export class CatalogAdminService {
839
981
  for (const v of variants) {
840
982
  const variantSku = await this.allocateCopySku(em, v.sku);
841
983
  const newVariant = em.create(ProductVariant, {
842
- parentProductId: dup.id,
984
+ parentProductId: targetId,
843
985
  sku: variantSku,
844
986
  variantAttributeValues: { ...v.variantAttributeValues },
845
987
  ...(v.stockLevel != null ? { stockLevel: v.stockLevel } : {}),
@@ -848,13 +990,18 @@ export class CatalogAdminService {
848
990
  }
849
991
  await em.flush();
850
992
  }
851
- this.events.emit('product.created.v1', {
852
- eventId: randomUUID(),
853
- occurredAt: new Date().toISOString(),
854
- productId: dup.id,
855
- sku: dup.sku,
856
- });
857
- return dup;
993
+ return {
994
+ valueOverrides,
995
+ channelScopes,
996
+ galleryItems,
997
+ galleryItemOverrides,
998
+ galleryRoles,
999
+ galleryRoleOverrides,
1000
+ attachments,
1001
+ attachmentOverrides,
1002
+ packagingUnits,
1003
+ packagingUnitOverrides,
1004
+ };
858
1005
  }
859
1006
  /**
860
1007
  * Find a free SKU derived from `baseSku` by appending `-copy`,
@@ -872,10 +1019,11 @@ export class CatalogAdminService {
872
1019
  const suffix = i === 0 ? '-copy' : `-copy-${i + 1}`;
873
1020
  const base = baseSku.slice(0, SKU_MAX_LENGTH - suffix.length);
874
1021
  const candidate = `${base}${suffix}`;
875
- const productHit = await em.findOne(Product, { sku: candidate });
1022
+ // Issue #693 — a deleted product or variant does not hold its SKU.
1023
+ const productHit = await em.findOne(Product, { sku: candidate, deletedAt: null });
876
1024
  if (productHit)
877
1025
  continue;
878
- const variantHit = await em.findOne(ProductVariant, { sku: candidate });
1026
+ const variantHit = await em.findOne(ProductVariant, { sku: candidate, deletedAt: null });
879
1027
  if (variantHit)
880
1028
  continue;
881
1029
  return candidate;
@@ -910,37 +1058,19 @@ export class CatalogAdminService {
910
1058
  */
911
1059
  async allocateUniqueSlug(em, source) {
912
1060
  const root = this.slugify(source);
913
- const probes = [];
914
- for (let i = 0; i < 1000 && probes.length < SLUG_CANDIDATE_LOCKS; i += 1) {
915
- const candidate = i === 0 ? root : this.slugify(`${root}-${i + 1}`);
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
- }
925
- }
1061
+ const candidates = Array.from({ length: 1000 }, (_, i) => (i === 0 ? root : this.slugify(`${root}-${i + 1}`)));
1062
+ // Feature 174 (T039) — the URL-key service's allocation: probe, lock in sorted order, re-check.
1063
+ const slug = await allocateFreeSlug(em, candidates, SLUG_CANDIDATE_LOCKS);
1064
+ if (slug !== null)
1065
+ return slug;
926
1066
  throw new HttpError(409, ERROR_CODES.VALIDATION_FAILED, `Could not allocate a unique slug derived from "${source}".`);
927
1067
  }
928
1068
  /**
929
- * Multilingual `name`: tag every locale with a "(copy)" suffix so the
930
- * duplicated product is obviously a clone in lists. Empty locales are
931
- * left untouched.
1069
+ * Feature 174 — the copy's Global name with a "(copy)" suffix, so the duplicate is obviously a
1070
+ * clone in lists. Its Channel and Channel × language names are copied verbatim (FR-119).
932
1071
  */
933
- suffixCopyNames(name) {
934
- const out = {};
935
- for (const [locale, value] of Object.entries(name)) {
936
- if (!value || value.trim() === '') {
937
- out[locale] = value;
938
- }
939
- else {
940
- out[locale] = `${value} (copy)`.slice(0, 255);
941
- }
942
- }
943
- return out;
1072
+ suffixCopyName(name) {
1073
+ return name.trim() === '' ? name : `${name} (copy)`.slice(0, 255);
944
1074
  }
945
1075
  /**
946
1076
  * Feature 163 (FR-019, research R30.3) — Archive one product: the `product.archive`
@@ -990,6 +1120,9 @@ export class CatalogAdminService {
990
1120
  // Checkpoint C code review (C-W1) — the row lock serialises a single and a bulk
991
1121
  // Archive of one product: the second reads the first's `archivedAt` and is the
992
1122
  // no-op, so the transition is audited and announced once.
1123
+ if (!isUuidShape(id)) {
1124
+ throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
1125
+ }
993
1126
  const product = await em.findOne(Product, { id, deletedAt: null }, { lockMode: LockMode.PESSIMISTIC_WRITE });
994
1127
  if (!product) {
995
1128
  throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
@@ -1052,6 +1185,9 @@ export class CatalogAdminService {
1052
1185
  objectType: 'product',
1053
1186
  objectId: id,
1054
1187
  run: async ({ em }) => {
1188
+ if (!isUuidShape(id)) {
1189
+ throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
1190
+ }
1055
1191
  const product = await em.findOne(Product, { id, deletedAt: null });
1056
1192
  if (!product) {
1057
1193
  throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
@@ -1060,7 +1196,7 @@ export class CatalogAdminService {
1060
1196
  const stateBefore = {
1061
1197
  status: product.status,
1062
1198
  sku: product.sku,
1063
- name: { ...product.name },
1199
+ name: product.name,
1064
1200
  deletedAt: product.deletedAt ?? null,
1065
1201
  };
1066
1202
  // Feature 163 (FR-072) — a deleted product's old URL keys stop redirecting.
@@ -1072,6 +1208,9 @@ export class CatalogAdminService {
1072
1208
  if (urlRedirects.length > 0)
1073
1209
  await em.nativeDelete(ProductUrlRedirect, { productId: id });
1074
1210
  product.deletedAt = new Date();
1211
+ // Issue #693 — the variants are deleted with their product, at the same instant, so
1212
+ // their SKUs are freed with the product's: uniqueness holds among live rows only.
1213
+ await em.nativeUpdate(ProductVariant, { parentProductId: id, deletedAt: null }, { deletedAt: product.deletedAt });
1075
1214
  await em.flush();
1076
1215
  return {
1077
1216
  result: { id: product.id, formerUrlKeys: urlRedirects.map((row) => row.key) },
@@ -1320,6 +1459,9 @@ export class CatalogAdminService {
1320
1459
  }
1321
1460
  async getProductById(id) {
1322
1461
  const em = this.emFactory();
1462
+ if (!isUuidShape(id)) {
1463
+ throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
1464
+ }
1323
1465
  const product = await em.findOne(Product, { id, deletedAt: null });
1324
1466
  if (!product) {
1325
1467
  throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
@@ -1496,6 +1638,19 @@ export class CatalogAdminService {
1496
1638
  }
1497
1639
  return view;
1498
1640
  }
1641
+ /**
1642
+ * Feature 172 (FR-007 – FR-009, research R-21) — what deleting the attribute
1643
+ * would meet, for the attributes screen's confirmation dialog. The same query
1644
+ * the delete Command's guard runs, so the dialog and the refusal agree.
1645
+ */
1646
+ async getAttributeUsage(idOrKey) {
1647
+ const attr = await this.getAttributeByIdOrKey(idOrKey);
1648
+ return readAttributeUsage(this.emFactory(), {
1649
+ definitionId: attr.customFieldDefinitionId,
1650
+ extensionId: attr.id,
1651
+ key: attr.key,
1652
+ });
1653
+ }
1499
1654
  /**
1500
1655
  * Feature 012 — delete an attribute. Refused while any Attribute Set or
1501
1656
  * product still references it (FR-006). The structured error names the
@@ -1527,15 +1682,22 @@ export class CatalogAdminService {
1527
1682
  }
1528
1683
  async createVariant(parentProductId, req) {
1529
1684
  const em = this.emFactory();
1530
- const parent = await em.findOne(Product, { id: parentProductId });
1685
+ if (!isUuidShape(parentProductId)) {
1686
+ throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, `Product ${parentProductId} not found.`);
1687
+ }
1688
+ // A deleted parent answers as an unknown one (#869).
1689
+ const parent = await em.findOne(Product, { id: parentProductId, deletedAt: null });
1531
1690
  if (!parent) {
1532
1691
  throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, `Product ${parentProductId} not found.`);
1533
1692
  }
1534
1693
  if (parent.type !== 'configurable') {
1535
- throw new HttpError(400, ERROR_CODES.VALIDATION_FAILED, `Variants can only be added to configurable Products; this Product is ${parent.type}.`);
1694
+ // Issue #624 (#86) — the stored product type refuses it: the module's
1695
+ // type-mismatch code, the token naming the rule.
1696
+ throw new HttpError(400, ERROR_CODES.PRODUCT_TYPE_MISMATCH, `Variants can only be added to configurable Products; this Product is ${parent.type}.`, { code: 'variants_need_configurable', productId: parentProductId, productType: parent.type });
1536
1697
  }
1537
- // SKU uniqueness MUST hold across both products and variants.
1538
- const existingProduct = await em.findOne(Product, { sku: req.sku });
1698
+ // SKU uniqueness MUST hold across both products and variants — among live
1699
+ // rows: a deleted product does not hold its SKU (issue #693).
1700
+ const existingProduct = await em.findOne(Product, { sku: req.sku, deletedAt: null });
1539
1701
  if (existingProduct) {
1540
1702
  throw new HttpError(409, ERROR_CODES.SKU_ALREADY_EXISTS, `SKU "${req.sku}" already taken by an existing Product.`);
1541
1703
  }
@@ -1569,6 +1731,9 @@ export class CatalogAdminService {
1569
1731
  }
1570
1732
  async updateVariant(parentProductId, variantId, req) {
1571
1733
  const variant = await this.#auditedWrite('product_variant.update', 'product_variant', variantId, async (em) => {
1734
+ if (!isUuidShape(variantId) || !isUuidShape(parentProductId)) {
1735
+ throw new HttpError(404, ERROR_CODES.NOT_FOUND, `Variant ${variantId} not found under Product ${parentProductId}.`);
1736
+ }
1572
1737
  const v = await em.findOne(ProductVariant, { id: variantId, parentProductId });
1573
1738
  if (!v) {
1574
1739
  throw new HttpError(404, ERROR_CODES.NOT_FOUND, `Variant ${variantId} not found under Product ${parentProductId}.`);
@@ -1600,6 +1765,9 @@ export class CatalogAdminService {
1600
1765
  }
1601
1766
  async deleteVariant(parentProductId, variantId) {
1602
1767
  await this.#auditedWrite('product_variant.delete', 'product_variant', variantId, async (em) => {
1768
+ if (!isUuidShape(variantId) || !isUuidShape(parentProductId)) {
1769
+ throw new HttpError(404, ERROR_CODES.NOT_FOUND, `Variant ${variantId} not found under Product ${parentProductId}.`);
1770
+ }
1603
1771
  const variant = await em.findOne(ProductVariant, { id: variantId, parentProductId });
1604
1772
  if (!variant) {
1605
1773
  // DELETE is idempotent — but we still 404 here so admins notice
@@ -1638,6 +1806,13 @@ export class CatalogAdminService {
1638
1806
  const keys = Object.keys(attributeValues);
1639
1807
  if (keys.length === 0)
1640
1808
  return;
1809
+ const views = await this.#requireAttributeRead().listAll();
1810
+ // Feature 172 (FR-014, research R-7) — a Page Builder content attribute's
1811
+ // key is refused **before** the `existingKeys` exemption below: whether it
1812
+ // is new to this save or resent as "already stored", its value is a
1813
+ // document authored on the product content screen, never an attribute
1814
+ // value. This is the one guard every product write crosses.
1815
+ assertNoContentAttributeValues(attributeValues, views);
1641
1816
  // Feature 061 — set membership is keyed by definition id; the key lives on
1642
1817
  // the definition, resolved through the composed view (Principle I).
1643
1818
  //
@@ -1648,7 +1823,6 @@ export class CatalogAdminService {
1648
1823
  const rows = (await em.execute(`select custom_field_definition_id
1649
1824
  from attribute_set_attributes
1650
1825
  where attribute_set_id = ?`, [attributeSetId]));
1651
- const views = await this.#requireAttributeRead().listAll();
1652
1826
  const keyByDefinitionId = new Map(views.map((v) => [v.customFieldDefinitionId, v.key]));
1653
1827
  const allowed = new Set(rows
1654
1828
  .map((r) => keyByDefinitionId.get(r.custom_field_definition_id))
@@ -1676,16 +1850,14 @@ export class CatalogAdminService {
1676
1850
  where attribute_set_id = ?`, [attributeSetId]));
1677
1851
  const views = await this.#requireAttributeRead().listAll();
1678
1852
  const viewByDefinitionId = new Map(views.map((v) => [v.customFieldDefinitionId, v]));
1679
- const missing = rows
1853
+ const missing = missingRequiredAttributeKeys(rows
1680
1854
  .map((r) => viewByDefinitionId.get(r.custom_field_definition_id))
1681
- .filter((v) => v !== undefined && v.isRequired)
1682
- .map((v) => v.key)
1683
- .filter((k) => {
1684
- const v = mergedAttributeValues[k];
1685
- return v === undefined || v === null || v === '';
1686
- });
1855
+ .filter((v) => v !== undefined), mergedAttributeValues);
1687
1856
  if (missing.length > 0) {
1688
- throw new HttpError(400, ERROR_CODES.VALIDATION_FAILED, `missing_required_attribute_values: ${missing.join(', ')}`);
1857
+ // Issue #624 (#86) — "required" is the attribute's configuration, and the
1858
+ // values are the stored ones merged with the patch: a refusal of its own.
1859
+ // The keys travel joined, because only a scalar fills a placeholder.
1860
+ throw new HttpError(400, ERROR_CODES.ATTRIBUTE_VALUES_REQUIRED, `Required attributes have no value: ${missing.join(', ')}.`, { attributeKeys: missing.join(', ') });
1689
1861
  }
1690
1862
  }
1691
1863
  /**
@@ -1696,6 +1868,9 @@ export class CatalogAdminService {
1696
1868
  */
1697
1869
  async previewAttributeSetSwap(productId, targetSetId) {
1698
1870
  const em = this.emFactory();
1871
+ if (!isUuidShape(productId)) {
1872
+ throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
1873
+ }
1699
1874
  const product = await em.findOne(Product, { id: productId });
1700
1875
  if (!product) {
1701
1876
  throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
@@ -1777,17 +1952,15 @@ export class CatalogAdminService {
1777
1952
  slugify(value) {
1778
1953
  return slugifyText(value, { maxLength: 160 });
1779
1954
  }
1780
- anyValue(blob) {
1781
- const key = Object.keys(blob)[0];
1782
- return key ? (blob[key] ?? '') : '';
1783
- }
1784
1955
  }
1785
1956
  /**
1786
1957
  * Feature 155 (FR-001, threat F5, D5) — a pieces minimum is an integer in
1787
1958
  * 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.
1959
+ * `null` (clear) and an absent key are always allowed. Refused with
1960
+ * `details.field`, the answer an in-process caller gets where no route schema
1961
+ * stood in front of it: a value out of range is `422 VALIDATION_FAILED`, a type
1962
+ * that takes no minimum `422 MIN_ORDER_QUANTITY_NOT_SUPPORTED_FOR_TYPE` (issue
1963
+ * #624, #86 — the product's type refuses it, not the value).
1791
1964
  */
1792
1965
  function assertOrderMinimumAllowed(type, value) {
1793
1966
  if (value === undefined || value === null)
@@ -1796,7 +1969,7 @@ function assertOrderMinimumAllowed(type, value) {
1796
1969
  throw new HttpError(422, ERROR_CODES.VALIDATION_FAILED, 'The minimum order quantity must be a whole number from 1 to 1000000.', { field: 'minOrderQuantity' });
1797
1970
  }
1798
1971
  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' });
1972
+ throw new HttpError(422, ERROR_CODES.MIN_ORDER_QUANTITY_NOT_SUPPORTED_FOR_TYPE, `A minimum order quantity applies to simple or configurable products only; got "${type}".`, { field: 'minOrderQuantity', productType: type });
1800
1973
  }
1801
1974
  }
1802
1975
  //# sourceMappingURL=catalog-admin.service.js.map