@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,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the vessel-api client — focused on fetchPois (the POI map feature).
|
|
3
|
+
*
|
|
4
|
+
* Covers query-param building, 404/error handling, and deduping by code
|
|
5
|
+
* (the live endpoint can return the same POI code more than once).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
9
|
+
import { fetchPois, type PoiInfo } from '../vessel-api'
|
|
10
|
+
|
|
11
|
+
// ─── Helpers ─────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
function makePoi(overrides: Partial<PoiInfo> & { code: string }): PoiInfo {
|
|
14
|
+
return {
|
|
15
|
+
code: overrides.code,
|
|
16
|
+
locode: overrides.locode ?? null as unknown as string,
|
|
17
|
+
type: overrides.type ?? 'WAYPOINT',
|
|
18
|
+
center: overrides.center ?? { lat: 0, lng: 0 },
|
|
19
|
+
radiusMeters: overrides.radiusMeters ?? 5000,
|
|
20
|
+
portName: overrides.portName ?? null,
|
|
21
|
+
terminalName: overrides.terminalName ?? null,
|
|
22
|
+
city: overrides.city ?? null,
|
|
23
|
+
country: overrides.country ?? null,
|
|
24
|
+
regionNamePl: overrides.regionNamePl ?? null,
|
|
25
|
+
regionNameEn: overrides.regionNameEn ?? null,
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function mockFetchOnce(body: unknown, init?: { ok?: boolean; status?: number }) {
|
|
30
|
+
const ok = init?.ok ?? true
|
|
31
|
+
const status = init?.status ?? 200
|
|
32
|
+
const fetchMock = vi.fn().mockResolvedValue({
|
|
33
|
+
ok,
|
|
34
|
+
status,
|
|
35
|
+
json: async () => body,
|
|
36
|
+
})
|
|
37
|
+
// @ts-expect-error - assigning a partial fetch mock for tests
|
|
38
|
+
global.fetch = fetchMock
|
|
39
|
+
return fetchMock
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function lastUrl(fetchMock: ReturnType<typeof vi.fn>): string {
|
|
43
|
+
return String(fetchMock.mock.calls[0][0])
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ─── Tests ───────────────────────────────────────────────────
|
|
47
|
+
|
|
48
|
+
describe('fetchPois', () => {
|
|
49
|
+
const originalFetch = global.fetch
|
|
50
|
+
const originalBaseUrl = process.env.NEXT_PUBLIC_VESSEL_API_URL
|
|
51
|
+
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
vi.restoreAllMocks()
|
|
54
|
+
process.env.NEXT_PUBLIC_VESSEL_API_URL = 'https://vessel.example.test'
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
afterEach(() => {
|
|
58
|
+
global.fetch = originalFetch
|
|
59
|
+
if (originalBaseUrl === undefined) delete process.env.NEXT_PUBLIC_VESSEL_API_URL
|
|
60
|
+
else process.env.NEXT_PUBLIC_VESSEL_API_URL = originalBaseUrl
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('dedupes POIs that share a code (live endpoint returns duplicates)', async () => {
|
|
64
|
+
const fetchMock = mockFetchOnce({
|
|
65
|
+
pois: [
|
|
66
|
+
makePoi({ code: 'N055E012-01920', regionNameEn: 'Baltic Sea' }),
|
|
67
|
+
makePoi({ code: 'N055E012-01920', regionNameEn: 'Baltic Sea (dup)' }),
|
|
68
|
+
makePoi({ code: 'PLGDY-T1', type: 'TERMINAL' }),
|
|
69
|
+
],
|
|
70
|
+
count: 3,
|
|
71
|
+
limit: 1000,
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
const pois = await fetchPois()
|
|
75
|
+
|
|
76
|
+
expect(fetchMock).toHaveBeenCalledTimes(1)
|
|
77
|
+
expect(pois).toHaveLength(2)
|
|
78
|
+
expect(pois.map((p) => p.code)).toEqual(['N055E012-01920', 'PLGDY-T1'])
|
|
79
|
+
// First occurrence wins
|
|
80
|
+
expect(pois[0].regionNameEn).toBe('Baltic Sea')
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('builds the bounding-box, type and limit query params', async () => {
|
|
84
|
+
const fetchMock = mockFetchOnce({ pois: [], count: 0, limit: 500 })
|
|
85
|
+
|
|
86
|
+
await fetchPois(
|
|
87
|
+
{ north: 55.5, south: 53, east: 20, west: 12 },
|
|
88
|
+
{ type: 'TERMINAL', limit: 500 }
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
const url = lastUrl(fetchMock)
|
|
92
|
+
expect(url).toContain('/poi?')
|
|
93
|
+
expect(url).toContain('north=55.5')
|
|
94
|
+
expect(url).toContain('south=53')
|
|
95
|
+
expect(url).toContain('east=20')
|
|
96
|
+
expect(url).toContain('west=12')
|
|
97
|
+
expect(url).toContain('type=TERMINAL')
|
|
98
|
+
expect(url).toContain('limit=500')
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('omits bounds/type/limit params when not provided', async () => {
|
|
102
|
+
const fetchMock = mockFetchOnce({ pois: [], count: 0, limit: 5000 })
|
|
103
|
+
|
|
104
|
+
await fetchPois()
|
|
105
|
+
|
|
106
|
+
const url = lastUrl(fetchMock)
|
|
107
|
+
expect(url).toMatch(/\/poi$/)
|
|
108
|
+
expect(url).not.toContain('?')
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it('returns an empty array on 404', async () => {
|
|
112
|
+
mockFetchOnce({}, { ok: false, status: 404 })
|
|
113
|
+
await expect(fetchPois()).resolves.toEqual([])
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('throws with the API error message on a non-ok response', async () => {
|
|
117
|
+
mockFetchOnce({ error: 'Invalid bounding box values' }, { ok: false, status: 400 })
|
|
118
|
+
await expect(fetchPois()).rejects.toThrow('Invalid bounding box values')
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
it('returns an empty array when the response has no pois field', async () => {
|
|
122
|
+
mockFetchOnce({ count: 0, limit: 5000 })
|
|
123
|
+
await expect(fetchPois()).resolves.toEqual([])
|
|
124
|
+
})
|
|
125
|
+
})
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { findLatestVesselInfo } from '../vessel-extraction'
|
|
2
|
+
|
|
3
|
+
describe('findLatestVesselInfo', () => {
|
|
4
|
+
it('should return null for empty array', () => {
|
|
5
|
+
expect(findLatestVesselInfo([])).toBeNull()
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
it('should return null when no events have vessel info', () => {
|
|
9
|
+
const events = [
|
|
10
|
+
{ vesselName: null, vesselImo: null, voyageNumber: null },
|
|
11
|
+
{ vesselName: undefined, vesselImo: undefined, voyageNumber: undefined },
|
|
12
|
+
]
|
|
13
|
+
expect(findLatestVesselInfo(events)).toBeNull()
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('should return vessel info from the latest event with data', () => {
|
|
17
|
+
const events = [
|
|
18
|
+
{ vesselName: 'VESSEL A', vesselImo: '1234567', voyageNumber: '001N' },
|
|
19
|
+
{ vesselName: 'VESSEL B', vesselImo: '7654321', voyageNumber: '002N' },
|
|
20
|
+
{ vesselName: null, vesselImo: null, voyageNumber: null }, // Gate operation
|
|
21
|
+
]
|
|
22
|
+
expect(findLatestVesselInfo(events)).toEqual({
|
|
23
|
+
vesselName: 'VESSEL B',
|
|
24
|
+
vesselImo: '7654321',
|
|
25
|
+
voyageNumber: '002N',
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('should find vessel by vesselName only', () => {
|
|
30
|
+
const events = [
|
|
31
|
+
{ vesselName: 'VESSEL A', vesselImo: null, voyageNumber: null },
|
|
32
|
+
{ vesselName: null, vesselImo: null, voyageNumber: null },
|
|
33
|
+
]
|
|
34
|
+
expect(findLatestVesselInfo(events)).toEqual({
|
|
35
|
+
vesselName: 'VESSEL A',
|
|
36
|
+
vesselImo: null,
|
|
37
|
+
voyageNumber: null,
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('should find vessel by vesselImo only', () => {
|
|
42
|
+
const events = [
|
|
43
|
+
{ vesselName: null, vesselImo: '1234567', voyageNumber: null },
|
|
44
|
+
{ vesselName: null, vesselImo: null, voyageNumber: null },
|
|
45
|
+
]
|
|
46
|
+
expect(findLatestVesselInfo(events)).toEqual({
|
|
47
|
+
vesselName: null,
|
|
48
|
+
vesselImo: '1234567',
|
|
49
|
+
voyageNumber: null,
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('should find vessel by voyageNumber only', () => {
|
|
54
|
+
const events = [
|
|
55
|
+
{ vesselName: null, vesselImo: null, voyageNumber: '001N' },
|
|
56
|
+
{ vesselName: null, vesselImo: null, voyageNumber: null },
|
|
57
|
+
]
|
|
58
|
+
expect(findLatestVesselInfo(events)).toEqual({
|
|
59
|
+
vesselName: null,
|
|
60
|
+
vesselImo: null,
|
|
61
|
+
voyageNumber: '001N',
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('should handle transshipment (multiple vessels)', () => {
|
|
66
|
+
const events = [
|
|
67
|
+
{ vesselName: 'EXAMPLE VESSEL 07', vesselImo: '8000007', voyageNumber: '101N' },
|
|
68
|
+
{ vesselName: 'EXAMPLE VESSEL 08', vesselImo: '8000008', voyageNumber: '102N' },
|
|
69
|
+
{ vesselName: 'EXAMPLE VESSEL 06', vesselImo: '8000006', voyageNumber: '603N' },
|
|
70
|
+
{ vesselName: null, vesselImo: null, voyageNumber: null }, // GTOT
|
|
71
|
+
{ vesselName: null, vesselImo: null, voyageNumber: null }, // GTIN
|
|
72
|
+
]
|
|
73
|
+
// Should return the last vessel (EXAMPLE VESSEL 06)
|
|
74
|
+
expect(findLatestVesselInfo(events)).toEqual({
|
|
75
|
+
vesselName: 'EXAMPLE VESSEL 06',
|
|
76
|
+
vesselImo: '8000006',
|
|
77
|
+
voyageNumber: '603N',
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it('should handle partial vessel info', () => {
|
|
82
|
+
const events = [
|
|
83
|
+
{ vesselName: 'VESSEL A', vesselImo: '1234567', voyageNumber: '001N' },
|
|
84
|
+
{ vesselName: 'VESSEL B', vesselImo: null, voyageNumber: null }, // Only name
|
|
85
|
+
{ vesselName: null, vesselImo: null, voyageNumber: null },
|
|
86
|
+
]
|
|
87
|
+
// Should return VESSEL B with partial info
|
|
88
|
+
expect(findLatestVesselInfo(events)).toEqual({
|
|
89
|
+
vesselName: 'VESSEL B',
|
|
90
|
+
vesselImo: null,
|
|
91
|
+
voyageNumber: null,
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('should return first event vessel info when only one event has data', () => {
|
|
96
|
+
const events = [
|
|
97
|
+
{ vesselName: 'FIRST VESSEL', vesselImo: '1111111', voyageNumber: '001N' },
|
|
98
|
+
{ vesselName: null, vesselImo: null, voyageNumber: null },
|
|
99
|
+
{ vesselName: null, vesselImo: null, voyageNumber: null },
|
|
100
|
+
{ vesselName: null, vesselImo: null, voyageNumber: null },
|
|
101
|
+
]
|
|
102
|
+
expect(findLatestVesselInfo(events)).toEqual({
|
|
103
|
+
vesselName: 'FIRST VESSEL',
|
|
104
|
+
vesselImo: '1111111',
|
|
105
|
+
voyageNumber: '001N',
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
})
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { CarrierAdapter, CarrierFetchResult, CarrierAdapterTestResult } from '../carrier-adapter'
|
|
2
|
+
import { extractDocumentReferences } from '../carrier-adapter'
|
|
3
|
+
import type { TrackingReferenceType } from '../../data/entities'
|
|
4
|
+
import { buildDcsaQueryParams } from '../dcsa-params'
|
|
5
|
+
import { parseDcsaEvents } from '../dcsa-event-parser'
|
|
6
|
+
import { withCarrierApiSpan } from '../logger'
|
|
7
|
+
|
|
8
|
+
const EVENTS_URL = 'https://apis.cma-cgm.net/operation/trackandtrace/v1/events'
|
|
9
|
+
|
|
10
|
+
type CmaCgmAuthConfig = {
|
|
11
|
+
api_key: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function getAuth(authConfig: Record<string, unknown> | null | undefined): CmaCgmAuthConfig {
|
|
15
|
+
const apiKey = authConfig?.api_key as string | undefined
|
|
16
|
+
if (!apiKey) {
|
|
17
|
+
throw new Error('CMA CGM authConfig requires api_key')
|
|
18
|
+
}
|
|
19
|
+
return { api_key: apiKey }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class CmaCgmAdapter implements CarrierAdapter {
|
|
23
|
+
readonly carrierCode = 'cma-cgm'
|
|
24
|
+
readonly supportedReferenceTypes: TrackingReferenceType[] = ['container', 'booking', 'bol']
|
|
25
|
+
|
|
26
|
+
async fetchEvents(input: {
|
|
27
|
+
referenceType: TrackingReferenceType
|
|
28
|
+
referenceValue: string
|
|
29
|
+
apiEndpoint?: string | null
|
|
30
|
+
authConfig?: Record<string, unknown> | null
|
|
31
|
+
}): Promise<CarrierFetchResult> {
|
|
32
|
+
return withCarrierApiSpan(
|
|
33
|
+
{
|
|
34
|
+
carrierCode: this.carrierCode,
|
|
35
|
+
operation: 'fetchEvents',
|
|
36
|
+
referenceType: input.referenceType,
|
|
37
|
+
referenceValue: input.referenceValue,
|
|
38
|
+
},
|
|
39
|
+
async (span) => {
|
|
40
|
+
const auth = getAuth(input.authConfig)
|
|
41
|
+
const params = buildDcsaQueryParams(input.referenceValue, input.referenceType)
|
|
42
|
+
const url = `${input.apiEndpoint || EVENTS_URL}?${params}`
|
|
43
|
+
|
|
44
|
+
const response = await fetch(url, {
|
|
45
|
+
headers: {
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
'keyId': auth.api_key,
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
span.setAttribute('http.status_code', response.status)
|
|
52
|
+
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
const errorText = await response.text().catch(() => 'unknown')
|
|
55
|
+
throw new Error(`CMA CGM API error (${response.status}): ${errorText}`)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const data = await response.json()
|
|
59
|
+
const events = parseDcsaEvents(data, 'CMA CGM')
|
|
60
|
+
const { bookingNumber, bolNumber } = extractDocumentReferences(events)
|
|
61
|
+
|
|
62
|
+
span.setAttribute('events.count', events.length)
|
|
63
|
+
return { events, bookingNumber, bolNumber }
|
|
64
|
+
},
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async testConnection(input: {
|
|
69
|
+
apiEndpoint?: string | null
|
|
70
|
+
authConfig?: Record<string, unknown> | null
|
|
71
|
+
}): Promise<CarrierAdapterTestResult> {
|
|
72
|
+
const start = Date.now()
|
|
73
|
+
try {
|
|
74
|
+
const auth = getAuth(input.authConfig)
|
|
75
|
+
if (!auth.api_key) {
|
|
76
|
+
throw new Error('Missing API key')
|
|
77
|
+
}
|
|
78
|
+
return { success: true, message: 'CMA CGM credentials validated', latencyMs: Date.now() - start }
|
|
79
|
+
} catch (error) {
|
|
80
|
+
const message = error instanceof Error ? error.message : 'Unknown error'
|
|
81
|
+
return { success: false, message: `CMA CGM connection failed: ${message}`, latencyMs: Date.now() - start }
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
export type CoscoShipmentData = {
|
|
2
|
+
shipmentContent?: string
|
|
3
|
+
containerDetail?: CoscoContainer[] | CoscoContainer
|
|
4
|
+
queryCriteria?: {
|
|
5
|
+
bookingNumber?: string
|
|
6
|
+
}
|
|
7
|
+
billOfLadingNumber?: string[]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type CoscoContainer = {
|
|
11
|
+
containerNumber?: {
|
|
12
|
+
containerNumber: string
|
|
13
|
+
}
|
|
14
|
+
event?: CoscoEvent[]
|
|
15
|
+
externalReference?: CoscoExternalReference[]
|
|
16
|
+
route?: {
|
|
17
|
+
shipmentLeg?: CoscoShipmentLeg[]
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type CoscoEvent = {
|
|
22
|
+
CSEvent?: {
|
|
23
|
+
CSEventCode: string
|
|
24
|
+
}
|
|
25
|
+
eventDescription?: string
|
|
26
|
+
carrEventCode?: string
|
|
27
|
+
eventDT?: CoscoDateTime
|
|
28
|
+
eventReceivedDT?: CoscoDateTime
|
|
29
|
+
location?: CoscoLocation
|
|
30
|
+
mode?: string
|
|
31
|
+
containerNumber?: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type CoscoExternalReference = {
|
|
35
|
+
CSReferenceType?: {
|
|
36
|
+
value: string
|
|
37
|
+
}
|
|
38
|
+
referenceNumber: string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type CoscoDateTime = {
|
|
42
|
+
GMT?: {
|
|
43
|
+
text: string
|
|
44
|
+
}
|
|
45
|
+
locDT?: {
|
|
46
|
+
text?: string
|
|
47
|
+
_value?: {
|
|
48
|
+
time: string
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type CoscoDateTimeIndicator = {
|
|
54
|
+
indicator?: {
|
|
55
|
+
value: 'E' | 'A'
|
|
56
|
+
}
|
|
57
|
+
GMT?: {
|
|
58
|
+
text: string
|
|
59
|
+
}
|
|
60
|
+
locDT?: {
|
|
61
|
+
text: string
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type CoscoLocation = {
|
|
66
|
+
locationName?: string
|
|
67
|
+
cityDetails?: CoscoCityDetails
|
|
68
|
+
facility?: CoscoFacility
|
|
69
|
+
CSStandardCity?: {
|
|
70
|
+
CSCountryCode?: string
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type CoscoCityDetails = {
|
|
75
|
+
city?: string
|
|
76
|
+
country?: string
|
|
77
|
+
state?: string
|
|
78
|
+
portName?: string
|
|
79
|
+
locationCode?: {
|
|
80
|
+
UNLocationCode: string
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export type CoscoFacility = {
|
|
85
|
+
facilityCode?: string
|
|
86
|
+
facilityName?: string
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type CoscoShipmentLeg = {
|
|
90
|
+
legSeq?: number
|
|
91
|
+
POL?: CoscoPort
|
|
92
|
+
POD?: CoscoPort
|
|
93
|
+
SVVD?: CoscoSVVD
|
|
94
|
+
arrivalDT?: CoscoDateTimeIndicator[]
|
|
95
|
+
departureDT?: CoscoDateTimeIndicator[]
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export type CoscoPort = {
|
|
99
|
+
port?: {
|
|
100
|
+
portName?: string
|
|
101
|
+
city?: string
|
|
102
|
+
country?: string
|
|
103
|
+
state?: string
|
|
104
|
+
locationCode?: {
|
|
105
|
+
UNLocationCode: string
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
facility?: CoscoFacility
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export type CoscoSVVD = {
|
|
112
|
+
loading?: CoscoVesselInfo
|
|
113
|
+
discharge?: CoscoVesselInfo
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export type CoscoVesselInfo = {
|
|
117
|
+
vesselName: string
|
|
118
|
+
lloydsNumber?: string
|
|
119
|
+
callSign?: string
|
|
120
|
+
vessel?: string
|
|
121
|
+
voyage?: string
|
|
122
|
+
service?: string
|
|
123
|
+
direction?: string
|
|
124
|
+
callNumber?: string
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export type ExtractedVesselData = {
|
|
128
|
+
vesselName: string
|
|
129
|
+
vesselIMONumber?: string
|
|
130
|
+
vesselCallSign?: string
|
|
131
|
+
vesselCode?: string
|
|
132
|
+
voyage?: string
|
|
133
|
+
service?: string
|
|
134
|
+
direction?: string
|
|
135
|
+
legType?: 'loading' | 'discharge'
|
|
136
|
+
legSequence?: number
|
|
137
|
+
pol?: string
|
|
138
|
+
pod?: string
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export type DcsaEventMapping = {
|
|
142
|
+
eventType: string
|
|
143
|
+
eventCode: string
|
|
144
|
+
eventClassification: string
|
|
145
|
+
}
|