@bzync/ph-address-intel 0.1.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/LICENSE +21 -0
- package/README.md +229 -0
- package/dist/index.cjs +227113 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +47 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +227106 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bzync
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# π΅π PH Address Library
|
|
2
|
+
|
|
3
|
+
> Framework-agnostic TypeScript library for Philippine address lookup, ZIP autofill, and hierarchical region β province β municipality β barangay selection.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/ph-address-intel)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## β¨ Features
|
|
11
|
+
|
|
12
|
+
- β‘ **ZIP Autofill**
|
|
13
|
+
Resolve a 4-digit ZIP code into region, province, municipality, and barangays.
|
|
14
|
+
|
|
15
|
+
- ποΈ **Cascading Selection**
|
|
16
|
+
Full PSGC hierarchy:
|
|
17
|
+
`getRegions β getProvinces β getMunicipalities β getBarangays`
|
|
18
|
+
|
|
19
|
+
- π **Free-Text Search**
|
|
20
|
+
Search across all address levels with a single function.
|
|
21
|
+
|
|
22
|
+
- π¦ **Zero Runtime Dependencies**
|
|
23
|
+
No API calls. Works offline and at the edge.
|
|
24
|
+
|
|
25
|
+
- π·οΈ **TypeScript First**
|
|
26
|
+
Fully typed API with `.d.ts` support (CJS + ESM).
|
|
27
|
+
|
|
28
|
+
- πΊοΈ **Official PSGC Data**
|
|
29
|
+
Based on PSA PSGC 4Q 2025
|
|
30
|
+
Covers:
|
|
31
|
+
- 17 Regions
|
|
32
|
+
- 80 Provinces
|
|
33
|
+
- 42,000+ Barangays
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## π¦ Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install ph-address-intel
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Other package managers
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
yarn add ph-address-intel
|
|
47
|
+
pnpm add ph-address-intel
|
|
48
|
+
bun add ph-address-intel
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## π Quick Start
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import {
|
|
57
|
+
lookupByZip,
|
|
58
|
+
getRegions,
|
|
59
|
+
getProvinces,
|
|
60
|
+
getMunicipalities,
|
|
61
|
+
getBarangays,
|
|
62
|
+
search,
|
|
63
|
+
} from 'ph-address-intel'
|
|
64
|
+
|
|
65
|
+
// ZIP autofill
|
|
66
|
+
const result = lookupByZip('4322')
|
|
67
|
+
|
|
68
|
+
// Hierarchical selection
|
|
69
|
+
const regions = getRegions()
|
|
70
|
+
const provinces = getProvinces('040000000')
|
|
71
|
+
const municipalities = getMunicipalities('045600000')
|
|
72
|
+
const barangays = getBarangays('045645000')
|
|
73
|
+
|
|
74
|
+
// Free-text search
|
|
75
|
+
const hits = search('Sariaya')
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## π’ ZIP Autofill Example
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
const result = lookupByZip('4322')
|
|
84
|
+
|
|
85
|
+
if (result) {
|
|
86
|
+
console.log(result.region.name)
|
|
87
|
+
console.log(result.province?.name)
|
|
88
|
+
console.log(result.municipality.name)
|
|
89
|
+
console.log(result.barangays.length)
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## π§ API Reference
|
|
96
|
+
|
|
97
|
+
### `lookupByZip(zip: string)`
|
|
98
|
+
Resolve ZIP β full address hierarchy
|
|
99
|
+
|
|
100
|
+
### `getRegions()`
|
|
101
|
+
Returns all 17 Philippine regions
|
|
102
|
+
|
|
103
|
+
### `getProvinces(regionCode: string)`
|
|
104
|
+
Returns provinces within a region
|
|
105
|
+
|
|
106
|
+
### `getMunicipalities(provinceCode: string)`
|
|
107
|
+
Returns municipalities/cities in a province
|
|
108
|
+
|
|
109
|
+
### `getBarangays(municipalityCode: string)`
|
|
110
|
+
Returns barangays within a municipality
|
|
111
|
+
|
|
112
|
+
### `search(query: string)`
|
|
113
|
+
Search across all address levels
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## π§ TypeScript Types
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
interface Region {
|
|
121
|
+
code: string
|
|
122
|
+
name: string
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
interface Province {
|
|
126
|
+
code: string
|
|
127
|
+
name: string
|
|
128
|
+
regionCode: string
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface Municipality {
|
|
132
|
+
code: string
|
|
133
|
+
name: string
|
|
134
|
+
regionCode: string
|
|
135
|
+
provinceCode: string | null
|
|
136
|
+
isCity: boolean
|
|
137
|
+
zipCodes: string[]
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
interface Barangay {
|
|
141
|
+
code: string
|
|
142
|
+
name: string
|
|
143
|
+
municipalityCode: string
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
interface ZipLookupResult {
|
|
147
|
+
zip: string
|
|
148
|
+
region: Region
|
|
149
|
+
province: Province | null
|
|
150
|
+
municipality: Municipality
|
|
151
|
+
barangays: Barangay[]
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## π§© PSGC Code Structure
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
RRPPMMMBBB
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
| Part | Meaning |
|
|
164
|
+
|------|--------|
|
|
165
|
+
| RR | Region |
|
|
166
|
+
| PP | Province |
|
|
167
|
+
| MMM | Municipality |
|
|
168
|
+
| BBB | Barangay |
|
|
169
|
+
|
|
170
|
+
Example:
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
040000000 β Region IV-A
|
|
174
|
+
045600000 β Quezon
|
|
175
|
+
045645000 β Sariaya
|
|
176
|
+
045645001 β Barangay Antipolo
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## β οΈ Notes
|
|
182
|
+
|
|
183
|
+
- NCR has **no provinces** β `province = null`
|
|
184
|
+
- ZIP dataset contains **~958 mappings**
|
|
185
|
+
- Some barangays share ZIP codes
|
|
186
|
+
- BARMM barangay data may be incomplete (PSGC limitation)
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## π Use Cases
|
|
191
|
+
|
|
192
|
+
- Address forms (checkout, signup)
|
|
193
|
+
- Government systems
|
|
194
|
+
- Delivery/logistics apps
|
|
195
|
+
- CRM systems
|
|
196
|
+
- Mobile apps (offline support)
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## π Why This Library?
|
|
201
|
+
|
|
202
|
+
Unlike other PH address libraries:
|
|
203
|
+
- β
No API required
|
|
204
|
+
- β
Fully offline
|
|
205
|
+
- β
Complete PSGC hierarchy
|
|
206
|
+
- β
ZIP β barangay resolution
|
|
207
|
+
- β
Type-safe out of the box
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## π οΈ Roadmap
|
|
212
|
+
|
|
213
|
+
- [ ] React/Vue autocomplete components
|
|
214
|
+
- [ ] CLI tools
|
|
215
|
+
- [ ] Dataset updates automation
|
|
216
|
+
- [ ] Validation helpers
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## π License
|
|
221
|
+
|
|
222
|
+
MIT License Β© 2026
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## β Support
|
|
227
|
+
|
|
228
|
+
If this helped you, consider starring the repo β
|
|
229
|
+
https://github.com/rzarviandoe/ph-address-intel
|