@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,228 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { useCallback, useMemo, useState } from 'react'
|
|
5
|
+
import { Page, PageBody } from '@freighttech/ui/backend/Page'
|
|
6
|
+
import { BooleanIcon } from '@freighttech/ui/backend/ValueIcons'
|
|
7
|
+
import { Button } from '@freighttech/ui/primitives-v2'
|
|
8
|
+
import {
|
|
9
|
+
DynamicTable,
|
|
10
|
+
TableSkeleton,
|
|
11
|
+
useDynamicTablePage,
|
|
12
|
+
} from '@freighttech/ui/backend/dynamic-table'
|
|
13
|
+
import type { ColumnDef, ContextMenuAction } from '@freighttech/ui/backend/dynamic-table'
|
|
14
|
+
import { apiCallOrThrow } from '@freighttech/ui/backend/utils/apiCall'
|
|
15
|
+
import { flash } from '@freighttech/ui/backend/FlashMessages'
|
|
16
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
17
|
+
import { Plus } from 'lucide-react'
|
|
18
|
+
import { WebhookDrawer } from '../../components/WebhookDrawer'
|
|
19
|
+
|
|
20
|
+
type WebhookRow = {
|
|
21
|
+
id: string
|
|
22
|
+
url: string
|
|
23
|
+
eventsSubscribed: string[]
|
|
24
|
+
isActive: boolean
|
|
25
|
+
createdAt: string | null
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function mapItem(item: Record<string, unknown>): WebhookRow | null {
|
|
29
|
+
const id = typeof item.id === 'string' ? item.id : null
|
|
30
|
+
if (!id) return null
|
|
31
|
+
|
|
32
|
+
const eventsRaw = item.eventsSubscribed ?? item.events_subscribed
|
|
33
|
+
const eventsSubscribed = Array.isArray(eventsRaw) ? eventsRaw as string[] : []
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
id,
|
|
37
|
+
url: (item.url as string) ?? '',
|
|
38
|
+
eventsSubscribed,
|
|
39
|
+
isActive: item.isActive === true || item.is_active === true,
|
|
40
|
+
createdAt: (item.createdAt as string) ?? (item.created_at as string) ?? null,
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default function WebhooksPage() {
|
|
45
|
+
const t = useT()
|
|
46
|
+
const [drawerOpen, setDrawerOpen] = useState(false)
|
|
47
|
+
const [drawerMode, setDrawerMode] = useState<'create' | 'edit'>('create')
|
|
48
|
+
const [selectedWebhookId, setSelectedWebhookId] = useState<string | undefined>(undefined)
|
|
49
|
+
|
|
50
|
+
const columns = useMemo<ColumnDef[]>(
|
|
51
|
+
() => [
|
|
52
|
+
{
|
|
53
|
+
data: 'url',
|
|
54
|
+
title: t('shipment_tracking.webhooks.fields.url', 'URL'),
|
|
55
|
+
width: 300,
|
|
56
|
+
readOnly: true,
|
|
57
|
+
renderer: (value: unknown) => (
|
|
58
|
+
<span className="font-medium text-sm truncate max-w-[280px] block">{String(value ?? '')}</span>
|
|
59
|
+
),
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
data: 'eventsSubscribed',
|
|
63
|
+
title: t('shipment_tracking.webhooks.fields.eventsSubscribed', 'Subscribed Events'),
|
|
64
|
+
width: 300,
|
|
65
|
+
readOnly: true,
|
|
66
|
+
renderer: (value: unknown) => {
|
|
67
|
+
const events = Array.isArray(value) ? value : []
|
|
68
|
+
return <span className="text-sm">{events.join(', ') || '-'}</span>
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
data: 'isActive',
|
|
73
|
+
title: t('shipment_tracking.webhooks.fields.isActive', 'Active'),
|
|
74
|
+
width: 80,
|
|
75
|
+
readOnly: true,
|
|
76
|
+
renderer: (value: unknown) => <BooleanIcon value={value === true || value === 'true'} />,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
[t],
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
const handleRowClick = useCallback((_rowIndex: number, rowData: Record<string, unknown>) => {
|
|
83
|
+
const id = rowData?.id as string | undefined
|
|
84
|
+
if (id) {
|
|
85
|
+
setDrawerMode('edit')
|
|
86
|
+
setSelectedWebhookId(id)
|
|
87
|
+
setDrawerOpen(true)
|
|
88
|
+
}
|
|
89
|
+
}, [])
|
|
90
|
+
|
|
91
|
+
const createButton = useMemo(
|
|
92
|
+
() => (
|
|
93
|
+
<Button
|
|
94
|
+
variant="primary"
|
|
95
|
+
size="sm"
|
|
96
|
+
icon={<Plus className="h-4 w-4" />}
|
|
97
|
+
onClick={() => {
|
|
98
|
+
setDrawerMode('create')
|
|
99
|
+
setSelectedWebhookId(undefined)
|
|
100
|
+
setDrawerOpen(true)
|
|
101
|
+
}}
|
|
102
|
+
>
|
|
103
|
+
{t('shipment_tracking.webhooks.create', 'Create Webhook')}
|
|
104
|
+
</Button>
|
|
105
|
+
),
|
|
106
|
+
[t],
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
const table = useDynamicTablePage<WebhookRow>({
|
|
110
|
+
source: '/api/shipment_tracking/webhooks',
|
|
111
|
+
// Saved views. Without this the perspective tab strip auto-hides
|
|
112
|
+
// (hidePerspectiveTabs ?? !hasPerspectives), so users cannot save or
|
|
113
|
+
// switch a view on this list at all.
|
|
114
|
+
perspectives: 'shipment_tracking_webhooks',
|
|
115
|
+
columns,
|
|
116
|
+
tableName: t('shipment_tracking.webhooks.title', 'Webhooks'),
|
|
117
|
+
defaultPageSize: 20,
|
|
118
|
+
mapApiItem: mapItem,
|
|
119
|
+
cellEdit: false,
|
|
120
|
+
tableProps: {
|
|
121
|
+
height: 'fill',
|
|
122
|
+
onRowClick: handleRowClick,
|
|
123
|
+
uiConfig: {
|
|
124
|
+
readOnlyStyle: 'normal',
|
|
125
|
+
hideAddRowButton: true,
|
|
126
|
+
searchBarEnd: createButton,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
const handleDelete = useCallback(
|
|
132
|
+
async (id: string) => {
|
|
133
|
+
if (!confirm('Delete this webhook?')) return
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
await apiCallOrThrow('/api/shipment_tracking/webhooks', {
|
|
137
|
+
method: 'DELETE',
|
|
138
|
+
body: JSON.stringify({ id }),
|
|
139
|
+
})
|
|
140
|
+
flash('Webhook deleted', 'success')
|
|
141
|
+
table.refresh()
|
|
142
|
+
} catch {
|
|
143
|
+
flash('Failed to delete webhook', 'error')
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
[table.refresh],
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
const handleTest = useCallback(
|
|
150
|
+
async (id: string) => {
|
|
151
|
+
try {
|
|
152
|
+
const { result } = await apiCallOrThrow<{ success: boolean; deliveryId: string }>(
|
|
153
|
+
'/api/shipment_tracking/webhooks/test',
|
|
154
|
+
{
|
|
155
|
+
method: 'POST',
|
|
156
|
+
body: JSON.stringify({ id }),
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
if (result?.success) {
|
|
160
|
+
flash(t('shipment_tracking.webhooks.flash.testSent', 'Test webhook sent successfully'), 'success')
|
|
161
|
+
} else {
|
|
162
|
+
flash(t('shipment_tracking.webhooks.flash.testFailed', 'Failed to send test webhook'), 'error')
|
|
163
|
+
}
|
|
164
|
+
} catch (error) {
|
|
165
|
+
const message = error instanceof Error ? error.message : t('shipment_tracking.webhooks.flash.testFailed', 'Failed to send test webhook')
|
|
166
|
+
flash(message, 'error')
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
[t],
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
const rowActions = useCallback(
|
|
173
|
+
(rowData: any): ContextMenuAction[] => {
|
|
174
|
+
if (!rowData?.id) return []
|
|
175
|
+
return [
|
|
176
|
+
{ id: 'test', label: t('shipment_tracking.webhooks.actions.test', 'Test Webhook') },
|
|
177
|
+
{ id: 'delete', label: 'Delete' },
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
[t],
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
const handleRowAction = useCallback(
|
|
184
|
+
(actionId: string, rowData: any) => {
|
|
185
|
+
const id = rowData?.id as string | undefined
|
|
186
|
+
if (!id) return
|
|
187
|
+
if (actionId === 'test') handleTest(id)
|
|
188
|
+
else if (actionId === 'delete') handleDelete(id)
|
|
189
|
+
},
|
|
190
|
+
[handleTest, handleDelete],
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
if (table.isLoading) {
|
|
194
|
+
return (
|
|
195
|
+
<Page>
|
|
196
|
+
<PageBody>
|
|
197
|
+
<TableSkeleton rows={10} columns={3} />
|
|
198
|
+
</PageBody>
|
|
199
|
+
</Page>
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<Page>
|
|
205
|
+
<PageBody>
|
|
206
|
+
<div className="-mx-4 lg:-mx-6">
|
|
207
|
+
<DynamicTable
|
|
208
|
+
{...table.props}
|
|
209
|
+
striped
|
|
210
|
+
density="md"
|
|
211
|
+
rowActions={rowActions}
|
|
212
|
+
onRowAction={handleRowAction}
|
|
213
|
+
/>
|
|
214
|
+
</div>
|
|
215
|
+
|
|
216
|
+
<WebhookDrawer
|
|
217
|
+
open={drawerOpen}
|
|
218
|
+
onOpenChange={setDrawerOpen}
|
|
219
|
+
mode={drawerMode}
|
|
220
|
+
webhookId={selectedWebhookId}
|
|
221
|
+
onSaved={() => {
|
|
222
|
+
table.refresh()
|
|
223
|
+
}}
|
|
224
|
+
/>
|
|
225
|
+
</PageBody>
|
|
226
|
+
</Page>
|
|
227
|
+
)
|
|
228
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const entities = [
|
|
2
|
+
{
|
|
3
|
+
id: 'shipment_tracking:shipment',
|
|
4
|
+
label: 'Shipment',
|
|
5
|
+
description: 'Ocean container shipment tracked across carriers.',
|
|
6
|
+
labelField: 'containerNumber',
|
|
7
|
+
showInSidebar: false,
|
|
8
|
+
fields: [],
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
id: 'shipment_tracking:tracking_job',
|
|
12
|
+
label: 'Tracking Job',
|
|
13
|
+
description: 'Scheduled polling job for a shipment carrier.',
|
|
14
|
+
labelField: 'referenceValue',
|
|
15
|
+
showInSidebar: false,
|
|
16
|
+
defaultEditor: false,
|
|
17
|
+
fields: [],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 'shipment_tracking:cargo_event',
|
|
21
|
+
label: 'Cargo Event',
|
|
22
|
+
description: 'Individual tracking event for a shipment.',
|
|
23
|
+
labelField: 'eventCode',
|
|
24
|
+
showInSidebar: false,
|
|
25
|
+
defaultEditor: false,
|
|
26
|
+
fields: [],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: 'shipment_tracking:carrier_config',
|
|
30
|
+
label: 'Carrier Config',
|
|
31
|
+
description: 'Carrier API configuration with authentication credentials.',
|
|
32
|
+
labelField: 'carrierCode',
|
|
33
|
+
showInSidebar: false,
|
|
34
|
+
defaultEditor: false,
|
|
35
|
+
fields: [],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 'shipment_tracking:webhook',
|
|
39
|
+
label: 'Webhook',
|
|
40
|
+
description: 'Webhook endpoint for shipment tracking event notifications.',
|
|
41
|
+
labelField: 'url',
|
|
42
|
+
showInSidebar: false,
|
|
43
|
+
defaultEditor: false,
|
|
44
|
+
fields: [],
|
|
45
|
+
},
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
export default entities
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import type { ModuleCli } from '@open-mercato/shared/modules/registry'
|
|
2
|
+
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
3
|
+
import type { PoiNatsService } from './services/poiNatsService'
|
|
4
|
+
|
|
5
|
+
// ─── Argument Parser ────────────────────────────────────────────
|
|
6
|
+
|
|
7
|
+
function parseArgs(args: string[]): Record<string, string | boolean> {
|
|
8
|
+
const result: Record<string, string | boolean> = {}
|
|
9
|
+
|
|
10
|
+
for (let i = 0; i < args.length; i++) {
|
|
11
|
+
const arg = args[i]
|
|
12
|
+
|
|
13
|
+
if (arg.startsWith('--')) {
|
|
14
|
+
const key = arg.slice(2)
|
|
15
|
+
|
|
16
|
+
if (arg.includes('=')) {
|
|
17
|
+
const [k, v] = arg.slice(2).split('=')
|
|
18
|
+
result[k] = v
|
|
19
|
+
} else {
|
|
20
|
+
const nextArg = args[i + 1]
|
|
21
|
+
if (nextArg && !nextArg.startsWith('--')) {
|
|
22
|
+
result[key] = nextArg
|
|
23
|
+
i++
|
|
24
|
+
} else {
|
|
25
|
+
result[key] = true
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return result
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ─── Scheduler Service Type ─────────────────────────────────────
|
|
35
|
+
|
|
36
|
+
type SchedulerServiceType = {
|
|
37
|
+
register: (registration: {
|
|
38
|
+
name: string
|
|
39
|
+
description?: string
|
|
40
|
+
scopeType: 'system' | 'organization' | 'tenant'
|
|
41
|
+
organizationId?: string
|
|
42
|
+
tenantId?: string
|
|
43
|
+
scheduleType: 'cron' | 'interval'
|
|
44
|
+
scheduleValue: string
|
|
45
|
+
timezone?: string
|
|
46
|
+
targetType: 'queue' | 'command'
|
|
47
|
+
targetQueue?: string
|
|
48
|
+
targetCommand?: string
|
|
49
|
+
targetPayload?: unknown
|
|
50
|
+
sourceType?: 'user' | 'module'
|
|
51
|
+
sourceModule?: string
|
|
52
|
+
isEnabled?: boolean
|
|
53
|
+
}) => Promise<void>
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ─── Setup Schedules Command ────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Register scheduled jobs for shipment tracking
|
|
60
|
+
*
|
|
61
|
+
* This command registers the daily poll and pre-arrival evaluation schedules
|
|
62
|
+
* for an organization.
|
|
63
|
+
*
|
|
64
|
+
* Usage:
|
|
65
|
+
* yarn mercato shipment_tracking setup-schedules --tenant <tenantId> --org <organizationId>
|
|
66
|
+
*
|
|
67
|
+
* After running, start the scheduler to sync with BullMQ:
|
|
68
|
+
* yarn mercato scheduler start
|
|
69
|
+
*/
|
|
70
|
+
const setupSchedulesCommand: ModuleCli = {
|
|
71
|
+
command: 'setup-schedules',
|
|
72
|
+
async run(rest) {
|
|
73
|
+
const args = parseArgs(rest)
|
|
74
|
+
const tenantId = String(args.tenantId ?? args.tenant ?? '')
|
|
75
|
+
const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? '')
|
|
76
|
+
|
|
77
|
+
if (!tenantId || !organizationId) {
|
|
78
|
+
console.error(
|
|
79
|
+
'Usage: mercato shipment_tracking setup-schedules --tenant <tenantId> --org <organizationId>',
|
|
80
|
+
)
|
|
81
|
+
console.error('')
|
|
82
|
+
console.error('This command registers the scheduled jobs for shipment tracking:')
|
|
83
|
+
console.error(' - Daily poll schedule (6:00 AM UTC): polls all active tracking jobs')
|
|
84
|
+
console.error(' - Pre-arrival evaluation (every 6h): upgrades IN_TRANSIT → PRE_ARRIVAL')
|
|
85
|
+
console.error('')
|
|
86
|
+
console.error('After running, sync with BullMQ:')
|
|
87
|
+
console.error(' yarn mercato scheduler start')
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const { resolve } = await createRequestContainer()
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
const schedulerService = resolve<SchedulerServiceType>('schedulerService')
|
|
95
|
+
|
|
96
|
+
if (!schedulerService) {
|
|
97
|
+
console.error('❌ Scheduler service not available.')
|
|
98
|
+
console.error(' Make sure the scheduler module is installed and configured.')
|
|
99
|
+
process.exit(1)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
console.log('📅 Registering shipment tracking schedules...\n')
|
|
103
|
+
|
|
104
|
+
// Register daily poll schedule
|
|
105
|
+
await schedulerService.register({
|
|
106
|
+
name: 'Daily Shipment Tracking Poll',
|
|
107
|
+
description:
|
|
108
|
+
'Polls all active tracking jobs for carrier updates every day at 6:00 AM UTC.',
|
|
109
|
+
scopeType: 'organization',
|
|
110
|
+
tenantId,
|
|
111
|
+
organizationId,
|
|
112
|
+
scheduleType: 'cron',
|
|
113
|
+
scheduleValue: '0 6 * * *', // 6:00 AM UTC daily
|
|
114
|
+
timezone: 'UTC',
|
|
115
|
+
targetType: 'command',
|
|
116
|
+
targetCommand: 'shipment_tracking.tracking.poll_all',
|
|
117
|
+
targetPayload: {
|
|
118
|
+
tenantId,
|
|
119
|
+
organizationId,
|
|
120
|
+
},
|
|
121
|
+
sourceType: 'module',
|
|
122
|
+
sourceModule: 'shipment_tracking',
|
|
123
|
+
isEnabled: true,
|
|
124
|
+
})
|
|
125
|
+
console.log(` ✅ Registered daily poll schedule`)
|
|
126
|
+
console.log(` Cron: 0 6 * * * (6:00 AM UTC daily)`)
|
|
127
|
+
|
|
128
|
+
// Register PRE_ARRIVAL evaluation schedule
|
|
129
|
+
await schedulerService.register({
|
|
130
|
+
name: 'Pre-Arrival Status Evaluation',
|
|
131
|
+
description:
|
|
132
|
+
'Checks IN_TRANSIT shipments every 6 hours and upgrades them to PRE_ARRIVAL when ETA is within 7 days.',
|
|
133
|
+
scopeType: 'organization',
|
|
134
|
+
tenantId,
|
|
135
|
+
organizationId,
|
|
136
|
+
scheduleType: 'cron',
|
|
137
|
+
scheduleValue: '0 */6 * * *', // Every 6 hours
|
|
138
|
+
timezone: 'UTC',
|
|
139
|
+
targetType: 'command',
|
|
140
|
+
targetCommand: 'shipment_tracking.tracking.evaluate_pre_arrival',
|
|
141
|
+
targetPayload: {
|
|
142
|
+
tenantId,
|
|
143
|
+
organizationId,
|
|
144
|
+
},
|
|
145
|
+
sourceType: 'module',
|
|
146
|
+
sourceModule: 'shipment_tracking',
|
|
147
|
+
isEnabled: true,
|
|
148
|
+
})
|
|
149
|
+
console.log(` ✅ Registered pre-arrival evaluation schedule`)
|
|
150
|
+
console.log(` Cron: 0 */6 * * * (every 6 hours)`)
|
|
151
|
+
|
|
152
|
+
console.log('')
|
|
153
|
+
console.log('✅ Schedules registered successfully!')
|
|
154
|
+
console.log('')
|
|
155
|
+
console.log('Next steps:')
|
|
156
|
+
console.log(' 1. Sync schedules with BullMQ: yarn mercato scheduler start')
|
|
157
|
+
console.log(' 2. Ensure worker is running: yarn mercato worker:start')
|
|
158
|
+
console.log('')
|
|
159
|
+
} catch (error: any) {
|
|
160
|
+
if (error.message?.includes('not registered')) {
|
|
161
|
+
console.error('❌ Scheduler service not available.')
|
|
162
|
+
console.error(' Make sure the scheduler module is installed.')
|
|
163
|
+
} else {
|
|
164
|
+
console.error('❌ Failed to register schedules:', error.message)
|
|
165
|
+
}
|
|
166
|
+
process.exit(1)
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// ─── POI NATS Subscriber Commands ────────────────────────────
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* POI NATS Worker
|
|
175
|
+
*
|
|
176
|
+
* Long-running worker process that consumes POI proximity events from NATS JetStream.
|
|
177
|
+
* Run this as a separate process/service alongside the main app.
|
|
178
|
+
*
|
|
179
|
+
* Usage:
|
|
180
|
+
* yarn mercato shipment_tracking poi:worker
|
|
181
|
+
*
|
|
182
|
+
* With pm2:
|
|
183
|
+
* pm2 start "yarn mercato shipment_tracking poi:worker" --name poi-worker
|
|
184
|
+
*
|
|
185
|
+
* With systemd:
|
|
186
|
+
* ExecStart=/path/to/yarn mercato shipment_tracking poi:worker
|
|
187
|
+
*/
|
|
188
|
+
const poiWorkerCommand: ModuleCli = {
|
|
189
|
+
command: 'poi:worker',
|
|
190
|
+
async run() {
|
|
191
|
+
const { resolve } = await createRequestContainer()
|
|
192
|
+
|
|
193
|
+
try {
|
|
194
|
+
const poiService = resolve<PoiNatsService>('poiNatsService')
|
|
195
|
+
|
|
196
|
+
if (!poiService) {
|
|
197
|
+
console.error('[poi-worker] PoiNatsService not available')
|
|
198
|
+
process.exit(1)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Check if POI NATS is configured
|
|
202
|
+
if (!poiService.isConfigured()) {
|
|
203
|
+
console.log('[poi-worker] POI_NATS_URL not configured, exiting')
|
|
204
|
+
console.log('[poi-worker] Set POI_NATS_URL environment variable to enable')
|
|
205
|
+
process.exit(0)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
console.log('[poi-worker] Starting POI NATS consumer...')
|
|
209
|
+
|
|
210
|
+
// Start the NATS subscriber
|
|
211
|
+
await poiService.start()
|
|
212
|
+
|
|
213
|
+
const stats = poiService.getStats()
|
|
214
|
+
console.log(`[poi-worker] Consumer started at ${stats.connectedAt?.toISOString()}`)
|
|
215
|
+
console.log('[poi-worker] Listening for POI proximity events')
|
|
216
|
+
|
|
217
|
+
// Keep the process alive and handle graceful shutdown
|
|
218
|
+
let isShuttingDown = false
|
|
219
|
+
const gracefulShutdown = async () => {
|
|
220
|
+
if (isShuttingDown) return
|
|
221
|
+
isShuttingDown = true
|
|
222
|
+
console.log('[poi-worker] Shutting down...')
|
|
223
|
+
try {
|
|
224
|
+
await poiService.stop()
|
|
225
|
+
console.log('[poi-worker] Stopped')
|
|
226
|
+
} catch (error) {
|
|
227
|
+
console.error('[poi-worker] Error during shutdown:', error)
|
|
228
|
+
}
|
|
229
|
+
process.exit(0)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
process.on('SIGINT', gracefulShutdown)
|
|
233
|
+
process.on('SIGTERM', gracefulShutdown)
|
|
234
|
+
|
|
235
|
+
// Keep alive
|
|
236
|
+
await new Promise(() => {})
|
|
237
|
+
} catch (error: any) {
|
|
238
|
+
console.error('[poi-worker] Failed to start:', error.message)
|
|
239
|
+
process.exit(1)
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const poiStatusCommand: ModuleCli = {
|
|
245
|
+
command: 'poi:status',
|
|
246
|
+
async run() {
|
|
247
|
+
const { resolve } = await createRequestContainer()
|
|
248
|
+
|
|
249
|
+
try {
|
|
250
|
+
const poiService = resolve<PoiNatsService>('poiNatsService')
|
|
251
|
+
|
|
252
|
+
if (!poiService) {
|
|
253
|
+
console.error('PoiNatsService not available.')
|
|
254
|
+
process.exit(1)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
console.log('POI NATS Subscriber Status\n')
|
|
258
|
+
|
|
259
|
+
// Check if POI NATS is configured
|
|
260
|
+
if (!poiService.isConfigured()) {
|
|
261
|
+
console.log(' Status: not configured')
|
|
262
|
+
console.log('')
|
|
263
|
+
console.log('Set POI_NATS_URL environment variable to enable POI event subscription.')
|
|
264
|
+
process.exit(0)
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const stats = poiService.getStats()
|
|
268
|
+
|
|
269
|
+
console.log(` Status: ${stats.status}`)
|
|
270
|
+
console.log(` Connected at: ${stats.connectedAt?.toISOString() ?? 'N/A'}`)
|
|
271
|
+
console.log(` Messages received: ${stats.messagesReceived}`)
|
|
272
|
+
console.log(` Messages processed: ${stats.messagesProcessed}`)
|
|
273
|
+
console.log(` Events created: ${stats.eventsCreated}`)
|
|
274
|
+
console.log(` Errors: ${stats.errors}`)
|
|
275
|
+
console.log(` Last message at: ${stats.lastMessageAt?.toISOString() ?? 'N/A'}`)
|
|
276
|
+
console.log('')
|
|
277
|
+
} catch (error: any) {
|
|
278
|
+
console.error('Failed to get status:', error.message)
|
|
279
|
+
process.exit(1)
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const poiHelpCommand: ModuleCli = {
|
|
285
|
+
command: 'poi:help',
|
|
286
|
+
async run() {
|
|
287
|
+
console.log('POI NATS Consumer Commands\n')
|
|
288
|
+
console.log('Commands:')
|
|
289
|
+
console.log(' poi:worker Start the POI NATS consumer worker (long-running)')
|
|
290
|
+
console.log(' poi:status Show consumer status and statistics')
|
|
291
|
+
console.log(' poi:help Show this help message')
|
|
292
|
+
console.log('')
|
|
293
|
+
console.log('Environment Variables:')
|
|
294
|
+
console.log(' POI_NATS_URL NATS server URL (required to enable)')
|
|
295
|
+
console.log(' POI_NATS_STREAM JetStream stream name (default: AIS_STREAM)')
|
|
296
|
+
console.log(' POI_NATS_SUBJECT Subject filter (default: ais.ship.proximity.events)')
|
|
297
|
+
console.log(' POI_NATS_CONSUMER Durable consumer name (default: shipment-tracking-poi)')
|
|
298
|
+
console.log('')
|
|
299
|
+
console.log('Prerequisites:')
|
|
300
|
+
console.log(' Create a durable consumer on the NATS server:')
|
|
301
|
+
console.log(' nats consumer add AIS_STREAM shipment-tracking-poi \\')
|
|
302
|
+
console.log(' --filter "ais.ship.proximity.events" \\')
|
|
303
|
+
console.log(' --ack explicit --deliver all --replay instant')
|
|
304
|
+
console.log('')
|
|
305
|
+
console.log('Running as a service:')
|
|
306
|
+
console.log(' # Direct:')
|
|
307
|
+
console.log(' POI_NATS_URL=nats://localhost:4222 yarn mercato shipment_tracking poi:worker')
|
|
308
|
+
console.log('')
|
|
309
|
+
console.log(' # With pm2:')
|
|
310
|
+
console.log(' pm2 start "yarn mercato shipment_tracking poi:worker" --name poi-worker')
|
|
311
|
+
console.log('')
|
|
312
|
+
console.log(' # With Docker (add to docker-compose.yml):')
|
|
313
|
+
console.log(' poi-worker:')
|
|
314
|
+
console.log(' command: yarn mercato shipment_tracking poi:worker')
|
|
315
|
+
console.log(' environment:')
|
|
316
|
+
console.log(' - POI_NATS_URL=nats://nats:4222')
|
|
317
|
+
console.log('')
|
|
318
|
+
},
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export default [setupSchedulesCommand, poiWorkerCommand, poiStatusCommand, poiHelpCommand]
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { registerCommand } from '@open-mercato/shared/lib/commands'
|
|
2
|
+
import type { CommandHandler, CommandRuntimeContext } from '@open-mercato/shared/lib/commands'
|
|
3
|
+
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
4
|
+
import { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'
|
|
5
|
+
import { BicConfig } from '../data/entities'
|
|
6
|
+
import type { BicConfigUpsertInput } from '../data/validators'
|
|
7
|
+
|
|
8
|
+
function ensureScope(ctx: CommandRuntimeContext, tenantId: string, organizationId: string) {
|
|
9
|
+
if (ctx.auth?.tenantId && ctx.auth.tenantId !== tenantId) {
|
|
10
|
+
throw new Error('Tenant mismatch')
|
|
11
|
+
}
|
|
12
|
+
if (!ctx.auth?.isSuperAdmin && ctx.auth?.organizationId && ctx.auth.organizationId !== organizationId) {
|
|
13
|
+
throw new Error('Organization mismatch')
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Upsert BIC config - creates if not exists, updates if exists.
|
|
19
|
+
* There is only one BIC config per organization/tenant.
|
|
20
|
+
*/
|
|
21
|
+
const upsertBicConfig: CommandHandler<BicConfigUpsertInput, { id: string }> = {
|
|
22
|
+
id: 'shipment_tracking.bic_config.upsert',
|
|
23
|
+
|
|
24
|
+
async execute(input, ctx) {
|
|
25
|
+
ensureScope(ctx, input.tenantId, input.organizationId)
|
|
26
|
+
|
|
27
|
+
const em = ctx.container.resolve<EntityManager>('em').fork()
|
|
28
|
+
|
|
29
|
+
// Find existing config for this org/tenant
|
|
30
|
+
let bicConfig = await findOneWithDecryption(
|
|
31
|
+
em,
|
|
32
|
+
BicConfig,
|
|
33
|
+
{ organizationId: input.organizationId, tenantId: input.tenantId },
|
|
34
|
+
{},
|
|
35
|
+
{ tenantId: input.tenantId, organizationId: input.organizationId },
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
if (bicConfig) {
|
|
39
|
+
// Update existing
|
|
40
|
+
bicConfig.isEnabled = input.isEnabled
|
|
41
|
+
bicConfig.username = input.username
|
|
42
|
+
// Only update password if a new one was provided (not the sentinel value)
|
|
43
|
+
if (input.password && input.password !== '__UNCHANGED__') {
|
|
44
|
+
bicConfig.password = input.password
|
|
45
|
+
}
|
|
46
|
+
bicConfig.baseUrl = input.baseUrl ?? 'https://api.bic-code.org'
|
|
47
|
+
} else {
|
|
48
|
+
// Create new
|
|
49
|
+
bicConfig = em.create(BicConfig, {
|
|
50
|
+
organizationId: input.organizationId,
|
|
51
|
+
tenantId: input.tenantId,
|
|
52
|
+
isEnabled: input.isEnabled,
|
|
53
|
+
username: input.username,
|
|
54
|
+
password: input.password,
|
|
55
|
+
baseUrl: input.baseUrl ?? 'https://api.bic-code.org',
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
await em.flush()
|
|
60
|
+
|
|
61
|
+
return { id: bicConfig.id }
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Delete BIC config
|
|
67
|
+
*/
|
|
68
|
+
const deleteBicConfig: CommandHandler<{ tenantId: string; organizationId: string }, { success: boolean }> = {
|
|
69
|
+
id: 'shipment_tracking.bic_config.delete',
|
|
70
|
+
|
|
71
|
+
async execute(input, ctx) {
|
|
72
|
+
ensureScope(ctx, input.tenantId, input.organizationId)
|
|
73
|
+
|
|
74
|
+
const em = ctx.container.resolve<EntityManager>('em').fork()
|
|
75
|
+
|
|
76
|
+
const bicConfig = await findOneWithDecryption(
|
|
77
|
+
em,
|
|
78
|
+
BicConfig,
|
|
79
|
+
{ organizationId: input.organizationId, tenantId: input.tenantId },
|
|
80
|
+
{},
|
|
81
|
+
{ tenantId: input.tenantId, organizationId: input.organizationId },
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
if (bicConfig) {
|
|
85
|
+
em.remove(bicConfig)
|
|
86
|
+
await em.flush()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return { success: true }
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
registerCommand(upsertBicConfig)
|
|
94
|
+
registerCommand(deleteBicConfig)
|