@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,236 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import {
|
|
5
|
+
Tooltip,
|
|
6
|
+
TooltipContent,
|
|
7
|
+
TooltipProvider,
|
|
8
|
+
TooltipTrigger,
|
|
9
|
+
} from '@freighttech/ui/primitives/tooltip'
|
|
10
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
11
|
+
|
|
12
|
+
export type TimestampEntry = {
|
|
13
|
+
value: string
|
|
14
|
+
offset: string | null
|
|
15
|
+
source: 'carrier_api' | 'manual' | 'ais' | 'port' | 'edi'
|
|
16
|
+
updatedAt: string
|
|
17
|
+
sourceEventId?: string | null
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type CombinedEntry = TimestampEntry & {
|
|
21
|
+
isActual: boolean
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type CombinedTimestampCellProps = {
|
|
25
|
+
estimatedTimestamps: TimestampEntry[] | null | undefined
|
|
26
|
+
actualTimestamps: TimestampEntry[] | null | undefined
|
|
27
|
+
label: 'ETD/ATD' | 'ETA/ATA'
|
|
28
|
+
format?: 'date' | 'datetime'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const SOURCE_LABELS: Record<string, string> = {
|
|
32
|
+
carrier_api: 'Carrier API',
|
|
33
|
+
manual: 'Manual',
|
|
34
|
+
ais: 'AIS',
|
|
35
|
+
port: 'Port',
|
|
36
|
+
edi: 'EDI',
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const SOURCE_COLORS: Record<string, string> = {
|
|
40
|
+
carrier_api: 'bg-blue-100 text-blue-700',
|
|
41
|
+
manual: 'bg-purple-100 text-purple-700',
|
|
42
|
+
ais: 'bg-green-100 text-green-700',
|
|
43
|
+
port: 'bg-orange-100 text-orange-700',
|
|
44
|
+
edi: 'bg-gray-100 text-gray-700',
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function formatDate(date: Date): string {
|
|
48
|
+
const day = String(date.getDate()).padStart(2, '0')
|
|
49
|
+
const month = String(date.getMonth() + 1).padStart(2, '0')
|
|
50
|
+
const year = date.getFullYear()
|
|
51
|
+
return `${day}/${month}/${year}`
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function FormattedDate({ date }: { date: Date }) {
|
|
55
|
+
const day = String(date.getDate()).padStart(2, '0')
|
|
56
|
+
const month = String(date.getMonth() + 1).padStart(2, '0')
|
|
57
|
+
const year = date.getFullYear()
|
|
58
|
+
return (
|
|
59
|
+
<>
|
|
60
|
+
{day}<span className="opacity-50">/</span>{month}<span className="opacity-50">/</span>{year}
|
|
61
|
+
</>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function formatTimestamp(value: string, offset: string | null, format: 'date' | 'datetime'): string {
|
|
66
|
+
const date = new Date(value)
|
|
67
|
+
if (Number.isNaN(date.getTime())) return '-'
|
|
68
|
+
|
|
69
|
+
if (format === 'date') {
|
|
70
|
+
return formatDate(date)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Include time
|
|
74
|
+
const timeStr = date.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' })
|
|
75
|
+
const dateStr = formatDate(date)
|
|
76
|
+
const offsetStr = offset ? ` (${offset})` : ''
|
|
77
|
+
return `${dateStr} ${timeStr}${offsetStr}`
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function FormattedTimestamp({ value, offset, format }: { value: string; offset: string | null; format: 'date' | 'datetime' }) {
|
|
81
|
+
const date = new Date(value)
|
|
82
|
+
if (Number.isNaN(date.getTime())) return <>-</>
|
|
83
|
+
|
|
84
|
+
if (format === 'date') {
|
|
85
|
+
return <FormattedDate date={date} />
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const timeStr = date.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' })
|
|
89
|
+
const offsetStr = offset ? ` (${offset})` : ''
|
|
90
|
+
return (
|
|
91
|
+
<>
|
|
92
|
+
<FormattedDate date={date} /> {timeStr}{offsetStr}
|
|
93
|
+
</>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function formatUpdatedAt(value: string): string {
|
|
98
|
+
const date = new Date(value)
|
|
99
|
+
if (Number.isNaN(date.getTime())) return '-'
|
|
100
|
+
return date.toLocaleString(undefined, {
|
|
101
|
+
month: 'short',
|
|
102
|
+
day: 'numeric',
|
|
103
|
+
hour: '2-digit',
|
|
104
|
+
minute: '2-digit',
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function combineTimestamps(
|
|
109
|
+
estimatedTimestamps: TimestampEntry[] | null | undefined,
|
|
110
|
+
actualTimestamps: TimestampEntry[] | null | undefined
|
|
111
|
+
): CombinedEntry[] {
|
|
112
|
+
const combined: CombinedEntry[] = []
|
|
113
|
+
|
|
114
|
+
if (estimatedTimestamps) {
|
|
115
|
+
for (const entry of estimatedTimestamps) {
|
|
116
|
+
combined.push({ ...entry, isActual: false })
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (actualTimestamps) {
|
|
121
|
+
for (const entry of actualTimestamps) {
|
|
122
|
+
combined.push({ ...entry, isActual: true })
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return combined
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function getLatestEntry(entries: CombinedEntry[]): CombinedEntry | null {
|
|
130
|
+
if (entries.length === 0) return null
|
|
131
|
+
return entries.reduce((latest, entry) =>
|
|
132
|
+
entry.updatedAt > latest.updatedAt ? entry : latest
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function CombinedTimestampCell({
|
|
137
|
+
estimatedTimestamps,
|
|
138
|
+
actualTimestamps,
|
|
139
|
+
label,
|
|
140
|
+
format = 'date',
|
|
141
|
+
}: CombinedTimestampCellProps) {
|
|
142
|
+
const t = useT()
|
|
143
|
+
|
|
144
|
+
const combined = combineTimestamps(estimatedTimestamps, actualTimestamps)
|
|
145
|
+
|
|
146
|
+
if (combined.length === 0) {
|
|
147
|
+
return <span className="text-muted-foreground">-</span>
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const latest = getLatestEntry(combined)
|
|
151
|
+
if (!latest) {
|
|
152
|
+
return <span className="text-muted-foreground">-</span>
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const hasHistory = combined.length > 1
|
|
156
|
+
|
|
157
|
+
// Sort by updatedAt descending (newest first)
|
|
158
|
+
const sortedHistory = [...combined].sort((a, b) => b.updatedAt.localeCompare(a.updatedAt))
|
|
159
|
+
|
|
160
|
+
// Badge for estimated vs actual
|
|
161
|
+
const typeBadgeClass = latest.isActual
|
|
162
|
+
? 'bg-green-100 text-green-700'
|
|
163
|
+
: 'bg-gray-100 text-gray-600'
|
|
164
|
+
const typeBadgeLabel = latest.isActual
|
|
165
|
+
? t('shipment_tracking.timestamps.actual', 'Actual')
|
|
166
|
+
: t('shipment_tracking.timestamps.estimated', 'Est.')
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<TooltipProvider>
|
|
170
|
+
<Tooltip delayDuration={200}>
|
|
171
|
+
<TooltipTrigger asChild>
|
|
172
|
+
<span className={`inline-flex items-center gap-1.5 cursor-help ${hasHistory ? 'border-b border-dashed border-muted-foreground/50' : ''}`}>
|
|
173
|
+
<span><FormattedTimestamp value={latest.value} offset={latest.offset} format={format} /></span>
|
|
174
|
+
<span className={`inline-flex items-center rounded px-1 py-0.5 text-[10px] font-medium ${typeBadgeClass}`}>
|
|
175
|
+
{typeBadgeLabel}
|
|
176
|
+
</span>
|
|
177
|
+
{hasHistory && (
|
|
178
|
+
<span className="text-[10px] text-muted-foreground">
|
|
179
|
+
({combined.length})
|
|
180
|
+
</span>
|
|
181
|
+
)}
|
|
182
|
+
</span>
|
|
183
|
+
</TooltipTrigger>
|
|
184
|
+
<TooltipContent side="bottom" align="start" className="max-w-sm p-0">
|
|
185
|
+
<div className="p-2 space-y-2">
|
|
186
|
+
<div className="text-xs font-medium text-muted-foreground border-b pb-1 mb-2">
|
|
187
|
+
{t(`shipment_tracking.timestamps.${label.replace('/', '_').toLowerCase()}History`, `${label} History`)}
|
|
188
|
+
</div>
|
|
189
|
+
<div className="space-y-1.5 max-h-64 overflow-y-auto">
|
|
190
|
+
{sortedHistory.map((entry, index) => {
|
|
191
|
+
const isLatest = entry === latest
|
|
192
|
+
const entryTypeBadgeClass = entry.isActual
|
|
193
|
+
? 'bg-green-100 text-green-700'
|
|
194
|
+
: 'bg-slate-200 text-slate-700'
|
|
195
|
+
const entryTypeBadgeLabel = entry.isActual
|
|
196
|
+
? t('shipment_tracking.timestamps.actual', 'Actual')
|
|
197
|
+
: t('shipment_tracking.timestamps.estimated', 'Est.')
|
|
198
|
+
|
|
199
|
+
return (
|
|
200
|
+
<div
|
|
201
|
+
key={`${entry.value}-${entry.updatedAt}-${index}`}
|
|
202
|
+
className={`text-xs rounded p-1.5 ${isLatest ? 'bg-accent' : 'bg-muted'}`}
|
|
203
|
+
>
|
|
204
|
+
<div className="flex items-center justify-between gap-2">
|
|
205
|
+
<span className="font-medium text-foreground">
|
|
206
|
+
{formatTimestamp(entry.value, entry.offset, 'datetime')}
|
|
207
|
+
</span>
|
|
208
|
+
<div className="flex items-center gap-1">
|
|
209
|
+
<span className={`inline-flex items-center rounded px-1 py-0.5 text-[10px] font-medium ${entryTypeBadgeClass}`}>
|
|
210
|
+
{entryTypeBadgeLabel}
|
|
211
|
+
</span>
|
|
212
|
+
<span className={`inline-flex items-center rounded px-1 py-0.5 text-[10px] font-medium ${SOURCE_COLORS[entry.source] || 'bg-gray-100 text-gray-700'}`}>
|
|
213
|
+
{SOURCE_LABELS[entry.source] || entry.source}
|
|
214
|
+
</span>
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
<div className="text-[10px] text-muted-foreground mt-0.5">
|
|
218
|
+
{t('shipment_tracking.timestamps.updatedAt', 'Updated')}: {formatUpdatedAt(entry.updatedAt)}
|
|
219
|
+
{isLatest && (
|
|
220
|
+
<span className="ml-1 text-primary font-medium">
|
|
221
|
+
({t('shipment_tracking.timestamps.latest', 'latest')})
|
|
222
|
+
</span>
|
|
223
|
+
)}
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
)
|
|
227
|
+
})}
|
|
228
|
+
</div>
|
|
229
|
+
</div>
|
|
230
|
+
</TooltipContent>
|
|
231
|
+
</Tooltip>
|
|
232
|
+
</TooltipProvider>
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export default CombinedTimestampCell
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { useState, useCallback } from 'react'
|
|
5
|
+
import { MapPin, Building2, Navigation, ChevronDown, ChevronUp } from 'lucide-react'
|
|
6
|
+
import { Input } from '@freighttech/ui/primitives/input'
|
|
7
|
+
import { Label } from '@freighttech/ui/primitives/label'
|
|
8
|
+
import { Button } from '@freighttech/ui/primitives/button'
|
|
9
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
10
|
+
import type { FacilityLocation } from '../lib/location-types'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Partial FacilityLocation for form input - all fields optional
|
|
14
|
+
*/
|
|
15
|
+
export type FacilityLocationInputValue = Partial<FacilityLocation>
|
|
16
|
+
|
|
17
|
+
interface FacilityLocationInputProps {
|
|
18
|
+
value: FacilityLocationInputValue | null
|
|
19
|
+
onChange: (value: FacilityLocationInputValue | null) => void
|
|
20
|
+
label?: string
|
|
21
|
+
disabled?: boolean
|
|
22
|
+
/** Show facility code and coordinates by default (not collapsed) */
|
|
23
|
+
showAdvanced?: boolean
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A form component for editing FacilityLocation data.
|
|
28
|
+
*
|
|
29
|
+
* Primary fields (always visible):
|
|
30
|
+
* - Port/Terminal Name
|
|
31
|
+
* - UN/LOCODE
|
|
32
|
+
* - Country Code
|
|
33
|
+
*
|
|
34
|
+
* Advanced fields (collapsible):
|
|
35
|
+
* - Facility Code + Provider (SMDG/BIC)
|
|
36
|
+
* - Address
|
|
37
|
+
* - Coordinates (lat/lng)
|
|
38
|
+
*/
|
|
39
|
+
export function FacilityLocationInput({
|
|
40
|
+
value,
|
|
41
|
+
onChange,
|
|
42
|
+
label,
|
|
43
|
+
disabled = false,
|
|
44
|
+
showAdvanced = false,
|
|
45
|
+
}: FacilityLocationInputProps) {
|
|
46
|
+
const t = useT()
|
|
47
|
+
const [advancedOpen, setAdvancedOpen] = useState(showAdvanced)
|
|
48
|
+
|
|
49
|
+
const updateField = useCallback(
|
|
50
|
+
<K extends keyof FacilityLocation>(field: K, fieldValue: FacilityLocation[K]) => {
|
|
51
|
+
onChange({
|
|
52
|
+
...value,
|
|
53
|
+
[field]: fieldValue,
|
|
54
|
+
source: 'manual',
|
|
55
|
+
})
|
|
56
|
+
},
|
|
57
|
+
[value, onChange]
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
const updateCoord = useCallback(
|
|
61
|
+
(coord: 'latitude' | 'longitude', numValue: number | null) => {
|
|
62
|
+
const currentCoords = value?.coords
|
|
63
|
+
const otherCoord = coord === 'latitude' ? currentCoords?.longitude : currentCoords?.latitude
|
|
64
|
+
|
|
65
|
+
// If both are null/undefined, set coords to null
|
|
66
|
+
if (numValue === null && (otherCoord === null || otherCoord === undefined)) {
|
|
67
|
+
onChange({
|
|
68
|
+
...value,
|
|
69
|
+
coords: null,
|
|
70
|
+
source: 'manual',
|
|
71
|
+
})
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
onChange({
|
|
76
|
+
...value,
|
|
77
|
+
coords: {
|
|
78
|
+
latitude: coord === 'latitude' ? (numValue ?? 0) : (currentCoords?.latitude ?? 0),
|
|
79
|
+
longitude: coord === 'longitude' ? (numValue ?? 0) : (currentCoords?.longitude ?? 0),
|
|
80
|
+
},
|
|
81
|
+
source: 'manual',
|
|
82
|
+
})
|
|
83
|
+
},
|
|
84
|
+
[value, onChange]
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div className="space-y-4">
|
|
89
|
+
{label && (
|
|
90
|
+
<div className="flex items-center gap-2 text-sm font-medium text-foreground">
|
|
91
|
+
<MapPin className="h-4 w-4" />
|
|
92
|
+
{label}
|
|
93
|
+
</div>
|
|
94
|
+
)}
|
|
95
|
+
|
|
96
|
+
{/* Primary fields: Name, UN/LOCODE, Country */}
|
|
97
|
+
<div className="grid grid-cols-2 gap-4">
|
|
98
|
+
<div className="space-y-2">
|
|
99
|
+
<Label>{t('shipment_tracking.location.name', 'Port/Terminal Name')}</Label>
|
|
100
|
+
<Input
|
|
101
|
+
placeholder="Shanghai Port"
|
|
102
|
+
value={value?.name || ''}
|
|
103
|
+
onChange={(e) => updateField('name', e.target.value || '')}
|
|
104
|
+
disabled={disabled}
|
|
105
|
+
/>
|
|
106
|
+
</div>
|
|
107
|
+
<div className="space-y-2">
|
|
108
|
+
<Label>{t('shipment_tracking.location.unlocode', 'UN/LOCODE')}</Label>
|
|
109
|
+
<Input
|
|
110
|
+
placeholder="CNSHA"
|
|
111
|
+
value={value?.unlocode || ''}
|
|
112
|
+
onChange={(e) => updateField('unlocode', e.target.value.toUpperCase() || null)}
|
|
113
|
+
disabled={disabled}
|
|
114
|
+
maxLength={5}
|
|
115
|
+
/>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<div className="space-y-2">
|
|
120
|
+
<Label>{t('shipment_tracking.location.country', 'Country Code')}</Label>
|
|
121
|
+
<Input
|
|
122
|
+
placeholder="CN"
|
|
123
|
+
value={value?.countryCode || ''}
|
|
124
|
+
onChange={(e) => updateField('countryCode', e.target.value.toUpperCase() || null)}
|
|
125
|
+
disabled={disabled}
|
|
126
|
+
maxLength={2}
|
|
127
|
+
/>
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
{/* Advanced fields toggle */}
|
|
131
|
+
<Button
|
|
132
|
+
type="button"
|
|
133
|
+
variant="ghost"
|
|
134
|
+
size="sm"
|
|
135
|
+
className="w-full justify-between"
|
|
136
|
+
onClick={() => setAdvancedOpen(!advancedOpen)}
|
|
137
|
+
>
|
|
138
|
+
<span className="flex items-center gap-2">
|
|
139
|
+
<Building2 className="h-4 w-4" />
|
|
140
|
+
{t('shipment_tracking.location.advancedDetails', 'Facility & Coordinates')}
|
|
141
|
+
</span>
|
|
142
|
+
{advancedOpen ? (
|
|
143
|
+
<ChevronUp className="h-4 w-4" />
|
|
144
|
+
) : (
|
|
145
|
+
<ChevronDown className="h-4 w-4" />
|
|
146
|
+
)}
|
|
147
|
+
</Button>
|
|
148
|
+
|
|
149
|
+
{/* Advanced fields: Facility, Address, Coordinates */}
|
|
150
|
+
{advancedOpen && (
|
|
151
|
+
<div className="space-y-4 pt-2">
|
|
152
|
+
{/* Facility Code */}
|
|
153
|
+
<div className="grid grid-cols-2 gap-4">
|
|
154
|
+
<div className="space-y-2">
|
|
155
|
+
<Label>{t('shipment_tracking.location.facilityCode', 'Facility Code')}</Label>
|
|
156
|
+
<Input
|
|
157
|
+
placeholder="DCT"
|
|
158
|
+
value={value?.facilityCode || ''}
|
|
159
|
+
onChange={(e) =>
|
|
160
|
+
updateField('facilityCode', e.target.value.toUpperCase() || null)
|
|
161
|
+
}
|
|
162
|
+
disabled={disabled}
|
|
163
|
+
/>
|
|
164
|
+
</div>
|
|
165
|
+
<div className="space-y-2">
|
|
166
|
+
<Label>{t('shipment_tracking.location.facilityProvider', 'Provider')}</Label>
|
|
167
|
+
<select
|
|
168
|
+
className="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"
|
|
169
|
+
value={value?.facilityCodeListProvider || ''}
|
|
170
|
+
onChange={(e) =>
|
|
171
|
+
updateField(
|
|
172
|
+
'facilityCodeListProvider',
|
|
173
|
+
(e.target.value as 'SMDG' | 'BIC') || null
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
disabled={disabled}
|
|
177
|
+
>
|
|
178
|
+
<option value="">-</option>
|
|
179
|
+
<option value="SMDG">SMDG</option>
|
|
180
|
+
<option value="BIC">BIC</option>
|
|
181
|
+
</select>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
{/* Address */}
|
|
186
|
+
<div className="space-y-2">
|
|
187
|
+
<Label>{t('shipment_tracking.location.address', 'Address')}</Label>
|
|
188
|
+
<Input
|
|
189
|
+
placeholder="Terminal Road 123, Shanghai, China"
|
|
190
|
+
value={value?.address || ''}
|
|
191
|
+
onChange={(e) => updateField('address', e.target.value || null)}
|
|
192
|
+
disabled={disabled}
|
|
193
|
+
/>
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
{/* Coordinates */}
|
|
197
|
+
<div className="grid grid-cols-2 gap-4">
|
|
198
|
+
<div className="space-y-2">
|
|
199
|
+
<Label className="flex items-center gap-1">
|
|
200
|
+
<Navigation className="h-3 w-3" />
|
|
201
|
+
{t('shipment_tracking.location.latitude', 'Latitude')}
|
|
202
|
+
</Label>
|
|
203
|
+
<Input
|
|
204
|
+
type="number"
|
|
205
|
+
step="0.000001"
|
|
206
|
+
placeholder="31.2304"
|
|
207
|
+
value={value?.coords?.latitude ?? ''}
|
|
208
|
+
onChange={(e) =>
|
|
209
|
+
updateCoord('latitude', e.target.value ? parseFloat(e.target.value) : null)
|
|
210
|
+
}
|
|
211
|
+
disabled={disabled}
|
|
212
|
+
/>
|
|
213
|
+
</div>
|
|
214
|
+
<div className="space-y-2">
|
|
215
|
+
<Label className="flex items-center gap-1">
|
|
216
|
+
<Navigation className="h-3 w-3" />
|
|
217
|
+
{t('shipment_tracking.location.longitude', 'Longitude')}
|
|
218
|
+
</Label>
|
|
219
|
+
<Input
|
|
220
|
+
type="number"
|
|
221
|
+
step="0.000001"
|
|
222
|
+
placeholder="121.4737"
|
|
223
|
+
value={value?.coords?.longitude ?? ''}
|
|
224
|
+
onChange={(e) =>
|
|
225
|
+
updateCoord('longitude', e.target.value ? parseFloat(e.target.value) : null)
|
|
226
|
+
}
|
|
227
|
+
disabled={disabled}
|
|
228
|
+
/>
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
)}
|
|
233
|
+
</div>
|
|
234
|
+
)
|
|
235
|
+
}
|