2026-04-14-8 auth and commercial

This commit is contained in:
Hamza-Ayed
2026-04-14 20:14:48 +03:00
parent be7dcc2652
commit f5b3f9f790
430 changed files with 6074 additions and 751 deletions
+155 -14
View File
@@ -16,41 +16,87 @@ 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 api_key_guard_1 = require("../common/guards/api-key.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;
constructor(geocodingService) {
adminBoundariesService;
jordanResearchService;
adminLinkingService;
constructor(geocodingService, adminBoundariesService, jordanResearchService, adminLinkingService) {
this.geocodingService = geocodingService;
this.adminBoundariesService = adminBoundariesService;
this.jordanResearchService = jordanResearchService;
this.adminLinkingService = adminLinkingService;
}
async search(query) {
return this.geocodingService.searchPlaces(query);
async search(queryDto) {
const { q, lat, lng, radius, country } = queryDto;
return this.geocodingService.searchPlaces(q, lat, lng, radius, country);
}
async reverse(lat, lng) {
async reverse(reverseDto) {
const { lat, lng } = reverseDto;
return this.geocodingService.reverseGeocode(lat, lng);
}
async addPlace(placeData) {
return this.geocodingService.addPlace(placeData);
}
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)' }),
(0, swagger_1.ApiQuery)({ name: 'q', required: true }),
__param(0, (0, common_1.Query)('q')),
__param(0, (0, common_1.Query)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:paramtypes", [search_query_dto_1.SearchQueryDto]),
__metadata("design:returntype", Promise)
], GeocodingController.prototype, "search", null);
__decorate([
(0, common_1.Get)('reverse'),
(0, swagger_1.ApiOperation)({ summary: 'Reverse Geocoding (Lat/Lng to Address)' }),
(0, swagger_1.ApiQuery)({ name: 'lat', required: true }),
(0, swagger_1.ApiQuery)({ name: 'lng', required: true }),
__param(0, (0, common_1.Query)('lat')),
__param(1, (0, common_1.Query)('lng')),
__param(0, (0, common_1.Query)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number, Number]),
__metadata("design:paramtypes", [reverse_geocode_dto_1.ReverseGeocodeDto]),
__metadata("design:returntype", Promise)
], GeocodingController.prototype, "reverse", null);
__decorate([
@@ -61,10 +107,105 @@ __decorate([
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], GeocodingController.prototype, "addPlace", null);
__decorate([
(0, common_1.Delete)('places'),
(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'] }),
__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, 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, 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, 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, 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'] }),
__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, swagger_1.ApiOperation)({ summary: 'Generate Voronoi polygons for neighborhoods' }),
(0, swagger_1.ApiQuery)({ name: 'country', required: false, enum: ['jordan', 'syria', 'egypt'] }),
__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, swagger_1.ApiOperation)({ summary: 'Link places to administrative hierarchy' }),
(0, swagger_1.ApiQuery)({ name: 'country', required: true, enum: ['jordan', 'syria', 'egypt'] }),
__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),
__metadata("design:paramtypes", [geocoding_service_1.GeocodingService])
(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])
], GeocodingController);
//# sourceMappingURL=geocoding.controller.js.map