@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,402 @@
|
|
|
1
|
+
import { inferRouteFromEvents, isValidUnlocode } from '../route-inference'
|
|
2
|
+
import { parseDcsaEvents } from '../dcsa-event-parser'
|
|
3
|
+
import { fixtures } from '../../__tests__/fixtures'
|
|
4
|
+
|
|
5
|
+
describe('Route Inference', () => {
|
|
6
|
+
describe('inferRouteFromEvents', () => {
|
|
7
|
+
it('should return null values for empty events array', () => {
|
|
8
|
+
const result = inferRouteFromEvents([])
|
|
9
|
+
|
|
10
|
+
expect(result.originUnlocode).toBeNull()
|
|
11
|
+
expect(result.destinationUnlocode).toBeNull()
|
|
12
|
+
expect(result.confidence.origin).toBeNull()
|
|
13
|
+
expect(result.confidence.destination).toBeNull()
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
describe('Direct voyage (CNYTN -> PLGDN)', () => {
|
|
17
|
+
it('should infer destination from EST ARRI event', () => {
|
|
18
|
+
const events = parseDcsaEvents(fixtures.direct.events, 'MSC')
|
|
19
|
+
const result = inferRouteFromEvents(events)
|
|
20
|
+
|
|
21
|
+
expect(result.destinationUnlocode).toBe('PLGDN')
|
|
22
|
+
expect(result.confidence.destination).toBe('high')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('should infer origin from first DEPA with exportVoyageNumber', () => {
|
|
26
|
+
const events = parseDcsaEvents(fixtures.direct.events, 'MSC')
|
|
27
|
+
const result = inferRouteFromEvents(events)
|
|
28
|
+
|
|
29
|
+
expect(result.originUnlocode).toBe('CNYTN')
|
|
30
|
+
expect(result.confidence.origin).toBe('high')
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('should match expected route from fixture metadata', () => {
|
|
34
|
+
const events = parseDcsaEvents(fixtures.direct.events, 'MSC')
|
|
35
|
+
const result = inferRouteFromEvents(events)
|
|
36
|
+
|
|
37
|
+
expect(result.originUnlocode).toBe(fixtures.direct.origin)
|
|
38
|
+
expect(result.destinationUnlocode).toBe(fixtures.direct.destination)
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
describe('Transshipment voyage (CNTAO -> CNNGB -> PLGDN)', () => {
|
|
43
|
+
it('should infer origin from first LOAD at port of loading', () => {
|
|
44
|
+
const events = parseDcsaEvents(fixtures.transshipment.events, 'MSC')
|
|
45
|
+
const result = inferRouteFromEvents(events)
|
|
46
|
+
|
|
47
|
+
// Origin should be first port of loading, not transshipment port
|
|
48
|
+
expect(result.originUnlocode).toBe(fixtures.transshipment.origin)
|
|
49
|
+
expect(result.confidence.origin).toBe('high')
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('should infer destination correctly', () => {
|
|
53
|
+
const events = parseDcsaEvents(fixtures.transshipment.events, 'MSC')
|
|
54
|
+
const result = inferRouteFromEvents(events)
|
|
55
|
+
|
|
56
|
+
expect(result.destinationUnlocode).toBe(fixtures.transshipment.destination)
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
describe('Completed multi-container transshipment (CRMOB -> BEANR -> PLGDY)', () => {
|
|
61
|
+
it('should infer destination from last ACT ARRI when no EST events', () => {
|
|
62
|
+
const events = parseDcsaEvents(fixtures.multiTransshipCompleted.events, 'MSC')
|
|
63
|
+
const result = inferRouteFromEvents(events)
|
|
64
|
+
|
|
65
|
+
// This is a completed voyage - no EST events, should use last ACT ARRI
|
|
66
|
+
expect(result.destinationUnlocode).toBe('PLGDY')
|
|
67
|
+
expect(result.confidence.destination).toBe('high')
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('should infer origin from first DEPA with exportVoyageNumber', () => {
|
|
71
|
+
const events = parseDcsaEvents(fixtures.multiTransshipCompleted.events, 'MSC')
|
|
72
|
+
const result = inferRouteFromEvents(events)
|
|
73
|
+
|
|
74
|
+
// Origin should be CRMOB (port of loading), not CRCAR (inland depot)
|
|
75
|
+
expect(result.originUnlocode).toBe('CRMOB')
|
|
76
|
+
expect(result.confidence.origin).toBe('high')
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it('should match expected route from fixture metadata', () => {
|
|
80
|
+
const events = parseDcsaEvents(fixtures.multiTransshipCompleted.events, 'MSC')
|
|
81
|
+
const result = inferRouteFromEvents(events)
|
|
82
|
+
|
|
83
|
+
expect(result.originUnlocode).toBe(fixtures.multiTransshipCompleted.origin)
|
|
84
|
+
expect(result.destinationUnlocode).toBe(fixtures.multiTransshipCompleted.destination)
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
describe('Multi-container booking (32 containers)', () => {
|
|
89
|
+
it('should infer route correctly for large booking', () => {
|
|
90
|
+
const events = parseDcsaEvents(fixtures.multiContainer.events, 'MSC')
|
|
91
|
+
const result = inferRouteFromEvents(events)
|
|
92
|
+
|
|
93
|
+
// Note: The fixture metadata says CNYTN but actual events show CNDLC (Dalian)
|
|
94
|
+
// The inference correctly identifies the actual port of loading from events
|
|
95
|
+
expect(result.originUnlocode).toBe('CNDLC')
|
|
96
|
+
expect(result.destinationUnlocode).toBe(fixtures.multiContainer.destination)
|
|
97
|
+
expect(result.confidence.origin).toBe('high')
|
|
98
|
+
expect(result.confidence.destination).toBe('high')
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
describe('Pre-departure tracking with only planned events', () => {
|
|
103
|
+
it('should infer origin from PLN DEPA when no actual events exist', () => {
|
|
104
|
+
// Shipment not yet departed - only planned events
|
|
105
|
+
const events = [
|
|
106
|
+
{
|
|
107
|
+
source: 'dcsa' as const,
|
|
108
|
+
sourceEventId: '1',
|
|
109
|
+
eventType: 'TRANSPORT' as const,
|
|
110
|
+
eventCode: 'DEPA',
|
|
111
|
+
eventClassifierCode: 'PLN' as const,
|
|
112
|
+
eventDateTime: new Date('2026-04-01T00:00:00Z'),
|
|
113
|
+
locationUnlocode: 'CNSHA',
|
|
114
|
+
locationName: 'SHANGHAI',
|
|
115
|
+
modeOfTransport: 'VESSEL' as const,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
source: 'dcsa' as const,
|
|
119
|
+
sourceEventId: '2',
|
|
120
|
+
eventType: 'TRANSPORT' as const,
|
|
121
|
+
eventCode: 'ARRI',
|
|
122
|
+
eventClassifierCode: 'PLN' as const,
|
|
123
|
+
eventDateTime: new Date('2026-04-15T00:00:00Z'),
|
|
124
|
+
locationUnlocode: 'SGSIN',
|
|
125
|
+
locationName: 'SINGAPORE',
|
|
126
|
+
modeOfTransport: 'VESSEL' as const,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
source: 'dcsa' as const,
|
|
130
|
+
sourceEventId: '3',
|
|
131
|
+
eventType: 'TRANSPORT' as const,
|
|
132
|
+
eventCode: 'ARRI',
|
|
133
|
+
eventClassifierCode: 'PLN' as const,
|
|
134
|
+
eventDateTime: new Date('2026-05-01T00:00:00Z'),
|
|
135
|
+
locationUnlocode: 'NLRTM',
|
|
136
|
+
locationName: 'ROTTERDAM',
|
|
137
|
+
modeOfTransport: 'VESSEL' as const,
|
|
138
|
+
},
|
|
139
|
+
]
|
|
140
|
+
|
|
141
|
+
const result = inferRouteFromEvents(events)
|
|
142
|
+
|
|
143
|
+
// Origin should be inferred from PLN DEPA
|
|
144
|
+
expect(result.originUnlocode).toBe('CNSHA')
|
|
145
|
+
expect(result.confidence.origin).toBe('medium') // Lower confidence for planned
|
|
146
|
+
// Destination should be last PLN ARRI
|
|
147
|
+
expect(result.destinationUnlocode).toBe('NLRTM')
|
|
148
|
+
expect(result.confidence.destination).toBe('high')
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
it('should infer origin from EST DEPA when no actual events exist', () => {
|
|
152
|
+
const events = [
|
|
153
|
+
{
|
|
154
|
+
source: 'dcsa' as const,
|
|
155
|
+
sourceEventId: '1',
|
|
156
|
+
eventType: 'TRANSPORT' as const,
|
|
157
|
+
eventCode: 'DEPA',
|
|
158
|
+
eventClassifierCode: 'EST' as const,
|
|
159
|
+
eventDateTime: new Date('2026-04-01T00:00:00Z'),
|
|
160
|
+
locationUnlocode: 'JPYOK',
|
|
161
|
+
locationName: 'YOKOHAMA',
|
|
162
|
+
modeOfTransport: 'VESSEL' as const,
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
source: 'dcsa' as const,
|
|
166
|
+
sourceEventId: '2',
|
|
167
|
+
eventType: 'TRANSPORT' as const,
|
|
168
|
+
eventCode: 'ARRI',
|
|
169
|
+
eventClassifierCode: 'EST' as const,
|
|
170
|
+
eventDateTime: new Date('2026-04-20T00:00:00Z'),
|
|
171
|
+
locationUnlocode: 'USLAX',
|
|
172
|
+
locationName: 'LOS ANGELES',
|
|
173
|
+
modeOfTransport: 'VESSEL' as const,
|
|
174
|
+
},
|
|
175
|
+
]
|
|
176
|
+
|
|
177
|
+
const result = inferRouteFromEvents(events)
|
|
178
|
+
|
|
179
|
+
expect(result.originUnlocode).toBe('JPYOK')
|
|
180
|
+
expect(result.confidence.origin).toBe('medium')
|
|
181
|
+
expect(result.destinationUnlocode).toBe('USLAX')
|
|
182
|
+
expect(result.confidence.destination).toBe('high')
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
it('should prefer ACT events over PLN events for origin', () => {
|
|
186
|
+
// Mix of actual and planned events - actual should take priority
|
|
187
|
+
const events = [
|
|
188
|
+
{
|
|
189
|
+
source: 'dcsa' as const,
|
|
190
|
+
sourceEventId: '1',
|
|
191
|
+
eventType: 'TRANSPORT' as const,
|
|
192
|
+
eventCode: 'DEPA',
|
|
193
|
+
eventClassifierCode: 'PLN' as const,
|
|
194
|
+
eventDateTime: new Date('2026-03-01T00:00:00Z'),
|
|
195
|
+
locationUnlocode: 'CNSHA',
|
|
196
|
+
locationName: 'SHANGHAI',
|
|
197
|
+
modeOfTransport: 'VESSEL' as const,
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
source: 'dcsa' as const,
|
|
201
|
+
sourceEventId: '2',
|
|
202
|
+
eventType: 'TRANSPORT' as const,
|
|
203
|
+
eventCode: 'DEPA',
|
|
204
|
+
eventClassifierCode: 'ACT' as const,
|
|
205
|
+
eventDateTime: new Date('2026-03-02T00:00:00Z'),
|
|
206
|
+
locationUnlocode: 'CNSHA',
|
|
207
|
+
locationName: 'SHANGHAI',
|
|
208
|
+
modeOfTransport: 'VESSEL' as const,
|
|
209
|
+
carrierExportVoyageNumber: '100E',
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
source: 'dcsa' as const,
|
|
213
|
+
sourceEventId: '3',
|
|
214
|
+
eventType: 'TRANSPORT' as const,
|
|
215
|
+
eventCode: 'ARRI',
|
|
216
|
+
eventClassifierCode: 'PLN' as const,
|
|
217
|
+
eventDateTime: new Date('2026-03-20T00:00:00Z'),
|
|
218
|
+
locationUnlocode: 'NLRTM',
|
|
219
|
+
locationName: 'ROTTERDAM',
|
|
220
|
+
modeOfTransport: 'VESSEL' as const,
|
|
221
|
+
},
|
|
222
|
+
]
|
|
223
|
+
|
|
224
|
+
const result = inferRouteFromEvents(events)
|
|
225
|
+
|
|
226
|
+
// Should pick ACT DEPA (high confidence) over PLN DEPA (medium confidence)
|
|
227
|
+
expect(result.originUnlocode).toBe('CNSHA')
|
|
228
|
+
expect(result.confidence.origin).toBe('high') // High because ACT event was used
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
it('should infer origin from PLN LOAD when no departure events exist', () => {
|
|
232
|
+
const events = [
|
|
233
|
+
{
|
|
234
|
+
source: 'dcsa' as const,
|
|
235
|
+
sourceEventId: '1',
|
|
236
|
+
eventType: 'EQUIPMENT' as const,
|
|
237
|
+
eventCode: 'LOAD',
|
|
238
|
+
eventClassifierCode: 'PLN' as const,
|
|
239
|
+
eventDateTime: new Date('2026-04-01T00:00:00Z'),
|
|
240
|
+
locationUnlocode: 'KRPUS',
|
|
241
|
+
locationName: 'BUSAN',
|
|
242
|
+
modeOfTransport: 'VESSEL' as const,
|
|
243
|
+
equipmentReference: 'TEMU1234567',
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
source: 'dcsa' as const,
|
|
247
|
+
sourceEventId: '2',
|
|
248
|
+
eventType: 'EQUIPMENT' as const,
|
|
249
|
+
eventCode: 'DISC',
|
|
250
|
+
eventClassifierCode: 'PLN' as const,
|
|
251
|
+
eventDateTime: new Date('2026-04-20T00:00:00Z'),
|
|
252
|
+
locationUnlocode: 'USOAK',
|
|
253
|
+
locationName: 'OAKLAND',
|
|
254
|
+
modeOfTransport: 'VESSEL' as const,
|
|
255
|
+
equipmentReference: 'TEMU1234567',
|
|
256
|
+
},
|
|
257
|
+
]
|
|
258
|
+
|
|
259
|
+
const result = inferRouteFromEvents(events)
|
|
260
|
+
|
|
261
|
+
expect(result.originUnlocode).toBe('KRPUS')
|
|
262
|
+
expect(result.confidence.origin).toBe('medium')
|
|
263
|
+
})
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
describe('Transshipment with EST ARRI at intermediate port and PLN ARRI at final destination', () => {
|
|
267
|
+
it('should pick LAST arrival event as destination (not first EST ARRI)', () => {
|
|
268
|
+
// Simulate a voyage: INNSA -> DEWVN (transship) -> PLGDY (final)
|
|
269
|
+
// with EST ARRI at DEWVN and PLN ARRI at PLGDY
|
|
270
|
+
const events = [
|
|
271
|
+
{
|
|
272
|
+
source: 'dcsa' as const,
|
|
273
|
+
sourceEventId: '1',
|
|
274
|
+
eventType: 'TRANSPORT' as const,
|
|
275
|
+
eventCode: 'DEPA',
|
|
276
|
+
eventClassifierCode: 'ACT' as const,
|
|
277
|
+
eventDateTime: new Date('2026-02-05T09:01:00Z'),
|
|
278
|
+
locationUnlocode: 'INNSA',
|
|
279
|
+
locationName: 'NHAVA SHEVA',
|
|
280
|
+
modeOfTransport: 'VESSEL' as const,
|
|
281
|
+
carrierExportVoyageNumber: '123E',
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
source: 'dcsa' as const,
|
|
285
|
+
sourceEventId: '2',
|
|
286
|
+
eventType: 'TRANSPORT' as const,
|
|
287
|
+
eventCode: 'ARRI',
|
|
288
|
+
eventClassifierCode: 'EST' as const,
|
|
289
|
+
eventDateTime: new Date('2026-03-15T21:00:00Z'),
|
|
290
|
+
locationUnlocode: 'DEWVN',
|
|
291
|
+
locationName: 'WILHELMSHAVEN',
|
|
292
|
+
modeOfTransport: 'VESSEL' as const,
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
source: 'dcsa' as const,
|
|
296
|
+
sourceEventId: '3',
|
|
297
|
+
eventType: 'TRANSPORT' as const,
|
|
298
|
+
eventCode: 'DEPA',
|
|
299
|
+
eventClassifierCode: 'PLN' as const,
|
|
300
|
+
eventDateTime: new Date('2026-03-27T13:00:00Z'),
|
|
301
|
+
locationUnlocode: 'DEWVN',
|
|
302
|
+
locationName: 'WILHELMSHAVEN',
|
|
303
|
+
modeOfTransport: 'VESSEL' as const,
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
source: 'dcsa' as const,
|
|
307
|
+
sourceEventId: '4',
|
|
308
|
+
eventType: 'TRANSPORT' as const,
|
|
309
|
+
eventCode: 'ARRI',
|
|
310
|
+
eventClassifierCode: 'PLN' as const,
|
|
311
|
+
eventDateTime: new Date('2026-03-30T04:00:00Z'),
|
|
312
|
+
locationUnlocode: 'PLGDY',
|
|
313
|
+
locationName: 'GDYNIA',
|
|
314
|
+
modeOfTransport: 'VESSEL' as const,
|
|
315
|
+
},
|
|
316
|
+
]
|
|
317
|
+
|
|
318
|
+
const result = inferRouteFromEvents(events)
|
|
319
|
+
|
|
320
|
+
// Should pick PLGDY (last arrival) not DEWVN (first EST ARRI)
|
|
321
|
+
expect(result.destinationUnlocode).toBe('PLGDY')
|
|
322
|
+
expect(result.confidence.destination).toBe('high')
|
|
323
|
+
expect(result.originUnlocode).toBe('INNSA')
|
|
324
|
+
expect(result.confidence.origin).toBe('high')
|
|
325
|
+
})
|
|
326
|
+
|
|
327
|
+
it('should pick last EST ARRI when multiple EST arrivals exist', () => {
|
|
328
|
+
// Multiple EST ARRI events - should pick the last one chronologically
|
|
329
|
+
const events = [
|
|
330
|
+
{
|
|
331
|
+
source: 'dcsa' as const,
|
|
332
|
+
sourceEventId: '1',
|
|
333
|
+
eventType: 'TRANSPORT' as const,
|
|
334
|
+
eventCode: 'DEPA',
|
|
335
|
+
eventClassifierCode: 'ACT' as const,
|
|
336
|
+
eventDateTime: new Date('2026-02-01T00:00:00Z'),
|
|
337
|
+
locationUnlocode: 'CNSHA',
|
|
338
|
+
locationName: 'SHANGHAI',
|
|
339
|
+
modeOfTransport: 'VESSEL' as const,
|
|
340
|
+
carrierExportVoyageNumber: '100E',
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
source: 'dcsa' as const,
|
|
344
|
+
sourceEventId: '2',
|
|
345
|
+
eventType: 'TRANSPORT' as const,
|
|
346
|
+
eventCode: 'ARRI',
|
|
347
|
+
eventClassifierCode: 'EST' as const,
|
|
348
|
+
eventDateTime: new Date('2026-02-15T00:00:00Z'),
|
|
349
|
+
locationUnlocode: 'SGSIN',
|
|
350
|
+
locationName: 'SINGAPORE',
|
|
351
|
+
modeOfTransport: 'VESSEL' as const,
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
source: 'dcsa' as const,
|
|
355
|
+
sourceEventId: '3',
|
|
356
|
+
eventType: 'TRANSPORT' as const,
|
|
357
|
+
eventCode: 'ARRI',
|
|
358
|
+
eventClassifierCode: 'EST' as const,
|
|
359
|
+
eventDateTime: new Date('2026-03-01T00:00:00Z'),
|
|
360
|
+
locationUnlocode: 'NLRTM',
|
|
361
|
+
locationName: 'ROTTERDAM',
|
|
362
|
+
modeOfTransport: 'VESSEL' as const,
|
|
363
|
+
},
|
|
364
|
+
]
|
|
365
|
+
|
|
366
|
+
const result = inferRouteFromEvents(events)
|
|
367
|
+
|
|
368
|
+
// Should pick NLRTM (last EST ARRI) not SGSIN (first EST ARRI)
|
|
369
|
+
expect(result.destinationUnlocode).toBe('NLRTM')
|
|
370
|
+
expect(result.confidence.destination).toBe('high')
|
|
371
|
+
})
|
|
372
|
+
})
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
describe('isValidUnlocode', () => {
|
|
376
|
+
it('should return true for valid UN/LOCODEs', () => {
|
|
377
|
+
expect(isValidUnlocode('CNYTN')).toBe(true)
|
|
378
|
+
expect(isValidUnlocode('PLGDN')).toBe(true)
|
|
379
|
+
expect(isValidUnlocode('BEANR')).toBe(true)
|
|
380
|
+
expect(isValidUnlocode('USNYC')).toBe(true)
|
|
381
|
+
expect(isValidUnlocode('SGSIN')).toBe(true)
|
|
382
|
+
expect(isValidUnlocode('DE123')).toBe(true) // 3 digits allowed
|
|
383
|
+
expect(isValidUnlocode('USX1Y')).toBe(true) // mixed alphanumeric
|
|
384
|
+
})
|
|
385
|
+
|
|
386
|
+
it('should return false for invalid UN/LOCODEs', () => {
|
|
387
|
+
expect(isValidUnlocode('')).toBe(false)
|
|
388
|
+
expect(isValidUnlocode(null)).toBe(false)
|
|
389
|
+
expect(isValidUnlocode(undefined)).toBe(false)
|
|
390
|
+
expect(isValidUnlocode('CN')).toBe(false) // too short
|
|
391
|
+
expect(isValidUnlocode('CNYTNX')).toBe(false) // too long
|
|
392
|
+
expect(isValidUnlocode('12YTN')).toBe(false) // starts with digits
|
|
393
|
+
expect(isValidUnlocode('C1YTN')).toBe(false) // second char is digit
|
|
394
|
+
expect(isValidUnlocode('cn-ytn')).toBe(false) // invalid chars
|
|
395
|
+
})
|
|
396
|
+
|
|
397
|
+
it('should handle lowercase by converting to uppercase', () => {
|
|
398
|
+
expect(isValidUnlocode('cnytn')).toBe(true)
|
|
399
|
+
expect(isValidUnlocode('PlGdN')).toBe(true)
|
|
400
|
+
})
|
|
401
|
+
})
|
|
402
|
+
})
|