@types/mapbox__mapbox-sdk 0.13.3 → 0.13.4

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.
@@ -8,7 +8,7 @@ This package contains type definitions for @mapbox/mapbox-sdk (https://github.co
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mapbox__mapbox-sdk.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Thu, 07 Apr 2022 05:31:19 GMT
11
+ * Last updated: Fri, 08 Apr 2022 22:01:18 GMT
12
12
  * Dependencies: [@types/geojson](https://npmjs.com/package/@types/geojson), [@types/mapbox-gl](https://npmjs.com/package/@types/mapbox-gl), [@types/node](https://npmjs.com/package/@types/node)
13
13
  * Global values: none
14
14
 
@@ -11,7 +11,7 @@
11
11
  /// <reference types="node" />
12
12
 
13
13
  declare module '@mapbox/mapbox-sdk/lib/classes/mapi-client' {
14
- import { MapiRequest, MapiRequestOptions, DirectionsApproach } from '@mapbox/mapbox-sdk/lib/classes/mapi-request';
14
+ import { MapiRequest, MapiRequestOptions } from '@mapbox/mapbox-sdk/lib/classes/mapi-request';
15
15
  export default class MapiClient {
16
16
  constructor(config: SdkConfig);
17
17
  accessToken: string;
@@ -30,9 +30,9 @@ declare module '@mapbox/mapbox-sdk/lib/classes/mapi-request' {
30
30
  import MapiClient from '@mapbox/mapbox-sdk/lib/classes/mapi-client';
31
31
  import { MapiError } from '@mapbox/mapbox-sdk/lib/classes/mapi-error';
32
32
 
33
- interface EventEmitter {
34
- response: MapiResponse;
35
- error: MapiError;
33
+ interface EventEmitter<T> {
34
+ response: MapiResponse<T>;
35
+ error: MapiError<T>;
36
36
  downloadProgress: ProgressEvent;
37
37
  uploadProgress: ProgressEvent;
38
38
  }
@@ -80,11 +80,11 @@ declare module '@mapbox/mapbox-sdk/lib/classes/mapi-request' {
80
80
  sendFileAs: 'data' | 'form';
81
81
  }
82
82
 
83
- type MapiRequest = MapiRequestOptions & {
83
+ type MapiRequest<T = any> = MapiRequestOptions & {
84
84
  /**
85
85
  * An event emitter.
86
86
  */
87
- emitter: EventEmitter;
87
+ emitter: EventEmitter<T>;
88
88
  /**
89
89
  * This request's MapiClient.
90
90
  */
@@ -92,11 +92,11 @@ declare module '@mapbox/mapbox-sdk/lib/classes/mapi-request' {
92
92
  /**
93
93
  * If this request has been sent and received a response, the response is available on this property.
94
94
  */
95
- response?: MapiResponse | undefined;
95
+ response?: MapiResponse<T> | undefined;
96
96
  /**
97
97
  * If this request has been sent and received an error in response, the error is available on this property.
98
98
  */
99
- error?: MapiError | Error | undefined;
99
+ error?: MapiError<T> | Error | undefined;
100
100
  /**
101
101
  * If the request has been aborted (via abort), this property will be true.
102
102
  */
@@ -108,15 +108,15 @@ declare module '@mapbox/mapbox-sdk/lib/classes/mapi-request' {
108
108
  */
109
109
  sent: boolean;
110
110
  url(accessToken?: string): string;
111
- send(): Promise<MapiResponse>;
111
+ send(): Promise<MapiResponse<T>>;
112
112
  abort(): void;
113
- eachPage(callback: PageCallbackFunction): void;
114
- clone(): MapiRequest;
113
+ eachPage(callback: PageCallbackFunction<T>): void;
114
+ clone(): MapiRequest<T>;
115
115
  };
116
116
 
117
- interface PageCallbackFunction {
118
- error: MapiError;
119
- response: MapiResponse;
117
+ interface PageCallbackFunction<T> {
118
+ error: MapiError<T>;
119
+ response: MapiResponse<T>;
120
120
  next: () => void;
121
121
  }
122
122
 
@@ -130,11 +130,11 @@ declare module '@mapbox/mapbox-sdk/lib/classes/mapi-request' {
130
130
  declare module '@mapbox/mapbox-sdk/lib/classes/mapi-response' {
131
131
  import { MapiRequest } from '@mapbox/mapbox-sdk/lib/classes/mapi-request';
132
132
 
133
- interface MapiResponse {
133
+ interface MapiResponse<T = any> {
134
134
  /**
135
135
  * The response body, parsed as JSON.
136
136
  */
137
- body: any;
137
+ body: T;
138
138
  /**
139
139
  * The raw response body.
140
140
  */
@@ -154,20 +154,20 @@ declare module '@mapbox/mapbox-sdk/lib/classes/mapi-response' {
154
154
  /**
155
155
  * The response's originating MapiRequest.
156
156
  */
157
- request: MapiRequest;
157
+ request: MapiRequest<T>;
158
158
  hasNextPage(): boolean;
159
- nextPage(): MapiRequest | null;
159
+ nextPage(): MapiRequest<T> | null;
160
160
  }
161
161
  }
162
162
 
163
163
  declare module '@mapbox/mapbox-sdk/lib/classes/mapi-error' {
164
164
  import { MapiRequest } from '@mapbox/mapbox-sdk/lib/classes/mapi-request';
165
165
 
166
- interface MapiError {
166
+ interface MapiError<T = any> {
167
167
  /**
168
168
  * The errored request.
169
169
  */
170
- request: MapiRequest;
170
+ request: MapiRequest<T>;
171
171
  /**
172
172
  * The type of error. Usually this is 'HttpError'.
173
173
  * If the request was aborted, so the error was not sent from the server, the type will be 'RequestAbortedError'.
@@ -180,7 +180,7 @@ declare module '@mapbox/mapbox-sdk/lib/classes/mapi-error' {
180
180
  /**
181
181
  * If the server sent a response body, this property exposes that response, parsed as JSON if possible.
182
182
  */
183
- body?: any;
183
+ body?: T;
184
184
  /**
185
185
  * Whatever message could be derived from the call site and HTTP response.
186
186
  */
@@ -312,7 +312,8 @@ declare module '@mapbox/mapbox-sdk/services/directions' {
312
312
  export default function Directions(config: SdkConfig | MapiClient): DirectionsService;
313
313
 
314
314
  interface DirectionsService {
315
- getDirections(request: DirectionsRequest): MapiRequest;
315
+ getDirections(request: DirectionsRequest | DirectionsRequest<'polyline' | 'polyline6'>): MapiRequest<DirectionsResponse>;
316
+ getDirections(request: DirectionsRequest<'geojson'>): MapiRequest<DirectionsResponse<GeoJSON.MultiLineString | GeoJSON.LineString>>;
316
317
  }
317
318
 
318
319
  type DirectionsAnnotation = 'duration' | 'distance' | 'speed' | 'congestion';
@@ -350,8 +351,10 @@ declare module '@mapbox/mapbox-sdk/services/directions' {
350
351
  | 'notification'
351
352
  | 'exit roundabout'
352
353
  | 'exit rotary';
354
+ type Polyline = string;
355
+ type RouteGeometry = GeoJSON.LineString | GeoJSON.MultiLineString | Polyline;
353
356
 
354
- interface CommonDirectionsRequest {
357
+ interface CommonDirectionsRequest<T extends DirectionsGeometry = 'polyline'> {
355
358
  waypoints: DirectionsWaypoint[];
356
359
  /**
357
360
  * Whether to try to return alternative routes. An alternative is classified as a route that is significantly
@@ -382,7 +385,7 @@ declare module '@mapbox/mapbox-sdk/services/directions' {
382
385
  * Format of the returned geometry. Allowed values are: geojson (as LineString ),
383
386
  * polyline with precision 5, polyline6 (a polyline with precision 6). The default value is polyline .
384
387
  */
385
- geometries?: DirectionsGeometry | undefined;
388
+ geometries?: T;
386
389
  /**
387
390
  * Language of returned turn-by-turn text instructions. See supported languages . The default is en for English.
388
391
  */
@@ -426,7 +429,7 @@ declare module '@mapbox/mapbox-sdk/services/directions' {
426
429
  exclude?: Array<'ferry' | 'toll' | 'motorway'> | undefined;
427
430
  };
428
431
 
429
- type DirectionsRequest = CommonDirectionsRequest & DirectionsProfileExclusion;
432
+ type DirectionsRequest<T extends DirectionsGeometry = "polyline"> = CommonDirectionsRequest<T> & DirectionsProfileExclusion;
430
433
 
431
434
  interface Waypoint {
432
435
  /**
@@ -464,11 +467,11 @@ declare module '@mapbox/mapbox-sdk/services/directions' {
464
467
  waypointName?: string | undefined;
465
468
  };
466
469
 
467
- interface DirectionsResponse {
470
+ interface DirectionsResponse<T extends RouteGeometry = Polyline> {
468
471
  /**
469
472
  * Array of Route objects ordered by descending recommendation rank. May contain at most two routes.
470
473
  */
471
- routes: Route[];
474
+ routes: Array<Route<T>>;
472
475
  /**
473
476
  * Array of Waypoint objects. Each waypoints is an input coordinate snapped to the road and path network.
474
477
  * The waypoints appear in the array in the order of the input coordinates.
@@ -482,13 +485,13 @@ declare module '@mapbox/mapbox-sdk/services/directions' {
482
485
  uuid: string;
483
486
  }
484
487
 
485
- interface Route {
488
+ interface Route<T extends RouteGeometry> {
486
489
  /**
487
490
  * Depending on the geometries parameter this is a GeoJSON LineString or a Polyline string.
488
491
  * Depending on the overview parameter this is the complete route geometry (full), a simplified geometry
489
492
  * to the zoom level at which the route can be displayed in full (simplified), or is not included (false)
490
493
  */
491
- geometry: GeoJSON.LineString | GeoJSON.MultiLineString;
494
+ geometry: T;
492
495
  /**
493
496
  * Array of RouteLeg objects.
494
497
  */
@@ -804,7 +807,6 @@ declare module '@mapbox/mapbox-sdk/services/directions' {
804
807
  declare module '@mapbox/mapbox-sdk/services/geocoding' {
805
808
  import { LngLatLike } from 'mapbox-gl';
806
809
  import { MapiRequest, Coordinates } from '@mapbox/mapbox-sdk/lib/classes/mapi-request';
807
- import { MapiResponse } from '@mapbox/mapbox-sdk/lib/classes/mapi-response';
808
810
  import MapiClient, { SdkConfig } from '@mapbox/mapbox-sdk/lib/classes/mapi-client';
809
811
 
810
812
  /*********************************************************************************************************************
@@ -814,8 +816,8 @@ declare module '@mapbox/mapbox-sdk/services/geocoding' {
814
816
  export default function Geocoding(config: SdkConfig | MapiClient): GeocodeService;
815
817
 
816
818
  interface GeocodeService {
817
- forwardGeocode(request: GeocodeRequest): MapiRequest;
818
- reverseGeocode(request: GeocodeRequest): MapiRequest;
819
+ forwardGeocode(request: GeocodeRequest): MapiRequest<GeocodeResponse>;
820
+ reverseGeocode(request: GeocodeRequest): MapiRequest<GeocodeResponse>;
819
821
  }
820
822
 
821
823
  type BoundingBox = [number, number, number, number];
@@ -883,7 +885,7 @@ declare module '@mapbox/mapbox-sdk/services/geocoding' {
883
885
  /**
884
886
  * "Feature Collection" , a GeoJSON type from the GeoJSON specification.
885
887
  */
886
- type: string;
888
+ type: "FeatureCollection";
887
889
  /**
888
890
  * An array of space and punctuation-separated strings from the original query.
889
891
  */
@@ -905,9 +907,9 @@ declare module '@mapbox/mapbox-sdk/services/geocoding' {
905
907
  */
906
908
  id: string;
907
909
  /**
908
- * "Feature" , a GeoJSON type from the GeoJSON specification.
910
+ * "Feature", a GeoJSON type from the GeoJSON specification.
909
911
  */
910
- type: string;
912
+ type: "Feature";
911
913
  /**
912
914
  * An array of feature types describing the feature. Options are country , region , postcode , district , place , locality , neighborhood ,
913
915
  * address , poi , and poi.landmark . Most features have only one type, but if the feature has multiple types,
@@ -977,7 +979,7 @@ declare module '@mapbox/mapbox-sdk/services/geocoding' {
977
979
  /**
978
980
  * Point, a GeoJSON type from the GeoJSON specification .
979
981
  */
980
- type: string;
982
+ type: "Point";
981
983
  /**
982
984
  * An array in the format [ longitude,latitude ] at the center of the specified bbox .
983
985
  */
@@ -1018,7 +1020,6 @@ declare module '@mapbox/mapbox-sdk/services/geocoding' {
1018
1020
  }
1019
1021
 
1020
1022
  declare module '@mapbox/mapbox-sdk/services/map-matching' {
1021
- import { LngLatLike } from 'mapbox-gl';
1022
1023
  import {
1023
1024
  DirectionsAnnotation,
1024
1025
  DirectionsGeometry,
@@ -1039,7 +1040,7 @@ declare module '@mapbox/mapbox-sdk/services/map-matching' {
1039
1040
  export default function MapMatching(config: SdkConfig | MapiClient): MapMatchingService;
1040
1041
 
1041
1042
  interface MapMatchingService {
1042
- getMatch(request: MapMatchingRequest): MapiRequest;
1043
+ getMatch(request: MapMatchingRequest): MapiRequest<MapMatchingResponse>;
1043
1044
  }
1044
1045
 
1045
1046
  interface MapMatchingRequest {
@@ -1170,7 +1171,7 @@ declare module '@mapbox/mapbox-sdk/services/matrix' {
1170
1171
  * Get a duration and/or distance matrix showing travel times and distances between coordinates.
1171
1172
  * @param request
1172
1173
  */
1173
- getMatrix(request: MatrixRequest): MapiRequest;
1174
+ getMatrix(request: MatrixRequest): MapiRequest<MatrixResponse>;
1174
1175
  }
1175
1176
 
1176
1177
  interface MatrixRequest {
@@ -1198,7 +1199,6 @@ declare module '@mapbox/mapbox-sdk/services/matrix' {
1198
1199
  declare module '@mapbox/mapbox-sdk/services/optimization' {
1199
1200
  import { Waypoint } from '@mapbox/mapbox-sdk/services/directions';
1200
1201
  import { MapiRequest, MapboxProfile, DirectionsApproach } from '@mapbox/mapbox-sdk/lib/classes/mapi-request';
1201
- import { MapiResponse } from '@mapbox/mapbox-sdk/lib/classes/mapi-response';
1202
1202
  import MapiClient, { SdkConfig } from '@mapbox/mapbox-sdk/lib/classes/mapi-client';
1203
1203
 
1204
1204
  /*********************************************************************************************************************
@@ -1650,7 +1650,6 @@ declare module '@mapbox/mapbox-sdk/services/tilesets' {
1650
1650
 
1651
1651
  declare module '@mapbox/mapbox-sdk/services/tokens' {
1652
1652
  import { MapiRequest } from '@mapbox/mapbox-sdk/lib/classes/mapi-request';
1653
- import { MapiResponse } from '@mapbox/mapbox-sdk/lib/classes/mapi-response';
1654
1653
  import MapiClient, { SdkConfig } from '@mapbox/mapbox-sdk/lib/classes/mapi-client';
1655
1654
 
1656
1655
  /*********************************************************************************************************************
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/mapbox__mapbox-sdk",
3
- "version": "0.13.3",
3
+ "version": "0.13.4",
4
4
  "description": "TypeScript definitions for @mapbox/mapbox-sdk",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mapbox__mapbox-sdk",
6
6
  "license": "MIT",
@@ -44,6 +44,6 @@
44
44
  "@types/mapbox-gl": "*",
45
45
  "@types/node": "*"
46
46
  },
47
- "typesPublisherContentHash": "a187dca402af20e5fc089bc696726b296d07ac88c9b8e7aede7355686c33eee0",
47
+ "typesPublisherContentHash": "920eb677eeb4e707e533a1a8bae5e138cf1e6686666707eff8870e6521f3820a",
48
48
  "typeScriptVersion": "3.9"
49
49
  }