@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.
- package/.turbo/turbo-build.log +2 -2
- package/dist/generated/entities/inventory_balance/index.js +21 -0
- package/dist/generated/entities/inventory_balance/index.js.map +7 -0
- package/dist/generated/entities/inventory_lot/index.js +19 -0
- package/dist/generated/entities/inventory_lot/index.js.map +7 -0
- package/dist/generated/entities/inventory_movement/index.js +35 -0
- package/dist/generated/entities/inventory_movement/index.js.map +7 -0
- package/dist/generated/entities/inventory_reservation/index.js +23 -0
- package/dist/generated/entities/inventory_reservation/index.js.map +7 -0
- package/dist/generated/entities/product_inventory_profile/index.js +21 -0
- package/dist/generated/entities/product_inventory_profile/index.js.map +7 -0
- package/dist/generated/entities/sales_order_warehouse_assignment/index.js +11 -0
- package/dist/generated/entities/sales_order_warehouse_assignment/index.js.map +7 -0
- package/dist/generated/entities/warehouse/index.js +25 -0
- package/dist/generated/entities/warehouse/index.js.map +7 -0
- package/dist/generated/entities/warehouse_location/index.js +21 -0
- package/dist/generated/entities/warehouse_location/index.js.map +7 -0
- package/dist/generated/entities/warehouse_zone/index.js +11 -0
- package/dist/generated/entities/warehouse_zone/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +12 -0
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +98 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/modules/auth/backend/roles/page.js +12 -4
- package/dist/modules/auth/backend/roles/page.js.map +2 -2
- package/dist/modules/auth/lib/backendChrome.js +1 -0
- package/dist/modules/auth/lib/backendChrome.js.map +2 -2
- package/dist/modules/auth/services/rbacService.js +16 -17
- package/dist/modules/auth/services/rbacService.js.map +2 -2
- package/dist/modules/catalog/api/products/route.js +3 -0
- package/dist/modules/catalog/api/products/route.js.map +2 -2
- package/dist/modules/catalog/api/variants/route.js +3 -0
- package/dist/modules/catalog/api/variants/route.js.map +2 -2
- package/dist/modules/query_index/lib/engine.js +6 -6
- package/dist/modules/query_index/lib/engine.js.map +2 -2
- package/dist/modules/sales/api/documents/factory.js +1 -0
- package/dist/modules/sales/api/documents/factory.js.map +2 -2
- package/dist/modules/sales/commands/documents.js +53 -0
- package/dist/modules/sales/commands/documents.js.map +2 -2
- package/dist/modules/sales/components/documents/ItemsSection.js +51 -2
- package/dist/modules/sales/components/documents/ItemsSection.js.map +2 -2
- package/dist/modules/sales/events.js +2 -0
- package/dist/modules/sales/events.js.map +2 -2
- package/dist/modules/sales/widgets/injection/order-items-context.js +11 -0
- package/dist/modules/sales/widgets/injection/order-items-context.js.map +7 -0
- package/dist/modules/wms/acl.js +18 -0
- package/dist/modules/wms/acl.js.map +7 -0
- package/dist/modules/wms/analytics.js +11 -0
- package/dist/modules/wms/analytics.js.map +7 -0
- package/dist/modules/wms/api/dashboard/operational/route.js +80 -0
- package/dist/modules/wms/api/dashboard/operational/route.js.map +7 -0
- package/dist/modules/wms/api/interceptors.js +90 -0
- package/dist/modules/wms/api/interceptors.js.map +7 -0
- package/dist/modules/wms/api/inventory/adjust/route.js +51 -0
- package/dist/modules/wms/api/inventory/adjust/route.js.map +7 -0
- package/dist/modules/wms/api/inventory/allocate/route.js +51 -0
- package/dist/modules/wms/api/inventory/allocate/route.js.map +7 -0
- package/dist/modules/wms/api/inventory/balances/route.js +172 -0
- package/dist/modules/wms/api/inventory/balances/route.js.map +7 -0
- package/dist/modules/wms/api/inventory/cycle-count/route.js +52 -0
- package/dist/modules/wms/api/inventory/cycle-count/route.js.map +7 -0
- package/dist/modules/wms/api/inventory/helpers.js +113 -0
- package/dist/modules/wms/api/inventory/helpers.js.map +7 -0
- package/dist/modules/wms/api/inventory/import/apply/route.js +46 -0
- package/dist/modules/wms/api/inventory/import/apply/route.js.map +7 -0
- package/dist/modules/wms/api/inventory/import/helpers.js +195 -0
- package/dist/modules/wms/api/inventory/import/helpers.js.map +7 -0
- package/dist/modules/wms/api/inventory/import/template/route.js +32 -0
- package/dist/modules/wms/api/inventory/import/template/route.js.map +7 -0
- package/dist/modules/wms/api/inventory/import/validate/route.js +54 -0
- package/dist/modules/wms/api/inventory/import/validate/route.js.map +7 -0
- package/dist/modules/wms/api/inventory/move/route.js +51 -0
- package/dist/modules/wms/api/inventory/move/route.js.map +7 -0
- package/dist/modules/wms/api/inventory/movements/route.js +164 -0
- package/dist/modules/wms/api/inventory/movements/route.js.map +7 -0
- package/dist/modules/wms/api/inventory/receive/route.js +50 -0
- package/dist/modules/wms/api/inventory/receive/route.js.map +7 -0
- package/dist/modules/wms/api/inventory/release/route.js +44 -0
- package/dist/modules/wms/api/inventory/release/route.js.map +7 -0
- package/dist/modules/wms/api/inventory/reservations/route.js +128 -0
- package/dist/modules/wms/api/inventory/reservations/route.js.map +7 -0
- package/dist/modules/wms/api/inventory/reserve/route.js +59 -0
- package/dist/modules/wms/api/inventory/reserve/route.js.map +7 -0
- package/dist/modules/wms/api/inventory-profiles/route.js +178 -0
- package/dist/modules/wms/api/inventory-profiles/route.js.map +7 -0
- package/dist/modules/wms/api/listEnrichers.js +181 -0
- package/dist/modules/wms/api/listEnrichers.js.map +7 -0
- package/dist/modules/wms/api/listSearch.js +77 -0
- package/dist/modules/wms/api/listSearch.js.map +7 -0
- package/dist/modules/wms/api/locations/route.js +172 -0
- package/dist/modules/wms/api/locations/route.js.map +7 -0
- package/dist/modules/wms/api/lots/route.js +204 -0
- package/dist/modules/wms/api/lots/route.js.map +7 -0
- package/dist/modules/wms/api/openapi.js +27 -0
- package/dist/modules/wms/api/openapi.js.map +7 -0
- package/dist/modules/wms/api/sales-orders/[salesOrderId]/re-run-reservation/route.js +54 -0
- package/dist/modules/wms/api/sales-orders/[salesOrderId]/re-run-reservation/route.js.map +7 -0
- package/dist/modules/wms/api/sales-orders/[salesOrderId]/warehouse-assignment/route.js +279 -0
- package/dist/modules/wms/api/sales-orders/[salesOrderId]/warehouse-assignment/route.js.map +7 -0
- package/dist/modules/wms/api/sales-orders/assign-warehouse/route.js +56 -0
- package/dist/modules/wms/api/sales-orders/assign-warehouse/route.js.map +7 -0
- package/dist/modules/wms/api/sales-orders/unassign-warehouse/route.js +43 -0
- package/dist/modules/wms/api/sales-orders/unassign-warehouse/route.js.map +7 -0
- package/dist/modules/wms/api/warehouses/route.js +181 -0
- package/dist/modules/wms/api/warehouses/route.js.map +7 -0
- package/dist/modules/wms/api/zones/route.js +159 -0
- package/dist/modules/wms/api/zones/route.js.map +7 -0
- package/dist/modules/wms/backend/config/wms/page.js +9 -0
- package/dist/modules/wms/backend/config/wms/page.js.map +7 -0
- package/dist/modules/wms/backend/config/wms/page.meta.js +18 -0
- package/dist/modules/wms/backend/config/wms/page.meta.js.map +7 -0
- package/dist/modules/wms/backend/page.js +9 -0
- package/dist/modules/wms/backend/page.js.map +7 -0
- package/dist/modules/wms/backend/page.meta.js +16 -0
- package/dist/modules/wms/backend/page.meta.js.map +7 -0
- package/dist/modules/wms/backend/wms/inventory/page.js +9 -0
- package/dist/modules/wms/backend/wms/inventory/page.js.map +7 -0
- package/dist/modules/wms/backend/wms/inventory/page.meta.js +18 -0
- package/dist/modules/wms/backend/wms/inventory/page.meta.js.map +7 -0
- package/dist/modules/wms/backend/wms/location/[id]/page.js +9 -0
- package/dist/modules/wms/backend/wms/location/[id]/page.js.map +7 -0
- package/dist/modules/wms/backend/wms/location/[id]/page.meta.js +18 -0
- package/dist/modules/wms/backend/wms/location/[id]/page.meta.js.map +7 -0
- package/dist/modules/wms/backend/wms/locations/page.js +10 -0
- package/dist/modules/wms/backend/wms/locations/page.js.map +7 -0
- package/dist/modules/wms/backend/wms/locations/page.meta.js +18 -0
- package/dist/modules/wms/backend/wms/locations/page.meta.js.map +7 -0
- package/dist/modules/wms/backend/wms/lot/[id]/page.js +9 -0
- package/dist/modules/wms/backend/wms/lot/[id]/page.js.map +7 -0
- package/dist/modules/wms/backend/wms/lot/[id]/page.meta.js +18 -0
- package/dist/modules/wms/backend/wms/lot/[id]/page.meta.js.map +7 -0
- package/dist/modules/wms/backend/wms/lots/page.js +9 -0
- package/dist/modules/wms/backend/wms/lots/page.js.map +7 -0
- package/dist/modules/wms/backend/wms/lots/page.meta.js +18 -0
- package/dist/modules/wms/backend/wms/lots/page.meta.js.map +7 -0
- package/dist/modules/wms/backend/wms/movements/page.js +22 -0
- package/dist/modules/wms/backend/wms/movements/page.js.map +7 -0
- package/dist/modules/wms/backend/wms/movements/page.meta.js +18 -0
- package/dist/modules/wms/backend/wms/movements/page.meta.js.map +7 -0
- package/dist/modules/wms/backend/wms/reservations/page.js +23 -0
- package/dist/modules/wms/backend/wms/reservations/page.js.map +7 -0
- package/dist/modules/wms/backend/wms/reservations/page.meta.js +18 -0
- package/dist/modules/wms/backend/wms/reservations/page.meta.js.map +7 -0
- package/dist/modules/wms/backend/wms/sku/[id]/page.js +9 -0
- package/dist/modules/wms/backend/wms/sku/[id]/page.js.map +7 -0
- package/dist/modules/wms/backend/wms/sku/[id]/page.meta.js +18 -0
- package/dist/modules/wms/backend/wms/sku/[id]/page.meta.js.map +7 -0
- package/dist/modules/wms/backend/wms/warehouses/page.js +10 -0
- package/dist/modules/wms/backend/wms/warehouses/page.js.map +7 -0
- package/dist/modules/wms/backend/wms/warehouses/page.meta.js +18 -0
- package/dist/modules/wms/backend/wms/warehouses/page.meta.js.map +7 -0
- package/dist/modules/wms/backend/wms/zones/page.js +10 -0
- package/dist/modules/wms/backend/wms/zones/page.js.map +7 -0
- package/dist/modules/wms/backend/wms/zones/page.meta.js +18 -0
- package/dist/modules/wms/backend/wms/zones/page.meta.js.map +7 -0
- package/dist/modules/wms/ce.js +80 -0
- package/dist/modules/wms/ce.js.map +7 -0
- package/dist/modules/wms/cli.js +83 -0
- package/dist/modules/wms/cli.js.map +7 -0
- package/dist/modules/wms/commands/configuration.js +1519 -0
- package/dist/modules/wms/commands/configuration.js.map +7 -0
- package/dist/modules/wms/commands/index.js +4 -0
- package/dist/modules/wms/commands/index.js.map +7 -0
- package/dist/modules/wms/commands/inventory-actions.js +1539 -0
- package/dist/modules/wms/commands/inventory-actions.js.map +7 -0
- package/dist/modules/wms/commands/sales-order-assignment.js +277 -0
- package/dist/modules/wms/commands/sales-order-assignment.js.map +7 -0
- package/dist/modules/wms/commands/shared.js +82 -0
- package/dist/modules/wms/commands/shared.js.map +7 -0
- package/dist/modules/wms/components/backend/AdjustInventoryDialog.js +755 -0
- package/dist/modules/wms/components/backend/AdjustInventoryDialog.js.map +7 -0
- package/dist/modules/wms/components/backend/ChangeLotStatusDialog.js +269 -0
- package/dist/modules/wms/components/backend/ChangeLotStatusDialog.js.map +7 -0
- package/dist/modules/wms/components/backend/CycleCountWizardDialog.js +1783 -0
- package/dist/modules/wms/components/backend/CycleCountWizardDialog.js.map +7 -0
- package/dist/modules/wms/components/backend/ImportInventoryDialog.js +766 -0
- package/dist/modules/wms/components/backend/ImportInventoryDialog.js.map +7 -0
- package/dist/modules/wms/components/backend/InventoryOperationsSection.js +119 -0
- package/dist/modules/wms/components/backend/InventoryOperationsSection.js.map +7 -0
- package/dist/modules/wms/components/backend/LocationEditDialog.js +140 -0
- package/dist/modules/wms/components/backend/LocationEditDialog.js.map +7 -0
- package/dist/modules/wms/components/backend/MoveInventoryDialog.js +791 -0
- package/dist/modules/wms/components/backend/MoveInventoryDialog.js.map +7 -0
- package/dist/modules/wms/components/backend/ReceiveInventoryDialog.js +656 -0
- package/dist/modules/wms/components/backend/ReceiveInventoryDialog.js.map +7 -0
- package/dist/modules/wms/components/backend/ReleaseReservationDialog.js +344 -0
- package/dist/modules/wms/components/backend/ReleaseReservationDialog.js.map +7 -0
- package/dist/modules/wms/components/backend/ReserveInventoryDialog.js +475 -0
- package/dist/modules/wms/components/backend/ReserveInventoryDialog.js.map +7 -0
- package/dist/modules/wms/components/backend/WmsConfigurationPage.js +1112 -0
- package/dist/modules/wms/components/backend/WmsConfigurationPage.js.map +7 -0
- package/dist/modules/wms/components/backend/WmsInventoryConsolePage.js +908 -0
- package/dist/modules/wms/components/backend/WmsInventoryConsolePage.js.map +7 -0
- package/dist/modules/wms/components/backend/WmsLocationDetailPage.js +1015 -0
- package/dist/modules/wms/components/backend/WmsLocationDetailPage.js.map +7 -0
- package/dist/modules/wms/components/backend/WmsLotDetailPage.js +1049 -0
- package/dist/modules/wms/components/backend/WmsLotDetailPage.js.map +7 -0
- package/dist/modules/wms/components/backend/WmsLotsListPage.js +297 -0
- package/dist/modules/wms/components/backend/WmsLotsListPage.js.map +7 -0
- package/dist/modules/wms/components/backend/WmsOperationalDashboardPage.js +757 -0
- package/dist/modules/wms/components/backend/WmsOperationalDashboardPage.js.map +7 -0
- package/dist/modules/wms/components/backend/WmsSkuDetailPage.js +975 -0
- package/dist/modules/wms/components/backend/WmsSkuDetailPage.js.map +7 -0
- package/dist/modules/wms/components/backend/inventoryMutationLoaders.js +710 -0
- package/dist/modules/wms/components/backend/inventoryMutationLoaders.js.map +7 -0
- package/dist/modules/wms/components/backend/useWmsInventoryMutationAccess.js +79 -0
- package/dist/modules/wms/components/backend/useWmsInventoryMutationAccess.js.map +7 -0
- package/dist/modules/wms/components/backend/useWmsInventoryScopeFromSearchParams.js +24 -0
- package/dist/modules/wms/components/backend/useWmsInventoryScopeFromSearchParams.js.map +7 -0
- package/dist/modules/wms/components/backend/wmsLookupLoaders.js +55 -0
- package/dist/modules/wms/components/backend/wmsLookupLoaders.js.map +7 -0
- package/dist/modules/wms/data/enrichers.js +501 -0
- package/dist/modules/wms/data/enrichers.js.map +7 -0
- package/dist/modules/wms/data/entities.js +467 -0
- package/dist/modules/wms/data/entities.js.map +7 -0
- package/dist/modules/wms/data/validators.js +399 -0
- package/dist/modules/wms/data/validators.js.map +7 -0
- package/dist/modules/wms/di.js +27 -0
- package/dist/modules/wms/di.js.map +7 -0
- package/dist/modules/wms/events.js +42 -0
- package/dist/modules/wms/events.js.map +7 -0
- package/dist/modules/wms/index.js +17 -0
- package/dist/modules/wms/index.js.map +7 -0
- package/dist/modules/wms/lib/catalogInventoryProfileIntent.js +54 -0
- package/dist/modules/wms/lib/catalogInventoryProfileIntent.js.map +7 -0
- package/dist/modules/wms/lib/catalogInventoryProfileSync.js +144 -0
- package/dist/modules/wms/lib/catalogInventoryProfileSync.js.map +7 -0
- package/dist/modules/wms/lib/expiry.js +29 -0
- package/dist/modules/wms/lib/expiry.js.map +7 -0
- package/dist/modules/wms/lib/flashMutationError.js +51 -0
- package/dist/modules/wms/lib/flashMutationError.js.map +7 -0
- package/dist/modules/wms/lib/inventoryDisplayUi.js +188 -0
- package/dist/modules/wms/lib/inventoryDisplayUi.js.map +7 -0
- package/dist/modules/wms/lib/inventoryIdempotency.js +37 -0
- package/dist/modules/wms/lib/inventoryIdempotency.js.map +7 -0
- package/dist/modules/wms/lib/inventoryImportCsv.js +173 -0
- package/dist/modules/wms/lib/inventoryImportCsv.js.map +7 -0
- package/dist/modules/wms/lib/inventoryImportService.js +468 -0
- package/dist/modules/wms/lib/inventoryImportService.js.map +7 -0
- package/dist/modules/wms/lib/inventoryMutationUi.js +25 -0
- package/dist/modules/wms/lib/inventoryMutationUi.js.map +7 -0
- package/dist/modules/wms/lib/inventoryPolicy.js +61 -0
- package/dist/modules/wms/lib/inventoryPolicy.js.map +7 -0
- package/dist/modules/wms/lib/inventoryReconciliation.js +193 -0
- package/dist/modules/wms/lib/inventoryReconciliation.js.map +7 -0
- package/dist/modules/wms/lib/inventoryTrackingValidation.js +13 -0
- package/dist/modules/wms/lib/inventoryTrackingValidation.js.map +7 -0
- package/dist/modules/wms/lib/loadOperationalDashboard.js +580 -0
- package/dist/modules/wms/lib/loadOperationalDashboard.js.map +7 -0
- package/dist/modules/wms/lib/lowStockBalanceFilter.js +49 -0
- package/dist/modules/wms/lib/lowStockBalanceFilter.js.map +7 -0
- package/dist/modules/wms/lib/primaryWarehousePolicy.js +32 -0
- package/dist/modules/wms/lib/primaryWarehousePolicy.js.map +7 -0
- package/dist/modules/wms/lib/roleFeatures.js +30 -0
- package/dist/modules/wms/lib/roleFeatures.js.map +7 -0
- package/dist/modules/wms/lib/salesOrderInventoryAutomation.js +291 -0
- package/dist/modules/wms/lib/salesOrderInventoryAutomation.js.map +7 -0
- package/dist/modules/wms/lib/salesOrderWarehouseAssignment.js +54 -0
- package/dist/modules/wms/lib/salesOrderWarehouseAssignment.js.map +7 -0
- package/dist/modules/wms/lib/wmsIntegrationToggles.js +71 -0
- package/dist/modules/wms/lib/wmsIntegrationToggles.js.map +7 -0
- package/dist/modules/wms/migrations/Migration20260428110546.js +78 -0
- package/dist/modules/wms/migrations/Migration20260428110546.js.map +7 -0
- package/dist/modules/wms/migrations/Migration20260527120000.js +15 -0
- package/dist/modules/wms/migrations/Migration20260527120000.js.map +7 -0
- package/dist/modules/wms/migrations/Migration20260527140000.js +37 -0
- package/dist/modules/wms/migrations/Migration20260527140000.js.map +7 -0
- package/dist/modules/wms/migrations/Migration20260613120000.js +23 -0
- package/dist/modules/wms/migrations/Migration20260613120000.js.map +7 -0
- package/dist/modules/wms/migrations/Migration20260616090000.js +13 -0
- package/dist/modules/wms/migrations/Migration20260616090000.js.map +7 -0
- package/dist/modules/wms/migrations/Migration20260707180000.js +15 -0
- package/dist/modules/wms/migrations/Migration20260707180000.js.map +7 -0
- package/dist/modules/wms/notifications.client.js +18 -0
- package/dist/modules/wms/notifications.client.js.map +7 -0
- package/dist/modules/wms/notifications.js +53 -0
- package/dist/modules/wms/notifications.js.map +7 -0
- package/dist/modules/wms/search.js +196 -0
- package/dist/modules/wms/search.js.map +7 -0
- package/dist/modules/wms/setup.js +30 -0
- package/dist/modules/wms/setup.js.map +7 -0
- package/dist/modules/wms/subscribers/low-stock-notification.js +40 -0
- package/dist/modules/wms/subscribers/low-stock-notification.js.map +7 -0
- package/dist/modules/wms/subscribers/reservation-shortfall-notification.js +69 -0
- package/dist/modules/wms/subscribers/reservation-shortfall-notification.js.map +7 -0
- package/dist/modules/wms/subscribers/sales-order-cancelled-release.js +14 -0
- package/dist/modules/wms/subscribers/sales-order-cancelled-release.js.map +7 -0
- package/dist/modules/wms/subscribers/sales-order-confirmed-reserve.js +14 -0
- package/dist/modules/wms/subscribers/sales-order-confirmed-reserve.js.map +7 -0
- package/dist/modules/wms/translations.js +10 -0
- package/dist/modules/wms/translations.js.map +7 -0
- package/dist/modules/wms/vector.js +9 -0
- package/dist/modules/wms/vector.js.map +7 -0
- package/dist/modules/wms/widgets/injection/catalog-inventory-profile/widget.js +200 -0
- package/dist/modules/wms/widgets/injection/catalog-inventory-profile/widget.js.map +7 -0
- package/dist/modules/wms/widgets/injection/order-items-stock-column/widget.js +104 -0
- package/dist/modules/wms/widgets/injection/order-items-stock-column/widget.js.map +7 -0
- package/dist/modules/wms/widgets/injection/sales-order-stock-context/widget.client.js +389 -0
- package/dist/modules/wms/widgets/injection/sales-order-stock-context/widget.client.js.map +7 -0
- package/dist/modules/wms/widgets/injection/sales-order-stock-context/widget.js +16 -0
- package/dist/modules/wms/widgets/injection/sales-order-stock-context/widget.js.map +7 -0
- package/dist/modules/wms/widgets/injection-table.js +36 -0
- package/dist/modules/wms/widgets/injection-table.js.map +7 -0
- package/dist/modules/wms/widgets/notifications/WmsLowStockRenderer.js +150 -0
- package/dist/modules/wms/widgets/notifications/WmsLowStockRenderer.js.map +7 -0
- package/dist/modules/wms/widgets/notifications/WmsReservationShortfallRenderer.js +186 -0
- package/dist/modules/wms/widgets/notifications/WmsReservationShortfallRenderer.js.map +7 -0
- package/dist/modules/wms/widgets/notifications/index.js +7 -0
- package/dist/modules/wms/widgets/notifications/index.js.map +7 -0
- package/generated/entities/inventory_balance/index.ts +9 -0
- package/generated/entities/inventory_lot/index.ts +8 -0
- package/generated/entities/inventory_movement/index.ts +16 -0
- package/generated/entities/inventory_reservation/index.ts +10 -0
- package/generated/entities/product_inventory_profile/index.ts +9 -0
- package/generated/entities/sales_order_warehouse_assignment/index.ts +4 -0
- package/generated/entities/warehouse/index.ts +11 -0
- package/generated/entities/warehouse_location/index.ts +9 -0
- package/generated/entities/warehouse_zone/index.ts +4 -0
- package/generated/entities.ids.generated.ts +12 -0
- package/generated/entity-fields-registry.ts +98 -0
- package/package.json +7 -7
- package/src/modules/auth/backend/roles/page.tsx +13 -4
- package/src/modules/auth/i18n/de.json +2 -0
- package/src/modules/auth/i18n/en.json +2 -0
- package/src/modules/auth/i18n/es.json +2 -0
- package/src/modules/auth/i18n/pl.json +2 -0
- package/src/modules/auth/lib/backendChrome.tsx +1 -0
- package/src/modules/auth/services/rbacService.ts +25 -21
- package/src/modules/catalog/api/products/route.ts +3 -0
- package/src/modules/catalog/api/variants/route.ts +3 -0
- package/src/modules/query_index/lib/engine.ts +18 -6
- package/src/modules/sales/api/documents/factory.ts +1 -0
- package/src/modules/sales/commands/documents.ts +71 -0
- package/src/modules/sales/components/documents/ItemsSection.tsx +58 -0
- package/src/modules/sales/events.ts +2 -0
- package/src/modules/sales/widgets/injection/order-items-context.ts +15 -0
- package/src/modules/wms/acl.ts +14 -0
- package/src/modules/wms/analytics.ts +9 -0
- package/src/modules/wms/api/dashboard/operational/route.ts +83 -0
- package/src/modules/wms/api/interceptors.ts +108 -0
- package/src/modules/wms/api/inventory/adjust/route.ts +50 -0
- package/src/modules/wms/api/inventory/allocate/route.ts +50 -0
- package/src/modules/wms/api/inventory/balances/route.ts +178 -0
- package/src/modules/wms/api/inventory/cycle-count/route.ts +51 -0
- package/src/modules/wms/api/inventory/helpers.ts +128 -0
- package/src/modules/wms/api/inventory/import/apply/route.ts +47 -0
- package/src/modules/wms/api/inventory/import/helpers.ts +223 -0
- package/src/modules/wms/api/inventory/import/template/route.ts +31 -0
- package/src/modules/wms/api/inventory/import/validate/route.ts +56 -0
- package/src/modules/wms/api/inventory/move/route.ts +50 -0
- package/src/modules/wms/api/inventory/movements/route.ts +164 -0
- package/src/modules/wms/api/inventory/receive/route.ts +49 -0
- package/src/modules/wms/api/inventory/release/route.ts +43 -0
- package/src/modules/wms/api/inventory/reservations/route.ts +128 -0
- package/src/modules/wms/api/inventory/reserve/route.ts +59 -0
- package/src/modules/wms/api/inventory-profiles/route.ts +177 -0
- package/src/modules/wms/api/listEnrichers.ts +312 -0
- package/src/modules/wms/api/listSearch.ts +121 -0
- package/src/modules/wms/api/locations/route.ts +171 -0
- package/src/modules/wms/api/lots/route.ts +205 -0
- package/src/modules/wms/api/openapi.ts +28 -0
- package/src/modules/wms/api/sales-orders/[salesOrderId]/re-run-reservation/route.ts +58 -0
- package/src/modules/wms/api/sales-orders/[salesOrderId]/warehouse-assignment/route.ts +306 -0
- package/src/modules/wms/api/sales-orders/assign-warehouse/route.ts +57 -0
- package/src/modules/wms/api/sales-orders/unassign-warehouse/route.ts +43 -0
- package/src/modules/wms/api/warehouses/route.ts +181 -0
- package/src/modules/wms/api/zones/route.ts +158 -0
- package/src/modules/wms/backend/config/wms/page.meta.ts +14 -0
- package/src/modules/wms/backend/config/wms/page.tsx +5 -0
- package/src/modules/wms/backend/page.meta.ts +12 -0
- package/src/modules/wms/backend/page.tsx +5 -0
- package/src/modules/wms/backend/wms/inventory/page.meta.ts +14 -0
- package/src/modules/wms/backend/wms/inventory/page.tsx +5 -0
- package/src/modules/wms/backend/wms/location/[id]/page.meta.ts +14 -0
- package/src/modules/wms/backend/wms/location/[id]/page.tsx +5 -0
- package/src/modules/wms/backend/wms/locations/page.meta.ts +14 -0
- package/src/modules/wms/backend/wms/locations/page.tsx +12 -0
- package/src/modules/wms/backend/wms/lot/[id]/page.meta.ts +14 -0
- package/src/modules/wms/backend/wms/lot/[id]/page.tsx +5 -0
- package/src/modules/wms/backend/wms/lots/page.meta.ts +14 -0
- package/src/modules/wms/backend/wms/lots/page.tsx +5 -0
- package/src/modules/wms/backend/wms/movements/page.meta.ts +14 -0
- package/src/modules/wms/backend/wms/movements/page.tsx +23 -0
- package/src/modules/wms/backend/wms/reservations/page.meta.ts +14 -0
- package/src/modules/wms/backend/wms/reservations/page.tsx +24 -0
- package/src/modules/wms/backend/wms/sku/[id]/page.meta.ts +14 -0
- package/src/modules/wms/backend/wms/sku/[id]/page.tsx +5 -0
- package/src/modules/wms/backend/wms/warehouses/page.meta.ts +14 -0
- package/src/modules/wms/backend/wms/warehouses/page.tsx +12 -0
- package/src/modules/wms/backend/wms/zones/page.meta.ts +14 -0
- package/src/modules/wms/backend/wms/zones/page.tsx +12 -0
- package/src/modules/wms/ce.ts +76 -0
- package/src/modules/wms/cli.ts +96 -0
- package/src/modules/wms/commands/configuration.ts +1844 -0
- package/src/modules/wms/commands/index.ts +3 -0
- package/src/modules/wms/commands/inventory-actions.ts +1866 -0
- package/src/modules/wms/commands/sales-order-assignment.ts +346 -0
- package/src/modules/wms/commands/shared.ts +90 -0
- package/src/modules/wms/components/backend/AdjustInventoryDialog.tsx +820 -0
- package/src/modules/wms/components/backend/ChangeLotStatusDialog.tsx +312 -0
- package/src/modules/wms/components/backend/CycleCountWizardDialog.tsx +2007 -0
- package/src/modules/wms/components/backend/ImportInventoryDialog.tsx +1018 -0
- package/src/modules/wms/components/backend/InventoryOperationsSection.tsx +159 -0
- package/src/modules/wms/components/backend/LocationEditDialog.tsx +185 -0
- package/src/modules/wms/components/backend/MoveInventoryDialog.tsx +907 -0
- package/src/modules/wms/components/backend/ReceiveInventoryDialog.tsx +695 -0
- package/src/modules/wms/components/backend/ReleaseReservationDialog.tsx +424 -0
- package/src/modules/wms/components/backend/ReserveInventoryDialog.tsx +511 -0
- package/src/modules/wms/components/backend/WmsConfigurationPage.tsx +1340 -0
- package/src/modules/wms/components/backend/WmsInventoryConsolePage.tsx +1132 -0
- package/src/modules/wms/components/backend/WmsLocationDetailPage.tsx +1310 -0
- package/src/modules/wms/components/backend/WmsLotDetailPage.tsx +1355 -0
- package/src/modules/wms/components/backend/WmsLotsListPage.tsx +359 -0
- package/src/modules/wms/components/backend/WmsOperationalDashboardPage.tsx +958 -0
- package/src/modules/wms/components/backend/WmsSkuDetailPage.tsx +1245 -0
- package/src/modules/wms/components/backend/inventoryMutationLoaders.ts +960 -0
- package/src/modules/wms/components/backend/useWmsInventoryMutationAccess.ts +89 -0
- package/src/modules/wms/components/backend/useWmsInventoryScopeFromSearchParams.ts +32 -0
- package/src/modules/wms/components/backend/wmsLookupLoaders.ts +78 -0
- package/src/modules/wms/data/enrichers.ts +718 -0
- package/src/modules/wms/data/entities.ts +436 -0
- package/src/modules/wms/data/validators.ts +463 -0
- package/src/modules/wms/di.ts +25 -0
- package/src/modules/wms/events.ts +41 -0
- package/src/modules/wms/i18n/de.json +1051 -0
- package/src/modules/wms/i18n/en.json +1051 -0
- package/src/modules/wms/i18n/es.json +1051 -0
- package/src/modules/wms/i18n/pl.json +1051 -0
- package/src/modules/wms/index.ts +15 -0
- package/src/modules/wms/lib/catalogInventoryProfileIntent.ts +65 -0
- package/src/modules/wms/lib/catalogInventoryProfileSync.ts +199 -0
- package/src/modules/wms/lib/expiry.ts +30 -0
- package/src/modules/wms/lib/flashMutationError.ts +74 -0
- package/src/modules/wms/lib/inventoryDisplayUi.ts +249 -0
- package/src/modules/wms/lib/inventoryIdempotency.ts +54 -0
- package/src/modules/wms/lib/inventoryImportCsv.ts +212 -0
- package/src/modules/wms/lib/inventoryImportService.ts +629 -0
- package/src/modules/wms/lib/inventoryMutationUi.ts +21 -0
- package/src/modules/wms/lib/inventoryPolicy.ts +111 -0
- package/src/modules/wms/lib/inventoryReconciliation.ts +263 -0
- package/src/modules/wms/lib/inventoryTrackingValidation.ts +23 -0
- package/src/modules/wms/lib/loadOperationalDashboard.ts +776 -0
- package/src/modules/wms/lib/lowStockBalanceFilter.ts +74 -0
- package/src/modules/wms/lib/primaryWarehousePolicy.ts +46 -0
- package/src/modules/wms/lib/roleFeatures.ts +32 -0
- package/src/modules/wms/lib/salesOrderInventoryAutomation.ts +390 -0
- package/src/modules/wms/lib/salesOrderWarehouseAssignment.ts +78 -0
- package/src/modules/wms/lib/wmsIntegrationToggles.ts +81 -0
- package/src/modules/wms/migrations/.snapshot-open-mercato.json +2880 -0
- package/src/modules/wms/migrations/Migration20260428110546.ts +91 -0
- package/src/modules/wms/migrations/Migration20260527120000.ts +15 -0
- package/src/modules/wms/migrations/Migration20260527140000.ts +35 -0
- package/src/modules/wms/migrations/Migration20260613120000.ts +21 -0
- package/src/modules/wms/migrations/Migration20260616090000.ts +11 -0
- package/src/modules/wms/migrations/Migration20260707180000.ts +13 -0
- package/src/modules/wms/notifications.client.ts +18 -0
- package/src/modules/wms/notifications.ts +51 -0
- package/src/modules/wms/search.ts +230 -0
- package/src/modules/wms/setup.ts +29 -0
- package/src/modules/wms/subscribers/low-stock-notification.ts +54 -0
- package/src/modules/wms/subscribers/reservation-shortfall-notification.ts +98 -0
- package/src/modules/wms/subscribers/sales-order-cancelled-release.ts +21 -0
- package/src/modules/wms/subscribers/sales-order-confirmed-reserve.ts +21 -0
- package/src/modules/wms/translations.ts +6 -0
- package/src/modules/wms/vector.ts +7 -0
- package/src/modules/wms/widgets/injection/catalog-inventory-profile/widget.ts +238 -0
- package/src/modules/wms/widgets/injection/order-items-stock-column/widget.tsx +153 -0
- package/src/modules/wms/widgets/injection/sales-order-stock-context/widget.client.tsx +476 -0
- package/src/modules/wms/widgets/injection/sales-order-stock-context/widget.ts +15 -0
- package/src/modules/wms/widgets/injection-table.ts +34 -0
- package/src/modules/wms/widgets/notifications/WmsLowStockRenderer.tsx +153 -0
- package/src/modules/wms/widgets/notifications/WmsReservationShortfallRenderer.tsx +194 -0
- package/src/modules/wms/widgets/notifications/index.ts +2 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
4
|
+
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
5
|
+
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
6
|
+
import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
7
|
+
import { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'
|
|
8
|
+
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
9
|
+
import { createLogger } from '@open-mercato/shared/lib/logger'
|
|
10
|
+
import {
|
|
11
|
+
operationalDashboardQuerySchema,
|
|
12
|
+
operationalDashboardResponseSchema,
|
|
13
|
+
} from '../../../data/validators'
|
|
14
|
+
import {
|
|
15
|
+
loadOperationalDashboard,
|
|
16
|
+
OperationalDashboardWarehouseNotFoundError,
|
|
17
|
+
} from '../../../lib/loadOperationalDashboard'
|
|
18
|
+
|
|
19
|
+
const logger = createLogger('wms')
|
|
20
|
+
|
|
21
|
+
export const metadata = {
|
|
22
|
+
GET: { requireAuth: true, requireFeatures: ['wms.view'] },
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function GET(request: Request) {
|
|
26
|
+
try {
|
|
27
|
+
const url = new URL(request.url)
|
|
28
|
+
const parsedQuery = operationalDashboardQuerySchema.parse(Object.fromEntries(url.searchParams.entries()))
|
|
29
|
+
const container = await createRequestContainer()
|
|
30
|
+
const auth = await getAuthFromRequest(request)
|
|
31
|
+
if (!auth?.tenantId) {
|
|
32
|
+
throw new CrudHttpError(401, { error: 'Unauthorized' })
|
|
33
|
+
}
|
|
34
|
+
const organizationScope = await resolveOrganizationScopeForRequest({
|
|
35
|
+
container,
|
|
36
|
+
auth,
|
|
37
|
+
request,
|
|
38
|
+
})
|
|
39
|
+
const organizationId = organizationScope?.selectedId ?? auth.orgId ?? null
|
|
40
|
+
if (!organizationId) {
|
|
41
|
+
throw new CrudHttpError(401, { error: 'Unauthorized' })
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const em = (container.resolve('em') as EntityManager).fork()
|
|
45
|
+
const payload = await loadOperationalDashboard(em, {
|
|
46
|
+
organizationId,
|
|
47
|
+
tenantId: auth.tenantId,
|
|
48
|
+
warehouseId: parsedQuery.warehouseId ?? null,
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
return NextResponse.json(operationalDashboardResponseSchema.parse(payload))
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (error instanceof OperationalDashboardWarehouseNotFoundError) {
|
|
54
|
+
return NextResponse.json({ error: 'Warehouse not found' }, { status: 404 })
|
|
55
|
+
}
|
|
56
|
+
if (error instanceof CrudHttpError) {
|
|
57
|
+
return NextResponse.json(error.body, { status: error.status })
|
|
58
|
+
}
|
|
59
|
+
if (error instanceof z.ZodError) {
|
|
60
|
+
return NextResponse.json({ error: 'Validation failed', details: error.issues }, { status: 400 })
|
|
61
|
+
}
|
|
62
|
+
logger.error('GET operational dashboard failed', { err: error })
|
|
63
|
+
return NextResponse.json({ error: 'Internal server error' }, { status: 500 })
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const openApi: OpenApiRouteDoc = {
|
|
68
|
+
tag: 'WMS',
|
|
69
|
+
summary: 'Operational dashboard',
|
|
70
|
+
description:
|
|
71
|
+
'Aggregated KPIs, expiry watch lot rows (`expiryLots`), monthly movement trends, and recent activity for the WMS operational dashboard.',
|
|
72
|
+
methods: {
|
|
73
|
+
GET: {
|
|
74
|
+
summary: 'Load operational dashboard data',
|
|
75
|
+
query: operationalDashboardQuerySchema,
|
|
76
|
+
responses: [
|
|
77
|
+
{ status: 200, description: 'Dashboard payload', schema: operationalDashboardResponseSchema },
|
|
78
|
+
{ status: 401, description: 'Unauthorized' },
|
|
79
|
+
{ status: 404, description: 'Warehouse not found' },
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { ApiInterceptor } from '@open-mercato/shared/lib/crud/api-interceptor'
|
|
2
|
+
import {
|
|
3
|
+
decodeCatalogInventoryProfileIntent,
|
|
4
|
+
WMS_CATALOG_PROFILE_HEADER,
|
|
5
|
+
} from '../lib/catalogInventoryProfileIntent'
|
|
6
|
+
import {
|
|
7
|
+
syncCatalogInventoryProfile,
|
|
8
|
+
} from '../lib/catalogInventoryProfileSync'
|
|
9
|
+
|
|
10
|
+
function resolveRecordId(
|
|
11
|
+
requestBody: Record<string, unknown> | undefined,
|
|
12
|
+
responseBody: Record<string, unknown> | undefined,
|
|
13
|
+
): string | null {
|
|
14
|
+
const responseId = responseBody?.id
|
|
15
|
+
if (typeof responseId === 'string' && responseId.trim().length > 0) {
|
|
16
|
+
return responseId
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const requestId = requestBody?.id
|
|
20
|
+
if (typeof requestId === 'string' && requestId.trim().length > 0) {
|
|
21
|
+
return requestId
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return null
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const interceptors: ApiInterceptor[] = [
|
|
28
|
+
{
|
|
29
|
+
id: 'wms.catalog-products.inventory-profile-sync',
|
|
30
|
+
targetRoute: 'catalog/products',
|
|
31
|
+
methods: ['POST', 'PUT'],
|
|
32
|
+
priority: 120,
|
|
33
|
+
async before(request) {
|
|
34
|
+
const rawHeader = request.headers[WMS_CATALOG_PROFILE_HEADER]
|
|
35
|
+
if (!rawHeader) return { ok: true }
|
|
36
|
+
|
|
37
|
+
const intent = decodeCatalogInventoryProfileIntent(rawHeader)
|
|
38
|
+
return {
|
|
39
|
+
ok: true,
|
|
40
|
+
metadata: { intent, target: 'product' },
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
async after(request, response, context) {
|
|
44
|
+
if (response.statusCode >= 400) return {}
|
|
45
|
+
|
|
46
|
+
const metadata = context.metadata as
|
|
47
|
+
| { intent?: ReturnType<typeof decodeCatalogInventoryProfileIntent>; target?: 'product' | 'variant' }
|
|
48
|
+
| undefined
|
|
49
|
+
if (!metadata?.intent) return {}
|
|
50
|
+
|
|
51
|
+
const recordId = resolveRecordId(request.body, response.body)
|
|
52
|
+
if (!recordId) return {}
|
|
53
|
+
|
|
54
|
+
await syncCatalogInventoryProfile({
|
|
55
|
+
intent: metadata.intent,
|
|
56
|
+
target: 'product',
|
|
57
|
+
recordId,
|
|
58
|
+
organizationId: context.organizationId,
|
|
59
|
+
tenantId: context.tenantId,
|
|
60
|
+
userId: context.userId,
|
|
61
|
+
container: context.container,
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
return {}
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: 'wms.catalog-variants.inventory-profile-sync',
|
|
69
|
+
targetRoute: 'catalog/variants',
|
|
70
|
+
methods: ['POST', 'PUT'],
|
|
71
|
+
priority: 120,
|
|
72
|
+
async before(request) {
|
|
73
|
+
const rawHeader = request.headers[WMS_CATALOG_PROFILE_HEADER]
|
|
74
|
+
if (!rawHeader) return { ok: true }
|
|
75
|
+
|
|
76
|
+
const intent = decodeCatalogInventoryProfileIntent(rawHeader)
|
|
77
|
+
return {
|
|
78
|
+
ok: true,
|
|
79
|
+
metadata: { intent, target: 'variant' },
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
async after(request, response, context) {
|
|
83
|
+
if (response.statusCode >= 400) return {}
|
|
84
|
+
|
|
85
|
+
const metadata = context.metadata as
|
|
86
|
+
| { intent?: ReturnType<typeof decodeCatalogInventoryProfileIntent>; target?: 'product' | 'variant' }
|
|
87
|
+
| undefined
|
|
88
|
+
if (!metadata?.intent) return {}
|
|
89
|
+
|
|
90
|
+
const recordId = resolveRecordId(request.body, response.body)
|
|
91
|
+
if (!recordId) return {}
|
|
92
|
+
|
|
93
|
+
await syncCatalogInventoryProfile({
|
|
94
|
+
intent: metadata.intent,
|
|
95
|
+
target: 'variant',
|
|
96
|
+
recordId,
|
|
97
|
+
organizationId: context.organizationId,
|
|
98
|
+
tenantId: context.tenantId,
|
|
99
|
+
userId: context.userId,
|
|
100
|
+
container: context.container,
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
return {}
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
]
|
|
107
|
+
|
|
108
|
+
export default interceptors
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
3
|
+
import { inventoryAdjustSchema } from '../../../data/validators'
|
|
4
|
+
import { executeWmsCustomPostRoute } from '../helpers'
|
|
5
|
+
|
|
6
|
+
export const metadata = {
|
|
7
|
+
POST: { requireAuth: true, requireFeatures: ['wms.adjust_inventory'] },
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export async function POST(request: Request) {
|
|
11
|
+
return executeWmsCustomPostRoute({
|
|
12
|
+
request,
|
|
13
|
+
routePath: 'wms/inventory/adjust',
|
|
14
|
+
inputSchema: inventoryAdjustSchema,
|
|
15
|
+
commandId: 'wms.inventory.adjust',
|
|
16
|
+
describeResource: (input) => ({
|
|
17
|
+
resourceKind: 'wms.inventory',
|
|
18
|
+
resourceId: `${input.warehouseId}:${input.locationId}:${input.catalogVariantId}`,
|
|
19
|
+
}),
|
|
20
|
+
mapSuccess: (result: { movementId: string }) => ({
|
|
21
|
+
ok: true,
|
|
22
|
+
movementId: result.movementId,
|
|
23
|
+
}),
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const successSchema = z.object({
|
|
28
|
+
ok: z.literal(true),
|
|
29
|
+
movementId: z.string().uuid(),
|
|
30
|
+
})
|
|
31
|
+
const errorSchema = z.object({ error: z.string() })
|
|
32
|
+
|
|
33
|
+
export const openApi: OpenApiRouteDoc = {
|
|
34
|
+
tag: 'WMS',
|
|
35
|
+
summary: 'Adjust inventory',
|
|
36
|
+
methods: {
|
|
37
|
+
POST: {
|
|
38
|
+
summary: 'Adjust inventory',
|
|
39
|
+
description: 'Applies a manual inventory adjustment and appends a movement ledger row.',
|
|
40
|
+
requestBody: { contentType: 'application/json', schema: inventoryAdjustSchema },
|
|
41
|
+
responses: [{ status: 200, description: 'Inventory adjusted', schema: successSchema }],
|
|
42
|
+
errors: [
|
|
43
|
+
{ status: 400, description: 'Validation failed', schema: errorSchema },
|
|
44
|
+
{ status: 401, description: 'Unauthorized', schema: errorSchema },
|
|
45
|
+
{ status: 409, description: 'Insufficient stock', schema: errorSchema },
|
|
46
|
+
{ status: 422, description: 'Invalid location', schema: errorSchema },
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
3
|
+
import { inventoryReservationAllocateSchema } from '../../../data/validators'
|
|
4
|
+
import { executeWmsCustomPostRoute } from '../helpers'
|
|
5
|
+
|
|
6
|
+
export const metadata = {
|
|
7
|
+
POST: { requireAuth: true, requireFeatures: ['wms.manage_reservations'] },
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export async function POST(request: Request) {
|
|
11
|
+
return executeWmsCustomPostRoute({
|
|
12
|
+
request,
|
|
13
|
+
routePath: 'wms/inventory/allocate',
|
|
14
|
+
inputSchema: inventoryReservationAllocateSchema,
|
|
15
|
+
commandId: 'wms.inventory.allocate',
|
|
16
|
+
describeResource: (input) => ({
|
|
17
|
+
resourceKind: 'wms.inventoryReservation',
|
|
18
|
+
resourceId: input.reservationId,
|
|
19
|
+
}),
|
|
20
|
+
mapSuccess: (result: { allocationState: 'allocated' }) => ({
|
|
21
|
+
ok: true,
|
|
22
|
+
allocationState: result.allocationState,
|
|
23
|
+
}),
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const successSchema = z.object({
|
|
28
|
+
ok: z.literal(true),
|
|
29
|
+
allocationState: z.literal('allocated'),
|
|
30
|
+
})
|
|
31
|
+
const errorSchema = z.object({ error: z.string() })
|
|
32
|
+
|
|
33
|
+
export const openApi: OpenApiRouteDoc = {
|
|
34
|
+
tag: 'WMS',
|
|
35
|
+
summary: 'Allocate reservation',
|
|
36
|
+
methods: {
|
|
37
|
+
POST: {
|
|
38
|
+
summary: 'Allocate reservation',
|
|
39
|
+
description: 'Converts a reservation from reserved quantity into allocated quantity on the selected stock buckets.',
|
|
40
|
+
requestBody: { contentType: 'application/json', schema: inventoryReservationAllocateSchema },
|
|
41
|
+
responses: [{ status: 200, description: 'Reservation allocated', schema: successSchema }],
|
|
42
|
+
errors: [
|
|
43
|
+
{ status: 400, description: 'Validation failed', schema: errorSchema },
|
|
44
|
+
{ status: 401, description: 'Unauthorized', schema: errorSchema },
|
|
45
|
+
{ status: 404, description: 'Reservation not found', schema: errorSchema },
|
|
46
|
+
{ status: 409, description: 'Invalid reservation state', schema: errorSchema },
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
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 type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
5
|
+
import { escapeLikePattern } from '@open-mercato/shared/lib/db/escapeLikePattern'
|
|
6
|
+
import { E } from '#generated/entities.ids.generated'
|
|
7
|
+
import { InventoryBalance } from '../../../data/entities'
|
|
8
|
+
import { inventoryBalanceListQuerySchema } from '../../../data/validators'
|
|
9
|
+
import {
|
|
10
|
+
formatLowStockVariantIdsForFilter,
|
|
11
|
+
resolveLowStockVariantIds,
|
|
12
|
+
} from '../../../lib/lowStockBalanceFilter'
|
|
13
|
+
import { createPagedListResponseSchema } from '../../openapi'
|
|
14
|
+
import {
|
|
15
|
+
attachLocationLabelsToListItems,
|
|
16
|
+
attachVariantLabelsToListItems,
|
|
17
|
+
attachWarehouseLabelsToListItems,
|
|
18
|
+
} from '../../listEnrichers'
|
|
19
|
+
import { buildInventoryListSearchOrFilters } from '../../listSearch'
|
|
20
|
+
|
|
21
|
+
export const metadata = {
|
|
22
|
+
GET: { requireAuth: true, requireFeatures: ['wms.view'] },
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function transformInventoryBalanceListItem(
|
|
26
|
+
item: Record<string, unknown>,
|
|
27
|
+
): Record<string, unknown> {
|
|
28
|
+
const onHand = Number(item.quantity_on_hand ?? 0)
|
|
29
|
+
const reserved = Number(item.quantity_reserved ?? 0)
|
|
30
|
+
const allocated = Number(item.quantity_allocated ?? 0)
|
|
31
|
+
const rawAvailable = item.quantity_available
|
|
32
|
+
return {
|
|
33
|
+
...item,
|
|
34
|
+
quantity_available: rawAvailable != null ? Number(rawAvailable) : onHand - reserved - allocated,
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const crud = makeCrudRoute({
|
|
39
|
+
metadata,
|
|
40
|
+
orm: {
|
|
41
|
+
entity: InventoryBalance,
|
|
42
|
+
idField: 'id',
|
|
43
|
+
orgField: 'organizationId',
|
|
44
|
+
tenantField: 'tenantId',
|
|
45
|
+
softDeleteField: 'deletedAt',
|
|
46
|
+
},
|
|
47
|
+
indexer: { entityType: E.wms.inventory_balance },
|
|
48
|
+
list: {
|
|
49
|
+
schema: inventoryBalanceListQuerySchema,
|
|
50
|
+
entityId: E.wms.inventory_balance,
|
|
51
|
+
disableListCache: true,
|
|
52
|
+
fields: [
|
|
53
|
+
'id',
|
|
54
|
+
'organization_id',
|
|
55
|
+
'tenant_id',
|
|
56
|
+
'warehouse_id',
|
|
57
|
+
'location_id',
|
|
58
|
+
'catalog_variant_id',
|
|
59
|
+
'lot_id',
|
|
60
|
+
'serial_number',
|
|
61
|
+
'quantity_on_hand',
|
|
62
|
+
'quantity_reserved',
|
|
63
|
+
'quantity_allocated',
|
|
64
|
+
'quantity_available',
|
|
65
|
+
'created_at',
|
|
66
|
+
'updated_at',
|
|
67
|
+
],
|
|
68
|
+
sortFieldMap: {
|
|
69
|
+
catalogVariantId: 'catalog_variant_id',
|
|
70
|
+
warehouseId: 'warehouse_id',
|
|
71
|
+
locationId: 'location_id',
|
|
72
|
+
quantityOnHand: 'quantity_on_hand',
|
|
73
|
+
quantityReserved: 'quantity_reserved',
|
|
74
|
+
quantityAllocated: 'quantity_allocated',
|
|
75
|
+
quantityAvailable: 'quantity_available',
|
|
76
|
+
createdAt: 'created_at',
|
|
77
|
+
updatedAt: 'updated_at',
|
|
78
|
+
},
|
|
79
|
+
transformItem: transformInventoryBalanceListItem,
|
|
80
|
+
buildFilters: async (query, ctx) => {
|
|
81
|
+
const filters: Record<string, unknown> = {}
|
|
82
|
+
if (query.warehouseId) filters.warehouse_id = { $eq: query.warehouseId }
|
|
83
|
+
if (query.locationId) filters.location_id = { $eq: query.locationId }
|
|
84
|
+
if (query.lotId) filters.lot_id = { $eq: query.lotId }
|
|
85
|
+
if (query.serialNumber) filters.serial_number = { $eq: query.serialNumber }
|
|
86
|
+
|
|
87
|
+
let lowStockVariantIds: string[] | null = null
|
|
88
|
+
if (query.lowStock === 'belowReorder' || query.lowStock === 'belowSafety') {
|
|
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
|
+
lowStockVariantIds = await resolveLowStockVariantIds(
|
|
94
|
+
em,
|
|
95
|
+
{
|
|
96
|
+
organizationId,
|
|
97
|
+
tenantId,
|
|
98
|
+
warehouseId: query.warehouseId ?? null,
|
|
99
|
+
},
|
|
100
|
+
query.lowStock,
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (query.catalogVariantId) {
|
|
106
|
+
if (lowStockVariantIds && !lowStockVariantIds.includes(query.catalogVariantId)) {
|
|
107
|
+
filters.catalog_variant_id = { $in: ['00000000-0000-4000-8000-000000000000'] }
|
|
108
|
+
} else {
|
|
109
|
+
filters.catalog_variant_id = { $eq: query.catalogVariantId }
|
|
110
|
+
}
|
|
111
|
+
} else if (lowStockVariantIds) {
|
|
112
|
+
filters.catalog_variant_id = {
|
|
113
|
+
$in: formatLowStockVariantIdsForFilter(lowStockVariantIds),
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const term = query.search?.trim()
|
|
118
|
+
if (term) {
|
|
119
|
+
filters.$or = await buildInventoryListSearchOrFilters(ctx, term, escapeLikePattern)
|
|
120
|
+
}
|
|
121
|
+
return filters
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
hooks: {
|
|
125
|
+
afterList: async (payload, ctx) => {
|
|
126
|
+
await Promise.all([
|
|
127
|
+
attachWarehouseLabelsToListItems(payload, ctx),
|
|
128
|
+
attachLocationLabelsToListItems(payload, ctx),
|
|
129
|
+
attachVariantLabelsToListItems(payload, ctx),
|
|
130
|
+
])
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
export const GET = crud.GET
|
|
136
|
+
|
|
137
|
+
const inventoryBalanceListItemSchema = z.object({
|
|
138
|
+
id: z.string().uuid().nullable().optional(),
|
|
139
|
+
organization_id: z.string().uuid().nullable().optional(),
|
|
140
|
+
tenant_id: z.string().uuid().nullable().optional(),
|
|
141
|
+
warehouse_id: z.string().uuid().nullable().optional(),
|
|
142
|
+
warehouse_name: z.string().nullable().optional(),
|
|
143
|
+
warehouse_code: z.string().nullable().optional(),
|
|
144
|
+
location_id: z.string().uuid().nullable().optional(),
|
|
145
|
+
location_code: z.string().nullable().optional(),
|
|
146
|
+
location_type: z.string().nullable().optional(),
|
|
147
|
+
catalog_variant_id: z.string().uuid().nullable().optional(),
|
|
148
|
+
catalog_product_id: z.string().uuid().nullable().optional(),
|
|
149
|
+
variant_name: z.string().nullable().optional(),
|
|
150
|
+
variant_sku: z.string().nullable().optional(),
|
|
151
|
+
lot_id: z.string().uuid().nullable().optional(),
|
|
152
|
+
serial_number: z.string().nullable().optional(),
|
|
153
|
+
quantity_on_hand: z.union([z.string(), z.number()]).nullable().optional(),
|
|
154
|
+
quantity_reserved: z.union([z.string(), z.number()]).nullable().optional(),
|
|
155
|
+
quantity_allocated: z.union([z.string(), z.number()]).nullable().optional(),
|
|
156
|
+
quantity_available: z.number().nullable().optional(),
|
|
157
|
+
created_at: z.string().nullable().optional(),
|
|
158
|
+
updated_at: z.string().nullable().optional(),
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
export const openApi: OpenApiRouteDoc = {
|
|
162
|
+
tag: 'WMS',
|
|
163
|
+
summary: 'Inventory balances',
|
|
164
|
+
methods: {
|
|
165
|
+
GET: {
|
|
166
|
+
summary: 'List inventory balances',
|
|
167
|
+
description: 'Returns paginated inventory balance buckets for the authenticated organization.',
|
|
168
|
+
query: inventoryBalanceListQuerySchema,
|
|
169
|
+
responses: [
|
|
170
|
+
{
|
|
171
|
+
status: 200,
|
|
172
|
+
description: 'Inventory balances collection',
|
|
173
|
+
schema: createPagedListResponseSchema(inventoryBalanceListItemSchema),
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
3
|
+
import { inventoryCycleCountSchema } from '../../../data/validators'
|
|
4
|
+
import { executeWmsCustomPostRoute } from '../helpers'
|
|
5
|
+
|
|
6
|
+
export const metadata = {
|
|
7
|
+
POST: { requireAuth: true, requireFeatures: ['wms.cycle_count'] },
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export async function POST(request: Request) {
|
|
11
|
+
return executeWmsCustomPostRoute({
|
|
12
|
+
request,
|
|
13
|
+
routePath: 'wms/inventory/cycle-count',
|
|
14
|
+
inputSchema: inventoryCycleCountSchema,
|
|
15
|
+
commandId: 'wms.inventory.cycleCount',
|
|
16
|
+
describeResource: (input) => ({
|
|
17
|
+
resourceKind: 'wms.inventory',
|
|
18
|
+
resourceId: `${input.warehouseId}:${input.locationId}:${input.catalogVariantId}`,
|
|
19
|
+
}),
|
|
20
|
+
mapSuccess: (result: { adjustmentDelta: string; movementId: string | null }) => ({
|
|
21
|
+
ok: true,
|
|
22
|
+
adjustmentDelta: result.adjustmentDelta,
|
|
23
|
+
movementId: result.movementId,
|
|
24
|
+
}),
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const successSchema = z.object({
|
|
29
|
+
ok: z.literal(true),
|
|
30
|
+
adjustmentDelta: z.string(),
|
|
31
|
+
movementId: z.string().uuid().nullable(),
|
|
32
|
+
})
|
|
33
|
+
const errorSchema = z.object({ error: z.string() })
|
|
34
|
+
|
|
35
|
+
export const openApi: OpenApiRouteDoc = {
|
|
36
|
+
tag: 'WMS',
|
|
37
|
+
summary: 'Cycle count reconcile',
|
|
38
|
+
methods: {
|
|
39
|
+
POST: {
|
|
40
|
+
summary: 'Cycle count reconcile',
|
|
41
|
+
description: 'Reconciles a counted quantity against the current on-hand balance and appends a cycle-count movement when a delta exists.',
|
|
42
|
+
requestBody: { contentType: 'application/json', schema: inventoryCycleCountSchema },
|
|
43
|
+
responses: [{ status: 200, description: 'Cycle count reconciled', schema: successSchema }],
|
|
44
|
+
errors: [
|
|
45
|
+
{ status: 400, description: 'Validation failed', schema: errorSchema },
|
|
46
|
+
{ status: 401, description: 'Unauthorized', schema: errorSchema },
|
|
47
|
+
{ status: 422, description: 'Invalid location', schema: errorSchema },
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
4
|
+
import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
5
|
+
import { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'
|
|
6
|
+
import type { CommandBus, CommandRuntimeContext } from '@open-mercato/shared/lib/commands'
|
|
7
|
+
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
8
|
+
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
9
|
+
import { readJsonSafe } from '@open-mercato/shared/lib/http/readJsonSafe'
|
|
10
|
+
import {
|
|
11
|
+
runCrudMutationGuardAfterSuccess,
|
|
12
|
+
validateCrudMutationGuard,
|
|
13
|
+
} from '@open-mercato/shared/lib/crud/mutation-guard'
|
|
14
|
+
import { runCustomRouteAfterInterceptors } from '@open-mercato/shared/lib/crud/custom-route-interceptor'
|
|
15
|
+
import { createLogger } from '@open-mercato/shared/lib/logger'
|
|
16
|
+
|
|
17
|
+
const logger = createLogger('wms')
|
|
18
|
+
|
|
19
|
+
type ResourceDescriptor = {
|
|
20
|
+
resourceKind: string
|
|
21
|
+
resourceId: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type ExecuteWmsCustomPostRouteOptions<TInput, TResult> = {
|
|
25
|
+
request: Request
|
|
26
|
+
routePath: string
|
|
27
|
+
inputSchema: z.ZodType<TInput>
|
|
28
|
+
commandId: string
|
|
29
|
+
describeResource: (input: TInput) => ResourceDescriptor
|
|
30
|
+
mapSuccess: (result: TResult) => Record<string, unknown>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function executeWmsCustomPostRoute<TInput, TResult>(
|
|
34
|
+
options: ExecuteWmsCustomPostRouteOptions<TInput, TResult>,
|
|
35
|
+
) {
|
|
36
|
+
try {
|
|
37
|
+
const container = await createRequestContainer()
|
|
38
|
+
const auth = await getAuthFromRequest(options.request)
|
|
39
|
+
const { translate } = await resolveTranslations()
|
|
40
|
+
if (!auth || !auth.tenantId) {
|
|
41
|
+
throw new CrudHttpError(401, { error: translate('wms.errors.unauthorized', 'Unauthorized') })
|
|
42
|
+
}
|
|
43
|
+
const organizationScope = await resolveOrganizationScopeForRequest({
|
|
44
|
+
container,
|
|
45
|
+
auth,
|
|
46
|
+
request: options.request,
|
|
47
|
+
})
|
|
48
|
+
const ctx: CommandRuntimeContext = {
|
|
49
|
+
container,
|
|
50
|
+
auth,
|
|
51
|
+
organizationScope,
|
|
52
|
+
selectedOrganizationId: organizationScope?.selectedId ?? auth.orgId ?? null,
|
|
53
|
+
organizationIds: organizationScope?.filterIds ?? (auth.orgId ? [auth.orgId] : null),
|
|
54
|
+
request: options.request,
|
|
55
|
+
}
|
|
56
|
+
const body = await readJsonSafe<Record<string, unknown>>(options.request, {})
|
|
57
|
+
const parsed = options.inputSchema.parse(body)
|
|
58
|
+
const resource = options.describeResource(parsed)
|
|
59
|
+
const guardResult = await validateCrudMutationGuard(container, {
|
|
60
|
+
tenantId: auth.tenantId,
|
|
61
|
+
organizationId: ctx.selectedOrganizationId,
|
|
62
|
+
userId: auth.sub,
|
|
63
|
+
resourceKind: resource.resourceKind,
|
|
64
|
+
resourceId: resource.resourceId,
|
|
65
|
+
operation: 'custom',
|
|
66
|
+
requestMethod: options.request.method,
|
|
67
|
+
requestHeaders: options.request.headers,
|
|
68
|
+
mutationPayload: parsed as Record<string, unknown>,
|
|
69
|
+
})
|
|
70
|
+
if (guardResult && !guardResult.ok) {
|
|
71
|
+
return NextResponse.json(guardResult.body, { status: guardResult.status })
|
|
72
|
+
}
|
|
73
|
+
const commandBus = container.resolve('commandBus') as CommandBus
|
|
74
|
+
const execution = await commandBus.execute<TInput, TResult>(options.commandId, {
|
|
75
|
+
input: parsed,
|
|
76
|
+
ctx,
|
|
77
|
+
})
|
|
78
|
+
if (guardResult?.ok && guardResult.shouldRunAfterSuccess) {
|
|
79
|
+
await runCrudMutationGuardAfterSuccess(container, {
|
|
80
|
+
tenantId: auth.tenantId,
|
|
81
|
+
organizationId: ctx.selectedOrganizationId,
|
|
82
|
+
userId: auth.sub,
|
|
83
|
+
resourceKind: resource.resourceKind,
|
|
84
|
+
resourceId: resource.resourceId,
|
|
85
|
+
operation: 'custom',
|
|
86
|
+
requestMethod: options.request.method,
|
|
87
|
+
requestHeaders: options.request.headers,
|
|
88
|
+
metadata: guardResult.metadata ?? null,
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
const responseBody = options.mapSuccess(execution.result)
|
|
92
|
+
const intercepted = await runCustomRouteAfterInterceptors({
|
|
93
|
+
routePath: options.routePath,
|
|
94
|
+
method: 'POST',
|
|
95
|
+
request: {
|
|
96
|
+
method: 'POST',
|
|
97
|
+
url: options.request.url,
|
|
98
|
+
body: parsed as Record<string, unknown>,
|
|
99
|
+
headers: Object.fromEntries(options.request.headers.entries()),
|
|
100
|
+
},
|
|
101
|
+
response: {
|
|
102
|
+
statusCode: 200,
|
|
103
|
+
body: responseBody,
|
|
104
|
+
headers: {},
|
|
105
|
+
},
|
|
106
|
+
context: {
|
|
107
|
+
em: container.resolve('em'),
|
|
108
|
+
container,
|
|
109
|
+
userId: auth.sub,
|
|
110
|
+
organizationId: ctx.selectedOrganizationId,
|
|
111
|
+
tenantId: auth.tenantId,
|
|
112
|
+
},
|
|
113
|
+
})
|
|
114
|
+
if (!intercepted.ok) {
|
|
115
|
+
return NextResponse.json(intercepted.body, { status: intercepted.statusCode })
|
|
116
|
+
}
|
|
117
|
+
return NextResponse.json(intercepted.body, { status: intercepted.statusCode })
|
|
118
|
+
} catch (error) {
|
|
119
|
+
if (error instanceof CrudHttpError) {
|
|
120
|
+
return NextResponse.json(error.body, { status: error.status })
|
|
121
|
+
}
|
|
122
|
+
if (error instanceof z.ZodError) {
|
|
123
|
+
return NextResponse.json({ error: 'Validation failed', details: error.issues }, { status: 400 })
|
|
124
|
+
}
|
|
125
|
+
logger.error('custom route failed', { routePath: options.routePath, commandId: options.commandId, err: error })
|
|
126
|
+
return NextResponse.json({ error: 'Internal server error' }, { status: 500 })
|
|
127
|
+
}
|
|
128
|
+
}
|