@hebcal/geo-sqlite 5.10.5 → 5.11.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/README.md +29 -3
- package/bin/make-test-dbs +1 -1
- package/dist/build-geonames-sqlite.d.ts +28 -0
- package/dist/build-geonames-sqlite.js +309 -0
- package/dist/build-geonames-sqlite.js.map +1 -0
- package/dist/city2geonameid.json.d.ts +490 -0
- package/dist/city2geonameid.json.js +490 -0
- package/dist/city2geonameid.json.js.map +1 -0
- package/dist/geodb.d.ts +87 -0
- package/dist/geodb.js +451 -0
- package/dist/geodb.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +4 -1483
- package/dist/index.js.map +1 -0
- package/dist/make-zips-sqlite.d.ts +6 -0
- package/dist/make-zips-sqlite.js +15 -0
- package/dist/make-zips-sqlite.js.map +1 -0
- package/dist/munge.d.ts +6 -0
- package/dist/munge.js +13 -0
- package/dist/munge.js.map +1 -0
- package/dist/pkgVersion.d.ts +1 -0
- package/dist/pkgVersion.js +3 -0
- package/dist/pkgVersion.js.map +1 -0
- package/package.json +26 -30
- package/geo-sqlite.d.ts +0 -161
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAC,mBAAmB,EAAC,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds `zips.sqlite3` from the bundled zips-dummy.sql schema file
|
|
3
|
+
* @param dbFilename path to the output SQLite database file
|
|
4
|
+
* @param sqlFile path to the SQL schema file
|
|
5
|
+
*/
|
|
6
|
+
export declare function makeZipsSqlite(dbFilename: string, sqlFile: string): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
/**
|
|
4
|
+
* Builds `zips.sqlite3` from the bundled zips-dummy.sql schema file
|
|
5
|
+
* @param dbFilename path to the output SQLite database file
|
|
6
|
+
* @param sqlFile path to the SQL schema file
|
|
7
|
+
*/
|
|
8
|
+
export function makeZipsSqlite(dbFilename, sqlFile) {
|
|
9
|
+
const sql = fs.readFileSync(sqlFile, 'utf8');
|
|
10
|
+
const db = new DatabaseSync(dbFilename);
|
|
11
|
+
console.log(sql);
|
|
12
|
+
db.exec(sql);
|
|
13
|
+
db.close();
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=make-zips-sqlite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-zips-sqlite.js","sourceRoot":"","sources":["../src/make-zips-sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,UAAkB,EAAE,OAAe;IAChE,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7C,MAAM,EAAE,GAAG,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjB,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,EAAE,CAAC,KAAK,EAAE,CAAC;AACb,CAAC"}
|
package/dist/munge.d.ts
ADDED
package/dist/munge.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes a city name for legacy lookups: lowercases and strips
|
|
3
|
+
* apostrophes, spaces, and plus signs.
|
|
4
|
+
* @private
|
|
5
|
+
*/
|
|
6
|
+
export function munge(s) {
|
|
7
|
+
return s
|
|
8
|
+
.toLowerCase()
|
|
9
|
+
.replaceAll("'", '')
|
|
10
|
+
.replaceAll(' ', '')
|
|
11
|
+
.replaceAll('+', '');
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=munge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"munge.js","sourceRoot":"","sources":["../src/munge.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,CAAS;IAC7B,OAAO,CAAC;SACL,WAAW,EAAE;SACb,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;SACnB,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;SACnB,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const version = "5.11.0";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pkgVersion.js","sourceRoot":"","sources":["../src/pkgVersion.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hebcal/geo-sqlite",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.11.0",
|
|
4
4
|
"author": "Michael J. Radwin (https://github.com/mjradwin)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hebcal"
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
"import": "./dist/index.js",
|
|
13
|
-
"types": "./
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
14
|
},
|
|
15
15
|
"bin": {
|
|
16
16
|
"build-geonames-sqlite": "bin/build-geonames-sqlite",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"bugs": {
|
|
26
26
|
"url": "https://github.com/hebcal/hebcal-geo-sqlite/issues"
|
|
27
27
|
},
|
|
28
|
-
"
|
|
28
|
+
"homepage": "https://hebcal.github.io/api/geo-sqlite/",
|
|
29
|
+
"typings": "./dist/index.d.ts",
|
|
29
30
|
"engines": {
|
|
30
31
|
"node": ">= 22.5.0"
|
|
31
32
|
},
|
|
@@ -34,12 +35,11 @@
|
|
|
34
35
|
"bin",
|
|
35
36
|
"test/fixtures",
|
|
36
37
|
"cities-patch.txt",
|
|
37
|
-
"zips-dummy.sql"
|
|
38
|
-
"geo-sqlite.d.ts"
|
|
38
|
+
"zips-dummy.sql"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@hebcal/cities": "^6.
|
|
42
|
-
"@hebcal/core": "^6.
|
|
41
|
+
"@hebcal/cities": "^6.2.0",
|
|
42
|
+
"@hebcal/core": "^6.6.0",
|
|
43
43
|
"minimist": "^1.2.8",
|
|
44
44
|
"pino": "^10.3.1",
|
|
45
45
|
"pino-pretty": "^13.1.3",
|
|
@@ -47,31 +47,27 @@
|
|
|
47
47
|
"transliteration": "^2.6.1"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
|
-
"build:
|
|
51
|
-
"build:
|
|
52
|
-
"
|
|
53
|
-
"build": "npm run build:version && npm run build:json2js && npm run
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
"build:version": "node ./version.cjs package.json src/pkgVersion.ts",
|
|
51
|
+
"build:json2js": "for f in src/*.json; do echo 'export default' > \"$f.ts\" && cat \"$f\" >> \"$f.ts\"; done",
|
|
52
|
+
"compile": "tsc",
|
|
53
|
+
"build": "npm run build:version && npm run build:json2js && npm run compile",
|
|
54
|
+
"clean": "gts clean",
|
|
55
|
+
"prepublishOnly": "npm run build",
|
|
56
|
+
"prepare": "npm run build",
|
|
57
|
+
"docs": "typedoc",
|
|
58
|
+
"lint": "gts lint",
|
|
59
|
+
"fix": "gts fix",
|
|
60
|
+
"pretest": "npm run build",
|
|
61
|
+
"test": "node --test test/*.spec.js"
|
|
62
62
|
},
|
|
63
63
|
"license": "BSD-2-Clause",
|
|
64
|
+
"overrides": {
|
|
65
|
+
"tmp": "^0.2.6"
|
|
66
|
+
},
|
|
64
67
|
"devDependencies": {
|
|
65
|
-
"@
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"eslint": "^10.4.1",
|
|
70
|
-
"eslint-config-google": "^0.14.0",
|
|
71
|
-
"eslint-plugin-n": "^18.0.1",
|
|
72
|
-
"globals": "^17.6.0",
|
|
73
|
-
"jsdoc": "^4.0.5",
|
|
74
|
-
"jsdoc-to-markdown": "^9.1.3",
|
|
75
|
-
"rollup": "^4.60.4"
|
|
68
|
+
"@types/node": "^26.0.0",
|
|
69
|
+
"gts": "^7.0.0",
|
|
70
|
+
"typedoc": "^0.28.19",
|
|
71
|
+
"typescript": "^6.0.3"
|
|
76
72
|
}
|
|
77
73
|
}
|
package/geo-sqlite.d.ts
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import {Location} from '@hebcal/core';
|
|
2
|
-
|
|
3
|
-
export type AutoComplete = {
|
|
4
|
-
id: number | string;
|
|
5
|
-
value: string;
|
|
6
|
-
geo: 'geoname' | 'zip';
|
|
7
|
-
name?: string;
|
|
8
|
-
asciiname?: string;
|
|
9
|
-
admin1?: string;
|
|
10
|
-
country?: string;
|
|
11
|
-
cc?: string;
|
|
12
|
-
population?: number;
|
|
13
|
-
latitude?: number;
|
|
14
|
-
longitude?: number;
|
|
15
|
-
timezone?: string;
|
|
16
|
-
elevation?: number;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Options for configuring the GeoDb constructor.
|
|
21
|
-
*/
|
|
22
|
-
export type GeoDbOptions = {
|
|
23
|
-
/** Maximum number of entries in the ZIP code LRU cache. Default is 150. */
|
|
24
|
-
zipsCacheSize?: number;
|
|
25
|
-
/** Maximum number of entries in the geonames LRU cache. Default is 750. */
|
|
26
|
-
geonamesCacheSize?: number;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Options for `buildGeonamesSqlite`.
|
|
31
|
-
*/
|
|
32
|
-
export type BuildGeonamesSqliteOptions = {
|
|
33
|
-
/** Path to the output SQLite database file. */
|
|
34
|
-
dbFilename: string;
|
|
35
|
-
/** Path to countryInfo.txt from geonames.org. */
|
|
36
|
-
countryInfotxt: string;
|
|
37
|
-
/** Path to cities5000.txt (or similar) from geonames.org. */
|
|
38
|
-
cities5000txt: string;
|
|
39
|
-
/** Path to a TSV patch file with additional city rows. */
|
|
40
|
-
citiesPatch: string;
|
|
41
|
-
/** Path to admin1CodesASCII.txt from geonames.org. */
|
|
42
|
-
admin1CodesASCIItxt: string;
|
|
43
|
-
/** Path to IL.txt (Israel geonames) from geonames.org. */
|
|
44
|
-
ILtxt: string;
|
|
45
|
-
/** Path to IL alternate names file from geonames.org. */
|
|
46
|
-
ILalternate: string;
|
|
47
|
-
/** Logger instance (e.g. pino). */
|
|
48
|
-
logger: any;
|
|
49
|
-
/** Minimum population filter for PPL feature codes. */
|
|
50
|
-
population?: number;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Wrapper around SQLite databases for looking up geographic locations
|
|
55
|
-
* by ZIP code, geoname ID, or legacy Hebcal city name.
|
|
56
|
-
*/
|
|
57
|
-
export class GeoDb {
|
|
58
|
-
/**
|
|
59
|
-
* Opens the ZIP code and geonames SQLite databases.
|
|
60
|
-
* @param logger - Logger instance (e.g. pino), or `null` to disable logging
|
|
61
|
-
* @param zipsFilename - Path to the ZIP codes SQLite database file
|
|
62
|
-
* @param geonamesFilename - Path to the geonames SQLite database file
|
|
63
|
-
* @param options - Optional cache size configuration
|
|
64
|
-
*/
|
|
65
|
-
constructor(logger: any, zipsFilename: string, geonamesFilename: string, options?: GeoDbOptions);
|
|
66
|
-
|
|
67
|
-
/** Closes both database handles. */
|
|
68
|
-
close(): void;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Looks up a US ZIP code and returns the corresponding location.
|
|
72
|
-
* @param zip - 5-digit US ZIP code (leading zeros preserved as string)
|
|
73
|
-
* @returns The location, or `null` if not found
|
|
74
|
-
*/
|
|
75
|
-
lookupZip(zip: string): Location;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Looks up a geonames.org ID and returns the corresponding location.
|
|
79
|
-
* @param geonameid - Numeric geoname ID from geonames.org
|
|
80
|
-
* @returns The location, or `null` if not found
|
|
81
|
-
*/
|
|
82
|
-
lookupGeoname(geonameid: number): Location;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Looks up a legacy Hebcal city name (e.g. "Jerusalem" or "New York")
|
|
86
|
-
* and returns the corresponding location.
|
|
87
|
-
* @param cityName - Legacy city name string
|
|
88
|
-
* @returns The location, or `null` if not found
|
|
89
|
-
*/
|
|
90
|
-
lookupLegacyCity(cityName: string): Location;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Generates autocomplete suggestions for a query string.
|
|
94
|
-
* Numeric queries search ZIP codes; alphabetic queries search geonames
|
|
95
|
-
* and ZIP city names via full-text search.
|
|
96
|
-
* @param qraw - Raw query string from user input
|
|
97
|
-
* @param latlong - If `true`, include latitude, longitude, timezone, and population in results
|
|
98
|
-
* @returns Array of autocomplete suggestion objects, sorted by population
|
|
99
|
-
*/
|
|
100
|
-
autoComplete(qraw: string, latlong?: boolean): AutoComplete[];
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Reads the entire ZIP code database into an in-memory cache,
|
|
104
|
-
* replacing the default LRU cache. Useful for high-throughput servers.
|
|
105
|
-
*/
|
|
106
|
-
cacheZips(): void;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Reads the entire geonames database into an in-memory cache,
|
|
110
|
-
* replacing the default LRU cache. Useful for high-throughput servers.
|
|
111
|
-
*/
|
|
112
|
-
cacheGeonames(): void;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Returns the version string of the `@hebcal/geo-sqlite` package.
|
|
116
|
-
*/
|
|
117
|
-
static version(): string;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Tests whether the given string begins with exactly 5 ASCII digits
|
|
121
|
-
* (a valid US ZIP code format).
|
|
122
|
-
* @param str - String to test
|
|
123
|
-
* @returns `true` if the string starts with 5 digits
|
|
124
|
-
*/
|
|
125
|
-
static is5DigitZip(str: string): boolean;
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Convenience wrapper around the `transliterate` function from the
|
|
129
|
-
* `transliteration` npm package. Converts Unicode text to ASCII.
|
|
130
|
-
* @param source - String to transliterate
|
|
131
|
-
* @param options - Options passed to the underlying `transliterate` function
|
|
132
|
-
* @returns Transliterated ASCII string
|
|
133
|
-
*/
|
|
134
|
-
static transliterate(source: string, options?: any): string;
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Builds a display string for a city from its name components.
|
|
138
|
-
* Applies special formatting for US ("USA") and UK ("UK") country names,
|
|
139
|
-
* and omits the admin1 subdivision when it duplicates the city name.
|
|
140
|
-
* @param cityName - City name, e.g. "Tel Aviv" or "Chicago"
|
|
141
|
-
* @param admin1 - First-level administrative subdivision, e.g. "Illinois"
|
|
142
|
-
* @param countryName - Full country name, e.g. "United States" or "Israel"
|
|
143
|
-
* @returns Formatted city description, e.g. "Chicago, Illinois, USA"
|
|
144
|
-
*/
|
|
145
|
-
static geonameCityDescr(cityName: string, admin1: string, countryName: string): string;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Builds the `geonames.sqlite3` database from raw text files
|
|
150
|
-
* downloaded from geonames.org.
|
|
151
|
-
* @param opts - Paths to input files and configuration
|
|
152
|
-
* @returns Resolves when the database has been built and closed
|
|
153
|
-
*/
|
|
154
|
-
export function buildGeonamesSqlite(opts: BuildGeonamesSqliteOptions): Promise<boolean>;
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Builds the `zips.sqlite3` database from a bundled SQL schema file.
|
|
158
|
-
* @param dbFilename - Path to the output SQLite database file
|
|
159
|
-
* @param sqlFile - Path to the SQL schema file to execute
|
|
160
|
-
*/
|
|
161
|
-
export function makeZipsSqlite(dbFilename: string, sqlFile: string): void;
|