feat: implement billing, usage tracking, and administrative geocoding features in API with infrastructure updates
This commit is contained in:
+37
-7
@@ -19,7 +19,9 @@ 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");
|
||||
@@ -28,22 +30,30 @@ let GeocodingController = class GeocodingController {
|
||||
adminBoundariesService;
|
||||
jordanResearchService;
|
||||
adminLinkingService;
|
||||
constructor(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(placeData) {
|
||||
return this.geocodingService.addPlace(placeData);
|
||||
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) {
|
||||
@@ -91,6 +101,17 @@ __decorate([
|
||||
__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)' }),
|
||||
@@ -101,14 +122,16 @@ __decorate([
|
||||
], GeocodingController.prototype, "reverse", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('places'),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Add a new location (User Submitted)' }),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
(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]),
|
||||
__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 }),
|
||||
@@ -122,6 +145,7 @@ __decorate([
|
||||
], 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),
|
||||
@@ -130,6 +154,7 @@ __decorate([
|
||||
], 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),
|
||||
@@ -153,6 +178,7 @@ __decorate([
|
||||
], 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 }),
|
||||
@@ -171,6 +197,7 @@ __decorate([
|
||||
], 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'] }),
|
||||
@@ -182,6 +209,7 @@ __decorate([
|
||||
], 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'] }),
|
||||
__param(0, (0, common_1.Query)('country')),
|
||||
@@ -191,6 +219,7 @@ __decorate([
|
||||
], 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'] }),
|
||||
__param(0, (0, common_1.Query)('country')),
|
||||
@@ -206,6 +235,7 @@ exports.GeocodingController = GeocodingController = __decorate([
|
||||
__metadata("design:paramtypes", [geocoding_service_1.GeocodingService,
|
||||
admin_boundaries_service_1.AdminBoundariesService,
|
||||
jordan_research_service_1.JordanResearchService,
|
||||
administrative_linking_service_1.AdministrativeLinkingService])
|
||||
administrative_linking_service_1.AdministrativeLinkingService,
|
||||
map_refinement_service_1.MapRefinementService])
|
||||
], GeocodingController);
|
||||
//# sourceMappingURL=geocoding.controller.js.map
|
||||
Reference in New Issue
Block a user