@open-mercato/core 0.9.1-develop.7474.1.51db10479d → 0.9.1-develop.7475.1.28ca93ed97

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 (597) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/dist/generated/entities/catalog_price_history_entry/index.js +53 -0
  3. package/dist/generated/entities/catalog_price_history_entry/index.js.map +7 -0
  4. package/dist/generated/entities/customer_group_terms/index.js +2 -0
  5. package/dist/generated/entities/customer_group_terms/index.js.map +2 -2
  6. package/dist/generated/entities/ecommerce_store/index.js +33 -0
  7. package/dist/generated/entities/ecommerce_store/index.js.map +7 -0
  8. package/dist/generated/entities/ecommerce_store_channel_binding/index.js +29 -0
  9. package/dist/generated/entities/ecommerce_store_channel_binding/index.js.map +7 -0
  10. package/dist/generated/entities/ecommerce_store_domain_binding/index.js +23 -0
  11. package/dist/generated/entities/ecommerce_store_domain_binding/index.js.map +7 -0
  12. package/dist/generated/entities.ids.generated.js +8 -1
  13. package/dist/generated/entities.ids.generated.js.map +2 -2
  14. package/dist/generated/entity-fields-registry.js +72 -0
  15. package/dist/generated/entity-fields-registry.js.map +2 -2
  16. package/dist/helpers/integration/customerGroupsFixtures.js.map +2 -2
  17. package/dist/modules/catalog/acl.js +8 -1
  18. package/dist/modules/catalog/acl.js.map +2 -2
  19. package/dist/modules/catalog/api/config/omnibus/route.js +184 -0
  20. package/dist/modules/catalog/api/config/omnibus/route.js.map +7 -0
  21. package/dist/modules/catalog/api/prices/history/route.js +131 -0
  22. package/dist/modules/catalog/api/prices/history/route.js.map +7 -0
  23. package/dist/modules/catalog/api/prices/omnibus-preview/route.js +184 -0
  24. package/dist/modules/catalog/api/prices/omnibus-preview/route.js.map +7 -0
  25. package/dist/modules/catalog/api/products/route.js +54 -245
  26. package/dist/modules/catalog/api/products/route.js.map +3 -3
  27. package/dist/modules/catalog/api/tags/route.js +6 -0
  28. package/dist/modules/catalog/api/tags/route.js.map +2 -2
  29. package/dist/modules/catalog/backend/config/catalog/page.js +3 -1
  30. package/dist/modules/catalog/backend/config/catalog/page.js.map +2 -2
  31. package/dist/modules/catalog/cli.js +80 -2
  32. package/dist/modules/catalog/cli.js.map +2 -2
  33. package/dist/modules/catalog/commands/categories.js +51 -2
  34. package/dist/modules/catalog/commands/categories.js.map +2 -2
  35. package/dist/modules/catalog/commands/prices.js +43 -1
  36. package/dist/modules/catalog/commands/prices.js.map +2 -2
  37. package/dist/modules/catalog/commands/products.js +71 -0
  38. package/dist/modules/catalog/commands/products.js.map +2 -2
  39. package/dist/modules/catalog/commands/variants.js +7 -0
  40. package/dist/modules/catalog/commands/variants.js.map +2 -2
  41. package/dist/modules/catalog/components/OmnibusSettings.js +703 -0
  42. package/dist/modules/catalog/components/OmnibusSettings.js.map +7 -0
  43. package/dist/modules/catalog/components/PriceEditorOmnibusRow.js +152 -0
  44. package/dist/modules/catalog/components/PriceEditorOmnibusRow.js.map +7 -0
  45. package/dist/modules/catalog/components/lookupSources.js +31 -0
  46. package/dist/modules/catalog/components/lookupSources.js.map +7 -0
  47. package/dist/modules/catalog/components/prices/PriceScopeSelectors.js +8 -2
  48. package/dist/modules/catalog/components/prices/PriceScopeSelectors.js.map +2 -2
  49. package/dist/modules/catalog/components/products/VariantBuilder.js +11 -1
  50. package/dist/modules/catalog/components/products/VariantBuilder.js.map +2 -2
  51. package/dist/modules/catalog/data/entities.js +122 -1
  52. package/dist/modules/catalog/data/entities.js.map +2 -2
  53. package/dist/modules/catalog/data/validators.js +78 -0
  54. package/dist/modules/catalog/data/validators.js.map +2 -2
  55. package/dist/modules/catalog/di.js +18 -0
  56. package/dist/modules/catalog/di.js.map +2 -2
  57. package/dist/modules/catalog/lib/omnibus.js +285 -0
  58. package/dist/modules/catalog/lib/omnibus.js.map +7 -0
  59. package/dist/modules/catalog/lib/omnibusBackfill.js +146 -0
  60. package/dist/modules/catalog/lib/omnibusBackfill.js.map +7 -0
  61. package/dist/modules/catalog/lib/omnibusCache.js +89 -0
  62. package/dist/modules/catalog/lib/omnibusCache.js.map +7 -0
  63. package/dist/modules/catalog/lib/omnibusConfig.js +64 -0
  64. package/dist/modules/catalog/lib/omnibusConfig.js.map +7 -0
  65. package/dist/modules/catalog/lib/omnibusHistoryQueries.js +191 -0
  66. package/dist/modules/catalog/lib/omnibusHistoryQueries.js.map +7 -0
  67. package/dist/modules/catalog/lib/omnibusPresentedEntry.js +73 -0
  68. package/dist/modules/catalog/lib/omnibusPresentedEntry.js.map +7 -0
  69. package/dist/modules/catalog/lib/omnibusProductListEnrichment.js +94 -0
  70. package/dist/modules/catalog/lib/omnibusProductListEnrichment.js.map +7 -0
  71. package/dist/modules/catalog/lib/omnibusTypes.js +115 -0
  72. package/dist/modules/catalog/lib/omnibusTypes.js.map +7 -0
  73. package/dist/modules/catalog/lib/optionSchemaTranslations.js +55 -0
  74. package/dist/modules/catalog/lib/optionSchemaTranslations.js.map +7 -0
  75. package/dist/modules/catalog/lib/priceHistoryQuery.js +103 -0
  76. package/dist/modules/catalog/lib/priceHistoryQuery.js.map +7 -0
  77. package/dist/modules/catalog/lib/pricing.js +26 -2
  78. package/dist/modules/catalog/lib/pricing.js.map +2 -2
  79. package/dist/modules/catalog/lib/productFilters.js +273 -0
  80. package/dist/modules/catalog/lib/productFilters.js.map +7 -0
  81. package/dist/modules/catalog/lib/productScopeKeys.js +105 -0
  82. package/dist/modules/catalog/lib/productScopeKeys.js.map +7 -0
  83. package/dist/modules/catalog/lib/productScopeReindex.js +73 -0
  84. package/dist/modules/catalog/lib/productScopeReindex.js.map +7 -0
  85. package/dist/modules/catalog/migrations/Migration20261005105352_catalog.js +39 -0
  86. package/dist/modules/catalog/migrations/Migration20261005105352_catalog.js.map +7 -0
  87. package/dist/modules/catalog/migrations/Migration20261005150824_catalog.js +39 -0
  88. package/dist/modules/catalog/migrations/Migration20261005150824_catalog.js.map +7 -0
  89. package/dist/modules/catalog/services/catalogOmnibusService.js +480 -0
  90. package/dist/modules/catalog/services/catalogOmnibusService.js.map +7 -0
  91. package/dist/modules/catalog/setup.js +3 -1
  92. package/dist/modules/catalog/setup.js.map +2 -2
  93. package/dist/modules/catalog/subscribers/product-scope-keys-category-deleted.js +16 -0
  94. package/dist/modules/catalog/subscribers/product-scope-keys-category-deleted.js.map +7 -0
  95. package/dist/modules/catalog/subscribers/product-scope-keys-category-updated.js +17 -0
  96. package/dist/modules/catalog/subscribers/product-scope-keys-category-updated.js.map +7 -0
  97. package/dist/modules/catalog/translations.js +10 -0
  98. package/dist/modules/catalog/translations.js.map +2 -2
  99. package/dist/modules/configs/lib/upgrade-actions.js +28 -0
  100. package/dist/modules/configs/lib/upgrade-actions.js.map +2 -2
  101. package/dist/modules/customer_groups/api/customer-groups/[id]/terms/route.js +5 -0
  102. package/dist/modules/customer_groups/api/customer-groups/[id]/terms/route.js.map +2 -2
  103. package/dist/modules/customer_groups/components/CustomerGroupTermsSection.js +111 -3
  104. package/dist/modules/customer_groups/components/CustomerGroupTermsSection.js.map +2 -2
  105. package/dist/modules/customer_groups/components/customerGroupAssortmentScope.js +43 -0
  106. package/dist/modules/customer_groups/components/customerGroupAssortmentScope.js.map +7 -0
  107. package/dist/modules/customer_groups/data/entities.js +3 -0
  108. package/dist/modules/customer_groups/data/entities.js.map +2 -2
  109. package/dist/modules/customer_groups/data/validators.js +9 -0
  110. package/dist/modules/customer_groups/data/validators.js.map +2 -2
  111. package/dist/modules/customer_groups/migrations/Migration20261005110250_customer_groups.js +17 -0
  112. package/dist/modules/customer_groups/migrations/Migration20261005110250_customer_groups.js.map +7 -0
  113. package/dist/modules/customer_groups/services/customerGroupsService.js +62 -15
  114. package/dist/modules/customer_groups/services/customerGroupsService.js.map +2 -2
  115. package/dist/modules/ecommerce/acl.js +13 -0
  116. package/dist/modules/ecommerce/acl.js.map +7 -0
  117. package/dist/modules/ecommerce/api/domain-mappings/route.js +72 -0
  118. package/dist/modules/ecommerce/api/domain-mappings/route.js.map +7 -0
  119. package/dist/modules/ecommerce/api/openapi.js +27 -0
  120. package/dist/modules/ecommerce/api/openapi.js.map +7 -0
  121. package/dist/modules/ecommerce/api/store-channel-bindings/[id]/assortment-count/route.js +109 -0
  122. package/dist/modules/ecommerce/api/store-channel-bindings/[id]/assortment-count/route.js.map +7 -0
  123. package/dist/modules/ecommerce/api/store-channel-bindings/crud.js +265 -0
  124. package/dist/modules/ecommerce/api/store-channel-bindings/crud.js.map +7 -0
  125. package/dist/modules/ecommerce/api/store-channel-bindings/route.js +67 -0
  126. package/dist/modules/ecommerce/api/store-channel-bindings/route.js.map +7 -0
  127. package/dist/modules/ecommerce/api/store-domain-bindings/crud.js +296 -0
  128. package/dist/modules/ecommerce/api/store-domain-bindings/crud.js.map +7 -0
  129. package/dist/modules/ecommerce/api/store-domain-bindings/route.js +73 -0
  130. package/dist/modules/ecommerce/api/store-domain-bindings/route.js.map +7 -0
  131. package/dist/modules/ecommerce/api/storefront/categories/[slug]/route.js +87 -0
  132. package/dist/modules/ecommerce/api/storefront/categories/[slug]/route.js.map +7 -0
  133. package/dist/modules/ecommerce/api/storefront/categories/openapiSchemas.js +50 -0
  134. package/dist/modules/ecommerce/api/storefront/categories/openapiSchemas.js.map +7 -0
  135. package/dist/modules/ecommerce/api/storefront/categories/route.js +75 -0
  136. package/dist/modules/ecommerce/api/storefront/categories/route.js.map +7 -0
  137. package/dist/modules/ecommerce/api/storefront/context/route.js +163 -0
  138. package/dist/modules/ecommerce/api/storefront/context/route.js.map +7 -0
  139. package/dist/modules/ecommerce/api/storefront/products/[idOrHandle]/route.js +87 -0
  140. package/dist/modules/ecommerce/api/storefront/products/[idOrHandle]/route.js.map +7 -0
  141. package/dist/modules/ecommerce/api/storefront/products/openapiSchemas.js +177 -0
  142. package/dist/modules/ecommerce/api/storefront/products/openapiSchemas.js.map +7 -0
  143. package/dist/modules/ecommerce/api/storefront/products/route.js +78 -0
  144. package/dist/modules/ecommerce/api/storefront/products/route.js.map +7 -0
  145. package/dist/modules/ecommerce/api/storefront/search/suggest/openapiSchemas.js +25 -0
  146. package/dist/modules/ecommerce/api/storefront/search/suggest/openapiSchemas.js.map +7 -0
  147. package/dist/modules/ecommerce/api/storefront/search/suggest/route.js +75 -0
  148. package/dist/modules/ecommerce/api/storefront/search/suggest/route.js.map +7 -0
  149. package/dist/modules/ecommerce/api/storefront/storefrontRouteSupport.js +58 -0
  150. package/dist/modules/ecommerce/api/storefront/storefrontRouteSupport.js.map +7 -0
  151. package/dist/modules/ecommerce/api/stores/[id]/branding/route.js +183 -0
  152. package/dist/modules/ecommerce/api/stores/[id]/branding/route.js.map +7 -0
  153. package/dist/modules/ecommerce/api/stores/[id]/preview-branding/route.js +92 -0
  154. package/dist/modules/ecommerce/api/stores/[id]/preview-branding/route.js.map +7 -0
  155. package/dist/modules/ecommerce/api/stores/crud.js +401 -0
  156. package/dist/modules/ecommerce/api/stores/crud.js.map +7 -0
  157. package/dist/modules/ecommerce/api/stores/route.js +64 -0
  158. package/dist/modules/ecommerce/api/stores/route.js.map +7 -0
  159. package/dist/modules/ecommerce/backend/config/ecommerce/[id]/page.js +9 -0
  160. package/dist/modules/ecommerce/backend/config/ecommerce/[id]/page.js.map +7 -0
  161. package/dist/modules/ecommerce/backend/config/ecommerce/[id]/page.meta.js +16 -0
  162. package/dist/modules/ecommerce/backend/config/ecommerce/[id]/page.meta.js.map +7 -0
  163. package/dist/modules/ecommerce/backend/config/ecommerce/page.js +9 -0
  164. package/dist/modules/ecommerce/backend/config/ecommerce/page.js.map +7 -0
  165. package/dist/modules/ecommerce/backend/config/ecommerce/page.meta.js +16 -0
  166. package/dist/modules/ecommerce/backend/config/ecommerce/page.meta.js.map +7 -0
  167. package/dist/modules/ecommerce/commands/stores.js +110 -0
  168. package/dist/modules/ecommerce/commands/stores.js.map +7 -0
  169. package/dist/modules/ecommerce/components/ChannelAssortmentCount.js +90 -0
  170. package/dist/modules/ecommerce/components/ChannelAssortmentCount.js.map +7 -0
  171. package/dist/modules/ecommerce/components/ChannelBindingFormSections.js +33 -0
  172. package/dist/modules/ecommerce/components/ChannelBindingFormSections.js.map +7 -0
  173. package/dist/modules/ecommerce/components/ChannelLookupPicker.js +11 -0
  174. package/dist/modules/ecommerce/components/ChannelLookupPicker.js.map +7 -0
  175. package/dist/modules/ecommerce/components/DomainStatusWarning.js +24 -0
  176. package/dist/modules/ecommerce/components/DomainStatusWarning.js.map +7 -0
  177. package/dist/modules/ecommerce/components/StoreAvailabilityDefaultsSection.js +190 -0
  178. package/dist/modules/ecommerce/components/StoreAvailabilityDefaultsSection.js.map +7 -0
  179. package/dist/modules/ecommerce/components/StoreBrandingControls.js +67 -0
  180. package/dist/modules/ecommerce/components/StoreBrandingControls.js.map +7 -0
  181. package/dist/modules/ecommerce/components/StoreBrandingPreview.js +69 -0
  182. package/dist/modules/ecommerce/components/StoreBrandingPreview.js.map +7 -0
  183. package/dist/modules/ecommerce/components/StoreBrandingTab.js +218 -0
  184. package/dist/modules/ecommerce/components/StoreBrandingTab.js.map +7 -0
  185. package/dist/modules/ecommerce/components/StoreChannelBindingDialog.js +270 -0
  186. package/dist/modules/ecommerce/components/StoreChannelBindingDialog.js.map +7 -0
  187. package/dist/modules/ecommerce/components/StoreChannelsTab.js +313 -0
  188. package/dist/modules/ecommerce/components/StoreChannelsTab.js.map +7 -0
  189. package/dist/modules/ecommerce/components/StoreCreateDialog.js +164 -0
  190. package/dist/modules/ecommerce/components/StoreCreateDialog.js.map +7 -0
  191. package/dist/modules/ecommerce/components/StoreDomainBindingDialog.js +162 -0
  192. package/dist/modules/ecommerce/components/StoreDomainBindingDialog.js.map +7 -0
  193. package/dist/modules/ecommerce/components/StoreDomainsTab.js +357 -0
  194. package/dist/modules/ecommerce/components/StoreDomainsTab.js.map +7 -0
  195. package/dist/modules/ecommerce/components/StoreEditPage.js +155 -0
  196. package/dist/modules/ecommerce/components/StoreEditPage.js.map +7 -0
  197. package/dist/modules/ecommerce/components/StoreGeneralTab.js +167 -0
  198. package/dist/modules/ecommerce/components/StoreGeneralTab.js.map +7 -0
  199. package/dist/modules/ecommerce/components/StoreListPage.js +290 -0
  200. package/dist/modules/ecommerce/components/StoreListPage.js.map +7 -0
  201. package/dist/modules/ecommerce/components/StoreSeoTab.js +132 -0
  202. package/dist/modules/ecommerce/components/StoreSeoTab.js.map +7 -0
  203. package/dist/modules/ecommerce/components/StoreStatusBadge.js +20 -0
  204. package/dist/modules/ecommerce/components/StoreStatusBadge.js.map +7 -0
  205. package/dist/modules/ecommerce/components/channelLookups.js +28 -0
  206. package/dist/modules/ecommerce/components/channelLookups.js.map +7 -0
  207. package/dist/modules/ecommerce/components/storeAdmin.js +41 -0
  208. package/dist/modules/ecommerce/components/storeAdmin.js.map +7 -0
  209. package/dist/modules/ecommerce/components/storeBrandingForm.js +197 -0
  210. package/dist/modules/ecommerce/components/storeBrandingForm.js.map +7 -0
  211. package/dist/modules/ecommerce/components/storeChannels.js +140 -0
  212. package/dist/modules/ecommerce/components/storeChannels.js.map +7 -0
  213. package/dist/modules/ecommerce/components/storeDomains.js +167 -0
  214. package/dist/modules/ecommerce/components/storeDomains.js.map +7 -0
  215. package/dist/modules/ecommerce/components/storeEditTabs.js +62 -0
  216. package/dist/modules/ecommerce/components/storeEditTabs.js.map +7 -0
  217. package/dist/modules/ecommerce/components/storeGeneral.js +95 -0
  218. package/dist/modules/ecommerce/components/storeGeneral.js.map +7 -0
  219. package/dist/modules/ecommerce/components/storeSeo.js +69 -0
  220. package/dist/modules/ecommerce/components/storeSeo.js.map +7 -0
  221. package/dist/modules/ecommerce/components/useChannelAssortmentCount.js +45 -0
  222. package/dist/modules/ecommerce/components/useChannelAssortmentCount.js.map +7 -0
  223. package/dist/modules/ecommerce/components/useStoreAccess.js +28 -0
  224. package/dist/modules/ecommerce/components/useStoreAccess.js.map +7 -0
  225. package/dist/modules/ecommerce/data/enrichers.js +157 -0
  226. package/dist/modules/ecommerce/data/enrichers.js.map +7 -0
  227. package/dist/modules/ecommerce/data/entities.js +197 -0
  228. package/dist/modules/ecommerce/data/entities.js.map +7 -0
  229. package/dist/modules/ecommerce/data/validators.js +406 -0
  230. package/dist/modules/ecommerce/data/validators.js.map +7 -0
  231. package/dist/modules/ecommerce/di.js +11 -0
  232. package/dist/modules/ecommerce/di.js.map +7 -0
  233. package/dist/modules/ecommerce/events.js +27 -0
  234. package/dist/modules/ecommerce/events.js.map +7 -0
  235. package/dist/modules/ecommerce/index.js +16 -0
  236. package/dist/modules/ecommerce/index.js.map +7 -0
  237. package/dist/modules/ecommerce/lib/assortmentCount.js +112 -0
  238. package/dist/modules/ecommerce/lib/assortmentCount.js.map +7 -0
  239. package/dist/modules/ecommerce/lib/brandingStyles.js +184 -0
  240. package/dist/modules/ecommerce/lib/brandingStyles.js.map +7 -0
  241. package/dist/modules/ecommerce/lib/buyerContext.js +284 -0
  242. package/dist/modules/ecommerce/lib/buyerContext.js.map +7 -0
  243. package/dist/modules/ecommerce/lib/cacheInvalidation.js +186 -0
  244. package/dist/modules/ecommerce/lib/cacheInvalidation.js.map +7 -0
  245. package/dist/modules/ecommerce/lib/cacheKeys.js +236 -0
  246. package/dist/modules/ecommerce/lib/cacheKeys.js.map +7 -0
  247. package/dist/modules/ecommerce/lib/createConflictRecheck.js +29 -0
  248. package/dist/modules/ecommerce/lib/createConflictRecheck.js.map +7 -0
  249. package/dist/modules/ecommerce/lib/crudEvents.js +94 -0
  250. package/dist/modules/ecommerce/lib/crudEvents.js.map +7 -0
  251. package/dist/modules/ecommerce/lib/crudSupport.js +64 -0
  252. package/dist/modules/ecommerce/lib/crudSupport.js.map +7 -0
  253. package/dist/modules/ecommerce/lib/domainBindingRebind.js +99 -0
  254. package/dist/modules/ecommerce/lib/domainBindingRebind.js.map +7 -0
  255. package/dist/modules/ecommerce/lib/domainMappingSummaries.js +39 -0
  256. package/dist/modules/ecommerce/lib/domainMappingSummaries.js.map +7 -0
  257. package/dist/modules/ecommerce/lib/exclusiveFlag.js +57 -0
  258. package/dist/modules/ecommerce/lib/exclusiveFlag.js.map +7 -0
  259. package/dist/modules/ecommerce/lib/references.js +70 -0
  260. package/dist/modules/ecommerce/lib/references.js.map +7 -0
  261. package/dist/modules/ecommerce/lib/seedDraftStore.js +99 -0
  262. package/dist/modules/ecommerce/lib/seedDraftStore.js.map +7 -0
  263. package/dist/modules/ecommerce/lib/storeBindingCascade.js +109 -0
  264. package/dist/modules/ecommerce/lib/storeBindingCascade.js.map +7 -0
  265. package/dist/modules/ecommerce/lib/storeBranding.js +40 -0
  266. package/dist/modules/ecommerce/lib/storeBranding.js.map +7 -0
  267. package/dist/modules/ecommerce/lib/storeBrandingRoute.js +76 -0
  268. package/dist/modules/ecommerce/lib/storeBrandingRoute.js.map +7 -0
  269. package/dist/modules/ecommerce/lib/storeContext.js +393 -0
  270. package/dist/modules/ecommerce/lib/storeContext.js.map +7 -0
  271. package/dist/modules/ecommerce/lib/storeContextService.js +43 -0
  272. package/dist/modules/ecommerce/lib/storeContextService.js.map +7 -0
  273. package/dist/modules/ecommerce/lib/storeLocale.js +60 -0
  274. package/dist/modules/ecommerce/lib/storeLocale.js.map +7 -0
  275. package/dist/modules/ecommerce/lib/storeNotifications.js +41 -0
  276. package/dist/modules/ecommerce/lib/storeNotifications.js.map +7 -0
  277. package/dist/modules/ecommerce/lib/storefrontCatalogSupport.js +248 -0
  278. package/dist/modules/ecommerce/lib/storefrontCatalogSupport.js.map +7 -0
  279. package/dist/modules/ecommerce/lib/storefrontCategories.js +241 -0
  280. package/dist/modules/ecommerce/lib/storefrontCategories.js.map +7 -0
  281. package/dist/modules/ecommerce/lib/storefrontCategoryCache.js +71 -0
  282. package/dist/modules/ecommerce/lib/storefrontCategoryCache.js.map +7 -0
  283. package/dist/modules/ecommerce/lib/storefrontDetail.js +447 -0
  284. package/dist/modules/ecommerce/lib/storefrontDetail.js.map +7 -0
  285. package/dist/modules/ecommerce/lib/storefrontFacets.js +441 -0
  286. package/dist/modules/ecommerce/lib/storefrontFacets.js.map +7 -0
  287. package/dist/modules/ecommerce/lib/storefrontOptionFilter.js +15 -0
  288. package/dist/modules/ecommerce/lib/storefrontOptionFilter.js.map +7 -0
  289. package/dist/modules/ecommerce/lib/storefrontPricing.js +393 -0
  290. package/dist/modules/ecommerce/lib/storefrontPricing.js.map +7 -0
  291. package/dist/modules/ecommerce/lib/storefrontProductCache.js +90 -0
  292. package/dist/modules/ecommerce/lib/storefrontProductCache.js.map +7 -0
  293. package/dist/modules/ecommerce/lib/storefrontProductScope.js +107 -0
  294. package/dist/modules/ecommerce/lib/storefrontProductScope.js.map +7 -0
  295. package/dist/modules/ecommerce/lib/storefrontProducts.js +670 -0
  296. package/dist/modules/ecommerce/lib/storefrontProducts.js.map +7 -0
  297. package/dist/modules/ecommerce/lib/storefrontQuery.js +156 -0
  298. package/dist/modules/ecommerce/lib/storefrontQuery.js.map +7 -0
  299. package/dist/modules/ecommerce/lib/storefrontRateLimit.js +99 -0
  300. package/dist/modules/ecommerce/lib/storefrontRateLimit.js.map +7 -0
  301. package/dist/modules/ecommerce/lib/storefrontSearch.js +303 -0
  302. package/dist/modules/ecommerce/lib/storefrontSearch.js.map +7 -0
  303. package/dist/modules/ecommerce/lib/storefrontSearchCache.js +35 -0
  304. package/dist/modules/ecommerce/lib/storefrontSearchCache.js.map +7 -0
  305. package/dist/modules/ecommerce/lib/subscriberSupport.js +33 -0
  306. package/dist/modules/ecommerce/lib/subscriberSupport.js.map +7 -0
  307. package/dist/modules/ecommerce/lib/types.js +1 -0
  308. package/dist/modules/ecommerce/lib/types.js.map +7 -0
  309. package/dist/modules/ecommerce/migrations/Migration20261005113233_ecommerce.js +32 -0
  310. package/dist/modules/ecommerce/migrations/Migration20261005113233_ecommerce.js.map +7 -0
  311. package/dist/modules/ecommerce/migrations/Migration20261006112733_ecommerce.js +17 -0
  312. package/dist/modules/ecommerce/migrations/Migration20261006112733_ecommerce.js.map +7 -0
  313. package/dist/modules/ecommerce/notifications.client.js +47 -0
  314. package/dist/modules/ecommerce/notifications.client.js.map +7 -0
  315. package/dist/modules/ecommerce/notifications.js +48 -0
  316. package/dist/modules/ecommerce/notifications.js.map +7 -0
  317. package/dist/modules/ecommerce/search.js +83 -0
  318. package/dist/modules/ecommerce/search.js.map +7 -0
  319. package/dist/modules/ecommerce/setup.js +17 -0
  320. package/dist/modules/ecommerce/setup.js.map +7 -0
  321. package/dist/modules/ecommerce/subscribers/assortment-empty-notifications.js +14 -0
  322. package/dist/modules/ecommerce/subscribers/assortment-empty-notifications.js.map +7 -0
  323. package/dist/modules/ecommerce/subscribers/availability-policy-cache-invalidation.js +14 -0
  324. package/dist/modules/ecommerce/subscribers/availability-policy-cache-invalidation.js.map +7 -0
  325. package/dist/modules/ecommerce/subscribers/catalog-category-cache-invalidation.js +14 -0
  326. package/dist/modules/ecommerce/subscribers/catalog-category-cache-invalidation.js.map +7 -0
  327. package/dist/modules/ecommerce/subscribers/catalog-price-cache-invalidation.js +14 -0
  328. package/dist/modules/ecommerce/subscribers/catalog-price-cache-invalidation.js.map +7 -0
  329. package/dist/modules/ecommerce/subscribers/catalog-product-cache-invalidation.js +14 -0
  330. package/dist/modules/ecommerce/subscribers/catalog-product-cache-invalidation.js.map +7 -0
  331. package/dist/modules/ecommerce/subscribers/catalog-variant-cache-invalidation.js +14 -0
  332. package/dist/modules/ecommerce/subscribers/catalog-variant-cache-invalidation.js.map +7 -0
  333. package/dist/modules/ecommerce/subscribers/customer-group-cache-invalidation.js +14 -0
  334. package/dist/modules/ecommerce/subscribers/customer-group-cache-invalidation.js.map +7 -0
  335. package/dist/modules/ecommerce/subscribers/customer-group-membership-cache-invalidation.js +14 -0
  336. package/dist/modules/ecommerce/subscribers/customer-group-membership-cache-invalidation.js.map +7 -0
  337. package/dist/modules/ecommerce/subscribers/customer-group-terms-cache-invalidation.js +14 -0
  338. package/dist/modules/ecommerce/subscribers/customer-group-terms-cache-invalidation.js.map +7 -0
  339. package/dist/modules/ecommerce/subscribers/customer-user-deleted-cache-invalidation.js +14 -0
  340. package/dist/modules/ecommerce/subscribers/customer-user-deleted-cache-invalidation.js.map +7 -0
  341. package/dist/modules/ecommerce/subscribers/customer-user-updated-cache-invalidation.js +14 -0
  342. package/dist/modules/ecommerce/subscribers/customer-user-updated-cache-invalidation.js.map +7 -0
  343. package/dist/modules/ecommerce/subscribers/domain-binding-rebind.js +16 -0
  344. package/dist/modules/ecommerce/subscribers/domain-binding-rebind.js.map +7 -0
  345. package/dist/modules/ecommerce/subscribers/domain-mapping-cache-invalidation.js +14 -0
  346. package/dist/modules/ecommerce/subscribers/domain-mapping-cache-invalidation.js.map +7 -0
  347. package/dist/modules/ecommerce/subscribers/store-cache-invalidation.js +14 -0
  348. package/dist/modules/ecommerce/subscribers/store-cache-invalidation.js.map +7 -0
  349. package/dist/modules/ecommerce/subscribers/store-channel-binding-cache-invalidation.js +14 -0
  350. package/dist/modules/ecommerce/subscribers/store-channel-binding-cache-invalidation.js.map +7 -0
  351. package/dist/modules/ecommerce/subscribers/store-domain-binding-cache-invalidation.js +14 -0
  352. package/dist/modules/ecommerce/subscribers/store-domain-binding-cache-invalidation.js.map +7 -0
  353. package/dist/modules/ecommerce/subscribers/store-notifications.js +14 -0
  354. package/dist/modules/ecommerce/subscribers/store-notifications.js.map +7 -0
  355. package/dist/modules/query_index/lib/batch.js +23 -9
  356. package/dist/modules/query_index/lib/batch.js.map +2 -2
  357. package/dist/modules/query_index/lib/doc-enrichers.js +212 -0
  358. package/dist/modules/query_index/lib/doc-enrichers.js.map +7 -0
  359. package/dist/modules/query_index/lib/document.js +2 -0
  360. package/dist/modules/query_index/lib/document.js.map +2 -2
  361. package/dist/modules/query_index/lib/engine.js +68 -1
  362. package/dist/modules/query_index/lib/engine.js.map +2 -2
  363. package/dist/modules/query_index/lib/indexer.js +7 -0
  364. package/dist/modules/query_index/lib/indexer.js.map +2 -2
  365. package/dist/modules/query_index/lib/search-tokens.js +2 -0
  366. package/dist/modules/query_index/lib/search-tokens.js.map +2 -2
  367. package/dist/modules/query_index/migrations/Migration20261005201500_query_index.js +17 -0
  368. package/dist/modules/query_index/migrations/Migration20261005201500_query_index.js.map +7 -0
  369. package/dist/modules/translations/components/TranslationManager.js +3 -3
  370. package/dist/modules/translations/components/TranslationManager.js.map +2 -2
  371. package/dist/modules/translations/data/validators.js +1 -1
  372. package/dist/modules/translations/data/validators.js.map +1 -1
  373. package/dist/modules/translations/lib/batch.js +21 -1
  374. package/dist/modules/translations/lib/batch.js.map +2 -2
  375. package/dist/modules/translations/lib/helpers.js +3 -0
  376. package/dist/modules/translations/lib/helpers.js.map +2 -2
  377. package/dist/modules/translations/lib/resolve-field-list.js +14 -2
  378. package/dist/modules/translations/lib/resolve-field-list.js.map +2 -2
  379. package/generated/entities/catalog_price_history_entry/index.ts +25 -0
  380. package/generated/entities/customer_group_terms/index.ts +1 -0
  381. package/generated/entities/ecommerce_store/index.ts +15 -0
  382. package/generated/entities/ecommerce_store_channel_binding/index.ts +13 -0
  383. package/generated/entities/ecommerce_store_domain_binding/index.ts +10 -0
  384. package/generated/entities.ids.generated.ts +8 -1
  385. package/generated/entity-fields-registry.ts +72 -0
  386. package/package.json +7 -7
  387. package/src/helpers/integration/customerGroupsFixtures.ts +2 -0
  388. package/src/modules/auth/i18n/de.json +8 -0
  389. package/src/modules/auth/i18n/en.json +8 -0
  390. package/src/modules/auth/i18n/es.json +8 -0
  391. package/src/modules/auth/i18n/ko.json +8 -0
  392. package/src/modules/auth/i18n/pl.json +8 -0
  393. package/src/modules/catalog/AGENTS.md +5 -2
  394. package/src/modules/catalog/acl.ts +7 -0
  395. package/src/modules/catalog/api/config/omnibus/route.ts +204 -0
  396. package/src/modules/catalog/api/prices/history/route.ts +139 -0
  397. package/src/modules/catalog/api/prices/omnibus-preview/route.ts +202 -0
  398. package/src/modules/catalog/api/products/route.ts +53 -308
  399. package/src/modules/catalog/api/tags/route.ts +6 -0
  400. package/src/modules/catalog/backend/config/catalog/page.tsx +2 -0
  401. package/src/modules/catalog/cli.ts +84 -1
  402. package/src/modules/catalog/commands/categories.ts +54 -2
  403. package/src/modules/catalog/commands/prices.ts +43 -1
  404. package/src/modules/catalog/commands/products.ts +84 -1
  405. package/src/modules/catalog/commands/variants.ts +7 -0
  406. package/src/modules/catalog/components/OmnibusSettings.tsx +832 -0
  407. package/src/modules/catalog/components/PriceEditorOmnibusRow.tsx +219 -0
  408. package/src/modules/catalog/components/lookupSources.ts +29 -0
  409. package/src/modules/catalog/components/prices/PriceScopeSelectors.tsx +9 -0
  410. package/src/modules/catalog/components/products/VariantBuilder.tsx +9 -0
  411. package/src/modules/catalog/data/entities.ts +123 -1
  412. package/src/modules/catalog/data/validators.ts +118 -0
  413. package/src/modules/catalog/di.ts +23 -0
  414. package/src/modules/catalog/i18n/de.json +77 -0
  415. package/src/modules/catalog/i18n/en.json +77 -0
  416. package/src/modules/catalog/i18n/es.json +77 -0
  417. package/src/modules/catalog/i18n/ko.json +77 -0
  418. package/src/modules/catalog/i18n/pl.json +77 -0
  419. package/src/modules/catalog/lib/omnibus.ts +406 -0
  420. package/src/modules/catalog/lib/omnibusBackfill.ts +198 -0
  421. package/src/modules/catalog/lib/omnibusCache.ts +111 -0
  422. package/src/modules/catalog/lib/omnibusConfig.ts +73 -0
  423. package/src/modules/catalog/lib/omnibusHistoryQueries.ts +248 -0
  424. package/src/modules/catalog/lib/omnibusPresentedEntry.ts +76 -0
  425. package/src/modules/catalog/lib/omnibusProductListEnrichment.ts +125 -0
  426. package/src/modules/catalog/lib/omnibusTypes.ts +202 -0
  427. package/src/modules/catalog/lib/optionSchemaTranslations.ts +55 -0
  428. package/src/modules/catalog/lib/priceHistoryQuery.ts +155 -0
  429. package/src/modules/catalog/lib/pricing.ts +42 -4
  430. package/src/modules/catalog/lib/productFilters.ts +349 -0
  431. package/src/modules/catalog/lib/productScopeKeys.ts +162 -0
  432. package/src/modules/catalog/lib/productScopeReindex.ts +139 -0
  433. package/src/modules/catalog/migrations/.snapshot-open-mercato.json +572 -0
  434. package/src/modules/catalog/migrations/Migration20261005105352_catalog.ts +39 -0
  435. package/src/modules/catalog/migrations/Migration20261005150824_catalog.ts +39 -0
  436. package/src/modules/catalog/services/catalogOmnibusService.ts +642 -0
  437. package/src/modules/catalog/setup.ts +2 -0
  438. package/src/modules/catalog/subscribers/product-scope-keys-category-deleted.ts +18 -0
  439. package/src/modules/catalog/subscribers/product-scope-keys-category-updated.ts +19 -0
  440. package/src/modules/catalog/translations.ts +12 -0
  441. package/src/modules/configs/i18n/de.json +5 -1
  442. package/src/modules/configs/i18n/en.json +5 -1
  443. package/src/modules/configs/i18n/es.json +5 -1
  444. package/src/modules/configs/i18n/ko.json +5 -1
  445. package/src/modules/configs/i18n/pl.json +5 -1
  446. package/src/modules/configs/lib/upgrade-actions.ts +35 -0
  447. package/src/modules/customer_groups/api/customer-groups/[id]/terms/route.ts +7 -0
  448. package/src/modules/customer_groups/components/CustomerGroupTermsSection.tsx +124 -2
  449. package/src/modules/customer_groups/components/customerGroupAssortmentScope.ts +46 -0
  450. package/src/modules/customer_groups/data/entities.ts +4 -0
  451. package/src/modules/customer_groups/data/validators.ts +14 -0
  452. package/src/modules/customer_groups/i18n/de.json +12 -0
  453. package/src/modules/customer_groups/i18n/en.json +12 -0
  454. package/src/modules/customer_groups/i18n/es.json +12 -0
  455. package/src/modules/customer_groups/i18n/ko.json +12 -0
  456. package/src/modules/customer_groups/i18n/pl.json +12 -0
  457. package/src/modules/customer_groups/migrations/.snapshot-open-mercato.json +17 -0
  458. package/src/modules/customer_groups/migrations/Migration20261005110250_customer_groups.ts +15 -0
  459. package/src/modules/customer_groups/services/customerGroupsService.ts +74 -23
  460. package/src/modules/ecommerce/acl.ts +9 -0
  461. package/src/modules/ecommerce/api/domain-mappings/route.ts +76 -0
  462. package/src/modules/ecommerce/api/openapi.ts +28 -0
  463. package/src/modules/ecommerce/api/store-channel-bindings/[id]/assortment-count/route.ts +141 -0
  464. package/src/modules/ecommerce/api/store-channel-bindings/crud.ts +283 -0
  465. package/src/modules/ecommerce/api/store-channel-bindings/route.ts +67 -0
  466. package/src/modules/ecommerce/api/store-domain-bindings/crud.ts +324 -0
  467. package/src/modules/ecommerce/api/store-domain-bindings/route.ts +73 -0
  468. package/src/modules/ecommerce/api/storefront/categories/[slug]/route.ts +94 -0
  469. package/src/modules/ecommerce/api/storefront/categories/openapiSchemas.ts +63 -0
  470. package/src/modules/ecommerce/api/storefront/categories/route.ts +78 -0
  471. package/src/modules/ecommerce/api/storefront/context/route.ts +203 -0
  472. package/src/modules/ecommerce/api/storefront/products/[idOrHandle]/route.ts +94 -0
  473. package/src/modules/ecommerce/api/storefront/products/openapiSchemas.ts +193 -0
  474. package/src/modules/ecommerce/api/storefront/products/route.ts +81 -0
  475. package/src/modules/ecommerce/api/storefront/search/suggest/openapiSchemas.ts +25 -0
  476. package/src/modules/ecommerce/api/storefront/search/suggest/route.ts +78 -0
  477. package/src/modules/ecommerce/api/storefront/storefrontRouteSupport.ts +68 -0
  478. package/src/modules/ecommerce/api/stores/[id]/branding/route.ts +205 -0
  479. package/src/modules/ecommerce/api/stores/[id]/preview-branding/route.ts +99 -0
  480. package/src/modules/ecommerce/api/stores/crud.ts +457 -0
  481. package/src/modules/ecommerce/api/stores/route.ts +66 -0
  482. package/src/modules/ecommerce/backend/config/ecommerce/[id]/page.meta.ts +12 -0
  483. package/src/modules/ecommerce/backend/config/ecommerce/[id]/page.tsx +5 -0
  484. package/src/modules/ecommerce/backend/config/ecommerce/page.meta.ts +12 -0
  485. package/src/modules/ecommerce/backend/config/ecommerce/page.tsx +5 -0
  486. package/src/modules/ecommerce/commands/stores.ts +154 -0
  487. package/src/modules/ecommerce/components/ChannelAssortmentCount.tsx +138 -0
  488. package/src/modules/ecommerce/components/ChannelBindingFormSections.tsx +40 -0
  489. package/src/modules/ecommerce/components/ChannelLookupPicker.tsx +5 -0
  490. package/src/modules/ecommerce/components/DomainStatusWarning.tsx +32 -0
  491. package/src/modules/ecommerce/components/StoreAvailabilityDefaultsSection.tsx +219 -0
  492. package/src/modules/ecommerce/components/StoreBrandingControls.tsx +73 -0
  493. package/src/modules/ecommerce/components/StoreBrandingPreview.tsx +77 -0
  494. package/src/modules/ecommerce/components/StoreBrandingTab.tsx +242 -0
  495. package/src/modules/ecommerce/components/StoreChannelBindingDialog.tsx +306 -0
  496. package/src/modules/ecommerce/components/StoreChannelsTab.tsx +375 -0
  497. package/src/modules/ecommerce/components/StoreCreateDialog.tsx +204 -0
  498. package/src/modules/ecommerce/components/StoreDomainBindingDialog.tsx +198 -0
  499. package/src/modules/ecommerce/components/StoreDomainsTab.tsx +426 -0
  500. package/src/modules/ecommerce/components/StoreEditPage.tsx +193 -0
  501. package/src/modules/ecommerce/components/StoreGeneralTab.tsx +189 -0
  502. package/src/modules/ecommerce/components/StoreListPage.tsx +326 -0
  503. package/src/modules/ecommerce/components/StoreSeoTab.tsx +152 -0
  504. package/src/modules/ecommerce/components/StoreStatusBadge.tsx +22 -0
  505. package/src/modules/ecommerce/components/channelLookups.ts +24 -0
  506. package/src/modules/ecommerce/components/storeAdmin.ts +56 -0
  507. package/src/modules/ecommerce/components/storeBrandingForm.ts +230 -0
  508. package/src/modules/ecommerce/components/storeChannels.ts +210 -0
  509. package/src/modules/ecommerce/components/storeDomains.ts +221 -0
  510. package/src/modules/ecommerce/components/storeEditTabs.tsx +76 -0
  511. package/src/modules/ecommerce/components/storeGeneral.ts +155 -0
  512. package/src/modules/ecommerce/components/storeSeo.ts +78 -0
  513. package/src/modules/ecommerce/components/useChannelAssortmentCount.ts +67 -0
  514. package/src/modules/ecommerce/components/useStoreAccess.ts +36 -0
  515. package/src/modules/ecommerce/data/enrichers.ts +213 -0
  516. package/src/modules/ecommerce/data/entities.ts +168 -0
  517. package/src/modules/ecommerce/data/validators.ts +587 -0
  518. package/src/modules/ecommerce/di.ts +9 -0
  519. package/src/modules/ecommerce/events.ts +27 -0
  520. package/src/modules/ecommerce/i18n/de.json +341 -0
  521. package/src/modules/ecommerce/i18n/en.json +341 -0
  522. package/src/modules/ecommerce/i18n/es.json +341 -0
  523. package/src/modules/ecommerce/i18n/ko.json +341 -0
  524. package/src/modules/ecommerce/i18n/pl.json +341 -0
  525. package/src/modules/ecommerce/index.ts +14 -0
  526. package/src/modules/ecommerce/lib/assortmentCount.ts +175 -0
  527. package/src/modules/ecommerce/lib/brandingStyles.ts +215 -0
  528. package/src/modules/ecommerce/lib/buyerContext.ts +401 -0
  529. package/src/modules/ecommerce/lib/cacheInvalidation.ts +302 -0
  530. package/src/modules/ecommerce/lib/cacheKeys.ts +340 -0
  531. package/src/modules/ecommerce/lib/createConflictRecheck.ts +31 -0
  532. package/src/modules/ecommerce/lib/crudEvents.ts +128 -0
  533. package/src/modules/ecommerce/lib/crudSupport.ts +85 -0
  534. package/src/modules/ecommerce/lib/domainBindingRebind.ts +138 -0
  535. package/src/modules/ecommerce/lib/domainMappingSummaries.ts +71 -0
  536. package/src/modules/ecommerce/lib/exclusiveFlag.ts +90 -0
  537. package/src/modules/ecommerce/lib/references.ts +93 -0
  538. package/src/modules/ecommerce/lib/seedDraftStore.ts +125 -0
  539. package/src/modules/ecommerce/lib/storeBindingCascade.ts +138 -0
  540. package/src/modules/ecommerce/lib/storeBranding.ts +48 -0
  541. package/src/modules/ecommerce/lib/storeBrandingRoute.ts +91 -0
  542. package/src/modules/ecommerce/lib/storeContext.ts +669 -0
  543. package/src/modules/ecommerce/lib/storeContextService.ts +71 -0
  544. package/src/modules/ecommerce/lib/storeLocale.ts +88 -0
  545. package/src/modules/ecommerce/lib/storeNotifications.ts +55 -0
  546. package/src/modules/ecommerce/lib/storefrontCatalogSupport.ts +427 -0
  547. package/src/modules/ecommerce/lib/storefrontCategories.ts +419 -0
  548. package/src/modules/ecommerce/lib/storefrontCategoryCache.ts +113 -0
  549. package/src/modules/ecommerce/lib/storefrontDetail.ts +654 -0
  550. package/src/modules/ecommerce/lib/storefrontFacets.ts +697 -0
  551. package/src/modules/ecommerce/lib/storefrontOptionFilter.ts +44 -0
  552. package/src/modules/ecommerce/lib/storefrontPricing.ts +583 -0
  553. package/src/modules/ecommerce/lib/storefrontProductCache.ts +126 -0
  554. package/src/modules/ecommerce/lib/storefrontProductScope.ts +181 -0
  555. package/src/modules/ecommerce/lib/storefrontProducts.ts +963 -0
  556. package/src/modules/ecommerce/lib/storefrontQuery.ts +215 -0
  557. package/src/modules/ecommerce/lib/storefrontRateLimit.ts +126 -0
  558. package/src/modules/ecommerce/lib/storefrontSearch.ts +454 -0
  559. package/src/modules/ecommerce/lib/storefrontSearchCache.ts +49 -0
  560. package/src/modules/ecommerce/lib/subscriberSupport.ts +41 -0
  561. package/src/modules/ecommerce/lib/types.ts +69 -0
  562. package/src/modules/ecommerce/migrations/.snapshot-open-mercato.json +829 -0
  563. package/src/modules/ecommerce/migrations/Migration20261005113233_ecommerce.ts +32 -0
  564. package/src/modules/ecommerce/migrations/Migration20261006112733_ecommerce.ts +15 -0
  565. package/src/modules/ecommerce/notifications.client.ts +46 -0
  566. package/src/modules/ecommerce/notifications.ts +46 -0
  567. package/src/modules/ecommerce/search.ts +93 -0
  568. package/src/modules/ecommerce/setup.ts +15 -0
  569. package/src/modules/ecommerce/subscribers/assortment-empty-notifications.ts +12 -0
  570. package/src/modules/ecommerce/subscribers/availability-policy-cache-invalidation.ts +12 -0
  571. package/src/modules/ecommerce/subscribers/catalog-category-cache-invalidation.ts +12 -0
  572. package/src/modules/ecommerce/subscribers/catalog-price-cache-invalidation.ts +12 -0
  573. package/src/modules/ecommerce/subscribers/catalog-product-cache-invalidation.ts +12 -0
  574. package/src/modules/ecommerce/subscribers/catalog-variant-cache-invalidation.ts +12 -0
  575. package/src/modules/ecommerce/subscribers/customer-group-cache-invalidation.ts +12 -0
  576. package/src/modules/ecommerce/subscribers/customer-group-membership-cache-invalidation.ts +12 -0
  577. package/src/modules/ecommerce/subscribers/customer-group-terms-cache-invalidation.ts +12 -0
  578. package/src/modules/ecommerce/subscribers/customer-user-deleted-cache-invalidation.ts +12 -0
  579. package/src/modules/ecommerce/subscribers/customer-user-updated-cache-invalidation.ts +12 -0
  580. package/src/modules/ecommerce/subscribers/domain-binding-rebind.ts +14 -0
  581. package/src/modules/ecommerce/subscribers/domain-mapping-cache-invalidation.ts +12 -0
  582. package/src/modules/ecommerce/subscribers/store-cache-invalidation.ts +12 -0
  583. package/src/modules/ecommerce/subscribers/store-channel-binding-cache-invalidation.ts +12 -0
  584. package/src/modules/ecommerce/subscribers/store-domain-binding-cache-invalidation.ts +12 -0
  585. package/src/modules/ecommerce/subscribers/store-notifications.ts +12 -0
  586. package/src/modules/query_index/lib/batch.ts +25 -9
  587. package/src/modules/query_index/lib/doc-enrichers.ts +306 -0
  588. package/src/modules/query_index/lib/document.ts +2 -0
  589. package/src/modules/query_index/lib/engine.ts +58 -1
  590. package/src/modules/query_index/lib/indexer.ts +8 -0
  591. package/src/modules/query_index/lib/search-tokens.ts +2 -0
  592. package/src/modules/query_index/migrations/Migration20261005201500_query_index.ts +42 -0
  593. package/src/modules/translations/components/TranslationManager.tsx +3 -3
  594. package/src/modules/translations/data/validators.ts +1 -1
  595. package/src/modules/translations/lib/batch.ts +47 -0
  596. package/src/modules/translations/lib/helpers.ts +4 -0
  597. package/src/modules/translations/lib/resolve-field-list.ts +16 -2
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/modules/catalog/api/products/route.ts"],
4
- "sourcesContent": ["import { z } from \"zod\";\nimport type { EntityManager } from \"@mikro-orm/postgresql\";\nimport { raw } from \"@mikro-orm/postgresql\";\nimport { makeCrudRoute } from \"@open-mercato/shared/lib/crud/factory\";\nimport { CrudHttpError } from \"@open-mercato/shared/lib/crud/errors\";\nimport {\n buildCustomFieldFiltersFromQuery,\n extractAllCustomFieldEntries,\n} from \"@open-mercato/shared/lib/crud/custom-fields\";\nimport { resolveTranslations } from \"@open-mercato/shared/lib/i18n/server\";\nimport {\n CatalogOffer,\n CatalogProduct,\n CatalogProductCategory,\n CatalogProductCategoryAssignment,\n CatalogProductPrice,\n CatalogProductUnitConversion,\n CatalogProductVariant,\n CatalogProductTagAssignment,\n} from \"../../data/entities\";\nimport { CATALOG_PRODUCT_TYPES } from \"../../data/types\";\nimport type { CatalogProductType } from \"../../data/types\";\nimport {\n productCreateSchema,\n productUpdateSchema,\n} from \"../../data/validators\";\nimport { parseScopedCommandInput, resolveCrudRecordId } from \"../utils\";\nimport { splitCustomFieldPayload } from \"@open-mercato/shared/lib/crud/custom-fields\";\nimport { E } from \"#generated/entities.ids.generated\";\nimport * as F from \"#generated/entities/catalog_product\";\nimport { parseBooleanFlag, sanitizeSearchTerm } from \"../helpers\";\nimport type { CrudCtx } from \"@open-mercato/shared/lib/crud/factory\";\nimport { buildScopedWhere } from \"@open-mercato/shared/lib/api/crud\";\nimport {\n resolvePriceChannelId,\n resolvePriceOfferId,\n resolvePriceVariantId,\n resolvePriceKindCode,\n type PricingContext,\n type PriceRow,\n} from \"../../lib/pricing\";\nimport type { CatalogPricingService } from \"../../services/catalogPricingService\";\nimport { fieldsetCodeRegex } from \"@open-mercato/core/modules/entities/data/validators\";\nimport { SalesChannel } from \"@open-mercato/core/modules/sales/data/entities\";\nimport {\n createCatalogCrudOpenApi,\n createPagedListResponseSchema,\n defaultOkResponseSchema,\n} from \"../openapi\";\nimport { findWithDecryption } from \"@open-mercato/shared/lib/encryption/find\";\nimport { warnOnEncryptedLikeFilter } from \"@open-mercato/shared/lib/encryption/likeFilterWarning\";\nimport { buildAccentInsensitiveContainsPatternSql } from \"@open-mercato/shared/lib/db/accentInsensitiveSearch\";\nimport {\n PRODUCT_SEARCH_COLUMNS,\n PRODUCT_SEARCH_EXPRESSION_SQL,\n} from \"../../lib/productSearch\";\nimport { canonicalizeUnitCode, toUnitLookupKey } from \"../../lib/unitCodes\";\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('catalog')\nconst rawBodySchema = z.object({}).passthrough();\n\nconst UUID_REGEX =\n /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/;\n\nconst listSchema = z\n .object({\n page: z.coerce.number().min(1).default(1),\n pageSize: z.coerce.number().min(1).max(100).default(50),\n id: z.string().uuid().optional(),\n search: z.string().optional(),\n status: z.string().optional(),\n isActive: z.string().optional(),\n configurable: z.string().optional(),\n productType: z.enum(CATALOG_PRODUCT_TYPES).optional(),\n channelIds: z.string().optional(),\n channelId: z.string().uuid().optional(),\n categoryIds: z.string().optional(),\n tagIds: z.string().optional(),\n offerId: z.string().uuid().optional(),\n userId: z.string().uuid().optional(),\n userGroupId: z.string().uuid().optional(),\n customerId: z.string().uuid().optional(),\n customerGroupId: z.string().uuid().optional(),\n quantity: z.coerce.number().min(1).max(100000).optional(),\n quantityUnit: z.string().trim().max(50).optional(),\n priceDate: z.string().optional(),\n sortField: z.string().optional(),\n sortDir: z.enum([\"asc\", \"desc\"]).optional(),\n withDeleted: z.coerce.boolean().optional(),\n customFieldset: z.string().regex(fieldsetCodeRegex).optional(),\n })\n .passthrough();\n\ntype ProductsQuery = z.infer<typeof listSchema>;\n\nconst routeMetadata = {\n GET: { requireAuth: true, requireFeatures: [\"catalog.products.view\"] },\n POST: { requireAuth: true, requireFeatures: [\"catalog.products.manage\"] },\n PUT: { requireAuth: true, requireFeatures: [\"catalog.products.manage\"] },\n DELETE: { requireAuth: true, requireFeatures: [\"catalog.products.manage\"] },\n};\n\nexport const metadata = routeMetadata;\n\nexport function parseIdList(raw?: string): string[] {\n if (!raw) return [];\n return raw\n .split(\",\")\n .map((value) => value.trim())\n .filter((value) => UUID_REGEX.test(value));\n}\n\nexport async function buildProductFilters(\n query: ProductsQuery,\n ctx: CrudCtx,\n): Promise<Record<string, unknown>> {\n const filters: Record<string, unknown> = {};\n const em = (ctx.container.resolve(\"em\") as EntityManager).fork();\n const restrictedProductIds: { value: Set<string> | null } = { value: null };\n\n const intersectProductIds = (ids: string[]) => {\n const normalized = ids.filter(\n (id): id is string => typeof id === \"string\" && id.trim().length > 0,\n );\n const current = new Set(normalized);\n if (!current.size) {\n restrictedProductIds.value = new Set();\n return;\n }\n if (!restrictedProductIds.value) {\n restrictedProductIds.value = current;\n return;\n }\n restrictedProductIds.value = new Set(\n Array.from(restrictedProductIds.value).filter((id) => current.has(id)),\n );\n };\n\n const applyRestrictedProducts = () => {\n if (!restrictedProductIds.value) return;\n if (restrictedProductIds.value.size === 0) {\n filters.id = { $eq: \"00000000-0000-0000-0000-000000000000\" };\n return;\n }\n const ids = Array.from(restrictedProductIds.value);\n const existing = filters.id as Record<string, unknown> | undefined;\n if (existing && typeof existing === \"object\") {\n if (\n \"$eq\" in existing &&\n typeof (existing as { $eq?: unknown }).$eq === \"string\"\n ) {\n const target = (existing as { $eq: string }).$eq;\n if (!restrictedProductIds.value.has(target)) {\n filters.id = { $eq: \"00000000-0000-0000-0000-000000000000\" };\n }\n return;\n }\n if (\n \"$in\" in existing &&\n Array.isArray((existing as { $in?: unknown }).$in)\n ) {\n const subset = (existing as { $in: string[] }).$in.filter((id) =>\n restrictedProductIds.value!.has(id),\n );\n filters.id = subset.length\n ? { $in: subset }\n : { $eq: \"00000000-0000-0000-0000-000000000000\" };\n return;\n }\n }\n filters.id = ids.length === 1 ? { $eq: ids[0] } : { $in: ids };\n };\n if (query.id) {\n filters.id = { $eq: query.id };\n }\n if (query.status && query.status.trim()) {\n filters.status_entry_id = { $eq: query.status.trim() };\n }\n const active = parseBooleanFlag(query.isActive);\n if (active !== undefined) {\n filters.is_active = active;\n }\n const configurable = parseBooleanFlag(query.configurable);\n if (configurable !== undefined) {\n filters.is_configurable = configurable;\n }\n if (query.productType) {\n filters.product_type = { $eq: query.productType };\n }\n const scope = {\n organizationId: ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null,\n tenantId: ctx.auth?.tenantId ?? null,\n };\n const scopeWhere = buildScopedWhere(\n {},\n {\n organizationId: scope.organizationId,\n organizationIds: ctx.organizationIds ?? undefined,\n tenantId: scope.tenantId,\n orgField: ctx.organizationIds === null ? null : undefined,\n softDeleteField: null,\n },\n );\n const term = sanitizeSearchTerm(query.search);\n const channelFilterIds = parseIdList(query.channelIds);\n const categoryFilterIds = parseIdList(query.categoryIds);\n const tagFilterIds = parseIdList(query.tagIds);\n const customFieldset =\n typeof query.customFieldset === \"string\" &&\n query.customFieldset.trim().length\n ? query.customFieldset.trim()\n : null;\n const tenantId = ctx.auth?.tenantId ?? null;\n\n // These prequeries are independent \u2014 each only feeds the final product-id\n // intersection, none depends on another's result \u2014 so dispatch them together\n // instead of awaiting one after another (#3179). A task returns null when its\n // filter is inactive (intersection skipped) or the matched product-id list\n // (possibly empty) when active, preserving the \"active filter with no matches\n // => empty result\" behavior.\n const searchTask = async (): Promise<string[] | null> => {\n if (!term) return null;\n // The predicate hides behind a raw() symbol key, which the filter walker in\n // findWithDecryption cannot see (Object.entries skips symbols), so the\n // encrypted-ILIKE diagnostic is raised here with the field list instead.\n // Without it, a tenant that encrypts one of these columns at rest gets an\n // empty result indistinguishable from a genuine no-match (#5051). It runs\n // alongside the query rather than before it: it is a development-only\n // diagnostic and must not add a round trip to the request path.\n const [searchMatches] = await Promise.all([\n findWithDecryption(\n em,\n CatalogProduct,\n {\n ...scopeWhere,\n ...(query.withDeleted ? {} : { deletedAt: null }),\n [raw(PRODUCT_SEARCH_EXPRESSION_SQL)]: {\n $ilike: raw(buildAccentInsensitiveContainsPatternSql(), [term]),\n },\n },\n { fields: [\"id\"] },\n scope,\n ),\n warnOnEncryptedLikeFilter({\n em,\n entityName: CatalogProduct,\n likeFields: [...PRODUCT_SEARCH_COLUMNS],\n tenantId: scope.tenantId,\n }),\n ]);\n return searchMatches\n .map((product) => product.id)\n .filter((id): id is string => typeof id === \"string\" && id.length > 0);\n };\n\n const channelTask = async (): Promise<string[] | null> => {\n if (!channelFilterIds.length) return null;\n const offerRows = await findWithDecryption(\n em,\n CatalogOffer,\n {\n channelId: { $in: channelFilterIds },\n deletedAt: null,\n ...scopeWhere,\n },\n { fields: [\"id\", \"product\"] },\n scope,\n );\n return offerRows\n .map((offer) =>\n typeof offer.product === \"string\"\n ? offer.product\n : (offer.product?.id ?? null),\n )\n .filter((id): id is string => !!id);\n };\n\n const categoryTask = async (): Promise<string[] | null> => {\n if (!categoryFilterIds.length) return null;\n const assignments = await findWithDecryption(\n em,\n CatalogProductCategoryAssignment,\n { category: { $in: categoryFilterIds }, ...scopeWhere },\n { fields: [\"id\", \"product\"] },\n scope,\n );\n return assignments\n .map((assignment) =>\n typeof assignment.product === \"string\"\n ? assignment.product\n : (assignment.product?.id ?? null),\n )\n .filter((id): id is string => !!id);\n };\n\n const tagTask = async (): Promise<string[] | null> => {\n if (!tagFilterIds.length) return null;\n const assignments = await findWithDecryption(\n em,\n CatalogProductTagAssignment,\n { tag: { $in: tagFilterIds }, ...scopeWhere },\n { fields: [\"id\", \"product\"] },\n scope,\n );\n return assignments\n .map((assignment) =>\n typeof assignment.product === \"string\"\n ? assignment.product\n : (assignment.product?.id ?? null),\n )\n .filter((id): id is string => !!id);\n };\n\n const customFieldTask = async (): Promise<Record<string, unknown>> => {\n try {\n const scopedEm = ctx.container.resolve(\"em\") as EntityManager;\n return await buildCustomFieldFiltersFromQuery({\n entityIds: [E.catalog.catalog_product],\n query,\n em: scopedEm,\n tenantId,\n fieldset: customFieldset ?? undefined,\n });\n } catch (err) {\n // Custom field filter parsing may fail for non-existent or misconfigured fields.\n // Fall back to base filters to avoid blocking the product listing.\n logger.debug('catalog.products custom field filter error', { err });\n return {};\n }\n };\n\n const [searchIds, channelIds, categoryIds, tagIds, cfFilters] =\n await Promise.all([\n searchTask(),\n channelTask(),\n categoryTask(),\n tagTask(),\n customFieldTask(),\n ]);\n\n // Apply intersections in the original order; intersection is commutative, so\n // the result is identical to the previous sequential pass. An empty array is\n // still intersected (active filter that matched nothing); null is skipped.\n for (const productIds of [searchIds, channelIds, categoryIds, tagIds]) {\n if (productIds) intersectProductIds(productIds);\n }\n Object.assign(filters, cfFilters);\n applyRestrictedProducts();\n return filters;\n}\n\nexport function buildPricingContext(\n query: ProductsQuery,\n channelFallback: string | null,\n): PricingContext {\n const quantity = Number.isFinite(Number(query.quantity))\n ? Number(query.quantity)\n : 1;\n const parsedDate = query.priceDate ? new Date(query.priceDate) : new Date();\n const channelId = query.channelId ?? channelFallback ?? null;\n return {\n channelId,\n offerId: query.offerId ?? null,\n userId: query.userId ?? null,\n userGroupId: query.userGroupId ?? null,\n customerId: query.customerId ?? null,\n customerGroupId: query.customerGroupId ?? null,\n quantity: Number.isFinite(quantity) && quantity > 0 ? quantity : 1,\n date: Number.isNaN(parsedDate.getTime()) ? new Date() : parsedDate,\n };\n}\n\ntype ProductListItem = Record<string, unknown> & {\n id?: string;\n title?: string | null;\n subtitle?: string | null;\n description?: string | null;\n sku?: string | null;\n handle?: string | null;\n product_type?: CatalogProductType | null;\n primary_currency_code?: string | null;\n default_unit?: string | null;\n default_sales_unit?: string | null;\n default_sales_unit_quantity?: number | null;\n uom_rounding_scale?: number | null;\n uom_rounding_mode?: \"half_up\" | \"down\" | \"up\" | null;\n unit_price_enabled?: boolean | null;\n unit_price_reference_unit?: \"kg\" | \"l\" | \"m2\" | \"m3\" | \"pc\" | null;\n unit_price_base_quantity?: number | null;\n default_media_id?: string | null;\n default_media_url?: string | null;\n weight_value?: string | null;\n weightValue?: string | null;\n weight_unit?: string | null;\n weightUnit?: string | null;\n dimensions?: Record<string, unknown> | null;\n custom_fieldset_code?: string | null;\n option_schema_id?: string | null;\n offers?: Array<Record<string, unknown>>;\n channelIds?: string[];\n categories?: Array<Record<string, unknown>>;\n categoryIds?: string[];\n tags?: string[];\n};\n\nasync function decorateProductsAfterList(\n payload: { items?: ProductListItem[] },\n ctx: CrudCtx & { query: ProductsQuery },\n): Promise<void> {\n const items = Array.isArray(payload?.items) ? payload.items : [];\n if (!items.length) return;\n const productIds = items\n .map((item) => (typeof item.id === \"string\" ? item.id : null))\n .filter((id): id is string => !!id);\n if (!productIds.length) return;\n try {\n const em = (ctx.container.resolve(\"em\") as EntityManager).fork();\n const scope = {\n organizationId: ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null,\n tenantId: ctx.auth?.tenantId ?? null,\n };\n const offers = await findWithDecryption(\n em,\n CatalogOffer,\n { product: { $in: productIds }, deletedAt: null, ...scope },\n { orderBy: { createdAt: \"asc\" } },\n scope,\n );\n const channelIds = Array.from(\n new Set(\n offers\n .map((offer) => offer.channelId)\n .filter(\n (id): id is string => typeof id === \"string\" && id.length > 0,\n ),\n ),\n );\n const channelLookup = new Map<\n string,\n { name?: string | null; code?: string | null }\n >();\n if (channelIds.length) {\n const scopedChannelsWhere = buildScopedWhere(\n { id: { $in: channelIds } },\n {\n organizationId: ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null,\n organizationIds: Array.isArray(ctx.organizationIds)\n ? ctx.organizationIds\n : undefined,\n tenantId: ctx.auth?.tenantId ?? null,\n },\n );\n const channels = await findWithDecryption(em, SalesChannel, scopedChannelsWhere, {\n fields: [\"id\", \"name\", \"code\"],\n });\n for (const channel of channels) {\n channelLookup.set(channel.id, {\n name: channel.name,\n code: channel.code ?? null,\n });\n }\n }\n const offersByProduct = new Map<string, Array<Record<string, unknown>>>();\n for (const offer of offers) {\n const productId =\n typeof offer.product === \"string\"\n ? offer.product\n : (offer.product?.id ?? null);\n if (!productId) continue;\n const channelInfo = channelLookup.get(offer.channelId);\n const entry = offersByProduct.get(productId) ?? [];\n entry.push({\n id: offer.id,\n channelId: offer.channelId,\n channelName: channelInfo?.name ?? null,\n channelCode: channelInfo?.code ?? null,\n title: offer.title,\n description: offer.description ?? null,\n isActive: offer.isActive,\n defaultMediaId: offer.defaultMediaId ?? null,\n defaultMediaUrl: offer.defaultMediaUrl ?? null,\n metadata: offer.metadata ?? null,\n updatedAt:\n offer.updatedAt instanceof Date\n ? offer.updatedAt.toISOString()\n : (typeof offer.updatedAt === \"string\" ? offer.updatedAt : null),\n });\n offersByProduct.set(productId, entry);\n }\n\n const categoryAssignments = await findWithDecryption(\n em,\n CatalogProductCategoryAssignment,\n { product: { $in: productIds }, ...scope },\n { populate: [\"category\"], orderBy: { position: \"asc\" } },\n scope,\n );\n const parentIds = new Set<string>();\n for (const assignment of categoryAssignments) {\n const category =\n typeof assignment.category === \"string\"\n ? null\n : (assignment.category ?? null);\n if (!category) continue;\n const parentId = category.parentId ?? null;\n if (parentId) parentIds.add(parentId);\n }\n const parentCategories = parentIds.size\n ? await findWithDecryption(\n em,\n CatalogProductCategory,\n { id: { $in: Array.from(parentIds) }, ...scope },\n { fields: [\"id\", \"name\"] },\n scope,\n )\n : [];\n const parentNameById = new Map<string, string | null>();\n for (const parent of parentCategories) {\n parentNameById.set(parent.id, parent.name ?? null);\n }\n const categoriesByProduct = new Map<\n string,\n Array<{\n id: string;\n name: string | null;\n treePath: string | null;\n parentId: string | null;\n parentName: string | null;\n }>\n >();\n for (const assignment of categoryAssignments) {\n const productId =\n typeof assignment.product === \"string\"\n ? assignment.product\n : (assignment.product?.id ?? null);\n if (!productId) continue;\n const category =\n typeof assignment.category === \"string\"\n ? null\n : (assignment.category ?? null);\n if (!category) continue;\n const parentId = category.parentId ?? null;\n const parentName = parentId\n ? (parentNameById.get(parentId) ?? null)\n : null;\n const bucket = categoriesByProduct.get(productId) ?? [];\n bucket.push({\n id: category.id,\n name: category.name ?? null,\n treePath: category.treePath ?? null,\n parentId,\n parentName,\n });\n categoriesByProduct.set(productId, bucket);\n }\n\n const tagAssignments = await findWithDecryption(\n em,\n CatalogProductTagAssignment,\n { product: { $in: productIds } },\n { populate: [\"tag\"] },\n {\n tenantId: ctx.auth?.tenantId ?? null,\n organizationId: ctx.auth?.orgId ?? null,\n },\n );\n const tagsByProduct = new Map<string, string[]>();\n for (const assignment of tagAssignments) {\n const productId =\n typeof assignment.product === \"string\"\n ? assignment.product\n : (assignment.product?.id ?? null);\n if (!productId) continue;\n const tag =\n typeof assignment.tag === \"string\" ? null : (assignment.tag ?? null);\n if (!tag) continue;\n const label =\n typeof tag.label === \"string\" && tag.label.trim().length\n ? tag.label\n : null;\n if (!label) continue;\n const bucket = tagsByProduct.get(productId) ?? [];\n bucket.push(label);\n tagsByProduct.set(productId, bucket);\n }\n\n const variants = await findWithDecryption(\n em,\n CatalogProductVariant,\n { product: { $in: productIds }, deletedAt: null, ...scope },\n { fields: [\"id\", \"product\"] },\n scope,\n );\n const variantToProduct = new Map<string, string>();\n for (const variant of variants) {\n const productId =\n typeof variant.product === \"string\"\n ? variant.product\n : (variant.product?.id ?? null);\n if (!productId) continue;\n variantToProduct.set(variant.id, productId);\n }\n const variantIds = Array.from(variantToProduct.keys());\n const priceWhere =\n variantIds.length > 0\n ? {\n $or: [\n { product: { $in: productIds } },\n { variant: { $in: variantIds } },\n ],\n }\n : { product: { $in: productIds } };\n const priceRows = await findWithDecryption<CatalogProductPrice>(\n em,\n CatalogProductPrice,\n { ...priceWhere, ...scope },\n { populate: [\"offer\", \"variant\", \"product\", \"priceKind\"] },\n scope,\n );\n const pricesByProduct = new Map<string, PriceRow[]>();\n for (const price of priceRows) {\n let productId: string | null = null;\n if (price.product) {\n productId =\n typeof price.product === \"string\"\n ? price.product\n : (price.product?.id ?? null);\n } else if (price.variant) {\n const variantId =\n typeof price.variant === \"string\" ? price.variant : price.variant.id;\n productId = variantToProduct.get(variantId) ?? null;\n }\n if (!productId) continue;\n const entry = pricesByProduct.get(productId) ?? [];\n entry.push(price);\n pricesByProduct.set(productId, entry);\n }\n\n const requestQuantityUnitKey = toUnitLookupKey(\n ctx.query.quantityUnit,\n );\n const conversionsByProduct = new Map<string, Map<string, number>>();\n const conversionOrganizationId =\n ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null;\n const conversionTenantId = ctx.auth?.tenantId ?? null;\n if (\n requestQuantityUnitKey &&\n productIds.length &&\n conversionOrganizationId &&\n conversionTenantId\n ) {\n const conversionRows = await findWithDecryption(\n em,\n CatalogProductUnitConversion,\n {\n product: { $in: productIds },\n organizationId: conversionOrganizationId,\n tenantId: conversionTenantId,\n deletedAt: null,\n isActive: true,\n },\n { fields: [\"id\", \"product\", \"unitCode\", \"toBaseFactor\"] },\n { organizationId: conversionOrganizationId, tenantId: conversionTenantId },\n );\n for (const row of conversionRows) {\n const productId =\n typeof row.product === \"string\"\n ? row.product\n : (row.product?.id ?? null);\n const unitKey = toUnitLookupKey(row.unitCode);\n const factor = Number(row.toBaseFactor);\n if (!productId || !unitKey || !Number.isFinite(factor) || factor <= 0)\n continue;\n const bucket =\n conversionsByProduct.get(productId) ?? new Map<string, number>();\n bucket.set(unitKey, factor);\n conversionsByProduct.set(productId, bucket);\n }\n }\n\n const channelFilterIds = parseIdList(ctx.query.channelIds);\n const channelContext =\n ctx.query.channelId ??\n (channelFilterIds.length === 1 ? channelFilterIds[0] : null);\n const pricingContext = buildPricingContext(ctx.query, channelContext);\n const pricingService = ctx.container.resolve<CatalogPricingService>(\n \"catalogPricingService\",\n );\n\n const pricingEntries: Array<{ rows: PriceRow[]; context: PricingContext } | null> = [];\n for (const item of items) {\n const id = typeof item.id === \"string\" ? item.id : null;\n if (!id) {\n pricingEntries.push(null);\n continue;\n }\n const offerEntries = offersByProduct.get(id) ?? [];\n item.offers = offerEntries;\n const channelIds = Array.from(\n new Set(\n offerEntries\n .map((offer) =>\n typeof offer.channelId === \"string\" ? offer.channelId : null,\n )\n .filter((channelId): channelId is string => !!channelId),\n ),\n );\n item.channelIds = channelIds;\n const categories = categoriesByProduct.get(id) ?? [];\n item.categories = categories;\n item.categoryIds = categories.map((category) => category.id);\n item.tags = tagsByProduct.get(id) ?? [];\n if (item.is_quote_only === true) {\n item.pricing = null;\n pricingEntries.push(null);\n continue;\n }\n const priceCandidates = pricesByProduct.get(id) ?? [];\n const normalizedQuantityForPricing = (() => {\n if (!requestQuantityUnitKey) return pricingContext.quantity;\n const baseUnit = toUnitLookupKey(item.default_unit);\n if (!baseUnit || requestQuantityUnitKey === baseUnit)\n return pricingContext.quantity;\n const productConversions = conversionsByProduct.get(id);\n const factor = productConversions?.get(requestQuantityUnitKey) ?? null;\n if (!factor || !Number.isFinite(factor) || factor <= 0) {\n logger.debug('catalog.products invalid conversion factor', { productId: id, unit: requestQuantityUnitKey, factor });\n return pricingContext.quantity;\n }\n const normalized = pricingContext.quantity * factor;\n return Number.isFinite(normalized) && normalized > 0\n ? normalized\n : pricingContext.quantity;\n })();\n const channelScopedContext =\n pricingContext.channelId || channelIds.length !== 1\n ? pricingContext\n : { ...pricingContext, channelId: channelIds[0] };\n pricingEntries.push({\n rows: priceCandidates,\n context: { ...channelScopedContext, quantity: normalizedQuantityForPricing },\n });\n }\n\n const resolveInputs: Array<{ rows: PriceRow[]; context: PricingContext }> = [];\n const resolveIndices: number[] = [];\n for (let i = 0; i < pricingEntries.length; i++) {\n if (pricingEntries[i] !== null) {\n resolveInputs.push(pricingEntries[i]!);\n resolveIndices.push(i);\n }\n }\n const priceResults = await pricingService.resolvePriceMany(resolveInputs);\n\n for (let i = 0; i < resolveIndices.length; i++) {\n const item = items[resolveIndices[i]];\n const best = priceResults[i];\n if (best) {\n item.pricing = {\n kind: resolvePriceKindCode(best),\n price_kind_id:\n typeof best.priceKind === \"string\"\n ? best.priceKind\n : (best.priceKind?.id ?? null),\n price_kind_code: resolvePriceKindCode(best),\n currency_code: best.currencyCode,\n unit_price_net: best.unitPriceNet,\n unit_price_gross: best.unitPriceGross,\n min_quantity: best.minQuantity,\n max_quantity: best.maxQuantity ?? null,\n tax_rate: best.taxRate ?? null,\n tax_amount: best.taxAmount ?? null,\n scope: {\n variant_id: resolvePriceVariantId(best),\n offer_id: resolvePriceOfferId(best),\n channel_id: resolvePriceChannelId(best),\n user_id: best.userId ?? null,\n user_group_id: best.userGroupId ?? null,\n customer_id: best.customerId ?? null,\n customer_group_id: best.customerGroupId ?? null,\n },\n };\n } else {\n item.pricing = null;\n }\n }\n } catch (error) {\n logger.error('decorateProductsAfterList Failed to load unit conversions', { err: error });\n }\n\n const searchTerm = ctx.query.search ? sanitizeSearchTerm(ctx.query.search) : null;\n if (searchTerm && !ctx.query.sortField && Array.isArray(payload.items)) {\n const needle = searchTerm.toLowerCase();\n payload.items.sort((a, b) => {\n const scoreA = scoreProductSearchRelevance(needle, a.title, a.sku);\n const scoreB = scoreProductSearchRelevance(needle, b.title, b.sku);\n if (scoreA !== scoreB) return scoreA - scoreB;\n return (a.title ?? \"\").localeCompare(b.title ?? \"\");\n });\n }\n}\n\nexport function scoreProductSearchRelevance(\n needle: string,\n title: string | null | undefined,\n sku: string | null | undefined,\n): number {\n const t = (title ?? \"\").toLowerCase();\n const s = (sku ?? \"\").toLowerCase();\n if (t === needle) return 0;\n if (s === needle) return 1;\n if (t.startsWith(needle)) return 2;\n if (s.startsWith(needle)) return 3;\n if (t.includes(needle)) return 4;\n if (s.includes(needle)) return 5;\n return 6;\n}\n\nconst crud = makeCrudRoute({\n metadata: routeMetadata,\n orm: {\n entity: CatalogProduct,\n idField: \"id\",\n orgField: \"organizationId\",\n tenantField: \"tenantId\",\n softDeleteField: \"deletedAt\",\n },\n indexer: {\n entityType: E.catalog.catalog_product,\n },\n enrichers: {\n entityId: E.catalog.catalog_product,\n },\n list: {\n schema: listSchema,\n entityId: E.catalog.catalog_product,\n fields: [\n F.id,\n F.title,\n F.subtitle,\n F.description,\n F.sku,\n F.handle,\n \"tax_rate_id\",\n \"tax_rate\",\n F.product_type,\n F.status_entry_id,\n F.primary_currency_code,\n F.default_unit,\n \"default_sales_unit\",\n \"default_sales_unit_quantity\",\n \"uom_rounding_scale\",\n \"uom_rounding_mode\",\n \"unit_price_enabled\",\n \"unit_price_reference_unit\",\n \"unit_price_base_quantity\",\n F.default_media_id,\n F.default_media_url,\n F.weight_value,\n F.weight_unit,\n F.dimensions,\n F.is_configurable,\n F.is_active,\n \"country_of_origin_code\",\n \"pkwiu_code\",\n \"cn_code\",\n \"hs_code\",\n \"tax_classification_code\",\n \"gtu_codes\",\n \"age_min\",\n \"is_excise_good\",\n \"excise_category\",\n \"requires_prescription\",\n \"hazmat_class\",\n \"un_number\",\n \"hazmat_packing_group\",\n \"contains_lithium_battery\",\n \"launch_at\",\n \"end_of_life_at\",\n \"available_from\",\n \"available_until\",\n \"min_order_qty\",\n \"max_order_qty\",\n \"order_qty_increment\",\n \"requires_shipping\",\n \"is_quote_only\",\n \"seo_title\",\n \"seo_description\",\n \"canonical_url\",\n F.metadata,\n \"custom_fieldset_code\",\n \"option_schema_id\",\n F.created_at,\n F.updated_at,\n ],\n decorateCustomFields: { entityIds: [E.catalog.catalog_product] },\n sortFieldMap: {\n title: F.title,\n sku: F.sku,\n createdAt: F.created_at,\n updatedAt: F.updated_at,\n },\n buildFilters: buildProductFilters,\n transformItem: (item: ProductListItem | null | undefined) => {\n if (!item) return item;\n const normalized = { ...item };\n const cfEntries = extractAllCustomFieldEntries(item);\n for (const key of Object.keys(normalized)) {\n if (key.startsWith(\"cf:\")) {\n delete normalized[key];\n }\n }\n const defaultUnit = canonicalizeUnitCode(normalized.default_unit) ?? null;\n const defaultSalesUnit =\n canonicalizeUnitCode(normalized.default_sales_unit) ?? null;\n const unitPriceReferenceUnit =\n canonicalizeUnitCode(normalized.unit_price_reference_unit) ?? null;\n return {\n ...normalized,\n default_unit: defaultUnit,\n default_sales_unit: defaultSalesUnit,\n unit_price_reference_unit: unitPriceReferenceUnit,\n ...cfEntries,\n unit_price: {\n enabled: Boolean(normalized.unit_price_enabled),\n reference_unit: unitPriceReferenceUnit,\n base_quantity: normalized.unit_price_base_quantity ?? null,\n },\n };\n },\n },\n hooks: {\n afterList: decorateProductsAfterList,\n },\n actions: {\n create: {\n commandId: \"catalog.products.create\",\n schema: rawBodySchema,\n mapInput: async ({ raw, ctx }) => {\n const { translate } = await resolveTranslations();\n const parsed = parseScopedCommandInput(\n productCreateSchema,\n raw ?? {},\n ctx,\n translate,\n );\n const { base, custom } = splitCustomFieldPayload(parsed);\n return Object.keys(custom).length\n ? { ...base, customFields: custom }\n : base;\n },\n response: ({ result }) => ({\n id: result?.productId ?? result?.id ?? null,\n }),\n status: 201,\n },\n update: {\n commandId: \"catalog.products.update\",\n schema: rawBodySchema,\n mapInput: async ({ raw, ctx }) => {\n const { translate } = await resolveTranslations();\n const parsed = parseScopedCommandInput(\n productUpdateSchema,\n raw ?? {},\n ctx,\n translate,\n );\n const { base, custom } = splitCustomFieldPayload(parsed);\n return Object.keys(custom).length\n ? { ...base, customFields: custom }\n : base;\n },\n response: ({ result }) => ({\n ok: true,\n updatedAt: result?.updatedAt ?? null,\n }),\n },\n delete: {\n commandId: \"catalog.products.delete\",\n schema: rawBodySchema,\n mapInput: async ({ parsed, ctx }) => {\n const { translate } = await resolveTranslations();\n const id = resolveCrudRecordId(parsed, ctx, translate);\n if (!id)\n throw new CrudHttpError(400, {\n error: translate(\n \"catalog.errors.id_required\",\n \"Product id is required.\",\n ),\n });\n return { id };\n },\n response: () => ({ ok: true }),\n },\n },\n});\n\nexport const GET = crud.GET;\nexport const POST = crud.POST;\nexport const PUT = crud.PUT;\nexport const DELETE = crud.DELETE;\n\nconst productListItemSchema = z.object({\n id: z.string().uuid(),\n title: z.string().nullable().optional(),\n subtitle: z.string().nullable().optional(),\n description: z.string().nullable().optional(),\n sku: z.string().nullable().optional(),\n handle: z.string().nullable().optional(),\n product_type: z.string().nullable().optional(),\n status_entry_id: z.string().uuid().nullable().optional(),\n primary_currency_code: z.string().nullable().optional(),\n default_unit: z.string().nullable().optional(),\n default_sales_unit: z.string().nullable().optional(),\n default_sales_unit_quantity: z.number().nullable().optional(),\n uom_rounding_scale: z.number().nullable().optional(),\n uom_rounding_mode: z.enum([\"half_up\", \"down\", \"up\"]).nullable().optional(),\n unit_price_enabled: z.boolean().nullable().optional(),\n unit_price_reference_unit: z\n .enum([\"kg\", \"l\", \"m2\", \"m3\", \"pc\"])\n .nullable()\n .optional(),\n unit_price_base_quantity: z.number().nullable().optional(),\n unit_price: z\n .object({\n enabled: z.boolean(),\n reference_unit: z.enum([\"kg\", \"l\", \"m2\", \"m3\", \"pc\"]).nullable(),\n base_quantity: z.number().nullable(),\n })\n .optional(),\n default_media_id: z.string().uuid().nullable().optional(),\n default_media_url: z.string().nullable().optional(),\n weight_value: z.number().nullable().optional(),\n weight_unit: z.string().nullable().optional(),\n dimensions: z.record(z.string(), z.unknown()).nullable().optional(),\n is_configurable: z.boolean().nullable().optional(),\n is_active: z.boolean().nullable().optional(),\n country_of_origin_code: z.string().nullable().optional(),\n pkwiu_code: z.string().nullable().optional(),\n cn_code: z.string().nullable().optional(),\n hs_code: z.string().nullable().optional(),\n tax_classification_code: z.string().nullable().optional(),\n gtu_codes: z.array(z.string()).nullable().optional(),\n age_min: z.number().nullable().optional(),\n is_excise_good: z.boolean().nullable().optional(),\n excise_category: z.string().nullable().optional(),\n requires_prescription: z.boolean().nullable().optional(),\n hazmat_class: z.string().nullable().optional(),\n un_number: z.string().nullable().optional(),\n hazmat_packing_group: z.string().nullable().optional(),\n contains_lithium_battery: z.boolean().nullable().optional(),\n launch_at: z.string().nullable().optional(),\n end_of_life_at: z.string().nullable().optional(),\n available_from: z.string().nullable().optional(),\n available_until: z.string().nullable().optional(),\n min_order_qty: z.number().nullable().optional(),\n max_order_qty: z.number().nullable().optional(),\n order_qty_increment: z.number().nullable().optional(),\n requires_shipping: z.boolean().nullable().optional(),\n is_quote_only: z.boolean().nullable().optional(),\n seo_title: z.string().nullable().optional(),\n seo_description: z.string().nullable().optional(),\n canonical_url: z.string().nullable().optional(),\n metadata: z.record(z.string(), z.unknown()).nullable().optional(),\n custom_fieldset_code: z.string().nullable().optional(),\n option_schema_id: z.string().uuid().nullable().optional(),\n created_at: z.string().nullable().optional(),\n updated_at: z.string().nullable().optional(),\n offers: z.array(z.record(z.string(), z.unknown())).optional(),\n channelIds: z.array(z.string()).optional(),\n categories: z.array(z.record(z.string(), z.unknown())).optional(),\n categoryIds: z.array(z.string()).optional(),\n tags: z.array(z.string()).optional(),\n pricing: z.record(z.string(), z.unknown()).nullable().optional(),\n});\n\nexport const openApi = createCatalogCrudOpenApi({\n resourceName: \"Product\",\n pluralName: \"Products\",\n querySchema: listSchema,\n listResponseSchema: createPagedListResponseSchema(productListItemSchema),\n create: {\n schema: productCreateSchema,\n description: \"Creates a new product in the catalog.\",\n },\n update: {\n schema: productUpdateSchema,\n responseSchema: defaultOkResponseSchema.extend({\n updatedAt: z.string().nullable().optional(),\n }),\n description: \"Updates an existing product by id.\",\n },\n del: {\n schema: z.object({ id: z.string().uuid() }),\n responseSchema: defaultOkResponseSchema,\n description: \"Deletes a product by id.\",\n },\n});\n"],
5
- "mappings": "AAAA,SAAS,SAAS;AAElB,SAAS,WAAW;AACpB,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AAEtC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB,2BAA2B;AAC7D,SAAS,+BAA+B;AACxC,SAAS,SAAS;AAClB,YAAY,OAAO;AACnB,SAAS,kBAAkB,0BAA0B;AAErD,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AACnC,SAAS,iCAAiC;AAC1C,SAAS,gDAAgD;AACzD;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB,uBAAuB;AACtD,SAAS,oBAAoB;AAE7B,MAAM,SAAS,aAAa,SAAS;AACrC,MAAM,gBAAgB,EAAE,OAAO,CAAC,CAAC,EAAE,YAAY;AAE/C,MAAM,aACJ;AAEF,MAAM,aAAa,EAChB,OAAO;AAAA,EACN,MAAM,EAAE,OAAO,OAAO,EAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;AAAA,EAC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AAAA,EAC3C,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EAC3C,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,EAAE,SAAS;AAAA,EAC5D,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EACzC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,EAAE,SAAS;AAAA,EAChE,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EAC1C,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EACnC,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,EAAE,SAAS,EAAE,SAAS;AACjE,CAAC;AAEM,MAAM,UAAU,yBAAyB;AAAA,EAC9C,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,oBAAoB,8BAA8B,qBAAqB;AAAA,EACvE,QAAQ;AAAA,IACN,QAAQ;AAAA,IACR,aAAa;AAAA,EACf;AAAA,EACA,QAAQ;AAAA,IACN,QAAQ;AAAA,IACR,gBAAgB,wBAAwB,OAAO;AAAA,MAC7C,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,IAC5C,CAAC;AAAA,IACD,aAAa;AAAA,EACf;AAAA,EACA,KAAK;AAAA,IACH,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAAA,IAC1C,gBAAgB;AAAA,IAChB,aAAa;AAAA,EACf;AACF,CAAC;",
6
- "names": ["raw", "channelIds"]
4
+ "sourcesContent": ["import { z } from \"zod\";\nimport type { EntityManager } from \"@mikro-orm/postgresql\";\nimport { makeCrudRoute } from \"@open-mercato/shared/lib/crud/factory\";\nimport { CrudHttpError } from \"@open-mercato/shared/lib/crud/errors\";\nimport { extractAllCustomFieldEntries } from \"@open-mercato/shared/lib/crud/custom-fields\";\nimport { resolveTranslations } from \"@open-mercato/shared/lib/i18n/server\";\nimport {\n CatalogOffer,\n CatalogProduct,\n CatalogProductCategory,\n CatalogProductCategoryAssignment,\n CatalogProductPrice,\n CatalogProductUnitConversion,\n CatalogProductVariant,\n CatalogProductTagAssignment,\n} from \"../../data/entities\";\nimport type { CatalogProductType } from \"../../data/types\";\nimport {\n productCreateSchema,\n productUpdateSchema,\n} from \"../../data/validators\";\nimport { parseScopedCommandInput, resolveCrudRecordId } from \"../utils\";\nimport { splitCustomFieldPayload } from \"@open-mercato/shared/lib/crud/custom-fields\";\nimport { E } from \"#generated/entities.ids.generated\";\nimport * as F from \"#generated/entities/catalog_product\";\nimport { sanitizeSearchTerm } from \"../helpers\";\nimport type { CrudCtx } from \"@open-mercato/shared/lib/crud/factory\";\nimport { buildScopedWhere } from \"@open-mercato/shared/lib/api/crud\";\nimport {\n resolvePriceChannelId,\n resolvePriceOfferId,\n resolvePriceVariantId,\n resolvePriceKindCode,\n type PricingContext,\n type PriceRow,\n} from \"../../lib/pricing\";\nimport type { CatalogPricingService } from \"../../services/catalogPricingService\";\nimport { SalesChannel } from \"@open-mercato/core/modules/sales/data/entities\";\nimport {\n createCatalogCrudOpenApi,\n createPagedListResponseSchema,\n defaultOkResponseSchema,\n} from \"../openapi\";\nimport { findWithDecryption } from \"@open-mercato/shared/lib/encryption/find\";\nimport { canonicalizeUnitCode, toUnitLookupKey } from \"../../lib/unitCodes\";\nimport {\n attachProductListOmnibusBlocks,\n type OmnibusProductListEntry,\n} from \"../../lib/omnibusProductListEnrichment\";\nimport { omnibusBlockSchema, type OmnibusBlock } from \"../../lib/omnibusTypes\";\nimport {\n buildProductFilters,\n catalogProductFilterQuerySchema,\n parseIdList,\n scoreProductSearchRelevance,\n type CatalogProductFilterQuery,\n} from \"../../lib/productFilters\";\nimport { createLogger } from '@open-mercato/shared/lib/logger'\nimport { getTelemetryRuntime } from '@open-mercato/shared/lib/telemetry/runtime'\n\nconst logger = createLogger('catalog')\nconst rawBodySchema = z.object({}).passthrough();\n\nconst listSchema = catalogProductFilterQuerySchema;\n\ntype ProductsQuery = CatalogProductFilterQuery;\n\nconst routeMetadata = {\n GET: { requireAuth: true, requireFeatures: [\"catalog.products.view\"] },\n POST: { requireAuth: true, requireFeatures: [\"catalog.products.manage\"] },\n PUT: { requireAuth: true, requireFeatures: [\"catalog.products.manage\"] },\n DELETE: { requireAuth: true, requireFeatures: [\"catalog.products.manage\"] },\n};\n\nexport const metadata = routeMetadata;\n\nexport {\n buildProductFilters,\n parseIdList,\n scoreProductSearchRelevance,\n} from \"../../lib/productFilters\";\n\nexport function buildPricingContext(\n query: ProductsQuery,\n channelFallback: string | null,\n): PricingContext {\n const quantity = Number.isFinite(Number(query.quantity))\n ? Number(query.quantity)\n : 1;\n const parsedDate = query.priceDate ? new Date(query.priceDate) : new Date();\n const channelId = query.channelId ?? channelFallback ?? null;\n return {\n channelId,\n offerId: query.offerId ?? null,\n userId: query.userId ?? null,\n userGroupId: query.userGroupId ?? null,\n customerId: query.customerId ?? null,\n customerGroupId: query.customerGroupId ?? null,\n quantity: Number.isFinite(quantity) && quantity > 0 ? quantity : 1,\n date: Number.isNaN(parsedDate.getTime()) ? new Date() : parsedDate,\n };\n}\n\ntype ProductListItem = Record<string, unknown> & {\n id?: string;\n title?: string | null;\n subtitle?: string | null;\n description?: string | null;\n sku?: string | null;\n handle?: string | null;\n product_type?: CatalogProductType | null;\n primary_currency_code?: string | null;\n default_unit?: string | null;\n default_sales_unit?: string | null;\n default_sales_unit_quantity?: number | null;\n uom_rounding_scale?: number | null;\n uom_rounding_mode?: \"half_up\" | \"down\" | \"up\" | null;\n unit_price_enabled?: boolean | null;\n unit_price_reference_unit?: \"kg\" | \"l\" | \"m2\" | \"m3\" | \"pc\" | null;\n unit_price_base_quantity?: number | null;\n default_media_id?: string | null;\n default_media_url?: string | null;\n weight_value?: string | null;\n weightValue?: string | null;\n weight_unit?: string | null;\n weightUnit?: string | null;\n dimensions?: Record<string, unknown> | null;\n custom_fieldset_code?: string | null;\n option_schema_id?: string | null;\n offers?: Array<Record<string, unknown>>;\n channelIds?: string[];\n categories?: Array<Record<string, unknown>>;\n categoryIds?: string[];\n tags?: string[];\n omnibus?: OmnibusBlock;\n};\n\nasync function decorateProductsAfterList(\n payload: { items?: ProductListItem[] },\n ctx: CrudCtx & { query: ProductsQuery },\n): Promise<void> {\n const items = Array.isArray(payload?.items) ? payload.items : [];\n if (!items.length) return;\n const productIds = items\n .map((item) => (typeof item.id === \"string\" ? item.id : null))\n .filter((id): id is string => !!id);\n if (!productIds.length) return;\n try {\n const em = (ctx.container.resolve(\"em\") as EntityManager).fork();\n const scope = {\n organizationId: ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null,\n tenantId: ctx.auth?.tenantId ?? null,\n };\n const offers = await findWithDecryption(\n em,\n CatalogOffer,\n { product: { $in: productIds }, deletedAt: null, ...scope },\n { orderBy: { createdAt: \"asc\" } },\n scope,\n );\n const channelIds = Array.from(\n new Set(\n offers\n .map((offer) => offer.channelId)\n .filter(\n (id): id is string => typeof id === \"string\" && id.length > 0,\n ),\n ),\n );\n const channelLookup = new Map<\n string,\n { name?: string | null; code?: string | null }\n >();\n if (channelIds.length) {\n const scopedChannelsWhere = buildScopedWhere(\n { id: { $in: channelIds } },\n {\n organizationId: ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null,\n organizationIds: Array.isArray(ctx.organizationIds)\n ? ctx.organizationIds\n : undefined,\n tenantId: ctx.auth?.tenantId ?? null,\n },\n );\n const channels = await findWithDecryption(em, SalesChannel, scopedChannelsWhere, {\n fields: [\"id\", \"name\", \"code\"],\n });\n for (const channel of channels) {\n channelLookup.set(channel.id, {\n name: channel.name,\n code: channel.code ?? null,\n });\n }\n }\n const offersByProduct = new Map<string, Array<Record<string, unknown>>>();\n for (const offer of offers) {\n const productId =\n typeof offer.product === \"string\"\n ? offer.product\n : (offer.product?.id ?? null);\n if (!productId) continue;\n const channelInfo = channelLookup.get(offer.channelId);\n const entry = offersByProduct.get(productId) ?? [];\n entry.push({\n id: offer.id,\n channelId: offer.channelId,\n channelName: channelInfo?.name ?? null,\n channelCode: channelInfo?.code ?? null,\n title: offer.title,\n description: offer.description ?? null,\n isActive: offer.isActive,\n defaultMediaId: offer.defaultMediaId ?? null,\n defaultMediaUrl: offer.defaultMediaUrl ?? null,\n metadata: offer.metadata ?? null,\n updatedAt:\n offer.updatedAt instanceof Date\n ? offer.updatedAt.toISOString()\n : (typeof offer.updatedAt === \"string\" ? offer.updatedAt : null),\n });\n offersByProduct.set(productId, entry);\n }\n\n const categoryAssignments = await findWithDecryption(\n em,\n CatalogProductCategoryAssignment,\n { product: { $in: productIds }, ...scope },\n { populate: [\"category\"], orderBy: { position: \"asc\" } },\n scope,\n );\n const parentIds = new Set<string>();\n for (const assignment of categoryAssignments) {\n const category =\n typeof assignment.category === \"string\"\n ? null\n : (assignment.category ?? null);\n if (!category) continue;\n const parentId = category.parentId ?? null;\n if (parentId) parentIds.add(parentId);\n }\n const parentCategories = parentIds.size\n ? await findWithDecryption(\n em,\n CatalogProductCategory,\n { id: { $in: Array.from(parentIds) }, ...scope },\n { fields: [\"id\", \"name\"] },\n scope,\n )\n : [];\n const parentNameById = new Map<string, string | null>();\n for (const parent of parentCategories) {\n parentNameById.set(parent.id, parent.name ?? null);\n }\n const categoriesByProduct = new Map<\n string,\n Array<{\n id: string;\n name: string | null;\n treePath: string | null;\n parentId: string | null;\n parentName: string | null;\n }>\n >();\n for (const assignment of categoryAssignments) {\n const productId =\n typeof assignment.product === \"string\"\n ? assignment.product\n : (assignment.product?.id ?? null);\n if (!productId) continue;\n const category =\n typeof assignment.category === \"string\"\n ? null\n : (assignment.category ?? null);\n if (!category) continue;\n const parentId = category.parentId ?? null;\n const parentName = parentId\n ? (parentNameById.get(parentId) ?? null)\n : null;\n const bucket = categoriesByProduct.get(productId) ?? [];\n bucket.push({\n id: category.id,\n name: category.name ?? null,\n treePath: category.treePath ?? null,\n parentId,\n parentName,\n });\n categoriesByProduct.set(productId, bucket);\n }\n\n const tagAssignments = await findWithDecryption(\n em,\n CatalogProductTagAssignment,\n { product: { $in: productIds } },\n { populate: [\"tag\"] },\n {\n tenantId: ctx.auth?.tenantId ?? null,\n organizationId: ctx.auth?.orgId ?? null,\n },\n );\n const tagsByProduct = new Map<string, string[]>();\n for (const assignment of tagAssignments) {\n const productId =\n typeof assignment.product === \"string\"\n ? assignment.product\n : (assignment.product?.id ?? null);\n if (!productId) continue;\n const tag =\n typeof assignment.tag === \"string\" ? null : (assignment.tag ?? null);\n if (!tag) continue;\n const label =\n typeof tag.label === \"string\" && tag.label.trim().length\n ? tag.label\n : null;\n if (!label) continue;\n const bucket = tagsByProduct.get(productId) ?? [];\n bucket.push(label);\n tagsByProduct.set(productId, bucket);\n }\n\n const variants = await findWithDecryption(\n em,\n CatalogProductVariant,\n { product: { $in: productIds }, deletedAt: null, ...scope },\n { fields: [\"id\", \"product\"] },\n scope,\n );\n const variantToProduct = new Map<string, string>();\n for (const variant of variants) {\n const productId =\n typeof variant.product === \"string\"\n ? variant.product\n : (variant.product?.id ?? null);\n if (!productId) continue;\n variantToProduct.set(variant.id, productId);\n }\n const variantIds = Array.from(variantToProduct.keys());\n const priceWhere =\n variantIds.length > 0\n ? {\n $or: [\n { product: { $in: productIds } },\n { variant: { $in: variantIds } },\n ],\n }\n : { product: { $in: productIds } };\n const priceRows = await findWithDecryption<CatalogProductPrice>(\n em,\n CatalogProductPrice,\n { ...priceWhere, ...scope },\n { populate: [\"offer\", \"variant\", \"product\", \"priceKind\"] },\n scope,\n );\n const pricesByProduct = new Map<string, PriceRow[]>();\n for (const price of priceRows) {\n let productId: string | null = null;\n if (price.product) {\n productId =\n typeof price.product === \"string\"\n ? price.product\n : (price.product?.id ?? null);\n } else if (price.variant) {\n const variantId =\n typeof price.variant === \"string\" ? price.variant : price.variant.id;\n productId = variantToProduct.get(variantId) ?? null;\n }\n if (!productId) continue;\n const entry = pricesByProduct.get(productId) ?? [];\n entry.push(price);\n pricesByProduct.set(productId, entry);\n }\n\n const requestQuantityUnitKey = toUnitLookupKey(\n ctx.query.quantityUnit,\n );\n const conversionsByProduct = new Map<string, Map<string, number>>();\n const conversionOrganizationId =\n ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null;\n const conversionTenantId = ctx.auth?.tenantId ?? null;\n if (\n requestQuantityUnitKey &&\n productIds.length &&\n conversionOrganizationId &&\n conversionTenantId\n ) {\n const conversionRows = await findWithDecryption(\n em,\n CatalogProductUnitConversion,\n {\n product: { $in: productIds },\n organizationId: conversionOrganizationId,\n tenantId: conversionTenantId,\n deletedAt: null,\n isActive: true,\n },\n { fields: [\"id\", \"product\", \"unitCode\", \"toBaseFactor\"] },\n { organizationId: conversionOrganizationId, tenantId: conversionTenantId },\n );\n for (const row of conversionRows) {\n const productId =\n typeof row.product === \"string\"\n ? row.product\n : (row.product?.id ?? null);\n const unitKey = toUnitLookupKey(row.unitCode);\n const factor = Number(row.toBaseFactor);\n if (!productId || !unitKey || !Number.isFinite(factor) || factor <= 0)\n continue;\n const bucket =\n conversionsByProduct.get(productId) ?? new Map<string, number>();\n bucket.set(unitKey, factor);\n conversionsByProduct.set(productId, bucket);\n }\n }\n\n const channelFilterIds = parseIdList(ctx.query.channelIds);\n const channelContext =\n ctx.query.channelId ??\n (channelFilterIds.length === 1 ? channelFilterIds[0] : null);\n const pricingContext = buildPricingContext(ctx.query, channelContext);\n const pricingService = ctx.container.resolve<CatalogPricingService>(\n \"catalogPricingService\",\n );\n\n const pricingEntries: Array<{ rows: PriceRow[]; context: PricingContext } | null> = [];\n for (const item of items) {\n const id = typeof item.id === \"string\" ? item.id : null;\n if (!id) {\n pricingEntries.push(null);\n continue;\n }\n const offerEntries = offersByProduct.get(id) ?? [];\n item.offers = offerEntries;\n const channelIds = Array.from(\n new Set(\n offerEntries\n .map((offer) =>\n typeof offer.channelId === \"string\" ? offer.channelId : null,\n )\n .filter((channelId): channelId is string => !!channelId),\n ),\n );\n item.channelIds = channelIds;\n const categories = categoriesByProduct.get(id) ?? [];\n item.categories = categories;\n item.categoryIds = categories.map((category) => category.id);\n item.tags = tagsByProduct.get(id) ?? [];\n if (item.is_quote_only === true) {\n item.pricing = null;\n pricingEntries.push(null);\n continue;\n }\n const priceCandidates = pricesByProduct.get(id) ?? [];\n const normalizedQuantityForPricing = (() => {\n if (!requestQuantityUnitKey) return pricingContext.quantity;\n const baseUnit = toUnitLookupKey(item.default_unit);\n if (!baseUnit || requestQuantityUnitKey === baseUnit)\n return pricingContext.quantity;\n const productConversions = conversionsByProduct.get(id);\n const factor = productConversions?.get(requestQuantityUnitKey) ?? null;\n if (!factor || !Number.isFinite(factor) || factor <= 0) {\n logger.debug('catalog.products invalid conversion factor', { productId: id, unit: requestQuantityUnitKey, factor });\n return pricingContext.quantity;\n }\n const normalized = pricingContext.quantity * factor;\n return Number.isFinite(normalized) && normalized > 0\n ? normalized\n : pricingContext.quantity;\n })();\n const channelScopedContext =\n pricingContext.channelId || channelIds.length !== 1\n ? pricingContext\n : { ...pricingContext, channelId: channelIds[0] };\n pricingEntries.push({\n rows: priceCandidates,\n context: { ...channelScopedContext, quantity: normalizedQuantityForPricing },\n });\n }\n\n const resolveInputs: Array<{ rows: PriceRow[]; context: PricingContext }> = [];\n const resolveIndices: number[] = [];\n for (let i = 0; i < pricingEntries.length; i++) {\n if (pricingEntries[i] !== null) {\n resolveInputs.push(pricingEntries[i]!);\n resolveIndices.push(i);\n }\n }\n const priceResults = await pricingService.resolvePriceMany(resolveInputs);\n\n const omnibusEntries: OmnibusProductListEntry[] = [];\n for (let i = 0; i < resolveIndices.length; i++) {\n const item = items[resolveIndices[i]];\n const best = priceResults[i];\n if (best) {\n if (typeof item.id === \"string\") {\n omnibusEntries.push({\n item,\n productId: item.id,\n candidates: resolveInputs[i].rows,\n best,\n context: resolveInputs[i].context,\n });\n }\n item.pricing = {\n kind: resolvePriceKindCode(best),\n price_kind_id:\n typeof best.priceKind === \"string\"\n ? best.priceKind\n : (best.priceKind?.id ?? null),\n price_kind_code: resolvePriceKindCode(best),\n currency_code: best.currencyCode,\n unit_price_net: best.unitPriceNet,\n unit_price_gross: best.unitPriceGross,\n min_quantity: best.minQuantity,\n max_quantity: best.maxQuantity ?? null,\n tax_rate: best.taxRate ?? null,\n tax_amount: best.taxAmount ?? null,\n scope: {\n variant_id: resolvePriceVariantId(best),\n offer_id: resolvePriceOfferId(best),\n channel_id: resolvePriceChannelId(best),\n user_id: best.userId ?? null,\n user_group_id: best.userGroupId ?? null,\n customer_id: best.customerId ?? null,\n customer_group_id: best.customerGroupId ?? null,\n },\n };\n } else {\n item.pricing = null;\n }\n }\n\n try {\n await attachProductListOmnibusBlocks({\n em,\n container: ctx.container,\n tenantId: ctx.auth?.tenantId ?? null,\n entries: omnibusEntries,\n });\n } catch (error) {\n logger.error('decorateProductsAfterList failed to attach Omnibus blocks', { err: error });\n getTelemetryRuntime()?.reportError(error, {\n module: 'catalog',\n code: 'catalog.omnibus_product_list_failed',\n });\n }\n } catch (error) {\n logger.error('decorateProductsAfterList Failed to load unit conversions', { err: error });\n }\n\n const searchTerm = ctx.query.search ? sanitizeSearchTerm(ctx.query.search) : null;\n if (searchTerm && !ctx.query.sortField && Array.isArray(payload.items)) {\n const needle = searchTerm.toLowerCase();\n payload.items.sort((a, b) => {\n const scoreA = scoreProductSearchRelevance(needle, a.title, a.sku);\n const scoreB = scoreProductSearchRelevance(needle, b.title, b.sku);\n if (scoreA !== scoreB) return scoreA - scoreB;\n return (a.title ?? \"\").localeCompare(b.title ?? \"\");\n });\n }\n}\n\nconst crud = makeCrudRoute({\n metadata: routeMetadata,\n orm: {\n entity: CatalogProduct,\n idField: \"id\",\n orgField: \"organizationId\",\n tenantField: \"tenantId\",\n softDeleteField: \"deletedAt\",\n },\n indexer: {\n entityType: E.catalog.catalog_product,\n },\n enrichers: {\n entityId: E.catalog.catalog_product,\n },\n list: {\n schema: listSchema,\n entityId: E.catalog.catalog_product,\n fields: [\n F.id,\n F.title,\n F.subtitle,\n F.description,\n F.sku,\n F.handle,\n \"tax_rate_id\",\n \"tax_rate\",\n F.product_type,\n F.status_entry_id,\n F.primary_currency_code,\n F.default_unit,\n \"default_sales_unit\",\n \"default_sales_unit_quantity\",\n \"uom_rounding_scale\",\n \"uom_rounding_mode\",\n \"unit_price_enabled\",\n \"unit_price_reference_unit\",\n \"unit_price_base_quantity\",\n F.default_media_id,\n F.default_media_url,\n F.weight_value,\n F.weight_unit,\n F.dimensions,\n F.is_configurable,\n F.is_active,\n \"country_of_origin_code\",\n \"pkwiu_code\",\n \"cn_code\",\n \"hs_code\",\n \"tax_classification_code\",\n \"gtu_codes\",\n \"age_min\",\n \"is_excise_good\",\n \"excise_category\",\n \"requires_prescription\",\n \"hazmat_class\",\n \"un_number\",\n \"hazmat_packing_group\",\n \"contains_lithium_battery\",\n \"launch_at\",\n \"end_of_life_at\",\n \"available_from\",\n \"available_until\",\n \"min_order_qty\",\n \"max_order_qty\",\n \"order_qty_increment\",\n \"requires_shipping\",\n \"is_quote_only\",\n \"seo_title\",\n \"seo_description\",\n \"canonical_url\",\n F.metadata,\n \"custom_fieldset_code\",\n \"option_schema_id\",\n F.created_at,\n F.updated_at,\n ],\n decorateCustomFields: { entityIds: [E.catalog.catalog_product] },\n sortFieldMap: {\n title: F.title,\n sku: F.sku,\n createdAt: F.created_at,\n updatedAt: F.updated_at,\n },\n buildFilters: buildProductFilters,\n transformItem: (item: ProductListItem | null | undefined) => {\n if (!item) return item;\n const normalized = { ...item };\n const cfEntries = extractAllCustomFieldEntries(item);\n for (const key of Object.keys(normalized)) {\n if (key.startsWith(\"cf:\")) {\n delete normalized[key];\n }\n }\n const defaultUnit = canonicalizeUnitCode(normalized.default_unit) ?? null;\n const defaultSalesUnit =\n canonicalizeUnitCode(normalized.default_sales_unit) ?? null;\n const unitPriceReferenceUnit =\n canonicalizeUnitCode(normalized.unit_price_reference_unit) ?? null;\n return {\n ...normalized,\n default_unit: defaultUnit,\n default_sales_unit: defaultSalesUnit,\n unit_price_reference_unit: unitPriceReferenceUnit,\n ...cfEntries,\n unit_price: {\n enabled: Boolean(normalized.unit_price_enabled),\n reference_unit: unitPriceReferenceUnit,\n base_quantity: normalized.unit_price_base_quantity ?? null,\n },\n };\n },\n },\n hooks: {\n afterList: decorateProductsAfterList,\n },\n actions: {\n create: {\n commandId: \"catalog.products.create\",\n schema: rawBodySchema,\n mapInput: async ({ raw, ctx }) => {\n const { translate } = await resolveTranslations();\n const parsed = parseScopedCommandInput(\n productCreateSchema,\n raw ?? {},\n ctx,\n translate,\n );\n const { base, custom } = splitCustomFieldPayload(parsed);\n return Object.keys(custom).length\n ? { ...base, customFields: custom }\n : base;\n },\n response: ({ result }) => ({\n id: result?.productId ?? result?.id ?? null,\n }),\n status: 201,\n },\n update: {\n commandId: \"catalog.products.update\",\n schema: rawBodySchema,\n mapInput: async ({ raw, ctx }) => {\n const { translate } = await resolveTranslations();\n const parsed = parseScopedCommandInput(\n productUpdateSchema,\n raw ?? {},\n ctx,\n translate,\n );\n const { base, custom } = splitCustomFieldPayload(parsed);\n return Object.keys(custom).length\n ? { ...base, customFields: custom }\n : base;\n },\n response: ({ result }) => ({\n ok: true,\n updatedAt: result?.updatedAt ?? null,\n }),\n },\n delete: {\n commandId: \"catalog.products.delete\",\n schema: rawBodySchema,\n mapInput: async ({ parsed, ctx }) => {\n const { translate } = await resolveTranslations();\n const id = resolveCrudRecordId(parsed, ctx, translate);\n if (!id)\n throw new CrudHttpError(400, {\n error: translate(\n \"catalog.errors.id_required\",\n \"Product id is required.\",\n ),\n });\n return { id };\n },\n response: () => ({ ok: true }),\n },\n },\n});\n\nexport const GET = crud.GET;\nexport const POST = crud.POST;\nexport const PUT = crud.PUT;\nexport const DELETE = crud.DELETE;\n\nconst productListItemSchema = z.object({\n id: z.string().uuid(),\n title: z.string().nullable().optional(),\n subtitle: z.string().nullable().optional(),\n description: z.string().nullable().optional(),\n sku: z.string().nullable().optional(),\n handle: z.string().nullable().optional(),\n product_type: z.string().nullable().optional(),\n status_entry_id: z.string().uuid().nullable().optional(),\n primary_currency_code: z.string().nullable().optional(),\n default_unit: z.string().nullable().optional(),\n default_sales_unit: z.string().nullable().optional(),\n default_sales_unit_quantity: z.number().nullable().optional(),\n uom_rounding_scale: z.number().nullable().optional(),\n uom_rounding_mode: z.enum([\"half_up\", \"down\", \"up\"]).nullable().optional(),\n unit_price_enabled: z.boolean().nullable().optional(),\n unit_price_reference_unit: z\n .enum([\"kg\", \"l\", \"m2\", \"m3\", \"pc\"])\n .nullable()\n .optional(),\n unit_price_base_quantity: z.number().nullable().optional(),\n unit_price: z\n .object({\n enabled: z.boolean(),\n reference_unit: z.enum([\"kg\", \"l\", \"m2\", \"m3\", \"pc\"]).nullable(),\n base_quantity: z.number().nullable(),\n })\n .optional(),\n default_media_id: z.string().uuid().nullable().optional(),\n default_media_url: z.string().nullable().optional(),\n weight_value: z.number().nullable().optional(),\n weight_unit: z.string().nullable().optional(),\n dimensions: z.record(z.string(), z.unknown()).nullable().optional(),\n is_configurable: z.boolean().nullable().optional(),\n is_active: z.boolean().nullable().optional(),\n country_of_origin_code: z.string().nullable().optional(),\n pkwiu_code: z.string().nullable().optional(),\n cn_code: z.string().nullable().optional(),\n hs_code: z.string().nullable().optional(),\n tax_classification_code: z.string().nullable().optional(),\n gtu_codes: z.array(z.string()).nullable().optional(),\n age_min: z.number().nullable().optional(),\n is_excise_good: z.boolean().nullable().optional(),\n excise_category: z.string().nullable().optional(),\n requires_prescription: z.boolean().nullable().optional(),\n hazmat_class: z.string().nullable().optional(),\n un_number: z.string().nullable().optional(),\n hazmat_packing_group: z.string().nullable().optional(),\n contains_lithium_battery: z.boolean().nullable().optional(),\n launch_at: z.string().nullable().optional(),\n end_of_life_at: z.string().nullable().optional(),\n available_from: z.string().nullable().optional(),\n available_until: z.string().nullable().optional(),\n min_order_qty: z.number().nullable().optional(),\n max_order_qty: z.number().nullable().optional(),\n order_qty_increment: z.number().nullable().optional(),\n requires_shipping: z.boolean().nullable().optional(),\n is_quote_only: z.boolean().nullable().optional(),\n seo_title: z.string().nullable().optional(),\n seo_description: z.string().nullable().optional(),\n canonical_url: z.string().nullable().optional(),\n metadata: z.record(z.string(), z.unknown()).nullable().optional(),\n custom_fieldset_code: z.string().nullable().optional(),\n option_schema_id: z.string().uuid().nullable().optional(),\n created_at: z.string().nullable().optional(),\n updated_at: z.string().nullable().optional(),\n offers: z.array(z.record(z.string(), z.unknown())).optional(),\n channelIds: z.array(z.string()).optional(),\n categories: z.array(z.record(z.string(), z.unknown())).optional(),\n categoryIds: z.array(z.string()).optional(),\n tags: z.array(z.string()).optional(),\n pricing: z.record(z.string(), z.unknown()).nullable().optional(),\n omnibus: omnibusBlockSchema\n .optional()\n .describe(\n \"EU Omnibus reference-price block for the presented price. Present only when Omnibus is enabled for the tenant and the product has a resolved price.\",\n ),\n});\n\nexport const openApi = createCatalogCrudOpenApi({\n resourceName: \"Product\",\n pluralName: \"Products\",\n querySchema: listSchema,\n listResponseSchema: createPagedListResponseSchema(productListItemSchema),\n create: {\n schema: productCreateSchema,\n description: \"Creates a new product in the catalog.\",\n },\n update: {\n schema: productUpdateSchema,\n responseSchema: defaultOkResponseSchema.extend({\n updatedAt: z.string().nullable().optional(),\n }),\n description: \"Updates an existing product by id.\",\n },\n del: {\n schema: z.object({ id: z.string().uuid() }),\n responseSchema: defaultOkResponseSchema,\n description: \"Deletes a product by id.\",\n },\n});\n"],
5
+ "mappings": "AAAA,SAAS,SAAS;AAElB,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,oCAAoC;AAC7C,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB,2BAA2B;AAC7D,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;AAAA,IACD,aAAa;AAAA,EACf;AAAA,EACA,KAAK;AAAA,IACH,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAAA,IAC1C,gBAAgB;AAAA,IAChB,aAAa;AAAA,EACf;AACF,CAAC;",
6
+ "names": ["buildProductFilters", "parseIdList", "scoreProductSearchRelevance", "channelIds"]
7
7
  }
@@ -8,12 +8,14 @@ import { resolveTranslations } from "@open-mercato/shared/lib/i18n/server";
8
8
  import { CatalogProductTag } from "../../data/entities.js";
9
9
  import { createPagedListResponseSchema } from "../openapi.js";
10
10
  import { escapeLikePattern } from "@open-mercato/shared/lib/db/escapeLikePattern";
11
+ import { isIdsParamProvided, parseIdsParam } from "@open-mercato/shared/lib/crud/ids";
11
12
  const routeMetadata = {
12
13
  GET: { requireAuth: true, requireFeatures: ["catalog.products.view"] }
13
14
  };
14
15
  const metadata = routeMetadata;
15
16
  const querySchema = z.object({
16
17
  search: z.string().optional(),
18
+ ids: z.string().optional().describe("Comma-separated tag ids to return; malformed ids match nothing."),
17
19
  page: z.coerce.number().min(1).default(1),
18
20
  pageSize: z.coerce.number().min(1).max(200).default(50)
19
21
  }).passthrough();
@@ -23,6 +25,7 @@ async function GET(req) {
23
25
  const url = new URL(req.url);
24
26
  const parsed = querySchema.safeParse({
25
27
  search: url.searchParams.get("search") ?? void 0,
28
+ ids: url.searchParams.get("ids") ?? void 0,
26
29
  page: url.searchParams.get("page") ?? void 0,
27
30
  pageSize: url.searchParams.get("pageSize") ?? void 0
28
31
  });
@@ -50,6 +53,9 @@ async function GET(req) {
50
53
  if (search) {
51
54
  where.label = { $ilike: `%${escapeLikePattern(search)}%` };
52
55
  }
56
+ if (isIdsParamProvided(query.ids)) {
57
+ where.id = { $in: parseIdsParam(query.ids) };
58
+ }
53
59
  const limit = query.pageSize;
54
60
  const offset = (query.page - 1) * query.pageSize;
55
61
  const [records, total] = await em.findAndCount(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/modules/catalog/api/tags/route.ts"],
4
- "sourcesContent": ["import { NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'\nimport { resolveOrganizationScopeFilter } from '@open-mercato/core/modules/directory/utils/organizationScopeFilter'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport { CatalogProductTag } from '../../data/entities'\nimport type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'\nimport { createPagedListResponseSchema } from '../openapi'\nimport { escapeLikePattern } from '@open-mercato/shared/lib/db/escapeLikePattern'\n\nconst routeMetadata = {\n GET: { requireAuth: true, requireFeatures: ['catalog.products.view'] },\n}\n\nexport const metadata = routeMetadata\n\nconst querySchema = z\n .object({\n search: z.string().optional(),\n page: z.coerce.number().min(1).default(1),\n pageSize: z.coerce.number().min(1).max(200).default(50),\n })\n .passthrough()\n\ntype QueryShape = z.infer<typeof querySchema>\n\nexport async function GET(req: Request) {\n const auth = await getAuthFromRequest(req)\n if (!auth) return NextResponse.json({ items: [] }, { status: 401 })\n\n const url = new URL(req.url)\n const parsed = querySchema.safeParse({\n search: url.searchParams.get('search') ?? undefined,\n page: url.searchParams.get('page') ?? undefined,\n pageSize: url.searchParams.get('pageSize') ?? undefined,\n })\n if (!parsed.success) {\n return NextResponse.json({ items: [], error: 'Invalid query' }, { status: 400 })\n }\n const query: QueryShape = parsed.data\n\n const container = await createRequestContainer()\n const em = container.resolve('em') as EntityManager\n const scope = await resolveOrganizationScopeForRequest({ container, auth, request: req })\n const { translate } = await resolveTranslations()\n\n const tenantId = scope?.tenantId ?? auth.tenantId ?? null\n if (!tenantId) {\n return NextResponse.json(\n { items: [], error: translate('catalog.errors.tenant_required', 'Tenant context is required.') },\n { status: 400 }\n )\n }\n\n // Scope by the caller's visible organizations. Under \"All organizations\"\n // (super-admin) `where` is empty, so the list scopes by tenant only instead\n // of 400-ing; restricted callers get their `filterIds` `$in` guard.\n const orgFilter = resolveOrganizationScopeFilter(scope, auth)\n\n const where: Record<string, unknown> = {\n ...orgFilter.where,\n tenantId,\n }\n const search = query.search?.trim()\n if (search) {\n where.label = { $ilike: `%${escapeLikePattern(search)}%` }\n }\n\n const limit = query.pageSize\n const offset = (query.page - 1) * query.pageSize\n const [records, total] = await em.findAndCount(\n CatalogProductTag,\n where,\n { limit, offset, orderBy: { label: 'asc' } }\n )\n\n return NextResponse.json({\n items: records.map((record) => ({\n id: record.id,\n label: record.label,\n slug: record.slug,\n createdAt: record.createdAt.toISOString(),\n updatedAt: record.updatedAt.toISOString(),\n })),\n total,\n })\n}\n\nconst tagListItemSchema = z.object({\n id: z.string().uuid(),\n label: z.string(),\n slug: z.string().nullable().optional(),\n createdAt: z.string(),\n updatedAt: z.string(),\n})\n\nexport const openApi: OpenApiRouteDoc = {\n tag: 'Catalog',\n summary: 'Product Tag management',\n methods: {\n GET: {\n summary: 'List product tags',\n description: 'Returns a paginated collection of product tags scoped to the authenticated organization.',\n query: querySchema,\n responses: [\n {\n status: 200,\n description: 'Paginated product tags',\n schema: createPagedListResponseSchema(tagListItemSchema),\n },\n ],\n },\n },\n}\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAElB,SAAS,0BAA0B;AACnC,SAAS,8BAA8B;AACvC,SAAS,0CAA0C;AACnD,SAAS,sCAAsC;AAC/C,SAAS,2BAA2B;AACpC,SAAS,yBAAyB;AAElC,SAAS,qCAAqC;AAC9C,SAAS,yBAAyB;AAElC,MAAM,gBAAgB;AAAA,EACpB,KAAK,EAAE,aAAa,MAAM,iBAAiB,CAAC,uBAAuB,EAAE;AACvE;AAEO,MAAM,WAAW;AAExB,MAAM,cAAc,EACjB,OAAO;AAAA,EACN,QA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Manager } from '@mikro-orm/postgresql'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'\nimport { resolveOrganizationScopeFilter } from '@open-mercato/core/modules/directory/utils/organizationScopeFilter'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport { CatalogProductTag } from '../../data/entities'\nimport type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'\nimport { createPagedListResponseSchema } from '../openapi'\nimport { escapeLikePattern } from '@open-mercato/shared/lib/db/escapeLikePattern'\nimport { isIdsParamProvided, parseIdsParam } from '@open-mercato/shared/lib/crud/ids'\n\nconst routeMetadata = {\n GET: { requireAuth: true, requireFeatures: ['catalog.products.view'] },\n}\n\nexport const metadata = routeMetadata\n\nconst querySchema = z\n .object({\n search: z.string().optional(),\n ids: z.string().optional().describe('Comma-separated tag ids to return; malformed ids match nothing.'),\n page: z.coerce.number().min(1).default(1),\n pageSize: z.coerce.number().min(1).max(200).default(50),\n })\n .passthrough()\n\ntype QueryShape = z.infer<typeof querySchema>\n\nexport async function GET(req: Request) {\n const auth = await getAuthFromRequest(req)\n if (!auth) return NextResponse.json({ items: [] }, { status: 401 })\n\n const url = new URL(req.url)\n const parsed = querySchema.safeParse({\n search: url.searchParams.get('search') ?? undefined,\n ids: url.searchParams.get('ids') ?? undefined,\n page: url.searchParams.get('page') ?? undefined,\n pageSize: url.searchParams.get('pageSize') ?? undefined,\n })\n if (!parsed.success) {\n return NextResponse.json({ items: [], error: 'Invalid query' }, { status: 400 })\n }\n const query: QueryShape = parsed.data\n\n const container = await createRequestContainer()\n const em = container.resolve('em') as EntityManager\n const scope = await resolveOrganizationScopeForRequest({ container, auth, request: req })\n const { translate } = await resolveTranslations()\n\n const tenantId = scope?.tenantId ?? auth.tenantId ?? null\n if (!tenantId) {\n return NextResponse.json(\n { items: [], error: translate('catalog.errors.tenant_required', 'Tenant context is required.') },\n { status: 400 }\n )\n }\n\n // Scope by the caller's visible organizations. Under \"All organizations\"\n // (super-admin) `where` is empty, so the list scopes by tenant only instead\n // of 400-ing; restricted callers get their `filterIds` `$in` guard.\n const orgFilter = resolveOrganizationScopeFilter(scope, auth)\n\n const where: Record<string, unknown> = {\n ...orgFilter.where,\n tenantId,\n }\n const search = query.search?.trim()\n if (search) {\n where.label = { $ilike: `%${escapeLikePattern(search)}%` }\n }\n if (isIdsParamProvided(query.ids)) {\n where.id = { $in: parseIdsParam(query.ids) }\n }\n\n const limit = query.pageSize\n const offset = (query.page - 1) * query.pageSize\n const [records, total] = await em.findAndCount(\n CatalogProductTag,\n where,\n { limit, offset, orderBy: { label: 'asc' } }\n )\n\n return NextResponse.json({\n items: records.map((record) => ({\n id: record.id,\n label: record.label,\n slug: record.slug,\n createdAt: record.createdAt.toISOString(),\n updatedAt: record.updatedAt.toISOString(),\n })),\n total,\n })\n}\n\nconst tagListItemSchema = z.object({\n id: z.string().uuid(),\n label: z.string(),\n slug: z.string().nullable().optional(),\n createdAt: z.string(),\n updatedAt: z.string(),\n})\n\nexport const openApi: OpenApiRouteDoc = {\n tag: 'Catalog',\n summary: 'Product Tag management',\n methods: {\n GET: {\n summary: 'List product tags',\n description: 'Returns a paginated collection of product tags scoped to the authenticated organization.',\n query: querySchema,\n responses: [\n {\n status: 200,\n description: 'Paginated product tags',\n schema: createPagedListResponseSchema(tagListItemSchema),\n },\n ],\n },\n },\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAElB,SAAS,0BAA0B;AACnC,SAAS,8BAA8B;AACvC,SAAS,0CAA0C;AACnD,SAAS,sCAAsC;AAC/C,SAAS,2BAA2B;AACpC,SAAS,yBAAyB;AAElC,SAAS,qCAAqC;AAC9C,SAAS,yBAAyB;AAClC,SAAS,oBAAoB,qBAAqB;AAElD,MAAM,gBAAgB;AAAA,EACpB,KAAK,EAAE,aAAa,MAA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K;AAAA,EACL,SAAS;AAAA,EACT,SAAS;AAAA,IACP,KAAK;AAAA,MACH,SAAS;AAAA,MACT,aAAa;AAAA,MACb,OAAO;AAAA,MACP,WAAW;AAAA,QACT;AAAA,UACE,QAAQ;AAAA,UACR,aAAa;AAAA,UACb,QAAQ,8BAA8B,iBAAiB;AAAA,QACzD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -2,10 +2,12 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Page, PageBody } from "@open-mercato/ui/backend/Page";
3
3
  import { PriceKindSettings } from "../../../components/PriceKindSettings.js";
4
4
  import { UnitPriceDisplaySettings } from "../../../components/UnitPriceDisplaySettings.js";
5
+ import { OmnibusSettings } from "../../../components/OmnibusSettings.js";
5
6
  function CatalogConfigurationPage() {
6
7
  return /* @__PURE__ */ jsx(Page, { children: /* @__PURE__ */ jsxs(PageBody, { className: "space-y-8", children: [
7
8
  /* @__PURE__ */ jsx(PriceKindSettings, {}),
8
- /* @__PURE__ */ jsx(UnitPriceDisplaySettings, {})
9
+ /* @__PURE__ */ jsx(UnitPriceDisplaySettings, {}),
10
+ /* @__PURE__ */ jsx(OmnibusSettings, {})
9
11
  ] }) });
10
12
  }
11
13
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/modules/catalog/backend/config/catalog/page.tsx"],
4
- "sourcesContent": ["import { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { PriceKindSettings } from '../../../components/PriceKindSettings'\nimport { UnitPriceDisplaySettings } from '../../../components/UnitPriceDisplaySettings'\n\nexport default function CatalogConfigurationPage() {\n return (\n <Page>\n <PageBody className=\"space-y-8\">\n <PriceKindSettings />\n <UnitPriceDisplaySettings />\n </PageBody>\n </Page>\n )\n}\n"],
5
- "mappings": "AAOM,SACE,KADF;AAPN,SAAS,MAAM,gBAAgB;AAC/B,SAAS,yBAAyB;AAClC,SAAS,gCAAgC;AAE1B,SAAR,2BAA4C;AACjD,SACE,oBAAC,QACC,+BAAC,YAAS,WAAU,aAClB;AAAA,wBAAC,qBAAkB;AAAA,IACnB,oBAAC,4BAAyB;AAAA,KAC5B,GACF;AAEJ;",
4
+ "sourcesContent": ["import { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { PriceKindSettings } from '../../../components/PriceKindSettings'\nimport { UnitPriceDisplaySettings } from '../../../components/UnitPriceDisplaySettings'\nimport { OmnibusSettings } from '../../../components/OmnibusSettings'\n\nexport default function CatalogConfigurationPage() {\n return (\n <Page>\n <PageBody className=\"space-y-8\">\n <PriceKindSettings />\n <UnitPriceDisplaySettings />\n <OmnibusSettings />\n </PageBody>\n </Page>\n )\n}\n"],
5
+ "mappings": "AAQM,SACE,KADF;AARN,SAAS,MAAM,gBAAgB;AAC/B,SAAS,yBAAyB;AAClC,SAAS,gCAAgC;AACzC,SAAS,uBAAuB;AAEjB,SAAR,2BAA4C;AACjD,SACE,oBAAC,QACC,+BAAC,YAAS,WAAU,aAClB;AAAA,wBAAC,qBAAkB;AAAA,IACnB,oBAAC,4BAAyB;AAAA,IAC1B,oBAAC,mBAAgB;AAAA,KACnB,GACF;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,9 @@
1
1
  import { createRequestContainer } from "@open-mercato/shared/lib/di/container";
2
+ import { runWithCacheTenant } from "@open-mercato/cache";
3
+ import { parseBooleanToken } from "@open-mercato/shared/lib/boolean";
4
+ import { runOmnibusBackfill } from "./lib/omnibusBackfill.js";
5
+ import { resolveOmnibusCache } from "./lib/omnibusCache.js";
6
+ import { omnibusBackfillOptionsSchema } from "./data/validators.js";
2
7
  import {
3
8
  installExampleCatalogData,
4
9
  seedCatalogExamplesForScope,
@@ -138,8 +143,81 @@ const installExamplesBundle = {
138
143
  }
139
144
  }
140
145
  };
141
- var cli_default = [seedUnitsCommand, seedPriceKindsCommand, seedExamplesCommand, installExamplesBundle];
146
+ const OMNIBUS_BACKFILL_USAGE = "Usage: mercato catalog omnibus:backfill --tenant <tenantId> [--org <organizationId>] [--channel-id <channelId> | --unscoped] [--batch-size N] [--dry-run]";
147
+ function readFlag(rest, name) {
148
+ for (const part of rest) {
149
+ if (part === `--${name}`) return true;
150
+ if (part.startsWith(`--${name}=`)) return parseBooleanToken(part.slice(name.length + 3)) === true;
151
+ }
152
+ return false;
153
+ }
154
+ function parseOmnibusBackfillArgs(rest) {
155
+ const args = parseArgs(rest.filter((part) => part !== "--dry-run" && part !== "--unscoped"));
156
+ const rawBatchSize = args.batchSize ?? args["batch-size"] ?? args.batch;
157
+ return omnibusBackfillOptionsSchema.safeParse({
158
+ tenantId: args.tenantId ?? args.tenant ?? "",
159
+ organizationId: args.organizationId ?? args.org ?? args.orgId ?? void 0,
160
+ channelId: args.channelId ?? args["channel-id"] ?? args.channel ?? void 0,
161
+ unscoped: readFlag(rest, "unscoped"),
162
+ batchSize: rawBatchSize !== void 0 ? Number(rawBatchSize) : void 0,
163
+ dryRun: readFlag(rest, "dry-run")
164
+ });
165
+ }
166
+ function printOmnibusBackfillResult(result) {
167
+ const label = result.dryRun ? "[omnibus:backfill] Dry run" : "[omnibus:backfill] Complete";
168
+ console.log(`${label} (tenant=${result.tenantId}, org=${result.organizationId ?? "all"})`);
169
+ for (const target of result.targets) {
170
+ const key = target.coverageKey || "(unscoped)";
171
+ console.log(
172
+ ` ${key}: lookbackDays=${target.lookbackDays} recordedAt=${target.recordedAt} scanned=${target.scanned} alreadyCovered=${target.alreadyCovered} missing=${target.missing} created=${target.created} skippedIncomplete=${target.skippedIncomplete} skippedUntracked=${target.skippedUntracked}`
173
+ );
174
+ }
175
+ if (!result.dryRun) {
176
+ console.log(` Coverage recorded: ${result.coverageRecorded.map((key) => key || "(unscoped)").join(", ") || "none"}`);
177
+ }
178
+ if (result.organizationId) {
179
+ console.log(
180
+ " Coverage is tenant-wide and is recorded only by a run without --org; run the backfill without --org before enabling Omnibus."
181
+ );
182
+ }
183
+ }
184
+ const omnibusBackfillCommand = {
185
+ command: "omnibus:backfill",
186
+ async run(rest) {
187
+ const parsed = parseOmnibusBackfillArgs(rest);
188
+ if (!parsed.success) {
189
+ console.error(OMNIBUS_BACKFILL_USAGE);
190
+ for (const issue of parsed.error.issues) {
191
+ console.error(` ${issue.path.join(".") || "options"}: ${issue.message}`);
192
+ }
193
+ process.exitCode = 2;
194
+ return;
195
+ }
196
+ const container = await createRequestContainer();
197
+ try {
198
+ const result = await runWithCacheTenant(
199
+ parsed.data.tenantId,
200
+ () => runOmnibusBackfill(
201
+ {
202
+ em: container.resolve("em"),
203
+ moduleConfigService: container.resolve("moduleConfigService"),
204
+ cache: resolveOmnibusCache(container)
205
+ },
206
+ parsed.data
207
+ )
208
+ );
209
+ printOmnibusBackfillResult(result);
210
+ } finally {
211
+ const disposable = container;
212
+ if (typeof disposable.dispose === "function") {
213
+ await disposable.dispose();
214
+ }
215
+ }
216
+ }
217
+ };
218
+ var cli_default = [seedUnitsCommand, seedPriceKindsCommand, seedExamplesCommand, installExamplesBundle, omnibusBackfillCommand];
142
219
  export {
143
- cli_default as default
220
+ cli_default as default,
221
+ parseOmnibusBackfillArgs
144
222
  };
145
223
  //# sourceMappingURL=cli.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/modules/catalog/cli.ts"],
4
- "sourcesContent": ["import type { ModuleCli } from '@open-mercato/shared/modules/registry'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport {\n installExampleCatalogData,\n seedCatalogExamplesForScope,\n seedCatalogPriceKinds,\n seedCatalogUnits,\n type CatalogSeedScope,\n} from './lib/seeds'\n\nfunction parseArgs(rest: string[]) {\n const args: Record<string, string> = {}\n for (let i = 0; i < rest.length; i += 1) {\n const part = rest[i]\n if (!part) continue\n if (part.startsWith('--')) {\n const [rawKey, rawValue] = part.slice(2).split('=')\n if (rawValue !== undefined) args[rawKey] = rawValue\n else if (rest[i + 1] && !rest[i + 1]!.startsWith('--')) {\n args[rawKey] = rest[i + 1]!\n i += 1\n }\n }\n }\n return args\n}\n\nconst seedUnitsCommand: ModuleCli = {\n command: 'seed-units',\n async run(rest) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? '')\n const organizationId = String(args.organizationId ?? args.org ?? args.orgId ?? '')\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato catalog seed-units --tenant <tenantId> --org <organizationId>')\n return\n }\n const container = await createRequestContainer()\n const scope: CatalogSeedScope = { tenantId, organizationId }\n try {\n const em = container.resolve<EntityManager>('em')\n await em.transactional(async (tem) => {\n await seedCatalogUnits(tem, scope)\n })\n console.log('\uD83D\uDCCF Unit dictionary seeded for organization', organizationId)\n } finally {\n const disposable = container as unknown as { dispose?: () => Promise<void> }\n if (typeof disposable.dispose === 'function') {\n await disposable.dispose()\n }\n }\n },\n}\n\nconst seedPriceKindsCommand: ModuleCli = {\n command: 'seed-price-kinds',\n async run(rest) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? '')\n const organizationId = String(args.organizationId ?? args.org ?? args.orgId ?? '')\n if (!tenantId) {\n console.error('Usage: mercato catalog seed-price-kinds --tenant <tenantId> [--org <organizationId>]')\n return\n }\n const container = await createRequestContainer()\n const scope = { tenantId, organizationId: organizationId || null }\n try {\n const em = container.resolve<EntityManager>('em')\n await em.transactional(async (tem) => {\n await seedCatalogPriceKinds(tem, scope)\n })\n console.log(\n '\uD83C\uDFF7\uFE0F Price kinds seeded for tenant',\n tenantId,\n organizationId ? `(org: ${organizationId})` : '(org: shared)',\n )\n } finally {\n const disposable = container as unknown as { dispose?: () => Promise<void> }\n if (typeof disposable.dispose === 'function') {\n await disposable.dispose()\n }\n }\n },\n}\n\nconst seedExamplesCommand: ModuleCli = {\n command: 'seed-examples',\n async run(rest) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? '')\n const organizationId = String(args.organizationId ?? args.org ?? args.orgId ?? '')\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato catalog seed-examples --tenant <tenantId> --org <organizationId>')\n return\n }\n const container = await createRequestContainer()\n const scope: CatalogSeedScope = { tenantId, organizationId }\n let seeded = false\n try {\n const em = container.resolve<EntityManager>('em')\n seeded = await em.transactional(async (tem) =>\n seedCatalogExamplesForScope(tem, container, scope)\n )\n } finally {\n const disposable = container as unknown as { dispose?: () => Promise<void> }\n if (typeof disposable.dispose === 'function') {\n await disposable.dispose()\n }\n }\n if (seeded) {\n console.log('Catalog example data seeded for organization', organizationId)\n } else {\n console.log('Catalog example data already present; skipping')\n }\n },\n}\n\nconst installExamplesBundle: ModuleCli = {\n command: 'seed-examples-bundle',\n async run(rest) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? '')\n const organizationId = String(args.organizationId ?? args.org ?? args.orgId ?? '')\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato catalog seed-examples-bundle --tenant <tenantId> --org <organizationId>')\n return\n }\n const container = await createRequestContainer()\n const scope: CatalogSeedScope = { tenantId, organizationId }\n try {\n const em = container.resolve<EntityManager>('em')\n const { seededExamples } = await em.transactional(async (tem) =>\n installExampleCatalogData(container, scope, tem)\n )\n if (seededExamples) {\n console.log('Catalog example data seeded for organization', organizationId)\n } else {\n console.log('Catalog example data already present; skipping examples')\n }\n } finally {\n const disposable = container as unknown as { dispose?: () => Promise<void> }\n if (typeof disposable.dispose === 'function') {\n await disposable.dispose()\n }\n }\n },\n}\n\nexport default [seedUnitsCommand, seedPriceKindsCommand, seedExamplesCommand, installExamplesBundle]\n"],
5
- "mappings": "AACA,SAAS,8BAA8B;AAEvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,UAAU,MAAgB;AACjC,QAAM,OAA+B,CAAC;AACtC,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK,GAAG;AACvC,UAAM,OAAO,KAAK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AQ,IAAI,gDAAgD,cAAc;AAAA,IAC5E,OAAO;AACL,cAAQ,IAAI,gDAAgD;AAAA,IAC9D;AAAA,EACF;AACF;AAEA,MAAM,wBAAmC;AAAA,EACvC,SAAS;AAAA,EACT,MAAM,IAAI,MAAM;AACd,UAAM,OAAO,UAAU,IAAI;AAC3B,UAAM,WAAW,OAAO,KAAK,YAAY,KAAK,UAAU,EAAE;AAC1D,UAAM,iBAAiB,OAAO,KAAK,kBAAkB,KAAK,OAAO,KAAK,SAAS,EAAE;AACjF,QAAI,CAAC,YAAY,CAAC,gBAAgB;AAChC,cAAQ,MAAM,wFAAwF;AACtG;AAAA,IACF;AACA,UAAM,YAAY,MAAM,uBAAuB;AAC/C,UAAM,QAA0B,EAAE,UAAU,eAAe;AAC3D,QAAI;AACF,YAAM,KAAK,UAAU,QAAuB,IAAI;AAChD,YAAM,EAAE,eAAe,IAAI,MAAM,GAAG;AAAA,QAAc,OAAO,QACvD,0BAA0B,WAAW,OAAO,GAAG;AAAA,MACjD;AACA,UAAI,gBAAgB;AAClB,gBAAQ,IAAI,gDAAgD,cAAc;AAAA,MAC5E,OAAO;AACL,gBAAQ,IAAI,yDAAyD;AAAA,MACvE;AAAA,IACF,UAAE;AACA,YAAM,aAAa;AACnB,UAAI,OAAO,WAAW,YAAY,YAAY;AAC5C,cAAM,WAAW,QAAQ;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,cAAQ,CAAC,kBAAkB,uBAAuB,qBAAqB,qBAAqB;",
4
+ "sourcesContent": ["import type { ModuleCli } from '@open-mercato/shared/modules/registry'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { runWithCacheTenant } from '@open-mercato/cache'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport type { ModuleConfigService } from '@open-mercato/core/modules/configs/lib/module-config-service'\nimport { parseBooleanToken } from '@open-mercato/shared/lib/boolean'\nimport { runOmnibusBackfill, type OmnibusBackfillResult } from './lib/omnibusBackfill'\nimport { resolveOmnibusCache } from './lib/omnibusCache'\nimport { omnibusBackfillOptionsSchema } from './data/validators'\nimport {\n installExampleCatalogData,\n seedCatalogExamplesForScope,\n seedCatalogPriceKinds,\n seedCatalogUnits,\n type CatalogSeedScope,\n} from './lib/seeds'\n\nfunction parseArgs(rest: string[]) {\n const args: Record<string, string> = {}\n for (let i = 0; i < rest.length; i += 1) {\n const part = rest[i]\n if (!part) continue\n if (part.startsWith('--')) {\n const [rawKey, rawValue] = part.slice(2).split('=')\n if (rawValue !== undefined) args[rawKey] = rawValue\n else if (rest[i + 1] && !rest[i + 1]!.startsWith('--')) {\n args[rawKey] = rest[i + 1]!\n i += 1\n }\n }\n }\n return args\n}\n\nconst seedUnitsCommand: ModuleCli = {\n command: 'seed-units',\n async run(rest) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? '')\n const organizationId = String(args.organizationId ?? args.org ?? args.orgId ?? '')\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato catalog seed-units --tenant <tenantId> --org <organizationId>')\n return\n }\n const container = await createRequestContainer()\n const scope: CatalogSeedScope = { tenantId, organizationId }\n try {\n const em = container.resolve<EntityManager>('em')\n await em.transactional(async (tem) => {\n await seedCatalogUnits(tem, scope)\n })\n console.log('\uD83D\uDCCF Unit dictionary seeded for organization', organizationId)\n } finally {\n const disposable = container as unknown as { dispose?: () => Promise<void> }\n if (typeof disposable.dispose === 'function') {\n await disposable.dispose()\n }\n }\n },\n}\n\nconst seedPriceKindsCommand: ModuleCli = {\n command: 'seed-price-kinds',\n async run(rest) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? '')\n const organizationId = String(args.organizationId ?? args.org ?? args.orgId ?? '')\n if (!tenantId) {\n console.error('Usage: mercato catalog seed-price-kinds --tenant <tenantId> [--org <organizationId>]')\n return\n }\n const container = await createRequestContainer()\n const scope = { tenantId, organizationId: organizationId || null }\n try {\n const em = container.resolve<EntityManager>('em')\n await em.transactional(async (tem) => {\n await seedCatalogPriceKinds(tem, scope)\n })\n console.log(\n '\uD83C\uDFF7\uFE0F Price kinds seeded for tenant',\n tenantId,\n organizationId ? `(org: ${organizationId})` : '(org: shared)',\n )\n } finally {\n const disposable = container as unknown as { dispose?: () => Promise<void> }\n if (typeof disposable.dispose === 'function') {\n await disposable.dispose()\n }\n }\n },\n}\n\nconst seedExamplesCommand: ModuleCli = {\n command: 'seed-examples',\n async run(rest) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? '')\n const organizationId = String(args.organizationId ?? args.org ?? args.orgId ?? '')\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato catalog seed-examples --tenant <tenantId> --org <organizationId>')\n return\n }\n const container = await createRequestContainer()\n const scope: CatalogSeedScope = { tenantId, organizationId }\n let seeded = false\n try {\n const em = container.resolve<EntityManager>('em')\n seeded = await em.transactional(async (tem) =>\n seedCatalogExamplesForScope(tem, container, scope)\n )\n } finally {\n const disposable = container as unknown as { dispose?: () => Promise<void> }\n if (typeof disposable.dispose === 'function') {\n await disposable.dispose()\n }\n }\n if (seeded) {\n console.log('Catalog example data seeded for organization', organizationId)\n } else {\n console.log('Catalog example data already present; skipping')\n }\n },\n}\n\nconst installExamplesBundle: ModuleCli = {\n command: 'seed-examples-bundle',\n async run(rest) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? '')\n const organizationId = String(args.organizationId ?? args.org ?? args.orgId ?? '')\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato catalog seed-examples-bundle --tenant <tenantId> --org <organizationId>')\n return\n }\n const container = await createRequestContainer()\n const scope: CatalogSeedScope = { tenantId, organizationId }\n try {\n const em = container.resolve<EntityManager>('em')\n const { seededExamples } = await em.transactional(async (tem) =>\n installExampleCatalogData(container, scope, tem)\n )\n if (seededExamples) {\n console.log('Catalog example data seeded for organization', organizationId)\n } else {\n console.log('Catalog example data already present; skipping examples')\n }\n } finally {\n const disposable = container as unknown as { dispose?: () => Promise<void> }\n if (typeof disposable.dispose === 'function') {\n await disposable.dispose()\n }\n }\n },\n}\n\nconst OMNIBUS_BACKFILL_USAGE =\n 'Usage: mercato catalog omnibus:backfill --tenant <tenantId> [--org <organizationId>] [--channel-id <channelId> | --unscoped] [--batch-size N] [--dry-run]'\n\nfunction readFlag(rest: string[], name: string): boolean {\n for (const part of rest) {\n if (part === `--${name}`) return true\n if (part.startsWith(`--${name}=`)) return parseBooleanToken(part.slice(name.length + 3)) === true\n }\n return false\n}\n\nexport function parseOmnibusBackfillArgs(rest: string[]) {\n const args = parseArgs(rest.filter((part) => part !== '--dry-run' && part !== '--unscoped'))\n const rawBatchSize = args.batchSize ?? args['batch-size'] ?? args.batch\n return omnibusBackfillOptionsSchema.safeParse({\n tenantId: args.tenantId ?? args.tenant ?? '',\n organizationId: args.organizationId ?? args.org ?? args.orgId ?? undefined,\n channelId: args.channelId ?? args['channel-id'] ?? args.channel ?? undefined,\n unscoped: readFlag(rest, 'unscoped'),\n batchSize: rawBatchSize !== undefined ? Number(rawBatchSize) : undefined,\n dryRun: readFlag(rest, 'dry-run'),\n })\n}\n\nfunction printOmnibusBackfillResult(result: OmnibusBackfillResult) {\n const label = result.dryRun ? '[omnibus:backfill] Dry run' : '[omnibus:backfill] Complete'\n console.log(`${label} (tenant=${result.tenantId}, org=${result.organizationId ?? 'all'})`)\n for (const target of result.targets) {\n const key = target.coverageKey || '(unscoped)'\n console.log(\n ` ${key}: lookbackDays=${target.lookbackDays} recordedAt=${target.recordedAt} scanned=${target.scanned} alreadyCovered=${target.alreadyCovered} missing=${target.missing} created=${target.created} skippedIncomplete=${target.skippedIncomplete} skippedUntracked=${target.skippedUntracked}`,\n )\n }\n if (!result.dryRun) {\n console.log(` Coverage recorded: ${result.coverageRecorded.map((key) => key || '(unscoped)').join(', ') || 'none'}`)\n }\n if (result.organizationId) {\n console.log(\n ' Coverage is tenant-wide and is recorded only by a run without --org; run the backfill without --org before enabling Omnibus.',\n )\n }\n}\n\nconst omnibusBackfillCommand: ModuleCli = {\n command: 'omnibus:backfill',\n async run(rest) {\n const parsed = parseOmnibusBackfillArgs(rest)\n if (!parsed.success) {\n console.error(OMNIBUS_BACKFILL_USAGE)\n for (const issue of parsed.error.issues) {\n console.error(` ${issue.path.join('.') || 'options'}: ${issue.message}`)\n }\n process.exitCode = 2\n return\n }\n const container = await createRequestContainer()\n try {\n const result = await runWithCacheTenant(parsed.data.tenantId, () =>\n runOmnibusBackfill(\n {\n em: container.resolve<EntityManager>('em'),\n moduleConfigService: container.resolve<ModuleConfigService>('moduleConfigService'),\n cache: resolveOmnibusCache(container),\n },\n parsed.data,\n ),\n )\n printOmnibusBackfillResult(result)\n } finally {\n const disposable = container as unknown as { dispose?: () => Promise<void> }\n if (typeof disposable.dispose === 'function') {\n await disposable.dispose()\n }\n }\n },\n}\n\nexport default [seedUnitsCommand, seedPriceKindsCommand, seedExamplesCommand, installExamplesBundle, omnibusBackfillCommand]\n"],
5
+ "mappings": "AACA,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AAGnC,SAAS,yBAAyB;AAClC,SAAS,0BAAsD;AAC/D,SAAS,2BAA2B;AACpC,SAAS,oCAAoC;AAC7C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,UAAU,MAAgB;AACjC,QAAM,OAA+B,CAAC;AACtC,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK,GAAG;AACvC,UAAM,OAAO,KAAK,CAAC;AACnB,QAAI,CAAC,KAAM;AACX,QAAI,KAAK,WAAW,IAAI,GAAG;AACzB,YAAM,CAAC,QAAQ,QAAQ,IAAI,KAAK,MAAM,CAAC,EAAE,MAAM,GAAG;AAClD,UAAI,aAAa,OAAW,MAAK,MAAM,IAAI;AAAA,eAClC,KAAK,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,EAAG,WAAW,IAAI,GAAG;AACtD,aAAK,MAAM,IAAI,KAAK,IAAI,CA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