@aprestmo/norway-geodata 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.
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Language status for Norwegian municipalities
3
+ */
4
+ export type LanguageStatus = 'Nøytral' | 'Bokmål' | 'Nynorsk' | 'Sami' | 'Kvensk';
5
+ /**
6
+ * Municipality (Kommune) data structure
7
+ */
8
+ export interface Municipality {
9
+ /** 4-digit municipality ID */
10
+ readonly k_id: string;
11
+ /** Municipality name */
12
+ readonly k_name: string;
13
+ /** Municipality name in Norwegian */
14
+ readonly k_name_no: string;
15
+ /** Administrative center */
16
+ readonly k_adm_center: string;
17
+ /** Population count */
18
+ readonly k_population: number;
19
+ /** Area in square kilometers */
20
+ readonly k_area: number;
21
+ /** Official language status */
22
+ readonly k_language: LanguageStatus;
23
+ /** Official website URL */
24
+ readonly k_url: string;
25
+ /** Array of postal codes with place names */
26
+ readonly k_postal_codes: readonly {
27
+ /** 4-digit postal code */
28
+ readonly postal_code: string;
29
+ /** Place name */
30
+ readonly postal_place: string;
31
+ }[];
32
+ }
33
+ /**
34
+ * County (Fylke) data structure
35
+ */
36
+ export interface County {
37
+ /** 2-digit county ID */
38
+ readonly f_id: string;
39
+ /** County name */
40
+ readonly f_name: string;
41
+ /** Official website URL */
42
+ readonly f_url: string;
43
+ }
44
+ /**
45
+ * Population density statistics
46
+ */
47
+ export interface PopulationDensityStats {
48
+ /** Minimum population density (people per km²) */
49
+ readonly min: number;
50
+ /** Maximum population density (people per km²) */
51
+ readonly max: number;
52
+ /** Average population density (people per km²) */
53
+ readonly average: number;
54
+ }
55
+ /**
56
+ * Version bump types for semantic versioning
57
+ */
58
+ export type VersionBumpType = 'patch' | 'minor' | 'major' | 'prerelease';
59
+ /**
60
+ * Sort order options
61
+ */
62
+ export type SortOrder = 'asc' | 'desc';
63
+ /**
64
+ * Search options for municipalities
65
+ */
66
+ export interface MunicipalitySearchOptions {
67
+ /** Search in both Norwegian and English names */
68
+ readonly includeAllNames?: boolean;
69
+ /** Case sensitive search */
70
+ readonly caseSensitive?: boolean;
71
+ /** Exact match only */
72
+ readonly exactMatch?: boolean;
73
+ }
74
+ /**
75
+ * Filter options for municipalities
76
+ */
77
+ export interface MunicipalityFilterOptions {
78
+ /** Minimum population */
79
+ readonly minPopulation?: number;
80
+ /** Maximum population */
81
+ readonly maxPopulation?: number;
82
+ /** Minimum area (km²) */
83
+ readonly minArea?: number;
84
+ /** Maximum area (km²) */
85
+ readonly maxArea?: number;
86
+ /** Language status */
87
+ readonly language?: LanguageStatus;
88
+ /** County ID */
89
+ readonly countyId?: string;
90
+ }
91
+ /**
92
+ * Postal Code data structure
93
+ */
94
+ export interface PostalCode {
95
+ /** 4-digit postal code */
96
+ readonly k_postal_code: string;
97
+ /** Postal place name */
98
+ readonly k_postal_place: string;
99
+ /** 4-digit municipality ID */
100
+ readonly k_id: string;
101
+ }
102
+ /**
103
+ * Search options for postal codes
104
+ */
105
+ export interface PostalCodeSearchOptions {
106
+ /** Case sensitive search */
107
+ readonly caseSensitive?: boolean;
108
+ /** Exact match only */
109
+ readonly exactMatch?: boolean;
110
+ }
111
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,207 @@
1
+ import type { Municipality, County, PostalCode, PopulationDensityStats, LanguageStatus, MunicipalitySearchOptions, MunicipalityFilterOptions, PostalCodeSearchOptions } from './types';
2
+ /**
3
+ * Get the library version following semantic versioning.
4
+ * @returns Version string (e.g., "1.0.0")
5
+ */
6
+ export declare function getVersion(): string;
7
+ /**
8
+ * Get all municipalities with metadata.
9
+ * @returns Array of all municipalities
10
+ */
11
+ export declare function getMunicipalities(): readonly Municipality[];
12
+ /**
13
+ * Get a municipality by municipality ID.
14
+ * @param id - 4-digit municipality ID (e.g., "0301" for Oslo)
15
+ * @returns Municipality object or undefined if not found
16
+ * @throws {TypeError} If id is not a string
17
+ */
18
+ export declare function getMunicipalityById(id: string): Municipality | undefined;
19
+ /**
20
+ * Get municipalities by name (case-insensitive partial match by default).
21
+ * @param name - Municipality name or partial name to search for
22
+ * @param options - Search options
23
+ * @returns Array of matching municipalities
24
+ * @throws {TypeError} If name is not a string
25
+ */
26
+ export declare function getMunicipalitiesByName(name: string, options?: MunicipalitySearchOptions): Municipality[];
27
+ /**
28
+ * Get all counties (fylker) with metadata.
29
+ * @returns Array of all counties
30
+ */
31
+ export declare function getCounties(): readonly County[];
32
+ /**
33
+ * Get a county by county ID.
34
+ * @param id - 2-digit county ID (e.g., "03" for Oslo)
35
+ * @returns County object or undefined if not found
36
+ * @throws {TypeError} If id is not a string
37
+ */
38
+ export declare function getCountyById(id: string): County | undefined;
39
+ /**
40
+ * Get county by name (case-insensitive partial match).
41
+ * @param name - County name or partial name to search for
42
+ * @param exactMatch - Whether to match exactly (default: false)
43
+ * @returns County object or undefined if not found
44
+ * @throws {TypeError} If name is not a string
45
+ */
46
+ export declare function getCountyByName(name: string, exactMatch?: boolean): County | undefined;
47
+ /**
48
+ * Get all municipalities in a given county.
49
+ * @param countyId - 2-digit county ID (first two digits of municipality k_id)
50
+ * @returns Array of municipalities in the county
51
+ * @throws {TypeError} If countyId is not a string
52
+ */
53
+ export declare function getMunicipalitiesByCounty(countyId: string): Municipality[];
54
+ /**
55
+ * Get municipality by postal code.
56
+ * @param postalCode - Postal code to search for
57
+ * @returns Municipality object or undefined if not found
58
+ * @throws {TypeError} If postal code is not a valid number
59
+ */
60
+ export declare function getMunicipalityByPostalCode(postalCode: string | number): Municipality | undefined;
61
+ /**
62
+ * Get all postal codes for a specific municipality.
63
+ * @param municipalityId - 4-digit municipality ID
64
+ * @returns Array of postal codes or undefined if municipality not found
65
+ */
66
+ export declare function getPostalCodesByMunicipality(municipalityId: string): readonly string[] | undefined;
67
+ /**
68
+ * Get all postal codes from all municipalities.
69
+ * @param includeDetails - If true, returns objects with postal code and place name. If false, returns only postal codes (default: false)
70
+ * @returns Array of postal codes or postal code objects
71
+ */
72
+ export declare function getAllPostalCodes(includeDetails?: boolean): readonly string[] | readonly {
73
+ zip: string;
74
+ place: string;
75
+ municipalityId: string;
76
+ municipalityName: string;
77
+ }[];
78
+ /**
79
+ * Get municipalities sorted by population.
80
+ * @param ascending - Sort in ascending order if true (default: false for descending)
81
+ * @returns Array of municipalities sorted by population
82
+ */
83
+ export declare function getMunicipalitiesByPopulation(ascending?: boolean): Municipality[];
84
+ /**
85
+ * Get municipalities sorted by area.
86
+ * @param ascending - Sort in ascending order if true (default: false for descending)
87
+ * @returns Array of municipalities sorted by area
88
+ */
89
+ export declare function getMunicipalitiesByArea(ascending?: boolean): Municipality[];
90
+ /**
91
+ * Get municipalities by language status.
92
+ * @param language - Language status
93
+ * @returns Array of municipalities with the specified language status
94
+ * @throws {TypeError} If language is not a string
95
+ */
96
+ export declare function getMunicipalitiesByLanguage(language: LanguageStatus): Municipality[];
97
+ /**
98
+ * Get municipalities with advanced filtering options.
99
+ * @param options - Filter options
100
+ * @returns Array of municipalities matching the filter criteria
101
+ */
102
+ export declare function getMunicipalitiesFiltered(options: MunicipalityFilterOptions): Municipality[];
103
+ /**
104
+ * Get total population of all municipalities.
105
+ * @returns Total population
106
+ */
107
+ export declare function getTotalPopulation(): number;
108
+ /**
109
+ * Get total area of all municipalities.
110
+ * @returns Total area in square kilometers
111
+ */
112
+ export declare function getTotalArea(): number;
113
+ /**
114
+ * Get population density statistics.
115
+ * @returns Object with min, max, and average population density
116
+ */
117
+ export declare function getPopulationDensityStats(): PopulationDensityStats;
118
+ /**
119
+ * Get municipalities by population density range.
120
+ * @param minDensity - Minimum population density (people per km²)
121
+ * @param maxDensity - Maximum population density (people per km²)
122
+ * @returns Array of municipalities within the density range
123
+ */
124
+ export declare function getMunicipalitiesByPopulationDensity(minDensity?: number, maxDensity?: number): Municipality[];
125
+ /**
126
+ * Get the largest municipalities by population.
127
+ * @param count - Number of municipalities to return (default: 10)
128
+ * @returns Array of largest municipalities by population
129
+ */
130
+ export declare function getLargestMunicipalities(count?: number): Municipality[];
131
+ /**
132
+ * Get the smallest municipalities by population.
133
+ * @param count - Number of municipalities to return (default: 10)
134
+ * @returns Array of smallest municipalities by population
135
+ */
136
+ export declare function getSmallestMunicipalities(count?: number): Municipality[];
137
+ /**
138
+ * Get all postal codes with metadata.
139
+ * @returns Array of all postal codes
140
+ */
141
+ export declare function getPostalCodes(): readonly PostalCode[];
142
+ /**
143
+ * Get postal code information by postal code.
144
+ * @param code - 4-digit postal code (e.g., "0001")
145
+ * @returns PostalCode object or undefined if not found
146
+ * @throws {TypeError} If code is not a string
147
+ */
148
+ export declare function getPostalCodeByCode(code: string): PostalCode | undefined;
149
+ /**
150
+ * Get postal codes by postal place (case-insensitive partial match by default).
151
+ * @param place - Postal place name or partial name to search for
152
+ * @param options - Search options
153
+ * @returns Array of matching postal codes
154
+ * @throws {TypeError} If place is not a string
155
+ */
156
+ export declare function getPostalCodesByPlace(place: string, options?: PostalCodeSearchOptions): PostalCode[];
157
+ /**
158
+ * Get postal codes by municipality ID.
159
+ * @param municipalityId - 4-digit municipality ID (e.g., "0301" for Oslo)
160
+ * @returns Array of postal codes for the municipality
161
+ * @throws {TypeError} If municipalityId is not a string
162
+ */
163
+ export declare function getPostalCodesByMunicipalityId(municipalityId: string): PostalCode[];
164
+ /**
165
+ * Get unique postal places.
166
+ * @returns Array of unique postal place names sorted alphabetically
167
+ */
168
+ export declare function getUniquePostalPlaces(): readonly string[];
169
+ /**
170
+ * Get postal codes within a range.
171
+ * @param startCode - Starting postal code (inclusive)
172
+ * @param endCode - Ending postal code (inclusive)
173
+ * @returns Array of postal codes within the range
174
+ * @throws {TypeError} If start or end codes are not strings
175
+ */
176
+ export declare function getPostalCodesInRange(startCode: string, endCode: string): PostalCode[];
177
+ /**
178
+ * Get postal codes statistics.
179
+ * @returns Object with total count and unique places count
180
+ */
181
+ export declare function getPostalCodesStats(): {
182
+ readonly totalPostalCodes: number;
183
+ readonly uniquePlaces: number;
184
+ readonly uniqueMunicipalities: number;
185
+ };
186
+ /**
187
+ * Get postal codes sorted by code.
188
+ * @param ascending - Sort in ascending order if true (default: true)
189
+ * @returns Array of postal codes sorted by postal code
190
+ */
191
+ export declare function getPostalCodesSorted(ascending?: boolean): PostalCode[];
192
+ /**
193
+ * Check if a postal code exists.
194
+ * @param code - 4-digit postal code to check
195
+ * @returns True if postal code exists, false otherwise
196
+ */
197
+ export declare function isValidPostalCode(code: string): boolean;
198
+ /**
199
+ * Get postal codes by municipality name.
200
+ * Note: This function combines data from municipalities and postal codes.
201
+ * @param municipalityName - Municipality name to search for
202
+ * @param exactMatch - Whether to match exactly (default: false)
203
+ * @returns Array of postal codes for municipalities matching the name
204
+ */
205
+ export declare function getPostalCodesByMunicipalityName(municipalityName: string, exactMatch?: boolean): PostalCode[];
206
+ export type { Municipality, County, PostalCode, PopulationDensityStats, LanguageStatus, MunicipalitySearchOptions, MunicipalityFilterOptions, PostalCodeSearchOptions };
207
+ //# sourceMappingURL=index.d.ts.map