From e324abc0e299a0b43bc8b945612ed5abfef404c2 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 11 May 2021 21:58:17 +0000 Subject: [PATCH] fix: use require() to load JSON protos (#548) The library is regenerated with gapic-generator-typescript v1.3.1. Committer: @alexander-fenster PiperOrigin-RevId: 372468161 Source-Link: https://github.com/googleapis/googleapis/commit/75880c3e6a6aa2597400582848e81bbbfac51dea Source-Link: https://github.com/googleapis/googleapis-gen/commit/77b18044813d4c8c415ff9ea68e76e307eb8e904 --- .../v1/video_intelligence_service_client.ts | 24 +++---------------- .../video_intelligence_service_client.ts | 24 +++---------------- .../video_intelligence_service_client.ts | 24 +++---------------- .../video_intelligence_service_client.ts | 24 +++---------------- ...aming_video_intelligence_service_client.ts | 18 ++------------ .../video_intelligence_service_client.ts | 24 +++---------------- 6 files changed, 17 insertions(+), 121 deletions(-) diff --git a/packages/google-cloud-videointelligence/src/v1/video_intelligence_service_client.ts b/packages/google-cloud-videointelligence/src/v1/video_intelligence_service_client.ts index d94a68905b5..66987856aea 100644 --- a/packages/google-cloud-videointelligence/src/v1/video_intelligence_service_client.ts +++ b/packages/google-cloud-videointelligence/src/v1/video_intelligence_service_client.ts @@ -28,6 +28,7 @@ import { import * as path from 'path'; import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); /** * Client JSON configuration object, loaded from * `src/v1/video_intelligence_service_client_config.json`. @@ -143,32 +144,13 @@ export class VideoIntelligenceServiceClient { 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. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - 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 - ); + 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-cloud-videointelligence/src/v1beta2/video_intelligence_service_client.ts b/packages/google-cloud-videointelligence/src/v1beta2/video_intelligence_service_client.ts index 1cdb49503d1..4b186e3cf10 100644 --- a/packages/google-cloud-videointelligence/src/v1beta2/video_intelligence_service_client.ts +++ b/packages/google-cloud-videointelligence/src/v1beta2/video_intelligence_service_client.ts @@ -28,6 +28,7 @@ import { import * as path from 'path'; import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); /** * Client JSON configuration object, loaded from * `src/v1beta2/video_intelligence_service_client_config.json`. @@ -143,32 +144,13 @@ export class VideoIntelligenceServiceClient { 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. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - 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 - ); + 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-cloud-videointelligence/src/v1p1beta1/video_intelligence_service_client.ts b/packages/google-cloud-videointelligence/src/v1p1beta1/video_intelligence_service_client.ts index 44c8b8487e3..2789742af15 100644 --- a/packages/google-cloud-videointelligence/src/v1p1beta1/video_intelligence_service_client.ts +++ b/packages/google-cloud-videointelligence/src/v1p1beta1/video_intelligence_service_client.ts @@ -28,6 +28,7 @@ import { import * as path from 'path'; import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); /** * Client JSON configuration object, loaded from * `src/v1p1beta1/video_intelligence_service_client_config.json`. @@ -143,32 +144,13 @@ export class VideoIntelligenceServiceClient { 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. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - 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 - ); + 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-cloud-videointelligence/src/v1p2beta1/video_intelligence_service_client.ts b/packages/google-cloud-videointelligence/src/v1p2beta1/video_intelligence_service_client.ts index 1fdeb85c72a..1e723f66232 100644 --- a/packages/google-cloud-videointelligence/src/v1p2beta1/video_intelligence_service_client.ts +++ b/packages/google-cloud-videointelligence/src/v1p2beta1/video_intelligence_service_client.ts @@ -28,6 +28,7 @@ import { import * as path from 'path'; import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); /** * Client JSON configuration object, loaded from * `src/v1p2beta1/video_intelligence_service_client_config.json`. @@ -143,32 +144,13 @@ export class VideoIntelligenceServiceClient { 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. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - 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 - ); + 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-cloud-videointelligence/src/v1p3beta1/streaming_video_intelligence_service_client.ts b/packages/google-cloud-videointelligence/src/v1p3beta1/streaming_video_intelligence_service_client.ts index 0d1077e2a66..b2a56b9ed7e 100644 --- a/packages/google-cloud-videointelligence/src/v1p3beta1/streaming_video_intelligence_service_client.ts +++ b/packages/google-cloud-videointelligence/src/v1p3beta1/streaming_video_intelligence_service_client.ts @@ -22,6 +22,7 @@ import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; import * as path from 'path'; import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); /** * Client JSON configuration object, loaded from * `src/v1p3beta1/streaming_video_intelligence_service_client_config.json`. @@ -136,22 +137,7 @@ export class StreamingVideoIntelligenceServiceClient { 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 provide streaming responses. // Provide descriptors for these. diff --git a/packages/google-cloud-videointelligence/src/v1p3beta1/video_intelligence_service_client.ts b/packages/google-cloud-videointelligence/src/v1p3beta1/video_intelligence_service_client.ts index da2b6550357..134901e8902 100644 --- a/packages/google-cloud-videointelligence/src/v1p3beta1/video_intelligence_service_client.ts +++ b/packages/google-cloud-videointelligence/src/v1p3beta1/video_intelligence_service_client.ts @@ -28,6 +28,7 @@ import { import * as path from 'path'; import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); /** * Client JSON configuration object, loaded from * `src/v1p3beta1/video_intelligence_service_client_config.json`. @@ -143,32 +144,13 @@ export class VideoIntelligenceServiceClient { 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. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - 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 - ); + 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({