@cyanheads/geonames-mcp-server 0.1.2 → 0.2.0
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/AGENTS.md +31 -17
- package/CLAUDE.md +31 -17
- package/Dockerfile +22 -7
- package/README.md +66 -122
- package/changelog/0.1.x/0.1.3.md +46 -0
- package/changelog/0.2.x/0.2.0.md +37 -0
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-server/tools/definitions/find-postal-codes.tool.d.ts +8 -5
- package/dist/mcp-server/tools/definitions/find-postal-codes.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/find-postal-codes.tool.js +84 -42
- package/dist/mcp-server/tools/definitions/find-postal-codes.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-children.tool.d.ts +6 -0
- package/dist/mcp-server/tools/definitions/get-children.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/get-children.tool.js +35 -18
- package/dist/mcp-server/tools/definitions/get-children.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-countries.tool.d.ts +6 -0
- package/dist/mcp-server/tools/definitions/get-countries.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/get-countries.tool.js +32 -14
- package/dist/mcp-server/tools/definitions/get-countries.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-hierarchy.tool.js +3 -3
- package/dist/mcp-server/tools/definitions/get-hierarchy.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-place.tool.d.ts +3 -1
- package/dist/mcp-server/tools/definitions/get-place.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/get-place.tool.js +35 -11
- package/dist/mcp-server/tools/definitions/get-place.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/index.d.ts +37 -5
- package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/list-reference.tool.d.ts +6 -0
- package/dist/mcp-server/tools/definitions/list-reference.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/list-reference.tool.js +34 -14
- package/dist/mcp-server/tools/definitions/list-reference.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/reverse-geocode.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/reverse-geocode.tool.js +85 -28
- package/dist/mcp-server/tools/definitions/reverse-geocode.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/search-places.tool.d.ts +12 -2
- package/dist/mcp-server/tools/definitions/search-places.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/search-places.tool.js +107 -26
- package/dist/mcp-server/tools/definitions/search-places.tool.js.map +1 -1
- package/dist/mcp-server/tools/shared-inputs.d.ts +62 -20
- package/dist/mcp-server/tools/shared-inputs.d.ts.map +1 -1
- package/dist/mcp-server/tools/shared-inputs.js +94 -29
- package/dist/mcp-server/tools/shared-inputs.js.map +1 -1
- package/dist/services/geonames/country-codes.d.ts +7 -1
- package/dist/services/geonames/country-codes.d.ts.map +1 -1
- package/dist/services/geonames/country-codes.js +15 -1
- package/dist/services/geonames/country-codes.js.map +1 -1
- package/dist/services/geonames/geonames-service.d.ts +7 -3
- package/dist/services/geonames/geonames-service.d.ts.map +1 -1
- package/dist/services/geonames/geonames-service.js +85 -35
- package/dist/services/geonames/geonames-service.js.map +1 -1
- package/dist/services/geonames/response-parsers.d.ts +9 -5
- package/dist/services/geonames/response-parsers.d.ts.map +1 -1
- package/dist/services/geonames/response-parsers.js +102 -22
- package/dist/services/geonames/response-parsers.js.map +1 -1
- package/dist/services/geonames/types.d.ts +30 -13
- package/dist/services/geonames/types.d.ts.map +1 -1
- package/dist/services/geonames/types.js +4 -3
- package/dist/services/geonames/types.js.map +1 -1
- package/dist/services/geonames/upstream-errors.d.ts.map +1 -1
- package/dist/services/geonames/upstream-errors.js +7 -7
- package/dist/services/geonames/upstream-errors.js.map +1 -1
- package/dist/utils/inline-text.d.ts +57 -12
- package/dist/utils/inline-text.d.ts.map +1 -1
- package/dist/utils/inline-text.js +137 -20
- package/dist/utils/inline-text.js.map +1 -1
- package/package.json +15 -13
- package/server.json +10 -24
- package/skills/geonames-guide/SKILL.md +64 -0
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
* Normalizations run in the schema, before validation: blanks from form clients
|
|
4
4
|
* become unset, lists accept a comma-separated string, codes are upper-cased (country
|
|
5
5
|
* codes mapped to alpha-2), and word enums are lower-cased. Also the checks tools run
|
|
6
|
-
* before any request: country codes no
|
|
7
|
-
* to nothing
|
|
6
|
+
* before any request: country codes GeoNames files no feature under, feature filters
|
|
7
|
+
* that intersect to nothing, and the clamp that holds a limit to the tool's cap; and, once
|
|
8
|
+
* a page is back, the notice fragment naming the territories a country filter also returned.
|
|
8
9
|
* @module mcp-server/tools/shared-inputs
|
|
9
10
|
*/
|
|
10
11
|
import { z } from '@cyanheads/mcp-ts-core';
|
|
11
|
-
import { alpha2For } from '../../services/geonames/country-codes.js';
|
|
12
|
+
import { alpha2For, isFiledCountryCode } from '../../services/geonames/country-codes.js';
|
|
12
13
|
import { FEATURE_CLASS_CODES, getFeatureCode, } from '../../services/geonames/feature-codes.js';
|
|
13
14
|
/** Blank when absent, null, or a whitespace-only string. */
|
|
14
15
|
export const isBlank = (value) => value === undefined || value === null || (typeof value === 'string' && value.trim() === '');
|
|
@@ -31,7 +32,8 @@ const unsetIfBlank = (value) => {
|
|
|
31
32
|
export const blankAsUnset = (schema) => z.preprocess(unsetIfBlank, schema);
|
|
32
33
|
/**
|
|
33
34
|
* An optional list that also accepts a comma-separated string. Items are trimmed and
|
|
34
|
-
* normalized, blanks dropped, and an empty list is unset.
|
|
35
|
+
* normalized, blanks dropped, and an empty list is unset. The advertised schema is the array
|
|
36
|
+
* alone, so a description offers only the list; the joined string is tolerated.
|
|
35
37
|
*/
|
|
36
38
|
export function listInput(item, { max, normalize }) {
|
|
37
39
|
return z.preprocess((value) => {
|
|
@@ -46,16 +48,25 @@ export function listInput(item, { max, normalize }) {
|
|
|
46
48
|
return items.length === 0 ? undefined : items.slice(0, max + 1);
|
|
47
49
|
}, z.array(item).max(max).optional());
|
|
48
50
|
}
|
|
49
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Lower-cases a string before `schema` validates it, so a word enum accepts any case (`Tourism`).
|
|
53
|
+
* The advertised enum lists only the lower-case members, so the description offers only those.
|
|
54
|
+
*/
|
|
50
55
|
export const lowerCased = (schema) => z.preprocess((value) => (typeof value === 'string' ? value.toLowerCase() : value), schema);
|
|
56
|
+
/**
|
|
57
|
+
* The two codes outside ISO 3166-1 alpha-2 that GeoNames' search answers as a country:
|
|
58
|
+
* `UK` (ISO's exceptionally reserved code for the United Kingdom) and `FL` (Liechtenstein's
|
|
59
|
+
* international vehicle code).
|
|
60
|
+
*/
|
|
61
|
+
const COUNTRY_ALIASES = { UK: 'GB', FL: 'LI' };
|
|
51
62
|
/**
|
|
52
63
|
* Upper-cases a country code and maps it to the alpha-2 GeoNames keys countries by: `UK`
|
|
53
|
-
*
|
|
54
|
-
*
|
|
64
|
+
* to `GB` and `FL` to `LI` (see {@link COUNTRY_ALIASES}), and an alpha-3 or three-digit
|
|
65
|
+
* numeric code to its country's alpha-2. A code no country has stays, upper-cased.
|
|
55
66
|
*/
|
|
56
67
|
export const toAlpha2 = (item) => {
|
|
57
68
|
const code = item.toUpperCase();
|
|
58
|
-
return code
|
|
69
|
+
return COUNTRY_ALIASES[code] ?? alpha2For(code) ?? code;
|
|
59
70
|
};
|
|
60
71
|
/** Optional caller GeoNames account; never logged, cached, or echoed. */
|
|
61
72
|
export const geonamesUsernameInput = blankAsUnset(z
|
|
@@ -67,10 +78,11 @@ export const USERNAME_ALIASES = { username: 'geonamesUsername' };
|
|
|
67
78
|
/**
|
|
68
79
|
* Argument names `setup()` registers with `sanitization.setSensitiveFields`, so the
|
|
69
80
|
* failed-call payload record redacts a username sent under a near-miss key. The framework
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
81
|
+
* splits a key into lower-cased words at separators, camelCase boundaries, the end of a run
|
|
82
|
+
* of capitals, and around digits, and matches every run of adjacent words, joined:
|
|
83
|
+
* `user` and `account` cover `geonames_user`, `GEONAMES_USER`, and `GeoNamesAccount`, and
|
|
84
|
+
* the run-together names cover a key written as one word, such as `geonamesuser` or
|
|
85
|
+
* `GEONAMESUSER`, which the word split leaves whole.
|
|
74
86
|
*/
|
|
75
87
|
export const USERNAME_LOG_FIELDS = [
|
|
76
88
|
'geonamesUsername',
|
|
@@ -87,6 +99,8 @@ const MAX_GEONAME_ID = 2_147_483_647;
|
|
|
87
99
|
/**
|
|
88
100
|
* Required GeoNames feature id, as a digit string of at most {@link MAX_GEONAME_ID}. A
|
|
89
101
|
* JSON integer becomes its digit string here, so an out-of-range one gets the range message.
|
|
102
|
+
* The advertised pattern admits only the digit string, so the description offers only that;
|
|
103
|
+
* the URL and integer forms are tolerated.
|
|
90
104
|
*/
|
|
91
105
|
export const geonameIdInput = z
|
|
92
106
|
.preprocess((value) => typeof value === 'string'
|
|
@@ -95,27 +109,33 @@ export const geonameIdInput = z
|
|
|
95
109
|
? String(value)
|
|
96
110
|
: value, z
|
|
97
111
|
.string()
|
|
98
|
-
.regex(/^[1-9]\d*$/, {
|
|
112
|
+
.regex(/^[1-9]\d*$/, {
|
|
113
|
+
error: 'Must be a digit string with no leading zero, such as "5809844".',
|
|
114
|
+
abort: true,
|
|
115
|
+
})
|
|
99
116
|
.refine((id) => Number(id) <= MAX_GEONAME_ID, {
|
|
100
117
|
error: `Must be at most ${MAX_GEONAME_ID}, the largest geonameId GeoNames accepts.`,
|
|
101
118
|
}))
|
|
102
|
-
.describe(`GeoNames feature id
|
|
119
|
+
.describe(`GeoNames feature id as a digit string up to ${MAX_GEONAME_ID}, such as "5809844" (Seattle): the geonameId the other geonames tools return, sent as a string.`);
|
|
103
120
|
/**
|
|
104
121
|
* Optional country filter, up to 10 codes, each mapped to alpha-2 by {@link toAlpha2}. A
|
|
105
|
-
* well-formed
|
|
106
|
-
* reject; see {@link unknownCountryCodes}.
|
|
122
|
+
* well-formed code GeoNames files no feature under passes the schema for the tool to
|
|
123
|
+
* reject before any request; see {@link unknownCountryCodes}. GeoNames' `country` filter
|
|
124
|
+
* also returns the territories it files under a listed country, and the tools relay those
|
|
125
|
+
* rows as returned, so the description says so.
|
|
107
126
|
*/
|
|
108
127
|
export const countriesInput = listInput(z
|
|
109
128
|
.string()
|
|
110
129
|
.regex(/^([A-Z]{2,3}|\d{3})$/)
|
|
111
|
-
.describe('ISO 3166-1 alpha-2, alpha-3, or three-digit numeric country code.'), { max: 10, normalize: toAlpha2 }).describe('ISO 3166-1 country codes, up to 10, as a list
|
|
130
|
+
.describe('ISO 3166-1 alpha-2, alpha-3, or three-digit numeric country code.'), { max: 10, normalize: toAlpha2 }).describe('ISO 3166-1 country codes, up to 10, as a list: alpha-2 (US, GB, DE), alpha-3 (USA, GBR, DEU), or three-digit numeric (840, 826, 276), each sent to GeoNames as alpha-2. UK is accepted for GB and FL for LI. A listed country also returns the territories GeoNames files under it (GB also returns IM, JE, and GG), each result naming its own country in countryCode.');
|
|
112
131
|
/**
|
|
113
|
-
* The `countries` entries
|
|
114
|
-
*
|
|
115
|
-
*
|
|
132
|
+
* The `countries` entries GeoNames files no feature under: after {@link toAlpha2}, each
|
|
133
|
+
* entry outside the 250 country codes and the retired `AN`, `CS`, and `YU`, whether an
|
|
134
|
+
* alpha-2 such as `EL` or an alpha-3 or numeric code the table could not map. Returns
|
|
135
|
+
* `undefined` when every entry is one of those codes.
|
|
116
136
|
*/
|
|
117
137
|
export function unknownCountryCodes(countries) {
|
|
118
|
-
const unknown = [...new Set(countries?.filter((code) => code
|
|
138
|
+
const unknown = [...new Set(countries?.filter((code) => !isFiledCountryCode(code)))];
|
|
119
139
|
if (unknown.length === 0)
|
|
120
140
|
return;
|
|
121
141
|
return {
|
|
@@ -123,15 +143,34 @@ export function unknownCountryCodes(countries) {
|
|
|
123
143
|
message: `No country has the ${unknown.length === 1 ? 'code' : 'codes'} ${unknown.join(', ')}. countries takes ISO 3166-1 codes: alpha-2 (US, GB, DE), alpha-3 (USA), or three-digit numeric (840).`,
|
|
124
144
|
};
|
|
125
145
|
}
|
|
146
|
+
const LIST = new Intl.ListFormat('en', { type: 'conjunction' });
|
|
147
|
+
/**
|
|
148
|
+
* The notice fragment naming the countries on a page that `countries` (as the schema
|
|
149
|
+
* normalized it, alpha-2) does not list: the territories GeoNames' `country` filter returns
|
|
150
|
+
* under a listed country, relayed rather than dropped. Each code appears once, in page
|
|
151
|
+
* order, read from the page's own rows, so no parent-to-territory table is needed; a row
|
|
152
|
+
* with no `countryCode` is skipped. `noun` names one row of the page. Returns `undefined`
|
|
153
|
+
* without `countries` or when every code on the page is listed.
|
|
154
|
+
*/
|
|
155
|
+
export function unlistedCountriesFragment(countryCodes, countries, noun) {
|
|
156
|
+
if (countries === undefined)
|
|
157
|
+
return;
|
|
158
|
+
const unlisted = [
|
|
159
|
+
...new Set(countryCodes.filter((code) => code !== undefined && !countries.includes(code))),
|
|
160
|
+
];
|
|
161
|
+
if (unlisted.length === 0)
|
|
162
|
+
return;
|
|
163
|
+
return `This page also holds ${noun}s in ${LIST.format(unlisted)}, which countries does not list: GeoNames returns the territories it files under a listed country, and each ${noun}'s countryCode names its own country.`;
|
|
164
|
+
}
|
|
126
165
|
/** Optional feature-class filter, up to all nine classes. */
|
|
127
|
-
export const featureClassesInput = listInput(z.enum(FEATURE_CLASS_CODES).describe('One-letter GeoNames feature class.'), { max: 9, normalize: (item) => item.toUpperCase() }).describe('GeoNames feature classes: A admin divisions, H water, L areas, P populated places, R roads, S spots and buildings, T terrain, U undersea, V vegetation.
|
|
166
|
+
export const featureClassesInput = listInput(z.enum(FEATURE_CLASS_CODES).describe('One-letter GeoNames feature class.'), { max: 9, normalize: (item) => item.toUpperCase() }).describe('GeoNames feature classes: A admin divisions, H water, L areas, P populated places, R roads, S spots and buildings, T terrain, U undersea, V vegetation. With featureCodes too, the two lists intersect: list exactly the classes of those codes, or pass featureCodes alone.');
|
|
128
167
|
/** Optional feature-code filter, up to 20 codes; tools check each against the bundled table. */
|
|
129
168
|
export const featureCodesInput = listInput(z
|
|
130
169
|
.string()
|
|
131
170
|
.regex(/^[A-Z0-9]{2,5}$/)
|
|
132
|
-
.describe('GeoNames feature code without its class prefix.'), { max: 20, normalize: (item) => item.toUpperCase().replace(/^[A-Z]\./, '') }).describe("GeoNames feature codes (PPLC capital, ADM1 state, MT mountain, AIRP airport), up to 20, as a list
|
|
171
|
+
.describe('GeoNames feature code without its class prefix.'), { max: 20, normalize: (item) => item.toUpperCase().replace(/^[A-Z]\./, '') }).describe("GeoNames feature codes (PPLC capital, ADM1 state, MT mountain, AIRP airport), up to 20, as a list. Each code implies its class; with featureClasses too, the two lists intersect, so featureClasses must list exactly these codes' classes. geonames_list_reference topic feature_codes lists every code.");
|
|
133
172
|
/** Optional population tier for populated places. */
|
|
134
|
-
export const citiesInput = blankAsUnset(lowerCased(z.enum(['cities1000', 'cities5000', 'cities15000']).optional())).describe("Keep only populated places (class P) with a population of at least 1,000 (cities1000), 5,000 (cities5000), or 15,000 (cities15000), plus seats of admin divisions: GeoNames' cities tiers. Beside featureClasses or featureCodes, list only class P or class-P codes such as PPLC.
|
|
173
|
+
export const citiesInput = blankAsUnset(lowerCased(z.enum(['cities1000', 'cities5000', 'cities15000']).optional())).describe("Keep only populated places (class P) with a population of at least 1,000 (cities1000), 5,000 (cities5000), or 15,000 (cities15000), plus seats of admin divisions: GeoNames' cities tiers. A city's sections (PPLX) with their own population pass too. Beside featureClasses or featureCodes, list only class P or class-P codes such as PPLC.");
|
|
135
174
|
/** `cities` as the class restriction it is. */
|
|
136
175
|
const CITIES_RESTRICTION = 'cities (class P only)';
|
|
137
176
|
/**
|
|
@@ -183,7 +222,7 @@ export function featureFilterMismatch({ featureClasses, featureCodes, cities, })
|
|
|
183
222
|
applied.push('featureCodes');
|
|
184
223
|
if (cities !== undefined)
|
|
185
224
|
applied.push('cities');
|
|
186
|
-
const filters =
|
|
225
|
+
const filters = LIST.format(applied);
|
|
187
226
|
const clauses = [...codeClauses.values(), ...classClauses.values()].join('; ');
|
|
188
227
|
return {
|
|
189
228
|
featureClasses: [...classClauses.keys()],
|
|
@@ -204,9 +243,31 @@ export const lngInput = z
|
|
|
204
243
|
.max(180)
|
|
205
244
|
.describe('Longitude in decimal degrees, -180 to 180.');
|
|
206
245
|
/** Optional local name filter; see {@link nameMatcher}. */
|
|
207
|
-
export const nameContainsInput = blankAsUnset(z.string().max(100).optional()).describe('Keep only entries whose name contains every word of this text as a substring (kansas also matches Arkansas), ignoring case, accents, and punctuation.');
|
|
208
|
-
/**
|
|
209
|
-
export const
|
|
246
|
+
export const nameContainsInput = blankAsUnset(z.string().max(100).optional()).describe('Keep only entries whose name contains every word of this text as a substring (kansas also matches Arkansas), ignoring case, accents, and punctuation. Give at least one letter or digit.');
|
|
247
|
+
/** The `name_contains_unsearchable` message: a nonblank `nameContains` with no letter or digit. */
|
|
248
|
+
export const UNSEARCHABLE_NAME_MESSAGE = 'nameContains has no letter or digit. Names are matched on their letters and digits alone, so this text would match every entry.';
|
|
249
|
+
/** The largest `limit` a clamped input accepts; anything above it fails validation as absurd. */
|
|
250
|
+
const LIMIT_CEILING = 1000;
|
|
251
|
+
/**
|
|
252
|
+
* A `limit` input for a tool that returns at most `cap` entries a call: 1 to 1,000, `fallback`
|
|
253
|
+
* when omitted or blank. The handler holds a value above `cap` to `cap` with {@link clampLimit}
|
|
254
|
+
* instead of rejecting a request it can answer up to the cap.
|
|
255
|
+
*/
|
|
256
|
+
export const clampedLimitInput = (cap, fallback) => blankAsUnset(z.number().int().min(1).max(LIMIT_CEILING).default(fallback)).describe(`Maximum entries to return, 1 to ${LIMIT_CEILING.toLocaleString('en-US')}. This tool returns at most ${cap} per call: a larger limit is held to ${cap}, and the notice says so when more entries remain. Default ${fallback}.`);
|
|
257
|
+
/**
|
|
258
|
+
* Holds `requested` to `cap`, before any request or slice. The tool writes `applied` as its
|
|
259
|
+
* `cap` enrichment, and puts `fragment` in its notice ahead of its continuation only on a page
|
|
260
|
+
* with entries remaining past it: a clamped call whose entries all fit says nothing of the
|
|
261
|
+
* clamp. `field` is the input's name as the fragment prints it.
|
|
262
|
+
*/
|
|
263
|
+
export function clampLimit(requested, cap, field = 'limit') {
|
|
264
|
+
return requested > cap
|
|
265
|
+
? {
|
|
266
|
+
applied: cap,
|
|
267
|
+
fragment: `${field} ${requested} was capped at ${cap}, the most this tool returns per call.`,
|
|
268
|
+
}
|
|
269
|
+
: { applied: requested };
|
|
270
|
+
}
|
|
210
271
|
/** An `offset` input: entries to skip, 0 when omitted or blank. */
|
|
211
272
|
export const offsetInput = (max) => blankAsUnset((max === undefined ? z.number().int().min(0) : z.number().int().min(0).max(max)).default(0)).describe(max === undefined
|
|
212
273
|
? 'Entries to skip before the first one returned, for paging. Default 0.'
|
|
@@ -219,10 +280,14 @@ const normalizeForMatch = (value) => value
|
|
|
219
280
|
.replace(/[^\p{L}\p{N}\s]/gu, ' ');
|
|
220
281
|
/**
|
|
221
282
|
* Builds the strict token matcher behind `nameContains`: every word of `query` must
|
|
222
|
-
* appear somewhere in the given fields.
|
|
283
|
+
* appear somewhere in the given fields. Returns `undefined` when `query` normalizes to no
|
|
284
|
+
* word (it holds no letter or digit), which would match everything; the tool rejects that
|
|
285
|
+
* as `name_contains_unsearchable` with {@link UNSEARCHABLE_NAME_MESSAGE}.
|
|
223
286
|
*/
|
|
224
287
|
export function nameMatcher(query) {
|
|
225
288
|
const tokens = normalizeForMatch(query).split(/\s+/).filter(Boolean);
|
|
289
|
+
if (tokens.length === 0)
|
|
290
|
+
return;
|
|
226
291
|
return (fields) => {
|
|
227
292
|
const haystack = fields
|
|
228
293
|
.filter((field) => field !== undefined)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-inputs.js","sourceRoot":"","sources":["../../../src/mcp-server/tools/shared-inputs.ts"],"names":[],"mappings":"AAAA
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E,CAAC,KAAK,KAAK,SAAS,CAAC;aACtC,GAAG,CAAC,iBAAiB,CAAC;aACtB,IAAI,CAAC,GAAG,CAAC,CAAC;QACb,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC;AASD,iFAAiF;AACjF,MAAM,UAAU,QAAQ,CAAI,KAAmB,EAAE,MAAc,EAAE,KAAa;IAC5E,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAClC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AAC3F,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview ISO 3166-1 alpha-2, alpha-3, and numeric codes of the 250 GeoNames
|
|
3
3
|
* countries, bundled so the country filters can map alpha-3 and numeric codes to the
|
|
4
|
-
* alpha-2 GeoNames takes inside a synchronous schema preprocess
|
|
4
|
+
* alpha-2 GeoNames takes inside a synchronous schema preprocess, and refuse before any
|
|
5
|
+
* request a code GeoNames files no feature under (the 250 plus three retired codes).
|
|
5
6
|
*
|
|
6
7
|
* Source: https://secure.geonames.org/countryInfoJSON (`countryCode`, `isoAlpha3`,
|
|
7
8
|
* `isoNumeric`), fetched 2026-10-01 (250 rows). Kosovo (XK/XKX) has no ISO numeric code
|
|
@@ -23,4 +24,9 @@ export declare const COUNTRY_CODES: readonly CountryCodes[];
|
|
|
23
24
|
* any other code, an alpha-2 code included.
|
|
24
25
|
*/
|
|
25
26
|
export declare function alpha2For(code: string): string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Whether GeoNames files features under the upper-case alpha-2 `code`: one of the 250
|
|
29
|
+
* countries, or a retired code in {@link RETIRED_CODES}.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isFiledCountryCode(code: string): boolean;
|
|
26
32
|
//# sourceMappingURL=country-codes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"country-codes.d.ts","sourceRoot":"","sources":["../../../src/services/geonames/country-codes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"country-codes.d.ts","sourceRoot":"","sources":["../../../src/services/geonames/country-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,sCAAsC;AACtC,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA+PD,4CAA4C;AAC5C,eAAO,MAAM,aAAa,EAAE,SAAS,YAAY,EAK7C,CAAC;AAgBL;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE1D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview ISO 3166-1 alpha-2, alpha-3, and numeric codes of the 250 GeoNames
|
|
3
3
|
* countries, bundled so the country filters can map alpha-3 and numeric codes to the
|
|
4
|
-
* alpha-2 GeoNames takes inside a synchronous schema preprocess
|
|
4
|
+
* alpha-2 GeoNames takes inside a synchronous schema preprocess, and refuse before any
|
|
5
|
+
* request a code GeoNames files no feature under (the 250 plus three retired codes).
|
|
5
6
|
*
|
|
6
7
|
* Source: https://secure.geonames.org/countryInfoJSON (`countryCode`, `isoAlpha3`,
|
|
7
8
|
* `isoNumeric`), fetched 2026-10-01 (250 rows). Kosovo (XK/XKX) has no ISO numeric code
|
|
@@ -274,6 +275,12 @@ for (const { alpha2, alpha3, numeric } of COUNTRY_CODES) {
|
|
|
274
275
|
if (numeric)
|
|
275
276
|
TO_ALPHA2.set(numeric, alpha2);
|
|
276
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* Retired codes GeoNames still files historical-country records under (allCountries dump
|
|
280
|
+
* of 2026-10-18: AN 2 features, CS 2, YU 1); no country row carries them.
|
|
281
|
+
*/
|
|
282
|
+
const RETIRED_CODES = new Set(['AN', 'CS', 'YU']);
|
|
283
|
+
const FILED_CODES = new Set([...COUNTRY_CODES.map(({ alpha2 }) => alpha2), ...RETIRED_CODES]);
|
|
277
284
|
/**
|
|
278
285
|
* The alpha-2 code for an upper-case alpha-3 or three-digit numeric code; `undefined` for
|
|
279
286
|
* any other code, an alpha-2 code included.
|
|
@@ -281,4 +288,11 @@ for (const { alpha2, alpha3, numeric } of COUNTRY_CODES) {
|
|
|
281
288
|
export function alpha2For(code) {
|
|
282
289
|
return TO_ALPHA2.get(code);
|
|
283
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Whether GeoNames files features under the upper-case alpha-2 `code`: one of the 250
|
|
293
|
+
* countries, or a retired code in {@link RETIRED_CODES}.
|
|
294
|
+
*/
|
|
295
|
+
export function isFiledCountryCode(code) {
|
|
296
|
+
return FILED_CODES.has(code);
|
|
297
|
+
}
|
|
284
298
|
//# sourceMappingURL=country-codes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"country-codes.js","sourceRoot":"","sources":["../../../src/services/geonames/country-codes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"country-codes.js","sourceRoot":"","sources":["../../../src/services/geonames/country-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,MAAM,IAAI,GAAG;;;;;;;;;;;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AC,MAAM,CAAC,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC;AAE9F;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -83,11 +83,15 @@ export declare class GeoNamesService {
|
|
|
83
83
|
/** `findNearbyJSON` (4 credits, cached 24 h): nearest features of the given classes/codes. */
|
|
84
84
|
nearbyFeatures(params: NearbyFeaturesParams, account: GeoNamesAccount, ctx: Context): Promise<Toponym[]>;
|
|
85
85
|
/**
|
|
86
|
-
* `timezoneJSON` (1 credit, never cached: it carries the current local time)
|
|
87
|
-
* `
|
|
86
|
+
* `timezoneJSON` (1 credit, never cached: it carries the current local time), with the
|
|
87
|
+
* `date` whose solar day covers the point's local date when GeoNames' default one does
|
|
88
|
+
* not. `undefined` when GeoNames answers status 15.
|
|
88
89
|
*/
|
|
89
90
|
timezone(lat: number, lng: number, account: GeoNamesAccount, ctx: Context): Promise<TimezoneInfo | undefined>;
|
|
90
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* `postalCodeSearchJSON` (1 credit, cached 24 h): by postal code or by place name. GeoNames
|
|
93
|
+
* documents no `startRow` here but honors it in both lookups, up to 5000.
|
|
94
|
+
*/
|
|
91
95
|
postalSearch(params: PostalSearchParams, account: GeoNamesAccount, ctx: Context): Promise<PostalCode[]>;
|
|
92
96
|
/** `findNearbyPostalCodesJSON` (2 credits, cached 24 h), nearest first. */
|
|
93
97
|
postalNearby(params: PostalNearbyParams, account: GeoNamesAccount, ctx: Context): Promise<PostalCode[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geonames-service.d.ts","sourceRoot":"","sources":["../../../src/services/geonames/geonames-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EACL,WAAW,EAMZ,MAAM,8BAA8B,CAAC;AAgBtC,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,cAAc,EACd,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EAClB,KAAK,EACL,WAAW,EACX,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,OAAO,EACR,MAAM,YAAY,CAAC;AAmCpB,4FAA4F;AAC5F,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE/E,0DAA0D;AAC1D,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,WAAW,CAAC;IACjC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,wEAAwE;IACxE,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC;AAED;;;;GAIG;AACH,qBAAa,eAAe;;IAE1B,oFAAoF;IACpF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAE/B,YAAY,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAOlD;IAED,wEAAwE;IACxE,IAAI,QAAQ,IAAI,MAAM,CAErB;CACF;
|
|
1
|
+
{"version":3,"file":"geonames-service.d.ts","sourceRoot":"","sources":["../../../src/services/geonames/geonames-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EACL,WA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O,EAAE,eAAe,EACxB,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,OAAO,EAAE,CAAC,CAoBpB;IAED;;;;OAIG;IACH,QAAQ,CACN,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,eAAe,EACxB,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAenC;IAED;;;OAGG;IACH,YAAY,CACV,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,eAAe,EACxB,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,UAAU,EAAE,CAAC,CAiBvB;IAED,2EAA2E;IAC3E,YAAY,CACV,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,eAAe,EACxB,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,UAAU,EAAE,CAAC,CAiBvB;IAED,mFAAmF;IACnF,SAAS,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAWxE;IAED,2FAA2F;IAC3F,eAAe,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAWhF;CA0PF;AAMD,8DAA8D;AAC9D,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,sBAA2B,GAAG,eAAe,CAIzF;AAED,mEAAmE;AACnE,wBAAgB,kBAAkB,IAAI,eAAe,CAKpD"}
|
|
@@ -60,6 +60,18 @@ function cacheKeyOf(endpoint, params) {
|
|
|
60
60
|
const sorted = params.toSorted(([a, av], [b, bv]) => a.localeCompare(b) || av.localeCompare(bv));
|
|
61
61
|
return `${endpoint}?${new URLSearchParams(sorted.map(([k, v]) => [k, v])).toString()}`;
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* The `date` sent to `timezoneJSON` (Design Decision 51). GeoNames' default sunrise and
|
|
65
|
+
* sunset are for the solar day of the UTC date at the point's longitude, and `date` asks
|
|
66
|
+
* for one more solar day. The solar day whose events fall on the point's local date is the
|
|
67
|
+
* default day or the one before it while UTC hours plus `lng / 15` stay below 12, and the
|
|
68
|
+
* default day or the one after it from then on, so `date` is that other day.
|
|
69
|
+
*/
|
|
70
|
+
function solarDateParam(nowMs, lng) {
|
|
71
|
+
const dayStart = nowMs - (nowMs % DAY_MS);
|
|
72
|
+
const solarHours = (nowMs - dayStart) / HOUR_MS + lng / 15;
|
|
73
|
+
return new Date(dayStart + (solarHours < 12 ? -DAY_MS : DAY_MS)).toISOString().slice(0, 10);
|
|
74
|
+
}
|
|
63
75
|
/** `withRetry` predicate: the framework default, except a spent quota fails at once. */
|
|
64
76
|
const isTransient = (error) => reasonOf(error) !== 'quota_exhausted' && defaultIsTransient(error);
|
|
65
77
|
/** Upstream access for every GeoNames tool. Construct through {@link initGeoNamesService}. */
|
|
@@ -69,6 +81,7 @@ export class GeoNamesService {
|
|
|
69
81
|
#createPacer;
|
|
70
82
|
#fetch;
|
|
71
83
|
#flights = new Map();
|
|
84
|
+
#now;
|
|
72
85
|
/** Caller-account pacers, least recently used first. */
|
|
73
86
|
#pacers = new Map();
|
|
74
87
|
#serverAccount;
|
|
@@ -77,10 +90,11 @@ export class GeoNamesService {
|
|
|
77
90
|
this.#baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
|
|
78
91
|
this.#createPacer = options.createPacer ?? createPacer;
|
|
79
92
|
this.#fetch = options.fetch ?? ((url, init) => fetch(url, init));
|
|
93
|
+
this.#now = options.now ?? Date.now;
|
|
80
94
|
this.#cache = new ResponseCache({
|
|
81
95
|
maxBytes: 32 * 1024 * 1024,
|
|
82
96
|
maxEntries: 5_000,
|
|
83
|
-
now:
|
|
97
|
+
now: this.#now,
|
|
84
98
|
});
|
|
85
99
|
this.#serverAccount =
|
|
86
100
|
options.serverUsername === undefined
|
|
@@ -131,6 +145,11 @@ export class GeoNamesService {
|
|
|
131
145
|
}
|
|
132
146
|
for (const country of params.countries ?? [])
|
|
133
147
|
query.push(['country', country]);
|
|
148
|
+
for (const name of ['adminCode1', 'adminCode2', 'adminCode3', 'adminCode4']) {
|
|
149
|
+
const code = params[name];
|
|
150
|
+
if (code !== undefined)
|
|
151
|
+
query.push([name, code]);
|
|
152
|
+
}
|
|
134
153
|
for (const featureClass of params.featureClasses ?? [])
|
|
135
154
|
query.push(['featureClass', featureClass]);
|
|
136
155
|
for (const featureCode of params.featureCodes ?? [])
|
|
@@ -141,8 +160,8 @@ export class GeoNamesService {
|
|
|
141
160
|
const { north, south, east, west } = params.boundingBox;
|
|
142
161
|
query.push(['north', String(north)], ['south', String(south)], ['east', String(east)], ['west', String(west)]);
|
|
143
162
|
}
|
|
144
|
-
if (params.orderBy
|
|
145
|
-
query.push(['orderby',
|
|
163
|
+
if (params.orderBy)
|
|
164
|
+
query.push(['orderby', params.orderBy]);
|
|
146
165
|
query.push(['maxRows', String(params.limit)], ['startRow', String(params.offset)]);
|
|
147
166
|
return this.#call({
|
|
148
167
|
endpoint: 'searchJSON',
|
|
@@ -277,8 +296,9 @@ export class GeoNamesService {
|
|
|
277
296
|
}, account, ctx);
|
|
278
297
|
}
|
|
279
298
|
/**
|
|
280
|
-
* `timezoneJSON` (1 credit, never cached: it carries the current local time)
|
|
281
|
-
* `
|
|
299
|
+
* `timezoneJSON` (1 credit, never cached: it carries the current local time), with the
|
|
300
|
+
* `date` whose solar day covers the point's local date when GeoNames' default one does
|
|
301
|
+
* not. `undefined` when GeoNames answers status 15.
|
|
282
302
|
*/
|
|
283
303
|
timezone(lat, lng, account, ctx) {
|
|
284
304
|
return this.#call({
|
|
@@ -286,12 +306,16 @@ export class GeoNamesService {
|
|
|
286
306
|
params: [
|
|
287
307
|
['lat', String(lat)],
|
|
288
308
|
['lng', String(lng)],
|
|
309
|
+
['date', solarDateParam(this.#now(), lng)],
|
|
289
310
|
],
|
|
290
311
|
ttlMs: 0,
|
|
291
312
|
parse: (payload) => bodyOr(payload, undefined, parseTimezone),
|
|
292
313
|
}, account, ctx);
|
|
293
314
|
}
|
|
294
|
-
/**
|
|
315
|
+
/**
|
|
316
|
+
* `postalCodeSearchJSON` (1 credit, cached 24 h): by postal code or by place name. GeoNames
|
|
317
|
+
* documents no `startRow` here but honors it in both lookups, up to 5000.
|
|
318
|
+
*/
|
|
295
319
|
postalSearch(params, account, ctx) {
|
|
296
320
|
const query = [];
|
|
297
321
|
if (params.postalCode !== undefined)
|
|
@@ -300,7 +324,7 @@ export class GeoNamesService {
|
|
|
300
324
|
query.push(['placename', params.placeName]);
|
|
301
325
|
for (const country of params.countries ?? [])
|
|
302
326
|
query.push(['country', country]);
|
|
303
|
-
query.push(['maxRows', String(params.limit)]);
|
|
327
|
+
query.push(['maxRows', String(params.limit)], ['startRow', String(params.offset)]);
|
|
304
328
|
return this.#call({
|
|
305
329
|
endpoint: 'postalCodeSearchJSON',
|
|
306
330
|
params: query,
|
|
@@ -348,8 +372,8 @@ export class GeoNamesService {
|
|
|
348
372
|
if (hit)
|
|
349
373
|
return Promise.resolve(hit.value);
|
|
350
374
|
}
|
|
351
|
-
return this.#singleFlight(`${account.key} ${cacheKey}`, ctx, async () => {
|
|
352
|
-
const { value, bytes } = await this.#fetchWithRetry(spec, account, ctx);
|
|
375
|
+
return this.#singleFlight(`${account.key} ${cacheKey}`, ctx.signal, async (signal) => {
|
|
376
|
+
const { value, bytes } = await this.#fetchWithRetry(spec, account, ctx, signal);
|
|
353
377
|
if (spec.ttlMs > 0 && (spec.cacheable?.(value) ?? true)) {
|
|
354
378
|
this.#cache.set(cacheKey, value, bytes, spec.ttlMs);
|
|
355
379
|
}
|
|
@@ -357,37 +381,61 @@ export class GeoNamesService {
|
|
|
357
381
|
});
|
|
358
382
|
}
|
|
359
383
|
/**
|
|
360
|
-
* Joins an identical in-flight request on the same account, else starts one.
|
|
361
|
-
*
|
|
384
|
+
* Joins an identical in-flight request on the same account, else starts one. Each
|
|
385
|
+
* caller races the shared request against its own signal: a cancelled caller rejects
|
|
386
|
+
* at once with its own `signal.reason` while the others keep waiting, and the request
|
|
387
|
+
* aborts only when its last caller has left. Its outcome, failure included, reaches
|
|
388
|
+
* every caller still waiting.
|
|
362
389
|
*/
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
390
|
+
#singleFlight(key, signal, run) {
|
|
391
|
+
if (signal.aborted)
|
|
392
|
+
return Promise.reject(signal.reason);
|
|
393
|
+
const flight = this.#flights.get(key) ?? this.#startFlight(key, run);
|
|
394
|
+
flight.waiting++;
|
|
395
|
+
return new Promise((resolve, reject) => {
|
|
396
|
+
const leave = () => {
|
|
397
|
+
reject(signal.reason);
|
|
398
|
+
if (--flight.waiting > 0)
|
|
399
|
+
return;
|
|
400
|
+
if (this.#flights.get(key) === flight)
|
|
401
|
+
this.#flights.delete(key);
|
|
402
|
+
flight.controller.abort(signal.reason);
|
|
403
|
+
};
|
|
404
|
+
signal.addEventListener('abort', leave, { once: true });
|
|
405
|
+
flight.promise.then((value) => {
|
|
406
|
+
signal.removeEventListener('abort', leave);
|
|
407
|
+
resolve(value);
|
|
408
|
+
}, (error) => {
|
|
409
|
+
signal.removeEventListener('abort', leave);
|
|
410
|
+
reject(error);
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Starts a shared request on a flight-owned signal, so no caller's cancellation
|
|
416
|
+
* reaches it. It leaves the map when it settles, or sooner when its last caller leaves.
|
|
417
|
+
*/
|
|
418
|
+
#startFlight(key, run) {
|
|
419
|
+
const controller = new AbortController();
|
|
420
|
+
const flight = { controller, promise: run(controller.signal), waiting: 0 };
|
|
375
421
|
this.#flights.set(key, flight);
|
|
376
|
-
|
|
377
|
-
return (await flight.promise);
|
|
378
|
-
}
|
|
379
|
-
finally {
|
|
422
|
+
const land = () => {
|
|
380
423
|
if (this.#flights.get(key) === flight)
|
|
381
424
|
this.#flights.delete(key);
|
|
382
|
-
}
|
|
425
|
+
};
|
|
426
|
+
flight.promise.then(land, land);
|
|
427
|
+
return flight;
|
|
383
428
|
}
|
|
384
|
-
/**
|
|
385
|
-
|
|
429
|
+
/**
|
|
430
|
+
* The retry ladder, run on the flight's signal rather than a caller's; `ctx` only
|
|
431
|
+
* correlates its log records. Its total-deadline expiry is restated as `upstream_timeout`.
|
|
432
|
+
*/
|
|
433
|
+
#fetchWithRetry(spec, account, ctx, signal) {
|
|
386
434
|
const pacer = this.#pacerFor(account);
|
|
387
|
-
const ladder = withRetry(async ({ remainingMs, signal }) => {
|
|
435
|
+
const ladder = withRetry(async ({ remainingMs, signal: attemptSignal }) => {
|
|
388
436
|
try {
|
|
389
437
|
return await pacer.run((taskSignal) => this.#attempt(spec, account, ctx, taskSignal), {
|
|
390
|
-
signal,
|
|
438
|
+
signal: attemptSignal,
|
|
391
439
|
maxWaitMs: Math.min(MAX_QUEUE_WAIT_MS, remainingMs),
|
|
392
440
|
});
|
|
393
441
|
}
|
|
@@ -400,7 +448,7 @@ export class GeoNamesService {
|
|
|
400
448
|
}, {
|
|
401
449
|
operation: `GeoNamesService.${spec.endpoint}`,
|
|
402
450
|
context: ctx,
|
|
403
|
-
signal
|
|
451
|
+
signal,
|
|
404
452
|
maxRetries: 2,
|
|
405
453
|
baseDelayMs: 1_000,
|
|
406
454
|
maxDelayMs: 5_000,
|
|
@@ -418,7 +466,9 @@ export class GeoNamesService {
|
|
|
418
466
|
* while the call is cancelled or out of time surfaces as the abort reason, so the
|
|
419
467
|
* runtime's own error, which can carry the request URL, never enters an error chain.
|
|
420
468
|
* The response record goes to the process logger only: through `ctx.log` it would
|
|
421
|
-
* tell the client a cache miss from a hit.
|
|
469
|
+
* tell the client a cache miss from a hit. It names the account side as `payer`,
|
|
470
|
+
* since every log sink redacts a key holding an `account` or `user` word
|
|
471
|
+
* (`USERNAME_LOG_FIELDS`).
|
|
422
472
|
*/
|
|
423
473
|
async #attempt(spec, account, ctx, signal) {
|
|
424
474
|
const timer = AbortSignal.timeout(ATTEMPT_TIMEOUT_MS);
|
|
@@ -444,7 +494,7 @@ export class GeoNamesService {
|
|
|
444
494
|
endpoint: spec.endpoint,
|
|
445
495
|
httpStatus: response.status,
|
|
446
496
|
bodyBytes: bytes,
|
|
447
|
-
|
|
497
|
+
payer: account.source,
|
|
448
498
|
}));
|
|
449
499
|
return { bytes, value: spec.parse(this.#toPayload(response.status, text, account)) };
|
|
450
500
|
}
|