@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,115 @@
|
|
|
1
|
+
import type { DocumentReference } from '../data/entities'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handles DCSA-compliant transport and equipment events and dispatches webhooks.
|
|
5
|
+
* These are granular events like transport.departed, equipment.loaded, etc.
|
|
6
|
+
*/
|
|
7
|
+
export const metadata = {
|
|
8
|
+
event: 'shipment_tracking.transport.*,shipment_tracking.equipment.*',
|
|
9
|
+
persistent: true,
|
|
10
|
+
id: 'shipment_tracking:dcsa-event-webhook-dispatch',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type DcsaEventPayload = {
|
|
14
|
+
id: string
|
|
15
|
+
shipmentId: string
|
|
16
|
+
tenantId: string
|
|
17
|
+
organizationId: string
|
|
18
|
+
|
|
19
|
+
// Core event fields
|
|
20
|
+
eventId: string
|
|
21
|
+
eventType: string
|
|
22
|
+
eventCode: string
|
|
23
|
+
eventClassifierCode?: string | null
|
|
24
|
+
eventDateTime?: string | null
|
|
25
|
+
description?: string | null
|
|
26
|
+
|
|
27
|
+
// Equipment fields
|
|
28
|
+
equipmentReference?: string | null
|
|
29
|
+
isoEquipmentCode?: string | null
|
|
30
|
+
emptyIndicatorCode?: string | null
|
|
31
|
+
isTransshipmentMove?: boolean | null
|
|
32
|
+
|
|
33
|
+
// Location fields
|
|
34
|
+
locationName?: string | null
|
|
35
|
+
locationUnlocode?: string | null
|
|
36
|
+
locationCountry?: string | null
|
|
37
|
+
facilityCode?: string | null
|
|
38
|
+
facilityTypeCode?: string | null
|
|
39
|
+
|
|
40
|
+
// Transport call fields
|
|
41
|
+
vesselName?: string | null
|
|
42
|
+
vesselImo?: string | null
|
|
43
|
+
voyageNumber?: string | null
|
|
44
|
+
carrierServiceCode?: string | null
|
|
45
|
+
modeOfTransport?: string | null
|
|
46
|
+
|
|
47
|
+
// Document references
|
|
48
|
+
relatedDocumentReferences?: DocumentReference[] | null
|
|
49
|
+
|
|
50
|
+
// Metadata
|
|
51
|
+
publisherName?: string | null
|
|
52
|
+
publisherRole?: string | null
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type ResolverContext = {
|
|
56
|
+
resolve: <T = unknown>(name: string) => T
|
|
57
|
+
eventName: string
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default async function handle(payload: DcsaEventPayload, ctx: ResolverContext) {
|
|
61
|
+
try {
|
|
62
|
+
const webhookService = ctx.resolve<any>('shipmentTrackingWebhookService')
|
|
63
|
+
|
|
64
|
+
await webhookService.dispatchEvent({
|
|
65
|
+
eventType: ctx.eventName,
|
|
66
|
+
payload: {
|
|
67
|
+
event: {
|
|
68
|
+
// IDs
|
|
69
|
+
id: payload.id,
|
|
70
|
+
shipmentId: payload.shipmentId,
|
|
71
|
+
|
|
72
|
+
// Core event fields
|
|
73
|
+
eventType: payload.eventType,
|
|
74
|
+
eventCode: payload.eventCode,
|
|
75
|
+
eventClassifierCode: payload.eventClassifierCode,
|
|
76
|
+
eventDateTime: payload.eventDateTime,
|
|
77
|
+
description: payload.description,
|
|
78
|
+
|
|
79
|
+
// Equipment fields (critical for multi-container bookings)
|
|
80
|
+
equipmentReference: payload.equipmentReference,
|
|
81
|
+
isoEquipmentCode: payload.isoEquipmentCode,
|
|
82
|
+
emptyIndicatorCode: payload.emptyIndicatorCode,
|
|
83
|
+
isTransshipmentMove: payload.isTransshipmentMove,
|
|
84
|
+
|
|
85
|
+
// Location fields
|
|
86
|
+
locationName: payload.locationName,
|
|
87
|
+
locationUnlocode: payload.locationUnlocode,
|
|
88
|
+
locationCountry: payload.locationCountry,
|
|
89
|
+
facilityCode: payload.facilityCode,
|
|
90
|
+
facilityTypeCode: payload.facilityTypeCode,
|
|
91
|
+
|
|
92
|
+
// Transport call fields
|
|
93
|
+
vesselName: payload.vesselName,
|
|
94
|
+
vesselImo: payload.vesselImo,
|
|
95
|
+
voyageNumber: payload.voyageNumber,
|
|
96
|
+
carrierServiceCode: payload.carrierServiceCode,
|
|
97
|
+
modeOfTransport: payload.modeOfTransport,
|
|
98
|
+
|
|
99
|
+
// Document references
|
|
100
|
+
relatedDocumentReferences: payload.relatedDocumentReferences,
|
|
101
|
+
|
|
102
|
+
// Metadata
|
|
103
|
+
publisherName: payload.publisherName,
|
|
104
|
+
publisherRole: payload.publisherRole,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
tenantId: payload.tenantId,
|
|
108
|
+
organizationId: payload.organizationId,
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
console.debug(`[shipment-tracking:dcsa-webhook] Dispatched ${ctx.eventName} for tracking event ${payload.id}`)
|
|
112
|
+
} catch (error) {
|
|
113
|
+
console.error(`[shipment-tracking:dcsa-webhook] Failed to dispatch ${ctx.eventName} webhook:`, error)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* POI Event Notification Subscriber
|
|
3
|
+
*
|
|
4
|
+
* Subscribes to per-tracking-job POI proximity events and creates in-app
|
|
5
|
+
* notifications for the user who created the tracking job.
|
|
6
|
+
*
|
|
7
|
+
* These events are emitted once per tracking job (BOL/Booking), not per
|
|
8
|
+
* shipment (container), so no deduplication is needed.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
12
|
+
import { resolveNotificationService } from '@open-mercato/core/modules/notifications/lib/notificationService'
|
|
13
|
+
import { buildNotificationFromType } from '@open-mercato/core/modules/notifications/lib/notificationBuilder'
|
|
14
|
+
import type { ProximityEventType } from '../lib/poi-types'
|
|
15
|
+
import { getTrackingJobCreator } from '../lib/audit-helpers'
|
|
16
|
+
import { notificationTypes } from '../notifications'
|
|
17
|
+
|
|
18
|
+
export const metadata = {
|
|
19
|
+
event: 'shipment_tracking.tracking_job.poi.*',
|
|
20
|
+
persistent: true,
|
|
21
|
+
id: 'shipment_tracking:tracking-job-poi-notification',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type TrackingJobPoiEventPayload = {
|
|
25
|
+
trackingJobId: string
|
|
26
|
+
shipmentId: string
|
|
27
|
+
trackingEventId: string
|
|
28
|
+
organizationId: string
|
|
29
|
+
tenantId: string
|
|
30
|
+
vesselName: string
|
|
31
|
+
vesselMmsi: number
|
|
32
|
+
vesselImo: string | null
|
|
33
|
+
eventType: ProximityEventType
|
|
34
|
+
poiCode: string | null
|
|
35
|
+
latitude: number
|
|
36
|
+
longitude: number
|
|
37
|
+
eventDateTime: string
|
|
38
|
+
distanceToPoiMeters: number | null
|
|
39
|
+
containerNumber?: string | null
|
|
40
|
+
bookingNumber?: string | null
|
|
41
|
+
bolNumber?: string | null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
type ResolverContext = {
|
|
45
|
+
resolve: <T = unknown>(name: string) => T
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Map POI event types to per-job notification type identifiers.
|
|
50
|
+
*/
|
|
51
|
+
function mapEventTypeToNotificationType(eventType: ProximityEventType): string {
|
|
52
|
+
const map: Record<ProximityEventType, string> = {
|
|
53
|
+
PORT_ARRIVAL: 'shipment_tracking.tracking_job.poi.port_arrival',
|
|
54
|
+
PORT_PROXIMITY_ARRIVAL: 'shipment_tracking.tracking_job.poi.port_proximity_arrival',
|
|
55
|
+
PORT_PROXIMITY_DEPARTURE: 'shipment_tracking.tracking_job.poi.port_departure',
|
|
56
|
+
TERMINAL_ARRIVAL: 'shipment_tracking.tracking_job.poi.terminal_arrival',
|
|
57
|
+
TERMINAL_PROXIMITY_ARRIVAL: 'shipment_tracking.tracking_job.poi.terminal_proximity_arrival',
|
|
58
|
+
TERMINAL_PROXIMITY_DEPARTURE: 'shipment_tracking.tracking_job.poi.terminal_departure',
|
|
59
|
+
WAYPOINT_REACHED: 'shipment_tracking.tracking_job.poi.waypoint_reached',
|
|
60
|
+
}
|
|
61
|
+
return map[eventType]
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Build a reference info string for the notification body.
|
|
66
|
+
* Shows the booking number, BOL number, or container number.
|
|
67
|
+
*
|
|
68
|
+
* Format: "Booking BOOK123" or "BOL 12345" or "Container MSCU1234567"
|
|
69
|
+
*/
|
|
70
|
+
function buildReferenceInfo(
|
|
71
|
+
bookingNumber: string | null | undefined,
|
|
72
|
+
bolNumber: string | null | undefined,
|
|
73
|
+
containerNumber: string | null | undefined
|
|
74
|
+
): string {
|
|
75
|
+
if (bookingNumber) {
|
|
76
|
+
return `Booking ${bookingNumber}`
|
|
77
|
+
}
|
|
78
|
+
if (bolNumber) {
|
|
79
|
+
return `BOL ${bolNumber}`
|
|
80
|
+
}
|
|
81
|
+
if (containerNumber) {
|
|
82
|
+
return `Container ${containerNumber}`
|
|
83
|
+
}
|
|
84
|
+
return 'Shipment'
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export default async function handle(payload: TrackingJobPoiEventPayload, ctx: ResolverContext) {
|
|
88
|
+
try {
|
|
89
|
+
const em = ctx.resolve<EntityManager>('em')
|
|
90
|
+
|
|
91
|
+
// Get the creator of the tracking job from audit logs
|
|
92
|
+
const creatorUserId = await getTrackingJobCreator(em, payload.trackingJobId, payload.tenantId)
|
|
93
|
+
|
|
94
|
+
if (!creatorUserId) {
|
|
95
|
+
console.info(
|
|
96
|
+
`[poi-notification] Skipping notification - no creator found for tracking job ${payload.trackingJobId}`
|
|
97
|
+
)
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Find the notification type definition
|
|
102
|
+
const notificationType = mapEventTypeToNotificationType(payload.eventType)
|
|
103
|
+
const typeDef = notificationTypes.find((t) => t.type === notificationType)
|
|
104
|
+
|
|
105
|
+
if (!typeDef) {
|
|
106
|
+
console.warn(`[poi-notification] No notification type found for event: ${payload.eventType}`)
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Build reference info string (e.g., "Booking BOOK123")
|
|
111
|
+
const referenceInfo = buildReferenceInfo(
|
|
112
|
+
payload.bookingNumber,
|
|
113
|
+
payload.bolNumber,
|
|
114
|
+
payload.containerNumber
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
// Build notification input
|
|
118
|
+
const notificationInput = buildNotificationFromType(typeDef, {
|
|
119
|
+
recipientUserId: creatorUserId,
|
|
120
|
+
bodyVariables: {
|
|
121
|
+
vesselName: payload.vesselName,
|
|
122
|
+
location: payload.poiCode ?? 'unknown location',
|
|
123
|
+
referenceInfo,
|
|
124
|
+
},
|
|
125
|
+
sourceEntityType: 'shipment_tracking:shipment',
|
|
126
|
+
sourceEntityId: payload.shipmentId,
|
|
127
|
+
linkHref: `/backend/shipment-tracking?shipment=${payload.shipmentId}`,
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
// Create the notification
|
|
131
|
+
const notificationService = resolveNotificationService(ctx)
|
|
132
|
+
await notificationService.create(notificationInput, {
|
|
133
|
+
tenantId: payload.tenantId,
|
|
134
|
+
organizationId: payload.organizationId ?? null,
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
console.info(
|
|
138
|
+
`[poi-notification] Created notification for tracking job ${payload.trackingJobId} ` +
|
|
139
|
+
`(event: ${payload.eventType}, recipient: ${creatorUserId}, ref: ${referenceInfo})`
|
|
140
|
+
)
|
|
141
|
+
} catch (error) {
|
|
142
|
+
console.error('[poi-notification] Failed to process POI event notification:', error)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* POI Event Webhook Dispatcher
|
|
3
|
+
*
|
|
4
|
+
* Handles POI proximity events and dispatches webhooks to registered endpoints.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ProximityEventType } from '../lib/poi-types'
|
|
8
|
+
|
|
9
|
+
export const metadata = {
|
|
10
|
+
event: 'shipment_tracking.poi.*',
|
|
11
|
+
persistent: true,
|
|
12
|
+
id: 'shipment_tracking:poi-event-webhook-dispatch',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type PoiEventPayload = {
|
|
16
|
+
shipmentId: string
|
|
17
|
+
trackingEventId: string
|
|
18
|
+
organizationId: string
|
|
19
|
+
tenantId: string
|
|
20
|
+
vesselName: string
|
|
21
|
+
vesselMmsi: number
|
|
22
|
+
vesselImo: string | null
|
|
23
|
+
eventType: ProximityEventType
|
|
24
|
+
poiCode: string | null
|
|
25
|
+
latitude: number
|
|
26
|
+
longitude: number
|
|
27
|
+
eventDateTime: string
|
|
28
|
+
distanceToPoiMeters: number | null
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type ResolverContext = {
|
|
32
|
+
resolve: <T = unknown>(name: string) => T
|
|
33
|
+
eventName: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type WebhookService = {
|
|
37
|
+
dispatchEvent: (params: {
|
|
38
|
+
eventType: string
|
|
39
|
+
payload: unknown
|
|
40
|
+
tenantId: string
|
|
41
|
+
organizationId: string
|
|
42
|
+
}) => Promise<void>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default async function handle(payload: PoiEventPayload, ctx: ResolverContext) {
|
|
46
|
+
try {
|
|
47
|
+
const webhookService = ctx.resolve<WebhookService | undefined>('shipmentTrackingWebhookService')
|
|
48
|
+
|
|
49
|
+
if (!webhookService) {
|
|
50
|
+
console.debug('[shipment-tracking:poi-webhook] WebhookService not available, skipping dispatch')
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
await webhookService.dispatchEvent({
|
|
55
|
+
eventType: ctx.eventName,
|
|
56
|
+
payload: {
|
|
57
|
+
event: {
|
|
58
|
+
// IDs
|
|
59
|
+
trackingEventId: payload.trackingEventId,
|
|
60
|
+
shipmentId: payload.shipmentId,
|
|
61
|
+
|
|
62
|
+
// Event type
|
|
63
|
+
eventType: payload.eventType,
|
|
64
|
+
eventDateTime: payload.eventDateTime,
|
|
65
|
+
|
|
66
|
+
// Vessel info
|
|
67
|
+
vesselName: payload.vesselName,
|
|
68
|
+
vesselMmsi: payload.vesselMmsi,
|
|
69
|
+
vesselImo: payload.vesselImo,
|
|
70
|
+
|
|
71
|
+
// Location info
|
|
72
|
+
poiCode: payload.poiCode,
|
|
73
|
+
latitude: payload.latitude,
|
|
74
|
+
longitude: payload.longitude,
|
|
75
|
+
distanceToPoiMeters: payload.distanceToPoiMeters,
|
|
76
|
+
|
|
77
|
+
// Source identifier
|
|
78
|
+
source: 'ais',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
tenantId: payload.tenantId,
|
|
82
|
+
organizationId: payload.organizationId,
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
console.debug(
|
|
86
|
+
`[shipment-tracking:poi-webhook] Dispatched ${ctx.eventName} for shipment ${payload.shipmentId}`
|
|
87
|
+
)
|
|
88
|
+
} catch (error) {
|
|
89
|
+
console.error(
|
|
90
|
+
`[shipment-tracking:poi-webhook] Failed to dispatch ${ctx.eventName} webhook:`,
|
|
91
|
+
error
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { WebhookService } from '../services/webhookService'
|
|
2
|
+
|
|
3
|
+
export const metadata = {
|
|
4
|
+
event: 'shipment_tracking.shipment.status_changed',
|
|
5
|
+
persistent: true,
|
|
6
|
+
id: 'shipment_tracking:shipment-status-changed',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type StatusChangedPayload = {
|
|
10
|
+
id: string
|
|
11
|
+
previousStatus: string
|
|
12
|
+
newStatus: string
|
|
13
|
+
tenantId: string
|
|
14
|
+
organizationId: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type ResolverContext = {
|
|
18
|
+
resolve: <T = unknown>(name: string) => T
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default async function handle(payload: StatusChangedPayload, ctx: ResolverContext) {
|
|
22
|
+
try {
|
|
23
|
+
const webhookService = ctx.resolve<WebhookService>('shipmentTrackingWebhookService')
|
|
24
|
+
|
|
25
|
+
// Build full shipment payload to include in the webhook
|
|
26
|
+
const shipmentData = await webhookService.buildFullShipmentPayload(payload.id)
|
|
27
|
+
|
|
28
|
+
await webhookService.dispatchEvent({
|
|
29
|
+
eventType: 'shipment_tracking.shipment.status_changed',
|
|
30
|
+
payload: {
|
|
31
|
+
previousStatus: payload.previousStatus,
|
|
32
|
+
newStatus: payload.newStatus,
|
|
33
|
+
shipment: shipmentData,
|
|
34
|
+
},
|
|
35
|
+
tenantId: payload.tenantId,
|
|
36
|
+
organizationId: payload.organizationId,
|
|
37
|
+
})
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error('[shipment-tracking:subscriber] Failed to dispatch status_changed webhook:', error)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal Event Ingest (bridge)
|
|
3
|
+
*
|
|
4
|
+
* Surfaces terminal-tracking events on the shipment-tracking timeline. Reacts
|
|
5
|
+
* to the `terminal_tracking.terminal_event.created` event (string coupling
|
|
6
|
+
* only — this module does NOT import @freighttech/terminal-tracking), finds the
|
|
7
|
+
* matching tracked Shipment by container number, and records a `source:'port'`
|
|
8
|
+
* TrackingEvent. Fully additive; no-ops when no matching shipment is tracked.
|
|
9
|
+
*/
|
|
10
|
+
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
11
|
+
import { Shipment, TrackingEvent } from '../data/entities'
|
|
12
|
+
import type { TrackingService } from '../services/trackingService'
|
|
13
|
+
|
|
14
|
+
export const metadata = {
|
|
15
|
+
event: 'terminal_tracking.terminal_event.created',
|
|
16
|
+
persistent: false,
|
|
17
|
+
id: 'shipment_tracking:terminal-event-ingest',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type TerminalEventPayload = {
|
|
21
|
+
sourceEventId: string
|
|
22
|
+
eventType: 'EQUIPMENT' | 'TRANSPORT'
|
|
23
|
+
eventCode: string
|
|
24
|
+
eventClassifierCode?: 'ACT' | 'PLN' | 'EST' | null
|
|
25
|
+
eventDateTime: string
|
|
26
|
+
containerNumber: string
|
|
27
|
+
tenantId: string
|
|
28
|
+
organizationId: string
|
|
29
|
+
unlocode?: string | null
|
|
30
|
+
facilityCode?: string | null
|
|
31
|
+
facilityCodeListProvider?: 'SMDG' | 'BIC' | null
|
|
32
|
+
vesselName?: string | null
|
|
33
|
+
voyageNumber?: string | null
|
|
34
|
+
modeOfTransport?: 'VESSEL' | 'RAIL' | 'TRUCK' | 'BARGE' | null
|
|
35
|
+
seals?: Array<{ number: string; type?: string | null; source?: string | null }> | null
|
|
36
|
+
rawData?: Record<string, unknown> | null
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type ResolverContext = { resolve: <T = unknown>(name: string) => T }
|
|
40
|
+
|
|
41
|
+
export default async function handle(payload: TerminalEventPayload, ctx: ResolverContext) {
|
|
42
|
+
if (!payload?.containerNumber || !payload?.sourceEventId) return
|
|
43
|
+
|
|
44
|
+
const em = ctx.resolve<EntityManager>('em').fork()
|
|
45
|
+
const trackingService = ctx.resolve<TrackingService>('shipmentTrackingService')
|
|
46
|
+
|
|
47
|
+
// Scope to currently-tracked, non-delivered shipments (mirror
|
|
48
|
+
// poi-event-processor). A container number is reused across journeys over
|
|
49
|
+
// time, so without this a returned container's new-visit events would refresh
|
|
50
|
+
// and override a historic, already-delivered shipment with the same number.
|
|
51
|
+
const shipments = await em.find(
|
|
52
|
+
Shipment,
|
|
53
|
+
{
|
|
54
|
+
organizationId: payload.organizationId,
|
|
55
|
+
tenantId: payload.tenantId,
|
|
56
|
+
containerNumber: payload.containerNumber,
|
|
57
|
+
deletedAt: null,
|
|
58
|
+
isActive: true,
|
|
59
|
+
status: { $nin: ['DELIVERED'] },
|
|
60
|
+
},
|
|
61
|
+
{ populate: ['trackingJob'] },
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
const eventDateTime = new Date(payload.eventDateTime)
|
|
65
|
+
const touchedJobs = new Map<string, Set<string>>()
|
|
66
|
+
|
|
67
|
+
for (const shipment of shipments) {
|
|
68
|
+
if (!shipment.trackingJob) continue
|
|
69
|
+
|
|
70
|
+
const exists = await em.findOne(TrackingEvent, {
|
|
71
|
+
trackingJob: shipment.trackingJob.id,
|
|
72
|
+
source: 'port',
|
|
73
|
+
sourceEventId: payload.sourceEventId,
|
|
74
|
+
})
|
|
75
|
+
if (exists) continue
|
|
76
|
+
|
|
77
|
+
const event = new TrackingEvent()
|
|
78
|
+
event.organizationId = shipment.organizationId
|
|
79
|
+
event.tenantId = shipment.tenantId
|
|
80
|
+
event.trackingJob = shipment.trackingJob
|
|
81
|
+
event.source = 'port'
|
|
82
|
+
event.sourceEventId = payload.sourceEventId
|
|
83
|
+
event.eventType = payload.eventType
|
|
84
|
+
event.eventCode = payload.eventCode
|
|
85
|
+
event.eventClassifierCode = payload.eventClassifierCode ?? 'ACT'
|
|
86
|
+
event.eventDateTime = eventDateTime
|
|
87
|
+
event.equipmentReference = payload.containerNumber
|
|
88
|
+
event.locationUnlocode = payload.unlocode ?? null
|
|
89
|
+
event.facilityCode = payload.facilityCode ?? null
|
|
90
|
+
event.facilityCodeListProvider = payload.facilityCodeListProvider ?? null
|
|
91
|
+
event.vesselName = payload.vesselName ?? null
|
|
92
|
+
event.voyageNumber = payload.voyageNumber ?? null
|
|
93
|
+
event.modeOfTransport = payload.modeOfTransport ?? null
|
|
94
|
+
event.seals = payload.seals ?? null
|
|
95
|
+
event.rawData = payload.rawData ?? null
|
|
96
|
+
em.persist(event)
|
|
97
|
+
|
|
98
|
+
const set = touchedJobs.get(shipment.trackingJob.id) ?? new Set<string>()
|
|
99
|
+
set.add(shipment.id)
|
|
100
|
+
touchedJobs.set(shipment.trackingJob.id, set)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (touchedJobs.size === 0) return
|
|
104
|
+
await em.flush()
|
|
105
|
+
|
|
106
|
+
for (const [jobId, shipmentIds] of touchedJobs) {
|
|
107
|
+
await trackingService.refreshShipmentsFromEvents(em, jobId, Array.from(shipmentIds))
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tracking Job Initial Poll Subscriber
|
|
3
|
+
*
|
|
4
|
+
* Triggers an immediate poll when a new tracking job is created.
|
|
5
|
+
* This ensures the carrier API is queried right away instead of waiting
|
|
6
|
+
* for the next scheduled poll interval.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { TrackingService } from '../services/trackingService'
|
|
10
|
+
|
|
11
|
+
export const metadata = {
|
|
12
|
+
event: 'shipment_tracking.tracking_job.created',
|
|
13
|
+
persistent: false, // In-process, immediate execution
|
|
14
|
+
id: 'shipment_tracking:tracking-job-initial-poll',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type TrackingJobCreatedPayload = {
|
|
18
|
+
id: string
|
|
19
|
+
carrierCode: string
|
|
20
|
+
referenceType: string
|
|
21
|
+
referenceValue: string
|
|
22
|
+
tenantId: string
|
|
23
|
+
organizationId: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type ResolverContext = {
|
|
27
|
+
resolve: <T = unknown>(name: string) => T
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default async function handle(payload: TrackingJobCreatedPayload, ctx: ResolverContext) {
|
|
31
|
+
const trackingService = ctx.resolve<TrackingService>('shipmentTrackingService')
|
|
32
|
+
|
|
33
|
+
console.log('[shipment-tracking] Triggering initial poll for new tracking job:', {
|
|
34
|
+
jobId: payload.id,
|
|
35
|
+
carrierCode: payload.carrierCode,
|
|
36
|
+
reference: `${payload.referenceType}:${payload.referenceValue}`,
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
const result = await trackingService.pollTrackingJob(payload.id)
|
|
41
|
+
|
|
42
|
+
console.log('[shipment-tracking] Initial poll completed:', {
|
|
43
|
+
jobId: payload.id,
|
|
44
|
+
newEvents: result.newEvents,
|
|
45
|
+
shipmentsCreated: result.shipmentsCreated,
|
|
46
|
+
shipmentsUpdated: result.shipmentsUpdated,
|
|
47
|
+
})
|
|
48
|
+
} catch (error) {
|
|
49
|
+
// Log error but don't rethrow - the job is created and will be polled on schedule
|
|
50
|
+
// Errors are already recorded in the job's errorHistory by pollTrackingJob
|
|
51
|
+
console.error('[shipment-tracking] Initial poll failed for job:', payload.id, error)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tracking Job Event Handler
|
|
3
|
+
*
|
|
4
|
+
* NOTE: As of DCSA T&T compliance update, tracking_job events are marked as
|
|
5
|
+
* internal events (excludeFromTriggers: true) and are NOT dispatched to
|
|
6
|
+
* external webhooks. These events are for internal system monitoring only.
|
|
7
|
+
*
|
|
8
|
+
* This subscriber remains for internal audit logging but does not dispatch
|
|
9
|
+
* webhooks to external consumers. External consumers should subscribe to
|
|
10
|
+
* DCSA-compliant events like:
|
|
11
|
+
* - shipment_tracking.transport.* (departed, arrived, eta_updated, etc.)
|
|
12
|
+
* - shipment_tracking.equipment.* (loaded, discharged, gate_in, etc.)
|
|
13
|
+
* - shipment_tracking.shipment.* (created, updated, status_changed, etc.)
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export const metadata = {
|
|
17
|
+
event: 'shipment_tracking.tracking_job.*',
|
|
18
|
+
persistent: true,
|
|
19
|
+
id: 'shipment_tracking:tracking-job-webhook-dispatch',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type TrackingJobEventPayload = {
|
|
23
|
+
id: string
|
|
24
|
+
shipmentId?: string
|
|
25
|
+
carrierCode?: string
|
|
26
|
+
tenantId: string
|
|
27
|
+
organizationId: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type ResolverContext = {
|
|
31
|
+
resolve: <T = unknown>(name: string) => T
|
|
32
|
+
eventName: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default async function handle(payload: TrackingJobEventPayload, ctx: ResolverContext) {
|
|
36
|
+
// Extract the action from the event name (e.g., "created", "updated", "failed")
|
|
37
|
+
const eventParts = ctx.eventName.split('.')
|
|
38
|
+
const action = eventParts[eventParts.length - 1]
|
|
39
|
+
|
|
40
|
+
// Internal logging only - no webhook dispatch for tracking_job events
|
|
41
|
+
// These are internal system events per DCSA compliance requirements
|
|
42
|
+
console.debug(`[shipment-tracking:internal] Tracking job event: ${action}`, {
|
|
43
|
+
jobId: payload.id,
|
|
44
|
+
shipmentId: payload.shipmentId,
|
|
45
|
+
carrierCode: payload.carrierCode,
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
// NOTE: Webhook dispatch removed - tracking_job events are internal only
|
|
49
|
+
// External consumers should subscribe to DCSA-compliant transport/equipment events
|
|
50
|
+
}
|