tesla-inventory 1.8.13 → 1.8.17

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/codes.json CHANGED
@@ -76,7 +76,7 @@
76
76
  "BTX8": "75 kWh",
77
77
  "BTX9": "100 kWh Battery Pack with Weight Reduction",
78
78
  "BTXA": "18650J2 Battery Cell",
79
- "BTXB": "99kWh 18650 Plaid E5 or E6 vin battery",
79
+ "BTXB": "99kWh 18650 Plaid <em>E5 or E6</em> vin battery",
80
80
  "BY00": "Model Y",
81
81
  "BY01": "Model Y",
82
82
  "CC01": "Five Seat Interior",
@@ -85,14 +85,14 @@
85
85
  "CC04": "Seven Seat Interior",
86
86
  "CC12": "Six Seat Interior with Center Console",
87
87
  "CDM0": "No CHAdeMO Charging Adaptor",
88
- "CF00": "High Power Charger",
88
+ "CF00": "72amp High Power Charger",
89
89
  "CF01": "48amp charger",
90
90
  "CH00": "Standard Charger (40 Amp)",
91
91
  "CH01": "Dual Chargers (80 Amp)",
92
92
  "CH04": "72 Amp Charger Gen3",
93
93
  "CH05": "48 Amp Charger",
94
94
  "CH07": "48 Amp Charger",
95
- "CH09": "Tesla Standard Charging System (Model S 2020 EU)",
95
+ "CH09": "Tesla Standard Charging System 72a (Model S mid2019 EU)",
96
96
  "CH11": "Single phase 48 Amperage Combo 1",
97
97
  "CH12": "48 Amperage Combo 1 Gen 3.5 Charger",
98
98
  "CH14": "32 Amp Charger Hardware (RENA) with Busbar",
@@ -142,6 +142,7 @@
142
142
  "DSHG": "Dash with Graphite trim",
143
143
  "DU00": "Drive Unit - IR",
144
144
  "DU01": "Drive Unit - Infineon",
145
+ "DU02": "Drive Unit - Non-performance front drive unit (raven)",
145
146
  "DV2W": "Rear-Wheel Drive",
146
147
  "DV4W": "All-Wheel Drive",
147
148
  "EUSB": "Safety EU Black",
@@ -171,7 +172,7 @@
171
172
  "FR01": "Base Front Row",
172
173
  "FR02": "Ventilated Front Seats",
173
174
  "FR03": "FR03",
174
- "FR04": "FR04",
175
+ "FR04": "Front Row Seat",
175
176
  "FR05": "Front Row Seat",
176
177
  "GLCN": "Assembly",
177
178
  "GLFR": "Assembly",
@@ -451,7 +452,7 @@
451
452
  "S07W": "White Seats",
452
453
  "S31B": "S31B",
453
454
  "S32C": "S32C",
454
- "S32P": "S32P",
455
+ "S32P": "Black PUR Seats",
455
456
  "S32W": "S32W",
456
457
  "S3PB": "Seat Black PUR Premium Seats",
457
458
  "S3PW": "Seat White PUR Premium Seats",
@@ -498,6 +499,7 @@
498
499
  "T3P3": "Tires M3",
499
500
  "TD00": "Tear Down NON-GLIDER",
500
501
  "TIC4": "Tires MX",
502
+ "TIC6": "Tires MS",
501
503
  "TIG2": "Summer Tires",
502
504
  "TIG5": "Goodyear Eagle Touring",
503
505
  "TIM7": "Summer Tires",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "tesla-inventory",
3
3
  "description": "Retrieve real-time data from Tesla Inventory.",
4
4
  "homepage": "https://nicedoc.io/Kikobeats/tesla-inventory",
5
- "version": "1.8.13",
5
+ "version": "1.8.17",
6
6
  "main": "index.js",
7
7
  "author": {
8
8
  "email": "josefrancisco.verdu@gmail.com",
@@ -34,20 +34,23 @@
34
34
  "teslaapi",
35
35
  "teslamotors"
36
36
  ],
37
+ "dependencies": {
38
+ "got": "11"
39
+ },
37
40
  "devDependencies": {
38
41
  "@commitlint/cli": "latest",
39
42
  "@commitlint/config-conventional": "latest",
40
43
  "ava": "latest",
41
- "cheerio": "latest",
42
44
  "ci-publish": "latest",
43
45
  "conventional-github-releaser": "latest",
44
46
  "debug-logfmt": "latest",
47
+ "entities": "latest",
45
48
  "finepack": "latest",
46
49
  "git-authors-cli": "latest",
47
50
  "git-dirty": "latest",
48
- "got": "11",
49
51
  "json-future": "latest",
50
52
  "lodash": "latest",
53
+ "markdown-tables-to-json": "latest",
51
54
  "nano-staged": "latest",
52
55
  "npm-check-updates": "latest",
53
56
  "nyc": "latest",
@@ -37,6 +37,7 @@
37
37
  "MT321": 8990,
38
38
  "MT322": 2590,
39
39
  "MT323": 7000,
40
+ "MT328": 13190,
40
41
  "MT336": 1880,
41
42
  "MT337": 2590,
42
43
  "MTS03": 5000,
package/scripts/codes.js CHANGED
@@ -1,12 +1,12 @@
1
1
  'use strict'
2
2
 
3
+ const { Extractor } = require('markdown-tables-to-json')
4
+ const { decodeHTML } = require('entities')
5
+
3
6
  const jsonFuture = require('json-future')
4
7
  const { chain } = require('lodash')
5
- const cheerio = require('cheerio')
6
8
  const got = require('got')
7
9
 
8
- const REGEX_ZERO_WIDTH_SPACE = /[\u200B-\u200D\uFEFF]/g
9
-
10
10
  const sortObjectByKey = obj =>
11
11
  chain(obj)
12
12
  .toPairs()
@@ -15,41 +15,17 @@ const sortObjectByKey = obj =>
15
15
  .value()
16
16
 
17
17
  const main = async () => {
18
- const body = await got('https://tesla-api.timdorr.com/vehicle/optioncodes', {
19
- resolveBodyOnly: true
20
- })
21
-
22
- const $ = cheerio.load(body)
23
-
24
- const codes = $(
25
- '.gitbook-root > div > div > div > div > div > div > div > div > div > div > div > div > div > div > div > div > div > div > div > div > div'
18
+ const markdown = await got(
19
+ 'https://raw.githubusercontent.com/timdorr/tesla-api/master/docs/vehicle/optioncodes.md',
20
+ { resolveBodyOnly: true }
26
21
  )
27
22
 
28
- const text = el => el.text().replace(REGEX_ZERO_WIDTH_SPACE, '')
29
-
30
- const optionCodes = codes
31
- .map(function (index) {
32
- if (index === 0) return null
33
- const el = $(this)
34
- const code = text(el.children('div:nth-child(1)'))
35
- const title = text(el.children('div:nth-child(2)'))
36
- const description = text(el.children('div:nth-child(3)'))
37
- return { code, title, description }
38
- })
39
- .get()
40
- .reduce(
41
- (acc, { code, title, description }) => ({
42
- ...acc,
43
- [code]: title || description
44
- }),
45
- {}
46
- )
47
-
48
- if (Object.keys(optionCodes).length === 0) {
49
- throw new Error(
50
- 'The target website has changed, selectors need to be rework.'
51
- )
52
- }
23
+ const json = Extractor.extractObject(markdown, 'rows', false)
24
+
25
+ const optionCodes = Object.keys(json).reduce((acc, code) => {
26
+ const { Title: title, Description: description } = json[code]
27
+ return { ...acc, [code]: decodeHTML(title || description) }
28
+ }, {})
53
29
 
54
30
  jsonFuture.save('codes.json', sortObjectByKey(optionCodes))
55
31
  }