From 308702115f1b9f5794d871b2b51ac45de1e60732 Mon Sep 17 00:00:00 2001 From: Alexander Fenster Date: Wed, 1 Feb 2023 21:59:51 +0000 Subject: [PATCH] feat!: convert to ESM --- .gitignore | 1 + package.json | 30 +- protos/index.d.ts | 622 ++- protos/index.js | 3730 ++++++++++++----- protos/protos.json | 2142 ++++++++++ .../typescript_gapic_metadata/package.json | 3 + templates/typescript_samples/package.json | 3 + .../samples/generated/$version/_util.njk | 4 +- tsconfig.json | 10 +- typescript/src/bundle.ts | 2 + typescript/src/gapic-generator-typescript.ts | 467 ++- typescript/src/generator.ts | 93 +- typescript/src/protoc-plugin.ts | 10 +- typescript/src/schema/api.ts | 15 +- typescript/src/schema/comments.ts | 39 +- typescript/src/schema/naming.ts | 10 +- typescript/src/schema/proto.ts | 92 +- typescript/src/schema/resource-database.ts | 10 +- typescript/src/schema/retryable-code-map.ts | 33 +- typescript/src/serviceyaml.ts | 4 +- typescript/src/templater.ts | 46 +- typescript/src/util.ts | 79 +- typescript/test/test-application/test-js.ts | 8 +- typescript/test/test-application/test-ts.ts | 9 +- typescript/test/unit-test-runner.ts | 8 +- typescript/test/unit/api.ts | 134 +- typescript/test/unit/baselines.ts | 2 +- typescript/test/unit/naming.ts | 98 +- typescript/test/unit/proto.ts | 198 +- typescript/test/unit/resource-database.ts | 6 +- typescript/test/unit/retryable-code-map.ts | 7 +- typescript/test/unit/util.ts | 81 +- typescript/test/util.ts | 11 +- typescript/tools/update-baselines.ts | 14 +- 34 files changed, 6215 insertions(+), 1806 deletions(-) create mode 100644 protos/protos.json create mode 100644 templates/typescript_gapic_metadata/package.json create mode 100644 templates/typescript_samples/package.json diff --git a/.gitignore b/.gitignore index 766fb07dc..fc9fc80f6 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ docker/gitlog.txt .test-application-js .test-application-ts bazel-* +.aspect diff --git a/package.json b/package.json index 0153c4004..d4e079b7f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "@google-cloud/gapic-generator", "version": "2.18.2", + "type": "module", "description": "Google API Client Library Generator for TypeScript, written in TypeScript.", "homepage": "https://github.com/googleapis/gapic-generator-typescript#readme", "bugs": { @@ -27,7 +28,9 @@ "clean": "bazel clean && rm -rf build", "codecov": "c8 --reporter=lcov mocha bazel-bin/typescript/test/unit && c8 report", "compile": "bazel build //...", - "compile-protos": "pbjs -t static-module -o protos/index.js -p node_modules/google-gax/build/protos -p protos google/api/annotations.proto google/api/field_behavior.proto google/api/resource.proto google/api/routing.proto google/longrunning/operations.proto google/protobuf/compiler/plugin.proto service_config.proto snippet_index.proto && pbts protos/index.js -o protos/index.d.ts", + "compile-protos-json": "pbjs -t json -o protos/protos.json -p node_modules/google-gax/build/protos -p protos google/api/annotations.proto google/api/field_behavior.proto google/api/resource.proto google/api/routing.proto google/longrunning/operations.proto google/protobuf/compiler/plugin.proto service_config.proto snippet_index.proto", + "compile-protos-js": "pbjs -t static-module -o protos/index.js -p node_modules/google-gax/build/protos -p protos google/api/annotations.proto google/api/field_behavior.proto google/api/resource.proto google/api/routing.proto google/longrunning/operations.proto google/protobuf/compiler/plugin.proto service_config.proto snippet_index.proto", + "compile-protos-dts": "pbts protos/index.js -o protos/index.d.ts", "docker-test": "sh docker/test.sh", "fix": "gts fix", "js-test-application": "mocha bazel-bin/typescript/test/test-application/test-js --timeout 600000", @@ -39,36 +42,31 @@ }, "dependencies": { "@types/js-yaml": "^4.0.5", - "fs-extra": "^10.1.0", "google-gax": "^3.5.2", "js-yaml": "^4.1.0", - "long": "^5.2.0", + "long": "^5.2.1", "nunjucks": "^3.2.3", "object-hash": "^3.0.0", + "proto3-json-serializer": "^1.1.0", "protobufjs": "^7.1.2", - "yargs": "^17.6.0" + "yargs": "^17.6.2" }, "devDependencies": { "@bazel/bazelisk": "^1.12.1", - "@bazel/buildifier": "^5.1.0", - "@bazel/typescript": "~4.6.1", "@types/fs-extra": "^9.0.13", - "@types/long": "^4.0.2", - "@types/mocha": "^10.0.0", + "@types/mocha": "^10.0.1", "@types/module-alias": "^2.0.1", - "@types/node": "^16.11.68", + "@types/node": "^18.11.17", "@types/nunjucks": "^3.2.1", - "@types/object-hash": "^2.2.1", - "@types/sinon": "^10.0.13", - "@types/yargs": "^17.0.13", + "@types/object-hash": "^3.0.2", + "@types/yargs": "^17.0.17", "c8": "^7.12.0", "espower-typescript": "^10.0.1", "gts": "^3.1.1", - "mocha": "^10.1.0", - "sinon": "^14.0.1", - "typescript": "~4.8.4" + "mocha": "^10.2.0", + "typescript": "4.9.3" }, "engines": { - "node": ">=12" + "node": ">=14" } } diff --git a/protos/index.d.ts b/protos/index.d.ts index c3558239b..3807e5e6f 100644 --- a/protos/index.d.ts +++ b/protos/index.d.ts @@ -1,4 +1,7 @@ import * as $protobuf from "protobufjs"; + +// Note: this file was manually edited to remove references to Long which are not needed in this project. + /** Namespace grpc. */ export namespace grpc { @@ -132,6 +135,13 @@ export namespace grpc { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for MethodConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace MethodConfig { @@ -230,6 +240,13 @@ export namespace grpc { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Name + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a RetryPolicy. */ @@ -344,6 +361,13 @@ export namespace grpc { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RetryPolicy + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a HedgingPolicy. */ @@ -446,6 +470,13 @@ export namespace grpc { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for HedgingPolicy + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } } @@ -531,6 +562,13 @@ export namespace grpc { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PickFirstConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a RoundRobinConfig. */ @@ -615,6 +653,13 @@ export namespace grpc { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RoundRobinConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a GrpcLbConfig. */ @@ -705,6 +750,13 @@ export namespace grpc { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GrpcLbConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a XdsConfig. */ @@ -807,6 +859,13 @@ export namespace grpc { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for XdsConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a LoadBalancingConfig. */ @@ -924,6 +983,13 @@ export namespace grpc { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for LoadBalancingConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a ServiceConfig. */ @@ -1038,6 +1104,13 @@ export namespace grpc { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ServiceConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace ServiceConfig { @@ -1142,6 +1215,13 @@ export namespace grpc { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RetryThrottlingPolicy + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a HealthCheckConfig. */ @@ -1232,6 +1312,13 @@ export namespace grpc { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for HealthCheckConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } } } @@ -1337,6 +1424,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Http + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a HttpRule. */ @@ -1484,6 +1578,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for HttpRule + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a CustomHttpPattern. */ @@ -1580,6 +1681,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CustomHttpPattern + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** FieldBehavior enum. */ @@ -1718,6 +1826,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ResourceDescriptor + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace ResourceDescriptor { @@ -1830,6 +1945,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ResourceReference + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a RoutingRule. */ @@ -1920,6 +2042,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RoutingRule + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a RoutingParameter. */ @@ -2016,6 +2145,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RoutingParameter + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } } @@ -2110,6 +2246,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FileDescriptorSet + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a FileDescriptorProto. */ @@ -2150,6 +2293,9 @@ export namespace google { /** FileDescriptorProto syntax */ syntax?: (string|null); + + /** FileDescriptorProto edition */ + edition?: (string|null); } /** Represents a FileDescriptorProto. */ @@ -2197,6 +2343,9 @@ export namespace google { /** FileDescriptorProto syntax. */ public syntax: string; + /** FileDescriptorProto edition. */ + public edition: string; + /** * Creates a new FileDescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -2266,6 +2415,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FileDescriptorProto + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a DescriptorProto. */ @@ -2410,6 +2566,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DescriptorProto + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace DescriptorProto { @@ -2514,6 +2677,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExtensionRange + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a ReservedRange. */ @@ -2610,6 +2780,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ReservedRange + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } } @@ -2701,6 +2878,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExtensionRangeOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a FieldDescriptorProto. */ @@ -2851,6 +3035,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FieldDescriptorProto + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace FieldDescriptorProto { @@ -2979,6 +3170,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for OneofDescriptorProto + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of an EnumDescriptorProto. */ @@ -3093,6 +3291,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for EnumDescriptorProto + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace EnumDescriptorProto { @@ -3191,6 +3396,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for EnumReservedRange + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } } @@ -3294,6 +3506,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for EnumValueDescriptorProto + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a ServiceDescriptorProto. */ @@ -3396,6 +3615,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ServiceDescriptorProto + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a MethodDescriptorProto. */ @@ -3516,6 +3742,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for MethodDescriptorProto + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a FileOptions. */ @@ -3729,6 +3962,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FileOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace FileOptions { @@ -3856,6 +4096,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for MessageOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a FieldOptions. */ @@ -3873,6 +4120,9 @@ export namespace google { /** FieldOptions lazy */ lazy?: (boolean|null); + /** FieldOptions unverifiedLazy */ + unverifiedLazy?: (boolean|null); + /** FieldOptions deprecated */ deprecated?: (boolean|null); @@ -3910,6 +4160,9 @@ export namespace google { /** FieldOptions lazy. */ public lazy: boolean; + /** FieldOptions unverifiedLazy. */ + public unverifiedLazy: boolean; + /** FieldOptions deprecated. */ public deprecated: boolean; @@ -3988,6 +4241,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FieldOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace FieldOptions { @@ -4095,6 +4355,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for OneofOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of an EnumOptions. */ @@ -4197,6 +4464,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for EnumOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of an EnumValueOptions. */ @@ -4293,6 +4567,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for EnumValueOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a ServiceOptions. */ @@ -4395,6 +4676,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ServiceOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a MethodOptions. */ @@ -4509,6 +4797,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for MethodOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace MethodOptions { @@ -4531,10 +4826,10 @@ export namespace google { identifierValue?: (string|null); /** UninterpretedOption positiveIntValue */ - positiveIntValue?: (number|Long|null); + positiveIntValue?: (number|null); /** UninterpretedOption negativeIntValue */ - negativeIntValue?: (number|Long|null); + negativeIntValue?: (number|null); /** UninterpretedOption doubleValue */ doubleValue?: (number|null); @@ -4562,10 +4857,10 @@ export namespace google { public identifierValue: string; /** UninterpretedOption positiveIntValue. */ - public positiveIntValue: (number|Long); + public positiveIntValue: (number); /** UninterpretedOption negativeIntValue. */ - public negativeIntValue: (number|Long); + public negativeIntValue: (number); /** UninterpretedOption doubleValue. */ public doubleValue: number; @@ -4645,6 +4940,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UninterpretedOption + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace UninterpretedOption { @@ -4743,6 +5045,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for NamePart + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } } @@ -4834,6 +5143,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SourceCodeInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace SourceCodeInfo { @@ -4950,6 +5266,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Location + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } } @@ -5041,6 +5364,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GeneratedCodeInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace GeneratedCodeInfo { @@ -5059,6 +5389,9 @@ export namespace google { /** Annotation end */ end?: (number|null); + + /** Annotation semantic */ + semantic?: (google.protobuf.GeneratedCodeInfo.Annotation.Semantic|null); } /** Represents an Annotation. */ @@ -5082,6 +5415,9 @@ export namespace google { /** Annotation end. */ public end: number; + /** Annotation semantic. */ + public semantic: google.protobuf.GeneratedCodeInfo.Annotation.Semantic; + /** * Creates a new Annotation instance using the specified properties. * @param [properties] Properties to set @@ -5151,6 +5487,23 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Annotation + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Annotation { + + /** Semantic enum. */ + enum Semantic { + NONE = 0, + SET = 1, + ALIAS = 2 + } } } @@ -5248,13 +5601,20 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Any + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a Duration. */ interface IDuration { /** Duration seconds */ - seconds?: (number|Long|null); + seconds?: (number|null); /** Duration nanos */ nanos?: (number|null); @@ -5270,7 +5630,7 @@ export namespace google { constructor(properties?: google.protobuf.IDuration); /** Duration seconds. */ - public seconds: (number|Long); + public seconds: (number); /** Duration nanos. */ public nanos: number; @@ -5344,6 +5704,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Duration + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of an Empty. */ @@ -5428,6 +5795,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Empty + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Namespace compiler. */ @@ -5539,6 +5913,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Version + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a CodeGeneratorRequest. */ @@ -5647,6 +6028,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CodeGeneratorRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a CodeGeneratorResponse. */ @@ -5656,7 +6044,7 @@ export namespace google { error?: (string|null); /** CodeGeneratorResponse supportedFeatures */ - supportedFeatures?: (number|Long|null); + supportedFeatures?: (number|null); /** CodeGeneratorResponse file */ file?: (google.protobuf.compiler.CodeGeneratorResponse.IFile[]|null); @@ -5675,7 +6063,7 @@ export namespace google { public error: string; /** CodeGeneratorResponse supportedFeatures. */ - public supportedFeatures: (number|Long); + public supportedFeatures: (number); /** CodeGeneratorResponse file. */ public file: google.protobuf.compiler.CodeGeneratorResponse.IFile[]; @@ -5749,6 +6137,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CodeGeneratorResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace CodeGeneratorResponse { @@ -5865,6 +6260,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for File + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } } } @@ -5957,6 +6359,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DoubleValue + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a FloatValue. */ @@ -6047,13 +6456,20 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FloatValue + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of an Int64Value. */ interface IInt64Value { /** Int64Value value */ - value?: (number|Long|null); + value?: (number|null); } /** Represents an Int64Value. */ @@ -6066,7 +6482,7 @@ export namespace google { constructor(properties?: google.protobuf.IInt64Value); /** Int64Value value. */ - public value: (number|Long); + public value: (number); /** * Creates a new Int64Value instance using the specified properties. @@ -6137,13 +6553,20 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Int64Value + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a UInt64Value. */ interface IUInt64Value { /** UInt64Value value */ - value?: (number|Long|null); + value?: (number|null); } /** Represents a UInt64Value. */ @@ -6156,7 +6579,7 @@ export namespace google { constructor(properties?: google.protobuf.IUInt64Value); /** UInt64Value value. */ - public value: (number|Long); + public value: (number); /** * Creates a new UInt64Value instance using the specified properties. @@ -6227,6 +6650,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UInt64Value + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of an Int32Value. */ @@ -6317,6 +6747,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Int32Value + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a UInt32Value. */ @@ -6407,6 +6844,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UInt32Value + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a BoolValue. */ @@ -6497,6 +6941,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BoolValue + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a StringValue. */ @@ -6587,6 +7038,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StringValue + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a BytesValue. */ @@ -6677,6 +7135,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BytesValue + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } } @@ -6927,6 +7392,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Operation + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a GetOperationRequest. */ @@ -7017,6 +7489,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetOperationRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a ListOperationsRequest. */ @@ -7125,6 +7604,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListOperationsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a ListOperationsResponse. */ @@ -7221,6 +7707,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListOperationsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a CancelOperationRequest. */ @@ -7311,6 +7804,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CancelOperationRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a DeleteOperationRequest. */ @@ -7401,6 +7901,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteOperationRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a WaitOperationRequest. */ @@ -7497,6 +8004,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for WaitOperationRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of an OperationInfo. */ @@ -7593,6 +8107,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for OperationInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } } @@ -7699,6 +8220,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Status + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Code enum. */ @@ -7832,6 +8360,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Index + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a Snippet. */ @@ -7970,6 +8505,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Snippet + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace Snippet { @@ -8082,6 +8624,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Segment + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace Segment { @@ -8223,6 +8772,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ClientMethod + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace ClientMethod { @@ -8321,6 +8877,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Parameter + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } } @@ -8418,6 +8981,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ServiceClient + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a ClientLibrary. */ @@ -8526,6 +9096,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ClientLibrary + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a Method. */ @@ -8628,6 +9205,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Method + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of a Service. */ @@ -8724,6 +9308,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Service + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Properties of an Api. */ @@ -8820,6 +9411,13 @@ export namespace google { * @returns JSON object */ public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Api + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } /** Language enum. */ diff --git a/protos/index.js b/protos/index.js index 922f4f4f2..13bab18ac 100644 --- a/protos/index.js +++ b/protos/index.js @@ -208,29 +208,36 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - if (!(message.name && message.name.length)) - message.name = []; - message.name.push($root.grpc.service_config.MethodConfig.Name.decode(reader, reader.uint32())); - break; - case 2: - message.waitForReady = $root.google.protobuf.BoolValue.decode(reader, reader.uint32()); - break; - case 3: - message.timeout = $root.google.protobuf.Duration.decode(reader, reader.uint32()); - break; - case 4: - message.maxRequestMessageBytes = $root.google.protobuf.UInt32Value.decode(reader, reader.uint32()); - break; - case 5: - message.maxResponseMessageBytes = $root.google.protobuf.UInt32Value.decode(reader, reader.uint32()); - break; - case 6: - message.retryPolicy = $root.grpc.service_config.MethodConfig.RetryPolicy.decode(reader, reader.uint32()); - break; - case 7: - message.hedgingPolicy = $root.grpc.service_config.MethodConfig.HedgingPolicy.decode(reader, reader.uint32()); - break; + case 1: { + if (!(message.name && message.name.length)) + message.name = []; + message.name.push($root.grpc.service_config.MethodConfig.Name.decode(reader, reader.uint32())); + break; + } + case 2: { + message.waitForReady = $root.google.protobuf.BoolValue.decode(reader, reader.uint32()); + break; + } + case 3: { + message.timeout = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + case 4: { + message.maxRequestMessageBytes = $root.google.protobuf.UInt32Value.decode(reader, reader.uint32()); + break; + } + case 5: { + message.maxResponseMessageBytes = $root.google.protobuf.UInt32Value.decode(reader, reader.uint32()); + break; + } + case 6: { + message.retryPolicy = $root.grpc.service_config.MethodConfig.RetryPolicy.decode(reader, reader.uint32()); + break; + } + case 7: { + message.hedgingPolicy = $root.grpc.service_config.MethodConfig.HedgingPolicy.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -430,6 +437,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for MethodConfig + * @function getTypeUrl + * @memberof grpc.service_config.MethodConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + MethodConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/grpc.service_config.MethodConfig"; + }; + MethodConfig.Name = (function() { /** @@ -533,12 +555,14 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.service = reader.string(); - break; - case 2: - message.method = reader.string(); - break; + case 1: { + message.service = reader.string(); + break; + } + case 2: { + message.method = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -637,6 +661,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Name + * @function getTypeUrl + * @memberof grpc.service_config.MethodConfig.Name + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Name.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/grpc.service_config.MethodConfig.Name"; + }; + return Name; })(); @@ -781,28 +820,33 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.maxAttempts = reader.uint32(); - break; - case 2: - message.initialBackoff = $root.google.protobuf.Duration.decode(reader, reader.uint32()); - break; - case 3: - message.maxBackoff = $root.google.protobuf.Duration.decode(reader, reader.uint32()); - break; - case 4: - message.backoffMultiplier = reader.float(); - break; - case 5: - if (!(message.retryableStatusCodes && message.retryableStatusCodes.length)) - message.retryableStatusCodes = []; - if ((tag & 7) === 2) { - var end2 = reader.uint32() + reader.pos; - while (reader.pos < end2) + case 1: { + message.maxAttempts = reader.uint32(); + break; + } + case 2: { + message.initialBackoff = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + case 3: { + message.maxBackoff = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + case 4: { + message.backoffMultiplier = reader.float(); + break; + } + case 5: { + if (!(message.retryableStatusCodes && message.retryableStatusCodes.length)) + message.retryableStatusCodes = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.retryableStatusCodes.push(reader.int32()); + } else message.retryableStatusCodes.push(reader.int32()); - } else - message.retryableStatusCodes.push(reader.int32()); - break; + break; + } default: reader.skipType(tag & 7); break; @@ -917,6 +961,10 @@ for (var i = 0; i < object.retryableStatusCodes.length; ++i) switch (object.retryableStatusCodes[i]) { default: + if (typeof object.retryableStatusCodes[i] === "number") { + message.retryableStatusCodes[i] = object.retryableStatusCodes[i]; + break; + } case "OK": case 0: message.retryableStatusCodes[i] = 0; @@ -1022,7 +1070,7 @@ if (message.retryableStatusCodes && message.retryableStatusCodes.length) { object.retryableStatusCodes = []; for (var j = 0; j < message.retryableStatusCodes.length; ++j) - object.retryableStatusCodes[j] = options.enums === String ? $root.google.rpc.Code[message.retryableStatusCodes[j]] : message.retryableStatusCodes[j]; + object.retryableStatusCodes[j] = options.enums === String ? $root.google.rpc.Code[message.retryableStatusCodes[j]] === undefined ? message.retryableStatusCodes[j] : $root.google.rpc.Code[message.retryableStatusCodes[j]] : message.retryableStatusCodes[j]; } return object; }; @@ -1038,6 +1086,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for RetryPolicy + * @function getTypeUrl + * @memberof grpc.service_config.MethodConfig.RetryPolicy + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RetryPolicy.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/grpc.service_config.MethodConfig.RetryPolicy"; + }; + return RetryPolicy; })(); @@ -1160,22 +1223,25 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.maxAttempts = reader.uint32(); - break; - case 2: - message.hedgingDelay = $root.google.protobuf.Duration.decode(reader, reader.uint32()); - break; - case 3: - if (!(message.nonFatalStatusCodes && message.nonFatalStatusCodes.length)) - message.nonFatalStatusCodes = []; - if ((tag & 7) === 2) { - var end2 = reader.uint32() + reader.pos; - while (reader.pos < end2) + case 1: { + message.maxAttempts = reader.uint32(); + break; + } + case 2: { + message.hedgingDelay = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + case 3: { + if (!(message.nonFatalStatusCodes && message.nonFatalStatusCodes.length)) + message.nonFatalStatusCodes = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.nonFatalStatusCodes.push(reader.int32()); + } else message.nonFatalStatusCodes.push(reader.int32()); - } else - message.nonFatalStatusCodes.push(reader.int32()); - break; + break; + } default: reader.skipType(tag & 7); break; @@ -1275,6 +1341,10 @@ for (var i = 0; i < object.nonFatalStatusCodes.length; ++i) switch (object.nonFatalStatusCodes[i]) { default: + if (typeof object.nonFatalStatusCodes[i] === "number") { + message.nonFatalStatusCodes[i] = object.nonFatalStatusCodes[i]; + break; + } case "OK": case 0: message.nonFatalStatusCodes[i] = 0; @@ -1374,7 +1444,7 @@ if (message.nonFatalStatusCodes && message.nonFatalStatusCodes.length) { object.nonFatalStatusCodes = []; for (var j = 0; j < message.nonFatalStatusCodes.length; ++j) - object.nonFatalStatusCodes[j] = options.enums === String ? $root.google.rpc.Code[message.nonFatalStatusCodes[j]] : message.nonFatalStatusCodes[j]; + object.nonFatalStatusCodes[j] = options.enums === String ? $root.google.rpc.Code[message.nonFatalStatusCodes[j]] === undefined ? message.nonFatalStatusCodes[j] : $root.google.rpc.Code[message.nonFatalStatusCodes[j]] : message.nonFatalStatusCodes[j]; } return object; }; @@ -1390,6 +1460,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for HedgingPolicy + * @function getTypeUrl + * @memberof grpc.service_config.MethodConfig.HedgingPolicy + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + HedgingPolicy.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/grpc.service_config.MethodConfig.HedgingPolicy"; + }; + return HedgingPolicy; })(); @@ -1553,6 +1638,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for PickFirstConfig + * @function getTypeUrl + * @memberof grpc.service_config.PickFirstConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PickFirstConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/grpc.service_config.PickFirstConfig"; + }; + return PickFirstConfig; })(); @@ -1713,6 +1813,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for RoundRobinConfig + * @function getTypeUrl + * @memberof grpc.service_config.RoundRobinConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RoundRobinConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/grpc.service_config.RoundRobinConfig"; + }; + return RoundRobinConfig; })(); @@ -1810,11 +1925,12 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - if (!(message.childPolicy && message.childPolicy.length)) - message.childPolicy = []; - message.childPolicy.push($root.grpc.service_config.LoadBalancingConfig.decode(reader, reader.uint32())); - break; + case 1: { + if (!(message.childPolicy && message.childPolicy.length)) + message.childPolicy = []; + message.childPolicy.push($root.grpc.service_config.LoadBalancingConfig.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -1921,6 +2037,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for GrpcLbConfig + * @function getTypeUrl + * @memberof grpc.service_config.GrpcLbConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GrpcLbConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/grpc.service_config.GrpcLbConfig"; + }; + return GrpcLbConfig; })(); @@ -2042,19 +2173,22 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.balancerName = reader.string(); - break; - case 2: - if (!(message.childPolicy && message.childPolicy.length)) - message.childPolicy = []; - message.childPolicy.push($root.grpc.service_config.LoadBalancingConfig.decode(reader, reader.uint32())); - break; - case 3: - if (!(message.fallbackPolicy && message.fallbackPolicy.length)) - message.fallbackPolicy = []; - message.fallbackPolicy.push($root.grpc.service_config.LoadBalancingConfig.decode(reader, reader.uint32())); - break; + case 1: { + message.balancerName = reader.string(); + break; + } + case 2: { + if (!(message.childPolicy && message.childPolicy.length)) + message.childPolicy = []; + message.childPolicy.push($root.grpc.service_config.LoadBalancingConfig.decode(reader, reader.uint32())); + break; + } + case 3: { + if (!(message.fallbackPolicy && message.fallbackPolicy.length)) + message.fallbackPolicy = []; + message.fallbackPolicy.push($root.grpc.service_config.LoadBalancingConfig.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -2196,6 +2330,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for XdsConfig + * @function getTypeUrl + * @memberof grpc.service_config.XdsConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + XdsConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/grpc.service_config.XdsConfig"; + }; + return XdsConfig; })(); @@ -2349,21 +2498,26 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 4: - message.pickFirst = $root.grpc.service_config.PickFirstConfig.decode(reader, reader.uint32()); - break; - case 1: - message.roundRobin = $root.grpc.service_config.RoundRobinConfig.decode(reader, reader.uint32()); - break; - case 3: - message.grpclb = $root.grpc.service_config.GrpcLbConfig.decode(reader, reader.uint32()); - break; - case 2: - message.xds = $root.grpc.service_config.XdsConfig.decode(reader, reader.uint32()); - break; - case 5: - message.xdsExperimental = $root.grpc.service_config.XdsConfig.decode(reader, reader.uint32()); - break; + case 4: { + message.pickFirst = $root.grpc.service_config.PickFirstConfig.decode(reader, reader.uint32()); + break; + } + case 1: { + message.roundRobin = $root.grpc.service_config.RoundRobinConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.grpclb = $root.grpc.service_config.GrpcLbConfig.decode(reader, reader.uint32()); + break; + } + case 2: { + message.xds = $root.grpc.service_config.XdsConfig.decode(reader, reader.uint32()); + break; + } + case 5: { + message.xdsExperimental = $root.grpc.service_config.XdsConfig.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -2543,6 +2697,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for LoadBalancingConfig + * @function getTypeUrl + * @memberof grpc.service_config.LoadBalancingConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + LoadBalancingConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/grpc.service_config.LoadBalancingConfig"; + }; + return LoadBalancingConfig; })(); @@ -2686,25 +2855,30 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.loadBalancingPolicy = reader.int32(); - break; - case 4: - if (!(message.loadBalancingConfig && message.loadBalancingConfig.length)) - message.loadBalancingConfig = []; - message.loadBalancingConfig.push($root.grpc.service_config.LoadBalancingConfig.decode(reader, reader.uint32())); - break; - case 2: - if (!(message.methodConfig && message.methodConfig.length)) - message.methodConfig = []; - message.methodConfig.push($root.grpc.service_config.MethodConfig.decode(reader, reader.uint32())); - break; - case 3: - message.retryThrottling = $root.grpc.service_config.ServiceConfig.RetryThrottlingPolicy.decode(reader, reader.uint32()); - break; - case 5: - message.healthCheckConfig = $root.grpc.service_config.ServiceConfig.HealthCheckConfig.decode(reader, reader.uint32()); - break; + case 1: { + message.loadBalancingPolicy = reader.int32(); + break; + } + case 4: { + if (!(message.loadBalancingConfig && message.loadBalancingConfig.length)) + message.loadBalancingConfig = []; + message.loadBalancingConfig.push($root.grpc.service_config.LoadBalancingConfig.decode(reader, reader.uint32())); + break; + } + case 2: { + if (!(message.methodConfig && message.methodConfig.length)) + message.methodConfig = []; + message.methodConfig.push($root.grpc.service_config.MethodConfig.decode(reader, reader.uint32())); + break; + } + case 3: { + message.retryThrottling = $root.grpc.service_config.ServiceConfig.RetryThrottlingPolicy.decode(reader, reader.uint32()); + break; + } + case 5: { + message.healthCheckConfig = $root.grpc.service_config.ServiceConfig.HealthCheckConfig.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -2792,6 +2966,12 @@ return object; var message = new $root.grpc.service_config.ServiceConfig(); switch (object.loadBalancingPolicy) { + default: + if (typeof object.loadBalancingPolicy === "number") { + message.loadBalancingPolicy = object.loadBalancingPolicy; + break; + } + break; case "UNSPECIFIED": case 0: message.loadBalancingPolicy = 0; @@ -2857,7 +3037,7 @@ object.healthCheckConfig = null; } if (message.loadBalancingPolicy != null && message.hasOwnProperty("loadBalancingPolicy")) - object.loadBalancingPolicy = options.enums === String ? $root.grpc.service_config.ServiceConfig.LoadBalancingPolicy[message.loadBalancingPolicy] : message.loadBalancingPolicy; + object.loadBalancingPolicy = options.enums === String ? $root.grpc.service_config.ServiceConfig.LoadBalancingPolicy[message.loadBalancingPolicy] === undefined ? message.loadBalancingPolicy : $root.grpc.service_config.ServiceConfig.LoadBalancingPolicy[message.loadBalancingPolicy] : message.loadBalancingPolicy; if (message.methodConfig && message.methodConfig.length) { object.methodConfig = []; for (var j = 0; j < message.methodConfig.length; ++j) @@ -2886,6 +3066,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for ServiceConfig + * @function getTypeUrl + * @memberof grpc.service_config.ServiceConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ServiceConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/grpc.service_config.ServiceConfig"; + }; + /** * LoadBalancingPolicy enum. * @name grpc.service_config.ServiceConfig.LoadBalancingPolicy @@ -3003,12 +3198,14 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.maxTokens = reader.uint32(); - break; - case 2: - message.tokenRatio = reader.float(); - break; + case 1: { + message.maxTokens = reader.uint32(); + break; + } + case 2: { + message.tokenRatio = reader.float(); + break; + } default: reader.skipType(tag & 7); break; @@ -3107,6 +3304,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for RetryThrottlingPolicy + * @function getTypeUrl + * @memberof grpc.service_config.ServiceConfig.RetryThrottlingPolicy + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RetryThrottlingPolicy.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/grpc.service_config.ServiceConfig.RetryThrottlingPolicy"; + }; + return RetryThrottlingPolicy; })(); @@ -3202,9 +3414,10 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.serviceName = $root.google.protobuf.StringValue.decode(reader, reader.uint32()); - break; + case 1: { + message.serviceName = $root.google.protobuf.StringValue.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -3299,6 +3512,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for HealthCheckConfig + * @function getTypeUrl + * @memberof grpc.service_config.ServiceConfig.HealthCheckConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + HealthCheckConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/grpc.service_config.ServiceConfig.HealthCheckConfig"; + }; + return HealthCheckConfig; })(); @@ -3434,14 +3662,16 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - if (!(message.rules && message.rules.length)) - message.rules = []; - message.rules.push($root.google.api.HttpRule.decode(reader, reader.uint32())); - break; - case 2: - message.fullyDecodeReservedExpansion = reader.bool(); - break; + case 1: { + if (!(message.rules && message.rules.length)) + message.rules = []; + message.rules.push($root.google.api.HttpRule.decode(reader, reader.uint32())); + break; + } + case 2: { + message.fullyDecodeReservedExpansion = reader.bool(); + break; + } default: reader.skipType(tag & 7); break; @@ -3557,6 +3787,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Http + * @function getTypeUrl + * @memberof google.api.Http + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Http.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.Http"; + }; + return Http; })(); @@ -3767,38 +4012,48 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.selector = reader.string(); - break; - case 2: - message.get = reader.string(); - break; - case 3: - message.put = reader.string(); - break; - case 4: - message.post = reader.string(); - break; - case 5: - message["delete"] = reader.string(); - break; - case 6: - message.patch = reader.string(); - break; - case 8: - message.custom = $root.google.api.CustomHttpPattern.decode(reader, reader.uint32()); - break; - case 7: - message.body = reader.string(); - break; - case 12: - message.responseBody = reader.string(); - break; - case 11: - if (!(message.additionalBindings && message.additionalBindings.length)) - message.additionalBindings = []; - message.additionalBindings.push($root.google.api.HttpRule.decode(reader, reader.uint32())); - break; + case 1: { + message.selector = reader.string(); + break; + } + case 2: { + message.get = reader.string(); + break; + } + case 3: { + message.put = reader.string(); + break; + } + case 4: { + message.post = reader.string(); + break; + } + case 5: { + message["delete"] = reader.string(); + break; + } + case 6: { + message.patch = reader.string(); + break; + } + case 8: { + message.custom = $root.google.api.CustomHttpPattern.decode(reader, reader.uint32()); + break; + } + case 7: { + message.body = reader.string(); + break; + } + case 12: { + message.responseBody = reader.string(); + break; + } + case 11: { + if (!(message.additionalBindings && message.additionalBindings.length)) + message.additionalBindings = []; + message.additionalBindings.push($root.google.api.HttpRule.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -4020,6 +4275,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for HttpRule + * @function getTypeUrl + * @memberof google.api.HttpRule + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + HttpRule.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.HttpRule"; + }; + return HttpRule; })(); @@ -4126,12 +4396,14 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.kind = reader.string(); - break; - case 2: - message.path = reader.string(); - break; + case 1: { + message.kind = reader.string(); + break; + } + case 2: { + message.path = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -4230,6 +4502,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for CustomHttpPattern + * @function getTypeUrl + * @memberof google.api.CustomHttpPattern + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CustomHttpPattern.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.CustomHttpPattern"; + }; + return CustomHttpPattern; })(); @@ -4424,36 +4711,43 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.type = reader.string(); - break; - case 2: - if (!(message.pattern && message.pattern.length)) - message.pattern = []; - message.pattern.push(reader.string()); - break; - case 3: - message.nameField = reader.string(); - break; - case 4: - message.history = reader.int32(); - break; - case 5: - message.plural = reader.string(); - break; - case 6: - message.singular = reader.string(); - break; - case 10: - if (!(message.style && message.style.length)) - message.style = []; - if ((tag & 7) === 2) { - var end2 = reader.uint32() + reader.pos; - while (reader.pos < end2) + case 1: { + message.type = reader.string(); + break; + } + case 2: { + if (!(message.pattern && message.pattern.length)) + message.pattern = []; + message.pattern.push(reader.string()); + break; + } + case 3: { + message.nameField = reader.string(); + break; + } + case 4: { + message.history = reader.int32(); + break; + } + case 5: { + message.plural = reader.string(); + break; + } + case 6: { + message.singular = reader.string(); + break; + } + case 10: { + if (!(message.style && message.style.length)) + message.style = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.style.push(reader.int32()); + } else message.style.push(reader.int32()); - } else - message.style.push(reader.int32()); - break; + break; + } default: reader.skipType(tag & 7); break; @@ -4556,6 +4850,12 @@ if (object.nameField != null) message.nameField = String(object.nameField); switch (object.history) { + default: + if (typeof object.history === "number") { + message.history = object.history; + break; + } + break; case "HISTORY_UNSPECIFIED": case 0: message.history = 0; @@ -4580,6 +4880,10 @@ for (var i = 0; i < object.style.length; ++i) switch (object.style[i]) { default: + if (typeof object.style[i] === "number") { + message.style[i] = object.style[i]; + break; + } case "STYLE_UNSPECIFIED": case 0: message.style[i] = 0; @@ -4627,7 +4931,7 @@ if (message.nameField != null && message.hasOwnProperty("nameField")) object.nameField = message.nameField; if (message.history != null && message.hasOwnProperty("history")) - object.history = options.enums === String ? $root.google.api.ResourceDescriptor.History[message.history] : message.history; + object.history = options.enums === String ? $root.google.api.ResourceDescriptor.History[message.history] === undefined ? message.history : $root.google.api.ResourceDescriptor.History[message.history] : message.history; if (message.plural != null && message.hasOwnProperty("plural")) object.plural = message.plural; if (message.singular != null && message.hasOwnProperty("singular")) @@ -4635,7 +4939,7 @@ if (message.style && message.style.length) { object.style = []; for (var j = 0; j < message.style.length; ++j) - object.style[j] = options.enums === String ? $root.google.api.ResourceDescriptor.Style[message.style[j]] : message.style[j]; + object.style[j] = options.enums === String ? $root.google.api.ResourceDescriptor.Style[message.style[j]] === undefined ? message.style[j] : $root.google.api.ResourceDescriptor.Style[message.style[j]] : message.style[j]; } return object; }; @@ -4651,6 +4955,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for ResourceDescriptor + * @function getTypeUrl + * @memberof google.api.ResourceDescriptor + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ResourceDescriptor.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.ResourceDescriptor"; + }; + /** * History enum. * @name google.api.ResourceDescriptor.History @@ -4787,12 +5106,14 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.type = reader.string(); - break; - case 2: - message.childType = reader.string(); - break; + case 1: { + message.type = reader.string(); + break; + } + case 2: { + message.childType = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -4891,6 +5212,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for ResourceReference + * @function getTypeUrl + * @memberof google.api.ResourceReference + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ResourceReference.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.ResourceReference"; + }; + return ResourceReference; })(); @@ -4988,11 +5324,12 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 2: - if (!(message.routingParameters && message.routingParameters.length)) - message.routingParameters = []; - message.routingParameters.push($root.google.api.RoutingParameter.decode(reader, reader.uint32())); - break; + case 2: { + if (!(message.routingParameters && message.routingParameters.length)) + message.routingParameters = []; + message.routingParameters.push($root.google.api.RoutingParameter.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -5099,6 +5436,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for RoutingRule + * @function getTypeUrl + * @memberof google.api.RoutingRule + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RoutingRule.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.RoutingRule"; + }; + return RoutingRule; })(); @@ -5205,12 +5557,14 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.field = reader.string(); - break; - case 2: - message.pathTemplate = reader.string(); - break; + case 1: { + message.field = reader.string(); + break; + } + case 2: { + message.pathTemplate = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -5309,6 +5663,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for RoutingParameter + * @function getTypeUrl + * @memberof google.api.RoutingParameter + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RoutingParameter.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.RoutingParameter"; + }; + return RoutingParameter; })(); @@ -5418,11 +5787,12 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - if (!(message.file && message.file.length)) - message.file = []; - message.file.push($root.google.protobuf.FileDescriptorProto.decode(reader, reader.uint32())); - break; + case 1: { + if (!(message.file && message.file.length)) + message.file = []; + message.file.push($root.google.protobuf.FileDescriptorProto.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -5529,6 +5899,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for FileDescriptorSet + * @function getTypeUrl + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FileDescriptorSet.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FileDescriptorSet"; + }; + return FileDescriptorSet; })(); @@ -5550,6 +5935,7 @@ * @property {google.protobuf.IFileOptions|null} [options] FileDescriptorProto options * @property {google.protobuf.ISourceCodeInfo|null} [sourceCodeInfo] FileDescriptorProto sourceCodeInfo * @property {string|null} [syntax] FileDescriptorProto syntax + * @property {string|null} [edition] FileDescriptorProto edition */ /** @@ -5670,6 +6056,14 @@ */ FileDescriptorProto.prototype.syntax = ""; + /** + * FileDescriptorProto edition. + * @member {string} edition + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.edition = ""; + /** * Creates a new FileDescriptorProto instance using the specified properties. * @function create @@ -5725,6 +6119,8 @@ writer.uint32(/* id 11, wireType 0 =*/88).int32(message.weakDependency[i]); if (message.syntax != null && Object.hasOwnProperty.call(message, "syntax")) writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax); + if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) + writer.uint32(/* id 13, wireType 2 =*/106).string(message.edition); return writer; }; @@ -5759,66 +6155,82 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.name = reader.string(); - break; - case 2: - message["package"] = reader.string(); - break; - case 3: - if (!(message.dependency && message.dependency.length)) - message.dependency = []; - message.dependency.push(reader.string()); - break; - case 10: - if (!(message.publicDependency && message.publicDependency.length)) - message.publicDependency = []; - if ((tag & 7) === 2) { - var end2 = reader.uint32() + reader.pos; - while (reader.pos < end2) + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message["package"] = reader.string(); + break; + } + case 3: { + if (!(message.dependency && message.dependency.length)) + message.dependency = []; + message.dependency.push(reader.string()); + break; + } + case 10: { + if (!(message.publicDependency && message.publicDependency.length)) + message.publicDependency = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.publicDependency.push(reader.int32()); + } else message.publicDependency.push(reader.int32()); - } else - message.publicDependency.push(reader.int32()); - break; - case 11: - if (!(message.weakDependency && message.weakDependency.length)) - message.weakDependency = []; - if ((tag & 7) === 2) { - var end2 = reader.uint32() + reader.pos; - while (reader.pos < end2) + break; + } + case 11: { + if (!(message.weakDependency && message.weakDependency.length)) + message.weakDependency = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.weakDependency.push(reader.int32()); + } else message.weakDependency.push(reader.int32()); - } else - message.weakDependency.push(reader.int32()); - break; - case 4: - if (!(message.messageType && message.messageType.length)) - message.messageType = []; - message.messageType.push($root.google.protobuf.DescriptorProto.decode(reader, reader.uint32())); - break; - case 5: - if (!(message.enumType && message.enumType.length)) - message.enumType = []; - message.enumType.push($root.google.protobuf.EnumDescriptorProto.decode(reader, reader.uint32())); - break; - case 6: - if (!(message.service && message.service.length)) - message.service = []; - message.service.push($root.google.protobuf.ServiceDescriptorProto.decode(reader, reader.uint32())); - break; - case 7: - if (!(message.extension && message.extension.length)) - message.extension = []; - message.extension.push($root.google.protobuf.FieldDescriptorProto.decode(reader, reader.uint32())); - break; - case 8: - message.options = $root.google.protobuf.FileOptions.decode(reader, reader.uint32()); - break; - case 9: - message.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.decode(reader, reader.uint32()); - break; - case 12: - message.syntax = reader.string(); - break; + break; + } + case 4: { + if (!(message.messageType && message.messageType.length)) + message.messageType = []; + message.messageType.push($root.google.protobuf.DescriptorProto.decode(reader, reader.uint32())); + break; + } + case 5: { + if (!(message.enumType && message.enumType.length)) + message.enumType = []; + message.enumType.push($root.google.protobuf.EnumDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 6: { + if (!(message.service && message.service.length)) + message.service = []; + message.service.push($root.google.protobuf.ServiceDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 7: { + if (!(message.extension && message.extension.length)) + message.extension = []; + message.extension.push($root.google.protobuf.FieldDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 8: { + message.options = $root.google.protobuf.FileOptions.decode(reader, reader.uint32()); + break; + } + case 9: { + message.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.decode(reader, reader.uint32()); + break; + } + case 12: { + message.syntax = reader.string(); + break; + } + case 13: { + message.edition = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -5930,6 +6342,9 @@ if (message.syntax != null && message.hasOwnProperty("syntax")) if (!$util.isString(message.syntax)) return "syntax: string expected"; + if (message.edition != null && message.hasOwnProperty("edition")) + if (!$util.isString(message.edition)) + return "edition: string expected"; return null; }; @@ -6022,6 +6437,8 @@ } if (object.syntax != null) message.syntax = String(object.syntax); + if (object.edition != null) + message.edition = String(object.edition); return message; }; @@ -6053,6 +6470,7 @@ object.options = null; object.sourceCodeInfo = null; object.syntax = ""; + object.edition = ""; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -6099,6 +6517,8 @@ } if (message.syntax != null && message.hasOwnProperty("syntax")) object.syntax = message.syntax; + if (message.edition != null && message.hasOwnProperty("edition")) + object.edition = message.edition; return object; }; @@ -6113,6 +6533,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for FileDescriptorProto + * @function getTypeUrl + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FileDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FileDescriptorProto"; + }; + return FileDescriptorProto; })(); @@ -6323,52 +6758,62 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.name = reader.string(); - break; - case 2: - if (!(message.field && message.field.length)) - message.field = []; - message.field.push($root.google.protobuf.FieldDescriptorProto.decode(reader, reader.uint32())); - break; - case 6: - if (!(message.extension && message.extension.length)) - message.extension = []; - message.extension.push($root.google.protobuf.FieldDescriptorProto.decode(reader, reader.uint32())); - break; - case 3: - if (!(message.nestedType && message.nestedType.length)) - message.nestedType = []; - message.nestedType.push($root.google.protobuf.DescriptorProto.decode(reader, reader.uint32())); - break; - case 4: - if (!(message.enumType && message.enumType.length)) - message.enumType = []; - message.enumType.push($root.google.protobuf.EnumDescriptorProto.decode(reader, reader.uint32())); - break; - case 5: - if (!(message.extensionRange && message.extensionRange.length)) - message.extensionRange = []; - message.extensionRange.push($root.google.protobuf.DescriptorProto.ExtensionRange.decode(reader, reader.uint32())); - break; - case 8: - if (!(message.oneofDecl && message.oneofDecl.length)) - message.oneofDecl = []; - message.oneofDecl.push($root.google.protobuf.OneofDescriptorProto.decode(reader, reader.uint32())); - break; - case 7: - message.options = $root.google.protobuf.MessageOptions.decode(reader, reader.uint32()); - break; - case 9: - if (!(message.reservedRange && message.reservedRange.length)) - message.reservedRange = []; - message.reservedRange.push($root.google.protobuf.DescriptorProto.ReservedRange.decode(reader, reader.uint32())); - break; - case 10: - if (!(message.reservedName && message.reservedName.length)) - message.reservedName = []; - message.reservedName.push(reader.string()); - break; + case 1: { + message.name = reader.string(); + break; + } + case 2: { + if (!(message.field && message.field.length)) + message.field = []; + message.field.push($root.google.protobuf.FieldDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 6: { + if (!(message.extension && message.extension.length)) + message.extension = []; + message.extension.push($root.google.protobuf.FieldDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 3: { + if (!(message.nestedType && message.nestedType.length)) + message.nestedType = []; + message.nestedType.push($root.google.protobuf.DescriptorProto.decode(reader, reader.uint32())); + break; + } + case 4: { + if (!(message.enumType && message.enumType.length)) + message.enumType = []; + message.enumType.push($root.google.protobuf.EnumDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 5: { + if (!(message.extensionRange && message.extensionRange.length)) + message.extensionRange = []; + message.extensionRange.push($root.google.protobuf.DescriptorProto.ExtensionRange.decode(reader, reader.uint32())); + break; + } + case 8: { + if (!(message.oneofDecl && message.oneofDecl.length)) + message.oneofDecl = []; + message.oneofDecl.push($root.google.protobuf.OneofDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 7: { + message.options = $root.google.protobuf.MessageOptions.decode(reader, reader.uint32()); + break; + } + case 9: { + if (!(message.reservedRange && message.reservedRange.length)) + message.reservedRange = []; + message.reservedRange.push($root.google.protobuf.DescriptorProto.ReservedRange.decode(reader, reader.uint32())); + break; + } + case 10: { + if (!(message.reservedName && message.reservedName.length)) + message.reservedName = []; + message.reservedName.push(reader.string()); + break; + } default: reader.skipType(tag & 7); break; @@ -6669,6 +7114,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for DescriptorProto + * @function getTypeUrl + * @memberof google.protobuf.DescriptorProto + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.DescriptorProto"; + }; + DescriptorProto.ExtensionRange = (function() { /** @@ -6783,15 +7243,18 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.start = reader.int32(); - break; - case 2: - message.end = reader.int32(); - break; - case 3: - message.options = $root.google.protobuf.ExtensionRangeOptions.decode(reader, reader.uint32()); - break; + case 1: { + message.start = reader.int32(); + break; + } + case 2: { + message.end = reader.int32(); + break; + } + case 3: { + message.options = $root.google.protobuf.ExtensionRangeOptions.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -6903,6 +7366,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for ExtensionRange + * @function getTypeUrl + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExtensionRange.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.DescriptorProto.ExtensionRange"; + }; + return ExtensionRange; })(); @@ -7009,12 +7487,14 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.start = reader.int32(); - break; - case 2: - message.end = reader.int32(); - break; + case 1: { + message.start = reader.int32(); + break; + } + case 2: { + message.end = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -7113,6 +7593,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for ReservedRange + * @function getTypeUrl + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReservedRange.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.DescriptorProto.ReservedRange"; + }; + return ReservedRange; })(); @@ -7213,11 +7708,12 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 999: - if (!(message.uninterpretedOption && message.uninterpretedOption.length)) - message.uninterpretedOption = []; - message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); - break; + case 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -7324,6 +7820,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for ExtensionRangeOptions + * @function getTypeUrl + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExtensionRangeOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.ExtensionRangeOptions"; + }; + return ExtensionRangeOptions; })(); @@ -7529,39 +8040,50 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.name = reader.string(); - break; - case 3: - message.number = reader.int32(); - break; - case 4: - message.label = reader.int32(); - break; - case 5: - message.type = reader.int32(); - break; - case 6: - message.typeName = reader.string(); - break; - case 2: - message.extendee = reader.string(); - break; - case 7: - message.defaultValue = reader.string(); - break; - case 9: - message.oneofIndex = reader.int32(); - break; - case 10: - message.jsonName = reader.string(); - break; - case 8: - message.options = $root.google.protobuf.FieldOptions.decode(reader, reader.uint32()); - break; - case 17: - message.proto3Optional = reader.bool(); - break; + case 1: { + message.name = reader.string(); + break; + } + case 3: { + message.number = reader.int32(); + break; + } + case 4: { + message.label = reader.int32(); + break; + } + case 5: { + message.type = reader.int32(); + break; + } + case 6: { + message.typeName = reader.string(); + break; + } + case 2: { + message.extendee = reader.string(); + break; + } + case 7: { + message.defaultValue = reader.string(); + break; + } + case 9: { + message.oneofIndex = reader.int32(); + break; + } + case 10: { + message.jsonName = reader.string(); + break; + } + case 8: { + message.options = $root.google.protobuf.FieldOptions.decode(reader, reader.uint32()); + break; + } + case 17: { + message.proto3Optional = reader.bool(); + break; + } default: reader.skipType(tag & 7); break; @@ -7679,6 +8201,12 @@ if (object.number != null) message.number = object.number | 0; switch (object.label) { + default: + if (typeof object.label === "number") { + message.label = object.label; + break; + } + break; case "LABEL_OPTIONAL": case 1: message.label = 1; @@ -7693,6 +8221,12 @@ break; } switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; case "TYPE_DOUBLE": case 1: message.type = 1; @@ -7819,9 +8353,9 @@ if (message.number != null && message.hasOwnProperty("number")) object.number = message.number; if (message.label != null && message.hasOwnProperty("label")) - object.label = options.enums === String ? $root.google.protobuf.FieldDescriptorProto.Label[message.label] : message.label; + object.label = options.enums === String ? $root.google.protobuf.FieldDescriptorProto.Label[message.label] === undefined ? message.label : $root.google.protobuf.FieldDescriptorProto.Label[message.label] : message.label; if (message.type != null && message.hasOwnProperty("type")) - object.type = options.enums === String ? $root.google.protobuf.FieldDescriptorProto.Type[message.type] : message.type; + object.type = options.enums === String ? $root.google.protobuf.FieldDescriptorProto.Type[message.type] === undefined ? message.type : $root.google.protobuf.FieldDescriptorProto.Type[message.type] : message.type; if (message.typeName != null && message.hasOwnProperty("typeName")) object.typeName = message.typeName; if (message.defaultValue != null && message.hasOwnProperty("defaultValue")) @@ -7848,6 +8382,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for FieldDescriptorProto + * @function getTypeUrl + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FieldDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldDescriptorProto"; + }; + /** * Type enum. * @name google.protobuf.FieldDescriptorProto.Type @@ -8016,12 +8565,14 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.name = reader.string(); - break; - case 2: - message.options = $root.google.protobuf.OneofOptions.decode(reader, reader.uint32()); - break; + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.options = $root.google.protobuf.OneofOptions.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -8125,6 +8676,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for OneofDescriptorProto + * @function getTypeUrl + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + OneofDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.OneofDescriptorProto"; + }; + return OneofDescriptorProto; })(); @@ -8270,27 +8836,32 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.name = reader.string(); - break; - case 2: - if (!(message.value && message.value.length)) - message.value = []; - message.value.push($root.google.protobuf.EnumValueDescriptorProto.decode(reader, reader.uint32())); - break; - case 3: - message.options = $root.google.protobuf.EnumOptions.decode(reader, reader.uint32()); - break; - case 4: - if (!(message.reservedRange && message.reservedRange.length)) - message.reservedRange = []; - message.reservedRange.push($root.google.protobuf.EnumDescriptorProto.EnumReservedRange.decode(reader, reader.uint32())); - break; - case 5: - if (!(message.reservedName && message.reservedName.length)) - message.reservedName = []; - message.reservedName.push(reader.string()); - break; + case 1: { + message.name = reader.string(); + break; + } + case 2: { + if (!(message.value && message.value.length)) + message.value = []; + message.value.push($root.google.protobuf.EnumValueDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 3: { + message.options = $root.google.protobuf.EnumOptions.decode(reader, reader.uint32()); + break; + } + case 4: { + if (!(message.reservedRange && message.reservedRange.length)) + message.reservedRange = []; + message.reservedRange.push($root.google.protobuf.EnumDescriptorProto.EnumReservedRange.decode(reader, reader.uint32())); + break; + } + case 5: { + if (!(message.reservedName && message.reservedName.length)) + message.reservedName = []; + message.reservedName.push(reader.string()); + break; + } default: reader.skipType(tag & 7); break; @@ -8466,6 +9037,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for EnumDescriptorProto + * @function getTypeUrl + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EnumDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.EnumDescriptorProto"; + }; + EnumDescriptorProto.EnumReservedRange = (function() { /** @@ -8569,12 +9155,14 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.start = reader.int32(); - break; - case 2: - message.end = reader.int32(); - break; + case 1: { + message.start = reader.int32(); + break; + } + case 2: { + message.end = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -8673,6 +9261,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for EnumReservedRange + * @function getTypeUrl + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EnumReservedRange.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.EnumDescriptorProto.EnumReservedRange"; + }; + return EnumReservedRange; })(); @@ -8793,15 +9396,18 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.name = reader.string(); - break; - case 2: - message.number = reader.int32(); - break; - case 3: - message.options = $root.google.protobuf.EnumValueOptions.decode(reader, reader.uint32()); - break; + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.number = reader.int32(); + break; + } + case 3: { + message.options = $root.google.protobuf.EnumValueOptions.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -8913,6 +9519,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for EnumValueDescriptorProto + * @function getTypeUrl + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EnumValueDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.EnumValueDescriptorProto"; + }; + return EnumValueDescriptorProto; })(); @@ -9032,17 +9653,20 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.name = reader.string(); - break; - case 2: - if (!(message.method && message.method.length)) - message.method = []; - message.method.push($root.google.protobuf.MethodDescriptorProto.decode(reader, reader.uint32())); - break; - case 3: - message.options = $root.google.protobuf.ServiceOptions.decode(reader, reader.uint32()); - break; + case 1: { + message.name = reader.string(); + break; + } + case 2: { + if (!(message.method && message.method.length)) + message.method = []; + message.method.push($root.google.protobuf.MethodDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 3: { + message.options = $root.google.protobuf.ServiceOptions.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -9172,6 +9796,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for ServiceDescriptorProto + * @function getTypeUrl + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ServiceDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.ServiceDescriptorProto"; + }; + return ServiceDescriptorProto; })(); @@ -9322,24 +9961,30 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.name = reader.string(); - break; - case 2: - message.inputType = reader.string(); - break; - case 3: - message.outputType = reader.string(); - break; - case 4: - message.options = $root.google.protobuf.MethodOptions.decode(reader, reader.uint32()); - break; - case 5: - message.clientStreaming = reader.bool(); - break; - case 6: - message.serverStreaming = reader.bool(); - break; + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.inputType = reader.string(); + break; + } + case 3: { + message.outputType = reader.string(); + break; + } + case 4: { + message.options = $root.google.protobuf.MethodOptions.decode(reader, reader.uint32()); + break; + } + case 5: { + message.clientStreaming = reader.bool(); + break; + } + case 6: { + message.serverStreaming = reader.bool(); + break; + } default: reader.skipType(tag & 7); break; @@ -9475,6 +10120,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for MethodDescriptorProto + * @function getTypeUrl + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + MethodDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.MethodDescriptorProto"; + }; + return MethodDescriptorProto; })(); @@ -9805,76 +10465,98 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.javaPackage = reader.string(); - break; - case 8: - message.javaOuterClassname = reader.string(); - break; - case 10: - message.javaMultipleFiles = reader.bool(); - break; - case 20: - message.javaGenerateEqualsAndHash = reader.bool(); - break; - case 27: - message.javaStringCheckUtf8 = reader.bool(); - break; - case 9: - message.optimizeFor = reader.int32(); - break; - case 11: - message.goPackage = reader.string(); - break; - case 16: - message.ccGenericServices = reader.bool(); - break; - case 17: - message.javaGenericServices = reader.bool(); - break; - case 18: - message.pyGenericServices = reader.bool(); - break; - case 42: - message.phpGenericServices = reader.bool(); - break; - case 23: - message.deprecated = reader.bool(); - break; - case 31: - message.ccEnableArenas = reader.bool(); - break; - case 36: - message.objcClassPrefix = reader.string(); - break; - case 37: - message.csharpNamespace = reader.string(); - break; - case 39: - message.swiftPrefix = reader.string(); - break; - case 40: - message.phpClassPrefix = reader.string(); - break; - case 41: - message.phpNamespace = reader.string(); - break; - case 44: - message.phpMetadataNamespace = reader.string(); - break; - case 45: - message.rubyPackage = reader.string(); - break; - case 999: - if (!(message.uninterpretedOption && message.uninterpretedOption.length)) - message.uninterpretedOption = []; - message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); - break; - case 1053: - if (!(message[".google.api.resourceDefinition"] && message[".google.api.resourceDefinition"].length)) - message[".google.api.resourceDefinition"] = []; - message[".google.api.resourceDefinition"].push($root.google.api.ResourceDescriptor.decode(reader, reader.uint32())); - break; + case 1: { + message.javaPackage = reader.string(); + break; + } + case 8: { + message.javaOuterClassname = reader.string(); + break; + } + case 10: { + message.javaMultipleFiles = reader.bool(); + break; + } + case 20: { + message.javaGenerateEqualsAndHash = reader.bool(); + break; + } + case 27: { + message.javaStringCheckUtf8 = reader.bool(); + break; + } + case 9: { + message.optimizeFor = reader.int32(); + break; + } + case 11: { + message.goPackage = reader.string(); + break; + } + case 16: { + message.ccGenericServices = reader.bool(); + break; + } + case 17: { + message.javaGenericServices = reader.bool(); + break; + } + case 18: { + message.pyGenericServices = reader.bool(); + break; + } + case 42: { + message.phpGenericServices = reader.bool(); + break; + } + case 23: { + message.deprecated = reader.bool(); + break; + } + case 31: { + message.ccEnableArenas = reader.bool(); + break; + } + case 36: { + message.objcClassPrefix = reader.string(); + break; + } + case 37: { + message.csharpNamespace = reader.string(); + break; + } + case 39: { + message.swiftPrefix = reader.string(); + break; + } + case 40: { + message.phpClassPrefix = reader.string(); + break; + } + case 41: { + message.phpNamespace = reader.string(); + break; + } + case 44: { + message.phpMetadataNamespace = reader.string(); + break; + } + case 45: { + message.rubyPackage = reader.string(); + break; + } + case 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } + case 1053: { + if (!(message[".google.api.resourceDefinition"] && message[".google.api.resourceDefinition"].length)) + message[".google.api.resourceDefinition"] = []; + message[".google.api.resourceDefinition"].push($root.google.api.ResourceDescriptor.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -10020,6 +10702,12 @@ if (object.javaStringCheckUtf8 != null) message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); switch (object.optimizeFor) { + default: + if (typeof object.optimizeFor === "number") { + message.optimizeFor = object.optimizeFor; + break; + } + break; case "SPEED": case 1: message.optimizeFor = 1; @@ -10128,7 +10816,7 @@ if (message.javaOuterClassname != null && message.hasOwnProperty("javaOuterClassname")) object.javaOuterClassname = message.javaOuterClassname; if (message.optimizeFor != null && message.hasOwnProperty("optimizeFor")) - object.optimizeFor = options.enums === String ? $root.google.protobuf.FileOptions.OptimizeMode[message.optimizeFor] : message.optimizeFor; + object.optimizeFor = options.enums === String ? $root.google.protobuf.FileOptions.OptimizeMode[message.optimizeFor] === undefined ? message.optimizeFor : $root.google.protobuf.FileOptions.OptimizeMode[message.optimizeFor] : message.optimizeFor; if (message.javaMultipleFiles != null && message.hasOwnProperty("javaMultipleFiles")) object.javaMultipleFiles = message.javaMultipleFiles; if (message.goPackage != null && message.hasOwnProperty("goPackage")) @@ -10187,6 +10875,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for FileOptions + * @function getTypeUrl + * @memberof google.protobuf.FileOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FileOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FileOptions"; + }; + /** * OptimizeMode enum. * @name google.protobuf.FileOptions.OptimizeMode @@ -10355,26 +11058,32 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.messageSetWireFormat = reader.bool(); - break; - case 2: - message.noStandardDescriptorAccessor = reader.bool(); - break; - case 3: - message.deprecated = reader.bool(); - break; - case 7: - message.mapEntry = reader.bool(); - break; - case 999: - if (!(message.uninterpretedOption && message.uninterpretedOption.length)) - message.uninterpretedOption = []; - message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); - break; - case 1053: - message[".google.api.resource"] = $root.google.api.ResourceDescriptor.decode(reader, reader.uint32()); - break; + case 1: { + message.messageSetWireFormat = reader.bool(); + break; + } + case 2: { + message.noStandardDescriptorAccessor = reader.bool(); + break; + } + case 3: { + message.deprecated = reader.bool(); + break; + } + case 7: { + message.mapEntry = reader.bool(); + break; + } + case 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } + case 1053: { + message[".google.api.resource"] = $root.google.api.ResourceDescriptor.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -10528,6 +11237,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for MessageOptions + * @function getTypeUrl + * @memberof google.protobuf.MessageOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + MessageOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.MessageOptions"; + }; + return MessageOptions; })(); @@ -10541,6 +11265,7 @@ * @property {boolean|null} [packed] FieldOptions packed * @property {google.protobuf.FieldOptions.JSType|null} [jstype] FieldOptions jstype * @property {boolean|null} [lazy] FieldOptions lazy + * @property {boolean|null} [unverifiedLazy] FieldOptions unverifiedLazy * @property {boolean|null} [deprecated] FieldOptions deprecated * @property {boolean|null} [weak] FieldOptions weak * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption @@ -10597,6 +11322,14 @@ */ FieldOptions.prototype.lazy = false; + /** + * FieldOptions unverifiedLazy. + * @member {boolean} unverifiedLazy + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.unverifiedLazy = false; + /** * FieldOptions deprecated. * @member {boolean} deprecated @@ -10673,6 +11406,8 @@ writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jstype); if (message.weak != null && Object.hasOwnProperty.call(message, "weak")) writer.uint32(/* id 10, wireType 0 =*/80).bool(message.weak); + if (message.unverifiedLazy != null && Object.hasOwnProperty.call(message, "unverifiedLazy")) + writer.uint32(/* id 15, wireType 0 =*/120).bool(message.unverifiedLazy); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -10718,42 +11453,55 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.ctype = reader.int32(); - break; - case 2: - message.packed = reader.bool(); - break; - case 6: - message.jstype = reader.int32(); - break; - case 5: - message.lazy = reader.bool(); - break; - case 3: - message.deprecated = reader.bool(); - break; - case 10: - message.weak = reader.bool(); - break; - case 999: - if (!(message.uninterpretedOption && message.uninterpretedOption.length)) - message.uninterpretedOption = []; - message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); - break; - case 1052: - if (!(message[".google.api.fieldBehavior"] && message[".google.api.fieldBehavior"].length)) - message[".google.api.fieldBehavior"] = []; - if ((tag & 7) === 2) { - var end2 = reader.uint32() + reader.pos; - while (reader.pos < end2) + case 1: { + message.ctype = reader.int32(); + break; + } + case 2: { + message.packed = reader.bool(); + break; + } + case 6: { + message.jstype = reader.int32(); + break; + } + case 5: { + message.lazy = reader.bool(); + break; + } + case 15: { + message.unverifiedLazy = reader.bool(); + break; + } + case 3: { + message.deprecated = reader.bool(); + break; + } + case 10: { + message.weak = reader.bool(); + break; + } + case 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } + case 1052: { + if (!(message[".google.api.fieldBehavior"] && message[".google.api.fieldBehavior"].length)) + message[".google.api.fieldBehavior"] = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message[".google.api.fieldBehavior"].push(reader.int32()); + } else message[".google.api.fieldBehavior"].push(reader.int32()); - } else - message[".google.api.fieldBehavior"].push(reader.int32()); - break; - case 1055: - message[".google.api.resourceReference"] = $root.google.api.ResourceReference.decode(reader, reader.uint32()); - break; + break; + } + case 1055: { + message[".google.api.resourceReference"] = $root.google.api.ResourceReference.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -10813,6 +11561,9 @@ if (message.lazy != null && message.hasOwnProperty("lazy")) if (typeof message.lazy !== "boolean") return "lazy: boolean expected"; + if (message.unverifiedLazy != null && message.hasOwnProperty("unverifiedLazy")) + if (typeof message.unverifiedLazy !== "boolean") + return "unverifiedLazy: boolean expected"; if (message.deprecated != null && message.hasOwnProperty("deprecated")) if (typeof message.deprecated !== "boolean") return "deprecated: boolean expected"; @@ -10867,6 +11618,12 @@ return object; var message = new $root.google.protobuf.FieldOptions(); switch (object.ctype) { + default: + if (typeof object.ctype === "number") { + message.ctype = object.ctype; + break; + } + break; case "STRING": case 0: message.ctype = 0; @@ -10883,6 +11640,12 @@ if (object.packed != null) message.packed = Boolean(object.packed); switch (object.jstype) { + default: + if (typeof object.jstype === "number") { + message.jstype = object.jstype; + break; + } + break; case "JS_NORMAL": case 0: message.jstype = 0; @@ -10898,6 +11661,8 @@ } if (object.lazy != null) message.lazy = Boolean(object.lazy); + if (object.unverifiedLazy != null) + message.unverifiedLazy = Boolean(object.unverifiedLazy); if (object.deprecated != null) message.deprecated = Boolean(object.deprecated); if (object.weak != null) @@ -10919,6 +11684,10 @@ for (var i = 0; i < object[".google.api.fieldBehavior"].length; ++i) switch (object[".google.api.fieldBehavior"][i]) { default: + if (typeof object[".google.api.fieldBehavior"][i] === "number") { + message[".google.api.fieldBehavior"][i] = object[".google.api.fieldBehavior"][i]; + break; + } case "FIELD_BEHAVIOR_UNSPECIFIED": case 0: message[".google.api.fieldBehavior"][i] = 0; @@ -10985,10 +11754,11 @@ object.lazy = false; object.jstype = options.enums === String ? "JS_NORMAL" : 0; object.weak = false; + object.unverifiedLazy = false; object[".google.api.resourceReference"] = null; } if (message.ctype != null && message.hasOwnProperty("ctype")) - object.ctype = options.enums === String ? $root.google.protobuf.FieldOptions.CType[message.ctype] : message.ctype; + object.ctype = options.enums === String ? $root.google.protobuf.FieldOptions.CType[message.ctype] === undefined ? message.ctype : $root.google.protobuf.FieldOptions.CType[message.ctype] : message.ctype; if (message.packed != null && message.hasOwnProperty("packed")) object.packed = message.packed; if (message.deprecated != null && message.hasOwnProperty("deprecated")) @@ -10996,9 +11766,11 @@ if (message.lazy != null && message.hasOwnProperty("lazy")) object.lazy = message.lazy; if (message.jstype != null && message.hasOwnProperty("jstype")) - object.jstype = options.enums === String ? $root.google.protobuf.FieldOptions.JSType[message.jstype] : message.jstype; + object.jstype = options.enums === String ? $root.google.protobuf.FieldOptions.JSType[message.jstype] === undefined ? message.jstype : $root.google.protobuf.FieldOptions.JSType[message.jstype] : message.jstype; if (message.weak != null && message.hasOwnProperty("weak")) object.weak = message.weak; + if (message.unverifiedLazy != null && message.hasOwnProperty("unverifiedLazy")) + object.unverifiedLazy = message.unverifiedLazy; if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -11007,7 +11779,7 @@ if (message[".google.api.fieldBehavior"] && message[".google.api.fieldBehavior"].length) { object[".google.api.fieldBehavior"] = []; for (var j = 0; j < message[".google.api.fieldBehavior"].length; ++j) - object[".google.api.fieldBehavior"][j] = options.enums === String ? $root.google.api.FieldBehavior[message[".google.api.fieldBehavior"][j]] : message[".google.api.fieldBehavior"][j]; + object[".google.api.fieldBehavior"][j] = options.enums === String ? $root.google.api.FieldBehavior[message[".google.api.fieldBehavior"][j]] === undefined ? message[".google.api.fieldBehavior"][j] : $root.google.api.FieldBehavior[message[".google.api.fieldBehavior"][j]] : message[".google.api.fieldBehavior"][j]; } if (message[".google.api.resourceReference"] != null && message.hasOwnProperty(".google.api.resourceReference")) object[".google.api.resourceReference"] = $root.google.api.ResourceReference.toObject(message[".google.api.resourceReference"], options); @@ -11025,6 +11797,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for FieldOptions + * @function getTypeUrl + * @memberof google.protobuf.FieldOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FieldOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldOptions"; + }; + /** * CType enum. * @name google.protobuf.FieldOptions.CType @@ -11154,11 +11941,12 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 999: - if (!(message.uninterpretedOption && message.uninterpretedOption.length)) - message.uninterpretedOption = []; - message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); - break; + case 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -11265,6 +12053,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for OneofOptions + * @function getTypeUrl + * @memberof google.protobuf.OneofOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + OneofOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.OneofOptions"; + }; + return OneofOptions; })(); @@ -11384,17 +12187,20 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 2: - message.allowAlias = reader.bool(); - break; - case 3: - message.deprecated = reader.bool(); - break; - case 999: - if (!(message.uninterpretedOption && message.uninterpretedOption.length)) - message.uninterpretedOption = []; - message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); - break; + case 2: { + message.allowAlias = reader.bool(); + break; + } + case 3: { + message.deprecated = reader.bool(); + break; + } + case 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -11519,6 +12325,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for EnumOptions + * @function getTypeUrl + * @memberof google.protobuf.EnumOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EnumOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.EnumOptions"; + }; + return EnumOptions; })(); @@ -11627,14 +12448,16 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.deprecated = reader.bool(); - break; - case 999: - if (!(message.uninterpretedOption && message.uninterpretedOption.length)) - message.uninterpretedOption = []; - message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); - break; + case 1: { + message.deprecated = reader.bool(); + break; + } + case 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -11750,6 +12573,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for EnumValueOptions + * @function getTypeUrl + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EnumValueOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.EnumValueOptions"; + }; + return EnumValueOptions; })(); @@ -11880,20 +12718,24 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 33: - message.deprecated = reader.bool(); - break; - case 999: - if (!(message.uninterpretedOption && message.uninterpretedOption.length)) - message.uninterpretedOption = []; - message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); - break; - case 1049: - message[".google.api.defaultHost"] = reader.string(); - break; - case 1050: - message[".google.api.oauthScopes"] = reader.string(); - break; + case 33: { + message.deprecated = reader.bool(); + break; + } + case 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } + case 1049: { + message[".google.api.defaultHost"] = reader.string(); + break; + } + case 1050: { + message[".google.api.oauthScopes"] = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -12026,6 +12868,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for ServiceOptions + * @function getTypeUrl + * @memberof google.protobuf.ServiceOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ServiceOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.ServiceOptions"; + }; + return ServiceOptions; })(); @@ -12191,31 +13048,38 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 33: - message.deprecated = reader.bool(); - break; - case 34: - message.idempotencyLevel = reader.int32(); - break; - case 999: - if (!(message.uninterpretedOption && message.uninterpretedOption.length)) - message.uninterpretedOption = []; - message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); - break; - case 72295728: - message[".google.api.http"] = $root.google.api.HttpRule.decode(reader, reader.uint32()); - break; - case 72295729: - message[".google.api.routing"] = $root.google.api.RoutingRule.decode(reader, reader.uint32()); - break; - case 1051: - if (!(message[".google.api.methodSignature"] && message[".google.api.methodSignature"].length)) - message[".google.api.methodSignature"] = []; - message[".google.api.methodSignature"].push(reader.string()); - break; - case 1049: - message[".google.longrunning.operationInfo"] = $root.google.longrunning.OperationInfo.decode(reader, reader.uint32()); - break; + case 33: { + message.deprecated = reader.bool(); + break; + } + case 34: { + message.idempotencyLevel = reader.int32(); + break; + } + case 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } + case 72295728: { + message[".google.api.http"] = $root.google.api.HttpRule.decode(reader, reader.uint32()); + break; + } + case 72295729: { + message[".google.api.routing"] = $root.google.api.RoutingRule.decode(reader, reader.uint32()); + break; + } + case 1051: { + if (!(message[".google.api.methodSignature"] && message[".google.api.methodSignature"].length)) + message[".google.api.methodSignature"] = []; + message[".google.api.methodSignature"].push(reader.string()); + break; + } + case 1049: { + message[".google.longrunning.operationInfo"] = $root.google.longrunning.OperationInfo.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -12312,6 +13176,12 @@ if (object.deprecated != null) message.deprecated = Boolean(object.deprecated); switch (object.idempotencyLevel) { + default: + if (typeof object.idempotencyLevel === "number") { + message.idempotencyLevel = object.idempotencyLevel; + break; + } + break; case "IDEMPOTENCY_UNKNOWN": case 0: message.idempotencyLevel = 0; @@ -12387,7 +13257,7 @@ if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; if (message.idempotencyLevel != null && message.hasOwnProperty("idempotencyLevel")) - object.idempotencyLevel = options.enums === String ? $root.google.protobuf.MethodOptions.IdempotencyLevel[message.idempotencyLevel] : message.idempotencyLevel; + object.idempotencyLevel = options.enums === String ? $root.google.protobuf.MethodOptions.IdempotencyLevel[message.idempotencyLevel] === undefined ? message.idempotencyLevel : $root.google.protobuf.MethodOptions.IdempotencyLevel[message.idempotencyLevel] : message.idempotencyLevel; if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -12418,6 +13288,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for MethodOptions + * @function getTypeUrl + * @memberof google.protobuf.MethodOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + MethodOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.MethodOptions"; + }; + /** * IdempotencyLevel enum. * @name google.protobuf.MethodOptions.IdempotencyLevel @@ -12597,29 +13482,36 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 2: - if (!(message.name && message.name.length)) - message.name = []; - message.name.push($root.google.protobuf.UninterpretedOption.NamePart.decode(reader, reader.uint32())); - break; - case 3: - message.identifierValue = reader.string(); - break; - case 4: - message.positiveIntValue = reader.uint64(); - break; - case 5: - message.negativeIntValue = reader.int64(); - break; - case 6: - message.doubleValue = reader.double(); - break; - case 7: - message.stringValue = reader.bytes(); - break; - case 8: - message.aggregateValue = reader.string(); - break; + case 2: { + if (!(message.name && message.name.length)) + message.name = []; + message.name.push($root.google.protobuf.UninterpretedOption.NamePart.decode(reader, reader.uint32())); + break; + } + case 3: { + message.identifierValue = reader.string(); + break; + } + case 4: { + message.positiveIntValue = reader.uint64(); + break; + } + case 5: { + message.negativeIntValue = reader.int64(); + break; + } + case 6: { + message.doubleValue = reader.double(); + break; + } + case 7: { + message.stringValue = reader.bytes(); + break; + } + case 8: { + message.aggregateValue = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -12732,7 +13624,7 @@ if (object.stringValue != null) if (typeof object.stringValue === "string") $util.base64.decode(object.stringValue, message.stringValue = $util.newBuffer($util.base64.length(object.stringValue)), 0); - else if (object.stringValue.length) + else if (object.stringValue.length >= 0) message.stringValue = object.stringValue; if (object.aggregateValue != null) message.aggregateValue = String(object.aggregateValue); @@ -12813,6 +13705,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for UninterpretedOption + * @function getTypeUrl + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UninterpretedOption.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.UninterpretedOption"; + }; + UninterpretedOption.NamePart = (function() { /** @@ -12914,12 +13821,14 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.namePart = reader.string(); - break; - case 2: - message.isExtension = reader.bool(); - break; + case 1: { + message.namePart = reader.string(); + break; + } + case 2: { + message.isExtension = reader.bool(); + break; + } default: reader.skipType(tag & 7); break; @@ -13020,6 +13929,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for NamePart + * @function getTypeUrl + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + NamePart.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.UninterpretedOption.NamePart"; + }; + return NamePart; })(); @@ -13120,11 +14044,12 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - if (!(message.location && message.location.length)) - message.location = []; - message.location.push($root.google.protobuf.SourceCodeInfo.Location.decode(reader, reader.uint32())); - break; + case 1: { + if (!(message.location && message.location.length)) + message.location = []; + message.location.push($root.google.protobuf.SourceCodeInfo.Location.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -13231,6 +14156,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for SourceCodeInfo + * @function getTypeUrl + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SourceCodeInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.SourceCodeInfo"; + }; + SourceCodeInfo.Location = (function() { /** @@ -13379,37 +14319,42 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - if (!(message.path && message.path.length)) - message.path = []; - if ((tag & 7) === 2) { - var end2 = reader.uint32() + reader.pos; - while (reader.pos < end2) + case 1: { + if (!(message.path && message.path.length)) + message.path = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.path.push(reader.int32()); + } else message.path.push(reader.int32()); - } else - message.path.push(reader.int32()); - break; - case 2: - if (!(message.span && message.span.length)) - message.span = []; - if ((tag & 7) === 2) { - var end2 = reader.uint32() + reader.pos; - while (reader.pos < end2) + break; + } + case 2: { + if (!(message.span && message.span.length)) + message.span = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.span.push(reader.int32()); + } else message.span.push(reader.int32()); - } else - message.span.push(reader.int32()); - break; - case 3: - message.leadingComments = reader.string(); - break; - case 4: - message.trailingComments = reader.string(); - break; - case 6: - if (!(message.leadingDetachedComments && message.leadingDetachedComments.length)) - message.leadingDetachedComments = []; - message.leadingDetachedComments.push(reader.string()); - break; + break; + } + case 3: { + message.leadingComments = reader.string(); + break; + } + case 4: { + message.trailingComments = reader.string(); + break; + } + case 6: { + if (!(message.leadingDetachedComments && message.leadingDetachedComments.length)) + message.leadingDetachedComments = []; + message.leadingDetachedComments.push(reader.string()); + break; + } default: reader.skipType(tag & 7); break; @@ -13570,6 +14515,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Location + * @function getTypeUrl + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Location.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.SourceCodeInfo.Location"; + }; + return Location; })(); @@ -13670,11 +14630,12 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - if (!(message.annotation && message.annotation.length)) - message.annotation = []; - message.annotation.push($root.google.protobuf.GeneratedCodeInfo.Annotation.decode(reader, reader.uint32())); - break; + case 1: { + if (!(message.annotation && message.annotation.length)) + message.annotation = []; + message.annotation.push($root.google.protobuf.GeneratedCodeInfo.Annotation.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -13781,6 +14742,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for GeneratedCodeInfo + * @function getTypeUrl + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GeneratedCodeInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.GeneratedCodeInfo"; + }; + GeneratedCodeInfo.Annotation = (function() { /** @@ -13791,6 +14767,7 @@ * @property {string|null} [sourceFile] Annotation sourceFile * @property {number|null} [begin] Annotation begin * @property {number|null} [end] Annotation end + * @property {google.protobuf.GeneratedCodeInfo.Annotation.Semantic|null} [semantic] Annotation semantic */ /** @@ -13841,6 +14818,14 @@ */ Annotation.prototype.end = 0; + /** + * Annotation semantic. + * @member {google.protobuf.GeneratedCodeInfo.Annotation.Semantic} semantic + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.semantic = 0; + /** * Creates a new Annotation instance using the specified properties. * @function create @@ -13877,6 +14862,8 @@ writer.uint32(/* id 3, wireType 0 =*/24).int32(message.begin); if (message.end != null && Object.hasOwnProperty.call(message, "end")) writer.uint32(/* id 4, wireType 0 =*/32).int32(message.end); + if (message.semantic != null && Object.hasOwnProperty.call(message, "semantic")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.semantic); return writer; }; @@ -13911,25 +14898,33 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - if (!(message.path && message.path.length)) - message.path = []; - if ((tag & 7) === 2) { - var end2 = reader.uint32() + reader.pos; - while (reader.pos < end2) + case 1: { + if (!(message.path && message.path.length)) + message.path = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.path.push(reader.int32()); + } else message.path.push(reader.int32()); - } else - message.path.push(reader.int32()); - break; - case 2: - message.sourceFile = reader.string(); - break; - case 3: - message.begin = reader.int32(); - break; - case 4: - message.end = reader.int32(); - break; + break; + } + case 2: { + message.sourceFile = reader.string(); + break; + } + case 3: { + message.begin = reader.int32(); + break; + } + case 4: { + message.end = reader.int32(); + break; + } + case 5: { + message.semantic = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -13981,6 +14976,15 @@ if (message.end != null && message.hasOwnProperty("end")) if (!$util.isInteger(message.end)) return "end: integer expected"; + if (message.semantic != null && message.hasOwnProperty("semantic")) + switch (message.semantic) { + default: + return "semantic: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -14009,6 +15013,26 @@ message.begin = object.begin | 0; if (object.end != null) message.end = object.end | 0; + switch (object.semantic) { + default: + if (typeof object.semantic === "number") { + message.semantic = object.semantic; + break; + } + break; + case "NONE": + case 0: + message.semantic = 0; + break; + case "SET": + case 1: + message.semantic = 1; + break; + case "ALIAS": + case 2: + message.semantic = 2; + break; + } return message; }; @@ -14031,6 +15055,7 @@ object.sourceFile = ""; object.begin = 0; object.end = 0; + object.semantic = options.enums === String ? "NONE" : 0; } if (message.path && message.path.length) { object.path = []; @@ -14043,6 +15068,8 @@ object.begin = message.begin; if (message.end != null && message.hasOwnProperty("end")) object.end = message.end; + if (message.semantic != null && message.hasOwnProperty("semantic")) + object.semantic = options.enums === String ? $root.google.protobuf.GeneratedCodeInfo.Annotation.Semantic[message.semantic] === undefined ? message.semantic : $root.google.protobuf.GeneratedCodeInfo.Annotation.Semantic[message.semantic] : message.semantic; return object; }; @@ -14057,6 +15084,37 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Annotation + * @function getTypeUrl + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Annotation.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.GeneratedCodeInfo.Annotation"; + }; + + /** + * Semantic enum. + * @name google.protobuf.GeneratedCodeInfo.Annotation.Semantic + * @enum {number} + * @property {number} NONE=0 NONE value + * @property {number} SET=1 SET value + * @property {number} ALIAS=2 ALIAS value + */ + Annotation.Semantic = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "NONE"] = 0; + values[valuesById[1] = "SET"] = 1; + values[valuesById[2] = "ALIAS"] = 2; + return values; + })(); + return Annotation; })(); @@ -14166,12 +15224,14 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.type_url = reader.string(); - break; - case 2: - message.value = reader.bytes(); - break; + case 1: { + message.type_url = reader.string(); + break; + } + case 2: { + message.value = reader.bytes(); + break; + } default: reader.skipType(tag & 7); break; @@ -14233,7 +15293,7 @@ if (object.value != null) if (typeof object.value === "string") $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); - else if (object.value.length) + else if (object.value.length >= 0) message.value = object.value; return message; }; @@ -14279,6 +15339,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Any + * @function getTypeUrl + * @memberof google.protobuf.Any + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Any.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.Any"; + }; + return Any; })(); @@ -14385,12 +15460,14 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.seconds = reader.int64(); - break; - case 2: - message.nanos = reader.int32(); - break; + case 1: { + message.seconds = reader.int64(); + break; + } + case 2: { + message.nanos = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -14503,6 +15580,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Duration + * @function getTypeUrl + * @memberof google.protobuf.Duration + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Duration.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.Duration"; + }; + return Duration; })(); @@ -14663,6 +15755,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Empty + * @function getTypeUrl + * @memberof google.protobuf.Empty + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Empty.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.Empty"; + }; + return Empty; })(); @@ -14800,18 +15907,22 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.major = reader.int32(); - break; - case 2: - message.minor = reader.int32(); - break; - case 3: - message.patch = reader.int32(); - break; - case 4: - message.suffix = reader.string(); - break; + case 1: { + message.major = reader.int32(); + break; + } + case 2: { + message.minor = reader.int32(); + break; + } + case 3: { + message.patch = reader.int32(); + break; + } + case 4: { + message.suffix = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -14926,6 +16037,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Version + * @function getTypeUrl + * @memberof google.protobuf.compiler.Version + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Version.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.compiler.Version"; + }; + return Version; })(); @@ -15058,22 +16184,26 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - if (!(message.fileToGenerate && message.fileToGenerate.length)) - message.fileToGenerate = []; - message.fileToGenerate.push(reader.string()); - break; - case 2: - message.parameter = reader.string(); - break; - case 15: - if (!(message.protoFile && message.protoFile.length)) - message.protoFile = []; - message.protoFile.push($root.google.protobuf.FileDescriptorProto.decode(reader, reader.uint32())); - break; - case 3: - message.compilerVersion = $root.google.protobuf.compiler.Version.decode(reader, reader.uint32()); - break; + case 1: { + if (!(message.fileToGenerate && message.fileToGenerate.length)) + message.fileToGenerate = []; + message.fileToGenerate.push(reader.string()); + break; + } + case 2: { + message.parameter = reader.string(); + break; + } + case 15: { + if (!(message.protoFile && message.protoFile.length)) + message.protoFile = []; + message.protoFile.push($root.google.protobuf.FileDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 3: { + message.compilerVersion = $root.google.protobuf.compiler.Version.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -15224,6 +16354,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for CodeGeneratorRequest + * @function getTypeUrl + * @memberof google.protobuf.compiler.CodeGeneratorRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CodeGeneratorRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.compiler.CodeGeneratorRequest"; + }; + return CodeGeneratorRequest; })(); @@ -15343,17 +16488,20 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.error = reader.string(); - break; - case 2: - message.supportedFeatures = reader.uint64(); - break; - case 15: - if (!(message.file && message.file.length)) - message.file = []; - message.file.push($root.google.protobuf.compiler.CodeGeneratorResponse.File.decode(reader, reader.uint32())); - break; + case 1: { + message.error = reader.string(); + break; + } + case 2: { + message.supportedFeatures = reader.uint64(); + break; + } + case 15: { + if (!(message.file && message.file.length)) + message.file = []; + message.file.push($root.google.protobuf.compiler.CodeGeneratorResponse.File.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -15492,6 +16640,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for CodeGeneratorResponse + * @function getTypeUrl + * @memberof google.protobuf.compiler.CodeGeneratorResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CodeGeneratorResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.compiler.CodeGeneratorResponse"; + }; + /** * Feature enum. * @name google.protobuf.compiler.CodeGeneratorResponse.Feature @@ -15631,18 +16794,22 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.name = reader.string(); - break; - case 2: - message.insertionPoint = reader.string(); - break; - case 15: - message.content = reader.string(); - break; - case 16: - message.generatedCodeInfo = $root.google.protobuf.GeneratedCodeInfo.decode(reader, reader.uint32()); - break; + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.insertionPoint = reader.string(); + break; + } + case 15: { + message.content = reader.string(); + break; + } + case 16: { + message.generatedCodeInfo = $root.google.protobuf.GeneratedCodeInfo.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -15762,6 +16929,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for File + * @function getTypeUrl + * @memberof google.protobuf.compiler.CodeGeneratorResponse.File + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + File.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.compiler.CodeGeneratorResponse.File"; + }; + return File; })(); @@ -15863,9 +17045,10 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.value = reader.double(); - break; + case 1: { + message.value = reader.double(); + break; + } default: reader.skipType(tag & 7); break; @@ -15955,6 +17138,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for DoubleValue + * @function getTypeUrl + * @memberof google.protobuf.DoubleValue + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DoubleValue.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.DoubleValue"; + }; + return DoubleValue; })(); @@ -16050,9 +17248,10 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.value = reader.float(); - break; + case 1: { + message.value = reader.float(); + break; + } default: reader.skipType(tag & 7); break; @@ -16142,6 +17341,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for FloatValue + * @function getTypeUrl + * @memberof google.protobuf.FloatValue + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FloatValue.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FloatValue"; + }; + return FloatValue; })(); @@ -16237,9 +17451,10 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.value = reader.int64(); - break; + case 1: { + message.value = reader.int64(); + break; + } default: reader.skipType(tag & 7); break; @@ -16343,6 +17558,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Int64Value + * @function getTypeUrl + * @memberof google.protobuf.Int64Value + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Int64Value.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.Int64Value"; + }; + return Int64Value; })(); @@ -16438,9 +17668,10 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.value = reader.uint64(); - break; + case 1: { + message.value = reader.uint64(); + break; + } default: reader.skipType(tag & 7); break; @@ -16544,6 +17775,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for UInt64Value + * @function getTypeUrl + * @memberof google.protobuf.UInt64Value + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UInt64Value.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.UInt64Value"; + }; + return UInt64Value; })(); @@ -16639,9 +17885,10 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.value = reader.int32(); - break; + case 1: { + message.value = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -16731,6 +17978,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Int32Value + * @function getTypeUrl + * @memberof google.protobuf.Int32Value + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Int32Value.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.Int32Value"; + }; + return Int32Value; })(); @@ -16826,9 +18088,10 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.value = reader.uint32(); - break; + case 1: { + message.value = reader.uint32(); + break; + } default: reader.skipType(tag & 7); break; @@ -16918,6 +18181,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for UInt32Value + * @function getTypeUrl + * @memberof google.protobuf.UInt32Value + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UInt32Value.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.UInt32Value"; + }; + return UInt32Value; })(); @@ -17013,9 +18291,10 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.value = reader.bool(); - break; + case 1: { + message.value = reader.bool(); + break; + } default: reader.skipType(tag & 7); break; @@ -17105,6 +18384,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for BoolValue + * @function getTypeUrl + * @memberof google.protobuf.BoolValue + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BoolValue.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.BoolValue"; + }; + return BoolValue; })(); @@ -17200,9 +18494,10 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.value = reader.string(); - break; + case 1: { + message.value = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -17292,6 +18587,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for StringValue + * @function getTypeUrl + * @memberof google.protobuf.StringValue + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + StringValue.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.StringValue"; + }; + return StringValue; })(); @@ -17387,9 +18697,10 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.value = reader.bytes(); - break; + case 1: { + message.value = reader.bytes(); + break; + } default: reader.skipType(tag & 7); break; @@ -17446,7 +18757,7 @@ if (object.value != null) if (typeof object.value === "string") $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); - else if (object.value.length) + else if (object.value.length >= 0) message.value = object.value; return message; }; @@ -17488,6 +18799,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for BytesValue + * @function getTypeUrl + * @memberof google.protobuf.BytesValue + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BytesValue.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.BytesValue"; + }; + return BytesValue; })(); @@ -17853,21 +19179,26 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.name = reader.string(); - break; - case 2: - message.metadata = $root.google.protobuf.Any.decode(reader, reader.uint32()); - break; - case 3: - message.done = reader.bool(); - break; - case 4: - message.error = $root.google.rpc.Status.decode(reader, reader.uint32()); - break; - case 5: - message.response = $root.google.protobuf.Any.decode(reader, reader.uint32()); - break; + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.metadata = $root.google.protobuf.Any.decode(reader, reader.uint32()); + break; + } + case 3: { + message.done = reader.bool(); + break; + } + case 4: { + message.error = $root.google.rpc.Status.decode(reader, reader.uint32()); + break; + } + case 5: { + message.response = $root.google.protobuf.Any.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -18018,6 +19349,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Operation + * @function getTypeUrl + * @memberof google.longrunning.Operation + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Operation.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.longrunning.Operation"; + }; + return Operation; })(); @@ -18113,9 +19459,10 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.name = reader.string(); - break; + case 1: { + message.name = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -18205,6 +19552,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for GetOperationRequest + * @function getTypeUrl + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetOperationRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.longrunning.GetOperationRequest"; + }; + return GetOperationRequest; })(); @@ -18333,18 +19695,22 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 4: - message.name = reader.string(); - break; - case 1: - message.filter = reader.string(); - break; - case 2: - message.pageSize = reader.int32(); - break; - case 3: - message.pageToken = reader.string(); - break; + case 4: { + message.name = reader.string(); + break; + } + case 1: { + message.filter = reader.string(); + break; + } + case 2: { + message.pageSize = reader.int32(); + break; + } + case 3: { + message.pageToken = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -18459,6 +19825,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for ListOperationsRequest + * @function getTypeUrl + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListOperationsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.longrunning.ListOperationsRequest"; + }; + return ListOperationsRequest; })(); @@ -18567,14 +19948,16 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - if (!(message.operations && message.operations.length)) - message.operations = []; - message.operations.push($root.google.longrunning.Operation.decode(reader, reader.uint32())); - break; - case 2: - message.nextPageToken = reader.string(); - break; + case 1: { + if (!(message.operations && message.operations.length)) + message.operations = []; + message.operations.push($root.google.longrunning.Operation.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -18690,6 +20073,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for ListOperationsResponse + * @function getTypeUrl + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListOperationsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.longrunning.ListOperationsResponse"; + }; + return ListOperationsResponse; })(); @@ -18785,9 +20183,10 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.name = reader.string(); - break; + case 1: { + message.name = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -18877,6 +20276,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for CancelOperationRequest + * @function getTypeUrl + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CancelOperationRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.longrunning.CancelOperationRequest"; + }; + return CancelOperationRequest; })(); @@ -18972,9 +20386,10 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.name = reader.string(); - break; + case 1: { + message.name = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -19064,6 +20479,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for DeleteOperationRequest + * @function getTypeUrl + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteOperationRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.longrunning.DeleteOperationRequest"; + }; + return DeleteOperationRequest; })(); @@ -19170,12 +20600,14 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.name = reader.string(); - break; - case 2: - message.timeout = $root.google.protobuf.Duration.decode(reader, reader.uint32()); - break; + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.timeout = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -19275,8 +20707,23 @@ * @instance * @returns {Object.} JSON object */ - WaitOperationRequest.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + WaitOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for WaitOperationRequest + * @function getTypeUrl + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + WaitOperationRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.longrunning.WaitOperationRequest"; }; return WaitOperationRequest; @@ -19385,12 +20832,14 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.responseType = reader.string(); - break; - case 2: - message.metadataType = reader.string(); - break; + case 1: { + message.responseType = reader.string(); + break; + } + case 2: { + message.metadataType = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -19489,6 +20938,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for OperationInfo + * @function getTypeUrl + * @memberof google.longrunning.OperationInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + OperationInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.longrunning.OperationInfo"; + }; + return OperationInfo; })(); @@ -19620,17 +21084,20 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.code = reader.int32(); - break; - case 2: - message.message = reader.string(); - break; - case 3: - if (!(message.details && message.details.length)) - message.details = []; - message.details.push($root.google.protobuf.Any.decode(reader, reader.uint32())); - break; + case 1: { + message.code = reader.int32(); + break; + } + case 2: { + message.message = reader.string(); + break; + } + case 3: { + if (!(message.details && message.details.length)) + message.details = []; + message.details.push($root.google.protobuf.Any.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -19755,6 +21222,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Status + * @function getTypeUrl + * @memberof google.rpc.Status + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Status.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.rpc.Status"; + }; + return Status; })(); @@ -19955,14 +21437,16 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.clientLibrary = $root.google.cloud.tools.snippetgen.snippetindex.v1.ClientLibrary.decode(reader, reader.uint32()); - break; - case 2: - if (!(message.snippets && message.snippets.length)) - message.snippets = []; - message.snippets.push($root.google.cloud.tools.snippetgen.snippetindex.v1.Snippet.decode(reader, reader.uint32())); - break; + case 1: { + message.clientLibrary = $root.google.cloud.tools.snippetgen.snippetindex.v1.ClientLibrary.decode(reader, reader.uint32()); + break; + } + case 2: { + if (!(message.snippets && message.snippets.length)) + message.snippets = []; + message.snippets.push($root.google.cloud.tools.snippetgen.snippetindex.v1.Snippet.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -20083,6 +21567,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Index + * @function getTypeUrl + * @memberof google.cloud.tools.snippetgen.snippetindex.v1.Index + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Index.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.tools.snippetgen.snippetindex.v1.Index"; + }; + return Index; })(); @@ -20268,35 +21767,44 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.regionTag = reader.string(); - break; - case 2: - message.title = reader.string(); - break; - case 3: - message.description = reader.string(); - break; - case 4: - message.file = reader.string(); - break; - case 5: - message.language = reader.int32(); - break; - case 6: - message.clientMethod = $root.google.cloud.tools.snippetgen.snippetindex.v1.ClientMethod.decode(reader, reader.uint32()); - break; - case 7: - message.canonical = reader.bool(); - break; - case 8: - message.origin = reader.int32(); - break; - case 9: - if (!(message.segments && message.segments.length)) - message.segments = []; - message.segments.push($root.google.cloud.tools.snippetgen.snippetindex.v1.Snippet.Segment.decode(reader, reader.uint32())); - break; + case 1: { + message.regionTag = reader.string(); + break; + } + case 2: { + message.title = reader.string(); + break; + } + case 3: { + message.description = reader.string(); + break; + } + case 4: { + message.file = reader.string(); + break; + } + case 5: { + message.language = reader.int32(); + break; + } + case 6: { + message.clientMethod = $root.google.cloud.tools.snippetgen.snippetindex.v1.ClientMethod.decode(reader, reader.uint32()); + break; + } + case 7: { + message.canonical = reader.bool(); + break; + } + case 8: { + message.origin = reader.int32(); + break; + } + case 9: { + if (!(message.segments && message.segments.length)) + message.segments = []; + message.segments.push($root.google.cloud.tools.snippetgen.snippetindex.v1.Snippet.Segment.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -20419,6 +21927,12 @@ if (object.file != null) message.file = String(object.file); switch (object.language) { + default: + if (typeof object.language === "number") { + message.language = object.language; + break; + } + break; case "LANGUAGE_UNSPECIFIED": case 0: message.language = 0; @@ -20500,6 +22014,12 @@ if (object.canonical != null) message.canonical = Boolean(object.canonical); switch (object.origin) { + default: + if (typeof object.origin === "number") { + message.origin = object.origin; + break; + } + break; case "ORIGIN_UNSPECIFIED": case 0: message.origin = 0; @@ -20564,13 +22084,13 @@ if (message.file != null && message.hasOwnProperty("file")) object.file = message.file; if (message.language != null && message.hasOwnProperty("language")) - object.language = options.enums === String ? $root.google.cloud.tools.snippetgen.snippetindex.v1.Language[message.language] : message.language; + object.language = options.enums === String ? $root.google.cloud.tools.snippetgen.snippetindex.v1.Language[message.language] === undefined ? message.language : $root.google.cloud.tools.snippetgen.snippetindex.v1.Language[message.language] : message.language; if (message.clientMethod != null && message.hasOwnProperty("clientMethod")) object.clientMethod = $root.google.cloud.tools.snippetgen.snippetindex.v1.ClientMethod.toObject(message.clientMethod, options); if (message.canonical != null && message.hasOwnProperty("canonical")) object.canonical = message.canonical; if (message.origin != null && message.hasOwnProperty("origin")) - object.origin = options.enums === String ? $root.google.cloud.tools.snippetgen.snippetindex.v1.Snippet.Origin[message.origin] : message.origin; + object.origin = options.enums === String ? $root.google.cloud.tools.snippetgen.snippetindex.v1.Snippet.Origin[message.origin] === undefined ? message.origin : $root.google.cloud.tools.snippetgen.snippetindex.v1.Snippet.Origin[message.origin] : message.origin; if (message.segments && message.segments.length) { object.segments = []; for (var j = 0; j < message.segments.length; ++j) @@ -20590,6 +22110,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Snippet + * @function getTypeUrl + * @memberof google.cloud.tools.snippetgen.snippetindex.v1.Snippet + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Snippet.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.tools.snippetgen.snippetindex.v1.Snippet"; + }; + /** * Origin enum. * @name google.cloud.tools.snippetgen.snippetindex.v1.Snippet.Origin @@ -20722,15 +22257,18 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.start = reader.int32(); - break; - case 2: - message.end = reader.int32(); - break; - case 3: - message.type = reader.int32(); - break; + case 1: { + message.start = reader.int32(); + break; + } + case 2: { + message.end = reader.int32(); + break; + } + case 3: { + message.type = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -20805,6 +22343,12 @@ if (object.end != null) message.end = object.end | 0; switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; case "SEGMENT_TYPE_UNSPECIFIED": case 0: message.type = 0; @@ -20860,7 +22404,7 @@ if (message.end != null && message.hasOwnProperty("end")) object.end = message.end; if (message.type != null && message.hasOwnProperty("type")) - object.type = options.enums === String ? $root.google.cloud.tools.snippetgen.snippetindex.v1.Snippet.Segment.SegmentType[message.type] : message.type; + object.type = options.enums === String ? $root.google.cloud.tools.snippetgen.snippetindex.v1.Snippet.Segment.SegmentType[message.type] === undefined ? message.type : $root.google.cloud.tools.snippetgen.snippetindex.v1.Snippet.Segment.SegmentType[message.type] : message.type; return object; }; @@ -20875,6 +22419,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Segment + * @function getTypeUrl + * @memberof google.cloud.tools.snippetgen.snippetindex.v1.Snippet.Segment + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Segment.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.tools.snippetgen.snippetindex.v1.Snippet.Segment"; + }; + /** * SegmentType enum. * @name google.cloud.tools.snippetgen.snippetindex.v1.Snippet.Segment.SegmentType @@ -21065,29 +22624,36 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.shortName = reader.string(); - break; - case 2: - message.fullName = reader.string(); - break; - case 3: - message.async = reader.bool(); - break; - case 4: - if (!(message.parameters && message.parameters.length)) - message.parameters = []; - message.parameters.push($root.google.cloud.tools.snippetgen.snippetindex.v1.ClientMethod.Parameter.decode(reader, reader.uint32())); - break; - case 5: - message.resultType = reader.string(); - break; - case 6: - message.client = $root.google.cloud.tools.snippetgen.snippetindex.v1.ServiceClient.decode(reader, reader.uint32()); - break; - case 7: - message.method = $root.google.cloud.tools.snippetgen.snippetindex.v1.Method.decode(reader, reader.uint32()); - break; + case 1: { + message.shortName = reader.string(); + break; + } + case 2: { + message.fullName = reader.string(); + break; + } + case 3: { + message.async = reader.bool(); + break; + } + case 4: { + if (!(message.parameters && message.parameters.length)) + message.parameters = []; + message.parameters.push($root.google.cloud.tools.snippetgen.snippetindex.v1.ClientMethod.Parameter.decode(reader, reader.uint32())); + break; + } + case 5: { + message.resultType = reader.string(); + break; + } + case 6: { + message.client = $root.google.cloud.tools.snippetgen.snippetindex.v1.ServiceClient.decode(reader, reader.uint32()); + break; + } + case 7: { + message.method = $root.google.cloud.tools.snippetgen.snippetindex.v1.Method.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -21254,6 +22820,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for ClientMethod + * @function getTypeUrl + * @memberof google.cloud.tools.snippetgen.snippetindex.v1.ClientMethod + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ClientMethod.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.tools.snippetgen.snippetindex.v1.ClientMethod"; + }; + ClientMethod.Parameter = (function() { /** @@ -21357,12 +22938,14 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.type = reader.string(); - break; - case 2: - message.name = reader.string(); - break; + case 1: { + message.type = reader.string(); + break; + } + case 2: { + message.name = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -21461,6 +23044,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Parameter + * @function getTypeUrl + * @memberof google.cloud.tools.snippetgen.snippetindex.v1.ClientMethod.Parameter + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Parameter.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.tools.snippetgen.snippetindex.v1.ClientMethod.Parameter"; + }; + return Parameter; })(); @@ -21570,12 +23168,14 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.shortName = reader.string(); - break; - case 2: - message.fullName = reader.string(); - break; + case 1: { + message.shortName = reader.string(); + break; + } + case 2: { + message.fullName = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -21674,6 +23274,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for ServiceClient + * @function getTypeUrl + * @memberof google.cloud.tools.snippetgen.snippetindex.v1.ServiceClient + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ServiceClient.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.tools.snippetgen.snippetindex.v1.ServiceClient"; + }; + return ServiceClient; })(); @@ -21804,20 +23419,24 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.name = reader.string(); - break; - case 2: - message.version = reader.string(); - break; - case 3: - message.language = reader.int32(); - break; - case 4: - if (!(message.apis && message.apis.length)) - message.apis = []; - message.apis.push($root.google.cloud.tools.snippetgen.snippetindex.v1.Api.decode(reader, reader.uint32())); - break; + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.version = reader.string(); + break; + } + case 3: { + message.language = reader.int32(); + break; + } + case 4: { + if (!(message.apis && message.apis.length)) + message.apis = []; + message.apis.push($root.google.cloud.tools.snippetgen.snippetindex.v1.Api.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -21912,6 +23531,12 @@ if (object.version != null) message.version = String(object.version); switch (object.language) { + default: + if (typeof object.language === "number") { + message.language = object.language; + break; + } + break; case "LANGUAGE_UNSPECIFIED": case 0: message.language = 0; @@ -22023,7 +23648,7 @@ if (message.version != null && message.hasOwnProperty("version")) object.version = message.version; if (message.language != null && message.hasOwnProperty("language")) - object.language = options.enums === String ? $root.google.cloud.tools.snippetgen.snippetindex.v1.Language[message.language] : message.language; + object.language = options.enums === String ? $root.google.cloud.tools.snippetgen.snippetindex.v1.Language[message.language] === undefined ? message.language : $root.google.cloud.tools.snippetgen.snippetindex.v1.Language[message.language] : message.language; if (message.apis && message.apis.length) { object.apis = []; for (var j = 0; j < message.apis.length; ++j) @@ -22043,6 +23668,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for ClientLibrary + * @function getTypeUrl + * @memberof google.cloud.tools.snippetgen.snippetindex.v1.ClientLibrary + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ClientLibrary.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.tools.snippetgen.snippetindex.v1.ClientLibrary"; + }; + return ClientLibrary; })(); @@ -22160,15 +23800,18 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.shortName = reader.string(); - break; - case 2: - message.fullName = reader.string(); - break; - case 3: - message.service = $root.google.cloud.tools.snippetgen.snippetindex.v1.Service.decode(reader, reader.uint32()); - break; + case 1: { + message.shortName = reader.string(); + break; + } + case 2: { + message.fullName = reader.string(); + break; + } + case 3: { + message.service = $root.google.cloud.tools.snippetgen.snippetindex.v1.Service.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -22280,6 +23923,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Method + * @function getTypeUrl + * @memberof google.cloud.tools.snippetgen.snippetindex.v1.Method + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Method.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.tools.snippetgen.snippetindex.v1.Method"; + }; + return Method; })(); @@ -22386,12 +24044,14 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.shortName = reader.string(); - break; - case 2: - message.fullName = reader.string(); - break; + case 1: { + message.shortName = reader.string(); + break; + } + case 2: { + message.fullName = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -22490,6 +24150,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Service + * @function getTypeUrl + * @memberof google.cloud.tools.snippetgen.snippetindex.v1.Service + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Service.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.tools.snippetgen.snippetindex.v1.Service"; + }; + return Service; })(); @@ -22596,12 +24271,14 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.id = reader.string(); - break; - case 2: - message.version = reader.string(); - break; + case 1: { + message.id = reader.string(); + break; + } + case 2: { + message.version = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -22700,6 +24377,21 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Gets the default type url for Api + * @function getTypeUrl + * @memberof google.cloud.tools.snippetgen.snippetindex.v1.Api + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Api.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.tools.snippetgen.snippetindex.v1.Api"; + }; + return Api; })(); diff --git a/protos/protos.json b/protos/protos.json new file mode 100644 index 000000000..77e265c03 --- /dev/null +++ b/protos/protos.json @@ -0,0 +1,2142 @@ +{ + "nested": { + "grpc": { + "nested": { + "service_config": { + "options": { + "java_package": "io.grpc.serviceconfig", + "java_multiple_files": true, + "java_outer_classname": "ServiceConfigProto" + }, + "nested": { + "MethodConfig": { + "oneofs": { + "retryOrHedgingPolicy": { + "oneof": [ + "retryPolicy", + "hedgingPolicy" + ] + } + }, + "fields": { + "name": { + "rule": "repeated", + "type": "Name", + "id": 1 + }, + "waitForReady": { + "type": "google.protobuf.BoolValue", + "id": 2 + }, + "timeout": { + "type": "google.protobuf.Duration", + "id": 3 + }, + "maxRequestMessageBytes": { + "type": "google.protobuf.UInt32Value", + "id": 4 + }, + "maxResponseMessageBytes": { + "type": "google.protobuf.UInt32Value", + "id": 5 + }, + "retryPolicy": { + "type": "RetryPolicy", + "id": 6 + }, + "hedgingPolicy": { + "type": "HedgingPolicy", + "id": 7 + } + }, + "nested": { + "Name": { + "fields": { + "service": { + "type": "string", + "id": 1 + }, + "method": { + "type": "string", + "id": 2 + } + } + }, + "RetryPolicy": { + "fields": { + "maxAttempts": { + "type": "uint32", + "id": 1 + }, + "initialBackoff": { + "type": "google.protobuf.Duration", + "id": 2 + }, + "maxBackoff": { + "type": "google.protobuf.Duration", + "id": 3 + }, + "backoffMultiplier": { + "type": "float", + "id": 4 + }, + "retryableStatusCodes": { + "rule": "repeated", + "type": "google.rpc.Code", + "id": 5 + } + } + }, + "HedgingPolicy": { + "fields": { + "maxAttempts": { + "type": "uint32", + "id": 1 + }, + "hedgingDelay": { + "type": "google.protobuf.Duration", + "id": 2 + }, + "nonFatalStatusCodes": { + "rule": "repeated", + "type": "google.rpc.Code", + "id": 3 + } + } + } + } + }, + "PickFirstConfig": { + "fields": {} + }, + "RoundRobinConfig": { + "fields": {} + }, + "GrpcLbConfig": { + "fields": { + "childPolicy": { + "rule": "repeated", + "type": "LoadBalancingConfig", + "id": 1 + } + } + }, + "XdsConfig": { + "fields": { + "balancerName": { + "type": "string", + "id": 1 + }, + "childPolicy": { + "rule": "repeated", + "type": "LoadBalancingConfig", + "id": 2 + }, + "fallbackPolicy": { + "rule": "repeated", + "type": "LoadBalancingConfig", + "id": 3 + } + } + }, + "LoadBalancingConfig": { + "oneofs": { + "policy": { + "oneof": [ + "pickFirst", + "roundRobin", + "grpclb", + "xds", + "xdsExperimental" + ] + } + }, + "fields": { + "pickFirst": { + "type": "PickFirstConfig", + "id": 4, + "options": { + "json_name": "pick_first" + } + }, + "roundRobin": { + "type": "RoundRobinConfig", + "id": 1, + "options": { + "json_name": "round_robin" + } + }, + "grpclb": { + "type": "GrpcLbConfig", + "id": 3 + }, + "xds": { + "type": "XdsConfig", + "id": 2 + }, + "xdsExperimental": { + "type": "XdsConfig", + "id": 5, + "options": { + "json_name": "xds_experimental" + } + } + } + }, + "ServiceConfig": { + "fields": { + "loadBalancingPolicy": { + "type": "LoadBalancingPolicy", + "id": 1, + "options": { + "deprecated": true + } + }, + "loadBalancingConfig": { + "rule": "repeated", + "type": "LoadBalancingConfig", + "id": 4 + }, + "methodConfig": { + "rule": "repeated", + "type": "MethodConfig", + "id": 2 + }, + "retryThrottling": { + "type": "RetryThrottlingPolicy", + "id": 3 + }, + "healthCheckConfig": { + "type": "HealthCheckConfig", + "id": 5 + } + }, + "nested": { + "LoadBalancingPolicy": { + "values": { + "UNSPECIFIED": 0, + "ROUND_ROBIN": 1 + } + }, + "RetryThrottlingPolicy": { + "fields": { + "maxTokens": { + "type": "uint32", + "id": 1 + }, + "tokenRatio": { + "type": "float", + "id": 2 + } + } + }, + "HealthCheckConfig": { + "fields": { + "serviceName": { + "type": "google.protobuf.StringValue", + "id": 1 + } + } + } + } + } + } + } + } + }, + "google": { + "nested": { + "api": { + "options": { + "go_package": "google.golang.org/genproto/googleapis/api/annotations;annotations", + "java_multiple_files": true, + "java_outer_classname": "ClientProto", + "java_package": "com.google.api", + "objc_class_prefix": "GAPI", + "cc_enable_arenas": true + }, + "nested": { + "http": { + "type": "HttpRule", + "id": 72295728, + "extend": "google.protobuf.MethodOptions" + }, + "Http": { + "fields": { + "rules": { + "rule": "repeated", + "type": "HttpRule", + "id": 1 + }, + "fullyDecodeReservedExpansion": { + "type": "bool", + "id": 2 + } + } + }, + "HttpRule": { + "oneofs": { + "pattern": { + "oneof": [ + "get", + "put", + "post", + "delete", + "patch", + "custom" + ] + } + }, + "fields": { + "selector": { + "type": "string", + "id": 1 + }, + "get": { + "type": "string", + "id": 2 + }, + "put": { + "type": "string", + "id": 3 + }, + "post": { + "type": "string", + "id": 4 + }, + "delete": { + "type": "string", + "id": 5 + }, + "patch": { + "type": "string", + "id": 6 + }, + "custom": { + "type": "CustomHttpPattern", + "id": 8 + }, + "body": { + "type": "string", + "id": 7 + }, + "responseBody": { + "type": "string", + "id": 12 + }, + "additionalBindings": { + "rule": "repeated", + "type": "HttpRule", + "id": 11 + } + } + }, + "CustomHttpPattern": { + "fields": { + "kind": { + "type": "string", + "id": 1 + }, + "path": { + "type": "string", + "id": 2 + } + } + }, + "fieldBehavior": { + "rule": "repeated", + "type": "google.api.FieldBehavior", + "id": 1052, + "extend": "google.protobuf.FieldOptions" + }, + "FieldBehavior": { + "values": { + "FIELD_BEHAVIOR_UNSPECIFIED": 0, + "OPTIONAL": 1, + "REQUIRED": 2, + "OUTPUT_ONLY": 3, + "INPUT_ONLY": 4, + "IMMUTABLE": 5, + "UNORDERED_LIST": 6, + "NON_EMPTY_DEFAULT": 7 + } + }, + "resourceReference": { + "type": "google.api.ResourceReference", + "id": 1055, + "extend": "google.protobuf.FieldOptions" + }, + "resourceDefinition": { + "rule": "repeated", + "type": "google.api.ResourceDescriptor", + "id": 1053, + "extend": "google.protobuf.FileOptions" + }, + "resource": { + "type": "google.api.ResourceDescriptor", + "id": 1053, + "extend": "google.protobuf.MessageOptions" + }, + "ResourceDescriptor": { + "fields": { + "type": { + "type": "string", + "id": 1 + }, + "pattern": { + "rule": "repeated", + "type": "string", + "id": 2 + }, + "nameField": { + "type": "string", + "id": 3 + }, + "history": { + "type": "History", + "id": 4 + }, + "plural": { + "type": "string", + "id": 5 + }, + "singular": { + "type": "string", + "id": 6 + }, + "style": { + "rule": "repeated", + "type": "Style", + "id": 10 + } + }, + "nested": { + "History": { + "values": { + "HISTORY_UNSPECIFIED": 0, + "ORIGINALLY_SINGLE_PATTERN": 1, + "FUTURE_MULTI_PATTERN": 2 + } + }, + "Style": { + "values": { + "STYLE_UNSPECIFIED": 0, + "DECLARATIVE_FRIENDLY": 1 + } + } + } + }, + "ResourceReference": { + "fields": { + "type": { + "type": "string", + "id": 1 + }, + "childType": { + "type": "string", + "id": 2 + } + } + }, + "routing": { + "type": "google.api.RoutingRule", + "id": 72295729, + "extend": "google.protobuf.MethodOptions" + }, + "RoutingRule": { + "fields": { + "routingParameters": { + "rule": "repeated", + "type": "RoutingParameter", + "id": 2 + } + } + }, + "RoutingParameter": { + "fields": { + "field": { + "type": "string", + "id": 1 + }, + "pathTemplate": { + "type": "string", + "id": 2 + } + } + }, + "methodSignature": { + "rule": "repeated", + "type": "string", + "id": 1051, + "extend": "google.protobuf.MethodOptions" + }, + "defaultHost": { + "type": "string", + "id": 1049, + "extend": "google.protobuf.ServiceOptions" + }, + "oauthScopes": { + "type": "string", + "id": 1050, + "extend": "google.protobuf.ServiceOptions" + } + } + }, + "protobuf": { + "options": { + "go_package": "google.golang.org/protobuf/types/descriptorpb", + "java_package": "com.google.protobuf", + "java_outer_classname": "DescriptorProtos", + "csharp_namespace": "Google.Protobuf.Reflection", + "objc_class_prefix": "GPB", + "cc_enable_arenas": true, + "optimize_for": "SPEED" + }, + "nested": { + "FileDescriptorSet": { + "fields": { + "file": { + "rule": "repeated", + "type": "FileDescriptorProto", + "id": 1 + } + } + }, + "FileDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "package": { + "type": "string", + "id": 2 + }, + "dependency": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "publicDependency": { + "rule": "repeated", + "type": "int32", + "id": 10, + "options": { + "packed": false + } + }, + "weakDependency": { + "rule": "repeated", + "type": "int32", + "id": 11, + "options": { + "packed": false + } + }, + "messageType": { + "rule": "repeated", + "type": "DescriptorProto", + "id": 4 + }, + "enumType": { + "rule": "repeated", + "type": "EnumDescriptorProto", + "id": 5 + }, + "service": { + "rule": "repeated", + "type": "ServiceDescriptorProto", + "id": 6 + }, + "extension": { + "rule": "repeated", + "type": "FieldDescriptorProto", + "id": 7 + }, + "options": { + "type": "FileOptions", + "id": 8 + }, + "sourceCodeInfo": { + "type": "SourceCodeInfo", + "id": 9 + }, + "syntax": { + "type": "string", + "id": 12 + }, + "edition": { + "type": "string", + "id": 13 + } + } + }, + "DescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "field": { + "rule": "repeated", + "type": "FieldDescriptorProto", + "id": 2 + }, + "extension": { + "rule": "repeated", + "type": "FieldDescriptorProto", + "id": 6 + }, + "nestedType": { + "rule": "repeated", + "type": "DescriptorProto", + "id": 3 + }, + "enumType": { + "rule": "repeated", + "type": "EnumDescriptorProto", + "id": 4 + }, + "extensionRange": { + "rule": "repeated", + "type": "ExtensionRange", + "id": 5 + }, + "oneofDecl": { + "rule": "repeated", + "type": "OneofDescriptorProto", + "id": 8 + }, + "options": { + "type": "MessageOptions", + "id": 7 + }, + "reservedRange": { + "rule": "repeated", + "type": "ReservedRange", + "id": 9 + }, + "reservedName": { + "rule": "repeated", + "type": "string", + "id": 10 + } + }, + "nested": { + "ExtensionRange": { + "fields": { + "start": { + "type": "int32", + "id": 1 + }, + "end": { + "type": "int32", + "id": 2 + }, + "options": { + "type": "ExtensionRangeOptions", + "id": 3 + } + } + }, + "ReservedRange": { + "fields": { + "start": { + "type": "int32", + "id": 1 + }, + "end": { + "type": "int32", + "id": 2 + } + } + } + } + }, + "ExtensionRangeOptions": { + "fields": { + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ] + }, + "FieldDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "number": { + "type": "int32", + "id": 3 + }, + "label": { + "type": "Label", + "id": 4 + }, + "type": { + "type": "Type", + "id": 5 + }, + "typeName": { + "type": "string", + "id": 6 + }, + "extendee": { + "type": "string", + "id": 2 + }, + "defaultValue": { + "type": "string", + "id": 7 + }, + "oneofIndex": { + "type": "int32", + "id": 9 + }, + "jsonName": { + "type": "string", + "id": 10 + }, + "options": { + "type": "FieldOptions", + "id": 8 + }, + "proto3Optional": { + "type": "bool", + "id": 17 + } + }, + "nested": { + "Type": { + "values": { + "TYPE_DOUBLE": 1, + "TYPE_FLOAT": 2, + "TYPE_INT64": 3, + "TYPE_UINT64": 4, + "TYPE_INT32": 5, + "TYPE_FIXED64": 6, + "TYPE_FIXED32": 7, + "TYPE_BOOL": 8, + "TYPE_STRING": 9, + "TYPE_GROUP": 10, + "TYPE_MESSAGE": 11, + "TYPE_BYTES": 12, + "TYPE_UINT32": 13, + "TYPE_ENUM": 14, + "TYPE_SFIXED32": 15, + "TYPE_SFIXED64": 16, + "TYPE_SINT32": 17, + "TYPE_SINT64": 18 + } + }, + "Label": { + "values": { + "LABEL_OPTIONAL": 1, + "LABEL_REQUIRED": 2, + "LABEL_REPEATED": 3 + } + } + } + }, + "OneofDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "options": { + "type": "OneofOptions", + "id": 2 + } + } + }, + "EnumDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "value": { + "rule": "repeated", + "type": "EnumValueDescriptorProto", + "id": 2 + }, + "options": { + "type": "EnumOptions", + "id": 3 + }, + "reservedRange": { + "rule": "repeated", + "type": "EnumReservedRange", + "id": 4 + }, + "reservedName": { + "rule": "repeated", + "type": "string", + "id": 5 + } + }, + "nested": { + "EnumReservedRange": { + "fields": { + "start": { + "type": "int32", + "id": 1 + }, + "end": { + "type": "int32", + "id": 2 + } + } + } + } + }, + "EnumValueDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "number": { + "type": "int32", + "id": 2 + }, + "options": { + "type": "EnumValueOptions", + "id": 3 + } + } + }, + "ServiceDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "method": { + "rule": "repeated", + "type": "MethodDescriptorProto", + "id": 2 + }, + "options": { + "type": "ServiceOptions", + "id": 3 + } + } + }, + "MethodDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "inputType": { + "type": "string", + "id": 2 + }, + "outputType": { + "type": "string", + "id": 3 + }, + "options": { + "type": "MethodOptions", + "id": 4 + }, + "clientStreaming": { + "type": "bool", + "id": 5, + "options": { + "default": false + } + }, + "serverStreaming": { + "type": "bool", + "id": 6, + "options": { + "default": false + } + } + } + }, + "FileOptions": { + "fields": { + "javaPackage": { + "type": "string", + "id": 1 + }, + "javaOuterClassname": { + "type": "string", + "id": 8 + }, + "javaMultipleFiles": { + "type": "bool", + "id": 10, + "options": { + "default": false + } + }, + "javaGenerateEqualsAndHash": { + "type": "bool", + "id": 20, + "options": { + "deprecated": true + } + }, + "javaStringCheckUtf8": { + "type": "bool", + "id": 27, + "options": { + "default": false + } + }, + "optimizeFor": { + "type": "OptimizeMode", + "id": 9, + "options": { + "default": "SPEED" + } + }, + "goPackage": { + "type": "string", + "id": 11 + }, + "ccGenericServices": { + "type": "bool", + "id": 16, + "options": { + "default": false + } + }, + "javaGenericServices": { + "type": "bool", + "id": 17, + "options": { + "default": false + } + }, + "pyGenericServices": { + "type": "bool", + "id": 18, + "options": { + "default": false + } + }, + "phpGenericServices": { + "type": "bool", + "id": 42, + "options": { + "default": false + } + }, + "deprecated": { + "type": "bool", + "id": 23, + "options": { + "default": false + } + }, + "ccEnableArenas": { + "type": "bool", + "id": 31, + "options": { + "default": true + } + }, + "objcClassPrefix": { + "type": "string", + "id": 36 + }, + "csharpNamespace": { + "type": "string", + "id": 37 + }, + "swiftPrefix": { + "type": "string", + "id": 39 + }, + "phpClassPrefix": { + "type": "string", + "id": 40 + }, + "phpNamespace": { + "type": "string", + "id": 41 + }, + "phpMetadataNamespace": { + "type": "string", + "id": 44 + }, + "rubyPackage": { + "type": "string", + "id": 45 + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ], + "reserved": [ + [ + 38, + 38 + ] + ], + "nested": { + "OptimizeMode": { + "values": { + "SPEED": 1, + "CODE_SIZE": 2, + "LITE_RUNTIME": 3 + } + } + } + }, + "MessageOptions": { + "fields": { + "messageSetWireFormat": { + "type": "bool", + "id": 1, + "options": { + "default": false + } + }, + "noStandardDescriptorAccessor": { + "type": "bool", + "id": 2, + "options": { + "default": false + } + }, + "deprecated": { + "type": "bool", + "id": 3, + "options": { + "default": false + } + }, + "mapEntry": { + "type": "bool", + "id": 7 + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ], + "reserved": [ + [ + 4, + 4 + ], + [ + 5, + 5 + ], + [ + 6, + 6 + ], + [ + 8, + 8 + ], + [ + 9, + 9 + ] + ] + }, + "FieldOptions": { + "fields": { + "ctype": { + "type": "CType", + "id": 1, + "options": { + "default": "STRING" + } + }, + "packed": { + "type": "bool", + "id": 2 + }, + "jstype": { + "type": "JSType", + "id": 6, + "options": { + "default": "JS_NORMAL" + } + }, + "lazy": { + "type": "bool", + "id": 5, + "options": { + "default": false + } + }, + "unverifiedLazy": { + "type": "bool", + "id": 15, + "options": { + "default": false + } + }, + "deprecated": { + "type": "bool", + "id": 3, + "options": { + "default": false + } + }, + "weak": { + "type": "bool", + "id": 10, + "options": { + "default": false + } + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ], + "reserved": [ + [ + 4, + 4 + ] + ], + "nested": { + "CType": { + "values": { + "STRING": 0, + "CORD": 1, + "STRING_PIECE": 2 + } + }, + "JSType": { + "values": { + "JS_NORMAL": 0, + "JS_STRING": 1, + "JS_NUMBER": 2 + } + } + } + }, + "OneofOptions": { + "fields": { + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ] + }, + "EnumOptions": { + "fields": { + "allowAlias": { + "type": "bool", + "id": 2 + }, + "deprecated": { + "type": "bool", + "id": 3, + "options": { + "default": false + } + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ], + "reserved": [ + [ + 5, + 5 + ] + ] + }, + "EnumValueOptions": { + "fields": { + "deprecated": { + "type": "bool", + "id": 1, + "options": { + "default": false + } + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ] + }, + "ServiceOptions": { + "fields": { + "deprecated": { + "type": "bool", + "id": 33, + "options": { + "default": false + } + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ] + }, + "MethodOptions": { + "fields": { + "deprecated": { + "type": "bool", + "id": 33, + "options": { + "default": false + } + }, + "idempotencyLevel": { + "type": "IdempotencyLevel", + "id": 34, + "options": { + "default": "IDEMPOTENCY_UNKNOWN" + } + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ], + "nested": { + "IdempotencyLevel": { + "values": { + "IDEMPOTENCY_UNKNOWN": 0, + "NO_SIDE_EFFECTS": 1, + "IDEMPOTENT": 2 + } + } + } + }, + "UninterpretedOption": { + "fields": { + "name": { + "rule": "repeated", + "type": "NamePart", + "id": 2 + }, + "identifierValue": { + "type": "string", + "id": 3 + }, + "positiveIntValue": { + "type": "uint64", + "id": 4 + }, + "negativeIntValue": { + "type": "int64", + "id": 5 + }, + "doubleValue": { + "type": "double", + "id": 6 + }, + "stringValue": { + "type": "bytes", + "id": 7 + }, + "aggregateValue": { + "type": "string", + "id": 8 + } + }, + "nested": { + "NamePart": { + "fields": { + "namePart": { + "rule": "required", + "type": "string", + "id": 1 + }, + "isExtension": { + "rule": "required", + "type": "bool", + "id": 2 + } + } + } + } + }, + "SourceCodeInfo": { + "fields": { + "location": { + "rule": "repeated", + "type": "Location", + "id": 1 + } + }, + "nested": { + "Location": { + "fields": { + "path": { + "rule": "repeated", + "type": "int32", + "id": 1 + }, + "span": { + "rule": "repeated", + "type": "int32", + "id": 2 + }, + "leadingComments": { + "type": "string", + "id": 3 + }, + "trailingComments": { + "type": "string", + "id": 4 + }, + "leadingDetachedComments": { + "rule": "repeated", + "type": "string", + "id": 6 + } + } + } + } + }, + "GeneratedCodeInfo": { + "fields": { + "annotation": { + "rule": "repeated", + "type": "Annotation", + "id": 1 + } + }, + "nested": { + "Annotation": { + "fields": { + "path": { + "rule": "repeated", + "type": "int32", + "id": 1 + }, + "sourceFile": { + "type": "string", + "id": 2 + }, + "begin": { + "type": "int32", + "id": 3 + }, + "end": { + "type": "int32", + "id": 4 + }, + "semantic": { + "type": "Semantic", + "id": 5 + } + }, + "nested": { + "Semantic": { + "values": { + "NONE": 0, + "SET": 1, + "ALIAS": 2 + } + } + } + } + } + }, + "Any": { + "fields": { + "type_url": { + "type": "string", + "id": 1 + }, + "value": { + "type": "bytes", + "id": 2 + } + } + }, + "Duration": { + "fields": { + "seconds": { + "type": "int64", + "id": 1 + }, + "nanos": { + "type": "int32", + "id": 2 + } + } + }, + "Empty": { + "fields": {} + }, + "compiler": { + "options": { + "java_package": "com.google.protobuf.compiler", + "java_outer_classname": "PluginProtos", + "go_package": "google.golang.org/protobuf/types/pluginpb" + }, + "nested": { + "Version": { + "fields": { + "major": { + "type": "int32", + "id": 1 + }, + "minor": { + "type": "int32", + "id": 2 + }, + "patch": { + "type": "int32", + "id": 3 + }, + "suffix": { + "type": "string", + "id": 4 + } + } + }, + "CodeGeneratorRequest": { + "fields": { + "fileToGenerate": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "parameter": { + "type": "string", + "id": 2 + }, + "protoFile": { + "rule": "repeated", + "type": "FileDescriptorProto", + "id": 15 + }, + "compilerVersion": { + "type": "Version", + "id": 3 + } + } + }, + "CodeGeneratorResponse": { + "fields": { + "error": { + "type": "string", + "id": 1 + }, + "supportedFeatures": { + "type": "uint64", + "id": 2 + }, + "file": { + "rule": "repeated", + "type": "File", + "id": 15 + } + }, + "nested": { + "Feature": { + "values": { + "FEATURE_NONE": 0, + "FEATURE_PROTO3_OPTIONAL": 1 + } + }, + "File": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "insertionPoint": { + "type": "string", + "id": 2 + }, + "content": { + "type": "string", + "id": 15 + }, + "generatedCodeInfo": { + "type": "GeneratedCodeInfo", + "id": 16 + } + } + } + } + } + } + }, + "DoubleValue": { + "fields": { + "value": { + "type": "double", + "id": 1 + } + } + }, + "FloatValue": { + "fields": { + "value": { + "type": "float", + "id": 1 + } + } + }, + "Int64Value": { + "fields": { + "value": { + "type": "int64", + "id": 1 + } + } + }, + "UInt64Value": { + "fields": { + "value": { + "type": "uint64", + "id": 1 + } + } + }, + "Int32Value": { + "fields": { + "value": { + "type": "int32", + "id": 1 + } + } + }, + "UInt32Value": { + "fields": { + "value": { + "type": "uint32", + "id": 1 + } + } + }, + "BoolValue": { + "fields": { + "value": { + "type": "bool", + "id": 1 + } + } + }, + "StringValue": { + "fields": { + "value": { + "type": "string", + "id": 1 + } + } + }, + "BytesValue": { + "fields": { + "value": { + "type": "bytes", + "id": 1 + } + } + } + } + }, + "longrunning": { + "options": { + "cc_enable_arenas": true, + "csharp_namespace": "Google.LongRunning", + "go_package": "google.golang.org/genproto/googleapis/longrunning;longrunning", + "java_multiple_files": true, + "java_outer_classname": "OperationsProto", + "java_package": "com.google.longrunning", + "php_namespace": "Google\\LongRunning" + }, + "nested": { + "operationInfo": { + "type": "google.longrunning.OperationInfo", + "id": 1049, + "extend": "google.protobuf.MethodOptions" + }, + "Operations": { + "options": { + "(google.api.default_host)": "longrunning.googleapis.com" + }, + "methods": { + "ListOperations": { + "requestType": "ListOperationsRequest", + "responseType": "ListOperationsResponse", + "options": { + "(google.api.http).get": "/v1/{name=operations}", + "(google.api.method_signature)": "name,filter" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/{name=operations}" + } + }, + { + "(google.api.method_signature)": "name,filter" + } + ] + }, + "GetOperation": { + "requestType": "GetOperationRequest", + "responseType": "Operation", + "options": { + "(google.api.http).get": "/v1/{name=operations/**}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/{name=operations/**}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "DeleteOperation": { + "requestType": "DeleteOperationRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v1/{name=operations/**}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v1/{name=operations/**}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "CancelOperation": { + "requestType": "CancelOperationRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).post": "/v1/{name=operations/**}:cancel", + "(google.api.http).body": "*", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{name=operations/**}:cancel", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "WaitOperation": { + "requestType": "WaitOperationRequest", + "responseType": "Operation" + } + } + }, + "Operation": { + "oneofs": { + "result": { + "oneof": [ + "error", + "response" + ] + } + }, + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "metadata": { + "type": "google.protobuf.Any", + "id": 2 + }, + "done": { + "type": "bool", + "id": 3 + }, + "error": { + "type": "google.rpc.Status", + "id": 4 + }, + "response": { + "type": "google.protobuf.Any", + "id": 5 + } + } + }, + "GetOperationRequest": { + "fields": { + "name": { + "type": "string", + "id": 1 + } + } + }, + "ListOperationsRequest": { + "fields": { + "name": { + "type": "string", + "id": 4 + }, + "filter": { + "type": "string", + "id": 1 + }, + "pageSize": { + "type": "int32", + "id": 2 + }, + "pageToken": { + "type": "string", + "id": 3 + } + } + }, + "ListOperationsResponse": { + "fields": { + "operations": { + "rule": "repeated", + "type": "Operation", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "CancelOperationRequest": { + "fields": { + "name": { + "type": "string", + "id": 1 + } + } + }, + "DeleteOperationRequest": { + "fields": { + "name": { + "type": "string", + "id": 1 + } + } + }, + "WaitOperationRequest": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "timeout": { + "type": "google.protobuf.Duration", + "id": 2 + } + } + }, + "OperationInfo": { + "fields": { + "responseType": { + "type": "string", + "id": 1 + }, + "metadataType": { + "type": "string", + "id": 2 + } + } + } + } + }, + "rpc": { + "options": { + "cc_enable_arenas": true, + "go_package": "google.golang.org/genproto/googleapis/rpc/code;code", + "java_multiple_files": true, + "java_outer_classname": "CodeProto", + "java_package": "com.google.rpc", + "objc_class_prefix": "RPC" + }, + "nested": { + "Status": { + "fields": { + "code": { + "type": "int32", + "id": 1 + }, + "message": { + "type": "string", + "id": 2 + }, + "details": { + "rule": "repeated", + "type": "google.protobuf.Any", + "id": 3 + } + } + }, + "Code": { + "values": { + "OK": 0, + "CANCELLED": 1, + "UNKNOWN": 2, + "INVALID_ARGUMENT": 3, + "DEADLINE_EXCEEDED": 4, + "NOT_FOUND": 5, + "ALREADY_EXISTS": 6, + "PERMISSION_DENIED": 7, + "UNAUTHENTICATED": 16, + "RESOURCE_EXHAUSTED": 8, + "FAILED_PRECONDITION": 9, + "ABORTED": 10, + "OUT_OF_RANGE": 11, + "UNIMPLEMENTED": 12, + "INTERNAL": 13, + "UNAVAILABLE": 14, + "DATA_LOSS": 15 + } + } + } + }, + "cloud": { + "nested": { + "tools": { + "nested": { + "snippetgen": { + "nested": { + "snippetindex": { + "nested": { + "v1": { + "options": { + "csharp_namespace": "Google.Cloud.Tools.SnippetGen.SnippetIndex.V1", + "php_namespace": "Google\\Cloud\\Tools\\SnippetGen\\SnippetIndex\\V1", + "ruby_package": "Google::Cloud::Tools::SnippetGen::SnippetIndex::V1" + }, + "nested": { + "Index": { + "fields": { + "clientLibrary": { + "type": "ClientLibrary", + "id": 1 + }, + "snippets": { + "rule": "repeated", + "type": "Snippet", + "id": 2 + } + } + }, + "Snippet": { + "fields": { + "regionTag": { + "type": "string", + "id": 1 + }, + "title": { + "type": "string", + "id": 2 + }, + "description": { + "type": "string", + "id": 3 + }, + "file": { + "type": "string", + "id": 4 + }, + "language": { + "type": "Language", + "id": 5 + }, + "clientMethod": { + "type": "ClientMethod", + "id": 6 + }, + "canonical": { + "type": "bool", + "id": 7 + }, + "origin": { + "type": "Origin", + "id": 8 + }, + "segments": { + "rule": "repeated", + "type": "Segment", + "id": 9 + } + }, + "nested": { + "Origin": { + "values": { + "ORIGIN_UNSPECIFIED": 0, + "API_DEFINITION": 1, + "CONFIG": 2, + "HANDWRITTEN": 3 + } + }, + "Segment": { + "fields": { + "start": { + "type": "int32", + "id": 1 + }, + "end": { + "type": "int32", + "id": 2 + }, + "type": { + "type": "SegmentType", + "id": 3 + } + }, + "nested": { + "SegmentType": { + "values": { + "SEGMENT_TYPE_UNSPECIFIED": 0, + "FULL": 1, + "SHORT": 2, + "CLIENT_INITIALIZATION": 3, + "REQUEST_INITIALIZATION": 4, + "REQUEST_EXECUTION": 5, + "RESPONSE_HANDLING": 6 + } + } + } + } + } + }, + "ClientMethod": { + "fields": { + "shortName": { + "type": "string", + "id": 1 + }, + "fullName": { + "type": "string", + "id": 2 + }, + "async": { + "type": "bool", + "id": 3 + }, + "parameters": { + "rule": "repeated", + "type": "Parameter", + "id": 4 + }, + "resultType": { + "type": "string", + "id": 5 + }, + "client": { + "type": "ServiceClient", + "id": 6 + }, + "method": { + "type": "Method", + "id": 7 + } + }, + "nested": { + "Parameter": { + "fields": { + "type": { + "type": "string", + "id": 1 + }, + "name": { + "type": "string", + "id": 2 + } + } + } + } + }, + "ServiceClient": { + "fields": { + "shortName": { + "type": "string", + "id": 1 + }, + "fullName": { + "type": "string", + "id": 2 + } + } + }, + "ClientLibrary": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "version": { + "type": "string", + "id": 2 + }, + "language": { + "type": "Language", + "id": 3 + }, + "apis": { + "rule": "repeated", + "type": "Api", + "id": 4 + } + } + }, + "Method": { + "fields": { + "shortName": { + "type": "string", + "id": 1 + }, + "fullName": { + "type": "string", + "id": 2 + }, + "service": { + "type": "Service", + "id": 3 + } + } + }, + "Service": { + "fields": { + "shortName": { + "type": "string", + "id": 1 + }, + "fullName": { + "type": "string", + "id": 2 + } + } + }, + "Api": { + "fields": { + "id": { + "type": "string", + "id": 1 + }, + "version": { + "type": "string", + "id": 2 + } + } + }, + "Language": { + "values": { + "LANGUAGE_UNSPECIFIED": 0, + "C_PLUS_PLUS": 1, + "C_SHARP": 2, + "DART": 3, + "ELIXIR": 4, + "ERLANG": 5, + "F_SHARP": 6, + "GO": 7, + "JAVA": 8, + "JAVASCRIPT": 9, + "KOTLIN": 10, + "PHP": 11, + "PYTHON": 12, + "RUBY": 13, + "RUST": 14, + "SWIFT": 15, + "TYPESCRIPT": 16, + "VB_NET": 17 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/templates/typescript_gapic_metadata/package.json b/templates/typescript_gapic_metadata/package.json new file mode 100644 index 000000000..c29c3b02f --- /dev/null +++ b/templates/typescript_gapic_metadata/package.json @@ -0,0 +1,3 @@ +{ + "_comment": "This fake package.json is not a part of the template, but it allows the templater import namer.js in the ESM context." +} diff --git a/templates/typescript_samples/package.json b/templates/typescript_samples/package.json new file mode 100644 index 000000000..c29c3b02f --- /dev/null +++ b/templates/typescript_samples/package.json @@ -0,0 +1,3 @@ +{ + "_comment": "This fake package.json is not a part of the template, but it allows the templater import namer.js in the ESM context." +} diff --git a/templates/typescript_samples/samples/generated/$version/_util.njk b/templates/typescript_samples/samples/generated/$version/_util.njk index 83498121b..605ac7622 100644 --- a/templates/typescript_samples/samples/generated/$version/_util.njk +++ b/templates/typescript_samples/samples/generated/$version/_util.njk @@ -23,9 +23,9 @@ * {{ formattedLine -}} {% else %} {%- if regExpFindCase3.test(formattedLine) %} - * {{ formattedLine.replaceAll(r/\]\[/, " ").replaceAll(r/\[/, "").replaceAll(r/\]/, "") | safe -}} + * {{ formattedLine.replaceAll(r/\]\[/g, " ").replaceAll(r/\[/g, "").replaceAll(r/\]/g, "") | safe -}} {% else %} - * {{ formattedLine.replaceAll(r/\[/, "").replaceAll(r/\]/, " ") | safe -}} + * {{ formattedLine.replaceAll(r/\[/g, "").replaceAll(r/\]/g, " ") | safe -}} {%- endif %} {%- endif %} {%- else %} diff --git a/tsconfig.json b/tsconfig.json index e41d23413..4481dbca8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,22 +1,24 @@ { "compilerOptions": { + "allowSyntheticDefaultImports": true, "allowUnreachableCode": false, "allowUnusedLabels": false, "declaration": true, "forceConsistentCasingInFileNames": true, - "lib": ["es2018", "dom"], - "module": "commonjs", + "lib": ["ESNext", "dom"], + "module": "NodeNext", "noEmitOnError": true, "noFallthroughCasesInSwitch": true, "noImplicitReturns": true, "pretty": true, "sourceMap": true, "strict": true, - "target": "es2018", + "target": "ESNext", "rootDir": ".", "outDir": "build", "baseUrl": ".", - "allowJs": true + "allowJs": true, + "resolveJsonModule": true, }, "include": [ "typescript/**/*.ts", diff --git a/typescript/src/bundle.ts b/typescript/src/bundle.ts index 2445f09f1..6b061507b 100644 --- a/typescript/src/bundle.ts +++ b/typescript/src/bundle.ts @@ -18,11 +18,13 @@ export interface Thresholds { delay_threshold_millis: number; element_count_limit?: number; } + export interface BatchDescriptor { batched_field: string; discriminator_fields: string[]; subresponse_field: string; } + export interface BundleConfig { serviceName: string; methodName: string; diff --git a/typescript/src/gapic-generator-typescript.ts b/typescript/src/gapic-generator-typescript.ts index eb0c08a99..b7637bfba 100755 --- a/typescript/src/gapic-generator-typescript.ts +++ b/typescript/src/gapic-generator-typescript.ts @@ -14,247 +14,246 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {execFileSync} from 'child_process'; +import {execFile} from 'child_process'; +import {createRequire} from 'module'; import * as path from 'path'; -import * as yargs from 'yargs'; -import * as fs from 'fs-extra'; +import yargs from 'yargs'; +import * as fs from 'fs'; +import * as fsp from 'fs/promises'; +import * as url from 'url'; +import {promisify} from 'util'; +import {copy} from './util.js'; -const googleGaxPath = path.dirname(require.resolve('google-gax')); // ...../google-gax/build/src -const googleGaxProtosDir = path.join( - googleGaxPath, - '..', - '..', - 'build', - 'protos' -); -const allTemplates = fs.readdirSync( - path.join(__dirname, '..', '..', 'templates') -); +const execFileAsync = promisify(execFile); -// If we're built with bazel, we'll have a shell wrapper to be used as a protoc plugin. -// Just in case if someone builds us without bazel, let's have a fallback to an actual -// JS protoc plugin without a wrapper. -const protocPluginBash = path.join(__dirname, '..', 'protoc_plugin.sh'); -const protocPlugin = fs.existsSync(protocPluginBash) - ? protocPluginBash - : path.join(__dirname, 'protoc-plugin.js'); +// https://blog.logrocket.com/alternatives-dirname-node-js-es-modules/#help-im-missing-dirname +const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); -yargs.array('I'); -yargs.nargs('I', 1); -yargs.alias('proto_path', 'I'); -yargs.alias('proto-path', 'I'); -yargs.demandOption('output_dir'); -yargs.describe('I', 'Include directory to pass to protoc'); -yargs.alias('output-dir', 'output_dir'); -yargs.describe( - 'gapic-validator_out', - 'Path to the output of the gapic validator' -); -yargs.alias('gapic-validator_out', 'gapic_validator_out'); -yargs.describe( - 'validation', - 'Option to set the validation of proto files, default value is true' -); -yargs.describe('output_dir', 'Path to a directory for the generated code'); -yargs.alias('grpc-service-config', 'grpc_service_config'); -yargs.describe('grpc-service-config', 'Path to gRPC service config JSON'); -yargs.alias('bundle-config', 'bundle_config'); -yargs.describe('bundle-config', 'Path to bundle request config JSON'); -yargs.alias('service-yaml', 'service_yaml'); -yargs.describe('service-yaml', 'Path to service yaml'); -yargs.alias('package-name', 'package_name'); -yargs.describe('package-name', 'Publish package name'); -yargs.alias('main-service', 'main_service'); -yargs.describe( - 'main_service', - 'Main service name (if the package has multiple services, this one will be used for Webpack bundle name)' -); -yargs.alias('common-proto-path', 'common_protos_path'); -yargs.describe( - 'common_proto_path', - 'Path to API common protos to use (if unset, will use protos shipped with google-gax)' -); -yargs.describe( - 'template', - `Semicolon-separated list of templates to use. Allowed values: "${allTemplates.join( - ';' - )}"` -); -yargs.describe( - 'metadata', - 'Set to true if GAPIC metadata generation is requested' -); -yargs.boolean('metadata'); -yargs.describe( - 'transport', - 'Default transport is gRPC. Set transport=rest for gRPC or non-gRPC API requires REST transport with http annotation in proto3 files.' -); -yargs.describe( - 'diregapic', - 'DIREGAPIC represents Discovery Rest GAPICs. Set to true for GCE API or non-gRPC APIs with a Discovery doc description.' -); -yargs.describe( - 'handwritten_layer', - 'Set to true if the library has a handwritten layer over GAPIC layer.' -); -yargs.describe( - 'legacy_proto_load', - 'Load protos from *.proto directly at runtime, without compiling a proto JSON file. May speed up loading huge proto trees. Disables all fallback modes.' -); -yargs.boolean('legacy-proto-load'); -yargs.alias('legacy-proto-load', 'legacy_proto_load'); -yargs.describe( - 'rest_numeric_enums', - 'The generated library will pass and accept enum values as numbers when using the HTTP/1.1 REST transport.' -); -yargs.boolean('rest-numeric-enums'); -yargs.alias('rest-numeric-enums', 'rest_numeric_enums'); -yargs.describe( - 'mixins', - 'Override the list of mixins to use. Semicolon-separated list of API names to mixin, e.g. google.longrunning.Operations. Use "none" to disable all mixins.' -); -yargs.string('mixins'); -yargs.describe('protoc', 'Path to protoc binary'); -yargs.usage('Usage: $0 -I /path/to/googleapis'); -yargs.usage(' --output_dir /path/to/output_directory'); -yargs.usage(' google/example/api/v1/api.proto'); +async function main(processArgv: string[]) { + // https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules + const require = createRequire(import.meta.url); + const googleGaxPath = path.dirname( + require.resolve('google-gax/build/src/index.js') + ); // ...../google-gax/build/src -export interface IArguments { - [x: string]: unknown; - outputDir?: string; - grpcServiceConfig?: string; - bundleConfig?: string; - serviceYaml?: string; - packageName?: string; - mainService?: string; - template?: string; - gapicValidatorOut?: string; - validation?: string; - metadata?: boolean; - protoc?: string; - protoDirs?: string[]; - commonProtoPath?: string; - descriptor?: string; - transport?: string; - diregapic?: boolean; - handwrittenLayer?: boolean; - legacyProtoLoad?: boolean; - restNumericEnums?: boolean; - mixins?: string; - _: string[]; - $0: string; -} + const googleGaxProtosDir = path.join( + googleGaxPath, + '..', + '..', + 'build', + 'protos' + ); + const allTemplates = await fsp.readdir( + path.join(__dirname, '..', '..', 'templates') + ); -const argv = yargs.argv as IArguments; -const outputDir = argv.outputDir as string; -const grpcServiceConfig = argv.grpcServiceConfig as string | undefined; -const bundleConfig = argv.bundleConfig as string | undefined; -const serviceYaml = argv.serviceYaml as string | undefined; -const packageName = argv.packageName as string | undefined; -const mainServiceName = argv.mainService as string | undefined; -const template = argv.template as string | undefined; -const gapicValidatorOut = argv.gapicValidatorOut as string | undefined; -const validation = (argv.validation as string | undefined) ?? 'true'; -const metadata = argv.metadata as boolean | undefined; -const transport = argv.transport as string | undefined; -const diregapic = argv.diregapic as boolean | undefined; -const handwrittenLayer = argv.handwrittenLayer as boolean | undefined; -const legacyProtoLoad = argv.legacyProtoLoad as boolean | undefined; -const restNumericEnums = argv.restNumericEnums as boolean | undefined; -const mixins = argv.mixins as string | undefined; + // If we're built with bazel, we'll have a shell wrapper to be used as a protoc plugin. + // Just in case if someone builds us without bazel, let's have a fallback to an actual + // JS protoc plugin without a wrapper. + const protocPluginBash = path.join(__dirname, '..', 'protoc_plugin.sh'); + const protocPlugin = fs.existsSync(protocPluginBash) + ? protocPluginBash + : path.join(__dirname, 'protoc-plugin.js'); -// --protoc can be passed from BUILD.bazel and overridden from the command line -let protocParameter = argv.protoc as string | string[] | undefined; -if (Array.isArray(protocParameter)) { - protocParameter = protocParameter[protocParameter.length - 1]; -} -const protoc = protocParameter ?? 'protoc'; + const argv = await yargs(processArgv) + .array('I') + .nargs('I', 1) + .alias('proto_path', 'I') + .alias('proto-path', 'I') + .demandOption('output_dir') + .describe('I', 'Include directory to pass to protoc') + .alias('output-dir', 'output_dir') + .describe( + 'gapic-validator_out', + 'Path to the output of the gapic validator' + ) + .alias('gapic-validator_out', 'gapic_validator_out') + .describe( + 'validation', + 'Option to set the validation of proto files, default value is true' + ) + .describe('output_dir', 'Path to a directory for the generated code') + .alias('grpc-service-config', 'grpc_service_config') + .describe('grpc-service-config', 'Path to gRPC service config JSON') + .alias('bundle-config', 'bundle_config') + .describe('bundle-config', 'Path to bundle request config JSON') + .alias('service-yaml', 'service_yaml') + .describe('service-yaml', 'Path to service yaml') + .alias('package-name', 'package_name') + .describe('package-name', 'Publish package name') + .alias('main-service', 'main_service') + .describe( + 'main_service', + 'Main service name (if the package has multiple services, this one will be used for Webpack bundle name)' + ) + .alias('common-proto-path', 'common_protos_path') + .describe( + 'common_proto_path', + 'Path to API common protos to use (if unset, will use protos shipped with google-gax)' + ) + .describe( + 'template', + `Semicolon-separated list of templates to use. Allowed values: "${allTemplates.join( + ';' + )}"` + ) + .describe( + 'metadata', + 'Set to true if GAPIC metadata generation is requested' + ) + .boolean('metadata') + .describe( + 'transport', + 'Default transport is gRPC. Set transport=rest for gRPC or non-gRPC API requires REST transport with http annotation in proto3 files.' + ) + .describe( + 'diregapic', + 'DIREGAPIC represents Discovery Rest GAPICs. Set to true for GCE API or non-gRPC APIs with a Discovery doc description.' + ) + .describe( + 'handwritten_layer', + 'Set to true if the library has a handwritten layer over GAPIC layer.' + ) + .describe( + 'legacy_proto_load', + 'Load protos from *.proto directly at runtime, without compiling a proto JSON file. May speed up loading huge proto trees. Disables all fallback modes.' + ) + .boolean('legacy-proto-load') + .alias('legacy-proto-load', 'legacy_proto_load') + .describe( + 'rest_numeric_enums', + 'The generated library will pass and accept enum values as numbers when using the HTTP/1.1 REST transport.' + ) + .boolean('rest-numeric-enums') + .alias('rest-numeric-enums', 'rest_numeric_enums') + .describe( + 'mixins', + 'Override the list of mixins to use. Semicolon-separated list of API names to mixin, e.g. google.longrunning.Operations. Use "none" to disable all mixins.' + ) + .string('mixins') + .describe('protoc', 'Path to protoc binary') + .usage('Usage: $0 -I /path/to/googleapis') + .usage(' --output_dir /path/to/output_directory') + .usage(' google/example/api/v1/api.proto').argv; -const protoDirs: string[] = []; -if (argv.I) { - protoDirs.push(...(argv.I as string[])); -} -const protoDirsArg = protoDirs.map(dir => `-I${dir}`); + const outputDir = argv.outputDir as string; + const grpcServiceConfig = argv.grpcServiceConfig as string | undefined; + const bundleConfig = argv.bundleConfig as string | undefined; + const serviceYaml = argv.serviceYaml as string | undefined; + const packageName = argv.packageName as string | undefined; + const mainServiceName = argv.mainService as string | undefined; + const template = argv.template as string | undefined; + const gapicValidatorOut = argv.gapicValidatorOut as string | undefined; + const validation = (argv.validation as string | undefined) ?? 'true'; + const metadata = argv.metadata as boolean | undefined; + const transport = argv.transport as string | undefined; + const diregapic = argv.diregapic as boolean | undefined; + const handwrittenLayer = argv.handwrittenLayer as boolean | undefined; + const legacyProtoLoad = argv.legacyProtoLoad as boolean | undefined; + const restNumericEnums = argv.restNumericEnums as boolean | undefined; + const mixins = argv.mixins as string | undefined; -const protoFiles: string[] = []; -if (Array.isArray(argv._)) { - protoFiles.push(...(argv._ as string[])); -} else { - protoFiles.push(argv._ as string); -} + // --protoc can be taken from environment or from the command line + let protocParameter = argv.protoc as string | string[] | undefined; + const protocEnv = process.env['PROTOC_PATH']; + if (Array.isArray(protocParameter)) { + protocParameter = protocParameter[protocParameter.length - 1]; + } + const protoc = protocParameter ?? protocEnv ?? 'protoc'; + if (!fs.existsSync(protoc)) { + throw new Error( + `protoc binary is not found at ${protoc}, use --protoc option to point to your protoc binary` + ); + } -const commonProtoPath = argv.commonProtoPath || googleGaxProtosDir; + const protoDirs: string[] = []; + if (argv.I) { + protoDirs.push(...(argv.I as string[])); + } + const protoDirsArg = protoDirs.map(dir => `-I${dir}`); -// run protoc command to generate client library -const protocCommand = [ - `--plugin=protoc-gen-typescript_gapic=${protocPlugin}`, - `--typescript_gapic_out=${outputDir}`, -]; -if (gapicValidatorOut && validation === 'true') { - protocCommand.push(`--gapic-validator_out=${gapicValidatorOut}`); -} -if (grpcServiceConfig) { - protocCommand.push( - `--typescript_gapic_opt="grpc-service-config=${grpcServiceConfig}"` - ); -} -if (bundleConfig) { - protocCommand.push(`--typescript_gapic_opt="bundle-config=${bundleConfig}"`); -} -if (serviceYaml) { - protocCommand.push(`--typescript_gapic_opt="service-yaml=${serviceYaml}"`); -} -if (packageName) { - protocCommand.push(`--typescript_gapic_opt="package-name=${packageName}"`); -} -if (mainServiceName) { - protocCommand.push( - `--typescript_gapic_opt="main-service=${mainServiceName}"` - ); -} -if (template) { - protocCommand.push(`--typescript_gapic_opt="template=${template}"`); -} -if (metadata) { - protocCommand.push('--typescript_gapic_opt="metadata"'); -} -if (diregapic) { - protocCommand.push('--typescript_gapic_opt="diregapic"'); -} -if (handwrittenLayer) { - protocCommand.push('--typescript_gapic_opt="handwritten-layer"'); -} -if (transport && transport === 'rest') { - protocCommand.push('--typescript_gapic_opt="transport=rest"'); -} -if (legacyProtoLoad) { - protocCommand.push('--typescript_gapic_opt="legacy-proto-load"'); -} -if (restNumericEnums) { - protocCommand.push('--typescript_gapic_opt="rest-numeric-enums"'); -} -if (mixins) { - protocCommand.push(`--typescript_gapic_opt="mixins=${mixins}"`); -} -protocCommand.push(...protoDirsArg); -protocCommand.push(...protoFiles); -protocCommand.push(`-I${commonProtoPath}`); + const protoFiles: string[] = []; + if (Array.isArray(argv._)) { + protoFiles.push(...(argv._ as string[])); + } else { + protoFiles.push(argv._ as string); + } -execFileSync(protoc, protocCommand, {stdio: 'inherit'}); + const commonProtoPath = argv.commonProtoPath || googleGaxProtosDir; -// create protos folder to copy proto file -const copyProtoDir = path.join(outputDir, 'protos'); -if (!fs.existsSync(copyProtoDir)) { - fs.mkdirSync(copyProtoDir); -} -// copy proto file to generated folder -const protoList = path.join(outputDir, 'proto.list'); -const protoFilesSet = new Set(protoFiles); -fs.readFileSync(protoList) - .toString() - .split('\n') - .forEach(proto => { - protoDirs.forEach(dir => { + // run protoc command to generate client library + const protocCommand = [ + `--plugin=protoc-gen-typescript_gapic=${protocPlugin}`, + `--typescript_gapic_out=${outputDir}`, + ]; + if (gapicValidatorOut && validation === 'true') { + protocCommand.push(`--gapic-validator_out=${gapicValidatorOut}`); + } + if (grpcServiceConfig) { + protocCommand.push( + `--typescript_gapic_opt="grpc-service-config=${grpcServiceConfig}"` + ); + } + if (bundleConfig) { + protocCommand.push( + `--typescript_gapic_opt="bundle-config=${bundleConfig}"` + ); + } + if (serviceYaml) { + protocCommand.push(`--typescript_gapic_opt="service-yaml=${serviceYaml}"`); + } + if (packageName) { + protocCommand.push(`--typescript_gapic_opt="package-name=${packageName}"`); + } + if (mainServiceName) { + protocCommand.push( + `--typescript_gapic_opt="main-service=${mainServiceName}"` + ); + } + if (template) { + protocCommand.push(`--typescript_gapic_opt="template=${template}"`); + } + if (metadata) { + protocCommand.push('--typescript_gapic_opt="metadata"'); + } + if (diregapic) { + protocCommand.push('--typescript_gapic_opt="diregapic"'); + } + if (handwrittenLayer) { + protocCommand.push('--typescript_gapic_opt="handwritten-layer"'); + } + if (transport && transport === 'rest') { + protocCommand.push('--typescript_gapic_opt="transport=rest"'); + } + if (legacyProtoLoad) { + protocCommand.push('--typescript_gapic_opt="legacy-proto-load"'); + } + if (restNumericEnums) { + protocCommand.push('--typescript_gapic_opt="rest-numeric-enums"'); + } + if (mixins) { + protocCommand.push(`--typescript_gapic_opt="mixins=${mixins}"`); + } + protocCommand.push(...protoDirsArg); + protocCommand.push(...protoFiles); + protocCommand.push(`-I${commonProtoPath}`); + + const {stdout, stderr} = await execFileAsync(protoc, protocCommand); + console.log(stdout); + console.warn(stderr); + + // create protos folder to copy proto file + const copyProtoDir = path.join(outputDir, 'protos'); + if (!fs.existsSync(copyProtoDir)) { + fs.mkdirSync(copyProtoDir); + } + // copy proto file to generated folder + const protoList = path.join(outputDir, 'proto.list'); + const protoFilesSet = new Set(protoFiles); + const protoListContent = (await fsp.readFile(protoList)).toString(); + const protoListLines = protoListContent.split('\n'); + for (const proto of protoListLines) { + for (const dir of protoDirs) { const protoFile = path.join(dir, proto); if ( (protoFilesSet.has(protoFile) || @@ -262,9 +261,11 @@ fs.readFileSync(protoList) fs.existsSync(protoFile) ) { const destination = path.join(copyProtoDir, proto); - fs.mkdirpSync(path.dirname(destination)); - fs.copyFileSync(protoFile, destination); + await copy(protoFile, destination); } - }); - }); -fs.unlinkSync(protoList); + } + } + await fsp.unlink(protoList); +} + +main(process.argv.slice(2)); diff --git a/typescript/src/generator.ts b/typescript/src/generator.ts index 1a71d21f8..12576935a 100644 --- a/typescript/src/generator.ts +++ b/typescript/src/generator.ts @@ -16,14 +16,20 @@ import * as path from 'path'; import * as fs from 'fs'; import * as util from 'util'; import * as yaml from 'js-yaml'; -import * as protos from '../../protos'; +import * as serializer from 'proto3-json-serializer'; +import {protobuf} from 'google-gax'; +import type * as protos from '../../protos/index.js'; +import protoJson from '../../protos/protos.json' assert { type: 'json' }; +import * as url from 'url'; -import {API} from './schema/api'; -import {processTemplates} from './templater'; -import {BundleConfigClient, BundleConfig} from './bundle'; -import {ServiceYaml} from './serviceyaml'; -import {commonPrefix, duration} from './util'; -import Long = require('long'); +import {API} from './schema/api.js'; +import {processTemplates} from './templater.js'; +import {BundleConfigClient, BundleConfig} from './bundle.js'; +import {ServiceYaml} from './serviceyaml.js'; +import {commonPrefix} from './util.js'; + +// https://blog.logrocket.com/alternatives-dirname-node-js-es-modules/#help-im-missing-dirname +const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); function getStdin() { return new Promise(resolve => { @@ -81,33 +87,17 @@ export class Generator { restNumericEnums?: boolean; mixinsOverride?: string[]; + private root: protobuf.Root; + constructor() { - this.request = protos.google.protobuf.compiler.CodeGeneratorRequest.create(); - this.response = protos.google.protobuf.compiler.CodeGeneratorResponse.create(); - this.grpcServiceConfig = protos.grpc.service_config.ServiceConfig.create(); + this.root = protobuf.Root.fromJSON(protoJson); + this.request = {} as protos.google.protobuf.compiler.CodeGeneratorRequest; + this.response = {} as protos.google.protobuf.compiler.CodeGeneratorResponse; + this.grpcServiceConfig = {} as protos.grpc.service_config.ServiceConfig; this.paramMap = {}; this.templates = defaultTemplates; } - // Fixes gRPC service config to replace string google.protobuf.Duration - // to a proper Duration message, since protobufjs does not support - // string Durations such as "30s". - private static updateDuration(obj: {[key: string]: {}}) { - const fieldNames = [ - 'timeout', - 'initialBackoff', - 'maxBackoff', - 'hedgingDelay', - ]; - for (const key of Object.keys(obj)) { - if (fieldNames.includes(key) && typeof obj[key] === 'string') { - obj[key] = duration((obj[key] as unknown) as string); - } else if (typeof obj[key] === 'object') { - this.updateDuration(obj[key]); - } - } - } - private getParamMap(parameter: string) { // Example: "grpc-service-config=path/to/grpc-service-config.json","package-name=packageName" const parameters = parameter.split(','); @@ -132,10 +122,15 @@ export class Generator { } const content = await readFile(filename); const json = JSON.parse(content.toString()); - Generator.updateDuration(json); - this.grpcServiceConfig = protos.grpc.service_config.ServiceConfig.fromObject( - json - ); + const ServiceConfig = this.root.lookupType('ServiceConfig'); + if (!ServiceConfig) { + throw new Error('Cannot find ServiceConfig type in proto JSON'); + } + const deserialized = serializer.fromProto3JSON(ServiceConfig, json); + if (!deserialized) { + throw new Error('Cannot parse the content of gRPC service config'); + } + this.grpcServiceConfig = ServiceConfig.toObject(deserialized) as protos.grpc.service_config.ServiceConfig; } } @@ -240,9 +235,14 @@ export class Generator { async initializeFromStdin() { const inputBuffer = await getStdin(); - this.request = protos.google.protobuf.compiler.CodeGeneratorRequest.decode( - inputBuffer - ); + const CodeGeneratorRequest = this.root.lookupType('CodeGeneratorRequest'); + if (!CodeGeneratorRequest) { + throw new Error('Cannot find CodeGeneratorRequest type in proto JSON'); + } + this.request = CodeGeneratorRequest.toObject(CodeGeneratorRequest.decode(inputBuffer)) as protos.google.protobuf.compiler.CodeGeneratorRequest; + if (!this.request.protoFile) { + throw new Error('No input files given to the protoc plugin.'); + } if (this.request.parameter) { this.getParamMap(this.request.parameter); await this.readGrpcServiceConfig(); @@ -267,7 +267,11 @@ export class Generator { protoFilenames.push(proto.name); } } - const protoList = protos.google.protobuf.compiler.CodeGeneratorResponse.File.create(); + const File = this.root.lookupType('File'); + if (!File) { + throw new Error('Cannot find File type in proto JSON'); + } + const protoList = {} as protos.google.protobuf.compiler.CodeGeneratorResponse.File; protoList.name = 'proto.list'; protoList.content = protoFilenames.join('\n') + '\n'; this.response.file.push(protoList); @@ -316,10 +320,13 @@ export class Generator { } async generate() { - this.response = protos.google.protobuf.compiler.CodeGeneratorResponse.create(); - this.response.supportedFeatures = new Long( - protos.google.protobuf.compiler.CodeGeneratorResponse.Feature.FEATURE_PROTO3_OPTIONAL - ); + const CodeGeneratorResponse = this.root.lookupType('CodeGeneratorResponse'); + if (!CodeGeneratorResponse) { + throw new Error('Cannot find CodeGeneratorResponse type in proto JSON'); + } + this.response = {} as protos.google.protobuf.compiler.CodeGeneratorResponse; + this.response.supportedFeatures = 1; // FEATURE_PROTO3_OPTIONAL + this.response.file = []; try { this.addProtosToResponse(); @@ -334,8 +341,8 @@ export class Generator { } } - const outputBuffer = protos.google.protobuf.compiler.CodeGeneratorResponse.encode( - this.response + const outputBuffer = CodeGeneratorResponse.encode( + CodeGeneratorResponse.fromObject(this.response) ).finish(); process.stdout.write(outputBuffer); } diff --git a/typescript/src/protoc-plugin.ts b/typescript/src/protoc-plugin.ts index 8b8307529..28aa911d2 100644 --- a/typescript/src/protoc-plugin.ts +++ b/typescript/src/protoc-plugin.ts @@ -14,17 +14,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as yargs from 'yargs'; -import {Generator} from './generator'; -import {IArguments} from './gapic-generator-typescript'; +import {Generator} from './generator.js'; async function main() { - const argv = yargs.argv as IArguments; - - if (argv.descriptor) { - throw new Error('Descriptor option is not yet supported.'); - } - const generator = new Generator(); await generator.initializeFromStdin(); await generator.generate(); diff --git a/typescript/src/schema/api.ts b/typescript/src/schema/api.ts index 3cc523e00..94059c7e7 100644 --- a/typescript/src/schema/api.ts +++ b/typescript/src/schema/api.ts @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as protos from '../../../protos'; +import type * as protos from '../../../protos/index.js'; -import {Naming, Options as namingOptions} from './naming'; -import {Proto, MessagesMap, ServiceDescriptorProto} from './proto'; -import {ResourceDatabase, ResourceDescriptor} from './resource-database'; -import {CommentsMap} from './comments'; +import {Naming, Options as namingOptions} from './naming.js'; +import {Proto, MessagesMap, ServiceDescriptorProto} from './proto.js'; +import {ResourceDatabase, ResourceDescriptor} from './resource-database.js'; +import {CommentsMap} from './comments.js'; export interface ProtosMap { [filename: string]: Proto; @@ -109,11 +109,13 @@ export class API { allMessages['.' + fd.package! + '.' + message.name!] = message; }); } + const commentsMap = new CommentsMap(fileDescriptors); const filteredProtos = API.filterOutIgnoredServices( fileDescriptors.filter(fd => fd.name) ); + this.protos = filteredProtos.reduce((map, fd) => { map[fd.name!] = new Proto({ fd, @@ -128,6 +130,7 @@ export class API { }, {} as ProtosMap); const serviceNamesList: string[] = []; + filteredProtos .filter(fd => fd.service) .reduce((servicesList, fd) => { @@ -163,11 +166,13 @@ export class API { this.port = port ?? this.port ?? '443'; serviceNamesList.push(service.name || this.naming.name); }); + if (serviceNamesList.length === 0) { throw new Error( `Can't find ${this.naming.name}'s service names, please make sure that services are defined in the proto file.` ); } + this.mainServiceName = options.mainServiceName || serviceNamesList[0]; // For generating keywords in package.json this.uniqKeywords = [ diff --git a/typescript/src/schema/comments.ts b/typescript/src/schema/comments.ts index 81c70469e..a304f2666 100644 --- a/typescript/src/schema/comments.ts +++ b/typescript/src/schema/comments.ts @@ -12,7 +12,29 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as protos from '../../../protos'; +import type * as protos from '../../../protos/index.js'; + +// Copied from FieldDescriptorProto to simplify the build +export enum Type { + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + TYPE_GROUP = 10, + TYPE_MESSAGE = 11, + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + TYPE_SINT32 = 17, + TYPE_SINT64 = 18, +} // For one comment in service and method level, paramName & paramName will be ''. // Only field has name and type of parameters. @@ -49,8 +71,8 @@ export class CommentsMap { // since the field tag of Service is 6. // [6, x, 2, y] refers to the yth method in that service, // since the field tag of Method is 2. - const p = location.path!; - if (p.length === 2 && p[0] === 6) { + const p = location.path; + if (p && p.length === 2 && p[0] === 6) { if (fd.service && fd.service[p[1]] && fd.service[p[1]].name) { const serviceName = fd.service[p[1]].name!; const comments = (location.leadingComments || '') @@ -63,7 +85,7 @@ export class CommentsMap { }; commentsMap[serviceName] = serviceComment; } - } else if (p.length === 4 && p[2] === 2 && p[0] === 6) { + } else if (p && p.length === 4 && p[2] === 2 && p[0] === 6) { if ( fd.service && fd.service[p[1]] && @@ -85,7 +107,7 @@ export class CommentsMap { commentsMap[key] = methodComment; } } - } else if (p.length === 4 && p[0] === 4 && p[2] === 2) { + } else if (p && p.length === 4 && p[0] === 4 && p[2] === 2) { // This contains a field's information // example, this path: // [ 4, 3, 2, 7, 1 ] @@ -108,11 +130,8 @@ export class CommentsMap { const messageType = fd.messageType[p[1]].name; const field = fd.messageType[p[1]].field![p[3]]; if (field) { - //Type Enum: TYPE_STRING, TYPE_BOOL, etc. - let paramType = - protos.google.protobuf.FieldDescriptorProto.Type[ - field.type! - ]; + // Type Enum: TYPE_STRING, TYPE_BOOL, etc. + let paramType = Type[field.type!]; // If field.label is 'REPEATED' then the paramType is an array. if (field.label === 3) { paramType += '[]'; diff --git a/typescript/src/schema/naming.ts b/typescript/src/schema/naming.ts index a922297d7..88dfeaa6b 100644 --- a/typescript/src/schema/naming.ts +++ b/typescript/src/schema/naming.ts @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as protos from '../../../protos'; -import {commonPrefix} from '../util'; -import {API} from './api'; -import {BundleConfig} from '../bundle'; -import {ServiceYaml} from '../serviceyaml'; +import type * as protos from '../../../protos/index.js'; +import {commonPrefix} from '../util.js'; +import {API} from './api.js'; +import {BundleConfig} from '../bundle.js'; +import {ServiceYaml} from '../serviceyaml.js'; export interface Options { grpcServiceConfig: protos.grpc.service_config.ServiceConfig; diff --git a/typescript/src/schema/proto.ts b/typescript/src/schema/proto.ts index ee11e760e..13a2f83b4 100644 --- a/typescript/src/schema/proto.ts +++ b/typescript/src/schema/proto.ts @@ -12,20 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as protos from '../../../protos'; -import {CommentsMap, Comment} from './comments'; -import {processPathTemplate, milliseconds} from '../util'; -import {ResourceDescriptor, ResourceDatabase} from './resource-database'; +import type * as protos from '../../../protos/index.js'; +import {CommentsMap, Comment, Type} from './comments.js'; +import {processPathTemplate, milliseconds} from '../util.js'; +import {ResourceDescriptor, ResourceDatabase} from './resource-database.js'; import { RetryableCodeMap, defaultParametersName, defaultNonIdempotentRetryCodesName, defaultParameters, -} from './retryable-code-map'; -import {BundleConfig} from '../bundle'; -import {Options} from './naming'; -import {ServiceYaml} from '../serviceyaml'; -import {google} from '../../../protos'; +} from './retryable-code-map.js'; +import {BundleConfig} from '../bundle.js'; +import {Options} from './naming.js'; +import {ServiceYaml} from '../serviceyaml.js'; +import {protobuf} from 'google-gax'; +import protoJson from '../../../protos/protos.json' assert { type: 'json' }; const COMMON_PROTO_LIST = [ 'google.api', @@ -99,7 +100,7 @@ export interface ServiceDescriptorProto LongRunningOperationsMixin: number; protoFile: string; diregapicLRO?: MethodDescriptorProto[]; - httpRules?: google.api.IHttpRule[]; + httpRules?: protos.google.api.IHttpRule[]; } export interface ServicesMap { @@ -235,27 +236,26 @@ function pagingField( const inputType = messages[method.inputType!]; const outputType = messages[method.outputType!]; const hasPageToken = - inputType && inputType.field!.some(field => field.name === 'page_token'); + inputType && inputType.field && inputType.field.some(field => field.name === 'page_token'); // Support paginated methods defined in Discovery-based APIs, // where it uses "max_results" to define the maximum number of // paginated resources to return. const hasPageSize = - inputType && - inputType.field!.some( + inputType && inputType.field && + inputType.field.some( field => field.name === 'page_size' || (diregapic && field.name === 'max_results') ); const hasNextPageToken = - outputType && - outputType.field!.some(field => field.name === 'next_page_token'); + outputType && outputType.field && + outputType.field.some(field => field.name === 'next_page_token'); if (!hasPageToken || !hasPageSize || !hasNextPageToken) { return undefined; } const repeatedFields = outputType.field!.filter( field => - field.label === - protos.google.protobuf.FieldDescriptorProto.Label.LABEL_REPEATED + field.label === 3 // LABEL_REPEATED ); if (repeatedFields.length === 0) { return undefined; @@ -310,16 +310,16 @@ function pagingResponseType( return undefined; } if ( - field.type === protos.google.protobuf.FieldDescriptorProto.Type.TYPE_MESSAGE + field.type === 11 // TYPE_MESSAGE ) { return field.typeName; //.google.showcase.v1beta1.EchoResponse } - const type = protos.google.protobuf.FieldDescriptorProto.Type[field.type]; + const type = Type[field.type]; // .google.protobuf.FieldDescriptorProto.Type.TYPE_STRING return '.google.protobuf.FieldDescriptorProto.Type.' + type; } -// Ignore non-diregapic pagation method where its response type contains a map. +// Ignore non-diregapic pagination method where its response type contains a map. function ignoreMapPagingMethod( messages: MessagesMap, method: MethodDescriptorProto, @@ -373,9 +373,8 @@ function pagingMapResponseType( if (pagingMapResponse.field) { if ( pagingMapResponse.field.length === 2 && - pagingMapResponse.field[0] === 'key' && - pagingMapResponse.field[0].type !== - protos.google.protobuf.FieldDescriptorProto.Type.TYPE_STRING + pagingMapResponse.field[0].name === 'key' && + pagingMapResponse.field[0].type !== 9 // TYPE_STRING ) { throw new Error( `Paginated "${method.name}" method map response field key's type should be string` @@ -393,22 +392,26 @@ function getMethodConfig( ): protos.grpc.service_config.MethodConfig { let exactMatch: protos.grpc.service_config.IMethodConfig | undefined; let serviceMatch: protos.grpc.service_config.IMethodConfig | undefined; - for (const config of grpcServiceConfig.methodConfig) { - if (!config.name) { - continue; - } - for (const name of config.name) { - if (name.service === serviceName && !name.method) { - serviceMatch = config; + if (Array.isArray(grpcServiceConfig.methodConfig)) { + for (const config of grpcServiceConfig.methodConfig) { + if (!config.name) { + continue; } - if (name.service === serviceName && name.method === methodName) { - exactMatch = config; + for (const name of config.name) { + if (name.service === serviceName && !name.method) { + serviceMatch = config; + } + if (name.service === serviceName && name.method === methodName) { + exactMatch = config; + } } } } - const result = protos.grpc.service_config.MethodConfig.fromObject( + const root = protobuf.Root.fromJSON(protoJson); + const MethodConfig = root.lookupType('MethodConfig'); + const result = MethodConfig.toObject(MethodConfig.fromObject( exactMatch || serviceMatch || {} - ); + )) as protos.grpc.service_config.MethodConfig; return result; } @@ -495,10 +498,8 @@ function augmentMethod( const inputType = parameters.allMessages[method.inputType!]; const repeatedFields = inputType.field!.filter( field => - field.label === - protos.google.protobuf.FieldDescriptorProto.Label - .LABEL_REPEATED && - field.name === bc.batchDescriptor.batched_field + field.label === 3 // LABEL_REPEATED + && field.name === bc.batchDescriptor.batched_field ); if (!repeatedFields[0].typeName) { throw new Error( @@ -767,7 +768,7 @@ function augmentService(parameters: AugmentServiceParameters) { augmentedService.bundleConfigs = parameters.options.bundleConfigs?.filter( bc => bc.serviceName === parameters.service.name ); - augmentedService.method = augmentedService.method.map(method => + augmentedService.method = augmentedService.method?.map(method => augmentMethod( { allMessages: parameters.allMessages, @@ -777,7 +778,7 @@ function augmentService(parameters: AugmentServiceParameters) { }, method ) - ); + ) ?? []; augmentedService.bundleConfigsMethods = augmentedService.method.filter( method => method.bundleConfig ); @@ -914,6 +915,14 @@ interface ProtoParameters { } export class Proto { + // instrumentation for unit tests + static constructorCallCount = 0; + static constructorCallArgs: ProtoParameters[] = []; + static resetInstrumentation() { + Proto.constructorCallCount = 0; + Proto.constructorCallArgs = []; + } + filePB2: protos.google.protobuf.IFileDescriptorProto; services: ServicesMap = {}; allMessages: MessagesMap = {}; @@ -925,6 +934,9 @@ export class Proto { // allResourceDatabase: resources that defined by `google.api.resource` // resourceDatabase: all resources defined by `google.api.resource` or `google.api.resource_definition` constructor(parameters: ProtoParameters) { + ++Proto.constructorCallCount; + Proto.constructorCallArgs.push(parameters); + parameters.fd.service = parameters.fd.service || []; parameters.fd.messageType = parameters.fd.messageType || []; diff --git a/typescript/src/schema/resource-database.ts b/typescript/src/schema/resource-database.ts index 5d4b0f41a..d3d3b4e2e 100644 --- a/typescript/src/schema/resource-database.ts +++ b/typescript/src/schema/resource-database.ts @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as protos from '../../../protos'; -import {getResourceNameByPattern} from '../util'; +import type * as protos from '../../../protos/index.js'; +import {getResourceNameByPattern} from '../util.js'; export interface ResourceDescriptor extends protos.google.api.IResourceDescriptor { @@ -181,9 +181,9 @@ export class ResourceDatabase { } private getParams(pattern: string): string[] { - let params = pattern.match(/{[a-zA-Z_]+(?:=.*?)?}/g) || []; - params = params.map(p => p.replace(/{([a-zA-Z_]+).*/, '$1')); - return params; + const params = pattern.match(/{[a-zA-Z_]+(?:=.*?)?}/g) || []; + const result = params.map(p => p.replace(/{([a-zA-Z_]+).*/, '$1')); + return result; } private getResourceDescriptor( diff --git a/typescript/src/schema/retryable-code-map.ts b/typescript/src/schema/retryable-code-map.ts index f017a9da1..a0473fa77 100644 --- a/typescript/src/schema/retryable-code-map.ts +++ b/typescript/src/schema/retryable-code-map.ts @@ -12,15 +12,36 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as objectHash from 'object-hash'; -import * as protos from '../../../protos'; +import objectHash from 'object-hash'; +import type * as protos from '../../../protos/index.js'; + +// copied from google.rpc.Code to simplify build +export enum Code { + OK = 0, + CANCELLED = 1, + UNKNOWN = 2, + INVALID_ARGUMENT = 3, + DEADLINE_EXCEEDED = 4, + NOT_FOUND = 5, + ALREADY_EXISTS = 6, + PERMISSION_DENIED = 7, + UNAUTHENTICATED = 16, + RESOURCE_EXHAUSTED = 8, + FAILED_PRECONDITION = 9, + ABORTED = 10, + OUT_OF_RANGE = 11, + UNIMPLEMENTED = 12, + INTERNAL = 13, + UNAVAILABLE = 14, + DATA_LOSS = 15, +} export const defaultNonIdempotentRetryCodesName = 'non_idempotent'; export const defaultNonIdempotentCodes: protos.google.rpc.Code[] = []; export const defaultIdempotentRetryCodesName = 'idempotent'; export const defaultIdempotentCodes = [ - protos.google.rpc.Code.DEADLINE_EXCEEDED, - protos.google.rpc.Code.UNAVAILABLE, + Code.DEADLINE_EXCEEDED, + Code.UNAVAILABLE, ]; export const defaultParametersName = 'default'; export const defaultParameters = { @@ -58,10 +79,10 @@ export class RetryableCodeMap { this.prettyParamNamesMap = {}; // build reverse mapping for enum: 0 => OK, 1 => CANCELLED, etc. this.codeEnumMapping = {}; - const allCodes = Object.keys(protos.google.rpc.Code); + const allCodes = Object.keys(Code); for (const code of allCodes) { this.codeEnumMapping[ - ((protos.google.rpc.Code as unknown) as { + ((Code as unknown) as { [key: string]: protos.google.rpc.Code; })[code].toString() ] = code; diff --git a/typescript/src/serviceyaml.ts b/typescript/src/serviceyaml.ts index 143cbb619..44c82fdd2 100644 --- a/typescript/src/serviceyaml.ts +++ b/typescript/src/serviceyaml.ts @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {google} from 'protos'; +import type * as protos from '../../protos/index.js'; export interface Http { - rules: google.api.IHttpRule[]; + rules: protos.google.api.IHttpRule[]; } export interface ServiceYaml { diff --git a/typescript/src/templater.ts b/typescript/src/templater.ts index 6b68bcabd..9b6eee9f0 100644 --- a/typescript/src/templater.ts +++ b/typescript/src/templater.ts @@ -13,14 +13,14 @@ // limitations under the License. import * as fs from 'fs'; -import * as nunjucks from 'nunjucks'; +import nunjucks from 'nunjucks'; import * as path from 'path'; import * as util from 'util'; -import * as protos from '../../protos'; +import type * as protos from '../../protos/index.js'; -import {API} from './schema/api'; -import {MethodDescriptorProto, ServiceDescriptorProto} from './schema/proto'; +import {API} from './schema/api.js'; +import {MethodDescriptorProto, ServiceDescriptorProto} from './schema/proto.js'; interface Namer { register: (name: string, serviceName?: string) => string; @@ -56,10 +56,10 @@ async function recursiveFileList( return result; } -function createSnippetIndexMetadata( +async function createSnippetIndexMetadata( api: API, basePath: string -): protos.google.cloud.tools.snippetgen.snippetindex.v1.IIndex { +): Promise { const clientLibrary: protos.google.cloud.tools.snippetgen.snippetindex.v1.IClientLibrary = { name: `nodejs-${api.naming.productName.toKebabCase()}`, version: '0.1.0', @@ -67,14 +67,14 @@ function createSnippetIndexMetadata( apis: [{id: api.naming.protoPackage, version: api.naming.version}], }; - const snippets = createSnippetMetadata(api, basePath); + const snippets = await createSnippetMetadata(api, basePath); return {clientLibrary, snippets}; } -function createSnippetMetadata( +async function createSnippetMetadata( api: API, basePath: string -): protos.google.cloud.tools.snippetgen.snippetindex.v1.ISnippet[] { +): Promise { const snippets: protos.google.cloud.tools.snippetgen.snippetindex.v1.ISnippet[] = []; for (const service of api.services) { @@ -85,7 +85,7 @@ function createSnippetMetadata( paramNameAndTypes.push({name: x.paramName, type: x.paramType}) ); - const startRegionTag = countRegionTagLines( + const startRegionTag = await countRegionTagLines( 'samples/generated/$version/$service.$method.js.njk', basePath, api, @@ -146,14 +146,14 @@ function createSnippetMetadata( return snippets; } -function countRegionTagLines( +async function countRegionTagLines( templateName: string, basePath: string, api: API, service: ServiceDescriptorProto, method: MethodDescriptorProto ) { - const id = loadNamerPlugin(basePath); + const id = await loadNamerPlugin(basePath); const processed = nunjucks.render(templateName, {api, service, method, id}); const processedArray = processed.split(/\r?\n/); @@ -197,13 +197,13 @@ function renderFile( } } } - const output = protos.google.protobuf.compiler.CodeGeneratorResponse.File.create(); + const output = {} as protos.google.protobuf.compiler.CodeGeneratorResponse.File; output.name = targetFilename; output.content = processed; return output; } -function processOneTemplate( +async function processOneTemplate( basePath: string, templateFilename: string, api: API, @@ -227,8 +227,8 @@ function processOneTemplate( .replace(/\.njk$/, '') .replace(/\$apiNamingProtoPackage/, api.naming.protoPackage); - const jsonMetadata = createSnippetIndexMetadata(api, basePath); - const output = protos.google.protobuf.compiler.CodeGeneratorResponse.File.create(); + const jsonMetadata = await createSnippetIndexMetadata(api, basePath); + const output = {} as protos.google.protobuf.compiler.CodeGeneratorResponse.File; output.name = pushFilename; output.content = JSON.stringify(jsonMetadata, null, ' ') + '\n'; @@ -275,7 +275,7 @@ function processOneTemplate( return result; } -function loadNamerPlugin(basePath: string) { +async function loadNamerPlugin(basePath: string) { const namerLocation = path.join(basePath, 'namer.js'); const id: Namer = { register: () => { @@ -287,13 +287,7 @@ function loadNamerPlugin(basePath: string) { }; if (fs.existsSync(namerLocation)) { let namer: Namer; - // different location when running from Bazel, hence try {} - // (because Bazel alters behavior of `require`) - try { - namer = require(namerLocation) as Namer; - } catch (err) { - namer = require(namerLocation.replace(/^..\//, '')) as Namer; - } + namer = (await import(namerLocation)).default as Namer; const {register, get} = namer; id.register = register; id.get = get; @@ -307,12 +301,12 @@ export async function processTemplates(basePath: string, api: API) { basePath = basePath.replace(/\/*$/, ''); // If this template provides a namer plugin, load it - const id = loadNamerPlugin(basePath); + const id = await loadNamerPlugin(basePath); const templateFiles = await recursiveFileList(basePath, /^(?!_[^_]).*\.njk$/); const result: protos.google.protobuf.compiler.CodeGeneratorResponse.File[] = []; for (const templateFilename of templateFiles) { - const generatedFiles = processOneTemplate( + const generatedFiles = await processOneTemplate( basePath, templateFilename, api, diff --git a/typescript/src/util.ts b/typescript/src/util.ts index 18394d841..66ea639a1 100644 --- a/typescript/src/util.ts +++ b/typescript/src/util.ts @@ -12,7 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as protos from '../../protos'; +import * as fs from 'fs'; +import * as fsp from 'fs/promises'; +import * as path from 'path'; +import type * as protos from '../../protos/index.js'; export function commonPrefix(strings: string[]): string { if (strings.length === 0) { @@ -31,32 +34,6 @@ export function commonPrefix(strings: string[]): string { return result; } -// Convert a string Duration, e.g. "600s", to a proper protobuf type since -// protobufjs does not support it at this moment. -export function duration(text: string): protos.google.protobuf.Duration { - const multipliers: {[suffix: string]: number} = { - s: 1, - m: 60, - h: 60 * 60, - d: 60 * 60 * 24, - }; - const match = text.match(/^([\d.]+)([smhd])$/); - if (!match) { - throw new Error(`Cannot parse "${text}" into google.protobuf.Duration.`); - } - const float = Number(match[1]); - const suffix = match[2]; - const multiplier = multipliers[suffix]; - const seconds = float * multiplier; - const floor = Math.floor(seconds); - const frac = seconds - floor; - const result = protos.google.protobuf.Duration.fromObject({ - seconds: floor, - nanos: frac * 1e9, - }); - return result; -} - // Convert a Duration to (possibly fractional) seconds. export function seconds(duration: protos.google.protobuf.IDuration): number { return Number(duration.seconds || 0) + Number(duration.nanos || 0) * 1e-9; @@ -161,14 +138,6 @@ String.prototype.toSnakeCase = function ( return words.join('_'); }; -String.prototype.replaceAll = function ( - this: string, - search: string, - replacement: string -) { - return this.split(search).join(replacement); -}; - Array.prototype.toCamelCaseString = function ( this: string[], joiner: string @@ -258,3 +227,43 @@ export function processPathTemplate( return {fieldSend, messageRegex}; } + +// Quick'n'dirty implementation of mkdirp to avoid pulling a dependency +export async function mkdirp(directory: string) { + const components = directory.split(path.sep); + let parent = ''; + for (const component of components) { + parent += `/${component}`; + if (!fs.existsSync(parent)) { + await fsp.mkdir(parent); + } + } +} + +// Quick'n'dirty implementation of cp -r to avoid pulling a dependency +export async function copy(from: string, to: string) { + const stat = await fsp.stat(from); + if (stat.isDirectory()) { + const contents = await fsp.readdir(from); + for (const entry of contents) { + await copy(path.join(from, entry), path.join(to, entry)); + } + } else { + const dirname = path.dirname(to); + await mkdirp(dirname); + await fsp.copyFile(from, to); + } +} + +// Quick'n'dirty implementation of rm -rf to avoid pulling a dependency +export async function remove(fileOrDirectory: string) { + const stat = await fsp.stat(fileOrDirectory); + if (stat.isDirectory()) { + const contents = await fsp.readdir(fileOrDirectory); + for (const entry of contents) { + await remove(path.join(fileOrDirectory, entry)); + } + } else { + await fsp.unlink(fileOrDirectory); + } +} diff --git a/typescript/test/test-application/test-js.ts b/typescript/test/test-application/test-js.ts index 386dd776a..574fe63d7 100644 --- a/typescript/test/test-application/test-js.ts +++ b/typescript/test/test-application/test-js.ts @@ -13,9 +13,9 @@ // limitations under the License. import * as child_process from 'child_process'; -import * as fs from 'fs-extra'; import * as path from 'path'; import {describe, it} from 'mocha'; +import {copy} from 'typescript/src/util.js'; const root = process.cwd(); const baselineZip = path.join( @@ -66,15 +66,15 @@ describe('Test application for JavaScript users', () => { it('npm install showcase', async function () { this.timeout(240000); // copy protos to generated client library and copy test application to local. - fs.copySync(protos, path.join(showcaseLib, 'protos')); - fs.copySync(jsTestApplication, localJsApplication); + await copy(protos, path.join(showcaseLib, 'protos')); + await copy(jsTestApplication, localJsApplication); process.chdir(showcaseLib); await spawn('npm', ['install']); }); it('npm pack showcase library and copy it to test application', async function () { this.timeout(240000); await spawn('npm', ['pack']); - fs.copySync(packedLibPath, path.join(localJsApplication, packedLib)); + await copy(packedLibPath, path.join(localJsApplication, packedLib)); }); it('npm install showcase library in test application', async function () { this.timeout(500000); diff --git a/typescript/test/test-application/test-ts.ts b/typescript/test/test-application/test-ts.ts index fbdc5ea5e..b614568b8 100644 --- a/typescript/test/test-application/test-ts.ts +++ b/typescript/test/test-application/test-ts.ts @@ -13,9 +13,10 @@ // limitations under the License. import * as child_process from 'child_process'; -import * as fs from 'fs-extra'; +import * as fs from 'fs'; import * as path from 'path'; import {describe, it} from 'mocha'; +import {copy} from 'typescript/src/util.js'; const root = process.cwd(); const baselineZip = path.join( @@ -67,10 +68,10 @@ describe('Test application for TypeScript users', () => { this.timeout(240000); // copy protos to generated client library and copy test application to local. if (!fs.existsSync(path.join(showcaseLib, 'protos'))) { - fs.copySync(protos, path.join(showcaseLib, 'protos')); + await copy(protos, path.join(showcaseLib, 'protos')); } if (!fs.existsSync(localTsApplication)) { - fs.copySync(tsTestApplication, localTsApplication); + await copy(tsTestApplication, localTsApplication); } process.chdir(showcaseLib); await spawn('npm', ['install']); @@ -78,7 +79,7 @@ describe('Test application for TypeScript users', () => { it('npm pack showcase library and copy it to test application', async function () { this.timeout(240000); await spawn('npm', ['pack']); - fs.copySync(packedLibPath, path.join(localTsApplication, packedLib)); + await copy(packedLibPath, path.join(localTsApplication, packedLib)); }); it('npm install showcase library in test application', async function () { this.timeout(500000); diff --git a/typescript/test/unit-test-runner.ts b/typescript/test/unit-test-runner.ts index c2101be6d..719380b11 100644 --- a/typescript/test/unit-test-runner.ts +++ b/typescript/test/unit-test-runner.ts @@ -20,14 +20,16 @@ const testDirectory = path.join('.', 'typescript', 'test', 'unit'); async function main() { const mocha = new Mocha(); - + const files = await fsp.readdir(testDirectory); const tests = files.filter(file => file.endsWith('.js')); for (const test of tests) { mocha.addFile(path.join(process.cwd(), testDirectory, test)); } await mocha.loadFilesAsync(); - mocha.run((failures: number) => { process.exitCode = failures; }); + mocha.run((failures: number) => { + process.exitCode = failures; + }); } -main(); \ No newline at end of file +main(); diff --git a/typescript/test/unit/api.ts b/typescript/test/unit/api.ts index 42898c2fe..ee99fd574 100644 --- a/typescript/test/unit/api.ts +++ b/typescript/test/unit/api.ts @@ -12,25 +12,24 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {API} from '../../src/schema/api'; -import * as protos from '../../../protos'; -import * as assert from 'assert'; -import {afterEach, describe, it} from 'mocha'; -import * as sinon from 'sinon'; -import * as proto from '../../src/schema/proto'; +import {API} from '../../src/schema/api.js'; +import type * as protos from '../../../protos/index.js'; +import assert from 'assert'; +import {describe, it} from 'mocha'; +import {Proto} from '../../src/schema/proto.js'; describe('src/schema/api.ts', () => { it('should construct an API object and return list of protos', () => { - const fd = new protos.google.protobuf.FileDescriptorProto(); + const fd = {} as protos.google.protobuf.FileDescriptorProto; fd.name = 'google/cloud/test/v1/test.proto'; fd.package = 'google.cloud.test.v1'; - fd.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd.service[0].name = 'ZService'; fd.service[0].options = { '.google.api.defaultHost': 'hostname.example.com:443', }; const api = new API([fd], 'google.cloud.test.v1', { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }); assert.deepStrictEqual(api.filesToGenerate, [ 'google/cloud/test/v1/test.proto', @@ -38,37 +37,37 @@ describe('src/schema/api.ts', () => { }); it('throw error if an api does not have default host', () => { - const fd = new protos.google.protobuf.FileDescriptorProto(); + const fd = {} as protos.google.protobuf.FileDescriptorProto; fd.name = 'google/cloud/test/v1/test.proto'; fd.package = 'google.cloud.test.v1'; - fd.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd.service[0].name = 'ZService'; assert.throws(() => { new API([fd], 'google.cloud.test.v1', { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }); }, /service "google.cloud.test.v1.ZService" is missing option google.api.default_host/); }); it('should not return common protos in the list of protos', () => { - const fd1 = new protos.google.protobuf.FileDescriptorProto(); + const fd1 = {} as protos.google.protobuf.FileDescriptorProto; fd1.name = 'google/cloud/test/v1/test.proto'; fd1.package = 'google.cloud.test.v1'; - fd1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd1.service[0].name = 'ZService'; fd1.service[0].options = { '.google.api.defaultHost': 'hostname.example.com:443', }; - const fd2 = new protos.google.protobuf.FileDescriptorProto(); + const fd2 = {} as protos.google.protobuf.FileDescriptorProto; fd2.name = 'google/longrunning/operation.proto'; fd2.package = 'google.longrunning'; - fd2.service = [new protos.google.protobuf.ServiceDescriptorProto()]; - const fd3 = new protos.google.protobuf.FileDescriptorProto(); + fd2.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; + const fd3 = {} as protos.google.protobuf.FileDescriptorProto; fd3.name = 'google/iam/v1/iam_policy.proto'; fd3.package = 'google.iam.v1'; - fd3.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd3.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; const api = new API([fd1, fd2, fd3], 'google.cloud.test.v1', { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }); assert.deepStrictEqual(api.filesToGenerate, [ 'google/cloud/test/v1/test.proto', @@ -76,16 +75,16 @@ describe('src/schema/api.ts', () => { }); it('should be able to generate google.iam.v1 alone', () => { - const fd = new protos.google.protobuf.FileDescriptorProto(); + const fd = {} as protos.google.protobuf.FileDescriptorProto; fd.name = 'google/iam/v1/iam_policy.proto'; fd.package = 'google.iam.v1'; - fd.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd.service[0].name = 'IAMPolicy'; fd.service[0].options = { '.google.api.defaultHost': 'iam.googleapis.com', }; const api = new API([fd], 'google.iam.v1', { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }); assert.deepStrictEqual(api.filesToGenerate, [ 'google/iam/v1/iam_policy.proto', @@ -93,31 +92,31 @@ describe('src/schema/api.ts', () => { }); it('should not return common protos in the proto list', () => { - const fd1 = new protos.google.protobuf.FileDescriptorProto(); + const fd1 = {} as protos.google.protobuf.FileDescriptorProto; fd1.name = 'google/cloud/test/v1/test.proto'; fd1.package = 'google.cloud.test.v1'; - fd1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd1.service[0].name = 'ZService'; fd1.service[0].options = { '.google.api.defaultHost': 'hostname.example.com:443', }; - const fd2 = new protos.google.protobuf.FileDescriptorProto(); + const fd2 = {} as protos.google.protobuf.FileDescriptorProto; fd2.name = 'google/api/annotations.proto'; fd2.package = 'google.api'; - const fd3 = new protos.google.protobuf.FileDescriptorProto(); + const fd3 = {} as protos.google.protobuf.FileDescriptorProto; fd3.name = 'google/orgpolicy/v1/orgpolicy.proto'; fd3.package = 'google.orgpolicy.v1'; - const fd4 = new protos.google.protobuf.FileDescriptorProto(); + const fd4 = {} as protos.google.protobuf.FileDescriptorProto; fd4.name = 'google/cloud/common_resources.proto'; fd4.package = 'google.cloud'; - const fd5 = new protos.google.protobuf.FileDescriptorProto(); + const fd5 = {} as protos.google.protobuf.FileDescriptorProto; fd5.name = 'google/api/servicemanagement/v1/servicemanager.proto'; fd5.package = 'google.api.servicemanager.v1'; - const fd6 = new protos.google.protobuf.FileDescriptorProto(); + const fd6 = {} as protos.google.protobuf.FileDescriptorProto; fd6.name = 'google/rpc/context/attribute_context.proto'; fd6.package = 'google.rpc.context'; const api = new API([fd1, fd2, fd3, fd4, fd5, fd6], 'google', { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }); assert.deepStrictEqual(api.filesToGenerate, [ 'google/cloud/test/v1/test.proto', @@ -127,20 +126,20 @@ describe('src/schema/api.ts', () => { }); it('should include the protos has no service and different package name', () => { - const fd1 = new protos.google.protobuf.FileDescriptorProto(); + const fd1 = {} as protos.google.protobuf.FileDescriptorProto; fd1.name = 'google/cloud/example/v1/test.proto'; fd1.package = 'google.cloud.example.v1'; - fd1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd1.service[0].name = 'Service'; fd1.service[0].options = { '.google.api.defaultHost': 'hostname.example.com:443', }; - const fd2 = new protos.google.protobuf.FileDescriptorProto(); + const fd2 = {} as protos.google.protobuf.FileDescriptorProto; fd2.name = 'google/cloud/example/v1/error.proto'; fd2.package = 'google.cloud.example.v1.errors'; const api = new API([fd1, fd2], 'google.cloud.example.v1', { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }); assert.deepStrictEqual(JSON.parse(api.protoFilesToGenerateJSON), [ '../../protos/google/cloud/example/v1/error.proto', @@ -149,83 +148,83 @@ describe('src/schema/api.ts', () => { }); it('should return lexicographically first service name as mainServiceName', () => { - const fd1 = new protos.google.protobuf.FileDescriptorProto(); + const fd1 = {} as protos.google.protobuf.FileDescriptorProto; fd1.name = 'google/cloud/test/v1/test.proto'; fd1.package = 'google.cloud.test.v1'; - fd1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd1.service[0].name = 'ZService'; fd1.service[0].options = { '.google.api.defaultHost': 'hostname.example.com:443', }; - const fd2 = new protos.google.protobuf.FileDescriptorProto(); + const fd2 = {} as protos.google.protobuf.FileDescriptorProto; fd2.name = 'google/cloud/example/v1/example.proto'; fd2.package = 'google.cloud.example.v1'; - fd2.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd2.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd2.service[0].name = 'AService'; fd2.service[0].options = { '.google.api.defaultHost': 'hostname.example.com:443', }; const api = new API([fd1, fd2], 'google.cloud.test.v1', { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }); assert.deepStrictEqual(api.mainServiceName, 'AService'); }); it('should return correct mainServiceName for API without namespace', () => { - const fd1 = new protos.google.protobuf.FileDescriptorProto(); + const fd1 = {} as protos.google.protobuf.FileDescriptorProto; fd1.name = 'service/v1/test.proto'; fd1.package = 'service.v1'; - fd1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd1.service[0].name = 'Service'; fd1.service[0].options = { '.google.api.defaultHost': 'hostname.example.com:443', }; const api = new API([fd1], 'service.v1', { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }); assert.deepStrictEqual(api.mainServiceName, 'Service'); }); it('should return main service name specificed as an option', () => { - const fd1 = new protos.google.protobuf.FileDescriptorProto(); + const fd1 = {} as protos.google.protobuf.FileDescriptorProto; fd1.name = 'google/cloud/test/v1/test.proto'; fd1.package = 'google.cloud.test.v1'; - fd1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd1.service[0].name = 'ZService'; fd1.service[0].options = { '.google.api.defaultHost': 'hostname.example.com:443', }; - const fd2 = new protos.google.protobuf.FileDescriptorProto(); + const fd2 = {} as protos.google.protobuf.FileDescriptorProto; fd2.name = 'google/cloud/example/v1/example.proto'; fd2.package = 'google.cloud.example.v1'; - fd2.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd2.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd2.service[0].name = 'AService'; fd2.service[0].options = { '.google.api.defaultHost': 'hostname.example.com:443', }; const api = new API([fd1, fd2], 'google.cloud.test.v1', { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, mainServiceName: 'OverriddenName', }); assert.deepStrictEqual(api.mainServiceName, 'OverriddenName'); }); it('should return list of protos in lexicographical order', () => { - const fd1 = new protos.google.protobuf.FileDescriptorProto(); + const fd1 = {} as protos.google.protobuf.FileDescriptorProto; fd1.name = 'google/cloud/example/v1/test.proto'; fd1.package = 'google.cloud.example.v1'; - fd1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd1.service[0].name = 'Service'; fd1.service[0].options = { '.google.api.defaultHost': 'hostname.example.com:443', }; - const fd2 = new protos.google.protobuf.FileDescriptorProto(); + const fd2 = {} as protos.google.protobuf.FileDescriptorProto; fd2.name = 'google/cloud/example/v1/example.proto'; fd2.package = 'google.cloud.example.v1'; fd2.service = []; const api = new API([fd1, fd2], 'google.cloud.example.v1', { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }); assert.deepStrictEqual(JSON.parse(api.protoFilesToGenerateJSON), [ '../../protos/google/cloud/example/v1/example.proto', @@ -234,52 +233,47 @@ describe('src/schema/api.ts', () => { }); it('should throw error when the service name is not found', () => { - const fd = new protos.google.protobuf.FileDescriptorProto(); + const fd = {} as protos.google.protobuf.FileDescriptorProto; fd.name = 'google/cloud/test/v1/test.proto'; fd.package = 'google.cloud.test.v1'; - fd.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; assert.throws(() => { const api = new API([fd], 'google.cloud.test.v1', { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }); assert(api); }); }); describe('Calling Proto constructor', () => { - afterEach(() => { - sinon.restore(); - }); - it('should pass all messages to Proto constructor', () => { - const fd1 = new protos.google.protobuf.FileDescriptorProto(); + Proto.resetInstrumentation(); + + const fd1 = {} as protos.google.protobuf.FileDescriptorProto; fd1.name = 'google/cloud/example/v1/test.proto'; fd1.package = 'google.cloud.example.v1'; - fd1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd1.service[0].name = 'Service'; fd1.service[0].options = { '.google.api.defaultHost': 'hostname.example.com:443', }; - fd1.messageType = [new protos.google.protobuf.MethodDescriptorProto()]; + fd1.messageType = [{} as protos.google.protobuf.MethodDescriptorProto]; fd1.messageType[0].name = 'MessageA'; - const fd2 = new protos.google.protobuf.FileDescriptorProto(); + const fd2 = {} as protos.google.protobuf.FileDescriptorProto; fd2.name = 'google/cloud/example/v1/example.proto'; fd2.package = 'google.cloud.example.v1'; - fd2.messageType = [new protos.google.protobuf.MethodDescriptorProto()]; + fd2.messageType = [{} as protos.google.protobuf.MethodDescriptorProto]; fd2.messageType[0].name = 'MessageB'; - const spy = sinon.spy(proto, 'Proto'); - new API([fd1, fd2], 'google.cloud.example.v1', { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }); - assert(spy.calledWithNew()); - assert.strictEqual(spy.callCount, 2); // one Proto object created for each fd - const firstCallMessages = spy.getCall(0).args[0].allMessages; - const secondCallMessages = spy.getCall(1).args[0].allMessages; + assert.strictEqual(Proto.constructorCallCount, 2); // one Proto object created for each fd + const firstCallMessages = Proto.constructorCallArgs[0].allMessages; + const secondCallMessages = Proto.constructorCallArgs[1].allMessages; assert('.google.cloud.example.v1.MessageA' in firstCallMessages); assert('.google.cloud.example.v1.MessageB' in firstCallMessages); assert('.google.cloud.example.v1.MessageA' in secondCallMessages); diff --git a/typescript/test/unit/baselines.ts b/typescript/test/unit/baselines.ts index 8d2015395..d928b8138 100644 --- a/typescript/test/unit/baselines.ts +++ b/typescript/test/unit/baselines.ts @@ -13,7 +13,7 @@ // limitations under the License. import {describe} from 'mocha'; -import {runBaselineTest} from '../util'; +import {runBaselineTest} from '../util.js'; describe('Baseline tests', () => { runBaselineTest({ diff --git a/typescript/test/unit/naming.ts b/typescript/test/unit/naming.ts index f79879fe2..5ada3bf41 100644 --- a/typescript/test/unit/naming.ts +++ b/typescript/test/unit/naming.ts @@ -12,19 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as assert from 'assert'; +import assert from 'assert'; import {describe, it} from 'mocha'; -import * as protos from '../../../protos'; -import {Naming, Options} from '../../src/schema/naming'; +import type * as protos from '../../../protos/index.js'; +import {Naming, Options} from '../../src/schema/naming.js'; describe('src/schema/naming.ts', () => { it('parses name correctly', () => { - const descriptor1 = new protos.google.protobuf.FileDescriptorProto(); - const descriptor2 = new protos.google.protobuf.FileDescriptorProto(); + const descriptor1 = {} as protos.google.protobuf.FileDescriptorProto; + const descriptor2 = {} as protos.google.protobuf.FileDescriptorProto; descriptor1.package = 'google.namespace.service.v1beta1'; - descriptor1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; descriptor2.package = 'google.namespace.service.v1beta1'; - descriptor2.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor2.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; const naming = new Naming([descriptor1, descriptor2]); assert.strictEqual(naming.name, 'Service'); assert.strictEqual(naming.productName, 'Service'); @@ -34,9 +34,9 @@ describe('src/schema/naming.ts', () => { }); it('parses name correctly 2', () => { - const descriptor1 = new protos.google.protobuf.FileDescriptorProto(); + const descriptor1 = {} as protos.google.protobuf.FileDescriptorProto; descriptor1.package = 'service.v1beta1'; - descriptor1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; const naming = new Naming([descriptor1]); assert.strictEqual(naming.name, 'Service'); assert.strictEqual(naming.productName, 'Service'); @@ -46,9 +46,9 @@ describe('src/schema/naming.ts', () => { }); it('parses name correctly 3', () => { - const descriptor1 = new protos.google.protobuf.FileDescriptorProto(); + const descriptor1 = {} as protos.google.protobuf.FileDescriptorProto; descriptor1.package = 'company.service.v1beta1'; - descriptor1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; const naming = new Naming([descriptor1]); assert.strictEqual(naming.name, 'Service'); assert.strictEqual(naming.productName, 'Service'); @@ -58,9 +58,9 @@ describe('src/schema/naming.ts', () => { }); it('ignores everything after the version', () => { - const descriptor1 = new protos.google.protobuf.FileDescriptorProto(); + const descriptor1 = {} as protos.google.protobuf.FileDescriptorProto; descriptor1.package = 'company.service.v1beta1.unexpected'; - descriptor1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; const naming = new Naming([descriptor1]); assert.strictEqual(naming.name, 'Service'); assert.strictEqual(naming.productName, 'Service'); @@ -73,10 +73,10 @@ describe('src/schema/naming.ts', () => { }); it('ignores files with no services when determining package name', () => { - const descriptor1 = new protos.google.protobuf.FileDescriptorProto(); - const descriptor2 = new protos.google.protobuf.FileDescriptorProto(); + const descriptor1 = {} as protos.google.protobuf.FileDescriptorProto; + const descriptor2 = {} as protos.google.protobuf.FileDescriptorProto; descriptor1.package = 'google.namespace.service.v1beta1'; - descriptor1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; descriptor2.package = 'google.namespace.service.v1beta2'; const naming = new Naming([descriptor1, descriptor2]); assert.strictEqual(naming.name, 'Service'); @@ -87,12 +87,12 @@ describe('src/schema/naming.ts', () => { }); it('ignores LRO files when determining package name', () => { - const descriptor1 = new protos.google.protobuf.FileDescriptorProto(); - const descriptor2 = new protos.google.protobuf.FileDescriptorProto(); + const descriptor1 = {} as protos.google.protobuf.FileDescriptorProto; + const descriptor2 = {} as protos.google.protobuf.FileDescriptorProto; descriptor1.package = 'google.namespace.service.v1beta1'; - descriptor1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; descriptor2.package = 'google.longrunning'; - descriptor2.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor2.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; const naming = new Naming([descriptor1, descriptor2]); assert.strictEqual(naming.name, 'Service'); assert.strictEqual(naming.productName, 'Service'); @@ -102,12 +102,12 @@ describe('src/schema/naming.ts', () => { }); it('ignores IAM files when determining package name', () => { - const descriptor1 = new protos.google.protobuf.FileDescriptorProto(); - const descriptor2 = new protos.google.protobuf.FileDescriptorProto(); + const descriptor1 = {} as protos.google.protobuf.FileDescriptorProto; + const descriptor2 = {} as protos.google.protobuf.FileDescriptorProto; descriptor1.package = 'google.namespace.service.v1beta1'; - descriptor1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; descriptor2.package = 'google.iam.v1'; - descriptor2.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor2.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; const naming = new Naming([descriptor1, descriptor2]); assert.strictEqual(naming.name, 'Service'); assert.strictEqual(naming.productName, 'Service'); @@ -117,9 +117,9 @@ describe('src/schema/naming.ts', () => { }); it('determines package name for IAM alone', () => { - const descriptor = new protos.google.protobuf.FileDescriptorProto(); + const descriptor = {} as protos.google.protobuf.FileDescriptorProto; descriptor.package = 'google.iam.v1'; - descriptor.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; const naming = new Naming([descriptor]); assert.strictEqual(naming.name, 'Iam'); assert.strictEqual(naming.productName, 'Iam'); @@ -129,9 +129,9 @@ describe('src/schema/naming.ts', () => { }); it('fails on bad package name 1', () => { - const descriptor = new protos.google.protobuf.FileDescriptorProto(); + const descriptor = {} as protos.google.protobuf.FileDescriptorProto; descriptor.package = 'nonamespace'; - descriptor.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; assert.throws(() => { const naming = new Naming([descriptor]); assert(naming); @@ -139,9 +139,9 @@ describe('src/schema/naming.ts', () => { }); it('fails on bad package name 2', () => { - const descriptor = new protos.google.protobuf.FileDescriptorProto(); + const descriptor = {} as protos.google.protobuf.FileDescriptorProto; descriptor.package = '---'; - descriptor.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; assert.throws(() => { const naming = new Naming([descriptor]); assert(naming); @@ -149,9 +149,9 @@ describe('src/schema/naming.ts', () => { }); it('fails on no package name', () => { - const descriptor = new protos.google.protobuf.FileDescriptorProto(); + const descriptor = {} as protos.google.protobuf.FileDescriptorProto; descriptor.package = ''; - descriptor.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; assert.throws(() => { const naming = new Naming([descriptor]); assert(naming); @@ -159,12 +159,12 @@ describe('src/schema/naming.ts', () => { }); it('fails if no common package, no service-name', () => { - const descriptor1 = new protos.google.protobuf.FileDescriptorProto(); - const descriptor2 = new protos.google.protobuf.FileDescriptorProto(); + const descriptor1 = {} as protos.google.protobuf.FileDescriptorProto; + const descriptor2 = {} as protos.google.protobuf.FileDescriptorProto; descriptor1.package = 'namespace1.service.v1beta1'; - descriptor1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; descriptor2.package = 'namespace2.service.v1beta1'; - descriptor2.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor2.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; assert.throws(() => { const naming = new Naming([descriptor1, descriptor2]); assert(naming); @@ -172,13 +172,13 @@ describe('src/schema/naming.ts', () => { }); it('parse name correctly if no common package, but service-name specified', () => { - const descriptor1 = new protos.google.protobuf.FileDescriptorProto(); - const descriptor2 = new protos.google.protobuf.FileDescriptorProto(); + const descriptor1 = {} as protos.google.protobuf.FileDescriptorProto; + const descriptor2 = {} as protos.google.protobuf.FileDescriptorProto; descriptor1.package = 'namespace1.service1.v1beta1'; - descriptor1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; descriptor2.package = 'namespace2.service2.v1beta1'; - descriptor2.service = [new protos.google.protobuf.ServiceDescriptorProto()]; - const serviceConfig = new protos.grpc.service_config.ServiceConfig(); + descriptor2.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; + const serviceConfig = {} as protos.grpc.service_config.ServiceConfig; const options: Options = { grpcServiceConfig: serviceConfig, mainServiceName: 'service1', @@ -194,12 +194,12 @@ describe('src/schema/naming.ts', () => { }); it('fails if different versions', () => { - const descriptor1 = new protos.google.protobuf.FileDescriptorProto(); - const descriptor2 = new protos.google.protobuf.FileDescriptorProto(); + const descriptor1 = {} as protos.google.protobuf.FileDescriptorProto; + const descriptor2 = {} as protos.google.protobuf.FileDescriptorProto; descriptor1.package = 'namespace.service.v1beta1'; - descriptor1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; descriptor2.package = 'namespace.service.v1beta2'; - descriptor2.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor2.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; assert.throws(() => { const naming = new Naming([descriptor1, descriptor2]); assert(naming); @@ -207,12 +207,12 @@ describe('src/schema/naming.ts', () => { }); it('fails if not all packages have versions', () => { - const descriptor1 = new protos.google.protobuf.FileDescriptorProto(); - const descriptor2 = new protos.google.protobuf.FileDescriptorProto(); + const descriptor1 = {} as protos.google.protobuf.FileDescriptorProto; + const descriptor2 = {} as protos.google.protobuf.FileDescriptorProto; descriptor1.package = 'namespace.service.v1beta1'; - descriptor1.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor1.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; descriptor2.package = 'namespace.service'; - descriptor2.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + descriptor2.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; assert.throws(() => { const naming = new Naming([descriptor1, descriptor2]); assert(naming); diff --git a/typescript/test/unit/proto.ts b/typescript/test/unit/proto.ts index bba740a3e..fa83f4082 100644 --- a/typescript/test/unit/proto.ts +++ b/typescript/test/unit/proto.ts @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as assert from 'assert'; +import assert from 'assert'; import {describe, it} from 'mocha'; -import * as protos from '../../../protos'; +import type * as protos from '../../../protos/index.js'; import { convertFieldToCamelCase, DynamicRoutingParameters, @@ -22,11 +22,11 @@ import { getHeaderRequestParams, getSingleRoutingHeaderParam, MessagesMap, -} from '../../src/schema/proto'; -import {Proto} from '../../src/schema/proto'; -import {Options} from '../../src/schema/naming'; -import {ResourceDatabase} from '../../src/schema/resource-database'; -import {CommentsMap} from '../../src/schema/comments'; + Proto, +} from '../../src/schema/proto.js'; +import {Options} from '../../src/schema/naming.js'; +import {ResourceDatabase} from '../../src/schema/resource-database.js'; +import {CommentsMap} from '../../src/schema/comments.js'; describe('src/schema/proto.ts', () => { describe('should get header parameters from http rule', () => { @@ -385,27 +385,22 @@ describe('src/schema/proto.ts', () => { describe('AugmentService', () => { it('should pass proto file name to the service', () => { - const fd = new protos.google.protobuf.FileDescriptorProto(); + const fd = {} as protos.google.protobuf.FileDescriptorProto; fd.name = 'google/cloud/showcase/v1beta1/test.proto'; fd.package = 'google.cloud.showcase.v1beta1'; - fd.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd.service[0].name = 'TestService'; fd.service[0].method = [ - new protos.google.protobuf.MethodDescriptorProto(), + {} as protos.google.protobuf.MethodDescriptorProto, ]; - fd.service[0].method[0] = new protos.google.protobuf.MethodDescriptorProto(); + fd.service[0].method[0] = {} as protos.google.protobuf.MethodDescriptorProto; fd.service[0].method[0].name = 'Test'; fd.service[0].method[0].outputType = '.google.cloud.showcase.v1beta1.TestOutput'; const options: Options = { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }; const allMessages: MessagesMap = {}; - fd.messageType - .filter(message => message.name) - .forEach(message => { - allMessages['.' + fd.package! + '.' + message.name!] = message; - }); const commentsMap = new CommentsMap([fd]); const proto = new Proto({ fd, @@ -422,54 +417,53 @@ describe('src/schema/proto.ts', () => { describe('special work around for talent API', () => { it('The pagingFieldName should be undefined for SearchJobs & SearchProfiles rpc', () => { - const fd = new protos.google.protobuf.FileDescriptorProto(); + const fd = {} as protos.google.protobuf.FileDescriptorProto; fd.name = 'google/cloud/talent/v4beta1/service.proto'; fd.package = 'google.cloud.talent.v4beta1'; - fd.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd.service[0].name = 'service'; fd.service[0].method = [ - new protos.google.protobuf.MethodDescriptorProto(), + {} as protos.google.protobuf.MethodDescriptorProto, ]; - fd.service[0].method[0] = new protos.google.protobuf.MethodDescriptorProto(); + fd.service[0].method[0] = {} as protos.google.protobuf.MethodDescriptorProto; fd.service[0].method[0].name = 'SearchJobs'; - fd.service[0].method[1] = new protos.google.protobuf.MethodDescriptorProto(); + fd.service[0].method[1] = {} as protos.google.protobuf.MethodDescriptorProto; fd.service[0].method[1].name = 'SearchProfiles'; - fd.service[0].method[2] = new protos.google.protobuf.MethodDescriptorProto(); + fd.service[0].method[2] = {} as protos.google.protobuf.MethodDescriptorProto; fd.service[0].method[2].name = 'SearchJobsForAlert'; - fd.service[0].method[3] = new protos.google.protobuf.MethodDescriptorProto(); + fd.service[0].method[3] = {} as protos.google.protobuf.MethodDescriptorProto; fd.service[0].method[3].name = 'ListJobs'; fd.service[0].method[3].outputType = '.google.cloud.talent.v4beta1.ListJobsOutput'; fd.service[0].method[3].inputType = '.google.cloud.talent.v4beta1.ListJobsInput'; - fd.messageType = [new protos.google.protobuf.DescriptorProto()]; - fd.messageType[0] = new protos.google.protobuf.DescriptorProto(); - fd.messageType[1] = new protos.google.protobuf.DescriptorProto(); + fd.messageType = [{} as protos.google.protobuf.DescriptorProto]; + fd.messageType[0] = {} as protos.google.protobuf.DescriptorProto; + fd.messageType[1] = {} as protos.google.protobuf.DescriptorProto; fd.messageType[0].name = 'ListJobsOutput'; fd.messageType[1].name = 'ListJobsInput'; fd.messageType[0].field = [ - new protos.google.protobuf.FieldDescriptorProto(), + {} as protos.google.protobuf.FieldDescriptorProto, ]; - fd.messageType[0].field[0] = new protos.google.protobuf.FieldDescriptorProto(); + fd.messageType[0].field[0] = {} as protos.google.protobuf.FieldDescriptorProto; fd.messageType[0].field[0].name = 'next_page_token'; - fd.messageType[0].field[0].label = - protos.google.protobuf.FieldDescriptorProto.Label.LABEL_REPEATED; + fd.messageType[0].field[0].label = 3; // LABEL_REPEATED fd.messageType[1].field = [ - new protos.google.protobuf.FieldDescriptorProto(), + {} as protos.google.protobuf.FieldDescriptorProto, ]; - fd.messageType[1].field[0] = new protos.google.protobuf.FieldDescriptorProto(); + fd.messageType[1].field[0] = {} as protos.google.protobuf.FieldDescriptorProto; fd.messageType[1].field[0].name = 'page_size'; - fd.messageType[1].field[1] = new protos.google.protobuf.FieldDescriptorProto(); + fd.messageType[1].field[1] = {} as protos.google.protobuf.FieldDescriptorProto; fd.messageType[1].field[1].name = 'page_token'; const options: Options = { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }; const allMessages: MessagesMap = {}; fd.messageType - .filter(message => message.name) + ?.filter(message => message.name) .forEach(message => { allMessages['.' + fd.package! + '.' + message.name!] = message; }); @@ -501,17 +495,12 @@ describe('src/schema/proto.ts', () => { ); }); it("should allow generate a proto has no service and its package name differ from service's", () => { - const fd = new protos.google.protobuf.FileDescriptorProto(); + const fd = {} as protos.google.protobuf.FileDescriptorProto; fd.name = 'google/cloud/showcase/v1beta1/test.proto'; fd.package = 'google.cloud.showcase.v1beta1.errors'; const allMessages: MessagesMap = {}; - fd.messageType - .filter(message => message.name) - .forEach(message => { - allMessages['.' + fd.package! + '.' + message.name!] = message; - }); const options: Options = { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }; const commentsMap = new CommentsMap([fd]); const proto = new Proto({ @@ -526,27 +515,22 @@ describe('src/schema/proto.ts', () => { assert.deepStrictEqual(proto.fileToGenerate, true); }); it("should not allow generate a service proto with package name differ from the param's pakage name", () => { - const fd = new protos.google.protobuf.FileDescriptorProto(); + const fd = {} as protos.google.protobuf.FileDescriptorProto; fd.name = 'google/cloud/showcase/v1beta1/test.proto'; fd.package = 'google.cloud.showcase.v1beta1.TestService'; - fd.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd.service[0].name = 'service'; fd.service[0].method = [ - new protos.google.protobuf.MethodDescriptorProto(), + {} as protos.google.protobuf.MethodDescriptorProto, ]; - fd.service[0].method[0] = new protos.google.protobuf.MethodDescriptorProto(); + fd.service[0].method[0] = {} as protos.google.protobuf.MethodDescriptorProto; fd.service[0].method[0].name = 'Test'; fd.service[0].method[0].outputType = '.google.cloud.showcase.v1beta1.TestOutput'; const options: Options = { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }; const allMessages: MessagesMap = {}; - fd.messageType - .filter(message => message.name) - .forEach(message => { - allMessages['.' + fd.package! + '.' + message.name!] = message; - }); const commentsMap = new CommentsMap([fd]); const proto = new Proto({ fd, @@ -562,26 +546,21 @@ describe('src/schema/proto.ts', () => { }); describe('throw error for misconfigured LRO', () => { it('throw error if method returns Operation, but without operation_info option', () => { - const fd = new protos.google.protobuf.FileDescriptorProto(); + const fd = {} as protos.google.protobuf.FileDescriptorProto; fd.name = 'google/cloud/showcase/v1beta1/test.proto'; fd.package = 'google.cloud.showcase.v1beta1'; - fd.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd.service[0].name = 'service'; fd.service[0].method = [ - new protos.google.protobuf.MethodDescriptorProto(), + {} as protos.google.protobuf.MethodDescriptorProto, ]; - fd.service[0].method[0] = new protos.google.protobuf.MethodDescriptorProto(); + fd.service[0].method[0] = {} as protos.google.protobuf.MethodDescriptorProto; fd.service[0].method[0].name = 'Test'; fd.service[0].method[0].outputType = '.google.longrunning.Operation'; const options: Options = { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }; const allMessages: MessagesMap = {}; - fd.messageType - .filter(message => message.name) - .forEach(message => { - allMessages['.' + fd.package! + '.' + message.name!] = message; - }); const commentsMap = new CommentsMap([fd]); assert.throws(() => { new Proto({ @@ -596,28 +575,23 @@ describe('src/schema/proto.ts', () => { }, 'rpc "google.cloud.showcase.v1beta1.Test" returns google.longrunning.Operation but is missing option google.longrunning.operation_info'); }); it('throw error if method returns Operation, but without operation_info option', () => { - const fd = new protos.google.protobuf.FileDescriptorProto(); + const fd = {} as protos.google.protobuf.FileDescriptorProto; fd.name = 'google/cloud/showcase/v1beta1/test.proto'; fd.package = 'google.cloud.showcase.v1beta1'; - fd.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd.service[0].name = 'service'; fd.service[0].method = [ - new protos.google.protobuf.MethodDescriptorProto(), + {} as protos.google.protobuf.MethodDescriptorProto, ]; - fd.service[0].method[0] = new protos.google.protobuf.MethodDescriptorProto(); + fd.service[0].method[0] = {} as protos.google.protobuf.MethodDescriptorProto; fd.service[0].method[0].name = 'Test'; fd.service[0].method[0].outputType = '.google.longrunning.Operation'; const options: Options = { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }; - fd.service[0].method[0].options = new protos.google.protobuf.MethodOptions(); + fd.service[0].method[0].options = {} as protos.google.protobuf.MethodOptions; fd.service[0].method[0].options['.google.longrunning.operationInfo'] = {}; const allMessages: MessagesMap = {}; - fd.messageType - .filter(message => message.name) - .forEach(message => { - allMessages['.' + fd.package! + '.' + message.name!] = message; - }); const commentsMap = new CommentsMap([fd]); assert.throws(() => { new Proto({ @@ -635,7 +609,7 @@ describe('src/schema/proto.ts', () => { describe('should add diregapic option for Proto class', () => { it('should be false when diregapic is not set', () => { - const fd = new protos.google.protobuf.FileDescriptorProto(); + const fd = {} as protos.google.protobuf.FileDescriptorProto; const proto = new Proto({ fd, packageName: 'google.cloud.example.v1beta1', @@ -643,14 +617,14 @@ describe('src/schema/proto.ts', () => { allResourceDatabase: new ResourceDatabase(), resourceDatabase: new ResourceDatabase(), options: { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }, commentsMap: new CommentsMap([fd]), }); assert.strictEqual(proto.diregapic, undefined); }); it('should be true when diregapic is set', () => { - const fd = new protos.google.protobuf.FileDescriptorProto(); + const fd = {} as protos.google.protobuf.FileDescriptorProto; const proto = new Proto({ fd, packageName: 'google.cloud.example.v1beta1', @@ -658,7 +632,7 @@ describe('src/schema/proto.ts', () => { allResourceDatabase: new ResourceDatabase(), resourceDatabase: new ResourceDatabase(), options: { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, diregapic: true, }, commentsMap: new CommentsMap([fd]), @@ -669,53 +643,51 @@ describe('src/schema/proto.ts', () => { describe('should support pagination for non-gRPC APIs, diregapic mode', () => { it('should be page field if diregapic mode and use "max_results" as field name', () => { - const fd = new protos.google.protobuf.FileDescriptorProto(); + const fd = {} as protos.google.protobuf.FileDescriptorProto; fd.name = 'google/cloud/showcase/v1beta1/test.proto'; fd.package = 'google.cloud.showcase.v1beta1'; - fd.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd.service[0].name = 'service'; fd.service[0].method = [ - new protos.google.protobuf.MethodDescriptorProto(), + {} as protos.google.protobuf.MethodDescriptorProto, ]; - fd.service[0].method[0] = new protos.google.protobuf.MethodDescriptorProto(); + fd.service[0].method[0] = {} as protos.google.protobuf.MethodDescriptorProto; fd.service[0].method[0].name = 'List'; fd.service[0].method[0].outputType = '.google.cloud.showcase.v1beta1.AddressList'; fd.service[0].method[0].inputType = '.google.cloud.showcase.v1beta1.ListAddressesRequest'; - fd.messageType = [new protos.google.protobuf.DescriptorProto()]; - fd.messageType[0] = new protos.google.protobuf.DescriptorProto(); - fd.messageType[1] = new protos.google.protobuf.DescriptorProto(); + fd.messageType = [{} as protos.google.protobuf.DescriptorProto]; + fd.messageType[0] = {} as protos.google.protobuf.DescriptorProto; + fd.messageType[1] = {} as protos.google.protobuf.DescriptorProto; fd.messageType[0].name = 'AddressList'; fd.messageType[1].name = 'ListAddressesRequest'; fd.messageType[0].field = [ - new protos.google.protobuf.FieldDescriptorProto(), + {} as protos.google.protobuf.FieldDescriptorProto, ]; - fd.messageType[0].field[0] = new protos.google.protobuf.FieldDescriptorProto(); + fd.messageType[0].field[0] = {} as protos.google.protobuf.FieldDescriptorProto; fd.messageType[0].field[0].name = 'next_page_token'; - fd.messageType[0].field[0].label = - protos.google.protobuf.FieldDescriptorProto.Label.LABEL_REPEATED; - fd.messageType[0].field[0].type = - protos.google.protobuf.FieldDescriptorProto.Type.TYPE_MESSAGE; + fd.messageType[0].field[0].label = 3; // LABEL_REPEATED + fd.messageType[0].field[0].type = 11; // TYPE_MESSAGE fd.messageType[0].field[0].typeName = '.google.cloud.showcase.v1beta1.Address'; fd.messageType[1].field = [ - new protos.google.protobuf.FieldDescriptorProto(), + {} as protos.google.protobuf.FieldDescriptorProto, ]; - fd.messageType[1].field[0] = new protos.google.protobuf.FieldDescriptorProto(); + fd.messageType[1].field[0] = {} as protos.google.protobuf.FieldDescriptorProto; fd.messageType[1].field[0].name = 'max_results'; - fd.messageType[1].field[1] = new protos.google.protobuf.FieldDescriptorProto(); + fd.messageType[1].field[1] = {} as protos.google.protobuf.FieldDescriptorProto; fd.messageType[1].field[1].name = 'page_token'; const options: Options = { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, diregapic: true, }; const allMessages: MessagesMap = {}; fd.messageType - .filter(message => message.name) + ?.filter(message => message.name) .forEach(message => { allMessages['.' + fd.package! + '.' + message.name!] = message; }); @@ -748,51 +720,45 @@ describe('src/schema/proto.ts', () => { ); }); it('should not be page field if api is not google discovery api but use "max_result"', () => { - const fd = new protos.google.protobuf.FileDescriptorProto(); + const fd = {} as protos.google.protobuf.FileDescriptorProto; fd.name = 'google/cloud/showcase/v1beta1/test.proto'; fd.package = 'google.cloud.showcase.v1beta1'; - fd.service = [new protos.google.protobuf.ServiceDescriptorProto()]; + fd.service = [{} as protos.google.protobuf.ServiceDescriptorProto]; fd.service[0].name = 'service'; fd.service[0].method = [ - new protos.google.protobuf.MethodDescriptorProto(), + {} as protos.google.protobuf.MethodDescriptorProto, ]; - fd.service[0].method[0] = new protos.google.protobuf.MethodDescriptorProto(); + fd.service[0].method[0] = {} as protos.google.protobuf.MethodDescriptorProto; fd.service[0].method[0].name = 'List'; fd.service[0].method[0].outputType = '.google.cloud.showcase.v1beta1.AddressList'; fd.service[0].method[0].inputType = '.google.cloud.showcase.v1beta1.ListAddressesRequest'; - fd.messageType = [new protos.google.protobuf.DescriptorProto()]; - fd.messageType[0] = new protos.google.protobuf.DescriptorProto(); - fd.messageType[1] = new protos.google.protobuf.DescriptorProto(); + fd.messageType = [{} as protos.google.protobuf.DescriptorProto]; + fd.messageType[0] = {} as protos.google.protobuf.DescriptorProto; + fd.messageType[1] = {} as protos.google.protobuf.DescriptorProto; fd.messageType[0].name = 'AddressList'; fd.messageType[1].name = 'ListAddressesRequest'; fd.messageType[0].field = [ - new protos.google.protobuf.FieldDescriptorProto(), + {} as protos.google.protobuf.FieldDescriptorProto, ]; - fd.messageType[0].field[0] = new protos.google.protobuf.FieldDescriptorProto(); + fd.messageType[0].field[0] = {} as protos.google.protobuf.FieldDescriptorProto; fd.messageType[0].field[0].name = 'next_page_token'; - fd.messageType[0].field[0].label = - protos.google.protobuf.FieldDescriptorProto.Label.LABEL_REPEATED; + fd.messageType[0].field[0].label = 3; // LABEL_REPEATED fd.messageType[1].field = [ - new protos.google.protobuf.FieldDescriptorProto(), + {} as protos.google.protobuf.FieldDescriptorProto, ]; - fd.messageType[1].field[0] = new protos.google.protobuf.FieldDescriptorProto(); + fd.messageType[1].field[0] = {} as protos.google.protobuf.FieldDescriptorProto; fd.messageType[1].field[0].name = 'max_results'; - fd.messageType[1].field[1] = new protos.google.protobuf.FieldDescriptorProto(); + fd.messageType[1].field[1] = {} as protos.google.protobuf.FieldDescriptorProto; fd.messageType[1].field[1].name = 'page_token'; const options: Options = { - grpcServiceConfig: new protos.grpc.service_config.ServiceConfig(), + grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig, }; const allMessages: MessagesMap = {}; - fd.messageType - .filter(message => message.name) - .forEach(message => { - allMessages['.' + fd.package! + '.' + message.name!] = message; - }); const commentsMap = new CommentsMap([fd]); const proto = new Proto({ fd, diff --git a/typescript/test/unit/resource-database.ts b/typescript/test/unit/resource-database.ts index cfff157c5..90f198c10 100644 --- a/typescript/test/unit/resource-database.ts +++ b/typescript/test/unit/resource-database.ts @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as protos from '../../../protos'; -import {ResourceDatabase} from '../../src/schema/resource-database'; +import type * as protos from '../../../protos/index.js'; +import {ResourceDatabase} from '../../src/schema/resource-database.js'; import {describe, it, beforeEach, afterEach} from 'mocha'; -import * as assert from 'assert'; +import assert from 'assert'; describe('src/schema/resource-database.ts', () => { let warnings: string[] = []; diff --git a/typescript/test/unit/retryable-code-map.ts b/typescript/test/unit/retryable-code-map.ts index 9307675dc..fb74f81eb 100644 --- a/typescript/test/unit/retryable-code-map.ts +++ b/typescript/test/unit/retryable-code-map.ts @@ -12,13 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {RetryableCodeMap} from '../../src/schema/retryable-code-map'; -import * as protos from '../../../protos'; -import * as assert from 'assert'; +import {RetryableCodeMap, Code} from '../../src/schema/retryable-code-map.js'; +import assert from 'assert'; import {describe, it} from 'mocha'; -const Code = protos.google.rpc.Code; - describe('src/schema/retryable-code-map.ts', () => { describe('Retry codes', () => { it('has readable names for common code lists', () => { diff --git a/typescript/test/unit/util.ts b/typescript/test/unit/util.ts index 4b7663cd8..39e5d3fb3 100644 --- a/typescript/test/unit/util.ts +++ b/typescript/test/unit/util.ts @@ -12,17 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as assert from 'assert'; +import assert from 'assert'; import {describe, it} from 'mocha'; import { commonPrefix, - duration, seconds, milliseconds, isDigit, processPathTemplate, -} from '../../src/util'; -import * as protos from '../../../protos'; +} from '../../src/util.js'; +import {protobuf} from 'google-gax'; +import protoJson from '../../../protos/protos.json' assert { type: 'json' }; +import type * as protos from '../../../protos/index.js'; describe('src/util.ts', () => { describe('CommonPrefix', () => { @@ -41,80 +42,41 @@ describe('src/util.ts', () => { }); describe('Duration', () => { - it('should support fractional seconds', () => { - const input = '0.1s'; - const dur = duration(input); - assert.strictEqual(Number(dur.seconds), 0); - assert.strictEqual(Number(dur.nanos), 0.1 * 1e9); - }); - - it('should support fractional minutes', () => { - const input = '0.5m'; - const dur = duration(input); - assert.strictEqual(Number(dur.seconds), 30); - assert.strictEqual(Number(dur.nanos), 0); - }); - - it('should build correct Duration object for seconds', () => { - const input = '5s'; - const dur = duration(input); - assert.strictEqual(Number(dur.seconds), 5); - assert.strictEqual(Number(dur.nanos), 0); - }); - - it('should build correct Duration object for minutes', () => { - const input = '10m'; - const dur = duration(input); - assert.strictEqual(Number(dur.seconds), 10 * 60); - assert.strictEqual(Number(dur.nanos), 0); - }); - - it('should build correct Duration object for hours', () => { - const input = '2h'; - const dur = duration(input); - assert.strictEqual(Number(dur.seconds), 2 * 60 * 60); - assert.strictEqual(Number(dur.nanos), 0); - }); - - it('should build correct Duration object for days', () => { - const input = '3d'; - const dur = duration(input); - assert.strictEqual(Number(dur.seconds), 3 * 60 * 60 * 24); - assert.strictEqual(Number(dur.nanos), 0); - }); + const root = protobuf.Root.fromJSON(protoJson); + const Duration = root.lookupType('google.protobuf.Duration'); it('should convert Duration to whole seconds', () => { - const duration = protos.google.protobuf.Duration.fromObject({ + const duration = Duration.toObject(Duration.fromObject({ seconds: 10, nanos: 0, - }); + })) as protos.google.protobuf.Duration; const result = seconds(duration); assert.strictEqual(result, 10); }); it('should convert Duration to fractional seconds', () => { - const duration = protos.google.protobuf.Duration.fromObject({ + const duration = Duration.toObject(Duration.fromObject({ seconds: 5, nanos: 500000000, - }); + })) as protos.google.protobuf.Duration; const result = seconds(duration); assert.strictEqual(result, 5.5); }); it('should convert Duration to whole milliseconds', () => { - const duration = protos.google.protobuf.Duration.fromObject({ + const duration = Duration.toObject(Duration.fromObject({ seconds: 10, nanos: 0, - }); + })) as protos.google.protobuf.Duration; const result = milliseconds(duration); assert.strictEqual(result, 10000); }); it('should convert Duration to fractional milliseconds', () => { - const duration = protos.google.protobuf.Duration.fromObject({ + const duration = Duration.toObject(Duration.fromObject({ seconds: 5, nanos: 500000000, - }); + })) as protos.google.protobuf.Duration; const result = milliseconds(duration); assert.strictEqual(result, 5500); }); @@ -338,19 +300,6 @@ describe('src/util.ts', () => { 'product_name_v1p1beta1' ); }); - - it('should replace all search item with replacement', () => { - assert.deepStrictEqual(''.replaceAll('', 'success'), ''); - assert.deepStrictEqual('Read me'.replaceAll('me', 'this'), 'Read this'); - assert.deepStrictEqual( - 'This is a Test'.replaceAll('T', 't'), - 'this is a test' - ); - assert.deepStrictEqual( - 'location*/address*/room/*'.replaceAll('*/', '* /'), - 'location* /address* /room/*' - ); - }); }); describe('array manipulation', () => { diff --git a/typescript/test/util.ts b/typescript/test/util.ts index d1677a07f..6a3029155 100644 --- a/typescript/test/util.ts +++ b/typescript/test/util.ts @@ -12,11 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as fs from 'fs-extra'; +import * as fs from 'fs'; import * as path from 'path'; +import * as url from 'url'; import {it} from 'mocha'; import {execSync} from 'child_process'; -import * as assert from 'assert'; +import assert from 'assert'; +import {remove} from '../src/util.js'; + +// https://blog.logrocket.com/alternatives-dirname-node-js-es-modules/#help-im-missing-dirname +const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); const NO_OUTPUT_FILE = 0; const IDENTICAL_FILE = 1; @@ -91,7 +96,7 @@ export function runBaselineTest(options: BaselineOptions) { it(options.baselineName, async function () { this.timeout(60000); if (fs.existsSync(outputDir)) { - await fs.remove(outputDir); + await remove(outputDir); } fs.mkdirSync(outputDir); diff --git a/typescript/tools/update-baselines.ts b/typescript/tools/update-baselines.ts index 23f54ecae..a57c9b07f 100644 --- a/typescript/tools/update-baselines.ts +++ b/typescript/tools/update-baselines.ts @@ -21,15 +21,9 @@ import {exec} from 'child_process'; import * as path from 'path'; import {promisify} from 'util'; -import { - readdir, - mkdirp, - existsSync, - stat, - symlink, - copy, - remove, -} from 'fs-extra'; +import {existsSync} from 'fs'; +import {readdir, stat, symlink} from 'fs/promises'; +import {copy, mkdirp, remove} from '../src/util.js'; const execp = promisify(exec); @@ -40,7 +34,7 @@ const baselineZip = path.join( 'bazel-testlogs', 'unit_tests', 'test.outputs', - 'outputs.zip' + 'outputs.zip', ); function getBaselineDirectory(library: string): string {