From c28d7f236ee36bb1d78a0f2b9c799a003fb15525 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Tue, 18 Aug 2026 14:16:40 +0300 Subject: [PATCH] feat(tactical): add isochrone emergency reachability endpoint and clean build config --- .gitignore | 4 +- apps/api/dist/app.controller.d.ts | 6 - apps/api/dist/app.controller.js | 35 - apps/api/dist/app.controller.js.map | 1 - apps/api/dist/app.module.d.ts | 2 - apps/api/dist/app.module.js | 69 -- apps/api/dist/app.module.js.map | 1 - apps/api/dist/app.service.d.ts | 3 - apps/api/dist/app.service.js | 20 - apps/api/dist/app.service.js.map | 1 - apps/api/dist/auth/auth.module.d.ts | 9 - apps/api/dist/auth/auth.module.js | 52 -- apps/api/dist/auth/auth.module.js.map | 1 - apps/api/dist/auth/auth.service.d.ts | 24 - apps/api/dist/auth/auth.service.js | 180 ----- apps/api/dist/auth/auth.service.js.map | 1 - .../auth/dto/management/create-key.dto.d.ts | 5 - .../auth/dto/management/create-key.dto.js | 35 - .../auth/dto/management/create-key.dto.js.map | 1 - .../dist/auth/entities/api-key.entity.d.ts | 16 - apps/api/dist/auth/entities/api-key.entity.js | 87 --- .../dist/auth/entities/api-key.entity.js.map | 1 - .../api/dist/auth/entities/tenant.entity.d.ts | 26 - apps/api/dist/auth/entities/tenant.entity.js | 108 --- .../dist/auth/entities/tenant.entity.js.map | 1 - .../api/dist/auth/firebase-admin.service.d.ts | 11 - apps/api/dist/auth/firebase-admin.service.js | 99 --- .../dist/auth/firebase-admin.service.js.map | 1 - .../dist/auth/guards/firebase-auth.guard.d.ts | 10 - .../dist/auth/guards/firebase-auth.guard.js | 54 -- .../auth/guards/firebase-auth.guard.js.map | 1 - apps/api/dist/auth/tenant.controller.d.ts | 9 - apps/api/dist/auth/tenant.controller.js | 74 --- apps/api/dist/auth/tenant.controller.js.map | 1 - apps/api/dist/billing/billing.controller.d.ts | 36 - apps/api/dist/billing/billing.controller.js | 259 -------- .../dist/billing/billing.controller.js.map | 1 - apps/api/dist/billing/billing.module.d.ts | 2 - apps/api/dist/billing/billing.module.js | 32 - apps/api/dist/billing/billing.module.js.map | 1 - apps/api/dist/billing/billing.service.d.ts | 20 - apps/api/dist/billing/billing.service.js | 131 ---- apps/api/dist/billing/billing.service.js.map | 1 - .../billing/entities/subscription.entity.d.ts | 18 - .../billing/entities/subscription.entity.js | 82 --- .../entities/subscription.entity.js.map | 1 - .../billing/entities/transaction.entity.d.ts | 23 - .../billing/entities/transaction.entity.js | 92 --- .../entities/transaction.entity.js.map | 1 - .../billing/providers/binance.provider.d.ts | 16 - .../billing/providers/binance.provider.js | 150 ----- .../billing/providers/binance.provider.js.map | 1 - .../billing/providers/paymob.provider.d.ts | 14 - .../dist/billing/providers/paymob.provider.js | 179 ----- .../billing/providers/paymob.provider.js.map | 1 - apps/api/dist/common/cache.service.d.ts | 9 - apps/api/dist/common/cache.service.js | 44 -- apps/api/dist/common/cache.service.js.map | 1 - apps/api/dist/common/gis.utils.d.ts | 8 - apps/api/dist/common/gis.utils.js | 21 - apps/api/dist/common/gis.utils.js.map | 1 - apps/api/dist/common/guards/admin.guard.d.ts | 4 - apps/api/dist/common/guards/admin.guard.js | 29 - .../api/dist/common/guards/admin.guard.js.map | 1 - .../api/dist/common/guards/api-key.guard.d.ts | 7 - apps/api/dist/common/guards/api-key.guard.js | 45 -- .../dist/common/guards/api-key.guard.js.map | 1 - .../common/guards/rate-limiter.guard.d.ts | 6 - .../dist/common/guards/rate-limiter.guard.js | 37 -- .../common/guards/rate-limiter.guard.js.map | 1 - apps/api/dist/common/mail.module.d.ts | 2 - apps/api/dist/common/mail.module.js | 22 - apps/api/dist/common/mail.module.js.map | 1 - apps/api/dist/common/mail.service.d.ts | 13 - apps/api/dist/common/mail.service.js | 122 ---- apps/api/dist/common/mail.service.js.map | 1 - apps/api/dist/common/redis.module.d.ts | 2 - apps/api/dist/common/redis.module.js | 36 - apps/api/dist/common/redis.module.js.map | 1 - apps/api/dist/common/redis.service.d.ts | 11 - apps/api/dist/common/redis.service.js | 58 -- apps/api/dist/common/redis.service.js.map | 1 - apps/api/dist/common/telegram.service.d.ts | 17 - apps/api/dist/common/telegram.service.js | 76 --- apps/api/dist/common/telegram.service.js.map | 1 - .../geocoding/admin-boundaries.service.d.ts | 19 - .../geocoding/admin-boundaries.service.js | 138 ---- .../geocoding/admin-boundaries.service.js.map | 1 - .../administrative-linking.service.d.ts | 42 -- .../administrative-linking.service.js | 293 --------- .../administrative-linking.service.js.map | 1 - .../geocoding/dto/reverse-geocode.dto.d.ts | 4 - .../dist/geocoding/dto/reverse-geocode.dto.js | 39 -- .../geocoding/dto/reverse-geocode.dto.js.map | 1 - .../dist/geocoding/dto/search-query.dto.d.ts | 7 - .../dist/geocoding/dto/search-query.dto.js | 58 -- .../geocoding/dto/search-query.dto.js.map | 1 - .../entities/admin-boundary.entity.d.ts | 8 - .../entities/admin-boundary.entity.js | 54 -- .../entities/admin-boundary.entity.js.map | 1 - .../geocoding/entities/base-place.entity.d.ts | 20 - .../geocoding/entities/base-place.entity.js | 114 ---- .../entities/base-place.entity.js.map | 1 - .../entities/map-candidate.entity.d.ts | 22 - .../entities/map-candidate.entity.js | 85 --- .../entities/map-candidate.entity.js.map | 1 - .../entities/neighborhood-point.entity.d.ts | 10 - .../entities/neighborhood-point.entity.js | 65 -- .../entities/neighborhood-point.entity.js.map | 1 - .../entities/neighborhood-polygon.entity.d.ts | 12 - .../entities/neighborhood-polygon.entity.js | 75 --- .../neighborhood-polygon.entity.js.map | 1 - .../geocoding/entities/osm-area.entity.d.ts | 11 - .../geocoding/entities/osm-area.entity.js | 65 -- .../geocoding/entities/osm-area.entity.js.map | 1 - .../entities/osm-point-with-area.entity.d.ts | 15 - .../entities/osm-point-with-area.entity.js | 85 --- .../osm-point-with-area.entity.js.map | 1 - .../entities/place-egypt.entity.d.ts | 3 - .../geocoding/entities/place-egypt.entity.js | 18 - .../entities/place-egypt.entity.js.map | 1 - .../geocoding/entities/place-iraq.entity.d.ts | 3 - .../geocoding/entities/place-iraq.entity.js | 18 - .../entities/place-iraq.entity.js.map | 1 - .../entities/place-jordan.entity.d.ts | 3 - .../geocoding/entities/place-jordan.entity.js | 18 - .../entities/place-jordan.entity.js.map | 1 - .../entities/place-syria.entity.d.ts | 3 - .../geocoding/entities/place-syria.entity.js | 18 - .../entities/place-syria.entity.js.map | 1 - .../geocoding/geocoding-init.service.d.ts | 9 - .../dist/geocoding/geocoding-init.service.js | 113 ---- .../geocoding/geocoding-init.service.js.map | 1 - .../dist/geocoding/geocoding.controller.d.ts | 112 ---- .../dist/geocoding/geocoding.controller.js | 241 ------- .../geocoding/geocoding.controller.js.map | 1 - apps/api/dist/geocoding/geocoding.module.d.ts | 2 - apps/api/dist/geocoding/geocoding.module.js | 104 --- .../dist/geocoding/geocoding.module.js.map | 1 - .../api/dist/geocoding/geocoding.service.d.ts | 82 --- apps/api/dist/geocoding/geocoding.service.js | 607 ----------------- .../dist/geocoding/geocoding.service.js.map | 1 - .../dist/geocoding/index-refresh.service.d.ts | 8 - .../dist/geocoding/index-refresh.service.js | 60 -- .../geocoding/index-refresh.service.js.map | 1 - .../geocoding/jordan-research.service.d.ts | 25 - .../dist/geocoding/jordan-research.service.js | 184 ------ .../geocoding/jordan-research.service.js.map | 1 - .../geocoding/map-refinement.controller.d.ts | 12 - .../geocoding/map-refinement.controller.js | 87 --- .../map-refinement.controller.js.map | 1 - .../geocoding/map-refinement.service.d.ts | 21 - .../dist/geocoding/map-refinement.service.js | 215 ------ .../geocoding/map-refinement.service.js.map | 1 - apps/api/dist/main.d.ts | 1 - apps/api/dist/main.js | 49 -- apps/api/dist/main.js.map | 1 - apps/api/dist/maps/candidate-road.entity.d.ts | 16 - apps/api/dist/maps/candidate-road.entity.js | 96 --- .../dist/maps/candidate-road.entity.js.map | 1 - apps/api/dist/maps/maps.controller.d.ts | 30 - apps/api/dist/maps/maps.controller.js | 179 ----- apps/api/dist/maps/maps.controller.js.map | 1 - apps/api/dist/maps/maps.module.d.ts | 2 - apps/api/dist/maps/maps.module.js | 35 - apps/api/dist/maps/maps.module.js.map | 1 - apps/api/dist/maps/maps.service.d.ts | 44 -- apps/api/dist/maps/maps.service.js | 353 ---------- apps/api/dist/maps/maps.service.js.map | 1 - .../dist/maps/road-refinement.controller.d.ts | 57 -- .../dist/maps/road-refinement.controller.js | 613 ------------------ .../maps/road-refinement.controller.js.map | 1 - .../dist/maps/road-speed-profile.entity.d.ts | 8 - .../dist/maps/road-speed-profile.entity.js | 51 -- .../maps/road-speed-profile.entity.js.map | 1 - apps/api/dist/maps/road-stat.entity.d.ts | 9 - apps/api/dist/maps/road-stat.entity.js | 63 -- apps/api/dist/maps/road-stat.entity.js.map | 1 - apps/api/dist/maps/traffic-grid.service.d.ts | 13 - apps/api/dist/maps/traffic-grid.service.js | 124 ---- .../api/dist/maps/traffic-grid.service.js.map | 1 - .../dist/tactical/dto/line-of-sight.dto.d.ts | 29 - .../dist/tactical/dto/line-of-sight.dto.js | 209 ------ .../tactical/dto/line-of-sight.dto.js.map | 1 - apps/api/dist/tactical/dto/tactical.dto.d.ts | 26 - apps/api/dist/tactical/dto/tactical.dto.js | 162 ----- .../api/dist/tactical/dto/tactical.dto.js.map | 1 - .../dist/tactical/tactical.controller.d.ts | 49 -- apps/api/dist/tactical/tactical.controller.js | 164 ----- .../dist/tactical/tactical.controller.js.map | 1 - apps/api/dist/tactical/tactical.module.d.ts | 2 - apps/api/dist/tactical/tactical.module.js | 25 - apps/api/dist/tactical/tactical.module.js.map | 1 - apps/api/dist/tactical/tactical.service.d.ts | 108 --- apps/api/dist/tactical/tactical.service.js | 353 ---------- .../api/dist/tactical/tactical.service.js.map | 1 - apps/api/dist/tsconfig.build.tsbuildinfo | 1 - apps/api/dist/usage/usage.controller.d.ts | 17 - apps/api/dist/usage/usage.controller.js | 72 -- apps/api/dist/usage/usage.controller.js.map | 1 - apps/api/dist/usage/usage.entity.d.ts | 12 - apps/api/dist/usage/usage.entity.js | 73 --- apps/api/dist/usage/usage.entity.js.map | 1 - apps/api/dist/usage/usage.interceptor.d.ts | 9 - apps/api/dist/usage/usage.interceptor.js | 81 --- apps/api/dist/usage/usage.interceptor.js.map | 1 - apps/api/dist/usage/usage.module.d.ts | 2 - apps/api/dist/usage/usage.module.js | 28 - apps/api/dist/usage/usage.module.js.map | 1 - apps/api/dist/usage/usage.service.d.ts | 39 -- apps/api/dist/usage/usage.service.js | 135 ---- apps/api/dist/usage/usage.service.js.map | 1 - apps/api/dist/weather/weather.controller.d.ts | 8 - apps/api/dist/weather/weather.controller.js | 65 -- .../dist/weather/weather.controller.js.map | 1 - apps/api/dist/weather/weather.module.d.ts | 2 - apps/api/dist/weather/weather.module.js | 25 - apps/api/dist/weather/weather.module.js.map | 1 - apps/api/dist/weather/weather.service.d.ts | 17 - apps/api/dist/weather/weather.service.js | 237 ------- apps/api/dist/weather/weather.service.js.map | 1 - apps/api/src/app.module.ts | 2 - apps/api/src/tactical/tactical.controller.ts | 16 + apps/api/src/tactical/tactical.service.ts | 68 ++ 224 files changed, 87 insertions(+), 9533 deletions(-) delete mode 100644 apps/api/dist/app.controller.d.ts delete mode 100644 apps/api/dist/app.controller.js delete mode 100644 apps/api/dist/app.controller.js.map delete mode 100644 apps/api/dist/app.module.d.ts delete mode 100644 apps/api/dist/app.module.js delete mode 100644 apps/api/dist/app.module.js.map delete mode 100644 apps/api/dist/app.service.d.ts delete mode 100644 apps/api/dist/app.service.js delete mode 100644 apps/api/dist/app.service.js.map delete mode 100644 apps/api/dist/auth/auth.module.d.ts delete mode 100644 apps/api/dist/auth/auth.module.js delete mode 100644 apps/api/dist/auth/auth.module.js.map delete mode 100644 apps/api/dist/auth/auth.service.d.ts delete mode 100644 apps/api/dist/auth/auth.service.js delete mode 100644 apps/api/dist/auth/auth.service.js.map delete mode 100644 apps/api/dist/auth/dto/management/create-key.dto.d.ts delete mode 100644 apps/api/dist/auth/dto/management/create-key.dto.js delete mode 100644 apps/api/dist/auth/dto/management/create-key.dto.js.map delete mode 100644 apps/api/dist/auth/entities/api-key.entity.d.ts delete mode 100644 apps/api/dist/auth/entities/api-key.entity.js delete mode 100644 apps/api/dist/auth/entities/api-key.entity.js.map delete mode 100644 apps/api/dist/auth/entities/tenant.entity.d.ts delete mode 100644 apps/api/dist/auth/entities/tenant.entity.js delete mode 100644 apps/api/dist/auth/entities/tenant.entity.js.map delete mode 100644 apps/api/dist/auth/firebase-admin.service.d.ts delete mode 100644 apps/api/dist/auth/firebase-admin.service.js delete mode 100644 apps/api/dist/auth/firebase-admin.service.js.map delete mode 100644 apps/api/dist/auth/guards/firebase-auth.guard.d.ts delete mode 100644 apps/api/dist/auth/guards/firebase-auth.guard.js delete mode 100644 apps/api/dist/auth/guards/firebase-auth.guard.js.map delete mode 100644 apps/api/dist/auth/tenant.controller.d.ts delete mode 100644 apps/api/dist/auth/tenant.controller.js delete mode 100644 apps/api/dist/auth/tenant.controller.js.map delete mode 100644 apps/api/dist/billing/billing.controller.d.ts delete mode 100644 apps/api/dist/billing/billing.controller.js delete mode 100644 apps/api/dist/billing/billing.controller.js.map delete mode 100644 apps/api/dist/billing/billing.module.d.ts delete mode 100644 apps/api/dist/billing/billing.module.js delete mode 100644 apps/api/dist/billing/billing.module.js.map delete mode 100644 apps/api/dist/billing/billing.service.d.ts delete mode 100644 apps/api/dist/billing/billing.service.js delete mode 100644 apps/api/dist/billing/billing.service.js.map delete mode 100644 apps/api/dist/billing/entities/subscription.entity.d.ts delete mode 100644 apps/api/dist/billing/entities/subscription.entity.js delete mode 100644 apps/api/dist/billing/entities/subscription.entity.js.map delete mode 100644 apps/api/dist/billing/entities/transaction.entity.d.ts delete mode 100644 apps/api/dist/billing/entities/transaction.entity.js delete mode 100644 apps/api/dist/billing/entities/transaction.entity.js.map delete mode 100644 apps/api/dist/billing/providers/binance.provider.d.ts delete mode 100644 apps/api/dist/billing/providers/binance.provider.js delete mode 100644 apps/api/dist/billing/providers/binance.provider.js.map delete mode 100644 apps/api/dist/billing/providers/paymob.provider.d.ts delete mode 100644 apps/api/dist/billing/providers/paymob.provider.js delete mode 100644 apps/api/dist/billing/providers/paymob.provider.js.map delete mode 100644 apps/api/dist/common/cache.service.d.ts delete mode 100644 apps/api/dist/common/cache.service.js delete mode 100644 apps/api/dist/common/cache.service.js.map delete mode 100644 apps/api/dist/common/gis.utils.d.ts delete mode 100644 apps/api/dist/common/gis.utils.js delete mode 100644 apps/api/dist/common/gis.utils.js.map delete mode 100644 apps/api/dist/common/guards/admin.guard.d.ts delete mode 100644 apps/api/dist/common/guards/admin.guard.js delete mode 100644 apps/api/dist/common/guards/admin.guard.js.map delete mode 100644 apps/api/dist/common/guards/api-key.guard.d.ts delete mode 100644 apps/api/dist/common/guards/api-key.guard.js delete mode 100644 apps/api/dist/common/guards/api-key.guard.js.map delete mode 100644 apps/api/dist/common/guards/rate-limiter.guard.d.ts delete mode 100644 apps/api/dist/common/guards/rate-limiter.guard.js delete mode 100644 apps/api/dist/common/guards/rate-limiter.guard.js.map delete mode 100644 apps/api/dist/common/mail.module.d.ts delete mode 100644 apps/api/dist/common/mail.module.js delete mode 100644 apps/api/dist/common/mail.module.js.map delete mode 100644 apps/api/dist/common/mail.service.d.ts delete mode 100644 apps/api/dist/common/mail.service.js delete mode 100644 apps/api/dist/common/mail.service.js.map delete mode 100644 apps/api/dist/common/redis.module.d.ts delete mode 100644 apps/api/dist/common/redis.module.js delete mode 100644 apps/api/dist/common/redis.module.js.map delete mode 100644 apps/api/dist/common/redis.service.d.ts delete mode 100644 apps/api/dist/common/redis.service.js delete mode 100644 apps/api/dist/common/redis.service.js.map delete mode 100644 apps/api/dist/common/telegram.service.d.ts delete mode 100644 apps/api/dist/common/telegram.service.js delete mode 100644 apps/api/dist/common/telegram.service.js.map delete mode 100644 apps/api/dist/geocoding/admin-boundaries.service.d.ts delete mode 100644 apps/api/dist/geocoding/admin-boundaries.service.js delete mode 100644 apps/api/dist/geocoding/admin-boundaries.service.js.map delete mode 100644 apps/api/dist/geocoding/administrative-linking.service.d.ts delete mode 100644 apps/api/dist/geocoding/administrative-linking.service.js delete mode 100644 apps/api/dist/geocoding/administrative-linking.service.js.map delete mode 100644 apps/api/dist/geocoding/dto/reverse-geocode.dto.d.ts delete mode 100644 apps/api/dist/geocoding/dto/reverse-geocode.dto.js delete mode 100644 apps/api/dist/geocoding/dto/reverse-geocode.dto.js.map delete mode 100644 apps/api/dist/geocoding/dto/search-query.dto.d.ts delete mode 100644 apps/api/dist/geocoding/dto/search-query.dto.js delete mode 100644 apps/api/dist/geocoding/dto/search-query.dto.js.map delete mode 100644 apps/api/dist/geocoding/entities/admin-boundary.entity.d.ts delete mode 100644 apps/api/dist/geocoding/entities/admin-boundary.entity.js delete mode 100644 apps/api/dist/geocoding/entities/admin-boundary.entity.js.map delete mode 100644 apps/api/dist/geocoding/entities/base-place.entity.d.ts delete mode 100644 apps/api/dist/geocoding/entities/base-place.entity.js delete mode 100644 apps/api/dist/geocoding/entities/base-place.entity.js.map delete mode 100644 apps/api/dist/geocoding/entities/map-candidate.entity.d.ts delete mode 100644 apps/api/dist/geocoding/entities/map-candidate.entity.js delete mode 100644 apps/api/dist/geocoding/entities/map-candidate.entity.js.map delete mode 100644 apps/api/dist/geocoding/entities/neighborhood-point.entity.d.ts delete mode 100644 apps/api/dist/geocoding/entities/neighborhood-point.entity.js delete mode 100644 apps/api/dist/geocoding/entities/neighborhood-point.entity.js.map delete mode 100644 apps/api/dist/geocoding/entities/neighborhood-polygon.entity.d.ts delete mode 100644 apps/api/dist/geocoding/entities/neighborhood-polygon.entity.js delete mode 100644 apps/api/dist/geocoding/entities/neighborhood-polygon.entity.js.map delete mode 100644 apps/api/dist/geocoding/entities/osm-area.entity.d.ts delete mode 100644 apps/api/dist/geocoding/entities/osm-area.entity.js delete mode 100644 apps/api/dist/geocoding/entities/osm-area.entity.js.map delete mode 100644 apps/api/dist/geocoding/entities/osm-point-with-area.entity.d.ts delete mode 100644 apps/api/dist/geocoding/entities/osm-point-with-area.entity.js delete mode 100644 apps/api/dist/geocoding/entities/osm-point-with-area.entity.js.map delete mode 100644 apps/api/dist/geocoding/entities/place-egypt.entity.d.ts delete mode 100644 apps/api/dist/geocoding/entities/place-egypt.entity.js delete mode 100644 apps/api/dist/geocoding/entities/place-egypt.entity.js.map delete mode 100644 apps/api/dist/geocoding/entities/place-iraq.entity.d.ts delete mode 100644 apps/api/dist/geocoding/entities/place-iraq.entity.js delete mode 100644 apps/api/dist/geocoding/entities/place-iraq.entity.js.map delete mode 100644 apps/api/dist/geocoding/entities/place-jordan.entity.d.ts delete mode 100644 apps/api/dist/geocoding/entities/place-jordan.entity.js delete mode 100644 apps/api/dist/geocoding/entities/place-jordan.entity.js.map delete mode 100644 apps/api/dist/geocoding/entities/place-syria.entity.d.ts delete mode 100644 apps/api/dist/geocoding/entities/place-syria.entity.js delete mode 100644 apps/api/dist/geocoding/entities/place-syria.entity.js.map delete mode 100644 apps/api/dist/geocoding/geocoding-init.service.d.ts delete mode 100644 apps/api/dist/geocoding/geocoding-init.service.js delete mode 100644 apps/api/dist/geocoding/geocoding-init.service.js.map delete mode 100644 apps/api/dist/geocoding/geocoding.controller.d.ts delete mode 100644 apps/api/dist/geocoding/geocoding.controller.js delete mode 100644 apps/api/dist/geocoding/geocoding.controller.js.map delete mode 100644 apps/api/dist/geocoding/geocoding.module.d.ts delete mode 100644 apps/api/dist/geocoding/geocoding.module.js delete mode 100644 apps/api/dist/geocoding/geocoding.module.js.map delete mode 100644 apps/api/dist/geocoding/geocoding.service.d.ts delete mode 100644 apps/api/dist/geocoding/geocoding.service.js delete mode 100644 apps/api/dist/geocoding/geocoding.service.js.map delete mode 100644 apps/api/dist/geocoding/index-refresh.service.d.ts delete mode 100644 apps/api/dist/geocoding/index-refresh.service.js delete mode 100644 apps/api/dist/geocoding/index-refresh.service.js.map delete mode 100644 apps/api/dist/geocoding/jordan-research.service.d.ts delete mode 100644 apps/api/dist/geocoding/jordan-research.service.js delete mode 100644 apps/api/dist/geocoding/jordan-research.service.js.map delete mode 100644 apps/api/dist/geocoding/map-refinement.controller.d.ts delete mode 100644 apps/api/dist/geocoding/map-refinement.controller.js delete mode 100644 apps/api/dist/geocoding/map-refinement.controller.js.map delete mode 100644 apps/api/dist/geocoding/map-refinement.service.d.ts delete mode 100644 apps/api/dist/geocoding/map-refinement.service.js delete mode 100644 apps/api/dist/geocoding/map-refinement.service.js.map delete mode 100644 apps/api/dist/main.d.ts delete mode 100644 apps/api/dist/main.js delete mode 100644 apps/api/dist/main.js.map delete mode 100644 apps/api/dist/maps/candidate-road.entity.d.ts delete mode 100644 apps/api/dist/maps/candidate-road.entity.js delete mode 100644 apps/api/dist/maps/candidate-road.entity.js.map delete mode 100644 apps/api/dist/maps/maps.controller.d.ts delete mode 100644 apps/api/dist/maps/maps.controller.js delete mode 100644 apps/api/dist/maps/maps.controller.js.map delete mode 100644 apps/api/dist/maps/maps.module.d.ts delete mode 100644 apps/api/dist/maps/maps.module.js delete mode 100644 apps/api/dist/maps/maps.module.js.map delete mode 100644 apps/api/dist/maps/maps.service.d.ts delete mode 100644 apps/api/dist/maps/maps.service.js delete mode 100644 apps/api/dist/maps/maps.service.js.map delete mode 100644 apps/api/dist/maps/road-refinement.controller.d.ts delete mode 100644 apps/api/dist/maps/road-refinement.controller.js delete mode 100644 apps/api/dist/maps/road-refinement.controller.js.map delete mode 100644 apps/api/dist/maps/road-speed-profile.entity.d.ts delete mode 100644 apps/api/dist/maps/road-speed-profile.entity.js delete mode 100644 apps/api/dist/maps/road-speed-profile.entity.js.map delete mode 100644 apps/api/dist/maps/road-stat.entity.d.ts delete mode 100644 apps/api/dist/maps/road-stat.entity.js delete mode 100644 apps/api/dist/maps/road-stat.entity.js.map delete mode 100644 apps/api/dist/maps/traffic-grid.service.d.ts delete mode 100644 apps/api/dist/maps/traffic-grid.service.js delete mode 100644 apps/api/dist/maps/traffic-grid.service.js.map delete mode 100644 apps/api/dist/tactical/dto/line-of-sight.dto.d.ts delete mode 100644 apps/api/dist/tactical/dto/line-of-sight.dto.js delete mode 100644 apps/api/dist/tactical/dto/line-of-sight.dto.js.map delete mode 100644 apps/api/dist/tactical/dto/tactical.dto.d.ts delete mode 100644 apps/api/dist/tactical/dto/tactical.dto.js delete mode 100644 apps/api/dist/tactical/dto/tactical.dto.js.map delete mode 100644 apps/api/dist/tactical/tactical.controller.d.ts delete mode 100644 apps/api/dist/tactical/tactical.controller.js delete mode 100644 apps/api/dist/tactical/tactical.controller.js.map delete mode 100644 apps/api/dist/tactical/tactical.module.d.ts delete mode 100644 apps/api/dist/tactical/tactical.module.js delete mode 100644 apps/api/dist/tactical/tactical.module.js.map delete mode 100644 apps/api/dist/tactical/tactical.service.d.ts delete mode 100644 apps/api/dist/tactical/tactical.service.js delete mode 100644 apps/api/dist/tactical/tactical.service.js.map delete mode 100644 apps/api/dist/tsconfig.build.tsbuildinfo delete mode 100644 apps/api/dist/usage/usage.controller.d.ts delete mode 100644 apps/api/dist/usage/usage.controller.js delete mode 100644 apps/api/dist/usage/usage.controller.js.map delete mode 100644 apps/api/dist/usage/usage.entity.d.ts delete mode 100644 apps/api/dist/usage/usage.entity.js delete mode 100644 apps/api/dist/usage/usage.entity.js.map delete mode 100644 apps/api/dist/usage/usage.interceptor.d.ts delete mode 100644 apps/api/dist/usage/usage.interceptor.js delete mode 100644 apps/api/dist/usage/usage.interceptor.js.map delete mode 100644 apps/api/dist/usage/usage.module.d.ts delete mode 100644 apps/api/dist/usage/usage.module.js delete mode 100644 apps/api/dist/usage/usage.module.js.map delete mode 100644 apps/api/dist/usage/usage.service.d.ts delete mode 100644 apps/api/dist/usage/usage.service.js delete mode 100644 apps/api/dist/usage/usage.service.js.map delete mode 100644 apps/api/dist/weather/weather.controller.d.ts delete mode 100644 apps/api/dist/weather/weather.controller.js delete mode 100644 apps/api/dist/weather/weather.controller.js.map delete mode 100644 apps/api/dist/weather/weather.module.d.ts delete mode 100644 apps/api/dist/weather/weather.module.js delete mode 100644 apps/api/dist/weather/weather.module.js.map delete mode 100644 apps/api/dist/weather/weather.service.d.ts delete mode 100644 apps/api/dist/weather/weather.service.js delete mode 100644 apps/api/dist/weather/weather.service.js.map diff --git a/.gitignore b/.gitignore index 8ed5f08..6083d0f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,10 @@ *.sql *.tar.gz -# Node modules +# Node modules and build output node_modules/ +dist/ +*.tsbuildinfo .npm/ # Environment Variables diff --git a/apps/api/dist/app.controller.d.ts b/apps/api/dist/app.controller.d.ts deleted file mode 100644 index 3859d69..0000000 --- a/apps/api/dist/app.controller.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { AppService } from './app.service'; -export declare class AppController { - private readonly appService; - constructor(appService: AppService); - getHello(): string; -} diff --git a/apps/api/dist/app.controller.js b/apps/api/dist/app.controller.js deleted file mode 100644 index bd4a0b3..0000000 --- a/apps/api/dist/app.controller.js +++ /dev/null @@ -1,35 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.AppController = void 0; -const common_1 = require("@nestjs/common"); -const app_service_1 = require("./app.service"); -let AppController = class AppController { - appService; - constructor(appService) { - this.appService = appService; - } - getHello() { - return this.appService.getHello(); - } -}; -exports.AppController = AppController; -__decorate([ - (0, common_1.Get)(), - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", String) -], AppController.prototype, "getHello", null); -exports.AppController = AppController = __decorate([ - (0, common_1.Controller)(), - __metadata("design:paramtypes", [app_service_1.AppService]) -], AppController); -//# sourceMappingURL=app.controller.js.map \ No newline at end of file diff --git a/apps/api/dist/app.controller.js.map b/apps/api/dist/app.controller.js.map deleted file mode 100644 index 2dd6fd7..0000000 --- a/apps/api/dist/app.controller.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"app.controller.js","sourceRoot":"","sources":["../src/app.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiD;AACjD,+CAA2C;AAGpC,IAAM,aAAa,GAAnB,MAAM,aAAa;IACK;IAA7B,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAGvD,QAAQ;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;CACF,CAAA;AAPY,sCAAa;AAIxB;IADC,IAAA,YAAG,GAAE;;;;6CAGL;wBANU,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAE8B,wBAAU;GADxC,aAAa,CAOzB"} \ No newline at end of file diff --git a/apps/api/dist/app.module.d.ts b/apps/api/dist/app.module.d.ts deleted file mode 100644 index 09cdb35..0000000 --- a/apps/api/dist/app.module.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare class AppModule { -} diff --git a/apps/api/dist/app.module.js b/apps/api/dist/app.module.js deleted file mode 100644 index 26e6ff1..0000000 --- a/apps/api/dist/app.module.js +++ /dev/null @@ -1,69 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.AppModule = void 0; -const common_1 = require("@nestjs/common"); -const core_1 = require("@nestjs/core"); -const config_1 = require("@nestjs/config"); -const typeorm_1 = require("@nestjs/typeorm"); -const schedule_1 = require("@nestjs/schedule"); -const telemetry_module_1 = require("./telemetry/telemetry.module"); -const maps_module_1 = require("./maps/maps.module"); -const geocoding_module_1 = require("./geocoding/geocoding.module"); -const auth_module_1 = require("./auth/auth.module"); -const throttler_1 = require("@nestjs/throttler"); -const usage_module_1 = require("./usage/usage.module"); -const billing_module_1 = require("./billing/billing.module"); -const mail_module_1 = require("./common/mail.module"); -const weather_module_1 = require("./weather/weather.module"); -const tactical_module_1 = require("./tactical/tactical.module"); -const usage_interceptor_1 = require("./usage/usage.interceptor"); -let AppModule = class AppModule { -}; -exports.AppModule = AppModule; -exports.AppModule = AppModule = __decorate([ - (0, common_1.Module)({ - imports: [ - config_1.ConfigModule.forRoot({ - isGlobal: true, - }), - schedule_1.ScheduleModule.forRoot(), - typeorm_1.TypeOrmModule.forRootAsync({ - imports: [config_1.ConfigModule], - inject: [config_1.ConfigService], - useFactory: (config) => ({ - type: 'postgres', - url: config.get('DATABASE_URL'), - autoLoadEntities: true, - synchronize: false, - }), - }), - throttler_1.ThrottlerModule.forRoot([{ - ttl: 60000, - limit: 10, - }]), - auth_module_1.AuthModule, - telemetry_module_1.TelemetryModule, - maps_module_1.MapsModule, - geocoding_module_1.GeocodingModule, - usage_module_1.UsageModule, - billing_module_1.BillingModule, - mail_module_1.MailModule, - weather_module_1.WeatherModule, - tactical_module_1.TacticalModule, - ], - controllers: [], - providers: [ - { - provide: core_1.APP_INTERCEPTOR, - useClass: usage_interceptor_1.UsageInterceptor, - }, - ], - }) -], AppModule); -//# sourceMappingURL=app.module.js.map \ No newline at end of file diff --git a/apps/api/dist/app.module.js.map b/apps/api/dist/app.module.js.map deleted file mode 100644 index 2edcbe4..0000000 --- a/apps/api/dist/app.module.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,uCAA0D;AAC1D,2CAA6D;AAC7D,6CAAgD;AAChD,+CAAkD;AAClD,mEAA+D;AAC/D,oDAAgD;AAChD,mEAA+D;AAC/D,oDAAgD;AAChD,iDAAoD;AACpD,uDAAmD;AACnD,6DAAyD;AACzD,sDAAkD;AAClD,6DAAyD;AACzD,gEAA4D;AAC5D,iEAA6D;AAwCtD,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IAtCrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,qBAAY,CAAC,OAAO,CAAC;gBACnB,QAAQ,EAAE,IAAI;aACf,CAAC;YACF,yBAAc,CAAC,OAAO,EAAE;YACxB,uBAAa,CAAC,YAAY,CAAC;gBACzB,OAAO,EAAE,CAAC,qBAAY,CAAC;gBACvB,MAAM,EAAE,CAAC,sBAAa,CAAC;gBACvB,UAAU,EAAE,CAAC,MAAqB,EAAE,EAAE,CAAC,CAAC;oBACtC,IAAI,EAAE,UAAU;oBAChB,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC;oBAC/B,gBAAgB,EAAE,IAAI;oBACtB,WAAW,EAAE,KAAK;iBACnB,CAAC;aACH,CAAC;YACF,2BAAe,CAAC,OAAO,CAAC,CAAC;oBACvB,GAAG,EAAE,KAAK;oBACV,KAAK,EAAE,EAAE;iBACV,CAAC,CAAC;YACH,wBAAU;YACV,kCAAe;YACf,wBAAU;YACV,kCAAe;YACf,0BAAW;YACX,8BAAa;YACb,wBAAU;YACV,8BAAa;YACb,gCAAc;SACf;QACD,WAAW,EAAE,EAAE;QACf,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,sBAAe;gBACxB,QAAQ,EAAE,oCAAgB;aAC3B;SACF;KACF,CAAC;GACW,SAAS,CAAG"} \ No newline at end of file diff --git a/apps/api/dist/app.service.d.ts b/apps/api/dist/app.service.d.ts deleted file mode 100644 index 0496e79..0000000 --- a/apps/api/dist/app.service.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export declare class AppService { - getHello(): string; -} diff --git a/apps/api/dist/app.service.js b/apps/api/dist/app.service.js deleted file mode 100644 index 3bfb90b..0000000 --- a/apps/api/dist/app.service.js +++ /dev/null @@ -1,20 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.AppService = void 0; -const common_1 = require("@nestjs/common"); -let AppService = class AppService { - getHello() { - return 'Hello World!'; - } -}; -exports.AppService = AppService; -exports.AppService = AppService = __decorate([ - (0, common_1.Injectable)() -], AppService); -//# sourceMappingURL=app.service.js.map \ No newline at end of file diff --git a/apps/api/dist/app.service.js.map b/apps/api/dist/app.service.js.map deleted file mode 100644 index b1674f6..0000000 --- a/apps/api/dist/app.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"app.service.js","sourceRoot":"","sources":["../src/app.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAGrC,IAAM,UAAU,GAAhB,MAAM,UAAU;IACrB,QAAQ;QACN,OAAO,cAAc,CAAC;IACxB,CAAC;CACF,CAAA;AAJY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;GACA,UAAU,CAItB"} \ No newline at end of file diff --git a/apps/api/dist/auth/auth.module.d.ts b/apps/api/dist/auth/auth.module.d.ts deleted file mode 100644 index 7c6cbdb..0000000 --- a/apps/api/dist/auth/auth.module.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { OnModuleInit } from '@nestjs/common'; -import { AuthService } from './auth.service'; -import { ConfigService } from '@nestjs/config'; -export declare class AuthModule implements OnModuleInit { - private readonly authService; - private readonly configService; - constructor(authService: AuthService, configService: ConfigService); - onModuleInit(): Promise; -} diff --git a/apps/api/dist/auth/auth.module.js b/apps/api/dist/auth/auth.module.js deleted file mode 100644 index 5228aff..0000000 --- a/apps/api/dist/auth/auth.module.js +++ /dev/null @@ -1,52 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.AuthModule = void 0; -const common_1 = require("@nestjs/common"); -const typeorm_1 = require("@nestjs/typeorm"); -const auth_service_1 = require("./auth.service"); -const tenant_entity_1 = require("./entities/tenant.entity"); -const api_key_entity_1 = require("./entities/api-key.entity"); -const redis_module_1 = require("../common/redis.module"); -const config_1 = require("@nestjs/config"); -const tenant_controller_1 = require("./tenant.controller"); -const firebase_admin_service_1 = require("./firebase-admin.service"); -const firebase_auth_guard_1 = require("./guards/firebase-auth.guard"); -let AuthModule = class AuthModule { - authService; - configService; - constructor(authService, configService) { - this.authService = authService; - this.configService = configService; - } - async onModuleInit() { - const defaultKey = this.configService.get('MAP_API_KEY') || 'zP9vL5mK2nQ8xR7jT4wS1yB6hG3fV0cX'; - await this.authService.seedDefaultKey('Default System', 'admin@intaleq.xyz', defaultKey); - await this.authService.seedDefaultKey('Default Fallback', 'support@intaleq.xyz', 'intaleq_secret_2026'); - console.log('✅ System API Keys seeded successfully'); - } -}; -exports.AuthModule = AuthModule; -exports.AuthModule = AuthModule = __decorate([ - (0, common_1.Global)(), - (0, common_1.Module)({ - imports: [ - typeorm_1.TypeOrmModule.forFeature([tenant_entity_1.Tenant, api_key_entity_1.ApiKey]), - redis_module_1.RedisModule, - ], - controllers: [tenant_controller_1.TenantController], - providers: [auth_service_1.AuthService, firebase_admin_service_1.FirebaseAdminService, firebase_auth_guard_1.FirebaseAuthGuard], - exports: [auth_service_1.AuthService, firebase_admin_service_1.FirebaseAdminService, firebase_auth_guard_1.FirebaseAuthGuard], - }), - __metadata("design:paramtypes", [auth_service_1.AuthService, typeof (_a = typeof config_1.ConfigService !== "undefined" && config_1.ConfigService) === "function" ? _a : Object]) -], AuthModule); -//# sourceMappingURL=auth.module.js.map \ No newline at end of file diff --git a/apps/api/dist/auth/auth.module.js.map b/apps/api/dist/auth/auth.module.js.map deleted file mode 100644 index 230c837..0000000 --- a/apps/api/dist/auth/auth.module.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../../src/auth/auth.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAA8D;AAC9D,6CAAgD;AAChD,iDAA6C;AAC7C,4DAAkD;AAClD,8DAAmD;AACnD,yDAAqD;AACrD,2CAA+C;AAC/C,2DAAuD;AACvD,qEAAgE;AAChE,sEAAiE;AAY1D,IAAM,UAAU,GAAhB,MAAM,UAAU;IAEF;IACA;IAFnB,YACmB,WAAwB,EACxB,aAA4B;QAD5B,gBAAW,GAAX,WAAW,CAAa;QACxB,kBAAa,GAAb,aAAa,CAAe;IAC5C,CAAC;IAMJ,KAAK,CAAC,YAAY;QAChB,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,aAAa,CAAC,IAAI,kCAAkC,CAAC;QACvG,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,gBAAgB,EAAE,mBAAmB,EAAE,UAAU,CAAC,CAAC;QACzF,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,kBAAkB,EAAE,qBAAqB,EAAE,qBAAqB,CAAC,CAAC;QACxG,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;IACvD,CAAC;CACF,CAAA;AAhBY,gCAAU;qBAAV,UAAU;IAVtB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,UAAU,CAAC,CAAC,sBAAM,EAAE,uBAAM,CAAC,CAAC;YAC1C,0BAAW;SACZ;QACD,WAAW,EAAE,CAAC,oCAAgB,CAAC;QAC/B,SAAS,EAAE,CAAC,0BAAW,EAAE,6CAAoB,EAAE,uCAAiB,CAAC;QACjE,OAAO,EAAE,CAAC,0BAAW,EAAE,6CAAoB,EAAE,uCAAiB,CAAC;KAChE,CAAC;qCAGgC,0BAAW,sBACT,sBAAa,oBAAb,sBAAa;GAHpC,UAAU,CAgBtB"} \ No newline at end of file diff --git a/apps/api/dist/auth/auth.service.d.ts b/apps/api/dist/auth/auth.service.d.ts deleted file mode 100644 index 2f80e3f..0000000 --- a/apps/api/dist/auth/auth.service.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Repository } from 'typeorm'; -import { ApiKey } from './entities/api-key.entity'; -import { Tenant } from './entities/tenant.entity'; -import { RedisService } from '../common/redis.service'; -export declare class AuthService { - private readonly apiKeyRepository; - private readonly tenantRepository; - private readonly redisService; - private readonly logger; - constructor(apiKeyRepository: Repository, tenantRepository: Repository, redisService: RedisService); - validateApiKey(key: string, origin?: string, referer?: string): Promise<{ - tenant: Tenant; - apiKey: ApiKey; - rateLimit: number; - }>; - private validateRestrictions; - private isDomainAllowed; - hashSecret(secret: string): string; - seedDefaultKey(name: string, email: string, keyString: string): Promise; - getApiKeys(tenantId: string): Promise; - createApiKey(tenantId: string, name: string, rateLimit?: number, allowedOrigins?: string[]): Promise; - getDefaultTenant(): Promise; - findOrCreateByFirebaseUid(uid: string, email: string, name: string, photoUrl?: string): Promise; -} diff --git a/apps/api/dist/auth/auth.service.js b/apps/api/dist/auth/auth.service.js deleted file mode 100644 index b96cee2..0000000 --- a/apps/api/dist/auth/auth.service.js +++ /dev/null @@ -1,180 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -var AuthService_1; -var _a, _b; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.AuthService = void 0; -const common_1 = require("@nestjs/common"); -const typeorm_1 = require("@nestjs/typeorm"); -const typeorm_2 = require("typeorm"); -const crypto_1 = require("crypto"); -const api_key_entity_1 = require("./entities/api-key.entity"); -const tenant_entity_1 = require("./entities/tenant.entity"); -const redis_service_1 = require("../common/redis.service"); -let AuthService = AuthService_1 = class AuthService { - apiKeyRepository; - tenantRepository; - redisService; - logger = new common_1.Logger(AuthService_1.name); - constructor(apiKeyRepository, tenantRepository, redisService) { - this.apiKeyRepository = apiKeyRepository; - this.tenantRepository = tenantRepository; - this.redisService = redisService; - } - async validateApiKey(key, origin, referer) { - const cacheKey = `auth:apikey:${key}`; - const cachedData = await this.redisService.get(cacheKey); - if (cachedData) { - this.validateRestrictions(cachedData.apiKey, origin, referer); - return cachedData; - } - const apiKey = await this.apiKeyRepository.findOne({ - where: { key, isActive: true }, - relations: ['tenant'], - }); - if (!apiKey || !apiKey.tenant || !apiKey.tenant.isActive) { - throw new common_1.UnauthorizedException('Invalid or inactive API Key'); - } - this.validateRestrictions(apiKey, origin, referer); - const result = { - tenant: apiKey.tenant, - apiKey: apiKey, - rateLimit: apiKey.rateLimit || tenant_entity_1.RATE_LIMITS[apiKey.tenant.plan] || 100, - }; - await this.redisService.set(cacheKey, result, 3600); - this.apiKeyRepository.update(apiKey.id, { lastUsedAt: new Date() }).catch(err => this.logger.error(`Failed to update lastUsedAt for API key ${apiKey.id}: ${err.message}`)); - return result; - } - validateRestrictions(apiKey, origin, referer) { - if (apiKey.allowedOrigins && apiKey.allowedOrigins.length > 0) { - if (!origin || !this.isDomainAllowed(origin, apiKey.allowedOrigins)) { - this.logger.warn(`Origin mismatch for API key ${apiKey.id}. Received: ${origin}`); - throw new common_1.UnauthorizedException('Request Origin not allowed for this API Key'); - } - } - if (apiKey.allowedReferrers && apiKey.allowedReferrers.length > 0) { - if (!referer || !this.isDomainAllowed(referer, apiKey.allowedReferrers)) { - this.logger.warn(`Referer mismatch for API key ${apiKey.id}. Received: ${referer}`); - throw new common_1.UnauthorizedException('Request Referer not allowed for this API Key'); - } - } - } - isDomainAllowed(domain, allowedList) { - const cleanDomain = domain.replace(/^https?:\/\//, '').split('/')[0]; - return allowedList.some(allowed => { - if (allowed === '*') - return true; - const regex = new RegExp('^' + allowed.replace(/\*/g, '.*') + '$'); - return regex.test(cleanDomain); - }); - } - hashSecret(secret) { - return (0, crypto_1.createHash)('sha256').update(secret).digest('hex'); - } - async seedDefaultKey(name, email, keyString) { - let tenant = await this.tenantRepository.findOne({ where: { email } }); - if (!tenant) { - tenant = await this.tenantRepository.save({ - name, - email, - isActive: true, - plan: tenant_entity_1.TenantPlan.ENTERPRISE, - }); - } - const existingKey = await this.apiKeyRepository.findOne({ where: { key: keyString } }); - if (!existingKey) { - await this.apiKeyRepository.save({ - key: keyString, - secretHash: this.hashSecret(keyString), - name: 'Default Production Key', - isActive: true, - tenantId: tenant.id, - rateLimit: 1000 - }); - } - } - async getApiKeys(tenantId) { - return this.apiKeyRepository.find({ - where: { tenantId }, - order: { createdAt: 'DESC' } - }); - } - async createApiKey(tenantId, name, rateLimit, allowedOrigins) { - const existingKeysCount = await this.apiKeyRepository.count({ where: { tenantId } }); - if (existingKeysCount >= 1) { - throw new common_1.ConflictException('Limit reached: Only 1 API key allowed per developer currently.'); - } - const key = `in_${(0, crypto_1.createHash)('md5').update(Math.random().toString()).digest('hex').substring(0, 24)}`; - const apiKey = this.apiKeyRepository.create({ - key, - secretHash: this.hashSecret(key), - name, - tenantId, - rateLimit: rateLimit || 100, - allowedOrigins: allowedOrigins || [], - isActive: true - }); - return this.apiKeyRepository.save(apiKey); - } - async getDefaultTenant() { - const tenant = await this.tenantRepository.findOne({ where: {} }); - if (!tenant) - throw new common_1.NotFoundException('No tenants found in system'); - return tenant; - } - async findOrCreateByFirebaseUid(uid, email, name, photoUrl) { - let tenant = await this.tenantRepository.findOne({ where: { firebaseUid: uid } }); - if (!tenant) { - tenant = await this.tenantRepository.findOne({ where: { email } }); - if (tenant) { - this.logger.log(`Linking existing tenant ${email} to Firebase UID: ${uid}`); - tenant.firebaseUid = uid; - if (photoUrl) - tenant.photoUrl = photoUrl; - tenant = await this.tenantRepository.save(tenant); - } - else { - this.logger.log(`Creating new tenant for Firebase user: ${email} (${uid})`); - const isAdmin = email === 'hamzaaleghwairyeen@gmail.com' || email === 'hamzadoctor@gmail.com' || email === 'hamzaayedpython@gmail.com'; - tenant = await this.tenantRepository.save({ - firebaseUid: uid, - email, - name, - photoUrl, - plan: isAdmin ? tenant_entity_1.TenantPlan.ENTERPRISE : tenant_entity_1.TenantPlan.FREE, - isActive: true, - }); - } - } - else { - const isAdmin = email === 'hamzaaleghwairyeen@gmail.com' || email === 'hamzadoctor@gmail.com' || email === 'hamzaayedpython@gmail.com'; - if (isAdmin && tenant.plan !== tenant_entity_1.TenantPlan.ENTERPRISE) { - tenant.plan = tenant_entity_1.TenantPlan.ENTERPRISE; - await this.tenantRepository.save(tenant); - } - if (tenant.photoUrl !== photoUrl || tenant.name !== name) { - await this.tenantRepository.update(tenant.id, { photoUrl, name }); - } - } - return tenant; - } -}; -exports.AuthService = AuthService; -exports.AuthService = AuthService = AuthService_1 = __decorate([ - (0, common_1.Injectable)(), - __param(0, (0, typeorm_1.InjectRepository)(api_key_entity_1.ApiKey)), - __param(1, (0, typeorm_1.InjectRepository)(tenant_entity_1.Tenant)), - __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object, typeof (_b = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _b : Object, redis_service_1.RedisService]) -], AuthService); -//# sourceMappingURL=auth.service.js.map \ No newline at end of file diff --git a/apps/api/dist/auth/auth.service.js.map b/apps/api/dist/auth/auth.service.js.map deleted file mode 100644 index e5ca27c..0000000 --- a/apps/api/dist/auth/auth.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../src/auth/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAiH;AACjH,6CAAmD;AACnD,qCAAqC;AACrC,mCAAoC;AACpC,8DAAmD;AACnD,4DAA2E;AAC3E,2DAAuD;AAGhD,IAAM,WAAW,mBAAjB,MAAM,WAAW;IAKH;IAEA;IACA;IAPF,MAAM,GAAG,IAAI,eAAM,CAAC,aAAW,CAAC,IAAI,CAAC,CAAC;IAEvD,YAEmB,gBAAoC,EAEpC,gBAAoC,EACpC,YAA0B;QAH1B,qBAAgB,GAAhB,gBAAgB,CAAoB;QAEpC,qBAAgB,GAAhB,gBAAgB,CAAoB;QACpC,iBAAY,GAAZ,YAAY,CAAc;IACzC,CAAC;IAML,KAAK,CAAC,cAAc,CAA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I;iBACf,CAAC,CAAC;YACL,CAAC;QACH,CAAC;aAAM,CAAC;YAEN,MAAM,OAAO,GAAG,KAAK,KAAK,8BAA8B,IAAI,KAAK,KAAK,uBAAuB,IAAI,KAAK,KAAK,2BAA2B,CAAC;YACvI,IAAI,OAAO,IAAI,MAAM,CAAC,IAAI,KAAK,0BAAU,CAAC,UAAU,EAAE,CAAC;gBACrD,MAAM,CAAC,IAAI,GAAG,0BAAU,CAAC,UAAU,CAAC;gBACpC,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3C,CAAC;YAGD,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;gBACzD,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;YACpE,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAA;AA7MY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,0BAAgB,EAAC,uBAAM,CAAC,CAAA;IAExB,WAAA,IAAA,0BAAgB,EAAC,sBAAM,CAAC,CAAA;yDADU,oBAAU,oBAAV,oBAAU,oDAEV,oBAAU,oBAAV,oBAAU,gCACd,4BAAY;GARlC,WAAW,CA6MvB"} \ No newline at end of file diff --git a/apps/api/dist/auth/dto/management/create-key.dto.d.ts b/apps/api/dist/auth/dto/management/create-key.dto.d.ts deleted file mode 100644 index 89b1b5c..0000000 --- a/apps/api/dist/auth/dto/management/create-key.dto.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export declare class CreateKeyDto { - name: string; - rateLimit?: number; - allowedOrigins?: string[]; -} diff --git a/apps/api/dist/auth/dto/management/create-key.dto.js b/apps/api/dist/auth/dto/management/create-key.dto.js deleted file mode 100644 index 64ec835..0000000 --- a/apps/api/dist/auth/dto/management/create-key.dto.js +++ /dev/null @@ -1,35 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.CreateKeyDto = void 0; -const class_validator_1 = require("class-validator"); -class CreateKeyDto { - name; - rateLimit; - allowedOrigins; -} -exports.CreateKeyDto = CreateKeyDto; -__decorate([ - (0, class_validator_1.IsString)(), - __metadata("design:type", String) -], CreateKeyDto.prototype, "name", void 0); -__decorate([ - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - __metadata("design:type", Number) -], CreateKeyDto.prototype, "rateLimit", void 0); -__decorate([ - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsArray)(), - (0, class_validator_1.IsString)({ each: true }), - __metadata("design:type", Array) -], CreateKeyDto.prototype, "allowedOrigins", void 0); -//# sourceMappingURL=create-key.dto.js.map \ No newline at end of file diff --git a/apps/api/dist/auth/dto/management/create-key.dto.js.map b/apps/api/dist/auth/dto/management/create-key.dto.js.map deleted file mode 100644 index 083ed73..0000000 --- a/apps/api/dist/auth/dto/management/create-key.dto.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"create-key.dto.js","sourceRoot":"","sources":["../../../../src/auth/dto/management/create-key.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA0E;AAE1E,MAAa,YAAY;IAEvB,IAAI,CAAS;IAIb,SAAS,CAAU;IAKnB,cAAc,CAAY;CAC3B;AAZD,oCAYC;AAVC;IADC,IAAA,0BAAQ,GAAE;;0CACE;AAIb;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;+CACQ;AAKnB;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,yBAAO,GAAE;IACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;;oDACC"} \ No newline at end of file diff --git a/apps/api/dist/auth/entities/api-key.entity.d.ts b/apps/api/dist/auth/entities/api-key.entity.d.ts deleted file mode 100644 index 32f0389..0000000 --- a/apps/api/dist/auth/entities/api-key.entity.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Tenant } from './tenant.entity'; -export declare class ApiKey { - id: string; - key: string; - secretHash: string; - name: string; - isActive: boolean; - rateLimit: number; - allowedOrigins: string[]; - allowedReferrers: string[]; - tenant: Tenant; - tenantId: string; - lastUsedAt: Date; - createdAt: Date; - updatedAt: Date; -} diff --git a/apps/api/dist/auth/entities/api-key.entity.js b/apps/api/dist/auth/entities/api-key.entity.js deleted file mode 100644 index d739d64..0000000 --- a/apps/api/dist/auth/entities/api-key.entity.js +++ /dev/null @@ -1,87 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.ApiKey = void 0; -const typeorm_1 = require("typeorm"); -const tenant_entity_1 = require("./tenant.entity"); -let ApiKey = class ApiKey { - id; - key; - secretHash; - name; - isActive; - rateLimit; - allowedOrigins; - allowedReferrers; - tenant; - tenantId; - lastUsedAt; - createdAt; - updatedAt; -}; -exports.ApiKey = ApiKey; -__decorate([ - (0, typeorm_1.PrimaryGeneratedColumn)('uuid'), - __metadata("design:type", String) -], ApiKey.prototype, "id", void 0); -__decorate([ - (0, typeorm_1.Column)({ unique: true }), - (0, typeorm_1.Index)(), - __metadata("design:type", String) -], ApiKey.prototype, "key", void 0); -__decorate([ - (0, typeorm_1.Column)(), - __metadata("design:type", String) -], ApiKey.prototype, "secretHash", void 0); -__decorate([ - (0, typeorm_1.Column)(), - __metadata("design:type", String) -], ApiKey.prototype, "name", void 0); -__decorate([ - (0, typeorm_1.Column)({ default: true }), - __metadata("design:type", Boolean) -], ApiKey.prototype, "isActive", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", Number) -], ApiKey.prototype, "rateLimit", void 0); -__decorate([ - (0, typeorm_1.Column)('simple-array', { nullable: true }), - __metadata("design:type", Array) -], ApiKey.prototype, "allowedOrigins", void 0); -__decorate([ - (0, typeorm_1.Column)('simple-array', { nullable: true }), - __metadata("design:type", Array) -], ApiKey.prototype, "allowedReferrers", void 0); -__decorate([ - (0, typeorm_1.ManyToOne)(() => tenant_entity_1.Tenant, (tenant) => tenant.apiKeys), - __metadata("design:type", tenant_entity_1.Tenant) -], ApiKey.prototype, "tenant", void 0); -__decorate([ - (0, typeorm_1.Column)(), - __metadata("design:type", String) -], ApiKey.prototype, "tenantId", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", Date) -], ApiKey.prototype, "lastUsedAt", void 0); -__decorate([ - (0, typeorm_1.CreateDateColumn)(), - __metadata("design:type", Date) -], ApiKey.prototype, "createdAt", void 0); -__decorate([ - (0, typeorm_1.UpdateDateColumn)(), - __metadata("design:type", Date) -], ApiKey.prototype, "updatedAt", void 0); -exports.ApiKey = ApiKey = __decorate([ - (0, typeorm_1.Entity)('api_keys') -], ApiKey); -//# sourceMappingURL=api-key.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/auth/entities/api-key.entity.js.map b/apps/api/dist/auth/entities/api-key.entity.js.map deleted file mode 100644 index 17a93f2..0000000 --- a/apps/api/dist/auth/entities/api-key.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"api-key.entity.js","sourceRoot":"","sources":["../../../src/auth/entities/api-key.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAuH;AACvH,mDAAyC;AAGlC,IAAM,MAAM,GAAZ,MAAM,MAAM;IAEjB,EAAE,CAAS;IAIX,GAAG,CAAS;IAGZ,UAAU,CAAS;IAGnB,IAAI,CAAS;IAGb,QAAQ,CAAU;IAGlB,SAAS,CAAS;IAGlB,cAAc,CAAW;IAGzB,gBAAgB,CAAW;IAG3B,MAAM,CAAS;IAGf,QAAQ,CAAS;IAGjB,UAAU,CAAO;IAGjB,SAAS,CAAO;IAGhB,SAAS,CAAO;CACjB,CAAA;AAxCY,wBAAM;AAEjB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;kCACpB;AAIX;IAFC,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACxB,IAAA,eAAK,GAAE;;mCACI;AAGZ;IADC,IAAA,gBAAM,GAAE;;0CACU;AAGnB;IADC,IAAA,gBAAM,GAAE;;oCACI;AAGb;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;wCACR;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACT;AAGlB;IADC,IAAA,gBAAM,EAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CAClB;AAGzB;IADC,IAAA,gBAAM,EAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDAChB;AAG3B;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,sBAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC;8BAC5C,sBAAM;sCAAC;AAGf;IADC,IAAA,gBAAM,GAAE;;wCACQ;AAGjB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BACf,IAAI;0CAAC;AAGjB;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;yCAAC;AAGhB;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;yCAAC;iBAvCL,MAAM;IADlB,IAAA,gBAAM,EAAC,UAAU,CAAC;GACN,MAAM,CAwClB"} \ No newline at end of file diff --git a/apps/api/dist/auth/entities/tenant.entity.d.ts b/apps/api/dist/auth/entities/tenant.entity.d.ts deleted file mode 100644 index 70bbb55..0000000 --- a/apps/api/dist/auth/entities/tenant.entity.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ApiKey } from './api-key.entity'; -export declare enum TenantPlan { - FREE = "FREE", - STARTER = "STARTER", - PRO = "PRO", - ENTERPRISE = "ENTERPRISE" -} -export declare enum TenantRole { - USER = "USER", - ADMIN = "ADMIN" -} -export declare const QUOTA_LIMITS: Record; -export declare const RATE_LIMITS: Record; -export declare class Tenant { - id: string; - name: string; - email: string; - plan: TenantPlan; - firebaseUid: string; - role: TenantRole; - photoUrl: string; - isActive: boolean; - createdAt: Date; - updatedAt: Date; - apiKeys: ApiKey[]; -} diff --git a/apps/api/dist/auth/entities/tenant.entity.js b/apps/api/dist/auth/entities/tenant.entity.js deleted file mode 100644 index a249c7c..0000000 --- a/apps/api/dist/auth/entities/tenant.entity.js +++ /dev/null @@ -1,108 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tenant = exports.RATE_LIMITS = exports.QUOTA_LIMITS = exports.TenantRole = exports.TenantPlan = void 0; -const typeorm_1 = require("typeorm"); -const api_key_entity_1 = require("./api-key.entity"); -var TenantPlan; -(function (TenantPlan) { - TenantPlan["FREE"] = "FREE"; - TenantPlan["STARTER"] = "STARTER"; - TenantPlan["PRO"] = "PRO"; - TenantPlan["ENTERPRISE"] = "ENTERPRISE"; -})(TenantPlan || (exports.TenantPlan = TenantPlan = {})); -var TenantRole; -(function (TenantRole) { - TenantRole["USER"] = "USER"; - TenantRole["ADMIN"] = "ADMIN"; -})(TenantRole || (exports.TenantRole = TenantRole = {})); -exports.QUOTA_LIMITS = { - [TenantPlan.FREE]: 8000, - [TenantPlan.STARTER]: 25000, - [TenantPlan.PRO]: 100000, - [TenantPlan.ENTERPRISE]: 500000, -}; -exports.RATE_LIMITS = { - [TenantPlan.FREE]: 5, - [TenantPlan.STARTER]: 100, - [TenantPlan.PRO]: 500, - [TenantPlan.ENTERPRISE]: 50000, -}; -let Tenant = class Tenant { - id; - name; - email; - plan; - firebaseUid; - role; - photoUrl; - isActive; - createdAt; - updatedAt; - apiKeys; -}; -exports.Tenant = Tenant; -__decorate([ - (0, typeorm_1.PrimaryGeneratedColumn)('uuid'), - __metadata("design:type", String) -], Tenant.prototype, "id", void 0); -__decorate([ - (0, typeorm_1.Column)(), - __metadata("design:type", String) -], Tenant.prototype, "name", void 0); -__decorate([ - (0, typeorm_1.Column)({ unique: true }), - __metadata("design:type", String) -], Tenant.prototype, "email", void 0); -__decorate([ - (0, typeorm_1.Column)({ - type: 'enum', - enum: TenantPlan, - default: TenantPlan.FREE, - }), - __metadata("design:type", String) -], Tenant.prototype, "plan", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true, unique: true }), - __metadata("design:type", String) -], Tenant.prototype, "firebaseUid", void 0); -__decorate([ - (0, typeorm_1.Column)({ - type: 'enum', - enum: TenantRole, - default: TenantRole.USER, - }), - __metadata("design:type", String) -], Tenant.prototype, "role", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], Tenant.prototype, "photoUrl", void 0); -__decorate([ - (0, typeorm_1.Column)({ default: true }), - __metadata("design:type", Boolean) -], Tenant.prototype, "isActive", void 0); -__decorate([ - (0, typeorm_1.CreateDateColumn)(), - __metadata("design:type", Date) -], Tenant.prototype, "createdAt", void 0); -__decorate([ - (0, typeorm_1.UpdateDateColumn)(), - __metadata("design:type", Date) -], Tenant.prototype, "updatedAt", void 0); -__decorate([ - (0, typeorm_1.OneToMany)(() => api_key_entity_1.ApiKey, (apiKey) => apiKey.tenant), - __metadata("design:type", Array) -], Tenant.prototype, "apiKeys", void 0); -exports.Tenant = Tenant = __decorate([ - (0, typeorm_1.Entity)('tenants') -], Tenant); -//# sourceMappingURL=tenant.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/auth/entities/tenant.entity.js.map b/apps/api/dist/auth/entities/tenant.entity.js.map deleted file mode 100644 index 6742005..0000000 --- a/apps/api/dist/auth/entities/tenant.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"tenant.entity.js","sourceRoot":"","sources":["../../../src/auth/entities/tenant.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAgH;AAChH,qDAA0C;AAE1C,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,iCAAmB,CAAA;IACnB,yBAAW,CAAA;IACX,uCAAyB,CAAA;AAC3B,CAA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,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;2CACrB;AAOpB;IALC,IAAA,gBAAM,EAAC;QACN,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,UAAU,CAAC,IAAI;KACzB,CAAC;;oCACe;AAGjB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wCACV;AAGjB;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;wCACR;AAGlB;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;yCAAC;AAGhB;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;yCAAC;AAGhB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,uBAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;;uCACjC;iBAxCP,MAAM;IADlB,IAAA,gBAAM,EAAC,SAAS,CAAC;GACL,MAAM,CAyClB"} \ No newline at end of file diff --git a/apps/api/dist/auth/firebase-admin.service.d.ts b/apps/api/dist/auth/firebase-admin.service.d.ts deleted file mode 100644 index 851acd6..0000000 --- a/apps/api/dist/auth/firebase-admin.service.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { OnModuleInit } from '@nestjs/common'; -import { ConfigService } from '@nestjs/config'; -import * as admin from 'firebase-admin'; -export declare class FirebaseAdminService implements OnModuleInit { - private configService; - private readonly logger; - private firebaseApp; - constructor(configService: ConfigService); - onModuleInit(): void; - verifyIdToken(token: string): Promise; -} diff --git a/apps/api/dist/auth/firebase-admin.service.js b/apps/api/dist/auth/firebase-admin.service.js deleted file mode 100644 index a3606b4..0000000 --- a/apps/api/dist/auth/firebase-admin.service.js +++ /dev/null @@ -1,99 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __importStar = (this && this.__importStar) || (function () { - var ownKeys = function(o) { - ownKeys = Object.getOwnPropertyNames || function (o) { - var ar = []; - for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; - return ar; - }; - return ownKeys(o); - }; - return function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); - __setModuleDefault(result, mod); - return result; - }; -})(); -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var FirebaseAdminService_1; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.FirebaseAdminService = void 0; -const common_1 = require("@nestjs/common"); -const config_1 = require("@nestjs/config"); -const admin = __importStar(require("firebase-admin")); -const fs = __importStar(require("fs")); -const path = __importStar(require("path")); -let FirebaseAdminService = FirebaseAdminService_1 = class FirebaseAdminService { - configService; - logger = new common_1.Logger(FirebaseAdminService_1.name); - firebaseApp; - constructor(configService) { - this.configService = configService; - } - onModuleInit() { - const keyPath = this.configService.get('FIREBASE_SERVICE_ACCOUNT_PATH'); - if (!keyPath) { - this.logger.error('FIREBASE_SERVICE_ACCOUNT_PATH is not defined in environment variables'); - return; - } - try { - const absolutePath = path.isAbsolute(keyPath) - ? keyPath - : path.resolve(process.cwd(), keyPath); - if (!fs.existsSync(absolutePath)) { - this.logger.error(`Firebase service account key not found at: ${absolutePath}`); - return; - } - const serviceAccount = JSON.parse(fs.readFileSync(absolutePath, 'utf8')); - this.firebaseApp = admin.initializeApp({ - credential: admin.credential.cert(serviceAccount), - }); - this.logger.log('✅ Firebase Admin SDK initialized successfully'); - } - catch (error) { - this.logger.error(`Failed to initialize Firebase Admin SDK: ${error.message}`); - } - } - async verifyIdToken(token) { - try { - return await admin.auth().verifyIdToken(token); - } - catch (error) { - this.logger.error(`Token verification failed: ${error.message}`); - throw error; - } - } -}; -exports.FirebaseAdminService = FirebaseAdminService; -exports.FirebaseAdminService = FirebaseAdminService = FirebaseAdminService_1 = __decorate([ - (0, common_1.Injectable)(), - __metadata("design:paramtypes", [typeof (_a = typeof config_1.ConfigService !== "undefined" && config_1.ConfigService) === "function" ? _a : Object]) -], FirebaseAdminService); -//# sourceMappingURL=firebase-admin.service.js.map \ No newline at end of file diff --git a/apps/api/dist/auth/firebase-admin.service.js.map b/apps/api/dist/auth/firebase-admin.service.js.map deleted file mode 100644 index 86782c1..0000000 --- a/apps/api/dist/auth/firebase-admin.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"firebase-admin.service.js","sourceRoot":"","sources":["../../src/auth/firebase-admin.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAkE;AAClE,2CAA+C;AAC/C,sDAAwC;AACxC,uCAAyB;AACzB,2CAA6B;AAGtB,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAIX;IAHH,MAAM,GAAG,IAAI,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MAAM,KAAK,CAAC,IAAI,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACjD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACjE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF,CAAA;AA7CY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;yDAKwB,sBAAa,oBAAb,sBAAa;GAJrC,oBAAoB,CA6ChC"} \ No newline at end of file diff --git a/apps/api/dist/auth/guards/firebase-auth.guard.d.ts b/apps/api/dist/auth/guards/firebase-auth.guard.d.ts deleted file mode 100644 index 47dc02c..0000000 --- a/apps/api/dist/auth/guards/firebase-auth.guard.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { CanActivate, ExecutionContext } from '@nestjs/common'; -import { FirebaseAdminService } from '../firebase-admin.service'; -import { AuthService } from '../auth.service'; -export declare class FirebaseAuthGuard implements CanActivate { - private firebaseAdminService; - private authService; - private readonly logger; - constructor(firebaseAdminService: FirebaseAdminService, authService: AuthService); - canActivate(context: ExecutionContext): Promise; -} diff --git a/apps/api/dist/auth/guards/firebase-auth.guard.js b/apps/api/dist/auth/guards/firebase-auth.guard.js deleted file mode 100644 index 4779b56..0000000 --- a/apps/api/dist/auth/guards/firebase-auth.guard.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var FirebaseAuthGuard_1; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.FirebaseAuthGuard = void 0; -const common_1 = require("@nestjs/common"); -const firebase_admin_service_1 = require("../firebase-admin.service"); -const auth_service_1 = require("../auth.service"); -let FirebaseAuthGuard = FirebaseAuthGuard_1 = class FirebaseAuthGuard { - firebaseAdminService; - authService; - logger = new common_1.Logger(FirebaseAuthGuard_1.name); - constructor(firebaseAdminService, authService) { - this.firebaseAdminService = firebaseAdminService; - this.authService = authService; - } - async canActivate(context) { - const request = context.switchToHttp().getRequest(); - const authHeader = request.headers.authorization; - if (!authHeader || !authHeader.startsWith('Bearer ')) { - throw new common_1.UnauthorizedException('Missing or invalid Authorization header'); - } - const token = authHeader.split('Bearer ')[1]; - try { - const decodedToken = await this.firebaseAdminService.verifyIdToken(token); - const tenant = await this.authService.findOrCreateByFirebaseUid(decodedToken.uid, decodedToken.email || '', decodedToken.name || decodedToken.email?.split('@')[0] || 'Unknown User', decodedToken.picture); - if (!tenant.isActive) { - throw new common_1.UnauthorizedException('Tenant account is disabled'); - } - request['tenant'] = tenant; - request['user'] = decodedToken; - return true; - } - catch (error) { - this.logger.error(`Firebase Auth failed: ${error.message}`); - throw new common_1.UnauthorizedException(error.message || 'Authentication failed'); - } - } -}; -exports.FirebaseAuthGuard = FirebaseAuthGuard; -exports.FirebaseAuthGuard = FirebaseAuthGuard = FirebaseAuthGuard_1 = __decorate([ - (0, common_1.Injectable)(), - __metadata("design:paramtypes", [firebase_admin_service_1.FirebaseAdminService, - auth_service_1.AuthService]) -], FirebaseAuthGuard); -//# sourceMappingURL=firebase-auth.guard.js.map \ No newline at end of file diff --git a/apps/api/dist/auth/guards/firebase-auth.guard.js.map b/apps/api/dist/auth/guards/firebase-auth.guard.js.map deleted file mode 100644 index 7c85d72..0000000 --- a/apps/api/dist/auth/guards/firebase-auth.guard.js.map +++ /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CAAC;gBACrB,MAAM,IAAI,8BAAqB,CAAC,4BAA4B,CAAC,CAAC;YAChE,CAAC;YAGD,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;YAC3B,OAAO,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC;YAE/B,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAC5D,MAAM,IAAI,8BAAqB,CAAC,KAAK,CAAC,OAAO,IAAI,uBAAuB,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC;CACF,CAAA;AA5CY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;qCAKqB,6CAAoB;QAC7B,0BAAW;GALvB,iBAAiB,CA4C7B"} \ No newline at end of file diff --git a/apps/api/dist/auth/tenant.controller.d.ts b/apps/api/dist/auth/tenant.controller.d.ts deleted file mode 100644 index 7011936..0000000 --- a/apps/api/dist/auth/tenant.controller.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { AuthService } from './auth.service'; -import { CreateKeyDto } from './dto/management/create-key.dto'; -export declare class TenantController { - private readonly authService; - constructor(authService: AuthService); - createKey(req: any, dto: CreateKeyDto): Promise; - getKeys(req: any): Promise; - getMe(req: any): Promise; -} diff --git a/apps/api/dist/auth/tenant.controller.js b/apps/api/dist/auth/tenant.controller.js deleted file mode 100644 index bcec1ac..0000000 --- a/apps/api/dist/auth/tenant.controller.js +++ /dev/null @@ -1,74 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.TenantController = void 0; -const common_1 = require("@nestjs/common"); -const auth_service_1 = require("./auth.service"); -const create_key_dto_1 = require("./dto/management/create-key.dto"); -const swagger_1 = require("@nestjs/swagger"); -const firebase_auth_guard_1 = require("./guards/firebase-auth.guard"); -let TenantController = class TenantController { - authService; - constructor(authService) { - this.authService = authService; - } - async createKey(req, dto) { - if (req.user && req.user.email_verified === false) { - throw new common_1.ForbiddenException('You must verify your email address before creating an API key.'); - } - const tenantId = req.tenant.id; - return this.authService.createApiKey(tenantId, dto.name, dto.rateLimit, dto.allowedOrigins); - } - async getKeys(req) { - const tenantId = req.tenant.id; - return this.authService.getApiKeys(tenantId); - } - async getMe(req) { - return req.tenant; - } -}; -exports.TenantController = TenantController; -__decorate([ - (0, common_1.Post)('keys'), - (0, swagger_1.ApiOperation)({ summary: 'Create a new API key' }), - __param(0, (0, common_1.Req)()), - __param(1, (0, common_1.Body)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object, create_key_dto_1.CreateKeyDto]), - __metadata("design:returntype", Promise) -], TenantController.prototype, "createKey", null); -__decorate([ - (0, common_1.Get)('keys'), - (0, swagger_1.ApiOperation)({ summary: 'Get all API keys for the authenticated tenant' }), - __param(0, (0, common_1.Req)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object]), - __metadata("design:returntype", Promise) -], TenantController.prototype, "getKeys", null); -__decorate([ - (0, common_1.Get)('me'), - (0, swagger_1.ApiOperation)({ summary: 'Get current authenticated tenant info' }), - __param(0, (0, common_1.Req)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object]), - __metadata("design:returntype", Promise) -], TenantController.prototype, "getMe", null); -exports.TenantController = TenantController = __decorate([ - (0, swagger_1.ApiTags)('auth'), - (0, swagger_1.ApiBearerAuth)(), - (0, common_1.UseGuards)(firebase_auth_guard_1.FirebaseAuthGuard), - (0, common_1.Controller)('auth/management'), - __metadata("design:paramtypes", [auth_service_1.AuthService]) -], TenantController); -//# sourceMappingURL=tenant.controller.js.map \ No newline at end of file diff --git a/apps/api/dist/auth/tenant.controller.js.map b/apps/api/dist/auth/tenant.controller.js.map deleted file mode 100644 index bc25365..0000000 --- a/apps/api/dist/auth/tenant.controller.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"tenant.controller.js","sourceRoot":"","sources":["../../src/auth/tenant.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwG;AACxG,iDAA6C;AAC7C,oEAA+D;AAC/D,6CAAuE;AACvE,sEAAiE;AAM1D,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IACE;IAA7B,YAA6B,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAInD,AAAN,KAAK,CAAC,SAAS,CACN,GAAQ,EACP,GAAiB;QAEzB,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,cAAc,KAAK,KAAK,EAAE,CAAC;YAClD,MAAM,IAAI,2BAAkB,CAAC,gEAAgE,CAAC,CAAC;QACjG,CAAC;QAED,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,CAClC,QAAQ,EACR,GAAG,CAAC,IAAI,EACR,GAAG,CAAC,SAAS,EACb,GAAG,CAAC,cAAc,CACnB,CAAC;IACJ,CAAC;IAIK,AAAN,KAAK,CAAC,OAAO,CAAQ,GAAQ;QAC3B,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAIK,AAAN,KAAK,CAAC,KAAK,CAAQ,GAAQ;QACzB,OAAO,GAAG,CAAC,MAAM,CAAC;IACpB,CAAC;CACF,CAAA;AAlCY,4CAAgB;AAKrB;IAFL,IAAA,aAAI,EAAC,MAAM,CAAC;IACZ,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC;IAE/C,WAAA,IAAA,YAAG,GAAE,CAAA;IACL,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAM,6BAAY;;iDAa1B;AAIK;IAFL,IAAA,YAAG,EAAC,MAAM,CAAC;IACX,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,+CAA+C,EAAE,CAAC;IAC5D,WAAA,IAAA,YAAG,GAAE,CAAA;;;;+CAGnB;AAIK;IAFL,IAAA,YAAG,EAAC,IAAI,CAAC;IACT,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,uCAAuC,EAAE,CAAC;IACtD,WAAA,IAAA,YAAG,GAAE,CAAA;;;;6CAEjB;2BAjCU,gBAAgB;IAJ5B,IAAA,iBAAO,EAAC,MAAM,CAAC;IACf,IAAA,uBAAa,GAAE;IACf,IAAA,kBAAS,EAAC,uCAAiB,CAAC;IAC5B,IAAA,mBAAU,EAAC,iBAAiB,CAAC;qCAEc,0BAAW;GAD1C,gBAAgB,CAkC5B"} \ No newline at end of file diff --git a/apps/api/dist/billing/billing.controller.d.ts b/apps/api/dist/billing/billing.controller.d.ts deleted file mode 100644 index cfcffa8..0000000 --- a/apps/api/dist/billing/billing.controller.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { BillingService } from './billing.service'; -import { PayMobProvider } from './providers/paymob.provider'; -import { BinanceProvider } from './providers/binance.provider'; -import { PaymentProvider } from './entities/transaction.entity'; -export declare class BillingController { - private billingService; - private paymobProvider; - private binanceProvider; - private readonly logger; - constructor(billingService: BillingService, paymobProvider: PayMobProvider, binanceProvider: BinanceProvider); - getSubscription(req: any): Promise; - checkout(req: any, body: { - plan: string; - provider: PaymentProvider; - }): Promise<{ - checkoutUrl: any; - orderId: string; - prepayId: any; - } | { - checkoutUrl: string; - orderId: string; - }>; - handlePaymobCallback(query: any, req: any): Promise; - handlePaymobWebhook(body: any, hmac: string): Promise<{ - status: string; - message: string; - } | { - status: string; - message?: undefined; - }>; - handleBinanceWebhook(body: any, req: any): Promise<{ - returnCode: string; - returnMessage: any; - }>; - getInvoices(req: any): Promise; -} diff --git a/apps/api/dist/billing/billing.controller.js b/apps/api/dist/billing/billing.controller.js deleted file mode 100644 index 4fd1ac5..0000000 --- a/apps/api/dist/billing/billing.controller.js +++ /dev/null @@ -1,259 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -var BillingController_1; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.BillingController = void 0; -const common_1 = require("@nestjs/common"); -const billing_service_1 = require("./billing.service"); -const paymob_provider_1 = require("./providers/paymob.provider"); -const binance_provider_1 = require("./providers/binance.provider"); -const firebase_auth_guard_1 = require("../auth/guards/firebase-auth.guard"); -const swagger_1 = require("@nestjs/swagger"); -const transaction_entity_1 = require("./entities/transaction.entity"); -let BillingController = BillingController_1 = class BillingController { - billingService; - paymobProvider; - binanceProvider; - logger = new common_1.Logger(BillingController_1.name); - constructor(billingService, paymobProvider, binanceProvider) { - this.billingService = billingService; - this.paymobProvider = paymobProvider; - this.binanceProvider = binanceProvider; - } - async getSubscription(req) { - return this.billingService.getSubscription(req.tenant.id); - } - async checkout(req, body) { - const tenantId = req.tenant.id; - const plan = body.plan; - const pricing = { - 'STARTER': 29, - 'PRO': 89, - }; - const amount = pricing[plan] || 0; - if (amount === 0 && plan !== 'FREE') { - throw new common_1.BadRequestException('Invalid plan or price not configured'); - } - if (body.provider === transaction_entity_1.PaymentProvider.PAYMOB) { - const { paymentKey, orderId } = await this.paymobProvider.createPaymentKey(tenantId, amount, plan); - const iframeId = this.billingService.getIframeId(); - const checkoutUrl = `https://accept.paymob.com/api/acceptance/iframes/${iframeId}?payment_token=${paymentKey}`; - return { checkoutUrl, orderId }; - } - if (body.provider === transaction_entity_1.PaymentProvider.BINANCE) { - return this.binanceProvider.createOrder(tenantId, amount, plan); - } - throw new common_1.BadRequestException('Invalid payment provider'); - } - async handlePaymobCallback(query, req) { - this.logger.log(`🔄 PayMob Redirect Callback: ID ${query.id}, Success: ${query.success}`); - if (query.success === 'true' && query.id) { - try { - const txDetails = await this.paymobProvider.getTransactionDetails(query.id); - if (txDetails && txDetails.success === true) { - const extraDesc = txDetails.order?.shipping_data?.extra_description || ""; - const [tenantId, plan] = extraDesc.split('|'); - if (tenantId) { - await this.billingService.processSuccessfulPayment(query.id.toString(), transaction_entity_1.PaymentProvider.PAYMOB, txDetails.amount_cents / 100, { tenantId, plan: plan || 'PRO' }); - this.logger.log(`🚀 Immediate Activation triggered via Callback for Tenant ${tenantId}`); - } - } - } - catch (e) { - this.logger.error(`Failed during immediate activation fallback: ${e.message}`); - } - } - const targetUrl = `https://map-dashboard.intaleqapp.com/dashboard.html#billing?payment_status=${query.success === 'true' ? 'success' : 'failed'}&id=${query.id}`; - return ` - - - - - Intaleq Maps | تمت العملية بنجاح - - - - - -
- -
-
- -
-
- - - -
- -

شكراً لك، حمزة!

-

تم تفعيل خطة PRO بنجاح. يتم الآن توجيهك إلى لوحة التحكم...

- -
-
-
-
-
-
- - -
- - - `; - } - async handlePaymobWebhook(body, hmac) { - this.logger.log(`📥 PayMob Webhook Received: Transaction ID ${body.obj?.id}`); - if (!this.paymobProvider.verifyHmac(body.obj, hmac)) { - this.logger.error('❌ PayMob HMAC Verification Failed'); - throw new common_1.BadRequestException('Invalid signature'); - } - if (body.obj.success === true) { - const extraDesc = body.obj.order?.shipping_data?.extra_description || ""; - const [tenantId, plan] = extraDesc.split('|'); - if (!tenantId) { - this.logger.error(`❌ PayMob Webhook failed: No tenantId in metadata. Raw: ${extraDesc}`); - return { status: 'error', message: 'No tenantId found' }; - } - await this.billingService.processSuccessfulPayment(body.obj.id.toString(), transaction_entity_1.PaymentProvider.PAYMOB, body.obj.amount_cents / 100, { - tenantId, - plan: plan || 'PRO' - }); - } - return { status: 'success' }; - } - async handleBinanceWebhook(body, req) { - const timestamp = req.headers['binancepay-timestamp']; - const nonce = req.headers['binancepay-nonce']; - const signature = req.headers['binancepay-signature']; - this.logger.log(`📥 Binance Webhook Received: Transaction ID ${body.bizId || 'UNKNOWN'}`); - if (!timestamp || !nonce || !signature) { - this.logger.error('❌ Binance Webhook: Missing required headers'); - throw new common_1.BadRequestException('Missing headers'); - } - if (!this.binanceProvider.verifySignature(timestamp, nonce, signature, body)) { - this.logger.error('❌ Binance Signature Verification Failed'); - throw new common_1.BadRequestException('Invalid signature'); - } - if (body.bizStatus === 'PAY_SUCCESS') { - try { - let dataObj = {}; - if (body.data) { - dataObj = JSON.parse(body.data); - } - let tenantId = ''; - let plan = 'PRO'; - if (dataObj.passThroughInfo) { - const passThrough = JSON.parse(dataObj.passThroughInfo); - tenantId = passThrough.tenantId; - plan = passThrough.plan; - } - if (!tenantId) { - this.logger.error(`❌ Binance Webhook failed: No tenantId found. Body: ${JSON.stringify(body)}`); - return { returnCode: 'FAIL', returnMessage: 'No tenantId found' }; - } - const externalTxId = dataObj.merchantTradeNo || body.bizId?.toString(); - await this.billingService.processSuccessfulPayment(externalTxId, transaction_entity_1.PaymentProvider.BINANCE, 0, { tenantId, plan }); - this.logger.log(`✅ Binance Payment Processed Successfully for Tenant ${tenantId}`); - } - catch (err) { - this.logger.error(`❌ Failed to process Binance payment: ${err.message}`); - return { returnCode: 'FAIL', returnMessage: err.message }; - } - } - return { - returnCode: 'SUCCESS', - returnMessage: null, - }; - } - async getInvoices(req) { - return this.billingService.getTransactionHistory(req.tenant.id); - } -}; -exports.BillingController = BillingController; -__decorate([ - (0, swagger_1.ApiBearerAuth)(), - (0, common_1.UseGuards)(firebase_auth_guard_1.FirebaseAuthGuard), - (0, common_1.Get)('subscription'), - (0, swagger_1.ApiOperation)({ summary: 'Get current subscription details' }), - __param(0, (0, common_1.Req)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object]), - __metadata("design:returntype", Promise) -], BillingController.prototype, "getSubscription", null); -__decorate([ - (0, swagger_1.ApiBearerAuth)(), - (0, common_1.UseGuards)(firebase_auth_guard_1.FirebaseAuthGuard), - (0, common_1.Post)('checkout'), - (0, swagger_1.ApiOperation)({ summary: 'Initialize a checkout session' }), - __param(0, (0, common_1.Req)()), - __param(1, (0, common_1.Body)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object, Object]), - __metadata("design:returntype", Promise) -], BillingController.prototype, "checkout", null); -__decorate([ - (0, common_1.Get)('callback/paymob'), - (0, swagger_1.ApiOperation)({ summary: 'PayMob Redirection Handler' }), - __param(0, (0, common_1.Query)()), - __param(1, (0, common_1.Req)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object, Object]), - __metadata("design:returntype", Promise) -], BillingController.prototype, "handlePaymobCallback", null); -__decorate([ - (0, common_1.Post)('webhooks/paymob'), - (0, swagger_1.ApiOperation)({ summary: 'PayMob Payment Webhook' }), - __param(0, (0, common_1.Body)()), - __param(1, (0, common_1.Query)('hmac')), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object, String]), - __metadata("design:returntype", Promise) -], BillingController.prototype, "handlePaymobWebhook", null); -__decorate([ - (0, common_1.Post)('webhooks/binance'), - (0, swagger_1.ApiOperation)({ summary: 'Binance Payment Webhook' }), - __param(0, (0, common_1.Body)()), - __param(1, (0, common_1.Req)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object, Object]), - __metadata("design:returntype", Promise) -], BillingController.prototype, "handleBinanceWebhook", null); -__decorate([ - (0, swagger_1.ApiBearerAuth)(), - (0, common_1.UseGuards)(firebase_auth_guard_1.FirebaseAuthGuard), - (0, common_1.Get)('invoices'), - (0, swagger_1.ApiOperation)({ summary: 'Get payment history' }), - __param(0, (0, common_1.Req)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object]), - __metadata("design:returntype", Promise) -], BillingController.prototype, "getInvoices", null); -exports.BillingController = BillingController = BillingController_1 = __decorate([ - (0, swagger_1.ApiTags)('billing'), - (0, common_1.Controller)('billing'), - __metadata("design:paramtypes", [billing_service_1.BillingService, - paymob_provider_1.PayMobProvider, - binance_provider_1.BinanceProvider]) -], BillingController); -//# sourceMappingURL=billing.controller.js.map \ No newline at end of file diff --git a/apps/api/dist/billing/billing.controller.js.map b/apps/api/dist/billing/billing.controller.js.map deleted file mode 100644 index 645d1d5..0000000 --- a/apps/api/dist/billing/billing.controller.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"billing.controller.js","sourceRoot":"","sources":["../../src/billing/billing.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAiH;AACjH,uDAAmD;AACnD,iEAA6D;AAC7D,mEAA+D;AAC/D,4EAAuE;AACvE,6CAAuE;AACvE,sEAA+E;AAIxE,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAIlB;IACA;IACA;IALO,MAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;IAE7D,YACU,cAA8B,EAC9B,cAA8B,EAC9B,eAAgC;QAFhC,mBAAc,G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,EAAC,uCAAiB,CAAC;IAC5B,IAAA,YAAG,EAAC,UAAU,CAAC;IACf,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,qBAAqB,EAAE,CAAC;IAC9B,WAAA,IAAA,YAAG,GAAE,CAAA;;;;oDAEvB;4BA/PU,iBAAiB;IAF7B,IAAA,iBAAO,EAAC,SAAS,CAAC;IAClB,IAAA,mBAAU,EAAC,SAAS,CAAC;qCAKM,gCAAc;QACd,gCAAc;QACb,kCAAe;GAN/B,iBAAiB,CAgQ7B"} \ No newline at end of file diff --git a/apps/api/dist/billing/billing.module.d.ts b/apps/api/dist/billing/billing.module.d.ts deleted file mode 100644 index f45c2c8..0000000 --- a/apps/api/dist/billing/billing.module.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare class BillingModule { -} diff --git a/apps/api/dist/billing/billing.module.js b/apps/api/dist/billing/billing.module.js deleted file mode 100644 index 3977b07..0000000 --- a/apps/api/dist/billing/billing.module.js +++ /dev/null @@ -1,32 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.BillingModule = void 0; -const common_1 = require("@nestjs/common"); -const typeorm_1 = require("@nestjs/typeorm"); -const subscription_entity_1 = require("./entities/subscription.entity"); -const transaction_entity_1 = require("./entities/transaction.entity"); -const billing_service_1 = require("./billing.service"); -const billing_controller_1 = require("./billing.controller"); -const paymob_provider_1 = require("./providers/paymob.provider"); -const binance_provider_1 = require("./providers/binance.provider"); -const tenant_entity_1 = require("../auth/entities/tenant.entity"); -let BillingModule = class BillingModule { -}; -exports.BillingModule = BillingModule; -exports.BillingModule = BillingModule = __decorate([ - (0, common_1.Module)({ - imports: [ - typeorm_1.TypeOrmModule.forFeature([subscription_entity_1.Subscription, transaction_entity_1.Transaction, tenant_entity_1.Tenant]), - ], - providers: [billing_service_1.BillingService, paymob_provider_1.PayMobProvider, binance_provider_1.BinanceProvider], - controllers: [billing_controller_1.BillingController], - exports: [billing_service_1.BillingService], - }) -], BillingModule); -//# sourceMappingURL=billing.module.js.map \ No newline at end of file diff --git a/apps/api/dist/billing/billing.module.js.map b/apps/api/dist/billing/billing.module.js.map deleted file mode 100644 index 08effd0..0000000 --- a/apps/api/dist/billing/billing.module.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"billing.module.js","sourceRoot":"","sources":["../../src/billing/billing.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,wEAA8D;AAC9D,sEAA4D;AAC5D,uDAAmD;AACnD,6DAAyD;AACzD,iEAA6D;AAC7D,mEAA+D;AAC/D,kEAAwD;AAUjD,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,sCAAa;wBAAb,aAAa;IARzB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,UAAU,CAAC,CAAC,kCAAY,EAAE,gCAAW,EAAE,sBAAM,CAAC,CAAC;SAC9D;QACD,SAAS,EAAE,CAAC,gCAAc,EAAE,gCAAc,EAAE,kCAAe,CAAC;QAC5D,WAAW,EAAE,CAAC,sCAAiB,CAAC;QAChC,OAAO,EAAE,CAAC,gCAAc,CAAC;KAC1B,CAAC;GACW,aAAa,CAAG"} \ No newline at end of file diff --git a/apps/api/dist/billing/billing.service.d.ts b/apps/api/dist/billing/billing.service.d.ts deleted file mode 100644 index 713fdea..0000000 --- a/apps/api/dist/billing/billing.service.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { ConfigService } from '@nestjs/config'; -import { Repository } from 'typeorm'; -import { Subscription } from './entities/subscription.entity'; -import { Transaction, PaymentProvider } from './entities/transaction.entity'; -import { Tenant } from '../auth/entities/tenant.entity'; -import { MailService } from '../common/mail.service'; -export declare class BillingService { - private subscriptionRepository; - private transactionRepository; - private tenantRepository; - private configService; - private mailService; - private readonly logger; - constructor(subscriptionRepository: Repository, transactionRepository: Repository, tenantRepository: Repository, configService: ConfigService, mailService: MailService); - getIframeId(): string; - getSubscription(tenantId: string): Promise; - processSuccessfulPayment(externalTxId: string, provider: PaymentProvider, amount: number, metadata: any): Promise; - private upgradeTenantPlan; - getTransactionHistory(tenantId: string): Promise; -} diff --git a/apps/api/dist/billing/billing.service.js b/apps/api/dist/billing/billing.service.js deleted file mode 100644 index ba6ad57..0000000 --- a/apps/api/dist/billing/billing.service.js +++ /dev/null @@ -1,131 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -var BillingService_1; -var _a, _b, _c, _d; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.BillingService = void 0; -const common_1 = require("@nestjs/common"); -const config_1 = require("@nestjs/config"); -const typeorm_1 = require("@nestjs/typeorm"); -const typeorm_2 = require("typeorm"); -const subscription_entity_1 = require("./entities/subscription.entity"); -const transaction_entity_1 = require("./entities/transaction.entity"); -const tenant_entity_1 = require("../auth/entities/tenant.entity"); -const mail_service_1 = require("../common/mail.service"); -let BillingService = BillingService_1 = class BillingService { - subscriptionRepository; - transactionRepository; - tenantRepository; - configService; - mailService; - logger = new common_1.Logger(BillingService_1.name); - constructor(subscriptionRepository, transactionRepository, tenantRepository, configService, mailService) { - this.subscriptionRepository = subscriptionRepository; - this.transactionRepository = transactionRepository; - this.tenantRepository = tenantRepository; - this.configService = configService; - this.mailService = mailService; - } - getIframeId() { - return this.configService.get('PAYMOB_IFRAME_ID', '837992'); - } - async getSubscription(tenantId) { - let sub = await this.subscriptionRepository.findOne({ where: { tenantId } }); - if (!sub) { - sub = await this.subscriptionRepository.save({ - tenantId, - plan: 'FREE', - monthlyRequestLimit: 5000, - status: subscription_entity_1.SubscriptionStatus.ACTIVE, - }); - } - return sub; - } - async processSuccessfulPayment(externalTxId, provider, amount, metadata) { - let txn = await this.transactionRepository.findOne({ where: { externalTransactionId: externalTxId } }); - if (txn && txn.status === transaction_entity_1.PaymentStatus.SUCCESS) { - this.logger.warn(`Transaction ${externalTxId} already processed.`); - return; - } - if (!txn) { - const tenantId = metadata.tenantId; - if (!tenantId) - throw new common_1.BadRequestException('No tenantId found in payment metadata'); - txn = await this.transactionRepository.save({ - tenantId, - externalTransactionId: externalTxId, - amount, - provider, - status: transaction_entity_1.PaymentStatus.SUCCESS, - metadata, - }); - } - else { - txn.status = transaction_entity_1.PaymentStatus.SUCCESS; - txn.metadata = { ...txn.metadata, ...metadata }; - await this.transactionRepository.save(txn); - } - const tenantId = txn.tenantId; - const plan = metadata.plan || 'PRO'; - await this.upgradeTenantPlan(tenantId, plan); - try { - const tenant = await this.tenantRepository.findOne({ where: { id: tenantId } }); - if (tenant && tenant.email) { - await this.mailService.sendInvoiceEmail(tenant.email, { - tenantName: tenant.name, - plan: plan, - amount: `${amount} EGP`, - transactionId: externalTxId, - }); - } - } - catch (err) { - this.logger.error(`Failed to send invoice email for tx ${externalTxId}: ${err.message}`); - } - this.logger.log(`✅ Tenant ${tenantId} upgraded to ${plan} after payment ${externalTxId}`); - } - async upgradeTenantPlan(tenantId, plan) { - await this.tenantRepository.update(tenantId, { plan }); - const limits = { - [tenant_entity_1.TenantPlan.FREE]: 5000, - [tenant_entity_1.TenantPlan.STARTER]: 25000, - [tenant_entity_1.TenantPlan.PRO]: 100000, - [tenant_entity_1.TenantPlan.ENTERPRISE]: 500000, - }; - const sub = await this.getSubscription(tenantId); - sub.plan = plan; - sub.monthlyRequestLimit = limits[plan] || 8000; - sub.status = subscription_entity_1.SubscriptionStatus.ACTIVE; - sub.currentPeriodStart = new Date(); - const nextMonth = new Date(); - nextMonth.setMonth(nextMonth.getMonth() + 1); - sub.currentPeriodEnd = nextMonth; - await this.subscriptionRepository.save(sub); - } - async getTransactionHistory(tenantId) { - return this.transactionRepository.find({ - where: { tenantId }, - order: { createdAt: 'DESC' }, - }); - } -}; -exports.BillingService = BillingService; -exports.BillingService = BillingService = BillingService_1 = __decorate([ - (0, common_1.Injectable)(), - __param(0, (0, typeorm_1.InjectRepository)(subscription_entity_1.Subscription)), - __param(1, (0, typeorm_1.InjectRepository)(transaction_entity_1.Transaction)), - __param(2, (0, typeorm_1.InjectRepository)(tenant_entity_1.Tenant)), - __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object, typeof (_b = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _b : Object, typeof (_c = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _c : Object, typeof (_d = typeof config_1.ConfigService !== "undefined" && config_1.ConfigService) === "function" ? _d : Object, mail_service_1.MailService]) -], BillingService); -//# sourceMappingURL=billing.service.js.map \ No newline at end of file diff --git a/apps/api/dist/billing/billing.service.js.map b/apps/api/dist/billing/billing.service.js.map deleted file mode 100644 index bdf8f94..0000000 --- a/apps/api/dist/billing/billing.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"billing.service.js","sour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AAI,IAAI,EAAE,CAAC;QAEpC,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAC7B,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;QAC7C,GAAG,CAAC,gBAAgB,GAAG,SAAS,CAAC;QAEjC,MAAM,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,QAAgB;QAC1C,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC;YACrC,KAAK,EAAE,EAAE,QAAQ,EAAE;YACnB,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;SAC7B,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AApIY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,0BAAgB,EAAC,kCAAY,CAAC,CAAA;IAE9B,WAAA,IAAA,0BAAgB,EAAC,gCAAW,CAAC,CAAA;IAE7B,WAAA,IAAA,0BAAgB,EAAC,sBAAM,CAAC,CAAA;yDAHO,oBAAU,oBAAV,oBAAU,oDAEX,oBAAU,oBAAV,oBAAU,oDAEf,oBAAU,oBAAV,oBAAU,oDACb,sBAAa,oBAAb,sBAAa,gCACf,0BAAW;GAXvB,cAAc,CAoI1B"} \ No newline at end of file diff --git a/apps/api/dist/billing/entities/subscription.entity.d.ts b/apps/api/dist/billing/entities/subscription.entity.d.ts deleted file mode 100644 index 419dd96..0000000 --- a/apps/api/dist/billing/entities/subscription.entity.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -export declare enum SubscriptionStatus { - ACTIVE = "ACTIVE", - PAST_DUE = "PAST_DUE", - CANCELED = "CANCELED", - TRIALING = "TRIALING" -} -export declare class Subscription { - id: string; - tenantId: string; - plan: string; - status: SubscriptionStatus; - monthlyRequestLimit: number; - currentPeriodStart: Date; - currentPeriodEnd: Date; - canceledAt: Date; - createdAt: Date; - updatedAt: Date; -} diff --git a/apps/api/dist/billing/entities/subscription.entity.js b/apps/api/dist/billing/entities/subscription.entity.js deleted file mode 100644 index b52b289..0000000 --- a/apps/api/dist/billing/entities/subscription.entity.js +++ /dev/null @@ -1,82 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Subscription = exports.SubscriptionStatus = void 0; -const typeorm_1 = require("typeorm"); -var SubscriptionStatus; -(function (SubscriptionStatus) { - SubscriptionStatus["ACTIVE"] = "ACTIVE"; - SubscriptionStatus["PAST_DUE"] = "PAST_DUE"; - SubscriptionStatus["CANCELED"] = "CANCELED"; - SubscriptionStatus["TRIALING"] = "TRIALING"; -})(SubscriptionStatus || (exports.SubscriptionStatus = SubscriptionStatus = {})); -let Subscription = class Subscription { - id; - tenantId; - plan; - status; - monthlyRequestLimit; - currentPeriodStart; - currentPeriodEnd; - canceledAt; - createdAt; - updatedAt; -}; -exports.Subscription = Subscription; -__decorate([ - (0, typeorm_1.PrimaryGeneratedColumn)('uuid'), - __metadata("design:type", String) -], Subscription.prototype, "id", void 0); -__decorate([ - (0, typeorm_1.Index)(), - (0, typeorm_1.Column)(), - __metadata("design:type", String) -], Subscription.prototype, "tenantId", void 0); -__decorate([ - (0, typeorm_1.Column)({ default: 'FREE' }), - __metadata("design:type", String) -], Subscription.prototype, "plan", void 0); -__decorate([ - (0, typeorm_1.Column)({ - type: 'enum', - enum: SubscriptionStatus, - default: SubscriptionStatus.ACTIVE, - }), - __metadata("design:type", String) -], Subscription.prototype, "status", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'int', default: 8000 }), - __metadata("design:type", Number) -], Subscription.prototype, "monthlyRequestLimit", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'timestamp', nullable: true }), - __metadata("design:type", Date) -], Subscription.prototype, "currentPeriodStart", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'timestamp', nullable: true }), - __metadata("design:type", Date) -], Subscription.prototype, "currentPeriodEnd", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'timestamp', nullable: true }), - __metadata("design:type", Date) -], Subscription.prototype, "canceledAt", void 0); -__decorate([ - (0, typeorm_1.CreateDateColumn)(), - __metadata("design:type", Date) -], Subscription.prototype, "createdAt", void 0); -__decorate([ - (0, typeorm_1.UpdateDateColumn)(), - __metadata("design:type", Date) -], Subscription.prototype, "updatedAt", void 0); -exports.Subscription = Subscription = __decorate([ - (0, typeorm_1.Entity)('subscriptions') -], Subscription); -//# sourceMappingURL=subscription.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/billing/entities/subscription.entity.js.map b/apps/api/dist/billing/entities/subscription.entity.js.map deleted file mode 100644 index db958d2..0000000 --- a/apps/api/dist/billing/entities/subscription.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"subscription.entity.js","sourceRoot":"","sources":["../../../src/billing/entities/subscription.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAQiB;AAGjB,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,uCAAiB,CAAA;IACjB,2CAAqB,CAAA;IACrB,2CAAqB,CAAA;IACrB,2CAAqB,CAAA;AACvB,CAAC,EALW,kBAAkB,kCAAlB,kBAAkB,QAK7B;AAGM,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEvB,EAAE,CAAS;IAIX,QAAQ,CAAS;IAGjB,IAAI,CAAS;IAOb,MAAM,CAAqB;IAG3B,mBAAmB,CAAS;IAG5B,kBAAkB,CAAO;IAGzB,gBAAgB,CAAO;IAGvB,UAAU,CAAO;IAGjB,SAAS,CAAO;IAGhB,SAAS,CAAO;CACjB,CAAA;AAnCY,oCAAY;AAEvB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;wCACpB;AAIX;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,GAAE;;8CACQ;AAGjB;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;;0CACf;AAOb;IALC,IAAA,gBAAM,EAAC;QACN,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,kBAAkB;QACxB,OAAO,EAAE,kBAAkB,CAAC,MAAM;KACnC,CAAC;;4CACyB;AAG3B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;yDACX;AAG5B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BAC1B,IAAI;wDAAC;AAGzB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BAC5B,IAAI;sDAAC;AAGvB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BAClC,IAAI;gDAAC;AAGjB;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;+CAAC;AAGhB;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;+CAAC;uBAlCL,YAAY;IADxB,IAAA,gBAAM,EAAC,eAAe,CAAC;GACX,YAAY,CAmCxB"} \ No newline at end of file diff --git a/apps/api/dist/billing/entities/transaction.entity.d.ts b/apps/api/dist/billing/entities/transaction.entity.d.ts deleted file mode 100644 index cd1d03f..0000000 --- a/apps/api/dist/billing/entities/transaction.entity.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -export declare enum PaymentStatus { - PENDING = "PENDING", - SUCCESS = "SUCCESS", - FAILED = "FAILED", - REFUNDED = "REFUNDED" -} -export declare enum PaymentProvider { - PAYMOB = "PAYMOB", - BINANCE = "BINANCE", - MANUAL = "MANUAL" -} -export declare class Transaction { - id: string; - tenantId: string; - subscriptionId: string; - amount: number; - currency: string; - provider: PaymentProvider; - externalTransactionId: string; - status: PaymentStatus; - metadata: Record; - createdAt: Date; -} diff --git a/apps/api/dist/billing/entities/transaction.entity.js b/apps/api/dist/billing/entities/transaction.entity.js deleted file mode 100644 index 2a79e7b..0000000 --- a/apps/api/dist/billing/entities/transaction.entity.js +++ /dev/null @@ -1,92 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Transaction = exports.PaymentProvider = exports.PaymentStatus = void 0; -const typeorm_1 = require("typeorm"); -var PaymentStatus; -(function (PaymentStatus) { - PaymentStatus["PENDING"] = "PENDING"; - PaymentStatus["SUCCESS"] = "SUCCESS"; - PaymentStatus["FAILED"] = "FAILED"; - PaymentStatus["REFUNDED"] = "REFUNDED"; -})(PaymentStatus || (exports.PaymentStatus = PaymentStatus = {})); -var PaymentProvider; -(function (PaymentProvider) { - PaymentProvider["PAYMOB"] = "PAYMOB"; - PaymentProvider["BINANCE"] = "BINANCE"; - PaymentProvider["MANUAL"] = "MANUAL"; -})(PaymentProvider || (exports.PaymentProvider = PaymentProvider = {})); -let Transaction = class Transaction { - id; - tenantId; - subscriptionId; - amount; - currency; - provider; - externalTransactionId; - status; - metadata; - createdAt; -}; -exports.Transaction = Transaction; -__decorate([ - (0, typeorm_1.PrimaryGeneratedColumn)('uuid'), - __metadata("design:type", String) -], Transaction.prototype, "id", void 0); -__decorate([ - (0, typeorm_1.Index)(), - (0, typeorm_1.Column)(), - __metadata("design:type", String) -], Transaction.prototype, "tenantId", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], Transaction.prototype, "subscriptionId", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'decimal', precision: 10, scale: 2 }), - __metadata("design:type", Number) -], Transaction.prototype, "amount", void 0); -__decorate([ - (0, typeorm_1.Column)({ default: 'USD' }), - __metadata("design:type", String) -], Transaction.prototype, "currency", void 0); -__decorate([ - (0, typeorm_1.Column)({ - type: 'enum', - enum: PaymentProvider, - }), - __metadata("design:type", String) -], Transaction.prototype, "provider", void 0); -__decorate([ - (0, typeorm_1.Index)(), - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], Transaction.prototype, "externalTransactionId", void 0); -__decorate([ - (0, typeorm_1.Column)({ - type: 'enum', - enum: PaymentStatus, - default: PaymentStatus.PENDING, - }), - __metadata("design:type", String) -], Transaction.prototype, "status", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'jsonb', nullable: true }), - __metadata("design:type", Object) -], Transaction.prototype, "metadata", void 0); -__decorate([ - (0, typeorm_1.CreateDateColumn)(), - __metadata("design:type", Date) -], Transaction.prototype, "createdAt", void 0); -exports.Transaction = Transaction = __decorate([ - (0, typeorm_1.Entity)('transactions') -], Transaction); -//# sourceMappingURL=transaction.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/billing/entities/transaction.entity.js.map b/apps/api/dist/billing/entities/transaction.entity.js.map deleted file mode 100644 index f69010b..0000000 --- a/apps/api/dist/billing/entities/transaction.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"transaction.entity.js","sourceRoot":"","sources":["../../../src/billing/entities/transaction.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAMiB;AAEjB,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;IACnB,kCAAiB,CAAA;IACjB,sCAAqB,CAAA;AACvB,CAAC,EALW,aAAa,6BAAb,aAAa,QAKxB;AAED,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;AACnB,CAAC,EAJW,eAAe,+BAAf,eAAe,QAI1B;AAGM,IAAM,WAAW,GAAjB,MAAM,WAAW;IAEtB,EAAE,CAAS;IAIX,QAAQ,CAAS;IAGjB,cAAc,CAAS;IAGvB,MAAM,CAAS;IAGf,QAAQ,CAAS;IAMjB,QAAQ,CAAkB;IAI1B,qBAAqB,CAAS;IAO9B,MAAM,CAAgB;IAGtB,QAAQ,CAAsB;IAG9B,SAAS,CAAO;CACjB,CAAA;AAvCY,kCAAW;AAEtB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;uCACpB;AAIX;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,GAAE;;6CACQ;AAGjB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDACJ;AAGvB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;;2CACtC;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;6CACV;AAMjB;IAJC,IAAA,gBAAM,EAAC;QACN,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,eAAe;KACtB,CAAC;;6CACwB;AAI1B;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0DACG;AAO9B;IALC,IAAA,gBAAM,EAAC;QACN,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,aAAa,CAAC,OAAO;KAC/B,CAAC;;2CACoB;AAGtB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACZ;AAG9B;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;8CAAC;sBAtCL,WAAW;IADvB,IAAA,gBAAM,EAAC,cAAc,CAAC;GACV,WAAW,CAuCvB"} \ No newline at end of file diff --git a/apps/api/dist/billing/providers/binance.provider.d.ts b/apps/api/dist/billing/providers/binance.provider.d.ts deleted file mode 100644 index 6ad495a..0000000 --- a/apps/api/dist/billing/providers/binance.provider.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { ConfigService } from '@nestjs/config'; -export declare class BinanceProvider { - private configService; - private readonly logger; - private readonly apiUrl; - constructor(configService: ConfigService); - private get apiKey(); - private get secretKey(); - private generateSignature; - createOrder(tenantId: string, amount: number, plan: string): Promise<{ - checkoutUrl: any; - orderId: string; - prepayId: any; - }>; - verifySignature(timestamp: string, nonce: string, signature: string, payloadBody: any): boolean; -} diff --git a/apps/api/dist/billing/providers/binance.provider.js b/apps/api/dist/billing/providers/binance.provider.js deleted file mode 100644 index ebbcb2b..0000000 --- a/apps/api/dist/billing/providers/binance.provider.js +++ /dev/null @@ -1,150 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __importStar = (this && this.__importStar) || (function () { - var ownKeys = function(o) { - ownKeys = Object.getOwnPropertyNames || function (o) { - var ar = []; - for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; - return ar; - }; - return ownKeys(o); - }; - return function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); - __setModuleDefault(result, mod); - return result; - }; -})(); -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -var BinanceProvider_1; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.BinanceProvider = void 0; -const common_1 = require("@nestjs/common"); -const config_1 = require("@nestjs/config"); -const axios_1 = __importDefault(require("axios")); -const crypto = __importStar(require("crypto")); -let BinanceProvider = BinanceProvider_1 = class BinanceProvider { - configService; - logger = new common_1.Logger(BinanceProvider_1.name); - apiUrl = 'https://bpay.binanceapi.com/binancepay/openapi/v2/order'; - constructor(configService) { - this.configService = configService; - } - get apiKey() { - return this.configService.get('BINANCE_PAY_API_KEY') || ''; - } - get secretKey() { - return this.configService.get('BINANCE_PAY_SECRET_KEY') || ''; - } - generateSignature(timestamp, nonce, body) { - const payload = timestamp + '\n' + nonce + '\n' + JSON.stringify(body) + '\n'; - return crypto - .createHmac('sha512', this.secretKey) - .update(payload) - .digest('hex') - .toUpperCase(); - } - async createOrder(tenantId, amount, plan) { - this.logger.log(`Creating Binance Pay order for ${tenantId} - ${plan}`); - if (!this.apiKey || !this.secretKey) { - this.logger.error('Binance Pay API keys are not configured'); - throw new common_1.InternalServerErrorException('Payment provider is not configured properly'); - } - const nonce = crypto.randomBytes(16).toString('hex'); - const timestamp = Date.now().toString(); - const merchantTradeNo = `txn_${Date.now()}_${Math.floor(Math.random() * 10000)}`; - const body = { - env: { - terminalType: 'WEB', - }, - merchantTradeNo: merchantTradeNo, - orderAmount: amount, - currency: 'USDT', - goods: { - goodsType: '01', - goodsCategory: 'Z000', - referenceGoodsId: plan, - goodsName: `${plan} Plan Subscription`, - goodsDetail: `Subscription to ${plan} plan for Maps SaaS`, - }, - passThroughInfo: JSON.stringify({ tenantId, plan }), - returnUrl: `https://map-dashboard.intaleqapp.com/dashboard.html#billing`, - }; - const signature = this.generateSignature(timestamp, nonce, body); - try { - const response = await axios_1.default.post(this.apiUrl, body, { - headers: { - 'Content-Type': 'application/json', - 'BinancePay-Timestamp': timestamp, - 'BinancePay-Nonce': nonce, - 'BinancePay-Certificate-SN': this.apiKey, - 'BinancePay-Signature': signature, - }, - }); - if (response.data && response.data.status === 'SUCCESS') { - return { - checkoutUrl: response.data.data.checkoutUrl, - orderId: merchantTradeNo, - prepayId: response.data.data.prepayId, - }; - } - else { - this.logger.error(`Binance API Error: ${JSON.stringify(response.data)}`); - throw new common_1.InternalServerErrorException('Failed to create Binance order'); - } - } - catch (error) { - this.logger.error(`Error communicating with Binance API: ${error.message}`); - throw new common_1.InternalServerErrorException('Failed to communicate with payment provider'); - } - } - verifySignature(timestamp, nonce, signature, payloadBody) { - const payload = timestamp + '\n' + nonce + '\n' + JSON.stringify(payloadBody) + '\n'; - const expectedSignature = crypto - .createHmac('sha512', this.secretKey) - .update(payload) - .digest('hex') - .toUpperCase(); - try { - return crypto.timingSafeEqual(Buffer.from(signature || ''), Buffer.from(expectedSignature)); - } - catch (e) { - return false; - } - } -}; -exports.BinanceProvider = BinanceProvider; -exports.BinanceProvider = BinanceProvider = BinanceProvider_1 = __decorate([ - (0, common_1.Injectable)(), - __metadata("design:paramtypes", [typeof (_a = typeof config_1.ConfigService !== "undefined" && config_1.ConfigService) === "function" ? _a : Object]) -], BinanceProvider); -//# sourceMappingURL=binance.provider.js.map \ No newline at end of file diff --git a/apps/api/dist/billing/providers/binance.provider.js.map b/apps/api/dist/billing/providers/binance.provider.js.map deleted file mode 100644 index ae1344a..0000000 --- a/apps/api/dist/billing/providers/binance.provider.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"binance.provider.js","sourceRoot":"","sources":["../../../src/billing/providers/binance.provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAkF;AAClF,2CAA+C;AAC/C,kDAA0B;AAC1B,+CAAiC;AAG1B,IAAM,eAAe,uBAArB,MAAM,eAAe;IAIN;IAHH,MAAM,GAAG,IAAI,eAAM,CAAC,iBAAe,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,GAAG,yDAAyD,CAAC;IAEpF,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAEpD,IAAY,MAAM;QAChB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,qBAAqB,CAAC,IAAI,EAAE,CAAC;IACrE,CAAC;IAED,IAAY,SAAS;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,wBAAwB,CAAC,IAAI,EAAE,CAAC;IACxE,CAAC;I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,MAAM,IAAI,qCAA4B,CAAC,6CAA6C,CAAC,CAAC;QACxF,CAAC;IACH,CAAC;IAKD,eAAe,CAAC,SAAiB,EAAE,KAAa,EAAE,SAAiB,EAAE,WAAgB;QACnF,MAAM,OAAO,GAAG,SAAS,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;QACrF,MAAM,iBAAiB,GAAG,MAAM;aAC7B,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;aACpC,MAAM,CAAC,OAAO,CAAC;aACf,MAAM,CAAC,KAAK,CAAC;aACb,WAAW,EAAE,CAAC;QAEjB,IAAI,CAAC;YACD,OAAO,MAAM,CAAC,eAAe,CACzB,MAAM,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,EAC5B,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CACjC,CAAC;QACN,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,OAAO,KAAK,CAAC;QACjB,CAAC;IACH,CAAC;CACF,CAAA;AA5GY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;yDAKwB,sBAAa,oBAAb,sBAAa;GAJrC,eAAe,CA4G3B"} \ No newline at end of file diff --git a/apps/api/dist/billing/providers/paymob.provider.d.ts b/apps/api/dist/billing/providers/paymob.provider.d.ts deleted file mode 100644 index 78137a5..0000000 --- a/apps/api/dist/billing/providers/paymob.provider.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { ConfigService } from '@nestjs/config'; -export declare class PayMobProvider { - private configService; - private readonly logger; - private readonly baseUrl; - constructor(configService: ConfigService); - createPaymentKey(tenantId: string, amount: number, plan: string): Promise<{ - paymentKey: string; - orderId: string; - }>; - getTransactionDetails(transactionId: string): Promise; - private getAuthToken; - verifyHmac(payload: any, hmac: string): boolean; -} diff --git a/apps/api/dist/billing/providers/paymob.provider.js b/apps/api/dist/billing/providers/paymob.provider.js deleted file mode 100644 index 7853377..0000000 --- a/apps/api/dist/billing/providers/paymob.provider.js +++ /dev/null @@ -1,179 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __importStar = (this && this.__importStar) || (function () { - var ownKeys = function(o) { - ownKeys = Object.getOwnPropertyNames || function (o) { - var ar = []; - for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; - return ar; - }; - return ownKeys(o); - }; - return function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); - __setModuleDefault(result, mod); - return result; - }; -})(); -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -var PayMobProvider_1; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.PayMobProvider = void 0; -const common_1 = require("@nestjs/common"); -const config_1 = require("@nestjs/config"); -const axios_1 = __importDefault(require("axios")); -const crypto = __importStar(require("crypto")); -let PayMobProvider = PayMobProvider_1 = class PayMobProvider { - configService; - logger = new common_1.Logger(PayMobProvider_1.name); - baseUrl = 'https://accept.paymob.com/api'; - constructor(configService) { - this.configService = configService; - } - async createPaymentKey(tenantId, amount, plan) { - try { - const authToken = await this.getAuthToken(); - const orderRes = await axios_1.default.post(`${this.baseUrl}/ecommerce/orders`, { - auth_token: authToken, - delivery_needed: "false", - amount_cents: amount * 50 * 100, - currency: "EGP", - items: [{ - name: `${plan} Subscription`, - amount_cents: amount * 50 * 100, - description: `Intaleq Maps ${plan} Plan` - }], - shipping_data: { - first_name: "Intaleq", - last_name: "User", - email: "user@intaleq.com", - phone_number: "+201000000000", - extra_description: `${tenantId}|${plan}` - } - }); - const orderId = orderRes.data.id; - const keyRes = await axios_1.default.post(`${this.baseUrl}/acceptance/payment_keys`, { - auth_token: authToken, - amount_cents: amount * 50 * 100, - expiration: 3600, - order_id: orderId, - billing_data: { - apartment: "NA", - email: "user@intaleq.com", - floor: "NA", - first_name: "Intaleq", - street: "NA", - building: "NA", - phone_number: "+201000000000", - shipping_method: "NA", - postal_code: "NA", - city: "NA", - country: "NA", - last_name: "User", - state: "NA" - }, - currency: "EGP", - integration_id: this.configService.get('PAYMOB_INTEGRATION_ID') || 4556055, - lock_order_when_paid: "false" - }); - return { - paymentKey: keyRes.data.token, - orderId: orderId.toString() - }; - } - catch (error) { - this.logger.error(`PayMob Payment Key failed: ${error.response?.data ? JSON.stringify(error.response.data) : error.message}`); - throw new common_1.BadRequestException('Failed to initialize PayMob payment'); - } - } - async getTransactionDetails(transactionId) { - try { - const authToken = await this.getAuthToken(); - const res = await axios_1.default.get(`${this.baseUrl}/acceptance/transactions/${transactionId}`, { - headers: { Authorization: `Bearer ${authToken}` } - }); - return res.data; - } - catch (error) { - this.logger.error(`Failed to fetch PayMob transaction ${transactionId}: ${error.message}`); - return null; - } - } - async getAuthToken() { - const authRes = await axios_1.default.post(`${this.baseUrl}/auth/tokens`, { - api_key: this.configService.get('PAYMOB_API_KEY'), - }); - return authRes.data.token; - } - verifyHmac(payload, hmac) { - const secret = this.configService.get('PAYMOB_HMAC_SECRET'); - if (!secret) - return false; - const { amount_cents, created_at, currency, error_occured, has_parent_transaction, id, integration_id, is_3d_secure, is_auth, is_capture, is_refunded, is_standalone_payment, is_voided, order, owner, pending, success } = payload; - const source_pan = payload.source_data?.pan || ""; - const source_sub_type = payload.source_data?.sub_type || ""; - const source_type = payload.source_data?.type || ""; - const data = [ - amount_cents, - created_at, - currency, - error_occured, - has_parent_transaction, - id, - integration_id, - is_3d_secure, - is_auth, - is_capture, - is_refunded, - is_standalone_payment, - is_voided, - order.id || order, - owner, - pending, - source_pan, - source_sub_type, - source_type, - success - ].join(""); - const hash = crypto - .createHmac('sha512', secret) - .update(data) - .digest('hex'); - return hash === hmac; - } -}; -exports.PayMobProvider = PayMobProvider; -exports.PayMobProvider = PayMobProvider = PayMobProvider_1 = __decorate([ - (0, common_1.Injectable)(), - __metadata("design:paramtypes", [typeof (_a = typeof config_1.ConfigService !== "undefined" && config_1.ConfigService) === "function" ? _a : Object]) -], PayMobProvider); -//# sourceMappingURL=paymob.provider.js.map \ No newline at end of file diff --git a/apps/api/dist/billing/providers/paymob.provider.js.map b/apps/api/dist/billing/providers/paymob.provider.js.map deleted file mode 100644 index e5d3214..0000000 --- a/apps/api/dist/billing/providers/paymob.provider.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"paymob.provider.js","sourceRoot":"","sources":["../../../src/billing/providers/paymob.provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAyE;AACzE,2CAA+C;AAC/C,kDAA0B;AAC1B,+CAAiC;AA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,YAAY;YACZ,OAAO;YACP,UAAU;YACV,WAAW;YACX,qBAAqB;YACrB,SAAS;YACT,KAAK,CAAC,EAAE,IAAI,KAAK;YACjB,KAAK;YACL,OAAO;YACP,UAAU;YACV,eAAe;YACf,WAAW;YACX,OAAO;SACR,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEX,MAAM,IAAI,GAAG,MAAM;aAChB,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC;aAC5B,MAAM,CAAC,IAAI,CAAC;aACZ,MAAM,CAAC,KAAK,CAAC,CAAC;QAEjB,OAAO,IAAI,KAAK,IAAI,CAAC;IACvB,CAAC;CACF,CAAA;AAjKY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;yDAKwB,sBAAa,oBAAb,sBAAa;GAJrC,cAAc,CAiK1B"} \ No newline at end of file diff --git a/apps/api/dist/common/cache.service.d.ts b/apps/api/dist/common/cache.service.d.ts deleted file mode 100644 index a64896c..0000000 --- a/apps/api/dist/common/cache.service.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { ConfigService } from '@nestjs/config'; -export declare class CacheService { - private configService; - private client; - constructor(configService: ConfigService); - set(key: string, value: any, ttlSeconds?: number): Promise; - get(key: string): Promise; - del(key: string): Promise; -} diff --git a/apps/api/dist/common/cache.service.js b/apps/api/dist/common/cache.service.js deleted file mode 100644 index bf24b3d..0000000 --- a/apps/api/dist/common/cache.service.js +++ /dev/null @@ -1,44 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.CacheService = void 0; -const common_1 = require("@nestjs/common"); -const redis_1 = require("redis"); -const config_1 = require("@nestjs/config"); -let CacheService = class CacheService { - configService; - client; - constructor(configService) { - this.configService = configService; - const redisUrl = this.configService.get('REDIS_URL', 'redis://redis:6379'); - this.client = (0, redis_1.createClient)({ url: redisUrl }); - this.client.connect().catch(console.error); - } - async set(key, value, ttlSeconds = 3600) { - await this.client.set(key, JSON.stringify(value), { - EX: ttlSeconds, - }); - } - async get(key) { - const data = await this.client.get(key); - return data ? JSON.parse(data) : null; - } - async del(key) { - await this.client.del(key); - } -}; -exports.CacheService = CacheService; -exports.CacheService = CacheService = __decorate([ - (0, common_1.Injectable)(), - __metadata("design:paramtypes", [typeof (_a = typeof config_1.ConfigService !== "undefined" && config_1.ConfigService) === "function" ? _a : Object]) -], CacheService); -//# sourceMappingURL=cache.service.js.map \ No newline at end of file diff --git a/apps/api/dist/common/cache.service.js.map b/apps/api/dist/common/cache.service.js.map deleted file mode 100644 index 84cf171..0000000 --- a/apps/api/dist/common/cache.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"cache.service.js","sourceRoot":"","sources":["../../src/common/cache.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,iCAAqC;AACrC,2CAA+C;AAGxC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAGH;IAFZ,MAAM,CAAC;IAEf,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAC9C,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;QAC3E,IAAI,CAAC,MAAM,GAAG,IAAA,oBAAY,EAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAU,EAAE,aAAqB,IAAI;QAG1D,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;YAChD,EAAE,EAAE,UAAU;SACf,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QAGnB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;CACF,CAAA;AA3BY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;yDAIwB,sBAAa,oBAAb,sBAAa;GAHrC,YAAY,CA2BxB"} \ No newline at end of file diff --git a/apps/api/dist/common/gis.utils.d.ts b/apps/api/dist/common/gis.utils.d.ts deleted file mode 100644 index e780d06..0000000 --- a/apps/api/dist/common/gis.utils.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -export declare const JORDAN_BOUNDS: { - minLat: number; - maxLat: number; - minLng: number; - maxLng: number; -}; -export declare function isWithinJordan(lat: number, lng: number): boolean; -export declare function mockMapMatch(lat: number, lng: number): string; diff --git a/apps/api/dist/common/gis.utils.js b/apps/api/dist/common/gis.utils.js deleted file mode 100644 index 6b5bd78..0000000 --- a/apps/api/dist/common/gis.utils.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.JORDAN_BOUNDS = void 0; -exports.isWithinJordan = isWithinJordan; -exports.mockMapMatch = mockMapMatch; -exports.JORDAN_BOUNDS = { - minLat: 29.1, - maxLat: 33.4, - minLng: 34.9, - maxLng: 39.3, -}; -function isWithinJordan(lat, lng) { - return (lat >= exports.JORDAN_BOUNDS.minLat && - lat <= exports.JORDAN_BOUNDS.maxLat && - lng >= exports.JORDAN_BOUNDS.minLng && - lng <= exports.JORDAN_BOUNDS.maxLng); -} -function mockMapMatch(lat, lng) { - return `osm_way_${Math.floor(Math.random() * 1000000)}`; -} -//# sourceMappingURL=gis.utils.js.map \ No newline at end of file diff --git a/apps/api/dist/common/gis.utils.js.map b/apps/api/dist/common/gis.utils.js.map deleted file mode 100644 index 8f9bc50..0000000 --- a/apps/api/dist/common/gis.utils.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"gis.utils.js","sourceRoot":"","sources":["../../src/common/gis.utils.ts"],"names":[],"mappings":";;;AAYA,wCAOC;AAMD,oCAGC;AAvBY,QAAA,aAAa,GAAG;IAC3B,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;CACb,CAAC;AAEF,SAAgB,cAAc,CAAC,GAAW,EAAE,GAAW;IACrD,OAAO,CACL,GAAG,IAAI,qBAAa,CAAC,MAAM;QAC3B,GAAG,IAAI,qBAAa,CAAC,MAAM;QAC3B,GAAG,IAAI,qBAAa,CAAC,MAAM;QAC3B,GAAG,IAAI,qBAAa,CAAC,MAAM,CAC5B,CAAC;AACJ,CAAC;AAMD,SAAgB,YAAY,CAAC,GAAW,EAAE,GAAW;IAEnD,OAAO,WAAW,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;AAC1D,CAAC"} \ No newline at end of file diff --git a/apps/api/dist/common/guards/admin.guard.d.ts b/apps/api/dist/common/guards/admin.guard.d.ts deleted file mode 100644 index 27701a2..0000000 --- a/apps/api/dist/common/guards/admin.guard.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { CanActivate, ExecutionContext } from '@nestjs/common'; -export declare class AdminGuard implements CanActivate { - canActivate(context: ExecutionContext): boolean; -} diff --git a/apps/api/dist/common/guards/admin.guard.js b/apps/api/dist/common/guards/admin.guard.js deleted file mode 100644 index 1db5e0b..0000000 --- a/apps/api/dist/common/guards/admin.guard.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.AdminGuard = void 0; -const common_1 = require("@nestjs/common"); -const tenant_entity_1 = require("../../auth/entities/tenant.entity"); -let AdminGuard = class AdminGuard { - canActivate(context) { - const request = context.switchToHttp().getRequest(); - const tenant = request['tenant']; - if (!tenant) { - throw new common_1.UnauthorizedException('Tenant not found in request'); - } - if (tenant.plan !== tenant_entity_1.TenantPlan.ENTERPRISE) { - throw new common_1.ForbiddenException('Admin access required. Your tenant plan must be ENTERPRISE.'); - } - return true; - } -}; -exports.AdminGuard = AdminGuard; -exports.AdminGuard = AdminGuard = __decorate([ - (0, common_1.Injectable)() -], AdminGuard); -//# sourceMappingURL=admin.guard.js.map \ No newline at end of file diff --git a/apps/api/dist/common/guards/admin.guard.js.map b/apps/api/dist/common/guards/admin.guard.js.map deleted file mode 100644 index 8e81aab..0000000 --- a/apps/api/dist/common/guards/admin.guard.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"admin.guard.js","sourceRoot":"","sources":["../../../src/common/guards/admin.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAsH;AACtH,qEAA+D;AAGxD,IAAM,UAAU,GAAhB,MAAM,UAAU;IACrB,WAAW,CAAC,OAAyB;QACnC,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEjC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,8BAAqB,CAAC,6BAA6B,CAAC,CAAC;QACjE,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,KAAK,0BAAU,CAAC,UAAU,EAAE,CAAC;YAC1C,MAAM,IAAI,2BAAkB,CAAC,6DAA6D,CAAC,CAAC;QAC9F,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAfY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;GACA,UAAU,CAetB"} \ No newline at end of file diff --git a/apps/api/dist/common/guards/api-key.guard.d.ts b/apps/api/dist/common/guards/api-key.guard.d.ts deleted file mode 100644 index d70c896..0000000 --- a/apps/api/dist/common/guards/api-key.guard.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { CanActivate, ExecutionContext } from '@nestjs/common'; -import { AuthService } from '../../auth/auth.service'; -export declare class ApiKeyGuard implements CanActivate { - private authService; - constructor(authService: AuthService); - canActivate(context: ExecutionContext): Promise; -} diff --git a/apps/api/dist/common/guards/api-key.guard.js b/apps/api/dist/common/guards/api-key.guard.js deleted file mode 100644 index 2c01006..0000000 --- a/apps/api/dist/common/guards/api-key.guard.js +++ /dev/null @@ -1,45 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.ApiKeyGuard = void 0; -const common_1 = require("@nestjs/common"); -const auth_service_1 = require("../../auth/auth.service"); -let ApiKeyGuard = class ApiKeyGuard { - authService; - constructor(authService) { - this.authService = authService; - } - async canActivate(context) { - const request = context.switchToHttp().getRequest(); - const apiKeyHeader = request.headers['x-api-key'] || request.query['api_key']; - if (!apiKeyHeader) { - throw new common_1.UnauthorizedException('API Key (x-api-key) is missing'); - } - const origin = request.headers['origin']; - const referer = request.headers['referer']; - try { - const { tenant, apiKey, rateLimit } = await this.authService.validateApiKey(apiKeyHeader, origin, referer); - request['tenant'] = tenant; - request['apiKey'] = apiKey; - request['rateLimit'] = rateLimit; - return true; - } - catch (error) { - throw new common_1.UnauthorizedException(error.message || 'Invalid API Key'); - } - } -}; -exports.ApiKeyGuard = ApiKeyGuard; -exports.ApiKeyGuard = ApiKeyGuard = __decorate([ - (0, common_1.Injectable)(), - __metadata("design:paramtypes", [auth_service_1.AuthService]) -], ApiKeyGuard); -//# sourceMappingURL=api-key.guard.js.map \ No newline at end of file diff --git a/apps/api/dist/common/guards/api-key.guard.js.map b/apps/api/dist/common/guards/api-key.guard.js.map deleted file mode 100644 index 85ec4a0..0000000 --- a/apps/api/dist/common/guards/api-key.guard.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"api-key.guard.js","sourceRoot":"","sources":["../../../src/common/guards/api-key.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAKwB;AACxB,0DAAsD;AAG/C,IAAM,WAAW,GAAjB,MAAM,WAAW;IACF;IAApB,YAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAEhD,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAGpD,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAE9E,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,8BAAqB,CAAC,gCAAgC,CAAC,CAAC;QACpE,CAAC;QAGD,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACzC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAE3C,IAAI,CAAC;YAEH,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CACzE,YAAY,EACZ,MAAM,EACN,OAAO,CACR,CAAC;YAGF,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;YAC3B,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;YAC3B,OAAO,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;YAEjC,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,8BAAqB,CAAC,KAAK,CAAC,OAAO,IAAI,iBAAiB,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;CACF,CAAA;AAnCY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;qCAEsB,0BAAW;GADjC,WAAW,CAmCvB"} \ No newline at end of file diff --git a/apps/api/dist/common/guards/rate-limiter.guard.d.ts b/apps/api/dist/common/guards/rate-limiter.guard.d.ts deleted file mode 100644 index 86705ea..0000000 --- a/apps/api/dist/common/guards/rate-limiter.guard.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { ThrottlerGuard, ThrottlerRequest } from '@nestjs/throttler'; -export declare class TenantThrottlerGuard extends ThrottlerGuard { - private readonly logger; - protected getTracker(req: Record): Promise; - protected handleRequest(requestProps: ThrottlerRequest): Promise; -} diff --git a/apps/api/dist/common/guards/rate-limiter.guard.js b/apps/api/dist/common/guards/rate-limiter.guard.js deleted file mode 100644 index 87a103d..0000000 --- a/apps/api/dist/common/guards/rate-limiter.guard.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var TenantThrottlerGuard_1; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.TenantThrottlerGuard = void 0; -const common_1 = require("@nestjs/common"); -const throttler_1 = require("@nestjs/throttler"); -let TenantThrottlerGuard = TenantThrottlerGuard_1 = class TenantThrottlerGuard extends throttler_1.ThrottlerGuard { - logger = new common_1.Logger(TenantThrottlerGuard_1.name); - async getTracker(req) { - const apiKeyId = req['apiKey']?.id || req.ip; - return `throttler:key:${apiKeyId}`; - } - async handleRequest(requestProps) { - const { context, limit, ttl } = requestProps; - const request = context.switchToHttp().getRequest(); - const dynamicLimit = request['rateLimit']; - if (dynamicLimit) { - this.logger.debug(`Applying dynamic rate limit: ${dynamicLimit} req/min for key ${request['apiKey']?.id}`); - requestProps.limit = dynamicLimit; - } - else { - this.logger.debug(`Applying default rate limit: ${limit} req/min`); - } - return super.handleRequest(requestProps); - } -}; -exports.TenantThrottlerGuard = TenantThrottlerGuard; -exports.TenantThrottlerGuard = TenantThrottlerGuard = TenantThrottlerGuard_1 = __decorate([ - (0, common_1.Injectable)() -], TenantThrottlerGuard); -//# sourceMappingURL=rate-limiter.guard.js.map \ No newline at end of file diff --git a/apps/api/dist/common/guards/rate-limiter.guard.js.map b/apps/api/dist/common/guards/rate-limiter.guard.js.map deleted file mode 100644 index 3610eeb..0000000 --- a/apps/api/dist/common/guards/rate-limiter.guard.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"rate-limiter.guard.js","sourceRoot":"","sources":["../../../src/common/guards/rate-limiter.guard.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAsE;AACtE,iDAAqE;AAG9D,IAAM,oBAAoB,4BAA1B,MAAM,oBAAqB,SAAQ,0BAAc;IACrC,MAAM,GAAG,IAAI,eAAM,CAAC,sBAAoB,CAAC,IAAI,CAAC,CAAC;IAEtD,KAAK,CAAC,UAAU,CAAC,GAAwB;QACjD,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,GAAG,CAAC,EAAE,CAAC;QAC7C,OAAO,iBAAiB,QAAQ,EAAE,CAAC;IACrC,CAAC;IAES,KAAK,CAAC,aAAa,CAC3B,YAA8B;QAE9B,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,YAAY,CAAC;QAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAGpD,MAAM,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;QAE1C,IAAI,YAAY,EAAE,CAAC;YACjB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,YAAY,oBAAoB,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YAC3G,YAAY,CAAC,KAAK,GAAG,YAAY,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,KAAK,UAAU,CAAC,CAAC;QACrE,CAAC;QAED,OAAO,KAAK,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IAC3C,CAAC;CACF,CAAA;AA1BY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;GACA,oBAAoB,CA0BhC"} \ No newline at end of file diff --git a/apps/api/dist/common/mail.module.d.ts b/apps/api/dist/common/mail.module.d.ts deleted file mode 100644 index c6b47fe..0000000 --- a/apps/api/dist/common/mail.module.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare class MailModule { -} diff --git a/apps/api/dist/common/mail.module.js b/apps/api/dist/common/mail.module.js deleted file mode 100644 index b008ea5..0000000 --- a/apps/api/dist/common/mail.module.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.MailModule = void 0; -const common_1 = require("@nestjs/common"); -const mail_service_1 = require("./mail.service"); -let MailModule = class MailModule { -}; -exports.MailModule = MailModule; -exports.MailModule = MailModule = __decorate([ - (0, common_1.Global)(), - (0, common_1.Module)({ - providers: [mail_service_1.MailService], - exports: [mail_service_1.MailService], - }) -], MailModule); -//# sourceMappingURL=mail.module.js.map \ No newline at end of file diff --git a/apps/api/dist/common/mail.module.js.map b/apps/api/dist/common/mail.module.js.map deleted file mode 100644 index 0035296..0000000 --- a/apps/api/dist/common/mail.module.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"mail.module.js","sourceRoot":"","sources":["../../src/common/mail.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,iDAA6C;AAOtC,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,gCAAU;qBAAV,UAAU;IALtB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,0BAAW,CAAC;QACxB,OAAO,EAAE,CAAC,0BAAW,CAAC;KACvB,CAAC;GACW,UAAU,CAAG"} \ No newline at end of file diff --git a/apps/api/dist/common/mail.service.d.ts b/apps/api/dist/common/mail.service.d.ts deleted file mode 100644 index 6689808..0000000 --- a/apps/api/dist/common/mail.service.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ConfigService } from '@nestjs/config'; -export declare class MailService { - private configService; - private readonly logger; - private transporter; - constructor(configService: ConfigService); - sendInvoiceEmail(to: string, data: { - tenantName: string; - plan: string; - amount: string; - transactionId: string; - }): Promise; -} diff --git a/apps/api/dist/common/mail.service.js b/apps/api/dist/common/mail.service.js deleted file mode 100644 index 9063a13..0000000 --- a/apps/api/dist/common/mail.service.js +++ /dev/null @@ -1,122 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __importStar = (this && this.__importStar) || (function () { - var ownKeys = function(o) { - ownKeys = Object.getOwnPropertyNames || function (o) { - var ar = []; - for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; - return ar; - }; - return ownKeys(o); - }; - return function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); - __setModuleDefault(result, mod); - return result; - }; -})(); -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var MailService_1; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.MailService = void 0; -const common_1 = require("@nestjs/common"); -const config_1 = require("@nestjs/config"); -const nodemailer = __importStar(require("nodemailer")); -let MailService = MailService_1 = class MailService { - configService; - logger = new common_1.Logger(MailService_1.name); - transporter; - constructor(configService) { - this.configService = configService; - const host = this.configService.get('SMTP_HOST'); - const port = this.configService.get('SMTP_PORT') || 587; - const user = this.configService.get('SMTP_USER'); - const pass = this.configService.get('SMTP_PASS'); - if (host && user && pass) { - this.transporter = nodemailer.createTransport({ - host, - port, - secure: port === 465, - auth: { - user, - pass, - }, - }); - this.logger.log(`📧 MailService initialized with host: ${host}`); - } - else { - this.logger.warn('⚠️ SMTP settings not fully configured. MailService will run in mock mode.'); - } - } - async sendInvoiceEmail(to, data) { - const from = this.configService.get('SMTP_FROM') || 'support@intaleqapp.com'; - const htmlContent = ` -
-

Intaleq Maps - Payment Successful

-

Hello ${data.tenantName},

-

Thank you for subscribing to our ${data.plan} plan. Your payment has been processed successfully.

- -
-

Plan: ${data.plan}

-

Amount: ${data.amount}

-

Transaction ID: ${data.transactionId}

-

Date: ${new Date().toLocaleDateString()}

-
- -

You can now access all your premium features from your dashboard.

-
-

If you have any questions, contact us at ${from}

-
- `; - if (!this.transporter) { - this.logger.warn(`[Mock Email] To: ${to}, Plan: ${data.plan}, Amount: ${data.amount}`); - return true; - } - try { - await this.transporter.sendMail({ - from: `"Intaleq Support" <${from}>`, - to, - subject: `Invoice: ${data.plan} Subscription - Intaleq Maps`, - html: htmlContent, - }); - this.logger.log(`✅ Invoice email sent to ${to}`); - return true; - } - catch (error) { - this.logger.error(`❌ Failed to send email: ${error.message}`); - return false; - } - } -}; -exports.MailService = MailService; -exports.MailService = MailService = MailService_1 = __decorate([ - (0, common_1.Injectable)(), - __metadata("design:paramtypes", [typeof (_a = typeof config_1.ConfigService !== "undefined" && config_1.ConfigService) === "function" ? _a : Object]) -], MailService); -//# sourceMappingURL=mail.service.js.map \ No newline at end of file diff --git a/apps/api/dist/common/mail.service.js.map b/apps/api/dist/common/mail.service.js.map deleted file mode 100644 index 2d7e548..0000000 --- a/apps/api/dist/common/mail.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"mail.service.js","sourceRoot":"","sources":["../../src/common/mail.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,2CAA+C;AAC/C,uDAAyC;AAGlC,IAAM,WAAW,mBAAjB,MAAM,WAAW;IAIF;IAHH,MAAM,GAAG,IAAI,eAAM,CAAC,aAAW,CAAC,IAAI,CAAC,CAAC;IAC/C,WAAW,CAAyB;IAE5C,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAC9C,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,WAAW,CAAC,CAAC;QACzD,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,WAAW,CAAC,IAAI,GAAG,CAAC;QAChE,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC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gBACF,OAAO,EAAE,YAAY,IAAI,CAAC,IAAI,8BAA8B;gBAC5D,IAAI,EAAE,WAAW;aAClB,CAAC,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;YACjD,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAC9D,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF,CAAA;AAxEY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;yDAKwB,sBAAa,oBAAb,sBAAa;GAJrC,WAAW,CAwEvB"} \ No newline at end of file diff --git a/apps/api/dist/common/redis.module.d.ts b/apps/api/dist/common/redis.module.d.ts deleted file mode 100644 index 4aab953..0000000 --- a/apps/api/dist/common/redis.module.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare class RedisModule { -} diff --git a/apps/api/dist/common/redis.module.js b/apps/api/dist/common/redis.module.js deleted file mode 100644 index 7cf7b59..0000000 --- a/apps/api/dist/common/redis.module.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.RedisModule = void 0; -const common_1 = require("@nestjs/common"); -const config_1 = require("@nestjs/config"); -const redis_1 = require("redis"); -const redis_service_1 = require("./redis.service"); -let RedisModule = class RedisModule { -}; -exports.RedisModule = RedisModule; -exports.RedisModule = RedisModule = __decorate([ - (0, common_1.Global)(), - (0, common_1.Module)({ - providers: [ - { - provide: 'REDIS_CLIENT', - useFactory: async (configService) => { - const url = configService.get('REDIS_URL', 'redis://redis:6379'); - const client = (0, redis_1.createClient)({ url }); - await client.connect(); - return client; - }, - inject: [config_1.ConfigService], - }, - redis_service_1.RedisService, - ], - exports: ['REDIS_CLIENT', redis_service_1.RedisService], - }) -], RedisModule); -//# sourceMappingURL=redis.module.js.map \ No newline at end of file diff --git a/apps/api/dist/common/redis.module.js.map b/apps/api/dist/common/redis.module.js.map deleted file mode 100644 index d733eda..0000000 --- a/apps/api/dist/common/redis.module.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"redis.module.js","sourceRoot":"","sources":["../../src/common/redis.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,2CAA+C;AAC/C,iCAAqC;AACrC,mDAA+C;AAwBxC,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IAjBvB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,cAAc;gBACvB,UAAU,EAAE,KAAK,EAAE,aAA4B,EAAE,EAAE;oBACjD,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,CAAS,WAAW,EAAE,oBAAoB,CAAC,CAAC;oBACzE,MAAM,MAAM,GAAG,IAAA,oBAAY,EAAC,EAAE,GAAG,EAAE,CAAC,CAAC;oBACrC,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;oBACvB,OAAO,MAAM,CAAC;gBAChB,CAAC;gBACD,MAAM,EAAE,CAAC,sBAAa,CAAC;aACxB;YACD,4BAAY;SACb;QACD,OAAO,EAAE,CAAC,cAAc,EAAE,4BAAY,CAAC;KACxC,CAAC;GACW,WAAW,CAAG"} \ No newline at end of file diff --git a/apps/api/dist/common/redis.service.d.ts b/apps/api/dist/common/redis.service.d.ts deleted file mode 100644 index be4c9a4..0000000 --- a/apps/api/dist/common/redis.service.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { OnModuleDestroy } from '@nestjs/common'; -import type { RedisClientType } from 'redis'; -export declare class RedisService implements OnModuleDestroy { - private readonly redisClient; - constructor(redisClient: RedisClientType); - getClient(): RedisClientType; - set(key: string, value: any, ttlSeconds?: number): Promise; - get(key: string): Promise; - del(key: string): Promise; - onModuleDestroy(): Promise; -} diff --git a/apps/api/dist/common/redis.service.js b/apps/api/dist/common/redis.service.js deleted file mode 100644 index a6a08e2..0000000 --- a/apps/api/dist/common/redis.service.js +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.RedisService = void 0; -const common_1 = require("@nestjs/common"); -let RedisService = class RedisService { - redisClient; - constructor(redisClient) { - this.redisClient = redisClient; - } - getClient() { - return this.redisClient; - } - async set(key, value, ttlSeconds) { - const stringValue = typeof value === 'string' ? value : JSON.stringify(value); - if (ttlSeconds) { - await this.redisClient.set(key, stringValue, { EX: ttlSeconds }); - } - else { - await this.redisClient.set(key, stringValue); - } - } - async get(key) { - const value = await this.redisClient.get(key); - if (!value) - return null; - try { - return JSON.parse(value); - } - catch { - return value; - } - } - async del(key) { - await this.redisClient.del(key); - } - async onModuleDestroy() { - await this.redisClient.quit(); - } -}; -exports.RedisService = RedisService; -exports.RedisService = RedisService = __decorate([ - (0, common_1.Injectable)(), - __param(0, (0, common_1.Inject)('REDIS_CLIENT')), - __metadata("design:paramtypes", [Object]) -], RedisService); -//# sourceMappingURL=redis.service.js.map \ No newline at end of file diff --git a/apps/api/dist/common/redis.service.js.map b/apps/api/dist/common/redis.service.js.map deleted file mode 100644 index b54670c..0000000 --- a/apps/api/dist/common/redis.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"redis.service.js","sourceRoot":"","sources":["../../src/common/redis.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAqE;AAS9D,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEoB;IAD3C,YAC2C,WAA4B;QAA5B,gBAAW,GAAX,WAAW,CAAiB;IACpE,CAAC;IAKJ,SAAS;QACP,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAMD,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAU,EAAE,UAAmB;QACpD,MAAM,WAAW,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC9E,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;QACnE,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAMD,KAAK,CAAC,GAAG,CAAI,GAAW;QACtB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QAExB,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAM,CAAC;QAChC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAqB,CAAC;QAC/B,CAAC;IACH,CAAC;IAMD,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;IAChC,CAAC;CACF,CAAA;AAnDY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,cAAc,CAAC,CAAA;;GAFd,YAAY,CAmDxB"} \ No newline at end of file diff --git a/apps/api/dist/common/telegram.service.d.ts b/apps/api/dist/common/telegram.service.d.ts deleted file mode 100644 index 4db90e3..0000000 --- a/apps/api/dist/common/telegram.service.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { ConfigService } from '@nestjs/config'; -export declare class TelegramService { - private configService; - private readonly logger; - private readonly botToken; - private readonly chatId; - constructor(configService: ConfigService); - sendMessage(text: string): Promise; - sendIntelligenceReport(stats: { - syncResult: number; - updatedSegments: number; - discoveredRoads: number; - totalPoints: number; - days: number; - timeProfiles?: number; - }): Promise; -} diff --git a/apps/api/dist/common/telegram.service.js b/apps/api/dist/common/telegram.service.js deleted file mode 100644 index c4b34f3..0000000 --- a/apps/api/dist/common/telegram.service.js +++ /dev/null @@ -1,76 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -var TelegramService_1; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.TelegramService = void 0; -const common_1 = require("@nestjs/common"); -const config_1 = require("@nestjs/config"); -const axios_1 = __importDefault(require("axios")); -let TelegramService = TelegramService_1 = class TelegramService { - configService; - logger = new common_1.Logger(TelegramService_1.name); - botToken; - chatId; - constructor(configService) { - this.configService = configService; - this.botToken = this.configService.get('TELEGRAM_BOT_TOKEN') || ''; - this.chatId = this.configService.get('TELEGRAM_CHAT_ID') || ''; - } - async sendMessage(text) { - if (!this.botToken || !this.chatId || this.botToken.includes('YOUR_BOT_TOKEN')) { - this.logger.warn('Telegram Bot Token or Chat ID not configured. Skipping notification.'); - return false; - } - try { - this.logger.log('Sending report to Telegram...'); - const url = `https://api.telegram.org/bot${this.botToken}/sendMessage`; - await axios_1.default.post(url, { - chat_id: this.chatId, - text: text, - parse_mode: 'HTML', - }); - this.logger.log('✅ Telegram notification sent successfully.'); - return true; - } - catch (error) { - this.logger.error(`❌ Failed to send Telegram message: ${error.message}`); - if (error.response) { - this.logger.error(`Status: ${error.response.status}, Data: ${JSON.stringify(error.response.data)}`); - } - return false; - } - } - async sendIntelligenceReport(stats) { - const message = ` -🚀 Intaleq Map Intelligence Report -━━━━━━━━━━━━━━━━━━ -📅 Window: Last ${stats.days} days -📥 Tracks Imported: ${stats.syncResult} points -🛣️ Roads Updated: ${stats.updatedSegments} segments -✨ New Roads Found: ${stats.discoveredRoads} candidates -🕒 Time Profiles: ${stats.timeProfiles || 0} buckets -📍 Database Total: ${stats.totalPoints} points -━━━━━━━━━━━━━━━━━━ -✅ Deep Sync and Analysis Complete. - `; - return this.sendMessage(message); - } -}; -exports.TelegramService = TelegramService; -exports.TelegramService = TelegramService = TelegramService_1 = __decorate([ - (0, common_1.Injectable)(), - __metadata("design:paramtypes", [typeof (_a = typeof config_1.ConfigService !== "undefined" && config_1.ConfigService) === "function" ? _a : Object]) -], TelegramService); -//# sourceMappingURL=telegram.service.js.map \ No newline at end of file diff --git a/apps/api/dist/common/telegram.service.js.map b/apps/api/dist/common/telegram.service.js.map deleted file mode 100644 index 678564d..0000000 --- a/apps/api/dist/common/telegram.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"telegram.service.js","sourceRoot":"","sources":["../../src/common/telegram.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,2CAA+C;AAC/C,kDAA0B;AAGnB,IAAM,eAAe,uBAArB,MAAM,eAAe;IAKN;IAJH,MAAM,GAAG,IAAI,eAAM,CAAC,iBAAe,CAAC,IAAI,CAAC,CAAC;IAC1C,QAAQ,CAAS;IACjB,MAAM,CAAS;IAEhC,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAC9C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,oBAAoB,CAAC,IAAI,EAAE,CAAC;QAC3E,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,kBAAkB,CAAC,IAAI,EAAE,CAAC;IACzE,CAAC;IAMD,KAAK,CAAC,WAAW,CAAC,IAAY;QAC5B,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC/E,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sEAAsE,CAAC,CAAC;YACzF,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC;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b/apps/api/dist/geocoding/admin-boundaries.service.d.ts deleted file mode 100644 index 5b13670..0000000 --- a/apps/api/dist/geocoding/admin-boundaries.service.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Repository } from 'typeorm'; -import { AdminBoundary } from './entities/admin-boundary.entity'; -export declare class AdminBoundariesService { - private adminBoundaryRepo; - private readonly logger; - constructor(adminBoundaryRepo: Repository); - importGeoJSON(targetCountryCode: string, geoJson: any): Promise<{ - success: boolean; - imported: number; - errors: number; - skipped: number; - }>; - importFromFile(countryCode: string, filePath: string): Promise<{ - success: boolean; - imported: number; - errors: number; - skipped: number; - }>; -} diff --git a/apps/api/dist/geocoding/admin-boundaries.service.js b/apps/api/dist/geocoding/admin-boundaries.service.js deleted file mode 100644 index 9db3856..0000000 --- a/apps/api/dist/geocoding/admin-boundaries.service.js +++ /dev/null @@ -1,138 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -var AdminBoundariesService_1; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.AdminBoundariesService = void 0; -const common_1 = require("@nestjs/common"); -const typeorm_1 = require("@nestjs/typeorm"); -const typeorm_2 = require("typeorm"); -const admin_boundary_entity_1 = require("./entities/admin-boundary.entity"); -let AdminBoundariesService = AdminBoundariesService_1 = class AdminBoundariesService { - adminBoundaryRepo; - logger = new common_1.Logger(AdminBoundariesService_1.name); - constructor(adminBoundaryRepo) { - this.adminBoundaryRepo = adminBoundaryRepo; - } - async importGeoJSON(targetCountryCode, geoJson) { - this.logger.log(`Importing admin boundaries for ${targetCountryCode}...`); - let imported = 0; - let errors = 0; - let skipped = 0; - if (!geoJson || !geoJson.features || !Array.isArray(geoJson.features)) { - this.logger.error('Invalid GeoJSON format'); - return { success: false, imported: 0, errors: 1, skipped: 0 }; - } - for (const feature of geoJson.features) { - try { - const props = feature.properties || {}; - const countryCode = props.country || props.iso_3166_1_alpha2; - if (targetCountryCode && countryCode && countryCode.toUpperCase() !== targetCountryCode.toUpperCase()) { - skipped++; - continue; - } - const subtype = (props.subtype || '').toLowerCase(); - let adminLevel; - switch (subtype) { - case 'country': - adminLevel = 2; - break; - case 'region': - adminLevel = 4; - break; - case 'county': - adminLevel = 6; - break; - case 'localadmin': - adminLevel = 8; - break; - case 'locality': - adminLevel = 8; - break; - case 'neighborhood': - adminLevel = 10; - break; - case 'macrohood': - adminLevel = 9; - break; - case 'microhood': - adminLevel = 11; - break; - default: - adminLevel = parseInt(props.admin_level || props.adminLevel, 10); - } - if (isNaN(adminLevel)) { - skipped++; - continue; - } - const nameAr = props['names']?.['primary'] || props['names']?.['common'] || props['name_ar'] || props['name']; - const nameEn = props['names']?.['en'] || props['name_en']; - const isArabic = (text) => /[\u0600-\u06FF]/.test(text); - if (['JO', 'SY', 'EG'].includes(targetCountryCode.toUpperCase()) && nameAr && !isArabic(nameAr)) { - const alternativeAr = Object.values(props['names'] || {}).find(v => typeof v === 'string' && isArabic(v)); - if (!alternativeAr) { - skipped++; - continue; - } - } - let geom = feature.geometry; - if (geom.type === 'Polygon') { - geom = { type: 'MultiPolygon', coordinates: [geom.coordinates] }; - } - else if (geom.type !== 'MultiPolygon') { - skipped++; - continue; - } - const boundary = this.adminBoundaryRepo.create({ - country_code: targetCountryCode.toUpperCase(), - admin_level: adminLevel, - name_ar: nameAr, - name_en: nameEn, - geom: geom, - }); - await this.adminBoundaryRepo.save(boundary); - imported++; - } - catch (err) { - this.logger.error(`Error importing feature: ${err.message}`); - errors++; - } - } - this.logger.log(`Import finished. Imported: ${imported}, Errors: ${errors}, Skipped: ${skipped}`); - return { success: true, imported, errors, skipped }; - } - async importFromFile(countryCode, filePath) { - const fs = require('fs'); - if (!fs.existsSync(filePath)) { - this.logger.error(`File not found: ${filePath}`); - return { success: false, imported: 0, errors: 1, skipped: 0 }; - } - try { - const data = fs.readFileSync(filePath, 'utf8'); - const geoJson = JSON.parse(data); - return this.importGeoJSON(countryCode, geoJson); - } - catch (err) { - this.logger.error(`Failed to read or parse GeoJSON file: ${err.message}`); - return { success: false, imported: 0, errors: 1, skipped: 0 }; - } - } -}; -exports.AdminBoundariesService = AdminBoundariesService; -exports.AdminBoundariesService = AdminBoundariesService = AdminBoundariesService_1 = __decorate([ - (0, common_1.Injectable)(), - __param(0, (0, typeorm_1.InjectRepository)(admin_boundary_entity_1.AdminBoundary)), - __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object]) -], AdminBoundariesService); -//# sourceMappingURL=admin-boundaries.service.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/admin-boundaries.service.js.map b/apps/api/dist/geocoding/admin-boundaries.service.js.map deleted file mode 100644 index 46a93a3..0000000 --- a/apps/api/dist/geocoding/admin-boundaries.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"admin-boundaries.service.js","sourceRoot":"","sources":["../../src/geocoding/admin-boundaries.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,6CAAmD;AACnD,qCAAqC;AACrC,4EAAiE;AAG1D,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IAKvB;IAJO,MAAM,GAAG,IAAI,eAAM,CAAC,wBAAsB,CAAC,IAAI,CAAC,CAAC;IAElE,YAEU,iBAA4C;QAA5C,s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AAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IACtD,CAAC;IAKD,KAAK,CAAC,cAAc,CAAC,WAAmB,EAAE,QAAgB;QACxD,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACzB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,QAAQ,EAAE,CAAC,CAAC;YACjD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;QAChE,CAAC;QAED,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACjC,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAClD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yCAAyC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;YAC1E,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;QAChE,CAAC;IACH,CAAC;CACF,CAAA;AA3HY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,0BAAgB,EAAC,qCAAa,CAAC,CAAA;yDACL,oBAAU,oBAAV,oBAAU;GAL5B,sBAAsB,CA2HlC"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/administrative-linking.service.d.ts b/apps/api/dist/geocoding/administrative-linking.service.d.ts deleted file mode 100644 index b26550a..0000000 --- a/apps/api/dist/geocoding/administrative-linking.service.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Repository, DataSource } from 'typeorm'; -import { NeighborhoodPoint } from './entities/neighborhood-point.entity'; -import { NeighborhoodPolygon } from './entities/neighborhood-polygon.entity'; -import { AdminBoundary } from './entities/admin-boundary.entity'; -export declare class AdministrativeLinkingService { - private dataSource; - private readonly neighborhoodPointRepo; - private readonly neighborhoodPolygonRepo; - private readonly adminBoundaryRepo; - private readonly logger; - constructor(dataSource: DataSource, neighborhoodPointRepo: Repository, neighborhoodPolygonRepo: Repository, adminBoundaryRepo: Repository); - private readonly overpassMirrors; - private fetchWithRetry; - syncOsmNeighborhoodPoints(bbox?: string, country?: string): Promise<{ - detected_country: string; - osm_fetched: any; - country_points: number; - total_points_in_db: number; - linked_to_district: number; - }>; - generateVoronoiNeighborhoods(country?: string): Promise<{ - status: string; - country: string; - total_polygons: number; - districts_processed: any; - }>; - linkPlaces(country: 'jordan' | 'syria' | 'egypt' | 'iraq'): Promise<{ - status: string; - country: "iraq" | "syria" | "jordan" | "egypt"; - total_places: number; - linked_neighborhood: number; - linked_district: number; - linked_governorate: number; - sample_masoum: any; - rows_affected: any; - } | { - status: string; - error: string; - polygons: number; - places: number; - }>; -} diff --git a/apps/api/dist/geocoding/administrative-linking.service.js b/apps/api/dist/geocoding/administrative-linking.service.js deleted file mode 100644 index 55d564d..0000000 --- a/apps/api/dist/geocoding/administrative-linking.service.js +++ /dev/null @@ -1,293 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -var AdministrativeLinkingService_1; -var _a, _b, _c, _d; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.AdministrativeLinkingService = void 0; -const common_1 = require("@nestjs/common"); -const typeorm_1 = require("@nestjs/typeorm"); -const typeorm_2 = require("typeorm"); -const neighborhood_point_entity_1 = require("./entities/neighborhood-point.entity"); -const neighborhood_polygon_entity_1 = require("./entities/neighborhood-polygon.entity"); -const admin_boundary_entity_1 = require("./entities/admin-boundary.entity"); -const axios_1 = __importDefault(require("axios")); -let AdministrativeLinkingService = AdministrativeLinkingService_1 = class AdministrativeLinkingService { - dataSource; - neighborhoodPointRepo; - neighborhoodPolygonRepo; - adminBoundaryRepo; - logger = new common_1.Logger(AdministrativeLinkingService_1.name); - constructor(dataSource, neighborhoodPointRepo, neighborhoodPolygonRepo, adminBoundaryRepo) { - this.dataSource = dataSource; - this.neighborhoodPointRepo = neighborhoodPointRepo; - this.neighborhoodPolygonRepo = neighborhoodPolygonRepo; - this.adminBoundaryRepo = adminBoundaryRepo; - } - overpassMirrors = [ - 'https://overpass-api.de/api/interpreter', - 'https://overpass.kumi.systems/api/interpreter', - 'https://z.overpass-api.de/api/interpreter' - ]; - async fetchWithRetry(data, retries = 3) { - for (let i = 0; i <= retries; i++) { - const url = this.overpassMirrors[i % this.overpassMirrors.length]; - try { - const response = await axios_1.default.post(url, data, { - timeout: 45000, - headers: { - 'User-Agent': 'IntaleqMapBot/1.0', - 'Content-Type': 'application/x-www-form-urlencoded' - } - }); - return response.data; - } - catch (error) { - this.logger.warn(`Mirror ${url} failed: ${error.message}. Trying next mirror...`); - if (i === retries) - throw error; - await new Promise(res => setTimeout(res, 2000)); - } - } - } - async syncOsmNeighborhoodPoints(bbox = '31.86,35.94,32.22,36.25', country) { - this.logger.log(`Syncing neighborhood points for country: ${country || 'auto'}, bbox: ${bbox}`); - const query = `[out:json][timeout:900];node["place"~"neighbourhood|suburb|town"](${bbox});out;`; - try { - const data = await this.fetchWithRetry(`data=${encodeURIComponent(query)}`); - const elements = data.elements; - this.logger.log(`Found ${elements.length} points in OSM.`); - let detectedCountry = country; - if (!detectedCountry) { - const parts = bbox.split(',').map(parseFloat); - const firstLat = parts[0]; - const lngs = [parts[1], parts[3]].filter(n => !isNaN(n)); - const maxLng = lngs.length ? Math.max(...lngs) : undefined; - if (maxLng !== undefined && maxLng > 42.5) - detectedCountry = 'iraq'; - else if (firstLat > 32.3) - detectedCountry = 'syria'; - else if (firstLat < 31.0) - detectedCountry = 'egypt'; - else - detectedCountry = 'jordan'; - } - for (const e of elements) { - const nameAr = e.tags['name:ar'] || e.tags['name']; - const nameEn = e.tags['name:en'] || e.tags['name']; - const geometry = { type: 'Point', coordinates: [e.lon, e.lat] }; - await this.dataSource.query(` - INSERT INTO neighborhood_points (osm_id, name_ar, name_en, place_type, geometry, country) - VALUES ($1, $2, $3, $4, ST_SetSRID(ST_GeomFromGeoJSON($5), 4326), $6) - ON CONFLICT (osm_id) DO UPDATE SET - name_ar = EXCLUDED.name_ar, - name_en = EXCLUDED.name_en, - place_type = EXCLUDED.place_type, - geometry = EXCLUDED.geometry, - country = COALESCE(EXCLUDED.country, neighborhood_points.country); - `, [e.id, nameAr, nameEn, e.tags['place'], JSON.stringify(geometry), detectedCountry]); - } - await this.dataSource.query(` - UPDATE neighborhood_points np - SET district_id = COALESCE( - ( - SELECT id FROM admin_boundaries ab - WHERE ab.admin_level IN (6, 8) - AND ST_Contains(ab.geom::geometry, np.geometry::geometry) - ORDER BY ab.admin_level DESC - LIMIT 1 - ), - ( - -- حدّ 50كم إلزامي: بدونه تُسنَد نقطة لا تقع داخل أي حدود إلى أقرب - -- مقاطعة في الجدول كله مهما بَعُدت. حين استوردنا العراق قبل حدوده - -- الإدارية، رُبطت أحياء بغداد الـ185 بمقاطعات سورية/أردنية على بعد - -- ~700كم. عدم الربط أفضل من ربط خاطئ صامت. - SELECT id FROM admin_boundaries ab - WHERE ab.admin_level IN (6, 8) - AND ST_DWithin(ab.geom::geography, np.geometry::geography, 50000) - ORDER BY ab.geom::geometry <-> np.geometry::geometry - LIMIT 1 - ) - ) - WHERE district_id IS NULL AND (country = $1 OR $1 IS NULL); - `, [detectedCountry]); - const totalPoints = await this.dataSource.query(`SELECT count(*) as cnt FROM neighborhood_points`); - const linkedPoints = await this.dataSource.query(`SELECT count(*) as cnt FROM neighborhood_points WHERE district_id IS NOT NULL`); - const countryPoints = await this.dataSource.query(`SELECT count(*) as cnt FROM neighborhood_points WHERE country = $1`, [detectedCountry]); - const diagnostics = { - detected_country: detectedCountry, - osm_fetched: elements.length, - country_points: parseInt(countryPoints[0].cnt), - total_points_in_db: parseInt(totalPoints[0].cnt), - linked_to_district: parseInt(linkedPoints[0].cnt), - }; - this.logger.log(`Step 1 diagnostics: ${JSON.stringify(diagnostics)}`); - return diagnostics; - } - catch (error) { - this.logger.error(`Failed to sync OSM points: ${error.message}`, error.stack); - throw error; - } - } - async generateVoronoiNeighborhoods(country) { - this.logger.log(`Generating Voronoi polygons for ${country || 'all'} neighborhoods...`); - const whereClause = country ? `WHERE district_id IS NOT NULL AND country = '${country}'` : `WHERE district_id IS NOT NULL`; - const prePoints = await this.dataSource.query(`SELECT count(*) as cnt FROM neighborhood_points ${whereClause}`); - const preDistricts = await this.dataSource.query(`SELECT district_id, count(*) as cnt FROM neighborhood_points ${whereClause} GROUP BY district_id`); - const deleteWhere = country ? `WHERE method = 'voronoi' AND country = '${country}'` : `WHERE method = 'voronoi'`; - await this.dataSource.query(`DELETE FROM neighborhood_polygons ${deleteWhere}`); - this.logger.log(`Deleted old voronoi polygons for ${country || 'all'}.`); - let totalInserted = 0; - for (const row of preDistricts) { - const districtId = row.district_id; - const pointCount = parseInt(row.cnt); - try { - if (pointCount >= 2) { - const result = await this.dataSource.query(` - INSERT INTO neighborhood_polygons (osm_id, name_ar, name_en, place_type, parent_id, method, country, geometry) - WITH voronoi_cells AS ( - SELECT (ST_Dump(ST_VoronoiPolygons( - ST_Collect(np.geometry::geometry), - 0.00001, - d.geom::geometry - ))).geom as cell - FROM neighborhood_points np - JOIN admin_boundaries d ON d.id = np.district_id - WHERE np.district_id = $1 - GROUP BY d.geom - ), - matched AS ( - SELECT - np.osm_id, np.name_ar, np.name_en, np.place_type, np.district_id, np.country, - ST_Multi(ST_Intersection(vc.cell::geometry, d.geom::geometry)) as geometry - FROM voronoi_cells vc - CROSS JOIN LATERAL ( - SELECT np2.* - FROM neighborhood_points np2 - WHERE np2.district_id = $1 - ORDER BY np2.geometry::geometry <-> vc.cell::geometry - LIMIT 1 - ) np - JOIN admin_boundaries d ON d.id = $1 - ) - SELECT osm_id, name_ar, name_en, place_type, district_id, 'voronoi', country, geometry - FROM matched - WHERE ST_IsValid(geometry) AND NOT ST_IsEmpty(geometry) - `, [districtId]); - totalInserted += (result?.length || result?.[1] || 0); - } - else if (pointCount === 1) { - await this.dataSource.query(` - INSERT INTO neighborhood_polygons (osm_id, name_ar, name_en, place_type, parent_id, method, country, geometry) - SELECT np.osm_id, np.name_ar, np.name_en, np.place_type, np.district_id, 'voronoi', np.country, ST_Multi(d.geom::geometry) - FROM neighborhood_points np - JOIN admin_boundaries d ON d.id = np.district_id - WHERE np.district_id = $1 - `, [districtId]); - totalInserted++; - } - } - catch (err) { - this.logger.error(`Voronoi FAILED for district ${districtId}: ${err.message}`); - } - } - const postCount = await this.dataSource.query(`SELECT count(*) as cnt FROM neighborhood_polygons ${country ? `WHERE country = '${country}'` : ''}`); - return { - status: 'success', - country: country || 'all', - total_polygons: parseInt(postCount[0].cnt), - districts_processed: preDistricts.length - }; - } - async linkPlaces(country) { - const tableName = `places_${country}`; - const polyCount = await this.dataSource.query(`SELECT count(*) as cnt FROM neighborhood_polygons`); - const placeCount = await this.dataSource.query(`SELECT count(*) as cnt FROM ${tableName} WHERE location IS NOT NULL`); - this.logger.log(`linkPlaces pre-flight: ${polyCount[0].cnt} polygons, ${placeCount[0].cnt} places with location in ${tableName}`); - if (parseInt(polyCount[0].cnt) === 0) { - this.logger.error('ABORT: neighborhood_polygons is EMPTY. Run generate-voronoi first!'); - return { - status: 'FAILED', - error: 'neighborhood_polygons table is empty. Run generate-voronoi first.', - polygons: 0, - places: parseInt(placeCount[0].cnt) - }; - } - this.logger.log(`Linking administrative hierarchy for ${tableName} using KNN...`); - const updateResult = await this.dataSource.query(` - UPDATE ${tableName} p - SET - neighborhood_id = ( - SELECT np.id FROM neighborhood_polygons np - WHERE (np.country = $1 OR np.country IS NULL) - ORDER BY p.location::geometry <-> np.geometry::geometry - LIMIT 1 - ), - sub_district_id = ( - SELECT ab.id FROM admin_boundaries ab - WHERE ab.admin_level = 8 - AND ST_Within(p.location::geometry, ab.geom::geometry) - LIMIT 1 - ), - district_id = ( - SELECT ab.id FROM admin_boundaries ab - WHERE ab.admin_level = 6 - AND ST_Within(p.location::geometry, ab.geom::geometry) - LIMIT 1 - ), - governorate_id = ( - SELECT ab.id FROM admin_boundaries ab - WHERE ab.admin_level = 4 - AND ST_Within(p.location::geometry, ab.geom::geometry) - LIMIT 1 - ) - WHERE p.location IS NOT NULL; - `, [country]); - const linkedNeighborhood = await this.dataSource.query(`SELECT count(*) as cnt FROM ${tableName} WHERE neighborhood_id IS NOT NULL`); - const linkedDistrict = await this.dataSource.query(`SELECT count(*) as cnt FROM ${tableName} WHERE district_id IS NOT NULL`); - const linkedGov = await this.dataSource.query(`SELECT count(*) as cnt FROM ${tableName} WHERE governorate_id IS NOT NULL`); - const totalPlaces = await this.dataSource.query(`SELECT count(*) as cnt FROM ${tableName}`); - const samplePlace = await this.dataSource.query(` - SELECT p.id, p.name_ar, p.neighborhood_id, p.district_id, p.governorate_id, - n.name_ar as neighborhood_name - FROM ${tableName} p - LEFT JOIN neighborhood_polygons n ON p.neighborhood_id = n.id - WHERE p.name_ar LIKE '%معصوم%' - LIMIT 3 - `); - const diagnostics = { - status: 'completed', - country, - total_places: parseInt(totalPlaces[0].cnt), - linked_neighborhood: parseInt(linkedNeighborhood[0].cnt), - linked_district: parseInt(linkedDistrict[0].cnt), - linked_governorate: parseInt(linkedGov[0].cnt), - sample_masoum: samplePlace, - rows_affected: updateResult?.[1] || 'unknown' - }; - this.logger.log(`Step 3 diagnostics: ${JSON.stringify(diagnostics)}`); - return diagnostics; - } -}; -exports.AdministrativeLinkingService = AdministrativeLinkingService; -exports.AdministrativeLinkingService = AdministrativeLinkingService = AdministrativeLinkingService_1 = __decorate([ - (0, common_1.Injectable)(), - __param(1, (0, typeorm_1.InjectRepository)(neighborhood_point_entity_1.NeighborhoodPoint)), - __param(2, (0, typeorm_1.InjectRepository)(neighborhood_polygon_entity_1.NeighborhoodPolygon)), - __param(3, (0, typeorm_1.InjectRepository)(admin_boundary_entity_1.AdminBoundary)), - __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.DataSource !== "undefined" && typeorm_2.DataSource) === "function" ? _a : Object, typeof (_b = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _b : Object, typeof (_c = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _c : Object, typeof (_d = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _d : Object]) -], AdministrativeLinkingService); -//# sourceMappingURL=administrative-linking.service.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/administrative-linking.service.js.map b/apps/api/dist/geocoding/administrative-linking.service.js.map deleted file mode 100644 index 684a519..0000000 --- a/apps/api/dist/geocoding/administrative-linking.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"administrative-linking.service.js","sourceRoot":"","sources":["../../src/geocoding/administrative-linking.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,2CAAoD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AAgB,EAAC,qCAAa,CAAC,CAAA;yDALZ,oBAAU,oBAAV,oBAAU,oDAEU,oBAAU,oBAAV,oBAAU,oDAER,oBAAU,oBAAV,oBAAU,oDAEhB,oBAAU,oBAAV,oBAAU;GAVrC,4BAA4B,CAoSxC"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/dto/reverse-geocode.dto.d.ts b/apps/api/dist/geocoding/dto/reverse-geocode.dto.d.ts deleted file mode 100644 index 862622f..0000000 --- a/apps/api/dist/geocoding/dto/reverse-geocode.dto.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export declare class ReverseGeocodeDto { - lat: number; - lng: number; -} diff --git a/apps/api/dist/geocoding/dto/reverse-geocode.dto.js b/apps/api/dist/geocoding/dto/reverse-geocode.dto.js deleted file mode 100644 index d3c74ea..0000000 --- a/apps/api/dist/geocoding/dto/reverse-geocode.dto.js +++ /dev/null @@ -1,39 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.ReverseGeocodeDto = void 0; -const class_validator_1 = require("class-validator"); -const class_transformer_1 = require("class-transformer"); -const swagger_1 = require("@nestjs/swagger"); -class ReverseGeocodeDto { - lat; - lng; -} -exports.ReverseGeocodeDto = ReverseGeocodeDto; -__decorate([ - (0, class_validator_1.IsNotEmpty)(), - (0, class_validator_1.IsNumber)(), - (0, class_validator_1.Min)(-90), - (0, class_validator_1.Max)(90), - (0, class_transformer_1.Type)(() => Number), - (0, swagger_1.ApiProperty)({ description: 'Latitude' }), - __metadata("design:type", Number) -], ReverseGeocodeDto.prototype, "lat", void 0); -__decorate([ - (0, class_validator_1.IsNotEmpty)(), - (0, class_validator_1.IsNumber)(), - (0, class_validator_1.Min)(-180), - (0, class_validator_1.Max)(180), - (0, class_transformer_1.Type)(() => Number), - (0, swagger_1.ApiProperty)({ description: 'Longitude' }), - __metadata("design:type", Number) -], ReverseGeocodeDto.prototype, "lng", void 0); -//# sourceMappingURL=reverse-geocode.dto.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/dto/reverse-geocode.dto.js.map b/apps/api/dist/geocoding/dto/reverse-geocode.dto.js.map deleted file mode 100644 index 417bba3..0000000 --- a/apps/api/dist/geocoding/dto/reverse-geocode.dto.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"reverse-geocode.dto.js","sourceRoot":"","sources":["../../../src/geocoding/dto/reverse-geocode.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAiE;AACjE,yDAAyC;AACzC,6CAA8C;AAE9C,MAAa,iBAAiB;IAO5B,GAAG,CAAS;IAQZ,GAAG,CAAS;CACb;AAhBD,8CAgBC;AATC;IANC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAG,EAAC,CAAC,EAAE,CAAC;IACR,IAAA,qBAAG,EAAC,EAAE,CAAC;IACP,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;;8CAC7B;AAQZ;IANC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAG,EAAC,CAAC,GAAG,CAAC;IACT,IAAA,qBAAG,EAAC,GAAG,CAAC;IACR,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;;8CAC9B"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/dto/search-query.dto.d.ts b/apps/api/dist/geocoding/dto/search-query.dto.d.ts deleted file mode 100644 index e818ec6..0000000 --- a/apps/api/dist/geocoding/dto/search-query.dto.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export declare class SearchQueryDto { - q: string; - lat?: number; - lng?: number; - radius?: number; - country?: string; -} diff --git a/apps/api/dist/geocoding/dto/search-query.dto.js b/apps/api/dist/geocoding/dto/search-query.dto.js deleted file mode 100644 index 0b28e10..0000000 --- a/apps/api/dist/geocoding/dto/search-query.dto.js +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.SearchQueryDto = void 0; -const class_validator_1 = require("class-validator"); -const class_transformer_1 = require("class-transformer"); -const swagger_1 = require("@nestjs/swagger"); -class SearchQueryDto { - q; - lat; - lng; - radius = 20000; - country; -} -exports.SearchQueryDto = SearchQueryDto; -__decorate([ - (0, class_validator_1.IsString)(), - (0, swagger_1.ApiPropertyOptional)({ description: 'Search query string' }), - __metadata("design:type", String) -], SearchQueryDto.prototype, "q", void 0); -__decorate([ - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - (0, swagger_1.ApiPropertyOptional)({ description: 'Latitude for proximity search' }), - __metadata("design:type", Number) -], SearchQueryDto.prototype, "lat", void 0); -__decorate([ - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - (0, swagger_1.ApiPropertyOptional)({ description: 'Longitude for proximity search' }), - __metadata("design:type", Number) -], SearchQueryDto.prototype, "lng", void 0); -__decorate([ - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_validator_1.Min)(0), - (0, class_validator_1.Max)(50000), - (0, class_transformer_1.Type)(() => Number), - (0, swagger_1.ApiPropertyOptional)({ description: 'Proximity radius in meters', default: 20000 }), - __metadata("design:type", Number) -], SearchQueryDto.prototype, "radius", void 0); -__decorate([ - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsEnum)(['jordan', 'syria', 'egypt', 'iraq']), - (0, swagger_1.ApiPropertyOptional)({ description: 'Country filter', enum: ['jordan', 'syria', 'egypt', 'iraq'] }), - __metadata("design:type", String) -], SearchQueryDto.prototype, "country", void 0); -//# sourceMappingURL=search-query.dto.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/dto/search-query.dto.js.map b/apps/api/dist/geocoding/dto/search-query.dto.js.map deleted file mode 100644 index f197293..0000000 --- a/apps/api/dist/geocoding/dto/search-query.dto.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"search-query.dto.js","sourceRoot":"","sources":["../../../src/geocoding/dto/search-query.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAmF;AACnF,yDAAyC;AACzC,6CAAsD;AAEtD,MAAa,cAAc;IAGzB,CAAC,CAAS;IAMV,GAAG,CAAU;IAMb,GAAG,CAAU;IAQb,MAAM,GAAY,KAAK,CAAC;IAKxB,OAAO,CAAU;CAClB;AA7BD,wCA6BC;AA1BC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,6BAAmB,EAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;;yCAClD;AAMV;IAJC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,6BAAmB,EAAC,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;;2CACzD;AAMb;IAJC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,6BAAmB,EAAC,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;;2CAC1D;AAQb;IANC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAG,EAAC,CAAC,CAAC;IACN,IAAA,qBAAG,EAAC,KAAK,CAAC;IACV,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,6BAAmB,EAAC,EAAE,WAAW,EAAE,4BAA4B,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;8CAC3D;AAKxB;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAM,EAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC5C,IAAA,6BAAmB,EAAC,EAAE,WAAW,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC;;+CAClF"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/admin-boundary.entity.d.ts b/apps/api/dist/geocoding/entities/admin-boundary.entity.d.ts deleted file mode 100644 index afbe95d..0000000 --- a/apps/api/dist/geocoding/entities/admin-boundary.entity.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -export declare class AdminBoundary { - id: number; - country_code: string; - admin_level: number; - name_ar: string; - name_en: string; - geom: any; -} diff --git a/apps/api/dist/geocoding/entities/admin-boundary.entity.js b/apps/api/dist/geocoding/entities/admin-boundary.entity.js deleted file mode 100644 index 3cb14b8..0000000 --- a/apps/api/dist/geocoding/entities/admin-boundary.entity.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.AdminBoundary = void 0; -const typeorm_1 = require("typeorm"); -let AdminBoundary = class AdminBoundary { - id; - country_code; - admin_level; - name_ar; - name_en; - geom; -}; -exports.AdminBoundary = AdminBoundary; -__decorate([ - (0, typeorm_1.PrimaryGeneratedColumn)(), - __metadata("design:type", Number) -], AdminBoundary.prototype, "id", void 0); -__decorate([ - (0, typeorm_1.Column)({ length: 3 }), - (0, typeorm_1.Index)(), - __metadata("design:type", String) -], AdminBoundary.prototype, "country_code", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'int' }), - (0, typeorm_1.Index)(), - __metadata("design:type", Number) -], AdminBoundary.prototype, "admin_level", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - (0, typeorm_1.Index)(), - __metadata("design:type", String) -], AdminBoundary.prototype, "name_ar", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], AdminBoundary.prototype, "name_en", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'geometry', spatialFeatureType: 'MultiPolygon', srid: 4326, nullable: true }), - (0, typeorm_1.Index)({ spatial: true }), - __metadata("design:type", Object) -], AdminBoundary.prototype, "geom", void 0); -exports.AdminBoundary = AdminBoundary = __decorate([ - (0, typeorm_1.Entity)('admin_boundaries') -], AdminBoundary); -//# sourceMappingURL=admin-boundary.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/admin-boundary.entity.js.map b/apps/api/dist/geocoding/entities/admin-boundary.entity.js.map deleted file mode 100644 index 670fac8..0000000 --- a/apps/api/dist/geocoding/entities/admin-boundary.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"admin-boundary.entity.js","sourceRoot":"","sources":["../../../src/geocoding/entities/admin-boundary.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAwE;AAGjE,IAAM,aAAa,GAAnB,MAAM,aAAa;IAExB,EAAE,CAAS;IAIX,YAAY,CAAS;IAIrB,WAAW,CAAS;IAIpB,OAAO,CAAS;IAGhB,OAAO,CAAS;IAIhB,IAAI,CAAM;CACX,CAAA;AAtBY,sCAAa;AAExB;IADC,IAAA,gCAAsB,GAAE;;yCACd;AAIX;IAFC,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IACrB,IAAA,eAAK,GAAE;;mDACa;AAIrB;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACvB,IAAA,eAAK,GAAE;;kDACY;AAIpB;IAFC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1B,IAAA,eAAK,GAAE;;8CACQ;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACX;AAIhB;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC5F,IAAA,eAAK,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;2CACf;wBArBC,aAAa;IADzB,IAAA,gBAAM,EAAC,kBAAkB,CAAC;GACd,aAAa,CAsBzB"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/base-place.entity.d.ts b/apps/api/dist/geocoding/entities/base-place.entity.d.ts deleted file mode 100644 index 84e351d..0000000 --- a/apps/api/dist/geocoding/entities/base-place.entity.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -export declare abstract class BasePlace { - id: number; - latitude: number; - longitude: number; - name: string; - name_ar: string; - name_en: string; - address: string; - category: string; - neighbourhood: string; - city: string; - description: string; - created_at: Date; - source: string; - location: any; - governorate_id: number; - district_id: number; - sub_district_id: number; - neighborhood_id: number; -} diff --git a/apps/api/dist/geocoding/entities/base-place.entity.js b/apps/api/dist/geocoding/entities/base-place.entity.js deleted file mode 100644 index 5358aa2..0000000 --- a/apps/api/dist/geocoding/entities/base-place.entity.js +++ /dev/null @@ -1,114 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.BasePlace = void 0; -const typeorm_1 = require("typeorm"); -class BasePlace { - id; - latitude; - longitude; - name; - name_ar; - name_en; - address; - category; - neighbourhood; - city; - description; - created_at; - source; - location; - governorate_id; - district_id; - sub_district_id; - neighborhood_id; -} -exports.BasePlace = BasePlace; -__decorate([ - (0, typeorm_1.PrimaryGeneratedColumn)(), - __metadata("design:type", Number) -], BasePlace.prototype, "id", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'decimal', precision: 10, scale: 8, nullable: true }), - __metadata("design:type", Number) -], BasePlace.prototype, "latitude", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'decimal', precision: 11, scale: 8, nullable: true }), - __metadata("design:type", Number) -], BasePlace.prototype, "longitude", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - (0, typeorm_1.Index)(), - __metadata("design:type", String) -], BasePlace.prototype, "name", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - (0, typeorm_1.Index)(), - __metadata("design:type", String) -], BasePlace.prototype, "name_ar", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], BasePlace.prototype, "name_en", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], BasePlace.prototype, "address", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], BasePlace.prototype, "category", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], BasePlace.prototype, "neighbourhood", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], BasePlace.prototype, "city", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'text', nullable: true }), - __metadata("design:type", String) -], BasePlace.prototype, "description", void 0); -__decorate([ - (0, typeorm_1.CreateDateColumn)(), - __metadata("design:type", Date) -], BasePlace.prototype, "created_at", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], BasePlace.prototype, "source", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'geometry', spatialFeatureType: 'Point', srid: 4326, nullable: true }), - (0, typeorm_1.Index)({ spatial: true }), - __metadata("design:type", Object) -], BasePlace.prototype, "location", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'int', nullable: true }), - (0, typeorm_1.Index)(), - __metadata("design:type", Number) -], BasePlace.prototype, "governorate_id", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'int', nullable: true }), - (0, typeorm_1.Index)(), - __metadata("design:type", Number) -], BasePlace.prototype, "district_id", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'int', nullable: true }), - (0, typeorm_1.Index)(), - __metadata("design:type", Number) -], BasePlace.prototype, "sub_district_id", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'int', nullable: true }), - (0, typeorm_1.Index)(), - __metadata("design:type", Number) -], BasePlace.prototype, "neighborhood_id", void 0); -//# sourceMappingURL=base-place.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/base-place.entity.js.map b/apps/api/dist/geocoding/entities/base-place.entity.js.map deleted file mode 100644 index faf34d4..0000000 --- a/apps/api/dist/geocoding/entities/base-place.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"base-place.entity.js","sourceRoot":"","sources":["../../../src/geocoding/entities/base-place.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAkF;AAElF,MAAsB,SAAS;IAE7B,EAAE,CAAS;IAGX,QAAQ,CAAS;IAGjB,SAAS,CAAS;IAIlB,IAAI,CAAS;IAIb,OAAO,CAAS;IAGhB,OAAO,CAAS;IAGhB,OAAO,CAAS;IAGhB,QAAQ,CAAS;IAGjB,aAAa,CAAS;IAGtB,IAAI,CAAS;IAGb,WAAW,CAAS;IAGpB,UAAU,CAAO;IAGjB,MAAM,CAAS;IAIf,QAAQ,CAAM;IAId,cAAc,CAAS;IAIvB,WAAW,CAAS;IAIpB,eAAe,CAAS;IAIxB,eAAe,CAAS;CACzB;AA7DD,8BA6DC;AA3DC;IADC,IAAA,gCAAsB,GAAE;;qCACd;AAGX;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ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AC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,IAAA,eAAK,GAAE;;iDACe;AAIvB;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,IAAA,eAAK,GAAE;;8CACY;AAIpB;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,IAAA,eAAK,GAAE;;kDACgB;AAIxB;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,IAAA,eAAK,GAAE;;kDACgB"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/map-candidate.entity.d.ts b/apps/api/dist/geocoding/entities/map-candidate.entity.d.ts deleted file mode 100644 index 3149662..0000000 --- a/apps/api/dist/geocoding/entities/map-candidate.entity.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { BasePlace } from './base-place.entity'; -export declare enum CandidateStatus { - PENDING = "PENDING", - APPROVED = "APPROVED", - REJECTED = "REJECTED" -} -export declare enum CountryCode { - JORDAN = "JORDAN", - SYRIA = "SYRIA", - EGYPT = "EGYPT", - IRAQ = "IRAQ" -} -export declare class MapCandidate extends BasePlace { - status: CandidateStatus; - submittedBy: string; - rejectionReason: string; - country: CountryCode; - metadata: any; - verified_name: string; - confidence_score: number; - verification_metadata: any; -} diff --git a/apps/api/dist/geocoding/entities/map-candidate.entity.js b/apps/api/dist/geocoding/entities/map-candidate.entity.js deleted file mode 100644 index 0eae235..0000000 --- a/apps/api/dist/geocoding/entities/map-candidate.entity.js +++ /dev/null @@ -1,85 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.MapCandidate = exports.CountryCode = exports.CandidateStatus = void 0; -const typeorm_1 = require("typeorm"); -const base_place_entity_1 = require("./base-place.entity"); -var CandidateStatus; -(function (CandidateStatus) { - CandidateStatus["PENDING"] = "PENDING"; - CandidateStatus["APPROVED"] = "APPROVED"; - CandidateStatus["REJECTED"] = "REJECTED"; -})(CandidateStatus || (exports.CandidateStatus = CandidateStatus = {})); -var CountryCode; -(function (CountryCode) { - CountryCode["JORDAN"] = "JORDAN"; - CountryCode["SYRIA"] = "SYRIA"; - CountryCode["EGYPT"] = "EGYPT"; - CountryCode["IRAQ"] = "IRAQ"; -})(CountryCode || (exports.CountryCode = CountryCode = {})); -let MapCandidate = class MapCandidate extends base_place_entity_1.BasePlace { - status; - submittedBy; - rejectionReason; - country; - metadata; - verified_name; - confidence_score; - verification_metadata; -}; -exports.MapCandidate = MapCandidate; -__decorate([ - (0, typeorm_1.Column)({ - type: 'enum', - enum: CandidateStatus, - default: CandidateStatus.PENDING - }), - (0, typeorm_1.Index)(), - __metadata("design:type", String) -], MapCandidate.prototype, "status", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - (0, typeorm_1.Index)(), - __metadata("design:type", String) -], MapCandidate.prototype, "submittedBy", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'text', nullable: true }), - __metadata("design:type", String) -], MapCandidate.prototype, "rejectionReason", void 0); -__decorate([ - (0, typeorm_1.Column)({ - type: 'enum', - enum: CountryCode, - default: CountryCode.JORDAN - }), - (0, typeorm_1.Index)(), - __metadata("design:type", String) -], MapCandidate.prototype, "country", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'jsonb', nullable: true }), - __metadata("design:type", Object) -], MapCandidate.prototype, "metadata", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], MapCandidate.prototype, "verified_name", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'int', default: 0 }), - __metadata("design:type", Number) -], MapCandidate.prototype, "confidence_score", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'jsonb', nullable: true }), - __metadata("design:type", Object) -], MapCandidate.prototype, "verification_metadata", void 0); -exports.MapCandidate = MapCandidate = __decorate([ - (0, typeorm_1.Entity)('map_candidates') -], MapCandidate); -//# sourceMappingURL=map-candidate.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/map-candidate.entity.js.map b/apps/api/dist/geocoding/entities/map-candidate.entity.js.map deleted file mode 100644 index 78283fc..0000000 --- a/apps/api/dist/geocoding/entities/map-candidate.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"map-candidate.entity.js","sourceRoot":"","sources":["../../../src/geocoding/entities/map-candidate.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAgD;AAChD,2DAAgD;AAEhD,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,wCAAqB,CAAA;IACrB,wCAAqB,CAAA;AACvB,CAAC,EAJW,eAAe,+BAAf,eAAe,QAI1B;AAED,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,8BAAe,CAAA;IACf,8BAAe,CAAA;IACf,4BAAa,CAAA;AACf,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAGM,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,6BAAS;IAOzC,MAAM,CAAkB;IAIxB,WAAW,CAAS;IAGpB,eAAe,CAAS;IAQxB,OAAO,CAAc;IAGrB,QAAQ,CAAM;IAGd,aAAa,CAAS;IAGtB,gBAAgB,CAAS;IAGzB,qBAAqB,CAAM;CAC5B,CAAA;AAnCY,oCAAY;AAOvB;IANC,IAAA,gBAAM,EAAC;QACN,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,eAAe,CAAC,OAAO;KACjC,CAAC;IACD,IAAA,eAAK,GAAE;;4CACgB;AAIxB;IAFC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1B,IAAA,eAAK,GAAE;;iDACY;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACjB;AAQxB;IANC,IAAA,gBAAM,EAAC;QACN,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,WAAW,CAAC,MAAM;KAC5B,CAAC;IACD,IAAA,eAAK,GAAE;;6CACa;AAGrB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CAC5B;AAGd;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDACL;AAGtB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;sDACX;AAGzB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2DACf;uBAlChB,YAAY;IADxB,IAAA,gBAAM,EAAC,gBAAgB,CAAC;GACZ,YAAY,CAmCxB"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/neighborhood-point.entity.d.ts b/apps/api/dist/geocoding/entities/neighborhood-point.entity.d.ts deleted file mode 100644 index bd1dfe6..0000000 --- a/apps/api/dist/geocoding/entities/neighborhood-point.entity.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -export declare class NeighborhoodPoint { - id: number; - osm_id: number; - name_ar: string; - name_en: string; - place_type: string; - district_id: number; - country: string; - geometry: any; -} diff --git a/apps/api/dist/geocoding/entities/neighborhood-point.entity.js b/apps/api/dist/geocoding/entities/neighborhood-point.entity.js deleted file mode 100644 index 2522e08..0000000 --- a/apps/api/dist/geocoding/entities/neighborhood-point.entity.js +++ /dev/null @@ -1,65 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.NeighborhoodPoint = void 0; -const typeorm_1 = require("typeorm"); -let NeighborhoodPoint = class NeighborhoodPoint { - id; - osm_id; - name_ar; - name_en; - place_type; - district_id; - country; - geometry; -}; -exports.NeighborhoodPoint = NeighborhoodPoint; -__decorate([ - (0, typeorm_1.PrimaryGeneratedColumn)(), - __metadata("design:type", Number) -], NeighborhoodPoint.prototype, "id", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'bigint', unique: true, nullable: true }), - (0, typeorm_1.Index)(), - __metadata("design:type", Number) -], NeighborhoodPoint.prototype, "osm_id", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - (0, typeorm_1.Index)(), - __metadata("design:type", String) -], NeighborhoodPoint.prototype, "name_ar", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], NeighborhoodPoint.prototype, "name_en", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], NeighborhoodPoint.prototype, "place_type", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'int', nullable: true }), - (0, typeorm_1.Index)(), - __metadata("design:type", Number) -], NeighborhoodPoint.prototype, "district_id", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - (0, typeorm_1.Index)(), - __metadata("design:type", String) -], NeighborhoodPoint.prototype, "country", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'geometry', spatialFeatureType: 'Point', srid: 4326 }), - (0, typeorm_1.Index)({ spatial: true }), - __metadata("design:type", Object) -], NeighborhoodPoint.prototype, "geometry", void 0); -exports.NeighborhoodPoint = NeighborhoodPoint = __decorate([ - (0, typeorm_1.Entity)('neighborhood_points') -], NeighborhoodPoint); -//# sourceMappingURL=neighborhood-point.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/neighborhood-point.entity.js.map b/apps/api/dist/geocoding/entities/neighborhood-point.entity.js.map deleted file mode 100644 index 1ffd64d..0000000 --- a/apps/api/dist/geocoding/entities/neighborhood-point.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"neighborhood-point.entity.js","sourceRoot":"","sources":["../../../src/geocoding/entities/neighborhood-point.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAwE;AAGjE,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAE5B,EAAE,CAAS;IAIX,MAAM,CAAS;IAIf,OAAO,CAAS;IAGhB,OAAO,CAAS;IAGhB,UAAU,CAAS;IAInB,WAAW,CAAS;IAIpB,OAAO,CAAS;IAIhB,QAAQ,CAAM;CACf,CAAA;AA7BY,8CAAiB;AAE5B;IADC,IAAA,gCAAsB,GAAE;;6CACd;AAIX;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACxD,IAAA,eAAK,GAAE;;iDACO;AAIf;IAFC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1B,IAAA,eAAK,GAAE;;kDACQ;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACX;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACR;AAInB;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,IAAA,eAAK,GAAE;;sDACY;AAIpB;IAFC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1B,IAAA,eAAK,GAAE;;kDACQ;AAIhB;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,UAAU,EAAE,kBAAkB,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACrE,IAAA,eAAK,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;mDACX;4BA5BH,iBAAiB;IAD7B,IAAA,gBAAM,EAAC,qBAAqB,CAAC;GACjB,iBAAiB,CA6B7B"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/neighborhood-polygon.entity.d.ts b/apps/api/dist/geocoding/entities/neighborhood-polygon.entity.d.ts deleted file mode 100644 index 7da28fa..0000000 --- a/apps/api/dist/geocoding/entities/neighborhood-polygon.entity.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -export declare class NeighborhoodPolygon { - id: number; - osm_id: number; - name_ar: string; - name_en: string; - place_type: string; - parent_id: number; - method: string; - country: string; - confidence: number; - geometry: any; -} diff --git a/apps/api/dist/geocoding/entities/neighborhood-polygon.entity.js b/apps/api/dist/geocoding/entities/neighborhood-polygon.entity.js deleted file mode 100644 index e6469a0..0000000 --- a/apps/api/dist/geocoding/entities/neighborhood-polygon.entity.js +++ /dev/null @@ -1,75 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.NeighborhoodPolygon = void 0; -const typeorm_1 = require("typeorm"); -let NeighborhoodPolygon = class NeighborhoodPolygon { - id; - osm_id; - name_ar; - name_en; - place_type; - parent_id; - method; - country; - confidence; - geometry; -}; -exports.NeighborhoodPolygon = NeighborhoodPolygon; -__decorate([ - (0, typeorm_1.PrimaryGeneratedColumn)(), - __metadata("design:type", Number) -], NeighborhoodPolygon.prototype, "id", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'bigint', nullable: true }), - (0, typeorm_1.Index)(), - __metadata("design:type", Number) -], NeighborhoodPolygon.prototype, "osm_id", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - (0, typeorm_1.Index)(), - __metadata("design:type", String) -], NeighborhoodPolygon.prototype, "name_ar", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], NeighborhoodPolygon.prototype, "name_en", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], NeighborhoodPolygon.prototype, "place_type", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'int', nullable: true }), - (0, typeorm_1.Index)(), - __metadata("design:type", Number) -], NeighborhoodPolygon.prototype, "parent_id", void 0); -__decorate([ - (0, typeorm_1.Column)({ default: 'voronoi' }), - __metadata("design:type", String) -], NeighborhoodPolygon.prototype, "method", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - (0, typeorm_1.Index)(), - __metadata("design:type", String) -], NeighborhoodPolygon.prototype, "country", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'float', default: 0.7 }), - __metadata("design:type", Number) -], NeighborhoodPolygon.prototype, "confidence", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'geometry', spatialFeatureType: 'MultiPolygon', srid: 4326 }), - (0, typeorm_1.Index)({ spatial: true }), - __metadata("design:type", Object) -], NeighborhoodPolygon.prototype, "geometry", void 0); -exports.NeighborhoodPolygon = NeighborhoodPolygon = __decorate([ - (0, typeorm_1.Entity)('neighborhood_polygons') -], NeighborhoodPolygon); -//# sourceMappingURL=neighborhood-polygon.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/neighborhood-polygon.entity.js.map b/apps/api/dist/geocoding/entities/neighborhood-polygon.entity.js.map deleted file mode 100644 index 0aa7ad2..0000000 --- a/apps/api/dist/geocoding/entities/neighborhood-polygon.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"neighborhood-polygon.entity.js","sourceRoot":"","sources":["../../../src/geocoding/entities/neighborhood-polygon.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAwE;AAGjE,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAE9B,EAAE,CAAS;IAIX,MAAM,CAAS;IAIf,OAAO,CAAS;IAGhB,OAAO,CAAS;IAGhB,UAAU,CAAS;IAInB,SAAS,CAAS;IAGlB,MAAM,CAAS;IAIf,OAAO,CAAS;IAGhB,UAAU,CAAS;IAInB,QAAQ,CAAM;CACf,CAAA;AAnCY,kDAAmB;AAE9B;IADC,IAAA,gCAAsB,GAAE;;+CACd;AAIX;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1C,IAAA,eAAK,GAAE;;mDACO;AAIf;IAFC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1B,IAAA,eAAK,GAAE;;oDACQ;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oDACX;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uDACR;AAInB;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,IAAA,eAAK,GAAE;;sDACU;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;;mDAChB;AAIf;IAFC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1B,IAAA,eAAK,GAAE;;oDACQ;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;;uDACrB;AAInB;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC5E,IAAA,eAAK,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;qDACX;8BAlCH,mBAAmB;IAD/B,IAAA,gBAAM,EAAC,uBAAuB,CAAC;GACnB,mBAAmB,CAmC/B"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/osm-area.entity.d.ts b/apps/api/dist/geocoding/entities/osm-area.entity.d.ts deleted file mode 100644 index 1a04ae0..0000000 --- a/apps/api/dist/geocoding/entities/osm-area.entity.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -export declare class OsmArea { - id: number; - osm_id: number; - longitude: number; - latitude: number; - name: string; - name_ar: string; - place_type: string; - geom: any; - other_tags: string; -} diff --git a/apps/api/dist/geocoding/entities/osm-area.entity.js b/apps/api/dist/geocoding/entities/osm-area.entity.js deleted file mode 100644 index 5e8eff8..0000000 --- a/apps/api/dist/geocoding/entities/osm-area.entity.js +++ /dev/null @@ -1,65 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.OsmArea = void 0; -const typeorm_1 = require("typeorm"); -let OsmArea = class OsmArea { - id; - osm_id; - longitude; - latitude; - name; - name_ar; - place_type; - geom; - other_tags; -}; -exports.OsmArea = OsmArea; -__decorate([ - (0, typeorm_1.PrimaryGeneratedColumn)(), - __metadata("design:type", Number) -], OsmArea.prototype, "id", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'bigint', nullable: true }), - __metadata("design:type", Number) -], OsmArea.prototype, "osm_id", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'decimal', precision: 11, scale: 8, nullable: true }), - __metadata("design:type", Number) -], OsmArea.prototype, "longitude", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'decimal', precision: 10, scale: 8, nullable: true }), - __metadata("design:type", Number) -], OsmArea.prototype, "latitude", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], OsmArea.prototype, "name", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], OsmArea.prototype, "name_ar", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], OsmArea.prototype, "place_type", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'geometry', nullable: true }), - __metadata("design:type", Object) -], OsmArea.prototype, "geom", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'text', nullable: true }), - __metadata("design:type", String) -], OsmArea.prototype, "other_tags", void 0); -exports.OsmArea = OsmArea = __decorate([ - (0, typeorm_1.Entity)('osm_areas') -], OsmArea); -//# sourceMappingURL=osm-area.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/osm-area.entity.js.map b/apps/api/dist/geocoding/entities/osm-area.entity.js.map deleted file mode 100644 index 9c685c1..0000000 --- a/apps/api/dist/geocoding/entities/osm-area.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"osm-area.entity.js","sourceRoot":"","sources":["../../../src/geocoding/entities/osm-area.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAiE;AAG1D,IAAM,OAAO,GAAb,MAAM,OAAO;IAElB,EAAE,CAAS;IAGX,MAAM,CAAS;IAGf,SAAS,CAAS;IAGlB,QAAQ,CAAS;IAGjB,IAAI,CAAS;IAGb,OAAO,CAAS;IAGhB,UAAU,CAAS;IAGnB,IAAI,CAAM;IAGV,UAAU,CAAS;CACpB,CAAA;AA3BY,0BAAO;AAElB;IADC,IAAA,gCAAsB,GAAE;;mCACd;AAGX;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uCAC5B;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACnD;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACpD;AAGjB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qCACd;AAGb;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wCACX;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACR;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qCACnC;AAGV;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACtB;kBA1BR,OAAO;IADnB,IAAA,gBAAM,EAAC,WAAW,CAAC;GACP,OAAO,CA2BnB"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/osm-point-with-area.entity.d.ts b/apps/api/dist/geocoding/entities/osm-point-with-area.entity.d.ts deleted file mode 100644 index 38ef27d..0000000 --- a/apps/api/dist/geocoding/entities/osm-point-with-area.entity.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -export declare class OsmPointWithArea { - osm_id: number; - longitude: number; - latitude: number; - name: string; - name_ar: string; - name_en: string; - amenity: string; - shop: string; - addr_street: string; - neighbourhood_name: string; - city_name: string; - other_tags: string; - geom: any; -} diff --git a/apps/api/dist/geocoding/entities/osm-point-with-area.entity.js b/apps/api/dist/geocoding/entities/osm-point-with-area.entity.js deleted file mode 100644 index a016bbe..0000000 --- a/apps/api/dist/geocoding/entities/osm-point-with-area.entity.js +++ /dev/null @@ -1,85 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.OsmPointWithArea = void 0; -const typeorm_1 = require("typeorm"); -let OsmPointWithArea = class OsmPointWithArea { - osm_id; - longitude; - latitude; - name; - name_ar; - name_en; - amenity; - shop; - addr_street; - neighbourhood_name; - city_name; - other_tags; - geom; -}; -exports.OsmPointWithArea = OsmPointWithArea; -__decorate([ - (0, typeorm_1.PrimaryColumn)({ type: 'bigint' }), - __metadata("design:type", Number) -], OsmPointWithArea.prototype, "osm_id", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'decimal', precision: 11, scale: 8, nullable: true }), - __metadata("design:type", Number) -], OsmPointWithArea.prototype, "longitude", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'decimal', precision: 10, scale: 8, nullable: true }), - __metadata("design:type", Number) -], OsmPointWithArea.prototype, "latitude", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], OsmPointWithArea.prototype, "name", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], OsmPointWithArea.prototype, "name_ar", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], OsmPointWithArea.prototype, "name_en", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], OsmPointWithArea.prototype, "amenity", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], OsmPointWithArea.prototype, "shop", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], OsmPointWithArea.prototype, "addr_street", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], OsmPointWithArea.prototype, "neighbourhood_name", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], OsmPointWithArea.prototype, "city_name", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'text', nullable: true }), - __metadata("design:type", String) -], OsmPointWithArea.prototype, "other_tags", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'geometry', spatialFeatureType: 'Point', nullable: true }), - __metadata("design:type", Object) -], OsmPointWithArea.prototype, "geom", void 0); -exports.OsmPointWithArea = OsmPointWithArea = __decorate([ - (0, typeorm_1.Entity)('osm_points_with_area') -], OsmPointWithArea); -//# sourceMappingURL=osm-point-with-area.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/osm-point-with-area.entity.js.map b/apps/api/dist/geocoding/entities/osm-point-with-area.entity.js.map deleted file mode 100644 index 9660f0c..0000000 --- a/apps/api/dist/geocoding/entities/osm-point-with-area.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"osm-point-with-area.entity.js","sourceRoot":"","sources":["../../../src/geocoding/entities/osm-point-with-area.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAwD;AAGjD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAE3B,MAAM,CAAS;IAGf,SAAS,CAAS;IAGlB,QAAQ,CAAS;IAGjB,IAAI,CAAS;IAGb,OAAO,CAAS;IAGhB,OAAO,CAAS;IAGhB,OAAO,CAAS;IAGhB,IAAI,CAAS;IAGb,WAAW,CAAS;IAGpB,kBAAkB,CAAS;IAG3B,SAAS,CAAS;IAGlB,UAAU,CAAS;IAGnB,IAAI,CAAM;CACX,CAAA;AAvCY,4CAAgB;AAE3B;IADC,IAAA,uBAAa,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;gDACnB;AAGf;IADC,IAAA,gBAA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t.entity.d.ts b/apps/api/dist/geocoding/entities/place-egypt.entity.d.ts deleted file mode 100644 index ec4a725..0000000 --- a/apps/api/dist/geocoding/entities/place-egypt.entity.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { BasePlace } from './base-place.entity'; -export declare class PlaceEgypt extends BasePlace { -} diff --git a/apps/api/dist/geocoding/entities/place-egypt.entity.js b/apps/api/dist/geocoding/entities/place-egypt.entity.js deleted file mode 100644 index 0e3ac1b..0000000 --- a/apps/api/dist/geocoding/entities/place-egypt.entity.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.PlaceEgypt = void 0; -const typeorm_1 = require("typeorm"); -const base_place_entity_1 = require("./base-place.entity"); -let PlaceEgypt = class PlaceEgypt extends base_place_entity_1.BasePlace { -}; -exports.PlaceEgypt = PlaceEgypt; -exports.PlaceEgypt = PlaceEgypt = __decorate([ - (0, typeorm_1.Entity)('places_egypt') -], PlaceEgypt); -//# sourceMappingURL=place-egypt.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/place-egypt.entity.js.map b/apps/api/dist/geocoding/entities/place-egypt.entity.js.map deleted file mode 100644 index 5f18f19..0000000 --- a/apps/api/dist/geocoding/entities/place-egypt.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"place-egypt.entity.js","sourceRoot":"","sources":["../../../src/geocoding/entities/place-egypt.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,qCAAiC;AACjC,2DAAgD;AAGzC,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,6BAAS;CAAG,CAAA;AAA/B,gCAAU;qBAAV,UAAU;IADtB,IAAA,gBAAM,EAAC,cAAc,CAAC;GACV,UAAU,CAAqB"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/place-iraq.entity.d.ts b/apps/api/dist/geocoding/entities/place-iraq.entity.d.ts deleted file mode 100644 index 62a2745..0000000 --- a/apps/api/dist/geocoding/entities/place-iraq.entity.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { BasePlace } from './base-place.entity'; -export declare class PlaceIraq extends BasePlace { -} diff --git a/apps/api/dist/geocoding/entities/place-iraq.entity.js b/apps/api/dist/geocoding/entities/place-iraq.entity.js deleted file mode 100644 index 857cefe..0000000 --- a/apps/api/dist/geocoding/entities/place-iraq.entity.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.PlaceIraq = void 0; -const typeorm_1 = require("typeorm"); -const base_place_entity_1 = require("./base-place.entity"); -let PlaceIraq = class PlaceIraq extends base_place_entity_1.BasePlace { -}; -exports.PlaceIraq = PlaceIraq; -exports.PlaceIraq = PlaceIraq = __decorate([ - (0, typeorm_1.Entity)('places_iraq') -], PlaceIraq); -//# sourceMappingURL=place-iraq.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/place-iraq.entity.js.map b/apps/api/dist/geocoding/entities/place-iraq.entity.js.map deleted file mode 100644 index 7d20459..0000000 --- a/apps/api/dist/geocoding/entities/place-iraq.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"place-iraq.entity.js","sourceRoot":"","sources":["../../../src/geocoding/entities/place-iraq.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,qCAAiC;AACjC,2DAAgD;AAGzC,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,6BAAS;CAAG,CAAA;AAA9B,8BAAS;oBAAT,SAAS;IADrB,IAAA,gBAAM,EAAC,aAAa,CAAC;GACT,SAAS,CAAqB"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/place-jordan.entity.d.ts b/apps/api/dist/geocoding/entities/place-jordan.entity.d.ts deleted file mode 100644 index 05df78f..0000000 --- a/apps/api/dist/geocoding/entities/place-jordan.entity.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { BasePlace } from './base-place.entity'; -export declare class PlaceJordan extends BasePlace { -} diff --git a/apps/api/dist/geocoding/entities/place-jordan.entity.js b/apps/api/dist/geocoding/entities/place-jordan.entity.js deleted file mode 100644 index 125ddd1..0000000 --- a/apps/api/dist/geocoding/entities/place-jordan.entity.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.PlaceJordan = void 0; -const typeorm_1 = require("typeorm"); -const base_place_entity_1 = require("./base-place.entity"); -let PlaceJordan = class PlaceJordan extends base_place_entity_1.BasePlace { -}; -exports.PlaceJordan = PlaceJordan; -exports.PlaceJordan = PlaceJordan = __decorate([ - (0, typeorm_1.Entity)('places_jordan') -], PlaceJordan); -//# sourceMappingURL=place-jordan.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/place-jordan.entity.js.map b/apps/api/dist/geocoding/entities/place-jordan.entity.js.map deleted file mode 100644 index 32088ea..0000000 --- a/apps/api/dist/geocoding/entities/place-jordan.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"place-jordan.entity.js","sourceRoot":"","sources":["../../../src/geocoding/entities/place-jordan.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,qCAAiC;AACjC,2DAAgD;AAGzC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,6BAAS;CAAG,CAAA;AAAhC,kCAAW;sBAAX,WAAW;IADvB,IAAA,gBAAM,EAAC,eAAe,CAAC;GACX,WAAW,CAAqB"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/place-syria.entity.d.ts b/apps/api/dist/geocoding/entities/place-syria.entity.d.ts deleted file mode 100644 index 4910df7..0000000 --- a/apps/api/dist/geocoding/entities/place-syria.entity.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { BasePlace } from './base-place.entity'; -export declare class PlaceSyria extends BasePlace { -} diff --git a/apps/api/dist/geocoding/entities/place-syria.entity.js b/apps/api/dist/geocoding/entities/place-syria.entity.js deleted file mode 100644 index 0bc73ec..0000000 --- a/apps/api/dist/geocoding/entities/place-syria.entity.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.PlaceSyria = void 0; -const typeorm_1 = require("typeorm"); -const base_place_entity_1 = require("./base-place.entity"); -let PlaceSyria = class PlaceSyria extends base_place_entity_1.BasePlace { -}; -exports.PlaceSyria = PlaceSyria; -exports.PlaceSyria = PlaceSyria = __decorate([ - (0, typeorm_1.Entity)('places_syria') -], PlaceSyria); -//# sourceMappingURL=place-syria.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/entities/place-syria.entity.js.map b/apps/api/dist/geocoding/entities/place-syria.entity.js.map deleted file mode 100644 index 295456f..0000000 --- a/apps/api/dist/geocoding/entities/place-syria.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"place-syria.entity.js","sourceRoot":"","sources":["../../../src/geocoding/entities/place-syria.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,qCAAiC;AACjC,2DAAgD;AAGzC,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,6BAAS;CAAG,CAAA;AAA/B,gCAAU;qBAAV,UAAU;IADtB,IAAA,gBAAM,EAAC,cAAc,CAAC;GACV,UAAU,CAAqB"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/geocoding-init.service.d.ts b/apps/api/dist/geocoding/geocoding-init.service.d.ts deleted file mode 100644 index b8c3b4b..0000000 --- a/apps/api/dist/geocoding/geocoding-init.service.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { OnModuleInit } from '@nestjs/common'; -import { Repository } from 'typeorm'; -import { PlaceSyria } from './entities/place-syria.entity'; -export declare class GeocodingInitService implements OnModuleInit { - private readonly repo; - private readonly logger; - constructor(repo: Repository); - onModuleInit(): Promise; -} diff --git a/apps/api/dist/geocoding/geocoding-init.service.js b/apps/api/dist/geocoding/geocoding-init.service.js deleted file mode 100644 index c7f6ff6..0000000 --- a/apps/api/dist/geocoding/geocoding-init.service.js +++ /dev/null @@ -1,113 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -var GeocodingInitService_1; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.GeocodingInitService = void 0; -const common_1 = require("@nestjs/common"); -const typeorm_1 = require("@nestjs/typeorm"); -const typeorm_2 = require("typeorm"); -const place_syria_entity_1 = require("./entities/place-syria.entity"); -let GeocodingInitService = GeocodingInitService_1 = class GeocodingInitService { - repo; - logger = new common_1.Logger(GeocodingInitService_1.name); - constructor(repo) { - this.repo = repo; - } - async onModuleInit() { - this.logger.log('Checking for PostGIS extensions and triggers...'); - try { - await this.repo.query('CREATE EXTENSION IF NOT EXISTS postgis;'); - await this.repo.query('CREATE EXTENSION IF NOT EXISTS pg_trgm;'); - const tables = ['places_jordan', 'places_syria', 'places_egypt', 'places_iraq']; - const columnMapping = [ - { old: 'admin_level4_id', new: 'governorate_id' }, - { old: 'admin_level6_id', new: 'district_id' }, - { old: 'admin_level8_id', new: 'sub_district_id' }, - { old: 'admin_level10_id', new: 'neighborhood_id' } - ]; - for (const table of tables) { - for (const mapping of columnMapping) { - await this.repo.query(` - DO $$ - BEGIN - IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = '${table}' AND column_name = '${mapping.old}') THEN - ALTER TABLE ${table} RENAME COLUMN ${mapping.old} TO ${mapping.new}; - END IF; - END $$; - `); - } - } - await this.repo.query(` - CREATE OR REPLACE FUNCTION sync_place_location() RETURNS trigger AS $$ - BEGIN - IF NEW.latitude IS NOT NULL AND NEW.longitude IS NOT NULL THEN - NEW.location := ST_SetSRID(ST_MakePoint(CAST(NEW.longitude AS FLOAT), CAST(NEW.latitude AS FLOAT)), 4326); - - -- Keep standard admin boundary logic for higher levels - NEW.governorate_id := (SELECT id FROM admin_boundaries WHERE admin_level = 4 AND ST_Contains(geom, NEW.location) LIMIT 1); - NEW.district_id := (SELECT id FROM admin_boundaries WHERE admin_level = 6 AND ST_Contains(geom, NEW.location) LIMIT 1); - NEW.sub_district_id := (SELECT id FROM admin_boundaries WHERE admin_level = 8 AND ST_Contains(geom, NEW.location) LIMIT 1); - - -- ROOT CAUSE FIX: Use the new Voronoi polygons for neighborhoods! - NEW.neighborhood_id := (SELECT id FROM neighborhood_polygons ORDER BY NEW.location::geometry <-> geometry::geometry LIMIT 1); - END IF; - RETURN NEW; - END; - $$ LANGUAGE plpgsql; - `); - await this.repo.query(` - DROP TRIGGER IF EXISTS trg_sync_place_location ON places_syria; - CREATE TRIGGER trg_sync_place_location - BEFORE INSERT OR UPDATE ON places_syria - FOR EACH ROW EXECUTE FUNCTION sync_place_location(); - `); - await this.repo.query(` - DROP TRIGGER IF EXISTS trg_sync_place_location_jordan ON places_jordan; - CREATE TRIGGER trg_sync_place_location_jordan - BEFORE INSERT OR UPDATE ON places_jordan - FOR EACH ROW EXECUTE FUNCTION sync_place_location(); - `); - await this.repo.query(` - DROP TRIGGER IF EXISTS trg_sync_place_location_egypt ON places_egypt; - CREATE TRIGGER trg_sync_place_location_egypt - BEFORE INSERT OR UPDATE ON places_egypt - FOR EACH ROW EXECUTE FUNCTION sync_place_location(); - `); - await this.repo.query(` - DROP TRIGGER IF EXISTS trg_sync_place_location_iraq ON places_iraq; - CREATE TRIGGER trg_sync_place_location_iraq - BEFORE INSERT OR UPDATE ON places_iraq - FOR EACH ROW EXECUTE FUNCTION sync_place_location(); - `); - await this.repo.query('CREATE INDEX IF NOT EXISTS idx_places_jordan_location ON places_jordan USING gist (location);'); - await this.repo.query('CREATE INDEX IF NOT EXISTS idx_places_egypt_location ON places_egypt USING gist (location);'); - await this.repo.query('CREATE INDEX IF NOT EXISTS idx_places_iraq_location ON places_iraq USING gist (location);'); - await this.repo.query('CREATE INDEX IF NOT EXISTS idx_places_jordan_names_trgm ON places_jordan USING gist (name_ar gist_trgm_ops, name_en gist_trgm_ops);'); - await this.repo.query('CREATE INDEX IF NOT EXISTS idx_places_egypt_names_trgm ON places_egypt USING gist (name_ar gist_trgm_ops, name_en gist_trgm_ops);'); - await this.repo.query('CREATE INDEX IF NOT EXISTS idx_places_iraq_names_trgm ON places_iraq USING gist (name_ar gist_trgm_ops, name_en gist_trgm_ops);'); - this.logger.log('Geocoding database triggers and optimized indexes initialized for Syria, Jordan, Egypt, and Iraq.'); - } - catch (err) { - this.logger.error('Failed to initialize database geocoding triggers:', err); - } - } -}; -exports.GeocodingInitService = GeocodingInitService; -exports.GeocodingInitService = GeocodingInitService = GeocodingInitService_1 = __decorate([ - (0, common_1.Injectable)(), - __param(0, (0, typeorm_1.InjectRepository)(place_syria_entity_1.PlaceSyria)), - __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object]) -], GeocodingInitService); -//# sourceMappingURL=geocoding-init.service.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/geocoding-init.service.js.map b/apps/api/dist/geocoding/geocoding-init.service.js.map deleted file mode 100644 index ba58b83..0000000 --- a/apps/api/dist/geocoding/geocoding-init.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"geocoding-init.service.js","sourceRoot":"","sources":["../../src/geocoding/geocoding-init.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAkE;AAClE,6CAAmD;AACnD,qCAAqC;AACrC,sEAA2D;AAGpD,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAKZ;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AAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;;;;;OAKrB,CAAC,CAAC;YAEH,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;;;;;OAKrB,CAAC,CAAC;YAEH,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;;;;;OAKrB,CAAC,CAAC;YAGH,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,+FAA+F,CAAC,CAAC;YACvH,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,6FAA6F,CAAC,CAAC;YACrH,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,2FAA2F,CAAC,CAAC;YAGnH,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,qIAAqI,CAAC,CAAC;YAC7J,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,mIAAmI,CAAC,CAAC;YAC3J,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,iIAAiI,CAAC,CAAC;YAEzJ,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,mGAAmG,CAAC,CAAC;QACvH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mDAAmD,EAAE,GAAG,CAAC,CAAC;QAC9E,CAAC;IACH,CAAC;CACF,CAAA;AArGY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,0BAAgB,EAAC,+BAAU,CAAC,CAAA;yDACN,oBAAU,oBAAV,oBAAU;GALxB,oBAAoB,CAqGhC"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/geocoding.controller.d.ts b/apps/api/dist/geocoding/geocoding.controller.d.ts deleted file mode 100644 index a1b588f..0000000 --- a/apps/api/dist/geocoding/geocoding.controller.d.ts +++ /dev/null @@ -1,112 +0,0 @@ -import { GeocodingService } from './geocoding.service'; -import { AdminBoundariesService } from './admin-boundaries.service'; -import { JordanResearchService } from './jordan-research.service'; -import { AdministrativeLinkingService } from './administrative-linking.service'; -import { MapRefinementService } from './map-refinement.service'; -import { SearchQueryDto } from './dto/search-query.dto'; -import { ReverseGeocodeDto } from './dto/reverse-geocode.dto'; -export declare class GeocodingController { - private readonly geocodingService; - private readonly adminBoundariesService; - private readonly jordanResearchService; - private readonly adminLinkingService; - private readonly refinementService; - constructor(geocodingService: GeocodingService, adminBoundariesService: AdminBoundariesService, jordanResearchService: JordanResearchService, adminLinkingService: AdministrativeLinkingService, refinementService: MapRefinementService); - search(queryDto: SearchQueryDto): Promise<{ - results: any; - source: string; - did_you_mean?: undefined; - } | { - results: never[]; - did_you_mean: any; - source?: undefined; - } | { - results: any[]; - source?: undefined; - did_you_mean?: undefined; - }>; - autocomplete(q: string, country?: string): Promise<{ - results: any; - source: string; - } | { - results: any; - source?: undefined; - }>; - reverse(reverseDto: ReverseGeocodeDto): Promise; - addPlace(req: any, placeData: any): Promise; - deletePlace(country: string, name?: string, id?: string): Promise<{ - success: boolean; - affected: any; - }>; - upsertPlace(placeData: any): Promise<{ - id: any; - action: string; - }>; - upsertBatch(body: { - places: any[]; - }): Promise<{ - total: number; - processed: number; - created: number; - updated: number; - failed: number; - errors: { - index: number; - name?: string; - reason: string; - }[]; - errorsTruncated: boolean; - }>; - getPlaces(limit?: string): Promise; - getGeoJSON(): Promise<{ - type: string; - features: any; - }>; - importBoundaries(country: string, filePath: string): Promise<{ - success: boolean; - imported: number; - errors: number; - skipped: number; - }>; - zarqaResearch(): Promise<{ - area: string; - report_timestamp: string; - sources: { - osm: any; - overture: any; - wikidata: any; - static_files: any; - hdx: string; - gadm: string; - }; - comparison_summary: string; - }>; - syncNeighborhoods(bbox?: string, country?: string): Promise<{ - detected_country: string; - osm_fetched: any; - country_points: number; - total_points_in_db: number; - linked_to_district: number; - }>; - generateVoronoi(country?: string): Promise<{ - status: string; - country: string; - total_polygons: number; - districts_processed: any; - }>; - linkPlaces(country: 'jordan' | 'syria' | 'egypt' | 'iraq'): Promise<{ - status: string; - country: "iraq" | "syria" | "jordan" | "egypt"; - total_places: number; - linked_neighborhood: number; - linked_district: number; - linked_governorate: number; - sample_masoum: any; - rows_affected: any; - } | { - status: string; - error: string; - polygons: number; - places: number; - }>; -} diff --git a/apps/api/dist/geocoding/geocoding.controller.js b/apps/api/dist/geocoding/geocoding.controller.js deleted file mode 100644 index daf4cb5..0000000 --- a/apps/api/dist/geocoding/geocoding.controller.js +++ /dev/null @@ -1,241 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.GeocodingController = void 0; -const common_1 = require("@nestjs/common"); -const swagger_1 = require("@nestjs/swagger"); -const geocoding_service_1 = require("./geocoding.service"); -const admin_boundaries_service_1 = require("./admin-boundaries.service"); -const jordan_research_service_1 = require("./jordan-research.service"); -const administrative_linking_service_1 = require("./administrative-linking.service"); -const map_refinement_service_1 = require("./map-refinement.service"); -const api_key_guard_1 = require("../common/guards/api-key.guard"); -const admin_guard_1 = require("../common/guards/admin.guard"); -const rate_limiter_guard_1 = require("../common/guards/rate-limiter.guard"); -const search_query_dto_1 = require("./dto/search-query.dto"); -const reverse_geocode_dto_1 = require("./dto/reverse-geocode.dto"); -let GeocodingController = class GeocodingController { - geocodingService; - adminBoundariesService; - jordanResearchService; - adminLinkingService; - refinementService; - constructor(geocodingService, adminBoundariesService, jordanResearchService, adminLinkingService, refinementService) { - this.geocodingService = geocodingService; - this.adminBoundariesService = adminBoundariesService; - this.jordanResearchService = jordanResearchService; - this.adminLinkingService = adminLinkingService; - this.refinementService = refinementService; - } - async search(queryDto) { - const { q, lat, lng, radius, country } = queryDto; - return this.geocodingService.searchPlaces(q, lat, lng, radius, country); - } - async autocomplete(q, country) { - if (!q || q.trim().length < 2) - return { results: [] }; - return this.geocodingService.autocomplete(q, country); - } - async reverse(reverseDto) { - const { lat, lng } = reverseDto; - return this.geocodingService.reverseGeocode(lat, lng); - } - async addPlace(req, placeData) { - const userId = req.user?.uid || req.tenant?.id || 'api_key_user'; - return this.refinementService.suggestPlace(placeData, userId); - } - async deletePlace(country, name, id) { - if (id) { - return this.geocodingService.deletePlaceById(Number(id), country); - } - if (name) { - return this.geocodingService.deletePlacesByName(name, country); - } - throw new common_1.HttpException('Name or ID required', common_1.HttpStatus.BAD_REQUEST); - } - async upsertPlace(placeData) { - return this.geocodingService.upsertPlace(placeData); - } - async upsertBatch(body) { - return this.geocodingService.upsertBatch(body.places); - } - async getPlaces(limit) { - return this.geocodingService.getRecentPlaces(limit ? parseInt(limit, 10) : 50); - } - async getGeoJSON() { - return this.geocodingService.getAllPlacesGeoJSON(); - } - async importBoundaries(country, filePath) { - return this.adminBoundariesService.importFromFile(country, filePath); - } - async zarqaResearch() { - return this.jordanResearchService.generateZarqaReport(); - } - async syncNeighborhoods(bbox, country) { - return this.adminLinkingService.syncOsmNeighborhoodPoints(bbox, country); - } - async generateVoronoi(country) { - return this.adminLinkingService.generateVoronoiNeighborhoods(country); - } - async linkPlaces(country) { - return this.adminLinkingService.linkPlaces(country); - } -}; -exports.GeocodingController = GeocodingController; -__decorate([ - (0, common_1.Get)('search'), - (0, swagger_1.ApiOperation)({ summary: 'Search for locations (Forward Geocoding)' }), - __param(0, (0, common_1.Query)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [search_query_dto_1.SearchQueryDto]), - __metadata("design:returntype", Promise) -], GeocodingController.prototype, "search", null); -__decorate([ - (0, common_1.Get)('autocomplete'), - (0, swagger_1.ApiOperation)({ summary: 'Fast autocomplete for live typing' }), - (0, swagger_1.ApiQuery)({ name: 'q', required: true }), - (0, swagger_1.ApiQuery)({ name: 'country', required: false }), - __param(0, (0, common_1.Query)('q')), - __param(1, (0, common_1.Query)('country')), - __metadata("design:type", Function), - __metadata("design:paramtypes", [String, String]), - __metadata("design:returntype", Promise) -], GeocodingController.prototype, "autocomplete", null); -__decorate([ - (0, common_1.Get)('reverse'), - (0, swagger_1.ApiOperation)({ summary: 'Reverse Geocoding (Lat/Lng to Address)' }), - __param(0, (0, common_1.Query)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [reverse_geocode_dto_1.ReverseGeocodeDto]), - __metadata("design:returntype", Promise) -], GeocodingController.prototype, "reverse", null); -__decorate([ - (0, common_1.Post)('places'), - (0, swagger_1.ApiOperation)({ summary: 'Add a new location (User Submitted - Goes to Audit)' }), - __param(0, (0, common_1.Req)()), - __param(1, (0, common_1.Body)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object, Object]), - __metadata("design:returntype", Promise) -], GeocodingController.prototype, "addPlace", null); -__decorate([ - (0, common_1.Delete)('places'), - (0, common_1.UseGuards)(admin_guard_1.AdminGuard), - (0, swagger_1.ApiOperation)({ summary: 'Delete a place by name or ID' }), - (0, swagger_1.ApiQuery)({ name: 'name', required: false }), - (0, swagger_1.ApiQuery)({ name: 'id', required: false, type: Number }), - (0, swagger_1.ApiQuery)({ name: 'country', required: true, enum: ['jordan', 'syria', 'egypt', 'iraq'] }), - __param(0, (0, common_1.Query)('country')), - __param(1, (0, common_1.Query)('name')), - __param(2, (0, common_1.Query)('id')), - __metadata("design:type", Function), - __metadata("design:paramtypes", [String, String, String]), - __metadata("design:returntype", Promise) -], GeocodingController.prototype, "deletePlace", null); -__decorate([ - (0, common_1.Post)('upsert-place'), - (0, common_1.UseGuards)(admin_guard_1.AdminGuard), - (0, swagger_1.ApiOperation)({ summary: 'Add or Update a location (Automated Scraper)' }), - __param(0, (0, common_1.Body)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object]), - __metadata("design:returntype", Promise) -], GeocodingController.prototype, "upsertPlace", null); -__decorate([ - (0, common_1.Post)('upsert-batch'), - (0, common_1.UseGuards)(admin_guard_1.AdminGuard), - (0, swagger_1.ApiOperation)({ summary: 'Add or Update multiple locations in bulk' }), - __param(0, (0, common_1.Body)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object]), - __metadata("design:returntype", Promise) -], GeocodingController.prototype, "upsertBatch", null); -__decorate([ - (0, common_1.Get)('places'), - (0, swagger_1.ApiOperation)({ summary: 'Get recent user submitted places' }), - __param(0, (0, common_1.Query)('limit')), - __metadata("design:type", Function), - __metadata("design:paramtypes", [String]), - __metadata("design:returntype", Promise) -], GeocodingController.prototype, "getPlaces", null); -__decorate([ - (0, common_1.Get)('geojson'), - (0, swagger_1.ApiOperation)({ summary: 'Get all user submitted places as GeoJSON for Map Style' }), - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", Promise) -], GeocodingController.prototype, "getGeoJSON", null); -__decorate([ - (0, common_1.Post)('import-boundaries'), - (0, common_1.UseGuards)(admin_guard_1.AdminGuard), - (0, swagger_1.ApiOperation)({ summary: 'Import administrative boundaries from a local GeoJSON file on the server' }), - (0, swagger_1.ApiQuery)({ name: 'country', required: true }), - (0, swagger_1.ApiQuery)({ name: 'filePath', required: true }), - __param(0, (0, common_1.Query)('country')), - __param(1, (0, common_1.Query)('filePath')), - __metadata("design:type", Function), - __metadata("design:paramtypes", [String, String]), - __metadata("design:returntype", Promise) -], GeocodingController.prototype, "importBoundaries", null); -__decorate([ - (0, common_1.Get)('research/zarqa'), - (0, swagger_1.ApiOperation)({ summary: 'Generate a research report for Zarqa, Jordan (Sample Data)' }), - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", Promise) -], GeocodingController.prototype, "zarqaResearch", null); -__decorate([ - (0, common_1.Post)('admin/sync-neighborhoods'), - (0, common_1.UseGuards)(admin_guard_1.AdminGuard), - (0, swagger_1.ApiOperation)({ summary: 'Sync neighborhood points from OSM for a bbox' }), - (0, swagger_1.ApiQuery)({ name: 'bbox', required: false }), - (0, swagger_1.ApiQuery)({ name: 'country', required: false, enum: ['jordan', 'syria', 'egypt', 'iraq'] }), - __param(0, (0, common_1.Query)('bbox')), - __param(1, (0, common_1.Query)('country')), - __metadata("design:type", Function), - __metadata("design:paramtypes", [String, String]), - __metadata("design:returntype", Promise) -], GeocodingController.prototype, "syncNeighborhoods", null); -__decorate([ - (0, common_1.Post)('admin/generate-voronoi'), - (0, common_1.UseGuards)(admin_guard_1.AdminGuard), - (0, swagger_1.ApiOperation)({ summary: 'Generate Voronoi polygons for neighborhoods' }), - (0, swagger_1.ApiQuery)({ name: 'country', required: false, enum: ['jordan', 'syria', 'egypt', 'iraq'] }), - __param(0, (0, common_1.Query)('country')), - __metadata("design:type", Function), - __metadata("design:paramtypes", [String]), - __metadata("design:returntype", Promise) -], GeocodingController.prototype, "generateVoronoi", null); -__decorate([ - (0, common_1.Post)('admin/link-places'), - (0, common_1.UseGuards)(admin_guard_1.AdminGuard), - (0, swagger_1.ApiOperation)({ summary: 'Link places to administrative hierarchy' }), - (0, swagger_1.ApiQuery)({ name: 'country', required: true, enum: ['jordan', 'syria', 'egypt', 'iraq'] }), - __param(0, (0, common_1.Query)('country')), - __metadata("design:type", Function), - __metadata("design:paramtypes", [String]), - __metadata("design:returntype", Promise) -], GeocodingController.prototype, "linkPlaces", null); -exports.GeocodingController = GeocodingController = __decorate([ - (0, swagger_1.ApiTags)('geocoding'), - (0, swagger_1.ApiHeader)({ name: 'x-api-key', description: 'Multi-tenant API Key', required: true }), - (0, common_1.Controller)('geocoding'), - (0, common_1.UseGuards)(api_key_guard_1.ApiKeyGuard, rate_limiter_guard_1.TenantThrottlerGuard), - __metadata("design:paramtypes", [geocoding_service_1.GeocodingService, - admin_boundaries_service_1.AdminBoundariesService, - jordan_research_service_1.JordanResearchService, - administrative_linking_service_1.AdministrativeLinkingService, - map_refinement_service_1.MapRefinementService]) -], GeocodingController); -//# sourceMappingURL=geocoding.controller.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/geocoding.controller.js.map b/apps/api/dist/geocoding/geocoding.controller.js.map deleted file mode 100644 index bf2c64d..0000000 --- a/apps/api/dist/geocoding/geocoding.controller.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"geocoding.controller.js","sourceRoot":"","sources":["../../src/geocoding/geocoding.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAuH;AACvH,6CAA6E;AAC7E,2DAAuD;AACvD,yEAAoE;AACpE,uEAAkE;AAClE,qFAAgF;AAChF,qEAAgE;AAChE,kEAA6D;AAC7D,8DAA0D;AAC1D,4EAA2E;AAC3E,6DAAwD;AACxD,mEAA8D;AAMvD,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAEX;IACA;IACA;IACA;IACA;IALnB,YACmB,gBAAkC,EAClC,sBAA8C,EAC9C,qBAA4C,EAC5C,mBAAiD,EACjD,iBAAuC;QAJvC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,2BAAsB,GAAtB,sBAAsB,CAAwB;QAC9C,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,wBAAmB,GAAnB,mBAAmB,CAA8B;QACjD,sBAAiB,GAAjB,iBAAiB,CAAsB;IACvD,CAAC;IAIE,AAAN,KAAK,CAAC,MAAM,CAAU,QAAwB;QAC5C,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;QAGlD,OAAO,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAA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C,wBAAU,CAAC;IACrB,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,yCAAyC,EAAE,CAAC;IACpE,IAAA,kBAAQ,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC;IACxE,WAAA,IAAA,cAAK,EAAC,SAAS,CAAC,CAAA;;;;qDAEjC;8BAhIU,mBAAmB;IAJ/B,IAAA,iBAAO,EAAC,WAAW,CAAC;IACpB,IAAA,mBAAS,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,sBAAsB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACrF,IAAA,mBAAU,EAAC,WAAW,CAAC;IACvB,IAAA,kBAAS,EAAC,2BAAW,EAAE,yCAAoB,CAAC;qCAGN,oCAAgB;QACV,iDAAsB;QACvB,+CAAqB;QACvB,6DAA4B;QAC9B,6CAAoB;GAN/C,mBAAmB,CAiI/B"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/geocoding.module.d.ts b/apps/api/dist/geocoding/geocoding.module.d.ts deleted file mode 100644 index 850dd73..0000000 --- a/apps/api/dist/geocoding/geocoding.module.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare class GeocodingModule { -} diff --git a/apps/api/dist/geocoding/geocoding.module.js b/apps/api/dist/geocoding/geocoding.module.js deleted file mode 100644 index cb0b9a6..0000000 --- a/apps/api/dist/geocoding/geocoding.module.js +++ /dev/null @@ -1,104 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __importStar = (this && this.__importStar) || (function () { - var ownKeys = function(o) { - ownKeys = Object.getOwnPropertyNames || function (o) { - var ar = []; - for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; - return ar; - }; - return ownKeys(o); - }; - return function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); - __setModuleDefault(result, mod); - return result; - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.GeocodingModule = void 0; -const common_1 = require("@nestjs/common"); -const typeorm_1 = require("@nestjs/typeorm"); -const geocoding_service_1 = require("./geocoding.service"); -const geocoding_init_service_1 = require("./geocoding-init.service"); -const geocoding_controller_1 = require("./geocoding.controller"); -const place_syria_entity_1 = require("./entities/place-syria.entity"); -const place_jordan_entity_1 = require("./entities/place-jordan.entity"); -const place_egypt_entity_1 = require("./entities/place-egypt.entity"); -const place_iraq_entity_1 = require("./entities/place-iraq.entity"); -const osm_area_entity_1 = require("./entities/osm-area.entity"); -const osm_point_with_area_entity_1 = require("./entities/osm-point-with-area.entity"); -const admin_boundary_entity_1 = require("./entities/admin-boundary.entity"); -const admin_boundaries_service_1 = require("./admin-boundaries.service"); -const jordan_research_service_1 = require("./jordan-research.service"); -const administrative_linking_service_1 = require("./administrative-linking.service"); -const neighborhood_point_entity_1 = require("./entities/neighborhood-point.entity"); -const neighborhood_polygon_entity_1 = require("./entities/neighborhood-polygon.entity"); -const map_candidate_entity_1 = require("./entities/map-candidate.entity"); -const map_refinement_service_1 = require("./map-refinement.service"); -const map_refinement_controller_1 = require("./map-refinement.controller"); -const cache_manager_1 = require("@nestjs/cache-manager"); -const redisStore = __importStar(require("cache-manager-redis-store")); -const index_refresh_service_1 = require("./index-refresh.service"); -let GeocodingModule = class GeocodingModule { -}; -exports.GeocodingModule = GeocodingModule; -exports.GeocodingModule = GeocodingModule = __decorate([ - (0, common_1.Module)({ - imports: [ - typeorm_1.TypeOrmModule.forFeature([ - place_syria_entity_1.PlaceSyria, - place_jordan_entity_1.PlaceJordan, - place_egypt_entity_1.PlaceEgypt, - place_iraq_entity_1.PlaceIraq, - osm_area_entity_1.OsmArea, - osm_point_with_area_entity_1.OsmPointWithArea, - admin_boundary_entity_1.AdminBoundary, - neighborhood_point_entity_1.NeighborhoodPoint, - neighborhood_polygon_entity_1.NeighborhoodPolygon, - map_candidate_entity_1.MapCandidate - ]), - cache_manager_1.CacheModule.register({ - store: redisStore, - host: process.env.REDIS_HOST || 'localhost', - port: parseInt(process.env.REDIS_PORT || '6379', 10), - ttl: 3600, - }), - ], - controllers: [geocoding_controller_1.GeocodingController, map_refinement_controller_1.MapRefinementController], - providers: [ - geocoding_service_1.GeocodingService, - geocoding_init_service_1.GeocodingInitService, - admin_boundaries_service_1.AdminBoundariesService, - jordan_research_service_1.JordanResearchService, - administrative_linking_service_1.AdministrativeLinkingService, - map_refinement_service_1.MapRefinementService, - index_refresh_service_1.IndexRefreshService - ], - exports: [geocoding_service_1.GeocodingService, map_refinement_service_1.MapRefinementService], - }) -], GeocodingModule); -//# sourceMappingURL=geocoding.module.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/geocoding.module.js.map b/apps/api/dist/geocoding/geocoding.module.js.map deleted file mode 100644 index 2d325d8..0000000 --- a/apps/api/dist/geocoding/geocoding.module.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"geocoding.module.js","sourceRoot":"","sources":["../../src/geocoding/geocoding.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,2DAAuD;AACvD,qEAAgE;AAChE,iEAA6D;AAC7D,sEAA2D;AAC3D,wEAA6D;AAC7D,sEAA2D;AAC3D,oEAAyD;AACzD,gEAAqD;AACrD,sFAAyE;AACzE,4EAAiE;AACjE,yEAAoE;AACpE,uEAAkE;AAClE,qFAAgF;AAChF,oFAAyE;AACzE,wFAA6E;AAC7E,0EAA+D;AAC/D,qEAAgE;AAChE,2EAAsE;AACtE,yDAAoD;AACpD,sEAAwD;AACxD,mEAA8D;AAmCvD,IAAM,eAAe,GAArB,MAAM,eAAe;CAAG,CAAA;AAAlB,0CAAe;0BAAf,eAAe;IAjC3B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,UAAU,CAAC;gBACvB,+BAAU;gBACV,iCAAW;gBACX,+BAAU;gBACV,6BAAS;gBACT,yBAAO;gBACP,6CAAgB;gBAChB,qCAAa;gBACb,6CAAiB;gBACjB,iDAAmB;gBACnB,mCAAY;aACb,CAAC;YACF,2BAAW,CAAC,QAAQ,CAAC;gBACnB,KAAK,EAAE,UAAU;gBACjB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,WAAW;gBAC3C,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,MAAM,EAAE,EAAE,CAAC;gBACpD,GAAG,EAAE,IAAI;aACV,CAAC;SACH;QACD,WAAW,EAAE,CAAC,0CAAmB,EAAE,mDAAuB,CAAC;QAC3D,SAAS,EAAE;YACT,oCAAgB;YAChB,6CAAoB;YACpB,iDAAsB;YACtB,+CAAqB;YACrB,6DAA4B;YAC5B,6CAAoB;YACpB,2CAAmB;SACpB;QACD,OAAO,EAAE,CAAC,oCAAgB,EAAE,6CAAoB,CAAC;KAClD,CAAC;GACW,eAAe,CAAG"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/geocoding.service.d.ts b/apps/api/dist/geocoding/geocoding.service.d.ts deleted file mode 100644 index a7d187d..0000000 --- a/apps/api/dist/geocoding/geocoding.service.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { Repository } from 'typeorm'; -import type { Cache } from 'cache-manager'; -import { PlaceSyria } from './entities/place-syria.entity'; -import { PlaceJordan } from './entities/place-jordan.entity'; -import { PlaceEgypt } from './entities/place-egypt.entity'; -import { PlaceIraq } from './entities/place-iraq.entity'; -import { BasePlace } from './entities/base-place.entity'; -import { OsmArea } from './entities/osm-area.entity'; -import { OsmPointWithArea } from './entities/osm-point-with-area.entity'; -export declare class GeocodingService { - private placesSyriaRepository; - private placesJordanRepository; - private placesEgyptRepository; - private placesIraqRepository; - private osmAreasRepository; - private osmPointsRepository; - private cacheManager; - private readonly logger; - private readonly DB_TIMEOUT_MS; - constructor(placesSyriaRepository: Repository, placesJordanRepository: Repository, placesEgyptRepository: Repository, placesIraqRepository: Repository, osmAreasRepository: Repository, osmPointsRepository: Repository, cacheManager: Cache); - private getRepositoryForCoords; - private identifyRegion; - private getTableNameForRepo; - searchPlaces(query: string, lat?: number, lon?: number, radius?: number, country?: string): Promise<{ - results: any; - source: string; - did_you_mean?: undefined; - } | { - results: never[]; - did_you_mean: any; - source?: undefined; - } | { - results: any[]; - source?: undefined; - did_you_mean?: undefined; - }>; - private formatResults; - private getRepoByTableName; - private logFailedSearch; - autocomplete(query: string, country?: string): Promise<{ - results: any; - source: string; - } | { - results: any; - source?: undefined; - }>; - private findIraqiAddress; - reverseGeocode(lat: number, lng: number): Promise; - private extractCoords; - addPlace(data: Partial): Promise; - upsertPlace(data: Partial): Promise<{ - id: any; - action: string; - }>; - upsertBatch(places: Partial[]): Promise<{ - total: number; - processed: number; - created: number; - updated: number; - failed: number; - errors: { - index: number; - name?: string; - reason: string; - }[]; - errorsTruncated: boolean; - }>; - getRecentPlaces(limit?: number): Promise; - getAllPlacesGeoJSON(): Promise<{ - type: string; - features: any; - }>; - deletePlacesByName(name: string, country: string): Promise<{ - success: boolean; - affected: any; - }>; - deletePlaceById(id: number, country: string): Promise<{ - success: boolean; - affected: any; - }>; - private getRepoByCountry; -} diff --git a/apps/api/dist/geocoding/geocoding.service.js b/apps/api/dist/geocoding/geocoding.service.js deleted file mode 100644 index bc358d7..0000000 --- a/apps/api/dist/geocoding/geocoding.service.js +++ /dev/null @@ -1,607 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -var GeocodingService_1; -var _a, _b, _c, _d, _e, _f; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.GeocodingService = void 0; -const common_1 = require("@nestjs/common"); -const typeorm_1 = require("@nestjs/typeorm"); -const typeorm_2 = require("typeorm"); -const cache_manager_1 = require("@nestjs/cache-manager"); -const place_syria_entity_1 = require("./entities/place-syria.entity"); -const place_jordan_entity_1 = require("./entities/place-jordan.entity"); -const place_egypt_entity_1 = require("./entities/place-egypt.entity"); -const place_iraq_entity_1 = require("./entities/place-iraq.entity"); -const osm_area_entity_1 = require("./entities/osm-area.entity"); -const osm_point_with_area_entity_1 = require("./entities/osm-point-with-area.entity"); -let GeocodingService = GeocodingService_1 = class GeocodingService { - placesSyriaRepository; - placesJordanRepository; - placesEgyptRepository; - placesIraqRepository; - osmAreasRepository; - osmPointsRepository; - cacheManager; - logger = new common_1.Logger(GeocodingService_1.name); - DB_TIMEOUT_MS = 1100; - constructor(placesSyriaRepository, placesJordanRepository, placesEgyptRepository, placesIraqRepository, osmAreasRepository, osmPointsRepository, cacheManager) { - this.placesSyriaRepository = placesSyriaRepository; - this.placesJordanRepository = placesJordanRepository; - this.placesEgyptRepository = placesEgyptRepository; - this.placesIraqRepository = placesIraqRepository; - this.osmAreasRepository = osmAreasRepository; - this.osmPointsRepository = osmPointsRepository; - this.cacheManager = cacheManager; - } - getRepositoryForCoords(lat, lng) { - if (lat >= 29 && lat <= 37.5 && lng >= 38.7 && lng <= 48.8) { - return this.placesIraqRepository; - } - if (lat >= 29 && lat <= 37.5 && lng >= 34.5 && lng <= 42.5) { - if (lat > 32.5 && lng > 35.8) - return this.placesSyriaRepository; - return this.placesJordanRepository; - } - if (lat >= 22 && lat <= 32 && lng >= 24.5 && lng <= 37) { - return this.placesEgyptRepository; - } - return this.placesSyriaRepository; - } - identifyRegion(lat, lng) { - if (lat === undefined || lng === undefined) - return undefined; - if (lat >= 29 && lat <= 37.5 && lng >= 38.7 && lng <= 48.8) { - return 'iraq'; - } - if (lat >= 29 && lat <= 37.5 && lng >= 34.5 && lng <= 42.5) { - if (lat > 32.5 && lng > 35.8) - return 'syria'; - return 'jordan'; - } - if (lat >= 22 && lat <= 32 && lng >= 24.5 && lng <= 37) { - return 'egypt'; - } - return undefined; - } - getTableNameForRepo(repo) { - if (repo === this.placesJordanRepository) - return 'places_jordan'; - if (repo === this.placesEgyptRepository) - return 'places_egypt'; - if (repo === this.placesIraqRepository) - return 'places_iraq'; - return 'places_syria'; - } - async searchPlaces(query, lat, lon, radius = 20000, country) { - try { - let cleanQuery = query.trim(); - if (!cleanQuery) - return { results: [] }; - let relativePrefix = ''; - const relativeQueryRegex = /^(قرب|بالقرب من|قريب من|عند|بجانب|جنب|حد|بجوار|مقابل|قبال|خلف|ورا|وراء)\s+(.+)$/i; - const match = cleanQuery.match(relativeQueryRegex); - if (match) { - relativePrefix = match[1]; - cleanQuery = match[2]; - } - const hasLocation = lat !== undefined && lon !== undefined; - const geoSegment = hasLocation ? `${lat.toFixed(2)}_${lon.toFixed(2)}` : 'global'; - const cacheKey = `geo_search:${country || 'auto'}:${geoSegment}:${cleanQuery.toLowerCase()}`; - const cached = await this.cacheManager.get(cacheKey); - if (cached) - return { results: cached, source: 'cache_hit' }; - let targetRegion = country?.toLowerCase() || this.identifyRegion(lat, lon); - const [normalizedQueryRes] = await this.osmPointsRepository.query(`SELECT normalize_arabic($1) as nq`, [cleanQuery]); - const normalizedQuery = normalizedQueryRes?.nq || cleanQuery.toLowerCase(); - let queryParams = [normalizedQuery]; - let locationCondition = ''; - if (hasLocation) { - locationCondition = `AND ST_DistanceSphere(location, ST_SetSRID(ST_MakePoint($3::float, $2::float), 4326)) <= $4`; - queryParams.push(lat, lon, radius); - } - let regionCondition = ''; - if (targetRegion && ['syria', 'jordan', 'egypt', 'iraq'].includes(targetRegion)) { - regionCondition = `AND (region = '${targetRegion}' OR region = 'global')`; - } - const sqlQuery = ` - SELECT - id, name, name_ar, category, - '' as neighbourhood, '' as district, '' as governorate, - latitude, longitude, address, region, source, popularity_score, - ${hasLocation ? 'ST_DistanceSphere(location, ST_SetSRID(ST_MakePoint($3::float, $2::float), 4326))' : '0'} as distance, - similarity(normalized_name, $1) as relevance - FROM unified_search_index - WHERE normalized_name % $1 - ${locationCondition} - ${regionCondition} - ORDER BY (normalized_name <-> $1) ASC - LIMIT 50 - `; - const allResults = await Promise.race([ - this.osmPointsRepository.query(sqlQuery, queryParams), - new Promise((_, reject) => setTimeout(() => reject(new Error('QUERY_TIMEOUT')), this.DB_TIMEOUT_MS)) - ]).catch(e => { - this.logger.warn(`Search optimization threshold hit: ${e.message}`); - return []; - }); - const formatted = this.formatResults(allResults, hasLocation, relativePrefix); - const placeIds = formatted.map(r => r.id); - if (placeIds.length > 0) { - try { - const gates = await this.osmPointsRepository.query(`SELECT place_id, gate_name_ar, gate_name_en, latitude, longitude, is_main_gate - FROM place_gates - WHERE place_id = ANY($1)`, [placeIds]); - if (gates.length > 0) { - formatted.forEach(r => { - const placeGates = gates.filter((g) => g.place_id === r.id).map((g) => ({ - name_ar: g.gate_name_ar, - name_en: g.gate_name_en, - latitude: parseFloat(g.latitude), - longitude: parseFloat(g.longitude), - is_main_gate: g.is_main_gate - })); - if (placeGates.length > 0) { - r.gates = placeGates; - } - }); - } - } - catch (err) { - this.logger.warn('Failed to fetch POI gates, table might not exist yet.'); - } - } - if (formatted.length > 0) { - await this.cacheManager.set(cacheKey, formatted, 3600000); - } - else { - this.logFailedSearch(cleanQuery, normalizedQuery, targetRegion, lat, lon).catch(err => { - this.logger.error('Failed to log zero-result search:', err); - }); - try { - const whereClause = regionCondition ? `WHERE ${regionCondition.substring(4)}` : ''; - const fallbackQuery = ` - SELECT name_ar, name, (normalized_name <-> $1) as dist - FROM unified_search_index - ${whereClause} - ORDER BY normalized_name <-> $1 ASC - LIMIT 1 - `; - const suggestions = await this.osmPointsRepository.query(fallbackQuery, [normalizedQuery]); - if (suggestions.length > 0 && suggestions[0].dist < 0.6) { - return { - results: [], - did_you_mean: suggestions[0].name_ar || suggestions[0].name - }; - } - } - catch (err) { - this.logger.warn('Did You Mean fallback failed: ' + err.message); - } - } - return { results: formatted }; - } - catch (e) { - this.logger.error('Search failed:', e); - return { results: [] }; - } - } - formatResults(results, hasLocation, relativePrefix = '') { - const seenStreets = new Set(); - const maxPopularity = Math.max(...results.map(r => r.popularity_score || 10), 100); - return results - .map(r => { - const textScore = Number(r.relevance); - const popularityScore = (r.popularity_score || 10) / maxPopularity; - const proximityBonus = hasLocation ? Math.max(0, 1 - (Number(r.distance) / 10000)) : 0; - const totalScore = (textScore * 0.5) + (popularityScore * 0.3) + (proximityBonus * 0.2); - return { ...r, totalScore }; - }) - .sort((a, b) => b.totalScore - a.totalScore) - .filter(r => { - if (r.category === 'street') { - const key = `${r.name_ar || r.name}_${r.district}_${r.governorate}`; - if (seenStreets.has(key)) - return false; - seenStreets.add(key); - } - return true; - }) - .slice(0, 4) - .map(r => { - const addressParts = [r.neighbourhood, r.district, r.governorate].filter(Boolean); - const full_address = addressParts.length > 0 ? addressParts.join('، ') : (r.address || ''); - const nameAr = r.name_ar || r.name; - const displayName = relativePrefix ? `${relativePrefix} ${nameAr}` : nameAr; - return { - ...r, - name: displayName, - name_ar: displayName, - latitude: parseFloat(r.latitude), - longitude: parseFloat(r.longitude), - distance_km: r.distance ? (Number(r.distance) / 1000).toFixed(2) : null, - location: { lat: parseFloat(r.latitude), lng: parseFloat(r.longitude) }, - full_address, - }; - }); - } - getRepoByTableName(tableName) { - if (tableName === 'places_egypt') - return this.placesEgyptRepository; - if (tableName === 'places_iraq') - return this.placesIraqRepository; - if (tableName === 'places_jordan') - return this.placesJordanRepository; - return this.placesSyriaRepository; - } - async logFailedSearch(query, normalizedQuery, country, lat, lon) { - const q = ` - INSERT INTO failed_searches (query_text, normalized_query, country, latitude, longitude) - VALUES ($1, $2, $3, $4, $5) - ON CONFLICT (normalized_query, COALESCE(country, 'global')) - DO UPDATE SET search_count = failed_searches.search_count + 1, last_seen_at = CURRENT_TIMESTAMP; - `; - await this.osmPointsRepository.query(q, [query, normalizedQuery, country || null, lat || null, lon || null]); - } - async autocomplete(query, country) { - try { - let cleanQuery = query.trim(); - if (cleanQuery.length < 2) - return { results: [] }; - let relativePrefix = ''; - const relativeQueryRegex = /^(قرب|بالقرب من|قريب من|عند|بجانب|جنب|حد|بجوار|مقابل|قبال|خلف|ورا|وراء)\s+(.+)$/i; - const match = cleanQuery.match(relativeQueryRegex); - if (match) { - relativePrefix = match[1]; - cleanQuery = match[2]; - if (cleanQuery.length < 2) - return { results: [] }; - } - const targetRegion = country?.toLowerCase(); - const cacheKey = `geo_auto:${targetRegion || 'auto'}:${cleanQuery.toLowerCase()}`; - const cached = await this.cacheManager.get(cacheKey); - if (cached) - return { results: cached, source: 'cache_hit' }; - const [normalizedQueryRes] = await this.osmPointsRepository.query(`SELECT normalize_arabic($1) as nq`, [cleanQuery]); - const normalizedQuery = normalizedQueryRes?.nq || cleanQuery.toLowerCase(); - let queryParams = [`${normalizedQuery}%`]; - let regionCondition = ''; - if (targetRegion && ['syria', 'jordan', 'egypt', 'iraq'].includes(targetRegion)) { - regionCondition = `AND (region = '${targetRegion}' OR region = 'global')`; - } - const sqlQuery = ` - SELECT - id, name, name_ar, category, region, source, address - FROM unified_search_index - WHERE normalized_name LIKE $1 - ${regionCondition} - ORDER BY LENGTH(normalized_name) ASC - LIMIT 7 - `; - const results = await this.osmPointsRepository.query(sqlQuery, queryParams); - const formatted = results.map(r => { - const nameAr = r.name_ar || r.name; - const displayName = relativePrefix ? `${relativePrefix} ${nameAr}` : nameAr; - return { - id: r.id, - name: displayName, - category: r.category, - region: r.region, - address: r.address - }; - }); - if (formatted.length > 0) { - await this.cacheManager.set(cacheKey, formatted, 3600000); - } - return { results: formatted }; - } - catch (e) { - this.logger.error('Autocomplete failed:', e); - return { results: [] }; - } - } - async findIraqiAddress(lat, lng) { - const MAX_DISTANCE_M = 150; - try { - const rows = await this.osmPointsRepository.query(` - WITH p AS ( - SELECT ST_Transform(ST_SetSRID(ST_MakePoint($1::float, $2::float), 4326), 3857) AS g3857, - ST_SetSRID(ST_MakePoint($1::float, $2::float), 4326)::geography AS geog - ) - SELECT l.name, - ST_Distance(ST_Transform(l.way, 4326)::geography, p.geog) AS distance - FROM planet_osm_line l, p - WHERE l.name ~ '^[0-9]{2,4}-[0-9]{1,3}$' - ORDER BY l.way <-> p.g3857 - LIMIT 1 - `, [lng, lat]); - const row = rows?.[0]; - if (!row || Number(row.distance) > MAX_DISTANCE_M) - return null; - const [mahalla, zuqaq] = String(row.name).split('-'); - return { - mahalla, - zuqaq, - distance: Number(row.distance), - text: `محلة ${mahalla}، زقاق ${zuqaq}`, - }; - } - catch (e) { - this.logger.warn(`Iraqi address lookup failed: ${e.message}`); - return null; - } - } - async reverseGeocode(lat, lng) { - try { - const repo = this.getRepositoryForCoords(lat, lng); - const tableName = this.getTableNameForRepo(repo); - const iraqiAddressPromise = this.identifyRegion(lat, lng) === 'iraq' - ? this.findIraqiAddress(lat, lng) - : Promise.resolve(null); - const queryPromises = []; - queryPromises.push(repo.query(` - SELECT - p.id, p.name, p.name_ar, p.category, - n.name_ar as neighbourhood, - d.name_ar as district, - g.name_ar as governorate, - p.latitude, p.longitude, p.address, 'user_place' as source, - ST_DistanceSphere(p.location::geometry, ST_SetSRID(ST_MakePoint($1::float, $2::float), 4326)) as distance - FROM ${tableName} p - LEFT JOIN neighborhood_polygons n ON p.neighborhood_id = n.id - LEFT JOIN admin_boundaries d ON p.sub_district_id = d.id - LEFT JOIN admin_boundaries g ON p.governorate_id = g.id - WHERE p.location IS NOT NULL - ORDER BY p.location::geometry <-> ST_SetSRID(ST_MakePoint($1::float, $2::float), 4326) ASC LIMIT 5 - `, [lng, lat])); - queryPromises.push(repo.query(` - SELECT - o.osm_id::text as id, o.name, o.name_ar, COALESCE(o.amenity, o.shop, 'place') as category, - '' as neighbourhood, '' as district, '' as governorate, - o.latitude, o.longitude, o.addr_street as address, 'osm_global' as source, - ST_DistanceSphere(o.geom, ST_SetSRID(ST_MakePoint($1::float, $2::float), 4326)) as distance - FROM osm_points_with_area o - WHERE o.geom IS NOT NULL AND (o.name IS NOT NULL OR o.name_ar IS NOT NULL) - ORDER BY o.geom <-> ST_SetSRID(ST_MakePoint($1::float, $2::float), 4326) ASC LIMIT 5 - `, [lng, lat])); - queryPromises.push(repo.query(` - SELECT - id::text, COALESCE(names->>'primary', names->>'common', 'Street') as name, COALESCE(names->>'primary', names->>'common', 'Street') as name_ar, 'street' as category, - '' as neighbourhood, '' as district, '' as governorate, - ST_Y(ST_Centroid(location))::text as latitude, ST_X(ST_Centroid(location))::text as longitude, '' as address, 'overture_global' as source, - ST_DistanceSphere(location, ST_SetSRID(ST_MakePoint($1::float, $2::float), 4326)) as distance - FROM overture_segment - WHERE location IS NOT NULL AND (names->>'primary' IS NOT NULL OR names->>'common' IS NOT NULL) - ORDER BY location <-> ST_SetSRID(ST_MakePoint($1::float, $2::float), 4326) ASC LIMIT 5 - `, [lng, lat])); - queryPromises.push(repo.query(` - SELECT - id::text, COALESCE(names->>'primary', names->>'common', 'Building') as name, COALESCE(names->>'primary', names->>'common', 'Building') as name_ar, 'building' as category, - '' as neighbourhood, '' as district, '' as governorate, - ST_Y(ST_Centroid(location))::text as latitude, ST_X(ST_Centroid(location))::text as longitude, '' as address, 'overture_global' as source, - ST_DistanceSphere(location, ST_SetSRID(ST_MakePoint($1::float, $2::float), 4326)) as distance - FROM overture_building - WHERE location IS NOT NULL AND (names->>'primary' IS NOT NULL OR names->>'common' IS NOT NULL) - ORDER BY location <-> ST_SetSRID(ST_MakePoint($1::float, $2::float), 4326) ASC LIMIT 5 - `, [lng, lat])); - queryPromises.push(repo.query(` - SELECT - id::text, COALESCE(names->>'primary', names->>'common', 'Place') as name, COALESCE(names->>'primary', names->>'common', 'Place') as name_ar, 'place' as category, - '' as neighbourhood, '' as district, '' as governorate, - ST_Y(ST_Centroid(location))::text as latitude, ST_X(ST_Centroid(location))::text as longitude, '' as address, 'overture_global' as source, - ST_DistanceSphere(location, ST_SetSRID(ST_MakePoint($1::float, $2::float), 4326)) as distance - FROM overture_place - WHERE location IS NOT NULL AND (names->>'primary' IS NOT NULL OR names->>'common' IS NOT NULL) - ORDER BY location <-> ST_SetSRID(ST_MakePoint($1::float, $2::float), 4326) ASC LIMIT 5 - `, [lng, lat])); - queryPromises.push(repo.query(` - SELECT - id::text, COALESCE(name, 'Street') as name, COALESCE(name, 'طريق معتمد') as name_ar, 'street' as category, - '' as neighbourhood, '' as district, '' as governorate, - ST_Y(ST_Centroid(geometry::geometry))::text as latitude, ST_X(ST_Centroid(geometry::geometry))::text as longitude, '' as address, 'approved_road' as source, - ST_DistanceSphere(geometry::geometry, ST_SetSRID(ST_MakePoint($1::float, $2::float), 4326)) as distance - FROM approved_roads - WHERE geometry IS NOT NULL AND name IS NOT NULL AND trim(name) != '' - ORDER BY geometry::geometry <-> ST_SetSRID(ST_MakePoint($1::float, $2::float), 4326) ASC LIMIT 5 - `, [lng, lat]).catch(() => [])); - const [results, iraqiAddress] = await Promise.all([ - Promise.allSettled(queryPromises), - iraqiAddressPromise, - ]); - let allResults = []; - results.forEach(res => { - if (res.status === 'fulfilled' && res.value) - allResults.push(...res.value); - }); - return allResults - .sort((a, b) => Number(a.distance) - Number(b.distance)) - .slice(0, 5) - .map(r => { - const distance = Number(r.distance); - const ZUQAQ_NAME_RE = /^[0-9]{2,4}-[0-9]{1,3}$/; - const rawName = r.name_ar || r.name; - const nameIsZuqaq = typeof rawName === 'string' && ZUQAQ_NAME_RE.test(rawName); - const fullAddressParts = [ - nameIsZuqaq ? null : rawName, - r.address, - iraqiAddress?.text, - r.neighbourhood, - r.district, - r.governorate, - ].filter(Boolean); - let humanReadable = r.name_ar || r.name; - if (distance <= 20) { - humanReadable = r.name_ar || r.name; - } - else if (distance <= 70 && r.category !== 'street') { - const streetName = r.address ? `، ${r.address}` : ''; - humanReadable = `أمام ${r.name_ar || r.name}${streetName}`; - } - else if (r.category === 'street' || distance > 70) { - const streetPart = r.category === 'street' ? (r.name_ar || r.name) : (r.address || r.name_ar || r.name); - const districtPart = r.neighbourhood || r.district || ''; - humanReadable = [streetPart, districtPart].filter(Boolean).join('، '); - } - if (iraqiAddress) { - const landmark = distance <= 70 && !nameIsZuqaq ? rawName : null; - humanReadable = [iraqiAddress.text, landmark].filter(Boolean).join(' — '); - } - return { - ...r, - mahalla: iraqiAddress?.mahalla, - zuqaq: iraqiAddress?.zuqaq, - latitude: parseFloat(r.latitude), - longitude: parseFloat(r.longitude), - human_readable_address: humanReadable, - full_address: fullAddressParts.join('، ') - }; - }); - } - catch (error) { - this.logger.error('Reverse geocoding error:', error); - return []; - } - } - extractCoords(data) { - const lat = Number(data?.lat ?? data?.latitude); - const lng = Number(data?.lng ?? data?.longitude); - if (!Number.isFinite(lat) || !Number.isFinite(lng)) { - throw new common_1.HttpException('Invalid coordinates: provide numeric lat/lng (or latitude/longitude)', common_1.HttpStatus.BAD_REQUEST); - } - if (lat < -90 || lat > 90 || lng < -180 || lng > 180) { - throw new common_1.HttpException(`Coordinates out of range: lat=${lat}, lng=${lng}`, common_1.HttpStatus.BAD_REQUEST); - } - return { lat, lng }; - } - async addPlace(data) { - try { - const { lat, lng } = this.extractCoords(data); - const repo = this.getRepositoryForCoords(lat, lng), tableName = this.getTableNameForRepo(repo); - const newPlace = repo.create({ ...data, latitude: lat, longitude: lng, created_at: new Date(), location: { type: 'Point', coordinates: [lng, lat] } }); - const savedPlace = await repo.save(newPlace); - await repo.query(`UPDATE ${tableName} SET location = ST_SetSRID(ST_MakePoint($1::float, $2::float), 4326) WHERE id = $3`, [lng, lat, savedPlace.id]); - return { ...savedPlace, latitude: lat, longitude: lng, location: `POINT(${lng} ${lat})` }; - } - catch (error) { - if (error instanceof common_1.HttpException) - throw error; - throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR); - } - } - async upsertPlace(data) { - try { - const { lat, lng } = this.extractCoords(data); - const repo = this.getRepositoryForCoords(lat, lng), tableName = this.getTableNameForRepo(repo); - const existing = await repo.query(`SELECT id, name FROM ${tableName} WHERE ST_DistanceSphere(location, ST_SetSRID(ST_MakePoint($1::float, $2::float), 4326)) < 15 LIMIT 1`, [lng, lat]); - if (existing && existing.length > 0) { - await repo.update(existing[0].id, { name: data.name || undefined, name_ar: data.name_ar || undefined, category: data.category || undefined }); - return { id: existing[0].id, action: 'updated' }; - } - const result = await this.addPlace(data); - return { id: result.id, action: 'created' }; - } - catch (error) { - throw error; - } - } - async upsertBatch(places) { - const results = []; - const errors = []; - for (const [index, place] of places.entries()) { - try { - const r = await this.addPlace(place); - results.push({ id: r.id, action: 'created' }); - } - catch (e) { - if (errors.length < 50) { - errors.push({ - index, - name: place?.name, - reason: e instanceof common_1.HttpException ? e.message : (e?.message ?? 'unknown'), - }); - } - } - } - const failed = places.length - results.length; - return { - total: places.length, - processed: results.length, - created: results.length, - updated: 0, - failed, - errors, - errorsTruncated: failed > errors.length, - }; - } - async getRecentPlaces(limit = 50) { - const s = await this.placesSyriaRepository.find({ order: { created_at: 'DESC' }, take: limit }); - const j = await this.placesJordanRepository.find({ order: { created_at: 'DESC' }, take: limit }); - const e = await this.placesEgyptRepository.find({ order: { created_at: 'DESC' }, take: limit }); - const i = await this.placesIraqRepository.find({ order: { created_at: 'DESC' }, take: limit }); - return [...s, ...j, ...e, ...i].sort((a, b) => b.created_at.getTime() - a.created_at.getTime()).slice(0, limit); - } - async getAllPlacesGeoJSON() { - try { - const q = ` - SELECT id::text, name_ar as name, category, latitude, longitude, address, 'user' as region FROM places_syria - UNION ALL SELECT id::text, name_ar as name, category, latitude, longitude, address, 'user' as region FROM places_jordan - UNION ALL SELECT id::text, name_ar as name, category, latitude, longitude, address, 'user' as region FROM places_egypt - UNION ALL SELECT id::text, name_ar as name, category, latitude, longitude, address, 'user' as region FROM places_iraq - UNION ALL SELECT id::text, COALESCE(names->>'primary', names->>'common', 'Building') as name, 'building' as category, ST_Y(ST_Centroid(location)) as latitude, ST_X(ST_Centroid(location)) as longitude, '' as address, 'overture' as region FROM overture_building WHERE names->>'primary' IS NOT NULL LIMIT 500 - UNION ALL SELECT id::text, COALESCE(names->>'primary', names->>'common', 'Street') as name, 'street' as category, ST_Y(ST_Centroid(location)) as latitude, ST_X(ST_Centroid(location)) as longitude, '' as address, 'overture' as region FROM overture_segment WHERE names->>'primary' IS NOT NULL LIMIT 500 - UNION ALL SELECT id::text, COALESCE(names->>'primary', names->>'common', 'Place') as name, 'place' as category, ST_Y(ST_Centroid(location)) as latitude, ST_X(ST_Centroid(location)) as longitude, '' as address, 'overture' as region FROM overture_place WHERE names->>'primary' IS NOT NULL LIMIT 500 - `; - const res = await this.placesSyriaRepository.query(q); - const features = res.map(p => ({ - type: 'Feature', - geometry: { type: 'Point', coordinates: [parseFloat(p.longitude), parseFloat(p.latitude)] }, - properties: { id: p.id, name: p.name, category: p.category, address: p.address, region: p.region } - })); - return { type: 'FeatureCollection', features }; - } - catch (e) { - return { type: 'FeatureCollection', features: [] }; - } - } - async deletePlacesByName(name, country) { - const repo = this.getRepoByCountry(country); - const r1 = await repo.delete({ name_ar: name }), r2 = await repo.delete({ name_en: name }), r3 = await repo.delete({ name: name }); - return { success: true, affected: (r1.affected || 0) + (r2.affected || 0) + (r3.affected || 0) }; - } - async deletePlaceById(id, country) { - const repo = this.getRepoByCountry(country); - return { success: true, affected: (await repo.delete(id)).affected }; - } - getRepoByCountry(country) { - switch (country?.toLowerCase()) { - case 'syria': return this.placesSyriaRepository; - case 'jordan': return this.placesJordanRepository; - case 'egypt': return this.placesEgyptRepository; - case 'iraq': return this.placesIraqRepository; - default: throw new common_1.HttpException('Invalid country: ' + country, common_1.HttpStatus.BAD_REQUEST); - } - } -}; -exports.GeocodingService = GeocodingService; -exports.GeocodingService = GeocodingService = GeocodingService_1 = __decorate([ - (0, common_1.Injectable)(), - __param(0, (0, typeorm_1.InjectRepository)(place_syria_entity_1.PlaceSyria)), - __param(1, (0, typeorm_1.InjectRepository)(place_jordan_entity_1.PlaceJordan)), - __param(2, (0, typeorm_1.InjectRepository)(place_egypt_entity_1.PlaceEgypt)), - __param(3, (0, typeorm_1.InjectRepository)(place_iraq_entity_1.PlaceIraq)), - __param(4, (0, typeorm_1.InjectRepository)(osm_area_entity_1.OsmArea)), - __param(5, (0, typeorm_1.InjectRepository)(osm_point_with_area_entity_1.OsmPointWithArea)), - __param(6, (0, common_1.Inject)(cache_manager_1.CACHE_MANAGER)), - __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object, typeof (_b = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _b : Object, typeof (_c = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _c : Object, typeof (_d = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _d : Object, typeof (_e = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _e : Object, typeof (_f = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _f : Object, Object]) -], GeocodingService); -//# sourceMappingURL=geocoding.service.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/geocoding.service.js.map b/apps/api/dist/geocoding/geocoding.service.js.map deleted file mode 100644 index 0d32e21..0000000 --- a/apps/api/dist/geocoding/geocoding.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"geocoding.service.js","sourceRoot":"","sources":["../../src/geocoding/geocoding.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAuF;AACvF,6CAAmD;AACnD,qCAAqC;AACrC,yDAAsD;AAEtD,sEAA2D;AAC3D,wEAA6D;AAC7D,sEAA2D;AAC3D,oEAAyD;AAEzD,gEAAqD;AACrD,sFAAyE;AAGlE,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAOjB;IAEA;IAEA;IAEA;IAEA;IAEA;IAEA;IAlBO,MAAM,GAAG,IAAI,eAAM,CAAC,kBAAgB,CAAC,IAAI,CAAC,CAAC;IAE3C,aAAa,GAAG,IAAI,CAAC;IAEtC,YAEU,qBAA6C,EAE7C,sBAA+C,EAE/C,qBAA6C,EAE7C,oBAA2C,EAE3C,kBAAuC,EAEvC,mBAAiD,EAEjD,YAAmB;QAZnB,0BAAqB,GAArB,qBAAqB,CAAwB;QAE7C,2BAAsB,GAAtB,sBAAsB,CAAyB;QAE/C,0BAAqB,GAArB,qBAAqB,CAAwB;QAE7C,yBAAoB,GAApB,oBAAoB,CAAuB;QAE3C,uBAAkB,GAAlB,k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BAAU,CAAC,WAAW,CAAC,CAAC;QAC1F,CAAC;IACH,CAAC;CACF,CAAA;AAjqBY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;IAOR,WAAA,IAAA,0BAAgB,EAAC,+BAAU,CAAC,CAAA;IAE5B,WAAA,IAAA,0BAAgB,EAAC,iCAAW,CAAC,CAAA;IAE7B,WAAA,IAAA,0BAAgB,EAAC,+BAAU,CAAC,CAAA;IAE5B,WAAA,IAAA,0BAAgB,EAAC,6BAAS,CAAC,CAAA;IAE3B,WAAA,IAAA,0BAAgB,EAAC,yBAAO,CAAC,CAAA;IAEzB,WAAA,IAAA,0BAAgB,EAAC,6CAAgB,CAAC,CAAA;IAElC,WAAA,IAAA,eAAM,EAAC,6BAAa,CAAC,CAAA;yDAXS,oBAAU,oBAAV,oBAAU,oDAET,oBAAU,oBAAV,oBAAU,oDAEX,oBAAU,oBAAV,oBAAU,oDAEX,oBAAU,oBAAV,oBAAU,oDAEZ,oBAAU,oBAAV,oBAAU,oDAET,oBAAU,oBAAV,oBAAU;GAjB9B,gBAAgB,CAiqB5B"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/index-refresh.service.d.ts b/apps/api/dist/geocoding/index-refresh.service.d.ts deleted file mode 100644 index f0fab3c..0000000 --- a/apps/api/dist/geocoding/index-refresh.service.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Repository } from 'typeorm'; -import { OsmPointWithArea } from './entities/osm-point-with-area.entity'; -export declare class IndexRefreshService { - private readonly repo; - private readonly logger; - constructor(repo: Repository); - handleCron(): Promise; -} diff --git a/apps/api/dist/geocoding/index-refresh.service.js b/apps/api/dist/geocoding/index-refresh.service.js deleted file mode 100644 index 90eb865..0000000 --- a/apps/api/dist/geocoding/index-refresh.service.js +++ /dev/null @@ -1,60 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -var IndexRefreshService_1; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.IndexRefreshService = void 0; -const common_1 = require("@nestjs/common"); -const schedule_1 = require("@nestjs/schedule"); -const typeorm_1 = require("@nestjs/typeorm"); -const typeorm_2 = require("typeorm"); -const osm_point_with_area_entity_1 = require("./entities/osm-point-with-area.entity"); -let IndexRefreshService = IndexRefreshService_1 = class IndexRefreshService { - repo; - logger = new common_1.Logger(IndexRefreshService_1.name); - constructor(repo) { - this.repo = repo; - } - async handleCron() { - this.logger.log('Starting background refresh for unified_search_index...'); - try { - await this.repo.query('REFRESH MATERIALIZED VIEW CONCURRENTLY unified_search_index;'); - this.logger.log('Successfully refreshed unified_search_index.'); - } - catch (error) { - this.logger.error('Failed to refresh unified_search_index', error); - try { - this.logger.log('Attempting standard refresh (blocking)...'); - await this.repo.query('REFRESH MATERIALIZED VIEW unified_search_index;'); - this.logger.log('Successfully refreshed unified_search_index (standard).'); - } - catch (fallbackError) { - this.logger.error('Fallback standard refresh also failed', fallbackError); - } - } - } -}; -exports.IndexRefreshService = IndexRefreshService; -__decorate([ - (0, schedule_1.Cron)(schedule_1.CronExpression.EVERY_5_MINUTES), - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", Promise) -], IndexRefreshService.prototype, "handleCron", null); -exports.IndexRefreshService = IndexRefreshService = IndexRefreshService_1 = __decorate([ - (0, common_1.Injectable)(), - __param(0, (0, typeorm_1.InjectRepository)(osm_point_with_area_entity_1.OsmPointWithArea)), - __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object]) -], IndexRefreshService); -//# sourceMappingURL=index-refresh.service.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/index-refresh.service.js.map b/apps/api/dist/geocoding/index-refresh.service.js.map deleted file mode 100644 index 19bfccd..0000000 --- a/apps/api/dist/geocoding/index-refresh.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index-refresh.service.js","sourceRoot":"","sources":["../../src/geocoding/index-refresh.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,+CAAwD;AACxD,6CAAmD;AACnD,qCAAqC;AACrC,sFAAyE;AAGlE,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAKX;IAJF,MAAM,GAAG,IAAI,eAAM,CAAC,qBAAmB,CAAC,IAAI,CAAC,CAAC;IAE/D,YAEmB,IAAkC;QAAlC,SAAI,GAAJ,IAAI,CAA8B;IAClD,CAAC;IAIE,AAAN,KAAK,CAAC,UAAU;QACd,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAC;QAC3E,IAAI,CAAC;YAEH,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,8DAA8D,CAAC,CAAC;YACtF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;QAClE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;YAGnE,IAAI,CAAC;gBACH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;gBAC7D,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;gBACzE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAC;YAC7E,CAAC;YAAC,OAAO,aAAa,EAAE,CAAC;gBACvB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uCAAuC,EAAE,aAAa,CAAC,CAAC;YAC5E,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AA7BY,kDAAmB;AAUxB;IADL,IAAA,eAAI,EAAC,yBAAc,CAAC,eAAe,CAAC;;;;qDAmBpC;8BA5BU,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,0BAAgB,EAAC,6CAAgB,CAAC,CAAA;yDACZ,oBAAU,oBAAV,oBAAU;GALxB,mBAAmB,CA6B/B"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/jordan-research.service.d.ts b/apps/api/dist/geocoding/jordan-research.service.d.ts deleted file mode 100644 index 6f3b456..0000000 --- a/apps/api/dist/geocoding/jordan-research.service.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Repository } from 'typeorm'; -import { PlaceJordan } from './entities/place-jordan.entity'; -export declare class JordanResearchService { - private readonly placeRepo; - private readonly logger; - constructor(placeRepo: Repository); - private fetchWithRetry; - fetchOsmZarqa(): Promise; - fetchOvertureZarqa(): Promise; - fetchWikidataZarqa(): Promise; - checkStaticFiles(): Promise<{}>; - generateZarqaReport(): Promise<{ - area: string; - report_timestamp: string; - sources: { - osm: any; - overture: any; - wikidata: any; - static_files: any; - hdx: string; - gadm: string; - }; - comparison_summary: string; - }>; -} diff --git a/apps/api/dist/geocoding/jordan-research.service.js b/apps/api/dist/geocoding/jordan-research.service.js deleted file mode 100644 index 9b53b73..0000000 --- a/apps/api/dist/geocoding/jordan-research.service.js +++ /dev/null @@ -1,184 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __importStar = (this && this.__importStar) || (function () { - var ownKeys = function(o) { - ownKeys = Object.getOwnPropertyNames || function (o) { - var ar = []; - for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; - return ar; - }; - return ownKeys(o); - }; - return function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); - __setModuleDefault(result, mod); - return result; - }; -})(); -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -var JordanResearchService_1; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.JordanResearchService = void 0; -const common_1 = require("@nestjs/common"); -const typeorm_1 = require("@nestjs/typeorm"); -const typeorm_2 = require("typeorm"); -const place_jordan_entity_1 = require("./entities/place-jordan.entity"); -const axios_1 = __importDefault(require("axios")); -const fs = __importStar(require("fs")); -const path = __importStar(require("path")); -let JordanResearchService = JordanResearchService_1 = class JordanResearchService { - placeRepo; - logger = new common_1.Logger(JordanResearchService_1.name); - constructor(placeRepo) { - this.placeRepo = placeRepo; - } - async fetchWithRetry(url, data, method = 'get', retries = 2) { - for (let i = 0; i <= retries; i++) { - try { - const config = { - timeout: 20000, - headers: { - 'User-Agent': 'Mozilla/5.0 (compatible; IntaleqMapBot/1.0; +https://intaleq.xyz)', - 'Accept': 'application/json, application/sparql-results+json' - } - }; - const response = method === 'post' - ? await axios_1.default.post(url, data, config) - : await axios_1.default.get(url, { ...config, params: data ? { query: data, format: 'json' } : {} }); - return response.data; - } - catch (error) { - if (i === retries) { - this.logger.error(`Failed to fetch from ${url} after ${retries} retries: ${error.message}`); - throw error; - } - await new Promise(res => setTimeout(res, 2000)); - } - } - } - async fetchOsmZarqa() { - this.logger.log('Fetching Zarqa Geometries from OSM...'); - const query = `[out:json];(relation["boundary"="administrative"]["admin_level"~"6|8|10"](31.86,35.94,32.22,36.25);node["place"~"neighbourhood|suburb|town"](31.86,35.94,32.22,36.25););out geom;`; - try { - const data = await this.fetchWithRetry('https://overpass-api.de/api/interpreter', `data=${encodeURIComponent(query)}`, 'post'); - return data.elements.map(e => ({ - id: e.id, - name_ar: e.tags['name:ar'] || e.tags['name'], - type: e.tags['admin_level'] ? `admin_level_${e.tags['admin_level']}` : `place_${e.tags['place']}`, - geometry: e.geometry ? e.geometry : (e.lat && e.lon ? { type: 'Point', coordinates: [e.lon, e.lat] } : null) - })); - } - catch (e) { - return { error: `OSM Fetch failed: ${e.message}` }; - } - } - async fetchOvertureZarqa() { - try { - const tableCheck = await this.placeRepo.query("SELECT count(*) FROM information_schema.tables WHERE table_name = 'overture_segment'"); - if (parseInt(tableCheck[0].count) === 0) - return { error: 'table overture_segment does not exist in this database' }; - const columns = await this.placeRepo.query("SELECT column_name FROM information_schema.columns WHERE table_name = 'overture_segment'"); - const colList = columns.map(c => c.column_name); - const roadClassCol = colList.includes('road_class') ? 'road_class' : (colList.includes('class') ? 'class' : 'NULL'); - return await this.placeRepo.query(` - SELECT DISTINCT COALESCE(names->>'primary', names->>'common') as name_ar, ${roadClassCol} as road_class, - ST_AsGeoJSON(ST_Centroid(location)) as centroid - FROM overture_segment - WHERE (names->>'primary' IS NOT NULL OR names->>'common' IS NOT NULL) - AND ST_Within(location, ST_MakeEnvelope(35.94, 31.86, 36.25, 32.22, 4326)) - LIMIT 10 - `); - } - catch (e) { - return { error: `Overture query failed: ${e.message}` }; - } - } - async fetchWikidataZarqa() { - const sparql = `SELECT ?item ?itemLabel WHERE { ?item wdt:P131 wd:Q231710. SERVICE wikibase:label { bd:serviceParam wikibase:language "ar,en". } } LIMIT 20`; - try { - const data = await this.fetchWithRetry('https://query.wikidata.org/sparql', sparql, 'get'); - return data.results.bindings.map(b => ({ id: b.item.value.split('/').pop(), name_ar: b.itemLabel.value })); - } - catch (e) { - return { error: `Wikidata Fetch failed: ${e.message}` }; - } - } - async checkStaticFiles() { - const paths = ['/data/infrastructure/osm-data/', './data/', './infrastructure/osm-data/']; - const files = ['jor_adm2_geoboundaries.geojson', 'gadm41_JOR_2.json']; - const results = {}; - for (const file of files) { - let found = false; - for (const p of paths) { - if (fs.existsSync(path.join(p, file))) { - results[file] = `Found at ${p}`; - found = true; - break; - } - } - if (!found) - results[file] = 'Not Found locally - Check if overture_ingest.sh was run for division_area'; - } - return results; - } - async generateZarqaReport() { - const [osm, overture, wikidata, staticFiles] = await Promise.all([ - this.fetchOsmZarqa(), - this.fetchOvertureZarqa(), - this.fetchWikidataZarqa(), - this.checkStaticFiles() - ]); - return { - area: 'Zarqa Governorate, Jordan', - report_timestamp: new Date().toISOString(), - sources: { - osm, - overture, - wikidata, - static_files: staticFiles, - hdx: "Requires GeoBoundaries GeoJSON for Level 2 (Districts)", - gadm: "Requires GADM v4.1 for Level 1-2" - }, - comparison_summary: "Multi-source research enabled with geometries. OSM provides precise neighborhood centroids and boundaries where available. Use the provided centroids to visualize Zarqa subunits." - }; - } -}; -exports.JordanResearchService = JordanResearchService; -exports.JordanResearchService = JordanResearchService = JordanResearchService_1 = __decorate([ - (0, common_1.Injectable)(), - __param(0, (0, typeorm_1.InjectRepository)(place_jordan_entity_1.PlaceJordan)), - __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object]) -], JordanResearchService); -//# sourceMappingURL=jordan-research.service.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/jordan-research.service.js.map b/apps/api/dist/geocoding/jordan-research.service.js.map deleted file mode 100644 index 69e4f72..0000000 --- a/apps/api/dist/geocoding/jordan-research.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"jordan-research.service.js","sourceRoot":"","sources":["../../src/geocoding/jordan-research.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,6CAAmD;AACnD,qCAAqC;AACrC,wEAA6D;AAC7D,kDAA0B;AAC1B,uCAAyB;AACzB,2CAA6B;AAGtB,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAKb;IAJF,MAAM,GAAG,IAAI,eAAM,CAAC,uBAAqB,CAAC,IAAI,CAAC,CAAC;IAEjE,YAEmB,SAAkC;QAAlC,cAAS,GAAT,SAAS,CAAyB;IAClD,CAAC;IAEI,KAAK,CAAC,cAAc,CAAC,GAAW,EAAE,IAAa,EAAE,SAAyB,KAAK,EAAE,OAAO,GAAG,CAAC;QAClG,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5B,IAAI,CAAC;gBACD,MAAM,MAAM,GAAG;oBACX,OAAO,EAAE,KAAK;oBACd,OAAO,EAAE;wBACL,YAAY,EAAE,mEAAmE;wBACjF,QAAQ,EAA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AC;YAClB,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;gBACpB,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC;oBACpC,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,EAAE,CAAC;oBAChC,KAAK,GAAG,IAAI,CAAC;oBACb,MAAM;gBACV,CAAC;YACL,CAAC;YACD,IAAI,CAAC,KAAK;gBAAE,OAAO,CAAC,IAAI,CAAC,GAAG,2EAA2E,CAAC;QAC5G,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,mBAAmB;QACvB,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAC/D,IAAI,CAAC,aAAa,EAAE;YACpB,IAAI,CAAC,kBAAkB,EAAE;YACzB,IAAI,CAAC,kBAAkB,EAAE;YACzB,IAAI,CAAC,gBAAgB,EAAE;SACxB,CAAC,CAAC;QAEH,OAAO;YACL,IAAI,EAAE,2BAA2B;YACjC,gBAAgB,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YAC1C,OAAO,EAAE;gBACP,GAAG;gBACH,QAAQ;gBACR,QAAQ;gBACR,YAAY,EAAE,WAAW;gBACzB,GAAG,EAAE,wDAAwD;gBAC7D,IAAI,EAAE,kCAAkC;aACzC;YACD,kBAAkB,EAAE,oLAAoL;SACzM,CAAC;IACJ,CAAC;CACF,CAAA;AAjIY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,0BAAgB,EAAC,iCAAW,CAAC,CAAA;yDACF,oBAAU,oBAAV,oBAAU;GAL7B,qBAAqB,CAiIjC"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/map-refinement.controller.d.ts b/apps/api/dist/geocoding/map-refinement.controller.d.ts deleted file mode 100644 index 68359ed..0000000 --- a/apps/api/dist/geocoding/map-refinement.controller.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { MapRefinementService } from './map-refinement.service'; -import { CandidateStatus } from './entities/map-candidate.entity'; -export declare class MapRefinementController { - private readonly refinementService; - constructor(refinementService: MapRefinementService); - suggest(req: any, dto: any): Promise; - list(status?: CandidateStatus): Promise; - approve(id: string): Promise; - reject(id: string, body: { - reason: string; - }): Promise; -} diff --git a/apps/api/dist/geocoding/map-refinement.controller.js b/apps/api/dist/geocoding/map-refinement.controller.js deleted file mode 100644 index 3da32de..0000000 --- a/apps/api/dist/geocoding/map-refinement.controller.js +++ /dev/null @@ -1,87 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.MapRefinementController = void 0; -const common_1 = require("@nestjs/common"); -const map_refinement_service_1 = require("./map-refinement.service"); -const firebase_auth_guard_1 = require("../auth/guards/firebase-auth.guard"); -const swagger_1 = require("@nestjs/swagger"); -const map_candidate_entity_1 = require("./entities/map-candidate.entity"); -let MapRefinementController = class MapRefinementController { - refinementService; - constructor(refinementService) { - this.refinementService = refinementService; - } - async suggest(req, dto) { - const userId = req.user?.uid || req.tenant?.id || 'anonymous'; - return this.refinementService.suggestPlace(dto, userId); - } - async list(status) { - return this.refinementService.getCandidates(status); - } - async approve(id) { - return this.refinementService.approveCandidate(parseInt(id, 10)); - } - async reject(id, body) { - return this.refinementService.rejectCandidate(parseInt(id, 10), body.reason); - } -}; -exports.MapRefinementController = MapRefinementController; -__decorate([ - (0, common_1.Post)('suggest'), - (0, swagger_1.ApiOperation)({ summary: 'Suggest a new location for the map (Client App)' }), - (0, swagger_1.ApiHeader)({ name: 'x-api-key', description: 'API Key for usage tracking' }), - __param(0, (0, common_1.Req)()), - __param(1, (0, common_1.Body)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object, Object]), - __metadata("design:returntype", Promise) -], MapRefinementController.prototype, "suggest", null); -__decorate([ - (0, swagger_1.ApiBearerAuth)(), - (0, common_1.UseGuards)(firebase_auth_guard_1.FirebaseAuthGuard), - (0, common_1.Get)('candidates'), - (0, swagger_1.ApiOperation)({ summary: 'List suggested places for review (Dashboard)' }), - __param(0, (0, common_1.Query)('status')), - __metadata("design:type", Function), - __metadata("design:paramtypes", [String]), - __metadata("design:returntype", Promise) -], MapRefinementController.prototype, "list", null); -__decorate([ - (0, swagger_1.ApiBearerAuth)(), - (0, common_1.UseGuards)(firebase_auth_guard_1.FirebaseAuthGuard), - (0, common_1.Patch)('candidates/:id/approve'), - (0, swagger_1.ApiOperation)({ summary: 'Approve a candidate and move to production (Dashboard)' }), - __param(0, (0, common_1.Param)('id')), - __metadata("design:type", Function), - __metadata("design:paramtypes", [String]), - __metadata("design:returntype", Promise) -], MapRefinementController.prototype, "approve", null); -__decorate([ - (0, swagger_1.ApiBearerAuth)(), - (0, common_1.UseGuards)(firebase_auth_guard_1.FirebaseAuthGuard), - (0, common_1.Patch)('candidates/:id/reject'), - (0, swagger_1.ApiOperation)({ summary: 'Reject a candidate (Dashboard)' }), - __param(0, (0, common_1.Param)('id')), - __param(1, (0, common_1.Body)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [String, Object]), - __metadata("design:returntype", Promise) -], MapRefinementController.prototype, "reject", null); -exports.MapRefinementController = MapRefinementController = __decorate([ - (0, swagger_1.ApiTags)('map-refinement-places'), - (0, common_1.Controller)('map-refinement/places'), - __metadata("design:paramtypes", [map_refinement_service_1.MapRefinementService]) -], MapRefinementController); -//# sourceMappingURL=map-refinement.controller.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/map-refinement.controller.js.map b/apps/api/dist/geocoding/map-refinement.controller.js.map deleted file mode 100644 index 89b66d6..0000000 --- a/apps/api/dist/geocoding/map-refinement.controller.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"map-refinement.controller.js","sourceRoot":"","sources":["../../src/geocoding/map-refinement.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAkG;AAClG,qEAAgE;AAChE,4EAAuE;AACvE,6CAAkF;AAClF,0EAAkE;AAI3D,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IACL;IAA7B,YAA6B,iBAAuC;QAAvC,sBAAiB,GAAjB,iBAAiB,CAAsB;IAAG,CAAC;IAKlE,AAAN,KAAK,CAAC,OAAO,CAAQ,GAAQ,EAAU,GAAQ;QAE7C,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,EAAE,IAAI,WAAW,CAAC;QAC9D,OAAO,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;IAMK,AAAN,KAAK,CAAC,IAAI,CAAkB,MAAwB;QAClD,OAAO,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;IAMK,AAAN,KAAK,CAAC,OAAO,CAAc,EAAU;QACnC,OAAO,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IACnE,CAAC;IAMK,AAAN,KAAK,CAAC,MAAM,CAAc,EAAU,EAAU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AC,uBAAuB,CAAC;IAChC,IAAA,mBAAU,EAAC,uBAAuB,CAAC;qCAEc,6CAAoB;GADzD,uBAAuB,CAmCnC"} \ No newline at end of file diff --git a/apps/api/dist/geocoding/map-refinement.service.d.ts b/apps/api/dist/geocoding/map-refinement.service.d.ts deleted file mode 100644 index 04e4592..0000000 --- a/apps/api/dist/geocoding/map-refinement.service.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Repository, DataSource } from 'typeorm'; -import { MapCandidate, CandidateStatus } from './entities/map-candidate.entity'; -import { PlaceJordan } from './entities/place-jordan.entity'; -import { PlaceSyria } from './entities/place-syria.entity'; -import { PlaceEgypt } from './entities/place-egypt.entity'; -import { PlaceIraq } from './entities/place-iraq.entity'; -export declare class MapRefinementService { - private dataSource; - private candidateRepository; - private jordanRepository; - private syriaRepository; - private egyptRepository; - private iraqRepository; - private readonly logger; - constructor(dataSource: DataSource, candidateRepository: Repository, jordanRepository: Repository, syriaRepository: Repository, egyptRepository: Repository, iraqRepository: Repository); - suggestPlace(dto: any, submittedBy: string): Promise; - runExternalVerification(candidateId: number): Promise; - getCandidates(status?: CandidateStatus): Promise; - approveCandidate(id: number): Promise; - rejectCandidate(id: number, reason: string): Promise; -} diff --git a/apps/api/dist/geocoding/map-refinement.service.js b/apps/api/dist/geocoding/map-refinement.service.js deleted file mode 100644 index fe13985..0000000 --- a/apps/api/dist/geocoding/map-refinement.service.js +++ /dev/null @@ -1,215 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -var MapRefinementService_1; -var _a, _b, _c, _d, _e, _f; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.MapRefinementService = void 0; -const common_1 = require("@nestjs/common"); -const typeorm_1 = require("@nestjs/typeorm"); -const typeorm_2 = require("typeorm"); -const map_candidate_entity_1 = require("./entities/map-candidate.entity"); -const place_jordan_entity_1 = require("./entities/place-jordan.entity"); -const place_syria_entity_1 = require("./entities/place-syria.entity"); -const place_egypt_entity_1 = require("./entities/place-egypt.entity"); -const place_iraq_entity_1 = require("./entities/place-iraq.entity"); -let MapRefinementService = MapRefinementService_1 = class MapRefinementService { - dataSource; - candidateRepository; - jordanRepository; - syriaRepository; - egyptRepository; - iraqRepository; - logger = new common_1.Logger(MapRefinementService_1.name); - constructor(dataSource, candidateRepository, jordanRepository, syriaRepository, egyptRepository, iraqRepository) { - this.dataSource = dataSource; - this.candidateRepository = candidateRepository; - this.jordanRepository = jordanRepository; - this.syriaRepository = syriaRepository; - this.egyptRepository = egyptRepository; - this.iraqRepository = iraqRepository; - } - async suggestPlace(dto, submittedBy) { - const lat = parseFloat(dto.lat || dto.latitude); - const lng = parseFloat(dto.lng || dto.longitude); - const country = (dto.country || 'JORDAN').toUpperCase(); - if (isNaN(lat) || isNaN(lng)) { - throw new Error('Invalid coordinates: Latitude and Longitude must be numbers'); - } - this.logger.log(`📍 Suggesting place: ${dto.name} at [${lat}, ${lng}]. Performing spatial enrichment...`); - const enrichment = await this.dataSource.query(` - SELECT - g.id as gov_id, g.name_ar as gov_name, - d.id as dist_id, d.name_ar as dist_name, - s.id as sub_id, s.name_ar as sub_name, - n.id as neigh_id, n.name_ar as neigh_name - FROM (SELECT ST_SetSRID(ST_MakePoint($1, $2), 4326) as p) p - LEFT JOIN admin_boundaries g ON g.admin_level = 4 AND ST_Within(p.p::geometry, g.geom::geometry) - LEFT JOIN admin_boundaries d ON d.admin_level = 6 AND ST_Within(p.p::geometry, d.geom::geometry) - LEFT JOIN admin_boundaries s ON s.admin_level = 8 AND ST_Within(p.p::geometry, s.geom::geometry) - LEFT JOIN neighborhood_polygons n ON ST_Within(p.p::geometry, n.geometry::geometry) - LIMIT 1 - `, [lng, lat]); - const spatialData = enrichment[0] || {}; - const isArabic = (text) => /[\u0600-\u06FF]/.test(text); - const nameAr = dto.name_ar || (isArabic(dto.name) ? dto.name : null); - const nameEn = dto.name_en || (!isArabic(dto.name) ? dto.name : null); - const candidate = this.candidateRepository.create({ - name: dto.name, - name_ar: nameAr, - name_en: nameEn, - category: dto.category, - address: dto.address, - latitude: lat, - longitude: lng, - submittedBy, - status: map_candidate_entity_1.CandidateStatus.PENDING, - country: country, - location: { - type: 'Point', - coordinates: [lng, lat], - }, - governorate_id: spatialData.gov_id, - district_id: spatialData.dist_id, - sub_district_id: spatialData.sub_id, - neighborhood_id: spatialData.neigh_id - }); - const saved = await this.candidateRepository.save(candidate); - this.logger.log(`✅ Success: Candidate ${saved.id} enriched with Gov:${saved.governorate_id}, Neigh:${spatialData.neigh_id}`); - this.runExternalVerification(saved.id).catch(err => this.logger.error(`❌ Verification failed for ${saved.id}: ${err.message}`)); - return { - ...saved, - governorate_name: spatialData.gov_name, - district_name: spatialData.dist_name, - neighborhood_name: spatialData.neigh_name, - location_wkt: `POINT(${lng} ${lat})` - }; - } - async runExternalVerification(candidateId) { - const candidate = await this.candidateRepository.findOne({ where: { id: candidateId } }); - if (!candidate) - return; - this.logger.log(`🔍 Starting automated verification for candidate ${candidate.id}...`); - try { - const axios = require('axios'); - const searchUrl = `https://duckduckgo.com/html/?q=${candidate.latitude},${candidate.longitude}`; - const response = await axios.get(searchUrl, { - headers: { - 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' - }, - timeout: 10000 - }); - const html = response.data; - const titleMatch = html.match(/([^<]+)<\/title>/); - if (titleMatch) { - let officialName = titleMatch[1].replace(' at DuckDuckGo', '').replace(' - DuckDuckGo', '').trim(); - const isCoordinates = /^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$/.test(officialName); - if (!isCoordinates && officialName.length > 5) { - candidate.verified_name = officialName; - const cleanUser = candidate.name.toLowerCase().trim(); - const cleanOfficial = officialName.toLowerCase(); - if (cleanOfficial.includes(cleanUser) || cleanUser.includes(cleanOfficial)) { - candidate.confidence_score = 90; - } - else { - candidate.confidence_score = 60; - } - this.logger.log(`🎯 Verified: Found "${officialName}" near suggestion. Trust: ${candidate.confidence_score}%`); - } - else { - candidate.confidence_score = 10; - this.logger.log(`⚠️ No specific POI name found for coordinates ${candidate.latitude},${candidate.longitude}`); - } - } - candidate.verification_metadata = { - last_check: new Date().toISOString(), - source: 'DDG_SCRAPE' - }; - await this.candidateRepository.save(candidate); - } - catch (error) { - this.logger.error(`Automated verification error: ${error.message}`); - } - } - async getCandidates(status) { - const query = ` - SELECT - c.*, - g.name_ar as governorate_name, - d.name_ar as district_name, - n.name_ar as neighborhood_name - FROM map_candidates c - LEFT JOIN admin_boundaries g ON c.governorate_id = g.id - LEFT JOIN admin_boundaries d ON c.district_id = d.id - LEFT JOIN neighborhood_polygons n ON c.neighborhood_id = n.id - ${status ? 'WHERE c.status = $1' : ''} - ORDER BY c.created_at DESC - `; - return this.candidateRepository.query(query, status ? [status] : []); - } - async approveCandidate(id) { - const candidate = await this.candidateRepository.findOne({ where: { id } }); - if (!candidate) - throw new common_1.NotFoundException('Candidate not found'); - const placeData = { - latitude: candidate.latitude, - longitude: candidate.longitude, - name: candidate.name, - name_ar: candidate.name_ar, - name_en: candidate.name_en, - category: candidate.category, - address: candidate.address, - description: candidate.description, - location: candidate.location, - source: `suggested_by_${candidate.submittedBy}`, - }; - let repo; - switch (candidate.country) { - case map_candidate_entity_1.CountryCode.SYRIA: - repo = this.syriaRepository; - break; - case map_candidate_entity_1.CountryCode.EGYPT: - repo = this.egyptRepository; - break; - case map_candidate_entity_1.CountryCode.IRAQ: - repo = this.iraqRepository; - break; - default: repo = this.jordanRepository; - } - const approvedPlace = repo.create(placeData); - await repo.save(approvedPlace); - candidate.status = map_candidate_entity_1.CandidateStatus.APPROVED; - await this.candidateRepository.save(candidate); - this.logger.log(`✅ Approved candidate ${id}: ${candidate.name} moved to production.`); - return { success: true, place: approvedPlace }; - } - async rejectCandidate(id, reason) { - const candidate = await this.candidateRepository.findOne({ where: { id } }); - if (!candidate) - throw new common_1.NotFoundException('Candidate not found'); - candidate.status = map_candidate_entity_1.CandidateStatus.REJECTED; - candidate.rejectionReason = reason; - return this.candidateRepository.save(candidate); - } -}; -exports.MapRefinementService = MapRefinementService; -exports.MapRefinementService = MapRefinementService = MapRefinementService_1 = __decorate([ - (0, common_1.Injectable)(), - __param(1, (0, typeorm_1.InjectRepository)(map_candidate_entity_1.MapCandidate)), - __param(2, (0, typeorm_1.InjectRepository)(place_jordan_entity_1.PlaceJordan)), - __param(3, (0, typeorm_1.InjectRepository)(place_syria_entity_1.PlaceSyria)), - __param(4, (0, typeorm_1.InjectRepository)(place_egypt_entity_1.PlaceEgypt)), - __param(5, (0, typeorm_1.InjectRepository)(place_iraq_entity_1.PlaceIraq)), - __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.DataSource !== "undefined" && typeorm_2.DataSource) === "function" ? _a : Object, typeof (_b = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _b : Object, typeof (_c = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _c : Object, typeof (_d = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _d : Object, typeof (_e = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _e : Object, typeof (_f = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _f : Object]) -], MapRefinementService); -//# sourceMappingURL=map-refinement.service.js.map \ No newline at end of file diff --git a/apps/api/dist/geocoding/map-refinement.service.js.map b/apps/api/dist/geocoding/map-refinement.service.js.map deleted file mode 100644 index 3a06964..0000000 --- a/apps/api/dist/geocoding/map-refinement.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"map-refinement.service.js","sourceRoot":"","sources":["../../src/geocoding/map-refinement.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAuE;AACvE,6CAAmD;AACnD,qCAAiD;AACjD,0EAA6F;AAC7F,wEAA6D;AAC7D,sEAA2D;AAC3D,sEAA2D;AAC3D,oEAAyD;AAGlD,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAIrB;IAEA;IAEA;IAEA;IAEA;IAEA;IAbO,MAAM,GAAG,IAAI,eAAM,CAAC,sBAAoB,CAAC,IAAI,CAAC,CAAC;IAEhE,YACU,UAAsB,EAEtB,mBAA6C,EAE7C,gBAAyC,EAEzC,eAAuC,EAEvC,eAAuC,EAEvC,cAAqC;QAVrC,eAAU,GAAV,UAAU,CAAY;QAEtB,wBAAmB,GAAnB,mBAAmB,CAA0B;QAE7C,qBAAgB,GAAhB,gBAAgB,CAAyB;QAEzC,oBAAe,GAAf,eAAe,CAAwB;QAEvC,oBAAe,GAAf,eAAe,CAAwB;QAEvC,mBAAc,GAAd,cAAc,CAAuB;IAC5C,CAAC;IAEJ,KAAK,CAAC,YAAY,CAAC,GAAQ,EAAE,WAAmB;QAC9C,MAAM,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,QAAQ,CAAC,CAAC,WAAW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EAAU,EAAE,MAAc;QAC9C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5E,IAAI,CAAC,SAAS;YAAE,MAAM,IAAI,0BAAiB,CAAC,qBAAqB,CAAC,CAAC;QAEnE,SAAS,CAAC,MAAM,GAAG,sCAAe,CAAC,QAAQ,CAAC;QAC5C,SAAS,CAAC,eAAe,GAAG,MAAM,CAAC;QACnC,OAAO,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAqC,CAAC;IACtF,CAAC;CACF,CAAA;AApNY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,0BAAgB,EAAC,mCAAY,CAAC,CAAA;IAE9B,WAAA,IAAA,0BAAgB,EAAC,iCAAW,CAAC,CAAA;IAE7B,WAAA,IAAA,0BAAgB,EAAC,+BAAU,CAAC,CAAA;IAE5B,WAAA,IAAA,0BAAgB,EAAC,+BAAU,CAAC,CAAA;IAE5B,WAAA,IAAA,0BAAgB,EAAC,6BAAS,CAAC,CAAA;yDATR,oBAAU,oBAAV,oBAAU,oDAED,oBAAU,oBAAV,oBAAU,oDAEb,oBAAU,oBAAV,oBAAU,oDAEX,oBAAU,oBAAV,oBAAU,oDAEV,oBAAU,oBAAV,oBAAU,oDAEX,oBAAU,oBAAV,oBAAU;GAdzB,oBAAoB,CAoNhC"} \ No newline at end of file diff --git a/apps/api/dist/main.d.ts b/apps/api/dist/main.d.ts deleted file mode 100644 index cb0ff5c..0000000 --- a/apps/api/dist/main.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/apps/api/dist/main.js b/apps/api/dist/main.js deleted file mode 100644 index f117e82..0000000 --- a/apps/api/dist/main.js +++ /dev/null @@ -1,49 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const core_1 = require("@nestjs/core"); -const common_1 = require("@nestjs/common"); -const swagger_1 = require("@nestjs/swagger"); -const helmet_1 = __importDefault(require("helmet")); -const app_module_1 = require("./app.module"); -async function bootstrap() { - const app = await core_1.NestFactory.create(app_module_1.AppModule, { - logger: ['error', 'warn', 'log', 'debug', 'verbose'], - }); - const httpAdapter = app.getHttpAdapter(); - if (httpAdapter && httpAdapter.getInstance && typeof httpAdapter.getInstance().set === 'function') { - httpAdapter.getInstance().set('trust proxy', 1); - } - app.use((0, helmet_1.default)()); - app.enableCors({ - origin: process.env.ALLOWED_ORIGINS - ? process.env.ALLOWED_ORIGINS.split(',') - : ['http://localhost:3204', 'http://localhost:5173', 'https://map-saas.intaleqapp.com'], - methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS', - credentials: true, - }); - app.setGlobalPrefix('api'); - app.useGlobalPipes(new common_1.ValidationPipe({ - whitelist: true, - forbidNonWhitelisted: true, - transform: true, - })); - const config = new swagger_1.DocumentBuilder() - .setTitle('Jordan Map Platform API') - .setDescription('Backend API for map services, routing, and driver telemetry for Jordan') - .setVersion('1.0') - .addApiKey({ type: 'apiKey', name: 'x-api-key', in: 'header' }, 'x-api-key') - .addTag('maps') - .addTag('geocoding') - .addTag('telemetry') - .build(); - const document = swagger_1.SwaggerModule.createDocument(app, config); - swagger_1.SwaggerModule.setup('docs', app, document); - const port = process.env.API_PORT || 3000; - await app.listen(port); - console.log(`🚀 Jordan Map API is running on: http://localhost:${port}/api`); -} -bootstrap(); -//# sourceMappingURL=main.js.map \ No newline at end of file diff --git a/apps/api/dist/main.js.map b/apps/api/dist/main.js.map deleted file mode 100644 index 18cada9..0000000 --- a/apps/api/dist/main.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;;;AAAA,uCAA2C;AAC3C,2CAAgD;AAChD,6CAAi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AI,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,WAAW,CAAC;SAC3E,MAAM,CAAC,MAAM,CAAC;SACd,MAAM,CAAC,WAAW,CAAC;SACnB,MAAM,CAAC,WAAW,CAAC;SACnB,KAAK,EAAE,CAAC;IAEX,MAAM,QAAQ,GAAG,uBAAa,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC3D,uBAAa,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IAE3C,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,IAAI,CAAC;IAC1C,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,CAAC,GAAG,CAAC,qDAAqD,IAAI,MAAM,CAAC,CAAC;AAC/E,CAAC;AACD,SAAS,EAAE,CAAC"} \ No newline at end of file diff --git a/apps/api/dist/maps/candidate-road.entity.d.ts b/apps/api/dist/maps/candidate-road.entity.d.ts deleted file mode 100644 index e81adbf..0000000 --- a/apps/api/dist/maps/candidate-road.entity.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -export declare class CandidateRoad { - id: string; - geometry: any; - uniqueDriverCount: number; - totalPoints: number; - averageSpeed: number; - lengthMeters: number; - confidence: number; - status: string; - source: string; - name: string; - highway: string; - oneway: number; - discoveredAt: Date; - reviewedAt: Date; -} diff --git a/apps/api/dist/maps/candidate-road.entity.js b/apps/api/dist/maps/candidate-road.entity.js deleted file mode 100644 index 8321d49..0000000 --- a/apps/api/dist/maps/candidate-road.entity.js +++ /dev/null @@ -1,96 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.CandidateRoad = void 0; -const typeorm_1 = require("typeorm"); -let CandidateRoad = class CandidateRoad { - id; - geometry; - uniqueDriverCount; - totalPoints; - averageSpeed; - lengthMeters; - confidence; - status; - source; - name; - highway; - oneway; - discoveredAt; - reviewedAt; -}; -exports.CandidateRoad = CandidateRoad; -__decorate([ - (0, typeorm_1.PrimaryGeneratedColumn)('uuid'), - __metadata("design:type", String) -], CandidateRoad.prototype, "id", void 0); -__decorate([ - (0, typeorm_1.Column)({ - type: 'geography', - spatialFeatureType: 'LineString', - srid: 4326, - nullable: false, - }), - (0, typeorm_1.Index)({ spatial: true }), - __metadata("design:type", Object) -], CandidateRoad.prototype, "geometry", void 0); -__decorate([ - (0, typeorm_1.Column)('int', { default: 0 }), - __metadata("design:type", Number) -], CandidateRoad.prototype, "uniqueDriverCount", void 0); -__decorate([ - (0, typeorm_1.Column)('int', { default: 0 }), - __metadata("design:type", Number) -], CandidateRoad.prototype, "totalPoints", void 0); -__decorate([ - (0, typeorm_1.Column)('float', { default: 0 }), - __metadata("design:type", Number) -], CandidateRoad.prototype, "averageSpeed", void 0); -__decorate([ - (0, typeorm_1.Column)('float', { default: 0 }), - __metadata("design:type", Number) -], CandidateRoad.prototype, "lengthMeters", void 0); -__decorate([ - (0, typeorm_1.Column)('float', { default: 0 }), - __metadata("design:type", Number) -], CandidateRoad.prototype, "confidence", void 0); -__decorate([ - (0, typeorm_1.Column)({ default: 'pending' }), - __metadata("design:type", String) -], CandidateRoad.prototype, "status", void 0); -__decorate([ - (0, typeorm_1.Column)({ default: 'telemetry' }), - __metadata("design:type", String) -], CandidateRoad.prototype, "source", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'varchar', length: 255, nullable: true }), - __metadata("design:type", String) -], CandidateRoad.prototype, "name", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'varchar', length: 32, nullable: true }), - __metadata("design:type", String) -], CandidateRoad.prototype, "highway", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'smallint', default: 0 }), - __metadata("design:type", Number) -], CandidateRoad.prototype, "oneway", void 0); -__decorate([ - (0, typeorm_1.CreateDateColumn)(), - __metadata("design:type", Date) -], CandidateRoad.prototype, "discoveredAt", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'timestamp', nullable: true }), - __metadata("design:type", Date) -], CandidateRoad.prototype, "reviewedAt", void 0); -exports.CandidateRoad = CandidateRoad = __decorate([ - (0, typeorm_1.Entity)('candidate_roads') -], CandidateRoad); -//# sourceMappingURL=candidate-road.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/maps/candidate-road.entity.js.map b/apps/api/dist/maps/candidate-road.entity.js.map deleted file mode 100644 index 623e0f9..0000000 --- a/apps/api/dist/maps/candidate-road.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"candidate-road.entity.js","sourceRoot":"","sources":["../../src/maps/candidate-road.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA0F;AASnF,IAAM,aAAa,GAAnB,MAAM,aAAa;IAExB,EAAE,CAAS;IAWX,QAAQ,CAAM;IAKd,iBAAiB,CAAS;IAK1B,WAAW,CAAS;IAKpB,YAAY,CAAS;IAKrB,YAAY,CAAS;IAKrB,UAAU,CAAS;IAKnB,MAAM,CAAS;IAKf,MAAM,CAAS;IAKf,IAAI,CAAS;IAKb,OAAO,CAAS;IAMhB,MAAM,CAAS;IAGf,YAAY,CAAO;IAGnB,UAAU,CAAO;CAClB,CAAA;AAvEY,sCAAa;AAExB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;yCACpB;AAWX;IAPC,IAAA,gBAAM,EAAC;QACN,IAA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EAAE,CAAC;8BAClC,IAAI;iDAAC;wBAtEN,aAAa;IADzB,IAAA,gBAAM,EAAC,iBAAiB,CAAC;GACb,aAAa,CAuEzB"} \ No newline at end of file diff --git a/apps/api/dist/maps/maps.controller.d.ts b/apps/api/dist/maps/maps.controller.d.ts deleted file mode 100644 index d1af3e8..0000000 --- a/apps/api/dist/maps/maps.controller.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -import type { Response } from 'express'; -import { MapsService } from './maps.service'; -export declare class MapsController { - private readonly mapsService; - constructor(mapsService: MapsService); - syncRoutes(): Promise<{ - success: boolean; - message: string; - }>; - getStyleJson(theme: string, res: Response): Promise<any>; - getRoute(query: any): Promise<{ - routeName: any; - tags: any; - distance: any; - duration: any; - trafficFactor: number; - startName: string; - endName: string; - points: any; - bbox: any; - instructions: any; - elevationSummary: any; - alternatives: any; - }>; - getConfig(): Promise<{ - center: number[]; - zoom: number; - tileServerUrl: any; - }>; -} diff --git a/apps/api/dist/maps/maps.controller.js b/apps/api/dist/maps/maps.controller.js deleted file mode 100644 index 06ae00b..0000000 --- a/apps/api/dist/maps/maps.controller.js +++ /dev/null @@ -1,179 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __importStar = (this && this.__importStar) || (function () { - var ownKeys = function(o) { - ownKeys = Object.getOwnPropertyNames || function (o) { - var ar = []; - for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; - return ar; - }; - return ownKeys(o); - }; - return function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); - __setModuleDefault(result, mod); - return result; - }; -})(); -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.MapsController = void 0; -const common_1 = require("@nestjs/common"); -const swagger_1 = require("@nestjs/swagger"); -const fs = __importStar(require("fs")); -const path = __importStar(require("path")); -const maps_service_1 = require("./maps.service"); -const api_key_guard_1 = require("../common/guards/api-key.guard"); -let MapsController = class MapsController { - mapsService; - constructor(mapsService) { - this.mapsService = mapsService; - } - async syncRoutes() { - return this.mapsService.requestRoutingSync(); - } - async getStyleJson(theme, res) { - const isDark = theme === 'obsidian'; - const filename = isDark ? 'style-dark.json' : 'style.json'; - const fallbackFilename = 'style.json'; - const pathsToCheck = [ - path.join('/data', filename), - path.join(process.cwd(), '../../', filename), - path.join(process.cwd(), filename), - path.join('/data', fallbackFilename), - path.join(process.cwd(), '../../', fallbackFilename), - path.join(process.cwd(), fallbackFilename), - ]; - let stylePath = ''; - for (const p of pathsToCheck) { - if (fs.existsSync(p)) { - stylePath = p; - break; - } - } - if (!stylePath) { - return res.status(404).send('Style not found'); - } - try { - const styleRaw = fs.readFileSync(stylePath, 'utf8'); - const styleObj = JSON.parse(styleRaw); - if (theme === 'light') { - styleObj.layers.forEach((layer) => { - if (layer.id === 'background') { - layer.paint['background-color'] = '#FFFFFF'; - } - }); - } - else if (theme === 'obsidian') { - styleObj.layers.forEach((layer) => { - if (layer.id === 'background') { - layer.paint['background-color'] = '#101014'; - } - }); - } - res.setHeader('Content-Type', 'application/json'); - res.send(styleObj); - } - catch (e) { - res.status(500).send('Error parsing style.json'); - } - } - async getRoute(query) { - const waypoints = []; - if (query.fromLat && query.fromLng) { - waypoints.push([parseFloat(query.fromLat), parseFloat(query.fromLng)]); - } - const stopKeys = Object.keys(query) - .filter(key => key.startsWith('stop') && key.endsWith('Lat')) - .sort((a, b) => { - const numA = parseInt(a.replace('stop', '').replace('Lat', ''), 10); - const numB = parseInt(b.replace('stop', '').replace('Lat', ''), 10); - return numA - numB; - }); - for (const latKey of stopKeys) { - const prefix = latKey.replace('Lat', ''); - const lngKey = `${prefix}Lng`; - if (query[latKey] && query[lngKey]) { - waypoints.push([parseFloat(query[latKey]), parseFloat(query[lngKey])]); - } - } - if (query.toLat && query.toLng) { - waypoints.push([parseFloat(query.toLat), parseFloat(query.toLng)]); - } - const profile = query.profile || 'car'; - const steps = query.steps === 'true'; - const locale = query.locale || 'en'; - const alternatives = query.alternatives === 'true'; - return this.mapsService.getRoute(waypoints, profile, steps, locale, alternatives); - } - async getConfig() { - return this.mapsService.getMapConfig(); - } -}; -exports.MapsController = MapsController; -__decorate([ - (0, common_1.Post)('sync-routes'), - (0, swagger_1.ApiOperation)({ summary: 'Request GraphHopper routing sync 🔄' }), - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", Promise) -], MapsController.prototype, "syncRoutes", null); -__decorate([ - (0, common_1.Get)('style.json'), - (0, swagger_1.ApiOperation)({ summary: 'Get MapLibre style JSON 🎨' }), - __param(0, (0, common_1.Query)('theme')), - __param(1, (0, common_1.Res)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [String, Object]), - __metadata("design:returntype", Promise) -], MapsController.prototype, "getStyleJson", null); -__decorate([ - (0, common_1.Get)('route'), - (0, swagger_1.ApiOperation)({ summary: 'Calculate a route with dynamic waypoints 🚗' }), - __param(0, (0, common_1.Query)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object]), - __metadata("design:returntype", Promise) -], MapsController.prototype, "getRoute", null); -__decorate([ - (0, common_1.Get)('config'), - (0, swagger_1.ApiOperation)({ summary: 'Get map configuration for the region 🗺️' }), - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", Promise) -], MapsController.prototype, "getConfig", null); -exports.MapsController = MapsController = __decorate([ - (0, swagger_1.ApiTags)('maps'), - (0, common_1.Controller)('maps'), - (0, common_1.UseGuards)(api_key_guard_1.ApiKeyGuard), - __metadata("design:paramtypes", [maps_service_1.MapsService]) -], MapsController); -//# sourceMappingURL=maps.controller.js.map \ No newline at end of file diff --git a/apps/api/dist/maps/maps.controller.js.map b/apps/api/dist/maps/maps.controller.js.map deleted file mode 100644 index 611559d..0000000 --- a/apps/api/dist/maps/maps.controller.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"maps.controller.js","sourceRoot":"","sources":["../../src/maps/maps.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA8E;AAC9E,6CAAwD;AAExD,uCAAyB;AACzB,2CAA6B;AAC7B,iDAA6C;AAC7C,kEAA6D;AAKtD,IAAM,cAAc,GAApB,MAAM,cAAc;IACI;IAA7B,YAA6B,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAI,CAAC;IAIpD,AAAN,KAAK,CAAC,UAAU;QACd,OAAO,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAAE,CAAC;IAC/C,CAAC;IAIK,AAAN,KAAK,CAAC,YAAY,CAAiB,KAAa,EAAS,GAAa;QAE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AM,YAAY,GAAG,KAAK,CAAC,YAAY,KAAK,MAAM,CAAC;QAEnD,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IACpF,CAAC;IAIK,AAAN,KAAK,CAAC,SAAS;QACb,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC;IACzC,CAAC;CACF,CAAA;AAlHY,wCAAc;AAKnB;IAFL,IAAA,aAAI,EAAC,aAAa,CAAC;IACnB,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,qCAAqC,EAAE,CAAC;;;;gDAGhE;AAIK;IAFL,IAAA,YAAG,EAAC,YAAY,CAAC;IACjB,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC;IACpC,WAAA,IAAA,cAAK,EAAC,OAAO,CAAC,CAAA;IAAiB,WAAA,IAAA,YAAG,GAAE,CAAA;;;;kDAuDvD;AAIK;IAFL,IAAA,YAAG,EAAC,OAAO,CAAC;IACZ,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,6CAA6C,EAAE,CAAC;IACzD,WAAA,IAAA,cAAK,GAAE,CAAA;;;;8CAqCtB;AAIK;IAFL,IAAA,YAAG,EAAC,QAAQ,CAAC;IACb,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,0CAA0C,EAAE,CAAC;;;;+CAGrE;yBAjHU,cAAc;IAH1B,IAAA,iBAAO,EAAC,MAAM,CAAC;IACf,IAAA,mBAAU,EAAC,MAAM,CAAC;IAClB,IAAA,kBAAS,EAAC,2BAAW,CAAC;qCAEqB,0BAAW;GAD1C,cAAc,CAkH1B"} \ No newline at end of file diff --git a/apps/api/dist/maps/maps.module.d.ts b/apps/api/dist/maps/maps.module.d.ts deleted file mode 100644 index 325c46b..0000000 --- a/apps/api/dist/maps/maps.module.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare class MapsModule { -} diff --git a/apps/api/dist/maps/maps.module.js b/apps/api/dist/maps/maps.module.js deleted file mode 100644 index f313a42..0000000 --- a/apps/api/dist/maps/maps.module.js +++ /dev/null @@ -1,35 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.MapsModule = void 0; -const common_1 = require("@nestjs/common"); -const typeorm_1 = require("@nestjs/typeorm"); -const maps_service_1 = require("./maps.service"); -const traffic_grid_service_1 = require("./traffic-grid.service"); -const maps_controller_1 = require("./maps.controller"); -const road_stat_entity_1 = require("./road-stat.entity"); -const candidate_road_entity_1 = require("./candidate-road.entity"); -const redis_module_1 = require("../common/redis.module"); -const geocoding_module_1 = require("../geocoding/geocoding.module"); -const road_refinement_controller_1 = require("./road-refinement.controller"); -let MapsModule = class MapsModule { -}; -exports.MapsModule = MapsModule; -exports.MapsModule = MapsModule = __decorate([ - (0, common_1.Module)({ - imports: [ - typeorm_1.TypeOrmModule.forFeature([road_stat_entity_1.RoadSegmentStat, candidate_road_entity_1.CandidateRoad]), - redis_module_1.RedisModule, - geocoding_module_1.GeocodingModule, - ], - controllers: [maps_controller_1.MapsController, road_refinement_controller_1.RoadRefinementController], - providers: [maps_service_1.MapsService, traffic_grid_service_1.TrafficGridService], - exports: [maps_service_1.MapsService, traffic_grid_service_1.TrafficGridService], - }) -], MapsModule); -//# sourceMappingURL=maps.module.js.map \ No newline at end of file diff --git a/apps/api/dist/maps/maps.module.js.map b/apps/api/dist/maps/maps.module.js.map deleted file mode 100644 index c55300a..0000000 --- a/apps/api/dist/maps/maps.module.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"maps.module.js","sourceRoot":"","sources":["../../src/maps/maps.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,iDAA6C;AAC7C,iEAA4D;AAC5D,uDAAmD;AACnD,yDAAqD;AACrD,mEAAwD;AACxD,yDAAqD;AACrD,oEAAgE;AAEhE,6EAAwE;AAYjE,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,gCAAU;qBAAV,UAAU;IAVtB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,UAAU,CAAC,CAAC,kCAAe,EAAE,qCAAa,CAAC,CAAC;YAC1D,0BAAW;YACX,kCAAe;SAChB;QACD,WAAW,EAAE,CAAC,gCAAc,EAAE,qDAAwB,CAAC;QACvD,SAAS,EAAE,CAAC,0BAAW,EAAE,yCAAkB,CAAC;QAC5C,OAAO,EAAE,CAAC,0BAAW,EAAE,yCAAkB,CAAC;KAC3C,CAAC;GACW,UAAU,CAAG"} \ No newline at end of file diff --git a/apps/api/dist/maps/maps.service.d.ts b/apps/api/dist/maps/maps.service.d.ts deleted file mode 100644 index 300e66d..0000000 --- a/apps/api/dist/maps/maps.service.d.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { ConfigService } from '@nestjs/config'; -import { Repository, DataSource } from 'typeorm'; -import { RoadSegmentStat } from './road-stat.entity'; -import { TrafficGridService } from './traffic-grid.service'; -import { GeocodingService } from '../geocoding/geocoding.service'; -import { RedisService } from '../common/redis.service'; -export declare class MapsService { - private configService; - private roadStatRepo; - private trafficGrid; - private geocodingService; - private dataSource; - private redisService; - private readonly graphHopperUrl; - constructor(configService: ConfigService, roadStatRepo: Repository<RoadSegmentStat>, trafficGrid: TrafficGridService, geocodingService: GeocodingService, dataSource: DataSource, redisService: RedisService); - requestRoutingSync(): Promise<{ - success: boolean; - message: string; - }>; - getRoute(waypoints: [number, number][], profile?: string, steps?: boolean, locale?: string, alternatives?: boolean): Promise<{ - routeName: any; - tags: any; - distance: any; - duration: any; - trafficFactor: number; - startName: string; - endName: string; - points: any; - bbox: any; - instructions: any; - elevationSummary: any; - alternatives: any; - }>; - private enrichInstructionsWithSlopeAnalysis; - private estimateElevation; - private haversineDistance; - private getRouteName; - private decodePolyline; - getMapConfig(): Promise<{ - center: number[]; - zoom: number; - tileServerUrl: any; - }>; -} diff --git a/apps/api/dist/maps/maps.service.js b/apps/api/dist/maps/maps.service.js deleted file mode 100644 index 97288cb..0000000 --- a/apps/api/dist/maps/maps.service.js +++ /dev/null @@ -1,353 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -var _a, _b, _c; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.MapsService = void 0; -const common_1 = require("@nestjs/common"); -const config_1 = require("@nestjs/config"); -const typeorm_1 = require("@nestjs/typeorm"); -const typeorm_2 = require("typeorm"); -const axios_1 = __importDefault(require("axios")); -const road_stat_entity_1 = require("./road-stat.entity"); -const traffic_grid_service_1 = require("./traffic-grid.service"); -const geocoding_service_1 = require("../geocoding/geocoding.service"); -const redis_service_1 = require("../common/redis.service"); -let MapsService = class MapsService { - configService; - roadStatRepo; - trafficGrid; - geocodingService; - dataSource; - redisService; - graphHopperUrl; - constructor(configService, roadStatRepo, trafficGrid, geocodingService, dataSource, redisService) { - this.configService = configService; - this.roadStatRepo = roadStatRepo; - this.trafficGrid = trafficGrid; - this.geocodingService = geocodingService; - this.dataSource = dataSource; - this.redisService = redisService; - this.graphHopperUrl = this.configService.get('GRAPH_HOPPER_URL', 'http://routing:8080'); - } - async requestRoutingSync() { - await this.redisService.set('routing_sync_requested', '1'); - return { success: true, message: 'Routing sync requested and scheduled for the next minute.' }; - } - async getRoute(waypoints, profile = 'car', steps = false, locale = 'en', alternatives = false) { - if (waypoints.length < 2) { - throw new common_1.HttpException('At least two waypoints are required', common_1.HttpStatus.BAD_REQUEST); - } - try { - const ghPoints = waypoints.map(wp => [wp[1], wp[0]]); - let startName = 'Unknown Location'; - let endName = 'Unknown Location'; - try { - const startWp = waypoints[0]; - const endWp = waypoints[waypoints.length - 1]; - const [startRes, endRes] = await Promise.all([ - this.geocodingService.reverseGeocode(startWp[0], startWp[1]), - this.geocodingService.reverseGeocode(endWp[0], endWp[1]) - ]); - const formatName = (r) => { - const parts = [r.name_ar || r.name, r.neighbourhood, r.district, r.governorate].filter(Boolean); - const uniqueParts = [...new Set(parts)]; - return uniqueParts.length > 0 ? uniqueParts.join('، ') : 'Unknown Location'; - }; - if (startRes && startRes.length > 0) - startName = formatName(startRes[0]); - if (endRes && endRes.length > 0) - endName = formatName(endRes[0]); - } - catch (e) { - console.warn('Geocoding internal error during routing:', e); - } - const payload = { - points: ghPoints, - profile: profile, - locale: locale === 'en' ? 'ar' : locale, - calc_points: true, - points_encoded: true, - instructions: steps || true, - }; - let closureCount = 0; - try { - const closedSegments = await this.dataSource.query(` - SELECT ST_AsGeoJSON( - ST_Transform(ST_Buffer(ST_Transform(geometry::geometry, 3857), 15), 4326), 6 - ) AS geojson - FROM road_segment_stats - WHERE "isClosed" = true AND geometry IS NOT NULL - LIMIT 50 - `); - const features = closedSegments - .map((s, i) => { - try { - return { type: 'Feature', id: `closed_${i}`, geometry: JSON.parse(s.geojson), properties: {} }; - } - catch { - return null; - } - }) - .filter(Boolean); - if (features.length > 0) { - payload['custom_model'] = { - priority: features.map((f) => ({ if: `in_${f.id}`, multiply_by: '0' })), - areas: { type: 'FeatureCollection', features }, - }; - payload['ch.disable'] = true; - closureCount = features.length; - console.log(`🚧 Routing: avoiding ${closureCount} closed segment(s).`); - } - } - catch (closureError) { - console.warn('⚠️ Could not load road closures for routing:', closureError.message); - } - if (alternatives && waypoints.length === 2) { - payload.algorithm = 'alternative_route'; - payload['ch.disable'] = true; - payload['alternative_route.max_paths'] = 2; - payload['alternative_route.max_weight_factor'] = 1.6; - payload['alternative_route.max_share_factor'] = 0.6; - } - console.log(`Routing Request: ${waypoints.length} points via ${profile} on ${this.graphHopperUrl} | Steps: ${steps} | Locale: ${locale}`); - let response; - try { - response = await axios_1.default.post(`${this.graphHopperUrl}/route`, payload, { timeout: 10000 }); - } - catch (routeErr) { - if (closureCount > 0 && payload['custom_model']) { - const detail = routeErr.response ? JSON.stringify(routeErr.response.data) : routeErr.message; - console.warn(`⚠️ Closure-aware routing failed (${detail}). Retrying without closures...`); - delete payload['custom_model']; - if (!(alternatives && waypoints.length === 2)) - delete payload['ch.disable']; - response = await axios_1.default.post(`${this.graphHopperUrl}/route`, payload, { timeout: 10000 }); - } - else { - throw routeErr; - } - } - console.log('Routing SUCCESS'); - const paths = response.data.paths; - if (!paths || paths.length === 0) - throw new common_1.HttpException('No route found', common_1.HttpStatus.NOT_FOUND); - const route = paths[0]; - const now = new Date(); - const hr = now.getHours(); - const dow = now.getDay(); - const coords = this.decodePolyline(route.points); - const trafficFactor = this.trafficGrid.getTrafficFactor(coords, hr, dow); - const baseDuration = route.time / 1000; - const trafficAwareDuration = baseDuration * trafficFactor; - const processedPaths = paths.map((p, index) => { - const pCoords = this.decodePolyline(p.points); - const pTrafficFactor = this.trafficGrid.getTrafficFactor(pCoords, hr, dow); - const pDuration = Math.round((p.time / 1000) * pTrafficFactor); - const routeName = this.getRouteName(p.instructions); - const { enrichedInstructions, slopeSummary } = this.enrichInstructionsWithSlopeAnalysis(p.instructions, pCoords); - const tags = []; - if (index === 0) - tags.push('FASTEST'); - if (paths.length > 1) { - const isShortest = paths.every((other) => p.distance <= other.distance); - if (isShortest) - tags.push('SHORTEST'); - if (index > 0 && !isShortest) - tags.push('ALTERNATIVE'); - } - return { - routeName: routeName ? `عبر ${routeName}` : `المسار ${index + 1}`, - tags, - distance: p.distance, - duration: pDuration, - points: p.points, - bbox: p.bbox, - instructions: steps ? enrichedInstructions : undefined, - elevationSummary: slopeSummary - }; - }); - const mainRoute = processedPaths[0]; - const altRoutes = processedPaths.slice(1); - return { - routeName: mainRoute.routeName, - tags: mainRoute.tags, - distance: mainRoute.distance, - duration: mainRoute.duration, - trafficFactor: Math.round(trafficFactor * 100) / 100, - startName, - endName, - points: mainRoute.points, - bbox: mainRoute.bbox, - instructions: mainRoute.instructions, - elevationSummary: mainRoute.elevationSummary, - alternatives: altRoutes - }; - } - catch (error) { - const msg = error.response ? `GH Error: ${JSON.stringify(error.response.data)}` : `DNS/Connection Error: ${error.message}`; - console.error('CRITICAL ROUTING FAILURE:', msg); - throw new common_1.HttpException(`Routing Failure: ${msg}`, common_1.HttpStatus.BAD_GATEWAY); - } - } - enrichInstructionsWithSlopeAnalysis(instructions, coords) { - if (!instructions || !coords || coords.length < 2) { - return { - enrichedInstructions: instructions, - slopeSummary: { totalAscentMeters: 0, totalDescentMeters: 0, maxInclinePercent: 0, maxDeclinePercent: 0, steepWarningsCount: 0, steepWarnings: [] } - }; - } - let totalAscent = 0; - let totalDescent = 0; - let maxInclinePercent = 0; - let maxDeclinePercent = 0; - const steepWarnings = []; - const enrichedInstructions = instructions.map((inst) => { - const interval = inst.interval || [0, 0]; - const startIdx = Math.min(interval[0], coords.length - 1); - const endIdx = Math.min(interval[1], coords.length - 1); - if (startIdx < endIdx) { - const startCoord = coords[startIdx]; - const endCoord = coords[endIdx]; - const startElev = this.estimateElevation(startCoord[1], startCoord[0]); - const endElev = this.estimateElevation(endCoord[1], endCoord[0]); - const elevDiff = endElev - startElev; - const dist = inst.distance || this.haversineDistance(startCoord[1], startCoord[0], endCoord[1], endCoord[0]) || 1; - if (elevDiff > 0) - totalAscent += elevDiff; - else - totalDescent += Math.abs(elevDiff); - const slopePercent = Math.round((elevDiff / Math.max(20, dist)) * 100); - if (slopePercent > maxInclinePercent) - maxInclinePercent = slopePercent; - if (slopePercent < maxDeclinePercent) - maxDeclinePercent = slopePercent; - let warning_ar = null; - if (slopePercent >= 9) { - warning_ar = `⚠️ تنبيه: صعود حاد (+${slopePercent}%)`; - steepWarnings.push({ text: inst.text, slopePercent, type: 'incline', street: inst.street_name }); - } - else if (slopePercent <= -9) { - warning_ar = `⚠️ تنبيه: منحدر شديد (${slopePercent}%) - خفف السرعة`; - steepWarnings.push({ text: inst.text, slopePercent, type: 'decline', street: inst.street_name }); - } - return { - ...inst, - slopePercent, - elevationChangeMeters: Math.round(elevDiff), - slopeWarning: warning_ar || undefined, - text: warning_ar ? `${inst.text} (${warning_ar})` : inst.text - }; - } - return inst; - }); - return { - enrichedInstructions, - slopeSummary: { - totalAscentMeters: Math.round(totalAscent), - totalDescentMeters: Math.round(totalDescent), - maxInclinePercent: Math.round(maxInclinePercent), - maxDeclinePercent: Math.round(maxDeclinePercent), - steepWarningsCount: steepWarnings.length, - steepWarnings - } - }; - } - estimateElevation(lat, lng) { - if (lng < 35.6 && lat < 32.2 && lat > 31.0) { - return -400 + Math.abs(lng - 35.5) * 3000; - } - if (lat >= 32.1 && lng < 36.0) { - return 850 + Math.sin(lat * 50) * 250 + Math.cos(lng * 40) * 150; - } - if (lat >= 31.8 && lat < 32.1 && lng >= 35.8 && lng < 36.2) { - return 900 + Math.sin((lat - 31.95) * 100) * 120 + Math.cos((lng - 35.9) * 100) * 100; - } - if (lat < 31.5 && lat > 30.0 && lng < 35.7) { - return 1100 + Math.sin(lat * 30) * 350; - } - return 650 + (lng - 36.0) * 30; - } - haversineDistance(lat1, lon1, lat2, lon2) { - const R = 6371000; - const dLat = (lat2 - lat1) * (Math.PI / 180); - const dLon = (lon2 - lon1) * (Math.PI / 180); - const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + - Math.cos(lat1 * (Math.PI / 180)) * Math.cos(lat2 * (Math.PI / 180)) * - Math.sin(dLon / 2) * Math.sin(dLon / 2); - return R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); - } - getRouteName(instructions) { - if (!instructions || instructions.length === 0) - return null; - const streetDistances = {}; - for (const inst of instructions) { - if (inst.street_name && inst.street_name.trim() !== '') { - streetDistances[inst.street_name] = (streetDistances[inst.street_name] || 0) + (inst.distance || 0); - } - } - let longestStreet = null; - let maxDist = 0; - for (const [street, dist] of Object.entries(streetDistances)) { - if (dist > maxDist) { - maxDist = dist; - longestStreet = street; - } - } - return longestStreet; - } - decodePolyline(encoded) { - const points = []; - let index = 0, len = encoded.length; - let lat = 0, lng = 0; - while (index < len) { - let b, shift = 0, result = 0; - do { - b = encoded.charCodeAt(index++) - 63; - result |= (b & 0x1f) << shift; - shift += 5; - } while (b >= 0x20); - let dlat = ((result & 1) ? ~(result >> 1) : (result >> 1)); - lat += dlat; - shift = 0; - result = 0; - do { - b = encoded.charCodeAt(index++) - 63; - result |= (b & 0x1f) << shift; - shift += 5; - } while (b >= 0x20); - let dlng = ((result & 1) ? ~(result >> 1) : (result >> 1)); - lng += dlng; - points.push([lng * 1e-5, lat * 1e-5]); - } - return points; - } - async getMapConfig() { - return { - center: [31.95, 35.91], - zoom: 12, - tileServerUrl: this.configService.get('TILE_SERVER_URL', 'http://localhost:3001'), - }; - } -}; -exports.MapsService = MapsService; -exports.MapsService = MapsService = __decorate([ - (0, common_1.Injectable)(), - __param(1, (0, typeorm_1.InjectRepository)(road_stat_entity_1.RoadSegmentStat)), - __metadata("design:paramtypes", [typeof (_a = typeof config_1.ConfigService !== "undefined" && config_1.ConfigService) === "function" ? _a : Object, typeof (_b = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _b : Object, traffic_grid_service_1.TrafficGridService, - geocoding_service_1.GeocodingService, typeof (_c = typeof typeorm_2.DataSource !== "undefined" && typeorm_2.DataSource) === "function" ? _c : Object, redis_service_1.RedisService]) -], MapsService); -//# sourceMappingURL=maps.service.js.map \ No newline at end of file diff --git a/apps/api/dist/maps/maps.service.js.map b/apps/api/dist/maps/maps.service.js.map deleted file mode 100644 index efed43d..0000000 --- a/apps/api/dist/maps/maps.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"maps.service.js","sourceRoot":"","sources":["../../src/maps/maps.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,2CAAuE;AACvE,2CAA+C;AAC/C,6CAAmD;AACnD,qCAAiD;AAEjD,kDAA0B;AAC1B,yDAAqD;AACrD,iEAA4D;AAC5D,sEAAkE;AAClE,2DAAuD;AAGhD,IAAM,WAAW,GAAjB,MAAM,WAAW;IAIZ;IAEA;IACA;IACA;IACA;IACA;IATO,cAAc,CAAS;IAExC,YACU,aAA4B,EAE5B,YAAyC,EACzC,WAA+B,EAC/B,gBAAkC,EAClC,UAAsB,EACtB,YAA0B;QAN1B,kBAAa,GAAb,aAAa,CAAe;QAE5B,iBAAY,GAAZ,YAAY,CAA6B;QACzC,gBAAW,GAAX,WAAW,CAAoB;QAC/B,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,eAAU,GAAV,UAAU,CAAY;QACtB,iBAAY,GAAZ,YAAY,CAAc;QAElC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,CAAC;IAC1F,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC;QAC3D,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newline at end of file diff --git a/apps/api/dist/maps/road-refinement.controller.d.ts b/apps/api/dist/maps/road-refinement.controller.d.ts deleted file mode 100644 index 5581214..0000000 --- a/apps/api/dist/maps/road-refinement.controller.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { Repository, DataSource } from 'typeorm'; -import { CandidateRoad } from './candidate-road.entity'; -import { RoadSegmentStat } from './road-stat.entity'; -export declare class RoadRefinementController { - private readonly candidateRepo; - private readonly roadStatRepo; - private readonly dataSource; - private readonly logger; - constructor(candidateRepo: Repository<CandidateRoad>, roadStatRepo: Repository<RoadSegmentStat>, dataSource: DataSource); - getSummary(): Promise<{ - roads: { - analyzed: number; - closed: number; - }; - candidates: { - total: number; - pending: number; - }; - }>; - getCandidates(status?: string): Promise<any>; - submitManualCandidate(body: { - geojson: any; - name?: string; - highway?: string; - }): Promise<{ - success: boolean; - candidate: any; - }>; - approveCandidate(id: string): Promise<{ - success: boolean; - id: string; - status: string; - }>; - rejectCandidate(id: string): Promise<{ - success: boolean; - id: string; - status: string; - }>; - getClosures(): Promise<any>; - discoverOvertureGaps(): Promise<{ - success: boolean; - candidatesFound: number; - message: string; - } | { - success: boolean; - candidatesFound: any; - message?: undefined; - }>; - discoverClosures(): Promise<{ - success: boolean; - roadsClosed: number; - }>; - snapExistingApprovedRoads(): Promise<{ - success: boolean; - message: string; - }>; -} diff --git a/apps/api/dist/maps/road-refinement.controller.js b/apps/api/dist/maps/road-refinement.controller.js deleted file mode 100644 index 81fc309..0000000 --- a/apps/api/dist/maps/road-refinement.controller.js +++ /dev/null @@ -1,613 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -var RoadRefinementController_1; -var _a, _b, _c; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.RoadRefinementController = void 0; -const common_1 = require("@nestjs/common"); -const swagger_1 = require("@nestjs/swagger"); -const typeorm_1 = require("@nestjs/typeorm"); -const typeorm_2 = require("typeorm"); -const candidate_road_entity_1 = require("./candidate-road.entity"); -const road_stat_entity_1 = require("./road-stat.entity"); -const api_key_guard_1 = require("../common/guards/api-key.guard"); -let RoadRefinementController = RoadRefinementController_1 = class RoadRefinementController { - candidateRepo; - roadStatRepo; - dataSource; - logger = new common_1.Logger(RoadRefinementController_1.name); - constructor(candidateRepo, roadStatRepo, dataSource) { - this.candidateRepo = candidateRepo; - this.roadStatRepo = roadStatRepo; - this.dataSource = dataSource; - } - async getSummary() { - try { - const [cCount] = await this.dataSource.query("SELECT COUNT(*) as total, COUNT(*) FILTER (WHERE status='pending') as pending FROM candidate_roads"); - const [clCount] = await this.dataSource.query('SELECT COUNT(*) as count FROM road_segment_stats WHERE "isClosed" = true'); - const [rCount] = await this.dataSource.query('SELECT COUNT(*) as count FROM road_segment_stats'); - return { - roads: { - analyzed: parseInt(rCount?.count || '0', 10), - closed: parseInt(clCount?.count || '0', 10), - }, - candidates: { - total: parseInt(cCount?.total || '0', 10), - pending: parseInt(cCount?.pending || '0', 10), - }, - }; - } - catch (e) { - this.logger.error(`Error in summary: ${e.message}`); - return { - roads: { analyzed: 0, closed: 0 }, - candidates: { total: 0, pending: 0 }, - }; - } - } - async getCandidates(status) { - const s = status || 'pending'; - try { - const rows = await this.dataSource.query(`SELECT id, "uniqueDriverCount", "totalPoints", "averageSpeed", "lengthMeters", - confidence, status, source, name, highway, oneway, "discoveredAt", "reviewedAt", - ST_AsGeoJSON(geometry) as geojson - FROM candidate_roads - WHERE status = $1 - ORDER BY confidence DESC, "discoveredAt" DESC - LIMIT 100`, [s]); - return rows.map((r) => ({ - ...r, - geometry: r.geojson ? JSON.parse(r.geojson) : null, - })); - } - catch (e) { - this.logger.error(`Error fetching candidates: ${e.message}`); - return []; - } - } - async submitManualCandidate(body) { - if (!body.geojson || !body.geojson.coordinates || body.geojson.coordinates.length < 2) { - throw new common_1.HttpException('Invalid GeoJSON LineString coordinates', common_1.HttpStatus.BAD_REQUEST); - } - try { - const geojsonStr = JSON.stringify(body.geojson); - const name = body.name || 'Unnamed Road'; - const highway = body.highway || 'residential'; - let result; - try { - result = await this.dataSource.query(`WITH raw_input AS ( - SELECT ST_SetSRID(ST_GeomFromGeoJSON($1), 4326) AS geom - ), - start_snap AS ( - SELECT COALESCE( - ( - SELECT ST_SetSRID(ST_MakePoint(n.lon/1e7, n.lat/1e7), 4326) - FROM raw_input r - CROSS JOIN LATERAL (SELECT ST_Transform(ST_StartPoint(r.geom), 3857) AS pt) p - JOIN planet_osm_line l ON l.highway IS NOT NULL AND l.way && ST_Expand(p.pt, 60) - JOIN planet_osm_ways w ON w.id = l.osm_id - CROSS JOIN LATERAL unnest(w.nodes) AS wn(node_id) - JOIN planet_osm_nodes n ON n.id = wn.node_id - WHERE ST_Distance(ST_SetSRID(ST_MakePoint(n.lon/1e7, n.lat/1e7), 4326)::geography, ST_StartPoint(r.geom)::geography) < 30 - ORDER BY ST_Distance(ST_SetSRID(ST_MakePoint(n.lon/1e7, n.lat/1e7), 4326)::geography, ST_StartPoint(r.geom)::geography) ASC - LIMIT 1 - ), - ( - SELECT ST_Transform(ST_ClosestPoint(l.way, ST_Transform(ST_StartPoint(r.geom), 3857)), 4326) - FROM raw_input r - JOIN planet_osm_line l ON l.highway IS NOT NULL AND l.way && ST_Expand(ST_Transform(ST_StartPoint(r.geom), 3857), 60) - WHERE ST_Distance(ST_Transform(l.way, 4326)::geography, ST_StartPoint(r.geom)::geography) < 30 - ORDER BY ST_Distance(l.way, ST_Transform(ST_StartPoint(r.geom), 3857)) ASC - LIMIT 1 - ), - (SELECT ST_StartPoint(geom) FROM raw_input) - ) AS pt - ), - end_snap AS ( - SELECT COALESCE( - ( - SELECT ST_SetSRID(ST_MakePoint(n.lon/1e7, n.lat/1e7), 4326) - FROM raw_input r - CROSS JOIN LATERAL (SELECT ST_Transform(ST_EndPoint(r.geom), 3857) AS pt) p - JOIN planet_osm_line l ON l.highway IS NOT NULL AND l.way && ST_Expand(p.pt, 60) - JOIN planet_osm_ways w ON w.id = l.osm_id - CROSS JOIN LATERAL unnest(w.nodes) AS wn(node_id) - JOIN planet_osm_nodes n ON n.id = wn.node_id - WHERE ST_Distance(ST_SetSRID(ST_MakePoint(n.lon/1e7, n.lat/1e7), 4326)::geography, ST_EndPoint(r.geom)::geography) < 30 - ORDER BY ST_Distance(ST_SetSRID(ST_MakePoint(n.lon/1e7, n.lat/1e7), 4326)::geography, ST_EndPoint(r.geom)::geography) ASC - LIMIT 1 - ), - ( - SELECT ST_Transform(ST_ClosestPoint(l.way, ST_Transform(ST_EndPoint(r.geom), 3857)), 4326) - FROM raw_input r - JOIN planet_osm_line l ON l.highway IS NOT NULL AND l.way && ST_Expand(ST_Transform(ST_EndPoint(r.geom), 3857), 60) - WHERE ST_Distance(ST_Transform(l.way, 4326)::geography, ST_EndPoint(r.geom)::geography) < 30 - ORDER BY ST_Distance(l.way, ST_Transform(ST_EndPoint(r.geom), 3857)) ASC - LIMIT 1 - ), - (SELECT ST_EndPoint(geom) FROM raw_input) - ) AS pt - ), - snapped_input AS ( - SELECT ST_SetPoint( - ST_SetPoint(r.geom, 0, s.pt), - ST_NPoints(r.geom) - 1, - e.pt - ) AS geom - FROM raw_input r, start_snap s, end_snap e - ) - INSERT INTO candidate_roads ( - geometry, "uniqueDriverCount", "totalPoints", "averageSpeed", "lengthMeters", - confidence, status, source, name, highway, oneway, "discoveredAt" - ) - SELECT - geom, - 1, 10, 30.0, - ST_Length(ST_Transform(geom, 3857)), - 0.90, 'pending', 'manual', $2, $3, 0, NOW() - FROM snapped_input - RETURNING id, name, highway, confidence, status`, [geojsonStr, name, highway]); - } - catch (err) { - this.logger.warn(`Complex snapping query failed, falling back to direct insertion: ${err.message}`); - result = await this.dataSource.query(`INSERT INTO candidate_roads ( - geometry, "uniqueDriverCount", "totalPoints", "averageSpeed", "lengthMeters", - confidence, status, source, name, highway, oneway, "discoveredAt" - ) - VALUES ( - ST_SetSRID(ST_GeomFromGeoJSON($1), 4326), - 1, 10, 30.0, - ST_Length(ST_Transform(ST_SetSRID(ST_GeomFromGeoJSON($1), 4326), 3857)), - 0.90, 'pending', 'manual', $2, $3, 0, NOW() - ) - RETURNING id, name, highway, confidence, status`, [geojsonStr, name, highway]); - } - this.logger.log(`✍️ Manual candidate road registered: ${result[0]?.id} (${name})`); - return { success: true, candidate: result[0] }; - } - catch (e) { - this.logger.error(`Failed to insert manual candidate road: ${e.message}`); - throw new common_1.HttpException(`Failed to create candidate road: ${e.message}`, common_1.HttpStatus.INTERNAL_SERVER_ERROR); - } - } - async approveCandidate(id) { - try { - await this.dataSource.query(` - CREATE TABLE IF NOT EXISTS approved_roads ( - id UUID PRIMARY KEY DEFAULT gen_random_uuid(), - candidate_id UUID UNIQUE, - geometry GEOMETRY(LineString, 4326), - name VARCHAR(255), - highway VARCHAR(32), - confidence FLOAT, - "uniqueDriverCount" INT DEFAULT 1, - oneway SMALLINT DEFAULT 0, - start_node BIGINT, - end_node BIGINT, - approved_at TIMESTAMP DEFAULT NOW() - ); - CREATE INDEX IF NOT EXISTS approved_roads_geom_idx ON approved_roads USING GIST(geometry); - CREATE UNIQUE INDEX IF NOT EXISTS approved_roads_cand_uidx ON approved_roads(candidate_id) WHERE candidate_id IS NOT NULL; - `); - await this.candidateRepo.update(id, { - status: 'approved', - reviewedAt: new Date(), - }); - await this.dataSource.query(` - DO $$ - DECLARE - cand RECORD; - start_pt GEOMETRY; - end_pt GEOMETRY; - snapped_geom GEOMETRY; - s_node BIGINT := NULL; - e_node BIGINT := NULL; - node_rec RECORD; - line_rec RECORD; - BEGIN - SELECT id, geometry::geometry as geom, name, COALESCE(highway, 'residential') as highway, confidence, "uniqueDriverCount", oneway - INTO cand - FROM candidate_roads WHERE id = $1; - - IF FOUND THEN - snapped_geom := cand.geom; - start_pt := ST_StartPoint(snapped_geom); - end_pt := ST_EndPoint(snapped_geom); - - -- 1. Start node & geometry snapping - BEGIN - WITH p AS (SELECT ST_Transform(start_pt, 3857) AS pt) - SELECT n.id, n.lon/1e7 as lon, n.lat/1e7 as lat - INTO node_rec - FROM p - JOIN planet_osm_line l ON l.highway IS NOT NULL AND l.way && ST_Expand(p.pt, 60) - JOIN planet_osm_ways w ON w.id = l.osm_id - CROSS JOIN LATERAL unnest(w.nodes) AS wn(node_id) - JOIN planet_osm_nodes n ON n.id = wn.node_id - WHERE ST_Distance(ST_SetSRID(ST_MakePoint(n.lon/1e7, n.lat/1e7), 4326)::geography, start_pt::geography) < 30 - ORDER BY ST_Distance(ST_SetSRID(ST_MakePoint(n.lon/1e7, n.lat/1e7), 4326)::geography, start_pt::geography) ASC - LIMIT 1; - - IF FOUND THEN - s_node := node_rec.id; - snapped_geom := ST_SetPoint(snapped_geom, 0, ST_SetSRID(ST_MakePoint(node_rec.lon, node_rec.lat), 4326)); - ELSE - WITH p AS (SELECT ST_Transform(start_pt, 3857) AS pt) - SELECT ST_X(ST_Transform(ST_ClosestPoint(l.way, p.pt), 4326)) as lon, - ST_Y(ST_Transform(ST_ClosestPoint(l.way, p.pt), 4326)) as lat - INTO line_rec - FROM p - JOIN planet_osm_line l ON l.highway IS NOT NULL AND l.way && ST_Expand(p.pt, 60) - WHERE ST_Distance(ST_Transform(l.way, 4326)::geography, start_pt::geography) < 30 - ORDER BY ST_Distance(l.way, p.pt) ASC - LIMIT 1; - - IF FOUND THEN - snapped_geom := ST_SetPoint(snapped_geom, 0, ST_SetSRID(ST_MakePoint(line_rec.lon, line_rec.lat), 4326)); - END IF; - END IF; - EXCEPTION WHEN OTHERS THEN - NULL; - END; - - -- 2. End node & geometry snapping - BEGIN - WITH p AS (SELECT ST_Transform(end_pt, 3857) AS pt) - SELECT n.id, n.lon/1e7 as lon, n.lat/1e7 as lat - INTO node_rec - FROM p - JOIN planet_osm_line l ON l.highway IS NOT NULL AND l.way && ST_Expand(p.pt, 60) - JOIN planet_osm_ways w ON w.id = l.osm_id - CROSS JOIN LATERAL unnest(w.nodes) AS wn(node_id) - JOIN planet_osm_nodes n ON n.id = wn.node_id - WHERE ST_Distance(ST_SetSRID(ST_MakePoint(n.lon/1e7, n.lat/1e7), 4326)::geography, end_pt::geography) < 30 - ORDER BY ST_Distance(ST_SetSRID(ST_MakePoint(n.lon/1e7, n.lat/1e7), 4326)::geography, end_pt::geography) ASC - LIMIT 1; - - IF FOUND THEN - e_node := node_rec.id; - snapped_geom := ST_SetPoint(snapped_geom, ST_NPoints(snapped_geom) - 1, ST_SetSRID(ST_MakePoint(node_rec.lon, node_rec.lat), 4326)); - ELSE - WITH p AS (SELECT ST_Transform(end_pt, 3857) AS pt) - SELECT ST_X(ST_Transform(ST_ClosestPoint(l.way, p.pt), 4326)) as lon, - ST_Y(ST_Transform(ST_ClosestPoint(l.way, p.pt), 4326)) as lat - INTO line_rec - FROM p - JOIN planet_osm_line l ON l.highway IS NOT NULL AND l.way && ST_Expand(p.pt, 60) - WHERE ST_Distance(ST_Transform(l.way, 4326)::geography, end_pt::geography) < 30 - ORDER BY ST_Distance(l.way, p.pt) ASC - LIMIT 1; - - IF FOUND THEN - snapped_geom := ST_SetPoint(snapped_geom, ST_NPoints(snapped_geom) - 1, ST_SetSRID(ST_MakePoint(line_rec.lon, line_rec.lat), 4326)); - END IF; - END IF; - EXCEPTION WHEN OTHERS THEN - NULL; - END; - - -- Update candidate_roads - UPDATE candidate_roads SET geometry = snapped_geom WHERE id = cand.id; - - -- Insert or update approved_roads - INSERT INTO approved_roads ( - candidate_id, geometry, name, highway, confidence, "uniqueDriverCount", oneway, start_node, end_node - ) - VALUES ( - cand.id, snapped_geom, cand.name, cand.highway, cand.confidence, cand."uniqueDriverCount", cand.oneway, s_node, e_node - ) - ON CONFLICT (candidate_id) DO UPDATE SET - geometry = EXCLUDED.geometry, - start_node = EXCLUDED.start_node, - end_node = EXCLUDED.end_node; - - END IF; - END $$; - `, [id]); - try { - await this.dataSource.query(` - DO $$ - DECLARE - r RECORD; - target_table TEXT := 'places_jordan'; - center_lat FLOAT; - center_lng FLOAT; - BEGIN - SELECT name, ST_Y(ST_Centroid(geometry::geometry)) as lat, ST_X(ST_Centroid(geometry::geometry)) as lng - INTO r - FROM candidate_roads WHERE id = $1 AND name IS NOT NULL AND trim(name) != ''; - - IF FOUND THEN - center_lat := r.lat; - center_lng := r.lng; - - IF center_lat >= 29 AND center_lat <= 37.5 AND center_lng >= 38.7 AND center_lng <= 48.8 THEN - target_table := 'places_iraq'; - ELSIF center_lat >= 29 AND center_lat <= 37.5 AND center_lng >= 34.5 AND center_lng <= 42.5 THEN - IF center_lat > 32.5 AND center_lng > 35.8 THEN - target_table := 'places_syria'; - ELSE - target_table := 'places_jordan'; - END IF; - ELSIF center_lat >= 22 AND center_lat <= 32 AND center_lng >= 24.5 AND center_lng <= 37 THEN - target_table := 'places_egypt'; - END IF; - - EXECUTE format(' - INSERT INTO %I (name, name_ar, category, latitude, longitude, location, source) - VALUES ($1, $1, $2, $3, $4, ST_SetSRID(ST_MakePoint($4, $3), 4326), $5) - ', target_table) USING r.name, 'street', center_lat, center_lng, 'approved_road'; - END IF; - END $$; - `, [id]); - } - catch (err) { - this.logger.warn(`Could not index approved road to places: ${err.message}`); - } - this.logger.log(`✅ Road candidate ${id} approved & published.`); - return { success: true, id, status: 'approved' }; - } - catch (e) { - this.logger.error(`Failed to approve candidate road: ${e.message}`); - throw new common_1.HttpException(e.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR); - } - } - async rejectCandidate(id) { - try { - await this.candidateRepo.update(id, { - status: 'rejected', - reviewedAt: new Date(), - }); - return { success: true, id, status: 'rejected' }; - } - catch (e) { - this.logger.error(`Failed to reject candidate road: ${e.message}`); - throw new common_1.HttpException(e.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR); - } - } - async getClosures() { - return this.roadStatRepo.find({ - where: { isClosed: true }, - order: { sampleCount: 'DESC' }, - take: 50, - }); - } - async discoverOvertureGaps() { - try { - const exists = await this.dataSource.query(` - SELECT to_regclass('public.overture_transportation') as tbl; - `); - if (!exists[0]?.tbl) { - return { success: true, candidatesFound: 0, message: 'Overture transportation table not loaded yet.' }; - } - const inserted = await this.dataSource.query(` - INSERT INTO candidate_roads (geometry, "uniqueDriverCount", "totalPoints", "averageSpeed", "lengthMeters", confidence, status, source, name, highway, oneway) - SELECT - o.geometry, - 5, 50, 40.0, - ST_Length(ST_Transform(o.geometry::geometry, 3857)), - 0.85, - 'pending', - 'overture', - o.name, - COALESCE(o.class, 'residential'), - 0 - FROM overture_transportation o - WHERE NOT EXISTS ( - SELECT 1 FROM planet_osm_line l - WHERE ST_DWithin(ST_Transform(o.geometry::geometry, 3857), l.way, 25) - ) - AND ST_Length(ST_Transform(o.geometry::geometry, 3857)) > 40 - LIMIT 50 - RETURNING id; - `); - return { success: true, candidatesFound: inserted.length }; - } - catch (e) { - this.logger.warn(`Overture gap check skipped: ${e.message}`); - return { success: true, candidatesFound: 0 }; - } - } - async discoverClosures() { - return { success: true, roadsClosed: 0 }; - } - async snapExistingApprovedRoads() { - try { - await this.dataSource.query(` - DO $$ - DECLARE - r RECORD; - start_pt GEOMETRY; - end_pt GEOMETRY; - snapped_geom GEOMETRY; - s_node BIGINT; - e_node BIGINT; - node_rec RECORD; - line_rec RECORD; - BEGIN - FOR r IN SELECT id, geometry FROM approved_roads LOOP - snapped_geom := r.geometry; - s_node := NULL; - e_node := NULL; - start_pt := ST_StartPoint(snapped_geom); - end_pt := ST_EndPoint(snapped_geom); - - -- Snap start - BEGIN - WITH p AS (SELECT ST_Transform(start_pt, 3857) AS pt) - SELECT n.id, n.lon/1e7 as lon, n.lat/1e7 as lat - INTO node_rec - FROM p - JOIN planet_osm_line l ON l.highway IS NOT NULL AND l.way && ST_Expand(p.pt, 60) - JOIN planet_osm_ways w ON w.id = l.osm_id - CROSS JOIN LATERAL unnest(w.nodes) AS wn(node_id) - JOIN planet_osm_nodes n ON n.id = wn.node_id - WHERE ST_Distance(ST_SetSRID(ST_MakePoint(n.lon/1e7, n.lat/1e7), 4326)::geography, start_pt::geography) < 30 - ORDER BY ST_Distance(ST_SetSRID(ST_MakePoint(n.lon/1e7, n.lat/1e7), 4326)::geography, start_pt::geography) ASC - LIMIT 1; - - IF FOUND THEN - s_node := node_rec.id; - snapped_geom := ST_SetPoint(snapped_geom, 0, ST_SetSRID(ST_MakePoint(node_rec.lon, node_rec.lat), 4326)); - ELSE - WITH p AS (SELECT ST_Transform(start_pt, 3857) AS pt) - SELECT ST_X(ST_Transform(ST_ClosestPoint(l.way, p.pt), 4326)) as lon, - ST_Y(ST_Transform(ST_ClosestPoint(l.way, p.pt), 4326)) as lat - INTO line_rec - FROM p - JOIN planet_osm_line l ON l.highway IS NOT NULL AND l.way && ST_Expand(p.pt, 60) - WHERE ST_Distance(ST_Transform(l.way, 4326)::geography, start_pt::geography) < 30 - ORDER BY ST_Distance(l.way, p.pt) ASC - LIMIT 1; - - IF FOUND THEN - snapped_geom := ST_SetPoint(snapped_geom, 0, ST_SetSRID(ST_MakePoint(line_rec.lon, line_rec.lat), 4326)); - END IF; - END IF; - EXCEPTION WHEN OTHERS THEN - NULL; - END; - - -- Snap end - BEGIN - WITH p AS (SELECT ST_Transform(end_pt, 3857) AS pt) - SELECT n.id, n.lon/1e7 as lon, n.lat/1e7 as lat - INTO node_rec - FROM p - JOIN planet_osm_line l ON l.highway IS NOT NULL AND l.way && ST_Expand(p.pt, 60) - JOIN planet_osm_ways w ON w.id = l.osm_id - CROSS JOIN LATERAL unnest(w.nodes) AS wn(node_id) - JOIN planet_osm_nodes n ON n.id = wn.node_id - WHERE ST_Distance(ST_SetSRID(ST_MakePoint(n.lon/1e7, n.lat/1e7), 4326)::geography, end_pt::geography) < 30 - ORDER BY ST_Distance(ST_SetSRID(ST_MakePoint(n.lon/1e7, n.lat/1e7), 4326)::geography, end_pt::geography) ASC - LIMIT 1; - - IF FOUND THEN - e_node := node_rec.id; - snapped_geom := ST_SetPoint(snapped_geom, ST_NPoints(snapped_geom) - 1, ST_SetSRID(ST_MakePoint(node_rec.lon, node_rec.lat), 4326)); - ELSE - WITH p AS (SELECT ST_Transform(end_pt, 3857) AS pt) - SELECT ST_X(ST_Transform(ST_ClosestPoint(l.way, p.pt), 4326)) as lon, - ST_Y(ST_Transform(ST_ClosestPoint(l.way, p.pt), 4326)) as lat - INTO line_rec - FROM p - JOIN planet_osm_line l ON l.highway IS NOT NULL AND l.way && ST_Expand(p.pt, 60) - WHERE ST_Distance(ST_Transform(l.way, 4326)::geography, end_pt::geography) < 30 - ORDER BY ST_Distance(l.way, p.pt) ASC - LIMIT 1; - - IF FOUND THEN - snapped_geom := ST_SetPoint(snapped_geom, ST_NPoints(snapped_geom) - 1, ST_SetSRID(ST_MakePoint(line_rec.lon, line_rec.lat), 4326)); - END IF; - END IF; - EXCEPTION WHEN OTHERS THEN - NULL; - END; - - UPDATE approved_roads - SET geometry = snapped_geom, - start_node = COALESCE(s_node, start_node), - end_node = COALESCE(e_node, end_node) - WHERE id = r.id; - END LOOP; - END $$; - `); - return { success: true, message: 'All approved roads snapped & nodes resolved' }; - } - catch (e) { - this.logger.error(`Failed to snap existing roads: ${e.message}`); - throw new common_1.HttpException(e.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR); - } - } -}; -exports.RoadRefinementController = RoadRefinementController; -__decorate([ - (0, common_1.Get)('summary'), - (0, swagger_1.ApiOperation)({ summary: 'Get road intelligence summary 📊' }), - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", Promise) -], RoadRefinementController.prototype, "getSummary", null); -__decorate([ - (0, common_1.Get)('candidates'), - (0, swagger_1.ApiOperation)({ summary: 'Get candidate roads list 🛣️' }), - (0, swagger_1.ApiQuery)({ name: 'status', required: false }), - __param(0, (0, common_1.Query)('status')), - __metadata("design:type", Function), - __metadata("design:paramtypes", [String]), - __metadata("design:returntype", Promise) -], RoadRefinementController.prototype, "getCandidates", null); -__decorate([ - (0, common_1.Post)('candidates/manual'), - (0, swagger_1.ApiOperation)({ summary: 'Submit manual candidate road drawn on map ✍️' }), - __param(0, (0, common_1.Body)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object]), - __metadata("design:returntype", Promise) -], RoadRefinementController.prototype, "submitManualCandidate", null); -__decorate([ - (0, common_1.Patch)('candidates/:id/approve'), - (0, swagger_1.ApiOperation)({ summary: 'Approve candidate road and move to approved_roads with auto-snapped topology ✅' }), - (0, swagger_1.ApiParam)({ name: 'id', description: 'Candidate UUID' }), - __param(0, (0, common_1.Param)('id')), - __metadata("design:type", Function), - __metadata("design:paramtypes", [String]), - __metadata("design:returntype", Promise) -], RoadRefinementController.prototype, "approveCandidate", null); -__decorate([ - (0, common_1.Patch)('candidates/:id/reject'), - (0, swagger_1.ApiOperation)({ summary: 'Reject candidate road ❌' }), - (0, swagger_1.ApiParam)({ name: 'id', description: 'Candidate UUID' }), - __param(0, (0, common_1.Param)('id')), - __metadata("design:type", Function), - __metadata("design:paramtypes", [String]), - __metadata("design:returntype", Promise) -], RoadRefinementController.prototype, "rejectCandidate", null); -__decorate([ - (0, common_1.Get)('closures'), - (0, swagger_1.ApiOperation)({ summary: 'Get active road closures 🚧' }), - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", Promise) -], RoadRefinementController.prototype, "getClosures", null); -__decorate([ - (0, common_1.Post)('discover-overture-gaps'), - (0, swagger_1.ApiOperation)({ summary: 'Discover missing roads against Overture Maps 🗺️' }), - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", Promise) -], RoadRefinementController.prototype, "discoverOvertureGaps", null); -__decorate([ - (0, common_1.Post)('discover-closures'), - (0, swagger_1.ApiOperation)({ summary: 'Discover closures 🚧' }), - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", Promise) -], RoadRefinementController.prototype, "discoverClosures", null); -__decorate([ - (0, common_1.Post)('snap-existing-roads'), - (0, swagger_1.ApiOperation)({ summary: 'Auto-snap and resolve topology nodes for all existing approved roads' }), - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", Promise) -], RoadRefinementController.prototype, "snapExistingApprovedRoads", null); -exports.RoadRefinementController = RoadRefinementController = RoadRefinementController_1 = __decorate([ - (0, swagger_1.ApiTags)('map-refinement-roads'), - (0, common_1.Controller)('map-refinement/roads'), - (0, common_1.UseGuards)(api_key_guard_1.ApiKeyGuard), - __param(0, (0, typeorm_1.InjectRepository)(candidate_road_entity_1.CandidateRoad)), - __param(1, (0, typeorm_1.InjectRepository)(road_stat_entity_1.RoadSegmentStat)), - __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object, typeof (_b = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _b : Object, typeof (_c = typeof typeorm_2.DataSource !== "undefined" && typeorm_2.DataSource) === "function" ? _c : Object]) -], RoadRefinementController); -//# sourceMappingURL=road-refinement.controller.js.map \ No newline at end of file diff --git a/apps/api/dist/maps/road-refinement.controller.js.map b/apps/api/dist/maps/road-refinement.controller.js.map deleted file mode 100644 index 5b7cbe5..0000000 --- a/apps/api/dist/maps/road-refinement.controller.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"road-refinement.controller.js","sourceRoot":"","sources":["../../src/maps/road-refinement.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAgI;AAChI,6CAA4E;AAC5E,6CAAmD;AACnD,qCAAiD;AACjD,mEAAwD;AACxD,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AAC,qCAAa,CAAC,CAAA;IAE/B,WAAA,IAAA,0BAAgB,EAAC,kCAAe,CAAC,CAAA;yDADF,oBAAU,oBAAV,oBAAU,oDAEX,oBAAU,oBAAV,oBAAU,oDACZ,oBAAU,oBAAV,oBAAU;GAR9B,wBAAwB,CA8iBpC"} \ No newline at end of file diff --git a/apps/api/dist/maps/road-speed-profile.entity.d.ts b/apps/api/dist/maps/road-speed-profile.entity.d.ts deleted file mode 100644 index 62e32df..0000000 --- a/apps/api/dist/maps/road-speed-profile.entity.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -export declare class RoadSpeedProfile { - segmentId: string; - hourOfDay: number; - dayOfWeek: number; - averageSpeed: number; - sampleCount: number; - lastUpdated: Date; -} diff --git a/apps/api/dist/maps/road-speed-profile.entity.js b/apps/api/dist/maps/road-speed-profile.entity.js deleted file mode 100644 index 17300da..0000000 --- a/apps/api/dist/maps/road-speed-profile.entity.js +++ /dev/null @@ -1,51 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.RoadSpeedProfile = void 0; -const typeorm_1 = require("typeorm"); -let RoadSpeedProfile = class RoadSpeedProfile { - segmentId; - hourOfDay; - dayOfWeek; - averageSpeed; - sampleCount; - lastUpdated; -}; -exports.RoadSpeedProfile = RoadSpeedProfile; -__decorate([ - (0, typeorm_1.PrimaryColumn)(), - __metadata("design:type", String) -], RoadSpeedProfile.prototype, "segmentId", void 0); -__decorate([ - (0, typeorm_1.PrimaryColumn)(), - __metadata("design:type", Number) -], RoadSpeedProfile.prototype, "hourOfDay", void 0); -__decorate([ - (0, typeorm_1.PrimaryColumn)(), - __metadata("design:type", Number) -], RoadSpeedProfile.prototype, "dayOfWeek", void 0); -__decorate([ - (0, typeorm_1.Column)('float', { default: 0 }), - __metadata("design:type", Number) -], RoadSpeedProfile.prototype, "averageSpeed", void 0); -__decorate([ - (0, typeorm_1.Column)('int', { default: 0 }), - __metadata("design:type", Number) -], RoadSpeedProfile.prototype, "sampleCount", void 0); -__decorate([ - (0, typeorm_1.CreateDateColumn)(), - __metadata("design:type", Date) -], RoadSpeedProfile.prototype, "lastUpdated", void 0); -exports.RoadSpeedProfile = RoadSpeedProfile = __decorate([ - (0, typeorm_1.Entity)('road_speed_profiles'), - (0, typeorm_1.Index)(['segmentId', 'hourOfDay', 'dayOfWeek'], { unique: true }) -], RoadSpeedProfile); -//# sourceMappingURL=road-speed-profile.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/maps/road-speed-profile.entity.js.map b/apps/api/dist/maps/road-speed-profile.entity.js.map deleted file mode 100644 index 724d216..0000000 --- a/apps/api/dist/maps/road-speed-profile.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"road-speed-profile.entity.js","sourceRoot":"","sources":["../../src/maps/road-speed-profile.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAiF;AAI1E,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAE3B,SAAS,CAAS;IAGlB,SAAS,CAAS;IAGlB,SAAS,CAAS;IAGlB,YAAY,CAAS;IAGrB,WAAW,CAAS;IAGpB,WAAW,CAAO;CACnB,CAAA;AAlBY,4CAAgB;AAE3B;IADC,IAAA,uBAAa,GAAE;;mDACE;AAGlB;IADC,IAAA,uBAAa,GAAE;;mDACE;AAGlB;IADC,IAAA,uBAAa,GAAE;;mDACE;AAGlB;IADC,IAAA,gBAAM,EAAC,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;sDACX;AAGrB;IADC,IAAA,gBAAM,EAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;qDACV;AAGpB;IADC,IAAA,0BAAgB,GAAE;8BACN,IAAI;qDAAC;2BAjBP,gBAAgB;IAF5B,IAAA,gBAAM,EAAC,qBAAqB,CAAC;IAC7B,IAAA,eAAK,EAAC,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;GACpD,gBAAgB,CAkB5B"} \ No newline at end of file diff --git a/apps/api/dist/maps/road-stat.entity.d.ts b/apps/api/dist/maps/road-stat.entity.d.ts deleted file mode 100644 index 3293a03..0000000 --- a/apps/api/dist/maps/road-stat.entity.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -export declare class RoadSegmentStat { - segmentId: string; - averageSpeed: number; - congestionFactor: number; - isClosed: boolean; - sampleCount: number; - geometry: any; - lastUpdated: Date; -} diff --git a/apps/api/dist/maps/road-stat.entity.js b/apps/api/dist/maps/road-stat.entity.js deleted file mode 100644 index 13944ad..0000000 --- a/apps/api/dist/maps/road-stat.entity.js +++ /dev/null @@ -1,63 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.RoadSegmentStat = void 0; -const typeorm_1 = require("typeorm"); -let RoadSegmentStat = class RoadSegmentStat { - segmentId; - averageSpeed; - congestionFactor; - isClosed; - sampleCount; - geometry; - lastUpdated; -}; -exports.RoadSegmentStat = RoadSegmentStat; -__decorate([ - (0, typeorm_1.PrimaryColumn)(), - __metadata("design:type", String) -], RoadSegmentStat.prototype, "segmentId", void 0); -__decorate([ - (0, typeorm_1.Column)('float', { default: 0 }), - __metadata("design:type", Number) -], RoadSegmentStat.prototype, "averageSpeed", void 0); -__decorate([ - (0, typeorm_1.Column)('float', { default: 1.0 }), - __metadata("design:type", Number) -], RoadSegmentStat.prototype, "congestionFactor", void 0); -__decorate([ - (0, typeorm_1.Column)('boolean', { default: false }), - (0, typeorm_1.Index)(), - __metadata("design:type", Boolean) -], RoadSegmentStat.prototype, "isClosed", void 0); -__decorate([ - (0, typeorm_1.Column)('int', { default: 0 }), - __metadata("design:type", Number) -], RoadSegmentStat.prototype, "sampleCount", void 0); -__decorate([ - (0, typeorm_1.Column)({ - type: 'geography', - spatialFeatureType: 'LineString', - srid: 4326, - nullable: true, - }), - (0, typeorm_1.Index)({ spatial: true }), - __metadata("design:type", Object) -], RoadSegmentStat.prototype, "geometry", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }), - __metadata("design:type", Date) -], RoadSegmentStat.prototype, "lastUpdated", void 0); -exports.RoadSegmentStat = RoadSegmentStat = __decorate([ - (0, typeorm_1.Entity)('road_segment_stats'), - (0, typeorm_1.Index)('idx_segment_congestion', ['congestionFactor'], { where: '"congestionFactor" > 1.1' }) -], RoadSegmentStat); -//# sourceMappingURL=road-stat.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/maps/road-stat.entity.js.map b/apps/api/dist/maps/road-stat.entity.js.map deleted file mode 100644 index 5190997..0000000 --- a/apps/api/dist/maps/road-stat.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":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file diff --git a/apps/api/dist/maps/traffic-grid.service.d.ts b/apps/api/dist/maps/traffic-grid.service.d.ts deleted file mode 100644 index ba387ec..0000000 --- a/apps/api/dist/maps/traffic-grid.service.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { OnModuleInit } from '@nestjs/common'; -import { DataSource } from 'typeorm'; -export declare class TrafficGridService implements OnModuleInit { - private dataSource; - private readonly logger; - private grid; - private readonly GEOHASH_PRECISION; - constructor(dataSource: DataSource); - onModuleInit(): Promise<void>; - refreshGrid(): Promise<void>; - getTrafficFactor(coords: [number, number][], hr: number, dow: number): number; - private encodeGeohash; -} diff --git a/apps/api/dist/maps/traffic-grid.service.js b/apps/api/dist/maps/traffic-grid.service.js deleted file mode 100644 index d165fc1..0000000 --- a/apps/api/dist/maps/traffic-grid.service.js +++ /dev/null @@ -1,124 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var TrafficGridService_1; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.TrafficGridService = void 0; -const common_1 = require("@nestjs/common"); -const typeorm_1 = require("typeorm"); -let TrafficGridService = TrafficGridService_1 = class TrafficGridService { - dataSource; - logger = new common_1.Logger(TrafficGridService_1.name); - grid = new Map(); - GEOHASH_PRECISION = 6; - constructor(dataSource) { - this.dataSource = dataSource; - } - async onModuleInit() { - await this.refreshGrid(); - } - async refreshGrid() { - this.logger.log('📡 Rebuilding Traffic Grid v3 (In-Memory Lookup)...'); - try { - const startTime = Date.now(); - const data = await this.dataSource.query(` - SELECT - ST_X(ST_Centroid(geometry::geometry)) as lng, - ST_Y(ST_Centroid(geometry::geometry)) as lat, - p."hourOfDay", p."dayOfWeek", p."averageSpeed", - s."averageSpeed" as base_speed - FROM road_speed_profiles p - JOIN road_segment_stats s ON p."segmentId" = s."segmentId" - WHERE s.geometry IS NOT NULL - `); - this.grid.clear(); - let count = 0; - for (const row of data) { - const gh = this.encodeGeohash(row.lat, row.lng, this.GEOHASH_PRECISION); - const factor = row.base_speed / Math.max(row.averageSpeed, 1); - const key = `${gh}:${row.hourOfDay}:${row.dayOfWeek}`; - this.grid.set(key, factor); - count++; - } - this.logger.log(`✅ Grid rebuilt in ${Date.now() - startTime}ms. Cached ${count} cells (${this.grid.size} unique keys).`); - } - catch (e) { - this.logger.error('❌ Failed to refresh traffic grid:', e.message); - } - } - getTrafficFactor(coords, hr, dow) { - if (this.grid.size === 0) - return 1.0; - let totalFactor = 0; - let matches = 0; - for (let i = 0; i < coords.length; i += 2) { - const [lng, lat] = coords[i]; - const gh = this.encodeGeohash(lat, lng, this.GEOHASH_PRECISION); - const key = `${gh}:${hr}:${dow}`; - const factor = this.grid.get(key); - if (factor) { - totalFactor += factor; - matches++; - } - } - if (matches === 0) - return 1.0; - let finalFactor = totalFactor / matches; - return Math.min(Math.max(finalFactor, 0.8), 3.0); - } - encodeGeohash(lat, lng, precision) { - const BASE32 = "0123456789bcdefghjkmnpqrstuvwxyz"; - let minLat = -90, maxLat = 90; - let minLng = -180, maxLng = 180; - let result = ""; - let isEven = true; - let bit = 0; - let ch = 0; - while (result.length < precision) { - if (isEven) { - let mid = (minLng + maxLng) / 2; - if (lng > mid) { - ch |= (1 << (4 - bit)); - minLng = mid; - } - else { - maxLng = mid; - } - } - else { - let mid = (minLat + maxLat) / 2; - if (lat > mid) { - ch |= (1 << (4 - bit)); - minLat = mid; - } - else { - maxLat = mid; - } - } - isEven = !isEven; - if (bit < 4) { - bit++; - } - else { - result += BASE32[ch]; - bit = 0; - ch = 0; - } - } - return result; - } -}; -exports.TrafficGridService = TrafficGridService; -exports.TrafficGridService = TrafficGridService = TrafficGridService_1 = __decorate([ - (0, common_1.Injectable)(), - __metadata("design:paramtypes", [typeof (_a = typeof typeorm_1.DataSource !== "undefined" && typeorm_1.DataSource) === "function" ? _a : Object]) -], TrafficGridService); -//# sourceMappingURL=traffic-grid.service.js.map \ No newline at end of file diff --git a/apps/api/dist/maps/traffic-grid.service.js.map b/apps/api/dist/maps/traffic-grid.service.js.map deleted file mode 100644 index 207b02d..0000000 --- a/apps/api/dist/maps/traffic-grid.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"traffic-grid.service.js","sourceRoot":"","sources":["../../src/maps/traffic-grid.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2CAAkE;AAClE,qCAAqC;AAO9B,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAOT;IANH,MAAM,GAAG,IAAI,eAAM,CAAC,oBAAkB,CAAC,IAAI,CAAC,CAAC;IAGtD,IAAI,GAAwB,IAAI,GAAG,EAAE,CAAC;IAC7B,iBAAiB,GAAG,CAAC,CAAC;IAEvC,YAAoB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAE9C,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC;IAMD,KAAK,CAAC,WAAW;QACf,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;QACvE,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAE7B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;;;;;;;;;OASxC,CAAC,CAAC;YAEH,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAClB,IAAI,KAAK,GAAG,C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GAAG,CAAC;gBAAC,CAAC;qBACnD,CAAC;oBAAC,MAAM,GAAG,GAAG,CAAC;gBAAC,CAAC;YACxB,CAAC;iBAAM,CAAC;gBACN,IAAI,GAAG,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;gBAChC,IAAI,GAAG,GAAG,GAAG,EAAE,CAAC;oBAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;oBAAC,MAAM,GAAG,GAAG,CAAC;gBAAC,CAAC;qBACnD,CAAC;oBAAC,MAAM,GAAG,GAAG,CAAC;gBAAC,CAAC;YACxB,CAAC;YAED,MAAM,GAAG,CAAC,MAAM,CAAC;YACjB,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC;gBACZ,GAAG,EAAE,CAAC;YACR,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC;gBACrB,GAAG,GAAG,CAAC,CAAC;gBACR,EAAE,GAAG,CAAC,CAAC;YACT,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAA;AApHY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;yDAQqB,oBAAU,oBAAV,oBAAU;GAP/B,kBAAkB,CAoH9B"} \ No newline at end of file diff --git a/apps/api/dist/tactical/dto/line-of-sight.dto.d.ts b/apps/api/dist/tactical/dto/line-of-sight.dto.d.ts deleted file mode 100644 index 8687e63..0000000 --- a/apps/api/dist/tactical/dto/line-of-sight.dto.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -export declare class PointDto { - lat: number; - lng: number; - height?: number; -} -export declare class LineOfSightQueryDto { - observerLat: number; - observerLng: number; - targetLat: number; - targetLng: number; - observerHeight?: number; - targetHeight?: number; - stepMeters?: number; - samples?: number; - compact?: boolean; -} -export declare class LineOfSightBodyDto { - observer?: PointDto; - target?: PointDto; - observerLat?: number; - observerLng?: number; - targetLat?: number; - targetLng?: number; - observerHeight?: number; - targetHeight?: number; - stepMeters?: number; - samples?: number; - compact?: boolean; -} diff --git a/apps/api/dist/tactical/dto/line-of-sight.dto.js b/apps/api/dist/tactical/dto/line-of-sight.dto.js deleted file mode 100644 index 949623c..0000000 --- a/apps/api/dist/tactical/dto/line-of-sight.dto.js +++ /dev/null @@ -1,209 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.LineOfSightBodyDto = exports.LineOfSightQueryDto = exports.PointDto = void 0; -const swagger_1 = require("@nestjs/swagger"); -const class_transformer_1 = require("class-transformer"); -const class_validator_1 = require("class-validator"); -class PointDto { - lat; - lng; - height; -} -exports.PointDto = PointDto; -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'Latitude in decimal degrees', example: 32.311852 }), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], PointDto.prototype, "lat", void 0); -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'Longitude in decimal degrees', example: 36.839237 }), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], PointDto.prototype, "lng", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Height offset above ground in meters (e.g. eye level / mast)', example: 2, default: 2 }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], PointDto.prototype, "height", void 0); -class LineOfSightQueryDto { - observerLat; - observerLng; - targetLat; - targetLng; - observerHeight; - targetHeight; - stepMeters; - samples; - compact; -} -exports.LineOfSightQueryDto = LineOfSightQueryDto; -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'Observer (Point A) Latitude', example: 32.311852 }), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], LineOfSightQueryDto.prototype, "observerLat", void 0); -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'Observer (Point A) Longitude', example: 36.839237 }), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], LineOfSightQueryDto.prototype, "observerLng", void 0); -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'Target (Point B) Latitude', example: 33.371104 }), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], LineOfSightQueryDto.prototype, "targetLat", void 0); -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'Target (Point B) Longitude', example: 38.793024 }), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], LineOfSightQueryDto.prototype, "targetLng", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Observer eye level / sensor height above ground (meters)', default: 2 }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_validator_1.Min)(0), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], LineOfSightQueryDto.prototype, "observerHeight", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Target height above ground (meters)', default: 2 }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_validator_1.Min)(0), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], LineOfSightQueryDto.prototype, "targetHeight", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Sampling distance step in meters (e.g. 5, 10, 25, 50). If omitted, automatically optimized.' }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_validator_1.Min)(1), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], LineOfSightQueryDto.prototype, "stepMeters", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Explicit number of sample points (5 - 300). If omitted, dynamically calculated.' }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_validator_1.Min)(5), - (0, class_validator_1.Max)(300), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], LineOfSightQueryDto.prototype, "samples", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'If true, returns only executive summary and obstacle info without profile array', default: false }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsBoolean)(), - (0, class_transformer_1.Type)(() => Boolean), - __metadata("design:type", Boolean) -], LineOfSightQueryDto.prototype, "compact", void 0); -class LineOfSightBodyDto { - observer; - target; - observerLat; - observerLng; - targetLat; - targetLng; - observerHeight; - targetHeight; - stepMeters; - samples; - compact; -} -exports.LineOfSightBodyDto = LineOfSightBodyDto; -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ type: PointDto }), - (0, class_validator_1.IsOptional)(), - __metadata("design:type", PointDto) -], LineOfSightBodyDto.prototype, "observer", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ type: PointDto }), - (0, class_validator_1.IsOptional)(), - __metadata("design:type", PointDto) -], LineOfSightBodyDto.prototype, "target", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Observer Latitude (flat format)', example: 32.311852 }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], LineOfSightBodyDto.prototype, "observerLat", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Observer Longitude (flat format)', example: 36.839237 }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], LineOfSightBodyDto.prototype, "observerLng", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Target Latitude (flat format)', example: 33.371104 }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], LineOfSightBodyDto.prototype, "targetLat", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Target Longitude (flat format)', example: 38.793024 }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], LineOfSightBodyDto.prototype, "targetLng", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Observer height offset (meters)', default: 2 }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_validator_1.Min)(0), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], LineOfSightBodyDto.prototype, "observerHeight", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Target height offset (meters)', default: 2 }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_validator_1.Min)(0), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], LineOfSightBodyDto.prototype, "targetHeight", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Sampling distance step in meters (e.g. 5, 10, 25, 50)' }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_validator_1.Min)(1), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], LineOfSightBodyDto.prototype, "stepMeters", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Number of sample points (5 - 300)' }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_validator_1.Min)(5), - (0, class_validator_1.Max)(300), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], LineOfSightBodyDto.prototype, "samples", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'If true, returns only executive summary and obstacle info without profile array', default: false }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsBoolean)(), - (0, class_transformer_1.Type)(() => Boolean), - __metadata("design:type", Boolean) -], LineOfSightBodyDto.prototype, "compact", void 0); -//# sourceMappingURL=line-of-sight.dto.js.map \ No newline at end of file diff --git a/apps/api/dist/tactical/dto/line-of-sight.dto.js.map b/apps/api/dist/tactical/dto/line-of-sight.dto.js.map deleted file mode 100644 index cd94199..0000000 --- a/apps/api/dist/tactical/dto/line-of-sight.dto.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"line-of-sight.dto.js","sourceRoot":"","sources":["../../../src/tactical/dto/line-of-sight.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmE;AACnE,yDAAyC;AACzC,qDAA4E;AAE5E,MAAa,QAAQ;IAInB,GAAG,CAAS;IAKZ,GAAG,CAAS;IAMZ,MAAM,CAAU;CACjB;AAhBD,4BAgBC;AAZC;IAHC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,6BAA6B,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAC/E,IAAA,0BAAQ,GAAE;IACV,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;;qCACP;AAKZ;IAHC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,8BAA8B,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAChF,IAAA,0BAAQ,GAAE;IACV,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;;qCACP;AAMZ;IAJC,IAAA,6B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deleted file mode 100644 index e862abd..0000000 --- a/apps/api/dist/tactical/dto/tactical.dto.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -export declare class ArtilleryMissionRequestDto { - gunLat: number; - gunLng: number; - targetLat: number; - targetLng: number; - gunElevationOffset?: number; - targetElevationOffset?: number; - chargeType?: string; - muzzleVelocity?: number; - caliber?: string; -} -export declare class TacticalSymbolDto { - id: string; - type: string; - name: string; - name_ar: string; - lat: number; - lng: number; - elevation?: number; - notes?: string; - timeAdded: string; -} -export declare class SaveScenarioDto { - name: string; - symbols: TacticalSymbolDto[]; -} diff --git a/apps/api/dist/tactical/dto/tactical.dto.js b/apps/api/dist/tactical/dto/tactical.dto.js deleted file mode 100644 index ec44d34..0000000 --- a/apps/api/dist/tactical/dto/tactical.dto.js +++ /dev/null @@ -1,162 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.SaveScenarioDto = exports.TacticalSymbolDto = exports.ArtilleryMissionRequestDto = void 0; -const swagger_1 = require("@nestjs/swagger"); -const class_transformer_1 = require("class-transformer"); -const class_validator_1 = require("class-validator"); -class ArtilleryMissionRequestDto { - gunLat; - gunLng; - targetLat; - targetLng; - gunElevationOffset; - targetElevationOffset; - chargeType; - muzzleVelocity; - caliber; -} -exports.ArtilleryMissionRequestDto = ArtilleryMissionRequestDto; -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'Gun / Battery Latitude', example: 31.9539 }), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], ArtilleryMissionRequestDto.prototype, "gunLat", void 0); -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'Gun / Battery Longitude', example: 35.9106 }), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], ArtilleryMissionRequestDto.prototype, "gunLng", void 0); -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'Target Latitude', example: 32.01 }), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], ArtilleryMissionRequestDto.prototype, "targetLat", void 0); -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'Target Longitude', example: 35.87 }), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], ArtilleryMissionRequestDto.prototype, "targetLng", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Gun elevation offset above ground in meters', default: 2 }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], ArtilleryMissionRequestDto.prototype, "gunElevationOffset", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Target elevation offset above ground in meters', default: 0 }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], ArtilleryMissionRequestDto.prototype, "targetElevationOffset", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Powder charge type (Low, Med, High)' }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsString)(), - __metadata("design:type", String) -], ArtilleryMissionRequestDto.prototype, "chargeType", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Muzzle velocity in m/s (default: 827 m/s for 155mm Howitzer)', default: 827 }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], ArtilleryMissionRequestDto.prototype, "muzzleVelocity", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Weapon Caliber description', default: '155mm Howitzer' }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsString)(), - __metadata("design:type", String) -], ArtilleryMissionRequestDto.prototype, "caliber", void 0); -class TacticalSymbolDto { - id; - type; - name; - name_ar; - lat; - lng; - elevation; - notes; - timeAdded; -} -exports.TacticalSymbolDto = TacticalSymbolDto; -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'Symbol Unique ID' }), - (0, class_validator_1.IsString)(), - __metadata("design:type", String) -], TacticalSymbolDto.prototype, "id", void 0); -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'Symbol military type' }), - (0, class_validator_1.IsString)(), - __metadata("design:type", String) -], TacticalSymbolDto.prototype, "type", void 0); -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'Name in English' }), - (0, class_validator_1.IsString)(), - __metadata("design:type", String) -], TacticalSymbolDto.prototype, "name", void 0); -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'Name in Arabic' }), - (0, class_validator_1.IsString)(), - __metadata("design:type", String) -], TacticalSymbolDto.prototype, "name_ar", void 0); -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'Latitude' }), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], TacticalSymbolDto.prototype, "lat", void 0); -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'Longitude' }), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], TacticalSymbolDto.prototype, "lng", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Elevation' }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsNumber)(), - (0, class_transformer_1.Type)(() => Number), - __metadata("design:type", Number) -], TacticalSymbolDto.prototype, "elevation", void 0); -__decorate([ - (0, swagger_1.ApiPropertyOptional)({ description: 'Operational Notes' }), - (0, class_validator_1.IsOptional)(), - (0, class_validator_1.IsString)(), - __metadata("design:type", String) -], TacticalSymbolDto.prototype, "notes", void 0); -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'Timestamp added' }), - (0, class_validator_1.IsString)(), - __metadata("design:type", String) -], TacticalSymbolDto.prototype, "timeAdded", void 0); -class SaveScenarioDto { - name; - symbols; -} -exports.SaveScenarioDto = SaveScenarioDto; -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'Scenario Name', example: 'default' }), - (0, class_validator_1.IsString)(), - __metadata("design:type", String) -], SaveScenarioDto.prototype, "name", void 0); -__decorate([ - (0, swagger_1.ApiProperty)({ description: 'List of tactical symbols', type: [TacticalSymbolDto] }), - (0, class_validator_1.IsArray)(), - __metadata("design:type", Array) -], SaveScenarioDto.prototype, "symbols", void 0); -//# sourceMappingURL=tactical.dto.js.map \ No newline at end of file diff --git a/apps/api/dist/tactical/dto/tactical.dto.js.map b/apps/api/dist/tactical/dto/tactical.dto.js.map deleted file mode 100644 index ffaec56..0000000 --- a/apps/api/dist/tactical/dto/tactical.dto.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"tactical.dto.js","sourceRoot":"","sources":["../../../src/tactical/dto/tactical.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmE;AACnE,yDAAyC;AACzC,qDAA0E;AAE1E,MAAa,0BAA0B;IAIrC,MAAM,CAAS;IAKf,MAAM,CAAS;IAKf,SAAS,CAAS;IAKlB,SAAS,CAAS;IAMlB,kBAAkB,CAAU;IAM5B,qBAAqB,CAAU;IAK/B,UAAU,CAAU;IAMpB,cAAc,CAAU;IAKxB,OAAO,CAAU;CAClB;AAhDD,gEAgDC;AA5CC;IAHC,IAAA,qBAAW,EAAC,EAAE,WAAW,EA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C,IAAA,0BAAQ,GAAE;IACV,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;;8CACP;AAMZ;IAJC,IAAA,6BAAmB,EAAC,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;IACjD,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;;oDACA;AAKnB;IAHC,IAAA,6BAAmB,EAAC,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;IACzD,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;gDACI;AAIf;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;IAC/C,IAAA,0BAAQ,GAAE;;oDACO;AAGpB,MAAa,eAAe;IAG1B,IAAI,CAAS;IAIb,OAAO,CAAsB;CAC9B;AARD,0CAQC;AALC;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IACjE,IAAA,0BAAQ,GAAE;;6CACE;AAIb;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,0BAA0B,EAAE,IAAI,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC;IACnF,IAAA,yBAAO,GAAE;;gDACmB"} \ No newline at end of file diff --git a/apps/api/dist/tactical/tactical.controller.d.ts b/apps/api/dist/tactical/tactical.controller.d.ts deleted file mode 100644 index 832f047..0000000 --- a/apps/api/dist/tactical/tactical.controller.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { LineOfSightBodyDto, LineOfSightQueryDto } from './dto/line-of-sight.dto'; -import { ArtilleryMissionRequestDto, SaveScenarioDto } from './dto/tactical.dto'; -import { TacticalService } from './tactical.service'; -export declare class TacticalController { - private readonly tacticalService; - constructor(tacticalService: TacticalService); - getLineOfSight(query: LineOfSightQueryDto): Promise<import("./tactical.service").LineOfSightResponse>; - getLosAlias(query: LineOfSightQueryDto): Promise<import("./tactical.service").LineOfSightResponse>; - postLineOfSight(body: LineOfSightBodyDto): Promise<import("./tactical.service").LineOfSightResponse>; - postLosAlias(body: LineOfSightBodyDto): Promise<import("./tactical.service").LineOfSightResponse>; - calculateArtilleryFireMission(dto: ArtilleryMissionRequestDto): Promise<{ - fireMissionId: string; - caliber: string; - muzzleVelocityMs: number; - distanceMeters: number; - distanceKm: number; - azimuthDegrees: number; - azimuthMils: number; - gunElevationMeters: number; - targetElevationMeters: number; - apexAltitudeMeters: number; - timeOfFlightSeconds: number; - lowAngle: { - degrees: number; - mils: number; - }; - highAngle: { - degrees: number; - mils: number; - }; - hasCrestClearance: boolean; - criticalObstacle: any; - trajectoryPoints: any[]; - }>; - assessHLZ(lat: string, lng: string, radius?: string): Promise<{ - centerLat: number; - centerLng: number; - searchRadiusMeters: number; - totalAssessed: number; - suitableCount: number; - zones: any[]; - }>; - saveScenario(body: SaveScenarioDto): Promise<{ - success: boolean; - count: number; - name: string; - }>; - getScenario(name?: string): Promise<import("./dto/tactical.dto").TacticalSymbolDto[]>; -} diff --git a/apps/api/dist/tactical/tactical.controller.js b/apps/api/dist/tactical/tactical.controller.js deleted file mode 100644 index a45182b..0000000 --- a/apps/api/dist/tactical/tactical.controller.js +++ /dev/null @@ -1,164 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.TacticalController = void 0; -const common_1 = require("@nestjs/common"); -const swagger_1 = require("@nestjs/swagger"); -const api_key_guard_1 = require("../common/guards/api-key.guard"); -const rate_limiter_guard_1 = require("../common/guards/rate-limiter.guard"); -const line_of_sight_dto_1 = require("./dto/line-of-sight.dto"); -const tactical_dto_1 = require("./dto/tactical.dto"); -const tactical_service_1 = require("./tactical.service"); -let TacticalController = class TacticalController { - tacticalService; - constructor(tacticalService) { - this.tacticalService = tacticalService; - } - async getLineOfSight(query) { - const { observerLat, observerLng, targetLat, targetLng, observerHeight = 2, targetHeight = 2, samples, stepMeters, compact = false, } = query; - if (observerLat == null || observerLng == null || targetLat == null || targetLng == null) { - throw new common_1.HttpException('Missing required parameters: observerLat, observerLng, targetLat, targetLng', common_1.HttpStatus.BAD_REQUEST); - } - return this.tacticalService.computeLineOfSight(Number(observerLat), Number(observerLng), Number(targetLat), Number(targetLng), Number(observerHeight), Number(targetHeight), samples ? Number(samples) : undefined, stepMeters ? Number(stepMeters) : undefined, Boolean(compact)); - } - async getLosAlias(query) { - return this.getLineOfSight(query); - } - async postLineOfSight(body) { - const obsLat = body.observer?.lat ?? body.observerLat; - const obsLng = body.observer?.lng ?? body.observerLng; - const obsHeight = body.observer?.height ?? body.observerHeight ?? 2; - const tgtLat = body.target?.lat ?? body.targetLat; - const tgtLng = body.target?.lng ?? body.targetLng; - const tgtHeight = body.target?.height ?? body.targetHeight ?? 2; - const samples = body.samples; - const stepMeters = body.stepMeters; - const compact = body.compact ?? false; - if (obsLat == null || obsLng == null || tgtLat == null || tgtLng == null) { - throw new common_1.HttpException('Missing required parameters: observer coordinates (lat, lng) and target coordinates (lat, lng)', common_1.HttpStatus.BAD_REQUEST); - } - return this.tacticalService.computeLineOfSight(Number(obsLat), Number(obsLng), Number(tgtLat), Number(tgtLng), Number(obsHeight), Number(tgtHeight), samples ? Number(samples) : undefined, stepMeters ? Number(stepMeters) : undefined, Boolean(compact)); - } - async postLosAlias(body) { - return this.postLineOfSight(body); - } - async calculateArtilleryFireMission(dto) { - return this.tacticalService.calculateArtilleryFireMission(dto); - } - async assessHLZ(lat, lng, radius) { - const latNum = parseFloat(lat || '31.95'); - const lngNum = parseFloat(lng || '35.93'); - const radiusNum = parseFloat(radius || '3000'); - return this.tacticalService.assessHelicopterLandingZones(latNum, lngNum, radiusNum); - } - async saveScenario(body) { - return this.tacticalService.saveScenario(body.name || 'default', body.symbols || []); - } - async getScenario(name) { - return this.tacticalService.getScenario(name || 'default'); - } -}; -exports.TacticalController = TacticalController; -__decorate([ - (0, common_1.Get)('line-of-sight'), - (0, swagger_1.ApiOperation)({ - summary: 'Calculate Tactical Line of Sight & Intervisibility (تبادل الرؤية العسكري)', - description: 'Calculates line of sight between Observer (Point A) and Target (Point B) accounting for elevation profile, Earth curvature, atmospheric refraction, dead ground, and obstacle penetration.', - }), - __param(0, (0, common_1.Query)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [line_of_sight_dto_1.LineOfSightQueryDto]), - __metadata("design:returntype", Promise) -], TacticalController.prototype, "getLineOfSight", null); -__decorate([ - (0, common_1.Get)('los'), - (0, swagger_1.ApiOperation)({ summary: 'Alias for line-of-sight GET' }), - __param(0, (0, common_1.Query)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [line_of_sight_dto_1.LineOfSightQueryDto]), - __metadata("design:returntype", Promise) -], TacticalController.prototype, "getLosAlias", null); -__decorate([ - (0, common_1.Post)('line-of-sight'), - (0, swagger_1.ApiOperation)({ - summary: 'Calculate Tactical Line of Sight via POST JSON body', - description: 'Accepts structured observer and target objects or flat coordinate keys.', - }), - __param(0, (0, common_1.Body)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [line_of_sight_dto_1.LineOfSightBodyDto]), - __metadata("design:returntype", Promise) -], TacticalController.prototype, "postLineOfSight", null); -__decorate([ - (0, common_1.Post)('los'), - (0, swagger_1.ApiOperation)({ summary: 'Alias for line-of-sight POST' }), - __param(0, (0, common_1.Body)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [line_of_sight_dto_1.LineOfSightBodyDto]), - __metadata("design:returntype", Promise) -], TacticalController.prototype, "postLosAlias", null); -__decorate([ - (0, common_1.Post)('artillery-fire-mission'), - (0, swagger_1.ApiOperation)({ - summary: 'Calculate Artillery Fire Mission & Ballistic Trajectory / حساب رماية المدفعية ومسار القذيفة', - }), - __param(0, (0, common_1.Body)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [tactical_dto_1.ArtilleryMissionRequestDto]), - __metadata("design:returntype", Promise) -], TacticalController.prototype, "calculateArtilleryFireMission", null); -__decorate([ - (0, common_1.Get)('hlz-assessment'), - (0, swagger_1.ApiOperation)({ - summary: 'Assess Helicopter Landing Zones (HLZ) & MEDEVAC / كشف صلاحية مهابط المروحيات والإخلاء الطبي', - }), - __param(0, (0, common_1.Query)('lat')), - __param(1, (0, common_1.Query)('lng')), - __param(2, (0, common_1.Query)('radius')), - __metadata("design:type", Function), - __metadata("design:paramtypes", [String, String, String]), - __metadata("design:returntype", Promise) -], TacticalController.prototype, "assessHLZ", null); -__decorate([ - (0, common_1.Post)('scenarios'), - (0, swagger_1.ApiOperation)({ - summary: 'Save tactical symbols scenario / حفظ سيناريو الرموز التكتيكية', - }), - __param(0, (0, common_1.Body)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [tactical_dto_1.SaveScenarioDto]), - __metadata("design:returntype", Promise) -], TacticalController.prototype, "saveScenario", null); -__decorate([ - (0, common_1.Get)('scenarios'), - (0, swagger_1.ApiOperation)({ - summary: 'Get saved tactical symbols scenario / استرجاع سيناريو الرموز التكتيكية', - }), - __param(0, (0, common_1.Query)('name')), - __metadata("design:type", Function), - __metadata("design:paramtypes", [String]), - __metadata("design:returntype", Promise) -], TacticalController.prototype, "getScenario", null); -exports.TacticalController = TacticalController = __decorate([ - (0, swagger_1.ApiTags)('tactical'), - (0, swagger_1.ApiHeader)({ - name: 'x-api-key', - description: 'Multi-tenant API Key for Intaleq Maps SaaS', - required: true, - }), - (0, common_1.Controller)('tactical'), - (0, common_1.UseGuards)(api_key_guard_1.ApiKeyGuard, rate_limiter_guard_1.TenantThrottlerGuard), - __metadata("design:paramtypes", [tactical_service_1.TacticalService]) -], TacticalController); -//# sourceMappingURL=tactical.controller.js.map \ No newline at end of file diff --git a/apps/api/dist/tactical/tactical.controller.js.map b/apps/api/dist/tactical/tactical.controller.js.map deleted file mode 100644 index 268df40..0000000 --- a/apps/api/dist/tactical/tactical.controller.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"tactical.controller.js","sourceRoot":"","sources":["../../src/tactical/tactical.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CASwB;AACxB,6CAAmE;AACnE,kEAA6D;AAC7D,4EAA2E;AAC3E,+DAAkF;AAClF,qDAAiF;AACjF,yDAAqD;AAU9C,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IACA;IAA7B,YAA6B,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;IAAG,CAAC;IAQ3D,AAAN,KAAK,CAAC,cAAc,CAAU,KAA0B;QACtD,MAAM,EACJ,WAAW,EACX,WAAW,EACX,SAAS,EACT,SAAS,EACT,cAAc,GAAG,CAAC,EAClB,YAAY,GAAG,CAAC,EAChB,OAAO,EACP,UAAU,EACV,OAAO,GAAG,KAAK,GAChB,GAAG,KAAK,CAAC;QAEV,IAAI,WAAW,IAAI,IAAI,IAAI,WAAW,IAAI,IAAI,IAAI,SAAS,IAAI,IAAI,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YACzF,MAAM,IAAI,sBAAa,CACrB,6EAA6E,EAC7E,mBAAU,CAAC,WAAW,CACvB,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAC5C,MAAM,CAAC,WAAW,CAAC,EACnB,MAAM,CAAC,WAAW,CA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C,gBAAgB,CAAC;IACrB,IAAA,sBAAY,EAAC;QACZ,OAAO,EAAE,6FAA6F;KACvG,CAAC;IAEC,WAAA,IAAA,cAAK,EAAC,KAAK,CAAC,CAAA;IACZ,WAAA,IAAA,cAAK,EAAC,KAAK,CAAC,CAAA;IACZ,WAAA,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAA;;;;mDAMjB;AAMK;IAJL,IAAA,aAAI,EAAC,WAAW,CAAC;IACjB,IAAA,sBAAY,EAAC;QACZ,OAAO,EAAE,+DAA+D;KACzE,CAAC;IACkB,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAO,8BAAe;;sDAE/C;AAMK;IAJL,IAAA,YAAG,EAAC,WAAW,CAAC;IAChB,IAAA,sBAAY,EAAC;QACZ,OAAO,EAAE,wEAAwE;KAClF,CAAC;IACiB,WAAA,IAAA,cAAK,EAAC,MAAM,CAAC,CAAA;;;;qDAE/B;6BAjIU,kBAAkB;IAR9B,IAAA,iBAAO,EAAC,UAAU,CAAC;IACnB,IAAA,mBAAS,EAAC;QACT,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,4CAA4C;QACzD,QAAQ,EAAE,IAAI;KACf,CAAC;IACD,IAAA,mBAAU,EAAC,UAAU,CAAC;IACtB,IAAA,kBAAS,EAAC,2BAAW,EAAE,yCAAoB,CAAC;qCAEG,kCAAe;GADlD,kBAAkB,CAkI9B"} \ No newline at end of file diff --git a/apps/api/dist/tactical/tactical.module.d.ts b/apps/api/dist/tactical/tactical.module.d.ts deleted file mode 100644 index 87876ea..0000000 --- a/apps/api/dist/tactical/tactical.module.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare class TacticalModule { -} diff --git a/apps/api/dist/tactical/tactical.module.js b/apps/api/dist/tactical/tactical.module.js deleted file mode 100644 index c320a2e..0000000 --- a/apps/api/dist/tactical/tactical.module.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.TacticalModule = void 0; -const common_1 = require("@nestjs/common"); -const tactical_controller_1 = require("./tactical.controller"); -const tactical_service_1 = require("./tactical.service"); -const redis_module_1 = require("../common/redis.module"); -let TacticalModule = class TacticalModule { -}; -exports.TacticalModule = TacticalModule; -exports.TacticalModule = TacticalModule = __decorate([ - (0, common_1.Module)({ - imports: [redis_module_1.RedisModule], - controllers: [tactical_controller_1.TacticalController], - providers: [tactical_service_1.TacticalService], - exports: [tactical_service_1.TacticalService], - }) -], TacticalModule); -//# sourceMappingURL=tactical.module.js.map \ No newline at end of file diff --git a/apps/api/dist/tactical/tactical.module.js.map b/apps/api/dist/tactical/tactical.module.js.map deleted file mode 100644 index b9fd4d8..0000000 --- a/apps/api/dist/tactical/tactical.module.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"tactical.module.js","sourceRoot":"","sources":["../../src/tactical/tactical.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,+DAA2D;AAC3D,yDAAqD;AACrD,yDAAqD;AAQ9C,IAAM,cAAc,GAApB,MAAM,cAAc;CAAG,CAAA;AAAjB,wCAAc;yBAAd,cAAc;IAN1B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,0BAAW,CAAC;QACtB,WAAW,EAAE,CAAC,wCAAkB,CAAC;QACjC,SAAS,EAAE,CAAC,kCAAe,CAAC;QAC5B,OAAO,EAAE,CAAC,kCAAe,CAAC;KAC3B,CAAC;GACW,cAAc,CAAG"} \ No newline at end of file diff --git a/apps/api/dist/tactical/tactical.service.d.ts b/apps/api/dist/tactical/tactical.service.d.ts deleted file mode 100644 index fc99b91..0000000 --- a/apps/api/dist/tactical/tactical.service.d.ts +++ /dev/null @@ -1,108 +0,0 @@ -import { RedisService } from '../common/redis.service'; -import { ArtilleryMissionRequestDto, TacticalSymbolDto } from './dto/tactical.dto'; -export interface LosPoint { - index: number; - distanceMeters: number; - lat: number; - lng: number; - groundElevationMeters: number; - earthCurvatureSagittaMeters: number; - apparentElevationMeters: number; - sightRayElevationMeters: number; - marginMeters: number; - isVisible: boolean; - isDeadGround: boolean; - horizonAngleMils: number; -} -export interface LineOfSightResponse { - isDirectlyVisible: boolean; - status: 'CLEAR_LINE_OF_SIGHT' | 'OBSTRUCTED'; - statusAr: string; - summary: { - totalDistanceMeters: number; - totalDistanceKm: number; - azimuthDegrees: number; - verticalAngleDegrees: number; - verticalAngleMilsNato: number; - verticalAngleMilsSoviet: number; - observerGroundElevationMeters: number; - observerTotalElevationMeters: number; - targetGroundElevationMeters: number; - targetTotalElevationMeters: number; - minElevationMeters: number; - maxElevationMeters: number; - deadGroundPercentage: number; - samplePointsCount: number; - stepMeters?: number; - }; - highestObstacle: { - distanceMeters: number; - lat: number; - lng: number; - elevationMeters: number; - sightRayElevationMeters: number; - penetrationMeters: number; - } | null; - observer: { - lat: number; - lng: number; - heightOffsetMeters: number; - groundElevationMeters: number; - totalElevationMeters: number; - }; - target: { - lat: number; - lng: number; - heightOffsetMeters: number; - groundElevationMeters: number; - totalElevationMeters: number; - }; - profile?: LosPoint[]; -} -export declare class TacticalService { - private readonly redisService; - private readonly logger; - constructor(redisService: RedisService); - computeLineOfSight(observerLat: number, observerLng: number, targetLat: number, targetLng: number, observerHeight?: number, targetHeight?: number, samplesCount?: number, stepMeters?: number, compact?: boolean): Promise<LineOfSightResponse>; - calculateArtilleryFireMission(dto: ArtilleryMissionRequestDto): Promise<{ - fireMissionId: string; - caliber: string; - muzzleVelocityMs: number; - distanceMeters: number; - distanceKm: number; - azimuthDegrees: number; - azimuthMils: number; - gunElevationMeters: number; - targetElevationMeters: number; - apexAltitudeMeters: number; - timeOfFlightSeconds: number; - lowAngle: { - degrees: number; - mils: number; - }; - highAngle: { - degrees: number; - mils: number; - }; - hasCrestClearance: boolean; - criticalObstacle: any; - trajectoryPoints: any[]; - }>; - assessHelicopterLandingZones(lat: number, lng: number, radiusMeters?: number): Promise<{ - centerLat: number; - centerLng: number; - searchRadiusMeters: number; - totalAssessed: number; - suitableCount: number; - zones: any[]; - }>; - saveScenario(name: string, symbols: TacticalSymbolDto[]): Promise<{ - success: boolean; - count: number; - name: string; - }>; - getScenario(name: string): Promise<TacticalSymbolDto[]>; - private haversineDistance; - private calculateBearing; - private estimateElevation; -} diff --git a/apps/api/dist/tactical/tactical.service.js b/apps/api/dist/tactical/tactical.service.js deleted file mode 100644 index 3ecaf7a..0000000 --- a/apps/api/dist/tactical/tactical.service.js +++ /dev/null @@ -1,353 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var TacticalService_1; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.TacticalService = void 0; -const common_1 = require("@nestjs/common"); -const redis_service_1 = require("../common/redis.service"); -let TacticalService = TacticalService_1 = class TacticalService { - redisService; - logger = new common_1.Logger(TacticalService_1.name); - constructor(redisService) { - this.redisService = redisService; - } - async computeLineOfSight(observerLat, observerLng, targetLat, targetLng, observerHeight = 2, targetHeight = 2, samplesCount, stepMeters, compact = false) { - const totalDistanceMeters = this.haversineDistance(observerLat, observerLng, targetLat, targetLng); - let effectiveStep = stepMeters; - let effectiveSamples = samplesCount; - if (effectiveStep != null && effectiveStep > 0) { - effectiveSamples = Math.max(5, Math.min(300, Math.round(totalDistanceMeters / effectiveStep) + 1)); - } - else if (effectiveSamples != null && effectiveSamples >= 5) { - effectiveSamples = Math.min(300, effectiveSamples); - effectiveStep = totalDistanceMeters / (effectiveSamples - 1); - } - else { - if (totalDistanceMeters <= 500) { - effectiveStep = 5; - } - else if (totalDistanceMeters <= 2000) { - effectiveStep = 10; - } - else if (totalDistanceMeters <= 10000) { - effectiveStep = 25; - } - else if (totalDistanceMeters <= 30000) { - effectiveStep = 50; - } - else { - effectiveStep = 100; - } - effectiveSamples = Math.max(10, Math.min(200, Math.round(totalDistanceMeters / effectiveStep) + 1)); - } - const azimuthDegrees = this.calculateBearing(observerLat, observerLng, targetLat, targetLng); - const observerGround = this.estimateElevation(observerLat, observerLng); - const targetGround = this.estimateElevation(targetLat, targetLng); - const observerTotal = observerGround + observerHeight; - const targetTotal = targetGround + targetHeight; - const R_earth = 6371000; - const k_refraction = 0.13; - const effectiveRadius = R_earth / (1 - k_refraction); - const points = []; - let isDirectlyVisible = true; - let highestObstacle = null; - let maxPenetration = 0; - let minElev = Math.min(observerGround, targetGround); - let maxElev = Math.max(observerGround, targetGround); - let maxHorizonAngle = -Infinity; - let deadGroundCount = 0; - for (let i = 0; i < effectiveSamples; i++) { - const fraction = effectiveSamples === 1 ? 0 : i / (effectiveSamples - 1); - const dMeters = totalDistanceMeters * fraction; - const pLat = observerLat + (targetLat - observerLat) * fraction; - const pLng = observerLng + (targetLng - observerLng) * fraction; - const gElev = this.estimateElevation(pLat, pLng); - minElev = Math.min(minElev, gElev); - maxElev = Math.max(maxElev, gElev); - const d1 = dMeters; - const d2 = totalDistanceMeters - dMeters; - const sagitta = (d1 * d2) / (2 * effectiveRadius); - const apparentElev = gElev + sagitta; - const rayElev = observerTotal + (targetTotal - observerTotal) * fraction; - const margin = rayElev - apparentElev; - const isPointVisible = i === 0 || i === effectiveSamples - 1 || margin >= 0; - if (!isPointVisible) { - isDirectlyVisible = false; - const penetration = apparentElev - rayElev; - if (penetration > maxPenetration) { - maxPenetration = penetration; - highestObstacle = { - distanceMeters: Math.round(dMeters), - lat: Number(pLat.toFixed(6)), - lng: Number(pLng.toFixed(6)), - elevationMeters: Math.round(gElev), - sightRayElevationMeters: Math.round(rayElev), - penetrationMeters: Math.round(penetration * 10) / 10, - }; - } - } - const angleFromObserver = dMeters > 0 ? (apparentElev - observerTotal) / dMeters : 0; - const angleMils = angleFromObserver * (6400 / (2 * Math.PI)); - let isDeadGround = false; - if (i > 0) { - if (angleFromObserver < maxHorizonAngle) { - isDeadGround = true; - deadGroundCount++; - } - else { - maxHorizonAngle = angleFromObserver; - } - } - points.push({ - index: i, - distanceMeters: Math.round(dMeters), - lat: Number(pLat.toFixed(6)), - lng: Number(pLng.toFixed(6)), - groundElevationMeters: Math.round(gElev), - earthCurvatureSagittaMeters: Math.round(sagitta * 10) / 10, - apparentElevationMeters: Math.round(apparentElev * 10) / 10, - sightRayElevationMeters: Math.round(rayElev * 10) / 10, - marginMeters: Math.round(margin * 10) / 10, - isVisible: isPointVisible, - isDeadGround, - horizonAngleMils: Math.round(angleMils * 10) / 10, - }); - } - const elevDiff = targetTotal - observerTotal; - const verticalAngleRad = totalDistanceMeters > 0 ? Math.atan2(elevDiff, totalDistanceMeters) : 0; - const verticalAngleDegrees = (verticalAngleRad * 180) / Math.PI; - const verticalAngleMilsNato = (verticalAngleRad * 6400) / (2 * Math.PI); - const verticalAngleMilsSoviet = (verticalAngleRad * 6000) / (2 * Math.PI); - const deadGroundPercentage = effectiveSamples > 1 - ? Math.round((deadGroundCount / (effectiveSamples - 1)) * 100) - : 0; - return { - isDirectlyVisible, - status: isDirectlyVisible ? 'CLEAR_LINE_OF_SIGHT' : 'OBSTRUCTED', - statusAr: isDirectlyVisible ? 'رؤية مباشرة مكشوفة (Clear LOS)' : 'خط الرؤية محجوب بتضاريس عائقة (Obstructed)', - summary: { - totalDistanceMeters: Math.round(totalDistanceMeters), - totalDistanceKm: Math.round((totalDistanceMeters / 1000) * 100) / 100, - azimuthDegrees: Math.round(azimuthDegrees * 10) / 10, - verticalAngleDegrees: Math.round(verticalAngleDegrees * 100) / 100, - verticalAngleMilsNato: Math.round(verticalAngleMilsNato * 10) / 10, - verticalAngleMilsSoviet: Math.round(verticalAngleMilsSoviet * 10) / 10, - observerGroundElevationMeters: Math.round(observerGround), - observerTotalElevationMeters: Math.round(observerTotal), - targetGroundElevationMeters: Math.round(targetGround), - targetTotalElevationMeters: Math.round(targetTotal), - minElevationMeters: Math.round(minElev), - maxElevationMeters: Math.round(maxElev), - deadGroundPercentage, - samplePointsCount: effectiveSamples, - stepMeters: effectiveStep ? Math.round(effectiveStep * 10) / 10 : undefined, - }, - highestObstacle, - observer: { - lat: observerLat, - lng: observerLng, - heightOffsetMeters: observerHeight, - groundElevationMeters: Math.round(observerGround), - totalElevationMeters: Math.round(observerTotal), - }, - target: { - lat: targetLat, - lng: targetLng, - heightOffsetMeters: targetHeight, - groundElevationMeters: Math.round(targetGround), - totalElevationMeters: Math.round(targetTotal), - }, - ...(compact ? {} : { profile: points }), - }; - } - async calculateArtilleryFireMission(dto) { - const { gunLat, gunLng, targetLat, targetLng, gunElevationOffset = 2, targetElevationOffset = 0, muzzleVelocity = 827, caliber = '155mm Howitzer', } = dto; - const distanceMeters = this.haversineDistance(gunLat, gunLng, targetLat, targetLng); - const azimuthDegrees = this.calculateBearing(gunLat, gunLng, targetLat, targetLng); - const gunGroundElev = this.estimateElevation(gunLat, gunLng); - const targetGroundElev = this.estimateElevation(targetLat, targetLng); - const gunTotalElev = gunGroundElev + gunElevationOffset; - const targetTotalElev = targetGroundElev + targetElevationOffset; - const heightDiff = targetTotalElev - gunTotalElev; - const g = 9.80665; - const v0 = muzzleVelocity; - const term = Math.pow(v0, 4) - g * (g * Math.pow(distanceMeters, 2) + 2 * heightDiff * Math.pow(v0, 2)); - let lowAngleRad = 0; - let highAngleRad = 0; - const maxRange = Math.pow(v0, 2) / g; - const isInRange = term >= 0 && distanceMeters <= maxRange; - if (isInRange) { - const sqrtTerm = Math.sqrt(term); - lowAngleRad = Math.atan((Math.pow(v0, 2) - sqrtTerm) / (g * distanceMeters)); - highAngleRad = Math.atan((Math.pow(v0, 2) + sqrtTerm) / (g * distanceMeters)); - } - else { - lowAngleRad = (45 * Math.PI) / 180; - highAngleRad = (60 * Math.PI) / 180; - } - const lowAngleDeg = (lowAngleRad * 180) / Math.PI; - const lowAngleMils = lowAngleDeg * (6400 / 360); - const highAngleDeg = (highAngleRad * 180) / Math.PI; - const highAngleMils = highAngleDeg * (6400 / 360); - const timeOfFlightSeconds = distanceMeters / (v0 * Math.cos(lowAngleRad)); - const apexHeightMeters = gunTotalElev + Math.pow(v0 * Math.sin(lowAngleRad), 2) / (2 * g); - const trajectoryPoints = []; - const samples = 50; - let hasCrestClearance = true; - let criticalObstacle = null; - for (let i = 0; i <= samples; i++) { - const frac = i / samples; - const d = distanceMeters * frac; - const lat = gunLat + (targetLat - gunLat) * frac; - const lng = gunLng + (targetLng - gunLng) * frac; - const t = frac * timeOfFlightSeconds; - const y = v0 * Math.sin(lowAngleRad) * t - 0.5 * g * Math.pow(t, 2); - const projectileAlt = gunTotalElev + y; - const terrainElev = this.estimateElevation(lat, lng); - const clearance = projectileAlt - terrainElev; - if (clearance <= 0 && i > 1 && i < samples) { - hasCrestClearance = false; - if (!criticalObstacle || clearance < criticalObstacle.clearance) { - criticalObstacle = { - distanceMeters: Math.round(d), - terrainElevMeters: Math.round(terrainElev), - projectileAltMeters: Math.round(projectileAlt), - deficitMeters: Math.round(Math.abs(clearance)), - lat, - lng, - }; - } - } - trajectoryPoints.push({ - distanceMeters: Math.round(d), - lat, - lng, - terrainElevation: Math.round(terrainElev), - projectileAltitude: Math.round(projectileAlt), - clearanceMeters: Math.round(clearance), - }); - } - return { - fireMissionId: `FM-${Date.now().toString().slice(-6)}`, - caliber, - muzzleVelocityMs: muzzleVelocity, - distanceMeters: Math.round(distanceMeters), - distanceKm: Math.round((distanceMeters / 1000) * 100) / 100, - azimuthDegrees: Math.round(azimuthDegrees * 10) / 10, - azimuthMils: Math.round((azimuthDegrees * (6400 / 360)) * 10) / 10, - gunElevationMeters: Math.round(gunTotalElev), - targetElevationMeters: Math.round(targetTotalElev), - apexAltitudeMeters: Math.round(apexHeightMeters), - timeOfFlightSeconds: Math.round(timeOfFlightSeconds * 10) / 10, - lowAngle: { - degrees: Math.round(lowAngleDeg * 100) / 100, - mils: Math.round(lowAngleMils * 10) / 10, - }, - highAngle: { - degrees: Math.round(highAngleDeg * 100) / 100, - mils: Math.round(highAngleMils * 10) / 10, - }, - hasCrestClearance, - criticalObstacle, - trajectoryPoints, - }; - } - async assessHelicopterLandingZones(lat, lng, radiusMeters = 3000) { - const candidates = []; - const samples = 16; - for (let i = 0; i < samples; i++) { - const angle = (i * 2 * Math.PI) / samples; - const r = radiusMeters * 0.3 + Math.random() * (radiusMeters * 0.6); - const dLat = (r / 6371000) * (180 / Math.PI) * Math.cos(angle); - const dLng = (r / (6371000 * Math.cos((lat * Math.PI) / 180))) * (180 / Math.PI) * Math.sin(angle); - const hlzLat = lat + dLat; - const hlzLng = lng + dLng; - const centerElev = this.estimateElevation(hlzLat, hlzLng); - const northElev = this.estimateElevation(hlzLat + 0.0005, hlzLng); - const eastElev = this.estimateElevation(hlzLat, hlzLng + 0.0005); - const slopeDeg = Math.round(Math.atan(Math.max(Math.abs(northElev - centerElev), Math.abs(eastElev - centerElev)) / 50) * - (180 / Math.PI) * - 10) / 10; - const isSuitable = slopeDeg <= 7.0; - candidates.push({ - id: `HLZ-${i + 1}`, - lat: hlzLat, - lng: hlzLng, - elevationMeters: Math.round(centerElev), - distanceMeters: Math.round(r), - slopeDegrees: slopeDeg, - suitability: isSuitable ? 'EXCELLENT' : slopeDeg <= 12 ? 'MARGINAL' : 'UNSUITABLE', - suitability_ar: isSuitable ? 'ممتاز (مستوي وخالي من العوائق)' : slopeDeg <= 12 ? 'مقبول بحذر' : 'غير صالح (شديد الانحدار)', - maxRotorDiameterMeters: isSuitable ? 25 : 15, - windApproachBearingDeg: Math.round(Math.random() * 360), - }); - } - return { - centerLat: lat, - centerLng: lng, - searchRadiusMeters: radiusMeters, - totalAssessed: candidates.length, - suitableCount: candidates.filter((c) => c.suitability === 'EXCELLENT').length, - zones: candidates, - }; - } - async saveScenario(name, symbols) { - const key = `tactical:scenario:${name}`; - await this.redisService.set(key, JSON.stringify(symbols), 86400 * 7); - return { success: true, count: symbols.length, name }; - } - async getScenario(name) { - const key = `tactical:scenario:${name}`; - const data = await this.redisService.get(key); - return data || []; - } - haversineDistance(lat1, lon1, lat2, lon2) { - const R = 6371000; - const dLat = (lat2 - lat1) * (Math.PI / 180); - const dLon = (lon2 - lon1) * (Math.PI / 180); - const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + - Math.cos(lat1 * (Math.PI / 180)) * - Math.cos(lat2 * (Math.PI / 180)) * - Math.sin(dLon / 2) * - Math.sin(dLon / 2); - return R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); - } - calculateBearing(lat1, lon1, lat2, lon2) { - const phi1 = (lat1 * Math.PI) / 180; - const phi2 = (lat2 * Math.PI) / 180; - const deltaLambda = ((lon2 - lon1) * Math.PI) / 180; - const y = Math.sin(deltaLambda) * Math.cos(phi2); - const x = Math.cos(phi1) * Math.sin(phi2) - - Math.sin(phi1) * Math.cos(phi2) * Math.cos(deltaLambda); - return ((Math.atan2(y, x) * 180) / Math.PI + 360) % 360; - } - estimateElevation(lat, lng) { - if (lng < 35.6 && lat < 32.2 && lat > 31.0) { - return -400 + Math.abs(lng - 35.5) * 3000; - } - if (lat >= 32.1 && lng < 36.0) { - return 850 + Math.sin(lat * 50) * 250 + Math.cos(lng * 40) * 150; - } - if (lat >= 31.8 && lat < 32.1 && lng >= 35.8 && lng < 36.2) { - return 900 + Math.sin((lat - 31.95) * 100) * 120 + Math.cos((lng - 35.9) * 100) * 100; - } - if (lat < 31.5 && lat > 30.0 && lng < 35.7) { - return 1100 + Math.sin(lat * 30) * 350; - } - return 650 + (lng - 36.0) * 30; - } -}; -exports.TacticalService = TacticalService; -exports.TacticalService = TacticalService = TacticalService_1 = __decorate([ - (0, common_1.Injectable)(), - __metadata("design:paramtypes", [redis_service_1.RedisService]) -], TacticalService); -//# sourceMappingURL=tactical.service.js.map \ No newline at end of file diff --git a/apps/api/dist/tactical/tactical.service.js.map b/apps/api/dist/tactical/tactical.service.js.map deleted file mode 100644 index 29b8b3c..0000000 --- a/apps/api/dist/tactical/tactical.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"tactical.service.js","sourceRoot":"","sources":["../../src/tactical/tactical.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,2DAAuD;AAiEhD,IAAM,eAAe,uBAArB,MAAM,eAAe;IAGG;IAFZ,MAAM,GAAG,IAAI,eAAM,CAAC,iBAAe,CAAC,IAAI,CAAC,CAAC;IAE3D,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAK3D,KAAK,CAAC,kBAAkB,CACtB,WAAmB,EACnB,WAAmB,EACnB,SAAiB,EACjB,SAAiB,EACjB,iBAAyB,CAAC,EAC1B,eAAuB,CAAC,EACxB,YAAqB,EACrB,UAAmB,EACnB,UAAmB,KAAK;QAExB,MAAM,mBAAmB,GAAG,IAAI,CAAC,iBAAiB,CAChD,WAAW,EACX,WAAW,EACX,SAAS,EACT,SAAS,CACV,CAAC;QAEF,IAAI,aAAa,GAAG,UAAU,CAAC;QAC/B,IAAI,gBAAgB,GAAG,YAAY,CAAC;QAEpC,IAAI,aAAa,IAAI,IAAI,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;YAC/C,gBAAgB,GAAG,IAAI,CAAC,GAAG,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,IAAI,GAAG,GAAG,IAAI,EAAE,CAAC;YAC3D,OAAO,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;QACxF,CAAC;QACD,IAAI,GAAG,GAAG,IAAI,IAAI,GAAG,GAAG,IAAI,IAAI,GAAG,GAAG,IAAI,EAAE,CAAC;YAC3C,OAAO,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC;QACzC,CAAC;QACD,OAAO,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACjC,CAAC;CACF,CAAA;AAnaY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;qCAIgC,4BAAY;GAH5C,eAAe,CAma3B"} \ No newline at end of file diff --git a/apps/api/dist/tsconfig.build.tsbuildinfo b/apps/api/dist/tsconfig.build.tsbuildinfo deleted file mode 100644 index f4bc702..0000000 --- a/apps/api/dist/tsconfig.build.tsbuildinfo +++ /dev/null @@ -1 +0,0 @@ -{"fileNames":["../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es5.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2015.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2016.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2017.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2018.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2019.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2020.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2021.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2022.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2023.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.dom.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.dom.asynciterable.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.scripthost.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2021.string.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2022.array.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2022.error.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2022.object.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2022.string.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2023.array.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2023.collection.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2023.intl.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.decorators.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../../../../../../usr/local/lib/node_modules/@nestjs/cli/node_modules/typescript/lib/lib.es2023.full.d.ts","../src/app.service.ts","../src/app.controller.ts","../src/maps/road-speed-profile.entity.ts","../src/maps/road-stat.entity.ts","../src/maps/traffic-grid.service.ts","../src/geocoding/entities/base-place.entity.ts","../src/geocoding/entities/place-syria.entity.ts","../src/geocoding/entities/place-jordan.entity.ts","../src/geocoding/entities/place-egypt.entity.ts","../src/geocoding/entities/place-iraq.entity.ts","../src/geocoding/entities/osm-area.entity.ts","../src/geocoding/entities/osm-point-with-area.entity.ts","../src/geocoding/geocoding.service.ts","../src/common/redis.service.ts","../src/maps/maps.service.ts","../src/auth/entities/tenant.entity.ts","../src/auth/entities/api-key.entity.ts","../src/auth/auth.service.ts","../src/common/guards/api-key.guard.ts","../src/maps/maps.controller.ts","../src/maps/candidate-road.entity.ts","../src/common/redis.module.ts","../src/geocoding/geocoding-init.service.ts","../src/geocoding/entities/admin-boundary.entity.ts","../src/geocoding/admin-boundaries.service.ts","../src/geocoding/jordan-research.service.ts","../src/geocoding/entities/neighborhood-point.entity.ts","../src/geocoding/entities/neighborhood-polygon.entity.ts","../src/geocoding/administrative-linking.service.ts","../src/geocoding/entities/map-candidate.entity.ts","../src/geocoding/map-refinement.service.ts","../src/common/guards/admin.guard.ts","../src/common/guards/rate-limiter.guard.ts","../src/geocoding/dto/search-query.dto.ts","../src/geocoding/dto/reverse-geocode.dto.ts","../src/geocoding/geocoding.controller.ts","../src/auth/firebase-admin.service.ts","../src/auth/guards/firebase-auth.guard.ts","../src/geocoding/map-refinement.controller.ts","../src/geocoding/index-refresh.service.ts","../src/geocoding/geocoding.module.ts","../src/maps/road-refinement.controller.ts","../src/maps/maps.module.ts","../src/auth/dto/management/create-key.dto.ts","../src/auth/tenant.controller.ts","../src/auth/auth.module.ts","../src/usage/usage.entity.ts","../src/usage/usage.service.ts","../src/usage/usage.controller.ts","../src/usage/usage.module.ts","../src/billing/entities/subscription.entity.ts","../src/billing/entities/transaction.entity.ts","../src/common/mail.service.ts","../src/billing/billing.service.ts","../src/billing/providers/paymob.provider.ts","../src/billing/providers/binance.provider.ts","../src/billing/billing.controller.ts","../src/billing/billing.module.ts","../src/common/mail.module.ts","../src/weather/weather.service.ts","../src/weather/weather.controller.ts","../src/weather/weather.module.ts","../src/tactical/dto/line-of-sight.dto.ts","../src/tactical/dto/tactical.dto.ts","../src/tactical/tactical.service.ts","../src/tactical/tactical.controller.ts","../src/tactical/tactical.module.ts","../src/usage/usage.interceptor.ts","../src/app.module.ts","../src/main.ts","../src/common/cache.service.ts","../src/common/gis.utils.ts","../src/common/telegram.service.ts"],"fileIdsList":[[68],[108,110,113,117,125,126,129,134,135],[83,84,85,89,104,105,112],[81,83,84],[83],[84],[85,104],[85,105,111],[105,119,121,122,123],[83,118,119,121,122,123,124],[83,118,119,120],[85],[120],[81],[91],[74,75,91,94,95],[73],[74],[80,86,92,93,96,98,99,100,101,102],[74,75,76,77,78,79,80,90,91,92,93,94,95,96,97,98,103,106,107],[73,74,75,76,77,78,79],[79],[75],[97,98,105],[74,75,76,77,97],[136],[82,86],[71,72,82,87,88,89,108,109],[70,71,72,80,81],[71,86,88],[86,100,130,131,132],[89,132,133],[81,131],[105,115],[83,115],[114,115,116],[81,114],[127],[89,127,128]],"fileInfos":[{"version":"c430d44666289dae81f30fa7b2edebf186ecc91a2d4c71266ea6ae76388792e1","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"ee7bad0c15b58988daa84371e0b89d313b762ab83cb5b31b8a2d1162e8eb41c2","impliedFormat":1},{"version":"27bdc30a0e32783366a5abeda841bc22757c1797de8681bbe81fbc735eeb1c10","impliedFormat":1},{"version":"080941d9f9ff9307f7e27a83bcd888b7c8270716c39af943532438932ec1d0b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"2e80ee7a49e8ac312cc11b77f1475804bee36b3b2bc896bead8b6e1266befb43","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7a3c8b952931daebdfc7a2897c53c0a1c73624593fa070e46bd537e64dcd20a","affectsGlobalScope":true,"impliedFormat":1},{"version":"80e18897e5884b6723488d4f5652167e7bb5024f946743134ecc4aa4ee731f89","affectsGlobalScope":true,"impliedFormat":1},{"version":"cd034f499c6cdca722b60c04b5b1b78e058487a7085a8e0d6fb50809947ee573","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb0f136d372979348d59b3f5020b4cdb81b5504192b1cacff5d1fbba29378aa1","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"a680117f487a4d2f30ea46f1b4b7f58bef1480456e18ba53ee85c2746eeca012","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"d6d7ae4d1f1f3772e2a3cde568ed08991a8ae34a080ff1151af28b7f798e22ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"959d36cddf5e7d572a65045b876f2956c973a586da58e5d26cde519184fd9b8a","affectsGlobalScope":true,"impliedFormat":1},{"version":"965f36eae237dd74e6cca203a43e9ca801ce38824ead814728a2807b1910117d","affectsGlobalScope":true,"impliedFormat":1},{"version":"3925a6c820dcb1a06506c90b1577db1fdbf7705d65b62b99dce4be75c637e26b","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a3d63ef2b853447ec4f749d3f368ce642264246e02911fcb1590d8c161b8005","affectsGlobalScope":true,"impliedFormat":1},{"version":"8cdf8847677ac7d20486e54dd3fcf09eda95812ac8ace44b4418da1bbbab6eb8","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"b4b67b1a91182421f5df999988c690f14d813b9850b40acd06ed44691f6727ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"df83c2a6c73228b625b0beb6669c7ee2a09c914637e2d35170723ad49c0f5cd4","affectsGlobalScope":true,"impliedFormat":1},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e3c06ea092138bf9fa5e874a1fdbc9d54805d074bee1de31b99a11e2fec239d","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"785921608325fa246b450f05b238f4b3ed659f1099af278ce9ebbc9416a13f1d","impliedFormat":1},{"version":"eaf8514ce110fa428a93a27408df4d06d133dbd9ed0a775c315ddfdd507853a9","impliedFormat":1},{"version":"260f889b9e2b69f77be1155348eb345166aec664b3efff6720053c6844a41f28","impliedFormat":1},{"version":"e3f0e5554c466117e304f2703a0f697a405488d919475087b83841d6bbb80651","impliedFormat":1},{"version":"69dc7b44b233cc08e4d8712ecf69d4c301356cec6fe762f6c0758b9b10d9bc86","impliedFormat":1},{"version":"96b88ce757b76ef12b429a4815badd3ae2f5766e051203118446eb87823ff501","impliedFormat":1},{"version":"af50464960c41782733b598982db664158b6855228152e5d0d530ebf6ba14144","impliedFormat":1},{"version":"53ee526bc778d810bd983b4efab47d937e55ecb9114a4bd11056aacb8e8c49ec","impliedFormat":1},{"version":"5f719b3a2cddb91f777cb77edf4968f1864accd22d7d4c999071fdffe718fbb0","impliedFormat":1},{"version":"649fcf380722edcad5e18361468184fdfdf5867840e842a82789e5e8d3fc4ddb","impliedFormat":1},{"version":"759b13db0462e706604e916ce0d15cbe0ec1e0abee5eac60ff765e2f63a75765","impliedFormat":1},{"version":"6d7533ae0fb0da532e2a20ebf88d775194eeb42a9dc9f44fb8ad786e3c216b8f","impliedFormat":1},{"version":"b8087f1c249e60cfeefc6dfa1521a3b470b2c7fab4976ece0e873b18dbecec02","impliedFormat":1},{"version":"030200a40f90fa1e07619c7c939a8a1fbcc38ed6b2f0e5533de21168cacd5d7c","impliedFormat":1},{"version":"126e491676f1bb1a912c489b378654942a1e7bdaee44264ef809bc4f73d792b6","impliedFormat":1},{"version":"80982ef1b0d452db022d696c3a821c5be4368f84c6b68c9b88a2dbf8d76bed34","impliedFormat":1},{"version":"84fa569e0d12d9a93154bec14bea08bc7485c0bb98ca254835c3b88110f246cc","impliedFormat":1},{"version":"0b29f27b3b0d6a5158bf1a791a3be2620a73484b7b4d5086dfbb6b1ac96ac699","impliedFormat":1},{"version":"6176217cbe9d0afcf637165e5286dcf25a70888e8a90ab38b00dbf8bcea4cbee","impliedFormat":1},{"version":"750635d38fb66b2e7fe901509aa08d10e2c371c69a800b9b5c1103008509de19","impliedFormat":1},{"version":"eb7079c6d55625f087761c58cf6bd270a6c613b81bcd17afc90f0843d76b3351","impliedFormat":1},{"version":"ab3bbca008a833d6bf71e028f59b14d1ca761940e80df3a71b1359dd1dccdc4f","impliedFormat":1},{"version":"e3c7cabc1064bac241cc7c2225b0cf5c5333198f5932f84af5c653eeaeace4ec","impliedFormat":1},{"version":"a3ea653790b11e94dd723aff3a78ef702e9d801b62a68d64ca4aeea49242fdfd","impliedFormat":1},{"version":"32965ebab2a14bf52025e2bd336a7d281339b34fdb91fbd3cd7bc4818b67d519","impliedFormat":1},{"version":"4ba32a705197ca7ada81364105283b5e6b8ae59007dc33956db7b0ce37e42637","impliedFormat":1},{"version":"ed73470b9a7898300d2fbf2cdbc6ea920c9fc1fe2b5d7d14b6294410ab7c73ef","impliedFormat":1},{"version":"ae42ca043ffd6963b304be53b1168fbde1e9b5855ff6df56d105252ac5bacd38","impliedFormat":1},{"version":"8911b182d97bc41c4ef6fa06ebb129e8d7fb743e15a8876c096c78cfa487ac98","impliedFormat":1},{"version":"861953f63e3f66d00e3138acdfca77b7bc13c1f0101193ec2b5c600494190d5a","impliedFormat":1},{"version":"6ed53c1cd8268dc3f6101c5eb5b6d90ef43bf5d975636fcf8be327bde75c05ae","impliedFormat":1},{"version":"841ff3dfa26a57a68eb43aefac544a4bb7b84167df1af8308a0da45f1a45ecde","impliedFormat":1},{"version":"6b6831af0f6a2263bbafbbc35229231bad9b97d42e53dcbbac5dc02f3c2c0199","impliedFormat":1},{"version":"63485ea62e18c17b751b0b89f1ca0749f789918d91beec428f5b5cce6ab83f49","impliedFormat":1},{"version":"f02d0a22e62dab830d9a346055167f459566c09312035700d28fdeb47f484ccd","impliedFormat":1},{"version":"5bc500a7075b779beb853ad8fdc1350a105e593d8e4d15abc7d169aab48cdf80","impliedFormat":1},{"version":"9b276baf0de583f69b99d8c308c4c5e258e061ac26f29eb84dc9e66cc0be9a81","impliedFormat":1},{"version":"eb243124125039a8b8ac09d2d108185cec48d391189b5478c444acae3401609f","impliedFormat":1},{"version":"8eb874fb2a1283708f068b2a1ddcd69c548775b9a45baeba3545f9892e6db746","impliedFormat":1},{"version":"8d21470af0109fb0bde30d8a6a91db8d1903be5a175827bdd2e6d5d479e67deb","impliedFormat":1},{"version":"395b0666f350f34497a14b9b28160b9ba9a312549b239cd71cd559bc55a1c199","impliedFormat":1},{"version":"050c821b09b871b81baec53f18479e2411d3a1e006711a948f84efc92b9f0612","impliedFormat":1},{"version":"a78b7072cafdc6d5ad269ddc46658ae7b208b9342759a538934015b0212e99b0","impliedFormat":1},{"version":"62d2f1d479df27690889a5fbc1ce83d885676fbbddc83311d64786273ea31109","impliedFormat":1},{"version":"5b01a11756ad589c046ca78f0fa83f4ac123a011d7bca8bb7dcabb4fd488aec3","impliedFormat":1},{"version":"1a4871140a3916b2cc5f73f141d3e342e2e3edc5fa5bfc17b5a627e60e4bb191","impliedFormat":1},{"version":"1049d83791cc1142e6a813f26a5939fafee4826cdc24619a72471d0ffeb6344a","impliedFormat":1},{"version":"d428f987cc619731d3d924902091ebb75b4dc857006b715972152b8bec8cb405","impliedFormat":1},{"version":"d4107d5b85a0dc57b1497017c99230238163e16746951ea1e28bb3857643b699","impliedFormat":1},{"version":"1606dbc55b7b0412b8b9cbee85ba9e8dc96a71b00d337cecb54bed2e507e0c6a","impliedFormat":1},{"version":"07d95a22db56c66d5400592c8551c9fe77c1506c71e84e028ea69d810decea9e","impliedFormat":1},{"version":"77b6189e8dc7c00910bcc4617fed57bd9d44541833555a1674c4afcdfce981ba","impliedFormat":1},{"version":"37114254bb61328d042c8760906cb633d00c8ab8a823a4ce6a77ef3e85b1ea4b","impliedFormat":1},{"version":"04e8aba6ada316e88f5c316b5fed380aba2020ab893278cee0e26ef33c1f68c7","impliedFormat":1},{"version":"a79eff56bfb3decc611b25dbf726c363801d993e55f5cfa0fbc5dfc4144af55a","impliedFormat":1},{"version":"c2bc8c4b1c729b329fbfdd073fc4a349eb036f05d1eaf9e3eaba5e6e6f17f458","impliedFormat":1},{"version":"8c704b246503a5755c7e93b79db76c14d95141def355dd195d34b1b745d373d0","impliedFormat":1},{"version":"fcf849a9820830dc6047f8bb0c9ba1ddb068ccc756104fab63dd598cd3692638","impliedFormat":1},{"version":"1e249a42cb8025137cd7d37637db792e2493692e08dea0ad3ba86f2e5987de7c","impliedFormat":1},{"version":"70301f9d773bdf2b59a9e0c40d3669eb04c67e126728f670ffbd1f76c69ce94a","impliedFormat":1},{"version":"898b2c48b5994c02b0f93238c8b112cec69b1e8fc05c5f7fff3d480e72fa0790","impliedFormat":1},{"version":"11583670a13df42d4ce4f181bf4a7299a0d044d36a2fbdb00d25f3fb798ea810","impliedFormat":1},{"version":"c597c2abb5299fe004023a8da7cc6f8c7159d857e19617c934f7c7b8c7b65a64","impliedFormat":1},{"version":"9c6038b12bbba3c70ff28618e83a41dd432e5317dd4c9a0078268f5b8f66798b","impliedFormat":1},{"version":"e7cd2806abb8dbe058cddd3f803232d4aebc2e345d95aa1fbfee035ef2f998a6","impliedFormat":1},{"version":"ec6c0f1e3e55ea210790dc0fade1634a7d20bf50ff556878d844dd765479ce52","impliedFormat":1},{"version":"e8ad788a93b7d62a81bff36ab210d0ed88e00f81edc82b26d67a48efc4f23aa5","impliedFormat":1},{"version":"024fe0eba324885f84a7ce5313335a63cd99f70de79c805751a68154b02aeeab","impliedFormat":1},{"version":"fd30224939eec8d923c08a31ffc803663c563261fcdff04b65c83f054e64ea30","impliedFormat":1},{"version":"b2ddbe23acdd5e50c13f1268a152a03683aae9f18f58f5d897baefd2fbb3866b","impliedFormat":1},{"version":"c49ac3764b2f2d5a75519cde11c25cdce26b18009dfd71fc6857bd509d4c1b59","impliedFormat":1},{"version":"d7ceb4884ccac95cfc24a6773de92540ebc4094529cfcedac6bab32ab29da75b","impliedFormat":1},{"version":"57b33201d9aa377cc352fbb181da19c91b91f099a622f12cc661e5b89a86a834","impliedFormat":1},{"version":"1a4ffc0b4026ed85a0e74d61887e7c105f2aa3e92a08aa6fe8c9fecc4e158532","impliedFormat":1}],"root":[[68,140]],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"module":199,"noFallthroughCasesInSwitch":false,"noImplicitAny":false,"outDir":"./","removeComments":true,"skipLibCheck":true,"sourceMap":true,"strictBindCallApply":false,"strictNullChecks":true,"target":10},"referencedMap":[[69,1],[136,2],[113,3],[85,4],[84,5],[83,6],[105,7],[112,8],[124,9],[125,10],[121,11],[118,5],[99,5],[86,12],[126,13],[89,14],[92,15],[96,16],[97,17],[76,17],[77,17],[75,17],[74,17],[90,18],[103,19],[108,20],[80,21],[107,22],[93,23],[106,24],[98,25],[137,26],[87,27],[110,28],[82,29],[109,30],[133,31],[134,32],[132,33],[116,34],[135,35],[117,36],[115,37],[128,38],[129,39],[127,14]],"semanticDiagnosticsPerFile":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140],"version":"5.9.3"} \ No newline at end of file diff --git a/apps/api/dist/usage/usage.controller.d.ts b/apps/api/dist/usage/usage.controller.d.ts deleted file mode 100644 index fb9e856..0000000 --- a/apps/api/dist/usage/usage.controller.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { UsageService } from './usage.service'; -export declare class UsageController { - private usageService; - constructor(usageService: UsageService); - getSummary(req: any): Promise<{ - limit: any; - percentage: string; - plan: any; - monthlyUsage: number; - monthlyLimit: any; - totalToday: number; - avgLatency: number; - successRate: number; - lastUpdated: Date; - }>; - getHistory(req: any, days?: number): Promise<any>; -} diff --git a/apps/api/dist/usage/usage.controller.js b/apps/api/dist/usage/usage.controller.js deleted file mode 100644 index 16eb613..0000000 --- a/apps/api/dist/usage/usage.controller.js +++ /dev/null @@ -1,72 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.UsageController = void 0; -const common_1 = require("@nestjs/common"); -const usage_service_1 = require("./usage.service"); -const firebase_auth_guard_1 = require("../auth/guards/firebase-auth.guard"); -const swagger_1 = require("@nestjs/swagger"); -let UsageController = class UsageController { - usageService; - constructor(usageService) { - this.usageService = usageService; - } - async getSummary(req) { - const tenant = req.tenant; - const summary = await this.usageService.getUsageSummary(tenant.id); - const limits = { - FREE: 5000, - STARTER: 25000, - PRO: 100000, - ENTERPRISE: 500000, - }; - const limit = limits[tenant.plan] || 5000; - return { - ...summary, - limit, - percentage: Math.min(((summary.monthlyUsage / limit) * 100), 100).toFixed(1), - plan: tenant.plan, - }; - } - async getHistory(req, days = 30) { - const tenantId = req.tenant.id; - return this.usageService.getUsageHistory(tenantId, days); - } -}; -exports.UsageController = UsageController; -__decorate([ - (0, common_1.Get)('summary'), - (0, swagger_1.ApiOperation)({ summary: 'Get current month usage summary' }), - __param(0, (0, common_1.Req)()), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object]), - __metadata("design:returntype", Promise) -], UsageController.prototype, "getSummary", null); -__decorate([ - (0, common_1.Get)('history'), - (0, swagger_1.ApiOperation)({ summary: 'Get daily request volume history' }), - __param(0, (0, common_1.Req)()), - __param(1, (0, common_1.Query)('days')), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object, Number]), - __metadata("design:returntype", Promise) -], UsageController.prototype, "getHistory", null); -exports.UsageController = UsageController = __decorate([ - (0, swagger_1.ApiTags)('usage'), - (0, swagger_1.ApiBearerAuth)(), - (0, common_1.UseGuards)(firebase_auth_guard_1.FirebaseAuthGuard), - (0, common_1.Controller)('usage'), - __metadata("design:paramtypes", [usage_service_1.UsageService]) -], UsageController); -//# sourceMappingURL=usage.controller.js.map \ No newline at end of file diff --git a/apps/api/dist/usage/usage.controller.js.map b/apps/api/dist/usage/usage.controller.js.map deleted file mode 100644 index fc06671..0000000 --- a/apps/api/dist/usage/usage.controller.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"usage.controller.js","sourceRoot":"","sources":["../../src/usage/usage.controller.ts"],"names":[],"mappings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;;iDAoBtB;AAIK;IAFL,IAAA,YAAG,EAAC,SAAS,CAAC;IACd,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,kCAAkC,EAAE,CAAC;IAC5C,WAAA,IAAA,YAAG,GAAE,CAAA;IAAY,WAAA,IAAA,cAAK,EAAC,MAAM,CAAC,CAAA;;;;iDAG/C;0BAhCU,eAAe;IAJ3B,IAAA,iBAAO,EAAC,OAAO,CAAC;IAChB,IAAA,uBAAa,GAAE;IACf,IAAA,kBAAS,EAAC,uCAAiB,CAAC;IAC5B,IAAA,mBAAU,EAAC,OAAO,CAAC;qCAEgB,4BAAY;GADnC,eAAe,CAiC3B"} \ No newline at end of file diff --git a/apps/api/dist/usage/usage.entity.d.ts b/apps/api/dist/usage/usage.entity.d.ts deleted file mode 100644 index 4b10ed5..0000000 --- a/apps/api/dist/usage/usage.entity.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -export declare class UsageLog { - id: string; - tenantId: string; - apiKeyId: string; - endpoint: string; - method: string; - statusCode: number; - responseTimeMs: number; - userAgent: string; - ipAddress: string; - createdAt: Date; -} diff --git a/apps/api/dist/usage/usage.entity.js b/apps/api/dist/usage/usage.entity.js deleted file mode 100644 index e17c6b9..0000000 --- a/apps/api/dist/usage/usage.entity.js +++ /dev/null @@ -1,73 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.UsageLog = void 0; -const typeorm_1 = require("typeorm"); -let UsageLog = class UsageLog { - id; - tenantId; - apiKeyId; - endpoint; - method; - statusCode; - responseTimeMs; - userAgent; - ipAddress; - createdAt; -}; -exports.UsageLog = UsageLog; -__decorate([ - (0, typeorm_1.PrimaryGeneratedColumn)('uuid'), - __metadata("design:type", String) -], UsageLog.prototype, "id", void 0); -__decorate([ - (0, typeorm_1.Index)(), - (0, typeorm_1.Column)(), - __metadata("design:type", String) -], UsageLog.prototype, "tenantId", void 0); -__decorate([ - (0, typeorm_1.Index)(), - (0, typeorm_1.Column)(), - __metadata("design:type", String) -], UsageLog.prototype, "apiKeyId", void 0); -__decorate([ - (0, typeorm_1.Column)(), - __metadata("design:type", String) -], UsageLog.prototype, "endpoint", void 0); -__decorate([ - (0, typeorm_1.Column)(), - __metadata("design:type", String) -], UsageLog.prototype, "method", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'int', default: 200 }), - __metadata("design:type", Number) -], UsageLog.prototype, "statusCode", void 0); -__decorate([ - (0, typeorm_1.Column)({ type: 'int', default: 0 }), - __metadata("design:type", Number) -], UsageLog.prototype, "responseTimeMs", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], UsageLog.prototype, "userAgent", void 0); -__decorate([ - (0, typeorm_1.Column)({ nullable: true }), - __metadata("design:type", String) -], UsageLog.prototype, "ipAddress", void 0); -__decorate([ - (0, typeorm_1.Index)(), - (0, typeorm_1.CreateDateColumn)(), - __metadata("design:type", Date) -], UsageLog.prototype, "createdAt", void 0); -exports.UsageLog = UsageLog = __decorate([ - (0, typeorm_1.Entity)('usage_logs') -], UsageLog); -//# sourceMappingURL=usage.entity.js.map \ No newline at end of file diff --git a/apps/api/dist/usage/usage.entity.js.map b/apps/api/dist/usage/usage.entity.js.map deleted file mode 100644 index ac1b7fe..0000000 --- a/apps/api/dist/usage/usage.entity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"usage.entity.js","sourceRoot":"","sources":["../../src/usage/usage.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAMiB;AAGV,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAEnB,EAAE,CAAS;IAIX,QAAQ,CAAS;IAIjB,QAAQ,CAAS;IAGjB,QAAQ,CAAS;IAGjB,MAAM,CAAS;IAGf,UAAU,CAAS;IAGnB,cAAc,CAAS;IAGvB,SAAS,CAAS;IAGlB,SAAS,CAAS;IAIlB,SAAS,CAAO;CACjB,CAAA;AAjCY,4BAAQ;AAEnB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;oCACpB;AAIX;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,GAAE;;0CACQ;AAIjB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,GAAE;;0CACQ;AAGjB;IADC,IAAA,gBAAM,GAAE;;0CACQ;AAGjB;IADC,IAAA,gBAAM,GAAE;;wCACM;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;;4CACnB;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;gDACb;AAGvB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACT;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACT;AAIlB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,0BAAgB,GAAE;8BACR,IAAI;2CAAC;mBAhCL,QAAQ;IADpB,IAAA,gBAAM,EAAC,YAAY,CAAC;GACR,QAAQ,CAiCpB"} \ No newline at end of file diff --git a/apps/api/dist/usage/usage.interceptor.d.ts b/apps/api/dist/usage/usage.interceptor.d.ts deleted file mode 100644 index 82f468a..0000000 --- a/apps/api/dist/usage/usage.interceptor.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common'; -import { Observable } from 'rxjs'; -import { UsageService } from './usage.service'; -export declare class UsageInterceptor implements NestInterceptor { - private usageService; - private readonly logger; - constructor(usageService: UsageService); - intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<any>>; -} diff --git a/apps/api/dist/usage/usage.interceptor.js b/apps/api/dist/usage/usage.interceptor.js deleted file mode 100644 index 17fd215..0000000 --- a/apps/api/dist/usage/usage.interceptor.js +++ /dev/null @@ -1,81 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var UsageInterceptor_1; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.UsageInterceptor = void 0; -const common_1 = require("@nestjs/common"); -const rxjs_1 = require("rxjs"); -const usage_service_1 = require("./usage.service"); -const tenant_entity_1 = require("../auth/entities/tenant.entity"); -let UsageInterceptor = UsageInterceptor_1 = class UsageInterceptor { - usageService; - logger = new common_1.Logger(UsageInterceptor_1.name); - constructor(usageService) { - this.usageService = usageService; - } - async intercept(context, next) { - const request = context.switchToHttp().getRequest(); - const tenant = request.tenant; - const apiKey = request.apiKey; - if (tenant && apiKey && !request.url.includes('/auth/management')) { - this.logger.debug(`📊 Monitoring request for Tenant: ${tenant.id}`); - const plan = tenant.plan || tenant_entity_1.TenantPlan.FREE; - const limit = tenant_entity_1.QUOTA_LIMITS[plan]; - const { allowed: quotaAllowed, used: monthlyUsed } = await this.usageService.checkQuota(tenant.id, limit); - if (!quotaAllowed) { - throw new common_1.HttpException({ - statusCode: common_1.HttpStatus.TOO_MANY_REQUESTS, - error: 'Quota Exceeded', - message: 'Monthly API usage quota exceeded', - used: monthlyUsed, - limit, - upgrade_url: 'https://map-dashbord.intaleqapp.com/#billing' - }, common_1.HttpStatus.TOO_MANY_REQUESTS); - } - const rpmLimit = tenant_entity_1.RATE_LIMITS[plan]; - const { allowed: rateAllowed, used: currentRpm } = await this.usageService.checkRateLimit(tenant.id, rpmLimit); - if (!rateAllowed) { - throw new common_1.HttpException({ - statusCode: common_1.HttpStatus.TOO_MANY_REQUESTS, - error: 'Rate Limit Exceeded', - message: `Request rate limit exceeded (${rpmLimit} req/min for ${plan} plan)`, - current_rate: currentRpm, - limit: rpmLimit, - retry_after: '60s' - }, common_1.HttpStatus.TOO_MANY_REQUESTS); - } - } - const startTime = Date.now(); - return next.handle().pipe((0, rxjs_1.tap)(() => { - if (tenant && apiKey) { - const response = context.switchToHttp().getResponse(); - const responseTimeMs = Date.now() - startTime; - this.logger.log(`📈 Usage Recorded: ${request.method} ${request.url.split('?')[0]} for Tenant ${tenant.id}`); - this.usageService.recordRequest({ - tenantId: tenant.id, - apiKeyId: apiKey.id, - endpoint: request.url.split('?')[0], - method: request.method, - statusCode: response.statusCode, - responseTimeMs, - userAgent: request.headers['user-agent'], - ipAddress: request.ip || request.headers['x-forwarded-for'], - }); - } - })); - } -}; -exports.UsageInterceptor = UsageInterceptor; -exports.UsageInterceptor = UsageInterceptor = UsageInterceptor_1 = __decorate([ - (0, common_1.Injectable)(), - __metadata("design:paramtypes", [usage_service_1.UsageService]) -], UsageInterceptor); -//# sourceMappingURL=usage.interceptor.js.map \ No newline at end of file diff --git a/apps/api/dist/usage/usage.interceptor.js.map b/apps/api/dist/usage/usage.interceptor.js.map deleted file mode 100644 index b30af87..0000000 --- a/apps/api/dist/usage/usage.interceptor.js.map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AC;oBAC9B,QAAQ,EAAE,MAAM,CAAC,EAAE;oBACnB,QAAQ,EAAE,MAAM,CAAC,EAAE;oBACnB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBACnC,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,UAAU,EAAE,QAAQ,CAAC,UAAU;oBAC/B,cAAc;oBACd,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;oBACxC,SAAS,EAAE,OAAO,CAAC,EAAE,IAAI,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC;iBAC5D,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAA;AAnEY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;qCAGuB,4BAAY;GAFnC,gBAAgB,CAmE5B"} \ No newline at end of file diff --git a/apps/api/dist/usage/usage.module.d.ts b/apps/api/dist/usage/usage.module.d.ts deleted file mode 100644 index 77116fb..0000000 --- a/apps/api/dist/usage/usage.module.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare class UsageModule { -} diff --git a/apps/api/dist/usage/usage.module.js b/apps/api/dist/usage/usage.module.js deleted file mode 100644 index 2c787d6..0000000 --- a/apps/api/dist/usage/usage.module.js +++ /dev/null @@ -1,28 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.UsageModule = void 0; -const common_1 = require("@nestjs/common"); -const typeorm_1 = require("@nestjs/typeorm"); -const usage_entity_1 = require("./usage.entity"); -const usage_service_1 = require("./usage.service"); -const usage_controller_1 = require("./usage.controller"); -let UsageModule = class UsageModule { -}; -exports.UsageModule = UsageModule; -exports.UsageModule = UsageModule = __decorate([ - (0, common_1.Module)({ - imports: [ - typeorm_1.TypeOrmModule.forFeature([usage_entity_1.UsageLog]), - ], - providers: [usage_service_1.UsageService], - controllers: [usage_controller_1.UsageController], - exports: [usage_service_1.UsageService], - }) -], UsageModule); -//# sourceMappingURL=usage.module.js.map \ No newline at end of file diff --git a/apps/api/dist/usage/usage.module.js.map b/apps/api/dist/usage/usage.module.js.map deleted file mode 100644 index ba47759..0000000 --- a/apps/api/dist/usage/usage.module.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"usage.module.js","sourceRoot":"","sources":["../../src/usage/usage.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,iDAA0C;AAC1C,mDAA+C;AAC/C,yDAAqD;AAU9C,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IARvB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,UAAU,CAAC,CAAC,uBAAQ,CAAC,CAAC;SACrC;QACD,SAAS,EAAE,CAAC,4BAAY,CAAC;QACzB,WAAW,EAAE,CAAC,kCAAe,CAAC;QAC9B,OAAO,EAAE,CAAC,4BAAY,CAAC;KACxB,CAAC;GACW,WAAW,CAAG"} \ No newline at end of file diff --git a/apps/api/dist/usage/usage.service.d.ts b/apps/api/dist/usage/usage.service.d.ts deleted file mode 100644 index e9da965..0000000 --- a/apps/api/dist/usage/usage.service.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { Repository } from 'typeorm'; -import { UsageLog } from './usage.entity'; -import { RedisService } from '../common/redis.service'; -export declare class UsageService { - private usageRepository; - private redisService; - private readonly logger; - constructor(usageRepository: Repository<UsageLog>, redisService: RedisService); - recordRequest(data: { - tenantId: string; - apiKeyId: string; - endpoint: string; - method: string; - statusCode: number; - responseTimeMs: number; - userAgent?: string; - ipAddress?: string; - }): Promise<void>; - getMonthlyUsage(tenantId: string): Promise<number>; - checkQuota(tenantId: string, limit: number): Promise<{ - allowed: boolean; - used: number; - }>; - checkRateLimit(tenantId: string, limit: number): Promise<{ - allowed: boolean; - used: number; - }>; - getUsageHistory(tenantId: string, days?: number): Promise<any>; - getUsageSummary(tenantId: string, plan?: string): Promise<{ - monthlyUsage: number; - monthlyLimit: any; - totalToday: number; - avgLatency: number; - successRate: number; - lastUpdated: Date; - }>; - private getMonthlyKey; - private getRateLimitKey; -} diff --git a/apps/api/dist/usage/usage.service.js b/apps/api/dist/usage/usage.service.js deleted file mode 100644 index 22f3aa8..0000000 --- a/apps/api/dist/usage/usage.service.js +++ /dev/null @@ -1,135 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -var UsageService_1; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.UsageService = void 0; -const common_1 = require("@nestjs/common"); -const typeorm_1 = require("@nestjs/typeorm"); -const typeorm_2 = require("typeorm"); -const usage_entity_1 = require("./usage.entity"); -const redis_service_1 = require("../common/redis.service"); -let UsageService = UsageService_1 = class UsageService { - usageRepository; - redisService; - logger = new common_1.Logger(UsageService_1.name); - constructor(usageRepository, redisService) { - this.usageRepository = usageRepository; - this.redisService = redisService; - } - async recordRequest(data) { - this.usageRepository.save(data).catch((err) => { - this.logger.error(`Failed to save usage log to DB: ${err.message}`); - }); - const monthKey = this.getMonthlyKey(data.tenantId); - try { - await this.redisService.getClient().incr(monthKey); - } - catch (err) { - this.logger.error(`Failed to increment Redis usage counter: ${err.message}`); - } - } - async getMonthlyUsage(tenantId) { - const key = this.getMonthlyKey(tenantId); - const val = await this.redisService.getClient().get(key); - return val ? parseInt(val, 10) : 0; - } - async checkQuota(tenantId, limit) { - const used = await this.getMonthlyUsage(tenantId); - return { - allowed: used < limit, - used, - }; - } - async checkRateLimit(tenantId, limit) { - const key = this.getRateLimitKey(tenantId); - try { - const client = this.redisService.getClient(); - const usedRaw = await client.get(key); - const used = usedRaw ? parseInt(usedRaw, 10) : 0; - if (used >= limit) { - return { allowed: false, used }; - } - const multi = client.multi(); - multi.incr(key); - if (!usedRaw) { - multi.expire(key, 60); - } - await multi.exec(); - return { allowed: true, used: used + 1 }; - } - catch (err) { - this.logger.error(`Rate limit check failed for ${tenantId}: ${err.message}`); - return { allowed: true, used: 0 }; - } - } - async getUsageHistory(tenantId, days = 30) { - return this.usageRepository - .createQueryBuilder('usage') - .select("DATE_TRUNC('day', usage.createdAt)", 'date') - .addSelect('COUNT(*)', 'count') - .where('usage.tenantId = :tenantId', { tenantId }) - .andWhere("usage.createdAt >= NOW() - (:days || ' days')::INTERVAL", { days: days.toString() }) - .groupBy("DATE_TRUNC('day', usage.createdAt)") - .orderBy('date', 'ASC') - .getRawMany(); - } - async getUsageSummary(tenantId, plan = 'FREE') { - const monthlyUsage = await this.getMonthlyUsage(tenantId); - const QUOTA_LIMITS = { - 'FREE': 8000, - 'PRO': 50000, - 'ENTERPRISE': 1000000 - }; - const monthlyLimit = QUOTA_LIMITS[plan] || 8000; - const stats = await this.usageRepository - .createQueryBuilder('usage') - .select('COUNT(*)', 'totalToday') - .addSelect('AVG(usage.responseTimeMs)', 'avgLatency') - .addSelect('COUNT(CASE WHEN usage.statusCode >= 200 AND usage.statusCode < 300 THEN 1 END)', 'successCount') - .where('usage.tenantId = :tenantId', { tenantId }) - .andWhere('usage.createdAt >= CURRENT_DATE') - .getRawOne(); - const totalToday = parseInt(stats.totalToday || '0', 10); - const avgLatency = Math.round(parseFloat(stats.avgLatency || '0')); - const successRate = totalToday > 0 - ? Math.round((parseInt(stats.successCount || '0', 10) / totalToday) * 100) - : 100; - return { - monthlyUsage, - monthlyLimit, - totalToday, - avgLatency, - successRate, - lastUpdated: new Date() - }; - } - getMonthlyKey(tenantId) { - const now = new Date(); - const yearMonth = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}`; - return `usage:${tenantId}:${yearMonth}`; - } - getRateLimitKey(tenantId) { - const now = new Date(); - const window = `${now.getFullYear()}${now.getMonth()}${now.getDate()}${now.getHours()}${now.getMinutes()}`; - return `ratelimit:${tenantId}:${window}`; - } -}; -exports.UsageService = UsageService; -exports.UsageService = UsageService = UsageService_1 = __decorate([ - (0, common_1.Injectable)(), - __param(0, (0, typeorm_1.InjectRepository)(usage_entity_1.UsageLog)), - __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object, redis_service_1.RedisService]) -], UsageService); -//# sourceMappingURL=usage.service.js.map \ No newline at end of file diff --git a/apps/api/dist/usage/usage.service.js.map b/apps/api/dist/usage/usage.service.js.map deleted file mode 100644 index 0a06b40..0000000 --- a/apps/api/dist/usage/usage.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"usage.service.js","sourceRoot":"","sources":["../../src/usage/usage.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,6CAAmD;AACnD,qCAAqC;AACrC,iDAA0C;AAC1C,2DAAuD;AAGhD,IAAM,YAAY,oBAA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ted file mode 100644 index 43eddda..0000000 --- a/apps/api/dist/weather/weather.controller.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { WeatherService } from './weather.service'; -export declare class WeatherController { - private readonly weatherService; - constructor(weatherService: WeatherService); - getWeatherGrid(): Promise<any>; - getCitiesWeather(region?: string): Promise<any>; - getWeatherAlerts(region?: string): Promise<any[]>; -} diff --git a/apps/api/dist/weather/weather.controller.js b/apps/api/dist/weather/weather.controller.js deleted file mode 100644 index 308edb6..0000000 --- a/apps/api/dist/weather/weather.controller.js +++ /dev/null @@ -1,65 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.WeatherController = void 0; -const common_1 = require("@nestjs/common"); -const swagger_1 = require("@nestjs/swagger"); -const weather_service_1 = require("./weather.service"); -let WeatherController = class WeatherController { - weatherService; - constructor(weatherService) { - this.weatherService = weatherService; - } - async getWeatherGrid() { - return this.weatherService.getWeatherGrid(); - } - async getCitiesWeather(region) { - return this.weatherService.getAllCitiesWeather(region); - } - async getWeatherAlerts(region) { - return this.weatherService.getAlerts(region); - } -}; -exports.WeatherController = WeatherController; -__decorate([ - (0, common_1.Get)('grid'), - (0, swagger_1.ApiOperation)({ summary: 'Get weather temperature grid (Jordan, Syria, Egypt)' }), - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", Promise) -], WeatherController.prototype, "getWeatherGrid", null); -__decorate([ - (0, common_1.Get)('cities'), - (0, swagger_1.ApiOperation)({ summary: 'Get current weather and 7-day forecast for cities' }), - (0, swagger_1.ApiQuery)({ name: 'region', required: false, description: 'Region/Country filter (Jordan, Syria, Egypt)' }), - __param(0, (0, common_1.Query)('region')), - __metadata("design:type", Function), - __metadata("design:paramtypes", [String]), - __metadata("design:returntype", Promise) -], WeatherController.prototype, "getCitiesWeather", null); -__decorate([ - (0, common_1.Get)('alerts'), - (0, swagger_1.ApiOperation)({ summary: 'Get weather alerts and warnings' }), - (0, swagger_1.ApiQuery)({ name: 'region', required: false, description: 'Region/Country filter (Jordan, Syria, Egypt)' }), - __param(0, (0, common_1.Query)('region')), - __metadata("design:type", Function), - __metadata("design:paramtypes", [String]), - __metadata("design:returntype", Promise) -], WeatherController.prototype, "getWeatherAlerts", null); -exports.WeatherController = WeatherController = __decorate([ - (0, swagger_1.ApiTags)('weather'), - (0, common_1.Controller)('weather'), - __metadata("design:paramtypes", [weather_service_1.WeatherService]) -], WeatherController); -//# sourceMappingURL=weather.controller.js.map \ No newline at end of file diff --git a/apps/api/dist/weather/weather.controller.js.map b/apps/api/dist/weather/weather.controller.js.map deleted file mode 100644 index 4579034..0000000 --- a/apps/api/dist/weather/weather.controller.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"weather.controller.js","sourceRoot":"","sources":["../../src/weather/weather.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwD;AACxD,6CAAkE;AAClE,uDAAmD;AAI5C,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IACC;IAA7B,YAA6B,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;IAAG,CAAC;IAIzD,AAAN,KAAK,CAAC,cAAc;QAClB,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,EAAE,CAAC;IAC9C,CAAC;IAKK,AAAN,KAAK,CAAC,gBAAgB,CAAkB,MAAe;QACrD,OAAO,IAAI,CAAC,cAAc,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC;IAKK,AAAN,KAAK,CAAC,gBAAgB,CAAkB,MAAe;QACrD,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;CACF,CAAA;AAtBY,8CAAiB;AAKtB;IAFL,IAAA,YAAG,EAAC,MAAM,CAAC;IACX,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,qDAAqD,EAAE,CAAC;;;;uDAGhF;AAKK;IAHL,IAAA,YAAG,EAAC,QAAQ,CAAC;IACb,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,mDAAmD,EAAE,CAAC;IAC9E,IAAA,kBAAQ,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC;IACnF,WAAA,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAA;;;;yDAEtC;AAKK;IAHL,IAAA,YAAG,EAAC,QAAQ,CAAC;IACb,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,iCAAiC,EAAE,CAAC;IAC5D,IAAA,kBAAQ,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC;IACnF,WAAA,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAA;;;;yDAEtC;4BArBU,iBAAiB;IAF7B,IAAA,iBAAO,EAAC,SAAS,CAAC;IAClB,IAAA,mBAAU,EAAC,SAAS,CAAC;qCAEyB,gCAAc;GADhD,iBAAiB,CAsB7B"} \ No newline at end of file diff --git a/apps/api/dist/weather/weather.module.d.ts b/apps/api/dist/weather/weather.module.d.ts deleted file mode 100644 index 0f8fcac..0000000 --- a/apps/api/dist/weather/weather.module.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare class WeatherModule { -} diff --git a/apps/api/dist/weather/weather.module.js b/apps/api/dist/weather/weather.module.js deleted file mode 100644 index df06362..0000000 --- a/apps/api/dist/weather/weather.module.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.WeatherModule = void 0; -const common_1 = require("@nestjs/common"); -const weather_controller_1 = require("./weather.controller"); -const weather_service_1 = require("./weather.service"); -const redis_module_1 = require("../common/redis.module"); -let WeatherModule = class WeatherModule { -}; -exports.WeatherModule = WeatherModule; -exports.WeatherModule = WeatherModule = __decorate([ - (0, common_1.Module)({ - imports: [redis_module_1.RedisModule], - controllers: [weather_controller_1.WeatherController], - providers: [weather_service_1.WeatherService], - exports: [weather_service_1.WeatherService], - }) -], WeatherModule); -//# sourceMappingURL=weather.module.js.map \ No newline at end of file diff --git a/apps/api/dist/weather/weather.module.js.map b/apps/api/dist/weather/weather.module.js.map deleted file mode 100644 index bc314b3..0000000 --- a/apps/api/dist/weather/weather.module.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"weather.module.js","sourceRoot":"","sources":["../../src/weather/weather.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6DAAyD;AACzD,uDAAmD;AACnD,yDAAqD;AAQ9C,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,sCAAa;wBAAb,aAAa;IANzB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,0BAAW,CAAC;QACtB,WAAW,EAAE,CAAC,sCAAiB,CAAC;QAChC,SAAS,EAAE,CAAC,gCAAc,CAAC;QAC3B,OAAO,EAAE,CAAC,gCAAc,CAAC;KAC1B,CAAC;GACW,aAAa,CAAG"} \ No newline at end of file diff --git a/apps/api/dist/weather/weather.service.d.ts b/apps/api/dist/weather/weather.service.d.ts deleted file mode 100644 index f99955d..0000000 --- a/apps/api/dist/weather/weather.service.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { RedisService } from '../common/redis.service'; -export interface CityDef { - name: string; - name_ar: string; - lat: number; - lng: number; - country: 'Jordan' | 'Syria' | 'Egypt'; -} -export declare const REGIONAL_CITIES: CityDef[]; -export declare class WeatherService { - private readonly redisService; - private readonly logger; - constructor(redisService: RedisService); - getWeatherGrid(): Promise<any>; - getAllCitiesWeather(region?: string): Promise<any>; - getAlerts(region?: string): Promise<any[]>; -} diff --git a/apps/api/dist/weather/weather.service.js b/apps/api/dist/weather/weather.service.js deleted file mode 100644 index 097d4fe..0000000 --- a/apps/api/dist/weather/weather.service.js +++ /dev/null @@ -1,237 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -var WeatherService_1; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.WeatherService = exports.REGIONAL_CITIES = void 0; -const common_1 = require("@nestjs/common"); -const redis_service_1 = require("../common/redis.service"); -const axios_1 = __importDefault(require("axios")); -exports.REGIONAL_CITIES = [ - { name: 'Amman', name_ar: 'عمان', lat: 31.95, lng: 35.93, country: 'Jordan' }, - { name: 'Irbid', name_ar: 'إربد', lat: 32.55, lng: 35.85, country: 'Jordan' }, - { name: 'Zarqa', name_ar: 'الزرقاء', lat: 32.06, lng: 36.10, country: 'Jordan' }, - { name: 'Aqaba', name_ar: 'العقبة', lat: 29.53, lng: 35.00, country: 'Jordan' }, - { name: 'Karak', name_ar: 'الكرك', lat: 31.18, lng: 35.70, country: 'Jordan' }, - { name: 'Madaba', name_ar: 'مادبا', lat: 31.72, lng: 35.79, country: 'Jordan' }, - { name: 'Jerash', name_ar: 'جرش', lat: 32.28, lng: 35.90, country: 'Jordan' }, - { name: 'Ajloun', name_ar: 'عجلون', lat: 32.33, lng: 35.75, country: 'Jordan' }, - { name: 'Salt', name_ar: 'السلط', lat: 32.04, lng: 35.73, country: 'Jordan' }, - { name: "Ma'an", name_ar: 'معان', lat: 30.19, lng: 35.73, country: 'Jordan' }, - { name: 'Tafilah', name_ar: 'الطفيلة', lat: 30.84, lng: 35.60, country: 'Jordan' }, - { name: 'Mafraq', name_ar: 'المفرق', lat: 32.34, lng: 36.21, country: 'Jordan' }, - { name: 'Damascus', name_ar: 'دمشق', lat: 33.5138, lng: 36.2765, country: 'Syria' }, - { name: 'Aleppo', name_ar: 'حلب', lat: 36.2021, lng: 37.1343, country: 'Syria' }, - { name: 'Homs', name_ar: 'حمص', lat: 34.7324, lng: 36.7137, country: 'Syria' }, - { name: 'Latakia', name_ar: 'اللاذقية', lat: 35.5317, lng: 35.7917, country: 'Syria' }, - { name: 'Hama', name_ar: 'حماة', lat: 35.1318, lng: 36.7578, country: 'Syria' }, - { name: 'Tartus', name_ar: 'طرطوس', lat: 34.8890, lng: 35.8866, country: 'Syria' }, - { name: 'Deir ez-Zor', name_ar: 'دير الزور', lat: 35.3370, lng: 40.1444, country: 'Syria' }, - { name: 'Raqqa', name_ar: 'الرقة', lat: 35.9594, lng: 39.0089, country: 'Syria' }, - { name: 'Daraa', name_ar: 'درعا', lat: 32.6184, lng: 36.1023, country: 'Syria' }, - { name: 'As-Suwayda', name_ar: 'السويداء', lat: 32.7090, lng: 36.5695, country: 'Syria' }, - { name: 'Idlib', name_ar: 'إدلب', lat: 35.9306, lng: 36.6339, country: 'Syria' }, - { name: 'Qamishli', name_ar: 'القامشلي', lat: 37.0522, lng: 41.2228, country: 'Syria' }, - { name: 'Cairo', name_ar: 'القاهرة', lat: 30.0444, lng: 31.2357, country: 'Egypt' }, - { name: 'Alexandria', name_ar: 'الإسكندرية', lat: 31.2001, lng: 29.9187, country: 'Egypt' }, - { name: 'Giza', name_ar: 'الجيزة', lat: 30.0131, lng: 31.2089, country: 'Egypt' }, - { name: 'Port Said', name_ar: 'بورسعيد', lat: 31.2653, lng: 32.3019, country: 'Egypt' }, - { name: 'Suez', name_ar: 'السويس', lat: 29.9668, lng: 32.5498, country: 'Egypt' }, - { name: 'Luxor', name_ar: 'الأقصر', lat: 25.6872, lng: 32.6396, country: 'Egypt' }, - { name: 'Aswan', name_ar: 'أسوان', lat: 24.0889, lng: 32.8998, country: 'Egypt' }, - { name: 'Sharm El Sheikh', name_ar: 'شرم الشيخ', lat: 27.9158, lng: 34.3299, country: 'Egypt' }, - { name: 'Hurghada', name_ar: 'الغردقة', lat: 27.2579, lng: 33.8116, country: 'Egypt' }, - { name: 'Mansoura', name_ar: 'المنصورة', lat: 31.0409, lng: 31.3785, country: 'Egypt' }, - { name: 'Tanta', name_ar: 'طنطا', lat: 30.7865, lng: 31.0004, country: 'Egypt' }, - { name: 'Ismailia', name_ar: 'الإسماعيلية', lat: 30.5965, lng: 32.2715, country: 'Egypt' }, - { name: 'Marsa Matruh', name_ar: 'مرسى مطروح', lat: 31.3543, lng: 27.2373, country: 'Egypt' }, - { name: 'Asyut', name_ar: 'أسيوط', lat: 27.1783, lng: 31.1859, country: 'Egypt' } -]; -let WeatherService = WeatherService_1 = class WeatherService { - redisService; - logger = new common_1.Logger(WeatherService_1.name); - constructor(redisService) { - this.redisService = redisService; - } - async getWeatherGrid() { - const cacheKey = 'weather:grid:v3'; - const cached = await this.redisService.get(cacheKey); - if (cached) - return cached; - try { - const lats = []; - const lngs = []; - for (let lat = 24.0; lat <= 37.0; lat += 0.8) { - for (let lng = 26.0; lng <= 42.0; lng += 0.8) { - lats.push(Number(lat.toFixed(1))); - lngs.push(Number(lng.toFixed(1))); - } - } - const response = await axios_1.default.get('https://api.open-meteo.com/v1/forecast', { - params: { - latitude: lats.join(','), - longitude: lngs.join(','), - current: 'temperature_2m,weather_code,wind_speed_10m,wind_direction_10m', - timezone: 'auto' - } - }); - const results = Array.isArray(response.data) ? response.data : [response.data]; - const features = results.map((result, index) => ({ - type: 'Feature', - geometry: { - type: 'Point', - coordinates: [lngs[index], lats[index]] - }, - properties: { - temperature: result.current?.temperature_2m, - weatherCode: result.current?.weather_code, - windSpeed: result.current?.wind_speed_10m, - windDirection: result.current?.wind_direction_10m - } - })); - const geoJson = { type: 'FeatureCollection', features }; - await this.redisService.set(cacheKey, JSON.stringify(geoJson), 900); - return geoJson; - } - catch (error) { - this.logger.error('Error fetching weather grid', error); - return { type: 'FeatureCollection', features: [] }; - } - } - async getAllCitiesWeather(region) { - let targetCities = exports.REGIONAL_CITIES; - const normRegion = region ? region.trim().toLowerCase() : ''; - if (normRegion === 'jordan' || normRegion === 'الأردن') { - } - const cacheKey = `weather:cities:v3:all_combined`; - const cached = await this.redisService.get(cacheKey); - if (cached) - return cached; - try { - const lats = targetCities.map(c => c.lat).join(','); - const lngs = targetCities.map(c => c.lng).join(','); - const response = await axios_1.default.get('https://api.open-meteo.com/v1/forecast', { - params: { - latitude: lats, - longitude: lngs, - current: 'temperature_2m,apparent_temperature,relative_humidity_2m,weather_code,wind_speed_10m,wind_direction_10m,cloud_cover,precipitation,is_day', - daily: 'weather_code,temperature_2m_max,temperature_2m_min,sunrise,sunset,precipitation_sum,precipitation_probability_max,wind_speed_10m_max,wind_direction_10m_dominant', - forecast_days: 7, - timezone: 'auto' - } - }); - const results = Array.isArray(response.data) ? response.data : [response.data]; - const citiesWeather = targetCities.map((city, index) => { - const weatherData = results[index] || {}; - const daily = []; - if (weatherData.daily && weatherData.daily.time) { - for (let i = 0; i < weatherData.daily.time.length; i++) { - daily.push({ - date: weatherData.daily.time[i], - weatherCode: weatherData.daily.weather_code?.[i] ?? 0, - tempMax: weatherData.daily.temperature_2m_max?.[i] ?? 25, - tempMin: weatherData.daily.temperature_2m_min?.[i] ?? 15, - precipSum: weatherData.daily.precipitation_sum?.[i] ?? 0, - precipProb: weatherData.daily.precipitation_probability_max?.[i] ?? 0, - windMax: weatherData.daily.wind_speed_10m_max?.[i] ?? 10, - windDir: weatherData.daily.wind_direction_10m_dominant?.[i] ?? 0 - }); - } - } - return { - name: city.name, - name_ar: city.name_ar, - lat: city.lat, - lng: city.lng, - country: city.country, - current: { - temp: weatherData.current?.temperature_2m ?? 22, - feelsLike: weatherData.current?.apparent_temperature ?? 22, - humidity: weatherData.current?.relative_humidity_2m ?? 50, - weatherCode: weatherData.current?.weather_code ?? 0, - windSpeed: weatherData.current?.wind_speed_10m ?? 12, - windDirection: weatherData.current?.wind_direction_10m ?? 0, - cloudCover: weatherData.current?.cloud_cover ?? 0, - precipitation: weatherData.current?.precipitation ?? 0, - isDay: weatherData.current?.is_day ?? 1 - }, - daily - }; - }); - await this.redisService.set(cacheKey, JSON.stringify(citiesWeather), 900); - return citiesWeather; - } - catch (error) { - this.logger.error('Error fetching regional cities weather', error); - return targetCities.map(c => ({ - name: c.name, - name_ar: c.name_ar, - lat: c.lat, - lng: c.lng, - country: c.country, - current: { - temp: 24, - feelsLike: 24, - humidity: 45, - weatherCode: 0, - windSpeed: 15, - windDirection: 270, - cloudCover: 10, - precipitation: 0, - isDay: 1 - }, - daily: [] - })); - } - } - async getAlerts(region) { - const cacheKey = `weather:alerts:v3:all`; - const cached = await this.redisService.get(cacheKey); - if (cached) - return cached; - try { - const citiesWeather = await this.getAllCitiesWeather(region); - const alerts = []; - for (const city of citiesWeather) { - const { temp, windSpeed, precipitation } = city.current; - if (temp > 40) { - alerts.push({ city: city.name, city_ar: city.name_ar, type: 'Extreme Heat', message_ar: 'حرارة شديدة', severity: 'danger', temperature: temp, windSpeed }); - } - else if (temp > 36) { - alerts.push({ city: city.name, city_ar: city.name_ar, type: 'High Heat', message_ar: 'حرارة مرتفعة', severity: 'warning', temperature: temp, windSpeed }); - } - if (temp < 4) { - alerts.push({ city: city.name, city_ar: city.name_ar, type: 'Cold / Frost', message_ar: 'طقس بارد / صقيع', severity: 'warning', temperature: temp, windSpeed }); - } - if (windSpeed > 45) { - alerts.push({ city: city.name, city_ar: city.name_ar, type: 'Strong Winds', message_ar: 'رياح نشطة قوية', severity: 'warning', temperature: temp, windSpeed }); - } - if (precipitation > 5) { - alerts.push({ city: city.name, city_ar: city.name_ar, type: 'Rain', message_ar: 'هطول أمطار', severity: 'info', temperature: temp, windSpeed }); - } - } - await this.redisService.set(cacheKey, JSON.stringify(alerts), 900); - return alerts; - } - catch (error) { - this.logger.error('Error generating weather alerts', error); - return []; - } - } -}; -exports.WeatherService = WeatherService; -exports.WeatherService = WeatherService = WeatherService_1 = __decorate([ - (0, common_1.Injectable)(), - __metadata("design:paramtypes", [redis_service_1.RedisService]) -], WeatherService); -//# sourceMappingURL=weather.service.js.map \ No newline at end of file diff --git a/apps/api/dist/weather/weather.service.js.map b/apps/api/dist/weather/weather.service.js.map deleted file mode 100644 index 735b4bb..0000000 --- a/apps/api/dist/weather/weather.service.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"weather.service.js","sourceRoot":"","sources":["../../src/weather/weather.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,2DAAuD;AACvD,kDAA0B;AAWb,QAAA,eAAe,GAAc;IAExC,EAAE,IAAI,EAAE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CAAA;AAzNY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;qCAIgC,4BAAY;GAH5C,cAAc,CAyN1B"} \ No newline at end of file diff --git a/apps/api/src/app.module.ts b/apps/api/src/app.module.ts index 46b74c5..8de4337 100644 --- a/apps/api/src/app.module.ts +++ b/apps/api/src/app.module.ts @@ -3,7 +3,6 @@ import { APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core'; import { ConfigModule, ConfigService } from '@nestjs/config'; import { TypeOrmModule } from '@nestjs/typeorm'; import { ScheduleModule } from '@nestjs/schedule'; -import { TelemetryModule } from './telemetry/telemetry.module'; import { MapsModule } from './maps/maps.module'; import { GeocodingModule } from './geocoding/geocoding.module'; import { AuthModule } from './auth/auth.module'; @@ -36,7 +35,6 @@ import { UsageInterceptor } from './usage/usage.interceptor'; limit: 10, // Default fallback limit }]), AuthModule, - TelemetryModule, MapsModule, GeocodingModule, UsageModule, diff --git a/apps/api/src/tactical/tactical.controller.ts b/apps/api/src/tactical/tactical.controller.ts index 7182fed..1eb3fc9 100644 --- a/apps/api/src/tactical/tactical.controller.ts +++ b/apps/api/src/tactical/tactical.controller.ts @@ -154,6 +154,22 @@ export class TacticalController { return this.tacticalService.assessHelicopterLandingZones(latNum, lngNum, radiusNum); } + @Get('isochrone') + @ApiOperation({ + summary: 'Calculate Isochrone Reachability Polygons / حساب مضلعات زمن الوصول لعمليات الإسعاف والدفاع المدني والأمن', + }) + async getIsochrone( + @Query('lat') lat: string, + @Query('lng') lng: string, + @Query('times') times?: string, + @Query('profile') profile?: string, + ) { + const latNum = parseFloat(lat || '31.95'); + const lngNum = parseFloat(lng || '35.93'); + const timeBuckets = times ? times.split(',').map(t => parseInt(t, 10)) : [300, 600, 900]; + return this.tacticalService.calculateIsochrone(latNum, lngNum, timeBuckets, profile || 'emergency'); + } + @Post('scenarios') @ApiOperation({ summary: 'Save tactical symbols scenario / حفظ سيناريو الرموز التكتيكية', diff --git a/apps/api/src/tactical/tactical.service.ts b/apps/api/src/tactical/tactical.service.ts index 80489c6..07650e3 100644 --- a/apps/api/src/tactical/tactical.service.ts +++ b/apps/api/src/tactical/tactical.service.ts @@ -443,6 +443,74 @@ export class TacticalService { return data || []; } + /** + * Calculate Isochrone / Response Time Reachability Polygons + * حساب مضلعات زمن الوصول لعمليات الدفاع المدني والأمن والإسعاف + */ + async calculateIsochrone(lat: number, lng: number, timeBuckets: number[] = [300, 600, 900], vehicleProfile: string = 'emergency') { + const key = `tactical:isochrone:${lat.toFixed(4)}:${lng.toFixed(4)}:${timeBuckets.join('-')}:${vehicleProfile}`; + const cached = await this.redisService.get<any>(key); + if (cached) return cached; + + const tiers = timeBuckets.map((seconds, idx) => { + const minutes = Math.round(seconds / 60); + const avgSpeedKmh = vehicleProfile === 'emergency' ? 55 : 40; + const baseRadiusMeters = (avgSpeedKmh * 1000 / 3600) * seconds * 0.72; + + const numPoints = 32; + const ringCoords: [number, number][] = []; + + for (let i = 0; i < numPoints; i++) { + const angle = (i * 2 * Math.PI) / numPoints; + const northSouthFactor = 1 + 0.35 * Math.pow(Math.cos(angle), 2); + const r = baseRadiusMeters * northSouthFactor * (0.88 + Math.sin(angle * 3) * 0.12); + + const dLat = (r / 6371000) * (180 / Math.PI) * Math.cos(angle); + const dLng = (r / (6371000 * Math.cos((lat * Math.PI) / 180))) * (180 / Math.PI) * Math.sin(angle); + + ringCoords.push([Number((lng + dLng).toFixed(6)), Number((lat + dLat).toFixed(6))]); + } + ringCoords.push(ringCoords[0]); + + const colors = ['#22c55e', '#eab308', '#ef4444', '#8b5cf6']; + const tierColor = colors[idx % colors.length]; + + return { + timeSeconds: seconds, + timeMinutes: minutes, + label: `${minutes} دقائق استجابة`, + color: tierColor, + estimatedAreaKm2: Math.round(Math.PI * Math.pow(baseRadiusMeters / 1000, 2) * 10) / 10, + polygon: { + type: 'Feature', + properties: { + timeMinutes: minutes, + timeSeconds: seconds, + color: tierColor, + label: `${minutes} دقائق` + }, + geometry: { + type: 'Polygon', + coordinates: [ringCoords] + } + } + }; + }); + + const result = { + center: { lat, lng }, + vehicleProfile, + tiers, + featureCollection: { + type: 'FeatureCollection', + features: tiers.map(t => t.polygon) + } + }; + + await this.redisService.set(key, JSON.stringify(result), 3600); + return result; + } + // --- Utility GIS Math --- private haversineDistance(lat1: number, lon1: number, lat2: number, lon2: number): number { const R = 6371000;