Skip to content

Commit

Permalink
fix: use require() to load JSON protos (#746)
Browse files Browse the repository at this point in the history
* 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-Link: googleapis/googleapis@75880c3

Source-Link: googleapis/googleapis-gen@77b1804

* 🦉 Updates from OwlBot

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Jeff Ching <chingor@google.com>
  • Loading branch information
3 people committed May 11, 2021
1 parent de2447b commit a51fab1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 60 deletions.
26 changes: 4 additions & 22 deletions packages/google-cloud-speech/src/v1/speech_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/speech_client_config.json`.
Expand Down Expand Up @@ -142,22 +143,7 @@ export class SpeechClient {
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.
Expand All @@ -167,15 +153,11 @@ export class SpeechClient {
),
};

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({
Expand Down
18 changes: 2 additions & 16 deletions packages/google-cloud-speech/src/v1p1beta1/adaptation_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/v1p1beta1/adaptation_client_config.json`.
Expand Down Expand Up @@ -145,22 +146,7 @@ export class AdaptationClient {
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.
Expand Down
26 changes: 4 additions & 22 deletions packages/google-cloud-speech/src/v1p1beta1/speech_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/speech_client_config.json`.
Expand Down Expand Up @@ -143,22 +144,7 @@ export class SpeechClient {
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.
Expand All @@ -180,15 +166,11 @@ export class SpeechClient {
),
};

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({
Expand Down

0 comments on commit a51fab1

Please sign in to comment.