From 24d006d395fd9a226ad3fcbebedd2d094ed611b9 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 21 May 2021 10:07:33 -0700 Subject: [PATCH] fix: use require() to load JSON protos (#50) * fix: use require() to load JSON protos The library is regenerated with gapic-generator-typescript v1.3.1. Committer: @alexander-fenster PiperOrigin-RevId: 372468161 Source-Author: Google APIs Source-Date: Thu May 6 18:50:48 2021 -0700 Source-Repo: googleapis/googleapis Source-Sha: 75880c3e6a6aa2597400582848e81bbbfac51dea Source-Link: https://github.com/googleapis/googleapis/commit/75880c3e6a6aa2597400582848e81bbbfac51dea * chore: update gapic-generator-typescript to v1.3.2 Committer: @alexander-fenster PiperOrigin-RevId: 372656503 Source-Author: Google APIs Source-Date: Fri May 7 17:14:53 2021 -0700 Source-Repo: googleapis/googleapis Source-Sha: 6fa858c6489b1bbc505a7d7afe39f2dc45819c38 Source-Link: https://github.com/googleapis/googleapis/commit/6fa858c6489b1bbc505a7d7afe39f2dc45819c38 --- .../src/v1/service_manager_client.ts | 27 +++---------------- .../synth.metadata | 6 ++--- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/packages/google-api-servicemanagement/src/v1/service_manager_client.ts b/packages/google-api-servicemanagement/src/v1/service_manager_client.ts index a5536e1873c..3f8f1fb2d15 100644 --- a/packages/google-api-servicemanagement/src/v1/service_manager_client.ts +++ b/packages/google-api-servicemanagement/src/v1/service_manager_client.ts @@ -27,11 +27,11 @@ import { PaginationCallback, GaxCall, } from 'google-gax'; -import * as path from 'path'; import {Transform} from 'stream'; import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); /** * Client JSON configuration object, loaded from * `src/v1/service_manager_client_config.json`. @@ -146,22 +146,7 @@ export class ServiceManagerClient { clientHeader.push(`${opts.libName}/${opts.libVersion}`); } // Load the applicable protos. - // For Node.js, pass the path to JSON proto file. - // For browsers, pass the JSON content. - - const nodejsProtoPath = path.join( - __dirname, - '..', - '..', - 'protos', - 'protos.json' - ); - this._protos = this._gaxGrpc.loadProto( - opts.fallback - ? // eslint-disable-next-line @typescript-eslint/no-var-requires - require('../../protos/protos.json') - : nodejsProtoPath - ); + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent @@ -184,15 +169,11 @@ export class ServiceManagerClient { ), }; + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a // an Operation object that allows for tracking of the operation, // rather than holding a request open. - const protoFilesRoot = opts.fallback - ? this._gaxModule.protobuf.Root.fromJSON( - // eslint-disable-next-line @typescript-eslint/no-var-requires - require('../../protos/protos.json') - ) - : this._gaxModule.protobuf.loadSync(nodejsProtoPath); this.operationsClient = this._gaxModule .lro({ diff --git a/packages/google-api-servicemanagement/synth.metadata b/packages/google-api-servicemanagement/synth.metadata index 030acd081f3..028452ebf02 100644 --- a/packages/google-api-servicemanagement/synth.metadata +++ b/packages/google-api-servicemanagement/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-service-management.git", - "sha": "2735e9e9b0782dd7e433b62ddf9333072228cba5" + "sha": "e679ea9d735b9edd25913b990e3a0d037025c984" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "9f2dcbf032a77508144cf8a50b0d261e33653568", - "internalRef": "369759326" + "sha": "6fa858c6489b1bbc505a7d7afe39f2dc45819c38", + "internalRef": "372656503" } }, {