@mxpicture/teslamate-extended-cli 2.1.63 → 3.1.3
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/dist/cli.common.d.ts +64 -77
- package/dist/cli.common.d.ts.map +1 -1
- package/dist/cli.common.js +187 -180
- package/dist/cli.common.js.map +1 -1
- package/dist/cli.d.ts +13 -7
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +32 -23
- package/dist/cli.js.map +1 -1
- package/dist/notify.d.ts +15 -0
- package/dist/notify.d.ts.map +1 -0
- package/dist/notify.js +44 -0
- package/dist/notify.js.map +1 -0
- package/package.json +2 -2
package/dist/cli.common.d.ts
CHANGED
|
@@ -1,56 +1,38 @@
|
|
|
1
1
|
import { Option } from "@commander-js/extra-typings";
|
|
2
|
-
import { type FetchOptions, type FetchScope } from "@mxpicture/teslamate-extended-api/api";
|
|
3
2
|
import { type IStore } from "@mxpicture/teslamate-extended-api/store";
|
|
4
3
|
/** Reads the CLI package version from its package.json. */
|
|
5
4
|
export declare const readVersion: () => string;
|
|
6
|
-
/** One day in milliseconds — the schedule interval. */
|
|
5
|
+
/** One day in milliseconds — the schedule interval and the cadence clock unit. */
|
|
7
6
|
export declare const DAY_MS: number;
|
|
8
7
|
/**
|
|
9
|
-
* Match radius (km) for
|
|
10
|
-
* given Supercharger when it sits within this distance of it.
|
|
11
|
-
* covers the gap between where the car parks and the site's
|
|
12
|
-
* staying well under the spacing between distinct sites.
|
|
8
|
+
* Match radius (km) for the outdated-price determination: a TeslaMate charge
|
|
9
|
+
* location maps to a given Supercharger when it sits within this distance of it.
|
|
10
|
+
* ~300 m comfortably covers the gap between where the car parks and the site's
|
|
11
|
+
* listed point while staying well under the spacing between distinct sites.
|
|
13
12
|
*/
|
|
14
13
|
export declare const CHARGED_MATCH_KM = 0.3;
|
|
15
|
-
/** Parses a non-negative float (e.g. --delay). */
|
|
14
|
+
/** Parses a non-negative float (e.g. --delay, --radius). */
|
|
16
15
|
export declare const parseFloatArg: (v: string) => number;
|
|
17
16
|
/** Parses a non-negative integer (e.g. --limit). */
|
|
18
17
|
export declare const parseIntArg: (v: string) => number;
|
|
18
|
+
/** Parses a positive integer number of days (e.g. --*-every, --outdated-age). */
|
|
19
|
+
export declare const parseDaysArg: (v: string) => number;
|
|
19
20
|
/** Validates an HH:MM (24h) time string (e.g. --at). */
|
|
20
21
|
export declare const parseTime: (v: string) => string;
|
|
21
|
-
/**
|
|
22
|
-
export declare const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
/** One schedule tier: fetch within `radiusKm` of home every `everyDays` days. */
|
|
27
|
-
export interface Tier {
|
|
28
|
-
radiusKm: number;
|
|
29
|
-
everyDays: number;
|
|
30
|
-
}
|
|
31
|
-
/** Collects a repeatable --tier "radiusKm:everyDays" value onto the previous list. */
|
|
32
|
-
export declare const parseTier: (v: string, prev: Tier[]) => Tier[];
|
|
22
|
+
/** Commander option: radius (km) around the TeslaMate "Home" geofence. */
|
|
23
|
+
export declare const radiusOption: Option<"-r, --radius <km>", undefined, undefined, number, false, undefined>;
|
|
24
|
+
/** Commander option: cadence (days) for the radius determination. */
|
|
25
|
+
export declare const radiusEveryOption: Option<"--radius-every <days>", undefined, 7, number, false, undefined>;
|
|
33
26
|
/** Commander option: restrict to a single country. */
|
|
34
27
|
export declare const countryOption: Option<"-c, --country <name>", undefined, undefined, undefined, false, undefined>;
|
|
35
|
-
/** Commander option:
|
|
36
|
-
export declare const
|
|
37
|
-
/** Commander option:
|
|
38
|
-
export declare const
|
|
39
|
-
/** Commander option:
|
|
40
|
-
export declare const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}, false, undefined>;
|
|
44
|
-
/** Commander option: radius in km around --near. */
|
|
45
|
-
export declare const radiusOption: Option<"--radius <km>", undefined, undefined, number, false, undefined>;
|
|
46
|
-
/** Commander option (schedule): repeatable tier "radiusKm:everyDays". */
|
|
47
|
-
export declare const tierOption: Option<"--tier <km:everyDays>", undefined, Tier[], Tier[], false, undefined>;
|
|
48
|
-
/** Commander option: scope = the Superchargers you've charged at (TeslaMate DB). */
|
|
49
|
-
export declare const chargedOption: Option<"--charged", undefined, undefined, undefined, false, undefined>;
|
|
50
|
-
/** Commander option: center the radius scope on the TeslaMate "Home" geofence. */
|
|
51
|
-
export declare const homeFromTeslamateOption: Option<"--home-from-teslamate", undefined, undefined, undefined, false, undefined>;
|
|
52
|
-
/** Commander option: also upsert each fetched Supercharger as a TeslaMate geofence. */
|
|
53
|
-
export declare const geofencesOption: Option<"--teslamate-geofences", undefined, undefined, undefined, false, undefined>;
|
|
28
|
+
/** Commander option: cadence (days) for the country determination. */
|
|
29
|
+
export declare const countryEveryOption: Option<"--country-every <days>", undefined, 30, number, false, undefined>;
|
|
30
|
+
/** Commander option: enable the missing/outdated-price determination. */
|
|
31
|
+
export declare const outdatedOption: Option<"--outdated", undefined, undefined, undefined, false, undefined>;
|
|
32
|
+
/** Commander option: cadence (days) for the outdated determination. */
|
|
33
|
+
export declare const outdatedEveryOption: Option<"--outdated-every <days>", undefined, 1, number, false, undefined>;
|
|
34
|
+
/** Commander option: age (days) past which a managed geofence's price is "outdated". */
|
|
35
|
+
export declare const outdatedAgeOption: Option<"--outdated-age <days>", undefined, 30, number, false, undefined>;
|
|
54
36
|
/** Commander option: pricing locale. */
|
|
55
37
|
export declare const localeOption: Option<"-l, --locale <locale>", undefined, "en-US", undefined, false, undefined>;
|
|
56
38
|
/** Commander option: politeness delay between requests (seconds). */
|
|
@@ -69,27 +51,32 @@ export declare const httpUrlOption: Option<"--http-url <url>", undefined, undefi
|
|
|
69
51
|
export declare const httpUserOption: Option<"--http-user <user>", undefined, undefined, undefined, false, undefined>;
|
|
70
52
|
/** Commander option: Basic-auth password for --http-url. */
|
|
71
53
|
export declare const httpPasswordOption: Option<"--http-password <password>", undefined, undefined, undefined, false, undefined>;
|
|
72
|
-
/** Commander option:
|
|
73
|
-
export declare const
|
|
54
|
+
/** Commander option: also upsert each fetched Supercharger as a TeslaMate geofence. */
|
|
55
|
+
export declare const geofencesOption: Option<"--teslamate-geofences", undefined, undefined, undefined, false, undefined>;
|
|
56
|
+
/** Commander option: backfill TeslaMate charge costs from the managed geofence prices. */
|
|
57
|
+
export declare const chargesOption: Option<"--teslamate-charges", undefined, undefined, undefined, false, undefined>;
|
|
58
|
+
/** Commander option: after the run, alert (Pushover) when Supercharger charges remain unpriced. */
|
|
59
|
+
export declare const alertUnpricedChargesOption: Option<"--alert-unpriced-charges", undefined, undefined, undefined, false, undefined>;
|
|
74
60
|
/**
|
|
75
61
|
* Commander option: route tesla.com requests through a proxy. Sets
|
|
76
62
|
* HTTPS_PROXY/ALL_PROXY for the curl subprocess (which already honors them when
|
|
77
63
|
* set in the environment). Use this to escape datacenter IPs Akamai 403s.
|
|
78
64
|
*/
|
|
79
65
|
export declare const proxyOption: Option<"--proxy <url>", undefined, undefined, undefined, false, undefined>;
|
|
66
|
+
/** Commander option: daily run time for `schedule` (24h, local). */
|
|
67
|
+
export declare const atOption: Option<"-t, --at <HH:MM>", undefined, "03:30", string, false, undefined>;
|
|
80
68
|
/** Options common to `fetch` and `schedule`. */
|
|
81
69
|
export interface CommonOpts {
|
|
82
|
-
country?: string;
|
|
83
|
-
region?: string;
|
|
84
|
-
all?: boolean;
|
|
85
|
-
near?: {
|
|
86
|
-
lat: number;
|
|
87
|
-
lon: number;
|
|
88
|
-
};
|
|
89
70
|
radius?: number;
|
|
90
|
-
|
|
91
|
-
|
|
71
|
+
radiusEvery: number;
|
|
72
|
+
country?: string;
|
|
73
|
+
countryEvery: number;
|
|
74
|
+
outdated?: boolean;
|
|
75
|
+
outdatedEvery: number;
|
|
76
|
+
outdatedAge: number;
|
|
92
77
|
teslamateGeofences?: boolean;
|
|
78
|
+
teslamateCharges?: boolean;
|
|
79
|
+
alertUnpricedCharges?: boolean;
|
|
93
80
|
locale: string;
|
|
94
81
|
delay: number;
|
|
95
82
|
limit: number;
|
|
@@ -101,25 +88,10 @@ export interface CommonOpts {
|
|
|
101
88
|
httpPassword?: string;
|
|
102
89
|
proxy?: string;
|
|
103
90
|
}
|
|
104
|
-
/** `schedule` options: the common ones plus the daily run time
|
|
91
|
+
/** `schedule` options: the common ones plus the daily run time. */
|
|
105
92
|
export type ScheduleOpts = CommonOpts & {
|
|
106
93
|
at: string;
|
|
107
|
-
tier: Tier[];
|
|
108
94
|
};
|
|
109
|
-
/** Resolves the single scope flag (exactly one of country/region/all/near). */
|
|
110
|
-
export declare const toScope: (o: CommonOpts) => FetchScope;
|
|
111
|
-
/** The radius center: --near, or the TeslaMate "Home" geofence (--home-from-teslamate). */
|
|
112
|
-
export declare const resolveCenter: (o: CommonOpts) => Promise<{
|
|
113
|
-
lat: number;
|
|
114
|
-
lon: number;
|
|
115
|
-
}>;
|
|
116
|
-
/**
|
|
117
|
-
* Resolves the fetch scope, including the TeslaMate-backed ones. Exactly one of
|
|
118
|
-
* --country / --region / --all / --near|--home-from-teslamate / --charged.
|
|
119
|
-
*/
|
|
120
|
-
export declare const resolveFetchScope: (o: CommonOpts) => Promise<FetchScope>;
|
|
121
|
-
/** Maps CLI options to the api fetch options, optionally with an explicit scope. */
|
|
122
|
-
export declare const toFetchOptions: (o: CommonOpts, scope?: FetchScope) => FetchOptions;
|
|
123
95
|
/** Builds the sinks the user asked for (CLI flag or env). At least one required. */
|
|
124
96
|
export declare const buildStores: (o: CommonOpts) => IStore[];
|
|
125
97
|
/**
|
|
@@ -128,21 +100,36 @@ export declare const buildStores: (o: CommonOpts) => IStore[];
|
|
|
128
100
|
* env the process already has is left untouched.
|
|
129
101
|
*/
|
|
130
102
|
export declare const applyProxy: (o: CommonOpts) => void;
|
|
131
|
-
/**
|
|
132
|
-
export
|
|
133
|
-
/**
|
|
103
|
+
/** A Supercharger-selection method and how often (in days) it runs. */
|
|
104
|
+
export type DeterminationKind = "radius" | "country" | "outdated";
|
|
105
|
+
/** One enabled determination with its day-based cadence. */
|
|
106
|
+
export interface Determination {
|
|
107
|
+
kind: DeterminationKind;
|
|
108
|
+
everyDays: number;
|
|
109
|
+
}
|
|
110
|
+
/** The determinations the user enabled (at least one is required). */
|
|
111
|
+
export declare const buildDeterminations: (o: CommonOpts) => Determination[];
|
|
112
|
+
/**
|
|
113
|
+
* True when a determination with this cadence is due on `date`. Cadence is
|
|
114
|
+
* date-driven — `epochDay % everyDays === 0`, where epochDay is whole days since
|
|
115
|
+
* the Unix epoch (UTC) — so it survives restarts, with `7` landing on a fixed
|
|
116
|
+
* weekday and `30` meaning every 30 days.
|
|
117
|
+
*/
|
|
118
|
+
export declare const isDue: (everyDays: number, date: Date) => boolean;
|
|
119
|
+
/** The subset of `dets` whose cadence is due on `date`. */
|
|
120
|
+
export declare const dueDeterminations: (dets: Determination[], date: Date) => Determination[];
|
|
121
|
+
/**
|
|
122
|
+
* Run the given determinations as ONE snapshot: take the union of their target
|
|
123
|
+
* Superchargers (selected from the cached master list), fetch each site's pricing
|
|
124
|
+
* once, then fan the records out to the configured sinks. The union + de-dupe is
|
|
125
|
+
* what keeps requests down — a site several determinations want is fetched once.
|
|
126
|
+
*/
|
|
127
|
+
export declare const runDeterminations: (o: CommonOpts, dets: Determination[]) => Promise<void>;
|
|
128
|
+
/** `fetch` command: run every enabled determination once (ignoring cadence), then exit. */
|
|
134
129
|
export declare const runFetch: (o: CommonOpts) => Promise<void>;
|
|
135
130
|
/** ms from now until the next HH:MM (local); rolls to tomorrow if already passed. */
|
|
136
131
|
export declare const msUntil: (at: string) => number;
|
|
137
|
-
/**
|
|
138
|
-
* The largest tier radius whose cadence is due on `date`, or null if none is.
|
|
139
|
-
* A tier is "due" when `epochDay % everyDays === 0` (epochDay = whole days since
|
|
140
|
-
* the Unix epoch, UTC) — date-driven so it survives restarts, with `7` landing on
|
|
141
|
-
* a fixed weekday and `30` meaning every 30 days. Cumulative: the chosen radius
|
|
142
|
-
* already covers every smaller tier, so one fetch at it satisfies all due tiers.
|
|
143
|
-
*/
|
|
144
|
-
export declare const dueRadiusKm: (tiers: Tier[], date: Date) => number | null;
|
|
145
|
-
/** Runs once on start, then every day at o.at — keeping the process alive. */
|
|
132
|
+
/** Runs the due determinations on start, then every day at o.at — keeping the process alive. */
|
|
146
133
|
export declare const scheduleDaily: (o: ScheduleOpts) => Promise<void>;
|
|
147
134
|
/** Prints the countries and regions that have Superchargers. */
|
|
148
135
|
export declare const listCountries: () => Promise<void>;
|
package/dist/cli.common.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.common.d.ts","sourceRoot":"","sources":["../src/cli.common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,MAAM,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.common.d.ts","sourceRoot":"","sources":["../src/cli.common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAe3E,OAAO,EAOL,KAAK,MAAM,EACZ,MAAM,yCAAyC,CAAC;AAOjD,2DAA2D;AAC3D,eAAO,MAAM,WAAW,QAAO,MAET,CAAC;AAEvB,kFAAkF;AAClF,eAAO,MAAM,MAAM,QAAsB,CAAC;AAE1C;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAIpC,4DAA4D;AAC5D,eAAO,MAAM,aAAa,GAAI,GAAG,MAAM,KAAG,MAKzC,CAAC;AAEF,oDAAoD;AACpD,eAAO,MAAM,WAAW,GAAI,GAAG,MAAM,KAAG,MAKvC,CAAC;AAEF,iFAAiF;AACjF,eAAO,MAAM,YAAY,GAAI,GAAG,MAAM,KAAG,MAKxC,CAAC;AAEF,wDAAwD;AACxD,eAAO,MAAM,SAAS,GAAI,GAAG,MAAM,KAAG,MAIrC,CAAC;AAKF,0EAA0E;AAC1E,eAAO,MAAM,YAAY,6EAGC,CAAC;AAC3B,qEAAqE;AACrE,eAAO,MAAM,iBAAiB,yEAKJ,CAAC;AAG3B,sDAAsD;AACtD,eAAO,MAAM,aAA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eAAO,MAAM,iBAAiB,GAC5B,GAAG,UAAU,EACb,MAAM,aAAa,EAAE,KACpB,OAAO,CAAC,IAAI,CA8Dd,CAAC;AAEF,2FAA2F;AAC3F,eAAO,MAAM,QAAQ,GAAU,GAAG,UAAU,KAAG,OAAO,CAAC,IAAI,CAE1D,CAAC;AAEF,qFAAqF;AACrF,eAAO,MAAM,OAAO,GAAI,IAAI,MAAM,KAAG,MAOpC,CAAC;AAEF,gGAAgG;AAChG,eAAO,MAAM,aAAa,GAAU,GAAG,YAAY,KAAG,OAAO,CAAC,IAAI,CA8BjE,CAAC;AAEF,gEAAgE;AAChE,eAAO,MAAM,aAAa,QAAa,OAAO,CAAC,IAAI,CAclD,CAAC"}
|
package/dist/cli.common.js
CHANGED
|
@@ -3,23 +3,24 @@ import { readFileSync } from "node:fs";
|
|
|
3
3
|
import { dirname, resolve } from "node:path";
|
|
4
4
|
import { env, exit } from "node:process";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
-
import {
|
|
7
|
-
import { HttpStore,
|
|
6
|
+
import { countUnpricedSuperchargerCharges, fetchAllLocations, fetchHomeGeofence, fetchOutdatedChargeSites, fetchRecordsForLocations, inScope, isSupercharger, } from "@mxpicture/teslamate-extended-api/api";
|
|
7
|
+
import { HttpStore, ingestRecords, JsonFileStore, PostgresStore, TeslaMateChargeStore, TeslaMateGeofenceStore, } from "@mxpicture/teslamate-extended-api/store";
|
|
8
|
+
import { notifyFetchErrors, notifyUnpricedCharges } from "./notify.js";
|
|
8
9
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
10
|
/** Reads the CLI package version from its package.json. */
|
|
10
11
|
export const readVersion = () => JSON.parse(readFileSync(resolve(__dirname, "../package.json"), "utf8"))
|
|
11
12
|
.version;
|
|
12
|
-
/** One day in milliseconds — the schedule interval. */
|
|
13
|
+
/** One day in milliseconds — the schedule interval and the cadence clock unit. */
|
|
13
14
|
export const DAY_MS = 24 * 60 * 60 * 1000;
|
|
14
15
|
/**
|
|
15
|
-
* Match radius (km) for
|
|
16
|
-
* given Supercharger when it sits within this distance of it.
|
|
17
|
-
* covers the gap between where the car parks and the site's
|
|
18
|
-
* staying well under the spacing between distinct sites.
|
|
16
|
+
* Match radius (km) for the outdated-price determination: a TeslaMate charge
|
|
17
|
+
* location maps to a given Supercharger when it sits within this distance of it.
|
|
18
|
+
* ~300 m comfortably covers the gap between where the car parks and the site's
|
|
19
|
+
* listed point while staying well under the spacing between distinct sites.
|
|
19
20
|
*/
|
|
20
21
|
export const CHARGED_MATCH_KM = 0.3;
|
|
21
22
|
// ---------- argument parsers ----------
|
|
22
|
-
/** Parses a non-negative float (e.g. --delay). */
|
|
23
|
+
/** Parses a non-negative float (e.g. --delay, --radius). */
|
|
23
24
|
export const parseFloatArg = (v) => {
|
|
24
25
|
const n = Number(v);
|
|
25
26
|
if (!Number.isFinite(n) || n < 0)
|
|
@@ -33,54 +34,46 @@ export const parseIntArg = (v) => {
|
|
|
33
34
|
throw new InvalidArgumentError("must be a non-negative integer");
|
|
34
35
|
return n;
|
|
35
36
|
};
|
|
37
|
+
/** Parses a positive integer number of days (e.g. --*-every, --outdated-age). */
|
|
38
|
+
export const parseDaysArg = (v) => {
|
|
39
|
+
const n = parseInt(v, 10);
|
|
40
|
+
if (!Number.isInteger(n) || n < 1)
|
|
41
|
+
throw new InvalidArgumentError("must be a positive integer (>= 1)");
|
|
42
|
+
return n;
|
|
43
|
+
};
|
|
36
44
|
/** Validates an HH:MM (24h) time string (e.g. --at). */
|
|
37
45
|
export const parseTime = (v) => {
|
|
38
46
|
if (!/^([01]\d|2[0-3]):[0-5]\d$/.test(v))
|
|
39
47
|
throw new InvalidArgumentError("expected HH:MM (24h)");
|
|
40
48
|
return v;
|
|
41
49
|
};
|
|
42
|
-
/** Parses a "lat,lon" coordinate pair (e.g. --near). */
|
|
43
|
-
export const parseNear = (v) => {
|
|
44
|
-
const parts = v.split(",").map((s) => Number(s.trim()));
|
|
45
|
-
if (parts.length !== 2 || !parts.every((n) => Number.isFinite(n)))
|
|
46
|
-
throw new InvalidArgumentError("expected 'lat,lon' (e.g. 48.137,11.575)");
|
|
47
|
-
const [lat, lon] = parts;
|
|
48
|
-
if (lat < -90 || lat > 90 || lon < -180 || lon > 180)
|
|
49
|
-
throw new InvalidArgumentError("lat must be -90..90 and lon -180..180");
|
|
50
|
-
return { lat, lon };
|
|
51
|
-
};
|
|
52
|
-
/** Collects a repeatable --tier "radiusKm:everyDays" value onto the previous list. */
|
|
53
|
-
export const parseTier = (v, prev) => {
|
|
54
|
-
const [kmStr, daysStr] = v.split(":");
|
|
55
|
-
const radiusKm = Number(kmStr);
|
|
56
|
-
const everyDays = parseInt(daysStr ?? "", 10);
|
|
57
|
-
if (!Number.isFinite(radiusKm) || radiusKm <= 0)
|
|
58
|
-
throw new InvalidArgumentError("radius (km) must be a positive number");
|
|
59
|
-
if (!Number.isInteger(everyDays) || everyDays <= 0)
|
|
60
|
-
throw new InvalidArgumentError("everyDays must be a positive integer");
|
|
61
|
-
return [...prev, { radiusKm, everyDays }];
|
|
62
|
-
};
|
|
63
50
|
// ---------- commander options ----------
|
|
51
|
+
// --- determination: radius from the TeslaMate Home geofence ---
|
|
52
|
+
/** Commander option: radius (km) around the TeslaMate "Home" geofence. */
|
|
53
|
+
export const radiusOption = new Option("-r, --radius <km>", "Determination: fetch Superchargers within this many km of the TeslaMate 'Home' geofence").argParser(parseFloatArg);
|
|
54
|
+
/** Commander option: cadence (days) for the radius determination. */
|
|
55
|
+
export const radiusEveryOption = new Option("--radius-every <days>", "Run the radius determination every N days")
|
|
56
|
+
.default(7)
|
|
57
|
+
.argParser(parseDaysArg);
|
|
58
|
+
// --- determination: by country ---
|
|
64
59
|
/** Commander option: restrict to a single country. */
|
|
65
|
-
export const countryOption = new Option("-c, --country <name>", "
|
|
66
|
-
/** Commander option:
|
|
67
|
-
export const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
/** Commander option: also upsert each fetched Supercharger as a TeslaMate geofence. */
|
|
83
|
-
export const geofencesOption = new Option("--teslamate-geofences", "Also upsert each fetched Supercharger as a TeslaMate geofence (name + price); needs --postgres-url");
|
|
60
|
+
export const countryOption = new Option("-c, --country <name>", "Determination: fetch Superchargers in this country");
|
|
61
|
+
/** Commander option: cadence (days) for the country determination. */
|
|
62
|
+
export const countryEveryOption = new Option("--country-every <days>", "Run the country determination every N days")
|
|
63
|
+
.default(30)
|
|
64
|
+
.argParser(parseDaysArg);
|
|
65
|
+
// --- determination: missing/outdated price ---
|
|
66
|
+
/** Commander option: enable the missing/outdated-price determination. */
|
|
67
|
+
export const outdatedOption = new Option("--outdated", "Determination: fetch Superchargers whose TeslaMate price is missing or outdated; needs --postgres-url");
|
|
68
|
+
/** Commander option: cadence (days) for the outdated determination. */
|
|
69
|
+
export const outdatedEveryOption = new Option("--outdated-every <days>", "Run the outdated-price determination every N days")
|
|
70
|
+
.default(1)
|
|
71
|
+
.argParser(parseDaysArg);
|
|
72
|
+
/** Commander option: age (days) past which a managed geofence's price is "outdated". */
|
|
73
|
+
export const outdatedAgeOption = new Option("--outdated-age <days>", "A managed geofence's price counts as outdated once older than this many days")
|
|
74
|
+
.default(30)
|
|
75
|
+
.argParser(parseDaysArg);
|
|
76
|
+
// --- pricing / pacing ---
|
|
84
77
|
/** Commander option: pricing locale. */
|
|
85
78
|
export const localeOption = new Option("-l, --locale <locale>", "Locale for pricing").default("en-US");
|
|
86
79
|
/** Commander option: politeness delay between requests (seconds). */
|
|
@@ -91,6 +84,7 @@ export const delayOption = new Option("-d, --delay <seconds>", "Delay between re
|
|
|
91
84
|
export const limitOption = new Option("-n, --limit <count>", "Cap number of sites")
|
|
92
85
|
.default(0)
|
|
93
86
|
.argParser(parseIntArg);
|
|
87
|
+
// --- sinks ---
|
|
94
88
|
/** Commander option: JSON snapshot output directory. */
|
|
95
89
|
export const outOption = new Option("-o, --out <dir>", "Write JSON snapshots to this directory (env SUPERCHARGERS_OUT_DIR)");
|
|
96
90
|
/** Commander option: Postgres connection URL. */
|
|
@@ -103,37 +97,23 @@ export const httpUrlOption = new Option("--http-url <url>", "Push snapshots to t
|
|
|
103
97
|
export const httpUserOption = new Option("--http-user <user>", "Basic-auth username for --http-url (env SUPERCHARGERS_HTTP_USER)");
|
|
104
98
|
/** Commander option: Basic-auth password for --http-url. */
|
|
105
99
|
export const httpPasswordOption = new Option("--http-password <password>", "Basic-auth password for --http-url (env SUPERCHARGERS_HTTP_PASSWORD)");
|
|
106
|
-
/** Commander option:
|
|
107
|
-
export const
|
|
108
|
-
|
|
109
|
-
|
|
100
|
+
/** Commander option: also upsert each fetched Supercharger as a TeslaMate geofence. */
|
|
101
|
+
export const geofencesOption = new Option("--teslamate-geofences", "Upsert each fetched Supercharger as a TeslaMate geofence (name + price); needs --postgres-url");
|
|
102
|
+
/** Commander option: backfill TeslaMate charge costs from the managed geofence prices. */
|
|
103
|
+
export const chargesOption = new Option("--teslamate-charges", "Backfill TeslaMate charge costs from the managed geofence prices (implies --teslamate-geofences); needs --postgres-url");
|
|
104
|
+
/** Commander option: after the run, alert (Pushover) when Supercharger charges remain unpriced. */
|
|
105
|
+
export const alertUnpricedChargesOption = new Option("--alert-unpriced-charges", "After the run, send a Pushover alert if TeslaMate has Supercharger charges with no price; needs --postgres-url and PUSHOVER_API_TOKEN/PUSHOVER_USER_KEY");
|
|
106
|
+
// --- transport / scheduling ---
|
|
110
107
|
/**
|
|
111
108
|
* Commander option: route tesla.com requests through a proxy. Sets
|
|
112
109
|
* HTTPS_PROXY/ALL_PROXY for the curl subprocess (which already honors them when
|
|
113
110
|
* set in the environment). Use this to escape datacenter IPs Akamai 403s.
|
|
114
111
|
*/
|
|
115
112
|
export const proxyOption = new Option("--proxy <url>", "Route requests through this proxy (env HTTPS_PROXY / ALL_PROXY also honored)");
|
|
116
|
-
/**
|
|
117
|
-
export const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
o.region,
|
|
121
|
-
o.all ? "all" : undefined,
|
|
122
|
-
o.near ? "near" : undefined,
|
|
123
|
-
].filter(Boolean);
|
|
124
|
-
if (picked.length !== 1) {
|
|
125
|
-
console.error("Pick exactly one scope: --country | --region | --all | --near.");
|
|
126
|
-
exit(1);
|
|
127
|
-
}
|
|
128
|
-
if (o.near) {
|
|
129
|
-
if (o.radius === undefined) {
|
|
130
|
-
console.error("--near requires --radius <km>.");
|
|
131
|
-
exit(1);
|
|
132
|
-
}
|
|
133
|
-
return { near: { lat: o.near.lat, lon: o.near.lon, radiusKm: o.radius } };
|
|
134
|
-
}
|
|
135
|
-
return { country: o.country, region: o.region, all: o.all };
|
|
136
|
-
};
|
|
113
|
+
/** Commander option: daily run time for `schedule` (24h, local). */
|
|
114
|
+
export const atOption = new Option("-t, --at <HH:MM>", "Daily run time (24h, local)")
|
|
115
|
+
.default("03:30")
|
|
116
|
+
.argParser(parseTime);
|
|
137
117
|
/** pgUrl from --postgres-url or env; errors out when a flag needs it and it's absent. */
|
|
138
118
|
const requirePgUrl = (o, flag) => {
|
|
139
119
|
const pgUrl = o.postgresUrl ?? env.SUPERCHARGERS_PG_URL;
|
|
@@ -143,64 +123,8 @@ const requirePgUrl = (o, flag) => {
|
|
|
143
123
|
}
|
|
144
124
|
return pgUrl;
|
|
145
125
|
};
|
|
146
|
-
/**
|
|
147
|
-
|
|
148
|
-
if (o.near && o.homeFromTeslamate) {
|
|
149
|
-
console.error("Pass either --near or --home-from-teslamate, not both.");
|
|
150
|
-
exit(1);
|
|
151
|
-
}
|
|
152
|
-
if (o.near)
|
|
153
|
-
return o.near;
|
|
154
|
-
const home = await fetchHomeGeofence(requirePgUrl(o, "--home-from-teslamate"));
|
|
155
|
-
if (!home) {
|
|
156
|
-
console.error("No TeslaMate 'Home' geofence found (name ILIKE 'home').");
|
|
157
|
-
exit(1);
|
|
158
|
-
}
|
|
159
|
-
console.log(`Home geofence center: ${home.lat},${home.lon}.`);
|
|
160
|
-
return home;
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* Resolves the fetch scope, including the TeslaMate-backed ones. Exactly one of
|
|
164
|
-
* --country / --region / --all / --near|--home-from-teslamate / --charged.
|
|
165
|
-
*/
|
|
166
|
-
export const resolveFetchScope = async (o) => {
|
|
167
|
-
const nearScope = o.near || o.homeFromTeslamate;
|
|
168
|
-
const picked = [
|
|
169
|
-
o.country,
|
|
170
|
-
o.region,
|
|
171
|
-
o.all ? "all" : undefined,
|
|
172
|
-
nearScope ? "near" : undefined,
|
|
173
|
-
o.charged ? "charged" : undefined,
|
|
174
|
-
].filter(Boolean);
|
|
175
|
-
if (picked.length !== 1) {
|
|
176
|
-
console.error("Pick exactly one scope: --country | --region | --all | --near | --home-from-teslamate | --charged.");
|
|
177
|
-
exit(1);
|
|
178
|
-
}
|
|
179
|
-
if (o.charged) {
|
|
180
|
-
const points = await fetchChargeSiteCoords(requirePgUrl(o, "--charged"));
|
|
181
|
-
console.log(`Found ${points.length} charge locations in TeslaMate.`);
|
|
182
|
-
return { nearAny: { points, radiusKm: CHARGED_MATCH_KM } };
|
|
183
|
-
}
|
|
184
|
-
if (nearScope) {
|
|
185
|
-
if (o.radius === undefined) {
|
|
186
|
-
console.error("--near/--home-from-teslamate requires --radius <km>.");
|
|
187
|
-
exit(1);
|
|
188
|
-
}
|
|
189
|
-
const c = await resolveCenter(o);
|
|
190
|
-
return { near: { lat: c.lat, lon: c.lon, radiusKm: o.radius } };
|
|
191
|
-
}
|
|
192
|
-
return { country: o.country, region: o.region, all: o.all };
|
|
193
|
-
};
|
|
194
|
-
/** Maps CLI options to the api fetch options, optionally with an explicit scope. */
|
|
195
|
-
export const toFetchOptions = (o, scope) => {
|
|
196
|
-
return {
|
|
197
|
-
scope: scope ?? toScope(o),
|
|
198
|
-
locale: o.locale,
|
|
199
|
-
delayMs: o.delay * 1000,
|
|
200
|
-
limit: o.limit,
|
|
201
|
-
logger: (m) => console.log(m),
|
|
202
|
-
};
|
|
203
|
-
};
|
|
126
|
+
/** Directory the ~30 MB /all-locations download is cached in (so it's read monthly). */
|
|
127
|
+
const cacheDir = (o) => env.SUPERCHARGERS_CACHE_DIR ?? o.out ?? env.SUPERCHARGERS_OUT_DIR;
|
|
204
128
|
/** Builds the sinks the user asked for (CLI flag or env). At least one required. */
|
|
205
129
|
export const buildStores = (o) => {
|
|
206
130
|
const stores = [];
|
|
@@ -217,14 +141,20 @@ export const buildStores = (o) => {
|
|
|
217
141
|
username: o.httpUser ?? env.SUPERCHARGERS_HTTP_USER,
|
|
218
142
|
password: o.httpPassword ?? env.SUPERCHARGERS_HTTP_PASSWORD,
|
|
219
143
|
}));
|
|
220
|
-
|
|
144
|
+
// --teslamate-charges costs charges from the managed geofence prices, so it
|
|
145
|
+
// implies --teslamate-geofences; the geofence store must also run first.
|
|
146
|
+
if (o.teslamateGeofences || o.teslamateCharges)
|
|
221
147
|
stores.push(new TeslaMateGeofenceStore({
|
|
222
148
|
connectionString: requirePgUrl(o, "--teslamate-geofences"),
|
|
223
149
|
}));
|
|
150
|
+
if (o.teslamateCharges)
|
|
151
|
+
stores.push(new TeslaMateChargeStore({
|
|
152
|
+
connectionString: requirePgUrl(o, "--teslamate-charges"),
|
|
153
|
+
}));
|
|
224
154
|
if (stores.length === 0) {
|
|
225
|
-
console.error("No output configured. Pass --out <dir>, --postgres-url <url>,
|
|
226
|
-
"--http-url <url
|
|
227
|
-
"/ SUPERCHARGERS_HTTP_URL).");
|
|
155
|
+
console.error("No output configured. Pass --out <dir>, --postgres-url <url>, " +
|
|
156
|
+
"--http-url <url>, --teslamate-geofences and/or --teslamate-charges " +
|
|
157
|
+
"(or set SUPERCHARGERS_OUT_DIR / SUPERCHARGERS_PG_URL / SUPERCHARGERS_HTTP_URL).");
|
|
228
158
|
exit(1);
|
|
229
159
|
}
|
|
230
160
|
return stores;
|
|
@@ -240,24 +170,129 @@ export const applyProxy = (o) => {
|
|
|
240
170
|
env.HTTPS_PROXY = o.proxy;
|
|
241
171
|
env.ALL_PROXY = o.proxy;
|
|
242
172
|
};
|
|
243
|
-
/**
|
|
244
|
-
export const
|
|
173
|
+
/** The determinations the user enabled (at least one is required). */
|
|
174
|
+
export const buildDeterminations = (o) => {
|
|
175
|
+
const dets = [];
|
|
176
|
+
if (o.radius !== undefined)
|
|
177
|
+
dets.push({ kind: "radius", everyDays: o.radiusEvery });
|
|
178
|
+
if (o.country)
|
|
179
|
+
dets.push({ kind: "country", everyDays: o.countryEvery });
|
|
180
|
+
if (o.outdated)
|
|
181
|
+
dets.push({ kind: "outdated", everyDays: o.outdatedEvery });
|
|
182
|
+
if (dets.length === 0) {
|
|
183
|
+
console.error("Enable at least one determination: --radius <km>, --country <name>, and/or --outdated.");
|
|
184
|
+
exit(1);
|
|
185
|
+
}
|
|
186
|
+
return dets;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* True when a determination with this cadence is due on `date`. Cadence is
|
|
190
|
+
* date-driven — `epochDay % everyDays === 0`, where epochDay is whole days since
|
|
191
|
+
* the Unix epoch (UTC) — so it survives restarts, with `7` landing on a fixed
|
|
192
|
+
* weekday and `30` meaning every 30 days.
|
|
193
|
+
*/
|
|
194
|
+
export const isDue = (everyDays, date) => Math.floor(date.getTime() / DAY_MS) % everyDays === 0;
|
|
195
|
+
/** The subset of `dets` whose cadence is due on `date`. */
|
|
196
|
+
export const dueDeterminations = (dets, date) => dets.filter((d) => isDue(d.everyDays, date));
|
|
197
|
+
/**
|
|
198
|
+
* The fetch scope for one determination, or null to skip it this run:
|
|
199
|
+
* - radius: centered on the TeslaMate "Home" geofence; skipped with a warning
|
|
200
|
+
* when no Home geofence exists (radius-based selection is ignored).
|
|
201
|
+
* - country: a plain country match.
|
|
202
|
+
* - outdated: the charge sites whose managed price is missing/outdated, matched
|
|
203
|
+
* to Superchargers (skipped when there are none).
|
|
204
|
+
*/
|
|
205
|
+
const scopeForDetermination = async (det, o) => {
|
|
206
|
+
if (det.kind === "country")
|
|
207
|
+
return { country: o.country };
|
|
208
|
+
if (det.kind === "radius") {
|
|
209
|
+
if (o.radius === undefined)
|
|
210
|
+
return null;
|
|
211
|
+
const home = await fetchHomeGeofence(requirePgUrl(o, "--radius"));
|
|
212
|
+
if (!home) {
|
|
213
|
+
console.warn("No TeslaMate 'Home' geofence found (name ILIKE 'home'); skipping the radius determination.");
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
console.log(`Home geofence center: ${home.lat},${home.lon}.`);
|
|
217
|
+
return { near: { lat: home.lat, lon: home.lon, radiusKm: o.radius } };
|
|
218
|
+
}
|
|
219
|
+
// outdated
|
|
220
|
+
const sites = await fetchOutdatedChargeSites(requirePgUrl(o, "--outdated"), {
|
|
221
|
+
outdatedAgeDays: o.outdatedAge,
|
|
222
|
+
});
|
|
223
|
+
console.log(`Found ${sites.length} charge sites with missing/outdated pricing.`);
|
|
224
|
+
if (sites.length === 0)
|
|
225
|
+
return null;
|
|
226
|
+
return { nearAny: { points: sites, radiusKm: CHARGED_MATCH_KM } };
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Run the given determinations as ONE snapshot: take the union of their target
|
|
230
|
+
* Superchargers (selected from the cached master list), fetch each site's pricing
|
|
231
|
+
* once, then fan the records out to the configured sinks. The union + de-dupe is
|
|
232
|
+
* what keeps requests down — a site several determinations want is fetched once.
|
|
233
|
+
*/
|
|
234
|
+
export const runDeterminations = async (o, dets) => {
|
|
245
235
|
applyProxy(o);
|
|
246
|
-
|
|
236
|
+
// Build (and thereby validate) the sinks up front — before the expensive
|
|
237
|
+
// fetch — so a misconfigured run fails fast instead of after downloading
|
|
238
|
+
// everything; the `finally` always closes them.
|
|
247
239
|
const stores = buildStores(o);
|
|
240
|
+
const logger = (m) => console.log(m);
|
|
248
241
|
try {
|
|
249
|
-
const
|
|
242
|
+
const dir = cacheDir(o);
|
|
243
|
+
const all = (await fetchAllLocations(logger, dir ? { cacheDir: dir } : undefined)).filter(isSupercharger);
|
|
244
|
+
logger(` -> ${all.length} are Superchargers.`);
|
|
245
|
+
const targets = new Map();
|
|
246
|
+
for (const det of dets) {
|
|
247
|
+
const scope = await scopeForDetermination(det, o);
|
|
248
|
+
if (!scope)
|
|
249
|
+
continue;
|
|
250
|
+
let n = 0;
|
|
251
|
+
for (const loc of all) {
|
|
252
|
+
if (!inScope(loc, scope))
|
|
253
|
+
continue;
|
|
254
|
+
targets.set(loc.location_id ?? `${loc.latitude},${loc.longitude}`, loc);
|
|
255
|
+
n++;
|
|
256
|
+
}
|
|
257
|
+
logger(`Determination '${det.kind}': ${n} Superchargers.`);
|
|
258
|
+
}
|
|
259
|
+
let list = [...targets.values()];
|
|
260
|
+
if (o.limit)
|
|
261
|
+
list = list.slice(0, o.limit);
|
|
262
|
+
if (list.length === 0) {
|
|
263
|
+
logger("No Superchargers to fetch; nothing to do.");
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const summary = await fetchRecordsForLocations(list, {
|
|
267
|
+
locale: o.locale,
|
|
268
|
+
delayMs: o.delay * 1000,
|
|
269
|
+
logger,
|
|
270
|
+
});
|
|
271
|
+
const res = await ingestRecords(summary.records, stores);
|
|
250
272
|
console.log(`Saved ${res.count} Superchargers (run ${res.runId}, ` +
|
|
251
273
|
`${res.fetchedAt.toISOString()}).`);
|
|
274
|
+
// Opt-in Pushover alerts (no-ops unless PUSHOVER_* env is set).
|
|
275
|
+
await notifyFetchErrors(summary, logger);
|
|
276
|
+
if (o.alertUnpricedCharges) {
|
|
277
|
+
const pgUrl = o.postgresUrl ?? env.SUPERCHARGERS_PG_URL;
|
|
278
|
+
if (!pgUrl) {
|
|
279
|
+
logger("--alert-unpriced-charges needs --postgres-url (or env SUPERCHARGERS_PG_URL); skipping the unpriced-charge alert.");
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
const unpriced = await countUnpricedSuperchargerCharges(pgUrl);
|
|
283
|
+
logger(`Unpriced Supercharger charges: ${unpriced}.`);
|
|
284
|
+
await notifyUnpricedCharges(unpriced, logger);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
252
287
|
}
|
|
253
288
|
finally {
|
|
254
289
|
for (const s of stores)
|
|
255
290
|
await s.close?.();
|
|
256
291
|
}
|
|
257
292
|
};
|
|
258
|
-
/** `fetch` command:
|
|
293
|
+
/** `fetch` command: run every enabled determination once (ignoring cadence), then exit. */
|
|
259
294
|
export const runFetch = async (o) => {
|
|
260
|
-
await
|
|
295
|
+
await runDeterminations(o, buildDeterminations(o));
|
|
261
296
|
};
|
|
262
297
|
/** ms from now until the next HH:MM (local); rolls to tomorrow if already passed. */
|
|
263
298
|
export const msUntil = (at) => {
|
|
@@ -269,47 +304,18 @@ export const msUntil = (at) => {
|
|
|
269
304
|
next.setTime(next.getTime() + DAY_MS);
|
|
270
305
|
return next.getTime() - now.getTime();
|
|
271
306
|
};
|
|
272
|
-
/**
|
|
273
|
-
* The largest tier radius whose cadence is due on `date`, or null if none is.
|
|
274
|
-
* A tier is "due" when `epochDay % everyDays === 0` (epochDay = whole days since
|
|
275
|
-
* the Unix epoch, UTC) — date-driven so it survives restarts, with `7` landing on
|
|
276
|
-
* a fixed weekday and `30` meaning every 30 days. Cumulative: the chosen radius
|
|
277
|
-
* already covers every smaller tier, so one fetch at it satisfies all due tiers.
|
|
278
|
-
*/
|
|
279
|
-
export const dueRadiusKm = (tiers, date) => {
|
|
280
|
-
const epochDay = Math.floor(date.getTime() / DAY_MS);
|
|
281
|
-
const due = tiers.filter((t) => epochDay % t.everyDays === 0);
|
|
282
|
-
if (due.length === 0)
|
|
283
|
-
return null;
|
|
284
|
-
return Math.max(...due.map((t) => t.radiusKm));
|
|
285
|
-
};
|
|
286
|
-
/** Runs once on start, then every day at o.at — keeping the process alive. */
|
|
307
|
+
/** Runs the due determinations on start, then every day at o.at — keeping the process alive. */
|
|
287
308
|
export const scheduleDaily = async (o) => {
|
|
288
|
-
const
|
|
289
|
-
if (tiers.length > 0 && !o.near && !o.homeFromTeslamate) {
|
|
290
|
-
console.error("--tier requires --near <lat,lon> or --home-from-teslamate.");
|
|
291
|
-
exit(1);
|
|
292
|
-
}
|
|
293
|
-
// Resolve the tier center once (a coordinate, or the TeslaMate "Home" geofence).
|
|
294
|
-
const center = tiers.length > 0 ? await resolveCenter(o) : undefined;
|
|
309
|
+
const dets = buildDeterminations(o);
|
|
295
310
|
const safeRun = async () => {
|
|
311
|
+
const due = dueDeterminations(dets, new Date());
|
|
312
|
+
if (due.length === 0) {
|
|
313
|
+
console.log("No determination due today; skipping run.");
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
console.log(`Determinations due today: ${due.map((d) => d.kind).join(", ")}.`);
|
|
296
317
|
try {
|
|
297
|
-
|
|
298
|
-
const radiusKm = dueRadiusKm(tiers, new Date());
|
|
299
|
-
if (radiusKm === null) {
|
|
300
|
-
console.log("No tier due today; skipping run.");
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
console.log(`Tier due: fetching within ${radiusKm} km of ${center.lat},${center.lon}.`);
|
|
304
|
-
await runOnce(o, {
|
|
305
|
-
near: { lat: center.lat, lon: center.lon, radiusKm },
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
else {
|
|
309
|
-
// No tiers: country/region/all, --near, --home-from-teslamate, or --charged
|
|
310
|
-
// (re-resolved each fire so new charge locations are picked up over time).
|
|
311
|
-
await runOnce(o, await resolveFetchScope(o));
|
|
312
|
-
}
|
|
318
|
+
await runDeterminations(o, due);
|
|
313
319
|
}
|
|
314
320
|
catch (e) {
|
|
315
321
|
console.error("Run failed:", e instanceof Error ? e.message : e);
|
|
@@ -328,7 +334,8 @@ export const scheduleDaily = async (o) => {
|
|
|
328
334
|
};
|
|
329
335
|
/** Prints the countries and regions that have Superchargers. */
|
|
330
336
|
export const listCountries = async () => {
|
|
331
|
-
const
|
|
337
|
+
const dir = env.SUPERCHARGERS_CACHE_DIR ?? env.SUPERCHARGERS_OUT_DIR;
|
|
338
|
+
const locations = (await fetchAllLocations(undefined, dir ? { cacheDir: dir } : undefined)).filter(isSupercharger);
|
|
332
339
|
const countries = [
|
|
333
340
|
...new Set(locations.map((l) => l.country).filter(Boolean)),
|
|
334
341
|
].sort();
|
package/dist/cli.common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.common.js","sourceRoot":"","sources":["../src/cli.common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,GAGf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,sBAAsB,GAEvB,MAAM,yCAAyC,CAAC;AAEjD,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,2DAA2D;AAC3D,MAAM,CAAC,MAAM,WAAW,GAAG,GAAW,EAAE,CACtC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,iBAAiB,CAAC,EAAE,MAAM,CAAC,CAAC;KACpE,OAAiB,CAAC;AAEvB,uDAAuD;AACvD,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,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ACT,MAAM,OAAO,GAAG;QACd,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;KAC3D,CAAC,IAAI,EAAE,CAAC;IACT,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5C,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC5B,KAAK,MAAM,CAAC,IAAI,SAAS;QAAE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAClD,CAAC,CAAC"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -2,17 +2,23 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* teslamate-superchargers
|
|
4
4
|
* =======================
|
|
5
|
-
* Fetch
|
|
5
|
+
* Fetch Tesla Supercharger locations + pricing (via the public tesla.com
|
|
6
6
|
* endpoints, see `@mxpicture/teslamate-extended-api`) and persist each run as a
|
|
7
|
-
* dated snapshot — to JSON files and/or
|
|
8
|
-
* under its own timestamp, repeated runs build a price history.
|
|
7
|
+
* dated snapshot — to JSON files, PostgreSQL and/or TeslaMate. Because every run
|
|
8
|
+
* is stored under its own timestamp, repeated runs build a price history.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Which Superchargers to fetch is chosen by one or more "determinations", each
|
|
11
|
+
* with its own day-based cadence:
|
|
12
|
+
* --radius <km> within km of the TeslaMate "Home" geofence (--radius-every)
|
|
13
|
+
* --country <name> every Supercharger in a country (--country-every)
|
|
14
|
+
* --outdated sites whose TeslaMate price is missing/old (--outdated-every)
|
|
15
|
+
*
|
|
16
|
+
* teslamate-superchargers fetch --country Germany --out ./data
|
|
17
|
+
* teslamate-superchargers schedule --radius 100 --outdated --postgres-url "$PG_URL"
|
|
12
18
|
* teslamate-superchargers list-countries
|
|
13
19
|
*
|
|
14
|
-
* The `schedule` command runs
|
|
15
|
-
* process alive — so a single container
|
|
20
|
+
* The `schedule` command runs the due determinations on start and then daily at
|
|
21
|
+
* --at, keeping the process alive — so a single container refreshes the data.
|
|
16
22
|
*/
|
|
17
23
|
export {};
|
|
18
24
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;GAoBG"}
|
package/dist/cli.js
CHANGED
|
@@ -2,36 +2,44 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* teslamate-superchargers
|
|
4
4
|
* =======================
|
|
5
|
-
* Fetch
|
|
5
|
+
* Fetch Tesla Supercharger locations + pricing (via the public tesla.com
|
|
6
6
|
* endpoints, see `@mxpicture/teslamate-extended-api`) and persist each run as a
|
|
7
|
-
* dated snapshot — to JSON files and/or
|
|
8
|
-
* under its own timestamp, repeated runs build a price history.
|
|
7
|
+
* dated snapshot — to JSON files, PostgreSQL and/or TeslaMate. Because every run
|
|
8
|
+
* is stored under its own timestamp, repeated runs build a price history.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Which Superchargers to fetch is chosen by one or more "determinations", each
|
|
11
|
+
* with its own day-based cadence:
|
|
12
|
+
* --radius <km> within km of the TeslaMate "Home" geofence (--radius-every)
|
|
13
|
+
* --country <name> every Supercharger in a country (--country-every)
|
|
14
|
+
* --outdated sites whose TeslaMate price is missing/old (--outdated-every)
|
|
15
|
+
*
|
|
16
|
+
* teslamate-superchargers fetch --country Germany --out ./data
|
|
17
|
+
* teslamate-superchargers schedule --radius 100 --outdated --postgres-url "$PG_URL"
|
|
12
18
|
* teslamate-superchargers list-countries
|
|
13
19
|
*
|
|
14
|
-
* The `schedule` command runs
|
|
15
|
-
* process alive — so a single container
|
|
20
|
+
* The `schedule` command runs the due determinations on start and then daily at
|
|
21
|
+
* --at, keeping the process alive — so a single container refreshes the data.
|
|
16
22
|
*/
|
|
17
23
|
import { program } from "@commander-js/extra-typings";
|
|
18
24
|
import { argv, exit } from "node:process";
|
|
19
|
-
import {
|
|
25
|
+
import { alertUnpricedChargesOption, atOption, chargesOption, countryEveryOption, countryOption, delayOption, geofencesOption, httpPasswordOption, httpUrlOption, httpUserOption, limitOption, listCountries, localeOption, outdatedAgeOption, outdatedEveryOption, outdatedOption, outOption, pgTableOption, postgresUrlOption, proxyOption, radiusEveryOption, radiusOption, readVersion, runFetch, scheduleDaily, } from "./cli.common.js";
|
|
20
26
|
program
|
|
21
27
|
.name("teslamate-superchargers")
|
|
22
28
|
.version(readVersion())
|
|
23
29
|
.description("Fetch + store Tesla Supercharger locations and pricing");
|
|
24
30
|
program
|
|
25
31
|
.command("fetch")
|
|
26
|
-
.description("
|
|
27
|
-
.addOption(countryOption)
|
|
28
|
-
.addOption(regionOption)
|
|
29
|
-
.addOption(allOption)
|
|
30
|
-
.addOption(nearOption)
|
|
32
|
+
.description("Run every enabled determination once and store it, then exit")
|
|
31
33
|
.addOption(radiusOption)
|
|
32
|
-
.addOption(
|
|
33
|
-
.addOption(
|
|
34
|
+
.addOption(radiusEveryOption)
|
|
35
|
+
.addOption(countryOption)
|
|
36
|
+
.addOption(countryEveryOption)
|
|
37
|
+
.addOption(outdatedOption)
|
|
38
|
+
.addOption(outdatedEveryOption)
|
|
39
|
+
.addOption(outdatedAgeOption)
|
|
34
40
|
.addOption(geofencesOption)
|
|
41
|
+
.addOption(chargesOption)
|
|
42
|
+
.addOption(alertUnpricedChargesOption)
|
|
35
43
|
.addOption(localeOption)
|
|
36
44
|
.addOption(delayOption)
|
|
37
45
|
.addOption(limitOption)
|
|
@@ -45,16 +53,17 @@ program
|
|
|
45
53
|
.action((o) => runFetch(o));
|
|
46
54
|
program
|
|
47
55
|
.command("schedule")
|
|
48
|
-
.description("
|
|
49
|
-
.addOption(countryOption)
|
|
50
|
-
.addOption(regionOption)
|
|
51
|
-
.addOption(allOption)
|
|
52
|
-
.addOption(nearOption)
|
|
56
|
+
.description("Run the due determinations now, then daily at --at (keeps running)")
|
|
53
57
|
.addOption(radiusOption)
|
|
54
|
-
.addOption(
|
|
55
|
-
.addOption(
|
|
56
|
-
.addOption(
|
|
58
|
+
.addOption(radiusEveryOption)
|
|
59
|
+
.addOption(countryOption)
|
|
60
|
+
.addOption(countryEveryOption)
|
|
61
|
+
.addOption(outdatedOption)
|
|
62
|
+
.addOption(outdatedEveryOption)
|
|
63
|
+
.addOption(outdatedAgeOption)
|
|
57
64
|
.addOption(geofencesOption)
|
|
65
|
+
.addOption(chargesOption)
|
|
66
|
+
.addOption(alertUnpricedChargesOption)
|
|
58
67
|
.addOption(localeOption)
|
|
59
68
|
.addOption(delayOption)
|
|
60
69
|
.addOption(limitOption)
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,0BAA0B,EAC1B,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,WAAW,EACX,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX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SAAS,CAAC,mBAAmB,CAAC;KAC9B,SAAS,CAAC,iBAAiB,CAAC;KAC5B,SAAS,CAAC,eAAe,CAAC;KAC1B,SAAS,CAAC,aAAa,CAAC;KACxB,SAAS,CAAC,0BAA0B,CAAC;KACrC,SAAS,CAAC,YAAY,CAAC;KACvB,SAAS,CAAC,WAAW,CAAC;KACtB,SAAS,CAAC,WAAW,CAAC;KACtB,SAAS,CAAC,SAAS,CAAC;KACpB,SAAS,CAAC,iBAAiB,CAAC;KAC5B,SAAS,CAAC,aAAa,CAAC;KACxB,SAAS,CAAC,aAAa,CAAC;KACxB,SAAS,CAAC,cAAc,CAAC;KACzB,SAAS,CAAC,kBAAkB,CAAC;KAC7B,SAAS,CAAC,WAAW,CAAC;KACtB,SAAS,CAAC,QAAQ,CAAC;KACnB,MAAM,CAAC,aAAa,CAAC,CAAC;AAEzB,OAAO;KACJ,OAAO,CAAC,gBAAgB,CAAC;KACzB,WAAW,CAAC,wDAAwD,CAAC;KACrE,MAAM,CAAC,aAAa,CAAC,CAAC;AAEzB,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IACnC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjB,IAAI,CAAC,CAAC,CAAC,CAAC;AACV,CAAC,CAAC,CAAC"}
|
package/dist/notify.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pushover alerts for a scraper run. Both helpers are no-ops when
|
|
3
|
+
* PUSHOVER_API_TOKEN / PUSHOVER_USER_KEY are unset, so alerting is opt-in via
|
|
4
|
+
* the environment (the deployment injects the same creds the health-watch /
|
|
5
|
+
* backup scripts use). Sending never throws (see {@link sendPushover}).
|
|
6
|
+
*/
|
|
7
|
+
import { type FetchRunSummary } from "@mxpicture/teslamate-extended-api/api";
|
|
8
|
+
/**
|
|
9
|
+
* Alert when a fetch run had hard failures (`fail > 0`). City-mismatch warnings
|
|
10
|
+
* are reported in the body for context but never trigger an alert on their own.
|
|
11
|
+
*/
|
|
12
|
+
export declare const notifyFetchErrors: (summary: FetchRunSummary, logger?: (m: string) => void) => Promise<void>;
|
|
13
|
+
/** Alert when Supercharger charges remain unpriced after the run. */
|
|
14
|
+
export declare const notifyUnpricedCharges: (count: number, logger?: (m: string) => void) => Promise<void>;
|
|
15
|
+
//# sourceMappingURL=notify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notify.d.ts","sourceRoot":"","sources":["../src/notify.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,uCAAuC,CAAC;AAK/C;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,SAAS,eAAe,EACxB,SAAQ,CAAC,CAAC,EAAE,MAAM,KAAK,IAAkB,KACxC,OAAO,CAAC,IAAI,CAuBd,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,GAChC,OAAO,MAAM,EACb,SAAQ,CAAC,CAAC,EAAE,MAAM,KAAK,IAAkB,KACxC,OAAO,CAAC,IAAI,CAYd,CAAC"}
|
package/dist/notify.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pushover alerts for a scraper run. Both helpers are no-ops when
|
|
3
|
+
* PUSHOVER_API_TOKEN / PUSHOVER_USER_KEY are unset, so alerting is opt-in via
|
|
4
|
+
* the environment (the deployment injects the same creds the health-watch /
|
|
5
|
+
* backup scripts use). Sending never throws (see {@link sendPushover}).
|
|
6
|
+
*/
|
|
7
|
+
import { pushoverConfigFromEnv, sendPushover, } from "@mxpicture/teslamate-extended-api/api";
|
|
8
|
+
/** Max failed-site lines to include in an alert body before truncating. */
|
|
9
|
+
const MAX_LISTED = 10;
|
|
10
|
+
/**
|
|
11
|
+
* Alert when a fetch run had hard failures (`fail > 0`). City-mismatch warnings
|
|
12
|
+
* are reported in the body for context but never trigger an alert on their own.
|
|
13
|
+
*/
|
|
14
|
+
export const notifyFetchErrors = async (summary, logger = console.log) => {
|
|
15
|
+
if (summary.fail <= 0)
|
|
16
|
+
return;
|
|
17
|
+
const cfg = pushoverConfigFromEnv();
|
|
18
|
+
if (!cfg)
|
|
19
|
+
return;
|
|
20
|
+
const total = summary.ok + summary.warn + summary.fail;
|
|
21
|
+
const listed = summary.failures
|
|
22
|
+
.slice(0, MAX_LISTED)
|
|
23
|
+
.map((f) => `• ${f.label}: ${f.reason}`)
|
|
24
|
+
.join("\n");
|
|
25
|
+
const more = summary.failures.length > MAX_LISTED
|
|
26
|
+
? `\n…and ${summary.failures.length - MAX_LISTED} more.`
|
|
27
|
+
: "";
|
|
28
|
+
const message = `${summary.fail} of ${total} Superchargers failed ` +
|
|
29
|
+
`(ok=${summary.ok}, warn=${summary.warn}).\n${listed}${more}`;
|
|
30
|
+
await sendPushover(cfg, { title: "⚠️ Supercharger fetch errors", message, priority: 1 }, logger);
|
|
31
|
+
};
|
|
32
|
+
/** Alert when Supercharger charges remain unpriced after the run. */
|
|
33
|
+
export const notifyUnpricedCharges = async (count, logger = console.log) => {
|
|
34
|
+
if (count <= 0)
|
|
35
|
+
return;
|
|
36
|
+
const cfg = pushoverConfigFromEnv();
|
|
37
|
+
if (!cfg)
|
|
38
|
+
return;
|
|
39
|
+
await sendPushover(cfg, {
|
|
40
|
+
title: "⚠️ Unpriced Supercharger charges",
|
|
41
|
+
message: `${count} Supercharger charge(s) in TeslaMate still have no price.`,
|
|
42
|
+
}, logger);
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=notify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notify.js","sourceRoot":"","sources":["../src/notify.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,qBAAqB,EACrB,YAAY,GAEb,MAAM,uCAAuC,CAAC;AAE/C,2EAA2E;AAC3E,MAAM,UAAU,GAAG,EAAE,C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G,GAAG,qBAAqB,EAAE,CAAC;IACpC,IAAI,CAAC,GAAG;QAAE,OAAO;IACjB,MAAM,YAAY,CAChB,GAAG,EACH;QACE,KAAK,EAAE,kCAAkC;QACzC,OAAO,EAAE,GAAG,KAAK,2DAA2D;KAC7E,EACD,MAAM,CACP,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mxpicture/teslamate-extended-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "CLI to fetch + store Tesla Supercharger locations and pricing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "MXPicture",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@commander-js/extra-typings": "^14.0.0",
|
|
39
|
-
"@mxpicture/teslamate-extended-api": "^
|
|
39
|
+
"@mxpicture/teslamate-extended-api": "^3.1.3",
|
|
40
40
|
"commander": "^14.0.3"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|