geo-sl 1.0.0 → 1.0.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.
- package/README.md +43 -47
- package/package.json +13 -16
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# 🇱🇰 sl
|
|
1
|
+
# 🇱🇰 geo-sl
|
|
2
2
|
|
|
3
3
|
> Trilingual (**English**, **සිංහල**, **தமிழ்**) Sri Lanka geographic, postal code, and administrative dataset for TypeScript & JavaScript with zero runtime dependencies.
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/geo-sl)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
[]()
|
|
8
8
|
[]()
|
|
@@ -10,37 +10,41 @@
|
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
- **
|
|
32
|
-
- **
|
|
13
|
+
## 🗺️ 100% Comprehensive Island-wide Coverage
|
|
14
|
+
|
|
15
|
+
`geo-sl` is not limited to major metropolitan areas. It provides complete, authoritative, and verified geographic coverage across the entire territory of Sri Lanka—from provincial capitals down to individual rural villages:
|
|
16
|
+
|
|
17
|
+
| Administrative / Geographic Level | Total Count | Scope & Details | Supported Languages |
|
|
18
|
+
|---|---|---|---|
|
|
19
|
+
| **Provinces** | **9** | All 9 provinces (WP, CP, SP, NP, EP, NW, NC, UV, SG) | English, සිංහල, தமிழ் |
|
|
20
|
+
| **Districts** | **25** | All 25 administrative districts across the island | English, සිංහල, தமிழ் |
|
|
21
|
+
| **Divisional Secretariats (DSD)** | **340** | 100% of Divisional Secretariat Divisions (MOHA) | English, සිංහල, தமிழ் |
|
|
22
|
+
| **Grama Niladhari (GN) Divisions** | **14,020** | Every single village, ward, and local community | English, සිංහල, தமிழ் |
|
|
23
|
+
| **Cities, Towns & Post Offices** | **2,598** | Main post offices, towns, and sub-post offices | English, සිංහල, தமிழ் |
|
|
24
|
+
| **GPS Centroids** | **2,100+** | Accurate Latitude & Longitude coordinates | WGS84 coordinates |
|
|
25
|
+
| **Licensed Banks & Branches** | **45 Banks / 582+ Branches** | Complete CBSL & LankaPay routing codes | Official routing codes |
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## ⚡ Key Highlights
|
|
30
|
+
|
|
31
|
+
- **Zero Runtime Dependencies** – Pure TypeScript with pre-indexed lookup maps. Ultra-fast, deterministic performance.
|
|
32
|
+
- **Trilingual First-Class Support** – Seamless lookups in **English**, **Sinhala (සිංහල)**, and **Tamil (தமிழ்)** with native scripts.
|
|
33
|
+
- **Optimized Subpath Tree-Shaking** – Import only what you need. Lightweight modules like validators are only **~2.3 KB**.
|
|
34
|
+
- **Cascading Form Helper** – Out-of-the-box hierarchy builder (`Province ➔ District ➔ City`) for checkout address selectors.
|
|
35
|
+
- **Intelligent Relevance Search** – Multi-lingual search prioritizing exact matches, prefixes, and postal codes over broad substring matches.
|
|
36
|
+
- **Built-in Validators & Parsers** – National Identity Card (Old 9-digit + New 12-digit NIC), Sri Lankan mobile & landline phone numbers, and postal codes.
|
|
33
37
|
|
|
34
38
|
---
|
|
35
39
|
|
|
36
40
|
## Installation
|
|
37
41
|
|
|
38
42
|
```bash
|
|
39
|
-
npm install sl
|
|
43
|
+
npm install geo-sl
|
|
40
44
|
# or
|
|
41
|
-
pnpm add sl
|
|
45
|
+
pnpm add geo-sl
|
|
42
46
|
# or
|
|
43
|
-
yarn add sl
|
|
47
|
+
yarn add geo-sl
|
|
44
48
|
```
|
|
45
49
|
|
|
46
50
|
---
|
|
@@ -58,7 +62,7 @@ import {
|
|
|
58
62
|
PROVINCE_MAP,
|
|
59
63
|
DISTRICT_MAP,
|
|
60
64
|
search
|
|
61
|
-
} from 'sl
|
|
65
|
+
} from 'geo-sl';
|
|
62
66
|
|
|
63
67
|
// 1. Province Lookup
|
|
64
68
|
const wp = getProvince('WP');
|
|
@@ -99,25 +103,25 @@ To keep client bundles minimal, import only the modules your application needs:
|
|
|
99
103
|
|
|
100
104
|
```typescript
|
|
101
105
|
// Provinces only (~2 KB)
|
|
102
|
-
import { PROVINCES, getProvinces, getProvince } from 'sl
|
|
106
|
+
import { PROVINCES, getProvinces, getProvince } from 'geo-sl/provinces';
|
|
103
107
|
|
|
104
108
|
// Districts only (~7 KB)
|
|
105
|
-
import { DISTRICTS, getDistricts, getDistrictsByProvince } from 'sl
|
|
109
|
+
import { DISTRICTS, getDistricts, getDistrictsByProvince } from 'geo-sl/districts';
|
|
106
110
|
|
|
107
111
|
// Cities & Postal Codes (~900 KB)
|
|
108
|
-
import { CITIES, getCityByPostalCode, getPostalCode, search } from 'sl
|
|
112
|
+
import { CITIES, getCityByPostalCode, getPostalCode, search } from 'geo-sl/cities';
|
|
109
113
|
|
|
110
114
|
// Divisional Secretariats (~68 KB)
|
|
111
|
-
import { DIVISIONS, getDivisions, getDivisionsByDistrict } from 'sl
|
|
115
|
+
import { DIVISIONS, getDivisions, getDivisionsByDistrict } from 'geo-sl/divisions';
|
|
112
116
|
|
|
113
117
|
// CBSL Bank & Branch Codes (~140 KB)
|
|
114
|
-
import { BANKS, getBanks, getBankByCode, getBranches } from 'sl
|
|
118
|
+
import { BANKS, getBanks, getBankByCode, getBranches } from 'geo-sl/banks';
|
|
115
119
|
|
|
116
120
|
// Grama Niladhari Divisions (14,000+ entries, ~3 MB)
|
|
117
|
-
import { GN_DIVISIONS, getGNDivisions, searchGN } from 'sl
|
|
121
|
+
import { GN_DIVISIONS, getGNDivisions, searchGN } from 'geo-sl/gn';
|
|
118
122
|
|
|
119
123
|
// Validators & Parsers (~2.3 KB)
|
|
120
|
-
import { validateNIC, parseNIC, validatePhone, parsePhone, validatePostalCode } from 'sl
|
|
124
|
+
import { validateNIC, parseNIC, validatePhone, parsePhone, validatePostalCode } from 'geo-sl/validators';
|
|
121
125
|
```
|
|
122
126
|
|
|
123
127
|
---
|
|
@@ -128,7 +132,7 @@ The easiest way to build a Sri Lankan checkout address form:
|
|
|
128
132
|
|
|
129
133
|
```tsx
|
|
130
134
|
import React, { useState } from 'react';
|
|
131
|
-
import { getCascadingData } from 'sl
|
|
135
|
+
import { getCascadingData } from 'geo-sl';
|
|
132
136
|
|
|
133
137
|
const addressData = getCascadingData({ lang: 'en' });
|
|
134
138
|
|
|
@@ -193,12 +197,12 @@ export function SriLankaAddressForm() {
|
|
|
193
197
|
|
|
194
198
|
---
|
|
195
199
|
|
|
196
|
-
## 🏦 CBSL Bank & Branch Codes (`sl
|
|
200
|
+
## 🏦 CBSL Bank & Branch Codes (`geo-sl/banks`)
|
|
197
201
|
|
|
198
202
|
Essential for fintech, payment gateway integrations, and bank transfer checkouts:
|
|
199
203
|
|
|
200
204
|
```typescript
|
|
201
|
-
import { getBanks, getBankByCode, getBranches } from 'sl
|
|
205
|
+
import { getBanks, getBankByCode, getBranches } from 'geo-sl/banks';
|
|
202
206
|
|
|
203
207
|
// List all licensed banks
|
|
204
208
|
const allBanks = getBanks();
|
|
@@ -250,14 +254,14 @@ const branches = getBranches('7010');
|
|
|
250
254
|
* `getBranchByCode(bankCode: string | number, branchCode: string | number): Branch | undefined`
|
|
251
255
|
* `searchBranches(bankCode: string | number, query: string): Branch[]`
|
|
252
256
|
|
|
253
|
-
### Grama Niladhari (GN) Divisions (`sl
|
|
257
|
+
### Grama Niladhari (GN) Divisions (`geo-sl/gn`)
|
|
254
258
|
* `getGNDivisions(options?: { lang?: 'en' | 'si' | 'ta' }): GNDivision[]`
|
|
255
259
|
* `getGNDivisionsByDSD(divisionName: string, options?: { lang?: 'en' | 'si' | 'ta' }): GNDivision[]`
|
|
256
260
|
* `getGNDivisionsByDistrict(districtName: string, options?: { lang?: 'en' | 'si' | 'ta' }): GNDivision[]`
|
|
257
261
|
* `findGNByCode(code: string, options?: { lang?: 'en' | 'si' | 'ta' }): GNDivision | undefined`
|
|
258
262
|
* `searchGN(query: string, options?: { limit?: number; lang?: 'en' | 'si' | 'ta'; district?: string; division?: string }): GNDivision[]`
|
|
259
263
|
|
|
260
|
-
### Sri Lanka Validators & Parsers (`sl
|
|
264
|
+
### Sri Lanka Validators & Parsers (`geo-sl/validators`)
|
|
261
265
|
* `validateNIC(nic: string): boolean`
|
|
262
266
|
* `parseNIC(nic: string): ParsedNIC | null` – parses birthdate, gender, age, voter eligibility from Old (9+V/X) and New (12 digits) NICs.
|
|
263
267
|
* `convertOldNICToNew(oldNic: string): string | null` – converts 9-digit old NIC to 12-digit format.
|
|
@@ -286,19 +290,11 @@ import type {
|
|
|
286
290
|
DistrictCode,
|
|
287
291
|
QueryOptions,
|
|
288
292
|
SearchOptions
|
|
289
|
-
} from 'sl
|
|
293
|
+
} from 'geo-sl';
|
|
290
294
|
```
|
|
291
295
|
|
|
292
296
|
---
|
|
293
297
|
|
|
294
|
-
## 🏛️ Data Sources & Attribution
|
|
295
|
-
|
|
296
|
-
- **Postal Data**: [Department of Posts, Sri Lanka](https://slpost.gov.lk)
|
|
297
|
-
- **Administrative Hierarchy**: [Ministry of Public Administration & Home Affairs](http://moha.gov.lk) & [Department of Census and Statistics](http://www.statistics.gov.lk)
|
|
298
|
-
- **Bank & Branch Codes**: [Central Bank of Sri Lanka](https://www.cbsl.gov.lk) & [LankaPay](https://www.lankapay.net)
|
|
299
|
-
|
|
300
|
-
---
|
|
301
|
-
|
|
302
298
|
## 📄 License
|
|
303
299
|
|
|
304
300
|
MIT © [Mahesh Abeykoon](https://github.com/mahesh-abeykoon)
|
package/package.json
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "geo-sl",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Trilingual (English, සිංහල, தமிழ்) Sri Lanka geographic, postal code, and administrative dataset for TypeScript and JavaScript.",
|
|
5
5
|
"author": "Mahesh Abeykoon",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"homepage": "https://github.com/mahesh-abeykoon/sl
|
|
7
|
+
"homepage": "https://github.com/mahesh-abeykoon/geo-sl#readme",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/mahesh-abeykoon/sl
|
|
10
|
+
"url": "git+https://github.com/mahesh-abeykoon/geo-sl.git"
|
|
11
11
|
},
|
|
12
12
|
"bugs": {
|
|
13
|
-
"url": "https://github.com/mahesh-abeykoon/sl
|
|
13
|
+
"url": "https://github.com/mahesh-abeykoon/geo-sl/issues"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
14
17
|
},
|
|
15
18
|
"sideEffects": false,
|
|
16
19
|
"engines": {
|
|
@@ -116,21 +119,15 @@
|
|
|
116
119
|
"dist"
|
|
117
120
|
],
|
|
118
121
|
"keywords": [
|
|
119
|
-
"sri
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
+
"sri-lanka",
|
|
123
|
+
"geo",
|
|
124
|
+
"postal-codes",
|
|
122
125
|
"cities",
|
|
123
126
|
"districts",
|
|
124
127
|
"provinces",
|
|
125
|
-
"
|
|
126
|
-
"grama
|
|
127
|
-
"
|
|
128
|
-
"sinhala",
|
|
129
|
-
"tamil",
|
|
130
|
-
"lankapay",
|
|
131
|
-
"banks",
|
|
132
|
-
"address autocomplete",
|
|
133
|
-
"checkout"
|
|
128
|
+
"administrative-divisions",
|
|
129
|
+
"grama-niladhari",
|
|
130
|
+
"bank-codes"
|
|
134
131
|
],
|
|
135
132
|
"scripts": {
|
|
136
133
|
"build:data": "node scripts/build-datasets.mjs",
|