@chargealong/client 0.1.0 → 0.1.2

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/CHANGELOG.md ADDED
@@ -0,0 +1,28 @@
1
+ # Changelog
2
+
3
+ ## 0.1.2
4
+
5
+ First release published from GitHub Actions through trusted publishing, with
6
+ provenance. Carries the changes below: 0.1.1 was tagged but never reached npm.
7
+
8
+ ## 0.1.1 (not published)
9
+
10
+ - The package carries its README and changelog. 0.1.0 was published without
11
+ them, so its npm page said there was no README.
12
+ - The README links the website beside the contact page.
13
+
14
+ ## 0.1.0
15
+
16
+ First release.
17
+
18
+ - `nearby`, `planTrip`, `search`, `site`, `vehicles` and `vehicle`, plus the
19
+ directory: `countries`, `overview`, `country`, `region`, `networks`,
20
+ `network`, `locality` and `redirect`. The whole read surface of
21
+ api.chargealong.io.
22
+ - Errors keep the service's own words: `NotFound`, `BadRequest` and
23
+ `RateLimited`. A removed site answers with `status: "removed"`.
24
+ - `pageUrl` turns any row's path into its page on chargealong.io; builders for
25
+ the pages rows only carry slugs for.
26
+ - Options are checked against the service's bounds before a request goes out,
27
+ so NaN and out of range figures never reach a URL.
28
+ - No dependencies.
package/README.md ADDED
@@ -0,0 +1,152 @@
1
+ # @chargealong/client
2
+
3
+ **EV chargers, road trips and charging speeds, as an API.** Find the public
4
+ charging sites nearest a point, plan a trip through charging stops, and look up
5
+ how fast an electric car charges.
6
+
7
+ - Free and keyless. No account, nothing to configure
8
+ - Australia, New Zealand, the United States, the United Kingdom and Canada
9
+ - Runs anywhere there is `fetch`: a browser, a worker, a Node or Bun server, an
10
+ SSR loader
11
+ - Typed against the wire, with field names as the API sends them
12
+ - No dependencies
13
+
14
+ ```sh
15
+ npm install @chargealong/client
16
+ ```
17
+
18
+ ## Quick start
19
+
20
+ ```ts
21
+ import { ChargeAlong, metres, pageUrl } from "@chargealong/client";
22
+
23
+ const ca = new ChargeAlong();
24
+
25
+ const { near, sites } = await ca.nearby({
26
+ lat: -37.8136,
27
+ lng: 144.9631,
28
+ minKw: 50,
29
+ connector: "ccs2",
30
+ limit: 5,
31
+ });
32
+
33
+ console.log(`Near ${near?.name}`);
34
+ for (const site of sites) {
35
+ console.log(site.name, site.network_name, `${site.max_kw} kW`, `${metres(site.distance_km!)} m`, pageUrl(site));
36
+ }
37
+ ```
38
+
39
+ Nearest first, within 50 km unless you say otherwise. Only `active` sites are
40
+ worth sending a driver to; `status` also says `unavailable`, `planned` or
41
+ `removed`.
42
+
43
+ ## Plan a road trip
44
+
45
+ ```ts
46
+ const plan = await ca.planTrip({
47
+ from: { lat: -37.8136, lng: 144.9631 }, // Melbourne
48
+ to: { lat: -33.8688, lng: 151.2093 }, // Sydney
49
+ rangeKm: 400, // the real range, not the rated one
50
+ connectors: ["ccs2"],
51
+ });
52
+
53
+ if (plan.feasible) {
54
+ for (const stop of plan.stops) {
55
+ console.log(stop.site.name, `${stop.arrive_pct}% to ${stop.depart_pct}%`, `${stop.charge_min} min`);
56
+ }
57
+ console.log(`${plan.total_min} min in all, arriving with ${plan.arrival_pct}%`);
58
+ } else {
59
+ console.log(`No charger between km ${plan.gap?.from_km} and ${plan.gap?.to_km}`);
60
+ }
61
+ ```
62
+
63
+ `route.line` is the road as `[lng, lat]` pairs, ready for a map. Reserve, start
64
+ charge, charge limit, battery size and the car's AC and DC limits are all
65
+ options, with the service's defaults when left out.
66
+
67
+ Two different failures: no road at all between the points rejects with a
68
+ `BadRequest` of status 422; a road without enough chargers for this car
69
+ resolves with `feasible: false` and the `gap` it cannot cross.
70
+
71
+ ## Electric cars
72
+
73
+ ```ts
74
+ const { vehicles, source } = await ca.vehicles({ q: "ioniq 5" });
75
+ const { vehicle } = await ca.vehicle(vehicles[0]!.slug);
76
+
77
+ const fast = vehicle.charging.find((c) => c.charger_kw === 150);
78
+ console.log(`${vehicle.brand} ${vehicle.model}: 10 to 80% in ${fast?.minutes_10_80} min on a 150 kW charger`);
79
+ console.log(`Figures from ${source.name} (${source.licence})`);
80
+ ```
81
+
82
+ ## One site, and stored ids
83
+
84
+ ```ts
85
+ const detail = await ca.site("hwqb4abf");
86
+ detail.connectors; // standard, power, AC or DC, how many
87
+ detail.sources; // where the record came from, and when it was last seen
88
+ detail.alternatives; // other sites close by
89
+ ```
90
+
91
+ A site's `public_id` is permanent: minted once, never derived from a source
92
+ record. Store it. `site` rejects with `NotFound` for an id that never existed.
93
+ A site that was removed still answers, with `site.status` of `removed`, so code
94
+ walking stored ids can drop the retired ones and flag the wrong ones.
95
+
96
+ ## The rest of the directory
97
+
98
+ | Call | Answers |
99
+ |---|---|
100
+ | `search(q, { prefer: "AU" })` | places, postcodes and sites matching a name, for a search box |
101
+ | `countries()`, `overview()` | what the directory holds |
102
+ | `country`, `region`, `locality` | a place and its charging sites |
103
+ | `networks(country)`, `network(country, slug)` | charging networks and where they reach |
104
+ | `redirect(path)` | where a page on chargealong.io went, or null |
105
+
106
+ `search` answers empty without a request below three letters or digits.
107
+ Debounce typing and pass a `signal`, so a superseded keystroke is cancelled
108
+ rather than raced:
109
+
110
+ ```ts
111
+ const controller = new AbortController();
112
+ const found = await ca.search("coburg", { signal: controller.signal });
113
+ ```
114
+
115
+ ## Links to the site
116
+
117
+ Rows carry their page's `path`; `pageUrl(row)` makes it absolute. For rows that
118
+ only carry slugs, `countryPath`, `regionPath`, `localityPath`, `networkPath` and
119
+ `vehiclePath` build the same paths the site serves.
120
+
121
+ ## Errors
122
+
123
+ Every error is a `ChargeAlongError` with the service's own `title` and `detail`,
124
+ which name the problem: `lat: must be between -90 and 90`. The others are
125
+ `NotFound`, `BadRequest` and `RateLimited` (with `retryAfter` in
126
+ seconds). Options outside the service's bounds throw before a request goes out.
127
+
128
+ ## Other languages
129
+
130
+ | | |
131
+ |---|---|
132
+ | Python | [`chargealong`](https://pypi.org/project/chargealong/), source at [chargealong/chargealong-python](https://github.com/chargealong/chargealong-python) |
133
+
134
+ API reference: [api.chargealong.io/v1/openapi.json](https://api.chargealong.io/v1/openapi.json).
135
+
136
+ Every charger the API returns also has a page of its own on the website,
137
+ [chargealong.io](https://chargealong.io/). Building something that needs more
138
+ than the free API gives? Say what at
139
+ [chargealong.io/en/contact/](https://chargealong.io/en/contact/).
140
+
141
+ ## Attribution
142
+
143
+ Charging site data from Open Charge Map contributors, Transport for NSW and the
144
+ Queensland Government, and places from GeoNames, all under CC BY 4.0. Vehicle
145
+ figures from Open EV Data, MIT. Publishing what you get back means carrying
146
+ those credits; [where the data comes from](https://chargealong.io/en/guides/where-the-data-comes-from/)
147
+ lists them in full, and the [terms](https://chargealong.io/en/terms/) cover use
148
+ of the API.
149
+
150
+ ## Licence
151
+
152
+ MIT.
package/dist/index.cjs CHANGED
@@ -19,12 +19,6 @@ var NotFound = class extends ChargeAlongError {
19
19
  this.name = "NotFound";
20
20
  }
21
21
  };
22
- var Gone = class extends ChargeAlongError {
23
- constructor(status, title = "", detail = "") {
24
- super(status, title, detail);
25
- this.name = "Gone";
26
- }
27
- };
28
22
  var BadRequest = class extends ChargeAlongError {
29
23
  constructor(status, title = "", detail = "") {
30
24
  super(status, title, detail);
@@ -42,7 +36,6 @@ var RateLimited = class extends ChargeAlongError {
42
36
  };
43
37
  function errorFor(status, title = "", detail = "", retryAfter) {
44
38
  if (status === 404) return new NotFound(status, title, detail);
45
- if (status === 410) return new Gone(status, title, detail);
46
39
  if (status === 429) return new RateLimited(status, title, detail, retryAfter);
47
40
  if (status >= 400 && status < 500) return new BadRequest(status, title, detail);
48
41
  return new ChargeAlongError(status, title, detail);
@@ -52,7 +45,7 @@ function errorFor(status, title = "", detail = "", retryAfter) {
52
45
  var CONNECTORS = ["ccs2", "chademo", "type-2", "nacs", "ccs1", "type-1", "gbt"];
53
46
 
54
47
  // src/client.ts
55
- var VERSION = "0.1.0";
48
+ var VERSION = "0.1.2";
56
49
  var DEFAULT_BASE_URL = "https://api.chargealong.io";
57
50
  var MIN_QUERY = 3;
58
51
  var MAX_QUERY = 100;
@@ -104,8 +97,8 @@ var ChargeAlong = class {
104
97
  * and what is close by.
105
98
  *
106
99
  * The id is permanent. Rejects with {@link NotFound} for an id that never
107
- * existed, and with {@link Gone} for a site that was removed, so code holding
108
- * stored ids can drop the retired ones.
100
+ * existed. A site that was removed still answers, with `site.status` set to
101
+ * `removed`, so code holding stored ids can drop the retired ones.
109
102
  */
110
103
  async site(publicId, options = {}) {
111
104
  return (await this.get(`/v1/sites/${slug(publicId, "site id")}`, {}, options)).data;
@@ -158,9 +151,11 @@ var ChargeAlong = class {
158
151
  * A road trip from A to B through charging stops: the route, where to stop,
159
152
  * how long to charge at each, and the battery on arrival.
160
153
  *
161
- * Rejects with a {@link BadRequest} of status 422 when there is no road route
162
- * between the two points (across water, say), and with a 503 when trip
163
- * planning is briefly unavailable.
154
+ * Two different ways a trip can fail. When there is no road route at all
155
+ * between the points, it rejects with a {@link BadRequest} of status 422.
156
+ * When there is a road but not enough chargers along it for this car, it
157
+ * resolves with `feasible: false` and a `gap` saying which stretch the car
158
+ * cannot cross. A 503 means trip planning is briefly unavailable.
164
159
  */
165
160
  async planTrip(options) {
166
161
  const from = point(options.from ?? {});
@@ -365,7 +360,6 @@ exports.CONNECTORS = CONNECTORS;
365
360
  exports.ChargeAlong = ChargeAlong;
366
361
  exports.ChargeAlongError = ChargeAlongError;
367
362
  exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL;
368
- exports.Gone = Gone;
369
363
  exports.MIN_QUERY = MIN_QUERY;
370
364
  exports.NotFound = NotFound;
371
365
  exports.RateLimited = RateLimited;
package/dist/index.d.cts CHANGED
@@ -243,8 +243,17 @@ interface TripPlan {
243
243
  };
244
244
  /** Whether the car makes it with the chargers there are. */
245
245
  feasible: boolean;
246
- /** Battery on arrival, in percent. */
247
- arrival_pct: number;
246
+ /** Battery on arrival, in percent. Absent when the trip is not feasible. */
247
+ arrival_pct?: number;
248
+ /**
249
+ * The stretch of the route no charger lets the car cross, in km from the
250
+ * start, when the trip is not feasible. A longer range, a lower minKw or
251
+ * more connector types may close it.
252
+ */
253
+ gap?: {
254
+ from_km: number;
255
+ to_km: number;
256
+ };
248
257
  drive_min: number;
249
258
  charge_min: number;
250
259
  total_min: number;
@@ -290,7 +299,7 @@ interface Redirect {
290
299
  status: 301 | 302 | 308;
291
300
  }
292
301
 
293
- declare const VERSION = "0.1.0";
302
+ declare const VERSION = "0.1.2";
294
303
  declare const DEFAULT_BASE_URL = "https://api.chargealong.io";
295
304
  /** The service reads a search once it holds this many letters or digits. */
296
305
  declare const MIN_QUERY = 3;
@@ -393,8 +402,8 @@ declare class ChargeAlong {
393
402
  * and what is close by.
394
403
  *
395
404
  * The id is permanent. Rejects with {@link NotFound} for an id that never
396
- * existed, and with {@link Gone} for a site that was removed, so code holding
397
- * stored ids can drop the retired ones.
405
+ * existed. A site that was removed still answers, with `site.status` set to
406
+ * `removed`, so code holding stored ids can drop the retired ones.
398
407
  */
399
408
  site(publicId: string, options?: RequestOptions): Promise<SiteDetail>;
400
409
  /**
@@ -410,9 +419,11 @@ declare class ChargeAlong {
410
419
  * A road trip from A to B through charging stops: the route, where to stop,
411
420
  * how long to charge at each, and the battery on arrival.
412
421
  *
413
- * Rejects with a {@link BadRequest} of status 422 when there is no road route
414
- * between the two points (across water, say), and with a 503 when trip
415
- * planning is briefly unavailable.
422
+ * Two different ways a trip can fail. When there is no road route at all
423
+ * between the points, it rejects with a {@link BadRequest} of status 422.
424
+ * When there is a road but not enough chargers along it for this car, it
425
+ * resolves with `feasible: false` and a `gap` saying which stretch the car
426
+ * cannot cross. A 503 means trip planning is briefly unavailable.
416
427
  */
417
428
  planTrip(options: TripOptions): Promise<TripPlan>;
418
429
  /** Electric cars: battery, range and how they charge. */
@@ -452,15 +463,6 @@ declare class ChargeAlongError extends Error {
452
463
  declare class NotFound extends ChargeAlongError {
453
464
  constructor(status: number, title?: string, detail?: string);
454
465
  }
455
- /**
456
- * The site existed and was removed: decommissioned, or merged into another.
457
- *
458
- * Its own class rather than a NotFound, because code holding stored site ids
459
- * wants to tell "retired, drop it" from "never existed, something is wrong".
460
- */
461
- declare class Gone extends ChargeAlongError {
462
- constructor(status: number, title?: string, detail?: string);
463
- }
464
466
  /**
465
467
  * The request could not be served as written. The detail names the parameter.
466
468
  *
@@ -513,4 +515,4 @@ declare function vehiclePath(slug: string): string;
513
515
  /** Metres, rounded. What a page prints: "560 m", not "0.56 km". */
514
516
  declare function metres(distanceKm: number): number;
515
517
 
516
- export { BadRequest, CONNECTORS, ChargeAlong, ChargeAlongError, type ClientOptions, type Connection, type Connector, type CostKind, type CountryDetail, type CountrySummary, DEFAULT_BASE_URL, type DataSource, type Envelope, type Facet, Gone, type LocalityDetail, type LocalityInfo, type LocalitySummary, MIN_QUERY, type NearPlace, type NearbyOptions, type NearbyResult, type Neighbour, type NetworkDetail, type NetworkSummary, type NetworksDetail, NotFound, type Overview, type PlaceCount, type PlaceMatch, type Point, type PostcodeMatch, RateLimited, type Redirect, type RegionDetail, type RegionSummary, type RequestOptions, SITE_URL, type SearchOptions, type SearchResult, type Site, type SiteDetail, type SiteInfo, type SiteStatus, type Source, type Speed, type TripOptions, type TripPlan, type TripStop, VERSION, type Vehicle, type VehicleDetail, type VehiclesOptions, countryPath, createClient, localityPath, metres, networkPath, networksPath, pageUrl, regionPath, vehiclePath };
518
+ export { BadRequest, CONNECTORS, ChargeAlong, ChargeAlongError, type ClientOptions, type Connection, type Connector, type CostKind, type CountryDetail, type CountrySummary, DEFAULT_BASE_URL, type DataSource, type Envelope, type Facet, type LocalityDetail, type LocalityInfo, type LocalitySummary, MIN_QUERY, type NearPlace, type NearbyOptions, type NearbyResult, type Neighbour, type NetworkDetail, type NetworkSummary, type NetworksDetail, NotFound, type Overview, type PlaceCount, type PlaceMatch, type Point, type PostcodeMatch, RateLimited, type Redirect, type RegionDetail, type RegionSummary, type RequestOptions, SITE_URL, type SearchOptions, type SearchResult, type Site, type SiteDetail, type SiteInfo, type SiteStatus, type Source, type Speed, type TripOptions, type TripPlan, type TripStop, VERSION, type Vehicle, type VehicleDetail, type VehiclesOptions, countryPath, createClient, localityPath, metres, networkPath, networksPath, pageUrl, regionPath, vehiclePath };
package/dist/index.d.ts CHANGED
@@ -243,8 +243,17 @@ interface TripPlan {
243
243
  };
244
244
  /** Whether the car makes it with the chargers there are. */
245
245
  feasible: boolean;
246
- /** Battery on arrival, in percent. */
247
- arrival_pct: number;
246
+ /** Battery on arrival, in percent. Absent when the trip is not feasible. */
247
+ arrival_pct?: number;
248
+ /**
249
+ * The stretch of the route no charger lets the car cross, in km from the
250
+ * start, when the trip is not feasible. A longer range, a lower minKw or
251
+ * more connector types may close it.
252
+ */
253
+ gap?: {
254
+ from_km: number;
255
+ to_km: number;
256
+ };
248
257
  drive_min: number;
249
258
  charge_min: number;
250
259
  total_min: number;
@@ -290,7 +299,7 @@ interface Redirect {
290
299
  status: 301 | 302 | 308;
291
300
  }
292
301
 
293
- declare const VERSION = "0.1.0";
302
+ declare const VERSION = "0.1.2";
294
303
  declare const DEFAULT_BASE_URL = "https://api.chargealong.io";
295
304
  /** The service reads a search once it holds this many letters or digits. */
296
305
  declare const MIN_QUERY = 3;
@@ -393,8 +402,8 @@ declare class ChargeAlong {
393
402
  * and what is close by.
394
403
  *
395
404
  * The id is permanent. Rejects with {@link NotFound} for an id that never
396
- * existed, and with {@link Gone} for a site that was removed, so code holding
397
- * stored ids can drop the retired ones.
405
+ * existed. A site that was removed still answers, with `site.status` set to
406
+ * `removed`, so code holding stored ids can drop the retired ones.
398
407
  */
399
408
  site(publicId: string, options?: RequestOptions): Promise<SiteDetail>;
400
409
  /**
@@ -410,9 +419,11 @@ declare class ChargeAlong {
410
419
  * A road trip from A to B through charging stops: the route, where to stop,
411
420
  * how long to charge at each, and the battery on arrival.
412
421
  *
413
- * Rejects with a {@link BadRequest} of status 422 when there is no road route
414
- * between the two points (across water, say), and with a 503 when trip
415
- * planning is briefly unavailable.
422
+ * Two different ways a trip can fail. When there is no road route at all
423
+ * between the points, it rejects with a {@link BadRequest} of status 422.
424
+ * When there is a road but not enough chargers along it for this car, it
425
+ * resolves with `feasible: false` and a `gap` saying which stretch the car
426
+ * cannot cross. A 503 means trip planning is briefly unavailable.
416
427
  */
417
428
  planTrip(options: TripOptions): Promise<TripPlan>;
418
429
  /** Electric cars: battery, range and how they charge. */
@@ -452,15 +463,6 @@ declare class ChargeAlongError extends Error {
452
463
  declare class NotFound extends ChargeAlongError {
453
464
  constructor(status: number, title?: string, detail?: string);
454
465
  }
455
- /**
456
- * The site existed and was removed: decommissioned, or merged into another.
457
- *
458
- * Its own class rather than a NotFound, because code holding stored site ids
459
- * wants to tell "retired, drop it" from "never existed, something is wrong".
460
- */
461
- declare class Gone extends ChargeAlongError {
462
- constructor(status: number, title?: string, detail?: string);
463
- }
464
466
  /**
465
467
  * The request could not be served as written. The detail names the parameter.
466
468
  *
@@ -513,4 +515,4 @@ declare function vehiclePath(slug: string): string;
513
515
  /** Metres, rounded. What a page prints: "560 m", not "0.56 km". */
514
516
  declare function metres(distanceKm: number): number;
515
517
 
516
- export { BadRequest, CONNECTORS, ChargeAlong, ChargeAlongError, type ClientOptions, type Connection, type Connector, type CostKind, type CountryDetail, type CountrySummary, DEFAULT_BASE_URL, type DataSource, type Envelope, type Facet, Gone, type LocalityDetail, type LocalityInfo, type LocalitySummary, MIN_QUERY, type NearPlace, type NearbyOptions, type NearbyResult, type Neighbour, type NetworkDetail, type NetworkSummary, type NetworksDetail, NotFound, type Overview, type PlaceCount, type PlaceMatch, type Point, type PostcodeMatch, RateLimited, type Redirect, type RegionDetail, type RegionSummary, type RequestOptions, SITE_URL, type SearchOptions, type SearchResult, type Site, type SiteDetail, type SiteInfo, type SiteStatus, type Source, type Speed, type TripOptions, type TripPlan, type TripStop, VERSION, type Vehicle, type VehicleDetail, type VehiclesOptions, countryPath, createClient, localityPath, metres, networkPath, networksPath, pageUrl, regionPath, vehiclePath };
518
+ export { BadRequest, CONNECTORS, ChargeAlong, ChargeAlongError, type ClientOptions, type Connection, type Connector, type CostKind, type CountryDetail, type CountrySummary, DEFAULT_BASE_URL, type DataSource, type Envelope, type Facet, type LocalityDetail, type LocalityInfo, type LocalitySummary, MIN_QUERY, type NearPlace, type NearbyOptions, type NearbyResult, type Neighbour, type NetworkDetail, type NetworkSummary, type NetworksDetail, NotFound, type Overview, type PlaceCount, type PlaceMatch, type Point, type PostcodeMatch, RateLimited, type Redirect, type RegionDetail, type RegionSummary, type RequestOptions, SITE_URL, type SearchOptions, type SearchResult, type Site, type SiteDetail, type SiteInfo, type SiteStatus, type Source, type Speed, type TripOptions, type TripPlan, type TripStop, VERSION, type Vehicle, type VehicleDetail, type VehiclesOptions, countryPath, createClient, localityPath, metres, networkPath, networksPath, pageUrl, regionPath, vehiclePath };
package/dist/index.js CHANGED
@@ -17,12 +17,6 @@ var NotFound = class extends ChargeAlongError {
17
17
  this.name = "NotFound";
18
18
  }
19
19
  };
20
- var Gone = class extends ChargeAlongError {
21
- constructor(status, title = "", detail = "") {
22
- super(status, title, detail);
23
- this.name = "Gone";
24
- }
25
- };
26
20
  var BadRequest = class extends ChargeAlongError {
27
21
  constructor(status, title = "", detail = "") {
28
22
  super(status, title, detail);
@@ -40,7 +34,6 @@ var RateLimited = class extends ChargeAlongError {
40
34
  };
41
35
  function errorFor(status, title = "", detail = "", retryAfter) {
42
36
  if (status === 404) return new NotFound(status, title, detail);
43
- if (status === 410) return new Gone(status, title, detail);
44
37
  if (status === 429) return new RateLimited(status, title, detail, retryAfter);
45
38
  if (status >= 400 && status < 500) return new BadRequest(status, title, detail);
46
39
  return new ChargeAlongError(status, title, detail);
@@ -50,7 +43,7 @@ function errorFor(status, title = "", detail = "", retryAfter) {
50
43
  var CONNECTORS = ["ccs2", "chademo", "type-2", "nacs", "ccs1", "type-1", "gbt"];
51
44
 
52
45
  // src/client.ts
53
- var VERSION = "0.1.0";
46
+ var VERSION = "0.1.2";
54
47
  var DEFAULT_BASE_URL = "https://api.chargealong.io";
55
48
  var MIN_QUERY = 3;
56
49
  var MAX_QUERY = 100;
@@ -102,8 +95,8 @@ var ChargeAlong = class {
102
95
  * and what is close by.
103
96
  *
104
97
  * The id is permanent. Rejects with {@link NotFound} for an id that never
105
- * existed, and with {@link Gone} for a site that was removed, so code holding
106
- * stored ids can drop the retired ones.
98
+ * existed. A site that was removed still answers, with `site.status` set to
99
+ * `removed`, so code holding stored ids can drop the retired ones.
107
100
  */
108
101
  async site(publicId, options = {}) {
109
102
  return (await this.get(`/v1/sites/${slug(publicId, "site id")}`, {}, options)).data;
@@ -156,9 +149,11 @@ var ChargeAlong = class {
156
149
  * A road trip from A to B through charging stops: the route, where to stop,
157
150
  * how long to charge at each, and the battery on arrival.
158
151
  *
159
- * Rejects with a {@link BadRequest} of status 422 when there is no road route
160
- * between the two points (across water, say), and with a 503 when trip
161
- * planning is briefly unavailable.
152
+ * Two different ways a trip can fail. When there is no road route at all
153
+ * between the points, it rejects with a {@link BadRequest} of status 422.
154
+ * When there is a road but not enough chargers along it for this car, it
155
+ * resolves with `feasible: false` and a `gap` saying which stretch the car
156
+ * cannot cross. A 503 means trip planning is briefly unavailable.
162
157
  */
163
158
  async planTrip(options) {
164
159
  const from = point(options.from ?? {});
@@ -358,4 +353,4 @@ function metres(distanceKm) {
358
353
  return Math.round(distanceKm * 1e3);
359
354
  }
360
355
 
361
- export { BadRequest, CONNECTORS, ChargeAlong, ChargeAlongError, DEFAULT_BASE_URL, Gone, MIN_QUERY, NotFound, RateLimited, SITE_URL, VERSION, countryPath, createClient, localityPath, metres, networkPath, networksPath, pageUrl, regionPath, vehiclePath };
356
+ export { BadRequest, CONNECTORS, ChargeAlong, ChargeAlongError, DEFAULT_BASE_URL, MIN_QUERY, NotFound, RateLimited, SITE_URL, VERSION, countryPath, createClient, localityPath, metres, networkPath, networksPath, pageUrl, regionPath, vehiclePath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chargealong/client",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Find EV chargers near a point, plan a road trip through charging stops, and look up electric car charging speeds. Free and keyless.",
5
5
  "keywords": [
6
6
  "ev charger api",