vin-origin-decoder 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/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # vin-origin-decoder
2
+
3
+ Decode vehicle manufacturing origin from a VIN.
4
+
5
+ ## Installation
6
+ npm install vin-origin-decoder
7
+
8
+ ## Usage
9
+ ```ts
10
+ import { decodeVinOrigin } from 'vin-origin-decoder';
11
+
12
+ decodeVinOrigin('WF0MXXGBWM8R43240');
@@ -0,0 +1,2 @@
1
+ import { VinOriginResult } from './types';
2
+ export declare function decodeVinOrigin(vin: string): VinOriginResult;
package/dist/decode.js ADDED
@@ -0,0 +1,19 @@
1
+ import { WMI_MAP } from './wmi-map';
2
+ import { VIN_REGION_MAP } from './vin-region';
3
+ export function decodeVinOrigin(vin) {
4
+ if (!vin || vin.length < 3) {
5
+ throw new Error('Invalid VIN supplied');
6
+ }
7
+ const normalizedVin = vin.toUpperCase();
8
+ const wmi = normalizedVin.substring(0, 3);
9
+ const region = VIN_REGION_MAP[normalizedVin[0]] ?? 'Unknown';
10
+ const knownWmi = WMI_MAP[wmi];
11
+ return {
12
+ vin: normalizedVin,
13
+ wmi,
14
+ manufacturer: knownWmi?.manufacturer ?? 'Unknown',
15
+ country: knownWmi?.country ?? 'Unknown',
16
+ region,
17
+ confidence: knownWmi ? 'high' : region !== 'Unknown' ? 'medium' : 'low',
18
+ };
19
+ }
@@ -0,0 +1,2 @@
1
+ export { decodeVinOrigin } from './decode';
2
+ export type { VinOriginResult } from './types';
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ // export function decodeVinOrigin(vin: string) {
2
+ // if (!vin || vin.length < 3) {
3
+ // throw new Error('Invalid VIN');
4
+ // }
5
+ // const wmi = vin.substring(0, 3).toUpperCase();
6
+ // const data = WMI_MAP[wmi];
7
+ // return {
8
+ // vin,
9
+ // wmi,
10
+ // manufacturer: data?.manufacturer || 'Unknown',
11
+ // country: data?.country || 'Unknown',
12
+ // };
13
+ // }
14
+ export { decodeVinOrigin } from './decode';
@@ -0,0 +1,8 @@
1
+ export interface VinOriginResult {
2
+ vin: string;
3
+ wmi: string;
4
+ manufacturer: string;
5
+ country: string;
6
+ region: string;
7
+ confidence: 'high' | 'medium' | 'low';
8
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const VIN_REGION_MAP: Record<string, string>;
@@ -0,0 +1,13 @@
1
+ export const VIN_REGION_MAP = {
2
+ A: 'Africa', B: 'Africa', C: 'Africa', D: 'Africa',
3
+ E: 'Africa', F: 'Africa', G: 'Africa', H: 'Africa',
4
+ J: 'Asia', K: 'Asia', L: 'Asia', M: 'Asia',
5
+ N: 'Asia', P: 'Asia', R: 'Asia',
6
+ S: 'Europe', T: 'Europe', U: 'Europe', V: 'Europe',
7
+ W: 'Europe', X: 'Europe', Y: 'Europe', Z: 'Europe',
8
+ '1': 'North America', '4': 'North America', '5': 'North America',
9
+ '2': 'Canada',
10
+ '3': 'Mexico',
11
+ '6': 'Oceania', '7': 'Oceania',
12
+ '8': 'South America', '9': 'South America',
13
+ };
@@ -0,0 +1,4 @@
1
+ export declare const WMI_MAP: Record<string, {
2
+ manufacturer: string;
3
+ country: string;
4
+ }>;
@@ -0,0 +1,27 @@
1
+ export const WMI_MAP = {
2
+ // Ford
3
+ WF0: { manufacturer: 'Ford', country: 'Germany' },
4
+ '1FA': { manufacturer: 'Ford', country: 'USA' }, // ← Quote this
5
+ '3FA': { manufacturer: 'Ford', country: 'Mexico' }, // ← Quote this
6
+ AFM: { manufacturer: 'Ford', country: 'South Africa' },
7
+ // BMW
8
+ WBA: { manufacturer: 'BMW', country: 'Germany' },
9
+ '5UX': { manufacturer: 'BMW', country: 'USA' }, // ← Quote this
10
+ // Mercedes-Benz
11
+ WDB: { manufacturer: 'Mercedes-Benz', country: 'Germany' },
12
+ WDC: { manufacturer: 'Mercedes-Benz', country: 'Germany' },
13
+ // Toyota
14
+ JT2: { manufacturer: 'Toyota', country: 'Japan' },
15
+ JTD: { manufacturer: 'Toyota', country: 'Japan' },
16
+ '4T1': { manufacturer: 'Toyota', country: 'USA' }, // ← Quote this
17
+ // Honda
18
+ JHM: { manufacturer: 'Honda', country: 'Japan' },
19
+ '1HG': { manufacturer: 'Honda', country: 'USA' }, // ← Quote this
20
+ // VW Group
21
+ WVW: { manufacturer: 'Volkswagen', country: 'Germany' },
22
+ WAU: { manufacturer: 'Audi', country: 'Germany' },
23
+ // Stellantis
24
+ ZFA: { manufacturer: 'Fiat', country: 'Italy' },
25
+ VF1: { manufacturer: 'Renault', country: 'France' },
26
+ SAL: { manufacturer: 'Land Rover', country: 'United Kingdom' },
27
+ };
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "vin-origin-decoder",
3
+ "version": "1.0.0",
4
+ "description": "Decode vehicle origin and manufacturer from VIN",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.cjs"
11
+ }
12
+ },
13
+ "scripts": {
14
+ "build": "tsc"
15
+ },
16
+ "keywords": [
17
+ "vin",
18
+ "vehicle",
19
+ "car",
20
+ "decoder",
21
+ "origin"
22
+ ],
23
+ "author": "Ngoni Seremwe",
24
+ "license": "MIT",
25
+ "devDependencies": {
26
+ "typescript": "^5.9.3"
27
+ }
28
+ }
package/src/decode.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { WMI_MAP } from './wmi-map';
2
+ import { VIN_REGION_MAP } from './vin-region';
3
+ import { VinOriginResult } from './types';
4
+
5
+ export function decodeVinOrigin(vin: string): VinOriginResult {
6
+ if (!vin || vin.length < 3) {
7
+ throw new Error('Invalid VIN supplied');
8
+ }
9
+
10
+ const normalizedVin = vin.toUpperCase();
11
+ const wmi = normalizedVin.substring(0, 3);
12
+ const region = VIN_REGION_MAP[normalizedVin[0]] ?? 'Unknown';
13
+
14
+ const knownWmi = WMI_MAP[wmi];
15
+
16
+ return {
17
+ vin: normalizedVin,
18
+ wmi,
19
+ manufacturer: knownWmi?.manufacturer ?? 'Unknown',
20
+ country: knownWmi?.country ?? 'Unknown',
21
+ region,
22
+ confidence: knownWmi ? 'high' : region !== 'Unknown' ? 'medium' : 'low',
23
+ };
24
+ }
package/src/index.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { WMI_MAP } from './wmi-map';
2
+
3
+ // export function decodeVinOrigin(vin: string) {
4
+ // if (!vin || vin.length < 3) {
5
+ // throw new Error('Invalid VIN');
6
+ // }
7
+
8
+ // const wmi = vin.substring(0, 3).toUpperCase();
9
+ // const data = WMI_MAP[wmi];
10
+
11
+ // return {
12
+ // vin,
13
+ // wmi,
14
+ // manufacturer: data?.manufacturer || 'Unknown',
15
+ // country: data?.country || 'Unknown',
16
+ // };
17
+ // }
18
+ export { decodeVinOrigin } from './decode';
19
+ export type { VinOriginResult } from './types';
package/src/types.ts ADDED
@@ -0,0 +1,8 @@
1
+ export interface VinOriginResult {
2
+ vin: string;
3
+ wmi: string;
4
+ manufacturer: string;
5
+ country: string;
6
+ region: string;
7
+ confidence: 'high' | 'medium' | 'low';
8
+ }
@@ -0,0 +1,18 @@
1
+ export const VIN_REGION_MAP: Record<string, string> = {
2
+ A: 'Africa', B: 'Africa', C: 'Africa', D: 'Africa',
3
+ E: 'Africa', F: 'Africa', G: 'Africa', H: 'Africa',
4
+
5
+ J: 'Asia', K: 'Asia', L: 'Asia', M: 'Asia',
6
+ N: 'Asia', P: 'Asia', R: 'Asia',
7
+
8
+ S: 'Europe', T: 'Europe', U: 'Europe', V: 'Europe',
9
+ W: 'Europe', X: 'Europe', Y: 'Europe', Z: 'Europe',
10
+
11
+ '1': 'North America', '4': 'North America', '5': 'North America',
12
+ '2': 'Canada',
13
+ '3': 'Mexico',
14
+
15
+ '6': 'Oceania', '7': 'Oceania',
16
+
17
+ '8': 'South America', '9': 'South America',
18
+ };
package/src/wmi-map.ts ADDED
@@ -0,0 +1,36 @@
1
+ export const WMI_MAP: Record<string, {
2
+ manufacturer: string;
3
+ country: string;
4
+ }> = {
5
+ // Ford
6
+ WF0: { manufacturer: 'Ford', country: 'Germany' },
7
+ '1FA': { manufacturer: 'Ford', country: 'USA' }, // ← Quote this
8
+ '3FA': { manufacturer: 'Ford', country: 'Mexico' }, // ← Quote this
9
+ AFM: { manufacturer: 'Ford', country: 'South Africa' },
10
+
11
+ // BMW
12
+ WBA: { manufacturer: 'BMW', country: 'Germany' },
13
+ '5UX': { manufacturer: 'BMW', country: 'USA' }, // ← Quote this
14
+
15
+ // Mercedes-Benz
16
+ WDB: { manufacturer: 'Mercedes-Benz', country: 'Germany' },
17
+ WDC: { manufacturer: 'Mercedes-Benz', country: 'Germany' },
18
+
19
+ // Toyota
20
+ JT2: { manufacturer: 'Toyota', country: 'Japan' },
21
+ JTD: { manufacturer: 'Toyota', country: 'Japan' },
22
+ '4T1': { manufacturer: 'Toyota', country: 'USA' }, // ← Quote this
23
+
24
+ // Honda
25
+ JHM: { manufacturer: 'Honda', country: 'Japan' },
26
+ '1HG': { manufacturer: 'Honda', country: 'USA' }, // ← Quote this
27
+
28
+ // VW Group
29
+ WVW: { manufacturer: 'Volkswagen', country: 'Germany' },
30
+ WAU: { manufacturer: 'Audi', country: 'Germany' },
31
+
32
+ // Stellantis
33
+ ZFA: { manufacturer: 'Fiat', country: 'Italy' },
34
+ VF1: { manufacturer: 'Renault', country: 'France' },
35
+ SAL: { manufacturer: 'Land Rover', country: 'United Kingdom' },
36
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "declaration": true,
6
+ "outDir": "dist",
7
+ "strict": true,
8
+ "moduleResolution": "node",
9
+ "esModuleInterop": true
10
+ },
11
+ "include": ["src"]
12
+ }