From e7cdb8ba1759a02a5096c745830e0eb8365e4ff7 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:56:30 +0000 Subject: [PATCH] fix: use require() to load JSON protos (#273) 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/recaptcha_enterprise_service_client.ts | 18 ++---------------- ...ptcha_enterprise_service_v1_beta1_client.ts | 18 ++---------------- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/packages/google-cloud-recaptchaenterprise/src/v1/recaptcha_enterprise_service_client.ts b/packages/google-cloud-recaptchaenterprise/src/v1/recaptcha_enterprise_service_client.ts index b77fb281d0e..e83e50afaf9 100644 --- a/packages/google-cloud-recaptchaenterprise/src/v1/recaptcha_enterprise_service_client.ts +++ b/packages/google-cloud-recaptchaenterprise/src/v1/recaptcha_enterprise_service_client.ts @@ -31,6 +31,7 @@ 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/recaptcha_enterprise_service_client_config.json`. @@ -146,22 +147,7 @@ export class RecaptchaEnterpriseServiceClient { 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); // This API contains "path templates"; forward-slash-separated // identifiers to uniquely identify resources within the API. diff --git a/packages/google-cloud-recaptchaenterprise/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts b/packages/google-cloud-recaptchaenterprise/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts index 38fe9793c6e..4ee304ca359 100644 --- a/packages/google-cloud-recaptchaenterprise/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts +++ b/packages/google-cloud-recaptchaenterprise/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts @@ -31,6 +31,7 @@ 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/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json`. @@ -146,22 +147,7 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { 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); // This API contains "path templates"; forward-slash-separated // identifiers to uniquely identify resources within the API.