Skip to content

Commit

Permalink
fix: use require() to load JSON protos (#50)
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-Author: Google APIs <noreply@google.com>
Source-Date: Thu May 6 18:50:48 2021 -0700
Source-Repo: googleapis/googleapis
Source-Sha: 75880c3e6a6aa2597400582848e81bbbfac51dea
Source-Link: googleapis/googleapis@75880c3

* chore: update gapic-generator-typescript to v1.3.2

Committer: @alexander-fenster
PiperOrigin-RevId: 372656503

Source-Author: Google APIs <noreply@google.com>
Source-Date: Fri May 7 17:14:53 2021 -0700
Source-Repo: googleapis/googleapis
Source-Sha: 6fa858c6489b1bbc505a7d7afe39f2dc45819c38
Source-Link: googleapis/googleapis@6fa858c
  • Loading branch information
yoshi-automation authored May 21, 2021
1 parent 501b8b7 commit 24d006d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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
Expand All @@ -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({
Expand Down
6 changes: 3 additions & 3 deletions packages/google-api-servicemanagement/synth.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down

0 comments on commit 24d006d

Please sign in to comment.