@olule_solomon/ug-locations 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.
- package/dist/index.d.mts +49 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +589121 -0
- package/dist/index.mjs +589091 -0
- package/package.json +30 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ug-locations
|
|
3
|
+
*
|
|
4
|
+
* Uganda UBOS administrative unit gazetteer with hierarchical lookup.
|
|
5
|
+
* Data covers ~84 000 units across 5 levels:
|
|
6
|
+
* district (135) → county (303) → subcounty (2120) → parish (10359) → village (71232)
|
|
7
|
+
*
|
|
8
|
+
* All lookups are synchronous — the full dataset is bundled with the package.
|
|
9
|
+
*
|
|
10
|
+
* Uganda's hierarchy is District → County → Sub-county → Parish → Village,
|
|
11
|
+
* but the common PAP/land data model keeps district/sub-county/parish/village
|
|
12
|
+
* (skipping county). Use `fetchSubCountiesUnderDistrict` to traverse the county
|
|
13
|
+
* tier transparently.
|
|
14
|
+
*/
|
|
15
|
+
type AdminUnitLevel = 'district' | 'county' | 'subcounty' | 'parish' | 'village';
|
|
16
|
+
interface AdminUnit {
|
|
17
|
+
id: number;
|
|
18
|
+
name: string;
|
|
19
|
+
level: AdminUnitLevel;
|
|
20
|
+
code: string;
|
|
21
|
+
parent_id: number | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* List admin units by level, optionally filtered by parent and/or search query.
|
|
25
|
+
*
|
|
26
|
+
* - `parentId = null` + `level = 'district'` → all districts
|
|
27
|
+
* - `parentId = <id>` → children of that unit at the given level
|
|
28
|
+
* - Non-district levels with `parentId = null` return `[]`
|
|
29
|
+
*/
|
|
30
|
+
declare function listAdminUnits(level: AdminUnitLevel, parentId: number | null, query?: string): AdminUnit[];
|
|
31
|
+
/**
|
|
32
|
+
* Return all sub-counties under a district, resolving through the county tier.
|
|
33
|
+
*
|
|
34
|
+
* Uganda's real hierarchy has counties between districts and sub-counties.
|
|
35
|
+
* This function collects sub-counties directly under the district AND those
|
|
36
|
+
* under any counties in that district, deduped and sorted — so callers get
|
|
37
|
+
* a flat 4-level picker (district → sub-county → parish → village) without
|
|
38
|
+
* worrying about the county level.
|
|
39
|
+
*/
|
|
40
|
+
declare function fetchSubCountiesUnderDistrict(districtId: number): AdminUnit[];
|
|
41
|
+
/** True when the bundled dataset has data. Always true in a correctly installed package. */
|
|
42
|
+
declare function isGazetteerAvailable(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The complete dataset — all 84 000+ units.
|
|
45
|
+
* Use the helper functions above instead of filtering this directly.
|
|
46
|
+
*/
|
|
47
|
+
declare function getAllUnits(): AdminUnit[];
|
|
48
|
+
|
|
49
|
+
export { type AdminUnit, type AdminUnitLevel, fetchSubCountiesUnderDistrict, getAllUnits, isGazetteerAvailable, listAdminUnits };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ug-locations
|
|
3
|
+
*
|
|
4
|
+
* Uganda UBOS administrative unit gazetteer with hierarchical lookup.
|
|
5
|
+
* Data covers ~84 000 units across 5 levels:
|
|
6
|
+
* district (135) → county (303) → subcounty (2120) → parish (10359) → village (71232)
|
|
7
|
+
*
|
|
8
|
+
* All lookups are synchronous — the full dataset is bundled with the package.
|
|
9
|
+
*
|
|
10
|
+
* Uganda's hierarchy is District → County → Sub-county → Parish → Village,
|
|
11
|
+
* but the common PAP/land data model keeps district/sub-county/parish/village
|
|
12
|
+
* (skipping county). Use `fetchSubCountiesUnderDistrict` to traverse the county
|
|
13
|
+
* tier transparently.
|
|
14
|
+
*/
|
|
15
|
+
type AdminUnitLevel = 'district' | 'county' | 'subcounty' | 'parish' | 'village';
|
|
16
|
+
interface AdminUnit {
|
|
17
|
+
id: number;
|
|
18
|
+
name: string;
|
|
19
|
+
level: AdminUnitLevel;
|
|
20
|
+
code: string;
|
|
21
|
+
parent_id: number | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* List admin units by level, optionally filtered by parent and/or search query.
|
|
25
|
+
*
|
|
26
|
+
* - `parentId = null` + `level = 'district'` → all districts
|
|
27
|
+
* - `parentId = <id>` → children of that unit at the given level
|
|
28
|
+
* - Non-district levels with `parentId = null` return `[]`
|
|
29
|
+
*/
|
|
30
|
+
declare function listAdminUnits(level: AdminUnitLevel, parentId: number | null, query?: string): AdminUnit[];
|
|
31
|
+
/**
|
|
32
|
+
* Return all sub-counties under a district, resolving through the county tier.
|
|
33
|
+
*
|
|
34
|
+
* Uganda's real hierarchy has counties between districts and sub-counties.
|
|
35
|
+
* This function collects sub-counties directly under the district AND those
|
|
36
|
+
* under any counties in that district, deduped and sorted — so callers get
|
|
37
|
+
* a flat 4-level picker (district → sub-county → parish → village) without
|
|
38
|
+
* worrying about the county level.
|
|
39
|
+
*/
|
|
40
|
+
declare function fetchSubCountiesUnderDistrict(districtId: number): AdminUnit[];
|
|
41
|
+
/** True when the bundled dataset has data. Always true in a correctly installed package. */
|
|
42
|
+
declare function isGazetteerAvailable(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The complete dataset — all 84 000+ units.
|
|
45
|
+
* Use the helper functions above instead of filtering this directly.
|
|
46
|
+
*/
|
|
47
|
+
declare function getAllUnits(): AdminUnit[];
|
|
48
|
+
|
|
49
|
+
export { type AdminUnit, type AdminUnitLevel, fetchSubCountiesUnderDistrict, getAllUnits, isGazetteerAvailable, listAdminUnits };
|