@ouro.bot/cli 0.1.0-alpha.1306 → 0.1.0-alpha.1307
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/changelog.json +8 -1
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/mailbox-ui/assets/index-DEsikqKt.js +1 -0
- package/dist/mailbox-ui/index.html +1 -1
- package/dist/repertoire/tools-travel.js +1 -1
- package/dist/repertoire/travel-api-client.js +152 -49
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/mailbox-ui/assets/index-Cu8GV60v.js +0 -1
|
@@ -56,7 +56,7 @@ exports.travelToolDefinitions = [
|
|
|
56
56
|
properties: {
|
|
57
57
|
country_code: {
|
|
58
58
|
type: "string",
|
|
59
|
-
description: "ISO 3166 alpha-2 country code (e.g. 'US', '
|
|
59
|
+
description: "ISO 3166 alpha-2 country code (e.g. 'US', 'FR', 'AF')",
|
|
60
60
|
},
|
|
61
61
|
},
|
|
62
62
|
required: ["country_code"],
|
|
@@ -135,61 +135,162 @@ exports.TRAVEL_ADVISORY_RSS_URL = "https://travel.state.gov/_res/rss/TAsTWs.xml"
|
|
|
135
135
|
*
|
|
136
136
|
* The RSS feed Country-Tag uses FIPS codes. Callers typically pass ISO codes.
|
|
137
137
|
* When the codes match (e.g. AF for Afghanistan), no lookup is needed.
|
|
138
|
-
*
|
|
138
|
+
* A code that diverges must be listed even when its country has no advisory, because the
|
|
139
|
+
* bare tag then belongs to another country (ISO GB is the UK, but the feed's GB is Gabon;
|
|
140
|
+
* the UK's tag is UK). Values are the country names as the feed titles spell them, and a
|
|
141
|
+
* country with no advisory is listed so that it is reported as not found rather than
|
|
142
|
+
* answered with another country's advisory.
|
|
139
143
|
*/
|
|
140
144
|
const ISO_FIPS_DIVERGENCE = {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
145
|
+
AD: "Andorra",
|
|
146
|
+
AG: "Antigua and Barbuda",
|
|
147
|
+
AI: "Anguilla",
|
|
148
|
+
AQ: "Antarctica",
|
|
149
|
+
AS: "American Samoa",
|
|
150
|
+
AT: "Austria",
|
|
151
|
+
AU: "Australia",
|
|
152
|
+
AW: "Aruba",
|
|
153
|
+
AZ: "Azerbaijan",
|
|
154
|
+
BA: "Bosnia and Herzegovina",
|
|
155
|
+
BD: "Bangladesh",
|
|
156
|
+
BF: "Burkina Faso",
|
|
157
|
+
BG: "Bulgaria",
|
|
158
|
+
BH: "Bahrain",
|
|
159
|
+
BI: "Burundi",
|
|
160
|
+
BJ: "Benin",
|
|
161
|
+
BL: "Saint Barthelemy",
|
|
162
|
+
BM: "Bermuda",
|
|
163
|
+
BN: "Brunei",
|
|
164
|
+
BO: "Bolivia",
|
|
165
|
+
BS: "The Bahamas",
|
|
166
|
+
BW: "Botswana",
|
|
167
|
+
BY: "Belarus",
|
|
168
|
+
BZ: "Belize",
|
|
169
|
+
CD: "Democratic Republic of the Congo",
|
|
170
|
+
CF: "Central African Republic",
|
|
171
|
+
CG: "Republic of Congo",
|
|
172
|
+
CH: "Switzerland",
|
|
173
|
+
CI: "Côte d’Ivoire",
|
|
174
|
+
CL: "Chile",
|
|
175
|
+
CN: "China",
|
|
176
|
+
CR: "Costa Rica",
|
|
177
|
+
CW: "Curaçao",
|
|
178
|
+
CZ: "Czechia",
|
|
179
|
+
DE: "Germany",
|
|
180
|
+
DK: "Denmark",
|
|
181
|
+
DM: "Dominica",
|
|
182
|
+
DO: "Dominican Republic",
|
|
183
|
+
DZ: "Algeria",
|
|
184
|
+
EE: "Estonia",
|
|
185
|
+
ES: "Spain",
|
|
186
|
+
GA: "Gabon",
|
|
187
|
+
GB: "United Kingdom",
|
|
188
|
+
GD: "Grenada",
|
|
189
|
+
GE: "Georgia",
|
|
190
|
+
GF: "French Guiana",
|
|
191
|
+
GG: "Guernsey",
|
|
192
|
+
GM: "The Gambia",
|
|
193
|
+
GN: "Guinea",
|
|
194
|
+
GQ: "Equatorial Guinea",
|
|
195
|
+
HN: "Honduras",
|
|
196
|
+
HT: "Haiti",
|
|
197
|
+
IE: "Ireland",
|
|
198
|
+
IL: "Israel",
|
|
199
|
+
IQ: "Iraq",
|
|
200
|
+
IS: "Iceland",
|
|
201
|
+
JP: "Japan",
|
|
202
|
+
KH: "Cambodia",
|
|
203
|
+
KI: "Kiribati",
|
|
204
|
+
KM: "Comoros",
|
|
205
|
+
KN: "Saint Kitts and Nevis",
|
|
206
|
+
KP: "North Korea",
|
|
207
|
+
KR: "South Korea",
|
|
208
|
+
KW: "Kuwait",
|
|
209
|
+
KY: "Cayman Islands",
|
|
210
|
+
LB: "Lebanon",
|
|
211
|
+
LC: "Saint Lucia",
|
|
212
|
+
LI: "Liechtenstein",
|
|
213
|
+
LK: "Sri Lanka",
|
|
214
|
+
LR: "Liberia",
|
|
215
|
+
LS: "Lesotho",
|
|
216
|
+
LT: "Lithuania",
|
|
217
|
+
LV: "Latvia",
|
|
218
|
+
MA: "Morocco",
|
|
219
|
+
MC: "Monaco",
|
|
220
|
+
ME: "Montenegro",
|
|
221
|
+
MG: "Madagascar",
|
|
222
|
+
MH: "Marshall Islands",
|
|
223
|
+
MM: "Burma",
|
|
224
|
+
MN: "Mongolia",
|
|
225
|
+
MO: "Macau",
|
|
226
|
+
MP: "Northern Mariana Islands",
|
|
227
|
+
MS: "Montserrat",
|
|
228
|
+
MU: "Mauritius",
|
|
229
|
+
MW: "Malawi",
|
|
230
|
+
NA: "Namibia",
|
|
231
|
+
NE: "Niger",
|
|
232
|
+
NG: "Nigeria",
|
|
233
|
+
NI: "Nicaragua",
|
|
234
|
+
NU: "Niue",
|
|
235
|
+
OM: "Oman",
|
|
236
|
+
PA: "Panama",
|
|
237
|
+
PF: "French Polynesia",
|
|
238
|
+
PG: "Papua New Guinea",
|
|
239
|
+
PH: "Philippines",
|
|
240
|
+
PM: "Saint Pierre and Miquelon",
|
|
241
|
+
PS: "Palestinian Territories",
|
|
242
|
+
PT: "Portugal",
|
|
243
|
+
PW: "Palau",
|
|
244
|
+
PY: "Paraguay",
|
|
245
|
+
RS: "Serbia",
|
|
246
|
+
RU: "Russia",
|
|
247
|
+
SB: "Solomon Islands",
|
|
248
|
+
SC: "Seychelles",
|
|
249
|
+
SD: "Sudan",
|
|
250
|
+
SE: "Sweden",
|
|
251
|
+
SG: "Singapore",
|
|
252
|
+
SK: "Slovakia",
|
|
253
|
+
SN: "Senegal",
|
|
254
|
+
SR: "Suriname",
|
|
255
|
+
SS: "South Sudan",
|
|
256
|
+
ST: "São Tomé and Príncipe",
|
|
257
|
+
SV: "El Salvador",
|
|
258
|
+
SX: "Sint Maarten",
|
|
259
|
+
SZ: "Eswatini",
|
|
260
|
+
TC: "Turks and Caicos Islands",
|
|
261
|
+
TD: "Chad",
|
|
262
|
+
TG: "Togo",
|
|
263
|
+
TJ: "Tajikistan",
|
|
264
|
+
TK: "Tokelau",
|
|
265
|
+
TL: "Timor-Leste",
|
|
266
|
+
TM: "Turkmenistan",
|
|
267
|
+
TN: "Tunisia",
|
|
268
|
+
TO: "Tonga",
|
|
269
|
+
TR: "Turkey",
|
|
270
|
+
TT: "Trinidad and Tobago",
|
|
271
|
+
UA: "Ukraine",
|
|
272
|
+
VA: "Holy See",
|
|
273
|
+
VG: "British Virgin Islands",
|
|
274
|
+
VI: "U.S. Virgin Islands",
|
|
275
|
+
VN: "Vietnam",
|
|
276
|
+
VU: "Vanuatu",
|
|
277
|
+
XK: "Kosovo",
|
|
278
|
+
YE: "Yemen",
|
|
279
|
+
ZA: "South Africa",
|
|
280
|
+
ZM: "Zambia",
|
|
281
|
+
ZW: "Zimbabwe",
|
|
187
282
|
};
|
|
188
283
|
/**
|
|
189
284
|
* Look up the expected country name for an ISO alpha-2 code,
|
|
190
285
|
* but ONLY when that code diverges from the FIPS code used in the RSS feed.
|
|
191
286
|
* Returns undefined for codes where ISO == FIPS (no title fallback needed).
|
|
192
287
|
*/
|
|
288
|
+
const normalizeCountryName = (name) => name.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[’']/g, "'").toLowerCase().replace(/^the\s+/, "").trim();
|
|
289
|
+
function titleMatchesCountry(titleCountry, expected) {
|
|
290
|
+
const title = normalizeCountryName(titleCountry);
|
|
291
|
+
const name = normalizeCountryName(expected);
|
|
292
|
+
return title === name || title.startsWith(`${name} (`);
|
|
293
|
+
}
|
|
193
294
|
function isoToCountryName(isoCode) {
|
|
194
295
|
return ISO_FIPS_DIVERGENCE[isoCode.toUpperCase()];
|
|
195
296
|
}
|
|
@@ -258,10 +359,12 @@ async function getTravelAdvisory(countryCode) {
|
|
|
258
359
|
};
|
|
259
360
|
}
|
|
260
361
|
// Title-based match: when ISO differs from FIPS, match by country name.
|
|
261
|
-
//
|
|
362
|
+
// Names match whole, ignoring case, accents, apostrophe style and a leading "The", or with a
|
|
363
|
+
// parenthetical like "Burma (Myanmar)" after them; a prefix alone is not enough
|
|
364
|
+
// ("Niger" is not "Nigeria", "Guinea" is not "Guinea-Bissau").
|
|
262
365
|
if (expectedCountryName && !titleFallbackMatch) {
|
|
263
366
|
const titleCountry = parseCountryName(title);
|
|
264
|
-
if (titleCountry
|
|
367
|
+
if (titleMatchesCountry(titleCountry, expectedCountryName)) {
|
|
265
368
|
titleFallbackMatch = {
|
|
266
369
|
countryCode,
|
|
267
370
|
countryName: titleCountry,
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.1307",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@ouro.bot/cli",
|
|
9
|
-
"version": "0.1.0-alpha.
|
|
9
|
+
"version": "0.1.0-alpha.1307",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"@ouro.bot/friends"
|
|
12
12
|
],
|