@itdigitalwing/aladdin-common 1.0.281 → 1.0.282
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/build/constants/eventConstants.d.ts +1 -0
- package/build/constants/eventConstants.js +11 -0
- package/build/constants/eventTracker.d.ts +2 -0
- package/build/constants/eventTracker.js +5 -0
- package/build/constants/location.d.ts +9 -0
- package/build/constants/location.js +11 -0
- package/build/constants/trackEvents.mixpanel.d.ts +137 -0
- package/build/constants/trackEvents.mixpanel.js +141 -0
- package/build/errors/bad-request-error.d.ts +10 -0
- package/build/errors/bad-request-error.js +21 -0
- package/build/errors/custom-error.d.ts +8 -0
- package/build/errors/custom-error.js +10 -0
- package/build/errors/database-connection-error.d.ts +9 -0
- package/build/errors/database-connection-error.js +19 -0
- package/build/errors/not-authorized-error.d.ts +8 -0
- package/build/errors/not-authorized-error.js +17 -0
- package/build/errors/not-found-error.d.ts +8 -0
- package/build/errors/not-found-error.js +17 -0
- package/build/errors/request-validation-error.d.ts +11 -0
- package/build/errors/request-validation-error.js +19 -0
- package/build/events/Group-member-migrate-event.d.ts +13 -0
- package/build/events/Group-member-migrate-event.js +2 -0
- package/build/events/Group-migrate-event.d.ts +17 -0
- package/build/events/Group-migrate-event.js +2 -0
- package/build/events/SameStaticCompanyToAuthorisedCompany.d.ts +5 -0
- package/build/events/SameStaticCompanyToAuthorisedCompany.js +2 -0
- package/build/events/add-experience-company-follow.d.ts +9 -0
- package/build/events/add-experience-company-follow.js +2 -0
- package/build/events/aki-test-event.d.ts +7 -0
- package/build/events/aki-test-event.js +2 -0
- package/build/events/base-listener-test.d.ts +18 -0
- package/build/events/base-listener-test.js +56 -0
- package/build/events/base-listener-v2.d.ts +21 -0
- package/build/events/base-listener-v2.js +121 -0
- package/build/events/base-listener.d.ts +18 -0
- package/build/events/base-listener.js +105 -0
- package/build/events/base-publisher-test.d.ts +16 -0
- package/build/events/base-publisher-test.js +39 -0
- package/build/events/base-publisher-v2.d.ts +15 -0
- package/build/events/base-publisher-v2.js +51 -0
- package/build/events/base-publisher.d.ts +15 -0
- package/build/events/base-publisher.js +66 -0
- package/build/events/bulkUser-deleted-event.d.ts +7 -0
- package/build/events/bulkUser-deleted-event.js +2 -0
- package/build/events/common-event.d.ts +4 -0
- package/build/events/common-event.js +2 -0
- package/build/events/companies-migrate-event.d.ts +15 -0
- package/build/events/companies-migrate-event.js +2 -0
- package/build/events/company-admin-created-event.d.ts +9 -0
- package/build/events/company-admin-created-event.js +2 -0
- package/build/events/company-admin-removed-event.d.ts +8 -0
- package/build/events/company-admin-removed-event.js +2 -0
- package/build/events/company-created-event.d.ts +13 -0
- package/build/events/company-created-event.js +2 -0
- package/build/events/company-data-created-event.d.ts +9 -0
- package/build/events/company-data-created-event.js +2 -0
- package/build/events/company-deleted-event.d.ts +7 -0
- package/build/events/company-deleted-event.js +2 -0
- package/build/events/company-employee-joined-event.d.ts +8 -0
- package/build/events/company-employee-joined-event.js +2 -0
- package/build/events/company-employee-removed-event.d.ts +8 -0
- package/build/events/company-employee-removed-event.js +2 -0
- package/build/events/company-updated-event.d.ts +9 -0
- package/build/events/company-updated-event.js +2 -0
- package/build/events/employee-added-event.d.ts +18 -0
- package/build/events/employee-added-event.js +3 -0
- package/build/events/employee-removed-event.d.ts +10 -0
- package/build/events/employee-removed-event.js +2 -0
- package/build/events/employee-updated-event.d.ts +19 -0
- package/build/events/employee-updated-event.js +2 -0
- package/build/events/employmentType-created-event.d.ts +11 -0
- package/build/events/employmentType-created-event.js +2 -0
- package/build/events/employmentType-deleted-event.d.ts +7 -0
- package/build/events/employmentType-deleted-event.js +2 -0
- package/build/events/entities.d.ts +37 -0
- package/build/events/entities.js +41 -0
- package/build/events/eventTypes.d.ts +8 -0
- package/build/events/eventTypes.js +12 -0
- package/build/events/group-created-event.d.ts +12 -0
- package/build/events/group-created-event.js +2 -0
- package/build/events/group-deleted-event.d.ts +8 -0
- package/build/events/group-deleted-event.js +2 -0
- package/build/events/group-member-joined-event.d.ts +8 -0
- package/build/events/group-member-joined-event.js +2 -0
- package/build/events/group-member-removed-event.d.ts +8 -0
- package/build/events/group-member-removed-event.js +2 -0
- package/build/events/group-updated-event.d.ts +10 -0
- package/build/events/group-updated-event.js +2 -0
- package/build/events/hashtag-created-event.d.ts +11 -0
- package/build/events/hashtag-created-event.js +2 -0
- package/build/events/hashtag-tagged.d.ts +14 -0
- package/build/events/hashtag-tagged.js +7 -0
- package/build/events/headline-updated-event.d.ts +8 -0
- package/build/events/headline-updated-event.js +2 -0
- package/build/events/industry-created-event.d.ts +17 -0
- package/build/events/industry-created-event.js +2 -0
- package/build/events/industry-deleted-event.d.ts +8 -0
- package/build/events/industry-deleted-event.js +2 -0
- package/build/events/industry-updated-event.d.ts +14 -0
- package/build/events/industry-updated-event.js +2 -0
- package/build/events/initiate-notification.d.ts +32 -0
- package/build/events/initiate-notification.js +2 -0
- package/build/events/initiate-notify-notification.d.ts +32 -0
- package/build/events/initiate-notify-notification.js +2 -0
- package/build/events/institution-alumni-created-event.d.ts +11 -0
- package/build/events/institution-alumni-created-event.js +2 -0
- package/build/events/institution-alumni-removed-event.d.ts +9 -0
- package/build/events/institution-alumni-removed-event.js +2 -0
- package/build/events/institution-alumni-updated-event.d.ts +12 -0
- package/build/events/institution-alumni-updated-event.js +2 -0
- package/build/events/institution-created-event.d.ts +17 -0
- package/build/events/institution-created-event.js +2 -0
- package/build/events/institution-deleted-event.d.ts +8 -0
- package/build/events/institution-deleted-event.js +2 -0
- package/build/events/institution-employee-added.d.ts +11 -0
- package/build/events/institution-employee-added.js +2 -0
- package/build/events/institution-employee-edited.d.ts +12 -0
- package/build/events/institution-employee-edited.js +2 -0
- package/build/events/institution-employee-removed.d.ts +9 -0
- package/build/events/institution-employee-removed.js +2 -0
- package/build/events/institution-migrate-event.d.ts +31 -0
- package/build/events/institution-migrate-event.js +2 -0
- package/build/events/institution-updated-event.d.ts +17 -0
- package/build/events/institution-updated-event.js +2 -0
- package/build/events/invite-contact-event.d.ts +9 -0
- package/build/events/invite-contact-event.js +2 -0
- package/build/events/job-created-event.d.ts +17 -0
- package/build/events/job-created-event.js +2 -0
- package/build/events/job-deleted-event.d.ts +7 -0
- package/build/events/job-deleted-event.js +2 -0
- package/build/events/job-updated-event.d.ts +14 -0
- package/build/events/job-updated-event.js +2 -0
- package/build/events/jobTitleData-created-event.d.ts +12 -0
- package/build/events/jobTitleData-created-event.js +2 -0
- package/build/events/jobTitleData-deleted-event.d.ts +7 -0
- package/build/events/jobTitleData-deleted-event.js +2 -0
- package/build/events/location-created-event.d.ts +11 -0
- package/build/events/location-created-event.js +2 -0
- package/build/events/location-deleted-event.d.ts +8 -0
- package/build/events/location-deleted-event.js +2 -0
- package/build/events/location-updated-event.d.ts +11 -0
- package/build/events/location-updated-event.js +2 -0
- package/build/events/messageData.d.ts +20 -0
- package/build/events/messageData.js +2 -0
- package/build/events/migrate-connections-to-chat-data.d.ts +9 -0
- package/build/events/migrate-connections-to-chat-data.js +2 -0
- package/build/events/migrate-connections-to-chat.d.ts +8 -0
- package/build/events/migrate-connections-to-chat.js +2 -0
- package/build/events/migrate-education-data.d.ts +11 -0
- package/build/events/migrate-education-data.js +2 -0
- package/build/events/migrate-messages.d.ts +9 -0
- package/build/events/migrate-messages.js +2 -0
- package/build/events/migrate-profile-image.d.ts +8 -0
- package/build/events/migrate-profile-image.js +2 -0
- package/build/events/migrate-user-event.d.ts +34 -0
- package/build/events/migrate-user-event.js +2 -0
- package/build/events/migrate-user-location-to-job.d.ts +8 -0
- package/build/events/migrate-user-location-to-job.js +2 -0
- package/build/events/migrate-user-to-chat.d.ts +8 -0
- package/build/events/migrate-user-to-chat.js +2 -0
- package/build/events/organizationEmployeeCreatedEvent.d.ts +9 -0
- package/build/events/organizationEmployeeCreatedEvent.js +2 -0
- package/build/events/parentTypes.d.ts +6 -0
- package/build/events/parentTypes.js +10 -0
- package/build/events/process-created-event.d.ts +12 -0
- package/build/events/process-created-event.js +2 -0
- package/build/events/process-updated-event.d.ts +12 -0
- package/build/events/process-updated-event.js +2 -0
- package/build/events/profile-image-update-event.d.ts +8 -0
- package/build/events/profile-image-update-event.js +2 -0
- package/build/events/profile-viewed-event.d.ts +9 -0
- package/build/events/profile-viewed-event.js +2 -0
- package/build/events/resume-deleted-event.d.ts +8 -0
- package/build/events/resume-deleted-event.js +2 -0
- package/build/events/resume-uploaded-event.d.ts +6 -0
- package/build/events/resume-uploaded-event.js +2 -0
- package/build/events/resumeData-to-job-service.d.ts +6 -0
- package/build/events/resumeData-to-job-service.js +2 -0
- package/build/events/scraping-start-event.d.ts +7 -0
- package/build/events/scraping-start-event.js +2 -0
- package/build/events/scraping-success-event.d.ts +11 -0
- package/build/events/scraping-success-event.js +2 -0
- package/build/events/segment-created-event.d.ts +10 -0
- package/build/events/segment-created-event.js +2 -0
- package/build/events/segment-updated-event.d.ts +10 -0
- package/build/events/segment-updated-event.js +2 -0
- package/build/events/service-created-event.d.ts +10 -0
- package/build/events/service-created-event.js +2 -0
- package/build/events/service-delete-event.d.ts +7 -0
- package/build/events/service-delete-event.js +2 -0
- package/build/events/service-updated-event.d.ts +9 -0
- package/build/events/service-updated-event.js +2 -0
- package/build/events/skill-created-event.d.ts +11 -0
- package/build/events/skill-created-event.js +2 -0
- package/build/events/skill-deleted-event.d.ts +7 -0
- package/build/events/skill-deleted-event.js +2 -0
- package/build/events/specialization-created-event.d.ts +10 -0
- package/build/events/specialization-created-event.js +2 -0
- package/build/events/specialization-updated-event.d.ts +10 -0
- package/build/events/specialization-updated-event.js +2 -0
- package/build/events/subjects.d.ts +103 -0
- package/build/events/subjects.js +107 -0
- package/build/events/thread-line-event.d.ts +16 -0
- package/build/events/thread-line-event.js +2 -0
- package/build/events/university-updated-event.d.ts +11 -0
- package/build/events/university-updated-event.js +2 -0
- package/build/events/user-badge-added-event.d.ts +8 -0
- package/build/events/user-badge-added-event.js +2 -0
- package/build/events/user-badge-deleted-event.d.ts +8 -0
- package/build/events/user-badge-deleted-event.js +2 -0
- package/build/events/user-connection-count-update-event.d.ts +8 -0
- package/build/events/user-connection-count-update-event.js +2 -0
- package/build/events/user-created-event.d.ts +12 -0
- package/build/events/user-created-event.js +2 -0
- package/build/events/user-deleted-event.d.ts +7 -0
- package/build/events/user-deleted-event.js +2 -0
- package/build/events/user-follow-event.d.ts +9 -0
- package/build/events/user-follow-event.js +2 -0
- package/build/events/user-follow-update-event .d.ts +10 -0
- package/build/events/user-follow-update-event .js +2 -0
- package/build/events/user-location-data-to-job-service.d.ts +7 -0
- package/build/events/user-location-data-to-job-service.js +2 -0
- package/build/events/user-reactivate-event.d.ts +8 -0
- package/build/events/user-reactivate-event.js +2 -0
- package/build/events/user-segment-created-event.d.ts +15 -0
- package/build/events/user-segment-created-event.js +2 -0
- package/build/events/user-skill-addded-event.d.ts +14 -0
- package/build/events/user-skill-addded-event.js +2 -0
- package/build/events/user-skill-removed-event.d.ts +12 -0
- package/build/events/user-skill-removed-event.js +2 -0
- package/build/events/user-unfollow-event.d.ts +9 -0
- package/build/events/user-unfollow-event.js +2 -0
- package/build/events/user-updated-event.d.ts +24 -0
- package/build/events/user-updated-event.js +2 -0
- package/build/events/userData-to-chat-service.d.ts +9 -0
- package/build/events/userData-to-chat-service.js +2 -0
- package/build/events/users-connected-event.d.ts +10 -0
- package/build/events/users-connected-event.js +2 -0
- package/build/events/users-disconnected-event.d.ts +8 -0
- package/build/events/users-disconnected-event.js +2 -0
- package/build/index.d.ts +122 -0
- package/build/index.js +140 -0
- package/build/middleware/current-user.d.ts +18 -0
- package/build/middleware/current-user.js +53 -0
- package/build/middleware/error-handler.d.ts +2 -0
- package/build/middleware/error-handler.js +15 -0
- package/build/middleware/require-auth.d.ts +2 -0
- package/build/middleware/require-auth.js +10 -0
- package/build/middleware/validate-request.d.ts +2 -0
- package/build/middleware/validate-request.js +13 -0
- package/build/services/eventTracking.d.ts +17 -0
- package/build/services/eventTracking.js +91 -0
- package/build/utils/get-location.d.ts +11 -0
- package/build/utils/get-location.js +338 -0
- package/package.json +1 -1
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.getPlaceIdByLocationString = exports.getLocationStringOnlyByPlaceId = exports.getLocationByPlaceId = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
18
|
+
const location_js_1 = require("../constants/location.js");
|
|
19
|
+
dotenv_1.default.config();
|
|
20
|
+
const findContinent = (countryCode) => {
|
|
21
|
+
const data = {
|
|
22
|
+
AD: "Europe",
|
|
23
|
+
AE: "Asia",
|
|
24
|
+
AF: "Asia",
|
|
25
|
+
AG: "North America",
|
|
26
|
+
AI: "North America",
|
|
27
|
+
AL: "Europe",
|
|
28
|
+
AM: "Asia",
|
|
29
|
+
AN: "North America",
|
|
30
|
+
AO: "Africa",
|
|
31
|
+
AQ: "Antarctica",
|
|
32
|
+
AR: "South America",
|
|
33
|
+
AS: "Australia",
|
|
34
|
+
AT: "Europe",
|
|
35
|
+
AU: "Australia",
|
|
36
|
+
AW: "North America",
|
|
37
|
+
AZ: "Asia",
|
|
38
|
+
BA: "Europe",
|
|
39
|
+
BB: "North America",
|
|
40
|
+
BD: "Asia",
|
|
41
|
+
BE: "Europe",
|
|
42
|
+
BF: "Africa",
|
|
43
|
+
BG: "Europe",
|
|
44
|
+
BH: "Asia",
|
|
45
|
+
BI: "Africa",
|
|
46
|
+
BJ: "Africa",
|
|
47
|
+
BM: "North America",
|
|
48
|
+
BN: "Asia",
|
|
49
|
+
BO: "South America",
|
|
50
|
+
BR: "South America",
|
|
51
|
+
BS: "North America",
|
|
52
|
+
BT: "Asia",
|
|
53
|
+
BW: "Africa",
|
|
54
|
+
BY: "Europe",
|
|
55
|
+
BZ: "North America",
|
|
56
|
+
CA: "North America",
|
|
57
|
+
CC: "Asia",
|
|
58
|
+
CD: "Africa",
|
|
59
|
+
CF: "Africa",
|
|
60
|
+
CG: "Africa",
|
|
61
|
+
CH: "Europe",
|
|
62
|
+
CI: "Africa",
|
|
63
|
+
CK: "Australia",
|
|
64
|
+
CL: "South America",
|
|
65
|
+
CM: "Africa",
|
|
66
|
+
CN: "Asia",
|
|
67
|
+
CO: "South America",
|
|
68
|
+
CR: "North America",
|
|
69
|
+
CU: "North America",
|
|
70
|
+
CV: "Africa",
|
|
71
|
+
CX: "Asia",
|
|
72
|
+
CY: "Asia",
|
|
73
|
+
CZ: "Europe",
|
|
74
|
+
DE: "Europe",
|
|
75
|
+
DJ: "Africa",
|
|
76
|
+
DK: "Europe",
|
|
77
|
+
DM: "North America",
|
|
78
|
+
DO: "North America",
|
|
79
|
+
DZ: "Africa",
|
|
80
|
+
EC: "South America",
|
|
81
|
+
EE: "Europe",
|
|
82
|
+
EG: "Africa",
|
|
83
|
+
EH: "Africa",
|
|
84
|
+
ER: "Africa",
|
|
85
|
+
ES: "Europe",
|
|
86
|
+
ET: "Africa",
|
|
87
|
+
FI: "Europe",
|
|
88
|
+
FJ: "Australia",
|
|
89
|
+
FK: "South America",
|
|
90
|
+
FM: "Australia",
|
|
91
|
+
FO: "Europe",
|
|
92
|
+
FR: "Europe",
|
|
93
|
+
GA: "Africa",
|
|
94
|
+
GB: "Europe",
|
|
95
|
+
GD: "North America",
|
|
96
|
+
GE: "Asia",
|
|
97
|
+
GF: "South America",
|
|
98
|
+
GG: "Europe",
|
|
99
|
+
GH: "Africa",
|
|
100
|
+
GI: "Europe",
|
|
101
|
+
GL: "North America",
|
|
102
|
+
GM: "Africa",
|
|
103
|
+
GN: "Africa",
|
|
104
|
+
GP: "North America",
|
|
105
|
+
GQ: "Africa",
|
|
106
|
+
GR: "Europe",
|
|
107
|
+
GS: "Antarctica",
|
|
108
|
+
GT: "North America",
|
|
109
|
+
GU: "Australia",
|
|
110
|
+
GW: "Africa",
|
|
111
|
+
GY: "South America",
|
|
112
|
+
HK: "Asia",
|
|
113
|
+
HN: "North America",
|
|
114
|
+
HR: "Europe",
|
|
115
|
+
HT: "North America",
|
|
116
|
+
HU: "Europe",
|
|
117
|
+
ID: "Asia",
|
|
118
|
+
IE: "Europe",
|
|
119
|
+
IL: "Asia",
|
|
120
|
+
IM: "Europe",
|
|
121
|
+
IN: "Asia",
|
|
122
|
+
IO: "Asia",
|
|
123
|
+
IQ: "Asia",
|
|
124
|
+
IR: "Asia",
|
|
125
|
+
IS: "Europe",
|
|
126
|
+
IT: "Europe",
|
|
127
|
+
JE: "Europe",
|
|
128
|
+
JM: "North America",
|
|
129
|
+
JO: "Asia",
|
|
130
|
+
JP: "Asia",
|
|
131
|
+
KE: "Africa",
|
|
132
|
+
KG: "Asia",
|
|
133
|
+
KH: "Asia",
|
|
134
|
+
KI: "Australia",
|
|
135
|
+
KM: "Africa",
|
|
136
|
+
KN: "North America",
|
|
137
|
+
KP: "Asia",
|
|
138
|
+
KR: "Asia",
|
|
139
|
+
KW: "Asia",
|
|
140
|
+
KY: "North America",
|
|
141
|
+
KZ: "Asia",
|
|
142
|
+
LA: "Asia",
|
|
143
|
+
LB: "Asia",
|
|
144
|
+
LC: "North America",
|
|
145
|
+
LI: "Europe",
|
|
146
|
+
LK: "Asia",
|
|
147
|
+
LR: "Africa",
|
|
148
|
+
LS: "Africa",
|
|
149
|
+
LT: "Europe",
|
|
150
|
+
LU: "Europe",
|
|
151
|
+
LV: "Europe",
|
|
152
|
+
LY: "Africa",
|
|
153
|
+
MA: "Africa",
|
|
154
|
+
MC: "Europe",
|
|
155
|
+
MD: "Europe",
|
|
156
|
+
ME: "Europe",
|
|
157
|
+
MG: "Africa",
|
|
158
|
+
MH: "Australia",
|
|
159
|
+
MK: "Europe",
|
|
160
|
+
ML: "Africa",
|
|
161
|
+
MM: "Asia",
|
|
162
|
+
MN: "Asia",
|
|
163
|
+
MO: "Asia",
|
|
164
|
+
MP: "Australia",
|
|
165
|
+
MQ: "North America",
|
|
166
|
+
MR: "Africa",
|
|
167
|
+
MS: "North America",
|
|
168
|
+
MT: "Europe",
|
|
169
|
+
MU: "Africa",
|
|
170
|
+
MV: "Asia",
|
|
171
|
+
MW: "Africa",
|
|
172
|
+
MX: "North America",
|
|
173
|
+
MY: "Asia",
|
|
174
|
+
MZ: "Africa",
|
|
175
|
+
NA: "Africa",
|
|
176
|
+
NC: "Australia",
|
|
177
|
+
NE: "Africa",
|
|
178
|
+
NF: "Australia",
|
|
179
|
+
NG: "Africa",
|
|
180
|
+
NI: "North America",
|
|
181
|
+
NL: "Europe",
|
|
182
|
+
NO: "Europe",
|
|
183
|
+
NP: "Asia",
|
|
184
|
+
NR: "Australia",
|
|
185
|
+
NU: "Australia",
|
|
186
|
+
NZ: "Australia",
|
|
187
|
+
OM: "Asia",
|
|
188
|
+
PA: "North America",
|
|
189
|
+
PE: "South America",
|
|
190
|
+
PF: "Australia",
|
|
191
|
+
PG: "Australia",
|
|
192
|
+
PH: "Asia",
|
|
193
|
+
PK: "Asia",
|
|
194
|
+
PL: "Europe",
|
|
195
|
+
PM: "North America",
|
|
196
|
+
PN: "Australia",
|
|
197
|
+
PR: "North America",
|
|
198
|
+
PS: "Asia",
|
|
199
|
+
PT: "Europe",
|
|
200
|
+
PW: "Australia",
|
|
201
|
+
PY: "South America",
|
|
202
|
+
QA: "Asia",
|
|
203
|
+
RE: "Africa",
|
|
204
|
+
RO: "Europe",
|
|
205
|
+
RS: "Europe",
|
|
206
|
+
RU: "Europe",
|
|
207
|
+
RW: "Africa",
|
|
208
|
+
SA: "Asia",
|
|
209
|
+
SB: "Australia",
|
|
210
|
+
SC: "Africa",
|
|
211
|
+
SD: "Africa",
|
|
212
|
+
SE: "Europe",
|
|
213
|
+
SG: "Asia",
|
|
214
|
+
SH: "Africa",
|
|
215
|
+
SI: "Europe",
|
|
216
|
+
SJ: "Europe",
|
|
217
|
+
SK: "Europe",
|
|
218
|
+
SL: "Africa",
|
|
219
|
+
SM: "Europe",
|
|
220
|
+
SN: "Africa",
|
|
221
|
+
SO: "Africa",
|
|
222
|
+
SR: "South America",
|
|
223
|
+
ST: "Africa",
|
|
224
|
+
SV: "North America",
|
|
225
|
+
SY: "Asia",
|
|
226
|
+
SZ: "Africa",
|
|
227
|
+
TC: "North America",
|
|
228
|
+
TD: "Africa",
|
|
229
|
+
TF: "Antarctica",
|
|
230
|
+
TG: "Africa",
|
|
231
|
+
TH: "Asia",
|
|
232
|
+
TJ: "Asia",
|
|
233
|
+
TK: "Australia",
|
|
234
|
+
TM: "Asia",
|
|
235
|
+
TN: "Africa",
|
|
236
|
+
TO: "Australia",
|
|
237
|
+
TR: "Asia",
|
|
238
|
+
TT: "North America",
|
|
239
|
+
TV: "Australia",
|
|
240
|
+
TW: "Asia",
|
|
241
|
+
TZ: "Africa",
|
|
242
|
+
UA: "Europe",
|
|
243
|
+
UG: "Africa",
|
|
244
|
+
US: "North America",
|
|
245
|
+
UY: "South America",
|
|
246
|
+
UZ: "Asia",
|
|
247
|
+
VC: "North America",
|
|
248
|
+
VE: "South America",
|
|
249
|
+
VG: "North America",
|
|
250
|
+
VI: "North America",
|
|
251
|
+
VN: "Asia",
|
|
252
|
+
VU: "Australia",
|
|
253
|
+
WF: "Australia",
|
|
254
|
+
WS: "Australia",
|
|
255
|
+
YE: "Asia",
|
|
256
|
+
YT: "Africa",
|
|
257
|
+
ZA: "Africa",
|
|
258
|
+
ZM: "Africa",
|
|
259
|
+
ZW: "Africa",
|
|
260
|
+
};
|
|
261
|
+
return data[countryCode];
|
|
262
|
+
};
|
|
263
|
+
const findCountryNameFromLocation = (data) => {
|
|
264
|
+
try {
|
|
265
|
+
let country = null;
|
|
266
|
+
let countryShortName = null;
|
|
267
|
+
(data || []).forEach((item) => {
|
|
268
|
+
if (item === null || item === void 0 ? void 0 : item.types.includes("country")) {
|
|
269
|
+
country = item === null || item === void 0 ? void 0 : item.long_name;
|
|
270
|
+
countryShortName = item === null || item === void 0 ? void 0 : item.short_name;
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
return Object.assign({ country }, (country && { continent: findContinent(countryShortName) }));
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
console.log("Cant find the country", error);
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
const generateLocationString = (data) => {
|
|
280
|
+
try {
|
|
281
|
+
let locationString = [];
|
|
282
|
+
let MEDIUM = "-";
|
|
283
|
+
(data || []).forEach((item) => {
|
|
284
|
+
locationString.push(item === null || item === void 0 ? void 0 : item.long_name);
|
|
285
|
+
if (item === null || item === void 0 ? void 0 : item.types.includes("country")) {
|
|
286
|
+
locationString.push(findContinent(item === null || item === void 0 ? void 0 : item.short_name));
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
return locationString.join(MEDIUM);
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
console.log(error);
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
const getLocationByPlaceId = (placeId, isDevelopment = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
296
|
+
var _a, _b;
|
|
297
|
+
if (isDevelopment)
|
|
298
|
+
return location_js_1.dummyLocation;
|
|
299
|
+
const google_place_key = process.env.GOOGLE_PLACE_KEY || process.env.NEXT_PUBLIC_GOOGLE_PLACES_KEY;
|
|
300
|
+
const google_place_api = `https://maps.googleapis.com/maps/api/place/details/json?place_id=${placeId}&key=${google_place_key}`;
|
|
301
|
+
const { data } = yield axios_1.default.get(google_place_api);
|
|
302
|
+
const { country, continent } = findCountryNameFromLocation((_a = data === null || data === void 0 ? void 0 : data.result) === null || _a === void 0 ? void 0 : _a.address_components);
|
|
303
|
+
const location_address = generateLocationString((_b = data === null || data === void 0 ? void 0 : data.result) === null || _b === void 0 ? void 0 : _b.address_components);
|
|
304
|
+
return {
|
|
305
|
+
country,
|
|
306
|
+
continent,
|
|
307
|
+
location_address,
|
|
308
|
+
location_json: JSON.stringify(data === null || data === void 0 ? void 0 : data.result),
|
|
309
|
+
};
|
|
310
|
+
});
|
|
311
|
+
exports.getLocationByPlaceId = getLocationByPlaceId;
|
|
312
|
+
const getLocationStringOnlyByPlaceId = (placeId, isDevelopment = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
313
|
+
var _c;
|
|
314
|
+
if (isDevelopment)
|
|
315
|
+
return location_js_1.dummyLocation.location_address;
|
|
316
|
+
const google_place_key = process.env.GOOGLE_PLACE_KEY || process.env.NEXT_PUBLIC_GOOGLE_PLACES_KEY;
|
|
317
|
+
const google_place_api = `https://maps.googleapis.com/maps/api/place/details/json?place_id=${placeId}&key=${google_place_key}`;
|
|
318
|
+
const { data } = yield axios_1.default.get(google_place_api);
|
|
319
|
+
return generateLocationString((_c = data === null || data === void 0 ? void 0 : data.result) === null || _c === void 0 ? void 0 : _c.address_components);
|
|
320
|
+
});
|
|
321
|
+
exports.getLocationStringOnlyByPlaceId = getLocationStringOnlyByPlaceId;
|
|
322
|
+
const getPlaceIdByLocationString = (locationString, isDevelopment = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
323
|
+
var _d;
|
|
324
|
+
if (isDevelopment)
|
|
325
|
+
return {
|
|
326
|
+
place_id: location_js_1.dummyLocation.place_id,
|
|
327
|
+
formatted_address: location_js_1.dummyLocation.formatted_address,
|
|
328
|
+
};
|
|
329
|
+
const google_place_key = process.env.GOOGLE_PLACE_KEY || process.env.NEXT_PUBLIC_GOOGLE_PLACES_KEY;
|
|
330
|
+
const google_place_api = `https://maps.googleapis.com/maps/api/geocode/json?address=${locationString}&key=${google_place_key}`;
|
|
331
|
+
const { data } = yield axios_1.default.get(google_place_api);
|
|
332
|
+
const { place_id, formatted_address } = (_d = data === null || data === void 0 ? void 0 : data.results) === null || _d === void 0 ? void 0 : _d[0];
|
|
333
|
+
return {
|
|
334
|
+
place_id,
|
|
335
|
+
formatted_address,
|
|
336
|
+
};
|
|
337
|
+
});
|
|
338
|
+
exports.getPlaceIdByLocationString = getPlaceIdByLocationString;
|