@open-mercato/core 0.6.7-develop.6669.1.40b669666b → 0.6.7-develop.6671.1.4b925c5096

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,121 @@
1
+ import type { CrudCtx } from '@open-mercato/shared/lib/crud/factory'
2
+ import type { QueryEngine } from '@open-mercato/shared/lib/query/types'
3
+ import { createLogger } from '@open-mercato/shared/lib/logger'
4
+ import { E } from '#generated/entities.ids.generated'
5
+
6
+ const logger = createLogger('wms')
7
+
8
+ const SEARCH_PAGE_SIZE = 100
9
+
10
+ async function queryMatchingIds(
11
+ ctx: CrudCtx,
12
+ entityId: string,
13
+ filters: Record<string, unknown>,
14
+ source: string,
15
+ ): Promise<string[]> {
16
+ const tenantId = ctx.auth?.tenantId
17
+ if (!tenantId) return []
18
+ try {
19
+ const queryEngine = ctx.container.resolve('queryEngine') as QueryEngine
20
+ const result = await queryEngine.query<{ id?: string | null }>(entityId, {
21
+ tenantId,
22
+ organizationId: ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? undefined,
23
+ organizationIds: ctx.organizationIds ?? undefined,
24
+ filters,
25
+ fields: ['id'],
26
+ page: { page: 1, pageSize: SEARCH_PAGE_SIZE },
27
+ })
28
+ return (result.items ?? [])
29
+ .map((row) => (typeof row?.id === 'string' ? row.id : null))
30
+ .filter((id): id is string => Boolean(id))
31
+ } catch (err) {
32
+ logger.warn('lookup failed', { source, entityId, err })
33
+ return []
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Resolve warehouse ids whose name or code matches an already-escaped ILIKE term
39
+ * (e.g. `%midnight%`). Used by reservation/balance list search so operators can
40
+ * find rows by the labels shown in the table, not only serial numbers.
41
+ */
42
+ export async function resolveWarehouseIdsMatchingSearch(
43
+ ctx: CrudCtx,
44
+ like: string,
45
+ ): Promise<string[]> {
46
+ return queryMatchingIds(
47
+ ctx,
48
+ E.wms.warehouse,
49
+ {
50
+ $or: [
51
+ { name: { $ilike: like } },
52
+ { code: { $ilike: like } },
53
+ ],
54
+ },
55
+ 'warehouse-search',
56
+ )
57
+ }
58
+
59
+ /**
60
+ * Resolve catalog variant ids whose name or SKU matches an already-escaped
61
+ * ILIKE term. Decoupled from catalog ORM via QueryEngine (same as list enrichers).
62
+ */
63
+ export async function resolveVariantIdsMatchingSearch(
64
+ ctx: CrudCtx,
65
+ like: string,
66
+ ): Promise<string[]> {
67
+ return queryMatchingIds(
68
+ ctx,
69
+ E.catalog.catalog_product_variant,
70
+ {
71
+ $or: [
72
+ { name: { $ilike: like } },
73
+ { sku: { $ilike: like } },
74
+ ],
75
+ },
76
+ 'variant-search',
77
+ )
78
+ }
79
+
80
+ /**
81
+ * Build a list `$or` clause that matches serial number, warehouse label, or
82
+ * variant name/SKU for the given search term. Optional `extraFieldFilters`
83
+ * appends additional ILIKE clauses (e.g. movement reason fields).
84
+ */
85
+ export async function buildInventoryListSearchOrFilters(
86
+ ctx: CrudCtx,
87
+ term: string,
88
+ escapeLike: (value: string) => string,
89
+ options?: {
90
+ extraFieldFilters?: (like: string) => Array<Record<string, unknown>>
91
+ },
92
+ ): Promise<Array<Record<string, unknown>>> {
93
+ const like = `%${escapeLike(term)}%`
94
+ const orFilters: Array<Record<string, unknown>> = [{ serial_number: { $ilike: like } }]
95
+ if (options?.extraFieldFilters) {
96
+ orFilters.push(...options.extraFieldFilters(like))
97
+ }
98
+ const [warehouseIds, variantIds] = await Promise.all([
99
+ resolveWarehouseIdsMatchingSearch(ctx, like),
100
+ resolveVariantIdsMatchingSearch(ctx, like),
101
+ ])
102
+ if (warehouseIds.length > 0) {
103
+ orFilters.push({ warehouse_id: { $in: warehouseIds } })
104
+ }
105
+ if (variantIds.length > 0) {
106
+ orFilters.push({ catalog_variant_id: { $in: variantIds } })
107
+ }
108
+ return orFilters
109
+ }
110
+
111
+ /**
112
+ * Build a reservation-list `$or` clause that matches serial number, warehouse
113
+ * label, or variant name/SKU for the given search term.
114
+ */
115
+ export async function buildReservationSearchOrFilters(
116
+ ctx: CrudCtx,
117
+ term: string,
118
+ escapeLike: (value: string) => string,
119
+ ): Promise<Array<Record<string, unknown>>> {
120
+ return buildInventoryListSearchOrFilters(ctx, term, escapeLike)
121
+ }
@@ -0,0 +1,171 @@
1
+ import { z } from 'zod'
2
+ import { makeCrudRoute } from '@open-mercato/shared/lib/crud/factory'
3
+ import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
4
+ import { parseBooleanToken } from '@open-mercato/shared/lib/boolean'
5
+ import { parseScopedCommandInput, resolveCrudRecordId } from '@open-mercato/shared/lib/api/scoped'
6
+ import { escapeLikePattern } from '@open-mercato/shared/lib/db/escapeLikePattern'
7
+ import { E } from '#generated/entities.ids.generated'
8
+ import { WarehouseLocation } from '../../data/entities'
9
+ import { warehouseLocationCreateSchema, warehouseLocationUpdateSchema } from '../../data/validators'
10
+ import { createPagedListResponseSchema, createWmsCrudOpenApi, defaultOkResponseSchema } from '../openapi'
11
+ import { attachWarehouseLabelsToListItems } from '../listEnrichers'
12
+
13
+ const routeMetadata = {
14
+ GET: { requireAuth: true, requireFeatures: ['wms.view'] },
15
+ POST: { requireAuth: true, requireFeatures: ['wms.manage_locations'] },
16
+ PUT: { requireAuth: true, requireFeatures: ['wms.manage_locations'] },
17
+ DELETE: { requireAuth: true, requireFeatures: ['wms.manage_locations'] },
18
+ }
19
+
20
+ export const metadata = routeMetadata
21
+
22
+ const rawBodySchema = z.object({}).passthrough()
23
+
24
+ const listSchema = z.object({
25
+ page: z.coerce.number().min(1).default(1),
26
+ pageSize: z.coerce.number().min(1).max(100).default(25),
27
+ search: z.string().optional(),
28
+ warehouseId: z.string().uuid().optional(),
29
+ parentId: z.string().uuid().optional(),
30
+ type: z.enum(['zone', 'aisle', 'rack', 'bin', 'slot', 'dock', 'staging']).optional(),
31
+ isActive: z.string().optional(),
32
+ ids: z.string().optional(),
33
+ sortField: z.string().optional(),
34
+ sortDir: z.enum(['asc', 'desc']).optional(),
35
+ }).passthrough()
36
+
37
+ const crud = makeCrudRoute({
38
+ metadata: routeMetadata,
39
+ orm: {
40
+ entity: WarehouseLocation,
41
+ idField: 'id',
42
+ orgField: 'organizationId',
43
+ tenantField: 'tenantId',
44
+ softDeleteField: 'deletedAt',
45
+ },
46
+ indexer: { entityType: E.wms.warehouse_location },
47
+ list: {
48
+ schema: listSchema,
49
+ entityId: E.wms.warehouse_location,
50
+ fields: [
51
+ 'id',
52
+ 'organization_id',
53
+ 'tenant_id',
54
+ 'warehouse_id',
55
+ 'parent_id',
56
+ 'code',
57
+ 'type',
58
+ 'is_active',
59
+ 'capacity_units',
60
+ 'capacity_weight',
61
+ 'created_at',
62
+ 'updated_at',
63
+ ],
64
+ sortFieldMap: {
65
+ code: 'code',
66
+ type: 'type',
67
+ createdAt: 'created_at',
68
+ updatedAt: 'updated_at',
69
+ },
70
+ buildFilters: async (query) => {
71
+ const filters: Record<string, unknown> = {}
72
+ if (query.warehouseId) filters.warehouse_id = { $eq: query.warehouseId }
73
+ if (query.parentId) filters.parent_id = { $eq: query.parentId }
74
+ if (query.type) filters.type = { $eq: query.type }
75
+ const isActive = parseBooleanToken(query.isActive)
76
+ if (isActive !== null) filters.is_active = { $eq: isActive }
77
+ if (typeof query.ids === 'string' && query.ids.trim().length > 0) {
78
+ filters.id = {
79
+ $in: query.ids.split(',').map((value) => value.trim()).filter((value) => value.length > 0),
80
+ }
81
+ }
82
+ const term = query.search?.trim()
83
+ if (term) {
84
+ const like = `%${escapeLikePattern(term)}%`
85
+ filters.$or = [
86
+ { code: { $ilike: like } },
87
+ { type: { $ilike: like } },
88
+ ]
89
+ }
90
+ return filters
91
+ },
92
+ },
93
+ hooks: {
94
+ afterList: async (payload, ctx) => {
95
+ await attachWarehouseLabelsToListItems(payload, ctx)
96
+ },
97
+ },
98
+ actions: {
99
+ create: {
100
+ commandId: 'wms.locations.create',
101
+ schema: rawBodySchema,
102
+ mapInput: async ({ raw, ctx }) => {
103
+ const { translate } = await resolveTranslations()
104
+ return parseScopedCommandInput(warehouseLocationCreateSchema, raw ?? {}, ctx, translate)
105
+ },
106
+ response: ({ result }) => ({ id: result?.locationId ?? null }),
107
+ status: 201,
108
+ },
109
+ update: {
110
+ commandId: 'wms.locations.update',
111
+ schema: rawBodySchema,
112
+ mapInput: async ({ raw, ctx }) => {
113
+ const { translate } = await resolveTranslations()
114
+ return parseScopedCommandInput(warehouseLocationUpdateSchema, raw ?? {}, ctx, translate)
115
+ },
116
+ response: () => ({ ok: true }),
117
+ },
118
+ delete: {
119
+ commandId: 'wms.locations.delete',
120
+ schema: rawBodySchema,
121
+ mapInput: async ({ parsed, ctx }) => {
122
+ const { translate } = await resolveTranslations()
123
+ return { id: resolveCrudRecordId(parsed, ctx, translate) }
124
+ },
125
+ response: () => ({ ok: true }),
126
+ },
127
+ },
128
+ })
129
+
130
+ export const GET = crud.GET
131
+ export const POST = crud.POST
132
+ export const PUT = crud.PUT
133
+ export const DELETE = crud.DELETE
134
+
135
+ const locationListItemSchema = z.object({
136
+ id: z.string().uuid().nullable().optional(),
137
+ organization_id: z.string().uuid().nullable().optional(),
138
+ tenant_id: z.string().uuid().nullable().optional(),
139
+ warehouse_id: z.string().uuid().nullable().optional(),
140
+ warehouse_name: z.string().nullable().optional(),
141
+ warehouse_code: z.string().nullable().optional(),
142
+ parent_id: z.string().uuid().nullable().optional(),
143
+ code: z.string().nullable().optional(),
144
+ type: z.string().nullable().optional(),
145
+ is_active: z.boolean().nullable().optional(),
146
+ capacity_units: z.union([z.string(), z.number()]).nullable().optional(),
147
+ capacity_weight: z.union([z.string(), z.number()]).nullable().optional(),
148
+ created_at: z.string().nullable().optional(),
149
+ updated_at: z.string().nullable().optional(),
150
+ })
151
+
152
+ export const openApi = createWmsCrudOpenApi({
153
+ resourceName: 'Warehouse location',
154
+ pluralName: 'Warehouse locations',
155
+ querySchema: listSchema,
156
+ listResponseSchema: createPagedListResponseSchema(locationListItemSchema),
157
+ create: {
158
+ schema: warehouseLocationCreateSchema,
159
+ description: 'Creates a storage location within a warehouse hierarchy.',
160
+ },
161
+ update: {
162
+ schema: warehouseLocationUpdateSchema,
163
+ responseSchema: defaultOkResponseSchema,
164
+ description: 'Updates a warehouse location by id.',
165
+ },
166
+ del: {
167
+ schema: z.object({ id: z.string().uuid() }),
168
+ responseSchema: defaultOkResponseSchema,
169
+ description: 'Soft-deletes a warehouse location by id.',
170
+ },
171
+ })
@@ -0,0 +1,205 @@
1
+ import { z } from 'zod'
2
+ import type { EntityManager } from '@mikro-orm/postgresql'
3
+ import { makeCrudRoute } from '@open-mercato/shared/lib/crud/factory'
4
+ import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
5
+ import { parseScopedCommandInput, resolveCrudRecordId } from '@open-mercato/shared/lib/api/scoped'
6
+ import { escapeLikePattern } from '@open-mercato/shared/lib/db/escapeLikePattern'
7
+ import { E } from '#generated/entities.ids.generated'
8
+ import { InventoryLot } from '../../data/entities'
9
+ import { inventoryLotCreateSchema, inventoryLotUpdateSchema } from '../../data/validators'
10
+ import { buildExpiryWindowDateFilter, type ExpiryWindow } from '../../lib/expiry'
11
+ import { createPagedListResponseSchema, createWmsCrudOpenApi, defaultOkResponseSchema } from '../openapi'
12
+
13
+ const routeMetadata = {
14
+ GET: { requireAuth: true, requireFeatures: ['wms.view'] },
15
+ POST: { requireAuth: true, requireFeatures: ['wms.manage_inventory'] },
16
+ PUT: { requireAuth: true, requireFeatures: ['wms.manage_inventory'] },
17
+ DELETE: { requireAuth: true, requireFeatures: ['wms.manage_inventory'] },
18
+ }
19
+
20
+ export const metadata = routeMetadata
21
+
22
+ const rawBodySchema = z.object({}).passthrough()
23
+
24
+ const listSchema = z.object({
25
+ page: z.coerce.number().min(1).default(1),
26
+ pageSize: z.coerce.number().min(1).max(100).default(25),
27
+ search: z.string().optional(),
28
+ catalogVariantId: z.string().uuid().optional(),
29
+ status: z.enum(['available', 'hold', 'quarantine', 'expired']).optional(),
30
+ expiryWindow: z.enum(['expiringSoon', 'pastDue']).optional(),
31
+ warehouseId: z.string().uuid().optional(),
32
+ ids: z.string().optional(),
33
+ sortField: z.string().optional(),
34
+ sortDir: z.enum(['asc', 'desc']).optional(),
35
+ }).passthrough()
36
+
37
+ const crud = makeCrudRoute({
38
+ metadata: routeMetadata,
39
+ orm: {
40
+ entity: InventoryLot,
41
+ idField: 'id',
42
+ orgField: 'organizationId',
43
+ tenantField: 'tenantId',
44
+ softDeleteField: 'deletedAt',
45
+ },
46
+ indexer: { entityType: E.wms.inventory_lot },
47
+ list: {
48
+ schema: listSchema,
49
+ entityId: E.wms.inventory_lot,
50
+ fields: [
51
+ 'id',
52
+ 'organization_id',
53
+ 'tenant_id',
54
+ 'catalog_variant_id',
55
+ 'sku',
56
+ 'lot_number',
57
+ 'batch_number',
58
+ 'manufactured_at',
59
+ 'best_before_at',
60
+ 'expires_at',
61
+ 'status',
62
+ 'metadata',
63
+ 'created_at',
64
+ 'updated_at',
65
+ ],
66
+ sortFieldMap: {
67
+ lotNumber: 'lot_number',
68
+ sku: 'sku',
69
+ status: 'status',
70
+ expiresAt: 'expires_at',
71
+ createdAt: 'created_at',
72
+ updatedAt: 'updated_at',
73
+ },
74
+ buildFilters: async (query, ctx) => {
75
+ const filters: Record<string, unknown> = {}
76
+ if (query.catalogVariantId) filters.catalog_variant_id = { $eq: query.catalogVariantId }
77
+ if (query.status) filters.status = { $eq: query.status }
78
+ if (query.expiryWindow) {
79
+ Object.assign(filters, buildExpiryWindowDateFilter(query.expiryWindow as ExpiryWindow))
80
+ }
81
+ if (typeof query.ids === 'string' && query.ids.trim().length > 0) {
82
+ filters.id = {
83
+ $in: query.ids.split(',').map((value) => value.trim()).filter((value) => value.length > 0),
84
+ }
85
+ }
86
+ const requiresAvailableStock =
87
+ Boolean(query.warehouseId) || query.expiryWindow === 'pastDue'
88
+ if (requiresAvailableStock) {
89
+ const organizationId = ctx.selectedOrganizationId
90
+ const tenantId = ctx.auth?.tenantId
91
+ if (organizationId && tenantId) {
92
+ const em = ctx.container.resolve('em') as EntityManager
93
+ const balanceParams: unknown[] = [organizationId, tenantId]
94
+ let balanceSql = `
95
+ select distinct lot_id
96
+ from wms_inventory_balances
97
+ where organization_id = ?
98
+ and tenant_id = ?
99
+ and deleted_at is null
100
+ and lot_id is not null
101
+ and (
102
+ coalesce(quantity_on_hand, 0)
103
+ - coalesce(quantity_reserved, 0)
104
+ - coalesce(quantity_allocated, 0)
105
+ ) > 0`
106
+ if (query.warehouseId) {
107
+ balanceSql += ' and warehouse_id = ?'
108
+ balanceParams.push(query.warehouseId)
109
+ }
110
+ const rows = await em.getConnection().execute<Array<{ lot_id: string }>>(
111
+ balanceSql,
112
+ balanceParams,
113
+ )
114
+ const lotIds = rows.map((row) => row.lot_id).filter((value) => value.length > 0)
115
+ filters.id = {
116
+ $in: lotIds.length > 0 ? lotIds : ['00000000-0000-4000-8000-000000000000'],
117
+ }
118
+ }
119
+ }
120
+ const term = query.search?.trim()
121
+ if (term) {
122
+ const like = `%${escapeLikePattern(term)}%`
123
+ filters.$or = [
124
+ { sku: { $ilike: like } },
125
+ { lot_number: { $ilike: like } },
126
+ { batch_number: { $ilike: like } },
127
+ ]
128
+ }
129
+ return filters
130
+ },
131
+ },
132
+ actions: {
133
+ create: {
134
+ commandId: 'wms.lots.create',
135
+ schema: rawBodySchema,
136
+ mapInput: async ({ raw, ctx }) => {
137
+ const { translate } = await resolveTranslations()
138
+ return parseScopedCommandInput(inventoryLotCreateSchema, raw ?? {}, ctx, translate)
139
+ },
140
+ response: ({ result }) => ({ id: result?.lotId ?? null }),
141
+ status: 201,
142
+ },
143
+ update: {
144
+ commandId: 'wms.lots.update',
145
+ schema: rawBodySchema,
146
+ mapInput: async ({ raw, ctx }) => {
147
+ const { translate } = await resolveTranslations()
148
+ return parseScopedCommandInput(inventoryLotUpdateSchema, raw ?? {}, ctx, translate)
149
+ },
150
+ response: () => ({ ok: true }),
151
+ },
152
+ delete: {
153
+ commandId: 'wms.lots.delete',
154
+ schema: rawBodySchema,
155
+ mapInput: async ({ parsed, ctx }) => {
156
+ const { translate } = await resolveTranslations()
157
+ return { id: resolveCrudRecordId(parsed, ctx, translate) }
158
+ },
159
+ response: () => ({ ok: true }),
160
+ },
161
+ },
162
+ })
163
+
164
+ export const GET = crud.GET
165
+ export const POST = crud.POST
166
+ export const PUT = crud.PUT
167
+ export const DELETE = crud.DELETE
168
+
169
+ const lotListItemSchema = z.object({
170
+ id: z.string().uuid().nullable().optional(),
171
+ organization_id: z.string().uuid().nullable().optional(),
172
+ tenant_id: z.string().uuid().nullable().optional(),
173
+ catalog_variant_id: z.string().uuid().nullable().optional(),
174
+ sku: z.string().nullable().optional(),
175
+ lot_number: z.string().nullable().optional(),
176
+ batch_number: z.string().nullable().optional(),
177
+ manufactured_at: z.string().nullable().optional(),
178
+ best_before_at: z.string().nullable().optional(),
179
+ expires_at: z.string().nullable().optional(),
180
+ status: z.string().nullable().optional(),
181
+ metadata: z.record(z.string(), z.unknown()).nullable().optional(),
182
+ created_at: z.string().nullable().optional(),
183
+ updated_at: z.string().nullable().optional(),
184
+ })
185
+
186
+ export const openApi = createWmsCrudOpenApi({
187
+ resourceName: 'Inventory lot',
188
+ pluralName: 'Inventory lots',
189
+ querySchema: listSchema,
190
+ listResponseSchema: createPagedListResponseSchema(lotListItemSchema),
191
+ create: {
192
+ schema: inventoryLotCreateSchema,
193
+ description: 'Creates an inventory lot or batch record.',
194
+ },
195
+ update: {
196
+ schema: inventoryLotUpdateSchema,
197
+ responseSchema: defaultOkResponseSchema,
198
+ description: 'Updates an inventory lot by id.',
199
+ },
200
+ del: {
201
+ schema: z.object({ id: z.string().uuid() }),
202
+ responseSchema: defaultOkResponseSchema,
203
+ description: 'Soft-deletes an inventory lot by id.',
204
+ },
205
+ })
@@ -0,0 +1,28 @@
1
+ import { type ZodTypeAny } from 'zod'
2
+ import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
3
+ import {
4
+ createCrudOpenApiFactory,
5
+ createPagedListResponseSchema as createSharedPagedListResponseSchema,
6
+ defaultCreateResponseSchema as sharedDefaultCreateResponseSchema,
7
+ defaultOkResponseSchema as sharedDefaultOkResponseSchema,
8
+ type CrudOpenApiOptions,
9
+ } from '@open-mercato/shared/lib/openapi/crud'
10
+
11
+ export const defaultCreateResponseSchema = sharedDefaultCreateResponseSchema
12
+ export const defaultOkResponseSchema = sharedDefaultOkResponseSchema
13
+
14
+ export function createPagedListResponseSchema(itemSchema: ZodTypeAny) {
15
+ return createSharedPagedListResponseSchema(itemSchema, { paginationMetaOptional: true })
16
+ }
17
+
18
+ const buildWmsCrudOpenApi = createCrudOpenApiFactory({
19
+ defaultTag: 'WMS',
20
+ defaultCreateResponseSchema,
21
+ defaultOkResponseSchema,
22
+ makeListDescription: ({ pluralLower }) =>
23
+ `Returns a paginated collection of ${pluralLower} scoped to the authenticated organization.`,
24
+ })
25
+
26
+ export function createWmsCrudOpenApi(options: CrudOpenApiOptions): OpenApiRouteDoc {
27
+ return buildWmsCrudOpenApi(options)
28
+ }
@@ -0,0 +1,58 @@
1
+ import { z } from 'zod'
2
+ import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
3
+ import { readJsonSafe } from '@open-mercato/shared/lib/http/readJsonSafe'
4
+ import { executeWmsCustomPostRoute } from '../../../inventory/helpers'
5
+ import { reRunReservationInputSchema } from '../../../../commands/sales-order-assignment'
6
+
7
+ export const metadata = {
8
+ POST: { requireAuth: true, requireFeatures: ['wms.manage_reservations'] },
9
+ }
10
+
11
+ const paramsSchema = z.object({
12
+ salesOrderId: z.string().uuid(),
13
+ })
14
+
15
+ export async function POST(
16
+ request: Request,
17
+ routeContext: { params: { salesOrderId: string } },
18
+ ) {
19
+ const parsedParams = paramsSchema.parse(routeContext.params)
20
+ const body = await readJsonSafe<Record<string, unknown>>(request, {})
21
+ const scopedRequest = new Request(request.url, {
22
+ method: 'POST',
23
+ headers: request.headers,
24
+ body: JSON.stringify({ ...body, salesOrderId: parsedParams.salesOrderId }),
25
+ })
26
+ return executeWmsCustomPostRoute({
27
+ request: scopedRequest,
28
+ routePath: `wms/sales-orders/${parsedParams.salesOrderId}/re-run-reservation`,
29
+ inputSchema: reRunReservationInputSchema,
30
+ commandId: 'wms.sales-order.re-run-reservation',
31
+ describeResource: (input) => ({
32
+ resourceKind: 'wms.sales_order_reservation',
33
+ resourceId: input.salesOrderId,
34
+ }),
35
+ mapSuccess: () => ({ ok: true }),
36
+ })
37
+ }
38
+
39
+ const successSchema = z.object({ ok: z.literal(true) })
40
+ const errorSchema = z.object({ error: z.string() })
41
+
42
+ export const openApi: OpenApiRouteDoc = {
43
+ tag: 'WMS',
44
+ summary: 'Re-run reservation for sales order',
45
+ methods: {
46
+ POST: {
47
+ summary: 'Re-run reservation for sales order',
48
+ description:
49
+ 'Triggers the automatic reservation logic for a sales order, attempting to fill any remaining shortfall.',
50
+ responses: [{ status: 200, description: 'Reservation re-run attempted', schema: successSchema }],
51
+ errors: [
52
+ { status: 400, description: 'Validation failed', schema: errorSchema },
53
+ { status: 401, description: 'Unauthorized', schema: errorSchema },
54
+ { status: 404, description: 'Order not found', schema: errorSchema },
55
+ ],
56
+ },
57
+ },
58
+ }