@googlemaps/routeoptimization 0.4.0 → 0.5.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.
@@ -1738,6 +1738,11 @@
1738
1738
  "id": 1050,
1739
1739
  "extend": "google.protobuf.ServiceOptions"
1740
1740
  },
1741
+ "apiVersion": {
1742
+ "type": "string",
1743
+ "id": 525000001,
1744
+ "extend": "google.protobuf.ServiceOptions"
1745
+ },
1741
1746
  "CommonLanguageSettings": {
1742
1747
  "fields": {
1743
1748
  "referenceDocsUri": {
@@ -1846,6 +1851,10 @@
1846
1851
  "protoReferenceDocumentationUri": {
1847
1852
  "type": "string",
1848
1853
  "id": 110
1854
+ },
1855
+ "restReferenceDocumentationUri": {
1856
+ "type": "string",
1857
+ "id": 111
1849
1858
  }
1850
1859
  }
1851
1860
  },
@@ -2021,7 +2030,10 @@
2021
2030
  "rule": "repeated",
2022
2031
  "type": "google.api.FieldBehavior",
2023
2032
  "id": 1052,
2024
- "extend": "google.protobuf.FieldOptions"
2033
+ "extend": "google.protobuf.FieldOptions",
2034
+ "options": {
2035
+ "packed": false
2036
+ }
2025
2037
  },
2026
2038
  "FieldBehavior": {
2027
2039
  "values": {
@@ -2050,6 +2062,7 @@
2050
2062
  },
2051
2063
  "nested": {
2052
2064
  "FileDescriptorSet": {
2065
+ "edition": "proto2",
2053
2066
  "fields": {
2054
2067
  "file": {
2055
2068
  "rule": "repeated",
@@ -2059,6 +2072,7 @@
2059
2072
  }
2060
2073
  },
2061
2074
  "Edition": {
2075
+ "edition": "proto2",
2062
2076
  "values": {
2063
2077
  "EDITION_UNKNOWN": 0,
2064
2078
  "EDITION_PROTO2": 998,
@@ -2074,6 +2088,7 @@
2074
2088
  }
2075
2089
  },
2076
2090
  "FileDescriptorProto": {
2091
+ "edition": "proto2",
2077
2092
  "fields": {
2078
2093
  "name": {
2079
2094
  "type": "string",
@@ -2091,18 +2106,12 @@
2091
2106
  "publicDependency": {
2092
2107
  "rule": "repeated",
2093
2108
  "type": "int32",
2094
- "id": 10,
2095
- "options": {
2096
- "packed": false
2097
- }
2109
+ "id": 10
2098
2110
  },
2099
2111
  "weakDependency": {
2100
2112
  "rule": "repeated",
2101
2113
  "type": "int32",
2102
- "id": 11,
2103
- "options": {
2104
- "packed": false
2105
- }
2114
+ "id": 11
2106
2115
  },
2107
2116
  "messageType": {
2108
2117
  "rule": "repeated",
@@ -2143,6 +2152,7 @@
2143
2152
  }
2144
2153
  },
2145
2154
  "DescriptorProto": {
2155
+ "edition": "proto2",
2146
2156
  "fields": {
2147
2157
  "name": {
2148
2158
  "type": "string",
@@ -2225,6 +2235,7 @@
2225
2235
  }
2226
2236
  },
2227
2237
  "ExtensionRangeOptions": {
2238
+ "edition": "proto2",
2228
2239
  "fields": {
2229
2240
  "uninterpretedOption": {
2230
2241
  "rule": "repeated",
@@ -2298,6 +2309,7 @@
2298
2309
  }
2299
2310
  },
2300
2311
  "FieldDescriptorProto": {
2312
+ "edition": "proto2",
2301
2313
  "fields": {
2302
2314
  "name": {
2303
2315
  "type": "string",
@@ -2377,6 +2389,7 @@
2377
2389
  }
2378
2390
  },
2379
2391
  "OneofDescriptorProto": {
2392
+ "edition": "proto2",
2380
2393
  "fields": {
2381
2394
  "name": {
2382
2395
  "type": "string",
@@ -2389,6 +2402,7 @@
2389
2402
  }
2390
2403
  },
2391
2404
  "EnumDescriptorProto": {
2405
+ "edition": "proto2",
2392
2406
  "fields": {
2393
2407
  "name": {
2394
2408
  "type": "string",
@@ -2430,6 +2444,7 @@
2430
2444
  }
2431
2445
  },
2432
2446
  "EnumValueDescriptorProto": {
2447
+ "edition": "proto2",
2433
2448
  "fields": {
2434
2449
  "name": {
2435
2450
  "type": "string",
@@ -2446,6 +2461,7 @@
2446
2461
  }
2447
2462
  },
2448
2463
  "ServiceDescriptorProto": {
2464
+ "edition": "proto2",
2449
2465
  "fields": {
2450
2466
  "name": {
2451
2467
  "type": "string",
@@ -2463,6 +2479,7 @@
2463
2479
  }
2464
2480
  },
2465
2481
  "MethodDescriptorProto": {
2482
+ "edition": "proto2",
2466
2483
  "fields": {
2467
2484
  "name": {
2468
2485
  "type": "string",
@@ -2497,6 +2514,7 @@
2497
2514
  }
2498
2515
  },
2499
2516
  "FileOptions": {
2517
+ "edition": "proto2",
2500
2518
  "fields": {
2501
2519
  "javaPackage": {
2502
2520
  "type": "string",
@@ -2638,6 +2656,7 @@
2638
2656
  }
2639
2657
  },
2640
2658
  "MessageOptions": {
2659
+ "edition": "proto2",
2641
2660
  "fields": {
2642
2661
  "messageSetWireFormat": {
2643
2662
  "type": "bool",
@@ -2711,6 +2730,7 @@
2711
2730
  ]
2712
2731
  },
2713
2732
  "FieldOptions": {
2733
+ "edition": "proto2",
2714
2734
  "fields": {
2715
2735
  "ctype": {
2716
2736
  "type": "CType",
@@ -2772,10 +2792,7 @@
2772
2792
  "targets": {
2773
2793
  "rule": "repeated",
2774
2794
  "type": "OptionTargetType",
2775
- "id": 19,
2776
- "options": {
2777
- "packed": false
2778
- }
2795
+ "id": 19
2779
2796
  },
2780
2797
  "editionDefaults": {
2781
2798
  "rule": "repeated",
@@ -2859,6 +2876,7 @@
2859
2876
  }
2860
2877
  },
2861
2878
  "OneofOptions": {
2879
+ "edition": "proto2",
2862
2880
  "fields": {
2863
2881
  "features": {
2864
2882
  "type": "FeatureSet",
@@ -2878,6 +2896,7 @@
2878
2896
  ]
2879
2897
  },
2880
2898
  "EnumOptions": {
2899
+ "edition": "proto2",
2881
2900
  "fields": {
2882
2901
  "allowAlias": {
2883
2902
  "type": "bool",
@@ -2921,6 +2940,7 @@
2921
2940
  ]
2922
2941
  },
2923
2942
  "EnumValueOptions": {
2943
+ "edition": "proto2",
2924
2944
  "fields": {
2925
2945
  "deprecated": {
2926
2946
  "type": "bool",
@@ -2954,6 +2974,7 @@
2954
2974
  ]
2955
2975
  },
2956
2976
  "ServiceOptions": {
2977
+ "edition": "proto2",
2957
2978
  "fields": {
2958
2979
  "features": {
2959
2980
  "type": "FeatureSet",
@@ -2980,6 +3001,7 @@
2980
3001
  ]
2981
3002
  },
2982
3003
  "MethodOptions": {
3004
+ "edition": "proto2",
2983
3005
  "fields": {
2984
3006
  "deprecated": {
2985
3007
  "type": "bool",
@@ -3022,6 +3044,7 @@
3022
3044
  }
3023
3045
  },
3024
3046
  "UninterpretedOption": {
3047
+ "edition": "proto2",
3025
3048
  "fields": {
3026
3049
  "name": {
3027
3050
  "rule": "repeated",
@@ -3071,6 +3094,7 @@
3071
3094
  }
3072
3095
  },
3073
3096
  "FeatureSet": {
3097
+ "edition": "proto2",
3074
3098
  "fields": {
3075
3099
  "fieldPresence": {
3076
3100
  "type": "FieldPresence",
@@ -3142,9 +3166,21 @@
3142
3166
  1001,
3143
3167
  1001
3144
3168
  ],
3169
+ [
3170
+ 1002,
3171
+ 1002
3172
+ ],
3173
+ [
3174
+ 9990,
3175
+ 9990
3176
+ ],
3145
3177
  [
3146
3178
  9995,
3147
3179
  9999
3180
+ ],
3181
+ [
3182
+ 10000,
3183
+ 10000
3148
3184
  ]
3149
3185
  ],
3150
3186
  "reserved": [
@@ -3200,6 +3236,7 @@
3200
3236
  }
3201
3237
  },
3202
3238
  "FeatureSetDefaults": {
3239
+ "edition": "proto2",
3203
3240
  "fields": {
3204
3241
  "defaults": {
3205
3242
  "rule": "repeated",
@@ -3231,6 +3268,7 @@
3231
3268
  }
3232
3269
  },
3233
3270
  "SourceCodeInfo": {
3271
+ "edition": "proto2",
3234
3272
  "fields": {
3235
3273
  "location": {
3236
3274
  "rule": "repeated",
@@ -3244,12 +3282,18 @@
3244
3282
  "path": {
3245
3283
  "rule": "repeated",
3246
3284
  "type": "int32",
3247
- "id": 1
3285
+ "id": 1,
3286
+ "options": {
3287
+ "packed": true
3288
+ }
3248
3289
  },
3249
3290
  "span": {
3250
3291
  "rule": "repeated",
3251
3292
  "type": "int32",
3252
- "id": 2
3293
+ "id": 2,
3294
+ "options": {
3295
+ "packed": true
3296
+ }
3253
3297
  },
3254
3298
  "leadingComments": {
3255
3299
  "type": "string",
@@ -3269,6 +3313,7 @@
3269
3313
  }
3270
3314
  },
3271
3315
  "GeneratedCodeInfo": {
3316
+ "edition": "proto2",
3272
3317
  "fields": {
3273
3318
  "annotation": {
3274
3319
  "rule": "repeated",
@@ -3282,7 +3327,10 @@
3282
3327
  "path": {
3283
3328
  "rule": "repeated",
3284
3329
  "type": "int32",
3285
- "id": 1
3330
+ "id": 1,
3331
+ "options": {
3332
+ "packed": true
3333
+ }
3286
3334
  },
3287
3335
  "sourceFile": {
3288
3336
  "type": "string",
@@ -413,35 +413,35 @@ export declare class RouteOptimizationClient {
413
413
  */
414
414
  checkBatchOptimizeToursProgress(name: string): Promise<LROperation<protos.google.maps.routeoptimization.v1.BatchOptimizeToursResponse, protos.google.maps.routeoptimization.v1.BatchOptimizeToursMetadata>>;
415
415
  /**
416
- * Gets the latest state of a long-running operation. Clients can use this
417
- * method to poll the operation result at intervals as recommended by the API
418
- * service.
419
- *
420
- * @param {Object} request - The request object that will be sent.
421
- * @param {string} request.name - The name of the operation resource.
422
- * @param {Object=} options
423
- * Optional parameters. You can override the default settings for this call,
424
- * e.g, timeout, retries, paginations, etc. See {@link
425
- * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions}
426
- * for the details.
427
- * @param {function(?Error, ?Object)=} callback
428
- * The function which will be called with the result of the API call.
429
- *
430
- * The second parameter to the callback is an object representing
431
- * {@link google.longrunning.Operation | google.longrunning.Operation}.
432
- * @return {Promise} - The promise which resolves to an array.
433
- * The first element of the array is an object representing
434
- * {@link google.longrunning.Operation | google.longrunning.Operation}.
435
- * The promise has a method named "cancel" which cancels the ongoing API call.
436
- *
437
- * @example
438
- * ```
439
- * const client = longrunning.operationsClient();
440
- * const name = '';
441
- * const [response] = await client.getOperation({name});
442
- * // doThingsWith(response)
443
- * ```
444
- */
416
+ * Gets the latest state of a long-running operation. Clients can use this
417
+ * method to poll the operation result at intervals as recommended by the API
418
+ * service.
419
+ *
420
+ * @param {Object} request - The request object that will be sent.
421
+ * @param {string} request.name - The name of the operation resource.
422
+ * @param {Object=} options
423
+ * Optional parameters. You can override the default settings for this call,
424
+ * e.g, timeout, retries, paginations, etc. See {@link
425
+ * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions}
426
+ * for the details.
427
+ * @param {function(?Error, ?Object)=} callback
428
+ * The function which will be called with the result of the API call.
429
+ *
430
+ * The second parameter to the callback is an object representing
431
+ * {@link google.longrunning.Operation | google.longrunning.Operation}.
432
+ * @return {Promise} - The promise which resolves to an array.
433
+ * The first element of the array is an object representing
434
+ * {@link google.longrunning.Operation | google.longrunning.Operation}.
435
+ * The promise has a method named "cancel" which cancels the ongoing API call.
436
+ *
437
+ * @example
438
+ * ```
439
+ * const client = longrunning.operationsClient();
440
+ * const name = '';
441
+ * const [response] = await client.getOperation({name});
442
+ * // doThingsWith(response)
443
+ * ```
444
+ */
445
445
  getOperation(request: protos.google.longrunning.GetOperationRequest, optionsOrCallback?: gax.CallOptions | Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>, callback?: Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>): Promise<[protos.google.longrunning.Operation]>;
446
446
  /**
447
447
  * Lists operations that match the specified filter in the request. If the
@@ -473,7 +473,7 @@ export declare class RouteOptimizationClient {
473
473
  * // doThingsWith(response)
474
474
  * ```
475
475
  */
476
- listOperationsAsync(request: protos.google.longrunning.ListOperationsRequest, options?: gax.CallOptions): AsyncIterable<protos.google.longrunning.ListOperationsResponse>;
476
+ listOperationsAsync(request: protos.google.longrunning.ListOperationsRequest, options?: gax.CallOptions): AsyncIterable<protos.google.longrunning.IOperation>;
477
477
  /**
478
478
  * Starts asynchronous cancellation on a long-running operation. The server
479
479
  * makes a best effort to cancel the operation, but success is not
@@ -113,26 +113,17 @@ class RouteOptimizationClient {
113
113
  constructor(opts, gaxInstance) {
114
114
  // Ensure that options include all the required fields.
115
115
  const staticMembers = this.constructor;
116
- if (opts?.universe_domain &&
117
- opts?.universeDomain &&
118
- opts?.universe_domain !== opts?.universeDomain) {
116
+ if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) {
119
117
  throw new Error('Please set either universe_domain or universeDomain, but not both.');
120
118
  }
121
- const universeDomainEnvVar = typeof process === 'object' && typeof process.env === 'object'
122
- ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
123
- : undefined;
124
- this._universeDomain =
125
- opts?.universeDomain ??
126
- opts?.universe_domain ??
127
- universeDomainEnvVar ??
128
- 'googleapis.com';
119
+ const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined;
120
+ this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com';
129
121
  this._servicePath = 'routeoptimization.' + this._universeDomain;
130
122
  const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath;
131
123
  this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint);
132
124
  const port = opts?.port || staticMembers.port;
133
125
  const clientConfig = opts?.clientConfig ?? {};
134
- const fallback = opts?.fallback ??
135
- (typeof window !== 'undefined' && typeof window?.fetch === 'function');
126
+ const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function');
136
127
  opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
137
128
  // Request numeric enum values if REST transport is used.
138
129
  opts.numericEnums = true;
@@ -161,7 +152,10 @@ class RouteOptimizationClient {
161
152
  this.auth.defaultScopes = staticMembers.scopes;
162
153
  }
163
154
  // Determine the client header string.
164
- const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
155
+ const clientHeader = [
156
+ `gax/${this._gaxModule.version}`,
157
+ `gapic/${version}`,
158
+ ];
165
159
  if (typeof process === 'object' && 'versions' in process) {
166
160
  clientHeader.push(`gl-node/${process.versions.node}`);
167
161
  }
@@ -179,30 +173,23 @@ class RouteOptimizationClient {
179
173
  }
180
174
  // Load the applicable protos.
181
175
  this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
182
- const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
176
+ const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos);
183
177
  // This API contains "long-running operations", which return a
184
178
  // an Operation object that allows for tracking of the operation,
185
179
  // rather than holding a request open.
186
180
  const lroOptions = {
187
181
  auth: this.auth,
188
- grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
182
+ grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined
189
183
  };
190
184
  if (opts.fallback) {
191
185
  lroOptions.protoJson = protoFilesRoot;
192
- lroOptions.httpRules = [
193
- {
194
- selector: 'google.longrunning.Operations.GetOperation',
195
- get: '/v1/{name=projects/*/locations/*/operations/*}',
196
- },
197
- ];
186
+ lroOptions.httpRules = [{ selector: 'google.longrunning.Operations.GetOperation', get: '/v1/{name=projects/*/locations/*/operations/*}', }];
198
187
  }
199
- this.operationsClient = this._gaxModule
200
- .lro(lroOptions)
201
- .operationsClient(opts);
188
+ this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts);
202
189
  const batchOptimizeToursResponse = protoFilesRoot.lookup('.google.maps.routeoptimization.v1.BatchOptimizeToursResponse');
203
190
  const batchOptimizeToursMetadata = protoFilesRoot.lookup('.google.maps.routeoptimization.v1.BatchOptimizeToursMetadata');
204
191
  this.descriptors.longrunning = {
205
- batchOptimizeTours: new this._gaxModule.LongrunningDescriptor(this.operationsClient, batchOptimizeToursResponse.decode.bind(batchOptimizeToursResponse), batchOptimizeToursMetadata.decode.bind(batchOptimizeToursMetadata)),
192
+ batchOptimizeTours: new this._gaxModule.LongrunningDescriptor(this.operationsClient, batchOptimizeToursResponse.decode.bind(batchOptimizeToursResponse), batchOptimizeToursMetadata.decode.bind(batchOptimizeToursMetadata))
206
193
  };
207
194
  // Put together the default options sent with requests.
208
195
  this._defaults = this._gaxGrpc.constructSettings('google.maps.routeoptimization.v1.RouteOptimization', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
@@ -231,17 +218,13 @@ class RouteOptimizationClient {
231
218
  }
232
219
  // Put together the "service stub" for
233
220
  // google.maps.routeoptimization.v1.RouteOptimization.
234
- this.routeOptimizationStub = this._gaxGrpc.createStub(this._opts.fallback
235
- ? this._protos.lookupService('google.maps.routeoptimization.v1.RouteOptimization')
236
- : // eslint-disable-next-line @typescript-eslint/no-explicit-any
237
- this._protos.google.maps.routeoptimization.v1
238
- .RouteOptimization, this._opts, this._providedCustomServicePath);
221
+ this.routeOptimizationStub = this._gaxGrpc.createStub(this._opts.fallback ?
222
+ this._protos.lookupService('google.maps.routeoptimization.v1.RouteOptimization') :
223
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
224
+ this._protos.google.maps.routeoptimization.v1.RouteOptimization, this._opts, this._providedCustomServicePath);
239
225
  // Iterate over each of the methods that the service provides
240
226
  // and create an API call method for each.
241
- const routeOptimizationStubMethods = [
242
- 'optimizeTours',
243
- 'batchOptimizeTours',
244
- ];
227
+ const routeOptimizationStubMethods = ['optimizeTours', 'batchOptimizeTours'];
245
228
  for (const methodName of routeOptimizationStubMethods) {
246
229
  const callPromise = this.routeOptimizationStub.then(stub => (...args) => {
247
230
  if (this._terminated) {
@@ -252,7 +235,8 @@ class RouteOptimizationClient {
252
235
  }, (err) => () => {
253
236
  throw err;
254
237
  });
255
- const descriptor = this.descriptors.longrunning[methodName] || undefined;
238
+ const descriptor = this.descriptors.longrunning[methodName] ||
239
+ undefined;
256
240
  const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback);
257
241
  this.innerApiCalls[methodName] = apiCall;
258
242
  }
@@ -264,8 +248,7 @@ class RouteOptimizationClient {
264
248
  * @returns {string} The DNS address for this service.
265
249
  */
266
250
  static get servicePath() {
267
- if (typeof process === 'object' &&
268
- typeof process.emitWarning === 'function') {
251
+ if (typeof process === 'object' && typeof process.emitWarning === 'function') {
269
252
  process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
270
253
  }
271
254
  return 'routeoptimization.googleapis.com';
@@ -276,8 +259,7 @@ class RouteOptimizationClient {
276
259
  * @returns {string} The DNS address for this service.
277
260
  */
278
261
  static get apiEndpoint() {
279
- if (typeof process === 'object' &&
280
- typeof process.emitWarning === 'function') {
262
+ if (typeof process === 'object' && typeof process.emitWarning === 'function') {
281
263
  process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
282
264
  }
283
265
  return 'routeoptimization.googleapis.com';
@@ -305,7 +287,9 @@ class RouteOptimizationClient {
305
287
  * @returns {string[]} List of default scopes.
306
288
  */
307
289
  static get scopes() {
308
- return ['https://www.googleapis.com/auth/cloud-platform'];
290
+ return [
291
+ 'https://www.googleapis.com/auth/cloud-platform'
292
+ ];
309
293
  }
310
294
  /**
311
295
  * Return the project ID used by this class.
@@ -331,11 +315,10 @@ class RouteOptimizationClient {
331
315
  options = options || {};
332
316
  options.otherArgs = options.otherArgs || {};
333
317
  options.otherArgs.headers = options.otherArgs.headers || {};
334
- options.otherArgs.headers['x-goog-request-params'] =
335
- this._gaxModule.routingHeader.fromParams({
336
- parent: request.parent ?? '',
337
- });
338
- this.initialize();
318
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
319
+ 'parent': request.parent ?? '',
320
+ });
321
+ this.initialize().catch(err => { throw err; });
339
322
  this._log.info('optimizeTours request %j', request);
340
323
  const wrappedCallback = callback
341
324
  ? (error, response, options, rawResponse) => {
@@ -343,11 +326,16 @@ class RouteOptimizationClient {
343
326
  callback(error, response, options, rawResponse); // We verified callback above.
344
327
  }
345
328
  : undefined;
346
- return this.innerApiCalls
347
- .optimizeTours(request, options, wrappedCallback)
329
+ return this.innerApiCalls.optimizeTours(request, options, wrappedCallback)
348
330
  ?.then(([response, options, rawResponse]) => {
349
331
  this._log.info('optimizeTours response %j', response);
350
332
  return [response, options, rawResponse];
333
+ }).catch((error) => {
334
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
335
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
336
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
337
+ }
338
+ throw error;
351
339
  });
352
340
  }
353
341
  batchOptimizeTours(request, optionsOrCallback, callback) {
@@ -363,11 +351,10 @@ class RouteOptimizationClient {
363
351
  options = options || {};
364
352
  options.otherArgs = options.otherArgs || {};
365
353
  options.otherArgs.headers = options.otherArgs.headers || {};
366
- options.otherArgs.headers['x-goog-request-params'] =
367
- this._gaxModule.routingHeader.fromParams({
368
- parent: request.parent ?? '',
369
- });
370
- this.initialize();
354
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
355
+ 'parent': request.parent ?? '',
356
+ });
357
+ this.initialize().catch(err => { throw err; });
371
358
  const wrappedCallback = callback
372
359
  ? (error, response, rawResponse, _) => {
373
360
  this._log.info('batchOptimizeTours response %j', rawResponse);
@@ -375,8 +362,7 @@ class RouteOptimizationClient {
375
362
  }
376
363
  : undefined;
377
364
  this._log.info('batchOptimizeTours request %j', request);
378
- return this.innerApiCalls
379
- .batchOptimizeTours(request, options, wrappedCallback)
365
+ return this.innerApiCalls.batchOptimizeTours(request, options, wrappedCallback)
380
366
  ?.then(([response, rawResponse, _]) => {
381
367
  this._log.info('batchOptimizeTours response %j', rawResponse);
382
368
  return [response, rawResponse, _];
@@ -401,35 +387,35 @@ class RouteOptimizationClient {
401
387
  return decodeOperation;
402
388
  }
403
389
  /**
404
- * Gets the latest state of a long-running operation. Clients can use this
405
- * method to poll the operation result at intervals as recommended by the API
406
- * service.
407
- *
408
- * @param {Object} request - The request object that will be sent.
409
- * @param {string} request.name - The name of the operation resource.
410
- * @param {Object=} options
411
- * Optional parameters. You can override the default settings for this call,
412
- * e.g, timeout, retries, paginations, etc. See {@link
413
- * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions}
414
- * for the details.
415
- * @param {function(?Error, ?Object)=} callback
416
- * The function which will be called with the result of the API call.
417
- *
418
- * The second parameter to the callback is an object representing
419
- * {@link google.longrunning.Operation | google.longrunning.Operation}.
420
- * @return {Promise} - The promise which resolves to an array.
421
- * The first element of the array is an object representing
422
- * {@link google.longrunning.Operation | google.longrunning.Operation}.
423
- * The promise has a method named "cancel" which cancels the ongoing API call.
424
- *
425
- * @example
426
- * ```
427
- * const client = longrunning.operationsClient();
428
- * const name = '';
429
- * const [response] = await client.getOperation({name});
430
- * // doThingsWith(response)
431
- * ```
432
- */
390
+ * Gets the latest state of a long-running operation. Clients can use this
391
+ * method to poll the operation result at intervals as recommended by the API
392
+ * service.
393
+ *
394
+ * @param {Object} request - The request object that will be sent.
395
+ * @param {string} request.name - The name of the operation resource.
396
+ * @param {Object=} options
397
+ * Optional parameters. You can override the default settings for this call,
398
+ * e.g, timeout, retries, paginations, etc. See {@link
399
+ * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions}
400
+ * for the details.
401
+ * @param {function(?Error, ?Object)=} callback
402
+ * The function which will be called with the result of the API call.
403
+ *
404
+ * The second parameter to the callback is an object representing
405
+ * {@link google.longrunning.Operation | google.longrunning.Operation}.
406
+ * @return {Promise} - The promise which resolves to an array.
407
+ * The first element of the array is an object representing
408
+ * {@link google.longrunning.Operation | google.longrunning.Operation}.
409
+ * The promise has a method named "cancel" which cancels the ongoing API call.
410
+ *
411
+ * @example
412
+ * ```
413
+ * const client = longrunning.operationsClient();
414
+ * const name = '';
415
+ * const [response] = await client.getOperation({name});
416
+ * // doThingsWith(response)
417
+ * ```
418
+ */
433
419
  getOperation(request, optionsOrCallback, callback) {
434
420
  let options;
435
421
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -592,7 +578,7 @@ class RouteOptimizationClient {
592
578
  this._log.info('ending gRPC channel');
593
579
  this._terminated = true;
594
580
  stub.close();
595
- this.operationsClient.close();
581
+ void this.operationsClient.close();
596
582
  });
597
583
  }
598
584
  return Promise.resolve();