@mxpicture/tesla-superchargers-api 0.1.63 → 0.1.65

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,32 @@
1
+ import { type AdditionalCost, type AdditionalCostInput } from "@mxpicture/tesla-superchargers-mate/store";
2
+ import type { PicAdditionalCostsId } from "@mxpicture/tesla-superchargers-generated/public";
3
+ import { IApi } from "./IApi.js";
4
+ /**
5
+ * `pic_additional_costs` — the costs of running a car that TeslaMate never
6
+ * sees: service, repairs, tyres, insurance, tax and the subsidies that come
7
+ * back the other way. Charging costs are deliberately not in here; `pic_refs`
8
+ * and the pricing pass already model those, and a second copy would
9
+ * double-count in any future total.
10
+ *
11
+ * Full CRUD, unlike every other api in this package, because these rows are
12
+ * the only ones in the `pic_*` schema that are **not derivable**: nothing
13
+ * fetches them and no rebuild recreates them, so the UI is the only thing that
14
+ * can put one there. Hence no upsert, no snapshot sync and no soft delete.
15
+ *
16
+ * A recurring cost stays one row — `recurrence = 'monthly'` with `date` as the
17
+ * first occurrence, `end_date` as the last (null while it is still running)
18
+ * and `cost` as the amount per month. The Grafana view that will read this
19
+ * expands the series with `generate_series` at read time; nothing here
20
+ * materializes the occurrences.
21
+ */
22
+ export declare class AdditionalCostsApi extends IApi {
23
+ /** Every entry, newest date first. */
24
+ query(): Promise<AdditionalCost[]>;
25
+ create(input: AdditionalCostInput): Promise<AdditionalCost>;
26
+ /** The updated row, or null when no row has that id. */
27
+ update(id: PicAdditionalCostsId, input: AdditionalCostInput): Promise<AdditionalCost | null>;
28
+ /** False when the row was already gone; deleting twice is not an error. */
29
+ remove(id: PicAdditionalCostsId): Promise<boolean>;
30
+ }
31
+ export declare const additionalCostsApi: () => AdditionalCostsApi;
32
+ //# sourceMappingURL=AdditionalCostsApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdditionalCostsApi.d.ts","sourceRoot":"","sources":["../../src/api/AdditionalCostsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACzB,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAC;AAC5F,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,kBAAmB,SAAQ,IAAI;IAC1C,sCAAsC;IACzB,KAAK,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAIlC,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC;IAIxE,wDAAwD;IAC3C,MAAM,CACjB,EAAE,EAAE,oBAAoB,EACxB,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAIjC,2EAA2E;IAC9D,MAAM,CAAC,EAAE,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;CAGhE;AAGD,eAAO,MAAM,kBAAkB,0BAA4C,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { picAdditionalCostsStore, } from "@mxpicture/tesla-superchargers-mate/store";
2
+ import { IApi } from "./IApi.js";
3
+ /**
4
+ * `pic_additional_costs` — the costs of running a car that TeslaMate never
5
+ * sees: service, repairs, tyres, insurance, tax and the subsidies that come
6
+ * back the other way. Charging costs are deliberately not in here; `pic_refs`
7
+ * and the pricing pass already model those, and a second copy would
8
+ * double-count in any future total.
9
+ *
10
+ * Full CRUD, unlike every other api in this package, because these rows are
11
+ * the only ones in the `pic_*` schema that are **not derivable**: nothing
12
+ * fetches them and no rebuild recreates them, so the UI is the only thing that
13
+ * can put one there. Hence no upsert, no snapshot sync and no soft delete.
14
+ *
15
+ * A recurring cost stays one row — `recurrence = 'monthly'` with `date` as the
16
+ * first occurrence, `end_date` as the last (null while it is still running)
17
+ * and `cost` as the amount per month. The Grafana view that will read this
18
+ * expands the series with `generate_series` at read time; nothing here
19
+ * materializes the occurrences.
20
+ */
21
+ export class AdditionalCostsApi extends IApi {
22
+ /** Every entry, newest date first. */
23
+ async query() {
24
+ return await picAdditionalCostsStore().query();
25
+ }
26
+ async create(input) {
27
+ return await picAdditionalCostsStore().insert(input);
28
+ }
29
+ /** The updated row, or null when no row has that id. */
30
+ async update(id, input) {
31
+ return await picAdditionalCostsStore().update(id, input);
32
+ }
33
+ /** False when the row was already gone; deleting twice is not an error. */
34
+ async remove(id) {
35
+ return await picAdditionalCostsStore().remove(id);
36
+ }
37
+ }
38
+ let _api = null;
39
+ export const additionalCostsApi = () => (_api ??= new AdditionalCostsApi());
40
+ //# sourceMappingURL=AdditionalCostsApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdditionalCostsApi.js","sourceRoot":"","sources":["../../src/api/AdditionalCostsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,GAGxB,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,kBAAmB,SAAQ,IAAI;IAC1C,sCAAsC;IAC/B,KAAK,CAAC,KAAK;QAChB,OAAO,MAAM,uBAAuB,EAAE,CAAC,KAAK,EAAE,CAAC;IACjD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,KAA0B;QAC5C,OAAO,MAAM,uBAAuB,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvD,CAAC;IAED,wDAAwD;IACjD,KAAK,CAAC,MAAM,CACjB,EAAwB,EACxB,KAA0B;QAE1B,OAAO,MAAM,uBAAuB,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;IAED,2EAA2E;IACpE,KAAK,CAAC,MAAM,CAAC,EAAwB;QAC1C,OAAO,MAAM,uBAAuB,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF;AAED,IAAI,IAAI,GAA8B,IAAI,CAAC;AAC3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAAC,CAAC,IAAI,KAAK,IAAI,kBAAkB,EAAE,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type CarOption } from "@mxpicture/tesla-superchargers-mate/store";
2
+ import { IApi } from "./IApi.js";
3
+ /**
4
+ * TeslaMate's `cars`, read-only and only as far as the additional-costs form
5
+ * needs it: the id and the name behind its car picker. Its own class rather
6
+ * than a method on {@link AdditionalCostsApi} because a `cars` read behind an
7
+ * additional-costs name is a lie about what it touches.
8
+ */
9
+ export declare class CarsApi extends IApi {
10
+ query(): Promise<CarOption[]>;
11
+ }
12
+ export declare const carsApi: () => CarsApi;
13
+ //# sourceMappingURL=CarsApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CarsApi.d.ts","sourceRoot":"","sources":["../../src/api/CarsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACf,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;GAKG;AACH,qBAAa,OAAQ,SAAQ,IAAI;IAClB,KAAK,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;CAG3C;AAGD,eAAO,MAAM,OAAO,eAAiC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { carsStore, } from "@mxpicture/tesla-superchargers-mate/store";
2
+ import { IApi } from "./IApi.js";
3
+ /**
4
+ * TeslaMate's `cars`, read-only and only as far as the additional-costs form
5
+ * needs it: the id and the name behind its car picker. Its own class rather
6
+ * than a method on {@link AdditionalCostsApi} because a `cars` read behind an
7
+ * additional-costs name is a lie about what it touches.
8
+ */
9
+ export class CarsApi extends IApi {
10
+ async query() {
11
+ return await carsStore().queryNames();
12
+ }
13
+ }
14
+ let _api = null;
15
+ export const carsApi = () => (_api ??= new CarsApi());
16
+ //# sourceMappingURL=CarsApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CarsApi.js","sourceRoot":"","sources":["../../src/api/CarsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,GAEV,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,OAAO,OAAQ,SAAQ,IAAI;IACxB,KAAK,CAAC,KAAK;QAChB,OAAO,MAAM,SAAS,EAAE,CAAC,UAAU,EAAE,CAAC;IACxC,CAAC;CACF;AAED,IAAI,IAAI,GAAmB,IAAI,CAAC;AAChC,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,CAAC,IAAI,KAAK,IAAI,OAAO,EAAE,CAAC,CAAC"}
@@ -1,3 +1,5 @@
1
+ export * from "./AdditionalCostsApi.js";
2
+ export * from "./CarsApi.js";
1
3
  export * from "./ChargersApi.js";
2
4
  export * from "./ChargingProcessesApi.js";
3
5
  export * from "./ClustersApi.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,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC"}
package/dist/api/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  // This file is auto-generated by build-cli. Do not edit manually.
2
+ export * from "./AdditionalCostsApi.js";
3
+ export * from "./CarsApi.js";
2
4
  export * from "./ChargersApi.js";
3
5
  export * from "./ChargingProcessesApi.js";
4
6
  export * from "./ClustersApi.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,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,18 @@
1
+ export type { AdditionalCost, AdditionalCostInput, CarOption, } from "@mxpicture/tesla-superchargers-mate/store";
2
+ /**
3
+ * The category and recurrence values, straight out of the generated enums —
4
+ * which kanel derived from the `CREATE TYPE` in the migration. `packages/http`
5
+ * depends on `-api` and `-mate` but not on `-generated`, so re-exporting them
6
+ * here is what puts the DDL's own list in reach of the 400-validation and of
7
+ * the UI's `<select>` options, instead of a second hand-written copy.
8
+ */
9
+ export declare const COST_CATEGORIES: ("service" | "repair" | "tyres" | "insurance" | "tax" | "funding" | "other")[];
10
+ export declare const COST_RECURRENCES: ("once" | "monthly")[];
11
+ /**
12
+ * The largest amount `pic_additional_costs.cost` can hold, either sign — the
13
+ * `NUMERIC(10, 2)` the column is declared as. Checked before the insert so an
14
+ * extra digit comes back as a readable 400 rather than as a 500 from
15
+ * Postgres's own numeric overflow.
16
+ */
17
+ export declare const COST_MAX = 99999999.99;
18
+ //# sourceMappingURL=additionalCosts.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"additionalCosts.types.d.ts","sourceRoot":"","sources":["../../src/types/additionalCosts.types.ts"],"names":[],"mappings":"AAKA,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,SAAS,GACV,MAAM,2CAA2C,CAAC;AAEnD;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,gFAA0B,CAAC;AACvD,eAAO,MAAM,gBAAgB,wBAA4B,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,cAAc,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { picCostCategory, picCostRecurrence, } from "@mxpicture/tesla-superchargers-generated/public";
2
+ /**
3
+ * The category and recurrence values, straight out of the generated enums —
4
+ * which kanel derived from the `CREATE TYPE` in the migration. `packages/http`
5
+ * depends on `-api` and `-mate` but not on `-generated`, so re-exporting them
6
+ * here is what puts the DDL's own list in reach of the 400-validation and of
7
+ * the UI's `<select>` options, instead of a second hand-written copy.
8
+ */
9
+ export const COST_CATEGORIES = picCostCategory.options;
10
+ export const COST_RECURRENCES = picCostRecurrence.options;
11
+ /**
12
+ * The largest amount `pic_additional_costs.cost` can hold, either sign — the
13
+ * `NUMERIC(10, 2)` the column is declared as. Checked before the insert so an
14
+ * extra digit comes back as a readable 400 rather than as a 500 from
15
+ * Postgres's own numeric overflow.
16
+ */
17
+ export const COST_MAX = 99999999.99;
18
+ //# sourceMappingURL=additionalCosts.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"additionalCosts.types.js","sourceRoot":"","sources":["../../src/types/additionalCosts.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,iBAAiB,GAClB,MAAM,iDAAiD,CAAC;AAQzD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC,OAAO,CAAC;AACvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,OAAO,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,WAAW,CAAC"}
@@ -1,3 +1,4 @@
1
+ export * from "./additionalCosts.types.js";
1
2
  export * from "./chargers.types.js";
2
3
  export * from "./charging.types.js";
3
4
  export * from "./failures.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,eAAe,CAAC;AAC9B,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,4BAA4B,CAAC;AAC3C,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"}
@@ -1,4 +1,5 @@
1
1
  // This file is auto-generated by build-cli. Do not edit manually.
2
+ export * from "./additionalCosts.types.js";
2
3
  export * from "./chargers.types.js";
3
4
  export * from "./charging.types.js";
4
5
  export * from "./failures.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,eAAe,CAAC;AAC9B,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,4BAA4B,CAAC;AAC3C,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.63",
3
+ "version": "0.1.65",
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-cloud-store": "^0.1.63",
48
- "@mxpicture/tesla-superchargers-generated": "^0.1.63",
49
- "@mxpicture/tesla-superchargers-mate": "^0.1.63",
47
+ "@mxpicture/tesla-superchargers-cloud-store": "^0.1.65",
48
+ "@mxpicture/tesla-superchargers-generated": "^0.1.65",
49
+ "@mxpicture/tesla-superchargers-mate": "^0.1.65",
50
50
  "csv-parse": "^7.0.1",
51
51
  "fflate": "^0.8.3",
52
52
  "json5": "^2.2.3",