geo-sl 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.
@@ -0,0 +1,89 @@
1
+ import { City, QueryOptions, DistrictCode, ProvinceCode, Language, SearchOptions } from './types.cjs';
2
+
3
+ declare const CITIES: readonly City[];
4
+ /**
5
+ * Finds a city or post office by its 5-digit postal code.
6
+ *
7
+ * @param postalCode - 5-digit postal code (e.g. '00100' or 100).
8
+ * @param lang - Target language ('en' | 'si' | 'ta'). Default is 'en'.
9
+ * @returns Matching City object, or undefined if not found.
10
+ *
11
+ * @example
12
+ * getCityByPostalCode('00100') // => Colombo 1
13
+ * getCityByPostalCode('20000') // => Kandy
14
+ */
15
+ declare function getCityByPostalCode(postalCode: string | number, lang?: Language): City | undefined;
16
+ /**
17
+ * Alias for getCityByPostalCode.
18
+ *
19
+ * @see getCityByPostalCode
20
+ */
21
+ declare function lookupPostalCode(postalCode: string | number, options?: QueryOptions): City | undefined;
22
+ /**
23
+ * Returns all postal stations or sub-offices that share the specified postal code.
24
+ *
25
+ * @param postalCode - 5-digit postal code.
26
+ * @param options - Query options including language selection.
27
+ */
28
+ declare function lookupAllByPostalCode(postalCode: string | number, options?: QueryOptions): readonly City[];
29
+ /**
30
+ * Resolves the 5-digit postal code for a given city name (English, Sinhala, or Tamil).
31
+ *
32
+ * @param cityName - Name of the city or town.
33
+ * @returns 5-digit postal code string, or undefined if not found.
34
+ *
35
+ * @example
36
+ * getPostalCode('Athurugiriya') // => "10150"
37
+ * getPostalCode('Colombo 1') // => "00100"
38
+ * getPostalCode('මහනුවර') // => "20000"
39
+ */
40
+ declare function getPostalCode(cityName: string): string | undefined;
41
+ /**
42
+ * Checks whether a given postal code exists in the official Sri Lanka Post dataset.
43
+ *
44
+ * @param postalCode - 5-digit postal code.
45
+ *
46
+ * @example
47
+ * isValidPostalCode('00100') // => true
48
+ * isValidPostalCode('99999') // => false
49
+ */
50
+ declare function isValidPostalCode(postalCode: string | number): boolean;
51
+ /**
52
+ * Returns all cities and post offices within a district.
53
+ *
54
+ * @param district - District code (e.g. 'CO') or district name.
55
+ * @param options - Query options including language selection.
56
+ *
57
+ * @example
58
+ * getCitiesByDistrict('CO') // => Colombo cities
59
+ * getCitiesByDistrict('Gampaha') // => Gampaha cities
60
+ */
61
+ declare function getCitiesByDistrict(district: DistrictCode | string, options?: QueryOptions): readonly City[];
62
+ /**
63
+ * Returns all cities and post offices within a province.
64
+ *
65
+ * @param province - Province code (e.g. 'WP') or province name.
66
+ * @param options - Query options including language selection.
67
+ */
68
+ declare function getCitiesByProvince(province: ProvinceCode | string, options?: QueryOptions): readonly City[];
69
+ /**
70
+ * Returns cities and post offices, optionally filtered by district.
71
+ *
72
+ * @param districtOrOptions - District code/name or query options.
73
+ * @param options - Query options if district was specified as first argument.
74
+ */
75
+ declare function getCities(districtOrOptions?: string | QueryOptions, options?: QueryOptions): readonly City[];
76
+ /**
77
+ * Searches cities, towns, and postal stations across English, Sinhala, and Tamil.
78
+ * Uses relevance scoring to prioritize exact and prefix matches over district matches.
79
+ *
80
+ * @param query - Search term (town name, postal code, or district).
81
+ * @param options - Search options including limit, language, and district/province filters.
82
+ *
83
+ * @example
84
+ * search('colombo') // => ['Colombo 1', 'Colombo 2', ...]
85
+ * search('nawala') // => ['Nawala', 'Nawala-Koswatte', ...]
86
+ */
87
+ declare function search(query: string, options?: SearchOptions): City[];
88
+
89
+ export { CITIES, getCities, getCitiesByDistrict, getCitiesByProvince, getCityByPostalCode, getPostalCode, isValidPostalCode, lookupAllByPostalCode, lookupPostalCode, search };
@@ -0,0 +1,89 @@
1
+ import { City, QueryOptions, DistrictCode, ProvinceCode, Language, SearchOptions } from './types.js';
2
+
3
+ declare const CITIES: readonly City[];
4
+ /**
5
+ * Finds a city or post office by its 5-digit postal code.
6
+ *
7
+ * @param postalCode - 5-digit postal code (e.g. '00100' or 100).
8
+ * @param lang - Target language ('en' | 'si' | 'ta'). Default is 'en'.
9
+ * @returns Matching City object, or undefined if not found.
10
+ *
11
+ * @example
12
+ * getCityByPostalCode('00100') // => Colombo 1
13
+ * getCityByPostalCode('20000') // => Kandy
14
+ */
15
+ declare function getCityByPostalCode(postalCode: string | number, lang?: Language): City | undefined;
16
+ /**
17
+ * Alias for getCityByPostalCode.
18
+ *
19
+ * @see getCityByPostalCode
20
+ */
21
+ declare function lookupPostalCode(postalCode: string | number, options?: QueryOptions): City | undefined;
22
+ /**
23
+ * Returns all postal stations or sub-offices that share the specified postal code.
24
+ *
25
+ * @param postalCode - 5-digit postal code.
26
+ * @param options - Query options including language selection.
27
+ */
28
+ declare function lookupAllByPostalCode(postalCode: string | number, options?: QueryOptions): readonly City[];
29
+ /**
30
+ * Resolves the 5-digit postal code for a given city name (English, Sinhala, or Tamil).
31
+ *
32
+ * @param cityName - Name of the city or town.
33
+ * @returns 5-digit postal code string, or undefined if not found.
34
+ *
35
+ * @example
36
+ * getPostalCode('Athurugiriya') // => "10150"
37
+ * getPostalCode('Colombo 1') // => "00100"
38
+ * getPostalCode('මහනුවර') // => "20000"
39
+ */
40
+ declare function getPostalCode(cityName: string): string | undefined;
41
+ /**
42
+ * Checks whether a given postal code exists in the official Sri Lanka Post dataset.
43
+ *
44
+ * @param postalCode - 5-digit postal code.
45
+ *
46
+ * @example
47
+ * isValidPostalCode('00100') // => true
48
+ * isValidPostalCode('99999') // => false
49
+ */
50
+ declare function isValidPostalCode(postalCode: string | number): boolean;
51
+ /**
52
+ * Returns all cities and post offices within a district.
53
+ *
54
+ * @param district - District code (e.g. 'CO') or district name.
55
+ * @param options - Query options including language selection.
56
+ *
57
+ * @example
58
+ * getCitiesByDistrict('CO') // => Colombo cities
59
+ * getCitiesByDistrict('Gampaha') // => Gampaha cities
60
+ */
61
+ declare function getCitiesByDistrict(district: DistrictCode | string, options?: QueryOptions): readonly City[];
62
+ /**
63
+ * Returns all cities and post offices within a province.
64
+ *
65
+ * @param province - Province code (e.g. 'WP') or province name.
66
+ * @param options - Query options including language selection.
67
+ */
68
+ declare function getCitiesByProvince(province: ProvinceCode | string, options?: QueryOptions): readonly City[];
69
+ /**
70
+ * Returns cities and post offices, optionally filtered by district.
71
+ *
72
+ * @param districtOrOptions - District code/name or query options.
73
+ * @param options - Query options if district was specified as first argument.
74
+ */
75
+ declare function getCities(districtOrOptions?: string | QueryOptions, options?: QueryOptions): readonly City[];
76
+ /**
77
+ * Searches cities, towns, and postal stations across English, Sinhala, and Tamil.
78
+ * Uses relevance scoring to prioritize exact and prefix matches over district matches.
79
+ *
80
+ * @param query - Search term (town name, postal code, or district).
81
+ * @param options - Search options including limit, language, and district/province filters.
82
+ *
83
+ * @example
84
+ * search('colombo') // => ['Colombo 1', 'Colombo 2', ...]
85
+ * search('nawala') // => ['Nawala', 'Nawala-Koswatte', ...]
86
+ */
87
+ declare function search(query: string, options?: SearchOptions): City[];
88
+
89
+ export { CITIES, getCities, getCitiesByDistrict, getCitiesByProvince, getCityByPostalCode, getPostalCode, isValidPostalCode, lookupAllByPostalCode, lookupPostalCode, search };