bd-geo-address 0.1.1

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.
@@ -0,0 +1,667 @@
1
+ /** All 8 administrative divisions of Bangladesh */
2
+ declare enum DivisionName {
3
+ Dhaka = "Dhaka",
4
+ Chattogram = "Chattogram",
5
+ Mymensingh = "Mymensingh",
6
+ Khulna = "Khulna",
7
+ Rajshahi = "Rajshahi",
8
+ Rangpur = "Rangpur",
9
+ Sylhet = "Sylhet",
10
+ Barisal = "Barisal"
11
+ }
12
+ /** Union type of all 64 district names */
13
+ type DistrictName = "Dhaka" | "Faridpur" | "Gazipur" | "Gopalganj" | "Kishoreganj" | "Madaripur" | "Manikganj" | "Munshiganj" | "Narayanganj" | "Narsingdi" | "Rajbari" | "Shariatpur" | "Tangail" | "Bandarban" | "Brahmanbaria" | "Chandpur" | "Chattogram" | "Cox's Bazar" | "Cumilla" | "Feni" | "Khagrachhari" | "Lakshmipur" | "Noakhali" | "Rangamati" | "Jamalpur" | "Mymensingh" | "Netrokona" | "Sherpur" | "Bagerhat" | "Chuadanga" | "Jashore" | "Jhenaidah" | "Khulna" | "Kushtia" | "Magura" | "Meherpur" | "Narail" | "Satkhira" | "Bogura" | "Chapainawabganj" | "Joypurhat" | "Naogaon" | "Natore" | "Pabna" | "Rajshahi" | "Sirajganj" | "Dinajpur" | "Gaibandha" | "Kurigram" | "Lalmonirhat" | "Nilphamari" | "Panchagarh" | "Rangpur" | "Thakurgaon" | "Habiganj" | "Moulvibazar" | "Sunamganj" | "Sylhet" | "Barguna" | "Barisal" | "Bhola" | "Jhalokati" | "Patuakhali" | "Pirojpur";
14
+ /** Administrative level of a location */
15
+ type LocationLevel = "division" | "district" | "city_corp" | "municipality" | "upazila" | "thana" | "union" | "paurasava";
16
+ /** An upazila (sub-district) with its parent hierarchy */
17
+ interface Upazila {
18
+ upazila: string;
19
+ upazilaBn: string;
20
+ district: string;
21
+ districtBn: string;
22
+ division: string;
23
+ divisionBn: string;
24
+ }
25
+ /** A metropolitan police thana */
26
+ interface Thana {
27
+ thana: string;
28
+ thanaBn: string;
29
+ district: string;
30
+ districtBn: string;
31
+ division: string;
32
+ divisionBn: string;
33
+ type: "thana";
34
+ }
35
+ /** Result from cross-level text search */
36
+ interface SearchResult {
37
+ name: string;
38
+ nameBn: string;
39
+ type: "division" | "district" | "upazila" | "thana";
40
+ division?: string;
41
+ district?: string;
42
+ }
43
+ /** A location from the FHIR geocode dataset */
44
+ interface BDLocation {
45
+ code: string;
46
+ name: string;
47
+ nameBn: string;
48
+ level: LocationLevel;
49
+ parentCode: string | null;
50
+ postalCode?: string;
51
+ postOfficeName?: string;
52
+ lat?: number;
53
+ lng?: number;
54
+ }
55
+ /** Full hierarchical address resolved from a FHIR geocode */
56
+ interface BDAddress {
57
+ fhirCode: string;
58
+ union?: BDLocation;
59
+ paurasava?: BDLocation;
60
+ thana?: BDLocation;
61
+ upazila?: BDLocation;
62
+ municipality?: BDLocation;
63
+ city_corp?: BDLocation;
64
+ district: BDLocation;
65
+ division: BDLocation;
66
+ formatted: {
67
+ en: string;
68
+ bn: string;
69
+ short: string;
70
+ shortBn: string;
71
+ };
72
+ coordinates?: {
73
+ lat: number;
74
+ lng: number;
75
+ };
76
+ postal?: {
77
+ postalCode: string;
78
+ postOfficeName: string;
79
+ postOfficeNameBn: string;
80
+ };
81
+ }
82
+ /** A postal code entry */
83
+ interface BDPostalEntry {
84
+ postalCode: string;
85
+ postOfficeName: string;
86
+ postOfficeNameBn: string;
87
+ upazilaName: string;
88
+ districtName: string;
89
+ divisionName: string;
90
+ fhirCode?: string;
91
+ }
92
+
93
+ /** All upazila objects (595 entries). */
94
+ declare const upazilaData: Upazila[];
95
+ /** All upazila names in English. */
96
+ declare function allUpazila(): string[];
97
+ /** Alias for allUpazila(). */
98
+ declare function allUpazilaNames(): string[];
99
+ /** All upazila names in Bangla. */
100
+ declare function allUpazilaNamesBn(): string[];
101
+ /** All upazila objects for a given district (English name). */
102
+ declare function upazilasOf(district: DistrictName | string): Upazila[];
103
+ /** All upazila objects for a given district (Bangla name). */
104
+ declare function upazilasOfBn(districtBn: string): Upazila[];
105
+ /** All upazila names (strings) for a given district (English). */
106
+ declare function upazilaNamesOf(district: string): string[];
107
+ /** All upazila names (strings) for a given district (Bangla). */
108
+ declare function upazilaNamesOfBn(districtBn: string): string[];
109
+ /** All upazila objects for a given division (English). */
110
+ declare function upazilasOfDivision(division: DivisionName | string): Upazila[];
111
+ /** All upazila objects for a given division (Bangla). */
112
+ declare function upazilasOfDivisionBn(divisionBn: string): Upazila[];
113
+ /** All upazila names (strings) for a given division (English). */
114
+ declare function upazilaNamesOfDivision(division: string): string[];
115
+ /** All upazila names (strings) for a given division (Bangla). */
116
+ declare function upazilaNamesOfDivisionBn(divisionBn: string): string[];
117
+ /** Returns true if the English name is a known upazila (not a metropolitan thana). */
118
+ declare function isUpazila(name: string): boolean;
119
+ /** Returns true if the Bangla name is a known upazila (not a metropolitan thana). */
120
+ declare function isUpazilabn(nameBn: string): boolean;
121
+ /**
122
+ * Returns the upazila object for a given English name.
123
+ * Pass an optional division to disambiguate names that appear in multiple divisions.
124
+ */
125
+ declare function getUpazila(name: string, division?: string): Upazila | null;
126
+ /**
127
+ * Returns the upazila object for a given Bangla name.
128
+ * Pass an optional division (Bangla) to disambiguate.
129
+ */
130
+ declare function getUpazilabn(nameBn: string, divisionBn?: string): Upazila | null;
131
+ /**
132
+ * Returns the district an upazila belongs to (English).
133
+ * Pass an optional division to disambiguate.
134
+ */
135
+ declare function getDistrictOfUpazila(upazila: string, division?: string): string | null;
136
+ /**
137
+ * Returns the district an upazila belongs to (Bangla input).
138
+ * Pass an optional division (Bangla) to disambiguate.
139
+ */
140
+ declare function getDistrictOfUpazilabn(upazilaBn: string, divisionBn?: string): string | null;
141
+
142
+ /** All 26 metropolitan thana objects. */
143
+ declare const thanaData: Thana[];
144
+ /** All 26 metropolitan thana objects. */
145
+ declare function allThana(): Thana[];
146
+ /** All 26 metropolitan thana names in English. */
147
+ declare function allThanaNames(): string[];
148
+ /** All thana objects for a given district city (English). */
149
+ declare function thanasOf(district: string): Thana[];
150
+ /** All thana objects for a given district city (Bangla). */
151
+ declare function thanasOfBn(districtBn: string): Thana[];
152
+ /** All thana names (strings) for a given district city (English). */
153
+ declare function thanaNamesOf(district: string): string[];
154
+ /** All thana names (strings) for a given district city (Bangla). */
155
+ declare function thanaNamesOfBn(districtBn: string): string[];
156
+ /**
157
+ * Returns true if the name is a metropolitan thana.
158
+ * Pass an optional district to disambiguate (e.g. Kotwali exists in Dhaka and Chattogram).
159
+ */
160
+ declare function isThana(name: string, district?: string): boolean;
161
+ /**
162
+ * Returns true if the Bangla name is a metropolitan thana.
163
+ * Pass an optional district (Bangla) to disambiguate.
164
+ */
165
+ declare function isThanabn(nameBn: string, districtBn?: string): boolean;
166
+ /**
167
+ * Returns the thana object for a given English name.
168
+ * Pass an optional district to disambiguate.
169
+ */
170
+ declare function getThana(name: string, district?: string): Thana | null;
171
+ /**
172
+ * Returns the thana object for a given Bangla name.
173
+ * Pass an optional district (Bangla) to disambiguate.
174
+ */
175
+ declare function getThanabn(nameBn: string, districtBn?: string): Thana | null;
176
+
177
+ /**
178
+ * Returns all 8 division names in English.
179
+ * @returns Array of English division names.
180
+ * @example
181
+ * allDivision()
182
+ * // → ['Dhaka', 'Chattogram', 'Mymensingh', 'Khulna', 'Rajshahi', 'Rangpur', 'Sylhet', 'Barisal']
183
+ */
184
+ declare function allDivision(): string[];
185
+ /**
186
+ * Returns all 8 division names in Bangla.
187
+ * @returns Array of Bangla division names.
188
+ * @example
189
+ * allDivisionBn()
190
+ * // → ['ঢাকা', 'চট্টগ্রাম', 'ময়মনসিংহ', 'খুলনা', 'রাজশাহী', 'রংপুর', 'সিলেট', 'বরিশাল']
191
+ */
192
+ declare function allDivisionBn(): string[];
193
+ /**
194
+ * Returns all districts and upazilas belonging to a division.
195
+ * Accepts both English and Bangla division names.
196
+ * @param division - Division name (English or Bangla).
197
+ * @returns Object with `districts` (string[]) and `upazilas` (Upazila[]), or null if not found.
198
+ * @example
199
+ * divisionalDataOf('Dhaka')
200
+ * // → { districts: ['Dhaka', 'Gazipur', ...], upazilas: [{ upazila: 'Savar', ... }, ...] }
201
+ *
202
+ * divisionalDataOf(DivisionName.Sylhet)
203
+ * // → { districts: ['Sylhet', 'Sunamganj', 'Habiganj', 'Moulvibazar'], upazilas: [...] }
204
+ */
205
+ declare function divisionalDataOf(division: DivisionName | string): {
206
+ districts: string[];
207
+ upazilas: Upazila[];
208
+ } | null;
209
+ /**
210
+ * Returns all districts and upazilas belonging to a division by Bangla name.
211
+ * @param divisionBn - Division name in Bangla (e.g. `"ঢাকা"`).
212
+ * @returns Object with `districts` and `upazilas`, or null if not found.
213
+ * @example
214
+ * divisionalDataOfBn('ঢাকা')
215
+ * // → { districts: ['Dhaka', 'Gazipur', ...], upazilas: [...] }
216
+ */
217
+ declare function divisionalDataOfBn(divisionBn: string): {
218
+ districts: string[];
219
+ upazilas: Upazila[];
220
+ } | null;
221
+ /**
222
+ * Returns true if the name is a valid Bangladesh division.
223
+ * @param name - Division name to validate (case-insensitive).
224
+ * @returns `true` if valid, `false` otherwise.
225
+ * @example
226
+ * isValidDivision('Dhaka') // → true
227
+ * isValidDivision('InvalidName') // → false
228
+ */
229
+ declare function isValidDivision(name: string): boolean;
230
+ /**
231
+ * Returns true if the Bangla name is a valid Bangladesh division.
232
+ * @param nameBn - Division name in Bangla.
233
+ * @returns `true` if valid, `false` otherwise.
234
+ * @example
235
+ * isValidDivisionBn('ঢাকা') // → true
236
+ * isValidDivisionBn('অজানা') // → false
237
+ */
238
+ declare function isValidDivisionBn(nameBn: string): boolean;
239
+
240
+ /**
241
+ * Returns all 64 district names in English.
242
+ * @returns Array of all district names.
243
+ * @example
244
+ * allDistricts()
245
+ * // → ['Dhaka', 'Gazipur', 'Narayanganj', ..., 'Sylhet', "Cox's Bazar"]
246
+ */
247
+ declare function allDistricts(): string[];
248
+ /**
249
+ * Returns all 64 district names in Bangla.
250
+ * @returns Array of Bangla district names.
251
+ * @example
252
+ * allDistrictsBn()
253
+ * // → ['ঢাকা', 'গাজীপুর', 'নারায়ণগঞ্জ', ...]
254
+ */
255
+ declare function allDistrictsBn(): string[];
256
+ /**
257
+ * Returns all district names belonging to a division (English division name).
258
+ * @param division - Division name in English.
259
+ * @returns Array of district names, or empty array if division not found.
260
+ * @example
261
+ * districtsOf('Dhaka')
262
+ * // → ['Dhaka', 'Gazipur', 'Kishoreganj', 'Manikganj', 'Munshiganj', ...]
263
+ */
264
+ declare function districtsOf(division: string): string[];
265
+ /**
266
+ * Returns all district names belonging to a division (Bangla division name).
267
+ * @param divisionBn - Division name in Bangla.
268
+ * @returns Array of district names in English.
269
+ * @example
270
+ * districtsOfBn('ঢাকা')
271
+ * // → ['Dhaka', 'Gazipur', 'Kishoreganj', ...]
272
+ */
273
+ declare function districtsOfBn(divisionBn: string): string[];
274
+ /**
275
+ * Returns true if the name is a valid Bangladesh district.
276
+ * @param name - District name to validate (case-insensitive).
277
+ * @returns `true` if valid, `false` otherwise.
278
+ * @example
279
+ * isValidDistrict('Tangail') // → true
280
+ * isValidDistrict('Savar') // → false (Savar is an upazila)
281
+ */
282
+ declare function isValidDistrict(name: DistrictName | string): boolean;
283
+ /**
284
+ * Returns true if the Bangla name is a valid Bangladesh district.
285
+ * @param nameBn - District name in Bangla.
286
+ * @returns `true` if valid, `false` otherwise.
287
+ * @example
288
+ * isValidDistrictBn('টাঙ্গাইল') // → true
289
+ * isValidDistrictBn('অজানা') // → false
290
+ */
291
+ declare function isValidDistrictBn(nameBn: string): boolean;
292
+ /**
293
+ * Returns the English division name that the district belongs to.
294
+ * @param district - District name in English.
295
+ * @returns Division name, or null if district not found.
296
+ * @example
297
+ * getDivisionOfDistrict('Tangail') // → 'Dhaka'
298
+ * getDivisionOfDistrict("Cox's Bazar") // → 'Chattogram'
299
+ * getDivisionOfDistrict('Unknown') // → null
300
+ */
301
+ declare function getDivisionOfDistrict(district: string): string | null;
302
+ /**
303
+ * Returns the English division name for a district given by its Bangla name.
304
+ * @param districtBn - District name in Bangla.
305
+ * @returns Division name in English, or null if not found.
306
+ * @example
307
+ * getDivisionOfDistrictBn('টাঙ্গাইল') // → 'Dhaka'
308
+ */
309
+ declare function getDivisionOfDistrictBn(districtBn: string): string | null;
310
+
311
+ /**
312
+ * Cross-level text search across divisions, districts, upazilas, and thanas.
313
+ * Supports partial English or Bangla queries (case-insensitive for English).
314
+ * @param query - Partial or full name to search for.
315
+ * @returns Array of matching locations across all levels.
316
+ * @example
317
+ * searchLocations('pur')
318
+ * // → [
319
+ * // { name: 'Rangpur', type: 'division' },
320
+ * // { name: 'Rangpur', type: 'district', division: 'Rangpur' },
321
+ * // { name: 'Mirpur', type: 'thana', district: 'Dhaka', division: 'Dhaka' },
322
+ * // ...
323
+ * // ]
324
+ *
325
+ * searchLocations('সিলেট')
326
+ * // → [{ name: 'Sylhet', nameBn: 'সিলেট', type: 'division' }, ...]
327
+ */
328
+ declare function searchLocations(query: string): SearchResult[];
329
+
330
+ /**
331
+ * Resolves a BD FHIR geocode to a full hierarchical {@link BDAddress}.
332
+ * Requires at minimum a district-level code (4-digit or longer).
333
+ * @param code - BD FHIR geocode string (e.g. `"30262530"`).
334
+ * @returns Full address object, or null if the code is unknown or invalid.
335
+ * @example
336
+ * resolveCode('30262530')
337
+ * // {
338
+ * // fhirCode: '30262530',
339
+ * // thana: { name: 'Kafrul', level: 'thana', ... },
340
+ * // city_corp:{ name: 'Dhaka North City Corporation', ... },
341
+ * // district: { name: 'Dhaka', ... },
342
+ * // division: { name: 'Dhaka', ... },
343
+ * // formatted: {
344
+ * // en: 'Kafrul, Dhaka North City Corporation, Dhaka, Dhaka Division',
345
+ * // bn: 'কাফরুল, ঢাকা উত্তর সিটি কর্পোরেশন, ঢাকা, ঢাকা বিভাগ',
346
+ * // short: 'Kafrul, Dhaka',
347
+ * // shortBn: 'কাফরুল, ঢাকা'
348
+ * // }
349
+ * // }
350
+ *
351
+ * resolveCode('INVALID') // → null
352
+ */
353
+ declare function resolveCode(code: string): BDAddress | null;
354
+ /**
355
+ * Resolves multiple BD FHIR geocodes at once.
356
+ * Null is returned for each code that is not found.
357
+ * @param codes - Array of FHIR geocode strings.
358
+ * @returns Array of resolved addresses (parallel to input; null for unknown codes).
359
+ * @example
360
+ * resolveCodes(['30262530', '10040009', 'INVALID'])
361
+ * // → [BDAddress, BDAddress, null]
362
+ */
363
+ declare function resolveCodes(codes: string[]): (BDAddress | null)[];
364
+
365
+ /**
366
+ * Returns a full formatted address string for a FHIR geocode.
367
+ * @param code - BD FHIR geocode string.
368
+ * @param lang - Language for the output: `"en"` (default) or `"bn"`.
369
+ * @returns Formatted address string, or null if the code is not found.
370
+ * @example
371
+ * toAddressString('30262530')
372
+ * // → 'Kafrul, Dhaka North City Corporation, Dhaka, Dhaka Division'
373
+ *
374
+ * toAddressString('30262530', 'bn')
375
+ * // → 'কাফরুল, ঢাকা উত্তর সিটি কর্পোরেশন, ঢাকা, ঢাকা বিভাগ'
376
+ */
377
+ declare function toAddressString(code: string, lang?: "en" | "bn"): string | null;
378
+ /**
379
+ * Returns a short address (lowest-level name + district) for a FHIR geocode.
380
+ * @param code - BD FHIR geocode string.
381
+ * @param lang - Language for the output: `"en"` (default) or `"bn"`.
382
+ * @returns Short address string, or null if the code is not found.
383
+ * @example
384
+ * toShortAddress('30262530') // → 'Kafrul, Dhaka'
385
+ * toShortAddress('30262530', 'bn') // → 'কাফরুল, ঢাকা'
386
+ */
387
+ declare function toShortAddress(code: string, lang?: "en" | "bn"): string | null;
388
+ /**
389
+ * Returns a custom address using only the specified administrative levels,
390
+ * rendered in the order given. Levels absent from the resolved address are skipped.
391
+ * @param code - BD FHIR geocode string.
392
+ * @param levels - Ordered list of {@link LocationLevel} values to include.
393
+ * @param lang - Language for the output: `"en"` (default) or `"bn"`.
394
+ * @returns Comma-joined address string, or null if the code is not found or no levels match.
395
+ * @example
396
+ * toCustomAddress('30262530', ['thana', 'district', 'division'])
397
+ * // → 'Kafrul, Dhaka, Dhaka Division'
398
+ *
399
+ * toCustomAddress('30262530', ['thana', 'district'], 'bn')
400
+ * // → 'কাফরুল, ঢাকা'
401
+ */
402
+ declare function toCustomAddress(code: string, levels: LocationLevel[], lang?: "en" | "bn"): string | null;
403
+
404
+ /**
405
+ * Returns a single location by its FHIR code, or null if not found.
406
+ * @param code - BD FHIR geocode string (whitespace is trimmed).
407
+ * @returns The matching {@link BDLocation}, or null.
408
+ * @example
409
+ * getByCode('30') // → { code: '30', name: 'Dhaka', level: 'division', ... }
410
+ * getByCode('INVALID') // → null
411
+ */
412
+ declare function getByCode(code: string): BDLocation | null;
413
+ /**
414
+ * Returns all locations matching an English name, optionally filtered by level.
415
+ * Case-insensitive and whitespace-trimmed.
416
+ * @param name - English name to look up.
417
+ * @param level - Optional {@link LocationLevel} to filter results.
418
+ * @returns Array of matching locations (empty if none found).
419
+ * @example
420
+ * findByName('Dhaka') // → [division, district, ...]
421
+ * findByName('Dhaka', 'division') // → [{ name: 'Dhaka', level: 'division', ... }]
422
+ * findByName('unknown') // → []
423
+ */
424
+ declare function findByName(name: string, level?: LocationLevel): BDLocation[];
425
+ /**
426
+ * Returns all locations matching a Bangla name, optionally filtered by level.
427
+ * @param nameBn - Bangla name to look up.
428
+ * @param level - Optional {@link LocationLevel} to filter results.
429
+ * @returns Array of matching locations (empty if none found).
430
+ * @example
431
+ * findByNameBn('ঢাকা') // → [division, district, ...]
432
+ * findByNameBn('ঢাকা', 'division') // → [{ name: 'Dhaka', level: 'division', ... }]
433
+ */
434
+ declare function findByNameBn(nameBn: string, level?: LocationLevel): BDLocation[];
435
+ /**
436
+ * Searches by English name first; if no results, searches by Bangla name.
437
+ * @param query - English or Bangla name.
438
+ * @param level - Optional {@link LocationLevel} to filter results.
439
+ * @returns Array of matching locations.
440
+ * @example
441
+ * search('Dhaka') // → English matches
442
+ * search('ঢাকা') // → Bangla matches
443
+ */
444
+ declare function search(query: string, level?: LocationLevel): BDLocation[];
445
+ /**
446
+ * Returns all locations at a given administrative level.
447
+ * @param level - The {@link LocationLevel} to retrieve.
448
+ * @returns Array of all locations at that level.
449
+ * @example
450
+ * getAllByLevel('division') // → 8 division BDLocation objects
451
+ * getAllByLevel('district') // → 64 district BDLocation objects
452
+ */
453
+ declare function getAllByLevel(level: LocationLevel): BDLocation[];
454
+
455
+ /**
456
+ * Returns the immediate parent of a location in the FHIR hierarchy.
457
+ * @param code - BD FHIR geocode string.
458
+ * @returns The parent {@link BDLocation}, or null if the code is a root (division) or not found.
459
+ * @example
460
+ * getParent('1004') // → { code: '10', name: 'Barishal', level: 'division', ... }
461
+ * getParent('10') // → null (divisions have no parent)
462
+ */
463
+ declare function getParent(code: string): BDLocation | null;
464
+ /**
465
+ * Returns all direct children of a location in the FHIR hierarchy.
466
+ * @param code - BD FHIR geocode string.
467
+ * @returns Array of child {@link BDLocation} objects, or empty array if none / not found.
468
+ * @example
469
+ * getChildren('10') // → all 6-digit locations under Barishal division
470
+ * getChildren('INVALID') // → []
471
+ */
472
+ declare function getChildren(code: string): BDLocation[];
473
+ /**
474
+ * Returns all descendants of a location at any depth.
475
+ * Optionally filters to a specific administrative level.
476
+ * @param code - BD FHIR geocode string.
477
+ * @param level - Optional {@link LocationLevel} to filter results.
478
+ * @returns Array of descendant {@link BDLocation} objects.
479
+ * @example
480
+ * getAllDescendants('10') // → all locations under Barishal division
481
+ * getAllDescendants('10', 'district') // → only districts under Barishal
482
+ * getAllDescendants('10', 'upazila') // → only upazilas under Barishal
483
+ */
484
+ declare function getAllDescendants(code: string, level?: LocationLevel): BDLocation[];
485
+ /**
486
+ * Returns the full hierarchy for a FHIR code without the formatted strings.
487
+ * Useful for storing structured data without the pre-computed string fields.
488
+ * @param code - BD FHIR geocode string.
489
+ * @returns A {@link BDAddress} without the `formatted` field, or null if not found.
490
+ * @example
491
+ * getHierarchy('30262530')
492
+ * // → { fhirCode: '30262530', thana: {...}, district: {...}, division: {...}, ... }
493
+ * // (no `formatted` field)
494
+ */
495
+ declare function getHierarchy(code: string): Omit<BDAddress, "formatted"> | null;
496
+
497
+ /**
498
+ * Returns true if the FHIR code exists in the dataset.
499
+ * @param code - BD FHIR geocode string (whitespace is trimmed).
500
+ * @returns `true` if the code is known, `false` otherwise.
501
+ * @example
502
+ * isValidCode('30262530') // → true
503
+ * isValidCode('INVALID') // → false
504
+ * isValidCode('') // → false
505
+ */
506
+ declare function isValidCode(code: string): boolean;
507
+ /**
508
+ * Returns true if an English name exists in the dataset.
509
+ * Optionally checks only at a specific administrative level.
510
+ * @param name - English name to check (case-insensitive).
511
+ * @param level - Optional {@link LocationLevel} to restrict the check.
512
+ * @returns `true` if a match is found, `false` otherwise.
513
+ * @example
514
+ * isValidName('Dhaka') // → true (exists as division and district)
515
+ * isValidName('Dhaka', 'division') // → true
516
+ * isValidName('Dhaka', 'upazila') // → false
517
+ * isValidName('UnknownPlace') // → false
518
+ */
519
+ declare function isValidName(name: string, level?: LocationLevel): boolean;
520
+ /**
521
+ * Returns true if a Bangla name exists in the dataset.
522
+ * Optionally checks only at a specific administrative level.
523
+ * @param nameBn - Bangla name to check.
524
+ * @param level - Optional {@link LocationLevel} to restrict the check.
525
+ * @returns `true` if a match is found, `false` otherwise.
526
+ * @example
527
+ * isValidNameBn('ঢাকা') // → true
528
+ * isValidNameBn('ঢাকা', 'division') // → true
529
+ * isValidNameBn('ঢাকা', 'upazila') // → false
530
+ */
531
+ declare function isValidNameBn(nameBn: string, level?: LocationLevel): boolean;
532
+ /**
533
+ * Returns true if `childCode` is a descendant of `ancestorCode` at any depth.
534
+ * @param childCode - The potential child FHIR code.
535
+ * @param ancestorCode - The potential ancestor FHIR code.
536
+ * @returns `true` if child is within the ancestor's hierarchy.
537
+ * @example
538
+ * isChildOf('10040009', '10') // → true (upazila is in Barishal division)
539
+ * isChildOf('10040009', '1004') // → true (upazila is in Barguna district)
540
+ * isChildOf('10040009', '30') // → false (not in Dhaka division)
541
+ * isChildOf('10', '10') // → false (a code is not a child of itself)
542
+ */
543
+ declare function isChildOf(childCode: string, ancestorCode: string): boolean;
544
+ /**
545
+ * Returns the administrative level of a FHIR code, or null if not found.
546
+ * @param code - BD FHIR geocode string.
547
+ * @returns The {@link LocationLevel}, or null if the code is unknown.
548
+ * @example
549
+ * getLevel('10') // → 'division'
550
+ * getLevel('1004') // → 'district'
551
+ * getLevel('10040009') // → 'upazila'
552
+ * getLevel('INVALID') // → null
553
+ */
554
+ declare function getLevel(code: string): LocationLevel | null;
555
+
556
+ /**
557
+ * Returns a postal entry by postal code, or null if not found.
558
+ * @param postalCode - Bangladesh postal code string (whitespace is trimmed).
559
+ * @returns The matching {@link BDPostalEntry}, or null.
560
+ * @example
561
+ * getByPostalCode('8710')
562
+ * // → { postalCode: '8710', postOfficeName: 'Amtali', upazilaName: 'Amtali', ... }
563
+ *
564
+ * getByPostalCode('00000') // → null
565
+ */
566
+ declare function getByPostalCode(postalCode: string): BDPostalEntry | null;
567
+ /**
568
+ * Returns the postal code for a post office given its English name (exact match, case-insensitive).
569
+ * @param postOfficeName - English name of the post office.
570
+ * @returns Postal code string, or null if not found.
571
+ * @example
572
+ * getPostalCode('Amtali') // → '8710'
573
+ * getPostalCode('unknown') // → null
574
+ */
575
+ declare function getPostalCode(postOfficeName: string): string | null;
576
+ /**
577
+ * Returns the postal code for a post office given its Bangla name (exact match).
578
+ * @param postOfficeNameBn - Bangla name of the post office.
579
+ * @returns Postal code string, or null if not found.
580
+ * @example
581
+ * getPostalCodeBn('আমতলী') // → '8710' (if Bangla name is set in the dataset)
582
+ */
583
+ declare function getPostalCodeBn(postOfficeNameBn: string): string | null;
584
+ /**
585
+ * Returns all postal entries for an area (district or division) by English name.
586
+ * @param areaName - English name of the district or division.
587
+ * @param level - Either `"district"` or `"division"`.
588
+ * @returns Array of matching {@link BDPostalEntry} objects.
589
+ * @example
590
+ * getPostalCodesByArea('Barguna', 'district')
591
+ * // → all postal entries in Barguna district
592
+ *
593
+ * getPostalCodesByArea('Barisal', 'division')
594
+ * // → all postal entries in Barisal division
595
+ */
596
+ declare function getPostalCodesByArea(areaName: string, level: "district" | "division"): BDPostalEntry[];
597
+ /**
598
+ * Returns all postal entries for an area by Bangla name.
599
+ * Note: the current postal dataset does not include Bangla district/division names;
600
+ * this function always returns an empty array until the data is enriched.
601
+ * @param areaNameBn - Bangla name of the district or division.
602
+ * @param level - Either `"district"` or `"division"`.
603
+ * @returns Array of matching {@link BDPostalEntry} objects (currently always `[]`).
604
+ */
605
+ declare function getPostalCodesByAreaBn(areaNameBn: string, level: "district" | "division"): BDPostalEntry[];
606
+ /**
607
+ * Returns the FHIR geocode linked to a postal code, or null if none is linked.
608
+ * @param postalCode - Bangladesh postal code string.
609
+ * @returns FHIR geocode string, or null.
610
+ * @example
611
+ * getFhirCodeFromPostal('8710') // → '10040009' (Amtali upazila)
612
+ * getFhirCodeFromPostal('0000') // → null
613
+ */
614
+ declare function getFhirCodeFromPostal(postalCode: string): string | null;
615
+ /**
616
+ * Resolves a postal code all the way to a full {@link BDAddress}.
617
+ * Internally looks up the linked FHIR code, then calls {@link resolveCode}.
618
+ * @param postalCode - Bangladesh postal code string.
619
+ * @returns Full address object, or null if the postal code is not found or has no linked FHIR code.
620
+ * @example
621
+ * resolvePostalCode('8710')
622
+ * // → BDAddress for Amtali, Barguna (same as resolveCode('10040009'))
623
+ */
624
+ declare function resolvePostalCode(postalCode: string): BDAddress | null;
625
+
626
+ /**
627
+ * Returns the centroid coordinates of a location by FHIR code.
628
+ * Coordinates are available only after running `npm run build:coords`.
629
+ * @param code - BD FHIR geocode string.
630
+ * @returns `{ lat, lng }` in decimal degrees, or null if coordinates are not available.
631
+ * @example
632
+ * getCoordinates('30') // → { lat: 23.8103, lng: 90.4125 } (if shapefiles loaded)
633
+ * getCoordinates('30') // → null (before build:coords is run)
634
+ */
635
+ declare function getCoordinates(code: string): {
636
+ lat: number;
637
+ lng: number;
638
+ } | null;
639
+ /**
640
+ * Finds the nearest location in the dataset to a given lat/lng point.
641
+ * Requires coordinate data (`npm run build:coords`).
642
+ * Optionally filters by administrative level.
643
+ * @param lat - Latitude in decimal degrees.
644
+ * @param lng - Longitude in decimal degrees.
645
+ * @param level - Optional {@link LocationLevel} to restrict the search.
646
+ * @returns The nearest {@link BDLocation}, or null if no locations have coordinates.
647
+ * @example
648
+ * getNearestLocation(23.7, 90.4) // → nearest location of any level
649
+ * getNearestLocation(23.7, 90.4, 'division') // → nearest division centroid
650
+ */
651
+ declare function getNearestLocation(lat: number, lng: number, level?: LocationLevel): BDLocation | null;
652
+ /**
653
+ * Returns all locations within a given radius (km) of a lat/lng point.
654
+ * Requires coordinate data (`npm run build:coords`).
655
+ * Optionally filters by administrative level.
656
+ * @param lat - Latitude in decimal degrees.
657
+ * @param lng - Longitude in decimal degrees.
658
+ * @param radiusKm - Search radius in kilometres.
659
+ * @param level - Optional {@link LocationLevel} to restrict the search.
660
+ * @returns Array of {@link BDLocation} objects within the radius.
661
+ * @example
662
+ * getLocationsWithinRadius(23.7, 90.4, 50) // → all within 50 km
663
+ * getLocationsWithinRadius(23.7, 90.4, 30, 'upazila') // → upazilas within 30 km
664
+ */
665
+ declare function getLocationsWithinRadius(lat: number, lng: number, radiusKm: number, level?: LocationLevel): BDLocation[];
666
+
667
+ export { type BDAddress, type BDLocation, type BDPostalEntry, type DistrictName, DivisionName, type LocationLevel, type SearchResult, type Thana, type Upazila, allDistricts, allDistrictsBn, allDivision, allDivisionBn, allThana, allThanaNames, allUpazila, allUpazilaNames, allUpazilaNamesBn, districtsOf, districtsOfBn, divisionalDataOf, divisionalDataOfBn, findByName, findByNameBn, getAllByLevel, getAllDescendants, getByCode, getByPostalCode, getChildren, getCoordinates, getDistrictOfUpazila, getDistrictOfUpazilabn, getDivisionOfDistrict, getDivisionOfDistrictBn, getFhirCodeFromPostal, getHierarchy, getLevel, getLocationsWithinRadius, getNearestLocation, getParent, getPostalCode, getPostalCodeBn, getPostalCodesByArea, getPostalCodesByAreaBn, getThana, getThanabn, getUpazila, getUpazilabn, isChildOf, isThana, isThanabn, isUpazila, isUpazilabn, isValidCode, isValidDistrict, isValidDistrictBn, isValidDivision, isValidDivisionBn, isValidName, isValidNameBn, resolveCode, resolveCodes, resolvePostalCode, search, searchLocations, thanaData, thanaNamesOf, thanaNamesOfBn, thanasOf, thanasOfBn, toAddressString, toCustomAddress, toShortAddress, upazilaData, upazilaNamesOf, upazilaNamesOfBn, upazilaNamesOfDivision, upazilaNamesOfDivisionBn, upazilasOf, upazilasOfBn, upazilasOfDivision, upazilasOfDivisionBn };