@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 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
+ [![npm version](https://img.shields.io/npm/v/ph-address-intel)](https://www.npmjs.com/package/ph-address-intel)
6
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](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