@chargealong/client 0.1.0
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/LICENSE +21 -0
- package/dist/index.cjs +382 -0
- package/dist/index.d.cts +516 -0
- package/dist/index.d.ts +516 -0
- package/dist/index.js +361 -0
- package/package.json +57 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The API's responses, field for field as they arrive: snake case, as the
|
|
3
|
+
* service writes them, so the reference and your editor agree.
|
|
4
|
+
*/
|
|
5
|
+
/** The connector standards the service knows, by slug. */
|
|
6
|
+
declare const CONNECTORS: readonly ["ccs2", "chademo", "type-2", "nacs", "ccs1", "type-1", "gbt"];
|
|
7
|
+
type Connector = (typeof CONNECTORS)[number];
|
|
8
|
+
/** ac up to 22 kW, fast up to 99, ultra-fast from 100. */
|
|
9
|
+
type Speed = "ac" | "fast" | "ultra-fast";
|
|
10
|
+
/** Only active sites are worth sending a driver to. */
|
|
11
|
+
type SiteStatus = "active" | "unavailable" | "planned" | "removed";
|
|
12
|
+
type CostKind = "free" | "paid" | "unknown";
|
|
13
|
+
/** Every answer arrives in one envelope. */
|
|
14
|
+
interface Envelope<T> {
|
|
15
|
+
data: T;
|
|
16
|
+
/** When the service built this answer. */
|
|
17
|
+
generated_at?: string;
|
|
18
|
+
}
|
|
19
|
+
interface CountrySummary {
|
|
20
|
+
iso2: string;
|
|
21
|
+
slug: string;
|
|
22
|
+
name: string;
|
|
23
|
+
site_count: number;
|
|
24
|
+
}
|
|
25
|
+
/** A busy suburb or town, by how many sites it has. */
|
|
26
|
+
interface PlaceCount {
|
|
27
|
+
slug: string;
|
|
28
|
+
name: string;
|
|
29
|
+
postcode?: string;
|
|
30
|
+
site_count: number;
|
|
31
|
+
/** The region's slug. */
|
|
32
|
+
region: string;
|
|
33
|
+
}
|
|
34
|
+
interface Overview {
|
|
35
|
+
sites: number;
|
|
36
|
+
ultra_fast: number;
|
|
37
|
+
countries: (CountrySummary & {
|
|
38
|
+
busiest: PlaceCount[];
|
|
39
|
+
})[];
|
|
40
|
+
}
|
|
41
|
+
interface RegionSummary {
|
|
42
|
+
slug: string;
|
|
43
|
+
code: string;
|
|
44
|
+
name: string;
|
|
45
|
+
site_count: number;
|
|
46
|
+
}
|
|
47
|
+
interface CountryDetail {
|
|
48
|
+
country: CountrySummary;
|
|
49
|
+
regions: RegionSummary[];
|
|
50
|
+
busiest: PlaceCount[];
|
|
51
|
+
}
|
|
52
|
+
interface LocalitySummary {
|
|
53
|
+
slug: string;
|
|
54
|
+
name: string;
|
|
55
|
+
postcode?: string;
|
|
56
|
+
site_count: number;
|
|
57
|
+
}
|
|
58
|
+
interface RegionDetail {
|
|
59
|
+
country: CountrySummary;
|
|
60
|
+
region: RegionSummary;
|
|
61
|
+
localities: LocalitySummary[];
|
|
62
|
+
}
|
|
63
|
+
interface NetworkSummary {
|
|
64
|
+
/** The network's slug. */
|
|
65
|
+
key: string;
|
|
66
|
+
/** Empty for unbranded sites. */
|
|
67
|
+
name: string;
|
|
68
|
+
site_count: number;
|
|
69
|
+
region_count: number;
|
|
70
|
+
}
|
|
71
|
+
interface NetworksDetail {
|
|
72
|
+
country: CountrySummary;
|
|
73
|
+
networks: NetworkSummary[];
|
|
74
|
+
}
|
|
75
|
+
/** One charging site, as every list carries it. */
|
|
76
|
+
interface Site {
|
|
77
|
+
/** Permanent: minted once, never derived from a source record. Store this. */
|
|
78
|
+
public_id: string;
|
|
79
|
+
name: string;
|
|
80
|
+
network: string;
|
|
81
|
+
network_name: string;
|
|
82
|
+
address: string;
|
|
83
|
+
status: SiteStatus;
|
|
84
|
+
speed: Speed;
|
|
85
|
+
/** The fastest connector, in kW. */
|
|
86
|
+
max_kw: number;
|
|
87
|
+
plugs: number;
|
|
88
|
+
standards: Connector[];
|
|
89
|
+
cost_kind: CostKind;
|
|
90
|
+
lat: number;
|
|
91
|
+
lng: number;
|
|
92
|
+
/** The site's page on chargealong.io. */
|
|
93
|
+
path: string;
|
|
94
|
+
/** Present where the answer is about a point. */
|
|
95
|
+
distance_km?: number;
|
|
96
|
+
}
|
|
97
|
+
interface NetworkDetail {
|
|
98
|
+
country: CountrySummary;
|
|
99
|
+
network: NetworkSummary;
|
|
100
|
+
regions: RegionSummary[];
|
|
101
|
+
busiest: PlaceCount[];
|
|
102
|
+
/** A sample of the network's sites, not every one. */
|
|
103
|
+
sites: Site[];
|
|
104
|
+
}
|
|
105
|
+
interface LocalityInfo extends LocalitySummary {
|
|
106
|
+
time_zone: string;
|
|
107
|
+
}
|
|
108
|
+
interface Facet {
|
|
109
|
+
/** What the count is of: a speed, a connector, a network. */
|
|
110
|
+
kind: string;
|
|
111
|
+
key: string;
|
|
112
|
+
count: number;
|
|
113
|
+
}
|
|
114
|
+
interface Neighbour {
|
|
115
|
+
region: string;
|
|
116
|
+
slug: string;
|
|
117
|
+
name: string;
|
|
118
|
+
site_count: number;
|
|
119
|
+
distance_km: number;
|
|
120
|
+
}
|
|
121
|
+
interface LocalityDetail {
|
|
122
|
+
country: CountrySummary;
|
|
123
|
+
region: RegionSummary;
|
|
124
|
+
locality: LocalityInfo;
|
|
125
|
+
sites: Site[];
|
|
126
|
+
facets: Facet[];
|
|
127
|
+
neighbours: Neighbour[];
|
|
128
|
+
}
|
|
129
|
+
interface Connection {
|
|
130
|
+
standard: Connector;
|
|
131
|
+
label: string;
|
|
132
|
+
current: "ac" | "dc";
|
|
133
|
+
power_kw: number;
|
|
134
|
+
quantity: number;
|
|
135
|
+
}
|
|
136
|
+
interface Source {
|
|
137
|
+
/** ocm for Open Charge Map, and one key per government register. */
|
|
138
|
+
key: string;
|
|
139
|
+
external_id: string;
|
|
140
|
+
provider: string;
|
|
141
|
+
licence: string;
|
|
142
|
+
last_seen_at: string;
|
|
143
|
+
}
|
|
144
|
+
interface SiteInfo extends Site {
|
|
145
|
+
operator?: string;
|
|
146
|
+
usage?: string;
|
|
147
|
+
cost?: {
|
|
148
|
+
kind: CostKind;
|
|
149
|
+
has_conditions: boolean;
|
|
150
|
+
text: string;
|
|
151
|
+
};
|
|
152
|
+
/** When a person last confirmed the site worked, per its source. */
|
|
153
|
+
last_verified_at?: string;
|
|
154
|
+
updated_at?: string;
|
|
155
|
+
}
|
|
156
|
+
interface Review {
|
|
157
|
+
[field: string]: unknown;
|
|
158
|
+
}
|
|
159
|
+
interface SiteDetail {
|
|
160
|
+
country: CountrySummary;
|
|
161
|
+
region: RegionSummary;
|
|
162
|
+
locality: LocalityInfo;
|
|
163
|
+
site: SiteInfo;
|
|
164
|
+
connectors: Connection[];
|
|
165
|
+
sources: Source[];
|
|
166
|
+
/** Other sites close by. */
|
|
167
|
+
alternatives: Site[];
|
|
168
|
+
/** The nearest faster site, when there is one. */
|
|
169
|
+
faster?: Site | null;
|
|
170
|
+
reviews: {
|
|
171
|
+
summary: {
|
|
172
|
+
count: number;
|
|
173
|
+
average: number | null;
|
|
174
|
+
last_worked_at: string | null;
|
|
175
|
+
last_checked_at: string | null;
|
|
176
|
+
};
|
|
177
|
+
recent: Review[];
|
|
178
|
+
};
|
|
179
|
+
photos: unknown[];
|
|
180
|
+
}
|
|
181
|
+
interface PlaceMatch {
|
|
182
|
+
country_iso2: string;
|
|
183
|
+
country_name: string;
|
|
184
|
+
region_code?: string;
|
|
185
|
+
region_name: string;
|
|
186
|
+
slug: string;
|
|
187
|
+
name: string;
|
|
188
|
+
postcode?: string;
|
|
189
|
+
site_count: number;
|
|
190
|
+
path: string;
|
|
191
|
+
/** A name that matches in full: a search box can go straight to it. */
|
|
192
|
+
exact: boolean;
|
|
193
|
+
lat: number;
|
|
194
|
+
lng: number;
|
|
195
|
+
}
|
|
196
|
+
/** A postcode's centre, for chargers near it. */
|
|
197
|
+
interface PostcodeMatch {
|
|
198
|
+
country_iso2: string;
|
|
199
|
+
country_name: string;
|
|
200
|
+
code: string;
|
|
201
|
+
lat: number;
|
|
202
|
+
lng: number;
|
|
203
|
+
}
|
|
204
|
+
interface SearchResult {
|
|
205
|
+
localities: PlaceMatch[];
|
|
206
|
+
postcodes: PostcodeMatch[];
|
|
207
|
+
sites: Site[];
|
|
208
|
+
}
|
|
209
|
+
/** The closest named place to a point, for a heading. */
|
|
210
|
+
interface NearPlace {
|
|
211
|
+
country_iso2: string;
|
|
212
|
+
name: string;
|
|
213
|
+
region_code: string;
|
|
214
|
+
region_name: string;
|
|
215
|
+
path: string;
|
|
216
|
+
distance_km: number;
|
|
217
|
+
}
|
|
218
|
+
interface NearbyResult {
|
|
219
|
+
/** Null in the middle of nowhere. */
|
|
220
|
+
near: NearPlace | null;
|
|
221
|
+
/** Nearest first. */
|
|
222
|
+
sites: Site[];
|
|
223
|
+
}
|
|
224
|
+
interface TripStop {
|
|
225
|
+
site: Pick<Site, "public_id" | "name" | "network" | "network_name" | "address" | "status" | "lat" | "lng" | "path"> & {
|
|
226
|
+
operator?: string;
|
|
227
|
+
};
|
|
228
|
+
along_km: number;
|
|
229
|
+
detour_km: number;
|
|
230
|
+
power_kw: number;
|
|
231
|
+
dc: boolean;
|
|
232
|
+
arrive_pct: number;
|
|
233
|
+
depart_pct: number;
|
|
234
|
+
energy_kwh: number;
|
|
235
|
+
charge_min: number;
|
|
236
|
+
}
|
|
237
|
+
interface TripPlan {
|
|
238
|
+
route: {
|
|
239
|
+
distance_km: number;
|
|
240
|
+
duration_min: number;
|
|
241
|
+
/** The road, as [lng, lat] pairs: GeoJSON order, ready for a map. */
|
|
242
|
+
line: [number, number][];
|
|
243
|
+
};
|
|
244
|
+
/** Whether the car makes it with the chargers there are. */
|
|
245
|
+
feasible: boolean;
|
|
246
|
+
/** Battery on arrival, in percent. */
|
|
247
|
+
arrival_pct: number;
|
|
248
|
+
drive_min: number;
|
|
249
|
+
charge_min: number;
|
|
250
|
+
total_min: number;
|
|
251
|
+
stops: TripStop[];
|
|
252
|
+
}
|
|
253
|
+
interface Vehicle {
|
|
254
|
+
slug: string;
|
|
255
|
+
brand: string;
|
|
256
|
+
model: string;
|
|
257
|
+
variant?: string;
|
|
258
|
+
year: number;
|
|
259
|
+
source_id: string;
|
|
260
|
+
battery_kwh: number;
|
|
261
|
+
consumption_kwh_100km: number;
|
|
262
|
+
range_km: number;
|
|
263
|
+
ac_kw: number;
|
|
264
|
+
ac_ports: Connector[];
|
|
265
|
+
dc_kw: number;
|
|
266
|
+
dc_ports: Connector[];
|
|
267
|
+
/** DC charging power by state of charge. */
|
|
268
|
+
curve: {
|
|
269
|
+
pct: number;
|
|
270
|
+
power_kw: number;
|
|
271
|
+
}[];
|
|
272
|
+
voltage_v: number;
|
|
273
|
+
}
|
|
274
|
+
interface VehicleDetail extends Vehicle {
|
|
275
|
+
/** Minutes from 10 to 80 percent on chargers of each size. */
|
|
276
|
+
charging: {
|
|
277
|
+
charger_kw: number;
|
|
278
|
+
minutes_10_80: number;
|
|
279
|
+
}[];
|
|
280
|
+
}
|
|
281
|
+
/** Where vehicle figures come from, and their licence: credit it when you show them. */
|
|
282
|
+
interface DataSource {
|
|
283
|
+
name: string;
|
|
284
|
+
url: string;
|
|
285
|
+
licence: string;
|
|
286
|
+
}
|
|
287
|
+
interface Redirect {
|
|
288
|
+
from: string;
|
|
289
|
+
to: string;
|
|
290
|
+
status: 301 | 302 | 308;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
declare const VERSION = "0.1.0";
|
|
294
|
+
declare const DEFAULT_BASE_URL = "https://api.chargealong.io";
|
|
295
|
+
/** The service reads a search once it holds this many letters or digits. */
|
|
296
|
+
declare const MIN_QUERY = 3;
|
|
297
|
+
interface ClientOptions {
|
|
298
|
+
/** Point somewhere else: a proxy of your own, or a test server. */
|
|
299
|
+
baseUrl?: string;
|
|
300
|
+
/** Your own fetch, for a custom transport or for testing. */
|
|
301
|
+
fetch?: typeof globalThis.fetch;
|
|
302
|
+
}
|
|
303
|
+
interface RequestOptions {
|
|
304
|
+
/** Cancel a request whose answer is no longer wanted. */
|
|
305
|
+
signal?: AbortSignal;
|
|
306
|
+
}
|
|
307
|
+
interface Point {
|
|
308
|
+
lat: number;
|
|
309
|
+
lng: number;
|
|
310
|
+
}
|
|
311
|
+
interface SearchOptions extends RequestOptions {
|
|
312
|
+
/** A two letter country code whose places rank first. */
|
|
313
|
+
prefer?: string;
|
|
314
|
+
}
|
|
315
|
+
interface NearbyOptions extends RequestOptions, Point {
|
|
316
|
+
/** Only sites with a connector of at least this many kW, 0 to 400. */
|
|
317
|
+
minKw?: number;
|
|
318
|
+
/** How far to look, 1 to 150 km. The service's default is 50. */
|
|
319
|
+
radiusKm?: number;
|
|
320
|
+
/** How many sites, 1 to 50. The service's default is 30. */
|
|
321
|
+
limit?: number;
|
|
322
|
+
/** Only sites with one of these connectors. */
|
|
323
|
+
connector?: Connector | Connector[];
|
|
324
|
+
/** Only sites on this network, by slug: evie-networks. */
|
|
325
|
+
network?: string;
|
|
326
|
+
}
|
|
327
|
+
interface TripOptions extends RequestOptions {
|
|
328
|
+
from: Point;
|
|
329
|
+
/** Somewhere other than from. */
|
|
330
|
+
to: Point;
|
|
331
|
+
/** How far the car goes on a full battery, 50 to 1500 km: the real figure, not the rated one. */
|
|
332
|
+
rangeKm: number;
|
|
333
|
+
/** Never arrive anywhere below this percentage, 5 to 50. Default 20. */
|
|
334
|
+
reserve?: number;
|
|
335
|
+
/** Battery percentage at the start, above the reserve. Default 100. */
|
|
336
|
+
start?: number;
|
|
337
|
+
/** Never charge above this percentage, 50 to 100 and at least reserve + 10. Default 80. */
|
|
338
|
+
chargeTo?: number;
|
|
339
|
+
/** Usable battery, 10 to 250 kWh. Only charging times need it. */
|
|
340
|
+
batteryKwh?: number;
|
|
341
|
+
/** The most DC power the car accepts, 20 to 400 kW. Default 150. */
|
|
342
|
+
maxDcKw?: number;
|
|
343
|
+
/** The most AC power the car accepts, 3 to 22 kW. Default 11. */
|
|
344
|
+
maxAcKw?: number;
|
|
345
|
+
/** Ignore chargers slower than this, 0 to 350 kW. Default 50. */
|
|
346
|
+
minKw?: number;
|
|
347
|
+
/** The connectors the car takes. Default CCS2 and Type 2. */
|
|
348
|
+
connectors?: Connector[];
|
|
349
|
+
}
|
|
350
|
+
interface VehiclesOptions extends RequestOptions {
|
|
351
|
+
/** Any part of the brand, model or variant. */
|
|
352
|
+
q?: string;
|
|
353
|
+
/** 1 to 100. The service's default is 20. */
|
|
354
|
+
limit?: number;
|
|
355
|
+
/** Every car rather than the first page. Ignored when q is given. */
|
|
356
|
+
all?: boolean;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* A client for the ChargeAlong API: public EV charging sites, trip planning
|
|
360
|
+
* through charging stops, and how fast electric cars charge.
|
|
361
|
+
*
|
|
362
|
+
* ```ts
|
|
363
|
+
* const ca = new ChargeAlong();
|
|
364
|
+
* const { sites } = await ca.nearby({ lat: -37.8136, lng: 144.9631, minKw: 50 });
|
|
365
|
+
* ```
|
|
366
|
+
*
|
|
367
|
+
* Free, keyless and cached at the edge. Runs anywhere there is `fetch`: a
|
|
368
|
+
* browser, a worker, a server. Nothing is kept on the instance between calls,
|
|
369
|
+
* so one can be shared.
|
|
370
|
+
*
|
|
371
|
+
* Attribution travels with the data: see chargealong.io/en/guides/where-the-data-comes-from/.
|
|
372
|
+
*/
|
|
373
|
+
declare class ChargeAlong {
|
|
374
|
+
private readonly baseUrl;
|
|
375
|
+
private readonly fetchImpl;
|
|
376
|
+
constructor(options?: ClientOptions);
|
|
377
|
+
/** Every country with charging sites, and how many each has. */
|
|
378
|
+
countries(options?: RequestOptions): Promise<CountrySummary[]>;
|
|
379
|
+
/** What the whole directory holds: countries with their busiest places. */
|
|
380
|
+
overview(options?: RequestOptions): Promise<Overview>;
|
|
381
|
+
/** One country: its regions and their counts. */
|
|
382
|
+
country(country: string, options?: RequestOptions): Promise<CountryDetail>;
|
|
383
|
+
/** One region: the places in it that have charging sites. */
|
|
384
|
+
region(country: string, region: string, options?: RequestOptions): Promise<RegionDetail>;
|
|
385
|
+
/** Every charging network in a country, with its site and region counts. */
|
|
386
|
+
networks(country: string, options?: RequestOptions): Promise<NetworksDetail>;
|
|
387
|
+
/** One network in a country: where it reaches, and a sample of its sites. */
|
|
388
|
+
network(country: string, network: string, options?: RequestOptions): Promise<NetworkDetail>;
|
|
389
|
+
/** One suburb or town: every charging site in it, with facet counts. */
|
|
390
|
+
locality(country: string, region: string, locality: string, options?: RequestOptions): Promise<LocalityDetail>;
|
|
391
|
+
/**
|
|
392
|
+
* One charging site: connectors, power, price, access, network, sources,
|
|
393
|
+
* and what is close by.
|
|
394
|
+
*
|
|
395
|
+
* 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.
|
|
398
|
+
*/
|
|
399
|
+
site(publicId: string, options?: RequestOptions): Promise<SiteDetail>;
|
|
400
|
+
/**
|
|
401
|
+
* Places, postcodes and sites matching a name, for a search box.
|
|
402
|
+
*
|
|
403
|
+
* Fewer than three letters or digits answers empty without a request, which
|
|
404
|
+
* is what the service would answer anyway. Debounce and pass a `signal`.
|
|
405
|
+
*/
|
|
406
|
+
search(term: string, options?: SearchOptions): Promise<SearchResult>;
|
|
407
|
+
/** The charging sites nearest a coordinate, nearest first. */
|
|
408
|
+
nearby(options: NearbyOptions): Promise<NearbyResult>;
|
|
409
|
+
/**
|
|
410
|
+
* A road trip from A to B through charging stops: the route, where to stop,
|
|
411
|
+
* how long to charge at each, and the battery on arrival.
|
|
412
|
+
*
|
|
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.
|
|
416
|
+
*/
|
|
417
|
+
planTrip(options: TripOptions): Promise<TripPlan>;
|
|
418
|
+
/** Electric cars: battery, range and how they charge. */
|
|
419
|
+
vehicles(options?: VehiclesOptions): Promise<{
|
|
420
|
+
vehicles: Vehicle[];
|
|
421
|
+
source: DataSource;
|
|
422
|
+
}>;
|
|
423
|
+
/** One electric car, with how long it takes to charge on chargers of each size. */
|
|
424
|
+
vehicle(slugName: string, options?: RequestOptions): Promise<{
|
|
425
|
+
vehicle: VehicleDetail;
|
|
426
|
+
source: DataSource;
|
|
427
|
+
}>;
|
|
428
|
+
/**
|
|
429
|
+
* Where a page on chargealong.io went, if it moved. Null for a page that
|
|
430
|
+
* never did, which is most of them.
|
|
431
|
+
*/
|
|
432
|
+
redirect(path: string, options?: RequestOptions): Promise<Redirect | null>;
|
|
433
|
+
private get;
|
|
434
|
+
}
|
|
435
|
+
/** Shorthand for `new ChargeAlong(options)`, for code that prefers a factory. */
|
|
436
|
+
declare function createClient(options?: ClientOptions): ChargeAlong;
|
|
437
|
+
|
|
438
|
+
/** What the API said when it refused. */
|
|
439
|
+
/**
|
|
440
|
+
* The service answers RFC 7807 problem documents: a title and a detail written
|
|
441
|
+
* for a person to read and act on, such as which parameter is out of range.
|
|
442
|
+
* Collapsing that into "HTTP 400" throws away the only part of the answer that
|
|
443
|
+
* says what to do about it.
|
|
444
|
+
*/
|
|
445
|
+
declare class ChargeAlongError extends Error {
|
|
446
|
+
readonly status: number;
|
|
447
|
+
readonly title: string;
|
|
448
|
+
readonly detail: string;
|
|
449
|
+
constructor(status: number, title?: string, detail?: string);
|
|
450
|
+
}
|
|
451
|
+
/** Nothing is filed under that id or slug, and never was. */
|
|
452
|
+
declare class NotFound extends ChargeAlongError {
|
|
453
|
+
constructor(status: number, title?: string, detail?: string);
|
|
454
|
+
}
|
|
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
|
+
/**
|
|
465
|
+
* The request could not be served as written. The detail names the parameter.
|
|
466
|
+
*
|
|
467
|
+
* Also a 422 from planTrip: there is no road route between the two points.
|
|
468
|
+
*/
|
|
469
|
+
declare class BadRequest extends ChargeAlongError {
|
|
470
|
+
constructor(status: number, title?: string, detail?: string);
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Too many requests from here.
|
|
474
|
+
*
|
|
475
|
+
* The API is free and keyless and asks callers to be gentle: answers kept
|
|
476
|
+
* rather than fetched again, typing debounced.
|
|
477
|
+
*/
|
|
478
|
+
declare class RateLimited extends ChargeAlongError {
|
|
479
|
+
/** Seconds the service asked for, when it said. */
|
|
480
|
+
readonly retryAfter?: number;
|
|
481
|
+
constructor(status: number, title?: string, detail?: string, retryAfter?: number);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Where a row lives on chargealong.io.
|
|
486
|
+
*
|
|
487
|
+
* Sites, places and trip stops carry their page's `path`, so linking to the
|
|
488
|
+
* site needs no second request. The builders below cover the rows that carry
|
|
489
|
+
* only slugs, building the path the site itself serves.
|
|
490
|
+
*/
|
|
491
|
+
declare const SITE_URL = "https://chargealong.io";
|
|
492
|
+
/**
|
|
493
|
+
* A row's page as an absolute URL, or "" for a row without one.
|
|
494
|
+
*
|
|
495
|
+
* Only a path on this site becomes a link: a row claiming `//elsewhere` or a
|
|
496
|
+
* scheme gives nothing rather than a link off the site.
|
|
497
|
+
*/
|
|
498
|
+
declare function pageUrl(row: {
|
|
499
|
+
path?: string | null;
|
|
500
|
+
} | string): string;
|
|
501
|
+
/** `/en/australia/` */
|
|
502
|
+
declare function countryPath(country: string): string;
|
|
503
|
+
/** `/en/australia/victoria/` */
|
|
504
|
+
declare function regionPath(country: string, region: string): string;
|
|
505
|
+
/** `/en/australia/victoria/coburg/` */
|
|
506
|
+
declare function localityPath(country: string, region: string, locality: string): string;
|
|
507
|
+
/** `/en/australia/networks/` */
|
|
508
|
+
declare function networksPath(country: string): string;
|
|
509
|
+
/** `/en/australia/networks/chargefox/` */
|
|
510
|
+
declare function networkPath(country: string, network: string): string;
|
|
511
|
+
/** `/en/vehicles/tesla-model-3/` */
|
|
512
|
+
declare function vehiclePath(slug: string): string;
|
|
513
|
+
/** Metres, rounded. What a page prints: "560 m", not "0.56 km". */
|
|
514
|
+
declare function metres(distanceKm: number): number;
|
|
515
|
+
|
|
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 };
|