wenmar-open 0.1.0 → 0.3.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 +292 -2
- package/dist/batch.d.ts +5 -0
- package/dist/batch.js +7 -0
- package/dist/client.d.ts +153 -6
- package/dist/client.js +234 -7
- package/dist/errors.d.ts +21 -3
- package/dist/index.d.ts +5 -4
- package/dist/index.js +2 -1
- package/dist/offline/client.d.ts +190 -0
- package/dist/offline/client.js +482 -0
- package/dist/offline/engine.d.ts +53 -0
- package/dist/offline/engine.js +129 -0
- package/dist/offline/index.d.ts +10 -0
- package/dist/offline/index.js +4 -0
- package/dist/offline/node.d.ts +26 -0
- package/dist/offline/node.js +105 -0
- package/dist/offline/store.d.ts +78 -0
- package/dist/offline/store.js +156 -0
- package/dist/offline/wasm-inline.js +2 -0
- package/dist/offline/wenmar_open.wasm +0 -0
- package/dist/schema.d.ts +5152 -471
- package/dist/types.d.ts +124 -0
- package/package.json +30 -4
package/dist/client.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { MAX_BATCH } from "./batch.js";
|
|
1
2
|
import { WenmarOpenError, parseRetryAfter } from "./errors.js";
|
|
2
3
|
/** The hosted API. */
|
|
3
4
|
export const DEFAULT_BASE_URL = "https://open.wenmarpro.com";
|
|
4
5
|
/** How long a request may take before it fails with `timeout`. */
|
|
5
6
|
export const DEFAULT_TIMEOUT_MS = 10_000;
|
|
6
|
-
/** The most VINs the API decodes in one batch. */
|
|
7
|
-
export const MAX_BATCH = 50;
|
|
8
7
|
function queryString(query) {
|
|
9
8
|
const params = new URLSearchParams();
|
|
10
9
|
for (const [name, value] of Object.entries((query ?? {}))) {
|
|
@@ -34,10 +33,6 @@ function segment(field, value) {
|
|
|
34
33
|
function isRecord(value) {
|
|
35
34
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36
35
|
}
|
|
37
|
-
/** Whether an item of a batch is the error for its VIN and not a decode. */
|
|
38
|
-
export function isBatchError(item) {
|
|
39
|
-
return isRecord(item.error);
|
|
40
|
-
}
|
|
41
36
|
/** A client for the Wenmar Open API. It keeps no state between requests. */
|
|
42
37
|
export class WenmarOpen {
|
|
43
38
|
baseUrl;
|
|
@@ -67,7 +62,8 @@ export class WenmarOpen {
|
|
|
67
62
|
details: { field: "vins", max: MAX_BATCH, received: vins.length },
|
|
68
63
|
});
|
|
69
64
|
}
|
|
70
|
-
|
|
65
|
+
const path = `/v1/vin/batch${queryString({ include: options.include })}`;
|
|
66
|
+
return this.#request("POST", path, { vins }, options);
|
|
71
67
|
}
|
|
72
68
|
/** Model years, newest first. */
|
|
73
69
|
async years(query = {}, options = {}) {
|
|
@@ -101,6 +97,237 @@ export class WenmarOpen {
|
|
|
101
97
|
async vehicle(id, options = {}) {
|
|
102
98
|
return this.#request("GET", `/v1/vehicles/${segment("id", id)}`, undefined, options);
|
|
103
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* NHTSA's crash test ratings for a model year, by its id such as
|
|
102
|
+
* `2018_ford_f-150`. NHTSA rates by body style and drive, so `ratings`
|
|
103
|
+
* often has several entries: each names the vehicle it is for.
|
|
104
|
+
*/
|
|
105
|
+
async safety(id, options = {}) {
|
|
106
|
+
return this.#request("GET", `/v1/vehicles/${segment("id", id)}/safety`, undefined, options);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* What owners reported to NHTSA about a model year, as counts by
|
|
110
|
+
* component. These are owners' reports: not verified, and not a rate.
|
|
111
|
+
*/
|
|
112
|
+
async complaints(id, options = {}) {
|
|
113
|
+
return this.#request("GET", `/v1/vehicles/${segment("id", id)}/complaints`, undefined, options);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* One generic trouble code, such as `P0420`, described in this project's
|
|
117
|
+
* own words. A manufacturer-specific code has no description: the call
|
|
118
|
+
* fails with `not_found`.
|
|
119
|
+
*/
|
|
120
|
+
async code(code, options = {}) {
|
|
121
|
+
return this.#request("GET", `/v1/codes/${segment("code", code)}`, undefined, options);
|
|
122
|
+
}
|
|
123
|
+
/** The trouble codes that are described, by code, narrowed by text or system. */
|
|
124
|
+
async codes(query = {}, options = {}) {
|
|
125
|
+
return this.#request("GET", `/v1/codes${queryString(query)}`, undefined, options);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* A trouble code on one model year: its description, the bulletins of
|
|
129
|
+
* that model year that name it, and the bulletins and recalls about the
|
|
130
|
+
* same components. Any code answers, a manufacturer-specific one too.
|
|
131
|
+
*/
|
|
132
|
+
async vehicleCode(id, code, options = {}) {
|
|
133
|
+
const path = `/v1/vehicles/${segment("id", id)}/codes/${segment("code", code)}`;
|
|
134
|
+
return this.#request("GET", path, undefined, options);
|
|
135
|
+
}
|
|
136
|
+
/** The repair jobs a labour estimate can be about. A job's id never changes. */
|
|
137
|
+
async jobs(options = {}) {
|
|
138
|
+
return this.#request("GET", "/v1/jobs", undefined, options);
|
|
139
|
+
}
|
|
140
|
+
/** One repair job: what it covers, and what it typically takes by class of vehicle. */
|
|
141
|
+
async job(job, options = {}) {
|
|
142
|
+
return this.#request("GET", `/v1/jobs/${segment("job", job)}`, undefined, options);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Wenmar's labour estimates for a model year, or for one `job` of it:
|
|
146
|
+
* for each job, the hours of the narrowest scope that has a figure, and
|
|
147
|
+
* which scope that was. An estimate, not a quote. Credit it as
|
|
148
|
+
* `attribution` says.
|
|
149
|
+
*/
|
|
150
|
+
async labor(id, job, options = {}) {
|
|
151
|
+
const narrowed = job === undefined ? "" : `/${segment("job", job)}`;
|
|
152
|
+
const path = `/v1/vehicles/${segment("id", id)}/labor${narrowed}`;
|
|
153
|
+
return this.#request("GET", path, undefined, options);
|
|
154
|
+
}
|
|
155
|
+
/** Labour estimates for the vehicle a VIN decodes to, or for one `job` of it. */
|
|
156
|
+
async vinLabor(vin, job, options = {}) {
|
|
157
|
+
const narrowed = job === undefined ? "" : `/${segment("job", job)}`;
|
|
158
|
+
const path = `/v1/vin/${segment("vin", vin)}/labor${narrowed}${queryString({ year: options.year })}`;
|
|
159
|
+
return this.#request("GET", path, undefined, options);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* The income tax, CPP, CPP2 and EI on one regular pay in Ontario, by
|
|
163
|
+
* CRA's T4127 formulas, with the net pay, the employer's share and every
|
|
164
|
+
* factor used. Claims left out are the basic personal amounts (claim
|
|
165
|
+
* code 1). An estimate: the employer remains liable to CRA; check with
|
|
166
|
+
* CRA's PDOC at `pdoc_url`. Not available offline.
|
|
167
|
+
*/
|
|
168
|
+
async payrollDeductions(query, options = {}) {
|
|
169
|
+
return this.#request("GET", `/v1/payroll/deductions${queryString(query)}`, undefined, options);
|
|
170
|
+
}
|
|
171
|
+
/** One make by its id, name or alias, such as `honda`, with the maker's own links. */
|
|
172
|
+
async make(make, options = {}) {
|
|
173
|
+
return this.#request("GET", `/v1/makes/${segment("make", make)}`, undefined, options);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Recalls that may apply to a model year, by its id such as
|
|
177
|
+
* `2018_ford_f-150`. The list is for the year, make and model: it is not
|
|
178
|
+
* a lookup by VIN, and `lookup` says where one vehicle can be checked.
|
|
179
|
+
*/
|
|
180
|
+
async recalls(id, query = {}, options = {}) {
|
|
181
|
+
const path = `/v1/vehicles/${segment("id", id)}/recalls${queryString(query)}`;
|
|
182
|
+
return this.#request("GET", path, undefined, options);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Recalls that may apply to the model year a VIN decodes to. The VIN only
|
|
186
|
+
* names the model year: no public data says a recall applies to one VIN.
|
|
187
|
+
*/
|
|
188
|
+
async vinRecalls(vin, query = {}, options = {}) {
|
|
189
|
+
const path = `/v1/vin/${segment("vin", vin)}/recalls${queryString(query)}`;
|
|
190
|
+
return this.#request("GET", path, undefined, options);
|
|
191
|
+
}
|
|
192
|
+
/** One recall campaign: `source` is `nhtsa` or `tc`. */
|
|
193
|
+
async recall(source, campaign, options = {}) {
|
|
194
|
+
const path = `/v1/recalls/${segment("source", source)}/${segment("campaign", campaign)}`;
|
|
195
|
+
return this.#request("GET", path, undefined, options);
|
|
196
|
+
}
|
|
197
|
+
/** Recall campaigns, newest first, narrowed by what is given. */
|
|
198
|
+
async searchRecalls(query = {}, options = {}) {
|
|
199
|
+
return this.#request("GET", `/v1/recalls${queryString(query)}`, undefined, options);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Manufacturer communications that list a model year: service bulletins,
|
|
203
|
+
* service campaigns, warranty extensions and over-the-air updates, one
|
|
204
|
+
* page, newest first. `counts` says how many there are of each kind.
|
|
205
|
+
*/
|
|
206
|
+
async bulletins(id, query = {}, options = {}) {
|
|
207
|
+
const path = `/v1/vehicles/${segment("id", id)}/bulletins${queryString(query)}`;
|
|
208
|
+
return this.#request("GET", path, undefined, options);
|
|
209
|
+
}
|
|
210
|
+
/** Manufacturer communications for the model year a VIN decodes to. */
|
|
211
|
+
async vinBulletins(vin, query = {}, options = {}) {
|
|
212
|
+
const path = `/v1/vin/${segment("vin", vin)}/bulletins${queryString(query)}`;
|
|
213
|
+
return this.#request("GET", path, undefined, options);
|
|
214
|
+
}
|
|
215
|
+
/** One manufacturer communication, by NHTSA's id number. */
|
|
216
|
+
async bulletin(nhtsaId, options = {}) {
|
|
217
|
+
const path = `/v1/bulletins/${segment("nhtsa_id", String(nhtsaId))}`;
|
|
218
|
+
return this.#request("GET", path, undefined, options);
|
|
219
|
+
}
|
|
220
|
+
/** Manufacturer communications, newest first, narrowed by what is given. */
|
|
221
|
+
async searchBulletins(query = {}, options = {}) {
|
|
222
|
+
return this.#request("GET", `/v1/bulletins${queryString(query)}`, undefined, options);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Fuel consumption ratings of a model year, from EPA and Natural Resources
|
|
226
|
+
* Canada. Each rating says how far it was matched in `confidence`, and
|
|
227
|
+
* names a catalog engine only when the match settled one.
|
|
228
|
+
*/
|
|
229
|
+
async fuel(id, query = {}, options = {}) {
|
|
230
|
+
const path = `/v1/vehicles/${segment("id", id)}/fuel${queryString(query)}`;
|
|
231
|
+
return this.#request("GET", path, undefined, options);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Fuel consumption ratings for the vehicle a VIN decodes to: narrowed to
|
|
235
|
+
* its engine when `engine_settled` is `true`, the model year's otherwise.
|
|
236
|
+
*/
|
|
237
|
+
async vinFuel(vin, query = {}, options = {}) {
|
|
238
|
+
const path = `/v1/vin/${segment("vin", vin)}/fuel${queryString(query)}`;
|
|
239
|
+
return this.#request("GET", path, undefined, options);
|
|
240
|
+
}
|
|
241
|
+
/** Specifications of a model year from EPA's files, one entry per rating. */
|
|
242
|
+
async specs(id, options = {}) {
|
|
243
|
+
return this.#request("GET", `/v1/vehicles/${segment("id", id)}/specs`, undefined, options);
|
|
244
|
+
}
|
|
245
|
+
/** Specifications for the vehicle a VIN decodes to. */
|
|
246
|
+
async vinSpecs(vin, query = {}, options = {}) {
|
|
247
|
+
const path = `/v1/vin/${segment("vin", vin)}/specs${queryString(query)}`;
|
|
248
|
+
return this.#request("GET", path, undefined, options);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Fluids of a model year: the engine oil viscosity grade the maker
|
|
252
|
+
* certified each engine with, per EPA, and the records a person read from
|
|
253
|
+
* the maker's own documents, each with its source and the day it was checked.
|
|
254
|
+
*/
|
|
255
|
+
async fluids(id, options = {}) {
|
|
256
|
+
return this.#request("GET", `/v1/vehicles/${segment("id", id)}/fluids`, undefined, options);
|
|
257
|
+
}
|
|
258
|
+
/** Fluids for the vehicle a VIN decodes to: one engine's when the decode settles it. */
|
|
259
|
+
async vinFluids(vin, query = {}, options = {}) {
|
|
260
|
+
const path = `/v1/vin/${segment("vin", vin)}/fluids${queryString(query)}`;
|
|
261
|
+
return this.#request("GET", path, undefined, options);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Original-equipment tire fitments of a model year, read by a person from
|
|
265
|
+
* the door placard or the owner's manual. Every size on record is listed
|
|
266
|
+
* with the trims it covers; none is picked.
|
|
267
|
+
*/
|
|
268
|
+
async tires(id, options = {}) {
|
|
269
|
+
return this.#request("GET", `/v1/vehicles/${segment("id", id)}/tires`, undefined, options);
|
|
270
|
+
}
|
|
271
|
+
/** Tire fitments of the model year a VIN decodes to. Never narrowed: a VIN does not name the wheels. */
|
|
272
|
+
async vinTires(vin, query = {}, options = {}) {
|
|
273
|
+
const path = `/v1/vin/${segment("vin", vin)}/tires${queryString(query)}`;
|
|
274
|
+
return this.#request("GET", path, undefined, options);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* The parts-ordering card for a VIN: what a parts counter asks for, each
|
|
278
|
+
* line with where it came from. `text` is the card ready to paste.
|
|
279
|
+
*/
|
|
280
|
+
async partsCard(vin, query = {}, options = {}) {
|
|
281
|
+
const path = `/v1/vin/${segment("vin", vin)}/parts-card${queryString(query)}`;
|
|
282
|
+
return this.#request("GET", path, undefined, options);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Everything held for a model year in one answer, by its id such as
|
|
286
|
+
* `2018_ford_f-150`. A block the server has no data for is `null`.
|
|
287
|
+
* `recalls` counts the campaigns that may apply to the year, make and
|
|
288
|
+
* model: it is not a lookup by VIN.
|
|
289
|
+
*/
|
|
290
|
+
async overview(id, options = {}) {
|
|
291
|
+
return this.#request("GET", `/v1/vehicles/${segment("id", id)}/overview`, undefined, options);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* The overview of the model year a VIN decodes to, with `decode`. The VIN
|
|
295
|
+
* only names the model year: no public data says a recall applies to one
|
|
296
|
+
* VIN.
|
|
297
|
+
*/
|
|
298
|
+
async vinOverview(vin, options = {}) {
|
|
299
|
+
const path = `/v1/vin/${segment("vin", vin)}/overview${queryString({ year: options.year })}`;
|
|
300
|
+
return this.#request("GET", path, undefined, options);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Every model year of one model, newest first, each with its vehicle id
|
|
304
|
+
* and the number of recall campaigns that may apply to it.
|
|
305
|
+
*/
|
|
306
|
+
async modelYears(make, model, options = {}) {
|
|
307
|
+
const path = `/v1/models/${segment("make", make)}/${segment("model", model)}`;
|
|
308
|
+
return this.#request("GET", path, undefined, options);
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Recall campaigns reported on or after `since` (a day such as
|
|
312
|
+
* `2026-09-01`), newest first, each with the vehicles it may apply to.
|
|
313
|
+
*/
|
|
314
|
+
async recentRecalls(query, options = {}) {
|
|
315
|
+
return this.#request("GET", `/v1/recalls/recent${queryString(query)}`, undefined, options);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* The open NHTSA investigations that list a model year, by its id such as
|
|
319
|
+
* `2019_ram_1500`; `{ status: "all" }` adds the closed ones. An
|
|
320
|
+
* investigation is not a finding that a defect exists: show `note`.
|
|
321
|
+
*/
|
|
322
|
+
async investigations(id, query = {}, options = {}) {
|
|
323
|
+
const path = `/v1/vehicles/${segment("id", id)}/investigations${queryString(query)}`;
|
|
324
|
+
return this.#request("GET", path, undefined, options);
|
|
325
|
+
}
|
|
326
|
+
/** The NHTSA investigations that led to a recall campaign: `source` is `nhtsa` or `tc`. */
|
|
327
|
+
async recallInvestigations(source, campaign, options = {}) {
|
|
328
|
+
const path = `/v1/recalls/${segment("source", source)}/${segment("campaign", campaign)}/investigations`;
|
|
329
|
+
return this.#request("GET", path, undefined, options);
|
|
330
|
+
}
|
|
104
331
|
/** The data version, the vPIC release it came from, and the build time. */
|
|
105
332
|
async meta(options = {}) {
|
|
106
333
|
return this.#request("GET", "/v1/meta", undefined, options);
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The codes the API answers with.
|
|
3
|
+
*
|
|
4
|
+
* `dataset_unavailable` is a `404` from a method that reads a dataset the
|
|
5
|
+
* server does not hold, such as recalls: `details.dataset` names it, as
|
|
6
|
+
* `recalls_us` or `recalls_ca`. It is not `not_found`: the vehicle may well
|
|
7
|
+
* exist, and another server, or the same one later, may hold the data.
|
|
8
|
+
*/
|
|
9
|
+
export type ApiErrorCode = "invalid_vin" | "validation_failed" | "not_found" | "dataset_unavailable" | "method_not_allowed" | "payload_too_large" | "uri_too_long" | "rate_limited" | "unavailable" | "internal_error";
|
|
3
10
|
/**
|
|
4
11
|
* The codes this client adds for failures that never reached the API or
|
|
5
12
|
* did not come from it.
|
|
@@ -11,11 +18,22 @@ export type ApiErrorCode = "invalid_vin" | "validation_failed" | "not_found" | "
|
|
|
11
18
|
* error page and a sign-in page from a captive portal both end up here.
|
|
12
19
|
*/
|
|
13
20
|
export type ClientErrorCode = "network" | "timeout" | "aborted" | "bad_response";
|
|
21
|
+
/**
|
|
22
|
+
* The codes of `wenmar-open/offline`, for failures of the data and not of
|
|
23
|
+
* the question. The command-line tool uses `no_data` and `data_invalid` for
|
|
24
|
+
* the same things.
|
|
25
|
+
*
|
|
26
|
+
* - `no_data`: there is no data file where one was looked for.
|
|
27
|
+
* - `data_invalid`: the database is not a data file this version reads: it
|
|
28
|
+
* has another schema version, or a row is not what the layout says.
|
|
29
|
+
* - `store_error`: the database failed while it was being read.
|
|
30
|
+
*/
|
|
31
|
+
export type OfflineErrorCode = "no_data" | "data_invalid" | "store_error";
|
|
14
32
|
/**
|
|
15
33
|
* Every code known when this version was published. The API may add codes,
|
|
16
34
|
* so `code` is typed to accept any string while still completing these.
|
|
17
35
|
*/
|
|
18
|
-
export type ErrorCode = ApiErrorCode | ClientErrorCode | (string & {});
|
|
36
|
+
export type ErrorCode = ApiErrorCode | ClientErrorCode | OfflineErrorCode | (string & {});
|
|
19
37
|
export interface WenmarOpenErrorInit {
|
|
20
38
|
code: ErrorCode;
|
|
21
39
|
message: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export
|
|
1
|
+
export { MAX_BATCH, isBatchError } from "./batch.js";
|
|
2
|
+
export { DEFAULT_BASE_URL, DEFAULT_TIMEOUT_MS, WenmarOpen } from "./client.js";
|
|
3
|
+
export type { BatchOptions, ClientOptions, DecodeOptions, FetchInit, FetchLike, FetchResponse, RequestOptions, } from "./client.js";
|
|
3
4
|
export { WenmarOpenError } from "./errors.js";
|
|
4
|
-
export type { ApiErrorCode, ClientErrorCode, ErrorCode, WenmarOpenErrorInit } from "./errors.js";
|
|
5
|
-
export type { BatchItem, CheckDigit, Engine, EngineOption, EnginesQuery, Entry, ErrorBody, Make, MakesQuery, Manufacturer, Meta, Model, ModelsQuery, Plant, Safety, SearchQuery, Selection, Submodel, SubmodelsQuery, VinDecode, Warning, YearsQuery, } from "./types.js";
|
|
5
|
+
export type { ApiErrorCode, ClientErrorCode, ErrorCode, OfflineErrorCode, WenmarOpenErrorInit, } from "./errors.js";
|
|
6
|
+
export type { BatchItem, Bulletin, BulletinCounts, BulletinDetail, BulletinDocument, BulletinFilterQuery, BulletinList, BulletinSearchQuery, Code, CodeLink, CodeList, CodeSearchQuery, CheckDigit, Engine, EngineOil, FluidRecord, EngineOption, EnginesQuery, Entry, ErrorBody, FuelRating, Investigation, Make, MakeDetail, MakesQuery, Manufacturer, Meta, Model, ModelYears, ModelsQuery, Overview, OverviewBulletins, OverviewRecalls, PayrollDeductions, PayrollDeductionsQuery, PayrollFactor, PartsCard, PartsCardLine, Plant, Recall, RecallCampaign, RecallCompletion, RecallCount, RecallInvestigations, RecallList, RecallLookup, RecallSearchQuery, RecentRecalls, RecentRecallsQuery, Safety, SafetyRating, SearchQuery, Selection, Spec, Submodel, SubmodelsQuery, TireFitment, JobDetail, JobList, LaborFigure, VehicleLabor, VinLabor, VehicleBulletins, VehicleCode, VehicleComplaints, VehicleFluids, VehicleFuel, VehicleFuelQuery, VehicleInvestigations, VehicleInvestigationsQuery, VehicleRecalls, VehicleRecallsQuery, VehicleSafety, VehicleSpecs, VehicleTires, VinBulletins, VinBulletinsQuery, VinDecode, VinFluids, VinFuel, VinFuelQuery, VinRecallCount, VinRecalls, VinRecallsQuery, VinSpecs, VinTires, VinYearQuery, Warning, YearsQuery, } from "./types.js";
|
|
6
7
|
export type { components, operations, paths } from "./schema.js";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { MAX_BATCH, isBatchError } from "./batch.js";
|
|
2
|
+
export { DEFAULT_BASE_URL, DEFAULT_TIMEOUT_MS, WenmarOpen } from "./client.js";
|
|
2
3
|
export { WenmarOpenError } from "./errors.js";
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import type { DecodeOptions, RequestOptions } from "../client.js";
|
|
2
|
+
import type { BatchItem, EngineOption, EnginesQuery, Entry, Make, MakesQuery, Meta, Model, ModelsQuery, Code, CodeList, CodeSearchQuery, JobDetail, JobList, ModelYears, Overview, RecallCampaign, RecallList, RecallSearchQuery, RecentRecalls, RecentRecallsQuery, SearchQuery, Submodel, SubmodelsQuery, VehicleFluids, VehicleFuel, VehicleComplaints, VehicleFuelQuery, VehicleRecalls, VehicleRecallsQuery, VehicleCode, VehicleLabor, VehicleSafety, VehicleSpecs, VehicleTires, VinDecode, VinLabor, VinFluids, VinFuel, VinFuelQuery, VinRecalls, VinRecallsQuery, VinSpecs, VinTires, VinYearQuery, YearsQuery } from "../types.js";
|
|
3
|
+
import type { WasmSource } from "./engine.js";
|
|
4
|
+
import type { Store } from "./store.js";
|
|
5
|
+
/**
|
|
6
|
+
* The most times one question, or the opening of the data, may go back to
|
|
7
|
+
* the store. Opening takes 2; over the fixture of the tests a decode takes
|
|
8
|
+
* at most 7 and a search at most 4. Reaching this means something is wrong.
|
|
9
|
+
*/
|
|
10
|
+
export declare const MAX_STEPS = 32;
|
|
11
|
+
export interface OfflineOptions {
|
|
12
|
+
/** Where the data is: `syncStore(...)`, `d1Store(...)`, or your own. */
|
|
13
|
+
store: Store;
|
|
14
|
+
/**
|
|
15
|
+
* Where the shop file is: a second database, which holds the recalls.
|
|
16
|
+
* It must be the shop file that was built against the data file in
|
|
17
|
+
* `store`. Leave it out and the recall methods fail with
|
|
18
|
+
* `dataset_unavailable`; everything else works.
|
|
19
|
+
*/
|
|
20
|
+
shop?: Store;
|
|
21
|
+
/**
|
|
22
|
+
* The decoder. Leave it out everywhere but Cloudflare Workers, where it
|
|
23
|
+
* is the module `import wasm from "wenmar-open/offline.wasm"` gives.
|
|
24
|
+
*/
|
|
25
|
+
wasm?: WasmSource;
|
|
26
|
+
/**
|
|
27
|
+
* The current calendar year, which bounds the model years a VIN can
|
|
28
|
+
* have. Default: the year of the device's clock, in UTC.
|
|
29
|
+
*/
|
|
30
|
+
currentYear?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* VIN decoding and the vehicle catalog with no network: the methods of
|
|
34
|
+
* `WenmarOpen`, answered from a data file by the decoder inside the package.
|
|
35
|
+
* Every method gives what the hosted API gives for the same question and
|
|
36
|
+
* fails with the same `WenmarOpenError` codes.
|
|
37
|
+
*/
|
|
38
|
+
export declare class WenmarOpenOffline {
|
|
39
|
+
#private;
|
|
40
|
+
constructor(options: OfflineOptions);
|
|
41
|
+
/** Decode one VIN. Spaces, dashes and lowercase are accepted. */
|
|
42
|
+
decodeVin(vin: string, options?: DecodeOptions): Promise<VinDecode>;
|
|
43
|
+
/**
|
|
44
|
+
* Decode up to 50 VINs. The answer has one item per VIN, in order: a
|
|
45
|
+
* decode, or the error a single call for that VIN would have thrown.
|
|
46
|
+
* Tell them apart with `isBatchError`.
|
|
47
|
+
*/
|
|
48
|
+
decodeVins(vins: readonly string[], options?: RequestOptions): Promise<BatchItem[]>;
|
|
49
|
+
/** Model years, newest first. */
|
|
50
|
+
years(query?: YearsQuery, options?: RequestOptions): Promise<number[]>;
|
|
51
|
+
/** Makes, popular ones first and the rest by name. */
|
|
52
|
+
makes(query?: MakesQuery, options?: RequestOptions): Promise<Make[]>;
|
|
53
|
+
/** Models of a make, by name. An unknown make has no models. */
|
|
54
|
+
models(query: ModelsQuery, options?: RequestOptions): Promise<Model[]>;
|
|
55
|
+
/** Submodels of a model year: trims, or series where there are no trims. */
|
|
56
|
+
submodels(query: SubmodelsQuery, options?: RequestOptions): Promise<Submodel[]>;
|
|
57
|
+
/** The same as `submodels`, under the name most people use. */
|
|
58
|
+
trims(query: SubmodelsQuery, options?: RequestOptions): Promise<Submodel[]>;
|
|
59
|
+
/** Engines of a model year, in short form. */
|
|
60
|
+
engines(query: EnginesQuery, options?: RequestOptions): Promise<EngineOption[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Catalog entries for free text such as `2019 civic si`, best first. The
|
|
63
|
+
* hosted API also finds words in any order with an index of its own;
|
|
64
|
+
* here, text the catalog cannot read as year, make, model and submodel
|
|
65
|
+
* finds nothing.
|
|
66
|
+
*/
|
|
67
|
+
search(query: SearchQuery, options?: RequestOptions): Promise<Entry[]>;
|
|
68
|
+
/** One catalog entry by its id, such as `2019_honda_civic_si`. */
|
|
69
|
+
vehicle(id: string, options?: RequestOptions): Promise<Entry>;
|
|
70
|
+
/**
|
|
71
|
+
* NHTSA's crash test ratings for a model year, by its id such as
|
|
72
|
+
* `2018_ford_f-150`. NHTSA rates by body style and drive, so `ratings`
|
|
73
|
+
* often has several entries: each names the vehicle it is for. Needs a
|
|
74
|
+
* shop file that holds the ratings: without one it fails with
|
|
75
|
+
* `dataset_unavailable`.
|
|
76
|
+
*/
|
|
77
|
+
safety(id: string, options?: RequestOptions): Promise<VehicleSafety>;
|
|
78
|
+
/**
|
|
79
|
+
* What owners reported to NHTSA about a model year, as counts by component
|
|
80
|
+
* with the median mileage they gave. Without a shop file that holds the
|
|
81
|
+
* complaints it fails with `dataset_unavailable`.
|
|
82
|
+
*/
|
|
83
|
+
complaints(id: string, options?: RequestOptions): Promise<VehicleComplaints>;
|
|
84
|
+
/**
|
|
85
|
+
* Fuel consumption ratings of a model year, from EPA and Natural
|
|
86
|
+
* Resources Canada. Each says in `confidence` how far it was matched:
|
|
87
|
+
* `model`, `engine` or `submodel`. Needs a shop file that holds them:
|
|
88
|
+
* without one it fails with `dataset_unavailable`.
|
|
89
|
+
*/
|
|
90
|
+
fuel(id: string, query?: VehicleFuelQuery, options?: RequestOptions): Promise<VehicleFuel>;
|
|
91
|
+
/** Fuel ratings for the vehicle a VIN decodes to: one engine's when the decode settles it. */
|
|
92
|
+
vinFuel(vin: string, query?: VinFuelQuery, options?: RequestOptions): Promise<VinFuel>;
|
|
93
|
+
/** Specifications of a model year from EPA's files, one entry per EPA rating. */
|
|
94
|
+
specs(id: string, options?: RequestOptions): Promise<VehicleSpecs>;
|
|
95
|
+
/** Specifications for the vehicle a VIN decodes to: one engine's when the decode settles it. */
|
|
96
|
+
vinSpecs(vin: string, query?: VinYearQuery, options?: RequestOptions): Promise<VinSpecs>;
|
|
97
|
+
/**
|
|
98
|
+
* Fluids of a model year: the engine oil viscosity grade the maker
|
|
99
|
+
* certified each engine with, per EPA, and the records a person read from
|
|
100
|
+
* the maker's own documents, each with its source and the day it was checked.
|
|
101
|
+
*/
|
|
102
|
+
fluids(id: string, options?: RequestOptions): Promise<VehicleFluids>;
|
|
103
|
+
/** Fluids for the vehicle a VIN decodes to: one engine's when the decode settles it. */
|
|
104
|
+
vinFluids(vin: string, query?: VinYearQuery, options?: RequestOptions): Promise<VinFluids>;
|
|
105
|
+
/**
|
|
106
|
+
* Original-equipment tire fitments of a model year. Every size on record
|
|
107
|
+
* is listed with the trims it covers; none is picked.
|
|
108
|
+
*/
|
|
109
|
+
tires(id: string, options?: RequestOptions): Promise<VehicleTires>;
|
|
110
|
+
/** Tire fitments of the model year a VIN decodes to. Never narrowed: a VIN does not name the wheels. */
|
|
111
|
+
vinTires(vin: string, query?: VinYearQuery, options?: RequestOptions): Promise<VinTires>;
|
|
112
|
+
/** The repair jobs a labour estimate can be about. Needs a shop file that holds the job list. */
|
|
113
|
+
jobs(options?: RequestOptions): Promise<JobList>;
|
|
114
|
+
/** One repair job: what it covers, and what it typically takes by class of vehicle. */
|
|
115
|
+
job(job: string, options?: RequestOptions): Promise<JobDetail>;
|
|
116
|
+
/**
|
|
117
|
+
* Wenmar's labour estimates for a model year, or for one `job` of it.
|
|
118
|
+
* An estimate, not a quote; credit it as `attribution` says. Needs a
|
|
119
|
+
* shop file that holds the estimates.
|
|
120
|
+
*/
|
|
121
|
+
labor(id: string, job?: string, options?: RequestOptions): Promise<VehicleLabor>;
|
|
122
|
+
/** Labour estimates for the vehicle a VIN decodes to, or for one `job` of it. */
|
|
123
|
+
vinLabor(vin: string, job?: string, options?: RequestOptions & {
|
|
124
|
+
year?: number;
|
|
125
|
+
}): Promise<VinLabor>;
|
|
126
|
+
/**
|
|
127
|
+
* One generic trouble code, such as `P0420`, described in this project's
|
|
128
|
+
* own words. Needs a shop file that holds the codes: without one it
|
|
129
|
+
* fails with `dataset_unavailable`.
|
|
130
|
+
*/
|
|
131
|
+
code(code: string, options?: RequestOptions): Promise<Code>;
|
|
132
|
+
/** The trouble codes that are described, by code, narrowed by text or system. */
|
|
133
|
+
codes(query?: CodeSearchQuery, options?: RequestOptions): Promise<CodeList>;
|
|
134
|
+
/**
|
|
135
|
+
* A trouble code on one model year: its description and the recalls
|
|
136
|
+
* about the same components. `bulletins` and `related.bulletins` are
|
|
137
|
+
* always `null` offline: bulletins are on the hosted service only.
|
|
138
|
+
*/
|
|
139
|
+
vehicleCode(id: string, code: string, options?: RequestOptions): Promise<VehicleCode>;
|
|
140
|
+
/**
|
|
141
|
+
* Recalls that may apply to a model year, by its id such as
|
|
142
|
+
* `2018_ford_f-150`. The list is for the year, make and model: it is not
|
|
143
|
+
* a lookup by VIN, and `lookup` says where one vehicle can be checked.
|
|
144
|
+
* Needs a shop file: without one it fails with `dataset_unavailable`.
|
|
145
|
+
*/
|
|
146
|
+
recalls(id: string, query?: VehicleRecallsQuery, options?: RequestOptions): Promise<VehicleRecalls>;
|
|
147
|
+
/**
|
|
148
|
+
* Recalls that may apply to the model year a VIN decodes to. The VIN only
|
|
149
|
+
* names the model year: no public data says a recall applies to one VIN.
|
|
150
|
+
*/
|
|
151
|
+
vinRecalls(vin: string, query?: VinRecallsQuery, options?: RequestOptions): Promise<VinRecalls>;
|
|
152
|
+
/** One recall campaign: `source` is `nhtsa` or `tc`. */
|
|
153
|
+
recall(source: string, campaign: string, options?: RequestOptions): Promise<RecallCampaign>;
|
|
154
|
+
/** Recall campaigns, newest first, narrowed by what is given. */
|
|
155
|
+
searchRecalls(query?: RecallSearchQuery, options?: RequestOptions): Promise<RecallList>;
|
|
156
|
+
/**
|
|
157
|
+
* Everything held for a model year in one answer, by its id such as
|
|
158
|
+
* `2018_ford_f-150`. A block the files do not hold is `null`. `recalls`
|
|
159
|
+
* counts the campaigns that may apply to the year, make and model: it is
|
|
160
|
+
* not a lookup by VIN. With no shop file `recalls` is `null`, and the
|
|
161
|
+
* method still answers.
|
|
162
|
+
*/
|
|
163
|
+
overview(id: string, options?: RequestOptions): Promise<Overview>;
|
|
164
|
+
/**
|
|
165
|
+
* The overview of the model year a VIN decodes to, with `decode`. The VIN
|
|
166
|
+
* only names the model year: no public data says a recall applies to one
|
|
167
|
+
* VIN.
|
|
168
|
+
*/
|
|
169
|
+
vinOverview(vin: string, options?: DecodeOptions): Promise<Overview>;
|
|
170
|
+
/**
|
|
171
|
+
* Every model year of one model, newest first, each with its vehicle id
|
|
172
|
+
* and the number of recall campaigns that may apply to it: `null` with no
|
|
173
|
+
* shop file.
|
|
174
|
+
*/
|
|
175
|
+
modelYears(make: string, model: string, options?: RequestOptions): Promise<ModelYears>;
|
|
176
|
+
/**
|
|
177
|
+
* Recall campaigns reported on or after `since` (a day such as
|
|
178
|
+
* `2026-09-01`), newest first, each with the vehicles it may apply to.
|
|
179
|
+
* Needs a shop file: without one it fails with `dataset_unavailable`.
|
|
180
|
+
*/
|
|
181
|
+
recentRecalls(query: RecentRecallsQuery, options?: RequestOptions): Promise<RecentRecalls>;
|
|
182
|
+
/**
|
|
183
|
+
* The data version, the vPIC release it came from, and the build time.
|
|
184
|
+
* `server_version` is the version of this package. `datasets` lists what
|
|
185
|
+
* the shop file holds, and is empty when no shop store was given.
|
|
186
|
+
*/
|
|
187
|
+
meta(options?: RequestOptions): Promise<Meta>;
|
|
188
|
+
/** Closes the stores, if they were opened for this client. */
|
|
189
|
+
close(): void;
|
|
190
|
+
}
|