@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.
- 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,306 @@
|
|
|
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 type { CommandBus, CommandRuntimeContext } from '@open-mercato/shared/lib/commands'
|
|
9
|
+
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
10
|
+
import { readJsonSafe } from '@open-mercato/shared/lib/http/readJsonSafe'
|
|
11
|
+
import {
|
|
12
|
+
runCrudMutationGuardAfterSuccess,
|
|
13
|
+
validateCrudMutationGuard,
|
|
14
|
+
} from '@open-mercato/shared/lib/crud/mutation-guard'
|
|
15
|
+
import { runCustomRouteAfterInterceptors } from '@open-mercato/shared/lib/crud/custom-route-interceptor'
|
|
16
|
+
import { createLogger } from '@open-mercato/shared/lib/logger'
|
|
17
|
+
import { salesOrderWarehouseAssignBodySchema } from '../../../../data/validators'
|
|
18
|
+
import { loadSalesOrderWarehouseAssignmentView } from '../../../../lib/salesOrderWarehouseAssignment'
|
|
19
|
+
import { executeWmsCustomPostRoute } from '../../../inventory/helpers'
|
|
20
|
+
|
|
21
|
+
const logger = createLogger('wms')
|
|
22
|
+
|
|
23
|
+
const paramsSchema = z.object({
|
|
24
|
+
salesOrderId: z.string().uuid(),
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const assignmentResponseSchema = z.object({
|
|
28
|
+
assignment: z
|
|
29
|
+
.object({
|
|
30
|
+
id: z.string().uuid(),
|
|
31
|
+
salesOrderId: z.string().uuid(),
|
|
32
|
+
warehouseId: z.string().uuid(),
|
|
33
|
+
warehouseName: z.string().nullable(),
|
|
34
|
+
warehouseCode: z.string().nullable(),
|
|
35
|
+
notes: z.string().nullable(),
|
|
36
|
+
assignedBy: z.string().uuid().nullable(),
|
|
37
|
+
})
|
|
38
|
+
.nullable(),
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const assignSuccessSchema = z.object({
|
|
42
|
+
ok: z.literal(true),
|
|
43
|
+
assignmentId: z.string().uuid(),
|
|
44
|
+
warehouseId: z.string().uuid(),
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const okSchema = z.object({ ok: z.literal(true) })
|
|
48
|
+
const errorSchema = z.object({ error: z.string() })
|
|
49
|
+
|
|
50
|
+
export const metadata = {
|
|
51
|
+
GET: { requireAuth: true, requireFeatures: ['wms.view'] },
|
|
52
|
+
PUT: { requireAuth: true, requireFeatures: ['wms.manage_reservations'] },
|
|
53
|
+
PATCH: { requireAuth: true, requireFeatures: ['wms.manage_reservations'] },
|
|
54
|
+
DELETE: { requireAuth: true, requireFeatures: ['wms.manage_reservations'] },
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function resolveCommandContext(request: Request): Promise<CommandRuntimeContext> {
|
|
58
|
+
const container = await createRequestContainer()
|
|
59
|
+
const auth = await getAuthFromRequest(request)
|
|
60
|
+
if (!auth || !auth.tenantId) {
|
|
61
|
+
throw new CrudHttpError(401, { error: 'Unauthorized' })
|
|
62
|
+
}
|
|
63
|
+
const organizationScope = await resolveOrganizationScopeForRequest({
|
|
64
|
+
container,
|
|
65
|
+
auth,
|
|
66
|
+
request,
|
|
67
|
+
})
|
|
68
|
+
return {
|
|
69
|
+
container,
|
|
70
|
+
auth,
|
|
71
|
+
organizationScope,
|
|
72
|
+
selectedOrganizationId: organizationScope?.selectedId ?? auth.orgId ?? null,
|
|
73
|
+
organizationIds: organizationScope?.filterIds ?? (auth.orgId ? [auth.orgId] : null),
|
|
74
|
+
request,
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function resolveScope(ctx: CommandRuntimeContext) {
|
|
79
|
+
const organizationId = ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null
|
|
80
|
+
const tenantId = ctx.auth?.tenantId ?? null
|
|
81
|
+
if (!organizationId || !tenantId) {
|
|
82
|
+
throw new CrudHttpError(401, { error: 'Unauthorized' })
|
|
83
|
+
}
|
|
84
|
+
return { organizationId, tenantId }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export async function GET(
|
|
88
|
+
request: Request,
|
|
89
|
+
{ params }: { params: { salesOrderId: string } },
|
|
90
|
+
) {
|
|
91
|
+
try {
|
|
92
|
+
const parsedParams = paramsSchema.parse(params)
|
|
93
|
+
const ctx = await resolveCommandContext(request)
|
|
94
|
+
const scope = resolveScope(ctx)
|
|
95
|
+
const em = (ctx.container.resolve('em') as EntityManager).fork()
|
|
96
|
+
const assignment = await loadSalesOrderWarehouseAssignmentView(
|
|
97
|
+
em,
|
|
98
|
+
parsedParams.salesOrderId,
|
|
99
|
+
scope,
|
|
100
|
+
)
|
|
101
|
+
return NextResponse.json({ assignment })
|
|
102
|
+
} catch (error) {
|
|
103
|
+
if (error instanceof CrudHttpError) {
|
|
104
|
+
return NextResponse.json(error.body, { status: error.status })
|
|
105
|
+
}
|
|
106
|
+
if (error instanceof z.ZodError) {
|
|
107
|
+
return NextResponse.json({ error: 'Validation failed', details: error.issues }, { status: 400 })
|
|
108
|
+
}
|
|
109
|
+
logger.error('GET warehouse-assignment failed', { err: error })
|
|
110
|
+
return NextResponse.json({ error: 'Internal server error' }, { status: 500 })
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function executeAssignMutation(request: Request, salesOrderId: string) {
|
|
115
|
+
const body = await readJsonSafe<Record<string, unknown>>(request, {})
|
|
116
|
+
const parsedBody = salesOrderWarehouseAssignBodySchema.parse(body)
|
|
117
|
+
const scopedRequest = new Request(request.url, {
|
|
118
|
+
method: 'POST',
|
|
119
|
+
headers: request.headers,
|
|
120
|
+
body: JSON.stringify({
|
|
121
|
+
...parsedBody,
|
|
122
|
+
salesOrderId,
|
|
123
|
+
}),
|
|
124
|
+
})
|
|
125
|
+
return executeWmsCustomPostRoute({
|
|
126
|
+
request: scopedRequest,
|
|
127
|
+
routePath: `wms/sales-orders/${salesOrderId}/warehouse-assignment`,
|
|
128
|
+
inputSchema: z.object({
|
|
129
|
+
salesOrderId: z.string().uuid(),
|
|
130
|
+
warehouseId: z.string().uuid(),
|
|
131
|
+
notes: z.string().trim().max(500).optional(),
|
|
132
|
+
tenantId: z.string().uuid().optional(),
|
|
133
|
+
organizationId: z.string().uuid().optional(),
|
|
134
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
135
|
+
}),
|
|
136
|
+
commandId: 'wms.sales-order.assign-warehouse',
|
|
137
|
+
describeResource: (input) => ({
|
|
138
|
+
resourceKind: 'wms.sales_order_warehouse_assignment',
|
|
139
|
+
resourceId: input.salesOrderId,
|
|
140
|
+
}),
|
|
141
|
+
mapSuccess: (result: { assignmentId: string; warehouseId: string }) => ({
|
|
142
|
+
ok: true,
|
|
143
|
+
assignmentId: result.assignmentId,
|
|
144
|
+
warehouseId: result.warehouseId,
|
|
145
|
+
}),
|
|
146
|
+
})
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export async function PUT(
|
|
150
|
+
request: Request,
|
|
151
|
+
routeContext: { params: { salesOrderId: string } },
|
|
152
|
+
) {
|
|
153
|
+
const parsedParams = paramsSchema.parse(routeContext.params)
|
|
154
|
+
return executeAssignMutation(request, parsedParams.salesOrderId)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export async function PATCH(
|
|
158
|
+
request: Request,
|
|
159
|
+
routeContext: { params: { salesOrderId: string } },
|
|
160
|
+
) {
|
|
161
|
+
const parsedParams = paramsSchema.parse(routeContext.params)
|
|
162
|
+
return executeAssignMutation(request, parsedParams.salesOrderId)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export async function DELETE(
|
|
166
|
+
request: Request,
|
|
167
|
+
routeContext: { params: { salesOrderId: string } },
|
|
168
|
+
) {
|
|
169
|
+
try {
|
|
170
|
+
const parsedParams = paramsSchema.parse(routeContext.params)
|
|
171
|
+
const ctx = await resolveCommandContext(request)
|
|
172
|
+
const scope = resolveScope(ctx)
|
|
173
|
+
const resource = {
|
|
174
|
+
resourceKind: 'wms.sales_order_warehouse_assignment',
|
|
175
|
+
resourceId: parsedParams.salesOrderId,
|
|
176
|
+
}
|
|
177
|
+
const guardResult = await validateCrudMutationGuard(ctx.container, {
|
|
178
|
+
tenantId: scope.tenantId,
|
|
179
|
+
organizationId: scope.organizationId,
|
|
180
|
+
userId: ctx.auth?.sub ?? '',
|
|
181
|
+
resourceKind: resource.resourceKind,
|
|
182
|
+
resourceId: resource.resourceId,
|
|
183
|
+
operation: 'custom',
|
|
184
|
+
requestMethod: request.method,
|
|
185
|
+
requestHeaders: request.headers,
|
|
186
|
+
mutationPayload: { salesOrderId: parsedParams.salesOrderId },
|
|
187
|
+
})
|
|
188
|
+
if (guardResult && !guardResult.ok) {
|
|
189
|
+
return NextResponse.json(guardResult.body, { status: guardResult.status })
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const commandBus = ctx.container.resolve('commandBus') as CommandBus
|
|
193
|
+
await commandBus.execute('wms.sales-order.unassign-warehouse', {
|
|
194
|
+
input: {
|
|
195
|
+
salesOrderId: parsedParams.salesOrderId,
|
|
196
|
+
tenantId: scope.tenantId,
|
|
197
|
+
organizationId: scope.organizationId,
|
|
198
|
+
},
|
|
199
|
+
ctx,
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
if (guardResult?.ok && guardResult.shouldRunAfterSuccess) {
|
|
203
|
+
await runCrudMutationGuardAfterSuccess(ctx.container, {
|
|
204
|
+
tenantId: scope.tenantId,
|
|
205
|
+
organizationId: scope.organizationId,
|
|
206
|
+
userId: ctx.auth?.sub ?? '',
|
|
207
|
+
resourceKind: resource.resourceKind,
|
|
208
|
+
resourceId: resource.resourceId,
|
|
209
|
+
operation: 'custom',
|
|
210
|
+
requestMethod: request.method,
|
|
211
|
+
requestHeaders: request.headers,
|
|
212
|
+
metadata: guardResult.metadata ?? null,
|
|
213
|
+
})
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const responseBody = { ok: true as const }
|
|
217
|
+
const intercepted = await runCustomRouteAfterInterceptors({
|
|
218
|
+
routePath: `wms/sales-orders/${parsedParams.salesOrderId}/warehouse-assignment`,
|
|
219
|
+
method: 'DELETE',
|
|
220
|
+
request: {
|
|
221
|
+
method: 'DELETE',
|
|
222
|
+
url: request.url,
|
|
223
|
+
body: { salesOrderId: parsedParams.salesOrderId },
|
|
224
|
+
headers: Object.fromEntries(request.headers.entries()),
|
|
225
|
+
},
|
|
226
|
+
response: {
|
|
227
|
+
statusCode: 200,
|
|
228
|
+
body: responseBody,
|
|
229
|
+
headers: {},
|
|
230
|
+
},
|
|
231
|
+
context: {
|
|
232
|
+
em: ctx.container.resolve('em'),
|
|
233
|
+
container: ctx.container,
|
|
234
|
+
userId: ctx.auth?.sub ?? '',
|
|
235
|
+
organizationId: scope.organizationId,
|
|
236
|
+
tenantId: scope.tenantId,
|
|
237
|
+
},
|
|
238
|
+
})
|
|
239
|
+
if (!intercepted.ok) {
|
|
240
|
+
return NextResponse.json(intercepted.body, { status: intercepted.statusCode })
|
|
241
|
+
}
|
|
242
|
+
return NextResponse.json(intercepted.body, { status: intercepted.statusCode })
|
|
243
|
+
} catch (error) {
|
|
244
|
+
if (error instanceof CrudHttpError) {
|
|
245
|
+
return NextResponse.json(error.body, { status: error.status })
|
|
246
|
+
}
|
|
247
|
+
if (error instanceof z.ZodError) {
|
|
248
|
+
return NextResponse.json({ error: 'Validation failed', details: error.issues }, { status: 400 })
|
|
249
|
+
}
|
|
250
|
+
logger.error('DELETE warehouse-assignment failed', { err: error })
|
|
251
|
+
return NextResponse.json({ error: 'Internal server error' }, { status: 500 })
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export const openApi: OpenApiRouteDoc = {
|
|
256
|
+
tag: 'WMS',
|
|
257
|
+
summary: 'Sales order warehouse assignment',
|
|
258
|
+
methods: {
|
|
259
|
+
GET: {
|
|
260
|
+
summary: 'Get warehouse assignment for sales order',
|
|
261
|
+
description:
|
|
262
|
+
'Returns the explicit WMS warehouse assignment for a sales order, or null when none is set.',
|
|
263
|
+
responses: [
|
|
264
|
+
{ status: 200, description: 'Assignment state', schema: assignmentResponseSchema },
|
|
265
|
+
],
|
|
266
|
+
errors: [
|
|
267
|
+
{ status: 400, description: 'Validation failed', schema: errorSchema },
|
|
268
|
+
{ status: 401, description: 'Unauthorized', schema: errorSchema },
|
|
269
|
+
],
|
|
270
|
+
},
|
|
271
|
+
PUT: {
|
|
272
|
+
summary: 'Assign warehouse to sales order',
|
|
273
|
+
description:
|
|
274
|
+
'Creates or replaces the explicit warehouse assignment for a sales order.',
|
|
275
|
+
requestBody: { contentType: 'application/json', schema: salesOrderWarehouseAssignBodySchema },
|
|
276
|
+
responses: [
|
|
277
|
+
{ status: 200, description: 'Warehouse assigned', schema: assignSuccessSchema },
|
|
278
|
+
{ status: 201, description: 'Warehouse assigned', schema: assignSuccessSchema },
|
|
279
|
+
],
|
|
280
|
+
errors: [
|
|
281
|
+
{ status: 400, description: 'Validation failed', schema: errorSchema },
|
|
282
|
+
{ status: 401, description: 'Unauthorized', schema: errorSchema },
|
|
283
|
+
{ status: 404, description: 'Warehouse not found', schema: errorSchema },
|
|
284
|
+
{ status: 422, description: 'Warehouse is inactive', schema: errorSchema },
|
|
285
|
+
],
|
|
286
|
+
},
|
|
287
|
+
PATCH: {
|
|
288
|
+
summary: 'Patch warehouse assignment for sales order',
|
|
289
|
+
description: 'Same as PUT — upserts the explicit warehouse assignment.',
|
|
290
|
+
requestBody: { contentType: 'application/json', schema: salesOrderWarehouseAssignBodySchema },
|
|
291
|
+
responses: [{ status: 200, description: 'Warehouse assigned', schema: assignSuccessSchema }],
|
|
292
|
+
errors: [
|
|
293
|
+
{ status: 400, description: 'Validation failed', schema: errorSchema },
|
|
294
|
+
{ status: 401, description: 'Unauthorized', schema: errorSchema },
|
|
295
|
+
],
|
|
296
|
+
},
|
|
297
|
+
DELETE: {
|
|
298
|
+
summary: 'Remove warehouse assignment from sales order',
|
|
299
|
+
description: 'Clears the explicit assignment so enricher and automation fall back again.',
|
|
300
|
+
responses: [{ status: 200, description: 'Assignment removed', schema: okSchema }],
|
|
301
|
+
errors: [
|
|
302
|
+
{ status: 401, description: 'Unauthorized', schema: errorSchema },
|
|
303
|
+
],
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
3
|
+
import { salesOrderWarehouseAssignSchema } from '../../../data/validators'
|
|
4
|
+
import { executeWmsCustomPostRoute } from '../../inventory/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/sales-orders/assign-warehouse',
|
|
14
|
+
inputSchema: salesOrderWarehouseAssignSchema,
|
|
15
|
+
commandId: 'wms.sales-order.assign-warehouse',
|
|
16
|
+
describeResource: (input) => ({
|
|
17
|
+
resourceKind: 'wms.sales_order_warehouse_assignment',
|
|
18
|
+
resourceId: input.salesOrderId,
|
|
19
|
+
}),
|
|
20
|
+
mapSuccess: (result: { assignmentId: string; warehouseId: string }) => ({
|
|
21
|
+
ok: true,
|
|
22
|
+
assignmentId: result.assignmentId,
|
|
23
|
+
warehouseId: result.warehouseId,
|
|
24
|
+
}),
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const successSchema = z.object({
|
|
29
|
+
ok: z.literal(true),
|
|
30
|
+
assignmentId: z.string().uuid(),
|
|
31
|
+
warehouseId: z.string().uuid(),
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const errorSchema = z.object({ error: z.string() })
|
|
35
|
+
|
|
36
|
+
export const openApi: OpenApiRouteDoc = {
|
|
37
|
+
tag: 'WMS',
|
|
38
|
+
summary: 'Assign warehouse to sales order',
|
|
39
|
+
methods: {
|
|
40
|
+
POST: {
|
|
41
|
+
summary: 'Assign warehouse to sales order',
|
|
42
|
+
description:
|
|
43
|
+
'Explicitly assigns a warehouse to a sales order. When set, the enricher returns this warehouse and the reservation automation prefers it.',
|
|
44
|
+
requestBody: { contentType: 'application/json', schema: salesOrderWarehouseAssignSchema },
|
|
45
|
+
responses: [
|
|
46
|
+
{ status: 201, description: 'Warehouse assigned', schema: successSchema },
|
|
47
|
+
{ status: 200, description: 'Warehouse assignment updated', schema: successSchema },
|
|
48
|
+
],
|
|
49
|
+
errors: [
|
|
50
|
+
{ status: 400, description: 'Validation failed', schema: errorSchema },
|
|
51
|
+
{ status: 401, description: 'Unauthorized', schema: errorSchema },
|
|
52
|
+
{ status: 404, description: 'Warehouse not found', schema: errorSchema },
|
|
53
|
+
{ status: 422, description: 'Warehouse is inactive', schema: errorSchema },
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
3
|
+
import { salesOrderWarehouseUnassignSchema } from '../../../data/validators'
|
|
4
|
+
import { executeWmsCustomPostRoute } from '../../inventory/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/sales-orders/unassign-warehouse',
|
|
14
|
+
inputSchema: salesOrderWarehouseUnassignSchema,
|
|
15
|
+
commandId: 'wms.sales-order.unassign-warehouse',
|
|
16
|
+
describeResource: (input) => ({
|
|
17
|
+
resourceKind: 'wms.sales_order_warehouse_assignment',
|
|
18
|
+
resourceId: input.salesOrderId,
|
|
19
|
+
}),
|
|
20
|
+
mapSuccess: () => ({ ok: true }),
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const successSchema = z.object({ ok: z.literal(true) })
|
|
25
|
+
const errorSchema = z.object({ error: z.string() })
|
|
26
|
+
|
|
27
|
+
export const openApi: OpenApiRouteDoc = {
|
|
28
|
+
tag: 'WMS',
|
|
29
|
+
summary: 'Remove warehouse assignment from sales order',
|
|
30
|
+
methods: {
|
|
31
|
+
POST: {
|
|
32
|
+
summary: 'Remove warehouse assignment from sales order',
|
|
33
|
+
description:
|
|
34
|
+
'Removes an explicit warehouse assignment from a sales order. The enricher will fall back to deriving the warehouse from active reservations or the primary warehouse.',
|
|
35
|
+
requestBody: { contentType: 'application/json', schema: salesOrderWarehouseUnassignSchema },
|
|
36
|
+
responses: [{ status: 200, description: 'Assignment removed', schema: successSchema }],
|
|
37
|
+
errors: [
|
|
38
|
+
{ status: 400, description: 'Validation failed', schema: errorSchema },
|
|
39
|
+
{ status: 401, description: 'Unauthorized', schema: errorSchema },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
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 { parseScopedCommandInput, resolveCrudRecordId } from '@open-mercato/shared/lib/api/scoped'
|
|
5
|
+
import { escapeLikePattern } from '@open-mercato/shared/lib/db/escapeLikePattern'
|
|
6
|
+
import { parseBooleanToken } from '@open-mercato/shared/lib/boolean'
|
|
7
|
+
import { E } from '#generated/entities.ids.generated'
|
|
8
|
+
import { Warehouse } from '../../data/entities'
|
|
9
|
+
import { warehouseCreateSchema, warehouseUpdateSchema } from '../../data/validators'
|
|
10
|
+
import { createPagedListResponseSchema, createWmsCrudOpenApi, defaultOkResponseSchema } from '../openapi'
|
|
11
|
+
|
|
12
|
+
const F = {
|
|
13
|
+
id: 'id',
|
|
14
|
+
organization_id: 'organization_id',
|
|
15
|
+
tenant_id: 'tenant_id',
|
|
16
|
+
name: 'name',
|
|
17
|
+
code: 'code',
|
|
18
|
+
is_active: 'is_active',
|
|
19
|
+
is_primary: 'is_primary',
|
|
20
|
+
address_line1: 'address_line1',
|
|
21
|
+
city: 'city',
|
|
22
|
+
postal_code: 'postal_code',
|
|
23
|
+
country: 'country',
|
|
24
|
+
timezone: 'timezone',
|
|
25
|
+
created_at: 'created_at',
|
|
26
|
+
updated_at: 'updated_at',
|
|
27
|
+
} as const
|
|
28
|
+
|
|
29
|
+
const routeMetadata = {
|
|
30
|
+
GET: { requireAuth: true, requireFeatures: ['wms.view'] },
|
|
31
|
+
POST: { requireAuth: true, requireFeatures: ['wms.manage_warehouses'] },
|
|
32
|
+
PUT: { requireAuth: true, requireFeatures: ['wms.manage_warehouses'] },
|
|
33
|
+
DELETE: { requireAuth: true, requireFeatures: ['wms.manage_warehouses'] },
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const metadata = routeMetadata
|
|
37
|
+
|
|
38
|
+
const rawBodySchema = z.object({}).passthrough()
|
|
39
|
+
|
|
40
|
+
const listSchema = z.object({
|
|
41
|
+
page: z.coerce.number().min(1).default(1),
|
|
42
|
+
pageSize: z.coerce.number().min(1).max(100).default(25),
|
|
43
|
+
search: z.string().optional(),
|
|
44
|
+
ids: z.string().optional(),
|
|
45
|
+
isActive: z.string().optional(),
|
|
46
|
+
sortField: z.string().optional(),
|
|
47
|
+
sortDir: z.enum(['asc', 'desc']).optional(),
|
|
48
|
+
}).passthrough()
|
|
49
|
+
|
|
50
|
+
const crud = makeCrudRoute({
|
|
51
|
+
metadata: routeMetadata,
|
|
52
|
+
orm: {
|
|
53
|
+
entity: Warehouse,
|
|
54
|
+
idField: 'id',
|
|
55
|
+
orgField: 'organizationId',
|
|
56
|
+
tenantField: 'tenantId',
|
|
57
|
+
softDeleteField: 'deletedAt',
|
|
58
|
+
},
|
|
59
|
+
indexer: { entityType: E.wms.warehouse },
|
|
60
|
+
list: {
|
|
61
|
+
schema: listSchema,
|
|
62
|
+
disableListCache: true,
|
|
63
|
+
entityId: E.wms.warehouse,
|
|
64
|
+
fields: [
|
|
65
|
+
F.id,
|
|
66
|
+
F.organization_id,
|
|
67
|
+
F.tenant_id,
|
|
68
|
+
F.name,
|
|
69
|
+
F.code,
|
|
70
|
+
F.is_active,
|
|
71
|
+
F.is_primary,
|
|
72
|
+
F.address_line1,
|
|
73
|
+
F.city,
|
|
74
|
+
F.postal_code,
|
|
75
|
+
F.country,
|
|
76
|
+
F.timezone,
|
|
77
|
+
F.created_at,
|
|
78
|
+
F.updated_at,
|
|
79
|
+
],
|
|
80
|
+
sortFieldMap: {
|
|
81
|
+
name: F.name,
|
|
82
|
+
code: F.code,
|
|
83
|
+
createdAt: F.created_at,
|
|
84
|
+
updatedAt: F.updated_at,
|
|
85
|
+
},
|
|
86
|
+
buildFilters: async (query) => {
|
|
87
|
+
const filters: Record<string, unknown> = {}
|
|
88
|
+
if (typeof query.ids === 'string' && query.ids.trim().length > 0) {
|
|
89
|
+
filters[F.id] = {
|
|
90
|
+
$in: query.ids.split(',').map((value) => value.trim()).filter((value) => value.length > 0),
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const isActive = parseBooleanToken(query.isActive)
|
|
94
|
+
if (isActive !== null) filters[F.is_active] = { $eq: isActive }
|
|
95
|
+
const term = query.search?.trim()
|
|
96
|
+
if (term) {
|
|
97
|
+
const like = `%${escapeLikePattern(term)}%`
|
|
98
|
+
filters.$or = [
|
|
99
|
+
{ [F.name]: { $ilike: like } },
|
|
100
|
+
{ [F.code]: { $ilike: like } },
|
|
101
|
+
{ [F.city]: { $ilike: like } },
|
|
102
|
+
{ [F.country]: { $ilike: like } },
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
return filters
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
actions: {
|
|
109
|
+
create: {
|
|
110
|
+
commandId: 'wms.warehouses.create',
|
|
111
|
+
schema: rawBodySchema,
|
|
112
|
+
mapInput: async ({ raw, ctx }) => {
|
|
113
|
+
const { translate } = await resolveTranslations()
|
|
114
|
+
return parseScopedCommandInput(warehouseCreateSchema, raw ?? {}, ctx, translate)
|
|
115
|
+
},
|
|
116
|
+
response: ({ result }) => ({ id: result?.warehouseId ?? null }),
|
|
117
|
+
status: 201,
|
|
118
|
+
},
|
|
119
|
+
update: {
|
|
120
|
+
commandId: 'wms.warehouses.update',
|
|
121
|
+
schema: rawBodySchema,
|
|
122
|
+
mapInput: async ({ raw, ctx }) => {
|
|
123
|
+
const { translate } = await resolveTranslations()
|
|
124
|
+
return parseScopedCommandInput(warehouseUpdateSchema, raw ?? {}, ctx, translate)
|
|
125
|
+
},
|
|
126
|
+
response: () => ({ ok: true }),
|
|
127
|
+
},
|
|
128
|
+
delete: {
|
|
129
|
+
commandId: 'wms.warehouses.delete',
|
|
130
|
+
schema: rawBodySchema,
|
|
131
|
+
mapInput: async ({ parsed, ctx }) => {
|
|
132
|
+
const { translate } = await resolveTranslations()
|
|
133
|
+
return { id: resolveCrudRecordId(parsed, ctx, translate) }
|
|
134
|
+
},
|
|
135
|
+
response: () => ({ ok: true }),
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
export const GET = crud.GET
|
|
141
|
+
export const POST = crud.POST
|
|
142
|
+
export const PUT = crud.PUT
|
|
143
|
+
export const DELETE = crud.DELETE
|
|
144
|
+
|
|
145
|
+
const warehouseListItemSchema = z.object({
|
|
146
|
+
id: z.string().uuid().nullable().optional(),
|
|
147
|
+
organization_id: z.string().uuid().nullable().optional(),
|
|
148
|
+
tenant_id: z.string().uuid().nullable().optional(),
|
|
149
|
+
name: z.string().nullable().optional(),
|
|
150
|
+
code: z.string().nullable().optional(),
|
|
151
|
+
is_active: z.boolean().nullable().optional(),
|
|
152
|
+
is_primary: z.boolean().nullable().optional(),
|
|
153
|
+
address_line1: z.string().nullable().optional(),
|
|
154
|
+
city: z.string().nullable().optional(),
|
|
155
|
+
postal_code: z.string().nullable().optional(),
|
|
156
|
+
country: z.string().nullable().optional(),
|
|
157
|
+
timezone: z.string().nullable().optional(),
|
|
158
|
+
created_at: z.string().nullable().optional(),
|
|
159
|
+
updated_at: z.string().nullable().optional(),
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
export const openApi = createWmsCrudOpenApi({
|
|
163
|
+
resourceName: 'Warehouse',
|
|
164
|
+
pluralName: 'Warehouses',
|
|
165
|
+
querySchema: listSchema,
|
|
166
|
+
listResponseSchema: createPagedListResponseSchema(warehouseListItemSchema),
|
|
167
|
+
create: {
|
|
168
|
+
schema: warehouseCreateSchema,
|
|
169
|
+
description: 'Creates a warehouse for inventory operations.',
|
|
170
|
+
},
|
|
171
|
+
update: {
|
|
172
|
+
schema: warehouseUpdateSchema,
|
|
173
|
+
responseSchema: defaultOkResponseSchema,
|
|
174
|
+
description: 'Updates a warehouse by id.',
|
|
175
|
+
},
|
|
176
|
+
del: {
|
|
177
|
+
schema: z.object({ id: z.string().uuid() }),
|
|
178
|
+
responseSchema: defaultOkResponseSchema,
|
|
179
|
+
description: 'Soft-deletes a warehouse by id.',
|
|
180
|
+
},
|
|
181
|
+
})
|