@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,748 @@
|
|
|
1
|
+
import { Collection, OptionalProps } from '@mikro-orm/core'
|
|
2
|
+
import { Entity, PrimaryKey, Property, Index, Unique, ManyToOne, OneToMany } from '@mikro-orm/decorators/legacy'
|
|
3
|
+
import type { ShipmentTimestampEntry } from '../lib/timestamp-utils'
|
|
4
|
+
import type { RouteStopEntry, CargoEventEntry, SealInfo } from '../lib/route-extraction'
|
|
5
|
+
import type { FacilityLocation } from '../lib/location-types'
|
|
6
|
+
|
|
7
|
+
// Re-export timestamp types for convenience
|
|
8
|
+
export type { ShipmentTimestampEntry, TimestampSource, TimestampType } from '../lib/timestamp-utils'
|
|
9
|
+
// Re-export route extraction types for convenience
|
|
10
|
+
export type { RouteStopEntry, CargoEventEntry, SealInfo } from '../lib/route-extraction'
|
|
11
|
+
// Re-export location types for convenience
|
|
12
|
+
export type { FacilityLocation } from '../lib/location-types'
|
|
13
|
+
|
|
14
|
+
// ─── Enums ───────────────────────────────────────────────────
|
|
15
|
+
|
|
16
|
+
export type ShipmentStatusEnum =
|
|
17
|
+
| 'PENDING'
|
|
18
|
+
| 'BOOKED'
|
|
19
|
+
| 'DEPARTED'
|
|
20
|
+
| 'IN_TRANSIT'
|
|
21
|
+
| 'PRE_ARRIVAL'
|
|
22
|
+
| 'ARRIVED'
|
|
23
|
+
| 'DELIVERED'
|
|
24
|
+
|
|
25
|
+
export type TrackingJobStatusEnum = 'active' | 'paused' | 'deactivated' | 'failed' | 'completed'
|
|
26
|
+
|
|
27
|
+
export type TrackingEventType = 'EQUIPMENT' | 'TRANSPORT' | 'SHIPMENT'
|
|
28
|
+
|
|
29
|
+
export type TrackingEventClassifierCode = 'ACT' | 'PLN' | 'EST'
|
|
30
|
+
|
|
31
|
+
export type TrackingEventSource = 'dcsa' | 'ais' | 'port' | 'edi' | 'manual' | 'shipsgo'
|
|
32
|
+
|
|
33
|
+
export type WebhookDeliveryStatus = 'pending' | 'success' | 'failed'
|
|
34
|
+
|
|
35
|
+
export type TrackingReferenceType = 'container' | 'booking' | 'bol' | 'awb'
|
|
36
|
+
|
|
37
|
+
// Which upstream source a tracking job is driven by:
|
|
38
|
+
// 'carrier' → a direct DCSA carrier adapter (default, primary)
|
|
39
|
+
// 'shipsgo' → the ShipsGo aggregator (fallback for unsupported ocean carriers + air)
|
|
40
|
+
export type TrackingProvider = 'carrier' | 'shipsgo'
|
|
41
|
+
|
|
42
|
+
// Transport mode for a tracking job / shipment. Ocean is the historical default;
|
|
43
|
+
// air arrives with the ShipsGo integration.
|
|
44
|
+
export type TrackingMode = 'ocean' | 'air'
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
// Types for JSONB fields
|
|
49
|
+
export type DocumentReference = {
|
|
50
|
+
type: string // BKG, TRD, SHI, CBR, ARN, VGM, etc.
|
|
51
|
+
value: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// SealInfo is now imported from route-extraction.ts and re-exported
|
|
55
|
+
|
|
56
|
+
export type ModeOfTransport = 'VESSEL' | 'RAIL' | 'TRUCK' | 'BARGE' | 'AIR'
|
|
57
|
+
export type EmptyIndicatorCode = 'EMPTY' | 'LADEN'
|
|
58
|
+
export type FacilityCodeListProvider = 'SMDG' | 'BIC'
|
|
59
|
+
|
|
60
|
+
// ─── TrackingJob ─────────────────────────────────────────────
|
|
61
|
+
// Declared first as it's referenced by Shipment and TrackingEvent
|
|
62
|
+
|
|
63
|
+
@Entity({ tableName: 'shipment_tracking_jobs' })
|
|
64
|
+
@Index({ name: 'st_jobs_org_tenant_idx', properties: ['organizationId', 'tenantId'] })
|
|
65
|
+
@Index({ name: 'st_jobs_status_idx', properties: ['status'] })
|
|
66
|
+
@Index({ name: 'st_jobs_next_poll_idx', properties: ['nextPollAt'] })
|
|
67
|
+
export class TrackingJob {
|
|
68
|
+
[OptionalProps]?: 'createdAt' | 'updatedAt' | 'deletedAt' | 'status' | 'retryCount' | 'originUnlocode' | 'destinationUnlocode' | 'provider' | 'mode'
|
|
69
|
+
|
|
70
|
+
@PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
|
|
71
|
+
id!: string
|
|
72
|
+
|
|
73
|
+
@Property({ name: 'organization_id', type: 'uuid' })
|
|
74
|
+
organizationId!: string
|
|
75
|
+
|
|
76
|
+
@Property({ name: 'tenant_id', type: 'uuid' })
|
|
77
|
+
tenantId!: string
|
|
78
|
+
|
|
79
|
+
// Tracking source. 'carrier' = direct DCSA adapter (default); 'shipsgo' = aggregator fallback.
|
|
80
|
+
@Property({ type: 'text', default: 'carrier' })
|
|
81
|
+
provider: TrackingProvider = 'carrier'
|
|
82
|
+
|
|
83
|
+
// Transport mode. 'ocean' (default) or 'air'.
|
|
84
|
+
@Property({ type: 'text', default: 'ocean' })
|
|
85
|
+
mode: TrackingMode = 'ocean'
|
|
86
|
+
|
|
87
|
+
// For provider='shipsgo': the ShipsGo shipment id returned on registration,
|
|
88
|
+
// used for subsequent GET polls. Null until the job has been registered.
|
|
89
|
+
@Property({ name: 'provider_shipment_id', type: 'text', nullable: true })
|
|
90
|
+
providerShipmentId?: string | null
|
|
91
|
+
|
|
92
|
+
// For provider='carrier', the internal carrier code (SCAC-derived). For
|
|
93
|
+
// provider='shipsgo' ocean this may be a SCAC hint (optional — ShipsGo
|
|
94
|
+
// auto-detects) and for air it is unused (the AWB prefix identifies the airline).
|
|
95
|
+
@Property({ name: 'carrier_code', type: 'text' })
|
|
96
|
+
carrierCode!: string
|
|
97
|
+
|
|
98
|
+
@Property({ name: 'reference_type', type: 'text' })
|
|
99
|
+
referenceType!: TrackingReferenceType
|
|
100
|
+
|
|
101
|
+
@Property({ name: 'reference_value', type: 'text' })
|
|
102
|
+
referenceValue!: string
|
|
103
|
+
|
|
104
|
+
// Origin/destination are optional - will be auto-inferred from tracking events if not provided
|
|
105
|
+
@Property({ name: 'origin_unlocode', type: 'text', length: 5, nullable: true })
|
|
106
|
+
originUnlocode?: string | null
|
|
107
|
+
|
|
108
|
+
@Property({ name: 'destination_unlocode', type: 'text', length: 5, nullable: true })
|
|
109
|
+
destinationUnlocode?: string | null
|
|
110
|
+
|
|
111
|
+
@Property({ type: 'text', default: 'active' })
|
|
112
|
+
status: TrackingJobStatusEnum = 'active'
|
|
113
|
+
|
|
114
|
+
// JSON array of scheduled poll dates
|
|
115
|
+
@Property({ type: 'jsonb', nullable: true })
|
|
116
|
+
schedule?: string[] | null
|
|
117
|
+
|
|
118
|
+
@Property({ name: 'next_poll_at', type: Date, nullable: true })
|
|
119
|
+
nextPollAt?: Date | null
|
|
120
|
+
|
|
121
|
+
@Property({ name: 'last_poll_at', type: Date, nullable: true })
|
|
122
|
+
lastPollAt?: Date | null
|
|
123
|
+
|
|
124
|
+
@Property({ name: 'retry_count', type: 'integer', default: 0 })
|
|
125
|
+
retryCount: number = 0
|
|
126
|
+
|
|
127
|
+
@Property({ name: 'error_history', type: 'jsonb', nullable: true })
|
|
128
|
+
errorHistory?: Array<{ date: string; message: string }> | null
|
|
129
|
+
|
|
130
|
+
@Property({ name: 'created_at', type: Date, defaultRaw: 'now()' })
|
|
131
|
+
createdAt!: Date
|
|
132
|
+
|
|
133
|
+
@Property({ name: 'updated_at', type: Date, defaultRaw: 'now()', onUpdate: () => new Date() })
|
|
134
|
+
updatedAt!: Date
|
|
135
|
+
|
|
136
|
+
@Property({ name: 'deleted_at', type: Date, nullable: true })
|
|
137
|
+
deletedAt?: Date | null
|
|
138
|
+
|
|
139
|
+
// One TrackingJob can track multiple shipments (containers)
|
|
140
|
+
@OneToMany(() => Shipment, (s) => s.trackingJob)
|
|
141
|
+
shipments = new Collection<Shipment>(this)
|
|
142
|
+
|
|
143
|
+
// One TrackingJob has many TrackingEvents
|
|
144
|
+
@OneToMany(() => TrackingEvent, (e) => e.trackingJob)
|
|
145
|
+
events = new Collection<TrackingEvent>(this)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ─── Shipment ────────────────────────────────────────────────
|
|
149
|
+
|
|
150
|
+
@Entity({ tableName: 'shipment_tracking_shipments' })
|
|
151
|
+
@Index({ name: 'st_shipments_org_tenant_idx', properties: ['organizationId', 'tenantId'] })
|
|
152
|
+
@Index({ name: 'st_shipments_status_idx', properties: ['status'] })
|
|
153
|
+
@Index({ name: 'st_shipments_carrier_idx', properties: ['carrierCode'] })
|
|
154
|
+
@Index({ name: 'st_shipments_tracking_job_idx', properties: ['trackingJob'] })
|
|
155
|
+
export class Shipment {
|
|
156
|
+
[OptionalProps]?: 'isActive' | 'createdAt' | 'updatedAt' | 'deletedAt' | 'status' | 'eventCount' | 'trackingJob' | 'routeStops' | 'cargoEvents' | 'seals' | 'originLocation' | 'destinationLocation' | 'isoEquipmentCode' | 'mode'
|
|
157
|
+
|
|
158
|
+
@PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
|
|
159
|
+
id!: string
|
|
160
|
+
|
|
161
|
+
@Property({ name: 'organization_id', type: 'uuid' })
|
|
162
|
+
organizationId!: string
|
|
163
|
+
|
|
164
|
+
@Property({ name: 'tenant_id', type: 'uuid' })
|
|
165
|
+
tenantId!: string
|
|
166
|
+
|
|
167
|
+
@Property({ type: 'text', default: 'PENDING' })
|
|
168
|
+
status: ShipmentStatusEnum = 'PENDING'
|
|
169
|
+
|
|
170
|
+
// Transport mode. 'ocean' (default) or 'air'. Air shipments leave the
|
|
171
|
+
// container/vessel fields null and populate awb/flight/airline instead.
|
|
172
|
+
@Property({ type: 'text', default: 'ocean' })
|
|
173
|
+
mode: TrackingMode = 'ocean'
|
|
174
|
+
|
|
175
|
+
@Property({ name: 'carrier_code', type: 'text', nullable: true })
|
|
176
|
+
carrierCode?: string | null
|
|
177
|
+
|
|
178
|
+
@Property({ name: 'container_number', type: 'text', nullable: true })
|
|
179
|
+
containerNumber?: string | null
|
|
180
|
+
|
|
181
|
+
// ─── Air fields (mode='air') ───────────────────────────────────
|
|
182
|
+
@Property({ name: 'awb_number', type: 'text', nullable: true })
|
|
183
|
+
awbNumber?: string | null
|
|
184
|
+
|
|
185
|
+
@Property({ name: 'flight_number', type: 'text', nullable: true })
|
|
186
|
+
flightNumber?: string | null
|
|
187
|
+
|
|
188
|
+
@Property({ name: 'airline_code', type: 'text', nullable: true })
|
|
189
|
+
airlineCode?: string | null
|
|
190
|
+
|
|
191
|
+
@Property({ name: 'airline_name', type: 'text', nullable: true })
|
|
192
|
+
airlineName?: string | null
|
|
193
|
+
|
|
194
|
+
@Property({ name: 'iso_equipment_code', type: 'text', nullable: true })
|
|
195
|
+
isoEquipmentCode?: string | null // Container type (22G1, 45R1, etc.)
|
|
196
|
+
|
|
197
|
+
@Property({ name: 'booking_number', type: 'text', nullable: true })
|
|
198
|
+
bookingNumber?: string | null
|
|
199
|
+
|
|
200
|
+
@Property({ name: 'bol_number', type: 'text', nullable: true })
|
|
201
|
+
bolNumber?: string | null
|
|
202
|
+
|
|
203
|
+
// ─── Multi-source Timestamps (JSONB arrays) ────────────────────
|
|
204
|
+
// Each array tracks timestamps from multiple sources with full history (SCD pattern).
|
|
205
|
+
// Primary value is computed using "latest update wins" strategy.
|
|
206
|
+
// Use helpers from lib/timestamp-utils.ts: getLatestTimestamp(), getPrimaryTimestampValue()
|
|
207
|
+
@Property({ name: 'etd_timestamps', type: 'jsonb', nullable: true })
|
|
208
|
+
etdTimestamps?: ShipmentTimestampEntry[] | null
|
|
209
|
+
|
|
210
|
+
@Property({ name: 'eta_timestamps', type: 'jsonb', nullable: true })
|
|
211
|
+
etaTimestamps?: ShipmentTimestampEntry[] | null
|
|
212
|
+
|
|
213
|
+
@Property({ name: 'atd_timestamps', type: 'jsonb', nullable: true })
|
|
214
|
+
atdTimestamps?: ShipmentTimestampEntry[] | null
|
|
215
|
+
|
|
216
|
+
@Property({ name: 'ata_timestamps', type: 'jsonb', nullable: true })
|
|
217
|
+
ataTimestamps?: ShipmentTimestampEntry[] | null
|
|
218
|
+
|
|
219
|
+
// ─── Location Data (JSONB) ────────────────────────────────────
|
|
220
|
+
// Full origin/destination details including facility, address, coordinates.
|
|
221
|
+
// Populated from DCSA events, enriched with BIC API if needed.
|
|
222
|
+
|
|
223
|
+
@Property({ name: 'origin_location', type: 'jsonb', nullable: true })
|
|
224
|
+
originLocation?: FacilityLocation | null
|
|
225
|
+
|
|
226
|
+
@Property({ name: 'destination_location', type: 'jsonb', nullable: true })
|
|
227
|
+
destinationLocation?: FacilityLocation | null
|
|
228
|
+
|
|
229
|
+
// Vessel
|
|
230
|
+
@Property({ name: 'vessel_name', type: 'text', nullable: true })
|
|
231
|
+
vesselName?: string | null
|
|
232
|
+
|
|
233
|
+
@Property({ name: 'vessel_imo', type: 'text', nullable: true })
|
|
234
|
+
vesselImo?: string | null
|
|
235
|
+
|
|
236
|
+
@Property({ name: 'voyage_number', type: 'text', nullable: true })
|
|
237
|
+
voyageNumber?: string | null
|
|
238
|
+
|
|
239
|
+
@Property({ name: 'event_count', type: 'integer', default: 0 })
|
|
240
|
+
eventCount: number = 0
|
|
241
|
+
|
|
242
|
+
@Property({ name: 'last_event_at', type: Date, nullable: true })
|
|
243
|
+
lastEventAt?: Date | null
|
|
244
|
+
|
|
245
|
+
@Property({ type: 'jsonb', nullable: true })
|
|
246
|
+
extra?: Record<string, unknown> | null
|
|
247
|
+
|
|
248
|
+
// ─── Denormalized Route & Events (JSONB) ───────────────────────
|
|
249
|
+
// Pre-computed route stops and filtered cargo events for this specific container.
|
|
250
|
+
// Populated by TrackingService when processing events, eliminating extra API calls.
|
|
251
|
+
|
|
252
|
+
@Property({ name: 'route_stops', type: 'jsonb', nullable: true })
|
|
253
|
+
routeStops?: RouteStopEntry[] | null
|
|
254
|
+
|
|
255
|
+
@Property({ name: 'cargo_events', type: 'jsonb', nullable: true })
|
|
256
|
+
cargoEvents?: CargoEventEntry[] | null
|
|
257
|
+
|
|
258
|
+
// ─── Aggregated Seals ──────────────────────────────────────────
|
|
259
|
+
// All unique seals seen across all cargo events for this container.
|
|
260
|
+
// Deduplicated by seal number, keeping the most recent occurrence.
|
|
261
|
+
@Property({ type: 'jsonb', nullable: true })
|
|
262
|
+
seals?: SealInfo[] | null
|
|
263
|
+
|
|
264
|
+
@Property({ name: 'is_active', type: 'boolean', default: true })
|
|
265
|
+
isActive: boolean = true
|
|
266
|
+
|
|
267
|
+
@Property({ name: 'created_at', type: Date, defaultRaw: 'now()' })
|
|
268
|
+
createdAt!: Date
|
|
269
|
+
|
|
270
|
+
@Property({ name: 'updated_at', type: Date, defaultRaw: 'now()', onUpdate: () => new Date() })
|
|
271
|
+
updatedAt!: Date
|
|
272
|
+
|
|
273
|
+
@Property({ name: 'deleted_at', type: Date, nullable: true })
|
|
274
|
+
deletedAt?: Date | null
|
|
275
|
+
|
|
276
|
+
@Property({ name: 'created_by_user_id', type: 'uuid', nullable: true })
|
|
277
|
+
createdByUserId?: string | null
|
|
278
|
+
|
|
279
|
+
// Shipment belongs to a TrackingJob (nullable - shipment can exist without active tracking)
|
|
280
|
+
@ManyToOne(() => TrackingJob, { fieldName: 'tracking_job_id', nullable: true })
|
|
281
|
+
trackingJob?: TrackingJob | null
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// ─── TrackingEvent ───────────────────────────────────────────
|
|
285
|
+
|
|
286
|
+
@Entity({ tableName: 'shipment_tracking_events' })
|
|
287
|
+
@Index({ name: 'st_events_org_tenant_idx', properties: ['organizationId', 'tenantId'] })
|
|
288
|
+
@Index({ name: 'st_events_tracking_job_idx', properties: ['trackingJob'] })
|
|
289
|
+
@Index({ name: 'st_events_equipment_ref_idx', properties: ['equipmentReference'] })
|
|
290
|
+
@Index({ name: 'st_events_event_date_time_idx', properties: ['eventDateTime'] })
|
|
291
|
+
@Unique({ name: 'st_events_source_event_uniq', properties: ['trackingJob', 'source', 'sourceEventId'] })
|
|
292
|
+
export class TrackingEvent {
|
|
293
|
+
[OptionalProps]?: 'createdAt' | 'source'
|
|
294
|
+
|
|
295
|
+
@PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
|
|
296
|
+
id!: string
|
|
297
|
+
|
|
298
|
+
@Property({ name: 'organization_id', type: 'uuid' })
|
|
299
|
+
organizationId!: string
|
|
300
|
+
|
|
301
|
+
@Property({ name: 'tenant_id', type: 'uuid' })
|
|
302
|
+
tenantId!: string
|
|
303
|
+
|
|
304
|
+
// Event belongs to a TrackingJob (not Shipment)
|
|
305
|
+
@ManyToOne(() => TrackingJob, { fieldName: 'tracking_job_id' })
|
|
306
|
+
trackingJob!: TrackingJob
|
|
307
|
+
|
|
308
|
+
// ─── Event Source ──────────────────────────────────────────────
|
|
309
|
+
|
|
310
|
+
@Property({ type: 'text', default: 'dcsa' })
|
|
311
|
+
source: TrackingEventSource = 'dcsa'
|
|
312
|
+
|
|
313
|
+
@Property({ name: 'source_event_id', type: 'text', nullable: true })
|
|
314
|
+
sourceEventId?: string | null // Original ID from the source system (e.g., DCSA eventId)
|
|
315
|
+
|
|
316
|
+
// ─── Core Event Fields ─────────────────────────────────────────
|
|
317
|
+
|
|
318
|
+
@Property({ name: 'event_type', type: 'text' })
|
|
319
|
+
eventType!: TrackingEventType
|
|
320
|
+
|
|
321
|
+
@Property({ name: 'event_code', type: 'text' })
|
|
322
|
+
eventCode!: string
|
|
323
|
+
|
|
324
|
+
@Property({ name: 'event_classifier_code', type: 'text', nullable: true })
|
|
325
|
+
eventClassifierCode?: TrackingEventClassifierCode | null
|
|
326
|
+
|
|
327
|
+
@Property({ name: 'event_date_time', type: Date })
|
|
328
|
+
eventDateTime!: Date
|
|
329
|
+
|
|
330
|
+
@Property({ name: 'event_date_time_offset', type: 'text', nullable: true })
|
|
331
|
+
eventDateTimeOffset?: string | null
|
|
332
|
+
|
|
333
|
+
@Property({ type: 'text', nullable: true })
|
|
334
|
+
description?: string | null
|
|
335
|
+
|
|
336
|
+
@Property({ name: 'raw_data', type: 'jsonb', nullable: true })
|
|
337
|
+
rawData?: Record<string, unknown> | null
|
|
338
|
+
|
|
339
|
+
// ─── Equipment Fields (DCSA EQUIPMENT events) ──────────────────
|
|
340
|
+
|
|
341
|
+
@Property({ name: 'equipment_reference', type: 'text', nullable: true })
|
|
342
|
+
equipmentReference?: string | null // Container number (BIC ISO)
|
|
343
|
+
|
|
344
|
+
@Property({ name: 'iso_equipment_code', type: 'text', nullable: true })
|
|
345
|
+
isoEquipmentCode?: string | null // Container type (22G1, 45R1, etc.)
|
|
346
|
+
|
|
347
|
+
@Property({ name: 'empty_indicator_code', type: 'text', nullable: true })
|
|
348
|
+
emptyIndicatorCode?: EmptyIndicatorCode | null
|
|
349
|
+
|
|
350
|
+
@Property({ name: 'is_transshipment_move', type: 'boolean', nullable: true })
|
|
351
|
+
isTransshipmentMove?: boolean | null
|
|
352
|
+
|
|
353
|
+
// ─── Location Fields ───────────────────────────────────────────
|
|
354
|
+
|
|
355
|
+
@Property({ name: 'location_name', type: 'text', nullable: true })
|
|
356
|
+
locationName?: string | null
|
|
357
|
+
|
|
358
|
+
@Property({ name: 'location_unlocode', type: 'text', nullable: true })
|
|
359
|
+
locationUnlocode?: string | null
|
|
360
|
+
|
|
361
|
+
@Property({ name: 'location_country', type: 'text', nullable: true })
|
|
362
|
+
locationCountry?: string | null
|
|
363
|
+
|
|
364
|
+
// Human-friendly region names for AIS POI events (e.g. waypoints in open water that have
|
|
365
|
+
// no UN/LOCODE). Both locales are stored so the UI can localize at render; null for
|
|
366
|
+
// carrier (DCSA) events and unnamed POIs.
|
|
367
|
+
@Property({ name: 'region_name_pl', type: 'text', nullable: true })
|
|
368
|
+
regionNamePl?: string | null
|
|
369
|
+
|
|
370
|
+
@Property({ name: 'region_name_en', type: 'text', nullable: true })
|
|
371
|
+
regionNameEn?: string | null
|
|
372
|
+
|
|
373
|
+
@Property({ name: 'facility_code', type: 'text', nullable: true })
|
|
374
|
+
facilityCode?: string | null // Terminal/depot code (SMDG/BIC)
|
|
375
|
+
|
|
376
|
+
@Property({ name: 'facility_code_list_provider', type: 'text', nullable: true })
|
|
377
|
+
facilityCodeListProvider?: FacilityCodeListProvider | null
|
|
378
|
+
|
|
379
|
+
@Property({ name: 'facility_type_code', type: 'text', nullable: true })
|
|
380
|
+
facilityTypeCode?: string | null // POTE, DEPO, CLOC, COFS, INTE, etc.
|
|
381
|
+
|
|
382
|
+
@Property({ name: 'facility_address', type: 'text', nullable: true })
|
|
383
|
+
facilityAddress?: string | null // Full address string from carrier (DCSA otherFacility)
|
|
384
|
+
|
|
385
|
+
@Property({ type: 'float', nullable: true })
|
|
386
|
+
latitude?: number | null
|
|
387
|
+
|
|
388
|
+
@Property({ type: 'float', nullable: true })
|
|
389
|
+
longitude?: number | null
|
|
390
|
+
|
|
391
|
+
// ─── Transport Call Fields ─────────────────────────────────────
|
|
392
|
+
|
|
393
|
+
@Property({ name: 'transport_call_reference', type: 'text', nullable: true })
|
|
394
|
+
transportCallReference?: string | null
|
|
395
|
+
|
|
396
|
+
@Property({ name: 'mode_of_transport', type: 'text', nullable: true })
|
|
397
|
+
modeOfTransport?: ModeOfTransport | null
|
|
398
|
+
|
|
399
|
+
@Property({ name: 'vessel_name', type: 'text', nullable: true })
|
|
400
|
+
vesselName?: string | null
|
|
401
|
+
|
|
402
|
+
@Property({ name: 'vessel_imo', type: 'text', nullable: true })
|
|
403
|
+
vesselImo?: string | null
|
|
404
|
+
|
|
405
|
+
@Property({ name: 'voyage_number', type: 'text', nullable: true })
|
|
406
|
+
voyageNumber?: string | null
|
|
407
|
+
|
|
408
|
+
@Property({ name: 'carrier_service_code', type: 'text', nullable: true })
|
|
409
|
+
carrierServiceCode?: string | null
|
|
410
|
+
|
|
411
|
+
@Property({ name: 'carrier_export_voyage_number', type: 'text', nullable: true })
|
|
412
|
+
carrierExportVoyageNumber?: string | null
|
|
413
|
+
|
|
414
|
+
@Property({ name: 'carrier_import_voyage_number', type: 'text', nullable: true })
|
|
415
|
+
carrierImportVoyageNumber?: string | null
|
|
416
|
+
|
|
417
|
+
@Property({ name: 'universal_service_reference', type: 'text', nullable: true })
|
|
418
|
+
universalServiceReference?: string | null
|
|
419
|
+
|
|
420
|
+
@Property({ name: 'universal_export_voyage_reference', type: 'text', nullable: true })
|
|
421
|
+
universalExportVoyageReference?: string | null
|
|
422
|
+
|
|
423
|
+
@Property({ name: 'universal_import_voyage_reference', type: 'text', nullable: true })
|
|
424
|
+
universalImportVoyageReference?: string | null
|
|
425
|
+
|
|
426
|
+
@Property({ name: 'port_visit_reference', type: 'text', nullable: true })
|
|
427
|
+
portVisitReference?: string | null
|
|
428
|
+
|
|
429
|
+
// ─── Document References ───────────────────────────────────────
|
|
430
|
+
|
|
431
|
+
@Property({ name: 'related_document_references', type: 'jsonb', nullable: true })
|
|
432
|
+
relatedDocumentReferences?: DocumentReference[] | null
|
|
433
|
+
|
|
434
|
+
// ─── Metadata Fields ───────────────────────────────────────────
|
|
435
|
+
|
|
436
|
+
@Property({ name: 'event_created_date_time', type: Date, nullable: true })
|
|
437
|
+
eventCreatedDateTime?: Date | null
|
|
438
|
+
|
|
439
|
+
@Property({ name: 'retracted_event_id', type: 'text', nullable: true })
|
|
440
|
+
retractedEventId?: string | null
|
|
441
|
+
|
|
442
|
+
@Property({ name: 'publisher_name', type: 'text', nullable: true })
|
|
443
|
+
publisherName?: string | null
|
|
444
|
+
|
|
445
|
+
@Property({ name: 'publisher_role', type: 'text', nullable: true })
|
|
446
|
+
publisherRole?: string | null // CA, AG, VSL, TR, etc.
|
|
447
|
+
|
|
448
|
+
// ─── Additional Event Fields ───────────────────────────────────
|
|
449
|
+
|
|
450
|
+
@Property({ name: 'delay_reason_code', type: 'text', nullable: true })
|
|
451
|
+
delayReasonCode?: string | null // SMDG delay reason code
|
|
452
|
+
|
|
453
|
+
@Property({ name: 'change_remark', type: 'text', nullable: true })
|
|
454
|
+
changeRemark?: string | null
|
|
455
|
+
|
|
456
|
+
@Property({ type: 'jsonb', nullable: true })
|
|
457
|
+
seals?: SealInfo[] | null
|
|
458
|
+
|
|
459
|
+
// ─── Timestamps ────────────────────────────────────────────────
|
|
460
|
+
|
|
461
|
+
@Property({ name: 'created_at', type: Date, defaultRaw: 'now()' })
|
|
462
|
+
createdAt!: Date
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
// ─── CarrierConfig ───────────────────────────────────────────
|
|
468
|
+
|
|
469
|
+
@Entity({ tableName: 'shipment_tracking_carrier_configs' })
|
|
470
|
+
@Index({ name: 'st_carrier_configs_org_tenant_idx', properties: ['organizationId', 'tenantId'] })
|
|
471
|
+
@Unique({ name: 'st_carrier_configs_code_uniq', properties: ['organizationId', 'tenantId', 'carrierCode'] })
|
|
472
|
+
export class CarrierConfig {
|
|
473
|
+
[OptionalProps]?: 'isActive' | 'createdAt' | 'updatedAt' | 'deletedAt' | 'rateLimitRequests' | 'rateLimitWindowSeconds'
|
|
474
|
+
|
|
475
|
+
@PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
|
|
476
|
+
id!: string
|
|
477
|
+
|
|
478
|
+
@Property({ name: 'organization_id', type: 'uuid' })
|
|
479
|
+
organizationId!: string
|
|
480
|
+
|
|
481
|
+
@Property({ name: 'tenant_id', type: 'uuid' })
|
|
482
|
+
tenantId!: string
|
|
483
|
+
|
|
484
|
+
@Property({ name: 'carrier_code', type: 'text' })
|
|
485
|
+
carrierCode!: string
|
|
486
|
+
|
|
487
|
+
@Property({ name: 'api_endpoint', type: 'text', nullable: true })
|
|
488
|
+
apiEndpoint?: string | null
|
|
489
|
+
|
|
490
|
+
@Property({ name: 'auth_config', type: 'jsonb', nullable: true })
|
|
491
|
+
authConfig?: Record<string, unknown> | null
|
|
492
|
+
|
|
493
|
+
@Property({ name: 'rate_limit_requests', type: 'integer', default: 60 })
|
|
494
|
+
rateLimitRequests: number = 60
|
|
495
|
+
|
|
496
|
+
@Property({ name: 'rate_limit_window_seconds', type: 'integer', default: 60 })
|
|
497
|
+
rateLimitWindowSeconds: number = 60
|
|
498
|
+
|
|
499
|
+
@Property({ name: 'is_active', type: 'boolean', default: true })
|
|
500
|
+
isActive: boolean = true
|
|
501
|
+
|
|
502
|
+
@Property({ name: 'created_at', type: Date, defaultRaw: 'now()' })
|
|
503
|
+
createdAt!: Date
|
|
504
|
+
|
|
505
|
+
@Property({ name: 'updated_at', type: Date, defaultRaw: 'now()', onUpdate: () => new Date() })
|
|
506
|
+
updatedAt!: Date
|
|
507
|
+
|
|
508
|
+
@Property({ name: 'deleted_at', type: Date, nullable: true })
|
|
509
|
+
deletedAt?: Date | null
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// ─── BicConfig ───────────────────────────────────────────────
|
|
513
|
+
// Per-tenant configuration for BIC Facility API enrichment
|
|
514
|
+
|
|
515
|
+
@Entity({ tableName: 'shipment_tracking_bic_configs' })
|
|
516
|
+
@Index({ name: 'st_bic_configs_org_tenant_idx', properties: ['organizationId', 'tenantId'] })
|
|
517
|
+
@Unique({ name: 'st_bic_configs_scope_unique', properties: ['organizationId', 'tenantId'] })
|
|
518
|
+
export class BicConfig {
|
|
519
|
+
[OptionalProps]?: 'isEnabled' | 'createdAt' | 'updatedAt' | 'baseUrl'
|
|
520
|
+
|
|
521
|
+
@PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
|
|
522
|
+
id!: string
|
|
523
|
+
|
|
524
|
+
@Property({ name: 'organization_id', type: 'uuid' })
|
|
525
|
+
organizationId!: string
|
|
526
|
+
|
|
527
|
+
@Property({ name: 'tenant_id', type: 'uuid' })
|
|
528
|
+
tenantId!: string
|
|
529
|
+
|
|
530
|
+
@Property({ name: 'is_enabled', type: 'boolean', default: false })
|
|
531
|
+
isEnabled: boolean = false
|
|
532
|
+
|
|
533
|
+
@Property({ type: 'text' })
|
|
534
|
+
username!: string
|
|
535
|
+
|
|
536
|
+
@Property({ type: 'text' })
|
|
537
|
+
password!: string // Encrypted via tenant data encryption
|
|
538
|
+
|
|
539
|
+
@Property({ name: 'base_url', type: 'text', default: 'https://api.bic-code.org' })
|
|
540
|
+
baseUrl: string = 'https://api.bic-code.org'
|
|
541
|
+
|
|
542
|
+
@Property({ name: 'created_at', type: Date, defaultRaw: 'now()' })
|
|
543
|
+
createdAt!: Date
|
|
544
|
+
|
|
545
|
+
@Property({ name: 'updated_at', type: Date, defaultRaw: 'now()', onUpdate: () => new Date() })
|
|
546
|
+
updatedAt!: Date
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// ─── ShipsGoConfig ───────────────────────────────────────────
|
|
550
|
+
// Per-tenant configuration for the ShipsGo aggregator (fallback tracking for
|
|
551
|
+
// unsupported ocean carriers + air). One row per organization/tenant. The API
|
|
552
|
+
// token is encrypted at rest (see encryption.ts); a platform env var is the
|
|
553
|
+
// fallback when no row exists.
|
|
554
|
+
|
|
555
|
+
@Entity({ tableName: 'shipment_tracking_shipsgo_configs' })
|
|
556
|
+
@Index({ name: 'st_shipsgo_configs_org_tenant_idx', properties: ['organizationId', 'tenantId'] })
|
|
557
|
+
@Unique({ name: 'st_shipsgo_configs_scope_unique', properties: ['organizationId', 'tenantId'] })
|
|
558
|
+
export class ShipsGoConfig {
|
|
559
|
+
[OptionalProps]?: 'isEnabled' | 'createdAt' | 'updatedAt' | 'deletedAt' | 'baseUrl' | 'oceanEnabled' | 'airEnabled' | 'isActive' | 'rateLimitRequests' | 'rateLimitWindowSeconds'
|
|
560
|
+
|
|
561
|
+
@PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
|
|
562
|
+
id!: string
|
|
563
|
+
|
|
564
|
+
@Property({ name: 'organization_id', type: 'uuid' })
|
|
565
|
+
organizationId!: string
|
|
566
|
+
|
|
567
|
+
@Property({ name: 'tenant_id', type: 'uuid' })
|
|
568
|
+
tenantId!: string
|
|
569
|
+
|
|
570
|
+
@Property({ name: 'is_enabled', type: 'boolean', default: false })
|
|
571
|
+
isEnabled: boolean = false
|
|
572
|
+
|
|
573
|
+
@Property({ name: 'api_token', type: 'text' })
|
|
574
|
+
apiToken!: string // Encrypted via tenant data encryption (see encryption.ts)
|
|
575
|
+
|
|
576
|
+
@Property({ name: 'base_url', type: 'text', default: 'https://api.shipsgo.com/v2' })
|
|
577
|
+
baseUrl: string = 'https://api.shipsgo.com/v2'
|
|
578
|
+
|
|
579
|
+
@Property({ name: 'ocean_enabled', type: 'boolean', default: true })
|
|
580
|
+
oceanEnabled: boolean = true
|
|
581
|
+
|
|
582
|
+
@Property({ name: 'air_enabled', type: 'boolean', default: true })
|
|
583
|
+
airEnabled: boolean = true
|
|
584
|
+
|
|
585
|
+
@Property({ name: 'rate_limit_requests', type: 'integer', default: 60 })
|
|
586
|
+
rateLimitRequests: number = 60
|
|
587
|
+
|
|
588
|
+
@Property({ name: 'rate_limit_window_seconds', type: 'integer', default: 60 })
|
|
589
|
+
rateLimitWindowSeconds: number = 60
|
|
590
|
+
|
|
591
|
+
@Property({ name: 'is_active', type: 'boolean', default: true })
|
|
592
|
+
isActive: boolean = true
|
|
593
|
+
|
|
594
|
+
@Property({ name: 'created_at', type: Date, defaultRaw: 'now()' })
|
|
595
|
+
createdAt!: Date
|
|
596
|
+
|
|
597
|
+
@Property({ name: 'updated_at', type: Date, defaultRaw: 'now()', onUpdate: () => new Date() })
|
|
598
|
+
updatedAt!: Date
|
|
599
|
+
|
|
600
|
+
@Property({ name: 'deleted_at', type: Date, nullable: true })
|
|
601
|
+
deletedAt?: Date | null
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
// ─── Webhook ─────────────────────────────────────────────────
|
|
605
|
+
|
|
606
|
+
@Entity({ tableName: 'shipment_tracking_webhooks' })
|
|
607
|
+
@Index({ name: 'st_webhooks_org_tenant_idx', properties: ['organizationId', 'tenantId'] })
|
|
608
|
+
export class Webhook {
|
|
609
|
+
[OptionalProps]?: 'isActive' | 'createdAt' | 'updatedAt' | 'deletedAt'
|
|
610
|
+
|
|
611
|
+
@PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
|
|
612
|
+
id!: string
|
|
613
|
+
|
|
614
|
+
@Property({ name: 'organization_id', type: 'uuid' })
|
|
615
|
+
organizationId!: string
|
|
616
|
+
|
|
617
|
+
@Property({ name: 'tenant_id', type: 'uuid' })
|
|
618
|
+
tenantId!: string
|
|
619
|
+
|
|
620
|
+
@Property({ type: 'text' })
|
|
621
|
+
url!: string
|
|
622
|
+
|
|
623
|
+
@Property({ name: 'events_subscribed', type: 'jsonb' })
|
|
624
|
+
eventsSubscribed!: string[]
|
|
625
|
+
|
|
626
|
+
@Property({ name: 'hmac_secret', type: 'text', nullable: true })
|
|
627
|
+
hmacSecret?: string | null
|
|
628
|
+
|
|
629
|
+
@Property({ name: 'is_active', type: 'boolean', default: true })
|
|
630
|
+
isActive: boolean = true
|
|
631
|
+
|
|
632
|
+
@Property({ name: 'created_at', type: Date, defaultRaw: 'now()' })
|
|
633
|
+
createdAt!: Date
|
|
634
|
+
|
|
635
|
+
@Property({ name: 'updated_at', type: Date, defaultRaw: 'now()', onUpdate: () => new Date() })
|
|
636
|
+
updatedAt!: Date
|
|
637
|
+
|
|
638
|
+
@Property({ name: 'deleted_at', type: Date, nullable: true })
|
|
639
|
+
deletedAt?: Date | null
|
|
640
|
+
|
|
641
|
+
@OneToMany(() => WebhookDelivery, (delivery) => delivery.webhook)
|
|
642
|
+
deliveries = new Collection<WebhookDelivery>(this)
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
// ─── LocationOverride ────────────────────────────────────────
|
|
646
|
+
// Per-tenant location data corrections for BIC/SMDG facilities
|
|
647
|
+
|
|
648
|
+
@Entity({ tableName: 'shipment_tracking_location_overrides' })
|
|
649
|
+
@Unique({
|
|
650
|
+
name: 'st_location_overrides_match_uniq',
|
|
651
|
+
properties: ['organizationId', 'tenantId', 'carrierCode', 'unlocode', 'facilityCode', 'facilityCodeListProvider'],
|
|
652
|
+
})
|
|
653
|
+
@Index({ name: 'st_location_overrides_org_tenant_idx', properties: ['organizationId', 'tenantId'] })
|
|
654
|
+
@Index({ name: 'st_location_overrides_lookup_idx', properties: ['unlocode', 'facilityCode', 'facilityCodeListProvider'] })
|
|
655
|
+
export class LocationOverride {
|
|
656
|
+
[OptionalProps]?: 'isActive' | 'createdAt' | 'updatedAt' | 'deletedAt' | 'carrierCode' | 'description'
|
|
657
|
+
|
|
658
|
+
@PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
|
|
659
|
+
id!: string
|
|
660
|
+
|
|
661
|
+
@Property({ name: 'organization_id', type: 'uuid' })
|
|
662
|
+
organizationId!: string
|
|
663
|
+
|
|
664
|
+
@Property({ name: 'tenant_id', type: 'uuid' })
|
|
665
|
+
tenantId!: string
|
|
666
|
+
|
|
667
|
+
// Match criteria
|
|
668
|
+
@Property({ name: 'carrier_code', type: 'text', nullable: true })
|
|
669
|
+
carrierCode?: string | null // null = applies to all carriers
|
|
670
|
+
|
|
671
|
+
@Property({ name: 'unlocode', type: 'text', length: 5 })
|
|
672
|
+
unlocode!: string // e.g., "PLGDN"
|
|
673
|
+
|
|
674
|
+
@Property({ name: 'facility_code', type: 'text' })
|
|
675
|
+
facilityCode!: string // e.g., "PLGDA"
|
|
676
|
+
|
|
677
|
+
@Property({ name: 'facility_code_list_provider', type: 'text' })
|
|
678
|
+
facilityCodeListProvider!: FacilityCodeListProvider // BIC or SMDG
|
|
679
|
+
|
|
680
|
+
// Override data (partial FacilityLocation fields)
|
|
681
|
+
@Property({ name: 'override_data', type: 'jsonb' })
|
|
682
|
+
overrideData!: Partial<FacilityLocation>
|
|
683
|
+
|
|
684
|
+
// Metadata
|
|
685
|
+
@Property({ type: 'text', nullable: true })
|
|
686
|
+
description?: string | null // Optional note about why override exists
|
|
687
|
+
|
|
688
|
+
@Property({ name: 'is_active', type: 'boolean', default: true })
|
|
689
|
+
isActive: boolean = true
|
|
690
|
+
|
|
691
|
+
@Property({ name: 'created_at', type: Date, defaultRaw: 'now()' })
|
|
692
|
+
createdAt!: Date
|
|
693
|
+
|
|
694
|
+
@Property({ name: 'updated_at', type: Date, defaultRaw: 'now()', onUpdate: () => new Date() })
|
|
695
|
+
updatedAt!: Date
|
|
696
|
+
|
|
697
|
+
@Property({ name: 'deleted_at', type: Date, nullable: true })
|
|
698
|
+
deletedAt?: Date | null
|
|
699
|
+
|
|
700
|
+
@Property({ name: 'created_by_user_id', type: 'uuid', nullable: true })
|
|
701
|
+
createdByUserId?: string | null
|
|
702
|
+
|
|
703
|
+
@Property({ name: 'updated_by_user_id', type: 'uuid', nullable: true })
|
|
704
|
+
updatedByUserId?: string | null
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
// ─── WebhookDelivery ─────────────────────────────────────────
|
|
708
|
+
|
|
709
|
+
@Entity({ tableName: 'shipment_tracking_webhook_deliveries' })
|
|
710
|
+
@Index({ name: 'st_webhook_deliveries_webhook_idx', properties: ['webhook'] })
|
|
711
|
+
@Index({ name: 'st_webhook_deliveries_status_idx', properties: ['status'] })
|
|
712
|
+
@Index({ name: 'st_webhook_deliveries_next_retry_idx', properties: ['nextRetryAt'] })
|
|
713
|
+
export class WebhookDelivery {
|
|
714
|
+
[OptionalProps]?: 'createdAt' | 'status' | 'retryCount'
|
|
715
|
+
|
|
716
|
+
@PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
|
|
717
|
+
id!: string
|
|
718
|
+
|
|
719
|
+
@ManyToOne(() => Webhook, { fieldName: 'webhook_id' })
|
|
720
|
+
webhook!: Webhook
|
|
721
|
+
|
|
722
|
+
@Property({ name: 'event_type', type: 'text' })
|
|
723
|
+
eventType!: string
|
|
724
|
+
|
|
725
|
+
@Property({ type: 'text', default: 'pending' })
|
|
726
|
+
status: WebhookDeliveryStatus = 'pending'
|
|
727
|
+
|
|
728
|
+
@Property({ name: 'retry_count', type: 'integer', default: 0 })
|
|
729
|
+
retryCount: number = 0
|
|
730
|
+
|
|
731
|
+
@Property({ name: 'next_retry_at', type: Date, nullable: true })
|
|
732
|
+
nextRetryAt?: Date | null
|
|
733
|
+
|
|
734
|
+
@Property({ type: 'jsonb' })
|
|
735
|
+
payload!: Record<string, unknown>
|
|
736
|
+
|
|
737
|
+
@Property({ name: 'response_status', type: 'integer', nullable: true })
|
|
738
|
+
responseStatus?: number | null
|
|
739
|
+
|
|
740
|
+
@Property({ name: 'response_body', type: 'text', nullable: true })
|
|
741
|
+
responseBody?: string | null
|
|
742
|
+
|
|
743
|
+
@Property({ name: 'error_message', type: 'text', nullable: true })
|
|
744
|
+
errorMessage?: string | null
|
|
745
|
+
|
|
746
|
+
@Property({ name: 'created_at', type: Date, defaultRaw: 'now()' })
|
|
747
|
+
createdAt!: Date
|
|
748
|
+
}
|