@freighttech/shipment-tracking 0.6.0
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/LICENSE +21 -0
- package/NOTICE +25 -0
- package/dist/generated/entities/bic_config/index.js +21 -0
- package/dist/generated/entities/bic_config/index.js.map +7 -0
- package/dist/generated/entities/carrier_config/index.js +27 -0
- package/dist/generated/entities/carrier_config/index.js.map +7 -0
- package/dist/generated/entities/location_override/index.js +33 -0
- package/dist/generated/entities/location_override/index.js.map +7 -0
- package/dist/generated/entities/shipment/index.js +73 -0
- package/dist/generated/entities/shipment/index.js.map +7 -0
- package/dist/generated/entities/ships_go_config/index.js +31 -0
- package/dist/generated/entities/ships_go_config/index.js.map +7 -0
- package/dist/generated/entities/tracking_event/index.js +101 -0
- package/dist/generated/entities/tracking_event/index.js.map +7 -0
- package/dist/generated/entities/tracking_job/index.js +47 -0
- package/dist/generated/entities/tracking_job/index.js.map +7 -0
- package/dist/generated/entities/webhook/index.js +25 -0
- package/dist/generated/entities/webhook/index.js.map +7 -0
- package/dist/generated/entities/webhook_delivery/index.js +25 -0
- package/dist/generated/entities/webhook_delivery/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +21 -0
- package/dist/generated/entities.ids.generated.js.map +7 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +7 -0
- package/dist/modules/shipment_tracking/acl.js +22 -0
- package/dist/modules/shipment_tracking/acl.js.map +7 -0
- package/dist/modules/shipment_tracking/api/bic-configs/route.js +176 -0
- package/dist/modules/shipment_tracking/api/bic-configs/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/bic-configs/test/route.js +95 -0
- package/dist/modules/shipment_tracking/api/bic-configs/test/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/cargo-events/route.js +93 -0
- package/dist/modules/shipment_tracking/api/cargo-events/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/carrier-configs/route.js +139 -0
- package/dist/modules/shipment_tracking/api/carrier-configs/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/dashboard/ships-map/route.js +177 -0
- package/dist/modules/shipment_tracking/api/dashboard/ships-map/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/location-overrides/route.js +179 -0
- package/dist/modules/shipment_tracking/api/location-overrides/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/openapi.js +27 -0
- package/dist/modules/shipment_tracking/api/openapi.js.map +7 -0
- package/dist/modules/shipment_tracking/api/shipments/route.js +192 -0
- package/dist/modules/shipment_tracking/api/shipments/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/shipsgo-configs/route.js +185 -0
- package/dist/modules/shipment_tracking/api/shipsgo-configs/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/tracking-jobs/route.js +144 -0
- package/dist/modules/shipment_tracking/api/tracking-jobs/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/tracking-jobs/sync/route.js +107 -0
- package/dist/modules/shipment_tracking/api/tracking-jobs/sync/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/utils.js +12 -0
- package/dist/modules/shipment_tracking/api/utils.js.map +7 -0
- package/dist/modules/shipment_tracking/api/webhooks/deliveries/route.js +76 -0
- package/dist/modules/shipment_tracking/api/webhooks/deliveries/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/webhooks/route.js +135 -0
- package/dist/modules/shipment_tracking/api/webhooks/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/webhooks/test/route.js +71 -0
- package/dist/modules/shipment_tracking/api/webhooks/test/route.js.map +7 -0
- package/dist/modules/shipment_tracking/assets/carriers/cma_cgm.png +0 -0
- package/dist/modules/shipment_tracking/assets/carriers/cosco.png +0 -0
- package/dist/modules/shipment_tracking/assets/carriers/evergreen.png +0 -0
- package/dist/modules/shipment_tracking/assets/carriers/hapag_lloyd.png +0 -0
- package/dist/modules/shipment_tracking/assets/carriers/maersk.png +0 -0
- package/dist/modules/shipment_tracking/assets/carriers/msc.png +0 -0
- package/dist/modules/shipment_tracking/assets/carriers/one.png +0 -0
- package/dist/modules/shipment_tracking/assets/carriers/oocl.png +0 -0
- package/dist/modules/shipment_tracking/assets/carriers/yang_ming.png +0 -0
- package/dist/modules/shipment_tracking/assets/carriers/zim.png +0 -0
- package/dist/modules/shipment_tracking/assets/index.js +52 -0
- package/dist/modules/shipment_tracking/assets/index.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/carrier-configs/page.js +621 -0
- package/dist/modules/shipment_tracking/backend/carrier-configs/page.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/carrier-configs/page.meta.js +19 -0
- package/dist/modules/shipment_tracking/backend/carrier-configs/page.meta.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/location-overrides/page.js +198 -0
- package/dist/modules/shipment_tracking/backend/location-overrides/page.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/location-overrides/page.meta.js +19 -0
- package/dist/modules/shipment_tracking/backend/location-overrides/page.meta.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/shipment-tracking/page.js +279 -0
- package/dist/modules/shipment_tracking/backend/shipment-tracking/page.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/shipment-tracking/page.meta.js +19 -0
- package/dist/modules/shipment_tracking/backend/shipment-tracking/page.meta.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/tracking-jobs/page.js +10 -0
- package/dist/modules/shipment_tracking/backend/tracking-jobs/page.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/tracking-jobs/page.meta.js +19 -0
- package/dist/modules/shipment_tracking/backend/tracking-jobs/page.meta.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/webhooks/page.js +198 -0
- package/dist/modules/shipment_tracking/backend/webhooks/page.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/webhooks/page.meta.js +19 -0
- package/dist/modules/shipment_tracking/backend/webhooks/page.meta.js.map +7 -0
- package/dist/modules/shipment_tracking/ce.js +52 -0
- package/dist/modules/shipment_tracking/ce.js.map +7 -0
- package/dist/modules/shipment_tracking/cli.js +229 -0
- package/dist/modules/shipment_tracking/cli.js.map +7 -0
- package/dist/modules/shipment_tracking/commands/bic-configs.js +66 -0
- package/dist/modules/shipment_tracking/commands/bic-configs.js.map +7 -0
- package/dist/modules/shipment_tracking/commands/carrier-configs.js +65 -0
- package/dist/modules/shipment_tracking/commands/carrier-configs.js.map +7 -0
- package/dist/modules/shipment_tracking/commands/index.js +9 -0
- package/dist/modules/shipment_tracking/commands/index.js.map +7 -0
- package/dist/modules/shipment_tracking/commands/location-overrides.js +93 -0
- package/dist/modules/shipment_tracking/commands/location-overrides.js.map +7 -0
- package/dist/modules/shipment_tracking/commands/shipments.js +200 -0
- package/dist/modules/shipment_tracking/commands/shipments.js.map +7 -0
- package/dist/modules/shipment_tracking/commands/shipsgo-configs.js +75 -0
- package/dist/modules/shipment_tracking/commands/shipsgo-configs.js.map +7 -0
- package/dist/modules/shipment_tracking/commands/tracking-jobs.js +120 -0
- package/dist/modules/shipment_tracking/commands/tracking-jobs.js.map +7 -0
- package/dist/modules/shipment_tracking/commands/tracking.js +140 -0
- package/dist/modules/shipment_tracking/commands/tracking.js.map +7 -0
- package/dist/modules/shipment_tracking/commands/webhooks.js +115 -0
- package/dist/modules/shipment_tracking/commands/webhooks.js.map +7 -0
- package/dist/modules/shipment_tracking/components/CombinedTimestampCell.js +168 -0
- package/dist/modules/shipment_tracking/components/CombinedTimestampCell.js.map +7 -0
- package/dist/modules/shipment_tracking/components/FacilityLocationInput.js +202 -0
- package/dist/modules/shipment_tracking/components/FacilityLocationInput.js.map +7 -0
- package/dist/modules/shipment_tracking/components/LocationOverrideDrawer.js +501 -0
- package/dist/modules/shipment_tracking/components/LocationOverrideDrawer.js.map +7 -0
- package/dist/modules/shipment_tracking/components/ShipmentDetailsDrawer.js +818 -0
- package/dist/modules/shipment_tracking/components/ShipmentDetailsDrawer.js.map +7 -0
- package/dist/modules/shipment_tracking/components/ShipmentDrawer.js +404 -0
- package/dist/modules/shipment_tracking/components/ShipmentDrawer.js.map +7 -0
- package/dist/modules/shipment_tracking/components/ShipsGoConfigSection.js +200 -0
- package/dist/modules/shipment_tracking/components/ShipsGoConfigSection.js.map +7 -0
- package/dist/modules/shipment_tracking/components/TimestampCell.js +108 -0
- package/dist/modules/shipment_tracking/components/TimestampCell.js.map +7 -0
- package/dist/modules/shipment_tracking/components/TrackingJobDrawer.js +343 -0
- package/dist/modules/shipment_tracking/components/TrackingJobDrawer.js.map +7 -0
- package/dist/modules/shipment_tracking/components/VesselTrackingMap.js +496 -0
- package/dist/modules/shipment_tracking/components/VesselTrackingMap.js.map +7 -0
- package/dist/modules/shipment_tracking/components/WebhookDrawer.js +332 -0
- package/dist/modules/shipment_tracking/components/WebhookDrawer.js.map +7 -0
- package/dist/modules/shipment_tracking/data/entities.js +686 -0
- package/dist/modules/shipment_tracking/data/entities.js.map +7 -0
- package/dist/modules/shipment_tracking/data/validators.js +434 -0
- package/dist/modules/shipment_tracking/data/validators.js.map +7 -0
- package/dist/modules/shipment_tracking/di.js +60 -0
- package/dist/modules/shipment_tracking/di.js.map +7 -0
- package/dist/modules/shipment_tracking/encryption.js +12 -0
- package/dist/modules/shipment_tracking/encryption.js.map +7 -0
- package/dist/modules/shipment_tracking/events.js +87 -0
- package/dist/modules/shipment_tracking/events.js.map +7 -0
- package/dist/modules/shipment_tracking/hooks/useVesselTracking.js +137 -0
- package/dist/modules/shipment_tracking/hooks/useVesselTracking.js.map +7 -0
- package/dist/modules/shipment_tracking/i18n/de.json +327 -0
- package/dist/modules/shipment_tracking/i18n/en.json +327 -0
- package/dist/modules/shipment_tracking/i18n/es.json +327 -0
- package/dist/modules/shipment_tracking/i18n/pl.json +327 -0
- package/dist/modules/shipment_tracking/index.js +15 -0
- package/dist/modules/shipment_tracking/index.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/adapters/cma-cgm.js +66 -0
- package/dist/modules/shipment_tracking/lib/adapters/cma-cgm.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/adapters/cosco-types.js +1 -0
- package/dist/modules/shipment_tracking/lib/adapters/cosco-types.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/adapters/cosco.js +236 -0
- package/dist/modules/shipment_tracking/lib/adapters/cosco.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/adapters/evergreen.js +87 -0
- package/dist/modules/shipment_tracking/lib/adapters/evergreen.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/adapters/hapag-lloyd.js +68 -0
- package/dist/modules/shipment_tracking/lib/adapters/hapag-lloyd.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/adapters/index.js +20 -0
- package/dist/modules/shipment_tracking/lib/adapters/index.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/adapters/maersk.js +84 -0
- package/dist/modules/shipment_tracking/lib/adapters/maersk.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/adapters/msc.js +170 -0
- package/dist/modules/shipment_tracking/lib/adapters/msc.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/adapters/zim.js +85 -0
- package/dist/modules/shipment_tracking/lib/adapters/zim.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/audit-helpers.js +20 -0
- package/dist/modules/shipment_tracking/lib/audit-helpers.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/auth/base64url.js +8 -0
- package/dist/modules/shipment_tracking/lib/auth/base64url.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/auth/oauth-client.js +38 -0
- package/dist/modules/shipment_tracking/lib/auth/oauth-client.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/background.js +15 -0
- package/dist/modules/shipment_tracking/lib/background.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/bic-api-client.js +106 -0
- package/dist/modules/shipment_tracking/lib/bic-api-client.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/carrier-adapter.js +17 -0
- package/dist/modules/shipment_tracking/lib/carrier-adapter.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/current-vessel.js +149 -0
- package/dist/modules/shipment_tracking/lib/current-vessel.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/dcsa-event-mapping.js +124 -0
- package/dist/modules/shipment_tracking/lib/dcsa-event-mapping.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/dcsa-event-parser.js +112 -0
- package/dist/modules/shipment_tracking/lib/dcsa-event-parser.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/dcsa-params.js +16 -0
- package/dist/modules/shipment_tracking/lib/dcsa-params.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/empty-return.js +48 -0
- package/dist/modules/shipment_tracking/lib/empty-return.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/location-overrides.js +85 -0
- package/dist/modules/shipment_tracking/lib/location-overrides.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/location-types.js +59 -0
- package/dist/modules/shipment_tracking/lib/location-types.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/logger.js +113 -0
- package/dist/modules/shipment_tracking/lib/logger.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/poi-event-processor.js +183 -0
- package/dist/modules/shipment_tracking/lib/poi-event-processor.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/poi-nats-config.js +52 -0
- package/dist/modules/shipment_tracking/lib/poi-nats-config.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/poi-types.js +43 -0
- package/dist/modules/shipment_tracking/lib/poi-types.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/rate-limiter.js +31 -0
- package/dist/modules/shipment_tracking/lib/rate-limiter.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/route-extraction.js +187 -0
- package/dist/modules/shipment_tracking/lib/route-extraction.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/route-inference.js +106 -0
- package/dist/modules/shipment_tracking/lib/route-inference.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/schedule-generator.js +63 -0
- package/dist/modules/shipment_tracking/lib/schedule-generator.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/shipsgo-client.js +143 -0
- package/dist/modules/shipment_tracking/lib/shipsgo-client.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/shipsgo-mapper.js +204 -0
- package/dist/modules/shipment_tracking/lib/shipsgo-mapper.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/status-machine.js +131 -0
- package/dist/modules/shipment_tracking/lib/status-machine.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/time-extraction.js +41 -0
- package/dist/modules/shipment_tracking/lib/time-extraction.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/timestamp-utils.js +100 -0
- package/dist/modules/shipment_tracking/lib/timestamp-utils.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/vessel-api.js +111 -0
- package/dist/modules/shipment_tracking/lib/vessel-api.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/vessel-cache.js +50 -0
- package/dist/modules/shipment_tracking/lib/vessel-cache.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/vessel-extraction.js +13 -0
- package/dist/modules/shipment_tracking/lib/vessel-extraction.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/webhook-dispatcher.js +62 -0
- package/dist/modules/shipment_tracking/lib/webhook-dispatcher.js.map +7 -0
- package/dist/modules/shipment_tracking/migrations/Migration20260422161208_shipment_tracking.js +48 -0
- package/dist/modules/shipment_tracking/migrations/Migration20260422161208_shipment_tracking.js.map +7 -0
- package/dist/modules/shipment_tracking/migrations/Migration20260529120000_shipment_tracking_poi_region_names.js +15 -0
- package/dist/modules/shipment_tracking/migrations/Migration20260529120000_shipment_tracking_poi_region_names.js.map +7 -0
- package/dist/modules/shipment_tracking/migrations/Migration20260821120000_shipment_tracking_shipsgo.js +47 -0
- package/dist/modules/shipment_tracking/migrations/Migration20260821120000_shipment_tracking_shipsgo.js.map +7 -0
- package/dist/modules/shipment_tracking/notifications.js +145 -0
- package/dist/modules/shipment_tracking/notifications.js.map +7 -0
- package/dist/modules/shipment_tracking/services/carrierRegistry.js +24 -0
- package/dist/modules/shipment_tracking/services/carrierRegistry.js.map +7 -0
- package/dist/modules/shipment_tracking/services/poiNatsService.js +397 -0
- package/dist/modules/shipment_tracking/services/poiNatsService.js.map +7 -0
- package/dist/modules/shipment_tracking/services/shipsGoProvider.js +163 -0
- package/dist/modules/shipment_tracking/services/shipsGoProvider.js.map +7 -0
- package/dist/modules/shipment_tracking/services/trackingService.js +1283 -0
- package/dist/modules/shipment_tracking/services/trackingService.js.map +7 -0
- package/dist/modules/shipment_tracking/services/webhookService.js +263 -0
- package/dist/modules/shipment_tracking/services/webhookService.js.map +7 -0
- package/dist/modules/shipment_tracking/setup.js +72 -0
- package/dist/modules/shipment_tracking/setup.js.map +7 -0
- package/dist/modules/shipment_tracking/subscribers/cargo-event-created.js +60 -0
- package/dist/modules/shipment_tracking/subscribers/cargo-event-created.js.map +7 -0
- package/dist/modules/shipment_tracking/subscribers/dcsa-event-webhook-dispatch.js +58 -0
- package/dist/modules/shipment_tracking/subscribers/dcsa-event-webhook-dispatch.js.map +7 -0
- package/dist/modules/shipment_tracking/subscribers/poi-event-notification.js +82 -0
- package/dist/modules/shipment_tracking/subscribers/poi-event-notification.js.map +7 -0
- package/dist/modules/shipment_tracking/subscribers/poi-event-webhook-dispatch.js +53 -0
- package/dist/modules/shipment_tracking/subscribers/poi-event-webhook-dispatch.js.map +7 -0
- package/dist/modules/shipment_tracking/subscribers/shipment-status-changed.js +28 -0
- package/dist/modules/shipment_tracking/subscribers/shipment-status-changed.js.map +7 -0
- package/dist/modules/shipment_tracking/subscribers/terminal-event-ingest.js +67 -0
- package/dist/modules/shipment_tracking/subscribers/terminal-event-ingest.js.map +7 -0
- package/dist/modules/shipment_tracking/subscribers/tracking-job-initial-poll.js +30 -0
- package/dist/modules/shipment_tracking/subscribers/tracking-job-initial-poll.js.map +7 -0
- package/dist/modules/shipment_tracking/subscribers/tracking-job-webhook-dispatch.js +19 -0
- package/dist/modules/shipment_tracking/subscribers/tracking-job-webhook-dispatch.js.map +7 -0
- package/dist/modules/shipment_tracking/tables/index.js +6 -0
- package/dist/modules/shipment_tracking/tables/index.js.map +7 -0
- package/dist/modules/shipment_tracking/tables/tracking_job/table.client.js +284 -0
- package/dist/modules/shipment_tracking/tables/tracking_job/table.client.js.map +7 -0
- package/dist/modules/shipment_tracking/tables/tracking_job/table.js +36 -0
- package/dist/modules/shipment_tracking/tables/tracking_job/table.js.map +7 -0
- package/dist/modules/shipment_tracking/widgets/dashboard/ships-map/config.js +25 -0
- package/dist/modules/shipment_tracking/widgets/dashboard/ships-map/config.js.map +7 -0
- package/dist/modules/shipment_tracking/widgets/dashboard/ships-map/widget.client.js +355 -0
- package/dist/modules/shipment_tracking/widgets/dashboard/ships-map/widget.client.js.map +7 -0
- package/dist/modules/shipment_tracking/widgets/dashboard/ships-map/widget.js +26 -0
- package/dist/modules/shipment_tracking/widgets/dashboard/ships-map/widget.js.map +7 -0
- package/dist/types/assets.d.js +1 -0
- package/dist/types/assets.d.js.map +7 -0
- package/generated/entities/bic_config/index.ts +20 -0
- package/generated/entities/carrier_config/index.ts +23 -0
- package/generated/entities/location_override/index.ts +26 -0
- package/generated/entities/shipment/index.ts +46 -0
- package/generated/entities/ships_go_config/index.ts +25 -0
- package/generated/entities/tracking_event/index.ts +60 -0
- package/generated/entities/tracking_job/index.ts +33 -0
- package/generated/entities/webhook/index.ts +22 -0
- package/generated/entities/webhook_delivery/index.ts +22 -0
- package/generated/entities.ids.generated.ts +47 -0
- package/package.json +81 -0
- package/src/index.ts +39 -0
- package/src/modules/shipment_tracking/__integration__/TC-TRACK-410-shipsgo-config-api.spec.ts +133 -0
- package/src/modules/shipment_tracking/__integration__/meta.ts +4 -0
- package/src/modules/shipment_tracking/__tests__/empty-return-stop.test.ts +231 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/hapag-lloyd-transship-container.json +702 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/index.ts +434 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/maersk-multi-transship-completed.json +1518 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/maersk-transship-intransit.json +558 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/msc-direct.json +222 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/msc-multi-transship-completed.json +974 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/msc-multi.json +4846 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/msc-transship.json +409 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/poi-events.json +240 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/synthetic/index.ts +138 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/synthetic-eta-updates.json +288 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/synthetic-route-inference.json +201 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/synthetic-voyage-progression.json +410 -0
- package/src/modules/shipment_tracking/__tests__/shipsgo-air-mapper.test.ts +157 -0
- package/src/modules/shipment_tracking/__tests__/shipsgo-client.test.ts +155 -0
- package/src/modules/shipment_tracking/__tests__/shipsgo-mapper.test.ts +201 -0
- package/src/modules/shipment_tracking/__tests__/shipsgo-poll.test.ts +357 -0
- package/src/modules/shipment_tracking/__tests__/shipsgo-provider.test.ts +364 -0
- package/src/modules/shipment_tracking/__tests__/trackingService.integration.test.ts +2248 -0
- package/src/modules/shipment_tracking/__tests__/webhookPayload.test.ts +151 -0
- package/src/modules/shipment_tracking/acl.ts +18 -0
- package/src/modules/shipment_tracking/api/bic-configs/route.ts +206 -0
- package/src/modules/shipment_tracking/api/bic-configs/test/route.ts +108 -0
- package/src/modules/shipment_tracking/api/cargo-events/route.ts +101 -0
- package/src/modules/shipment_tracking/api/carrier-configs/route.ts +142 -0
- package/src/modules/shipment_tracking/api/dashboard/ships-map/route.ts +246 -0
- package/src/modules/shipment_tracking/api/location-overrides/route.ts +185 -0
- package/src/modules/shipment_tracking/api/openapi.ts +28 -0
- package/src/modules/shipment_tracking/api/shipments/route.ts +197 -0
- package/src/modules/shipment_tracking/api/shipsgo-configs/route.ts +215 -0
- package/src/modules/shipment_tracking/api/tracking-jobs/route.ts +149 -0
- package/src/modules/shipment_tracking/api/tracking-jobs/sync/route.ts +116 -0
- package/src/modules/shipment_tracking/api/utils.ts +10 -0
- package/src/modules/shipment_tracking/api/webhooks/deliveries/route.ts +82 -0
- package/src/modules/shipment_tracking/api/webhooks/route.ts +138 -0
- package/src/modules/shipment_tracking/api/webhooks/test/route.ts +84 -0
- package/src/modules/shipment_tracking/assets/carriers/cma_cgm.png +0 -0
- package/src/modules/shipment_tracking/assets/carriers/cosco.png +0 -0
- package/src/modules/shipment_tracking/assets/carriers/evergreen.png +0 -0
- package/src/modules/shipment_tracking/assets/carriers/hapag_lloyd.png +0 -0
- package/src/modules/shipment_tracking/assets/carriers/maersk.png +0 -0
- package/src/modules/shipment_tracking/assets/carriers/msc.png +0 -0
- package/src/modules/shipment_tracking/assets/carriers/one.png +0 -0
- package/src/modules/shipment_tracking/assets/carriers/oocl.png +0 -0
- package/src/modules/shipment_tracking/assets/carriers/yang_ming.png +0 -0
- package/src/modules/shipment_tracking/assets/carriers/zim.png +0 -0
- package/src/modules/shipment_tracking/assets/index.ts +66 -0
- package/src/modules/shipment_tracking/backend/carrier-configs/page.meta.ts +16 -0
- package/src/modules/shipment_tracking/backend/carrier-configs/page.tsx +782 -0
- package/src/modules/shipment_tracking/backend/location-overrides/page.meta.ts +16 -0
- package/src/modules/shipment_tracking/backend/location-overrides/page.tsx +241 -0
- package/src/modules/shipment_tracking/backend/shipment-tracking/page.meta.ts +16 -0
- package/src/modules/shipment_tracking/backend/shipment-tracking/page.tsx +340 -0
- package/src/modules/shipment_tracking/backend/tracking-jobs/page.meta.ts +16 -0
- package/src/modules/shipment_tracking/backend/tracking-jobs/page.tsx +16 -0
- package/src/modules/shipment_tracking/backend/webhooks/page.meta.ts +16 -0
- package/src/modules/shipment_tracking/backend/webhooks/page.tsx +228 -0
- package/src/modules/shipment_tracking/ce.ts +48 -0
- package/src/modules/shipment_tracking/cli.ts +321 -0
- package/src/modules/shipment_tracking/commands/bic-configs.ts +94 -0
- package/src/modules/shipment_tracking/commands/carrier-configs.ts +89 -0
- package/src/modules/shipment_tracking/commands/index.ts +8 -0
- package/src/modules/shipment_tracking/commands/location-overrides.ts +119 -0
- package/src/modules/shipment_tracking/commands/shipments.ts +247 -0
- package/src/modules/shipment_tracking/commands/shipsgo-configs.ts +101 -0
- package/src/modules/shipment_tracking/commands/tracking-jobs.ts +158 -0
- package/src/modules/shipment_tracking/commands/tracking.ts +230 -0
- package/src/modules/shipment_tracking/commands/webhooks.ts +159 -0
- package/src/modules/shipment_tracking/components/CombinedTimestampCell.tsx +236 -0
- package/src/modules/shipment_tracking/components/FacilityLocationInput.tsx +235 -0
- package/src/modules/shipment_tracking/components/LocationOverrideDrawer.tsx +586 -0
- package/src/modules/shipment_tracking/components/ShipmentDetailsDrawer.tsx +1364 -0
- package/src/modules/shipment_tracking/components/ShipmentDrawer.tsx +498 -0
- package/src/modules/shipment_tracking/components/ShipsGoConfigSection.tsx +266 -0
- package/src/modules/shipment_tracking/components/TimestampCell.tsx +146 -0
- package/src/modules/shipment_tracking/components/TrackingJobDrawer.tsx +467 -0
- package/src/modules/shipment_tracking/components/VesselTrackingMap.tsx +761 -0
- package/src/modules/shipment_tracking/components/WebhookDrawer.tsx +434 -0
- package/src/modules/shipment_tracking/data/entities.ts +748 -0
- package/src/modules/shipment_tracking/data/validators.ts +523 -0
- package/src/modules/shipment_tracking/di.ts +73 -0
- package/src/modules/shipment_tracking/encryption.ts +17 -0
- package/src/modules/shipment_tracking/events.ts +122 -0
- package/src/modules/shipment_tracking/hooks/useVesselTracking.ts +297 -0
- package/src/modules/shipment_tracking/i18n/de.json +327 -0
- package/src/modules/shipment_tracking/i18n/en.json +327 -0
- package/src/modules/shipment_tracking/i18n/es.json +327 -0
- package/src/modules/shipment_tracking/i18n/pl.json +327 -0
- package/src/modules/shipment_tracking/index.ts +13 -0
- package/src/modules/shipment_tracking/lib/__tests__/dcsa-event-mapping.test.ts +385 -0
- package/src/modules/shipment_tracking/lib/__tests__/dcsa-event-parser.test.ts +398 -0
- package/src/modules/shipment_tracking/lib/__tests__/empty-return.test.ts +174 -0
- package/src/modules/shipment_tracking/lib/__tests__/poi-event-processor.test.ts +699 -0
- package/src/modules/shipment_tracking/lib/__tests__/route-inference.test.ts +402 -0
- package/src/modules/shipment_tracking/lib/__tests__/status-machine.test.ts +447 -0
- package/src/modules/shipment_tracking/lib/__tests__/time-extraction.test.ts +331 -0
- package/src/modules/shipment_tracking/lib/__tests__/timestamp-utils.test.ts +260 -0
- package/src/modules/shipment_tracking/lib/__tests__/vessel-api.test.ts +125 -0
- package/src/modules/shipment_tracking/lib/__tests__/vessel-extraction.test.ts +108 -0
- package/src/modules/shipment_tracking/lib/adapters/cma-cgm.ts +84 -0
- package/src/modules/shipment_tracking/lib/adapters/cosco-types.ts +145 -0
- package/src/modules/shipment_tracking/lib/adapters/cosco.ts +314 -0
- package/src/modules/shipment_tracking/lib/adapters/evergreen.ts +107 -0
- package/src/modules/shipment_tracking/lib/adapters/hapag-lloyd.ts +88 -0
- package/src/modules/shipment_tracking/lib/adapters/index.ts +18 -0
- package/src/modules/shipment_tracking/lib/adapters/maersk.ts +104 -0
- package/src/modules/shipment_tracking/lib/adapters/msc.ts +223 -0
- package/src/modules/shipment_tracking/lib/adapters/zim.ts +106 -0
- package/src/modules/shipment_tracking/lib/audit-helpers.ts +29 -0
- package/src/modules/shipment_tracking/lib/auth/base64url.ts +4 -0
- package/src/modules/shipment_tracking/lib/auth/oauth-client.ts +53 -0
- package/src/modules/shipment_tracking/lib/background.ts +24 -0
- package/src/modules/shipment_tracking/lib/bic-api-client.ts +199 -0
- package/src/modules/shipment_tracking/lib/carrier-adapter.ts +136 -0
- package/src/modules/shipment_tracking/lib/current-vessel.ts +274 -0
- package/src/modules/shipment_tracking/lib/dcsa-event-mapping.ts +202 -0
- package/src/modules/shipment_tracking/lib/dcsa-event-parser.ts +163 -0
- package/src/modules/shipment_tracking/lib/dcsa-params.ts +14 -0
- package/src/modules/shipment_tracking/lib/empty-return.ts +122 -0
- package/src/modules/shipment_tracking/lib/location-overrides.ts +150 -0
- package/src/modules/shipment_tracking/lib/location-types.ts +154 -0
- package/src/modules/shipment_tracking/lib/logger.ts +195 -0
- package/src/modules/shipment_tracking/lib/poi-event-processor.ts +302 -0
- package/src/modules/shipment_tracking/lib/poi-nats-config.ts +134 -0
- package/src/modules/shipment_tracking/lib/poi-types.ts +198 -0
- package/src/modules/shipment_tracking/lib/rate-limiter.ts +58 -0
- package/src/modules/shipment_tracking/lib/route-extraction.ts +439 -0
- package/src/modules/shipment_tracking/lib/route-inference.ts +238 -0
- package/src/modules/shipment_tracking/lib/schedule-generator.ts +92 -0
- package/src/modules/shipment_tracking/lib/shipsgo-client.ts +350 -0
- package/src/modules/shipment_tracking/lib/shipsgo-mapper.ts +296 -0
- package/src/modules/shipment_tracking/lib/status-machine.ts +230 -0
- package/src/modules/shipment_tracking/lib/time-extraction.ts +85 -0
- package/src/modules/shipment_tracking/lib/timestamp-utils.ts +244 -0
- package/src/modules/shipment_tracking/lib/vessel-api.ts +299 -0
- package/src/modules/shipment_tracking/lib/vessel-cache.ts +102 -0
- package/src/modules/shipment_tracking/lib/vessel-extraction.ts +39 -0
- package/src/modules/shipment_tracking/lib/webhook-dispatcher.ts +93 -0
- package/src/modules/shipment_tracking/migrations/.snapshot-open-mercato.json +2914 -0
- package/src/modules/shipment_tracking/migrations/Migration20260422161208_shipment_tracking.ts +60 -0
- package/src/modules/shipment_tracking/migrations/Migration20260529120000_shipment_tracking_poi_region_names.ts +22 -0
- package/src/modules/shipment_tracking/migrations/Migration20260821120000_shipment_tracking_shipsgo.ts +65 -0
- package/src/modules/shipment_tracking/notifications.ts +151 -0
- package/src/modules/shipment_tracking/services/carrierRegistry.ts +29 -0
- package/src/modules/shipment_tracking/services/poiNatsService.ts +526 -0
- package/src/modules/shipment_tracking/services/shipsGoProvider.ts +231 -0
- package/src/modules/shipment_tracking/services/trackingService.ts +1777 -0
- package/src/modules/shipment_tracking/services/webhookService.ts +347 -0
- package/src/modules/shipment_tracking/setup.ts +99 -0
- package/src/modules/shipment_tracking/subscribers/__tests__/terminal-event-ingest.test.ts +141 -0
- package/src/modules/shipment_tracking/subscribers/cargo-event-created.ts +115 -0
- package/src/modules/shipment_tracking/subscribers/dcsa-event-webhook-dispatch.ts +115 -0
- package/src/modules/shipment_tracking/subscribers/poi-event-notification.ts +144 -0
- package/src/modules/shipment_tracking/subscribers/poi-event-webhook-dispatch.ts +94 -0
- package/src/modules/shipment_tracking/subscribers/shipment-status-changed.ts +41 -0
- package/src/modules/shipment_tracking/subscribers/terminal-event-ingest.ts +109 -0
- package/src/modules/shipment_tracking/subscribers/tracking-job-initial-poll.ts +53 -0
- package/src/modules/shipment_tracking/subscribers/tracking-job-webhook-dispatch.ts +50 -0
- package/src/modules/shipment_tracking/tables/index.ts +4 -0
- package/src/modules/shipment_tracking/tables/tracking_job/table.client.tsx +337 -0
- package/src/modules/shipment_tracking/tables/tracking_job/table.ts +34 -0
- package/src/modules/shipment_tracking/widgets/dashboard/ships-map/config.ts +32 -0
- package/src/modules/shipment_tracking/widgets/dashboard/ships-map/widget.client.tsx +448 -0
- package/src/modules/shipment_tracking/widgets/dashboard/ships-map/widget.ts +25 -0
- package/src/types/assets.d.ts +5 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
// The tracking-jobs table. Moved verbatim from
|
|
4
|
+
// `backend/tracking-jobs/page.tsx`, which is now a thin host over this
|
|
5
|
+
// component — so the page and any other host (a split-view pane, a drawer)
|
|
6
|
+
// render the SAME table rather than two that drift.
|
|
7
|
+
//
|
|
8
|
+
// Only the `TableHostContext` contract differs from the original page body:
|
|
9
|
+
// `storageScope`, `embedded`, `initialFilters`, `overflowExtras` and the hide*
|
|
10
|
+
// flags. Row clicks already opened a drawer rather than navigating, so nothing
|
|
11
|
+
// here tears a host down.
|
|
12
|
+
//
|
|
13
|
+
// Specs: .ai/specs/2026-08-04-module-table-registry.md
|
|
14
|
+
// .ai/specs/2026-08-17-split-view-workspace-composition.md
|
|
15
|
+
|
|
16
|
+
import * as React from 'react'
|
|
17
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
18
|
+
import { Button } from '@freighttech/ui/primitives-v2'
|
|
19
|
+
import {
|
|
20
|
+
DynamicTable,
|
|
21
|
+
DynamicTableBadge,
|
|
22
|
+
TableSkeleton,
|
|
23
|
+
useDynamicTablePage,
|
|
24
|
+
} from '@freighttech/ui/backend/dynamic-table'
|
|
25
|
+
import type { ColumnDef, ContextMenuAction, DynamicTableBadgeVariant, TableHostContext } from '@freighttech/ui/backend/dynamic-table'
|
|
26
|
+
import { apiCallOrThrow } from '@freighttech/ui/backend/utils/apiCall'
|
|
27
|
+
import { flash } from '@freighttech/ui/backend/FlashMessages'
|
|
28
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
29
|
+
import { Plus } from 'lucide-react'
|
|
30
|
+
import { TrackingJobDrawer } from '../../components/TrackingJobDrawer'
|
|
31
|
+
|
|
32
|
+
type TrackingJobRow = {
|
|
33
|
+
id: string
|
|
34
|
+
carrierCode: string
|
|
35
|
+
referenceType: string
|
|
36
|
+
referenceValue: string
|
|
37
|
+
status: string
|
|
38
|
+
nextPollAt: string | null
|
|
39
|
+
lastPollAt: string | null
|
|
40
|
+
retryCount: number
|
|
41
|
+
createdAt: string | null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function mapItem(item: Record<string, unknown>): TrackingJobRow | null {
|
|
45
|
+
const id = typeof item.id === 'string' ? item.id : null
|
|
46
|
+
if (!id) return null
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
id,
|
|
50
|
+
carrierCode: (item.carrierCode as string) ?? (item.carrier_code as string) ?? '',
|
|
51
|
+
referenceType: (item.referenceType as string) ?? (item.reference_type as string) ?? '',
|
|
52
|
+
referenceValue: (item.referenceValue as string) ?? (item.reference_value as string) ?? '',
|
|
53
|
+
status: (item.status as string) ?? 'active',
|
|
54
|
+
nextPollAt: (item.nextPollAt as string) ?? (item.next_poll_at as string) ?? null,
|
|
55
|
+
lastPollAt: (item.lastPollAt as string) ?? (item.last_poll_at as string) ?? null,
|
|
56
|
+
retryCount: typeof item.retryCount === 'number' ? item.retryCount : (typeof item.retry_count === 'number' ? item.retry_count : 0),
|
|
57
|
+
createdAt: (item.createdAt as string) ?? (item.created_at as string) ?? null,
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function formatDateTime(value: string | null): string {
|
|
62
|
+
if (!value) return '-'
|
|
63
|
+
const date = new Date(value)
|
|
64
|
+
if (Number.isNaN(date.getTime())) return '-'
|
|
65
|
+
return date.toLocaleString()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const JOB_STATUS_VARIANTS: Record<string, DynamicTableBadgeVariant> = {
|
|
69
|
+
active: 'success',
|
|
70
|
+
paused: 'warning',
|
|
71
|
+
deactivated: 'neutral',
|
|
72
|
+
failed: 'error',
|
|
73
|
+
completed: 'info',
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Cancels the AppShell's page padding so the grid bleeds edge-to-edge. A host
|
|
77
|
+
* supplies its own bounds, so an embedded table must not apply it. */
|
|
78
|
+
const PAGE_BLEED = '-mx-4 lg:-mx-6 -mb-4 lg:-mb-6 -mt-7 lg:-mt-9'
|
|
79
|
+
|
|
80
|
+
export default function TrackingJobTable({
|
|
81
|
+
storageScope = '',
|
|
82
|
+
embedded = false,
|
|
83
|
+
initialFilters,
|
|
84
|
+
sharedFilters,
|
|
85
|
+
sharedSearch,
|
|
86
|
+
overflowExtras,
|
|
87
|
+
hideToolbar,
|
|
88
|
+
hideSearch,
|
|
89
|
+
hideViews,
|
|
90
|
+
hidePagination,
|
|
91
|
+
}: TableHostContext = {}) {
|
|
92
|
+
const t = useT()
|
|
93
|
+
const [drawerOpen, setDrawerOpen] = useState(false)
|
|
94
|
+
const [drawerMode, setDrawerMode] = useState<'create' | 'edit'>('create')
|
|
95
|
+
const [selectedJobId, setSelectedJobId] = useState<string | undefined>(undefined)
|
|
96
|
+
const refreshRef = useRef<() => void>(() => {})
|
|
97
|
+
|
|
98
|
+
const handleAction = useCallback(
|
|
99
|
+
async (jobId: string, action: 'pause' | 'resume' | 'deactivate') => {
|
|
100
|
+
const commandMap = {
|
|
101
|
+
pause: 'PUT',
|
|
102
|
+
resume: 'PUT',
|
|
103
|
+
deactivate: 'DELETE',
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
await apiCallOrThrow('/api/shipment_tracking/tracking-jobs', {
|
|
108
|
+
method: commandMap[action],
|
|
109
|
+
body: JSON.stringify({ id: jobId, status: action === 'resume' ? 'active' : action === 'pause' ? 'paused' : undefined }),
|
|
110
|
+
})
|
|
111
|
+
flash(`Job ${action}d`, 'success')
|
|
112
|
+
refreshRef.current()
|
|
113
|
+
} catch {
|
|
114
|
+
flash(`Failed to ${action} job`, 'error')
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
[],
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
const handleSync = useCallback(async (jobId: string) => {
|
|
121
|
+
try {
|
|
122
|
+
const result = await apiCallOrThrow('/api/shipment_tracking/tracking-jobs/sync', {
|
|
123
|
+
method: 'POST',
|
|
124
|
+
body: JSON.stringify({ id: jobId }),
|
|
125
|
+
})
|
|
126
|
+
const data = result as { newEvents?: number; shipmentsCreated?: number }
|
|
127
|
+
const eventCount = data.newEvents ?? 0
|
|
128
|
+
const shipmentCount = data.shipmentsCreated ?? 0
|
|
129
|
+
flash(
|
|
130
|
+
eventCount > 0 || shipmentCount > 0
|
|
131
|
+
? `Sync complete: ${eventCount} new event(s), ${shipmentCount} shipment(s) created`
|
|
132
|
+
: 'Sync complete — no new data',
|
|
133
|
+
'success',
|
|
134
|
+
)
|
|
135
|
+
refreshRef.current()
|
|
136
|
+
} catch {
|
|
137
|
+
flash('Failed to sync tracking job', 'error')
|
|
138
|
+
}
|
|
139
|
+
}, [])
|
|
140
|
+
|
|
141
|
+
const columns = useMemo<ColumnDef[]>(
|
|
142
|
+
() => [
|
|
143
|
+
{
|
|
144
|
+
data: 'referenceValue',
|
|
145
|
+
title: 'Reference',
|
|
146
|
+
width: 200,
|
|
147
|
+
readOnly: true,
|
|
148
|
+
renderer: (value: unknown, rowData: Record<string, unknown>) => (
|
|
149
|
+
<div>
|
|
150
|
+
<span className="font-medium font-mono text-sm tracking-wider">{String(value ?? '')}</span>
|
|
151
|
+
<span className="text-xs text-muted-foreground ml-2">({String(rowData.referenceType ?? '')})</span>
|
|
152
|
+
</div>
|
|
153
|
+
),
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
data: 'carrierCode',
|
|
157
|
+
title: t('shipment_tracking.tracking_jobs.fields.carrierCode', 'Carrier'),
|
|
158
|
+
width: 130,
|
|
159
|
+
readOnly: true,
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
data: 'status',
|
|
163
|
+
title: t('shipment_tracking.tracking_jobs.fields.status', 'Status'),
|
|
164
|
+
width: 110,
|
|
165
|
+
readOnly: true,
|
|
166
|
+
renderer: (value: unknown) => {
|
|
167
|
+
const status = String(value ?? '')
|
|
168
|
+
return (
|
|
169
|
+
<DynamicTableBadge variant={JOB_STATUS_VARIANTS[status] ?? 'neutral'}>
|
|
170
|
+
{t(`shipment_tracking.tracking_jobs.statuses.${status}`, status)}
|
|
171
|
+
</DynamicTableBadge>
|
|
172
|
+
)
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
data: 'nextPollAt',
|
|
177
|
+
title: t('shipment_tracking.tracking_jobs.fields.nextPollAt', 'Next Poll'),
|
|
178
|
+
width: 170,
|
|
179
|
+
readOnly: true,
|
|
180
|
+
renderer: (value: unknown) => formatDateTime(value as string | null),
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
data: 'lastPollAt',
|
|
184
|
+
title: t('shipment_tracking.tracking_jobs.fields.lastPollAt', 'Last Poll'),
|
|
185
|
+
width: 170,
|
|
186
|
+
readOnly: true,
|
|
187
|
+
renderer: (value: unknown) => formatDateTime(value as string | null),
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
data: 'retryCount',
|
|
191
|
+
title: t('shipment_tracking.tracking_jobs.fields.retryCount', 'Retries'),
|
|
192
|
+
width: 80,
|
|
193
|
+
readOnly: true,
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
[t],
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
const handleRowClick = useCallback((_rowIndex: number, rowData: Record<string, unknown>) => {
|
|
200
|
+
const id = rowData?.id as string | undefined
|
|
201
|
+
if (id) {
|
|
202
|
+
setDrawerMode('edit')
|
|
203
|
+
setSelectedJobId(id)
|
|
204
|
+
setDrawerOpen(true)
|
|
205
|
+
}
|
|
206
|
+
}, [])
|
|
207
|
+
|
|
208
|
+
const createButton = useMemo(
|
|
209
|
+
() => (
|
|
210
|
+
<Button
|
|
211
|
+
variant="primary"
|
|
212
|
+
size="sm"
|
|
213
|
+
icon={<Plus className="h-4 w-4" />}
|
|
214
|
+
onClick={() => {
|
|
215
|
+
setDrawerMode('create')
|
|
216
|
+
setSelectedJobId(undefined)
|
|
217
|
+
setDrawerOpen(true)
|
|
218
|
+
}}
|
|
219
|
+
>
|
|
220
|
+
{t('shipment_tracking.tracking_jobs.create', 'Create Tracking Job')}
|
|
221
|
+
</Button>
|
|
222
|
+
),
|
|
223
|
+
[t],
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
const rowActions = useCallback(
|
|
227
|
+
(rowData: any): ContextMenuAction[] => {
|
|
228
|
+
const id = rowData?.id as string | undefined
|
|
229
|
+
const status = rowData?.status as string | undefined
|
|
230
|
+
if (!id) return []
|
|
231
|
+
|
|
232
|
+
const actions: ContextMenuAction[] = []
|
|
233
|
+
|
|
234
|
+
if (status === 'active') {
|
|
235
|
+
actions.push({ id: 'sync', label: t('shipment_tracking.tracking_jobs.actions.triggerSync', 'Trigger Sync') })
|
|
236
|
+
actions.push({ id: 'pause', label: t('shipment_tracking.tracking_jobs.actions.pause', 'Pause') })
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (status === 'paused' || status === 'failed') {
|
|
240
|
+
actions.push({ id: 'resume', label: t('shipment_tracking.tracking_jobs.actions.resume', 'Resume') })
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (status !== 'deactivated' && status !== 'completed') {
|
|
244
|
+
actions.push({ id: 'deactivate', label: t('shipment_tracking.tracking_jobs.actions.deactivate', 'Deactivate') })
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return actions
|
|
248
|
+
},
|
|
249
|
+
[t],
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
const handleRowAction = useCallback(
|
|
253
|
+
(actionId: string, rowData: any) => {
|
|
254
|
+
const id = rowData?.id as string | undefined
|
|
255
|
+
if (!id) return
|
|
256
|
+
if (actionId === 'sync') handleSync(id)
|
|
257
|
+
else if (actionId === 'pause') handleAction(id, 'pause')
|
|
258
|
+
else if (actionId === 'resume') handleAction(id, 'resume')
|
|
259
|
+
else if (actionId === 'deactivate') handleAction(id, 'deactivate')
|
|
260
|
+
},
|
|
261
|
+
[handleSync, handleAction],
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
const table = useDynamicTablePage<TrackingJobRow>({
|
|
265
|
+
source: '/api/shipment_tracking/tracking-jobs',
|
|
266
|
+
// Saved views. Without this the perspective tab strip auto-hides
|
|
267
|
+
// (hidePerspectiveTabs ?? !hasPerspectives), so users cannot save or
|
|
268
|
+
// switch a view on this list at all.
|
|
269
|
+
perspectives: 'shipment_tracking_jobs',
|
|
270
|
+
columns,
|
|
271
|
+
tableName: t('shipment_tracking.tracking_jobs.title', 'Tracking Jobs'),
|
|
272
|
+
storageScope,
|
|
273
|
+
initialFilters,
|
|
274
|
+
sharedFilters,
|
|
275
|
+
sharedSearch,
|
|
276
|
+
defaultPageSize: 20,
|
|
277
|
+
mapApiItem: mapItem,
|
|
278
|
+
cellEdit: false,
|
|
279
|
+
tableProps: {
|
|
280
|
+
height: 'fill',
|
|
281
|
+
// Opens the edit drawer — it never navigates, so it is safe inside a host
|
|
282
|
+
// and stays wired in both modes.
|
|
283
|
+
onRowClick: handleRowClick,
|
|
284
|
+
uiConfig: {
|
|
285
|
+
readOnlyStyle: 'normal',
|
|
286
|
+
hideAddRowButton: true,
|
|
287
|
+
searchBarEnd: createButton,
|
|
288
|
+
toolbarOverflowExtras: overflowExtras,
|
|
289
|
+
// Chrome the host asked to suppress, so a pane can trade toolbar rows
|
|
290
|
+
// for data rows.
|
|
291
|
+
hideToolbar,
|
|
292
|
+
hideSearch,
|
|
293
|
+
hidePerspectiveTabs: hideViews,
|
|
294
|
+
hidePagination,
|
|
295
|
+
// Fullscreen is a document-level overlay; in a host it would cover the
|
|
296
|
+
// host itself, so it is a full-page affordance only.
|
|
297
|
+
enableFullscreen: !embedded,
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
})
|
|
301
|
+
|
|
302
|
+
useEffect(() => {
|
|
303
|
+
refreshRef.current = table.refresh
|
|
304
|
+
}, [table.refresh])
|
|
305
|
+
|
|
306
|
+
const wrapperClass = embedded ? 'h-full min-h-0' : PAGE_BLEED
|
|
307
|
+
|
|
308
|
+
if (table.isLoading) {
|
|
309
|
+
return (
|
|
310
|
+
<div className={wrapperClass}>
|
|
311
|
+
<TableSkeleton rows={10} columns={6} />
|
|
312
|
+
</div>
|
|
313
|
+
)
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return (
|
|
317
|
+
<div className={wrapperClass} data-table-id="shipment_tracking.tracking_job">
|
|
318
|
+
<DynamicTable
|
|
319
|
+
{...table.props}
|
|
320
|
+
striped
|
|
321
|
+
density="md"
|
|
322
|
+
rowActions={rowActions}
|
|
323
|
+
onRowAction={handleRowAction}
|
|
324
|
+
/>
|
|
325
|
+
|
|
326
|
+
<TrackingJobDrawer
|
|
327
|
+
open={drawerOpen}
|
|
328
|
+
onOpenChange={setDrawerOpen}
|
|
329
|
+
mode={drawerMode}
|
|
330
|
+
trackingJobId={selectedJobId}
|
|
331
|
+
onSaved={() => {
|
|
332
|
+
table.refresh()
|
|
333
|
+
}}
|
|
334
|
+
/>
|
|
335
|
+
</div>
|
|
336
|
+
)
|
|
337
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { lazyTable, type TableDefinition } from '@freighttech/ui/backend/dynamic-table'
|
|
2
|
+
import { E } from '#generated/entities.ids.generated'
|
|
3
|
+
|
|
4
|
+
const table: TableDefinition = {
|
|
5
|
+
metadata: {
|
|
6
|
+
id: 'shipment_tracking.tracking_job',
|
|
7
|
+
title: 'Tracking Jobs',
|
|
8
|
+
titleKey: 'shipment_tracking.nav.tracking_jobs',
|
|
9
|
+
features: ['shipment_tracking.tracking_jobs.view'],
|
|
10
|
+
// Existing perspectives key — immutable, user views persist against it.
|
|
11
|
+
perspectiveTableId: 'shipment_tracking_jobs',
|
|
12
|
+
entityId: E.shipment_tracking.tracking_job,
|
|
13
|
+
href: '/backend/tracking-jobs',
|
|
14
|
+
icon: 'radar',
|
|
15
|
+
group: 'Shipment Tracking',
|
|
16
|
+
groupKey: 'shipment_tracking.nav.group',
|
|
17
|
+
// DELIBERATELY EMPTY. `status` is the one criterion this row could answer in
|
|
18
|
+
// principle, and it is still not mapped: api/tracking-jobs/route.ts is a
|
|
19
|
+
// `makeCrudRoute` whose `buildFilters` reads only its own named query params
|
|
20
|
+
// (status, carrierCode, referenceType, referenceValue). Neither branch of the
|
|
21
|
+
// factory looks at the DynamicTable `filters` JSON the hook sends — it merges
|
|
22
|
+
// `filter[...]` keys instead — so a shared status rule reaches the server and
|
|
23
|
+
// is discarded. Claiming the filter would show unfiltered rows to someone who
|
|
24
|
+
// believes they are filtered; reporting it as unmapped is the honest answer.
|
|
25
|
+
// (Mapping becomes correct the day that route parses `filters`.)
|
|
26
|
+
//
|
|
27
|
+
// The row also has no customer and no transport mode, and its only dates
|
|
28
|
+
// (`nextPollAt` / `lastPollAt`) are poller scheduling, not shipment dates.
|
|
29
|
+
sharedFilters: {},
|
|
30
|
+
},
|
|
31
|
+
Table: lazyTable(() => import('./table.client')),
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default table
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface ShipsMapSettings {
|
|
2
|
+
/** Initial map zoom (fleet view). */
|
|
3
|
+
defaultZoom: number
|
|
4
|
+
/** Initial map center latitude. */
|
|
5
|
+
centerLat: number
|
|
6
|
+
/** Initial map center longitude. */
|
|
7
|
+
centerLng: number
|
|
8
|
+
/** Auto-refresh interval in seconds; 0 disables auto-refresh. */
|
|
9
|
+
autoRefreshSeconds: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const DEFAULT_SETTINGS: ShipsMapSettings = {
|
|
13
|
+
defaultZoom: 3,
|
|
14
|
+
centerLat: 54.5, // Baltic, matches VesselTrackingMap default
|
|
15
|
+
centerLng: 18.5,
|
|
16
|
+
autoRefreshSeconds: 60,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function toFiniteNumber(value: unknown, fallback: number): number {
|
|
20
|
+
const n = typeof value === 'number' ? value : Number(value)
|
|
21
|
+
return Number.isFinite(n) ? n : fallback
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function hydrateShipsMapSettings(raw: unknown): ShipsMapSettings {
|
|
25
|
+
const r = (raw ?? {}) as Partial<Record<keyof ShipsMapSettings, unknown>>
|
|
26
|
+
return {
|
|
27
|
+
defaultZoom: Math.min(20, Math.max(1, Math.round(toFiniteNumber(r.defaultZoom, DEFAULT_SETTINGS.defaultZoom)))),
|
|
28
|
+
centerLat: Math.min(90, Math.max(-90, toFiniteNumber(r.centerLat, DEFAULT_SETTINGS.centerLat))),
|
|
29
|
+
centerLng: Math.min(180, Math.max(-180, toFiniteNumber(r.centerLng, DEFAULT_SETTINGS.centerLng))),
|
|
30
|
+
autoRefreshSeconds: Math.max(0, Math.round(toFiniteNumber(r.autoRefreshSeconds, DEFAULT_SETTINGS.autoRefreshSeconds))),
|
|
31
|
+
}
|
|
32
|
+
}
|