@open-mercato/core 0.6.7-develop.6669.1.40b669666b → 0.6.7-develop.6670.1.4efa7961c6

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 (473) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/dist/generated/entities/inventory_balance/index.js +21 -0
  3. package/dist/generated/entities/inventory_balance/index.js.map +7 -0
  4. package/dist/generated/entities/inventory_lot/index.js +19 -0
  5. package/dist/generated/entities/inventory_lot/index.js.map +7 -0
  6. package/dist/generated/entities/inventory_movement/index.js +35 -0
  7. package/dist/generated/entities/inventory_movement/index.js.map +7 -0
  8. package/dist/generated/entities/inventory_reservation/index.js +23 -0
  9. package/dist/generated/entities/inventory_reservation/index.js.map +7 -0
  10. package/dist/generated/entities/product_inventory_profile/index.js +21 -0
  11. package/dist/generated/entities/product_inventory_profile/index.js.map +7 -0
  12. package/dist/generated/entities/sales_order_warehouse_assignment/index.js +11 -0
  13. package/dist/generated/entities/sales_order_warehouse_assignment/index.js.map +7 -0
  14. package/dist/generated/entities/warehouse/index.js +25 -0
  15. package/dist/generated/entities/warehouse/index.js.map +7 -0
  16. package/dist/generated/entities/warehouse_location/index.js +21 -0
  17. package/dist/generated/entities/warehouse_location/index.js.map +7 -0
  18. package/dist/generated/entities/warehouse_zone/index.js +11 -0
  19. package/dist/generated/entities/warehouse_zone/index.js.map +7 -0
  20. package/dist/generated/entities.ids.generated.js +12 -0
  21. package/dist/generated/entities.ids.generated.js.map +2 -2
  22. package/dist/generated/entity-fields-registry.js +98 -0
  23. package/dist/generated/entity-fields-registry.js.map +2 -2
  24. package/dist/modules/auth/backend/roles/page.js +12 -4
  25. package/dist/modules/auth/backend/roles/page.js.map +2 -2
  26. package/dist/modules/auth/lib/backendChrome.js +1 -0
  27. package/dist/modules/auth/lib/backendChrome.js.map +2 -2
  28. package/dist/modules/auth/services/rbacService.js +16 -17
  29. package/dist/modules/auth/services/rbacService.js.map +2 -2
  30. package/dist/modules/catalog/api/products/route.js +3 -0
  31. package/dist/modules/catalog/api/products/route.js.map +2 -2
  32. package/dist/modules/catalog/api/variants/route.js +3 -0
  33. package/dist/modules/catalog/api/variants/route.js.map +2 -2
  34. package/dist/modules/query_index/lib/engine.js +6 -6
  35. package/dist/modules/query_index/lib/engine.js.map +2 -2
  36. package/dist/modules/sales/api/documents/factory.js +1 -0
  37. package/dist/modules/sales/api/documents/factory.js.map +2 -2
  38. package/dist/modules/sales/commands/documents.js +53 -0
  39. package/dist/modules/sales/commands/documents.js.map +2 -2
  40. package/dist/modules/sales/components/documents/ItemsSection.js +51 -2
  41. package/dist/modules/sales/components/documents/ItemsSection.js.map +2 -2
  42. package/dist/modules/sales/events.js +2 -0
  43. package/dist/modules/sales/events.js.map +2 -2
  44. package/dist/modules/sales/widgets/injection/order-items-context.js +11 -0
  45. package/dist/modules/sales/widgets/injection/order-items-context.js.map +7 -0
  46. package/dist/modules/wms/acl.js +18 -0
  47. package/dist/modules/wms/acl.js.map +7 -0
  48. package/dist/modules/wms/analytics.js +11 -0
  49. package/dist/modules/wms/analytics.js.map +7 -0
  50. package/dist/modules/wms/api/dashboard/operational/route.js +80 -0
  51. package/dist/modules/wms/api/dashboard/operational/route.js.map +7 -0
  52. package/dist/modules/wms/api/interceptors.js +90 -0
  53. package/dist/modules/wms/api/interceptors.js.map +7 -0
  54. package/dist/modules/wms/api/inventory/adjust/route.js +51 -0
  55. package/dist/modules/wms/api/inventory/adjust/route.js.map +7 -0
  56. package/dist/modules/wms/api/inventory/allocate/route.js +51 -0
  57. package/dist/modules/wms/api/inventory/allocate/route.js.map +7 -0
  58. package/dist/modules/wms/api/inventory/balances/route.js +172 -0
  59. package/dist/modules/wms/api/inventory/balances/route.js.map +7 -0
  60. package/dist/modules/wms/api/inventory/cycle-count/route.js +52 -0
  61. package/dist/modules/wms/api/inventory/cycle-count/route.js.map +7 -0
  62. package/dist/modules/wms/api/inventory/helpers.js +113 -0
  63. package/dist/modules/wms/api/inventory/helpers.js.map +7 -0
  64. package/dist/modules/wms/api/inventory/import/apply/route.js +46 -0
  65. package/dist/modules/wms/api/inventory/import/apply/route.js.map +7 -0
  66. package/dist/modules/wms/api/inventory/import/helpers.js +195 -0
  67. package/dist/modules/wms/api/inventory/import/helpers.js.map +7 -0
  68. package/dist/modules/wms/api/inventory/import/template/route.js +32 -0
  69. package/dist/modules/wms/api/inventory/import/template/route.js.map +7 -0
  70. package/dist/modules/wms/api/inventory/import/validate/route.js +54 -0
  71. package/dist/modules/wms/api/inventory/import/validate/route.js.map +7 -0
  72. package/dist/modules/wms/api/inventory/move/route.js +51 -0
  73. package/dist/modules/wms/api/inventory/move/route.js.map +7 -0
  74. package/dist/modules/wms/api/inventory/movements/route.js +164 -0
  75. package/dist/modules/wms/api/inventory/movements/route.js.map +7 -0
  76. package/dist/modules/wms/api/inventory/receive/route.js +50 -0
  77. package/dist/modules/wms/api/inventory/receive/route.js.map +7 -0
  78. package/dist/modules/wms/api/inventory/release/route.js +44 -0
  79. package/dist/modules/wms/api/inventory/release/route.js.map +7 -0
  80. package/dist/modules/wms/api/inventory/reservations/route.js +128 -0
  81. package/dist/modules/wms/api/inventory/reservations/route.js.map +7 -0
  82. package/dist/modules/wms/api/inventory/reserve/route.js +59 -0
  83. package/dist/modules/wms/api/inventory/reserve/route.js.map +7 -0
  84. package/dist/modules/wms/api/inventory-profiles/route.js +178 -0
  85. package/dist/modules/wms/api/inventory-profiles/route.js.map +7 -0
  86. package/dist/modules/wms/api/listEnrichers.js +181 -0
  87. package/dist/modules/wms/api/listEnrichers.js.map +7 -0
  88. package/dist/modules/wms/api/listSearch.js +77 -0
  89. package/dist/modules/wms/api/listSearch.js.map +7 -0
  90. package/dist/modules/wms/api/locations/route.js +172 -0
  91. package/dist/modules/wms/api/locations/route.js.map +7 -0
  92. package/dist/modules/wms/api/lots/route.js +204 -0
  93. package/dist/modules/wms/api/lots/route.js.map +7 -0
  94. package/dist/modules/wms/api/openapi.js +27 -0
  95. package/dist/modules/wms/api/openapi.js.map +7 -0
  96. package/dist/modules/wms/api/sales-orders/[salesOrderId]/re-run-reservation/route.js +54 -0
  97. package/dist/modules/wms/api/sales-orders/[salesOrderId]/re-run-reservation/route.js.map +7 -0
  98. package/dist/modules/wms/api/sales-orders/[salesOrderId]/warehouse-assignment/route.js +279 -0
  99. package/dist/modules/wms/api/sales-orders/[salesOrderId]/warehouse-assignment/route.js.map +7 -0
  100. package/dist/modules/wms/api/sales-orders/assign-warehouse/route.js +56 -0
  101. package/dist/modules/wms/api/sales-orders/assign-warehouse/route.js.map +7 -0
  102. package/dist/modules/wms/api/sales-orders/unassign-warehouse/route.js +43 -0
  103. package/dist/modules/wms/api/sales-orders/unassign-warehouse/route.js.map +7 -0
  104. package/dist/modules/wms/api/warehouses/route.js +181 -0
  105. package/dist/modules/wms/api/warehouses/route.js.map +7 -0
  106. package/dist/modules/wms/api/zones/route.js +159 -0
  107. package/dist/modules/wms/api/zones/route.js.map +7 -0
  108. package/dist/modules/wms/backend/config/wms/page.js +9 -0
  109. package/dist/modules/wms/backend/config/wms/page.js.map +7 -0
  110. package/dist/modules/wms/backend/config/wms/page.meta.js +18 -0
  111. package/dist/modules/wms/backend/config/wms/page.meta.js.map +7 -0
  112. package/dist/modules/wms/backend/page.js +9 -0
  113. package/dist/modules/wms/backend/page.js.map +7 -0
  114. package/dist/modules/wms/backend/page.meta.js +16 -0
  115. package/dist/modules/wms/backend/page.meta.js.map +7 -0
  116. package/dist/modules/wms/backend/wms/inventory/page.js +9 -0
  117. package/dist/modules/wms/backend/wms/inventory/page.js.map +7 -0
  118. package/dist/modules/wms/backend/wms/inventory/page.meta.js +18 -0
  119. package/dist/modules/wms/backend/wms/inventory/page.meta.js.map +7 -0
  120. package/dist/modules/wms/backend/wms/location/[id]/page.js +9 -0
  121. package/dist/modules/wms/backend/wms/location/[id]/page.js.map +7 -0
  122. package/dist/modules/wms/backend/wms/location/[id]/page.meta.js +18 -0
  123. package/dist/modules/wms/backend/wms/location/[id]/page.meta.js.map +7 -0
  124. package/dist/modules/wms/backend/wms/locations/page.js +10 -0
  125. package/dist/modules/wms/backend/wms/locations/page.js.map +7 -0
  126. package/dist/modules/wms/backend/wms/locations/page.meta.js +18 -0
  127. package/dist/modules/wms/backend/wms/locations/page.meta.js.map +7 -0
  128. package/dist/modules/wms/backend/wms/lot/[id]/page.js +9 -0
  129. package/dist/modules/wms/backend/wms/lot/[id]/page.js.map +7 -0
  130. package/dist/modules/wms/backend/wms/lot/[id]/page.meta.js +18 -0
  131. package/dist/modules/wms/backend/wms/lot/[id]/page.meta.js.map +7 -0
  132. package/dist/modules/wms/backend/wms/lots/page.js +9 -0
  133. package/dist/modules/wms/backend/wms/lots/page.js.map +7 -0
  134. package/dist/modules/wms/backend/wms/lots/page.meta.js +18 -0
  135. package/dist/modules/wms/backend/wms/lots/page.meta.js.map +7 -0
  136. package/dist/modules/wms/backend/wms/movements/page.js +22 -0
  137. package/dist/modules/wms/backend/wms/movements/page.js.map +7 -0
  138. package/dist/modules/wms/backend/wms/movements/page.meta.js +18 -0
  139. package/dist/modules/wms/backend/wms/movements/page.meta.js.map +7 -0
  140. package/dist/modules/wms/backend/wms/reservations/page.js +23 -0
  141. package/dist/modules/wms/backend/wms/reservations/page.js.map +7 -0
  142. package/dist/modules/wms/backend/wms/reservations/page.meta.js +18 -0
  143. package/dist/modules/wms/backend/wms/reservations/page.meta.js.map +7 -0
  144. package/dist/modules/wms/backend/wms/sku/[id]/page.js +9 -0
  145. package/dist/modules/wms/backend/wms/sku/[id]/page.js.map +7 -0
  146. package/dist/modules/wms/backend/wms/sku/[id]/page.meta.js +18 -0
  147. package/dist/modules/wms/backend/wms/sku/[id]/page.meta.js.map +7 -0
  148. package/dist/modules/wms/backend/wms/warehouses/page.js +10 -0
  149. package/dist/modules/wms/backend/wms/warehouses/page.js.map +7 -0
  150. package/dist/modules/wms/backend/wms/warehouses/page.meta.js +18 -0
  151. package/dist/modules/wms/backend/wms/warehouses/page.meta.js.map +7 -0
  152. package/dist/modules/wms/backend/wms/zones/page.js +10 -0
  153. package/dist/modules/wms/backend/wms/zones/page.js.map +7 -0
  154. package/dist/modules/wms/backend/wms/zones/page.meta.js +18 -0
  155. package/dist/modules/wms/backend/wms/zones/page.meta.js.map +7 -0
  156. package/dist/modules/wms/ce.js +80 -0
  157. package/dist/modules/wms/ce.js.map +7 -0
  158. package/dist/modules/wms/cli.js +83 -0
  159. package/dist/modules/wms/cli.js.map +7 -0
  160. package/dist/modules/wms/commands/configuration.js +1519 -0
  161. package/dist/modules/wms/commands/configuration.js.map +7 -0
  162. package/dist/modules/wms/commands/index.js +4 -0
  163. package/dist/modules/wms/commands/index.js.map +7 -0
  164. package/dist/modules/wms/commands/inventory-actions.js +1539 -0
  165. package/dist/modules/wms/commands/inventory-actions.js.map +7 -0
  166. package/dist/modules/wms/commands/sales-order-assignment.js +277 -0
  167. package/dist/modules/wms/commands/sales-order-assignment.js.map +7 -0
  168. package/dist/modules/wms/commands/shared.js +82 -0
  169. package/dist/modules/wms/commands/shared.js.map +7 -0
  170. package/dist/modules/wms/components/backend/AdjustInventoryDialog.js +755 -0
  171. package/dist/modules/wms/components/backend/AdjustInventoryDialog.js.map +7 -0
  172. package/dist/modules/wms/components/backend/ChangeLotStatusDialog.js +269 -0
  173. package/dist/modules/wms/components/backend/ChangeLotStatusDialog.js.map +7 -0
  174. package/dist/modules/wms/components/backend/CycleCountWizardDialog.js +1783 -0
  175. package/dist/modules/wms/components/backend/CycleCountWizardDialog.js.map +7 -0
  176. package/dist/modules/wms/components/backend/ImportInventoryDialog.js +766 -0
  177. package/dist/modules/wms/components/backend/ImportInventoryDialog.js.map +7 -0
  178. package/dist/modules/wms/components/backend/InventoryOperationsSection.js +119 -0
  179. package/dist/modules/wms/components/backend/InventoryOperationsSection.js.map +7 -0
  180. package/dist/modules/wms/components/backend/LocationEditDialog.js +140 -0
  181. package/dist/modules/wms/components/backend/LocationEditDialog.js.map +7 -0
  182. package/dist/modules/wms/components/backend/MoveInventoryDialog.js +791 -0
  183. package/dist/modules/wms/components/backend/MoveInventoryDialog.js.map +7 -0
  184. package/dist/modules/wms/components/backend/ReceiveInventoryDialog.js +656 -0
  185. package/dist/modules/wms/components/backend/ReceiveInventoryDialog.js.map +7 -0
  186. package/dist/modules/wms/components/backend/ReleaseReservationDialog.js +344 -0
  187. package/dist/modules/wms/components/backend/ReleaseReservationDialog.js.map +7 -0
  188. package/dist/modules/wms/components/backend/ReserveInventoryDialog.js +475 -0
  189. package/dist/modules/wms/components/backend/ReserveInventoryDialog.js.map +7 -0
  190. package/dist/modules/wms/components/backend/WmsConfigurationPage.js +1112 -0
  191. package/dist/modules/wms/components/backend/WmsConfigurationPage.js.map +7 -0
  192. package/dist/modules/wms/components/backend/WmsInventoryConsolePage.js +908 -0
  193. package/dist/modules/wms/components/backend/WmsInventoryConsolePage.js.map +7 -0
  194. package/dist/modules/wms/components/backend/WmsLocationDetailPage.js +1015 -0
  195. package/dist/modules/wms/components/backend/WmsLocationDetailPage.js.map +7 -0
  196. package/dist/modules/wms/components/backend/WmsLotDetailPage.js +1049 -0
  197. package/dist/modules/wms/components/backend/WmsLotDetailPage.js.map +7 -0
  198. package/dist/modules/wms/components/backend/WmsLotsListPage.js +297 -0
  199. package/dist/modules/wms/components/backend/WmsLotsListPage.js.map +7 -0
  200. package/dist/modules/wms/components/backend/WmsOperationalDashboardPage.js +757 -0
  201. package/dist/modules/wms/components/backend/WmsOperationalDashboardPage.js.map +7 -0
  202. package/dist/modules/wms/components/backend/WmsSkuDetailPage.js +975 -0
  203. package/dist/modules/wms/components/backend/WmsSkuDetailPage.js.map +7 -0
  204. package/dist/modules/wms/components/backend/inventoryMutationLoaders.js +710 -0
  205. package/dist/modules/wms/components/backend/inventoryMutationLoaders.js.map +7 -0
  206. package/dist/modules/wms/components/backend/useWmsInventoryMutationAccess.js +79 -0
  207. package/dist/modules/wms/components/backend/useWmsInventoryMutationAccess.js.map +7 -0
  208. package/dist/modules/wms/components/backend/useWmsInventoryScopeFromSearchParams.js +24 -0
  209. package/dist/modules/wms/components/backend/useWmsInventoryScopeFromSearchParams.js.map +7 -0
  210. package/dist/modules/wms/components/backend/wmsLookupLoaders.js +55 -0
  211. package/dist/modules/wms/components/backend/wmsLookupLoaders.js.map +7 -0
  212. package/dist/modules/wms/data/enrichers.js +501 -0
  213. package/dist/modules/wms/data/enrichers.js.map +7 -0
  214. package/dist/modules/wms/data/entities.js +467 -0
  215. package/dist/modules/wms/data/entities.js.map +7 -0
  216. package/dist/modules/wms/data/validators.js +399 -0
  217. package/dist/modules/wms/data/validators.js.map +7 -0
  218. package/dist/modules/wms/di.js +27 -0
  219. package/dist/modules/wms/di.js.map +7 -0
  220. package/dist/modules/wms/events.js +42 -0
  221. package/dist/modules/wms/events.js.map +7 -0
  222. package/dist/modules/wms/index.js +17 -0
  223. package/dist/modules/wms/index.js.map +7 -0
  224. package/dist/modules/wms/lib/catalogInventoryProfileIntent.js +54 -0
  225. package/dist/modules/wms/lib/catalogInventoryProfileIntent.js.map +7 -0
  226. package/dist/modules/wms/lib/catalogInventoryProfileSync.js +144 -0
  227. package/dist/modules/wms/lib/catalogInventoryProfileSync.js.map +7 -0
  228. package/dist/modules/wms/lib/expiry.js +29 -0
  229. package/dist/modules/wms/lib/expiry.js.map +7 -0
  230. package/dist/modules/wms/lib/flashMutationError.js +51 -0
  231. package/dist/modules/wms/lib/flashMutationError.js.map +7 -0
  232. package/dist/modules/wms/lib/inventoryDisplayUi.js +188 -0
  233. package/dist/modules/wms/lib/inventoryDisplayUi.js.map +7 -0
  234. package/dist/modules/wms/lib/inventoryIdempotency.js +37 -0
  235. package/dist/modules/wms/lib/inventoryIdempotency.js.map +7 -0
  236. package/dist/modules/wms/lib/inventoryImportCsv.js +173 -0
  237. package/dist/modules/wms/lib/inventoryImportCsv.js.map +7 -0
  238. package/dist/modules/wms/lib/inventoryImportService.js +468 -0
  239. package/dist/modules/wms/lib/inventoryImportService.js.map +7 -0
  240. package/dist/modules/wms/lib/inventoryMutationUi.js +25 -0
  241. package/dist/modules/wms/lib/inventoryMutationUi.js.map +7 -0
  242. package/dist/modules/wms/lib/inventoryPolicy.js +61 -0
  243. package/dist/modules/wms/lib/inventoryPolicy.js.map +7 -0
  244. package/dist/modules/wms/lib/inventoryReconciliation.js +193 -0
  245. package/dist/modules/wms/lib/inventoryReconciliation.js.map +7 -0
  246. package/dist/modules/wms/lib/inventoryTrackingValidation.js +13 -0
  247. package/dist/modules/wms/lib/inventoryTrackingValidation.js.map +7 -0
  248. package/dist/modules/wms/lib/loadOperationalDashboard.js +580 -0
  249. package/dist/modules/wms/lib/loadOperationalDashboard.js.map +7 -0
  250. package/dist/modules/wms/lib/lowStockBalanceFilter.js +49 -0
  251. package/dist/modules/wms/lib/lowStockBalanceFilter.js.map +7 -0
  252. package/dist/modules/wms/lib/primaryWarehousePolicy.js +32 -0
  253. package/dist/modules/wms/lib/primaryWarehousePolicy.js.map +7 -0
  254. package/dist/modules/wms/lib/roleFeatures.js +30 -0
  255. package/dist/modules/wms/lib/roleFeatures.js.map +7 -0
  256. package/dist/modules/wms/lib/salesOrderInventoryAutomation.js +291 -0
  257. package/dist/modules/wms/lib/salesOrderInventoryAutomation.js.map +7 -0
  258. package/dist/modules/wms/lib/salesOrderWarehouseAssignment.js +54 -0
  259. package/dist/modules/wms/lib/salesOrderWarehouseAssignment.js.map +7 -0
  260. package/dist/modules/wms/lib/wmsIntegrationToggles.js +71 -0
  261. package/dist/modules/wms/lib/wmsIntegrationToggles.js.map +7 -0
  262. package/dist/modules/wms/migrations/Migration20260428110546.js +78 -0
  263. package/dist/modules/wms/migrations/Migration20260428110546.js.map +7 -0
  264. package/dist/modules/wms/migrations/Migration20260527120000.js +15 -0
  265. package/dist/modules/wms/migrations/Migration20260527120000.js.map +7 -0
  266. package/dist/modules/wms/migrations/Migration20260527140000.js +37 -0
  267. package/dist/modules/wms/migrations/Migration20260527140000.js.map +7 -0
  268. package/dist/modules/wms/migrations/Migration20260613120000.js +23 -0
  269. package/dist/modules/wms/migrations/Migration20260613120000.js.map +7 -0
  270. package/dist/modules/wms/migrations/Migration20260616090000.js +13 -0
  271. package/dist/modules/wms/migrations/Migration20260616090000.js.map +7 -0
  272. package/dist/modules/wms/migrations/Migration20260707180000.js +15 -0
  273. package/dist/modules/wms/migrations/Migration20260707180000.js.map +7 -0
  274. package/dist/modules/wms/notifications.client.js +18 -0
  275. package/dist/modules/wms/notifications.client.js.map +7 -0
  276. package/dist/modules/wms/notifications.js +53 -0
  277. package/dist/modules/wms/notifications.js.map +7 -0
  278. package/dist/modules/wms/search.js +196 -0
  279. package/dist/modules/wms/search.js.map +7 -0
  280. package/dist/modules/wms/setup.js +30 -0
  281. package/dist/modules/wms/setup.js.map +7 -0
  282. package/dist/modules/wms/subscribers/low-stock-notification.js +40 -0
  283. package/dist/modules/wms/subscribers/low-stock-notification.js.map +7 -0
  284. package/dist/modules/wms/subscribers/reservation-shortfall-notification.js +69 -0
  285. package/dist/modules/wms/subscribers/reservation-shortfall-notification.js.map +7 -0
  286. package/dist/modules/wms/subscribers/sales-order-cancelled-release.js +14 -0
  287. package/dist/modules/wms/subscribers/sales-order-cancelled-release.js.map +7 -0
  288. package/dist/modules/wms/subscribers/sales-order-confirmed-reserve.js +14 -0
  289. package/dist/modules/wms/subscribers/sales-order-confirmed-reserve.js.map +7 -0
  290. package/dist/modules/wms/translations.js +10 -0
  291. package/dist/modules/wms/translations.js.map +7 -0
  292. package/dist/modules/wms/vector.js +9 -0
  293. package/dist/modules/wms/vector.js.map +7 -0
  294. package/dist/modules/wms/widgets/injection/catalog-inventory-profile/widget.js +200 -0
  295. package/dist/modules/wms/widgets/injection/catalog-inventory-profile/widget.js.map +7 -0
  296. package/dist/modules/wms/widgets/injection/order-items-stock-column/widget.js +104 -0
  297. package/dist/modules/wms/widgets/injection/order-items-stock-column/widget.js.map +7 -0
  298. package/dist/modules/wms/widgets/injection/sales-order-stock-context/widget.client.js +389 -0
  299. package/dist/modules/wms/widgets/injection/sales-order-stock-context/widget.client.js.map +7 -0
  300. package/dist/modules/wms/widgets/injection/sales-order-stock-context/widget.js +16 -0
  301. package/dist/modules/wms/widgets/injection/sales-order-stock-context/widget.js.map +7 -0
  302. package/dist/modules/wms/widgets/injection-table.js +36 -0
  303. package/dist/modules/wms/widgets/injection-table.js.map +7 -0
  304. package/dist/modules/wms/widgets/notifications/WmsLowStockRenderer.js +150 -0
  305. package/dist/modules/wms/widgets/notifications/WmsLowStockRenderer.js.map +7 -0
  306. package/dist/modules/wms/widgets/notifications/WmsReservationShortfallRenderer.js +186 -0
  307. package/dist/modules/wms/widgets/notifications/WmsReservationShortfallRenderer.js.map +7 -0
  308. package/dist/modules/wms/widgets/notifications/index.js +7 -0
  309. package/dist/modules/wms/widgets/notifications/index.js.map +7 -0
  310. package/generated/entities/inventory_balance/index.ts +9 -0
  311. package/generated/entities/inventory_lot/index.ts +8 -0
  312. package/generated/entities/inventory_movement/index.ts +16 -0
  313. package/generated/entities/inventory_reservation/index.ts +10 -0
  314. package/generated/entities/product_inventory_profile/index.ts +9 -0
  315. package/generated/entities/sales_order_warehouse_assignment/index.ts +4 -0
  316. package/generated/entities/warehouse/index.ts +11 -0
  317. package/generated/entities/warehouse_location/index.ts +9 -0
  318. package/generated/entities/warehouse_zone/index.ts +4 -0
  319. package/generated/entities.ids.generated.ts +12 -0
  320. package/generated/entity-fields-registry.ts +98 -0
  321. package/package.json +7 -7
  322. package/src/modules/auth/backend/roles/page.tsx +13 -4
  323. package/src/modules/auth/i18n/de.json +2 -0
  324. package/src/modules/auth/i18n/en.json +2 -0
  325. package/src/modules/auth/i18n/es.json +2 -0
  326. package/src/modules/auth/i18n/pl.json +2 -0
  327. package/src/modules/auth/lib/backendChrome.tsx +1 -0
  328. package/src/modules/auth/services/rbacService.ts +25 -21
  329. package/src/modules/catalog/api/products/route.ts +3 -0
  330. package/src/modules/catalog/api/variants/route.ts +3 -0
  331. package/src/modules/query_index/lib/engine.ts +18 -6
  332. package/src/modules/sales/api/documents/factory.ts +1 -0
  333. package/src/modules/sales/commands/documents.ts +71 -0
  334. package/src/modules/sales/components/documents/ItemsSection.tsx +58 -0
  335. package/src/modules/sales/events.ts +2 -0
  336. package/src/modules/sales/widgets/injection/order-items-context.ts +15 -0
  337. package/src/modules/wms/acl.ts +14 -0
  338. package/src/modules/wms/analytics.ts +9 -0
  339. package/src/modules/wms/api/dashboard/operational/route.ts +83 -0
  340. package/src/modules/wms/api/interceptors.ts +108 -0
  341. package/src/modules/wms/api/inventory/adjust/route.ts +50 -0
  342. package/src/modules/wms/api/inventory/allocate/route.ts +50 -0
  343. package/src/modules/wms/api/inventory/balances/route.ts +178 -0
  344. package/src/modules/wms/api/inventory/cycle-count/route.ts +51 -0
  345. package/src/modules/wms/api/inventory/helpers.ts +128 -0
  346. package/src/modules/wms/api/inventory/import/apply/route.ts +47 -0
  347. package/src/modules/wms/api/inventory/import/helpers.ts +223 -0
  348. package/src/modules/wms/api/inventory/import/template/route.ts +31 -0
  349. package/src/modules/wms/api/inventory/import/validate/route.ts +56 -0
  350. package/src/modules/wms/api/inventory/move/route.ts +50 -0
  351. package/src/modules/wms/api/inventory/movements/route.ts +164 -0
  352. package/src/modules/wms/api/inventory/receive/route.ts +49 -0
  353. package/src/modules/wms/api/inventory/release/route.ts +43 -0
  354. package/src/modules/wms/api/inventory/reservations/route.ts +128 -0
  355. package/src/modules/wms/api/inventory/reserve/route.ts +59 -0
  356. package/src/modules/wms/api/inventory-profiles/route.ts +177 -0
  357. package/src/modules/wms/api/listEnrichers.ts +312 -0
  358. package/src/modules/wms/api/listSearch.ts +121 -0
  359. package/src/modules/wms/api/locations/route.ts +171 -0
  360. package/src/modules/wms/api/lots/route.ts +205 -0
  361. package/src/modules/wms/api/openapi.ts +28 -0
  362. package/src/modules/wms/api/sales-orders/[salesOrderId]/re-run-reservation/route.ts +58 -0
  363. package/src/modules/wms/api/sales-orders/[salesOrderId]/warehouse-assignment/route.ts +306 -0
  364. package/src/modules/wms/api/sales-orders/assign-warehouse/route.ts +57 -0
  365. package/src/modules/wms/api/sales-orders/unassign-warehouse/route.ts +43 -0
  366. package/src/modules/wms/api/warehouses/route.ts +181 -0
  367. package/src/modules/wms/api/zones/route.ts +158 -0
  368. package/src/modules/wms/backend/config/wms/page.meta.ts +14 -0
  369. package/src/modules/wms/backend/config/wms/page.tsx +5 -0
  370. package/src/modules/wms/backend/page.meta.ts +12 -0
  371. package/src/modules/wms/backend/page.tsx +5 -0
  372. package/src/modules/wms/backend/wms/inventory/page.meta.ts +14 -0
  373. package/src/modules/wms/backend/wms/inventory/page.tsx +5 -0
  374. package/src/modules/wms/backend/wms/location/[id]/page.meta.ts +14 -0
  375. package/src/modules/wms/backend/wms/location/[id]/page.tsx +5 -0
  376. package/src/modules/wms/backend/wms/locations/page.meta.ts +14 -0
  377. package/src/modules/wms/backend/wms/locations/page.tsx +12 -0
  378. package/src/modules/wms/backend/wms/lot/[id]/page.meta.ts +14 -0
  379. package/src/modules/wms/backend/wms/lot/[id]/page.tsx +5 -0
  380. package/src/modules/wms/backend/wms/lots/page.meta.ts +14 -0
  381. package/src/modules/wms/backend/wms/lots/page.tsx +5 -0
  382. package/src/modules/wms/backend/wms/movements/page.meta.ts +14 -0
  383. package/src/modules/wms/backend/wms/movements/page.tsx +23 -0
  384. package/src/modules/wms/backend/wms/reservations/page.meta.ts +14 -0
  385. package/src/modules/wms/backend/wms/reservations/page.tsx +24 -0
  386. package/src/modules/wms/backend/wms/sku/[id]/page.meta.ts +14 -0
  387. package/src/modules/wms/backend/wms/sku/[id]/page.tsx +5 -0
  388. package/src/modules/wms/backend/wms/warehouses/page.meta.ts +14 -0
  389. package/src/modules/wms/backend/wms/warehouses/page.tsx +12 -0
  390. package/src/modules/wms/backend/wms/zones/page.meta.ts +14 -0
  391. package/src/modules/wms/backend/wms/zones/page.tsx +12 -0
  392. package/src/modules/wms/ce.ts +76 -0
  393. package/src/modules/wms/cli.ts +96 -0
  394. package/src/modules/wms/commands/configuration.ts +1844 -0
  395. package/src/modules/wms/commands/index.ts +3 -0
  396. package/src/modules/wms/commands/inventory-actions.ts +1866 -0
  397. package/src/modules/wms/commands/sales-order-assignment.ts +346 -0
  398. package/src/modules/wms/commands/shared.ts +90 -0
  399. package/src/modules/wms/components/backend/AdjustInventoryDialog.tsx +820 -0
  400. package/src/modules/wms/components/backend/ChangeLotStatusDialog.tsx +312 -0
  401. package/src/modules/wms/components/backend/CycleCountWizardDialog.tsx +2007 -0
  402. package/src/modules/wms/components/backend/ImportInventoryDialog.tsx +1018 -0
  403. package/src/modules/wms/components/backend/InventoryOperationsSection.tsx +159 -0
  404. package/src/modules/wms/components/backend/LocationEditDialog.tsx +185 -0
  405. package/src/modules/wms/components/backend/MoveInventoryDialog.tsx +907 -0
  406. package/src/modules/wms/components/backend/ReceiveInventoryDialog.tsx +695 -0
  407. package/src/modules/wms/components/backend/ReleaseReservationDialog.tsx +424 -0
  408. package/src/modules/wms/components/backend/ReserveInventoryDialog.tsx +511 -0
  409. package/src/modules/wms/components/backend/WmsConfigurationPage.tsx +1340 -0
  410. package/src/modules/wms/components/backend/WmsInventoryConsolePage.tsx +1132 -0
  411. package/src/modules/wms/components/backend/WmsLocationDetailPage.tsx +1310 -0
  412. package/src/modules/wms/components/backend/WmsLotDetailPage.tsx +1355 -0
  413. package/src/modules/wms/components/backend/WmsLotsListPage.tsx +359 -0
  414. package/src/modules/wms/components/backend/WmsOperationalDashboardPage.tsx +958 -0
  415. package/src/modules/wms/components/backend/WmsSkuDetailPage.tsx +1245 -0
  416. package/src/modules/wms/components/backend/inventoryMutationLoaders.ts +960 -0
  417. package/src/modules/wms/components/backend/useWmsInventoryMutationAccess.ts +89 -0
  418. package/src/modules/wms/components/backend/useWmsInventoryScopeFromSearchParams.ts +32 -0
  419. package/src/modules/wms/components/backend/wmsLookupLoaders.ts +78 -0
  420. package/src/modules/wms/data/enrichers.ts +718 -0
  421. package/src/modules/wms/data/entities.ts +436 -0
  422. package/src/modules/wms/data/validators.ts +463 -0
  423. package/src/modules/wms/di.ts +25 -0
  424. package/src/modules/wms/events.ts +41 -0
  425. package/src/modules/wms/i18n/de.json +1051 -0
  426. package/src/modules/wms/i18n/en.json +1051 -0
  427. package/src/modules/wms/i18n/es.json +1051 -0
  428. package/src/modules/wms/i18n/pl.json +1051 -0
  429. package/src/modules/wms/index.ts +15 -0
  430. package/src/modules/wms/lib/catalogInventoryProfileIntent.ts +65 -0
  431. package/src/modules/wms/lib/catalogInventoryProfileSync.ts +199 -0
  432. package/src/modules/wms/lib/expiry.ts +30 -0
  433. package/src/modules/wms/lib/flashMutationError.ts +74 -0
  434. package/src/modules/wms/lib/inventoryDisplayUi.ts +249 -0
  435. package/src/modules/wms/lib/inventoryIdempotency.ts +54 -0
  436. package/src/modules/wms/lib/inventoryImportCsv.ts +212 -0
  437. package/src/modules/wms/lib/inventoryImportService.ts +629 -0
  438. package/src/modules/wms/lib/inventoryMutationUi.ts +21 -0
  439. package/src/modules/wms/lib/inventoryPolicy.ts +111 -0
  440. package/src/modules/wms/lib/inventoryReconciliation.ts +263 -0
  441. package/src/modules/wms/lib/inventoryTrackingValidation.ts +23 -0
  442. package/src/modules/wms/lib/loadOperationalDashboard.ts +776 -0
  443. package/src/modules/wms/lib/lowStockBalanceFilter.ts +74 -0
  444. package/src/modules/wms/lib/primaryWarehousePolicy.ts +46 -0
  445. package/src/modules/wms/lib/roleFeatures.ts +32 -0
  446. package/src/modules/wms/lib/salesOrderInventoryAutomation.ts +390 -0
  447. package/src/modules/wms/lib/salesOrderWarehouseAssignment.ts +78 -0
  448. package/src/modules/wms/lib/wmsIntegrationToggles.ts +81 -0
  449. package/src/modules/wms/migrations/.snapshot-open-mercato.json +2880 -0
  450. package/src/modules/wms/migrations/Migration20260428110546.ts +91 -0
  451. package/src/modules/wms/migrations/Migration20260527120000.ts +15 -0
  452. package/src/modules/wms/migrations/Migration20260527140000.ts +35 -0
  453. package/src/modules/wms/migrations/Migration20260613120000.ts +21 -0
  454. package/src/modules/wms/migrations/Migration20260616090000.ts +11 -0
  455. package/src/modules/wms/migrations/Migration20260707180000.ts +13 -0
  456. package/src/modules/wms/notifications.client.ts +18 -0
  457. package/src/modules/wms/notifications.ts +51 -0
  458. package/src/modules/wms/search.ts +230 -0
  459. package/src/modules/wms/setup.ts +29 -0
  460. package/src/modules/wms/subscribers/low-stock-notification.ts +54 -0
  461. package/src/modules/wms/subscribers/reservation-shortfall-notification.ts +98 -0
  462. package/src/modules/wms/subscribers/sales-order-cancelled-release.ts +21 -0
  463. package/src/modules/wms/subscribers/sales-order-confirmed-reserve.ts +21 -0
  464. package/src/modules/wms/translations.ts +6 -0
  465. package/src/modules/wms/vector.ts +7 -0
  466. package/src/modules/wms/widgets/injection/catalog-inventory-profile/widget.ts +238 -0
  467. package/src/modules/wms/widgets/injection/order-items-stock-column/widget.tsx +153 -0
  468. package/src/modules/wms/widgets/injection/sales-order-stock-context/widget.client.tsx +476 -0
  469. package/src/modules/wms/widgets/injection/sales-order-stock-context/widget.ts +15 -0
  470. package/src/modules/wms/widgets/injection-table.ts +34 -0
  471. package/src/modules/wms/widgets/notifications/WmsLowStockRenderer.tsx +153 -0
  472. package/src/modules/wms/widgets/notifications/WmsReservationShortfallRenderer.tsx +194 -0
  473. package/src/modules/wms/widgets/notifications/index.ts +2 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/wms/lib/catalogInventoryProfileIntent.ts"],
4
+ "sourcesContent": ["import { z } from 'zod'\n\nconst inventoryStrategySchema = z.enum(['fifo', 'lifo', 'fefo'])\n\nexport const catalogInventoryProfileIntentSchema = z.object({\n manageInventory: z.boolean(),\n defaultUom: z.string().trim().max(32).nullable().optional(),\n defaultStrategy: inventoryStrategySchema.optional(),\n trackLot: z.boolean().optional(),\n trackSerial: z.boolean().optional(),\n trackExpiration: z.boolean().optional(),\n reorderPoint: z.coerce.number().finite().min(0).nullable().optional(),\n safetyStock: z.coerce.number().finite().min(0).nullable().optional(),\n}).superRefine((payload, ctx) => {\n if (!payload.manageInventory) return\n\n if (!payload.defaultUom || payload.defaultUom.trim().length === 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['defaultUom'],\n message: 'wms.widgets.catalog.inventoryProfile.errors.defaultUomRequired',\n })\n }\n\n if (!payload.defaultStrategy) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['defaultStrategy'],\n message: 'wms.widgets.catalog.inventoryProfile.errors.strategyRequired',\n })\n }\n\n if (payload.trackExpiration && payload.defaultStrategy !== 'fefo') {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['defaultStrategy'],\n message: 'wms.widgets.catalog.inventoryProfile.errors.fefoRequired',\n })\n }\n})\n\nexport type CatalogInventoryProfileIntent = z.infer<\n typeof catalogInventoryProfileIntentSchema\n>\n\nexport const WMS_CATALOG_PROFILE_HEADER =\n 'x-open-mercato-wms-catalog-profile'\n\nexport function encodeCatalogInventoryProfileIntent(\n intent: CatalogInventoryProfileIntent,\n): string {\n return encodeURIComponent(JSON.stringify(intent))\n}\n\nexport function decodeCatalogInventoryProfileIntent(\n rawHeader: string | null | undefined,\n): CatalogInventoryProfileIntent | null {\n if (typeof rawHeader !== 'string' || rawHeader.trim().length === 0) {\n return null\n }\n\n const decoded = decodeURIComponent(rawHeader)\n const parsed = JSON.parse(decoded) as unknown\n return catalogInventoryProfileIntentSchema.parse(parsed)\n}\n"],
5
+ "mappings": "AAAA,SAAS,SAAS;AAElB,MAAM,0BAA0B,EAAE,KAAK,CAAC,QAAQ,QAAQ,MAAM,CAAC;AAExD,MAAM,sCAAsC,EAAE,OAAO;AAAA,EAC1D,iBAAiB,EAAE,QAAQ;AAAA,EAC3B,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,SAAS;AAAA,EAC1D,iBAAiB,wBAAwB,SAAS;AAAA,EAClD,UAAU,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC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findOneWithDecryption } from "@open-mercato/shared/lib/encryption/find";
2
+ import { E } from "../../../generated/entities.ids.generated.js";
3
+ import { ProductInventoryProfile } from "../data/entities.js";
4
+ import {
5
+ catalogInventoryProfileIntentSchema
6
+ } from "./catalogInventoryProfileIntent.js";
7
+ function normalizeOptionalString(value) {
8
+ if (typeof value !== "string") return null;
9
+ const trimmed = value.trim();
10
+ return trimmed.length > 0 ? trimmed : null;
11
+ }
12
+ function buildCommandContext(params) {
13
+ const auth = {
14
+ sub: params.userId,
15
+ userId: params.userId,
16
+ tenantId: params.tenantId,
17
+ orgId: params.organizationId
18
+ };
19
+ return {
20
+ container: params.container,
21
+ auth,
22
+ organizationScope: null,
23
+ selectedOrganizationId: params.organizationId,
24
+ organizationIds: [params.organizationId]
25
+ };
26
+ }
27
+ async function loadExistingProfile(params) {
28
+ const em = params.container.resolve("em");
29
+ const scope = {
30
+ organizationId: params.organizationId,
31
+ tenantId: params.tenantId
32
+ };
33
+ if (params.target === "variant") {
34
+ return findOneWithDecryption(
35
+ em,
36
+ ProductInventoryProfile,
37
+ {
38
+ organizationId: params.organizationId,
39
+ tenantId: params.tenantId,
40
+ deletedAt: null,
41
+ catalogVariantId: params.recordId
42
+ },
43
+ void 0,
44
+ scope
45
+ );
46
+ }
47
+ return findOneWithDecryption(
48
+ em,
49
+ ProductInventoryProfile,
50
+ {
51
+ organizationId: params.organizationId,
52
+ tenantId: params.tenantId,
53
+ deletedAt: null,
54
+ catalogProductId: params.catalogProductId,
55
+ catalogVariantId: null
56
+ },
57
+ void 0,
58
+ scope
59
+ );
60
+ }
61
+ async function resolveCatalogProductId(params) {
62
+ if (params.target === "product") return params.recordId;
63
+ const queryEngine = params.container.resolve("queryEngine");
64
+ const result = await queryEngine.query(
65
+ E.catalog.catalog_product_variant,
66
+ {
67
+ tenantId: params.tenantId,
68
+ organizationId: params.organizationId,
69
+ filters: { id: { $eq: params.recordId } },
70
+ fields: ["id", "product_id"],
71
+ page: { page: 1, pageSize: 1 }
72
+ }
73
+ );
74
+ const variantRow = result.items[0];
75
+ if (!variantRow) {
76
+ throw new Error(`Variant ${params.recordId} not found for WMS profile sync`);
77
+ }
78
+ const productId = typeof variantRow.product_id === "string" ? variantRow.product_id : null;
79
+ if (!productId) {
80
+ throw new Error(
81
+ `Variant ${params.recordId} is missing product context for WMS profile sync`
82
+ );
83
+ }
84
+ return productId;
85
+ }
86
+ async function syncCatalogInventoryProfile(input) {
87
+ const intent = catalogInventoryProfileIntentSchema.parse(input.intent);
88
+ const commandBus = input.container.resolve("commandBus");
89
+ const ctx = buildCommandContext(input);
90
+ const catalogProductId = await resolveCatalogProductId({
91
+ target: input.target,
92
+ recordId: input.recordId,
93
+ organizationId: input.organizationId,
94
+ tenantId: input.tenantId,
95
+ container: input.container
96
+ });
97
+ const existingProfile = await loadExistingProfile({
98
+ organizationId: input.organizationId,
99
+ tenantId: input.tenantId,
100
+ target: input.target,
101
+ recordId: input.recordId,
102
+ catalogProductId,
103
+ container: input.container
104
+ });
105
+ if (!intent.manageInventory) {
106
+ if (!existingProfile) return;
107
+ await commandBus.execute("wms.inventoryProfiles.delete", {
108
+ input: { id: existingProfile.id },
109
+ ctx
110
+ });
111
+ return;
112
+ }
113
+ const profileInput = {
114
+ organizationId: input.organizationId,
115
+ tenantId: input.tenantId,
116
+ catalogProductId,
117
+ catalogVariantId: input.target === "variant" ? input.recordId : null,
118
+ defaultUom: normalizeOptionalString(intent.defaultUom),
119
+ defaultStrategy: intent.defaultStrategy,
120
+ trackLot: intent.trackLot ?? false,
121
+ trackSerial: intent.trackSerial ?? false,
122
+ trackExpiration: intent.trackExpiration ?? false,
123
+ reorderPoint: intent.reorderPoint ?? 0,
124
+ safetyStock: intent.safetyStock ?? 0
125
+ };
126
+ if (existingProfile) {
127
+ await commandBus.execute("wms.inventoryProfiles.update", {
128
+ input: {
129
+ id: existingProfile.id,
130
+ ...profileInput
131
+ },
132
+ ctx
133
+ });
134
+ return;
135
+ }
136
+ await commandBus.execute("wms.inventoryProfiles.create", {
137
+ input: profileInput,
138
+ ctx
139
+ });
140
+ }
141
+ export {
142
+ syncCatalogInventoryProfile
143
+ };
144
+ //# sourceMappingURL=catalogInventoryProfileSync.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/wms/lib/catalogInventoryProfileSync.ts"],
4
+ "sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport type { AwilixContainer } from 'awilix'\nimport type { CommandBus, CommandRuntimeContext } from '@open-mercato/shared/lib/commands'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport type { AuthContext } from '@open-mercato/shared/lib/auth/server'\nimport type { QueryEngine } from '@open-mercato/shared/lib/query/types'\nimport { E } from '#generated/entities.ids.generated'\nimport { ProductInventoryProfile } from '../data/entities'\nimport {\n catalogInventoryProfileIntentSchema,\n type CatalogInventoryProfileIntent,\n} from './catalogInventoryProfileIntent'\n\ntype SyncTarget = 'product' | 'variant'\n\ntype SyncCatalogInventoryProfileInput = {\n intent: CatalogInventoryProfileIntent\n target: SyncTarget\n recordId: string\n organizationId: string\n tenantId: string\n userId: string\n container: AwilixContainer\n}\n\nfunction normalizeOptionalString(value: unknown): string | null {\n if (typeof value !== 'string') return null\n const trimmed = value.trim()\n return trimmed.length > 0 ? trimmed : null\n}\n\nfunction buildCommandContext(params: {\n container: AwilixContainer\n organizationId: string\n tenantId: string\n userId: string\n}): CommandRuntimeContext {\n const auth: AuthContext = {\n sub: params.userId,\n userId: params.userId,\n tenantId: params.tenantId,\n orgId: params.organizationId,\n }\n\n return {\n container: params.container,\n auth,\n organizationScope: null,\n selectedOrganizationId: params.organizationId,\n organizationIds: [params.organizationId],\n }\n}\n\nasync function loadExistingProfile(params: {\n organizationId: string\n tenantId: string\n target: SyncTarget\n recordId: string\n catalogProductId: string\n container: AwilixContainer\n}) {\n const em = params.container.resolve('em') as EntityManager\n const scope = {\n organizationId: params.organizationId,\n tenantId: params.tenantId,\n }\n\n if (params.target === 'variant') {\n return findOneWithDecryption(\n em,\n ProductInventoryProfile,\n {\n organizationId: params.organizationId,\n tenantId: params.tenantId,\n deletedAt: null,\n catalogVariantId: params.recordId,\n } as never,\n undefined,\n scope,\n )\n }\n\n return findOneWithDecryption(\n em,\n ProductInventoryProfile,\n {\n organizationId: params.organizationId,\n tenantId: params.tenantId,\n deletedAt: null,\n catalogProductId: params.catalogProductId,\n catalogVariantId: null,\n } as never,\n undefined,\n scope,\n )\n}\n\nasync function resolveCatalogProductId(params: {\n target: SyncTarget\n recordId: string\n organizationId: string\n tenantId: string\n container: AwilixContainer\n}): Promise<string> {\n if (params.target === 'product') return params.recordId\n\n // Read the variant -> product_id mapping via QueryEngine so this module does\n // not import the catalog ORM entity directly. queryEngine resolves the\n // base table via Mikro-ORM metadata, so the only cross-module surface we\n // depend on is the public catalog entity id from the `E` registry.\n const queryEngine = params.container.resolve('queryEngine') as QueryEngine\n const result = await queryEngine.query<{ id?: string; product_id?: string }>(\n E.catalog.catalog_product_variant,\n {\n tenantId: params.tenantId,\n organizationId: params.organizationId,\n filters: { id: { $eq: params.recordId } },\n fields: ['id', 'product_id'],\n page: { page: 1, pageSize: 1 },\n },\n )\n\n const variantRow = result.items[0]\n if (!variantRow) {\n throw new Error(`Variant ${params.recordId} not found for WMS profile sync`)\n }\n\n const productId = typeof variantRow.product_id === 'string' ? variantRow.product_id : null\n if (!productId) {\n throw new Error(\n `Variant ${params.recordId} is missing product context for WMS profile sync`,\n )\n }\n\n return productId\n}\n\nexport async function syncCatalogInventoryProfile(\n input: SyncCatalogInventoryProfileInput,\n): Promise<void> {\n const intent = catalogInventoryProfileIntentSchema.parse(input.intent)\n const commandBus = input.container.resolve('commandBus') as CommandBus\n const ctx = buildCommandContext(input)\n const catalogProductId = await resolveCatalogProductId({\n target: input.target,\n recordId: input.recordId,\n organizationId: input.organizationId,\n tenantId: input.tenantId,\n container: input.container,\n })\n\n const existingProfile = await loadExistingProfile({\n organizationId: input.organizationId,\n tenantId: input.tenantId,\n target: input.target,\n recordId: input.recordId,\n catalogProductId,\n container: input.container,\n })\n\n if (!intent.manageInventory) {\n if (!existingProfile) return\n await commandBus.execute('wms.inventoryProfiles.delete', {\n input: { id: existingProfile.id },\n ctx,\n })\n return\n }\n\n const profileInput = {\n organizationId: input.organizationId,\n tenantId: input.tenantId,\n catalogProductId,\n catalogVariantId: input.target === 'variant' ? input.recordId : null,\n defaultUom: normalizeOptionalString(intent.defaultUom),\n defaultStrategy: intent.defaultStrategy,\n trackLot: intent.trackLot ?? false,\n trackSerial: intent.trackSerial ?? false,\n trackExpiration: intent.trackExpiration ?? false,\n reorderPoint: intent.reorderPoint ?? 0,\n safetyStock: intent.safetyStock ?? 0,\n }\n\n if (existingProfile) {\n await commandBus.execute('wms.inventoryProfiles.update', {\n input: {\n id: existingProfile.id,\n ...profileInput,\n },\n ctx,\n })\n return\n }\n\n await commandBus.execute('wms.inventoryProfiles.create', {\n input: profileInput,\n ctx,\n })\n}\n"],
5
+ "mappings": "AAGA,SAAS,6BAA6B;AAGtC,SAAS,SAAS;AAClB,SAAS,+BAA+B;AACxC;AAAA,EACE;AAAA,OAEK;AAcP,SAAS,wBAAwB,OAA+B;AAC9D,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,UAAU,MAAM,KAAK;AAC3B,SAAO,QAAQ,SAAS,IAAI,UAAU;AACxC;AAEA,SAAS,oBAAoB,QAKH;AACxB,QAAM,OAAoB;AAAA,IACxB,KAAK,OAAO;AAAA,IACZ,QAAQ,OAAO;AAAA,IACf,UAAU,OAAO;AAAA,IACjB,OAAO,OAAO;AAAA,EAChB;AAEA,SAAO;AAAA,IACL,WAAW,OAAO;AAAA,IAClB;AAAA,IACA,mBAAmB;AAAA,IACnB,wBAAwB,OAAO;AAAA,IAC/B,iBAAiB,CAAC,OAAO,cAAc;AAAA,EACzC;AACF;AAEA,eAAe,oBAAoB,QAOhC;AACD,QAAM,KAAK,OAAO,UAAU,QAAQ,IAAI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;AAAA,IACvD,OAAO;AAAA,IACP;AAAA,EACF,CAAC;AACH;",
6
+ "names": []
7
+ }
@@ -0,0 +1,29 @@
1
+ const EXPIRING_SOON_DAYS = 30;
2
+ function startOfUtcDay(date) {
3
+ return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()));
4
+ }
5
+ function addUtcDays(date, days) {
6
+ const next = new Date(date);
7
+ next.setUTCDate(next.getUTCDate() + days);
8
+ return next;
9
+ }
10
+ function buildExpiryWindowDateFilter(expiryWindow, now = /* @__PURE__ */ new Date()) {
11
+ const today = startOfUtcDay(now);
12
+ if (expiryWindow === "pastDue") {
13
+ return { expires_at: { $ne: null, $lt: today } };
14
+ }
15
+ return {
16
+ expires_at: {
17
+ $ne: null,
18
+ $gte: today,
19
+ $lte: addUtcDays(today, EXPIRING_SOON_DAYS)
20
+ }
21
+ };
22
+ }
23
+ export {
24
+ EXPIRING_SOON_DAYS,
25
+ addUtcDays,
26
+ buildExpiryWindowDateFilter,
27
+ startOfUtcDay
28
+ };
29
+ //# sourceMappingURL=expiry.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/wms/lib/expiry.ts"],
4
+ "sourcesContent": ["export const EXPIRING_SOON_DAYS = 30\n\nexport type ExpiryWindow = 'expiringSoon' | 'pastDue'\n\nexport function startOfUtcDay(date: Date): Date {\n return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()))\n}\n\nexport function addUtcDays(date: Date, days: number): Date {\n const next = new Date(date)\n next.setUTCDate(next.getUTCDate() + days)\n return next\n}\n\nexport function buildExpiryWindowDateFilter(\n expiryWindow: ExpiryWindow,\n now: Date = new Date(),\n): Record<string, unknown> {\n const today = startOfUtcDay(now)\n if (expiryWindow === 'pastDue') {\n return { expires_at: { $ne: null, $lt: today } }\n }\n return {\n expires_at: {\n $ne: null,\n $gte: today,\n $lte: addUtcDays(today, EXPIRING_SOON_DAYS),\n },\n }\n}\n"],
5
+ "mappings": "AAAO,MAAM,qBAAqB;AAI3B,SAAS,cAAc,MAAkB;AAC9C,SAAO,IAAI,KAAK,KAAK,IAAI,KAAK,eAAe,GAAG,KAAK,YAAY,GAAG,KAAK,WAAW,CAAC,CAAC;AACxF;AAEO,SAAS,WAAW,MAAY,MAAoB;AACzD,QAAM,OAAO,IAAI,KAAK,IAAI;AAC1B,OAAK,WAAW,KAAK,WAAW,IAAI,IAAI;AACxC,SAAO;AACT;AAEO,SAAS,4BACd,cACA,MAAY,oBAAI,KAAK,GACI;AACzB,QAAM,QAAQ,cAAc,GAAG;AAC/B,MAAI,iBAAiB,WAAW;AAC9B,WAAO,EAAE,YAAY,EAAE,KAAK,MAAM,KAAK,MAAM,EAAE;AAAA,EACjD;AACA,SAAO;AAAA,IACL,YAAY;AAAA,MACV,KAAK;AAAA,MACL,MAAM;AAAA,MACN,MAAM,WAAW,OAAO,kBAAkB;AAAA,IAC5C;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,51 @@
1
+ import { flash } from "@open-mercato/ui/backend/FlashMessages";
2
+ const FORBIDDEN_FEATURE_MESSAGE_KEYS = {
3
+ "wms.manage_warehouses": "wms.errors.forbidden.manageWarehouses",
4
+ "wms.manage_zones": "wms.errors.forbidden.manageZones",
5
+ "wms.manage_locations": "wms.errors.forbidden.manageLocations",
6
+ "wms.manage_inventory": "wms.errors.forbidden.manageInventory",
7
+ "wms.manage_reservations": "wms.errors.forbidden.manageReservations",
8
+ "wms.adjust_inventory": "wms.errors.forbidden.adjustInventory",
9
+ "wms.receive_inventory": "wms.errors.forbidden.receiveInventory",
10
+ "wms.cycle_count": "wms.errors.forbidden.cycleCount",
11
+ "wms.import": "wms.errors.forbidden.import"
12
+ };
13
+ const FORBIDDEN_FEATURE_MESSAGE_FALLBACKS = {
14
+ "wms.manage_warehouses": "You don't have permission to manage warehouses.",
15
+ "wms.manage_zones": "You don't have permission to manage warehouse zones.",
16
+ "wms.manage_locations": "You don't have permission to manage warehouse locations.",
17
+ "wms.manage_inventory": "You don't have permission to manage inventory profiles.",
18
+ "wms.manage_reservations": "You don't have permission to manage inventory reservations.",
19
+ "wms.adjust_inventory": "You don't have permission to adjust or move inventory.",
20
+ "wms.receive_inventory": "You don't have permission to receive inbound inventory.",
21
+ "wms.cycle_count": "You don't have permission to run cycle counts.",
22
+ "wms.import": "You don't have permission to import inventory."
23
+ };
24
+ function resolveForbiddenFeatureMessage(error, t) {
25
+ if (!error || typeof error !== "object") return null;
26
+ const status = error.status;
27
+ if (status !== 403) return null;
28
+ const requiredFeatures = error.requiredFeatures;
29
+ if (!Array.isArray(requiredFeatures)) return null;
30
+ const knownFeature = requiredFeatures.find(
31
+ (feature) => typeof feature === "string" && feature in FORBIDDEN_FEATURE_MESSAGE_KEYS
32
+ );
33
+ if (!knownFeature) return null;
34
+ const key = FORBIDDEN_FEATURE_MESSAGE_KEYS[knownFeature];
35
+ const fallback = FORBIDDEN_FEATURE_MESSAGE_FALLBACKS[knownFeature];
36
+ return t ? t(key, fallback) : fallback;
37
+ }
38
+ function flashMutationError(error, fallbackMessage, t) {
39
+ const forbiddenMessage = resolveForbiddenFeatureMessage(error, t);
40
+ if (forbiddenMessage) {
41
+ flash(forbiddenMessage, "error");
42
+ return;
43
+ }
44
+ const rawMessage = error instanceof Error ? error.message.trim() : "";
45
+ const isGenericForbidden = rawMessage.length === 0 || /^forbidden$/i.test(rawMessage);
46
+ flash(isGenericForbidden ? fallbackMessage : rawMessage, "error");
47
+ }
48
+ export {
49
+ flashMutationError
50
+ };
51
+ //# sourceMappingURL=flashMutationError.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/wms/lib/flashMutationError.ts"],
4
+ "sourcesContent": ["import { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport type { TranslateFn } from '@open-mercato/shared/lib/i18n/context'\n\n/**\n * Maps a `requireFeatures` ACL feature id to the i18n key that names the\n * specific permission a 403 response is missing (#4102 follow-up \u2014 the\n * generic \"Forbidden\" toast didn't say what was denied).\n */\nconst FORBIDDEN_FEATURE_MESSAGE_KEYS: Record<string, string> = {\n 'wms.manage_warehouses': 'wms.errors.forbidden.manageWarehouses',\n 'wms.manage_zones': 'wms.errors.forbidden.manageZones',\n 'wms.manage_locations': 'wms.errors.forbidden.manageLocations',\n 'wms.manage_inventory': 'wms.errors.forbidden.manageInventory',\n 'wms.manage_reservations': 'wms.errors.forbidden.manageReservations',\n 'wms.adjust_inventory': 'wms.errors.forbidden.adjustInventory',\n 'wms.receive_inventory': 'wms.errors.forbidden.receiveInventory',\n 'wms.cycle_count': 'wms.errors.forbidden.cycleCount',\n 'wms.import': 'wms.errors.forbidden.import',\n}\n\nconst FORBIDDEN_FEATURE_MESSAGE_FALLBACKS: Record<string, string> = {\n 'wms.manage_warehouses': \"You don't have permission to manage warehouses.\",\n 'wms.manage_zones': \"You don't have permission to manage warehouse zones.\",\n 'wms.manage_locations': \"You don't have permission to manage warehouse locations.\",\n 'wms.manage_inventory': \"You don't have permission to manage inventory profiles.\",\n 'wms.manage_reservations': \"You don't have permission to manage inventory reservations.\",\n 'wms.adjust_inventory': \"You don't have permission to adjust or move inventory.\",\n 'wms.receive_inventory': \"You don't have permission to receive inbound inventory.\",\n 'wms.cycle_count': \"You don't have permission to run cycle counts.\",\n 'wms.import': \"You don't have permission to import inventory.\",\n}\n\n/**\n * Reads the 403 response's `requiredFeatures` (attached to the thrown error\n * by `raiseCrudError`) and, when the missing feature is a known WMS\n * permission, resolves a translated message naming it. Returns `null` when\n * the error isn't a recognized 403-with-features shape so callers can fall\n * back to the generic message.\n */\nfunction resolveForbiddenFeatureMessage(error: unknown, t?: TranslateFn): string | null {\n if (!error || typeof error !== 'object') return null\n const status = (error as Record<string, unknown>).status\n if (status !== 403) return null\n const requiredFeatures = (error as Record<string, unknown>).requiredFeatures\n if (!Array.isArray(requiredFeatures)) return null\n const knownFeature = requiredFeatures.find(\n (feature): feature is string => typeof feature === 'string' && feature in FORBIDDEN_FEATURE_MESSAGE_KEYS,\n )\n if (!knownFeature) return null\n const key = FORBIDDEN_FEATURE_MESSAGE_KEYS[knownFeature]\n const fallback = FORBIDDEN_FEATURE_MESSAGE_FALLBACKS[knownFeature]\n return t ? t(key, fallback) : fallback\n}\n\n/**\n * Surfaces a mutation failure as an error flash toast. Prefers a\n * feature-specific 403 message derived from the server's `requiredFeatures`\n * hint (#4102 follow-up), then the thrown error's own message (already\n * server-derived and translated by `raiseCrudError`/`useGuardedMutation`),\n * and falls back to a translated, dialog-specific message otherwise (#4103).\n */\nexport function flashMutationError(error: unknown, fallbackMessage: string, t?: TranslateFn): void {\n const forbiddenMessage = resolveForbiddenFeatureMessage(error, t)\n if (forbiddenMessage) {\n flash(forbiddenMessage, 'error')\n return\n }\n // apiFetch throws ForbiddenError with a bare \"Forbidden\" message when the\n // ACL body has no mappable feature \u2014 prefer the dialog-specific fallback\n // over flashing the untranslated server token.\n const rawMessage = error instanceof Error ? error.message.trim() : ''\n const isGenericForbidden = rawMessage.length === 0 || /^forbidden$/i.test(rawMessage)\n flash(isGenericForbidden ? fallbackMessage : rawMessage, 'error')\n}\n"],
5
+ "mappings": "AAAA,SAAS,aAAa;AAQtB,MAAM,iCAAyD;AAAA,EAC7D,yBAAyB;AAAA,EACzB,oBAAoB;AAAA,EACpB,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,2BAA2B;AAAA,EAC3B,wBAAwB;AAAA,EACxB,yBAAyB;AAAA,EACzB,mBAAmB;AAAA,EACnB,cAAc;AAChB;AAEA,MAAM,sCAA8D;AAAA,EAClE,yBAAyB;AAAA,EACzB,oBAAoB;AAAA,EACpB,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,2BAA2B;AAAA,EAC3B,wBAAwB;AAAA,EACxB,yBAAyB;AAAA,EACzB,mBAAmB;AAAA,EACnB,cAAc;AAChB;AASA,SAAS,+BAA+B,OAAgB,GAAgC;AACtF,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAM,SAAU,MAAkC;AAClD,MAAI,WAAW,IAAK,QAAO;AAC3B,QAAM,mBAAoB,MAAkC;AAC5D,MAAI,CAAC,MAAM,QAAQ,gBAAgB,EAAG,QAAO;AAC7C,QAAM,eAAe,iBAAiB;AAAA,IACpC,CAAC,YAA+B,OAAO,YAAY,YAAY,WAAW;AAAA,EAC5E;AACA,MAAI,CAAC,aAAc,QAAO;AAC1B,QAAM,MAAM,+BAA+B,YAAY;AACvD,QAAM,WAAW,oCAAoC,YAAY;AACjE,SAAO,IAAI,EAAE,KAAK,QAAQ,IAAI;AAChC;AASO,SAAS,mBAAmB,OAAgB,iBAAyB,GAAuB;AACjG,QAAM,mBAAmB,+BAA+B,OAAO,CAAC;AAChE,MAAI,kBAAkB;AACpB,UAAM,kBAAkB,OAAO;AAC/B;AAAA,EACF;AAIA,QAAM,aAAa,iBAAiB,QAAQ,MAAM,QAAQ,KAAK,IAAI;AACnE,QAAM,qBAAqB,WAAW,WAAW,KAAK,eAAe,KAAK,UAAU;AACpF,QAAM,qBAAqB,kBAAkB,YAAY,OAAO;AAClE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,188 @@
1
+ import { parseInventoryQuantity } from "./inventoryMutationUi.js";
2
+ const MOVEMENT_TYPE_FALLBACKS = {
3
+ receipt: "Receive",
4
+ return_receive: "Receive",
5
+ adjust: "Adjust",
6
+ transfer: "Move",
7
+ pick: "Allocate",
8
+ pack: "Allocate",
9
+ cycle_count: "Reconcile",
10
+ putaway: "Putaway",
11
+ ship: "Ship"
12
+ };
13
+ const RESERVATION_SOURCE_TYPE_FALLBACKS = {
14
+ order: "Sales order",
15
+ transfer: "Transfer",
16
+ manual: "Manual"
17
+ };
18
+ const REFERENCE_TYPE_FALLBACKS = {
19
+ po: "Purchase order",
20
+ so: "Sales order",
21
+ transfer: "Transfer",
22
+ manual: "Manual",
23
+ qc: "Quality control",
24
+ rma: "RMA"
25
+ };
26
+ const RESERVATION_STATUS_FALLBACKS = {
27
+ active: "Active",
28
+ released: "Released",
29
+ fulfilled: "Fulfilled"
30
+ };
31
+ const ROTATION_STRATEGY_FALLBACKS = {
32
+ fifo: "FIFO",
33
+ lifo: "LIFO",
34
+ fefo: "FEFO"
35
+ };
36
+ const ADJUST_REASON_FALLBACKS = {
37
+ damaged: "Damaged",
38
+ shrinkage: "Shrinkage",
39
+ found: "Found stock",
40
+ correction: "Correction",
41
+ other: "Other"
42
+ };
43
+ const MOVE_REASON_FALLBACKS = {
44
+ transfer: "Transfer",
45
+ replenishment: "Replenishment",
46
+ consolidation: "Consolidation",
47
+ correction: "Correction",
48
+ other: "Other"
49
+ };
50
+ const RELEASE_REASON_FALLBACKS = {
51
+ order_cancelled: "Order cancelled",
52
+ manual_release: "Manual release",
53
+ correction: "Correction",
54
+ other: "Other"
55
+ };
56
+ const STABLE_REASON_CODE_PATTERN = /^[a-z][a-z0-9_]*$/;
57
+ function createInventoryQuantityFormatter(locale) {
58
+ return new Intl.NumberFormat(locale, { maximumFractionDigits: 2 });
59
+ }
60
+ function formatInventoryQuantity(value, formatter) {
61
+ return formatter.format(parseInventoryQuantity(value));
62
+ }
63
+ function createInventoryDateTimeFormatter(locale, options = {
64
+ month: "2-digit",
65
+ day: "2-digit",
66
+ hour: "2-digit",
67
+ minute: "2-digit"
68
+ }) {
69
+ return new Intl.DateTimeFormat(locale, options);
70
+ }
71
+ function formatInventoryDateTime(value, formatter) {
72
+ if (!value?.trim()) return "\u2014";
73
+ const date = new Date(value);
74
+ if (Number.isNaN(date.getTime())) return "\u2014";
75
+ return formatter.format(date);
76
+ }
77
+ function inventoryMovementTypeLabel(type, t) {
78
+ const normalized = type.trim();
79
+ if (!normalized) return "\u2014";
80
+ return t(
81
+ `wms.backend.dashboard.activity.types.${normalized}`,
82
+ MOVEMENT_TYPE_FALLBACKS[normalized] ?? normalized
83
+ );
84
+ }
85
+ function inventoryReservationSourceTypeLabel(sourceType, t) {
86
+ const normalized = sourceType.trim();
87
+ if (!normalized) return "\u2014";
88
+ return t(
89
+ `wms.backend.inventory.sourceTypes.${normalized}`,
90
+ RESERVATION_SOURCE_TYPE_FALLBACKS[normalized] ?? normalized
91
+ );
92
+ }
93
+ function inventoryReferenceTypeLabel(referenceType, t) {
94
+ const normalized = referenceType.trim();
95
+ if (!normalized) return "\u2014";
96
+ return t(
97
+ `wms.backend.inventory.referenceTypes.${normalized}`,
98
+ REFERENCE_TYPE_FALLBACKS[normalized] ?? normalized
99
+ );
100
+ }
101
+ function inventoryReservationStatusLabel(status, t) {
102
+ const normalized = status.trim();
103
+ if (!normalized) return "\u2014";
104
+ return t(
105
+ `wms.backend.inventory.reservationStatuses.${normalized}`,
106
+ RESERVATION_STATUS_FALLBACKS[normalized] ?? normalized
107
+ );
108
+ }
109
+ function inventoryRotationStrategyLabel(strategy, t) {
110
+ const normalized = strategy.trim();
111
+ if (!normalized) return "\u2014";
112
+ return t(
113
+ `wms.widgets.catalog.inventoryProfile.strategy.${normalized}`,
114
+ ROTATION_STRATEGY_FALLBACKS[normalized] ?? normalized
115
+ );
116
+ }
117
+ function translateStableReasonCode(code, movementType, t) {
118
+ if (code === "cycle_count") {
119
+ return t("wms.backend.dashboard.activity.reasons.cycleCount", "Cycle count");
120
+ }
121
+ const type = (movementType ?? "").trim();
122
+ if (type === "transfer" && code in MOVE_REASON_FALLBACKS) {
123
+ return t(`wms.backend.inventory.move.reasons.${code}`, MOVE_REASON_FALLBACKS[code]);
124
+ }
125
+ if ((type === "adjust" || type === "cycle_count") && code in ADJUST_REASON_FALLBACKS) {
126
+ return t(`wms.backend.inventory.adjust.reasons.${code}`, ADJUST_REASON_FALLBACKS[code]);
127
+ }
128
+ if (code in ADJUST_REASON_FALLBACKS) {
129
+ return t(`wms.backend.inventory.adjust.reasons.${code}`, ADJUST_REASON_FALLBACKS[code]);
130
+ }
131
+ if (code in MOVE_REASON_FALLBACKS) {
132
+ return t(`wms.backend.inventory.move.reasons.${code}`, MOVE_REASON_FALLBACKS[code]);
133
+ }
134
+ if (code in RELEASE_REASON_FALLBACKS) {
135
+ return t(`wms.backend.inventory.release.reasons.${code}`, RELEASE_REASON_FALLBACKS[code]);
136
+ }
137
+ return null;
138
+ }
139
+ function inventoryMovementReasonLabel(input, t) {
140
+ const reasonCode = input.reasonCode?.trim() || null;
141
+ const reason = input.reason?.trim() || null;
142
+ const candidateCode = reasonCode || (reason && STABLE_REASON_CODE_PATTERN.test(reason) ? reason : null);
143
+ if (candidateCode) {
144
+ const translated = translateStableReasonCode(candidateCode, input.movementType, t);
145
+ if (translated) return translated;
146
+ }
147
+ return reason;
148
+ }
149
+ function formatCatalogProductLabel(row) {
150
+ const title = (row.product_title ?? "").trim();
151
+ const sku = (row.product_sku ?? "").trim();
152
+ if (title && sku) return `${title} (${sku})`;
153
+ if (title) return title;
154
+ if (sku) return sku;
155
+ return row.catalog_product_id?.trim() || "\u2014";
156
+ }
157
+ function formatCatalogVariantLabel(row) {
158
+ const name = (row.variant_name ?? "").trim();
159
+ const sku = (row.variant_sku ?? "").trim();
160
+ if (name && sku) return `${name} (${sku})`;
161
+ if (name) return name;
162
+ if (sku) return sku;
163
+ return row.catalog_variant_id?.trim() || "\u2014";
164
+ }
165
+ function formatReservationSourceLabel(row, t) {
166
+ const sourceType = row.source_type?.trim();
167
+ if (!sourceType) return "\u2014";
168
+ const typeLabel = inventoryReservationSourceTypeLabel(sourceType, t);
169
+ const sourceLabel = row.source_label?.trim();
170
+ if (sourceLabel) return `${typeLabel} \xB7 ${sourceLabel}`;
171
+ return typeLabel;
172
+ }
173
+ export {
174
+ createInventoryDateTimeFormatter,
175
+ createInventoryQuantityFormatter,
176
+ formatCatalogProductLabel,
177
+ formatCatalogVariantLabel,
178
+ formatInventoryDateTime,
179
+ formatInventoryQuantity,
180
+ formatReservationSourceLabel,
181
+ inventoryMovementReasonLabel,
182
+ inventoryMovementTypeLabel,
183
+ inventoryReferenceTypeLabel,
184
+ inventoryReservationSourceTypeLabel,
185
+ inventoryReservationStatusLabel,
186
+ inventoryRotationStrategyLabel
187
+ };
188
+ //# sourceMappingURL=inventoryDisplayUi.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/wms/lib/inventoryDisplayUi.ts"],
4
+ "sourcesContent": ["import type { TranslateFn } from '@open-mercato/shared/lib/i18n/context'\nimport { parseInventoryQuantity } from './inventoryMutationUi'\n\nexport type InventoryDisplayTranslator = TranslateFn\n\nconst MOVEMENT_TYPE_FALLBACKS: Record<string, string> = {\n receipt: 'Receive',\n return_receive: 'Receive',\n adjust: 'Adjust',\n transfer: 'Move',\n pick: 'Allocate',\n pack: 'Allocate',\n cycle_count: 'Reconcile',\n putaway: 'Putaway',\n ship: 'Ship',\n}\n\nconst RESERVATION_SOURCE_TYPE_FALLBACKS: Record<string, string> = {\n order: 'Sales order',\n transfer: 'Transfer',\n manual: 'Manual',\n}\n\nconst REFERENCE_TYPE_FALLBACKS: Record<string, string> = {\n po: 'Purchase order',\n so: 'Sales order',\n transfer: 'Transfer',\n manual: 'Manual',\n qc: 'Quality control',\n rma: 'RMA',\n}\n\nconst RESERVATION_STATUS_FALLBACKS: Record<string, string> = {\n active: 'Active',\n released: 'Released',\n fulfilled: 'Fulfilled',\n}\n\nconst ROTATION_STRATEGY_FALLBACKS: Record<string, string> = {\n fifo: 'FIFO',\n lifo: 'LIFO',\n fefo: 'FEFO',\n}\n\nconst ADJUST_REASON_FALLBACKS: Record<string, string> = {\n damaged: 'Damaged',\n shrinkage: 'Shrinkage',\n found: 'Found stock',\n correction: 'Correction',\n other: 'Other',\n}\n\nconst MOVE_REASON_FALLBACKS: Record<string, string> = {\n transfer: 'Transfer',\n replenishment: 'Replenishment',\n consolidation: 'Consolidation',\n correction: 'Correction',\n other: 'Other',\n}\n\nconst RELEASE_REASON_FALLBACKS: Record<string, string> = {\n order_cancelled: 'Order cancelled',\n manual_release: 'Manual release',\n correction: 'Correction',\n other: 'Other',\n}\n\nconst STABLE_REASON_CODE_PATTERN = /^[a-z][a-z0-9_]*$/\n\nexport function createInventoryQuantityFormatter(locale: string): Intl.NumberFormat {\n return new Intl.NumberFormat(locale, { maximumFractionDigits: 2 })\n}\n\nexport function formatInventoryQuantity(\n value: string | number | null | undefined,\n formatter: Intl.NumberFormat,\n): string {\n return formatter.format(parseInventoryQuantity(value))\n}\n\nexport function createInventoryDateTimeFormatter(\n locale: string,\n options: Intl.DateTimeFormatOptions = {\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n },\n): Intl.DateTimeFormat {\n return new Intl.DateTimeFormat(locale, options)\n}\n\nexport function formatInventoryDateTime(\n value: string | null | undefined,\n formatter: Intl.DateTimeFormat,\n): string {\n if (!value?.trim()) return '\u2014'\n const date = new Date(value)\n if (Number.isNaN(date.getTime())) return '\u2014'\n return formatter.format(date)\n}\n\nexport function inventoryMovementTypeLabel(type: string, t: InventoryDisplayTranslator): string {\n const normalized = type.trim()\n if (!normalized) return '\u2014'\n return t(\n `wms.backend.dashboard.activity.types.${normalized}`,\n MOVEMENT_TYPE_FALLBACKS[normalized] ?? normalized,\n )\n}\n\nexport function inventoryReservationSourceTypeLabel(\n sourceType: string,\n t: InventoryDisplayTranslator,\n): string {\n const normalized = sourceType.trim()\n if (!normalized) return '\u2014'\n return t(\n `wms.backend.inventory.sourceTypes.${normalized}`,\n RESERVATION_SOURCE_TYPE_FALLBACKS[normalized] ?? normalized,\n )\n}\n\nexport function inventoryReferenceTypeLabel(\n referenceType: string,\n t: InventoryDisplayTranslator,\n): string {\n const normalized = referenceType.trim()\n if (!normalized) return '\u2014'\n return t(\n `wms.backend.inventory.referenceTypes.${normalized}`,\n REFERENCE_TYPE_FALLBACKS[normalized] ?? normalized,\n )\n}\n\nexport function inventoryReservationStatusLabel(status: string, t: InventoryDisplayTranslator): string {\n const normalized = status.trim()\n if (!normalized) return '\u2014'\n return t(\n `wms.backend.inventory.reservationStatuses.${normalized}`,\n RESERVATION_STATUS_FALLBACKS[normalized] ?? normalized,\n )\n}\n\nexport function inventoryRotationStrategyLabel(strategy: string, t: InventoryDisplayTranslator): string {\n const normalized = strategy.trim()\n if (!normalized) return '\u2014'\n return t(\n `wms.widgets.catalog.inventoryProfile.strategy.${normalized}`,\n ROTATION_STRATEGY_FALLBACKS[normalized] ?? normalized,\n )\n}\n\nfunction translateStableReasonCode(\n code: string,\n movementType: string | null | undefined,\n t: InventoryDisplayTranslator,\n): string | null {\n if (code === 'cycle_count') {\n return t('wms.backend.dashboard.activity.reasons.cycleCount', 'Cycle count')\n }\n\n const type = (movementType ?? '').trim()\n if (type === 'transfer' && code in MOVE_REASON_FALLBACKS) {\n return t(`wms.backend.inventory.move.reasons.${code}`, MOVE_REASON_FALLBACKS[code])\n }\n if ((type === 'adjust' || type === 'cycle_count') && code in ADJUST_REASON_FALLBACKS) {\n return t(`wms.backend.inventory.adjust.reasons.${code}`, ADJUST_REASON_FALLBACKS[code])\n }\n if (code in ADJUST_REASON_FALLBACKS) {\n return t(`wms.backend.inventory.adjust.reasons.${code}`, ADJUST_REASON_FALLBACKS[code])\n }\n if (code in MOVE_REASON_FALLBACKS) {\n return t(`wms.backend.inventory.move.reasons.${code}`, MOVE_REASON_FALLBACKS[code])\n }\n if (code in RELEASE_REASON_FALLBACKS) {\n return t(`wms.backend.inventory.release.reasons.${code}`, RELEASE_REASON_FALLBACKS[code])\n }\n return null\n}\n\n/**\n * Resolve a movement/activity reason for display. Prefers the stable\n * `reasonCode` (re-translated for the current locale) over a free-text\n * `reason` that may have been baked in a different language at write time.\n */\nexport function inventoryMovementReasonLabel(\n input: {\n reasonCode?: string | null\n reason?: string | null\n movementType?: string | null\n },\n t: InventoryDisplayTranslator,\n): string | null {\n const reasonCode = input.reasonCode?.trim() || null\n const reason = input.reason?.trim() || null\n const candidateCode =\n reasonCode ||\n (reason && STABLE_REASON_CODE_PATTERN.test(reason) ? reason : null)\n\n if (candidateCode) {\n const translated = translateStableReasonCode(candidateCode, input.movementType, t)\n if (translated) return translated\n }\n\n return reason\n}\n\nexport function formatCatalogProductLabel(row: {\n product_title?: string | null\n product_sku?: string | null\n catalog_product_id?: string | null\n}): string {\n const title = (row.product_title ?? '').trim()\n const sku = (row.product_sku ?? '').trim()\n if (title && sku) return `${title} (${sku})`\n if (title) return title\n if (sku) return sku\n return row.catalog_product_id?.trim() || '\u2014'\n}\n\nexport function formatCatalogVariantLabel(row: {\n variant_name?: string | null\n variant_sku?: string | null\n catalog_variant_id?: string | null\n}): string {\n const name = (row.variant_name ?? '').trim()\n const sku = (row.variant_sku ?? '').trim()\n if (name && sku) return `${name} (${sku})`\n if (name) return name\n if (sku) return sku\n return row.catalog_variant_id?.trim() || '\u2014'\n}\n\nexport function formatReservationSourceLabel(\n row: {\n source_type?: string | null\n source_id?: string | null\n source_label?: string | null\n },\n t: InventoryDisplayTranslator,\n): string {\n const sourceType = row.source_type?.trim()\n if (!sourceType) return '\u2014'\n const typeLabel = inventoryReservationSourceTypeLabel(sourceType, t)\n const sourceLabel = row.source_label?.trim()\n if (sourceLabel) return `${typeLabel} \u00B7 ${sourceLabel}`\n return typeLabel\n}\n"],
5
+ "mappings": "AACA,SAAS,8BAA8B;AAIvC,MAAM,0BAAkD;AAAA,EACtD,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,MAAM;AAAA,EACN,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS;AAAA,EACT,MAAM;AACR;AAEA,MAAM,oCAA4D;AAAA,EAChE,OAAO;AAAA,EACP,UAAU;AAAA,EACV,QAAQ;AACV;AAEA,MAAM,2BAAmD;AAAA,EACvD,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,IAAI;AAAA,EACJ,KAAK;AACP;AAEA,MAAM,+BAAuD;AAAA,EAC3D,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,WAAW;AACb;AAEA,MAAM,8BAAs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return value.trim();
4
+ }
5
+ function normalizeQuantity(value) {
6
+ return String(value);
7
+ }
8
+ function buildMovementIdempotencyKey(input) {
9
+ return [
10
+ "movement",
11
+ normalizeSegment(input.referenceType),
12
+ normalizeSegment(input.referenceId),
13
+ normalizeSegment(input.type),
14
+ normalizeSegment(input.warehouseId),
15
+ normalizeSegment(input.locationFromId),
16
+ normalizeSegment(input.locationToId),
17
+ normalizeSegment(input.catalogVariantId),
18
+ normalizeSegment(input.lotId),
19
+ normalizeSegment(input.serialNumber),
20
+ normalizeQuantity(input.quantity)
21
+ ].join("|");
22
+ }
23
+ function buildReservationIdempotencyKey(input) {
24
+ return [
25
+ "reservation",
26
+ normalizeSegment(input.sourceType),
27
+ normalizeSegment(input.sourceId),
28
+ normalizeSegment(input.catalogVariantId),
29
+ normalizeSegment(input.warehouseId),
30
+ normalizeQuantity(input.quantity)
31
+ ].join("|");
32
+ }
33
+ export {
34
+ buildMovementIdempotencyKey,
35
+ buildReservationIdempotencyKey
36
+ };
37
+ //# sourceMappingURL=inventoryIdempotency.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/wms/lib/inventoryIdempotency.ts"],
4
+ "sourcesContent": ["import type { InventoryMovementType, InventoryReservationSourceType } from '../data/entities'\n\nfunction normalizeSegment(value: string | null | undefined): string {\n if (typeof value !== 'string' || value.trim().length === 0) return ''\n return value.trim()\n}\n\nfunction normalizeQuantity(value: number): string {\n return String(value)\n}\n\nexport function buildMovementIdempotencyKey(input: {\n referenceType: string\n referenceId: string\n type: InventoryMovementType\n warehouseId: string\n locationFromId?: string | null\n locationToId?: string | null\n catalogVariantId: string\n lotId?: string | null\n serialNumber?: string | null\n quantity: number\n}): string {\n return [\n 'movement',\n normalizeSegment(input.referenceType),\n normalizeSegment(input.referenceId),\n normalizeSegment(input.type),\n normalizeSegment(input.warehouseId),\n normalizeSegment(input.locationFromId),\n normalizeSegment(input.locationToId),\n normalizeSegment(input.catalogVariantId),\n normalizeSegment(input.lotId),\n normalizeSegment(input.serialNumber),\n normalizeQuantity(input.quantity),\n ].join('|')\n}\n\nexport function buildReservationIdempotencyKey(input: {\n sourceType: InventoryReservationSourceType\n sourceId: string\n catalogVariantId: string\n warehouseId: string\n quantity: number\n}): string {\n return [\n 'reservation',\n normalizeSegment(input.sourceType),\n normalizeSegment(input.sourceId),\n normalizeSegment(input.catalogVariantId),\n normalizeSegment(input.warehouseId),\n normalizeQuantity(input.quantity),\n ].join('|')\n}\n"],
5
+ "mappings": "AAEA,SAAS,iBAAiB,OAA0C;AAClE,MAAI,OAAO,UAAU,YAAY,MAAM,KAAK,EAAE,WAAW,EAAG,QAAO;AACnE,SAAO,MAAM,KAAK;AACpB;AAEA,SAAS,kBAAkB,OAAuB;AAChD,SAAO,OAAO,KAAK;AACrB;AAEO,SAAS,4BAA4B,OAWjC;AACT,SAAO;AAAA,IACL;AAAA,IACA,iBAAiB,MAAM,aAAa;AAAA,IACpC,iBAAiB,MAAM,WAAW;AAAA,IAClC,iBAAiB,MAAM,IAAI;AAAA,IAC3B,iBAAiB,MAAM,WAAW;AAAA,IAClC,iBAAiB,MAAM,cAAc;AAAA,IACrC,iBAAiB,MAAM,YAAY;AAAA,IACnC,iBAAiB,MAAM,gBAAgB;AAAA,IACvC,iBAAiB,MAAM,KAAK;AAAA,IAC5B,iBAAiB,MAAM,YAAY;AAAA,IACnC,kBAAkB,MAAM,QAAQ;AAAA,EAClC,EAAE,KAAK,GAAG;AACZ;AAEO,SAAS,+BAA+B,OAMpC;AACT,SAAO;AAAA,IACL;AAAA,IACA,iBAAiB,MAAM,UAAU;AAAA,IACjC,iBAAiB,MAAM,QAAQ;AAAA,IAC/B,iBAAiB,MAAM,gBAAgB;AAAA,IACvC,iBAAiB,MAAM,WAAW;AAAA,IAClC,kBAAkB,MAAM,QAAQ;AAAA,EAClC,EAAE,KAAK,GAAG;AACZ;",
6
+ "names": []
7
+ }