@googlemaps/routing 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.
Files changed (35) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +202 -0
  3. package/README.md +238 -0
  4. package/build/protos/google/geo/type/viewport.proto +69 -0
  5. package/build/protos/google/maps/routing/v2/fallback_info.proto +72 -0
  6. package/build/protos/google/maps/routing/v2/location.proto +43 -0
  7. package/build/protos/google/maps/routing/v2/maneuver.proto +88 -0
  8. package/build/protos/google/maps/routing/v2/navigation_instruction.proto +40 -0
  9. package/build/protos/google/maps/routing/v2/polyline.proto +74 -0
  10. package/build/protos/google/maps/routing/v2/route.proto +208 -0
  11. package/build/protos/google/maps/routing/v2/route_modifiers.proto +64 -0
  12. package/build/protos/google/maps/routing/v2/route_travel_mode.proto +46 -0
  13. package/build/protos/google/maps/routing/v2/routes_service.proto +311 -0
  14. package/build/protos/google/maps/routing/v2/routing_preference.proto +55 -0
  15. package/build/protos/google/maps/routing/v2/speed_reading_interval.proto +57 -0
  16. package/build/protos/google/maps/routing/v2/toll_info.proto +40 -0
  17. package/build/protos/google/maps/routing/v2/toll_passes.proto +321 -0
  18. package/build/protos/google/maps/routing/v2/units.proto +40 -0
  19. package/build/protos/google/maps/routing/v2/vehicle_emission_type.proto +43 -0
  20. package/build/protos/google/maps/routing/v2/vehicle_info.proto +37 -0
  21. package/build/protos/google/maps/routing/v2/waypoint.proto +71 -0
  22. package/build/protos/protos.d.ts +8392 -0
  23. package/build/protos/protos.js +22576 -0
  24. package/build/protos/protos.json +2144 -0
  25. package/build/src/index.d.ts +11 -0
  26. package/build/src/index.js +28 -0
  27. package/build/src/index.js.map +1 -0
  28. package/build/src/v2/index.d.ts +1 -0
  29. package/build/src/v2/index.js +23 -0
  30. package/build/src/v2/index.js.map +1 -0
  31. package/build/src/v2/routes_client.d.ts +289 -0
  32. package/build/src/v2/routes_client.js +356 -0
  33. package/build/src/v2/routes_client.js.map +1 -0
  34. package/build/src/v2/routes_client_config.json +34 -0
  35. package/package.json +66 -0
@@ -0,0 +1,11 @@
1
+ import * as v2 from './v2';
2
+ declare const RoutesClient: typeof v2.RoutesClient;
3
+ declare type RoutesClient = v2.RoutesClient;
4
+ export { v2, RoutesClient };
5
+ declare const _default: {
6
+ v2: typeof v2;
7
+ RoutesClient: typeof v2.RoutesClient;
8
+ };
9
+ export default _default;
10
+ import * as protos from '../protos/protos';
11
+ export { protos };
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ // Copyright 2022 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // https://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
16
+ // ** This file is automatically generated by synthtool. **
17
+ // ** https://github.com/googleapis/synthtool **
18
+ // ** All changes to this file may be overwritten. **
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.protos = exports.RoutesClient = exports.v2 = void 0;
21
+ const v2 = require("./v2");
22
+ exports.v2 = v2;
23
+ const RoutesClient = v2.RoutesClient;
24
+ exports.RoutesClient = RoutesClient;
25
+ exports.default = { v2, RoutesClient };
26
+ const protos = require("../protos/protos");
27
+ exports.protos = protos;
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,2DAA2D;AAC3D,gDAAgD;AAChD,qDAAqD;;;AAErD,2BAA2B;AAKnB,gBAAE;AAHV,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC;AAGzB,oCAAY;AACxB,kBAAe,EAAC,EAAE,EAAE,YAAY,EAAC,CAAC;AAClC,2CAA2C;AACnC,wBAAM"}
@@ -0,0 +1 @@
1
+ export { RoutesClient } from './routes_client';
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ // Copyright 2022 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // https://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
16
+ // ** This file is automatically generated by gapic-generator-typescript. **
17
+ // ** https://github.com/googleapis/gapic-generator-typescript **
18
+ // ** All changes to this file may be overwritten. **
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.RoutesClient = void 0;
21
+ var routes_client_1 = require("./routes_client");
22
+ Object.defineProperty(exports, "RoutesClient", { enumerable: true, get: function () { return routes_client_1.RoutesClient; } });
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v2/index.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,4EAA4E;AAC5E,iEAAiE;AACjE,qDAAqD;;;AAErD,iDAA6C;AAArC,6GAAA,YAAY,OAAA"}
@@ -0,0 +1,289 @@
1
+ import type * as gax from 'google-gax';
2
+ import type { Callback, CallOptions, Descriptors, ClientOptions } from 'google-gax';
3
+ import * as protos from '../../protos/protos';
4
+ /**
5
+ * The Routes API.
6
+ * @class
7
+ * @memberof v2
8
+ */
9
+ export declare class RoutesClient {
10
+ private _terminated;
11
+ private _opts;
12
+ private _providedCustomServicePath;
13
+ private _gaxModule;
14
+ private _gaxGrpc;
15
+ private _protos;
16
+ private _defaults;
17
+ auth: gax.GoogleAuth;
18
+ descriptors: Descriptors;
19
+ warn: (code: string, message: string, warnType?: string) => void;
20
+ innerApiCalls: {
21
+ [name: string]: Function;
22
+ };
23
+ routesStub?: Promise<{
24
+ [name: string]: Function;
25
+ }>;
26
+ /**
27
+ * Construct an instance of RoutesClient.
28
+ *
29
+ * @param {object} [options] - The configuration object.
30
+ * The options accepted by the constructor are described in detail
31
+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
32
+ * The common options are:
33
+ * @param {object} [options.credentials] - Credentials object.
34
+ * @param {string} [options.credentials.client_email]
35
+ * @param {string} [options.credentials.private_key]
36
+ * @param {string} [options.email] - Account email address. Required when
37
+ * using a .pem or .p12 keyFilename.
38
+ * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
39
+ * .p12 key downloaded from the Google Developers Console. If you provide
40
+ * a path to a JSON file, the projectId option below is not necessary.
41
+ * NOTE: .pem and .p12 require you to specify options.email as well.
42
+ * @param {number} [options.port] - The port on which to connect to
43
+ * the remote host.
44
+ * @param {string} [options.projectId] - The project ID from the Google
45
+ * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
46
+ * the environment variable GCLOUD_PROJECT for your project ID. If your
47
+ * app is running in an environment which supports
48
+ * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
49
+ * your project ID will be detected automatically.
50
+ * @param {string} [options.apiEndpoint] - The domain name of the
51
+ * API remote host.
52
+ * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
53
+ * Follows the structure of {@link gapicConfig}.
54
+ * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
55
+ * Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
56
+ * For more information, please check the
57
+ * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
58
+ * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
59
+ * need to avoid loading the default gRPC version and want to use the fallback
60
+ * HTTP implementation. Load only fallback version and pass it to the constructor:
61
+ * ```
62
+ * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
63
+ * const client = new RoutesClient({fallback: 'rest'}, gax);
64
+ * ```
65
+ */
66
+ constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
67
+ /**
68
+ * Initialize the client.
69
+ * Performs asynchronous operations (such as authentication) and prepares the client.
70
+ * This function will be called automatically when any class method is called for the
71
+ * first time, but if you need to initialize it before calling an actual method,
72
+ * feel free to call initialize() directly.
73
+ *
74
+ * You can await on this method if you want to make sure the client is initialized.
75
+ *
76
+ * @returns {Promise} A promise that resolves to an authenticated service stub.
77
+ */
78
+ initialize(): Promise<{
79
+ [name: string]: Function;
80
+ }>;
81
+ /**
82
+ * The DNS address for this API service.
83
+ * @returns {string} The DNS address for this service.
84
+ */
85
+ static get servicePath(): string;
86
+ /**
87
+ * The DNS address for this API service - same as servicePath(),
88
+ * exists for compatibility reasons.
89
+ * @returns {string} The DNS address for this service.
90
+ */
91
+ static get apiEndpoint(): string;
92
+ /**
93
+ * The port for this API service.
94
+ * @returns {number} The default port for this service.
95
+ */
96
+ static get port(): number;
97
+ /**
98
+ * The scopes needed to make gRPC calls for every method defined
99
+ * in this service.
100
+ * @returns {string[]} List of default scopes.
101
+ */
102
+ static get scopes(): never[];
103
+ getProjectId(): Promise<string>;
104
+ getProjectId(callback: Callback<string, undefined, undefined>): void;
105
+ /**
106
+ * Returns the primary route along with optional alternate routes, given a set
107
+ * of terminal and intermediate waypoints.
108
+ *
109
+ * **NOTE:** This method requires that you specify a response field mask in
110
+ * the input. You can provide the response field mask by using URL parameter
111
+ * `$fields` or `fields`, or by using an HTTP/gRPC header `X-Goog-FieldMask`
112
+ * (see the [available URL parameters and
113
+ * headers](https://cloud.google.com/apis/docs/system-parameters). The value
114
+ * is a comma separated list of field paths. See detailed documentation about
115
+ * [how to construct the field
116
+ * paths](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto).
117
+ *
118
+ * For example, in this method:
119
+ *
120
+ * * Field mask of all available fields (for manual inspection):
121
+ * `X-Goog-FieldMask: *`
122
+ * * Field mask of Route-level duration, distance, and polyline (an example
123
+ * production setup):
124
+ * `X-Goog-FieldMask:
125
+ * routes.duration,routes.distanceMeters,routes.polyline.encodedPolyline`
126
+ *
127
+ * Google discourage the use of the wildcard (`*`) response field mask, or
128
+ * specifying the field mask at the top level (`routes`), because:
129
+ *
130
+ * * Selecting only the fields that you need helps our server save computation
131
+ * cycles, allowing us to return the result to you with a lower latency.
132
+ * * Selecting only the fields that you need
133
+ * in your production job ensures stable latency performance. We might add
134
+ * more response fields in the future, and those new fields might require
135
+ * extra computation time. If you select all fields, or if you select all
136
+ * fields at the top level, then you might experience performance degradation
137
+ * because any new field we add will be automatically included in the
138
+ * response.
139
+ * * Selecting only the fields that you need results in a smaller response
140
+ * size, and thus higher network throughput.
141
+ *
142
+ * @param {Object} request
143
+ * The request object that will be sent.
144
+ * @param {google.maps.routing.v2.Waypoint} request.origin
145
+ * Required. Origin waypoint.
146
+ * @param {google.maps.routing.v2.Waypoint} request.destination
147
+ * Required. Destination waypoint.
148
+ * @param {number[]} [request.intermediates]
149
+ * Optional. A set of waypoints along the route (excluding terminal points),
150
+ * for either stopping at or passing by. Up to 25 intermediate waypoints are
151
+ * supported.
152
+ * @param {google.maps.routing.v2.RouteTravelMode} [request.travelMode]
153
+ * Optional. Specifies the mode of transportation.
154
+ * @param {google.maps.routing.v2.RoutingPreference} [request.routingPreference]
155
+ * Optional. Specifies how to compute the route. The server
156
+ * attempts to use the selected routing preference to compute the route. If
157
+ * the routing preference results in an error or an extra long latency, then
158
+ * an error is returned. In the future, we might implement a fallback
159
+ * mechanism to use a different option when the preferred option does not give
160
+ * a valid result. You can specify this option only when the `travel_mode` is
161
+ * `DRIVE` or `TWO_WHEELER`, otherwise the request fails.
162
+ * @param {google.maps.routing.v2.PolylineQuality} [request.polylineQuality]
163
+ * Optional. Specifies your preference for the quality of the polyline.
164
+ * @param {google.maps.routing.v2.PolylineEncoding} [request.polylineEncoding]
165
+ * Optional. Specifies the preferred encoding for the polyline.
166
+ * @param {google.protobuf.Timestamp} [request.departureTime]
167
+ * Optional. The departure time. If you don't set this value, then this value
168
+ * defaults to the time that you made the request. If you set this value to a
169
+ * time that has already occurred, then the request fails.
170
+ * @param {boolean} [request.computeAlternativeRoutes]
171
+ * Optional. Specifies whether to calculate alternate routes in addition to the route.
172
+ * @param {google.maps.routing.v2.RouteModifiers} [request.routeModifiers]
173
+ * Optional. A set of conditions to satisfy that affect the way routes are
174
+ * calculated.
175
+ * @param {string} [request.languageCode]
176
+ * Optional. The BCP-47 language code, such as "en-US" or "sr-Latn". For more
177
+ * information, see
178
+ * http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. See
179
+ * [Language Support](https://developers.google.com/maps/faq#languagesupport)
180
+ * for the list of supported languages. When you don't provide this value, the
181
+ * display language is inferred from the location of the route request.
182
+ * @param {google.maps.routing.v2.Units} [request.units]
183
+ * Optional. Specifies the units of measure for the display fields. This
184
+ * includes the `instruction` field in `NavigationInstruction`. The units of
185
+ * measure used for the route, leg, step distance, and duration are not
186
+ * affected by this value. If you don't provide this value, then the display
187
+ * units are inferred from the location of the request.
188
+ * @param {object} [options]
189
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
190
+ * @returns {Promise} - The promise which resolves to an array.
191
+ * The first element of the array is an object representing [ComputeRoutesResponse]{@link google.maps.routing.v2.ComputeRoutesResponse}.
192
+ * Please see the
193
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
194
+ * for more details and examples.
195
+ * @example <caption>include:samples/generated/v2/routes.compute_routes.js</caption>
196
+ * region_tag:routes_v2_generated_Routes_ComputeRoutes_async
197
+ */
198
+ computeRoutes(request?: protos.google.maps.routing.v2.IComputeRoutesRequest, options?: CallOptions): Promise<[
199
+ protos.google.maps.routing.v2.IComputeRoutesResponse,
200
+ protos.google.maps.routing.v2.IComputeRoutesRequest | undefined,
201
+ {} | undefined
202
+ ]>;
203
+ computeRoutes(request: protos.google.maps.routing.v2.IComputeRoutesRequest, options: CallOptions, callback: Callback<protos.google.maps.routing.v2.IComputeRoutesResponse, protos.google.maps.routing.v2.IComputeRoutesRequest | null | undefined, {} | null | undefined>): void;
204
+ computeRoutes(request: protos.google.maps.routing.v2.IComputeRoutesRequest, callback: Callback<protos.google.maps.routing.v2.IComputeRoutesResponse, protos.google.maps.routing.v2.IComputeRoutesRequest | null | undefined, {} | null | undefined>): void;
205
+ /**
206
+ * Takes in a list of origins and destinations and returns a stream containing
207
+ * route information for each combination of origin and destination.
208
+ *
209
+ * **NOTE:** This method requires that you specify a response field mask in
210
+ * the input. You can provide the response field mask by using the URL
211
+ * parameter `$fields` or `fields`, or by using the HTTP/gRPC header
212
+ * `X-Goog-FieldMask` (see the [available URL parameters and
213
+ * headers](https://cloud.google.com/apis/docs/system-parameters). The value
214
+ * is a comma separated list of field paths. See this detailed documentation
215
+ * about [how to construct the field
216
+ * paths](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto).
217
+ *
218
+ * For example, in this method:
219
+ *
220
+ * * Field mask of all available fields (for manual inspection):
221
+ * `X-Goog-FieldMask: *`
222
+ * * Field mask of route durations, distances, element status, condition, and
223
+ * element indices (an example production setup):
224
+ * `X-Goog-FieldMask:
225
+ * originIndex,destinationIndex,status,condition,distanceMeters,duration`
226
+ *
227
+ * It is critical that you include `status` in your field mask as otherwise
228
+ * all messages will appear to be OK. Google discourages the use of the
229
+ * wildcard (`*`) response field mask, because:
230
+ *
231
+ * * Selecting only the fields that you need helps our server save computation
232
+ * cycles, allowing us to return the result to you with a lower latency.
233
+ * * Selecting only the fields that you need in your production job ensures
234
+ * stable latency performance. We might add more response fields in the
235
+ * future, and those new fields might require extra computation time. If you
236
+ * select all fields, or if you select all fields at the top level, then you
237
+ * might experience performance degradation because any new field we add will
238
+ * be automatically included in the response.
239
+ * * Selecting only the fields that you need results in a smaller response
240
+ * size, and thus higher network throughput.
241
+ *
242
+ * @param {Object} request
243
+ * The request object that will be sent.
244
+ * @param {number[]} request.origins
245
+ * Required. Array of origins, which determines the rows of the response matrix.
246
+ * Several size restrictions apply to the cardinality of origins and
247
+ * destinations:
248
+ *
249
+ * * The number of elements (origins × destinations) must be no greater than
250
+ * 625 in any case.
251
+ * * The number of elements (origins × destinations) must be no greater than
252
+ * 100 if routing_preference is set to `TRAFFIC_AWARE_OPTIMAL`.
253
+ * * The number of waypoints (origins + destinations) specified as `place_id`
254
+ * must be no greater than 50.
255
+ * @param {number[]} request.destinations
256
+ * Required. Array of destinations, which determines the columns of the response matrix.
257
+ * @param {google.maps.routing.v2.RouteTravelMode} [request.travelMode]
258
+ * Optional. Specifies the mode of transportation.
259
+ * @param {google.maps.routing.v2.RoutingPreference} [request.routingPreference]
260
+ * Optional. Specifies how to compute the route. The server attempts to use the selected
261
+ * routing preference to compute the route. If the routing preference results
262
+ * in an error or an extra long latency, an error is returned. In the future,
263
+ * we might implement a fallback mechanism to use a different option when the
264
+ * preferred option does not give a valid result. You can specify this option
265
+ * only when the `travel_mode` is `DRIVE` or `TWO_WHEELER`, otherwise the
266
+ * request fails.
267
+ * @param {google.protobuf.Timestamp} [request.departureTime]
268
+ * Optional. The departure time. If you don't set this value, this defaults to the time
269
+ * that you made the request. If you set this value to a time that has already
270
+ * occurred, the request fails.
271
+ * @param {object} [options]
272
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
273
+ * @returns {Stream}
274
+ * An object stream which emits [RouteMatrixElement]{@link google.maps.routing.v2.RouteMatrixElement} on 'data' event.
275
+ * Please see the
276
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming)
277
+ * for more details and examples.
278
+ * @example <caption>include:samples/generated/v2/routes.compute_route_matrix.js</caption>
279
+ * region_tag:routes_v2_generated_Routes_ComputeRouteMatrix_async
280
+ */
281
+ computeRouteMatrix(request?: protos.google.maps.routing.v2.IComputeRouteMatrixRequest, options?: CallOptions): gax.CancellableStream;
282
+ /**
283
+ * Terminate the gRPC channel and close the client.
284
+ *
285
+ * The client will no longer be usable and all future behavior is undefined.
286
+ * @returns {Promise} A promise that resolves when the client is closed.
287
+ */
288
+ close(): Promise<void>;
289
+ }