@uniorganization/uni-lib 4.0.14 → 4.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Point } from 'geojson';
|
|
1
2
|
import { Users } from './usr.entity';
|
|
2
3
|
import { ServiceCenterPhoneEntity } from './service-center-phone.entity';
|
|
3
4
|
export declare class ServiceCenterEntity {
|
|
@@ -37,4 +38,5 @@ export declare class ServiceCenterEntity {
|
|
|
37
38
|
agent: Users;
|
|
38
39
|
agentId: number;
|
|
39
40
|
dateUpdated: Date;
|
|
41
|
+
geolocation: Point;
|
|
40
42
|
}
|
|
@@ -164,6 +164,16 @@ __decorate([
|
|
|
164
164
|
(0, typeorm_1.UpdateDateColumn)({ name: 'date_updated', type: 'timestamp' }),
|
|
165
165
|
__metadata("design:type", Date)
|
|
166
166
|
], ServiceCenterEntity.prototype, "dateUpdated", void 0);
|
|
167
|
+
__decorate([
|
|
168
|
+
(0, typeorm_1.Index)({ spatial: true }),
|
|
169
|
+
(0, typeorm_1.Column)({
|
|
170
|
+
type: 'geometry',
|
|
171
|
+
spatialFeatureType: 'Point',
|
|
172
|
+
srid: 4326,
|
|
173
|
+
nullable: true,
|
|
174
|
+
}),
|
|
175
|
+
__metadata("design:type", Object)
|
|
176
|
+
], ServiceCenterEntity.prototype, "geolocation", void 0);
|
|
167
177
|
exports.ServiceCenterEntity = ServiceCenterEntity = __decorate([
|
|
168
178
|
(0, typeorm_1.Entity)('service_center', { schema: 'enr' })
|
|
169
179
|
], ServiceCenterEntity);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { DistanceMatrixResponseData } from '@googlemaps/google-maps-services-js';
|
|
1
|
+
import { DistanceMatrixResponseData, GeocodeResponseData } from '@googlemaps/google-maps-services-js';
|
|
2
2
|
export declare class GoogleMapsService {
|
|
3
3
|
private client;
|
|
4
4
|
private readonly logger;
|
|
5
5
|
constructor();
|
|
6
|
+
getGeocoding(address: string): Promise<GeocodeResponseData>;
|
|
6
7
|
getDistanceMatrix(origin: string, destination: string): Promise<DistanceMatrixResponseData>;
|
|
7
8
|
}
|
|
@@ -27,6 +27,32 @@ let GoogleMapsService = GoogleMapsService_1 = class GoogleMapsService {
|
|
|
27
27
|
this.logger = new common_1.Logger(GoogleMapsService_1.name);
|
|
28
28
|
this.client = new google_maps_services_js_1.Client({});
|
|
29
29
|
}
|
|
30
|
+
getGeocoding(address) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const apiKey = process.env.GOOGLE_MAPS_API_KEY;
|
|
33
|
+
if (!apiKey) {
|
|
34
|
+
this.logger.error('GOOGLE_MAPS_API_KEY is not defined');
|
|
35
|
+
throw new Error('Google Maps API configuration missing');
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const response = yield this.client.geocode({
|
|
39
|
+
params: {
|
|
40
|
+
address,
|
|
41
|
+
key: apiKey,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
if (response.status !== 200) {
|
|
45
|
+
this.logger.warn(`Google Geocoding API returned status ${response.status}: ${response.data.error_message || ''}`);
|
|
46
|
+
return response.data;
|
|
47
|
+
}
|
|
48
|
+
return response.data;
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
this.logger.error(`Google Geocoding API Error: ${e.message}`, e.stack);
|
|
52
|
+
throw e;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
30
56
|
getDistanceMatrix(origin, destination) {
|
|
31
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
58
|
const apiKey = process.env.GOOGLE_MAPS_API_KEY;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniorganization/uni-lib",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.15",
|
|
4
4
|
"description": "UNI Library",
|
|
5
5
|
"author": "Jhomiguel",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"@nestjs/testing": "^10.4.1",
|
|
43
43
|
"@nestjs/typeorm": "^10.0.2",
|
|
44
44
|
"@types/express": "4.17.21",
|
|
45
|
+
"@types/geojson": "^7946.0.16",
|
|
45
46
|
"@types/jest": "^29.5.12",
|
|
46
47
|
"@types/node": "^22.5.4",
|
|
47
48
|
"@types/passport-jwt": "^4.0.1",
|