Skip to content
This repository was archived by the owner on Jul 13, 2023. It is now read-only.

Commit 52fe53d

Browse files
fix: proper fallback option handling (#180)
1 parent 7f74781 commit 52fe53d

16 files changed

+122
-68
lines changed

.kokoro/populate-secrets.sh

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/publish.sh

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/release/publish.cfg

Lines changed: 3 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/trampoline.sh

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/protos.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5083,6 +5083,9 @@ export namespace google {
50835083

50845084
/** FieldDescriptorProto options */
50855085
options?: (google.protobuf.IFieldOptions|null);
5086+
5087+
/** FieldDescriptorProto proto3Optional */
5088+
proto3Optional?: (boolean|null);
50865089
}
50875090

50885091
/** Represents a FieldDescriptorProto. */
@@ -5124,6 +5127,9 @@ export namespace google {
51245127
/** FieldDescriptorProto options. */
51255128
public options?: (google.protobuf.IFieldOptions|null);
51265129

5130+
/** FieldDescriptorProto proto3Optional. */
5131+
public proto3Optional: boolean;
5132+
51275133
/**
51285134
* Creates a new FieldDescriptorProto instance using the specified properties.
51295135
* @param [properties] Properties to set

protos/protos.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
2929

3030
// Exported root namespace
31-
var $root = $protobuf.roots._google_cloud_recaptcha_enterprise_1_8_0_protos || ($protobuf.roots._google_cloud_recaptcha_enterprise_1_8_0_protos = {});
31+
var $root = $protobuf.roots._google_cloud_recaptcha_enterprise_protos || ($protobuf.roots._google_cloud_recaptcha_enterprise_protos = {});
3232

3333
$root.google = (function() {
3434

@@ -12382,6 +12382,7 @@
1238212382
* @property {number|null} [oneofIndex] FieldDescriptorProto oneofIndex
1238312383
* @property {string|null} [jsonName] FieldDescriptorProto jsonName
1238412384
* @property {google.protobuf.IFieldOptions|null} [options] FieldDescriptorProto options
12385+
* @property {boolean|null} [proto3Optional] FieldDescriptorProto proto3Optional
1238512386
*/
1238612387

1238712388
/**
@@ -12479,6 +12480,14 @@
1247912480
*/
1248012481
FieldDescriptorProto.prototype.options = null;
1248112482

12483+
/**
12484+
* FieldDescriptorProto proto3Optional.
12485+
* @member {boolean} proto3Optional
12486+
* @memberof google.protobuf.FieldDescriptorProto
12487+
* @instance
12488+
*/
12489+
FieldDescriptorProto.prototype.proto3Optional = false;
12490+
1248212491
/**
1248312492
* Creates a new FieldDescriptorProto instance using the specified properties.
1248412493
* @function create
@@ -12523,6 +12532,8 @@
1252312532
writer.uint32(/* id 9, wireType 0 =*/72).int32(message.oneofIndex);
1252412533
if (message.jsonName != null && Object.hasOwnProperty.call(message, "jsonName"))
1252512534
writer.uint32(/* id 10, wireType 2 =*/82).string(message.jsonName);
12535+
if (message.proto3Optional != null && Object.hasOwnProperty.call(message, "proto3Optional"))
12536+
writer.uint32(/* id 17, wireType 0 =*/136).bool(message.proto3Optional);
1252612537
return writer;
1252712538
};
1252812539

@@ -12587,6 +12598,9 @@
1258712598
case 8:
1258812599
message.options = $root.google.protobuf.FieldOptions.decode(reader, reader.uint32());
1258912600
break;
12601+
case 17:
12602+
message.proto3Optional = reader.bool();
12603+
break;
1259012604
default:
1259112605
reader.skipType(tag & 7);
1259212606
break;
@@ -12681,6 +12695,9 @@
1268112695
if (error)
1268212696
return "options." + error;
1268312697
}
12698+
if (message.proto3Optional != null && message.hasOwnProperty("proto3Optional"))
12699+
if (typeof message.proto3Optional !== "boolean")
12700+
return "proto3Optional: boolean expected";
1268412701
return null;
1268512702
};
1268612703

@@ -12803,6 +12820,8 @@
1280312820
throw TypeError(".google.protobuf.FieldDescriptorProto.options: object expected");
1280412821
message.options = $root.google.protobuf.FieldOptions.fromObject(object.options);
1280512822
}
12823+
if (object.proto3Optional != null)
12824+
message.proto3Optional = Boolean(object.proto3Optional);
1280612825
return message;
1280712826
};
1280812827

@@ -12830,6 +12849,7 @@
1283012849
object.options = null;
1283112850
object.oneofIndex = 0;
1283212851
object.jsonName = "";
12852+
object.proto3Optional = false;
1283312853
}
1283412854
if (message.name != null && message.hasOwnProperty("name"))
1283512855
object.name = message.name;
@@ -12851,6 +12871,8 @@
1285112871
object.oneofIndex = message.oneofIndex;
1285212872
if (message.jsonName != null && message.hasOwnProperty("jsonName"))
1285312873
object.jsonName = message.jsonName;
12874+
if (message.proto3Optional != null && message.hasOwnProperty("proto3Optional"))
12875+
object.proto3Optional = message.proto3Optional;
1285412876
return object;
1285512877
};
1285612878

@@ -14644,7 +14666,7 @@
1464414666
* @memberof google.protobuf.FileOptions
1464514667
* @instance
1464614668
*/
14647-
FileOptions.prototype.ccEnableArenas = false;
14669+
FileOptions.prototype.ccEnableArenas = true;
1464814670

1464914671
/**
1465014672
* FileOptions objcClassPrefix.
@@ -15130,7 +15152,7 @@
1513015152
object.javaGenerateEqualsAndHash = false;
1513115153
object.deprecated = false;
1513215154
object.javaStringCheckUtf8 = false;
15133-
object.ccEnableArenas = false;
15155+
object.ccEnableArenas = true;
1513415156
object.objcClassPrefix = "";
1513515157
object.csharpNamespace = "";
1513615158
object.swiftPrefix = "";

protos/protos.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,10 @@
13651365
"options": {
13661366
"type": "FieldOptions",
13671367
"id": 8
1368+
},
1369+
"proto3Optional": {
1370+
"type": "bool",
1371+
"id": 17
13681372
}
13691373
},
13701374
"nested": {
@@ -1600,7 +1604,7 @@
16001604
"type": "bool",
16011605
"id": 31,
16021606
"options": {
1603-
"default": false
1607+
"default": true
16041608
}
16051609
},
16061610
"objcClassPrefix": {

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
// ** https://github.com/googleapis/synthtool **
1717
// ** All changes to this file may be overwritten. **
1818

19-
import * as v1 from './v1';
2019
import * as v1beta1 from './v1beta1';
20+
import * as v1 from './v1';
2121

2222
const RecaptchaEnterpriseServiceClient = v1.RecaptchaEnterpriseServiceClient;
2323

24-
export {v1, v1beta1, RecaptchaEnterpriseServiceClient};
25-
export default {v1, v1beta1, RecaptchaEnterpriseServiceClient};
24+
export {v1beta1, v1, RecaptchaEnterpriseServiceClient};
25+
export default {v1beta1, v1, RecaptchaEnterpriseServiceClient};
2626
import * as protos from '../protos/protos';
2727
export {protos};

src/v1/recaptcha_enterprise_service_client.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,20 @@ export class RecaptchaEnterpriseServiceClient {
100100
}
101101
opts.servicePath = opts.servicePath || servicePath;
102102
opts.port = opts.port || port;
103+
104+
// users can override the config from client side, like retry codes name.
105+
// The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546
106+
// The way to override client config for Showcase API:
107+
//
108+
// const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}}
109+
// const showcaseClient = new showcaseClient({ projectId, customConfig });
103110
opts.clientConfig = opts.clientConfig || {};
104111

105-
const isBrowser = typeof window !== 'undefined';
106-
if (isBrowser) {
107-
opts.fallback = true;
108-
}
109-
// If we are in browser, we are already using fallback because of the
110-
// "browser" field in package.json.
111-
// But if we were explicitly requested to use fallback, let's do it now.
112-
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
112+
// If we're running in browser, it's OK to omit `fallback` since
113+
// google-gax has `browser` field in its `package.json`.
114+
// For Electron (which does not respect `browser` field),
115+
// pass `{fallback: true}` to the RecaptchaEnterpriseServiceClient constructor.
116+
this._gaxModule = opts.fallback ? gax.fallback : gax;
113117

114118
// Create a `gaxGrpc` object, with any grpc-specific options
115119
// sent to the client.

src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,20 @@ export class RecaptchaEnterpriseServiceV1Beta1Client {
100100
}
101101
opts.servicePath = opts.servicePath || servicePath;
102102
opts.port = opts.port || port;
103+
104+
// users can override the config from client side, like retry codes name.
105+
// The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546
106+
// The way to override client config for Showcase API:
107+
//
108+
// const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}}
109+
// const showcaseClient = new showcaseClient({ projectId, customConfig });
103110
opts.clientConfig = opts.clientConfig || {};
104111

105-
const isBrowser = typeof window !== 'undefined';
106-
if (isBrowser) {
107-
opts.fallback = true;
108-
}
109-
// If we are in browser, we are already using fallback because of the
110-
// "browser" field in package.json.
111-
// But if we were explicitly requested to use fallback, let's do it now.
112-
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
112+
// If we're running in browser, it's OK to omit `fallback` since
113+
// google-gax has `browser` field in its `package.json`.
114+
// For Electron (which does not respect `browser` field),
115+
// pass `{fallback: true}` to the RecaptchaEnterpriseServiceV1Beta1Client constructor.
116+
this._gaxModule = opts.fallback ? gax.fallback : gax;
113117

114118
// Create a `gaxGrpc` object, with any grpc-specific options
115119
// sent to the client.

0 commit comments

Comments
 (0)