@meterapp/vehicle-db 2.6.0 → 2.7.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
@@ -8,7 +8,9 @@ The catalog covers seven vehicle types: **Motorcycle**, **Passenger Car**, **Tru
8
8
 
9
9
  ## Demo and playground
10
10
 
11
- Want to see the API in action? Browse [Car Images](https://car-imgs.vercel.app), an example app built with this package, or explore the data directly in the [interactive playground](https://car-imgs.vercel.app/playground).
11
+ This catalog is the backbone of the [Car Image API](https://car-imgs.vercel.app) — an AI-native API that renders studio-quality, transparent-background images of every vehicle listed here (six camera angles, 15 colors, PNG/WebP/JPG, $1 per 1,000 images). Explore the data in the [interactive playground](https://car-imgs.vercel.app/playground) or browse vehicles at [car-imgs.vercel.app/cars](https://car-imgs.vercel.app/cars).
12
+
13
+ **Missing a vehicle?** Add it here and it becomes renderable in the API on the next release — see [CONTRIBUTING.md](CONTRIBUTING.md).
12
14
 
13
15
  ## Install
14
16
 
@@ -27,6 +29,10 @@ import {
27
29
  getMakes,
28
30
  getModels,
29
31
  getAvailableYears,
32
+ getAvailableYearRanges,
33
+ getModelAppearanceRanges,
34
+ getModelRenderGroups,
35
+ getRepresentativeYear,
30
36
  } from "@meterapp/vehicle-db";
31
37
 
32
38
  // Inspect provenance and coverage before querying.
@@ -86,6 +92,55 @@ const years = getAvailableYears({
86
92
  vehicleTypeId: 2,
87
93
  sourceId: "nhtsa-vpic",
88
94
  });
95
+
96
+ // Availability and exterior equivalence are intentionally separate.
97
+ const availability = getAvailableYearRanges({ makeId: toyota!.makeId });
98
+ const arteonAppearances = getModelAppearanceRanges({
99
+ makeId: getMakes().find((make) => make.makeName === "VOLKSWAGEN")!.makeId,
100
+ modelName: "Arteon",
101
+ });
102
+
103
+ // Safe cache identity: verified ranges share a representative year; unknown
104
+ // and overlapping transition years return the requested year unchanged.
105
+ const renderYear = getRepresentativeYear({
106
+ makeId: arteonAppearances[0].makeId,
107
+ modelName: "Arteon",
108
+ year: 2018,
109
+ }); // 2019
110
+ ```
111
+
112
+ ## Appearance ranges and image reuse
113
+
114
+ A model being available in consecutive years does **not** prove that its exterior stayed the
115
+ same. `getAvailableYearRanges()` only compresses catalog availability for display. Sourced
116
+ generation/facelift facts live in `data/appearance-ranges.json` and are returned by
117
+ `getModelAppearanceRanges()` with their body style, market, and evidence URL.
118
+
119
+ `getModelRenderGroups()` turns those facts into a complete cache plan. It groups a year only when
120
+ exactly one verified appearance range covers it. Years with no evidence, and transition years
121
+ covered by two overlapping ranges, remain singleton exact-year groups. `getRepresentativeYear()`
122
+ is the convenience lookup for storage/cache keys and has the same fail-closed behavior.
123
+
124
+ This split is deliberate. NHTSA vPIC provides model-year and body-class data but no global
125
+ generation identifier; Wikidata is CC0 but generation and facelift coverage is sparse. Broad
126
+ third-party generation dumps commonly carry restrictive or share-alike terms and overlapping
127
+ records, so they are useful for research but are not imported automatically. Verified ranges are
128
+ small, reviewable facts linked to first-party or equivalently authoritative public evidence.
129
+
130
+ NHTSA wheelbase, dimensions, doors, series, and truck cab/bed fields can rank possible body-family
131
+ matches. They are candidate evidence only: related platforms and trims can still have visibly
132
+ different bodywork. `appearanceId` is intentionally stricter than a derived `body_family_id` and
133
+ is the only grouping allowed to drive render reuse. See CONTRIBUTING for the review criteria.
134
+
135
+ ```typescript
136
+ const volkswagen = getMakes().find((make) => make.makeName === "VOLKSWAGEN")!;
137
+
138
+ getModelAppearanceRanges({ makeId: volkswagen.makeId, modelName: "Arteon" });
139
+ // Original Arteon: 2017–2020, Fastback, with Volkswagen evidence
140
+ // Updated Arteon: 2020–2026, Fastback, with Volkswagen evidence
141
+
142
+ getModelRenderGroups({ makeId: volkswagen.makeId, modelName: "Arteon" });
143
+ // 2017–2019 share one render; overlapping 2020 stays exact; 2021–2026 share one render.
89
144
  ```
90
145
 
91
146
  ## Driver search and autocomplete
@@ -212,6 +267,17 @@ getAvailableYears({ makeId: 448, vehicleTypeId: 2, sourceId: "nhtsa-vpic" });
212
267
  getAvailableYears({ modelId: 2469, sourceId: "nhtsa-vpic" });
213
268
  ```
214
269
 
270
+ ### Appearance and year-range APIs
271
+
272
+ - `getAvailableYearRanges(options?): VehicleYearRange[]` compresses consecutive availability
273
+ years; it makes no exterior-equivalence claim.
274
+ - `getModelAppearanceRanges({ makeId, modelName, year? }): VehicleAppearanceRange[]` returns
275
+ verified generation/facelift periods and evidence. Overlap is preserved.
276
+ - `getModelRenderGroups({ makeId, modelName, vehicleTypeId?, sourceId? }): VehicleRenderGroup[]`
277
+ returns safe, non-overlapping cache groups for every available year.
278
+ - `getRepresentativeYear({ makeId, modelName, year, ... }): number` returns the canonical cache
279
+ year for an unambiguous verified group, otherwise the requested year.
280
+
215
281
  ### `searchVehicles(query, options?): VehicleSearchResult[]`
216
282
 
217
283
  Import from `@meterapp/vehicle-db/search`. Returns deterministic make and grouped model candidates for free-form input. Options include `year`, `vehicleTypeId`, `sourceId`, `limit` (default 10, maximum 100), and `fuzzy` (default `true`).
package/dist/data.d.ts CHANGED
@@ -24,6 +24,20 @@ interface CompactData {
24
24
  }[];
25
25
  modelNames: string[];
26
26
  models: [number, number, number, number, number, number][];
27
+ appearanceRanges: {
28
+ id: string;
29
+ make_id: number;
30
+ make_name: string;
31
+ model_name: string;
32
+ label: string;
33
+ body_style: string;
34
+ year_from: number;
35
+ year_to: number;
36
+ representative_year: number;
37
+ regions: string[];
38
+ source_name: string;
39
+ source_url: string;
40
+ }[];
27
41
  }
28
42
  declare const data: CompactData;
29
43
  export default data;