@uniorganization/uni-lib 4.0.14 → 4.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/entities/service-center.entity.d.ts +4 -1
- package/dist/entities/service-center.entity.js +14 -3
- package/dist/enums/service-center-status.enum.d.ts +5 -0
- package/dist/enums/service-center-status.enum.js +9 -0
- package/dist/modules/google-maps/google-maps.service.d.ts +2 -1
- package/dist/modules/google-maps/google-maps.service.js +26 -0
- package/package.json +2 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { Point } from 'geojson';
|
|
1
2
|
import { Users } from './usr.entity';
|
|
2
3
|
import { ServiceCenterPhoneEntity } from './service-center-phone.entity';
|
|
4
|
+
import { ServiceCenterStatus } from 'src/enums/service-center-status.enum';
|
|
3
5
|
export declare class ServiceCenterEntity {
|
|
4
6
|
id: number;
|
|
5
7
|
servicerAccount: string;
|
|
@@ -14,7 +16,7 @@ export declare class ServiceCenterEntity {
|
|
|
14
16
|
zipCode: string;
|
|
15
17
|
country: string;
|
|
16
18
|
servicerType: string;
|
|
17
|
-
|
|
19
|
+
status: ServiceCenterStatus;
|
|
18
20
|
eligible: boolean;
|
|
19
21
|
locatingFlag: boolean;
|
|
20
22
|
autoAcceptanceFlag: boolean;
|
|
@@ -37,4 +39,5 @@ export declare class ServiceCenterEntity {
|
|
|
37
39
|
agent: Users;
|
|
38
40
|
agentId: number;
|
|
39
41
|
dateUpdated: Date;
|
|
42
|
+
geolocation: Point;
|
|
40
43
|
}
|
|
@@ -13,6 +13,7 @@ exports.ServiceCenterEntity = void 0;
|
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const usr_entity_1 = require("./usr.entity");
|
|
15
15
|
const service_center_phone_entity_1 = require("./service-center-phone.entity");
|
|
16
|
+
const service_center_status_enum_1 = require("src/enums/service-center-status.enum");
|
|
16
17
|
let ServiceCenterEntity = class ServiceCenterEntity {
|
|
17
18
|
};
|
|
18
19
|
exports.ServiceCenterEntity = ServiceCenterEntity;
|
|
@@ -70,9 +71,9 @@ __decorate([
|
|
|
70
71
|
__metadata("design:type", String)
|
|
71
72
|
], ServiceCenterEntity.prototype, "servicerType", void 0);
|
|
72
73
|
__decorate([
|
|
73
|
-
(0, typeorm_1.Column)({ name: '
|
|
74
|
-
__metadata("design:type",
|
|
75
|
-
], ServiceCenterEntity.prototype, "
|
|
74
|
+
(0, typeorm_1.Column)({ name: 'status', type: 'varchar', default: service_center_status_enum_1.ServiceCenterStatus.PENDING_APPROVAL }),
|
|
75
|
+
__metadata("design:type", String)
|
|
76
|
+
], ServiceCenterEntity.prototype, "status", void 0);
|
|
76
77
|
__decorate([
|
|
77
78
|
(0, typeorm_1.Column)({ name: 'eligible', type: 'boolean', nullable: true, select: false }),
|
|
78
79
|
__metadata("design:type", Boolean)
|
|
@@ -164,6 +165,16 @@ __decorate([
|
|
|
164
165
|
(0, typeorm_1.UpdateDateColumn)({ name: 'date_updated', type: 'timestamp' }),
|
|
165
166
|
__metadata("design:type", Date)
|
|
166
167
|
], ServiceCenterEntity.prototype, "dateUpdated", void 0);
|
|
168
|
+
__decorate([
|
|
169
|
+
(0, typeorm_1.Index)({ spatial: true }),
|
|
170
|
+
(0, typeorm_1.Column)({
|
|
171
|
+
type: 'geometry',
|
|
172
|
+
spatialFeatureType: 'Point',
|
|
173
|
+
srid: 4326,
|
|
174
|
+
nullable: true,
|
|
175
|
+
}),
|
|
176
|
+
__metadata("design:type", Object)
|
|
177
|
+
], ServiceCenterEntity.prototype, "geolocation", void 0);
|
|
167
178
|
exports.ServiceCenterEntity = ServiceCenterEntity = __decorate([
|
|
168
179
|
(0, typeorm_1.Entity)('service_center', { schema: 'enr' })
|
|
169
180
|
], ServiceCenterEntity);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServiceCenterStatus = void 0;
|
|
4
|
+
var ServiceCenterStatus;
|
|
5
|
+
(function (ServiceCenterStatus) {
|
|
6
|
+
ServiceCenterStatus["ACTIVE"] = "ACTIVE";
|
|
7
|
+
ServiceCenterStatus["INACTIVE"] = "INACTIVE";
|
|
8
|
+
ServiceCenterStatus["PENDING_APPROVAL"] = "PENDING APPROVAL";
|
|
9
|
+
})(ServiceCenterStatus || (exports.ServiceCenterStatus = ServiceCenterStatus = {}));
|
|
@@ -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.16",
|
|
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",
|