@open-mercato/core 0.10.1-develop.7708.1.5a5c248637 → 0.10.1-develop.7714.1.9dbb8200d8
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/asn/index.js +19 -0
- package/dist/generated/entities/asn/index.js.map +7 -0
- package/dist/generated/entities/putaway_task/index.js +25 -0
- package/dist/generated/entities/putaway_task/index.js.map +7 -0
- package/dist/generated/entities/receiving_line/index.js +21 -0
- package/dist/generated/entities/receiving_line/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +4 -1
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +34 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/modules/communication_channels/lib/sanitize-channel-html.js +22 -3
- package/dist/modules/communication_channels/lib/sanitize-channel-html.js.map +2 -2
- package/dist/modules/communication_channels/widgets/injection/channel-payload-renderer/widget.client.js +40 -11
- package/dist/modules/communication_channels/widgets/injection/channel-payload-renderer/widget.client.js.map +2 -2
- package/dist/modules/customers/components/calendar/CalendarEventEditor.js +13 -2
- package/dist/modules/customers/components/calendar/CalendarEventEditor.js.map +2 -2
- package/dist/modules/wms/acl.js +2 -0
- package/dist/modules/wms/acl.js.map +2 -2
- package/dist/modules/wms/api/asns/[id]/complete/route.js +61 -0
- package/dist/modules/wms/api/asns/[id]/complete/route.js.map +7 -0
- package/dist/modules/wms/api/asns/[id]/receive/route.js +68 -0
- package/dist/modules/wms/api/asns/[id]/receive/route.js.map +7 -0
- package/dist/modules/wms/api/asns/route.js +197 -0
- package/dist/modules/wms/api/asns/route.js.map +7 -0
- package/dist/modules/wms/api/inventory/helpers.js +42 -34
- package/dist/modules/wms/api/inventory/helpers.js.map +2 -2
- package/dist/modules/wms/api/inventory/receive/route.js +1 -1
- package/dist/modules/wms/api/inventory/receive/route.js.map +2 -2
- package/dist/modules/wms/api/listEnrichers.js +23 -0
- package/dist/modules/wms/api/listEnrichers.js.map +2 -2
- package/dist/modules/wms/api/putaway-tasks/[id]/assign/route.js +56 -0
- package/dist/modules/wms/api/putaway-tasks/[id]/assign/route.js.map +7 -0
- package/dist/modules/wms/api/putaway-tasks/[id]/cancel/route.js +56 -0
- package/dist/modules/wms/api/putaway-tasks/[id]/cancel/route.js.map +7 -0
- package/dist/modules/wms/api/putaway-tasks/[id]/complete/route.js +65 -0
- package/dist/modules/wms/api/putaway-tasks/[id]/complete/route.js.map +7 -0
- package/dist/modules/wms/api/putaway-tasks/[id]/start/route.js +56 -0
- package/dist/modules/wms/api/putaway-tasks/[id]/start/route.js.map +7 -0
- package/dist/modules/wms/api/putaway-tasks/create-from-balance/route.js +51 -0
- package/dist/modules/wms/api/putaway-tasks/create-from-balance/route.js.map +7 -0
- package/dist/modules/wms/api/putaway-tasks/route.js +192 -0
- package/dist/modules/wms/api/putaway-tasks/route.js.map +7 -0
- package/dist/modules/wms/api/receiving-lines/route.js +180 -0
- package/dist/modules/wms/api/receiving-lines/route.js.map +7 -0
- package/dist/modules/wms/api/scan/putaway/route.js +104 -0
- package/dist/modules/wms/api/scan/putaway/route.js.map +7 -0
- package/dist/modules/wms/api/scan/receive/route.js +109 -0
- package/dist/modules/wms/api/scan/receive/route.js.map +7 -0
- package/dist/modules/wms/api/scan/resolve-location/route.js +89 -0
- package/dist/modules/wms/api/scan/resolve-location/route.js.map +7 -0
- package/dist/modules/wms/api/scan/resolve-lot/route.js +89 -0
- package/dist/modules/wms/api/scan/resolve-lot/route.js.map +7 -0
- package/dist/modules/wms/backend/wms/asns/[id]/page.js +9 -0
- package/dist/modules/wms/backend/wms/asns/[id]/page.js.map +7 -0
- package/dist/modules/wms/backend/wms/asns/[id]/page.meta.js +18 -0
- package/dist/modules/wms/backend/wms/asns/[id]/page.meta.js.map +7 -0
- package/dist/modules/wms/backend/wms/asns/page.js +9 -0
- package/dist/modules/wms/backend/wms/asns/page.js.map +7 -0
- package/dist/modules/wms/backend/wms/asns/page.meta.js +18 -0
- package/dist/modules/wms/backend/wms/asns/page.meta.js.map +7 -0
- package/dist/modules/wms/backend/wms/putaway/page.js +9 -0
- package/dist/modules/wms/backend/wms/putaway/page.js.map +7 -0
- package/dist/modules/wms/backend/wms/putaway/page.meta.js +18 -0
- package/dist/modules/wms/backend/wms/putaway/page.meta.js.map +7 -0
- package/dist/modules/wms/backend/wms/receiving/page.js +8 -0
- package/dist/modules/wms/backend/wms/receiving/page.js.map +7 -0
- package/dist/modules/wms/backend/wms/receiving/page.meta.js +18 -0
- package/dist/modules/wms/backend/wms/receiving/page.meta.js.map +7 -0
- package/dist/modules/wms/ce.js +27 -0
- package/dist/modules/wms/ce.js.map +2 -2
- package/dist/modules/wms/commands/asn.js +1746 -0
- package/dist/modules/wms/commands/asn.js.map +7 -0
- package/dist/modules/wms/commands/index.js +2 -0
- package/dist/modules/wms/commands/index.js.map +2 -2
- package/dist/modules/wms/commands/inventory-actions.js +347 -243
- package/dist/modules/wms/commands/inventory-actions.js.map +2 -2
- package/dist/modules/wms/commands/putaway.js +945 -0
- package/dist/modules/wms/commands/putaway.js.map +7 -0
- package/dist/modules/wms/commands/shared.js +51 -0
- package/dist/modules/wms/commands/shared.js.map +2 -2
- package/dist/modules/wms/components/backend/AssignPutawayTaskDialog.js +278 -0
- package/dist/modules/wms/components/backend/AssignPutawayTaskDialog.js.map +7 -0
- package/dist/modules/wms/components/backend/CompletePutawayTaskDialog.js +327 -0
- package/dist/modules/wms/components/backend/CompletePutawayTaskDialog.js.map +7 -0
- package/dist/modules/wms/components/backend/CreateAsnDialog.js +404 -0
- package/dist/modules/wms/components/backend/CreateAsnDialog.js.map +7 -0
- package/dist/modules/wms/components/backend/InventoryOperationsSection.js +16 -3
- package/dist/modules/wms/components/backend/InventoryOperationsSection.js.map +2 -2
- package/dist/modules/wms/components/backend/ReceiveAsnLineDialog.js +476 -0
- package/dist/modules/wms/components/backend/ReceiveAsnLineDialog.js.map +7 -0
- package/dist/modules/wms/components/backend/ReceiveInventoryDialog.js +2 -2
- package/dist/modules/wms/components/backend/ReceiveInventoryDialog.js.map +2 -2
- package/dist/modules/wms/components/backend/WmsAsnDetailPage.js +524 -0
- package/dist/modules/wms/components/backend/WmsAsnDetailPage.js.map +7 -0
- package/dist/modules/wms/components/backend/WmsAsnsListPage.js +339 -0
- package/dist/modules/wms/components/backend/WmsAsnsListPage.js.map +7 -0
- package/dist/modules/wms/components/backend/WmsLocationDetailPage.js +5 -6
- package/dist/modules/wms/components/backend/WmsLocationDetailPage.js.map +2 -2
- package/dist/modules/wms/components/backend/WmsLotDetailPage.js +5 -6
- package/dist/modules/wms/components/backend/WmsLotDetailPage.js.map +2 -2
- package/dist/modules/wms/components/backend/WmsOperationalDashboardPage.js +14 -10
- package/dist/modules/wms/components/backend/WmsOperationalDashboardPage.js.map +2 -2
- package/dist/modules/wms/components/backend/WmsPutawayQueuePage.js +598 -0
- package/dist/modules/wms/components/backend/WmsPutawayQueuePage.js.map +7 -0
- package/dist/modules/wms/components/backend/WmsSkuDetailPage.js +5 -6
- package/dist/modules/wms/components/backend/WmsSkuDetailPage.js.map +2 -2
- package/dist/modules/wms/components/backend/asnCompleteOptimisticLock.js +32 -0
- package/dist/modules/wms/components/backend/asnCompleteOptimisticLock.js.map +7 -0
- package/dist/modules/wms/components/backend/asnReceivingLinesLoader.js +36 -0
- package/dist/modules/wms/components/backend/asnReceivingLinesLoader.js.map +7 -0
- package/dist/modules/wms/components/backend/inboundStatusUi.js +106 -0
- package/dist/modules/wms/components/backend/inboundStatusUi.js.map +7 -0
- package/dist/modules/wms/components/backend/inventoryMutationLoaders.js +17 -0
- package/dist/modules/wms/components/backend/inventoryMutationLoaders.js.map +2 -2
- package/dist/modules/wms/components/backend/putawayQueueOptimisticLock.js +14 -0
- package/dist/modules/wms/components/backend/putawayQueueOptimisticLock.js.map +7 -0
- package/dist/modules/wms/components/backend/useWmsInventoryMutationAccess.js +4 -0
- package/dist/modules/wms/components/backend/useWmsInventoryMutationAccess.js.map +2 -2
- package/dist/modules/wms/data/enrichers.js +117 -12
- package/dist/modules/wms/data/enrichers.js.map +2 -2
- package/dist/modules/wms/data/entities.js +150 -1
- package/dist/modules/wms/data/entities.js.map +2 -2
- package/dist/modules/wms/data/validators.js +214 -0
- package/dist/modules/wms/data/validators.js.map +2 -2
- package/dist/modules/wms/events.js +12 -1
- package/dist/modules/wms/events.js.map +2 -2
- package/dist/modules/wms/extension-points.js +3 -1
- package/dist/modules/wms/extension-points.js.map +2 -2
- package/dist/modules/wms/lib/asnReceiving.js +124 -0
- package/dist/modules/wms/lib/asnReceiving.js.map +7 -0
- package/dist/modules/wms/lib/asnVendor.js +52 -0
- package/dist/modules/wms/lib/asnVendor.js.map +7 -0
- package/dist/modules/wms/lib/flashMutationError.js +4 -0
- package/dist/modules/wms/lib/flashMutationError.js.map +2 -2
- package/dist/modules/wms/lib/inventoryDisplayUi.js +24 -0
- package/dist/modules/wms/lib/inventoryDisplayUi.js.map +2 -2
- package/dist/modules/wms/lib/inventoryPolicy.js +17 -0
- package/dist/modules/wms/lib/inventoryPolicy.js.map +2 -2
- package/dist/modules/wms/lib/loadOperationalDashboard.js +67 -1
- package/dist/modules/wms/lib/loadOperationalDashboard.js.map +2 -2
- package/dist/modules/wms/lib/putaway.js +141 -0
- package/dist/modules/wms/lib/putaway.js.map +7 -0
- package/dist/modules/wms/lib/roleFeatures.js +3 -1
- package/dist/modules/wms/lib/roleFeatures.js.map +2 -2
- package/dist/modules/wms/lib/salesOrderInventoryAutomation.js +99 -1
- package/dist/modules/wms/lib/salesOrderInventoryAutomation.js.map +2 -2
- package/dist/modules/wms/lib/scanResolve.js +147 -0
- package/dist/modules/wms/lib/scanResolve.js.map +7 -0
- package/dist/modules/wms/lib/wmsIntegrationToggles.js +1 -1
- package/dist/modules/wms/lib/wmsIntegrationToggles.js.map +2 -2
- package/dist/modules/wms/migrations/Migration20260812120000.js +43 -0
- package/dist/modules/wms/migrations/Migration20260812120000.js.map +7 -0
- package/dist/modules/wms/migrations/Migration20260812130000.js +30 -0
- package/dist/modules/wms/migrations/Migration20260812130000.js.map +7 -0
- package/dist/modules/wms/migrations/Migration20260822120000.js +17 -0
- package/dist/modules/wms/migrations/Migration20260822120000.js.map +7 -0
- package/dist/modules/wms/migrations/Migration20260822130000.js +17 -0
- package/dist/modules/wms/migrations/Migration20260822130000.js.map +7 -0
- package/dist/modules/wms/migrations/Migration20261029120000.js +13 -0
- package/dist/modules/wms/migrations/Migration20261029120000.js.map +7 -0
- package/dist/modules/wms/search.js +85 -0
- package/dist/modules/wms/search.js.map +2 -2
- package/dist/modules/wms/subscribers/asn-line-received-reevaluate-reservations.js +14 -0
- package/dist/modules/wms/subscribers/asn-line-received-reevaluate-reservations.js.map +7 -0
- package/dist/modules/wms/subscribers/invalidate-enricher-cache-asn.js +12 -0
- package/dist/modules/wms/subscribers/invalidate-enricher-cache-asn.js.map +7 -0
- package/dist/modules/wms/subscribers/procurement-goods-receipt-created.js +163 -0
- package/dist/modules/wms/subscribers/procurement-goods-receipt-created.js.map +7 -0
- package/dist/modules/wms/subscribers/putaway-completed-reevaluate-reservations.js +14 -0
- package/dist/modules/wms/subscribers/putaway-completed-reevaluate-reservations.js.map +7 -0
- package/dist/modules/wms/widgets/injection/sales-order-stock-context/widget.client.js +37 -8
- package/dist/modules/wms/widgets/injection/sales-order-stock-context/widget.client.js.map +2 -2
- package/dist/modules/workflows/lib/activity-executor.js +78 -51
- package/dist/modules/workflows/lib/activity-executor.js.map +2 -2
- package/dist/modules/workflows/lib/activity-registry.js.map +2 -2
- package/dist/modules/workflows/lib/activity-types.js +4 -1
- package/dist/modules/workflows/lib/activity-types.js.map +2 -2
- package/dist/modules/workflows/lib/activity-worker-handler.js +1 -1
- package/dist/modules/workflows/lib/activity-worker-handler.js.map +2 -2
- package/generated/entities/asn/index.ts +8 -0
- package/generated/entities/putaway_task/index.ts +11 -0
- package/generated/entities/receiving_line/index.ts +9 -0
- package/generated/entities.ids.generated.ts +4 -1
- package/generated/entity-fields-registry.ts +34 -0
- package/package.json +7 -7
- 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/ko.json +2 -0
- package/src/modules/auth/i18n/pl.json +2 -0
- package/src/modules/communication_channels/i18n/de.json +2 -0
- package/src/modules/communication_channels/i18n/en.json +2 -0
- package/src/modules/communication_channels/i18n/es.json +2 -0
- package/src/modules/communication_channels/i18n/ko.json +2 -0
- package/src/modules/communication_channels/i18n/pl.json +2 -0
- package/src/modules/communication_channels/lib/sanitize-channel-html.ts +23 -3
- package/src/modules/communication_channels/widgets/injection/channel-payload-renderer/widget.client.tsx +44 -12
- package/src/modules/customers/components/calendar/CalendarEventEditor.tsx +16 -2
- package/src/modules/wms/acl.ts +2 -0
- package/src/modules/wms/api/asns/[id]/complete/route.ts +62 -0
- package/src/modules/wms/api/asns/[id]/receive/route.ts +74 -0
- package/src/modules/wms/api/asns/route.ts +200 -0
- package/src/modules/wms/api/inventory/helpers.ts +57 -34
- package/src/modules/wms/api/inventory/receive/route.ts +2 -1
- package/src/modules/wms/api/listEnrichers.ts +38 -0
- package/src/modules/wms/api/putaway-tasks/[id]/assign/route.ts +56 -0
- package/src/modules/wms/api/putaway-tasks/[id]/cancel/route.ts +56 -0
- package/src/modules/wms/api/putaway-tasks/[id]/complete/route.ts +66 -0
- package/src/modules/wms/api/putaway-tasks/[id]/start/route.ts +56 -0
- package/src/modules/wms/api/putaway-tasks/create-from-balance/route.ts +50 -0
- package/src/modules/wms/api/putaway-tasks/route.ts +199 -0
- package/src/modules/wms/api/receiving-lines/route.ts +180 -0
- package/src/modules/wms/api/scan/putaway/route.ts +108 -0
- package/src/modules/wms/api/scan/receive/route.ts +118 -0
- package/src/modules/wms/api/scan/resolve-location/route.ts +92 -0
- package/src/modules/wms/api/scan/resolve-lot/route.ts +92 -0
- package/src/modules/wms/backend/wms/asns/[id]/page.meta.ts +14 -0
- package/src/modules/wms/backend/wms/asns/[id]/page.tsx +5 -0
- package/src/modules/wms/backend/wms/asns/page.meta.ts +14 -0
- package/src/modules/wms/backend/wms/asns/page.tsx +5 -0
- package/src/modules/wms/backend/wms/putaway/page.meta.ts +14 -0
- package/src/modules/wms/backend/wms/putaway/page.tsx +5 -0
- package/src/modules/wms/backend/wms/receiving/page.meta.ts +14 -0
- package/src/modules/wms/backend/wms/receiving/page.tsx +5 -0
- package/src/modules/wms/ce.ts +27 -0
- package/src/modules/wms/commands/asn.ts +2122 -0
- package/src/modules/wms/commands/index.ts +2 -0
- package/src/modules/wms/commands/inventory-actions.ts +413 -243
- package/src/modules/wms/commands/putaway.ts +1169 -0
- package/src/modules/wms/commands/shared.ts +51 -0
- package/src/modules/wms/components/backend/AssignPutawayTaskDialog.tsx +328 -0
- package/src/modules/wms/components/backend/CompletePutawayTaskDialog.tsx +366 -0
- package/src/modules/wms/components/backend/CreateAsnDialog.tsx +427 -0
- package/src/modules/wms/components/backend/InventoryOperationsSection.tsx +20 -2
- package/src/modules/wms/components/backend/ReceiveAsnLineDialog.tsx +535 -0
- package/src/modules/wms/components/backend/ReceiveInventoryDialog.tsx +2 -2
- package/src/modules/wms/components/backend/WmsAsnDetailPage.tsx +647 -0
- package/src/modules/wms/components/backend/WmsAsnsListPage.tsx +407 -0
- package/src/modules/wms/components/backend/WmsLocationDetailPage.tsx +4 -5
- package/src/modules/wms/components/backend/WmsLotDetailPage.tsx +4 -5
- package/src/modules/wms/components/backend/WmsOperationalDashboardPage.tsx +12 -8
- package/src/modules/wms/components/backend/WmsPutawayQueuePage.tsx +677 -0
- package/src/modules/wms/components/backend/WmsSkuDetailPage.tsx +4 -5
- package/src/modules/wms/components/backend/asnCompleteOptimisticLock.ts +52 -0
- package/src/modules/wms/components/backend/asnReceivingLinesLoader.ts +83 -0
- package/src/modules/wms/components/backend/inboundStatusUi.ts +154 -0
- package/src/modules/wms/components/backend/inventoryMutationLoaders.ts +20 -0
- package/src/modules/wms/components/backend/putawayQueueOptimisticLock.ts +20 -0
- package/src/modules/wms/components/backend/useWmsInventoryMutationAccess.ts +4 -0
- package/src/modules/wms/data/enrichers.ts +175 -13
- package/src/modules/wms/data/entities.ts +155 -0
- package/src/modules/wms/data/validators.ts +256 -0
- package/src/modules/wms/events.ts +11 -0
- package/src/modules/wms/extension-points.ts +2 -0
- package/src/modules/wms/i18n/de.json +205 -3
- package/src/modules/wms/i18n/en.json +205 -3
- package/src/modules/wms/i18n/es.json +205 -3
- package/src/modules/wms/i18n/ko.json +205 -3
- package/src/modules/wms/i18n/pl.json +205 -3
- package/src/modules/wms/lib/asnReceiving.ts +226 -0
- package/src/modules/wms/lib/asnVendor.ts +80 -0
- package/src/modules/wms/lib/flashMutationError.ts +4 -0
- package/src/modules/wms/lib/inventoryDisplayUi.ts +46 -0
- package/src/modules/wms/lib/inventoryPolicy.ts +31 -1
- package/src/modules/wms/lib/loadOperationalDashboard.ts +89 -1
- package/src/modules/wms/lib/putaway.ts +210 -0
- package/src/modules/wms/lib/roleFeatures.ts +2 -0
- package/src/modules/wms/lib/salesOrderInventoryAutomation.ts +150 -1
- package/src/modules/wms/lib/scanResolve.ts +185 -0
- package/src/modules/wms/lib/wmsIntegrationToggles.ts +2 -1
- package/src/modules/wms/migrations/.snapshot-open-mercato.json +1000 -0
- package/src/modules/wms/migrations/Migration20260812120000.ts +43 -0
- package/src/modules/wms/migrations/Migration20260812130000.ts +28 -0
- package/src/modules/wms/migrations/Migration20260822120000.ts +17 -0
- package/src/modules/wms/migrations/Migration20260822130000.ts +15 -0
- package/src/modules/wms/migrations/Migration20261029120000.ts +11 -0
- package/src/modules/wms/search.ts +95 -0
- package/src/modules/wms/subscribers/asn-line-received-reevaluate-reservations.ts +21 -0
- package/src/modules/wms/subscribers/invalidate-enricher-cache-asn.ts +12 -0
- package/src/modules/wms/subscribers/procurement-goods-receipt-created.ts +238 -0
- package/src/modules/wms/subscribers/putaway-completed-reevaluate-reservations.ts +21 -0
- package/src/modules/wms/widgets/injection/sales-order-stock-context/widget.client.tsx +63 -13
- package/src/modules/workflows/lib/activity-executor.ts +89 -58
- package/src/modules/workflows/lib/activity-registry.ts +1 -0
- package/src/modules/workflows/lib/activity-types.ts +4 -1
- package/src/modules/workflows/lib/activity-worker-handler.ts +2 -2
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
"communication_channels.channel.providers.whatsapp": "WhatsApp",
|
|
6
6
|
"communication_channels.channelPayload.aria": "Channel payload",
|
|
7
7
|
"communication_channels.channelPayload.email.aria": "Email payload",
|
|
8
|
+
"communication_channels.channelPayload.email.loadRemoteImages": "Load remote images",
|
|
9
|
+
"communication_channels.channelPayload.email.remoteImagesBlocked": "Remote images are blocked to protect your privacy. Loading them may let the sender know you opened this message.",
|
|
8
10
|
"communication_channels.channelPayload.types.email/mime": "Email (MIME)",
|
|
9
11
|
"communication_channels.columns.displayName": "Channel",
|
|
10
12
|
"communication_channels.columns.identifier": "External ID",
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
"communication_channels.channel.providers.whatsapp": "WhatsApp",
|
|
6
6
|
"communication_channels.channelPayload.aria": "Contenido del canal",
|
|
7
7
|
"communication_channels.channelPayload.email.aria": "Contenido del correo",
|
|
8
|
+
"communication_channels.channelPayload.email.loadRemoteImages": "Cargar imágenes remotas",
|
|
9
|
+
"communication_channels.channelPayload.email.remoteImagesBlocked": "Las imágenes remotas están bloqueadas para proteger su privacidad. Al cargarlas, el remitente podría saber que ha abierto este mensaje.",
|
|
8
10
|
"communication_channels.channelPayload.types.email/mime": "Correo (MIME)",
|
|
9
11
|
"communication_channels.columns.displayName": "Canal",
|
|
10
12
|
"communication_channels.columns.identifier": "ID externo",
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
"communication_channels.channel.providers.whatsapp": "WhatsApp",
|
|
6
6
|
"communication_channels.channelPayload.aria": "채널 페이로드",
|
|
7
7
|
"communication_channels.channelPayload.email.aria": "이메일 페이로드",
|
|
8
|
+
"communication_channels.channelPayload.email.loadRemoteImages": "원격 이미지 불러오기",
|
|
9
|
+
"communication_channels.channelPayload.email.remoteImagesBlocked": "개인정보 보호를 위해 원격 이미지가 차단되었습니다. 이미지를 불러오면 발신자가 이 메시지를 열었다는 사실을 알 수 있습니다.",
|
|
8
10
|
"communication_channels.channelPayload.types.email/mime": "이메일 (MIME)",
|
|
9
11
|
"communication_channels.columns.displayName": "채널",
|
|
10
12
|
"communication_channels.columns.identifier": "외부 ID",
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
"communication_channels.channel.providers.whatsapp": "WhatsApp",
|
|
6
6
|
"communication_channels.channelPayload.aria": "Treść kanału",
|
|
7
7
|
"communication_channels.channelPayload.email.aria": "Treść e-maila",
|
|
8
|
+
"communication_channels.channelPayload.email.loadRemoteImages": "Wczytaj zdalne obrazy",
|
|
9
|
+
"communication_channels.channelPayload.email.remoteImagesBlocked": "Zdalne obrazy są blokowane, aby chronić Twoją prywatność. Ich wczytanie może ujawnić nadawcy, że ta wiadomość została otwarta.",
|
|
8
10
|
"communication_channels.channelPayload.types.email/mime": "E-mail (MIME)",
|
|
9
11
|
"communication_channels.columns.displayName": "Kanał",
|
|
10
12
|
"communication_channels.columns.identifier": "Identyfikator zewn.",
|
|
@@ -14,6 +14,7 @@ import sanitizeHtml from 'sanitize-html'
|
|
|
14
14
|
*
|
|
15
15
|
* Allowlist is tuned for email + chat HTML:
|
|
16
16
|
* - Preserves typical email layout primitives (table-based layouts, inline images, basic typography).
|
|
17
|
+
* - Defers network images until the reader explicitly opts in for that message.
|
|
17
18
|
* - Strips `<script>`, `<style>`, `<iframe>`, all event-handler attributes (`on*`).
|
|
18
19
|
* - Blocks `javascript:` and `data:` URLs except `data:image/*;base64,…` (inline base64 images, common in email).
|
|
19
20
|
*/
|
|
@@ -55,7 +56,7 @@ const ALLOWED_TAGS = [
|
|
|
55
56
|
|
|
56
57
|
const ALLOWED_SCHEMES = ['http', 'https', 'mailto', 'tel']
|
|
57
58
|
const ALLOWED_SCHEMES_BY_TAG = {
|
|
58
|
-
img: ['
|
|
59
|
+
img: ['data'],
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
/**
|
|
@@ -72,13 +73,32 @@ const SANITIZE_OPTIONS: sanitizeHtml.IOptions = {
|
|
|
72
73
|
allowedTags: ALLOWED_TAGS,
|
|
73
74
|
allowedAttributes: {
|
|
74
75
|
a: ['href', 'title', 'class'],
|
|
75
|
-
img: ['src', 'alt', 'title', 'class', 'width', 'height'],
|
|
76
|
+
img: ['src', 'alt', 'title', 'class', 'width', 'height', 'data-channel-remote-src'],
|
|
76
77
|
'*': ['class', 'style', 'colspan', 'rowspan', 'width', 'height'],
|
|
77
78
|
},
|
|
78
79
|
allowedSchemes: ALLOWED_SCHEMES,
|
|
79
80
|
allowedSchemesByTag: ALLOWED_SCHEMES_BY_TAG,
|
|
80
81
|
allowedSchemesAppliedToAttributes: ['href', 'src'],
|
|
81
82
|
allowProtocolRelative: false,
|
|
83
|
+
transformTags: {
|
|
84
|
+
img: (tagName, attributes) => {
|
|
85
|
+
const { src } = attributes
|
|
86
|
+
const safeAttributes = { ...attributes }
|
|
87
|
+
delete safeAttributes.src
|
|
88
|
+
delete safeAttributes['data-channel-remote-src']
|
|
89
|
+
if (!src) return { tagName, attribs: safeAttributes }
|
|
90
|
+
if (/^data:/i.test(src)) return { tagName, attribs: { ...safeAttributes, src } }
|
|
91
|
+
try {
|
|
92
|
+
const remoteUrl = new URL(src.startsWith('//') ? `https:${src}` : src)
|
|
93
|
+
if (remoteUrl.protocol === 'http:' || remoteUrl.protocol === 'https:') {
|
|
94
|
+
safeAttributes['data-channel-remote-src'] = remoteUrl.href
|
|
95
|
+
}
|
|
96
|
+
} catch {
|
|
97
|
+
return { tagName, attribs: safeAttributes }
|
|
98
|
+
}
|
|
99
|
+
return { tagName, attribs: safeAttributes }
|
|
100
|
+
},
|
|
101
|
+
},
|
|
82
102
|
// disable inline scripts in style attributes
|
|
83
103
|
allowedStyles: {
|
|
84
104
|
'*': {
|
|
@@ -107,7 +127,7 @@ const SANITIZE_OPTIONS: sanitizeHtml.IOptions = {
|
|
|
107
127
|
exclusiveFilter: (frame) => {
|
|
108
128
|
if (frame.tag === 'img' && frame.attribs?.src) {
|
|
109
129
|
const src = frame.attribs.src
|
|
110
|
-
if (
|
|
130
|
+
if (/^data:/i.test(src) && !/^data:image\/(?:png|jpe?g|gif|webp);base64,/i.test(src)) {
|
|
111
131
|
return true
|
|
112
132
|
}
|
|
113
133
|
}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
import * as React from 'react'
|
|
4
4
|
import type { InjectionWidgetComponentProps } from '@open-mercato/shared/modules/widgets/injection'
|
|
5
5
|
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
6
|
+
import { Alert } from '@open-mercato/ui/primitives/alert'
|
|
7
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
6
8
|
|
|
7
9
|
type ChannelPayloadEnrichment = {
|
|
8
10
|
channelContentType: string | null
|
|
@@ -19,6 +21,47 @@ type MessageWithPayload = Record<string, unknown> & {
|
|
|
19
21
|
_channelPayload?: ChannelPayloadEnrichment | null
|
|
20
22
|
}
|
|
21
23
|
|
|
24
|
+
function EmailPayload({ html }: { html: string }) {
|
|
25
|
+
const t = useT()
|
|
26
|
+
const bodyRef = React.useRef<HTMLDivElement>(null)
|
|
27
|
+
const [remoteImagesAllowed, setRemoteImagesAllowed] = React.useState(false)
|
|
28
|
+
const hasRemoteImages = html.includes('data-channel-remote-src=')
|
|
29
|
+
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
if (!remoteImagesAllowed) return
|
|
32
|
+
for (const image of bodyRef.current?.querySelectorAll<HTMLImageElement>('img[data-channel-remote-src]') ?? []) {
|
|
33
|
+
const source = image.getAttribute('data-channel-remote-src')
|
|
34
|
+
if (source && /^https?:\/\//i.test(source)) {
|
|
35
|
+
image.referrerPolicy = 'no-referrer'
|
|
36
|
+
image.src = source.replace(/[<>"']/g, (character) => `%${character.charCodeAt(0).toString(16)}`)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}, [remoteImagesAllowed])
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<section
|
|
43
|
+
className="rounded-md border border-border bg-card p-4 text-sm"
|
|
44
|
+
aria-label={t('communication_channels.channelPayload.email.aria')}
|
|
45
|
+
>
|
|
46
|
+
{hasRemoteImages && !remoteImagesAllowed ? (
|
|
47
|
+
<Alert
|
|
48
|
+
status="information"
|
|
49
|
+
style="lighter"
|
|
50
|
+
className="mb-4"
|
|
51
|
+
action={(
|
|
52
|
+
<Button type="button" variant="outline" size="sm" onClick={() => setRemoteImagesAllowed(true)}>
|
|
53
|
+
{t('communication_channels.channelPayload.email.loadRemoteImages')}
|
|
54
|
+
</Button>
|
|
55
|
+
)}
|
|
56
|
+
>
|
|
57
|
+
{t('communication_channels.channelPayload.email.remoteImagesBlocked')}
|
|
58
|
+
</Alert>
|
|
59
|
+
) : null}
|
|
60
|
+
<div ref={bodyRef} dangerouslySetInnerHTML={{ __html: html }} />
|
|
61
|
+
</section>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
22
65
|
export default function ChannelPayloadRendererWidget({
|
|
23
66
|
data,
|
|
24
67
|
}: InjectionWidgetComponentProps<Record<string, unknown>, MessageWithPayload>) {
|
|
@@ -28,19 +71,8 @@ export default function ChannelPayloadRendererWidget({
|
|
|
28
71
|
|
|
29
72
|
const { channelContentType, channelPayload, sanitizedHtml } = payload
|
|
30
73
|
|
|
31
|
-
// Email / HTML — render the HTML the server already sanitized.
|
|
32
74
|
if (channelContentType.startsWith('email/') && typeof sanitizedHtml === 'string') {
|
|
33
|
-
return
|
|
34
|
-
<section
|
|
35
|
-
className="rounded-md border bg-card p-4 text-sm"
|
|
36
|
-
aria-label={t(
|
|
37
|
-
'communication_channels.channelPayload.email.aria',
|
|
38
|
-
'Channel payload — email',
|
|
39
|
-
)}
|
|
40
|
-
>
|
|
41
|
-
<div dangerouslySetInnerHTML={{ __html: sanitizedHtml }} />
|
|
42
|
-
</section>
|
|
43
|
-
)
|
|
75
|
+
return <EmailPayload key={`${data?.id ?? ''}:${sanitizedHtml}`} html={sanitizedHtml} />
|
|
44
76
|
}
|
|
45
77
|
|
|
46
78
|
// Provider-specific payloads (Slack Block Kit, WhatsApp interactive) —
|
|
@@ -9,6 +9,7 @@ import { extractOptimisticLockConflict } from '@open-mercato/ui/backend/utils/op
|
|
|
9
9
|
import { surfaceRecordConflict } from '@open-mercato/ui/backend/conflicts'
|
|
10
10
|
import { createCrudFormError } from '@open-mercato/ui/backend/utils/serverErrors'
|
|
11
11
|
import { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'
|
|
12
|
+
import { useCurrentOrganization } from '@open-mercato/ui/backend/BackendChromeProvider'
|
|
12
13
|
import { flash } from '@open-mercato/ui/backend/FlashMessages'
|
|
13
14
|
import { CrudForm, type CrudFormGroup, type CrudFormGroupComponentProps } from '@open-mercato/ui/backend/CrudForm'
|
|
14
15
|
import { useInjectionWidgets } from '@open-mercato/ui/backend/injection/InjectionSpot'
|
|
@@ -206,7 +207,6 @@ const EditorBody = React.memo(function EditorBody({
|
|
|
206
207
|
)
|
|
207
208
|
const capabilities = React.useMemo(() => ({ resourcesEnabled, staffEnabled }), [resourcesEnabled, staffEnabled])
|
|
208
209
|
|
|
209
|
-
useEditorLabelResolution(open, form, update)
|
|
210
210
|
// Probe against the owner the interaction will actually be SAVED with so the
|
|
211
211
|
// editor warning matches the grid's post-save conflict rings: tasks own via
|
|
212
212
|
// their assignee, other kinds stay ownerless on create / keep the existing
|
|
@@ -329,6 +329,7 @@ export function CalendarEventEditor({
|
|
|
329
329
|
onSaved,
|
|
330
330
|
}: CalendarEventEditorProps) {
|
|
331
331
|
const t = useT()
|
|
332
|
+
const activeOrgId = useCurrentOrganization()?.id ?? null
|
|
332
333
|
const [saving, setSaving] = React.useState(false)
|
|
333
334
|
const { confirm, ConfirmDialogElement } = useConfirmDialog()
|
|
334
335
|
const dirtyRef = React.useRef(false)
|
|
@@ -388,12 +389,24 @@ export function CalendarEventEditor({
|
|
|
388
389
|
wasOpenRef.current = open
|
|
389
390
|
}, [open])
|
|
390
391
|
const formKey = `${mode}:${item?.id ?? 'new'}:${openSeq}:${autoSelectedCreateType?.key ?? 'default'}`
|
|
392
|
+
const labelScopeKey = JSON.stringify([formKey, activeOrgId, item?.entityId, item?.dealId, item?.ownerUserId])
|
|
393
|
+
const [resolvedLabels, setResolvedLabels] = React.useState<{
|
|
394
|
+
scopeKey: string
|
|
395
|
+
values: Partial<EditorFormState>
|
|
396
|
+
} | null>(null)
|
|
397
|
+
const updateInitialLabels = React.useCallback((patch: Partial<EditorFormState>) => {
|
|
398
|
+
setResolvedLabels((previous) => ({
|
|
399
|
+
scopeKey: labelScopeKey,
|
|
400
|
+
values: { ...(previous?.scopeKey === labelScopeKey ? previous.values : {}), ...patch },
|
|
401
|
+
}))
|
|
402
|
+
}, [labelScopeKey])
|
|
391
403
|
|
|
392
404
|
const initialValues = React.useMemo<Record<string, unknown>>(() => {
|
|
393
405
|
if (isEdit && item) {
|
|
394
406
|
return {
|
|
395
407
|
...parseItemToFormState(item),
|
|
396
408
|
...customFieldInitialValues(item),
|
|
409
|
+
...(resolvedLabels?.scopeKey === labelScopeKey ? resolvedLabels.values : {}),
|
|
397
410
|
id: item.id,
|
|
398
411
|
updatedAt: item.updatedAt ?? undefined,
|
|
399
412
|
}
|
|
@@ -406,7 +419,8 @@ export function CalendarEventEditor({
|
|
|
406
419
|
category: autoSelectedCreateType.key,
|
|
407
420
|
}
|
|
408
421
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- openSeq re-seeds defaults per dialog open
|
|
409
|
-
}, [isEdit, item, defaultDate, defaultRange, openSeq, autoSelectedCreateType])
|
|
422
|
+
}, [isEdit, item, defaultDate, defaultRange, openSeq, autoSelectedCreateType, labelScopeKey, resolvedLabels])
|
|
423
|
+
useEditorLabelResolution(open, formStateOfValues(initialValues), updateInitialLabels)
|
|
410
424
|
const initialTypeKey = String(initialValues.category ?? initialValues.kind ?? 'meeting')
|
|
411
425
|
React.useEffect(() => { setSelectedTypeKey(initialTypeKey) }, [initialTypeKey, formKey])
|
|
412
426
|
const selectedDefinition = selectedEventType(catalog.items, selectedTypeKey)
|
package/src/modules/wms/acl.ts
CHANGED
|
@@ -7,6 +7,8 @@ export const features = [
|
|
|
7
7
|
{ id: 'wms.manage_reservations', title: 'Manage inventory reservations', module: 'wms' },
|
|
8
8
|
{ id: 'wms.adjust_inventory', title: 'Adjust and move inventory', module: 'wms' },
|
|
9
9
|
{ id: 'wms.receive_inventory', title: 'Receive inbound inventory', module: 'wms' },
|
|
10
|
+
{ id: 'wms.manage_asn', title: 'Manage ASNs and receiving lines', module: 'wms' },
|
|
11
|
+
{ id: 'wms.manage_putaway', title: 'Manage putaway tasks', module: 'wms' },
|
|
10
12
|
{ id: 'wms.cycle_count', title: 'Run cycle counts', module: 'wms' },
|
|
11
13
|
{ id: 'wms.import', title: 'Import inventory from CSV', module: 'wms' },
|
|
12
14
|
]
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
3
|
+
import { readJsonSafe } from '@open-mercato/shared/lib/http/readJsonSafe'
|
|
4
|
+
import { asnCloseSchema } from '../../../../data/validators'
|
|
5
|
+
import { executeWmsCustomPostRoute } from '../../../inventory/helpers'
|
|
6
|
+
|
|
7
|
+
export const metadata = {
|
|
8
|
+
POST: { requireAuth: true, requireFeatures: ['wms.manage_asn'] },
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const paramsSchema = z.object({
|
|
12
|
+
id: z.string().uuid(),
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export async function POST(request: Request, routeContext: { params: { id: string } }) {
|
|
16
|
+
const parsedParams = paramsSchema.parse(routeContext.params)
|
|
17
|
+
const body = await readJsonSafe<Record<string, unknown>>(request, {})
|
|
18
|
+
const scopedRequest = new Request(request.url, {
|
|
19
|
+
method: 'POST',
|
|
20
|
+
headers: request.headers,
|
|
21
|
+
body: JSON.stringify({ ...body, id: parsedParams.id }),
|
|
22
|
+
})
|
|
23
|
+
return executeWmsCustomPostRoute({
|
|
24
|
+
request: scopedRequest,
|
|
25
|
+
routePath: `wms/asns/${parsedParams.id}/complete`,
|
|
26
|
+
inputSchema: asnCloseSchema,
|
|
27
|
+
commandId: 'wms.asns.close',
|
|
28
|
+
describeResource: (input) => ({
|
|
29
|
+
resourceKind: 'wms.asn',
|
|
30
|
+
resourceId: input.id,
|
|
31
|
+
}),
|
|
32
|
+
mapSuccess: (result: { status: string }) => ({
|
|
33
|
+
ok: true,
|
|
34
|
+
status: result.status,
|
|
35
|
+
}),
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const successSchema = z.object({
|
|
40
|
+
ok: z.literal(true),
|
|
41
|
+
status: z.enum(['draft', 'in_transit', 'received', 'closed']),
|
|
42
|
+
})
|
|
43
|
+
const errorSchema = z.object({ error: z.string() })
|
|
44
|
+
|
|
45
|
+
export const openApi: OpenApiRouteDoc = {
|
|
46
|
+
tag: 'WMS',
|
|
47
|
+
summary: 'Complete ASN',
|
|
48
|
+
methods: {
|
|
49
|
+
POST: {
|
|
50
|
+
summary: 'Complete ASN',
|
|
51
|
+
description:
|
|
52
|
+
'Marks an ASN as received when it has receipt activity (at least one line with receivedQty > 0) and lines are complete (QC-passed accepted qty meets expected), or when closeWhenShort is true for short/QC-fail receipts after some receipt activity. Header-only ASNs and zero-receipt lines are rejected even with closeWhenShort.',
|
|
53
|
+
requestBody: { contentType: 'application/json', schema: asnCloseSchema },
|
|
54
|
+
responses: [{ status: 200, description: 'ASN completed', schema: successSchema }],
|
|
55
|
+
errors: [
|
|
56
|
+
{ status: 400, description: 'Validation failed', schema: errorSchema },
|
|
57
|
+
{ status: 401, description: 'Unauthorized', schema: errorSchema },
|
|
58
|
+
{ status: 409, description: 'Invalid receipt state', schema: errorSchema },
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
3
|
+
import { readJsonSafe } from '@open-mercato/shared/lib/http/readJsonSafe'
|
|
4
|
+
import { asnReceiveLineSchema } from '../../../../data/validators'
|
|
5
|
+
import { executeWmsCustomPostRoute } from '../../../inventory/helpers'
|
|
6
|
+
|
|
7
|
+
export const metadata = {
|
|
8
|
+
POST: { requireAuth: true, requireFeatures: ['wms.receive_inventory'] },
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const paramsSchema = z.object({
|
|
12
|
+
id: z.string().uuid(),
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export async function POST(request: Request, routeContext: { params: { id: string } }) {
|
|
16
|
+
const parsedParams = paramsSchema.parse(routeContext.params)
|
|
17
|
+
const body = await readJsonSafe<Record<string, unknown>>(request, {})
|
|
18
|
+
const scopedRequest = new Request(request.url, {
|
|
19
|
+
method: 'POST',
|
|
20
|
+
headers: request.headers,
|
|
21
|
+
body: JSON.stringify({ ...body, asnId: parsedParams.id }),
|
|
22
|
+
})
|
|
23
|
+
return executeWmsCustomPostRoute({
|
|
24
|
+
request: scopedRequest,
|
|
25
|
+
routePath: `wms/asns/${parsedParams.id}/receive`,
|
|
26
|
+
inputSchema: asnReceiveLineSchema,
|
|
27
|
+
commandId: 'wms.asns.receive-line',
|
|
28
|
+
describeResource: (input) => ({
|
|
29
|
+
resourceKind: 'wms.asn',
|
|
30
|
+
resourceId: input.asnId,
|
|
31
|
+
}),
|
|
32
|
+
mapSuccess: (result: {
|
|
33
|
+
movementIds: string[]
|
|
34
|
+
putawayTaskIds: string[]
|
|
35
|
+
receivedQty?: number
|
|
36
|
+
asnUpdatedAt?: string
|
|
37
|
+
}) => ({
|
|
38
|
+
ok: true,
|
|
39
|
+
movementIds: result.movementIds,
|
|
40
|
+
putawayTaskIds: result.putawayTaskIds,
|
|
41
|
+
receivedQty: result.receivedQty,
|
|
42
|
+
asnUpdatedAt: result.asnUpdatedAt,
|
|
43
|
+
}),
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const successSchema = z.object({
|
|
48
|
+
ok: z.literal(true),
|
|
49
|
+
movementIds: z.array(z.string().uuid()),
|
|
50
|
+
putawayTaskIds: z.array(z.string().uuid()),
|
|
51
|
+
receivedQty: z.number().optional(),
|
|
52
|
+
asnUpdatedAt: z.string().datetime().optional(),
|
|
53
|
+
})
|
|
54
|
+
const errorSchema = z.object({ error: z.string() })
|
|
55
|
+
|
|
56
|
+
export const openApi: OpenApiRouteDoc = {
|
|
57
|
+
tag: 'WMS',
|
|
58
|
+
summary: 'Receive ASN line',
|
|
59
|
+
methods: {
|
|
60
|
+
POST: {
|
|
61
|
+
summary: 'Receive ASN line',
|
|
62
|
+
description:
|
|
63
|
+
'Receives a line against an ASN with QC outcome. QC pass writes receipt stock at staging/dock; QC fail records audit without balance increase. Both require absolute targetReceivedQty for retry-safe attempts (optional idempotencyKey is an extra stabilizer).',
|
|
64
|
+
requestBody: { contentType: 'application/json', schema: asnReceiveLineSchema },
|
|
65
|
+
responses: [{ status: 200, description: 'ASN line received', schema: successSchema }],
|
|
66
|
+
errors: [
|
|
67
|
+
{ status: 400, description: 'Validation failed', schema: errorSchema },
|
|
68
|
+
{ status: 401, description: 'Unauthorized', schema: errorSchema },
|
|
69
|
+
{ status: 409, description: 'Invalid receipt state', schema: errorSchema },
|
|
70
|
+
{ status: 422, description: 'Tracking or QC transition invalid', schema: errorSchema },
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
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 { E } from '#generated/entities.ids.generated'
|
|
7
|
+
import { Asn } from '../../data/entities'
|
|
8
|
+
import { asnCreatePublicSchema, asnUpdateSchema } from '../../data/validators'
|
|
9
|
+
import { buildAsnStatusFilter } from '../../lib/asnReceiving'
|
|
10
|
+
import { attachVendorLabelsToListItems, attachWarehouseLabelsToListItems } from '../listEnrichers'
|
|
11
|
+
import { createPagedListResponseSchema, createWmsCrudOpenApi, defaultOkResponseSchema } from '../openapi'
|
|
12
|
+
|
|
13
|
+
const F = {
|
|
14
|
+
id: 'id',
|
|
15
|
+
organization_id: 'organization_id',
|
|
16
|
+
tenant_id: 'tenant_id',
|
|
17
|
+
warehouse_id: 'warehouse_id',
|
|
18
|
+
vendor_id: 'vendor_id',
|
|
19
|
+
status: 'status',
|
|
20
|
+
expected_at: 'expected_at',
|
|
21
|
+
reference_number: 'reference_number',
|
|
22
|
+
notes: 'notes',
|
|
23
|
+
created_at: 'created_at',
|
|
24
|
+
updated_at: 'updated_at',
|
|
25
|
+
} as const
|
|
26
|
+
|
|
27
|
+
const routeMetadata = {
|
|
28
|
+
GET: { requireAuth: true, requireFeatures: ['wms.view'] },
|
|
29
|
+
POST: { requireAuth: true, requireFeatures: ['wms.manage_asn'] },
|
|
30
|
+
PUT: { requireAuth: true, requireFeatures: ['wms.manage_asn'] },
|
|
31
|
+
DELETE: { requireAuth: true, requireFeatures: ['wms.manage_asn'] },
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const metadata = routeMetadata
|
|
35
|
+
|
|
36
|
+
const rawBodySchema = z.object({}).passthrough()
|
|
37
|
+
|
|
38
|
+
const listSchema = z.object({
|
|
39
|
+
page: z.coerce.number().min(1).default(1),
|
|
40
|
+
pageSize: z.coerce.number().min(1).max(100).default(25),
|
|
41
|
+
search: z.string().optional(),
|
|
42
|
+
ids: z.string().optional(),
|
|
43
|
+
warehouseId: z.string().uuid().optional(),
|
|
44
|
+
vendorId: z.string().uuid().optional(),
|
|
45
|
+
// Single status or comma-separated (e.g. draft,in_transit for open receiving queue).
|
|
46
|
+
status: z.string().optional(),
|
|
47
|
+
sortField: z.string().optional(),
|
|
48
|
+
sortDir: z.enum(['asc', 'desc']).optional(),
|
|
49
|
+
}).passthrough()
|
|
50
|
+
|
|
51
|
+
const crud = makeCrudRoute({
|
|
52
|
+
metadata: routeMetadata,
|
|
53
|
+
orm: {
|
|
54
|
+
entity: Asn,
|
|
55
|
+
idField: 'id',
|
|
56
|
+
orgField: 'organizationId',
|
|
57
|
+
tenantField: 'tenantId',
|
|
58
|
+
softDeleteField: 'deletedAt',
|
|
59
|
+
},
|
|
60
|
+
indexer: { entityType: E.wms.asn },
|
|
61
|
+
list: {
|
|
62
|
+
schema: listSchema,
|
|
63
|
+
disableListCache: true,
|
|
64
|
+
entityId: E.wms.asn,
|
|
65
|
+
fields: [
|
|
66
|
+
F.id,
|
|
67
|
+
F.organization_id,
|
|
68
|
+
F.tenant_id,
|
|
69
|
+
F.warehouse_id,
|
|
70
|
+
F.vendor_id,
|
|
71
|
+
F.status,
|
|
72
|
+
F.expected_at,
|
|
73
|
+
F.reference_number,
|
|
74
|
+
F.notes,
|
|
75
|
+
F.created_at,
|
|
76
|
+
F.updated_at,
|
|
77
|
+
],
|
|
78
|
+
sortFieldMap: {
|
|
79
|
+
status: F.status,
|
|
80
|
+
expectedAt: F.expected_at,
|
|
81
|
+
createdAt: F.created_at,
|
|
82
|
+
updatedAt: F.updated_at,
|
|
83
|
+
referenceNumber: F.reference_number,
|
|
84
|
+
},
|
|
85
|
+
buildFilters: async (query) => {
|
|
86
|
+
const filters: Record<string, unknown> = {}
|
|
87
|
+
if (typeof query.ids === 'string' && query.ids.trim().length > 0) {
|
|
88
|
+
filters[F.id] = {
|
|
89
|
+
$in: query.ids.split(',').map((value) => value.trim()).filter((value) => value.length > 0),
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (typeof query.warehouseId === 'string' && query.warehouseId.length > 0) {
|
|
93
|
+
filters[F.warehouse_id] = { $eq: query.warehouseId }
|
|
94
|
+
}
|
|
95
|
+
if (typeof query.vendorId === 'string' && query.vendorId.length > 0) {
|
|
96
|
+
filters[F.vendor_id] = { $eq: query.vendorId }
|
|
97
|
+
}
|
|
98
|
+
if (typeof query.status === 'string' && query.status.length > 0) {
|
|
99
|
+
const statusFilter = buildAsnStatusFilter(query.status)
|
|
100
|
+
if (statusFilter) filters[F.status] = statusFilter
|
|
101
|
+
}
|
|
102
|
+
const term = query.search?.trim()
|
|
103
|
+
if (term) {
|
|
104
|
+
const like = `%${escapeLikePattern(term)}%`
|
|
105
|
+
filters.$or = [
|
|
106
|
+
{ [F.reference_number]: { $ilike: like } },
|
|
107
|
+
{ [F.notes]: { $ilike: like } },
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
return filters
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
hooks: {
|
|
114
|
+
afterList: async (payload, ctx) => {
|
|
115
|
+
await Promise.all([
|
|
116
|
+
attachWarehouseLabelsToListItems(payload, ctx),
|
|
117
|
+
attachVendorLabelsToListItems(payload, ctx),
|
|
118
|
+
])
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
actions: {
|
|
122
|
+
create: {
|
|
123
|
+
commandId: 'wms.asns.create',
|
|
124
|
+
schema: rawBodySchema,
|
|
125
|
+
mapInput: async ({ raw, ctx }) => {
|
|
126
|
+
const { translate } = await resolveTranslations()
|
|
127
|
+
// Public create strips sourceKey — procurement/system sets it via command with auth: null.
|
|
128
|
+
return parseScopedCommandInput(asnCreatePublicSchema, raw ?? {}, ctx, translate)
|
|
129
|
+
},
|
|
130
|
+
response: ({ result }) => ({
|
|
131
|
+
id: result?.asnId ?? null,
|
|
132
|
+
lineIds: result?.lineIds ?? [],
|
|
133
|
+
}),
|
|
134
|
+
status: 201,
|
|
135
|
+
},
|
|
136
|
+
update: {
|
|
137
|
+
commandId: 'wms.asns.update',
|
|
138
|
+
schema: rawBodySchema,
|
|
139
|
+
mapInput: async ({ raw, ctx }) => {
|
|
140
|
+
const { translate } = await resolveTranslations()
|
|
141
|
+
return parseScopedCommandInput(asnUpdateSchema, raw ?? {}, ctx, translate)
|
|
142
|
+
},
|
|
143
|
+
response: () => ({ ok: true }),
|
|
144
|
+
},
|
|
145
|
+
delete: {
|
|
146
|
+
commandId: 'wms.asns.delete',
|
|
147
|
+
schema: rawBodySchema,
|
|
148
|
+
mapInput: async ({ parsed, ctx }) => {
|
|
149
|
+
const { translate } = await resolveTranslations()
|
|
150
|
+
return { id: resolveCrudRecordId(parsed, ctx, translate) }
|
|
151
|
+
},
|
|
152
|
+
response: () => ({ ok: true }),
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
export const GET = crud.GET
|
|
158
|
+
export const POST = crud.POST
|
|
159
|
+
export const PUT = crud.PUT
|
|
160
|
+
export const DELETE = crud.DELETE
|
|
161
|
+
|
|
162
|
+
const asnListItemSchema = z.object({
|
|
163
|
+
id: z.string().uuid().nullable().optional(),
|
|
164
|
+
organization_id: z.string().uuid().nullable().optional(),
|
|
165
|
+
tenant_id: z.string().uuid().nullable().optional(),
|
|
166
|
+
warehouse_id: z.string().uuid().nullable().optional(),
|
|
167
|
+
warehouse_name: z.string().nullable().optional(),
|
|
168
|
+
warehouse_code: z.string().nullable().optional(),
|
|
169
|
+
vendor_id: z.string().uuid().nullable().optional(),
|
|
170
|
+
vendor_name: z.string().nullable().optional(),
|
|
171
|
+
status: z.string().nullable().optional(),
|
|
172
|
+
expected_at: z.string().nullable().optional(),
|
|
173
|
+
reference_number: z.string().nullable().optional(),
|
|
174
|
+
notes: z.string().nullable().optional(),
|
|
175
|
+
created_at: z.string().nullable().optional(),
|
|
176
|
+
updated_at: z.string().nullable().optional(),
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
export const openApi = createWmsCrudOpenApi({
|
|
180
|
+
resourceName: 'ASN',
|
|
181
|
+
pluralName: 'ASNs',
|
|
182
|
+
querySchema: listSchema,
|
|
183
|
+
listResponseSchema: createPagedListResponseSchema(asnListItemSchema),
|
|
184
|
+
create: {
|
|
185
|
+
schema: asnCreatePublicSchema,
|
|
186
|
+
description:
|
|
187
|
+
'Creates an ASN with optional expected receiving lines. `sourceKey` is server-only (procurement/system path) and is not accepted on this public API.',
|
|
188
|
+
},
|
|
189
|
+
update: {
|
|
190
|
+
schema: asnUpdateSchema,
|
|
191
|
+
responseSchema: defaultOkResponseSchema,
|
|
192
|
+
description:
|
|
193
|
+
'Updates an ASN by id while status is draft or in_transit and no receiving line has receipt/QC activity. Received/closed ASNs, or ASNs with line receipt/QC activity, return 409 invalid_receipt_state (status demotion and warehouse/header changes are not allowed). Status may only be set to draft or in_transit; received/closed are set via receive/complete flows.',
|
|
194
|
+
},
|
|
195
|
+
del: {
|
|
196
|
+
schema: z.object({ id: z.string().uuid() }),
|
|
197
|
+
responseSchema: defaultOkResponseSchema,
|
|
198
|
+
description: 'Soft-deletes an ASN by id.',
|
|
199
|
+
},
|
|
200
|
+
})
|