pelias-openstreetmap 8.4.2 → 8.5.2

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.
@@ -7,7 +7,7 @@ jobs:
7
7
  matrix:
8
8
  os:
9
9
  - ubuntu-24.04
10
- node-version: [ 20.x, 22.x, 24.x ]
10
+ node-version: [ 20.x, 22.x, 24.x, 26.x ]
11
11
  steps:
12
12
  - uses: actions/checkout@v6
13
13
  - name: 'Install node.js ${{ matrix.node-version }}'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pelias-openstreetmap",
3
- "version": "8.4.2",
3
+ "version": "8.5.2",
4
4
  "engines": {
5
5
  "node": ">=10.0.0"
6
6
  },
@@ -14,6 +14,7 @@
14
14
  "coverage": "node_modules/.bin/istanbul cover test/run.js",
15
15
  "end-to-end": "export NODE_ENV=test && node test/end-to-end.js;",
16
16
  "lint": "jshint .",
17
+ "languages": "node scripts/generate_languages.js",
17
18
  "start": "./bin/start",
18
19
  "taginfo": "node scripts/generate_taginfo.js",
19
20
  "prepublishOnly": "npm run taginfo",
@@ -49,7 +50,7 @@
49
50
  "pelias-dbclient": "^3.1.0",
50
51
  "pelias-logger": "^1.6.0",
51
52
  "pelias-model": "^10.6.0",
52
- "pelias-wof-admin-lookup": "^7.17.0",
53
+ "pelias-wof-admin-lookup": "^7.19.0",
53
54
  "through2": "^3.0.0",
54
55
  "through2-sink": "^1.0.0"
55
56
  },
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /**
5
+ * Generates scripts/languages.json: a snapshot of the ISO-639-1 codes we accept
6
+ * as name:<lang> suffixes, mapped to their English language names.
7
+ *
8
+ * The snapshot exists so generate_taginfo.js can run with no node_modules — the
9
+ * npm-publish CI job runs semantic-release without an `npm install`, and both
10
+ * iso-639-3 and config/localized_name_keys (which needs lodash) are unavailable there.
11
+ *
12
+ * Run after upgrading iso-639-3; test/scripts/languages.js fails if it drifts.
13
+ */
14
+
15
+ const fs = require('fs');
16
+ const path = require('path');
17
+ const iso6393 = require('iso-639-3');
18
+
19
+ const localizedKeys = require('../config/localized_name_keys');
20
+
21
+ function build() {
22
+ const names = iso6393.reduce((acc, lang) => {
23
+ if (lang.iso6391) {
24
+ // iso-639-3 qualifies some names, eg 'Occitan (post 1500)', 'Malay (macrolanguage)'
25
+ acc[lang.iso6391] = lang.name.replace(/\s*\(.*\)\s*$/, '');
26
+ }
27
+ return acc;
28
+ }, {});
29
+
30
+ return localizedKeys.reduce((acc, code) => {
31
+ acc[code] = names[code] || code;
32
+ return acc;
33
+ }, {});
34
+ }
35
+
36
+ const outPath = path.join(__dirname, 'languages.json');
37
+
38
+ if (require.main === module) {
39
+ fs.writeFileSync(outPath, JSON.stringify(build(), null, 2) + '\n');
40
+ console.log(`languages.json written (${Object.keys(build()).length} languages)`);
41
+ }
42
+
43
+ module.exports = build;
@@ -8,12 +8,15 @@
8
8
  * - config/features.js (venue detection tags, address filter keys)
9
9
  * - config/addendum_whitelist.js (metadata tags stored in the OSM addendum)
10
10
  * - schema/name_osm.js (name/alias tags)
11
+ * - scripts/languages.json (name:<lang> codes, snapshot of localized_name_keys)
11
12
  * - schema/address_*.js (address tags)
12
13
  *
13
14
  * Published to npm and served by jsDelivr:
14
15
  * https://cdn.jsdelivr.net/npm/pelias-openstreetmap/taginfo.json
15
16
  */
16
17
 
18
+ // note: this script runs during `npm publish` in a checkout with no node_modules,
19
+ // so it must only require core modules and local files (see scripts/languages.json)
17
20
  const fs = require('fs');
18
21
  const path = require('path');
19
22
 
@@ -25,6 +28,7 @@ const osmAddr = require('../schema/address_osm');
25
28
  const tiger = require('../schema/address_tiger');
26
29
  const naptan = require('../schema/address_naptan');
27
30
  const addendumKeys = require('../config/addendum_whitelist');
31
+ const languages = require('./languages.json');
28
32
 
29
33
  const OBJECT_TYPES = ['node', 'way', 'relation'];
30
34
 
@@ -97,7 +101,7 @@ const addressTags = [...addressKeys].map(k =>
97
101
 
98
102
  // ---------------------------------------------------------------------------
99
103
  // Name tags — derived from schema/name_osm.js
100
- // Localized name tags (name:en, name:fr, …) are read dynamically via iso-639-3
104
+ // Localized name tags (name:en, name:fr, …) come from scripts/languages.json
101
105
  // ---------------------------------------------------------------------------
102
106
  const nameDescriptions = {
103
107
  name: 'Primary display name; the main search term for a record',
@@ -106,12 +110,18 @@ const nameDescriptions = {
106
110
  short_name: 'Short name; indexed as an alias',
107
111
  };
108
112
 
113
+ // taginfo has no wildcard syntax — 'name:*' would be read as a literal asterisk —
114
+ // so every localized key we accept is listed individually. scripts/languages.json is
115
+ // a snapshot of config/localized_name_keys; a unit test fails if the two diverge.
116
+ const localizedNameTags = Object.keys(languages).map(code =>
117
+ entry(`name:${code}`, `Name in ${languages[code]}, indexed as a localized alias`)
118
+ );
119
+
109
120
  const nameTags = [
110
121
  ...Object.keys(nameSchema).map(k =>
111
122
  entry(k, nameDescriptions[k] || 'Name variant indexed as an alias')
112
123
  ),
113
- // Localised names are resolved at import time from iso-639-3 (e.g. name:en, name:fr)
114
- entry('name:*', 'Language-specific names (e.g. name:en, name:fr) are indexed as localized aliases'),
124
+ ...localizedNameTags,
115
125
  ];
116
126
 
117
127
  // ---------------------------------------------------------------------------
@@ -0,0 +1,186 @@
1
+ {
2
+ "aa": "Afar",
3
+ "ab": "Abkhazian",
4
+ "af": "Afrikaans",
5
+ "ak": "Akan",
6
+ "am": "Amharic",
7
+ "ar": "Arabic",
8
+ "an": "Aragonese",
9
+ "as": "Assamese",
10
+ "av": "Avaric",
11
+ "ae": "Avestan",
12
+ "ay": "Aymara",
13
+ "az": "Azerbaijani",
14
+ "ba": "Bashkir",
15
+ "bm": "Bambara",
16
+ "be": "Belarusian",
17
+ "bn": "Bengali",
18
+ "bi": "Bislama",
19
+ "bo": "Tibetan",
20
+ "bs": "Bosnian",
21
+ "br": "Breton",
22
+ "bg": "Bulgarian",
23
+ "ca": "Catalan",
24
+ "cs": "Czech",
25
+ "ch": "Chamorro",
26
+ "ce": "Chechen",
27
+ "cu": "Church Slavic",
28
+ "cv": "Chuvash",
29
+ "kw": "Cornish",
30
+ "co": "Corsican",
31
+ "cr": "Cree",
32
+ "cy": "Welsh",
33
+ "da": "Danish",
34
+ "de": "German",
35
+ "dv": "Dhivehi",
36
+ "dz": "Dzongkha",
37
+ "el": "Modern Greek",
38
+ "en": "English",
39
+ "eo": "Esperanto",
40
+ "et": "Estonian",
41
+ "eu": "Basque",
42
+ "ee": "Ewe",
43
+ "fo": "Faroese",
44
+ "fa": "Persian",
45
+ "fj": "Fijian",
46
+ "fi": "Finnish",
47
+ "fr": "French",
48
+ "fy": "Western Frisian",
49
+ "ff": "Fulah",
50
+ "gd": "Scottish Gaelic",
51
+ "ga": "Irish",
52
+ "gl": "Galician",
53
+ "gv": "Manx",
54
+ "gn": "Guarani",
55
+ "gu": "Gujarati",
56
+ "ht": "Haitian",
57
+ "ha": "Hausa",
58
+ "sh": "Serbo-Croatian",
59
+ "he": "Hebrew",
60
+ "hz": "Herero",
61
+ "hi": "Hindi",
62
+ "ho": "Hiri Motu",
63
+ "hr": "Croatian",
64
+ "hu": "Hungarian",
65
+ "hy": "Armenian",
66
+ "ig": "Igbo",
67
+ "io": "Ido",
68
+ "ii": "Sichuan Yi",
69
+ "iu": "Inuktitut",
70
+ "ie": "Interlingue",
71
+ "ia": "Interlingua",
72
+ "id": "Indonesian",
73
+ "ik": "Inupiaq",
74
+ "is": "Icelandic",
75
+ "it": "Italian",
76
+ "jv": "Javanese",
77
+ "ja": "Japanese",
78
+ "kl": "Kalaallisut",
79
+ "kn": "Kannada",
80
+ "ks": "Kashmiri",
81
+ "ka": "Georgian",
82
+ "kr": "Kanuri",
83
+ "kk": "Kazakh",
84
+ "km": "Khmer",
85
+ "ki": "Kikuyu",
86
+ "rw": "Kinyarwanda",
87
+ "ky": "Kirghiz",
88
+ "kv": "Komi",
89
+ "kg": "Kongo",
90
+ "ko": "Korean",
91
+ "kj": "Kuanyama",
92
+ "ku": "Kurdish",
93
+ "lo": "Lao",
94
+ "la": "Latin",
95
+ "lv": "Latvian",
96
+ "li": "Limburgan",
97
+ "ln": "Lingala",
98
+ "lt": "Lithuanian",
99
+ "lb": "Luxembourgish",
100
+ "lu": "Luba-Katanga",
101
+ "lg": "Ganda",
102
+ "mh": "Marshallese",
103
+ "ml": "Malayalam",
104
+ "mr": "Marathi",
105
+ "mk": "Macedonian",
106
+ "mg": "Malagasy",
107
+ "mt": "Maltese",
108
+ "mn": "Mongolian",
109
+ "mi": "Maori",
110
+ "ms": "Malay",
111
+ "my": "Burmese",
112
+ "na": "Nauru",
113
+ "nv": "Navajo",
114
+ "nr": "South Ndebele",
115
+ "nd": "North Ndebele",
116
+ "ng": "Ndonga",
117
+ "ne": "Nepali",
118
+ "nl": "Dutch",
119
+ "nn": "Norwegian Nynorsk",
120
+ "nb": "Norwegian Bokmål",
121
+ "no": "Norwegian",
122
+ "ny": "Nyanja",
123
+ "oc": "Occitan",
124
+ "oj": "Ojibwa",
125
+ "or": "Oriya",
126
+ "om": "Oromo",
127
+ "os": "Ossetian",
128
+ "pa": "Panjabi",
129
+ "pi": "Pali",
130
+ "pl": "Polish",
131
+ "pt": "Portuguese",
132
+ "ps": "Pushto",
133
+ "qu": "Quechua",
134
+ "rm": "Romansh",
135
+ "ro": "Romanian",
136
+ "rn": "Rundi",
137
+ "ru": "Russian",
138
+ "sg": "Sango",
139
+ "sa": "Sanskrit",
140
+ "si": "Sinhala",
141
+ "sk": "Slovak",
142
+ "sl": "Slovenian",
143
+ "se": "Northern Sami",
144
+ "sm": "Samoan",
145
+ "sn": "Shona",
146
+ "sd": "Sindhi",
147
+ "so": "Somali",
148
+ "st": "Southern Sotho",
149
+ "es": "Spanish",
150
+ "sq": "Albanian",
151
+ "sc": "Sardinian",
152
+ "sr": "Serbian",
153
+ "ss": "Swati",
154
+ "su": "Sundanese",
155
+ "sw": "Swahili",
156
+ "sv": "Swedish",
157
+ "ty": "Tahitian",
158
+ "ta": "Tamil",
159
+ "tt": "Tatar",
160
+ "te": "Telugu",
161
+ "tg": "Tajik",
162
+ "tl": "Tagalog",
163
+ "th": "Thai",
164
+ "ti": "Tigrinya",
165
+ "to": "Tonga",
166
+ "tn": "Tswana",
167
+ "ts": "Tsonga",
168
+ "tk": "Turkmen",
169
+ "tr": "Turkish",
170
+ "tw": "Twi",
171
+ "ug": "Uighur",
172
+ "uk": "Ukrainian",
173
+ "ur": "Urdu",
174
+ "uz": "Uzbek",
175
+ "ve": "Venda",
176
+ "vi": "Vietnamese",
177
+ "vo": "Volapük",
178
+ "wa": "Walloon",
179
+ "wo": "Wolof",
180
+ "xh": "Xhosa",
181
+ "yi": "Yiddish",
182
+ "yo": "Yoruba",
183
+ "za": "Zhuang",
184
+ "zh": "Chinese",
185
+ "zu": "Zulu"
186
+ }