@forwardslashns/fws-geo-location-api 1.0.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.
Files changed (59) hide show
  1. package/README.md +509 -0
  2. package/dist/client/geo-location.client.d.ts +121 -0
  3. package/dist/client/geo-location.client.d.ts.map +1 -0
  4. package/dist/client/geo-location.client.js +389 -0
  5. package/dist/constants/api.constants.d.ts +21 -0
  6. package/dist/constants/api.constants.d.ts.map +1 -0
  7. package/dist/constants/api.constants.js +28 -0
  8. package/dist/constants/continent.constants.d.ts +13 -0
  9. package/dist/constants/continent.constants.d.ts.map +1 -0
  10. package/dist/constants/continent.constants.js +21 -0
  11. package/dist/constants/feature.constants.d.ts +53 -0
  12. package/dist/constants/feature.constants.d.ts.map +1 -0
  13. package/dist/constants/feature.constants.js +55 -0
  14. package/dist/errors/geo-location.error.d.ts +6 -0
  15. package/dist/errors/geo-location.error.d.ts.map +1 -0
  16. package/dist/errors/geo-location.error.js +13 -0
  17. package/dist/index.d.ts +7 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +14 -0
  20. package/dist/mappers/city.mapper.d.ts +4 -0
  21. package/dist/mappers/city.mapper.d.ts.map +1 -0
  22. package/dist/mappers/city.mapper.js +18 -0
  23. package/dist/mappers/country.mapper.d.ts +4 -0
  24. package/dist/mappers/country.mapper.d.ts.map +1 -0
  25. package/dist/mappers/country.mapper.js +19 -0
  26. package/dist/mappers/postal-code.mapper.d.ts +4 -0
  27. package/dist/mappers/postal-code.mapper.d.ts.map +1 -0
  28. package/dist/mappers/postal-code.mapper.js +24 -0
  29. package/dist/mappers/region.mapper.d.ts +4 -0
  30. package/dist/mappers/region.mapper.d.ts.map +1 -0
  31. package/dist/mappers/region.mapper.js +20 -0
  32. package/dist/services/http.service.d.ts +8 -0
  33. package/dist/services/http.service.d.ts.map +1 -0
  34. package/dist/services/http.service.js +60 -0
  35. package/dist/types/city.types.d.ts +21 -0
  36. package/dist/types/city.types.d.ts.map +1 -0
  37. package/dist/types/city.types.js +2 -0
  38. package/dist/types/client.types.d.ts +133 -0
  39. package/dist/types/client.types.d.ts.map +1 -0
  40. package/dist/types/client.types.js +2 -0
  41. package/dist/types/common.types.d.ts +29 -0
  42. package/dist/types/common.types.d.ts.map +1 -0
  43. package/dist/types/common.types.js +2 -0
  44. package/dist/types/country.types.d.ts +25 -0
  45. package/dist/types/country.types.d.ts.map +1 -0
  46. package/dist/types/country.types.js +2 -0
  47. package/dist/types/geonames-raw.types.d.ts +77 -0
  48. package/dist/types/geonames-raw.types.d.ts.map +1 -0
  49. package/dist/types/geonames-raw.types.js +2 -0
  50. package/dist/types/index.d.ts +7 -0
  51. package/dist/types/index.d.ts.map +1 -0
  52. package/dist/types/index.js +2 -0
  53. package/dist/types/postal-code.types.d.ts +31 -0
  54. package/dist/types/postal-code.types.d.ts.map +1 -0
  55. package/dist/types/postal-code.types.js +2 -0
  56. package/dist/types/region.types.d.ts +19 -0
  57. package/dist/types/region.types.d.ts.map +1 -0
  58. package/dist/types/region.types.js +2 -0
  59. package/package.json +42 -0
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapCity = mapCity;
4
+ function mapCity(raw) {
5
+ return {
6
+ geonameId: raw.geonameId,
7
+ name: raw.name,
8
+ countryCode: raw.countryCode,
9
+ countryName: raw.countryName,
10
+ adminCode1: raw.adminCode1,
11
+ adminName1: raw.adminName1,
12
+ population: raw.population ?? 0,
13
+ lat: parseFloat(raw.lat) || 0,
14
+ lng: parseFloat(raw.lng) || 0,
15
+ featureCode: raw.fcode,
16
+ featureName: raw.fcodeName,
17
+ };
18
+ }
@@ -0,0 +1,4 @@
1
+ import type { GeoNamesCountryRaw } from '../types/geonames-raw.types.js';
2
+ import type { Country } from '../types/country.types.js';
3
+ export declare function mapCountry(raw: GeoNamesCountryRaw): Country;
4
+ //# sourceMappingURL=country.mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"country.mapper.d.ts","sourceRoot":"","sources":["../../src/mappers/country.mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAGzD,wBAAgB,UAAU,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAe3D"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapCountry = mapCountry;
4
+ function mapCountry(raw) {
5
+ return {
6
+ countryCode: raw.countryCode,
7
+ isoAlpha3: raw.isoAlpha3,
8
+ isoNumeric: raw.isoNumeric,
9
+ countryName: raw.countryName,
10
+ continent: raw.continent,
11
+ continentName: raw.continentName,
12
+ capital: raw.capital,
13
+ languages: raw.languages ? raw.languages.split(',').map((l) => l.trim()) : [],
14
+ population: parseInt(raw.population, 10) || 0,
15
+ geonameId: raw.geonameId,
16
+ currencyCode: raw.currencyCode,
17
+ areaInSqKm: parseFloat(raw.areaInSqKm) || 0,
18
+ };
19
+ }
@@ -0,0 +1,4 @@
1
+ import type { GeoNamesPostalCodeRaw } from '../types/geonames-raw.types.js';
2
+ import type { PostalCode } from '../types/postal-code.types.js';
3
+ export declare function mapPostalCode(raw: GeoNamesPostalCodeRaw, countryName: string): PostalCode;
4
+ //# sourceMappingURL=postal-code.mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postal-code.mapper.d.ts","sourceRoot":"","sources":["../../src/mappers/postal-code.mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAOhE,wBAAgB,aAAa,CAAC,GAAG,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,GAAG,UAAU,CAgBzF"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapPostalCode = mapPostalCode;
4
+ function buildDisplayName(postalCode, placeName, adminName1, countryName) {
5
+ const parts = [placeName, adminName1, countryName].filter(Boolean);
6
+ return `${postalCode} \u2014 ${parts.join(', ')}`;
7
+ }
8
+ function mapPostalCode(raw, countryName) {
9
+ return {
10
+ postalCode: raw.postalCode,
11
+ placeName: raw.placeName,
12
+ countryCode: raw.countryCode,
13
+ countryName,
14
+ adminCode1: raw.adminCode1,
15
+ adminName1: raw.adminName1,
16
+ adminCode2: raw.adminCode2,
17
+ adminName2: raw.adminName2,
18
+ adminCode3: raw.adminCode3,
19
+ adminName3: raw.adminName3,
20
+ lat: raw.lat,
21
+ lng: raw.lng,
22
+ displayName: buildDisplayName(raw.postalCode, raw.placeName, raw.adminName1, countryName),
23
+ };
24
+ }
@@ -0,0 +1,4 @@
1
+ import type { GeoNamesSearchResultRaw } from '../types/geonames-raw.types.js';
2
+ import type { Region } from '../types/region.types.js';
3
+ export declare function mapRegion(raw: GeoNamesSearchResultRaw): Region;
4
+ //# sourceMappingURL=region.mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"region.mapper.d.ts","sourceRoot":"","sources":["../../src/mappers/region.mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAEvD,wBAAgB,SAAS,CAAC,GAAG,EAAE,uBAAuB,GAAG,MAAM,CAiB9D"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapRegion = mapRegion;
4
+ function mapRegion(raw) {
5
+ const isoCode = raw.adminCodes1?.ISO3166_2
6
+ ? `${raw.countryCode}-${raw.adminCodes1.ISO3166_2}`
7
+ : `${raw.countryCode}-${raw.adminCode1}`;
8
+ return {
9
+ geonameId: raw.geonameId,
10
+ name: raw.name,
11
+ code: raw.adminCode1,
12
+ isoCode,
13
+ countryCode: raw.countryCode,
14
+ countryName: raw.countryName,
15
+ population: raw.population ?? 0,
16
+ lat: parseFloat(raw.lat) || 0,
17
+ lng: parseFloat(raw.lng) || 0,
18
+ featureCode: raw.fcode,
19
+ };
20
+ }
@@ -0,0 +1,8 @@
1
+ import type { AtLeastOne } from '../types/common.types.js';
2
+ export declare class HttpService {
3
+ private readonly usernames;
4
+ private currentUsernameIndex;
5
+ constructor(usernames: AtLeastOne<string>);
6
+ get<T>(url: string, params: Record<string, string | number>): Promise<T>;
7
+ }
8
+ //# sourceMappingURL=http.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.service.d.ts","sourceRoot":"","sources":["../../src/services/http.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAiB3D,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAC/C,OAAO,CAAC,oBAAoB,CAAa;gBAEtB,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC;IAInC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CA4CtF"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.HttpService = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const geo_location_error_js_1 = require("../errors/geo-location.error.js");
9
+ const api_constants_js_1 = require("../constants/api.constants.js");
10
+ function isGeoNamesErrorResponse(data) {
11
+ return (typeof data === 'object' &&
12
+ data !== null &&
13
+ 'status' in data &&
14
+ typeof data.status === 'object' &&
15
+ data.status !== null &&
16
+ 'value' in data.status &&
17
+ 'message' in data.status);
18
+ }
19
+ class HttpService {
20
+ usernames;
21
+ currentUsernameIndex = 0;
22
+ constructor(usernames) {
23
+ this.usernames = usernames;
24
+ }
25
+ async get(url, params) {
26
+ while (this.currentUsernameIndex < this.usernames.length) {
27
+ const username = this.usernames[this.currentUsernameIndex];
28
+ try {
29
+ const response = await axios_1.default.get(url, {
30
+ params: { ...params, username },
31
+ timeout: 15_000,
32
+ });
33
+ const data = response.data;
34
+ if (isGeoNamesErrorResponse(data)) {
35
+ const { value, message } = data.status;
36
+ if (api_constants_js_1.GEONAMES_RATE_LIMIT_CODES.includes(value)) {
37
+ this.currentUsernameIndex++;
38
+ continue;
39
+ }
40
+ if (value === api_constants_js_1.GEONAMES_ERROR_CODES.AUTHORIZATION_EXCEPTION) {
41
+ throw new geo_location_error_js_1.GeoLocationError(`GeoNames authorization error for username "${username}": ${message}`, value);
42
+ }
43
+ throw new geo_location_error_js_1.GeoLocationError(`GeoNames API error (code ${value}): ${message}`, value);
44
+ }
45
+ return data;
46
+ }
47
+ catch (err) {
48
+ if (err instanceof geo_location_error_js_1.GeoLocationError)
49
+ throw err;
50
+ if (axios_1.default.isAxiosError(err)) {
51
+ throw new geo_location_error_js_1.GeoLocationError(`HTTP request to GeoNames failed: ${err.message ?? 'unknown error'}`);
52
+ }
53
+ throw err;
54
+ }
55
+ }
56
+ throw new geo_location_error_js_1.GeoLocationError(`All ${String(this.usernames.length)} GeoNames username(s) have reached their rate limit. ` +
57
+ 'Add more usernames to the client or wait until the limit resets.');
58
+ }
59
+ }
60
+ exports.HttpService = HttpService;
@@ -0,0 +1,21 @@
1
+ export interface City {
2
+ geonameId: number;
3
+ /** City display name, e.g. "New York City" */
4
+ name: string;
5
+ /** ISO 3166-1 alpha-2 country code, e.g. "US" */
6
+ countryCode: string;
7
+ /** Full country name, e.g. "United States" */
8
+ countryName: string;
9
+ /** First-order admin code (state/province), e.g. "NY" */
10
+ adminCode1: string;
11
+ /** First-order admin name (state/province), e.g. "New York" */
12
+ adminName1: string;
13
+ population: number;
14
+ lat: number;
15
+ lng: number;
16
+ /** GeoNames feature code, e.g. "PPLA", "PPL", "PPLC" */
17
+ featureCode: string;
18
+ /** Human-readable description of the feature code */
19
+ featureName: string;
20
+ }
21
+ //# sourceMappingURL=city.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"city.types.d.ts","sourceRoot":"","sources":["../../src/types/city.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,IAAI;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,wDAAwD;IACxD,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,133 @@
1
+ import type { ContinentCode } from '../constants/continent.constants.js';
2
+ import type { AtLeastOne } from './common.types.js';
3
+ import type { PostalCode } from './postal-code.types.js';
4
+ export interface GeoLocationRestrictions {
5
+ /**
6
+ * Restrict all API calls to the given continent(s).
7
+ * Uses GeoNames continent codes: 'AF' | 'AS' | 'EU' | 'NA' | 'OC' | 'SA' | 'AN'
8
+ */
9
+ continents?: ContinentCode[];
10
+ /**
11
+ * Restrict all API calls to the given ISO 3166-1 alpha-2 country codes (e.g. ['US', 'DE']).
12
+ * Applied as a post-filter where the GeoNames API does not support direct filtering.
13
+ */
14
+ countries?: string[];
15
+ }
16
+ export interface GeoLocationClientOptions {
17
+ /**
18
+ * One or more GeoNames usernames used for API authentication.
19
+ * Must contain at least one username — enforced at compile time via the AtLeastOne type.
20
+ * When a username hits its daily/hourly/weekly credit limit the client automatically
21
+ * advances to the next username in the array.
22
+ */
23
+ usernames: AtLeastOne<string>;
24
+ /**
25
+ * Optional global restrictions applied to every API call.
26
+ * Can be overridden per method call via the method's own options argument.
27
+ */
28
+ restrictions?: GeoLocationRestrictions;
29
+ }
30
+ export interface GetCountriesOptions {
31
+ /** Override global continent restriction for this call only. */
32
+ continents?: ContinentCode[];
33
+ /** Override global country restriction for this call only. */
34
+ countryCodes?: string[];
35
+ }
36
+ export interface GetRegionsOptions {
37
+ /** Maximum number of results to return. GeoNames free tier cap: 500. Default: 100. */
38
+ maxRows?: number;
39
+ /** Zero-based row offset for pagination. Mutually exclusive with `page`. */
40
+ startRow?: number;
41
+ /**
42
+ * 1-based page number — convenience alias for `startRow`.
43
+ * Page 1 = `startRow` 0, page 2 = `startRow` equal to `maxRows`, etc.
44
+ * Takes precedence over `startRow` when both are provided.
45
+ */
46
+ page?: number;
47
+ }
48
+ export interface GetCitiesOptions {
49
+ /**
50
+ * Filter cities to a specific first-order administrative division
51
+ * (e.g. 'NY' for New York state, 'CA' for California).
52
+ */
53
+ regionCode?: string;
54
+ /** Maximum number of results to return. GeoNames free tier cap: 500. Default: 100. */
55
+ maxRows?: number;
56
+ /** Sort order for results. Default: 'population'. */
57
+ orderBy?: 'population' | 'elevation' | 'relevance';
58
+ /**
59
+ * Free-text search term for city name. Useful when no country is specified
60
+ * for a global city lookup.
61
+ */
62
+ searchTerm?: string;
63
+ /** Zero-based row offset for pagination. Mutually exclusive with `page`. */
64
+ startRow?: number;
65
+ /**
66
+ * 1-based page number — convenience alias for `startRow`.
67
+ * Page 1 = `startRow` 0, page 2 = `startRow` equal to `maxRows`, etc.
68
+ * Takes precedence over `startRow` when both are provided.
69
+ */
70
+ page?: number;
71
+ }
72
+ export interface GetPostalCodesOptions {
73
+ /** Return only postal codes starting with this prefix. */
74
+ postalCodePrefix?: string;
75
+ /** Return only postal codes whose place name starts with this string. */
76
+ placeName?: string;
77
+ /** Maximum number of results to return. GeoNames free tier cap: 500. Default: 100. */
78
+ maxRows?: number;
79
+ /** Zero-based row offset for pagination. Mutually exclusive with `page`. */
80
+ startRow?: number;
81
+ /**
82
+ * 1-based page number — convenience alias for `startRow`.
83
+ * Page 1 = `startRow` 0, page 2 = `startRow` equal to `maxRows`, etc.
84
+ * Takes precedence over `startRow` when both are provided.
85
+ */
86
+ page?: number;
87
+ }
88
+ export interface GetAllPostalCodesOptions {
89
+ /**
90
+ * Called after every prefix bucket is fully fetched, with all postal codes
91
+ * collected so far. Use this to stream results into the UI progressively
92
+ * rather than waiting for the entire country dataset to finish loading.
93
+ *
94
+ * Note: the array passed is a snapshot at the time of the call — mutating it
95
+ * has no effect on the internal collection.
96
+ */
97
+ onProgress?: (loaded: ReadonlyArray<PostalCode>) => void;
98
+ }
99
+ export interface GetPostalCodePageOptions {
100
+ /**
101
+ * Opaque cursor returned by a previous `getPostalCodesPage` call.
102
+ * Omit (or pass `undefined`) to start from the very first postal code.
103
+ */
104
+ cursor?: string;
105
+ /**
106
+ * Number of postal codes to return per page.
107
+ * Clamped to the GeoNames free-tier maximum of 500.
108
+ * Default: the library's `DEFAULT_MAX_ROWS` (100).
109
+ */
110
+ maxRows?: number;
111
+ }
112
+ export interface PostalCodePage {
113
+ /** Postal codes for this page, already mapped to the library's `PostalCode` shape. */
114
+ data: PostalCode[];
115
+ /**
116
+ * Pass this value as `cursor` to the next `getPostalCodesPage` call to
117
+ * retrieve the following page. `null` when the entire country dataset has
118
+ * been returned.
119
+ */
120
+ nextCursor: string | null;
121
+ /** Convenience flag — `true` when `nextCursor` is non-null. */
122
+ hasMore: boolean;
123
+ /**
124
+ * How far through the 36 alphanumeric prefix buckets (0-9, A-Z) the cursor
125
+ * currently sits. Useful for rendering a progress indicator.
126
+ * `{ done: 36, total: 36 }` when exhausted.
127
+ */
128
+ prefixProgress: {
129
+ done: number;
130
+ total: 36;
131
+ };
132
+ }
133
+ //# sourceMappingURL=client.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.types.d.ts","sourceRoot":"","sources":["../../src/types/client.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAC7B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC9B;;;OAGG;IACH,YAAY,CAAC,EAAE,uBAAuB,CAAC;CACxC;AAED,MAAM,WAAW,mBAAmB;IAClC,gEAAgE;IAChE,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAC7B,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,sFAAsF;IACtF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sFAAsF;IACtF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,OAAO,CAAC,EAAE,YAAY,GAAG,WAAW,GAAG,WAAW,CAAC;IACnD;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,0DAA0D;IAC1D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sFAAsF;IACtF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,wBAAwB;IACvC;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CAC1D;AAED,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,sFAAsF;IACtF,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB;;;;OAIG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,+DAA+D;IAC/D,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,cAAc,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,EAAE,CAAA;KAAE,CAAC;CAC7C"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,29 @@
1
+ /**
2
+ * A tuple type that enforces at least one element.
3
+ * Used to guarantee that the `usernames` array passed to GeoLocationClient
4
+ * always contains at least one valid GeoNames username — enforced at compile time.
5
+ */
6
+ export type AtLeastOne<T> = [T, ...T[]];
7
+ /**
8
+ * Wraps a page of results returned by a paginated list method.
9
+ *
10
+ * Methods backed by the GeoNames `searchJSON` endpoint (cities, regions) can
11
+ * provide the true server-side total (`totalResultsCount`). For other
12
+ * endpoints that do not expose a total (e.g. postal codes), `total` is `-1`.
13
+ */
14
+ export interface PaginatedResult<T> {
15
+ /** The items for the current page. */
16
+ data: T[];
17
+ /**
18
+ * Total number of records matching the query on the server.
19
+ * `-1` means the data source does not expose a total count.
20
+ */
21
+ total: number;
22
+ /** Current 1-based page number. */
23
+ page: number;
24
+ /** Maximum number of records per page (the requested page size). */
25
+ pageSize: number;
26
+ /** `true` when there are more pages available after this one. */
27
+ hasMore: boolean;
28
+ }
29
+ //# sourceMappingURL=common.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.types.d.ts","sourceRoot":"","sources":["../../src/types/common.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;AAExC;;;;;;GAMG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,sCAAsC;IACtC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,OAAO,EAAE,OAAO,CAAC;CAClB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,25 @@
1
+ import type { ContinentCode } from '../constants/continent.constants.js';
2
+ export interface Country {
3
+ /** ISO 3166-1 alpha-2 code, e.g. "US" */
4
+ countryCode: string;
5
+ /** ISO 3166-1 alpha-3 code, e.g. "USA" */
6
+ isoAlpha3: string;
7
+ /** ISO 3166-1 numeric code, e.g. "840" */
8
+ isoNumeric: string;
9
+ /** Full English name, e.g. "United States" */
10
+ countryName: string;
11
+ /** GeoNames continent code */
12
+ continent: ContinentCode;
13
+ /** Full continent name, e.g. "North America" */
14
+ continentName: string;
15
+ /** Capital city name */
16
+ capital: string;
17
+ /** BCP 47 language tags spoken in the country */
18
+ languages: string[];
19
+ population: number;
20
+ geonameId: number;
21
+ /** ISO 4217 currency code, e.g. "USD" */
22
+ currencyCode: string;
23
+ areaInSqKm: number;
24
+ }
25
+ //# sourceMappingURL=country.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"country.types.d.ts","sourceRoot":"","sources":["../../src/types/country.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAEzE,MAAM,WAAW,OAAO;IACtB,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,SAAS,EAAE,aAAa,CAAC;IACzB,gDAAgD;IAChD,aAAa,EAAE,MAAM,CAAC;IACtB,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,77 @@
1
+ /** Raw shape of a single country returned by GeoNames countryInfoJSON. */
2
+ export interface GeoNamesCountryRaw {
3
+ continent: string;
4
+ capital: string;
5
+ languages: string;
6
+ geonameId: number;
7
+ south: number;
8
+ isoAlpha3: string;
9
+ north: number;
10
+ fipsCode: string;
11
+ population: string;
12
+ east: number;
13
+ isoNumeric: string;
14
+ areaInSqKm: string;
15
+ countryCode: string;
16
+ west: number;
17
+ countryName: string;
18
+ postalCodeFormat: string;
19
+ continentName: string;
20
+ currencyCode: string;
21
+ }
22
+ export interface GeoNamesCountryInfoResponse {
23
+ geonames: GeoNamesCountryRaw[];
24
+ }
25
+ /** Raw shape of a single result returned by GeoNames searchJSON. */
26
+ export interface GeoNamesSearchResultRaw {
27
+ adminCode1: string;
28
+ adminCode2?: string;
29
+ adminName1: string;
30
+ adminName2?: string;
31
+ adminCodes1?: {
32
+ ISO3166_2: string;
33
+ };
34
+ countryCode: string;
35
+ countryId: string;
36
+ countryName: string;
37
+ fcl: string;
38
+ fclName: string;
39
+ fcode: string;
40
+ fcodeName: string;
41
+ geonameId: number;
42
+ lat: string;
43
+ lng: string;
44
+ name: string;
45
+ population: number;
46
+ toponymName: string;
47
+ }
48
+ export interface GeoNamesSearchResponse {
49
+ totalResultsCount: number;
50
+ geonames: GeoNamesSearchResultRaw[];
51
+ }
52
+ /** Raw shape of a single postal code returned by GeoNames postalCodeSearchJSON. */
53
+ export interface GeoNamesPostalCodeRaw {
54
+ postalCode: string;
55
+ placeName: string;
56
+ countryCode: string;
57
+ adminCode1: string;
58
+ adminName1: string;
59
+ adminCode2?: string;
60
+ adminName2?: string;
61
+ adminCode3?: string;
62
+ adminName3?: string;
63
+ lat: number;
64
+ lng: number;
65
+ 'ISO3166-2': string;
66
+ }
67
+ export interface GeoNamesPostalCodeResponse {
68
+ postalCodes: GeoNamesPostalCodeRaw[];
69
+ }
70
+ /** GeoNames error envelope — returned inside a 200 response body on failure. */
71
+ export interface GeoNamesErrorResponse {
72
+ status: {
73
+ message: string;
74
+ value: number;
75
+ };
76
+ }
77
+ //# sourceMappingURL=geonames-raw.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geonames-raw.types.d.ts","sourceRoot":"","sources":["../../src/types/geonames-raw.types.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,kBAAkB,EAAE,CAAC;CAChC;AAED,oEAAoE;AACpE,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,uBAAuB,EAAE,CAAC;CACrC;AAED,mFAAmF;AACnF,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,0BAA0B;IACzC,WAAW,EAAE,qBAAqB,EAAE,CAAC;CACtC;AAED,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ export type { AtLeastOne, PaginatedResult } from './common.types.js';
2
+ export type { GeoLocationClientOptions, GeoLocationRestrictions, GetCountriesOptions, GetRegionsOptions, GetCitiesOptions, GetPostalCodesOptions, GetAllPostalCodesOptions, GetPostalCodePageOptions, PostalCodePage, } from './client.types.js';
3
+ export type { Country } from './country.types.js';
4
+ export type { Region } from './region.types.js';
5
+ export type { City } from './city.types.js';
6
+ export type { PostalCode } from './postal-code.types.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACrE,YAAY,EACV,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,31 @@
1
+ export interface PostalCode {
2
+ /** The postal / zip code string, e.g. "10001" */
3
+ postalCode: string;
4
+ /** Primary place name for this postal code, e.g. "New York City" */
5
+ placeName: string;
6
+ /** ISO 3166-1 alpha-2 country code, e.g. "US" */
7
+ countryCode: string;
8
+ /** Full country name, e.g. "United States" */
9
+ countryName: string;
10
+ /** First-order admin code (state/province), e.g. "NY" */
11
+ adminCode1: string;
12
+ /** First-order admin name (state/province), e.g. "New York" */
13
+ adminName1: string;
14
+ /** Second-order admin code (county/district), e.g. "061" */
15
+ adminCode2?: string;
16
+ /** Second-order admin name (county/district), e.g. "New York County" */
17
+ adminName2?: string;
18
+ /** Third-order admin code */
19
+ adminCode3?: string;
20
+ /** Third-order admin name */
21
+ adminName3?: string;
22
+ lat: number;
23
+ lng: number;
24
+ /**
25
+ * User-friendly display name for use in dropdowns and autocomplete components.
26
+ * Format: "{postalCode} — {placeName}, {adminName1}, {countryName}"
27
+ * Example: "10001 — New York City, New York, United States"
28
+ */
29
+ displayName: string;
30
+ }
31
+ //# sourceMappingURL=postal-code.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postal-code.types.d.ts","sourceRoot":"","sources":["../../src/types/postal-code.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,19 @@
1
+ export interface Region {
2
+ geonameId: number;
3
+ /** Region display name, e.g. "New York" */
4
+ name: string;
5
+ /** First-order admin code, e.g. "NY" */
6
+ code: string;
7
+ /** ISO 3166-2 code, e.g. "US-NY" */
8
+ isoCode: string;
9
+ /** ISO 3166-1 alpha-2 country code, e.g. "US" */
10
+ countryCode: string;
11
+ /** Full country name, e.g. "United States" */
12
+ countryName: string;
13
+ population: number;
14
+ lat: number;
15
+ lng: number;
16
+ /** GeoNames feature code, e.g. "ADM1" */
17
+ featureCode: string;
18
+ }
19
+ //# sourceMappingURL=region.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"region.types.d.ts","sourceRoot":"","sources":["../../src/types/region.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });