Skip to content

Commit 7c49e43

Browse files
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: googleapis/googleapis@75880c3 Source-Link: googleapis/googleapis-gen@77b1804
1 parent f4c889d commit 7c49e43

6 files changed

+17
-121
lines changed

packages/google-cloud-videointelligence/src/v1/video_intelligence_service_client.ts

+3-21
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
import * as path from 'path';
2929

3030
import * as protos from '../../protos/protos';
31+
import jsonProtos = require('../../protos/protos.json');
3132
/**
3233
* Client JSON configuration object, loaded from
3334
* `src/v1/video_intelligence_service_client_config.json`.
@@ -143,32 +144,13 @@ export class VideoIntelligenceServiceClient {
143144
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
144145
}
145146
// Load the applicable protos.
146-
// For Node.js, pass the path to JSON proto file.
147-
// For browsers, pass the JSON content.
147+
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
148148

149-
const nodejsProtoPath = path.join(
150-
__dirname,
151-
'..',
152-
'..',
153-
'protos',
154-
'protos.json'
155-
);
156-
this._protos = this._gaxGrpc.loadProto(
157-
opts.fallback
158-
? // eslint-disable-next-line @typescript-eslint/no-var-requires
159-
require('../../protos/protos.json')
160-
: nodejsProtoPath
161-
);
149+
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
162150

163151
// This API contains "long-running operations", which return a
164152
// an Operation object that allows for tracking of the operation,
165153
// rather than holding a request open.
166-
const protoFilesRoot = opts.fallback
167-
? this._gaxModule.protobuf.Root.fromJSON(
168-
// eslint-disable-next-line @typescript-eslint/no-var-requires
169-
require('../../protos/protos.json')
170-
)
171-
: this._gaxModule.protobuf.loadSync(nodejsProtoPath);
172154

173155
this.operationsClient = this._gaxModule
174156
.lro({

packages/google-cloud-videointelligence/src/v1beta2/video_intelligence_service_client.ts

+3-21
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
import * as path from 'path';
2929

3030
import * as protos from '../../protos/protos';
31+
import jsonProtos = require('../../protos/protos.json');
3132
/**
3233
* Client JSON configuration object, loaded from
3334
* `src/v1beta2/video_intelligence_service_client_config.json`.
@@ -143,32 +144,13 @@ export class VideoIntelligenceServiceClient {
143144
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
144145
}
145146
// Load the applicable protos.
146-
// For Node.js, pass the path to JSON proto file.
147-
// For browsers, pass the JSON content.
147+
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
148148

149-
const nodejsProtoPath = path.join(
150-
__dirname,
151-
'..',
152-
'..',
153-
'protos',
154-
'protos.json'
155-
);
156-
this._protos = this._gaxGrpc.loadProto(
157-
opts.fallback
158-
? // eslint-disable-next-line @typescript-eslint/no-var-requires
159-
require('../../protos/protos.json')
160-
: nodejsProtoPath
161-
);
149+
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
162150

163151
// This API contains "long-running operations", which return a
164152
// an Operation object that allows for tracking of the operation,
165153
// rather than holding a request open.
166-
const protoFilesRoot = opts.fallback
167-
? this._gaxModule.protobuf.Root.fromJSON(
168-
// eslint-disable-next-line @typescript-eslint/no-var-requires
169-
require('../../protos/protos.json')
170-
)
171-
: this._gaxModule.protobuf.loadSync(nodejsProtoPath);
172154

173155
this.operationsClient = this._gaxModule
174156
.lro({

packages/google-cloud-videointelligence/src/v1p1beta1/video_intelligence_service_client.ts

+3-21
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
import * as path from 'path';
2929

3030
import * as protos from '../../protos/protos';
31+
import jsonProtos = require('../../protos/protos.json');
3132
/**
3233
* Client JSON configuration object, loaded from
3334
* `src/v1p1beta1/video_intelligence_service_client_config.json`.
@@ -143,32 +144,13 @@ export class VideoIntelligenceServiceClient {
143144
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
144145
}
145146
// Load the applicable protos.
146-
// For Node.js, pass the path to JSON proto file.
147-
// For browsers, pass the JSON content.
147+
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
148148

149-
const nodejsProtoPath = path.join(
150-
__dirname,
151-
'..',
152-
'..',
153-
'protos',
154-
'protos.json'
155-
);
156-
this._protos = this._gaxGrpc.loadProto(
157-
opts.fallback
158-
? // eslint-disable-next-line @typescript-eslint/no-var-requires
159-
require('../../protos/protos.json')
160-
: nodejsProtoPath
161-
);
149+
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
162150

163151
// This API contains "long-running operations", which return a
164152
// an Operation object that allows for tracking of the operation,
165153
// rather than holding a request open.
166-
const protoFilesRoot = opts.fallback
167-
? this._gaxModule.protobuf.Root.fromJSON(
168-
// eslint-disable-next-line @typescript-eslint/no-var-requires
169-
require('../../protos/protos.json')
170-
)
171-
: this._gaxModule.protobuf.loadSync(nodejsProtoPath);
172154

173155
this.operationsClient = this._gaxModule
174156
.lro({

packages/google-cloud-videointelligence/src/v1p2beta1/video_intelligence_service_client.ts

+3-21
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
import * as path from 'path';
2929

3030
import * as protos from '../../protos/protos';
31+
import jsonProtos = require('../../protos/protos.json');
3132
/**
3233
* Client JSON configuration object, loaded from
3334
* `src/v1p2beta1/video_intelligence_service_client_config.json`.
@@ -143,32 +144,13 @@ export class VideoIntelligenceServiceClient {
143144
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
144145
}
145146
// Load the applicable protos.
146-
// For Node.js, pass the path to JSON proto file.
147-
// For browsers, pass the JSON content.
147+
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
148148

149-
const nodejsProtoPath = path.join(
150-
__dirname,
151-
'..',
152-
'..',
153-
'protos',
154-
'protos.json'
155-
);
156-
this._protos = this._gaxGrpc.loadProto(
157-
opts.fallback
158-
? // eslint-disable-next-line @typescript-eslint/no-var-requires
159-
require('../../protos/protos.json')
160-
: nodejsProtoPath
161-
);
149+
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
162150

163151
// This API contains "long-running operations", which return a
164152
// an Operation object that allows for tracking of the operation,
165153
// rather than holding a request open.
166-
const protoFilesRoot = opts.fallback
167-
? this._gaxModule.protobuf.Root.fromJSON(
168-
// eslint-disable-next-line @typescript-eslint/no-var-requires
169-
require('../../protos/protos.json')
170-
)
171-
: this._gaxModule.protobuf.loadSync(nodejsProtoPath);
172154

173155
this.operationsClient = this._gaxModule
174156
.lro({

packages/google-cloud-videointelligence/src/v1p3beta1/streaming_video_intelligence_service_client.ts

+2-16
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax';
2222
import * as path from 'path';
2323

2424
import * as protos from '../../protos/protos';
25+
import jsonProtos = require('../../protos/protos.json');
2526
/**
2627
* Client JSON configuration object, loaded from
2728
* `src/v1p3beta1/streaming_video_intelligence_service_client_config.json`.
@@ -136,22 +137,7 @@ export class StreamingVideoIntelligenceServiceClient {
136137
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
137138
}
138139
// Load the applicable protos.
139-
// For Node.js, pass the path to JSON proto file.
140-
// For browsers, pass the JSON content.
141-
142-
const nodejsProtoPath = path.join(
143-
__dirname,
144-
'..',
145-
'..',
146-
'protos',
147-
'protos.json'
148-
);
149-
this._protos = this._gaxGrpc.loadProto(
150-
opts.fallback
151-
? // eslint-disable-next-line @typescript-eslint/no-var-requires
152-
require('../../protos/protos.json')
153-
: nodejsProtoPath
154-
);
140+
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
155141

156142
// Some of the methods on this service provide streaming responses.
157143
// Provide descriptors for these.

packages/google-cloud-videointelligence/src/v1p3beta1/video_intelligence_service_client.ts

+3-21
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
import * as path from 'path';
2929

3030
import * as protos from '../../protos/protos';
31+
import jsonProtos = require('../../protos/protos.json');
3132
/**
3233
* Client JSON configuration object, loaded from
3334
* `src/v1p3beta1/video_intelligence_service_client_config.json`.
@@ -143,32 +144,13 @@ export class VideoIntelligenceServiceClient {
143144
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
144145
}
145146
// Load the applicable protos.
146-
// For Node.js, pass the path to JSON proto file.
147-
// For browsers, pass the JSON content.
147+
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
148148

149-
const nodejsProtoPath = path.join(
150-
__dirname,
151-
'..',
152-
'..',
153-
'protos',
154-
'protos.json'
155-
);
156-
this._protos = this._gaxGrpc.loadProto(
157-
opts.fallback
158-
? // eslint-disable-next-line @typescript-eslint/no-var-requires
159-
require('../../protos/protos.json')
160-
: nodejsProtoPath
161-
);
149+
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
162150

163151
// This API contains "long-running operations", which return a
164152
// an Operation object that allows for tracking of the operation,
165153
// rather than holding a request open.
166-
const protoFilesRoot = opts.fallback
167-
? this._gaxModule.protobuf.Root.fromJSON(
168-
// eslint-disable-next-line @typescript-eslint/no-var-requires
169-
require('../../protos/protos.json')
170-
)
171-
: this._gaxModule.protobuf.loadSync(nodejsProtoPath);
172154

173155
this.operationsClient = this._gaxModule
174156
.lro({

0 commit comments

Comments
 (0)