@mxpicture/tesla-superchargers-api 0.1.33 → 0.1.34

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.
@@ -0,0 +1,12 @@
1
+ import { IApi } from "./IApi.js";
2
+ import type { FxSyncSummary } from "../types/fx.types.js";
3
+ export declare class FxRatesApi extends IApi {
4
+ /**
5
+ * Fill the window's missing (date, currency) rates and prune everything
6
+ * outside it. A date the feed has not published yet is reported in
7
+ * `missingDates` and retried by the next run, never a failure.
8
+ */
9
+ sync(): Promise<FxSyncSummary>;
10
+ }
11
+ export declare const fxRatesApi: () => FxRatesApi;
12
+ //# sourceMappingURL=FxRatesApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FxRatesApi.d.ts","sourceRoot":"","sources":["../../src/api/FxRatesApi.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAOjC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAY1D,qBAAa,UAAW,SAAQ,IAAI;IAClC;;;;OAIG;IACU,IAAI,IAAI,OAAO,CAAC,aAAa,CAAC;CA2D5C;AAGD,eAAO,MAAM,UAAU,kBAAoC,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Daily FX rate sync: the primary filler of `pic_fx_rates`. One request per
3
+ * UTC date against the base-EUR feed covers every currency the price history
4
+ * uses, so a window of `FX_SYNC_DAYS` days costs at most that many requests —
5
+ * and none at all once the window is fully cached. `fxToEur` keeps its lazy
6
+ * per-charge fetch as the fallback for what the window does not cover.
7
+ */
8
+ import { picFxRatesStore, picPricebooksStore, } from "@mxpicture/tesla-superchargers-mate/store";
9
+ import { IApi } from "./IApi.js";
10
+ import { BASE_CURRENCY, FX_SYNC_DAYS, fetchEurRates, rateToEur, } from "../common/fx.common.js";
11
+ const DAY_MS = 24 * 60 * 60 * 1000;
12
+ /** The last `days` UTC calendar days as `YYYY-MM-DD`, oldest first, today last. */
13
+ const utcDates = (days) => {
14
+ const today = Date.now();
15
+ return Array.from({ length: days }, (_, i) => new Date(today - (days - 1 - i) * DAY_MS).toISOString().slice(0, 10));
16
+ };
17
+ export class FxRatesApi extends IApi {
18
+ /**
19
+ * Fill the window's missing (date, currency) rates and prune everything
20
+ * outside it. A date the feed has not published yet is reported in
21
+ * `missingDates` and retried by the next run, never a failure.
22
+ */
23
+ async sync() {
24
+ const currencies = (await picPricebooksStore().getDistinctCurrencies()).filter((c) => c !== BASE_CURRENCY);
25
+ const dates = utcDates(FX_SYNC_DAYS);
26
+ const fromDate = dates[0];
27
+ const fetchedDates = [];
28
+ const missingDates = [];
29
+ const unknownCurrencies = new Set();
30
+ const rows = [];
31
+ if (currencies.length) {
32
+ const coverage = new Set((await picFxRatesStore().getCoverage(fromDate)).map((row) => `${row.rate_date.toISOString().slice(0, 10)} ${row.quote_currency.toUpperCase()}`));
33
+ for (const rateDate of dates) {
34
+ const missing = currencies.filter((c) => !coverage.has(`${rateDate} ${c}`));
35
+ if (!missing.length)
36
+ continue;
37
+ const rates = await fetchEurRates(rateDate);
38
+ if (!rates) {
39
+ missingDates.push(rateDate);
40
+ continue;
41
+ }
42
+ fetchedDates.push(rateDate);
43
+ for (const quoteCurrency of missing) {
44
+ const rate = rateToEur(rates[quoteCurrency.toLowerCase()]);
45
+ if (rate === null) {
46
+ unknownCurrencies.add(quoteCurrency);
47
+ continue;
48
+ }
49
+ rows.push({ rateDate, quoteCurrency, rateToEur: String(rate) });
50
+ }
51
+ }
52
+ }
53
+ return {
54
+ days: FX_SYNC_DAYS,
55
+ fromDate,
56
+ currencies,
57
+ fetchedDates,
58
+ missingDates,
59
+ unknownCurrencies: [...unknownCurrencies],
60
+ inserted: await picFxRatesStore().putRates(rows),
61
+ deleted: await picFxRatesStore().deleteStale(fromDate, currencies),
62
+ };
63
+ }
64
+ }
65
+ let _api = null;
66
+ export const fxRatesApi = () => (_api ??= new FxRatesApi());
67
+ //# sourceM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Aa,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAClE,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO;YACL,IAAI,EAAE,YAAY;YAClB,QAAQ;YACR,UAAU;YACV,YAAY;YACZ,YAAY;YACZ,iBAAiB,EAAE,CAAC,GAAG,iBAAiB,CAAC;YACzC,QAAQ,EAAE,MAAM,eAAe,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;YAChD,OAAO,EAAE,MAAM,eAAe,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,UAAU,CAAC;SACnE,CAAC;IACJ,CAAC;CACF;AAED,IAAI,IAAI,GAAsB,IAAI,CAAC;AACnC,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,CAAC,IAAI,KAAK,IAAI,UAAU,EAAE,CAAC,CAAC"}
@@ -1,6 +1,7 @@
1
1
  export * from "./ChargersApi.js";
2
2
  export * from "./ChargingProcessesApi.js";
3
3
  export * from "./FailuresApi.js";
4
+ export * from "./FxRatesApi.js";
4
5
  export * from "./IApi.js";
5
6
  export * from "./InvoicesApi.js";
6
7
  export * from "./SlugsApi.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
package/dist/api/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  export * from "./ChargersApi.js";
3
3
  export * from "./ChargingProcessesApi.js";
4
4
  export * from "./FailuresApi.js";
5
+ export * from "./FxRatesApi.js";
5
6
  export * from "./IApi.js";
6
7
  export * from "./InvoicesApi.js";
7
8
  export * from "./SlugsApi.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
@@ -1,7 +1,15 @@
1
1
  /** The currency TeslaMate's `cost` column is aggregated in. */
2
2
  export declare const BASE_CURRENCY = "EUR";
3
- /** Fetch the EUR-per-unit rate, primary then fallback; null on any failure. */
4
- export declare const fetchRateToEur: (rateDate: string, quoteLower: string) => Promise<number | null>;
3
+ /** How many UTC days back the daily sync covers, today included. */
4
+ export declare const FX_SYNC_DAYS = 7;
5
+ /**
6
+ * All quote-per-EUR rates for a date, primary host then mirror; null when the
7
+ * date is not published yet or both hosts fail. One request serves every
8
+ * currency of that day.
9
+ */
10
+ export declare const fetchEurRates: (rateDate: string) => Promise<Record<string, number> | null>;
11
+ /** Invert a quote-per-EUR rate into EUR per 1 unit; null when unusable. */
12
+ export declare const rateToEur: (quotePerEur: number | undefined) => number | null;
5
13
  /**
6
14
  * EUR per 1 unit of `currencyCode` on the day of `at` (UTC), or null when the
7
15
  * rate can't be resolved. EUR returns 1 without any store or network access.
@@ -1 +1 @@
1
- {"version":3,"file":"fx.common.d.ts","sourceRoot":"","sources":["../../src/common/fx.common.ts"],"names":[],"mappings":"AAYA,+DAA+D;AAC/D,eAAO,MAAM,aAAa,QAAQ,CAAC;AAgBnC,+EAA+E;AAC/E,eAAO,MAAM,cAAc,GACzB,UAAU,MAAM,EAChB,YAAY,MAAM,KACjB,OAAO,CAAC,MAAM,GAAG,IAAI,CAevB,CAAC;AAKF;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAClB,cAAc,MAAM,EACpB,IAAI,IAAI,KACP,OAAO,CAAC,MAAM,GAAG,IAAI,CAevB,CAAC"}
1
+ {"version":3,"file":"fx.common.d.ts","sourceRoot":"","sources":["../../src/common/fx.common.ts"],"names":[],"mappings":"AAYA,+DAA+D;AAC/D,eAAO,MAAM,aAAa,QAAQ,CAAC;AAEnC,oEAAoE;AACpE,eAAO,MAAM,YAAY,IAAI,CAAC;AAgB9B;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,UAAU,MAAM,KACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAevC,CAAC;AAEF,2EAA2E;AAC3E,eAAO,MAAM,SAAS,GAAI,aAAa,MAAM,GAAG,SAAS,KAAG,MAAM,GAAG,IAK3D,CAAC;AAKX;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAClB,cAAc,MAAM,EACpB,IAAI,IAAI,KACP,OAAO,CAAC,MAAM,GAAG,IAAI,CAgBvB,CAAC"}
@@ -11,31 +11,36 @@ import { picFxRatesStore } from "@mxpicture/tesla-superchargers-mate/store";
11
11
  import { singleFlight } from "./concurrency.common.js";
12
12
  /** The currency TeslaMate's `cost` column is aggregated in. */
13
13
  export const BASE_CURRENCY = "EUR";
14
+ /** How many UTC days back the daily sync covers, today included. */
15
+ export const FX_SYNC_DAYS = 7;
14
16
  /** Abort a stalled FX request rather than block a pricing pass on it. */
15
17
  const FX_HTTP_TIMEOUT_MS = 10_000;
16
18
  /**
17
19
  * Historical daily rates from the keyless fawazahmed0/exchange-api. Primary is
18
- * the jsDelivr CDN, with the pages.dev mirror as fallback. The response is
19
- * `{ "date": ..., "{quote}": { "eur": <number>, ... } }`, so `[quote].eur` is
20
- * EUR per 1 unit of the quote currency.
20
+ * the jsDelivr CDN, with the pages.dev mirror as fallback. The base-EUR file's
21
+ * response is `{ "date": ..., "eur": { "czk": <number>, ... } }`, so `eur` maps
22
+ * every quote currency to the units of it worth 1 EUR.
21
23
  */
22
24
  const fxUrls = (rateDate, quoteLower) => [
23
25
  `https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@${rateDate}/v1/currencies/${quoteLower}.json`,
24
26
  `https://${rateDate}.currency-api.pages.dev/v1/currencies/${quoteLower}.json`,
25
27
  ];
26
- /** Fetch the EUR-per-unit rate, primary then fallback; null on any failure. */
27
- export const fetchRateToEur = async (rateDate, quoteLower) => {
28
- for (const url of fxUrls(rateDate, quoteLower)) {
28
+ /**
29
+ * All quote-per-EUR rates for a date, primary host then mirror; null when the
30
+ * date is not published yet or both hosts fail. One request serves every
31
+ * currency of that day.
32
+ */
33
+ export const fetchEurRates = async (rateDate) => {
34
+ for (const url of fxUrls(rateDate, "eur")) {
29
35
  try {
30
36
  const res = await fetch(url, {
31
37
  signal: AbortSignal.timeout(FX_HTTP_TIMEOUT_MS),
32
38
  });
33
39
  if (!res.ok)
34
40
  continue;
35
- const body = await res.json();
36
- const rate = body?.[quoteLower]?.eur;
37
- if (typeof rate === "number" && Number.isFinite(rate))
38
- return rate;
41
+ const rates = (await res.json())?.eur;
42
+ if (rates && typeof rates === "object")
43
+ return rates;
39
44
  }
40
45
  catch {
41
46
  // network error / timeout / bad JSON — try the next host
@@ -43,6 +48,12 @@ export const fetchRateToEur = async (rateDate, quoteLower) => {
43
48
  }
44
49
  return null;
45
50
  };
51
+ /** Invert a quote-per-EUR rate into EUR per 1 unit; null when unusable. */
52
+ export const rateToEur = (quotePerEur) => quotePerEur !== undefined &&
53
+ Number.isFinite(quotePerEur) &&
54
+ quotePerEur > 0
55
+ ? 1 / quotePerEur
56
+ : null;
46
57
  /** Coalesce concurrent lookups sharing a (date, currency) into one fetch. */
47
58
  const fxInFlight = singleFlight();
48
59
  /**
@@ -60,7 +71,8 @@ export const fxToEur = async (currencyCode, at) => {
60
71
  if (cached !== null)
61
72
  return Number(cached);
62
73
  return await fxInFlight(`${rateDate} ${quote}`, async () => {
63
- const rate = await fetchRateToEur(rateDate, quote.toLowerCase());
74
+ const rates = await fetchEurRates(rateDate);
75
+ const rate = rates ? rateToEur(rates[quote.toLowerCase()]) : null;
64
76
  if (rate === null)
65
77
  return null;
66
78
  await picFxRatesStore().putRate(rateDate, quote, String(rate));
@@ -1 +1 @@
1
- {"version":3,"file":"fx.common.js","sourceRoot":"","sources":["../../src/common/fx.common.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,+DAA+D;AAC/D,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC;AAEnC,yEAAyE;AACzE,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC;;;;;GAKG;AACH,MAAM,MAAM,GAAG,CAAC,QAAgB,EAAE,UAAkB,EAAY,EAAE,CAAC;IACjE,0DAA0D,QAAQ,kBAAkB,UAAU,OAAO;IACrG,WAAW,QAAQ,yCAAyC,UAAU,OAAO;CAC9E,CAAC;AAEF,+EAA+E;AAC/E,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EACjC,QAAgB,EAChB,UAAkB,EACM,EAAE;IAC1B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,CAAC;QAC/C,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,M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,CAAC,IAAI,CAAC;QAClE,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAC/B,MAAM,eAAe,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ export interface FxSyncSummary {
2
+ /** length of the synced window in UTC days, today included */
3
+ days: number;
4
+ /** oldest date in the window; also the prune cut-off */
5
+ fromDate: string;
6
+ /** synced quote currencies (EUR excluded) */
7
+ currencies: string[];
8
+ /** dates an HTTP request was made for and parsed */
9
+ fetchedDates: string[];
10
+ /** dates not published yet / both hosts failed */
11
+ missingDates: string[];
12
+ /** requested but absent from the feed (deduped) */
13
+ unknownCurrencies: string[];
14
+ inserted: number;
15
+ deleted: number;
16
+ }
17
+ //# sourceMappingURL=fx.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fx.types.d.ts","sourceRoot":"","sources":["../../src/types/fx.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,oDAAoD;IACpD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,kDAAkD;IAClD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,mDAAmD;IACnD,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=fx.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fx.types.js","sourceRoot":"","sources":["../../src/types/fx.types.ts"],"names":[],"mappings":""}
@@ -1,6 +1,7 @@
1
1
  export * from "./chargers.types.js";
2
2
  export * from "./charging.types.js";
3
3
  export * from "./failures.types.js";
4
+ export * from "./fx.types.js";
4
5
  export * from "./invoices.types.js";
5
6
  export * from "./pricebooks.types.js";
6
7
  export * from "./pushover.types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
@@ -2,6 +2,7 @@
2
2
  export * from "./chargers.types.js";
3
3
  export * from "./charging.types.js";
4
4
  export * from "./failures.types.js";
5
+ export * from "./fx.types.js";
5
6
  export * from "./invoices.types.js";
6
7
  export * from "./pricebooks.types.js";
7
8
  export * from "./pushover.types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mxpicture/tesla-superchargers-api",
3
- "version": "0.1.33",
3
+ "version": "0.1.34",
4
4
  "description": "Fetch + store Tesla Supercharger locations and pricing",
5
5
  "type": "module",
6
6
  "author": "MXPicture",
@@ -44,9 +44,9 @@
44
44
  "access": "public"
45
45
  },
46
46
  "dependencies": {
47
- "@mxpicture/tesla-superchargers-generated": "^0.1.33",
48
- "@mxpicture/tesla-superchargers-mate": "^0.1.33",
49
- "@mxpicture/tesla-superchargers-cloud-store": "^0.1.33",
47
+ "@mxpicture/tesla-superchargers-generated": "^0.1.34",
48
+ "@mxpicture/tesla-superchargers-mate": "^0.1.34",
49
+ "@mxpicture/tesla-superchargers-cloud-store": "^0.1.34",
50
50
  "csv-parse": "^7.0.1",
51
51
  "json5": "^2.2.3",
52
52
  "zod": "^4.4.3"