@open-mercato/core 0.6.7-develop.6661.1.0043ed1d03 → 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/customer_accounts/migrations/Migration20260724120000_customer_accounts.js +56 -0
- package/dist/modules/customer_accounts/migrations/Migration20260724120000_customer_accounts.js.map +7 -0
- package/dist/modules/directory/api/organizations/route.js +1 -1
- package/dist/modules/directory/api/organizations/route.js.map +1 -1
- package/dist/modules/entities/api/definitions.js +2 -0
- package/dist/modules/entities/api/definitions.js.map +2 -2
- package/dist/modules/entities/lib/helpers.js +1 -0
- package/dist/modules/entities/lib/helpers.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/api/quotes/accept/route.js +7 -2
- package/dist/modules/sales/api/quotes/accept/route.js.map +2 -2
- package/dist/modules/sales/api/quotes/public/[token]/route.js +2 -1
- package/dist/modules/sales/api/quotes/public/[token]/route.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/lib/publicQuoteTenantScope.js +24 -0
- package/dist/modules/sales/lib/publicQuoteTenantScope.js.map +7 -0
- 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/customer_accounts/migrations/Migration20260724120000_customer_accounts.ts +96 -0
- package/src/modules/directory/api/organizations/route.ts +1 -1
- package/src/modules/entities/api/definitions.ts +2 -0
- package/src/modules/entities/lib/helpers.ts +1 -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/api/quotes/accept/route.ts +9 -2
- package/src/modules/sales/api/quotes/public/[token]/route.ts +2 -1
- 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/lib/publicQuoteTenantScope.ts +49 -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,177 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { makeCrudRoute } from '@open-mercato/shared/lib/crud/factory'
|
|
3
|
+
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
4
|
+
import { parseBooleanToken } from '@open-mercato/shared/lib/boolean'
|
|
5
|
+
import { parseScopedCommandInput, resolveCrudRecordId } from '@open-mercato/shared/lib/api/scoped'
|
|
6
|
+
import { E } from '#generated/entities.ids.generated'
|
|
7
|
+
import { ProductInventoryProfile } from '../../data/entities'
|
|
8
|
+
import {
|
|
9
|
+
productInventoryProfileCreateSchema,
|
|
10
|
+
productInventoryProfileUpdateSchema,
|
|
11
|
+
} from '../../data/validators'
|
|
12
|
+
import { createPagedListResponseSchema, createWmsCrudOpenApi, defaultOkResponseSchema } from '../openapi'
|
|
13
|
+
import { attachInventoryProfileCatalogLabelsToListItems } from '../listEnrichers'
|
|
14
|
+
|
|
15
|
+
const routeMetadata = {
|
|
16
|
+
GET: { requireAuth: true, requireFeatures: ['wms.view'] },
|
|
17
|
+
POST: { requireAuth: true, requireFeatures: ['wms.manage_inventory'] },
|
|
18
|
+
PUT: { requireAuth: true, requireFeatures: ['wms.manage_inventory'] },
|
|
19
|
+
DELETE: { requireAuth: true, requireFeatures: ['wms.manage_inventory'] },
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const metadata = routeMetadata
|
|
23
|
+
|
|
24
|
+
const rawBodySchema = z.object({}).passthrough()
|
|
25
|
+
|
|
26
|
+
const listSchema = z.object({
|
|
27
|
+
page: z.coerce.number().min(1).default(1),
|
|
28
|
+
pageSize: z.coerce.number().min(1).max(100).default(25),
|
|
29
|
+
catalogProductId: z.string().uuid().optional(),
|
|
30
|
+
catalogVariantId: z.string().uuid().optional(),
|
|
31
|
+
defaultStrategy: z.enum(['fifo', 'lifo', 'fefo']).optional(),
|
|
32
|
+
trackLot: z.string().optional(),
|
|
33
|
+
trackSerial: z.string().optional(),
|
|
34
|
+
trackExpiration: z.string().optional(),
|
|
35
|
+
ids: z.string().optional(),
|
|
36
|
+
sortField: z.string().optional(),
|
|
37
|
+
sortDir: z.enum(['asc', 'desc']).optional(),
|
|
38
|
+
}).passthrough()
|
|
39
|
+
|
|
40
|
+
const crud = makeCrudRoute({
|
|
41
|
+
metadata: routeMetadata,
|
|
42
|
+
orm: {
|
|
43
|
+
entity: ProductInventoryProfile,
|
|
44
|
+
idField: 'id',
|
|
45
|
+
orgField: 'organizationId',
|
|
46
|
+
tenantField: 'tenantId',
|
|
47
|
+
softDeleteField: 'deletedAt',
|
|
48
|
+
},
|
|
49
|
+
indexer: { entityType: E.wms.product_inventory_profile },
|
|
50
|
+
list: {
|
|
51
|
+
schema: listSchema,
|
|
52
|
+
entityId: E.wms.product_inventory_profile,
|
|
53
|
+
fields: [
|
|
54
|
+
'id',
|
|
55
|
+
'organization_id',
|
|
56
|
+
'tenant_id',
|
|
57
|
+
'catalog_product_id',
|
|
58
|
+
'catalog_variant_id',
|
|
59
|
+
'default_uom',
|
|
60
|
+
'track_lot',
|
|
61
|
+
'track_serial',
|
|
62
|
+
'track_expiration',
|
|
63
|
+
'default_strategy',
|
|
64
|
+
'reorder_point',
|
|
65
|
+
'safety_stock',
|
|
66
|
+
'created_at',
|
|
67
|
+
'updated_at',
|
|
68
|
+
],
|
|
69
|
+
sortFieldMap: {
|
|
70
|
+
createdAt: 'created_at',
|
|
71
|
+
updatedAt: 'updated_at',
|
|
72
|
+
defaultStrategy: 'default_strategy',
|
|
73
|
+
reorderPoint: 'reorder_point',
|
|
74
|
+
safetyStock: 'safety_stock',
|
|
75
|
+
},
|
|
76
|
+
buildFilters: async (query) => {
|
|
77
|
+
const filters: Record<string, unknown> = {}
|
|
78
|
+
if (query.catalogProductId) filters.catalog_product_id = { $eq: query.catalogProductId }
|
|
79
|
+
if (query.catalogVariantId) filters.catalog_variant_id = { $eq: query.catalogVariantId }
|
|
80
|
+
if (query.defaultStrategy) filters.default_strategy = { $eq: query.defaultStrategy }
|
|
81
|
+
const trackLot = parseBooleanToken(query.trackLot)
|
|
82
|
+
const trackSerial = parseBooleanToken(query.trackSerial)
|
|
83
|
+
const trackExpiration = parseBooleanToken(query.trackExpiration)
|
|
84
|
+
if (trackLot !== null) filters.track_lot = { $eq: trackLot }
|
|
85
|
+
if (trackSerial !== null) filters.track_serial = { $eq: trackSerial }
|
|
86
|
+
if (trackExpiration !== null) filters.track_expiration = { $eq: trackExpiration }
|
|
87
|
+
if (typeof query.ids === 'string' && query.ids.trim().length > 0) {
|
|
88
|
+
filters.id = {
|
|
89
|
+
$in: query.ids.split(',').map((value) => value.trim()).filter((value) => value.length > 0),
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return filters
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
hooks: {
|
|
96
|
+
afterList: async (payload, ctx) => {
|
|
97
|
+
await attachInventoryProfileCatalogLabelsToListItems(payload, ctx)
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
actions: {
|
|
101
|
+
create: {
|
|
102
|
+
commandId: 'wms.inventoryProfiles.create',
|
|
103
|
+
schema: rawBodySchema,
|
|
104
|
+
mapInput: async ({ raw, ctx }) => {
|
|
105
|
+
const { translate } = await resolveTranslations()
|
|
106
|
+
return parseScopedCommandInput(productInventoryProfileCreateSchema, raw ?? {}, ctx, translate)
|
|
107
|
+
},
|
|
108
|
+
response: ({ result }) => ({ id: result?.profileId ?? null }),
|
|
109
|
+
status: 201,
|
|
110
|
+
},
|
|
111
|
+
update: {
|
|
112
|
+
commandId: 'wms.inventoryProfiles.update',
|
|
113
|
+
schema: rawBodySchema,
|
|
114
|
+
mapInput: async ({ raw, ctx }) => {
|
|
115
|
+
const { translate } = await resolveTranslations()
|
|
116
|
+
return parseScopedCommandInput(productInventoryProfileUpdateSchema, raw ?? {}, ctx, translate)
|
|
117
|
+
},
|
|
118
|
+
response: () => ({ ok: true }),
|
|
119
|
+
},
|
|
120
|
+
delete: {
|
|
121
|
+
commandId: 'wms.inventoryProfiles.delete',
|
|
122
|
+
schema: rawBodySchema,
|
|
123
|
+
mapInput: async ({ parsed, ctx }) => {
|
|
124
|
+
const { translate } = await resolveTranslations()
|
|
125
|
+
return { id: resolveCrudRecordId(parsed, ctx, translate) }
|
|
126
|
+
},
|
|
127
|
+
response: () => ({ ok: true }),
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
export const GET = crud.GET
|
|
133
|
+
export const POST = crud.POST
|
|
134
|
+
export const PUT = crud.PUT
|
|
135
|
+
export const DELETE = crud.DELETE
|
|
136
|
+
|
|
137
|
+
const profileListItemSchema = 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
|
+
catalog_product_id: z.string().uuid().nullable().optional(),
|
|
142
|
+
catalog_variant_id: z.string().uuid().nullable().optional(),
|
|
143
|
+
product_title: z.string().nullable().optional(),
|
|
144
|
+
product_sku: z.string().nullable().optional(),
|
|
145
|
+
variant_name: z.string().nullable().optional(),
|
|
146
|
+
variant_sku: z.string().nullable().optional(),
|
|
147
|
+
default_uom: z.string().nullable().optional(),
|
|
148
|
+
track_lot: z.boolean().nullable().optional(),
|
|
149
|
+
track_serial: z.boolean().nullable().optional(),
|
|
150
|
+
track_expiration: z.boolean().nullable().optional(),
|
|
151
|
+
default_strategy: z.string().nullable().optional(),
|
|
152
|
+
reorder_point: z.union([z.string(), z.number()]).nullable().optional(),
|
|
153
|
+
safety_stock: z.union([z.string(), z.number()]).nullable().optional(),
|
|
154
|
+
created_at: z.string().nullable().optional(),
|
|
155
|
+
updated_at: z.string().nullable().optional(),
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
export const openApi = createWmsCrudOpenApi({
|
|
159
|
+
resourceName: 'Inventory profile',
|
|
160
|
+
pluralName: 'Inventory profiles',
|
|
161
|
+
querySchema: listSchema,
|
|
162
|
+
listResponseSchema: createPagedListResponseSchema(profileListItemSchema),
|
|
163
|
+
create: {
|
|
164
|
+
schema: productInventoryProfileCreateSchema,
|
|
165
|
+
description: 'Creates a product inventory profile.',
|
|
166
|
+
},
|
|
167
|
+
update: {
|
|
168
|
+
schema: productInventoryProfileUpdateSchema,
|
|
169
|
+
responseSchema: defaultOkResponseSchema,
|
|
170
|
+
description: 'Updates an inventory profile by id.',
|
|
171
|
+
},
|
|
172
|
+
del: {
|
|
173
|
+
schema: z.object({ id: z.string().uuid() }),
|
|
174
|
+
responseSchema: defaultOkResponseSchema,
|
|
175
|
+
description: 'Soft-deletes an inventory profile by id.',
|
|
176
|
+
},
|
|
177
|
+
})
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
// Lightweight afterList enrichers shared across WMS list routes.
|
|
2
|
+
//
|
|
3
|
+
// These run inside `makeCrudRoute({ hooks: { afterList } })` and batch-resolve
|
|
4
|
+
// foreign-key labels (e.g. warehouse_id -> warehouse_name) so backend tables
|
|
5
|
+
// can render the human-readable label without N+1 lookups on the client.
|
|
6
|
+
//
|
|
7
|
+
// We deliberately use the `queryEngine` (entity-id-based) rather than ORM
|
|
8
|
+
// entity classes so this file stays decoupled from `wms/data/entities`
|
|
9
|
+
// internals and from the catalog ORM — same pattern used by High #5 in WMS
|
|
10
|
+
// data enrichers.
|
|
11
|
+
|
|
12
|
+
import type { CrudCtx } from '@open-mercato/shared/lib/crud/factory'
|
|
13
|
+
import type { QueryEngine } from '@open-mercato/shared/lib/query/types'
|
|
14
|
+
import { createLogger } from '@open-mercato/shared/lib/logger'
|
|
15
|
+
import { E } from '#generated/entities.ids.generated'
|
|
16
|
+
|
|
17
|
+
const logger = createLogger('wms')
|
|
18
|
+
|
|
19
|
+
type AnyListPayload = {
|
|
20
|
+
items?: Array<Record<string, unknown>>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type LookupRow = Record<string, unknown> & { id?: string | null }
|
|
24
|
+
|
|
25
|
+
const LOOKUP_BATCH_SIZE = 500
|
|
26
|
+
|
|
27
|
+
function uniqueIdsFromKeys(
|
|
28
|
+
items: Array<Record<string, unknown>>,
|
|
29
|
+
keys: string[],
|
|
30
|
+
): string[] {
|
|
31
|
+
const set = new Set<string>()
|
|
32
|
+
for (const item of items) {
|
|
33
|
+
for (const key of keys) {
|
|
34
|
+
const value = item?.[key]
|
|
35
|
+
if (typeof value === 'string' && value.length > 0) set.add(value)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return Array.from(set)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Internal: batch-load `entityId` rows by primary id through the QueryEngine
|
|
43
|
+
* and return them keyed by id. Splits requests into chunks of 500. Errors are
|
|
44
|
+
* logged (with a `source` tag for grep-ability) and degrade to an empty map so
|
|
45
|
+
* the surrounding list response still goes through.
|
|
46
|
+
*/
|
|
47
|
+
async function batchLoadById(
|
|
48
|
+
ctx: CrudCtx,
|
|
49
|
+
entityId: string,
|
|
50
|
+
ids: string[],
|
|
51
|
+
fields: string[],
|
|
52
|
+
source: string,
|
|
53
|
+
): Promise<Map<string, LookupRow>> {
|
|
54
|
+
if (ids.length === 0) return new Map()
|
|
55
|
+
const tenantId = ctx.auth?.tenantId
|
|
56
|
+
if (!tenantId) return new Map()
|
|
57
|
+
const queryEngine = ctx.container.resolve('queryEngine') as QueryEngine
|
|
58
|
+
const map = new Map<string, LookupRow>()
|
|
59
|
+
for (let offset = 0; offset < ids.length; offset += LOOKUP_BATCH_SIZE) {
|
|
60
|
+
const slice = ids.slice(offset, offset + LOOKUP_BATCH_SIZE)
|
|
61
|
+
try {
|
|
62
|
+
const result = await queryEngine.query<LookupRow>(entityId, {
|
|
63
|
+
tenantId,
|
|
64
|
+
organizationId: ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? undefined,
|
|
65
|
+
organizationIds: ctx.organizationIds ?? undefined,
|
|
66
|
+
filters: { id: { $in: slice } },
|
|
67
|
+
fields,
|
|
68
|
+
page: { page: 1, pageSize: slice.length },
|
|
69
|
+
})
|
|
70
|
+
for (const row of result.items ?? []) {
|
|
71
|
+
if (row?.id && typeof row.id === 'string') map.set(row.id, row)
|
|
72
|
+
}
|
|
73
|
+
} catch (err) {
|
|
74
|
+
logger.warn('batch lookup failed', { source, entityId, err })
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return map
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function decorateOnce(item: Record<string, unknown>, key: string, value: unknown): void {
|
|
81
|
+
if (item[key] === undefined) item[key] = value
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
// Warehouses
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
|
|
88
|
+
type WarehouseRow = LookupRow & { name?: string | null; code?: string | null }
|
|
89
|
+
|
|
90
|
+
const WAREHOUSE_FIELDS = ['id', 'name', 'code']
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Decorate list items with `warehouse_name` and `warehouse_code` when they
|
|
94
|
+
* carry a `warehouse_id` column. Mutates `payload.items` in place.
|
|
95
|
+
*/
|
|
96
|
+
export async function attachWarehouseLabelsToListItems(
|
|
97
|
+
payload: AnyListPayload,
|
|
98
|
+
ctx: CrudCtx,
|
|
99
|
+
): Promise<void> {
|
|
100
|
+
const items = Array.isArray(payload?.items) ? payload.items : []
|
|
101
|
+
if (items.length === 0) return
|
|
102
|
+
const ids = uniqueIdsFromKeys(items, ['warehouse_id'])
|
|
103
|
+
if (ids.length === 0) return
|
|
104
|
+
const map = (await batchLoadById(
|
|
105
|
+
ctx,
|
|
106
|
+
E.wms.warehouse,
|
|
107
|
+
ids,
|
|
108
|
+
WAREHOUSE_FIELDS,
|
|
109
|
+
'warehouse',
|
|
110
|
+
)) as Map<string, WarehouseRow>
|
|
111
|
+
if (map.size === 0) return
|
|
112
|
+
for (const item of items) {
|
|
113
|
+
const id = item?.warehouse_id
|
|
114
|
+
if (typeof id !== 'string' || !id) continue
|
|
115
|
+
const row = map.get(id)
|
|
116
|
+
if (!row) continue
|
|
117
|
+
decorateOnce(item, 'warehouse_name', row.name ?? null)
|
|
118
|
+
decorateOnce(item, 'warehouse_code', row.code ?? null)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// ---------------------------------------------------------------------------
|
|
123
|
+
// Locations
|
|
124
|
+
// ---------------------------------------------------------------------------
|
|
125
|
+
|
|
126
|
+
type LocationLookupRow = LookupRow & { code?: string | null; type?: string | null }
|
|
127
|
+
|
|
128
|
+
const LOCATION_FIELDS = ['id', 'code', 'type']
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Decorate list items with location label/type for any of these foreign-key
|
|
132
|
+
* columns: `location_id`, `location_from_id`, `location_to_id`. The decorated
|
|
133
|
+
* fields follow the same prefix:
|
|
134
|
+
*
|
|
135
|
+
* location_id -> location_code, location_type
|
|
136
|
+
* location_from_id -> location_from_code, location_from_type
|
|
137
|
+
* location_to_id -> location_to_code, location_to_type
|
|
138
|
+
*
|
|
139
|
+
* Mutates `payload.items` in place.
|
|
140
|
+
*/
|
|
141
|
+
export async function attachLocationLabelsToListItems(
|
|
142
|
+
payload: AnyListPayload,
|
|
143
|
+
ctx: CrudCtx,
|
|
144
|
+
): Promise<void> {
|
|
145
|
+
const items = Array.isArray(payload?.items) ? payload.items : []
|
|
146
|
+
if (items.length === 0) return
|
|
147
|
+
const fkColumns = ['location_id', 'location_from_id', 'location_to_id']
|
|
148
|
+
const ids = uniqueIdsFromKeys(items, fkColumns)
|
|
149
|
+
if (ids.length === 0) return
|
|
150
|
+
const map = (await batchLoadById(
|
|
151
|
+
ctx,
|
|
152
|
+
E.wms.warehouse_location,
|
|
153
|
+
ids,
|
|
154
|
+
LOCATION_FIELDS,
|
|
155
|
+
'location',
|
|
156
|
+
)) as Map<string, LocationLookupRow>
|
|
157
|
+
if (map.size === 0) return
|
|
158
|
+
for (const item of items) {
|
|
159
|
+
for (const fk of fkColumns) {
|
|
160
|
+
const id = item?.[fk]
|
|
161
|
+
if (typeof id !== 'string' || !id) continue
|
|
162
|
+
const row = map.get(id)
|
|
163
|
+
if (!row) continue
|
|
164
|
+
const prefix = fk.replace(/_id$/, '')
|
|
165
|
+
decorateOnce(item, `${prefix}_code`, row.code ?? null)
|
|
166
|
+
decorateOnce(item, `${prefix}_type`, row.type ?? null)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// ---------------------------------------------------------------------------
|
|
172
|
+
// Catalog variants
|
|
173
|
+
// ---------------------------------------------------------------------------
|
|
174
|
+
|
|
175
|
+
type VariantLookupRow = LookupRow & {
|
|
176
|
+
name?: string | null
|
|
177
|
+
sku?: string | null
|
|
178
|
+
product_id?: string | null
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const VARIANT_FIELDS = ['id', 'name', 'sku', 'product_id']
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Decorate list items with `variant_name`, `variant_sku`, and `product_id`
|
|
185
|
+
* when they carry a `catalog_variant_id` column. Mutates `payload.items` in
|
|
186
|
+
* place. Uses `queryEngine.query(E.catalog.catalog_product_variant, ...)`
|
|
187
|
+
* rather than importing the catalog ORM entity directly, to keep the WMS
|
|
188
|
+
* module decoupled from the catalog package internals.
|
|
189
|
+
*/
|
|
190
|
+
export async function attachVariantLabelsToListItems(
|
|
191
|
+
payload: AnyListPayload,
|
|
192
|
+
ctx: CrudCtx,
|
|
193
|
+
): Promise<void> {
|
|
194
|
+
const items = Array.isArray(payload?.items) ? payload.items : []
|
|
195
|
+
if (items.length === 0) return
|
|
196
|
+
const ids = uniqueIdsFromKeys(items, ['catalog_variant_id'])
|
|
197
|
+
if (ids.length === 0) return
|
|
198
|
+
const map = (await batchLoadById(
|
|
199
|
+
ctx,
|
|
200
|
+
E.catalog.catalog_product_variant,
|
|
201
|
+
ids,
|
|
202
|
+
VARIANT_FIELDS,
|
|
203
|
+
'variant',
|
|
204
|
+
)) as Map<string, VariantLookupRow>
|
|
205
|
+
if (map.size === 0) return
|
|
206
|
+
for (const item of items) {
|
|
207
|
+
const id = item?.catalog_variant_id
|
|
208
|
+
if (typeof id !== 'string' || !id) continue
|
|
209
|
+
const row = map.get(id)
|
|
210
|
+
if (!row) continue
|
|
211
|
+
decorateOnce(item, 'variant_name', row.name ?? null)
|
|
212
|
+
decorateOnce(item, 'variant_sku', row.sku ?? null)
|
|
213
|
+
decorateOnce(item, 'catalog_product_id', row.product_id ?? null)
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// ---------------------------------------------------------------------------
|
|
218
|
+
// Catalog products
|
|
219
|
+
// ---------------------------------------------------------------------------
|
|
220
|
+
|
|
221
|
+
type ProductLookupRow = LookupRow & { title?: string | null; sku?: string | null }
|
|
222
|
+
|
|
223
|
+
const PRODUCT_FIELDS = ['id', 'title', 'sku']
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Decorate list items with `product_title` and `product_sku` when they carry a
|
|
227
|
+
* `catalog_product_id` column. Mutates `payload.items` in place.
|
|
228
|
+
*/
|
|
229
|
+
export async function attachProductLabelsToListItems(
|
|
230
|
+
payload: AnyListPayload,
|
|
231
|
+
ctx: CrudCtx,
|
|
232
|
+
): Promise<void> {
|
|
233
|
+
const items = Array.isArray(payload?.items) ? payload.items : []
|
|
234
|
+
if (items.length === 0) return
|
|
235
|
+
const ids = uniqueIdsFromKeys(items, ['catalog_product_id'])
|
|
236
|
+
if (ids.length === 0) return
|
|
237
|
+
const map = (await batchLoadById(
|
|
238
|
+
ctx,
|
|
239
|
+
E.catalog.catalog_product,
|
|
240
|
+
ids,
|
|
241
|
+
PRODUCT_FIELDS,
|
|
242
|
+
'product',
|
|
243
|
+
)) as Map<string, ProductLookupRow>
|
|
244
|
+
if (map.size === 0) return
|
|
245
|
+
for (const item of items) {
|
|
246
|
+
const id = item?.catalog_product_id
|
|
247
|
+
if (typeof id !== 'string' || !id) continue
|
|
248
|
+
const row = map.get(id)
|
|
249
|
+
if (!row) continue
|
|
250
|
+
decorateOnce(item, 'product_title', row.title ?? null)
|
|
251
|
+
decorateOnce(item, 'product_sku', row.sku ?? null)
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Decorate inventory profile rows with catalog product and variant labels.
|
|
257
|
+
* Mutates `payload.items` in place.
|
|
258
|
+
*/
|
|
259
|
+
export async function attachInventoryProfileCatalogLabelsToListItems(
|
|
260
|
+
payload: AnyListPayload,
|
|
261
|
+
ctx: CrudCtx,
|
|
262
|
+
): Promise<void> {
|
|
263
|
+
await Promise.all([
|
|
264
|
+
attachProductLabelsToListItems(payload, ctx),
|
|
265
|
+
attachVariantLabelsToListItems(payload, ctx),
|
|
266
|
+
])
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// ---------------------------------------------------------------------------
|
|
270
|
+
// Reservation sources
|
|
271
|
+
// ---------------------------------------------------------------------------
|
|
272
|
+
|
|
273
|
+
type SalesOrderLookupRow = LookupRow & { order_number?: string | null }
|
|
274
|
+
|
|
275
|
+
const SALES_ORDER_FIELDS = ['id', 'order_number']
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Decorate reservation rows with `source_label` when the source can be resolved
|
|
279
|
+
* to a human-readable reference (currently sales orders). Mutates
|
|
280
|
+
* `payload.items` in place.
|
|
281
|
+
*/
|
|
282
|
+
export async function attachReservationSourceLabelsToListItems(
|
|
283
|
+
payload: AnyListPayload,
|
|
284
|
+
ctx: CrudCtx,
|
|
285
|
+
): Promise<void> {
|
|
286
|
+
const items = Array.isArray(payload?.items) ? payload.items : []
|
|
287
|
+
if (items.length === 0) return
|
|
288
|
+
|
|
289
|
+
const orderIds = uniqueIdsFromKeys(
|
|
290
|
+
items.filter((item) => item?.source_type === 'order'),
|
|
291
|
+
['source_id'],
|
|
292
|
+
)
|
|
293
|
+
if (orderIds.length === 0) return
|
|
294
|
+
|
|
295
|
+
const map = (await batchLoadById(
|
|
296
|
+
ctx,
|
|
297
|
+
E.sales.sales_order,
|
|
298
|
+
orderIds,
|
|
299
|
+
SALES_ORDER_FIELDS,
|
|
300
|
+
'reservation-source',
|
|
301
|
+
)) as Map<string, SalesOrderLookupRow>
|
|
302
|
+
if (map.size === 0) return
|
|
303
|
+
|
|
304
|
+
for (const item of items) {
|
|
305
|
+
if (item?.source_type !== 'order') continue
|
|
306
|
+
const id = item?.source_id
|
|
307
|
+
if (typeof id !== 'string' || !id) continue
|
|
308
|
+
const row = map.get(id)
|
|
309
|
+
const orderNumber = row?.order_number?.trim()
|
|
310
|
+
if (orderNumber) decorateOnce(item, 'source_label', orderNumber)
|
|
311
|
+
}
|
|
312
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { CrudCtx } from '@open-mercato/shared/lib/crud/factory'
|
|
2
|
+
import type { QueryEngine } from '@open-mercato/shared/lib/query/types'
|
|
3
|
+
import { createLogger } from '@open-mercato/shared/lib/logger'
|
|
4
|
+
import { E } from '#generated/entities.ids.generated'
|
|
5
|
+
|
|
6
|
+
const logger = createLogger('wms')
|
|
7
|
+
|
|
8
|
+
const SEARCH_PAGE_SIZE = 100
|
|
9
|
+
|
|
10
|
+
async function queryMatchingIds(
|
|
11
|
+
ctx: CrudCtx,
|
|
12
|
+
entityId: string,
|
|
13
|
+
filters: Record<string, unknown>,
|
|
14
|
+
source: string,
|
|
15
|
+
): Promise<string[]> {
|
|
16
|
+
const tenantId = ctx.auth?.tenantId
|
|
17
|
+
if (!tenantId) return []
|
|
18
|
+
try {
|
|
19
|
+
const queryEngine = ctx.container.resolve('queryEngine') as QueryEngine
|
|
20
|
+
const result = await queryEngine.query<{ id?: string | null }>(entityId, {
|
|
21
|
+
tenantId,
|
|
22
|
+
organizationId: ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? undefined,
|
|
23
|
+
organizationIds: ctx.organizationIds ?? undefined,
|
|
24
|
+
filters,
|
|
25
|
+
fields: ['id'],
|
|
26
|
+
page: { page: 1, pageSize: SEARCH_PAGE_SIZE },
|
|
27
|
+
})
|
|
28
|
+
return (result.items ?? [])
|
|
29
|
+
.map((row) => (typeof row?.id === 'string' ? row.id : null))
|
|
30
|
+
.filter((id): id is string => Boolean(id))
|
|
31
|
+
} catch (err) {
|
|
32
|
+
logger.warn('lookup failed', { source, entityId, err })
|
|
33
|
+
return []
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Resolve warehouse ids whose name or code matches an already-escaped ILIKE term
|
|
39
|
+
* (e.g. `%midnight%`). Used by reservation/balance list search so operators can
|
|
40
|
+
* find rows by the labels shown in the table, not only serial numbers.
|
|
41
|
+
*/
|
|
42
|
+
export async function resolveWarehouseIdsMatchingSearch(
|
|
43
|
+
ctx: CrudCtx,
|
|
44
|
+
like: string,
|
|
45
|
+
): Promise<string[]> {
|
|
46
|
+
return queryMatchingIds(
|
|
47
|
+
ctx,
|
|
48
|
+
E.wms.warehouse,
|
|
49
|
+
{
|
|
50
|
+
$or: [
|
|
51
|
+
{ name: { $ilike: like } },
|
|
52
|
+
{ code: { $ilike: like } },
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
'warehouse-search',
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Resolve catalog variant ids whose name or SKU matches an already-escaped
|
|
61
|
+
* ILIKE term. Decoupled from catalog ORM via QueryEngine (same as list enrichers).
|
|
62
|
+
*/
|
|
63
|
+
export async function resolveVariantIdsMatchingSearch(
|
|
64
|
+
ctx: CrudCtx,
|
|
65
|
+
like: string,
|
|
66
|
+
): Promise<string[]> {
|
|
67
|
+
return queryMatchingIds(
|
|
68
|
+
ctx,
|
|
69
|
+
E.catalog.catalog_product_variant,
|
|
70
|
+
{
|
|
71
|
+
$or: [
|
|
72
|
+
{ name: { $ilike: like } },
|
|
73
|
+
{ sku: { $ilike: like } },
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
'variant-search',
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Build a list `$or` clause that matches serial number, warehouse label, or
|
|
82
|
+
* variant name/SKU for the given search term. Optional `extraFieldFilters`
|
|
83
|
+
* appends additional ILIKE clauses (e.g. movement reason fields).
|
|
84
|
+
*/
|
|
85
|
+
export async function buildInventoryListSearchOrFilters(
|
|
86
|
+
ctx: CrudCtx,
|
|
87
|
+
term: string,
|
|
88
|
+
escapeLike: (value: string) => string,
|
|
89
|
+
options?: {
|
|
90
|
+
extraFieldFilters?: (like: string) => Array<Record<string, unknown>>
|
|
91
|
+
},
|
|
92
|
+
): Promise<Array<Record<string, unknown>>> {
|
|
93
|
+
const like = `%${escapeLike(term)}%`
|
|
94
|
+
const orFilters: Array<Record<string, unknown>> = [{ serial_number: { $ilike: like } }]
|
|
95
|
+
if (options?.extraFieldFilters) {
|
|
96
|
+
orFilters.push(...options.extraFieldFilters(like))
|
|
97
|
+
}
|
|
98
|
+
const [warehouseIds, variantIds] = await Promise.all([
|
|
99
|
+
resolveWarehouseIdsMatchingSearch(ctx, like),
|
|
100
|
+
resolveVariantIdsMatchingSearch(ctx, like),
|
|
101
|
+
])
|
|
102
|
+
if (warehouseIds.length > 0) {
|
|
103
|
+
orFilters.push({ warehouse_id: { $in: warehouseIds } })
|
|
104
|
+
}
|
|
105
|
+
if (variantIds.length > 0) {
|
|
106
|
+
orFilters.push({ catalog_variant_id: { $in: variantIds } })
|
|
107
|
+
}
|
|
108
|
+
return orFilters
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Build a reservation-list `$or` clause that matches serial number, warehouse
|
|
113
|
+
* label, or variant name/SKU for the given search term.
|
|
114
|
+
*/
|
|
115
|
+
export async function buildReservationSearchOrFilters(
|
|
116
|
+
ctx: CrudCtx,
|
|
117
|
+
term: string,
|
|
118
|
+
escapeLike: (value: string) => string,
|
|
119
|
+
): Promise<Array<Record<string, unknown>>> {
|
|
120
|
+
return buildInventoryListSearchOrFilters(ctx, term, escapeLike)
|
|
121
|
+
}
|