@meterapp/vehicle-db 2.3.0 → 2.5.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/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @meterapp/vehicle-db
2
2
 
3
- Offline NHTSA vehicle database plus Meter-owned auto-rickshaw and global market passenger fleet entries. All U.S. vehicle makes and models from 1990–2026, plus Atul Auto rickshaws and common global vans, MPVs, minibuses, sedans, SUVs, and EVs. Zero dependencies, ~190 KB on npm. No network requests needed.
3
+ An offline, international vehicle make/model catalog for Node.js and TypeScript. The package combines U.S. model-year data, the UK registered fleet, Asian-origin vehicles registered in New Zealand, Malaysian registration transactions, and an Indian manufacturer catalog into one small, zero-dependency API. It never makes runtime network requests.
4
4
 
5
- Covers four vehicle types: **Passenger Car**, **Truck**, **Multipurpose Passenger Vehicle (MPV)**, and **Auto Rickshaw**.
5
+ The catalog covers seven vehicle types: **Motorcycle**, **Passenger Car**, **Truck**, **Bus**, **Multipurpose Passenger Vehicle (MPV)**, **Auto Rickshaw**, and **Other Vehicle**. The Asia-Pacific sources add Japanese domestic and kei models, Chinese EVs, Indian and Korean vehicles, Southeast Asian makes such as Perodua and Proton, and additional motorcycles and commercial vehicles.
6
6
 
7
7
  ## Install
8
8
 
@@ -10,152 +10,208 @@ Covers four vehicle types: **Passenger Car**, **Truck**, **Multipurpose Passenge
10
10
  npm install @meterapp/vehicle-db
11
11
  ```
12
12
 
13
- > Requires Node.js 18+. Zero runtime dependencies — data is bundled as JSON.
13
+ Requires Node.js 18 or newer.
14
14
 
15
15
  ## Usage
16
16
 
17
17
  ```typescript
18
18
  import {
19
+ getDataSources,
19
20
  getVehicleTypes,
20
21
  getMakes,
21
22
  getModels,
22
23
  getAvailableYears,
23
- close,
24
24
  } from "@meterapp/vehicle-db";
25
25
 
26
- // List available vehicle types
26
+ // Inspect provenance and coverage before querying.
27
+ const sources = getDataSources();
28
+
29
+ // All seven categories, including Motorcycle (1) and Bus (5).
27
30
  const types = getVehicleTypes();
28
- // => [
29
- // { vehicleTypeId: 2, vehicleTypeName: "Passenger Car" },
30
- // { vehicleTypeId: 3, vehicleTypeName: "Truck" },
31
- // { vehicleTypeId: 7, vehicleTypeName: "Multipurpose Passenger Vehicle (MPV)" },
32
- // { vehicleTypeId: 10001, vehicleTypeName: "Auto Rickshaw" },
33
- // ]
34
-
35
- // Get all makes
36
- const allMakes = getMakes();
37
-
38
- // Get makes that have models in 2024
39
- const makes2024 = getMakes({ year: 2024 });
40
-
41
- // Get only truck makes for 2024
42
- const truckMakes = getMakes({ year: 2024, vehicleTypeId: 3 });
43
-
44
- // Get all Toyota models for 2024
45
- const toyotaModels = getModels({ makeId: 474, year: 2024 });
46
- // => [
47
- // { modelId: 2469, modelName: "Camry", makeId: 474, makeName: "TOYOTA", vehicleTypeId: 2, vehicleTypeName: "Passenger Car" },
48
- // { modelId: 2208, modelName: "Corolla", ... },
49
- // ...
50
- // ]
51
-
52
- // Get only Ford trucks for 2024
53
- const fordTrucks = getModels({ makeId: 460, year: 2024, vehicleTypeId: 3 });
54
- // => [{ modelId: 1801, modelName: "F-150", ... }, ...]
55
-
56
- // Get Atul auto-rickshaw models for 2024
57
- const atulRickshaws = getModels({ makeId: 100001, year: 2024, vehicleTypeId: 10001 });
58
- // => [{ modelId: 100001, modelName: "RIK", makeName: "ATUL AUTO", vehicleTypeName: "Auto Rickshaw", ... }, ...]
59
-
60
- // Get all available years
61
- const years = getAvailableYears();
62
- // => [1990, 1991, ..., 2026]
63
31
 
64
- // Optional: close the DB connection when you're done
65
- close();
32
+ // All makes with a 2024 motorcycle in the international UK fleet source.
33
+ const motorcycleMakes = getMakes({
34
+ year: 2024,
35
+ vehicleTypeId: 1,
36
+ sourceId: "uk-dft-vehicle-licensing",
37
+ });
38
+
39
+ // Honda motorcycle models manufactured in 2024.
40
+ const honda = motorcycleMakes.find((make) => make.makeName === "HONDA");
41
+ const hondaMotorcycles = getModels({
42
+ makeId: honda!.makeId,
43
+ year: 2024,
44
+ vehicleTypeId: 1,
45
+ sourceId: "uk-dft-vehicle-licensing",
46
+ });
47
+
48
+ // Coach and transit bus makes/models use vehicle type 5.
49
+ const busMakes = getMakes({ year: 2024, vehicleTypeId: 5 });
50
+ const alexanderDennis = busMakes.find((make) => make.makeName === "ALEXANDER DENNIS");
51
+ const buses = getModels({
52
+ makeId: alexanderDennis!.makeId,
53
+ year: 2024,
54
+ vehicleTypeId: 5,
55
+ });
56
+
57
+ // Japanese domestic and kei models from the Asian-origin NZTA slice.
58
+ const nztaAsiaMakes = getMakes({
59
+ year: 2022,
60
+ sourceId: "nzta-asia-pacific-mvr",
61
+ });
62
+ const hondaAsia = nztaAsiaMakes.find((make) => make.makeName === "HONDA");
63
+ const hondaAsiaModels = getModels({
64
+ makeId: hondaAsia!.makeId,
65
+ year: 2022,
66
+ sourceId: "nzta-asia-pacific-mvr",
67
+ }); // Includes N-BOX.
68
+
69
+ // Southeast Asian market models such as Perodua Myvi and Proton S70.
70
+ const malaysiaMakes = getMakes({
71
+ year: 2026,
72
+ sourceId: "malaysia-jpj-registrations",
73
+ });
74
+
75
+ // Existing queries remain valid.
76
+ const toyota = getMakes({ year: 2024 }).find((make) => make.makeName === "TOYOTA");
77
+ const toyotaModels = getModels({ makeId: toyota!.makeId, year: 2024 });
78
+ const years = getAvailableYears();
66
79
  ```
67
80
 
68
81
  ## API
69
82
 
83
+ ### `getDataSources(): DataSource[]`
84
+
85
+ Returns the provenance, license, region, retrieval date, year range, vehicle types, and record counts for every source.
86
+
87
+ ```typescript
88
+ interface DataSource {
89
+ sourceId: string;
90
+ sourceName: string;
91
+ sourceUrl: string;
92
+ license: string;
93
+ licenseUrl?: string;
94
+ region: string;
95
+ description: string;
96
+ retrievedAt: string;
97
+ vehicleTypeIds: number[];
98
+ yearFrom: number;
99
+ yearTo: number;
100
+ makeCount: number;
101
+ modelCount: number;
102
+ }
103
+ ```
104
+
70
105
  ### `getVehicleTypes(): VehicleType[]`
71
106
 
72
- Returns all vehicle types in the database.
107
+ Returns every vehicle category in the bundled catalog.
73
108
 
74
109
  ```typescript
75
110
  interface VehicleType {
76
- vehicleTypeId: number; // e.g. 2
77
- vehicleTypeName: string; // e.g. "Passenger Car"
111
+ vehicleTypeId: number;
112
+ vehicleTypeName: string;
78
113
  }
79
114
  ```
80
115
 
81
116
  ### `getMakes(options?): Make[]`
82
117
 
83
- Returns makes, optionally filtered by year and/or vehicle type.
118
+ Returns makes, optionally filtered by `year`, `vehicleTypeId`, and/or `sourceId`.
84
119
 
85
120
  ```typescript
86
- getMakes() // all makes
87
- getMakes({ year: 2024 }) // makes with models in 2024
88
- getMakes({ vehicleTypeId: 3 }) // truck makes (all years)
89
- getMakes({ year: 2024, vehicleTypeId: 3 }) // truck makes in 2024
90
- getMakes({ year: 2024, vehicleTypeId: 10001 }) // auto-rickshaw makes in 2024
121
+ getMakes();
122
+ getMakes({ year: 2024 });
123
+ getMakes({ year: 2024, vehicleTypeId: 5 });
124
+ getMakes({ sourceId: "uk-dft-vehicle-licensing" });
91
125
  ```
92
126
 
93
127
  ```typescript
94
128
  interface Make {
95
- makeId: number; // e.g. 460
96
- makeName: string; // e.g. "FORD"
129
+ makeId: number;
130
+ makeName: string;
97
131
  }
98
132
  ```
99
133
 
100
134
  ### `getModels(options?): Model[]`
101
135
 
102
- Returns models, optionally filtered by year, vehicle type, and/or make.
136
+ Returns models, optionally filtered by `year`, `vehicleTypeId`, `makeId`, and/or `sourceId`. `sourceIds` preserves provenance when equivalent records appear in more than one source.
103
137
 
104
138
  ```typescript
105
- getModels({ makeId: 474, year: 2024 }) // Toyota 2024 (all types)
106
- getModels({ makeId: 460, year: 2024, vehicleTypeId: 3 }) // Ford trucks 2024
107
- getModels({ makeId: 100001, year: 2024, vehicleTypeId: 10001 }) // Atul auto-rickshaws 2024
108
- getModels({ vehicleTypeId: 3 }) // all trucks (all years)
109
- getModels({ year: 2024 }) // everything in 2024
139
+ getModels({ makeId: 474, year: 2024 });
140
+ getModels({ year: 2024, vehicleTypeId: 1 });
141
+ getModels({ year: 2024, vehicleTypeId: 5, sourceId: "uk-dft-vehicle-licensing" });
110
142
  ```
111
143
 
112
144
  ```typescript
113
145
  interface Model {
114
- modelId: number; // e.g. 1801
115
- modelName: string; // e.g. "F-150"
116
- makeId: number; // e.g. 460
117
- makeName: string; // e.g. "FORD"
118
- vehicleTypeId: number; // e.g. 3
119
- vehicleTypeName: string; // e.g. "Truck"
146
+ modelId: number;
147
+ modelName: string;
148
+ makeId: number;
149
+ makeName: string;
150
+ vehicleTypeId: number;
151
+ vehicleTypeName: string;
152
+ sourceIds: string[];
120
153
  }
121
154
  ```
122
155
 
123
156
  ### `getAvailableYears(): number[]`
124
157
 
125
- Returns all years present in the database, sorted ascending.
158
+ Returns all years present in the combined catalog, sorted ascending.
159
+
160
+ ## Data sources
161
+
162
+ | Source | Coverage in this snapshot | Terms |
163
+ |---|---|---|
164
+ | [NHTSA vPIC](https://vpic.nhtsa.dot.gov/api/) | U.S. passenger cars, trucks, and MPVs; model years 1990–2026 | U.S. government public data |
165
+ | [UK DfT/DVLA vehicle licensing statistics](https://www.gov.uk/government/statistical-data-sets/vehicle-licensing-statistics-data-files) | 701 normalized makes across cars, motorcycles, goods vehicles, buses and coaches, and other vehicles; manufacture years 1990–2025 | [Open Government Licence v3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/) |
166
+ | [Atul Auto product catalog](https://atulauto.co.in/products/) | Current Indian passenger and cargo auto-rickshaw range; catalog years 2024–2026 | Source attribution; factual product names only |
167
+ | [NZTA Motor Vehicle Register](https://www.nzta.govt.nz/resources/new-zealand-motor-vehicle-register-statistics/new-zealand-vehicle-fleet-open-data-sets) | 30,374 Asian-origin car, truck, bus, motorcycle, and moped model-year records from 12 countries of origin; vehicle years 1990–2026 | [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) |
168
+ | [Malaysia JPJ registration transactions](https://data.gov.my/data-catalogue/registration_transactions_car) | 1,756 passenger car, MPV, jeep, pickup, and window-van model/registration-year records; 2024–2026 | [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) |
169
+
170
+ Year means the source’s model year for NHTSA, year of manufacture for DfT/DVLA (falling back to year of first use when manufacture year is unavailable), catalog year for Atul Auto, vehicle year for NZTA, and registration year for Malaysia JPJ. From 2007 onward, NZTA vehicle year means the year of first registration in New Zealand or overseas. Registration sources are evidence that a make/model was present in that market and do not guarantee a factory model-year designation. Source filters let applications choose the semantics appropriate for their workflow.
171
+
172
+ UK source attribution: Contains public sector information licensed under the Open Government Licence v3.0. Source: Department for Transport and Driver and Vehicle Licensing Agency.
173
+
174
+ NZTA and Malaysia source attribution: Licensed under Creative Commons Attribution 4.0 International. Sources: New Zealand Transport Agency Waka Kotahi and Malaysia Road Transport Department/data.gov.my.
126
175
 
127
- ### `close(): void`
176
+ ## Factory colors
128
177
 
129
- Closes the SQLite connection. Safe to call multiple times. The connection reopens automatically on the next query.
178
+ Factory paint availability is not included. The NZTA and Malaysia records contain the observed basic color of each registered vehicle, not the manufacturer’s stock colors for a make/model/year. Treating those fields as factory availability would produce false positives from repaints, imports, and broad color categories, so the importers intentionally omit them. A future color API should require manufacturer-backed paint options with explicit market and model-year provenance.
130
179
 
131
- ## Database stats
180
+ ## Snapshot stats
132
181
 
133
182
  | | |
134
- |---|---|
135
- | **Years** | 1990 – 2026 |
136
- | **Vehicle types** | 4 (Passenger Car, Truck, MPV, Auto Rickshaw) |
137
- | **Makes** | 409 |
138
- | **Model entries** | 55,589 |
139
- | **Data file** | 1.3 MB (JSON) |
140
- | **npm package** | 190 KB |
141
- | **npm package size** | 1.5 MB |
183
+ |---|---:|
184
+ | Years | 1990–2026 |
185
+ | Sources | 5 |
186
+ | Vehicle types | 7 |
187
+ | Makes | 1,145 |
188
+ | Model names | 14,841 |
189
+ | Deduplicated model-year entries | 132,491 |
190
+ | Bundled TypeScript data | 4.21 MB |
142
191
 
143
- ## Rebuilding the database
192
+ ## Refreshing and rebuilding
144
193
 
145
- To refresh the data from the NHTSA API:
194
+ The committed source snapshots make the package build deterministic and offline:
146
195
 
147
196
  ```bash
148
- npm run build:db
197
+ npm run build:data
198
+ npm test
199
+ npm run typecheck
200
+ npm run build
149
201
  ```
150
202
 
151
- Or for a specific year range:
203
+ Refresh either network source independently, then rebuild the combined catalog:
152
204
 
153
205
  ```bash
154
- npm run build:db -- --start-year 2020 --end-year 2026
206
+ npm run refresh:uk-dft
207
+ npm run refresh:nhtsa -- --start-year 1990 --end-year 2026
208
+ npm run refresh:nzta-asia-pacific -- --start-year 1990 --end-year 2026
209
+ npm run refresh:malaysia-jpj -- --start-year 2024 --end-year 2026
210
+ npm run build:data
155
211
  ```
156
212
 
157
- > The NHTSA API rate-limits aggressively. The build script retries failed requests, but some obscure makes may be skipped. Major manufacturers (Toyota, Honda, Ford, BMW, etc.) are always fetched successfully.
213
+ The NHTSA API rate-limits aggressively, so a full NHTSA refresh can take time. The UK importer downloads the two official VEH0124 CSV files. The NZTA importer discovers the current official ArcGIS service and requests distinct records for supported vehicle types and Asian countries of origin. The Malaysia importer downloads annual JPJ CSVs and aggregates individual transactions into unique model/registration-year records. Importers assign deterministic numeric IDs, write normalized snapshots, and discard temporary raw downloads.
158
214
 
159
215
  ## License
160
216
 
161
- ISC
217
+ The package code is ISC licensed. Upstream data remains subject to the terms listed above.
package/dist/data.d.ts CHANGED
@@ -1,4 +1,19 @@
1
1
  interface CompactData {
2
+ sources: {
3
+ source_id: string;
4
+ source_name: string;
5
+ source_url: string;
6
+ license: string;
7
+ license_url?: string;
8
+ region: string;
9
+ description: string;
10
+ retrieved_at: string;
11
+ vehicle_type_ids: number[];
12
+ year_from: number;
13
+ year_to: number;
14
+ make_count: number;
15
+ model_count: number;
16
+ }[];
2
17
  vehicleTypes: {
3
18
  vehicle_type_id: number;
4
19
  vehicle_type_name: string;
@@ -8,7 +23,7 @@ interface CompactData {
8
23
  make_name: string;
9
24
  }[];
10
25
  modelNames: string[];
11
- models: [number, number, number, number, number][];
26
+ models: [number, number, number, number, number, number][];
12
27
  }
13
28
  declare const data: CompactData;
14
29
  export default data;