diff --git a/packages/google-cloud-language/protos/protos.js b/packages/google-cloud-language/protos/protos.js index 0c67f1c08c4..222a0e18860 100644 --- a/packages/google-cloud-language/protos/protos.js +++ b/packages/google-cloud-language/protos/protos.js @@ -396,13 +396,13 @@ Document.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.type != null && message.hasOwnProperty("type")) + if (message.type != null && Object.hasOwnProperty.call(message, "type")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.type); - if (message.content != null && message.hasOwnProperty("content")) + if (message.content != null && Object.hasOwnProperty.call(message, "content")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.content); - if (message.gcsContentUri != null && message.hasOwnProperty("gcsContentUri")) + if (message.gcsContentUri != null && Object.hasOwnProperty.call(message, "gcsContentUri")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.gcsContentUri); - if (message.language != null && message.hasOwnProperty("language")) + if (message.language != null && Object.hasOwnProperty.call(message, "language")) writer.uint32(/* id 4, wireType 2 =*/34).string(message.language); return writer; }; @@ -596,7 +596,7 @@ /** * Type enum. * @name google.cloud.language.v1.Document.Type - * @enum {string} + * @enum {number} * @property {number} TYPE_UNSPECIFIED=0 TYPE_UNSPECIFIED value * @property {number} PLAIN_TEXT=1 PLAIN_TEXT value * @property {number} HTML=2 HTML value @@ -677,9 +677,9 @@ Sentence.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.text != null && message.hasOwnProperty("text")) + if (message.text != null && Object.hasOwnProperty.call(message, "text")) $root.google.cloud.language.v1.TextSpan.encode(message.text, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.sentiment != null && message.hasOwnProperty("sentiment")) + if (message.sentiment != null && Object.hasOwnProperty.call(message, "sentiment")) $root.google.cloud.language.v1.Sentiment.encode(message.sentiment, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -935,19 +935,19 @@ Entity.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.type != null && message.hasOwnProperty("type")) + if (message.type != null && Object.hasOwnProperty.call(message, "type")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.type); - if (message.metadata != null && message.hasOwnProperty("metadata")) + if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata")) for (var keys = Object.keys(message.metadata), i = 0; i < keys.length; ++i) writer.uint32(/* id 3, wireType 2 =*/26).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.metadata[keys[i]]).ldelim(); - if (message.salience != null && message.hasOwnProperty("salience")) + if (message.salience != null && Object.hasOwnProperty.call(message, "salience")) writer.uint32(/* id 4, wireType 5 =*/37).float(message.salience); if (message.mentions != null && message.mentions.length) for (var i = 0; i < message.mentions.length; ++i) $root.google.cloud.language.v1.EntityMention.encode(message.mentions[i], writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); - if (message.sentiment != null && message.hasOwnProperty("sentiment")) + if (message.sentiment != null && Object.hasOwnProperty.call(message, "sentiment")) $root.google.cloud.language.v1.Sentiment.encode(message.sentiment, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); return writer; }; @@ -1247,7 +1247,7 @@ /** * Type enum. * @name google.cloud.language.v1.Entity.Type - * @enum {string} + * @enum {number} * @property {number} UNKNOWN=0 UNKNOWN value * @property {number} PERSON=1 PERSON value * @property {number} LOCATION=2 LOCATION value @@ -1286,7 +1286,7 @@ /** * EncodingType enum. * @name google.cloud.language.v1.EncodingType - * @enum {string} + * @enum {number} * @property {number} NONE=0 NONE value * @property {number} UTF8=1 UTF8 value * @property {number} UTF16=2 UTF16 value @@ -1384,13 +1384,13 @@ Token.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.text != null && message.hasOwnProperty("text")) + if (message.text != null && Object.hasOwnProperty.call(message, "text")) $root.google.cloud.language.v1.TextSpan.encode(message.text, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.partOfSpeech != null && message.hasOwnProperty("partOfSpeech")) + if (message.partOfSpeech != null && Object.hasOwnProperty.call(message, "partOfSpeech")) $root.google.cloud.language.v1.PartOfSpeech.encode(message.partOfSpeech, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.dependencyEdge != null && message.hasOwnProperty("dependencyEdge")) + if (message.dependencyEdge != null && Object.hasOwnProperty.call(message, "dependencyEdge")) $root.google.cloud.language.v1.DependencyEdge.encode(message.dependencyEdge, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.lemma != null && message.hasOwnProperty("lemma")) + if (message.lemma != null && Object.hasOwnProperty.call(message, "lemma")) writer.uint32(/* id 4, wireType 2 =*/34).string(message.lemma); return writer; }; @@ -1635,9 +1635,9 @@ Sentiment.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.magnitude != null && message.hasOwnProperty("magnitude")) + if (message.magnitude != null && Object.hasOwnProperty.call(message, "magnitude")) writer.uint32(/* id 2, wireType 5 =*/21).float(message.magnitude); - if (message.score != null && message.hasOwnProperty("score")) + if (message.score != null && Object.hasOwnProperty.call(message, "score")) writer.uint32(/* id 3, wireType 5 =*/29).float(message.score); return writer; }; @@ -1935,29 +1935,29 @@ PartOfSpeech.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.tag != null && message.hasOwnProperty("tag")) + if (message.tag != null && Object.hasOwnProperty.call(message, "tag")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.tag); - if (message.aspect != null && message.hasOwnProperty("aspect")) + if (message.aspect != null && Object.hasOwnProperty.call(message, "aspect")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.aspect); - if (message["case"] != null && message.hasOwnProperty("case")) + if (message["case"] != null && Object.hasOwnProperty.call(message, "case")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message["case"]); - if (message.form != null && message.hasOwnProperty("form")) + if (message.form != null && Object.hasOwnProperty.call(message, "form")) writer.uint32(/* id 4, wireType 0 =*/32).int32(message.form); - if (message.gender != null && message.hasOwnProperty("gender")) + if (message.gender != null && Object.hasOwnProperty.call(message, "gender")) writer.uint32(/* id 5, wireType 0 =*/40).int32(message.gender); - if (message.mood != null && message.hasOwnProperty("mood")) + if (message.mood != null && Object.hasOwnProperty.call(message, "mood")) writer.uint32(/* id 6, wireType 0 =*/48).int32(message.mood); - if (message.number != null && message.hasOwnProperty("number")) + if (message.number != null && Object.hasOwnProperty.call(message, "number")) writer.uint32(/* id 7, wireType 0 =*/56).int32(message.number); - if (message.person != null && message.hasOwnProperty("person")) + if (message.person != null && Object.hasOwnProperty.call(message, "person")) writer.uint32(/* id 8, wireType 0 =*/64).int32(message.person); - if (message.proper != null && message.hasOwnProperty("proper")) + if (message.proper != null && Object.hasOwnProperty.call(message, "proper")) writer.uint32(/* id 9, wireType 0 =*/72).int32(message.proper); - if (message.reciprocity != null && message.hasOwnProperty("reciprocity")) + if (message.reciprocity != null && Object.hasOwnProperty.call(message, "reciprocity")) writer.uint32(/* id 10, wireType 0 =*/80).int32(message.reciprocity); - if (message.tense != null && message.hasOwnProperty("tense")) + if (message.tense != null && Object.hasOwnProperty.call(message, "tense")) writer.uint32(/* id 11, wireType 0 =*/88).int32(message.tense); - if (message.voice != null && message.hasOwnProperty("voice")) + if (message.voice != null && Object.hasOwnProperty.call(message, "voice")) writer.uint32(/* id 12, wireType 0 =*/96).int32(message.voice); return writer; }; @@ -2656,7 +2656,7 @@ /** * Tag enum. * @name google.cloud.language.v1.PartOfSpeech.Tag - * @enum {string} + * @enum {number} * @property {number} UNKNOWN=0 UNKNOWN value * @property {number} ADJ=1 ADJ value * @property {number} ADP=2 ADP value @@ -2694,7 +2694,7 @@ /** * Aspect enum. * @name google.cloud.language.v1.PartOfSpeech.Aspect - * @enum {string} + * @enum {number} * @property {number} ASPECT_UNKNOWN=0 ASPECT_UNKNOWN value * @property {number} PERFECTIVE=1 PERFECTIVE value * @property {number} IMPERFECTIVE=2 IMPERFECTIVE value @@ -2712,7 +2712,7 @@ /** * Case enum. * @name google.cloud.language.v1.PartOfSpeech.Case - * @enum {string} + * @enum {number} * @property {number} CASE_UNKNOWN=0 CASE_UNKNOWN value * @property {number} ACCUSATIVE=1 ACCUSATIVE value * @property {number} ADVERBIAL=2 ADVERBIAL value @@ -2752,7 +2752,7 @@ /** * Form enum. * @name google.cloud.language.v1.PartOfSpeech.Form - * @enum {string} + * @enum {number} * @property {number} FORM_UNKNOWN=0 FORM_UNKNOWN value * @property {number} ADNOMIAL=1 ADNOMIAL value * @property {number} AUXILIARY=2 AUXILIARY value @@ -2786,7 +2786,7 @@ /** * Gender enum. * @name google.cloud.language.v1.PartOfSpeech.Gender - * @enum {string} + * @enum {number} * @property {number} GENDER_UNKNOWN=0 GENDER_UNKNOWN value * @property {number} FEMININE=1 FEMININE value * @property {number} MASCULINE=2 MASCULINE value @@ -2804,7 +2804,7 @@ /** * Mood enum. * @name google.cloud.language.v1.PartOfSpeech.Mood - * @enum {string} + * @enum {number} * @property {number} MOOD_UNKNOWN=0 MOOD_UNKNOWN value * @property {number} CONDITIONAL_MOOD=1 CONDITIONAL_MOOD value * @property {number} IMPERATIVE=2 IMPERATIVE value @@ -2828,7 +2828,7 @@ /** * Number enum. * @name google.cloud.language.v1.PartOfSpeech.Number - * @enum {string} + * @enum {number} * @property {number} NUMBER_UNKNOWN=0 NUMBER_UNKNOWN value * @property {number} SINGULAR=1 SINGULAR value * @property {number} PLURAL=2 PLURAL value @@ -2846,7 +2846,7 @@ /** * Person enum. * @name google.cloud.language.v1.PartOfSpeech.Person - * @enum {string} + * @enum {number} * @property {number} PERSON_UNKNOWN=0 PERSON_UNKNOWN value * @property {number} FIRST=1 FIRST value * @property {number} SECOND=2 SECOND value @@ -2866,7 +2866,7 @@ /** * Proper enum. * @name google.cloud.language.v1.PartOfSpeech.Proper - * @enum {string} + * @enum {number} * @property {number} PROPER_UNKNOWN=0 PROPER_UNKNOWN value * @property {number} PROPER=1 PROPER value * @property {number} NOT_PROPER=2 NOT_PROPER value @@ -2882,7 +2882,7 @@ /** * Reciprocity enum. * @name google.cloud.language.v1.PartOfSpeech.Reciprocity - * @enum {string} + * @enum {number} * @property {number} RECIPROCITY_UNKNOWN=0 RECIPROCITY_UNKNOWN value * @property {number} RECIPROCAL=1 RECIPROCAL value * @property {number} NON_RECIPROCAL=2 NON_RECIPROCAL value @@ -2898,7 +2898,7 @@ /** * Tense enum. * @name google.cloud.language.v1.PartOfSpeech.Tense - * @enum {string} + * @enum {number} * @property {number} TENSE_UNKNOWN=0 TENSE_UNKNOWN value * @property {number} CONDITIONAL_TENSE=1 CONDITIONAL_TENSE value * @property {number} FUTURE=2 FUTURE value @@ -2922,7 +2922,7 @@ /** * Voice enum. * @name google.cloud.language.v1.PartOfSpeech.Voice - * @enum {string} + * @enum {number} * @property {number} VOICE_UNKNOWN=0 VOICE_UNKNOWN value * @property {number} ACTIVE=1 ACTIVE value * @property {number} CAUSATIVE=2 CAUSATIVE value @@ -3005,9 +3005,9 @@ DependencyEdge.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.headTokenIndex != null && message.hasOwnProperty("headTokenIndex")) + if (message.headTokenIndex != null && Object.hasOwnProperty.call(message, "headTokenIndex")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.headTokenIndex); - if (message.label != null && message.hasOwnProperty("label")) + if (message.label != null && Object.hasOwnProperty.call(message, "label")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.label); return writer; }; @@ -3568,7 +3568,7 @@ /** * Label enum. * @name google.cloud.language.v1.DependencyEdge.Label - * @enum {string} + * @enum {number} * @property {number} UNKNOWN=0 UNKNOWN value * @property {number} ABBREV=1 ABBREV value * @property {number} ACOMP=2 ACOMP value @@ -3818,11 +3818,11 @@ EntityMention.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.text != null && message.hasOwnProperty("text")) + if (message.text != null && Object.hasOwnProperty.call(message, "text")) $root.google.cloud.language.v1.TextSpan.encode(message.text, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.type != null && message.hasOwnProperty("type")) + if (message.type != null && Object.hasOwnProperty.call(message, "type")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.type); - if (message.sentiment != null && message.hasOwnProperty("sentiment")) + if (message.sentiment != null && Object.hasOwnProperty.call(message, "sentiment")) $root.google.cloud.language.v1.Sentiment.encode(message.sentiment, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -4004,7 +4004,7 @@ /** * Type enum. * @name google.cloud.language.v1.EntityMention.Type - * @enum {string} + * @enum {number} * @property {number} TYPE_UNKNOWN=0 TYPE_UNKNOWN value * @property {number} PROPER=1 PROPER value * @property {number} COMMON=2 COMMON value @@ -4085,9 +4085,9 @@ TextSpan.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.content != null && message.hasOwnProperty("content")) + if (message.content != null && Object.hasOwnProperty.call(message, "content")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.content); - if (message.beginOffset != null && message.hasOwnProperty("beginOffset")) + if (message.beginOffset != null && Object.hasOwnProperty.call(message, "beginOffset")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.beginOffset); return writer; }; @@ -4295,9 +4295,9 @@ ClassificationCategory.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.confidence != null && message.hasOwnProperty("confidence")) + if (message.confidence != null && Object.hasOwnProperty.call(message, "confidence")) writer.uint32(/* id 2, wireType 5 =*/21).float(message.confidence); return writer; }; @@ -4505,9 +4505,9 @@ AnalyzeSentimentRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.document != null && message.hasOwnProperty("document")) + if (message.document != null && Object.hasOwnProperty.call(message, "document")) $root.google.cloud.language.v1.Document.encode(message.document, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.encodingType != null && message.hasOwnProperty("encodingType")) + if (message.encodingType != null && Object.hasOwnProperty.call(message, "encodingType")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.encodingType); return writer; }; @@ -4753,9 +4753,9 @@ AnalyzeSentimentResponse.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.documentSentiment != null && message.hasOwnProperty("documentSentiment")) + if (message.documentSentiment != null && Object.hasOwnProperty.call(message, "documentSentiment")) $root.google.cloud.language.v1.Sentiment.encode(message.documentSentiment, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.language != null && message.hasOwnProperty("language")) + if (message.language != null && Object.hasOwnProperty.call(message, "language")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.language); if (message.sentences != null && message.sentences.length) for (var i = 0; i < message.sentences.length; ++i) @@ -5002,9 +5002,9 @@ AnalyzeEntitySentimentRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.document != null && message.hasOwnProperty("document")) + if (message.document != null && Object.hasOwnProperty.call(message, "document")) $root.google.cloud.language.v1.Document.encode(message.document, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.encodingType != null && message.hasOwnProperty("encodingType")) + if (message.encodingType != null && Object.hasOwnProperty.call(message, "encodingType")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.encodingType); return writer; }; @@ -5244,7 +5244,7 @@ if (message.entities != null && message.entities.length) for (var i = 0; i < message.entities.length; ++i) $root.google.cloud.language.v1.Entity.encode(message.entities[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.language != null && message.hasOwnProperty("language")) + if (message.language != null && Object.hasOwnProperty.call(message, "language")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.language); return writer; }; @@ -5471,9 +5471,9 @@ AnalyzeEntitiesRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.document != null && message.hasOwnProperty("document")) + if (message.document != null && Object.hasOwnProperty.call(message, "document")) $root.google.cloud.language.v1.Document.encode(message.document, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.encodingType != null && message.hasOwnProperty("encodingType")) + if (message.encodingType != null && Object.hasOwnProperty.call(message, "encodingType")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.encodingType); return writer; }; @@ -5713,7 +5713,7 @@ if (message.entities != null && message.entities.length) for (var i = 0; i < message.entities.length; ++i) $root.google.cloud.language.v1.Entity.encode(message.entities[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.language != null && message.hasOwnProperty("language")) + if (message.language != null && Object.hasOwnProperty.call(message, "language")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.language); return writer; }; @@ -5940,9 +5940,9 @@ AnalyzeSyntaxRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.document != null && message.hasOwnProperty("document")) + if (message.document != null && Object.hasOwnProperty.call(message, "document")) $root.google.cloud.language.v1.Document.encode(message.document, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.encodingType != null && message.hasOwnProperty("encodingType")) + if (message.encodingType != null && Object.hasOwnProperty.call(message, "encodingType")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.encodingType); return writer; }; @@ -6195,7 +6195,7 @@ if (message.tokens != null && message.tokens.length) for (var i = 0; i < message.tokens.length; ++i) $root.google.cloud.language.v1.Token.encode(message.tokens[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.language != null && message.hasOwnProperty("language")) + if (message.language != null && Object.hasOwnProperty.call(message, "language")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.language); return writer; }; @@ -6444,7 +6444,7 @@ ClassifyTextRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.document != null && message.hasOwnProperty("document")) + if (message.document != null && Object.hasOwnProperty.call(message, "document")) $root.google.cloud.language.v1.Document.encode(message.document, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); return writer; }; @@ -6862,11 +6862,11 @@ AnnotateTextRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.document != null && message.hasOwnProperty("document")) + if (message.document != null && Object.hasOwnProperty.call(message, "document")) $root.google.cloud.language.v1.Document.encode(message.document, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.features != null && message.hasOwnProperty("features")) + if (message.features != null && Object.hasOwnProperty.call(message, "features")) $root.google.cloud.language.v1.AnnotateTextRequest.Features.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.encodingType != null && message.hasOwnProperty("encodingType")) + if (message.encodingType != null && Object.hasOwnProperty.call(message, "encodingType")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.encodingType); return writer; }; @@ -7142,15 +7142,15 @@ Features.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.extractSyntax != null && message.hasOwnProperty("extractSyntax")) + if (message.extractSyntax != null && Object.hasOwnProperty.call(message, "extractSyntax")) writer.uint32(/* id 1, wireType 0 =*/8).bool(message.extractSyntax); - if (message.extractEntities != null && message.hasOwnProperty("extractEntities")) + if (message.extractEntities != null && Object.hasOwnProperty.call(message, "extractEntities")) writer.uint32(/* id 2, wireType 0 =*/16).bool(message.extractEntities); - if (message.extractDocumentSentiment != null && message.hasOwnProperty("extractDocumentSentiment")) + if (message.extractDocumentSentiment != null && Object.hasOwnProperty.call(message, "extractDocumentSentiment")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.extractDocumentSentiment); - if (message.extractEntitySentiment != null && message.hasOwnProperty("extractEntitySentiment")) + if (message.extractEntitySentiment != null && Object.hasOwnProperty.call(message, "extractEntitySentiment")) writer.uint32(/* id 4, wireType 0 =*/32).bool(message.extractEntitySentiment); - if (message.classifyText != null && message.hasOwnProperty("classifyText")) + if (message.classifyText != null && Object.hasOwnProperty.call(message, "classifyText")) writer.uint32(/* id 6, wireType 0 =*/48).bool(message.classifyText); return writer; }; @@ -7443,9 +7443,9 @@ if (message.entities != null && message.entities.length) for (var i = 0; i < message.entities.length; ++i) $root.google.cloud.language.v1.Entity.encode(message.entities[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.documentSentiment != null && message.hasOwnProperty("documentSentiment")) + if (message.documentSentiment != null && Object.hasOwnProperty.call(message, "documentSentiment")) $root.google.cloud.language.v1.Sentiment.encode(message.documentSentiment, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); - if (message.language != null && message.hasOwnProperty("language")) + if (message.language != null && Object.hasOwnProperty.call(message, "language")) writer.uint32(/* id 5, wireType 2 =*/42).string(message.language); if (message.categories != null && message.categories.length) for (var i = 0; i < message.categories.length; ++i) @@ -8060,13 +8060,13 @@ Document.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.type != null && message.hasOwnProperty("type")) + if (message.type != null && Object.hasOwnProperty.call(message, "type")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.type); - if (message.content != null && message.hasOwnProperty("content")) + if (message.content != null && Object.hasOwnProperty.call(message, "content")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.content); - if (message.gcsContentUri != null && message.hasOwnProperty("gcsContentUri")) + if (message.gcsContentUri != null && Object.hasOwnProperty.call(message, "gcsContentUri")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.gcsContentUri); - if (message.language != null && message.hasOwnProperty("language")) + if (message.language != null && Object.hasOwnProperty.call(message, "language")) writer.uint32(/* id 4, wireType 2 =*/34).string(message.language); return writer; }; @@ -8260,7 +8260,7 @@ /** * Type enum. * @name google.cloud.language.v1beta2.Document.Type - * @enum {string} + * @enum {number} * @property {number} TYPE_UNSPECIFIED=0 TYPE_UNSPECIFIED value * @property {number} PLAIN_TEXT=1 PLAIN_TEXT value * @property {number} HTML=2 HTML value @@ -8341,9 +8341,9 @@ Sentence.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.text != null && message.hasOwnProperty("text")) + if (message.text != null && Object.hasOwnProperty.call(message, "text")) $root.google.cloud.language.v1beta2.TextSpan.encode(message.text, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.sentiment != null && message.hasOwnProperty("sentiment")) + if (message.sentiment != null && Object.hasOwnProperty.call(message, "sentiment")) $root.google.cloud.language.v1beta2.Sentiment.encode(message.sentiment, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -8599,19 +8599,19 @@ Entity.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.type != null && message.hasOwnProperty("type")) + if (message.type != null && Object.hasOwnProperty.call(message, "type")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.type); - if (message.metadata != null && message.hasOwnProperty("metadata")) + if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata")) for (var keys = Object.keys(message.metadata), i = 0; i < keys.length; ++i) writer.uint32(/* id 3, wireType 2 =*/26).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.metadata[keys[i]]).ldelim(); - if (message.salience != null && message.hasOwnProperty("salience")) + if (message.salience != null && Object.hasOwnProperty.call(message, "salience")) writer.uint32(/* id 4, wireType 5 =*/37).float(message.salience); if (message.mentions != null && message.mentions.length) for (var i = 0; i < message.mentions.length; ++i) $root.google.cloud.language.v1beta2.EntityMention.encode(message.mentions[i], writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); - if (message.sentiment != null && message.hasOwnProperty("sentiment")) + if (message.sentiment != null && Object.hasOwnProperty.call(message, "sentiment")) $root.google.cloud.language.v1beta2.Sentiment.encode(message.sentiment, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); return writer; }; @@ -8911,7 +8911,7 @@ /** * Type enum. * @name google.cloud.language.v1beta2.Entity.Type - * @enum {string} + * @enum {number} * @property {number} UNKNOWN=0 UNKNOWN value * @property {number} PERSON=1 PERSON value * @property {number} LOCATION=2 LOCATION value @@ -9030,13 +9030,13 @@ Token.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.text != null && message.hasOwnProperty("text")) + if (message.text != null && Object.hasOwnProperty.call(message, "text")) $root.google.cloud.language.v1beta2.TextSpan.encode(message.text, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.partOfSpeech != null && message.hasOwnProperty("partOfSpeech")) + if (message.partOfSpeech != null && Object.hasOwnProperty.call(message, "partOfSpeech")) $root.google.cloud.language.v1beta2.PartOfSpeech.encode(message.partOfSpeech, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.dependencyEdge != null && message.hasOwnProperty("dependencyEdge")) + if (message.dependencyEdge != null && Object.hasOwnProperty.call(message, "dependencyEdge")) $root.google.cloud.language.v1beta2.DependencyEdge.encode(message.dependencyEdge, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.lemma != null && message.hasOwnProperty("lemma")) + if (message.lemma != null && Object.hasOwnProperty.call(message, "lemma")) writer.uint32(/* id 4, wireType 2 =*/34).string(message.lemma); return writer; }; @@ -9219,7 +9219,7 @@ /** * EncodingType enum. * @name google.cloud.language.v1beta2.EncodingType - * @enum {string} + * @enum {number} * @property {number} NONE=0 NONE value * @property {number} UTF8=1 UTF8 value * @property {number} UTF16=2 UTF16 value @@ -9299,9 +9299,9 @@ Sentiment.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.magnitude != null && message.hasOwnProperty("magnitude")) + if (message.magnitude != null && Object.hasOwnProperty.call(message, "magnitude")) writer.uint32(/* id 2, wireType 5 =*/21).float(message.magnitude); - if (message.score != null && message.hasOwnProperty("score")) + if (message.score != null && Object.hasOwnProperty.call(message, "score")) writer.uint32(/* id 3, wireType 5 =*/29).float(message.score); return writer; }; @@ -9599,29 +9599,29 @@ PartOfSpeech.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.tag != null && message.hasOwnProperty("tag")) + if (message.tag != null && Object.hasOwnProperty.call(message, "tag")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.tag); - if (message.aspect != null && message.hasOwnProperty("aspect")) + if (message.aspect != null && Object.hasOwnProperty.call(message, "aspect")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.aspect); - if (message["case"] != null && message.hasOwnProperty("case")) + if (message["case"] != null && Object.hasOwnProperty.call(message, "case")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message["case"]); - if (message.form != null && message.hasOwnProperty("form")) + if (message.form != null && Object.hasOwnProperty.call(message, "form")) writer.uint32(/* id 4, wireType 0 =*/32).int32(message.form); - if (message.gender != null && message.hasOwnProperty("gender")) + if (message.gender != null && Object.hasOwnProperty.call(message, "gender")) writer.uint32(/* id 5, wireType 0 =*/40).int32(message.gender); - if (message.mood != null && message.hasOwnProperty("mood")) + if (message.mood != null && Object.hasOwnProperty.call(message, "mood")) writer.uint32(/* id 6, wireType 0 =*/48).int32(message.mood); - if (message.number != null && message.hasOwnProperty("number")) + if (message.number != null && Object.hasOwnProperty.call(message, "number")) writer.uint32(/* id 7, wireType 0 =*/56).int32(message.number); - if (message.person != null && message.hasOwnProperty("person")) + if (message.person != null && Object.hasOwnProperty.call(message, "person")) writer.uint32(/* id 8, wireType 0 =*/64).int32(message.person); - if (message.proper != null && message.hasOwnProperty("proper")) + if (message.proper != null && Object.hasOwnProperty.call(message, "proper")) writer.uint32(/* id 9, wireType 0 =*/72).int32(message.proper); - if (message.reciprocity != null && message.hasOwnProperty("reciprocity")) + if (message.reciprocity != null && Object.hasOwnProperty.call(message, "reciprocity")) writer.uint32(/* id 10, wireType 0 =*/80).int32(message.reciprocity); - if (message.tense != null && message.hasOwnProperty("tense")) + if (message.tense != null && Object.hasOwnProperty.call(message, "tense")) writer.uint32(/* id 11, wireType 0 =*/88).int32(message.tense); - if (message.voice != null && message.hasOwnProperty("voice")) + if (message.voice != null && Object.hasOwnProperty.call(message, "voice")) writer.uint32(/* id 12, wireType 0 =*/96).int32(message.voice); return writer; }; @@ -10320,7 +10320,7 @@ /** * Tag enum. * @name google.cloud.language.v1beta2.PartOfSpeech.Tag - * @enum {string} + * @enum {number} * @property {number} UNKNOWN=0 UNKNOWN value * @property {number} ADJ=1 ADJ value * @property {number} ADP=2 ADP value @@ -10358,7 +10358,7 @@ /** * Aspect enum. * @name google.cloud.language.v1beta2.PartOfSpeech.Aspect - * @enum {string} + * @enum {number} * @property {number} ASPECT_UNKNOWN=0 ASPECT_UNKNOWN value * @property {number} PERFECTIVE=1 PERFECTIVE value * @property {number} IMPERFECTIVE=2 IMPERFECTIVE value @@ -10376,7 +10376,7 @@ /** * Case enum. * @name google.cloud.language.v1beta2.PartOfSpeech.Case - * @enum {string} + * @enum {number} * @property {number} CASE_UNKNOWN=0 CASE_UNKNOWN value * @property {number} ACCUSATIVE=1 ACCUSATIVE value * @property {number} ADVERBIAL=2 ADVERBIAL value @@ -10416,7 +10416,7 @@ /** * Form enum. * @name google.cloud.language.v1beta2.PartOfSpeech.Form - * @enum {string} + * @enum {number} * @property {number} FORM_UNKNOWN=0 FORM_UNKNOWN value * @property {number} ADNOMIAL=1 ADNOMIAL value * @property {number} AUXILIARY=2 AUXILIARY value @@ -10450,7 +10450,7 @@ /** * Gender enum. * @name google.cloud.language.v1beta2.PartOfSpeech.Gender - * @enum {string} + * @enum {number} * @property {number} GENDER_UNKNOWN=0 GENDER_UNKNOWN value * @property {number} FEMININE=1 FEMININE value * @property {number} MASCULINE=2 MASCULINE value @@ -10468,7 +10468,7 @@ /** * Mood enum. * @name google.cloud.language.v1beta2.PartOfSpeech.Mood - * @enum {string} + * @enum {number} * @property {number} MOOD_UNKNOWN=0 MOOD_UNKNOWN value * @property {number} CONDITIONAL_MOOD=1 CONDITIONAL_MOOD value * @property {number} IMPERATIVE=2 IMPERATIVE value @@ -10492,7 +10492,7 @@ /** * Number enum. * @name google.cloud.language.v1beta2.PartOfSpeech.Number - * @enum {string} + * @enum {number} * @property {number} NUMBER_UNKNOWN=0 NUMBER_UNKNOWN value * @property {number} SINGULAR=1 SINGULAR value * @property {number} PLURAL=2 PLURAL value @@ -10510,7 +10510,7 @@ /** * Person enum. * @name google.cloud.language.v1beta2.PartOfSpeech.Person - * @enum {string} + * @enum {number} * @property {number} PERSON_UNKNOWN=0 PERSON_UNKNOWN value * @property {number} FIRST=1 FIRST value * @property {number} SECOND=2 SECOND value @@ -10530,7 +10530,7 @@ /** * Proper enum. * @name google.cloud.language.v1beta2.PartOfSpeech.Proper - * @enum {string} + * @enum {number} * @property {number} PROPER_UNKNOWN=0 PROPER_UNKNOWN value * @property {number} PROPER=1 PROPER value * @property {number} NOT_PROPER=2 NOT_PROPER value @@ -10546,7 +10546,7 @@ /** * Reciprocity enum. * @name google.cloud.language.v1beta2.PartOfSpeech.Reciprocity - * @enum {string} + * @enum {number} * @property {number} RECIPROCITY_UNKNOWN=0 RECIPROCITY_UNKNOWN value * @property {number} RECIPROCAL=1 RECIPROCAL value * @property {number} NON_RECIPROCAL=2 NON_RECIPROCAL value @@ -10562,7 +10562,7 @@ /** * Tense enum. * @name google.cloud.language.v1beta2.PartOfSpeech.Tense - * @enum {string} + * @enum {number} * @property {number} TENSE_UNKNOWN=0 TENSE_UNKNOWN value * @property {number} CONDITIONAL_TENSE=1 CONDITIONAL_TENSE value * @property {number} FUTURE=2 FUTURE value @@ -10586,7 +10586,7 @@ /** * Voice enum. * @name google.cloud.language.v1beta2.PartOfSpeech.Voice - * @enum {string} + * @enum {number} * @property {number} VOICE_UNKNOWN=0 VOICE_UNKNOWN value * @property {number} ACTIVE=1 ACTIVE value * @property {number} CAUSATIVE=2 CAUSATIVE value @@ -10669,9 +10669,9 @@ DependencyEdge.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.headTokenIndex != null && message.hasOwnProperty("headTokenIndex")) + if (message.headTokenIndex != null && Object.hasOwnProperty.call(message, "headTokenIndex")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.headTokenIndex); - if (message.label != null && message.hasOwnProperty("label")) + if (message.label != null && Object.hasOwnProperty.call(message, "label")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.label); return writer; }; @@ -11232,7 +11232,7 @@ /** * Label enum. * @name google.cloud.language.v1beta2.DependencyEdge.Label - * @enum {string} + * @enum {number} * @property {number} UNKNOWN=0 UNKNOWN value * @property {number} ABBREV=1 ABBREV value * @property {number} ACOMP=2 ACOMP value @@ -11482,11 +11482,11 @@ EntityMention.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.text != null && message.hasOwnProperty("text")) + if (message.text != null && Object.hasOwnProperty.call(message, "text")) $root.google.cloud.language.v1beta2.TextSpan.encode(message.text, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.type != null && message.hasOwnProperty("type")) + if (message.type != null && Object.hasOwnProperty.call(message, "type")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.type); - if (message.sentiment != null && message.hasOwnProperty("sentiment")) + if (message.sentiment != null && Object.hasOwnProperty.call(message, "sentiment")) $root.google.cloud.language.v1beta2.Sentiment.encode(message.sentiment, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -11668,7 +11668,7 @@ /** * Type enum. * @name google.cloud.language.v1beta2.EntityMention.Type - * @enum {string} + * @enum {number} * @property {number} TYPE_UNKNOWN=0 TYPE_UNKNOWN value * @property {number} PROPER=1 PROPER value * @property {number} COMMON=2 COMMON value @@ -11749,9 +11749,9 @@ TextSpan.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.content != null && message.hasOwnProperty("content")) + if (message.content != null && Object.hasOwnProperty.call(message, "content")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.content); - if (message.beginOffset != null && message.hasOwnProperty("beginOffset")) + if (message.beginOffset != null && Object.hasOwnProperty.call(message, "beginOffset")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.beginOffset); return writer; }; @@ -11959,9 +11959,9 @@ ClassificationCategory.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.confidence != null && message.hasOwnProperty("confidence")) + if (message.confidence != null && Object.hasOwnProperty.call(message, "confidence")) writer.uint32(/* id 2, wireType 5 =*/21).float(message.confidence); return writer; }; @@ -12169,9 +12169,9 @@ AnalyzeSentimentRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.document != null && message.hasOwnProperty("document")) + if (message.document != null && Object.hasOwnProperty.call(message, "document")) $root.google.cloud.language.v1beta2.Document.encode(message.document, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.encodingType != null && message.hasOwnProperty("encodingType")) + if (message.encodingType != null && Object.hasOwnProperty.call(message, "encodingType")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.encodingType); return writer; }; @@ -12417,9 +12417,9 @@ AnalyzeSentimentResponse.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.documentSentiment != null && message.hasOwnProperty("documentSentiment")) + if (message.documentSentiment != null && Object.hasOwnProperty.call(message, "documentSentiment")) $root.google.cloud.language.v1beta2.Sentiment.encode(message.documentSentiment, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.language != null && message.hasOwnProperty("language")) + if (message.language != null && Object.hasOwnProperty.call(message, "language")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.language); if (message.sentences != null && message.sentences.length) for (var i = 0; i < message.sentences.length; ++i) @@ -12666,9 +12666,9 @@ AnalyzeEntitySentimentRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.document != null && message.hasOwnProperty("document")) + if (message.document != null && Object.hasOwnProperty.call(message, "document")) $root.google.cloud.language.v1beta2.Document.encode(message.document, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.encodingType != null && message.hasOwnProperty("encodingType")) + if (message.encodingType != null && Object.hasOwnProperty.call(message, "encodingType")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.encodingType); return writer; }; @@ -12908,7 +12908,7 @@ if (message.entities != null && message.entities.length) for (var i = 0; i < message.entities.length; ++i) $root.google.cloud.language.v1beta2.Entity.encode(message.entities[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.language != null && message.hasOwnProperty("language")) + if (message.language != null && Object.hasOwnProperty.call(message, "language")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.language); return writer; }; @@ -13135,9 +13135,9 @@ AnalyzeEntitiesRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.document != null && message.hasOwnProperty("document")) + if (message.document != null && Object.hasOwnProperty.call(message, "document")) $root.google.cloud.language.v1beta2.Document.encode(message.document, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.encodingType != null && message.hasOwnProperty("encodingType")) + if (message.encodingType != null && Object.hasOwnProperty.call(message, "encodingType")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.encodingType); return writer; }; @@ -13377,7 +13377,7 @@ if (message.entities != null && message.entities.length) for (var i = 0; i < message.entities.length; ++i) $root.google.cloud.language.v1beta2.Entity.encode(message.entities[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.language != null && message.hasOwnProperty("language")) + if (message.language != null && Object.hasOwnProperty.call(message, "language")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.language); return writer; }; @@ -13604,9 +13604,9 @@ AnalyzeSyntaxRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.document != null && message.hasOwnProperty("document")) + if (message.document != null && Object.hasOwnProperty.call(message, "document")) $root.google.cloud.language.v1beta2.Document.encode(message.document, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.encodingType != null && message.hasOwnProperty("encodingType")) + if (message.encodingType != null && Object.hasOwnProperty.call(message, "encodingType")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.encodingType); return writer; }; @@ -13859,7 +13859,7 @@ if (message.tokens != null && message.tokens.length) for (var i = 0; i < message.tokens.length; ++i) $root.google.cloud.language.v1beta2.Token.encode(message.tokens[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.language != null && message.hasOwnProperty("language")) + if (message.language != null && Object.hasOwnProperty.call(message, "language")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.language); return writer; }; @@ -14108,7 +14108,7 @@ ClassifyTextRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.document != null && message.hasOwnProperty("document")) + if (message.document != null && Object.hasOwnProperty.call(message, "document")) $root.google.cloud.language.v1beta2.Document.encode(message.document, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); return writer; }; @@ -14526,11 +14526,11 @@ AnnotateTextRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.document != null && message.hasOwnProperty("document")) + if (message.document != null && Object.hasOwnProperty.call(message, "document")) $root.google.cloud.language.v1beta2.Document.encode(message.document, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.features != null && message.hasOwnProperty("features")) + if (message.features != null && Object.hasOwnProperty.call(message, "features")) $root.google.cloud.language.v1beta2.AnnotateTextRequest.Features.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.encodingType != null && message.hasOwnProperty("encodingType")) + if (message.encodingType != null && Object.hasOwnProperty.call(message, "encodingType")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.encodingType); return writer; }; @@ -14806,15 +14806,15 @@ Features.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.extractSyntax != null && message.hasOwnProperty("extractSyntax")) + if (message.extractSyntax != null && Object.hasOwnProperty.call(message, "extractSyntax")) writer.uint32(/* id 1, wireType 0 =*/8).bool(message.extractSyntax); - if (message.extractEntities != null && message.hasOwnProperty("extractEntities")) + if (message.extractEntities != null && Object.hasOwnProperty.call(message, "extractEntities")) writer.uint32(/* id 2, wireType 0 =*/16).bool(message.extractEntities); - if (message.extractDocumentSentiment != null && message.hasOwnProperty("extractDocumentSentiment")) + if (message.extractDocumentSentiment != null && Object.hasOwnProperty.call(message, "extractDocumentSentiment")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.extractDocumentSentiment); - if (message.extractEntitySentiment != null && message.hasOwnProperty("extractEntitySentiment")) + if (message.extractEntitySentiment != null && Object.hasOwnProperty.call(message, "extractEntitySentiment")) writer.uint32(/* id 4, wireType 0 =*/32).bool(message.extractEntitySentiment); - if (message.classifyText != null && message.hasOwnProperty("classifyText")) + if (message.classifyText != null && Object.hasOwnProperty.call(message, "classifyText")) writer.uint32(/* id 6, wireType 0 =*/48).bool(message.classifyText); return writer; }; @@ -15107,9 +15107,9 @@ if (message.entities != null && message.entities.length) for (var i = 0; i < message.entities.length; ++i) $root.google.cloud.language.v1beta2.Entity.encode(message.entities[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.documentSentiment != null && message.hasOwnProperty("documentSentiment")) + if (message.documentSentiment != null && Object.hasOwnProperty.call(message, "documentSentiment")) $root.google.cloud.language.v1beta2.Sentiment.encode(message.documentSentiment, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); - if (message.language != null && message.hasOwnProperty("language")) + if (message.language != null && Object.hasOwnProperty.call(message, "language")) writer.uint32(/* id 5, wireType 2 =*/42).string(message.language); if (message.categories != null && message.categories.length) for (var i = 0; i < message.categories.length; ++i) @@ -15469,7 +15469,7 @@ if (message.rules != null && message.rules.length) for (var i = 0; i < message.rules.length; ++i) $root.google.api.HttpRule.encode(message.rules[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.fullyDecodeReservedExpansion != null && message.hasOwnProperty("fullyDecodeReservedExpansion")) + if (message.fullyDecodeReservedExpansion != null && Object.hasOwnProperty.call(message, "fullyDecodeReservedExpansion")) writer.uint32(/* id 2, wireType 0 =*/16).bool(message.fullyDecodeReservedExpansion); return writer; }; @@ -15783,26 +15783,26 @@ HttpRule.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.selector != null && message.hasOwnProperty("selector")) + if (message.selector != null && Object.hasOwnProperty.call(message, "selector")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.selector); - if (message.get != null && message.hasOwnProperty("get")) + if (message.get != null && Object.hasOwnProperty.call(message, "get")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.get); - if (message.put != null && message.hasOwnProperty("put")) + if (message.put != null && Object.hasOwnProperty.call(message, "put")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.put); - if (message.post != null && message.hasOwnProperty("post")) + if (message.post != null && Object.hasOwnProperty.call(message, "post")) writer.uint32(/* id 4, wireType 2 =*/34).string(message.post); - if (message["delete"] != null && message.hasOwnProperty("delete")) + if (message["delete"] != null && Object.hasOwnProperty.call(message, "delete")) writer.uint32(/* id 5, wireType 2 =*/42).string(message["delete"]); - if (message.patch != null && message.hasOwnProperty("patch")) + if (message.patch != null && Object.hasOwnProperty.call(message, "patch")) writer.uint32(/* id 6, wireType 2 =*/50).string(message.patch); - if (message.body != null && message.hasOwnProperty("body")) + if (message.body != null && Object.hasOwnProperty.call(message, "body")) writer.uint32(/* id 7, wireType 2 =*/58).string(message.body); - if (message.custom != null && message.hasOwnProperty("custom")) + if (message.custom != null && Object.hasOwnProperty.call(message, "custom")) $root.google.api.CustomHttpPattern.encode(message.custom, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); if (message.additionalBindings != null && message.additionalBindings.length) for (var i = 0; i < message.additionalBindings.length; ++i) $root.google.api.HttpRule.encode(message.additionalBindings[i], writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); - if (message.responseBody != null && message.hasOwnProperty("responseBody")) + if (message.responseBody != null && Object.hasOwnProperty.call(message, "responseBody")) writer.uint32(/* id 12, wireType 2 =*/98).string(message.responseBody); return writer; }; @@ -16159,9 +16159,9 @@ CustomHttpPattern.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.kind != null && message.hasOwnProperty("kind")) + if (message.kind != null && Object.hasOwnProperty.call(message, "kind")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.kind); - if (message.path != null && message.hasOwnProperty("path")) + if (message.path != null && Object.hasOwnProperty.call(message, "path")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.path); return writer; }; @@ -16307,7 +16307,7 @@ /** * FieldBehavior enum. * @name google.api.FieldBehavior - * @enum {string} + * @enum {number} * @property {number} FIELD_BEHAVIOR_UNSPECIFIED=0 FIELD_BEHAVIOR_UNSPECIFIED value * @property {number} OPTIONAL=1 OPTIONAL value * @property {number} REQUIRED=2 REQUIRED value @@ -16708,9 +16708,9 @@ FileDescriptorProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message["package"] != null && message.hasOwnProperty("package")) + if (message["package"] != null && Object.hasOwnProperty.call(message, "package")) writer.uint32(/* id 2, wireType 2 =*/18).string(message["package"]); if (message.dependency != null && message.dependency.length) for (var i = 0; i < message.dependency.length; ++i) @@ -16727,9 +16727,9 @@ if (message.extension != null && message.extension.length) for (var i = 0; i < message.extension.length; ++i) $root.google.protobuf.FieldDescriptorProto.encode(message.extension[i], writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); - if (message.options != null && message.hasOwnProperty("options")) + if (message.options != null && Object.hasOwnProperty.call(message, "options")) $root.google.protobuf.FileOptions.encode(message.options, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); - if (message.sourceCodeInfo != null && message.hasOwnProperty("sourceCodeInfo")) + if (message.sourceCodeInfo != null && Object.hasOwnProperty.call(message, "sourceCodeInfo")) $root.google.protobuf.SourceCodeInfo.encode(message.sourceCodeInfo, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); if (message.publicDependency != null && message.publicDependency.length) for (var i = 0; i < message.publicDependency.length; ++i) @@ -16737,7 +16737,7 @@ if (message.weakDependency != null && message.weakDependency.length) for (var i = 0; i < message.weakDependency.length; ++i) writer.uint32(/* id 11, wireType 0 =*/88).int32(message.weakDependency[i]); - if (message.syntax != null && message.hasOwnProperty("syntax")) + if (message.syntax != null && Object.hasOwnProperty.call(message, "syntax")) writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax); return writer; }; @@ -17275,7 +17275,7 @@ DescriptorProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); if (message.field != null && message.field.length) for (var i = 0; i < message.field.length; ++i) @@ -17292,7 +17292,7 @@ if (message.extension != null && message.extension.length) for (var i = 0; i < message.extension.length; ++i) $root.google.protobuf.FieldDescriptorProto.encode(message.extension[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); - if (message.options != null && message.hasOwnProperty("options")) + if (message.options != null && Object.hasOwnProperty.call(message, "options")) $root.google.protobuf.MessageOptions.encode(message.options, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); if (message.oneofDecl != null && message.oneofDecl.length) for (var i = 0; i < message.oneofDecl.length; ++i) @@ -17757,11 +17757,11 @@ ExtensionRange.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.start != null && message.hasOwnProperty("start")) + if (message.start != null && Object.hasOwnProperty.call(message, "start")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.start); - if (message.end != null && message.hasOwnProperty("end")) + if (message.end != null && Object.hasOwnProperty.call(message, "end")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.end); - if (message.options != null && message.hasOwnProperty("options")) + if (message.options != null && Object.hasOwnProperty.call(message, "options")) $root.google.protobuf.ExtensionRangeOptions.encode(message.options, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -17985,9 +17985,9 @@ ReservedRange.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.start != null && message.hasOwnProperty("start")) + if (message.start != null && Object.hasOwnProperty.call(message, "start")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.start); - if (message.end != null && message.hasOwnProperty("end")) + if (message.end != null && Object.hasOwnProperty.call(message, "end")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.end); return writer; }; @@ -18478,25 +18478,25 @@ FieldDescriptorProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.extendee != null && message.hasOwnProperty("extendee")) + if (message.extendee != null && Object.hasOwnProperty.call(message, "extendee")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.extendee); - if (message.number != null && message.hasOwnProperty("number")) + if (message.number != null && Object.hasOwnProperty.call(message, "number")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.number); - if (message.label != null && message.hasOwnProperty("label")) + if (message.label != null && Object.hasOwnProperty.call(message, "label")) writer.uint32(/* id 4, wireType 0 =*/32).int32(message.label); - if (message.type != null && message.hasOwnProperty("type")) + if (message.type != null && Object.hasOwnProperty.call(message, "type")) writer.uint32(/* id 5, wireType 0 =*/40).int32(message.type); - if (message.typeName != null && message.hasOwnProperty("typeName")) + if (message.typeName != null && Object.hasOwnProperty.call(message, "typeName")) writer.uint32(/* id 6, wireType 2 =*/50).string(message.typeName); - if (message.defaultValue != null && message.hasOwnProperty("defaultValue")) + if (message.defaultValue != null && Object.hasOwnProperty.call(message, "defaultValue")) writer.uint32(/* id 7, wireType 2 =*/58).string(message.defaultValue); - if (message.options != null && message.hasOwnProperty("options")) + if (message.options != null && Object.hasOwnProperty.call(message, "options")) $root.google.protobuf.FieldOptions.encode(message.options, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); - if (message.oneofIndex != null && message.hasOwnProperty("oneofIndex")) + if (message.oneofIndex != null && Object.hasOwnProperty.call(message, "oneofIndex")) writer.uint32(/* id 9, wireType 0 =*/72).int32(message.oneofIndex); - if (message.jsonName != null && message.hasOwnProperty("jsonName")) + if (message.jsonName != null && Object.hasOwnProperty.call(message, "jsonName")) writer.uint32(/* id 10, wireType 2 =*/82).string(message.jsonName); return writer; }; @@ -18843,7 +18843,7 @@ /** * Type enum. * @name google.protobuf.FieldDescriptorProto.Type - * @enum {string} + * @enum {number} * @property {number} TYPE_DOUBLE=1 TYPE_DOUBLE value * @property {number} TYPE_FLOAT=2 TYPE_FLOAT value * @property {number} TYPE_INT64=3 TYPE_INT64 value @@ -18889,7 +18889,7 @@ /** * Label enum. * @name google.protobuf.FieldDescriptorProto.Label - * @enum {string} + * @enum {number} * @property {number} LABEL_OPTIONAL=1 LABEL_OPTIONAL value * @property {number} LABEL_REQUIRED=2 LABEL_REQUIRED value * @property {number} LABEL_REPEATED=3 LABEL_REPEATED value @@ -18970,9 +18970,9 @@ OneofDescriptorProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.options != null && message.hasOwnProperty("options")) + if (message.options != null && Object.hasOwnProperty.call(message, "options")) $root.google.protobuf.OneofOptions.encode(message.options, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -19215,12 +19215,12 @@ EnumDescriptorProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); if (message.value != null && message.value.length) for (var i = 0; i < message.value.length; ++i) $root.google.protobuf.EnumValueDescriptorProto.encode(message.value[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.options != null && message.hasOwnProperty("options")) + if (message.options != null && Object.hasOwnProperty.call(message, "options")) $root.google.protobuf.EnumOptions.encode(message.options, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); if (message.reservedRange != null && message.reservedRange.length) for (var i = 0; i < message.reservedRange.length; ++i) @@ -19523,9 +19523,9 @@ EnumReservedRange.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.start != null && message.hasOwnProperty("start")) + if (message.start != null && Object.hasOwnProperty.call(message, "start")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.start); - if (message.end != null && message.hasOwnProperty("end")) + if (message.end != null && Object.hasOwnProperty.call(message, "end")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.end); return writer; }; @@ -19745,11 +19745,11 @@ EnumValueDescriptorProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.number != null && message.hasOwnProperty("number")) + if (message.number != null && Object.hasOwnProperty.call(message, "number")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.number); - if (message.options != null && message.hasOwnProperty("options")) + if (message.options != null && Object.hasOwnProperty.call(message, "options")) $root.google.protobuf.EnumValueOptions.encode(message.options, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -19983,12 +19983,12 @@ ServiceDescriptorProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); if (message.method != null && message.method.length) for (var i = 0; i < message.method.length; ++i) $root.google.protobuf.MethodDescriptorProto.encode(message.method[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.options != null && message.hasOwnProperty("options")) + if (message.options != null && Object.hasOwnProperty.call(message, "options")) $root.google.protobuf.ServiceOptions.encode(message.options, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -20268,17 +20268,17 @@ MethodDescriptorProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.inputType != null && message.hasOwnProperty("inputType")) + if (message.inputType != null && Object.hasOwnProperty.call(message, "inputType")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.inputType); - if (message.outputType != null && message.hasOwnProperty("outputType")) + if (message.outputType != null && Object.hasOwnProperty.call(message, "outputType")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.outputType); - if (message.options != null && message.hasOwnProperty("options")) + if (message.options != null && Object.hasOwnProperty.call(message, "options")) $root.google.protobuf.MethodOptions.encode(message.options, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); - if (message.clientStreaming != null && message.hasOwnProperty("clientStreaming")) + if (message.clientStreaming != null && Object.hasOwnProperty.call(message, "clientStreaming")) writer.uint32(/* id 5, wireType 0 =*/40).bool(message.clientStreaming); - if (message.serverStreaming != null && message.hasOwnProperty("serverStreaming")) + if (message.serverStreaming != null && Object.hasOwnProperty.call(message, "serverStreaming")) writer.uint32(/* id 6, wireType 0 =*/48).bool(message.serverStreaming); return writer; }; @@ -20707,45 +20707,45 @@ FileOptions.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.javaPackage != null && message.hasOwnProperty("javaPackage")) + if (message.javaPackage != null && Object.hasOwnProperty.call(message, "javaPackage")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.javaPackage); - if (message.javaOuterClassname != null && message.hasOwnProperty("javaOuterClassname")) + if (message.javaOuterClassname != null && Object.hasOwnProperty.call(message, "javaOuterClassname")) writer.uint32(/* id 8, wireType 2 =*/66).string(message.javaOuterClassname); - if (message.optimizeFor != null && message.hasOwnProperty("optimizeFor")) + if (message.optimizeFor != null && Object.hasOwnProperty.call(message, "optimizeFor")) writer.uint32(/* id 9, wireType 0 =*/72).int32(message.optimizeFor); - if (message.javaMultipleFiles != null && message.hasOwnProperty("javaMultipleFiles")) + if (message.javaMultipleFiles != null && Object.hasOwnProperty.call(message, "javaMultipleFiles")) writer.uint32(/* id 10, wireType 0 =*/80).bool(message.javaMultipleFiles); - if (message.goPackage != null && message.hasOwnProperty("goPackage")) + if (message.goPackage != null && Object.hasOwnProperty.call(message, "goPackage")) writer.uint32(/* id 11, wireType 2 =*/90).string(message.goPackage); - if (message.ccGenericServices != null && message.hasOwnProperty("ccGenericServices")) + if (message.ccGenericServices != null && Object.hasOwnProperty.call(message, "ccGenericServices")) writer.uint32(/* id 16, wireType 0 =*/128).bool(message.ccGenericServices); - if (message.javaGenericServices != null && message.hasOwnProperty("javaGenericServices")) + if (message.javaGenericServices != null && Object.hasOwnProperty.call(message, "javaGenericServices")) writer.uint32(/* id 17, wireType 0 =*/136).bool(message.javaGenericServices); - if (message.pyGenericServices != null && message.hasOwnProperty("pyGenericServices")) + if (message.pyGenericServices != null && Object.hasOwnProperty.call(message, "pyGenericServices")) writer.uint32(/* id 18, wireType 0 =*/144).bool(message.pyGenericServices); - if (message.javaGenerateEqualsAndHash != null && message.hasOwnProperty("javaGenerateEqualsAndHash")) + if (message.javaGenerateEqualsAndHash != null && Object.hasOwnProperty.call(message, "javaGenerateEqualsAndHash")) writer.uint32(/* id 20, wireType 0 =*/160).bool(message.javaGenerateEqualsAndHash); - if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) writer.uint32(/* id 23, wireType 0 =*/184).bool(message.deprecated); - if (message.javaStringCheckUtf8 != null && message.hasOwnProperty("javaStringCheckUtf8")) + if (message.javaStringCheckUtf8 != null && Object.hasOwnProperty.call(message, "javaStringCheckUtf8")) writer.uint32(/* id 27, wireType 0 =*/216).bool(message.javaStringCheckUtf8); - if (message.ccEnableArenas != null && message.hasOwnProperty("ccEnableArenas")) + if (message.ccEnableArenas != null && Object.hasOwnProperty.call(message, "ccEnableArenas")) writer.uint32(/* id 31, wireType 0 =*/248).bool(message.ccEnableArenas); - if (message.objcClassPrefix != null && message.hasOwnProperty("objcClassPrefix")) + if (message.objcClassPrefix != null && Object.hasOwnProperty.call(message, "objcClassPrefix")) writer.uint32(/* id 36, wireType 2 =*/290).string(message.objcClassPrefix); - if (message.csharpNamespace != null && message.hasOwnProperty("csharpNamespace")) + if (message.csharpNamespace != null && Object.hasOwnProperty.call(message, "csharpNamespace")) writer.uint32(/* id 37, wireType 2 =*/298).string(message.csharpNamespace); - if (message.swiftPrefix != null && message.hasOwnProperty("swiftPrefix")) + if (message.swiftPrefix != null && Object.hasOwnProperty.call(message, "swiftPrefix")) writer.uint32(/* id 39, wireType 2 =*/314).string(message.swiftPrefix); - if (message.phpClassPrefix != null && message.hasOwnProperty("phpClassPrefix")) + if (message.phpClassPrefix != null && Object.hasOwnProperty.call(message, "phpClassPrefix")) writer.uint32(/* id 40, wireType 2 =*/322).string(message.phpClassPrefix); - if (message.phpNamespace != null && message.hasOwnProperty("phpNamespace")) + if (message.phpNamespace != null && Object.hasOwnProperty.call(message, "phpNamespace")) writer.uint32(/* id 41, wireType 2 =*/330).string(message.phpNamespace); - if (message.phpGenericServices != null && message.hasOwnProperty("phpGenericServices")) + if (message.phpGenericServices != null && Object.hasOwnProperty.call(message, "phpGenericServices")) writer.uint32(/* id 42, wireType 0 =*/336).bool(message.phpGenericServices); - if (message.phpMetadataNamespace != null && message.hasOwnProperty("phpMetadataNamespace")) + if (message.phpMetadataNamespace != null && Object.hasOwnProperty.call(message, "phpMetadataNamespace")) writer.uint32(/* id 44, wireType 2 =*/354).string(message.phpMetadataNamespace); - if (message.rubyPackage != null && message.hasOwnProperty("rubyPackage")) + if (message.rubyPackage != null && Object.hasOwnProperty.call(message, "rubyPackage")) writer.uint32(/* id 45, wireType 2 =*/362).string(message.rubyPackage); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) @@ -21138,7 +21138,7 @@ /** * OptimizeMode enum. * @name google.protobuf.FileOptions.OptimizeMode - * @enum {string} + * @enum {number} * @property {number} SPEED=1 SPEED value * @property {number} CODE_SIZE=2 CODE_SIZE value * @property {number} LITE_RUNTIME=3 LITE_RUNTIME value @@ -21247,13 +21247,13 @@ MessageOptions.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.messageSetWireFormat != null && message.hasOwnProperty("messageSetWireFormat")) + if (message.messageSetWireFormat != null && Object.hasOwnProperty.call(message, "messageSetWireFormat")) writer.uint32(/* id 1, wireType 0 =*/8).bool(message.messageSetWireFormat); - if (message.noStandardDescriptorAccessor != null && message.hasOwnProperty("noStandardDescriptorAccessor")) + if (message.noStandardDescriptorAccessor != null && Object.hasOwnProperty.call(message, "noStandardDescriptorAccessor")) writer.uint32(/* id 2, wireType 0 =*/16).bool(message.noStandardDescriptorAccessor); - if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.deprecated); - if (message.mapEntry != null && message.hasOwnProperty("mapEntry")) + if (message.mapEntry != null && Object.hasOwnProperty.call(message, "mapEntry")) writer.uint32(/* id 7, wireType 0 =*/56).bool(message.mapEntry); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) @@ -21573,17 +21573,17 @@ FieldOptions.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.ctype != null && message.hasOwnProperty("ctype")) + if (message.ctype != null && Object.hasOwnProperty.call(message, "ctype")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.ctype); - if (message.packed != null && message.hasOwnProperty("packed")) + if (message.packed != null && Object.hasOwnProperty.call(message, "packed")) writer.uint32(/* id 2, wireType 0 =*/16).bool(message.packed); - if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.deprecated); - if (message.lazy != null && message.hasOwnProperty("lazy")) + if (message.lazy != null && Object.hasOwnProperty.call(message, "lazy")) writer.uint32(/* id 5, wireType 0 =*/40).bool(message.lazy); - if (message.jstype != null && message.hasOwnProperty("jstype")) + if (message.jstype != null && Object.hasOwnProperty.call(message, "jstype")) writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jstype); - if (message.weak != null && message.hasOwnProperty("weak")) + if (message.weak != null && Object.hasOwnProperty.call(message, "weak")) writer.uint32(/* id 10, wireType 0 =*/80).bool(message.weak); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) @@ -21912,7 +21912,7 @@ /** * CType enum. * @name google.protobuf.FieldOptions.CType - * @enum {string} + * @enum {number} * @property {number} STRING=0 STRING value * @property {number} CORD=1 CORD value * @property {number} STRING_PIECE=2 STRING_PIECE value @@ -21928,7 +21928,7 @@ /** * JSType enum. * @name google.protobuf.FieldOptions.JSType - * @enum {string} + * @enum {number} * @property {number} JS_NORMAL=0 JS_NORMAL value * @property {number} JS_STRING=1 JS_STRING value * @property {number} JS_NUMBER=2 JS_NUMBER value @@ -22227,9 +22227,9 @@ EnumOptions.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.allowAlias != null && message.hasOwnProperty("allowAlias")) + if (message.allowAlias != null && Object.hasOwnProperty.call(message, "allowAlias")) writer.uint32(/* id 2, wireType 0 =*/16).bool(message.allowAlias); - if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.deprecated); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) @@ -22472,7 +22472,7 @@ EnumValueOptions.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) writer.uint32(/* id 1, wireType 0 =*/8).bool(message.deprecated); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) @@ -22721,14 +22721,14 @@ ServiceOptions.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) writer.uint32(/* id 33, wireType 0 =*/264).bool(message.deprecated); 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(); - if (message[".google.api.defaultHost"] != null && message.hasOwnProperty(".google.api.defaultHost")) + if (message[".google.api.defaultHost"] != null && Object.hasOwnProperty.call(message, ".google.api.defaultHost")) writer.uint32(/* id 1049, wireType 2 =*/8394).string(message[".google.api.defaultHost"]); - if (message[".google.api.oauthScopes"] != null && message.hasOwnProperty(".google.api.oauthScopes")) + if (message[".google.api.oauthScopes"] != null && Object.hasOwnProperty.call(message, ".google.api.oauthScopes")) writer.uint32(/* id 1050, wireType 2 =*/8402).string(message[".google.api.oauthScopes"]); return writer; }; @@ -23007,9 +23007,9 @@ MethodOptions.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) writer.uint32(/* id 33, wireType 0 =*/264).bool(message.deprecated); - if (message.idempotencyLevel != null && message.hasOwnProperty("idempotencyLevel")) + if (message.idempotencyLevel != null && Object.hasOwnProperty.call(message, "idempotencyLevel")) writer.uint32(/* id 34, wireType 0 =*/272).int32(message.idempotencyLevel); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) @@ -23017,7 +23017,7 @@ if (message[".google.api.methodSignature"] != null && message[".google.api.methodSignature"].length) for (var i = 0; i < message[".google.api.methodSignature"].length; ++i) writer.uint32(/* id 1051, wireType 2 =*/8410).string(message[".google.api.methodSignature"][i]); - if (message[".google.api.http"] != null && message.hasOwnProperty(".google.api.http")) + if (message[".google.api.http"] != null && Object.hasOwnProperty.call(message, ".google.api.http")) $root.google.api.HttpRule.encode(message[".google.api.http"], writer.uint32(/* id 72295728, wireType 2 =*/578365826).fork()).ldelim(); return writer; }; @@ -23251,7 +23251,7 @@ /** * IdempotencyLevel enum. * @name google.protobuf.MethodOptions.IdempotencyLevel - * @enum {string} + * @enum {number} * @property {number} IDEMPOTENCY_UNKNOWN=0 IDEMPOTENCY_UNKNOWN value * @property {number} NO_SIDE_EFFECTS=1 NO_SIDE_EFFECTS value * @property {number} IDEMPOTENT=2 IDEMPOTENT value @@ -23381,17 +23381,17 @@ if (message.name != null && message.name.length) for (var i = 0; i < message.name.length; ++i) $root.google.protobuf.UninterpretedOption.NamePart.encode(message.name[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.identifierValue != null && message.hasOwnProperty("identifierValue")) + if (message.identifierValue != null && Object.hasOwnProperty.call(message, "identifierValue")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.identifierValue); - if (message.positiveIntValue != null && message.hasOwnProperty("positiveIntValue")) + if (message.positiveIntValue != null && Object.hasOwnProperty.call(message, "positiveIntValue")) writer.uint32(/* id 4, wireType 0 =*/32).uint64(message.positiveIntValue); - if (message.negativeIntValue != null && message.hasOwnProperty("negativeIntValue")) + if (message.negativeIntValue != null && Object.hasOwnProperty.call(message, "negativeIntValue")) writer.uint32(/* id 5, wireType 0 =*/40).int64(message.negativeIntValue); - if (message.doubleValue != null && message.hasOwnProperty("doubleValue")) + if (message.doubleValue != null && Object.hasOwnProperty.call(message, "doubleValue")) writer.uint32(/* id 6, wireType 1 =*/49).double(message.doubleValue); - if (message.stringValue != null && message.hasOwnProperty("stringValue")) + if (message.stringValue != null && Object.hasOwnProperty.call(message, "stringValue")) writer.uint32(/* id 7, wireType 2 =*/58).bytes(message.stringValue); - if (message.aggregateValue != null && message.hasOwnProperty("aggregateValue")) + if (message.aggregateValue != null && Object.hasOwnProperty.call(message, "aggregateValue")) writer.uint32(/* id 8, wireType 2 =*/66).string(message.aggregateValue); return writer; }; @@ -24168,9 +24168,9 @@ writer.int32(message.span[i]); writer.ldelim(); } - if (message.leadingComments != null && message.hasOwnProperty("leadingComments")) + if (message.leadingComments != null && Object.hasOwnProperty.call(message, "leadingComments")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.leadingComments); - if (message.trailingComments != null && message.hasOwnProperty("trailingComments")) + if (message.trailingComments != null && Object.hasOwnProperty.call(message, "trailingComments")) writer.uint32(/* id 4, wireType 2 =*/34).string(message.trailingComments); if (message.leadingDetachedComments != null && message.leadingDetachedComments.length) for (var i = 0; i < message.leadingDetachedComments.length; ++i) @@ -24701,11 +24701,11 @@ writer.int32(message.path[i]); writer.ldelim(); } - if (message.sourceFile != null && message.hasOwnProperty("sourceFile")) + if (message.sourceFile != null && Object.hasOwnProperty.call(message, "sourceFile")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.sourceFile); - if (message.begin != null && message.hasOwnProperty("begin")) + if (message.begin != null && Object.hasOwnProperty.call(message, "begin")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.begin); - if (message.end != null && message.hasOwnProperty("end")) + if (message.end != null && Object.hasOwnProperty.call(message, "end")) writer.uint32(/* id 4, wireType 0 =*/32).int32(message.end); return writer; }; @@ -24958,9 +24958,9 @@ Timestamp.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.seconds != null && message.hasOwnProperty("seconds")) + if (message.seconds != null && Object.hasOwnProperty.call(message, "seconds")) writer.uint32(/* id 1, wireType 0 =*/8).int64(message.seconds); - if (message.nanos != null && message.hasOwnProperty("nanos")) + if (message.nanos != null && Object.hasOwnProperty.call(message, "nanos")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.nanos); return writer; }; diff --git a/packages/google-cloud-language/src/v1/language_service_client.ts b/packages/google-cloud-language/src/v1/language_service_client.ts index a3c89f69df9..dac960769f0 100644 --- a/packages/google-cloud-language/src/v1/language_service_client.ts +++ b/packages/google-cloud-language/src/v1/language_service_client.ts @@ -39,7 +39,12 @@ export class LanguageServiceClient { private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; - descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; innerApiCalls: {[name: string]: Function}; languageServiceStub?: Promise<{[name: string]: Function}>; @@ -72,10 +77,12 @@ export class LanguageServiceClient { constructor(opts?: ClientOptions) { // Ensure that options include the service address and port. const staticMembers = this.constructor as typeof LanguageServiceClient; - const servicePath = opts && opts.servicePath ? - opts.servicePath : - ((opts && opts.apiEndpoint) ? opts.apiEndpoint : - staticMembers.servicePath); + const servicePath = + opts && opts.servicePath + ? opts.servicePath + : opts && opts.apiEndpoint + ? opts.apiEndpoint + : staticMembers.servicePath; const port = opts && opts.port ? opts.port : staticMembers.port; if (!opts) { @@ -85,8 +92,8 @@ export class LanguageServiceClient { opts.port = opts.port || port; opts.clientConfig = opts.clientConfig || {}; - const isBrowser = (typeof window !== 'undefined'); - if (isBrowser){ + const isBrowser = typeof window !== 'undefined'; + if (isBrowser) { opts.fallback = true; } // If we are in browser, we are already using fallback because of the @@ -103,13 +110,10 @@ export class LanguageServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -125,18 +129,27 @@ export class LanguageServiceClient { // For Node.js, pass the path to JSON proto file. // For browsers, pass the JSON content. - const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const nodejsProtoPath = path.join( + __dirname, + '..', + '..', + 'protos', + 'protos.json' + ); this._protos = this._gaxGrpc.loadProto( - opts.fallback ? - // eslint-disable-next-line @typescript-eslint/no-var-requires - require("../../protos/protos.json") : - nodejsProtoPath + opts.fallback + ? // eslint-disable-next-line @typescript-eslint/no-var-requires + require('../../protos/protos.json') + : nodejsProtoPath ); // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.language.v1.LanguageService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.language.v1.LanguageService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + {'x-goog-api-client': clientHeader.join(' ')} + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -164,16 +177,25 @@ export class LanguageServiceClient { // Put together the "service stub" for // google.cloud.language.v1.LanguageService. this.languageServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.language.v1.LanguageService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.language.v1.LanguageService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.language.v1.LanguageService, - this._opts) as Promise<{[method: string]: Function}>; + this._opts + ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const languageServiceStubMethods = - ['analyzeSentiment', 'analyzeEntities', 'analyzeEntitySentiment', 'analyzeSyntax', 'classifyText', 'annotateText']; + const languageServiceStubMethods = [ + 'analyzeSentiment', + 'analyzeEntities', + 'analyzeEntitySentiment', + 'analyzeSyntax', + 'classifyText', + 'annotateText', + ]; for (const methodName of languageServiceStubMethods) { const callPromise = this.languageServiceStub.then( stub => (...args: Array<{}>) => { @@ -183,16 +205,17 @@ export class LanguageServiceClient { const func = stub[methodName]; return func.apply(stub, args); }, - (err: Error|null|undefined) => () => { + (err: Error | null | undefined) => () => { throw err; - }); + } + ); const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], this.descriptors.page[methodName] || - this.descriptors.stream[methodName] || - this.descriptors.longrunning[methodName] + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] ); this.innerApiCalls[methodName] = apiCall; @@ -230,7 +253,7 @@ export class LanguageServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-language', - 'https://www.googleapis.com/auth/cloud-platform' + 'https://www.googleapis.com/auth/cloud-platform', ]; } @@ -241,8 +264,9 @@ export class LanguageServiceClient { * @param {function(Error, string)} callback - the callback to * be called with the current project Id. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -254,61 +278,82 @@ export class LanguageServiceClient { // -- Service calls -- // ------------------- analyzeSentiment( - request: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.language.v1.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1.IAnalyzeSentimentRequest | undefined, + {} | undefined + ] + >; analyzeSentiment( - request: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeSentimentResponse, + | protos.google.cloud.language.v1.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + > + ): void; analyzeSentiment( - request: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): void; -/** - * Analyzes the sentiment of the provided text. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Input document. - * @param {google.cloud.language.v1.EncodingType} request.encodingType - * The encoding type used by the API to calculate sentence offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AnalyzeSentimentResponse]{@link google.cloud.language.v1.AnalyzeSentimentResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeSentimentResponse, + | protos.google.cloud.language.v1.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Analyzes the sentiment of the provided text. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Input document. + * @param {google.cloud.language.v1.EncodingType} request.encodingType + * The encoding type used by the API to calculate sentence offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AnalyzeSentimentResponse]{@link google.cloud.language.v1.AnalyzeSentimentResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ analyzeSentiment( - request: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1.IAnalyzeSentimentResponse, + | protos.google.cloud.language.v1.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.language.v1.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1.IAnalyzeSentimentRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -316,63 +361,84 @@ export class LanguageServiceClient { return this.innerApiCalls.analyzeSentiment(request, options, callback); } analyzeEntities( - request: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1.IAnalyzeEntitiesRequest | undefined, + {} | undefined + ] + >; analyzeEntities( - request: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, + | protos.google.cloud.language.v1.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + > + ): void; analyzeEntities( - request: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): void; -/** - * Finds named entities (currently proper names and common nouns) in the text - * along with entity types, salience, mentions for each entity, and - * other properties. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Input document. - * @param {google.cloud.language.v1.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AnalyzeEntitiesResponse]{@link google.cloud.language.v1.AnalyzeEntitiesResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, + | protos.google.cloud.language.v1.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Finds named entities (currently proper names and common nouns) in the text + * along with entity types, salience, mentions for each entity, and + * other properties. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Input document. + * @param {google.cloud.language.v1.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AnalyzeEntitiesResponse]{@link google.cloud.language.v1.AnalyzeEntitiesResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ analyzeEntities( - request: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, + | protos.google.cloud.language.v1.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1.IAnalyzeEntitiesRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -380,126 +446,172 @@ export class LanguageServiceClient { return this.innerApiCalls.analyzeEntities(request, options, callback); } analyzeEntitySentiment( - request: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, + ( + | protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest + | undefined + ), + {} | undefined + ] + >; analyzeEntitySentiment( - request: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, + | protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest + | null + | undefined, + {} | null | undefined + > + ): void; analyzeEntitySentiment( - request: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>): void; -/** - * Finds entities, similar to {@link google.cloud.language.v1.LanguageService.AnalyzeEntities|AnalyzeEntities} in the text and analyzes - * sentiment associated with each entity and its mentions. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Input document. - * @param {google.cloud.language.v1.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AnalyzeEntitySentimentResponse]{@link google.cloud.language.v1.AnalyzeEntitySentimentResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, + | protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Finds entities, similar to {@link google.cloud.language.v1.LanguageService.AnalyzeEntities|AnalyzeEntities} in the text and analyzes + * sentiment associated with each entity and its mentions. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Input document. + * @param {google.cloud.language.v1.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AnalyzeEntitySentimentResponse]{@link google.cloud.language.v1.AnalyzeEntitySentimentResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ analyzeEntitySentiment( - request: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, + | protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, + ( + | protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest + | undefined + ), + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; this.initialize(); - return this.innerApiCalls.analyzeEntitySentiment(request, options, callback); + return this.innerApiCalls.analyzeEntitySentiment( + request, + options, + callback + ); } analyzeSyntax( - request: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1.IAnalyzeSyntaxRequest | undefined, + {} | undefined + ] + >; analyzeSyntax( - request: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1.IAnalyzeSyntaxRequest | null | undefined, + {} | null | undefined + > + ): void; analyzeSyntax( - request: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>): void; -/** - * Analyzes the syntax of the text and provides sentence boundaries and - * tokenization along with part of speech tags, dependency trees, and other - * properties. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Input document. - * @param {google.cloud.language.v1.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AnalyzeSyntaxResponse]{@link google.cloud.language.v1.AnalyzeSyntaxResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1.IAnalyzeSyntaxRequest | null | undefined, + {} | null | undefined + > + ): void; + /** + * Analyzes the syntax of the text and provides sentence boundaries and + * tokenization along with part of speech tags, dependency trees, and other + * properties. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Input document. + * @param {google.cloud.language.v1.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AnalyzeSyntaxResponse]{@link google.cloud.language.v1.AnalyzeSyntaxResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ analyzeSyntax( - request: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1.IAnalyzeSyntaxRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1.IAnalyzeSyntaxRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1.IAnalyzeSyntaxRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -507,59 +619,74 @@ export class LanguageServiceClient { return this.innerApiCalls.analyzeSyntax(request, options, callback); } classifyText( - request: protos.google.cloud.language.v1.IClassifyTextRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.language.v1.IClassifyTextRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.language.v1.IClassifyTextResponse, + protos.google.cloud.language.v1.IClassifyTextRequest | undefined, + {} | undefined + ] + >; classifyText( - request: protos.google.cloud.language.v1.IClassifyTextRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IClassifyTextRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IClassifyTextResponse, + protos.google.cloud.language.v1.IClassifyTextRequest | null | undefined, + {} | null | undefined + > + ): void; classifyText( - request: protos.google.cloud.language.v1.IClassifyTextRequest, - callback: Callback< - protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|null|undefined, - {}|null|undefined>): void; -/** - * Classifies a document into categories. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Input document. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ClassifyTextResponse]{@link google.cloud.language.v1.ClassifyTextResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.language.v1.IClassifyTextRequest, + callback: Callback< + protos.google.cloud.language.v1.IClassifyTextResponse, + protos.google.cloud.language.v1.IClassifyTextRequest | null | undefined, + {} | null | undefined + > + ): void; + /** + * Classifies a document into categories. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Input document. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ClassifyTextResponse]{@link google.cloud.language.v1.ClassifyTextResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ classifyText( - request: protos.google.cloud.language.v1.IClassifyTextRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protos.google.cloud.language.v1.IClassifyTextRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1.IClassifyTextRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1.IClassifyTextResponse, + protos.google.cloud.language.v1.IClassifyTextRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.language.v1.IClassifyTextResponse, + protos.google.cloud.language.v1.IClassifyTextRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -567,64 +694,79 @@ export class LanguageServiceClient { return this.innerApiCalls.classifyText(request, options, callback); } annotateText( - request: protos.google.cloud.language.v1.IAnnotateTextRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.language.v1.IAnnotateTextRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.language.v1.IAnnotateTextResponse, + protos.google.cloud.language.v1.IAnnotateTextRequest | undefined, + {} | undefined + ] + >; annotateText( - request: protos.google.cloud.language.v1.IAnnotateTextRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IAnnotateTextRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IAnnotateTextResponse, + protos.google.cloud.language.v1.IAnnotateTextRequest | null | undefined, + {} | null | undefined + > + ): void; annotateText( - request: protos.google.cloud.language.v1.IAnnotateTextRequest, - callback: Callback< - protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): void; -/** - * A convenience method that provides all the features that analyzeSentiment, - * analyzeEntities, and analyzeSyntax provide in one call. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Input document. - * @param {google.cloud.language.v1.AnnotateTextRequest.Features} request.features - * The enabled features. - * @param {google.cloud.language.v1.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AnnotateTextResponse]{@link google.cloud.language.v1.AnnotateTextResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.language.v1.IAnnotateTextRequest, + callback: Callback< + protos.google.cloud.language.v1.IAnnotateTextResponse, + protos.google.cloud.language.v1.IAnnotateTextRequest | null | undefined, + {} | null | undefined + > + ): void; + /** + * A convenience method that provides all the features that analyzeSentiment, + * analyzeEntities, and analyzeSyntax provide in one call. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Input document. + * @param {google.cloud.language.v1.AnnotateTextRequest.Features} request.features + * The enabled features. + * @param {google.cloud.language.v1.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AnnotateTextResponse]{@link google.cloud.language.v1.AnnotateTextResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ annotateText( - request: protos.google.cloud.language.v1.IAnnotateTextRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protos.google.cloud.language.v1.IAnnotateTextRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1.IAnnotateTextRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1.IAnnotateTextResponse, + protos.google.cloud.language.v1.IAnnotateTextRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.language.v1.IAnnotateTextResponse, + protos.google.cloud.language.v1.IAnnotateTextRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -632,7 +774,6 @@ export class LanguageServiceClient { return this.innerApiCalls.annotateText(request, options, callback); } - /** * Terminate the GRPC channel and close the client. * diff --git a/packages/google-cloud-language/src/v1beta2/language_service_client.ts b/packages/google-cloud-language/src/v1beta2/language_service_client.ts index 0243ebcf890..7ca3bf028a6 100644 --- a/packages/google-cloud-language/src/v1beta2/language_service_client.ts +++ b/packages/google-cloud-language/src/v1beta2/language_service_client.ts @@ -39,7 +39,12 @@ export class LanguageServiceClient { private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; - descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; innerApiCalls: {[name: string]: Function}; languageServiceStub?: Promise<{[name: string]: Function}>; @@ -72,10 +77,12 @@ export class LanguageServiceClient { constructor(opts?: ClientOptions) { // Ensure that options include the service address and port. const staticMembers = this.constructor as typeof LanguageServiceClient; - const servicePath = opts && opts.servicePath ? - opts.servicePath : - ((opts && opts.apiEndpoint) ? opts.apiEndpoint : - staticMembers.servicePath); + const servicePath = + opts && opts.servicePath + ? opts.servicePath + : opts && opts.apiEndpoint + ? opts.apiEndpoint + : staticMembers.servicePath; const port = opts && opts.port ? opts.port : staticMembers.port; if (!opts) { @@ -85,8 +92,8 @@ export class LanguageServiceClient { opts.port = opts.port || port; opts.clientConfig = opts.clientConfig || {}; - const isBrowser = (typeof window !== 'undefined'); - if (isBrowser){ + const isBrowser = typeof window !== 'undefined'; + if (isBrowser) { opts.fallback = true; } // If we are in browser, we are already using fallback because of the @@ -103,13 +110,10 @@ export class LanguageServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -125,18 +129,27 @@ export class LanguageServiceClient { // For Node.js, pass the path to JSON proto file. // For browsers, pass the JSON content. - const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const nodejsProtoPath = path.join( + __dirname, + '..', + '..', + 'protos', + 'protos.json' + ); this._protos = this._gaxGrpc.loadProto( - opts.fallback ? - // eslint-disable-next-line @typescript-eslint/no-var-requires - require("../../protos/protos.json") : - nodejsProtoPath + opts.fallback + ? // eslint-disable-next-line @typescript-eslint/no-var-requires + require('../../protos/protos.json') + : nodejsProtoPath ); // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.language.v1beta2.LanguageService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.language.v1beta2.LanguageService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + {'x-goog-api-client': clientHeader.join(' ')} + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -164,16 +177,25 @@ export class LanguageServiceClient { // Put together the "service stub" for // google.cloud.language.v1beta2.LanguageService. this.languageServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.language.v1beta2.LanguageService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.language.v1beta2.LanguageService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.language.v1beta2.LanguageService, - this._opts) as Promise<{[method: string]: Function}>; + this._opts + ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const languageServiceStubMethods = - ['analyzeSentiment', 'analyzeEntities', 'analyzeEntitySentiment', 'analyzeSyntax', 'classifyText', 'annotateText']; + const languageServiceStubMethods = [ + 'analyzeSentiment', + 'analyzeEntities', + 'analyzeEntitySentiment', + 'analyzeSyntax', + 'classifyText', + 'annotateText', + ]; for (const methodName of languageServiceStubMethods) { const callPromise = this.languageServiceStub.then( stub => (...args: Array<{}>) => { @@ -183,16 +205,17 @@ export class LanguageServiceClient { const func = stub[methodName]; return func.apply(stub, args); }, - (err: Error|null|undefined) => () => { + (err: Error | null | undefined) => () => { throw err; - }); + } + ); const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], this.descriptors.page[methodName] || - this.descriptors.stream[methodName] || - this.descriptors.longrunning[methodName] + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] ); this.innerApiCalls[methodName] = apiCall; @@ -230,7 +253,7 @@ export class LanguageServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-language', - 'https://www.googleapis.com/auth/cloud-platform' + 'https://www.googleapis.com/auth/cloud-platform', ]; } @@ -241,8 +264,9 @@ export class LanguageServiceClient { * @param {function(Error, string)} callback - the callback to * be called with the current project Id. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -254,62 +278,83 @@ export class LanguageServiceClient { // -- Service calls -- // ------------------- analyzeSentiment( - request: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest | undefined, + {} | undefined + ] + >; analyzeSentiment( - request: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + > + ): void; analyzeSentiment( - request: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): void; -/** - * Analyzes the sentiment of the provided text. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType - * The encoding type used by the API to calculate sentence offsets for the - * sentence sentiment. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AnalyzeSentimentResponse]{@link google.cloud.language.v1beta2.AnalyzeSentimentResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Analyzes the sentiment of the provided text. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType + * The encoding type used by the API to calculate sentence offsets for the + * sentence sentiment. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AnalyzeSentimentResponse]{@link google.cloud.language.v1beta2.AnalyzeSentimentResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ analyzeSentiment( - request: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -317,63 +362,84 @@ export class LanguageServiceClient { return this.innerApiCalls.analyzeSentiment(request, options, callback); } analyzeEntities( - request: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest | undefined, + {} | undefined + ] + >; analyzeEntities( - request: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + > + ): void; analyzeEntities( - request: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): void; -/** - * Finds named entities (currently proper names and common nouns) in the text - * along with entity types, salience, mentions for each entity, and - * other properties. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AnalyzeEntitiesResponse]{@link google.cloud.language.v1beta2.AnalyzeEntitiesResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Finds named entities (currently proper names and common nouns) in the text + * along with entity types, salience, mentions for each entity, and + * other properties. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AnalyzeEntitiesResponse]{@link google.cloud.language.v1beta2.AnalyzeEntitiesResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ analyzeEntities( - request: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -381,126 +447,178 @@ export class LanguageServiceClient { return this.innerApiCalls.analyzeEntities(request, options, callback); } analyzeEntitySentiment( - request: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, + ( + | protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest + | undefined + ), + {} | undefined + ] + >; analyzeEntitySentiment( - request: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest + | null + | undefined, + {} | null | undefined + > + ): void; analyzeEntitySentiment( - request: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>): void; -/** - * Finds entities, similar to {@link google.cloud.language.v1beta2.LanguageService.AnalyzeEntities|AnalyzeEntities} in the text and analyzes - * sentiment associated with each entity and its mentions. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AnalyzeEntitySentimentResponse]{@link google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Finds entities, similar to {@link google.cloud.language.v1beta2.LanguageService.AnalyzeEntities|AnalyzeEntities} in the text and analyzes + * sentiment associated with each entity and its mentions. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AnalyzeEntitySentimentResponse]{@link google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ analyzeEntitySentiment( - request: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, + ( + | protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest + | undefined + ), + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; this.initialize(); - return this.innerApiCalls.analyzeEntitySentiment(request, options, callback); + return this.innerApiCalls.analyzeEntitySentiment( + request, + options, + callback + ); } analyzeSyntax( - request: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest | undefined, + {} | undefined + ] + >; analyzeSyntax( - request: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest + | null + | undefined, + {} | null | undefined + > + ): void; analyzeSyntax( - request: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>): void; -/** - * Analyzes the syntax of the text and provides sentence boundaries and - * tokenization along with part-of-speech tags, dependency trees, and other - * properties. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AnalyzeSyntaxResponse]{@link google.cloud.language.v1beta2.AnalyzeSyntaxResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Analyzes the syntax of the text and provides sentence boundaries and + * tokenization along with part-of-speech tags, dependency trees, and other + * properties. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AnalyzeSyntaxResponse]{@link google.cloud.language.v1beta2.AnalyzeSyntaxResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ analyzeSyntax( - request: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -508,59 +626,80 @@ export class LanguageServiceClient { return this.innerApiCalls.analyzeSyntax(request, options, callback); } classifyText( - request: protos.google.cloud.language.v1beta2.IClassifyTextRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.language.v1beta2.IClassifyTextRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.language.v1beta2.IClassifyTextResponse, + protos.google.cloud.language.v1beta2.IClassifyTextRequest | undefined, + {} | undefined + ] + >; classifyText( - request: protos.google.cloud.language.v1beta2.IClassifyTextRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IClassifyTextRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IClassifyTextResponse, + | protos.google.cloud.language.v1beta2.IClassifyTextRequest + | null + | undefined, + {} | null | undefined + > + ): void; classifyText( - request: protos.google.cloud.language.v1beta2.IClassifyTextRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|null|undefined, - {}|null|undefined>): void; -/** - * Classifies a document into categories. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ClassifyTextResponse]{@link google.cloud.language.v1beta2.ClassifyTextResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.language.v1beta2.IClassifyTextRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IClassifyTextResponse, + | protos.google.cloud.language.v1beta2.IClassifyTextRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Classifies a document into categories. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ClassifyTextResponse]{@link google.cloud.language.v1beta2.ClassifyTextResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ classifyText( - request: protos.google.cloud.language.v1beta2.IClassifyTextRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protos.google.cloud.language.v1beta2.IClassifyTextRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1beta2.IClassifyTextRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1beta2.IClassifyTextResponse, + | protos.google.cloud.language.v1beta2.IClassifyTextRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.language.v1beta2.IClassifyTextResponse, + protos.google.cloud.language.v1beta2.IClassifyTextRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -568,64 +707,85 @@ export class LanguageServiceClient { return this.innerApiCalls.classifyText(request, options, callback); } annotateText( - request: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnnotateTextResponse, + protos.google.cloud.language.v1beta2.IAnnotateTextRequest | undefined, + {} | undefined + ] + >; annotateText( - request: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnnotateTextResponse, + | protos.google.cloud.language.v1beta2.IAnnotateTextRequest + | null + | undefined, + {} | null | undefined + > + ): void; annotateText( - request: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): void; -/** - * A convenience method that provides all syntax, sentiment, entity, and - * classification features in one call. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1beta2.AnnotateTextRequest.Features} request.features - * Required. The enabled features. - * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AnnotateTextResponse]{@link google.cloud.language.v1beta2.AnnotateTextResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnnotateTextResponse, + | protos.google.cloud.language.v1beta2.IAnnotateTextRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * A convenience method that provides all syntax, sentiment, entity, and + * classification features in one call. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1beta2.AnnotateTextRequest.Features} request.features + * Required. The enabled features. + * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AnnotateTextResponse]{@link google.cloud.language.v1beta2.AnnotateTextResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ annotateText( - request: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1beta2.IAnnotateTextRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1beta2.IAnnotateTextResponse, + | protos.google.cloud.language.v1beta2.IAnnotateTextRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnnotateTextResponse, + protos.google.cloud.language.v1beta2.IAnnotateTextRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -633,7 +793,6 @@ export class LanguageServiceClient { return this.innerApiCalls.annotateText(request, options, callback); } - /** * Terminate the GRPC channel and close the client. * diff --git a/packages/google-cloud-language/synth.metadata b/packages/google-cloud-language/synth.metadata index bae0a1d8bdc..e7871fabb5c 100644 --- a/packages/google-cloud-language/synth.metadata +++ b/packages/google-cloud-language/synth.metadata @@ -4,22 +4,22 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-language.git", - "sha": "e11e643289693bd582f379fc3b9015680811da38" + "sha": "69fd6680792b36c2fd73e096b4cb4ac284107b51" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "cdf13efacdea0649e940452f9c5d320b93735974", - "internalRef": "306783437" + "sha": "42ee97c1b93a0e3759bbba3013da309f670a90ab", + "internalRef": "307114445" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "52638600f387deb98efb5f9c85fec39e82aa9052" + "sha": "19465d3ec5e5acdb01521d8f3bddd311bcbee28d" } } ], diff --git a/packages/google-cloud-language/system-test/fixtures/sample/src/index.js b/packages/google-cloud-language/system-test/fixtures/sample/src/index.js index e05c05ecda1..a4274b479c3 100644 --- a/packages/google-cloud-language/system-test/fixtures/sample/src/index.js +++ b/packages/google-cloud-language/system-test/fixtures/sample/src/index.js @@ -16,7 +16,6 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** - /* eslint-disable node/no-missing-require, no-unused-vars */ const language = require('@google-cloud/language'); diff --git a/packages/google-cloud-language/system-test/install.ts b/packages/google-cloud-language/system-test/install.ts index 5e4ed636481..4c1ba3eb79a 100644 --- a/packages/google-cloud-language/system-test/install.ts +++ b/packages/google-cloud-language/system-test/install.ts @@ -16,34 +16,36 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import { packNTest } from 'pack-n-play'; -import { readFileSync } from 'fs'; -import { describe, it } from 'mocha'; +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; describe('typescript consumer tests', () => { - - it('should have correct type signature for typescript users', async function() { + it('should have correct type signature for typescript users', async function () { this.timeout(300000); const options = { - packageDir: process.cwd(), // path to your module. + packageDir: process.cwd(), // path to your module. sample: { description: 'typescript based user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.ts' + ).toString(), + }, }; - await packNTest(options); // will throw upon error. + await packNTest(options); // will throw upon error. }); - it('should have correct type signature for javascript users', async function() { + it('should have correct type signature for javascript users', async function () { this.timeout(300000); const options = { - packageDir: process.cwd(), // path to your module. + packageDir: process.cwd(), // path to your module. sample: { description: 'typescript based user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.js' + ).toString(), + }, }; - await packNTest(options); // will throw upon error. + await packNTest(options); // will throw upon error. }); - }); diff --git a/packages/google-cloud-language/test/gapic_language_service_v1.ts b/packages/google-cloud-language/test/gapic_language_service_v1.ts index fed52aa338e..c9b4dda10af 100644 --- a/packages/google-cloud-language/test/gapic_language_service_v1.ts +++ b/packages/google-cloud-language/test/gapic_language_service_v1.ts @@ -20,461 +20,658 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; +import {describe, it} from 'mocha'; import * as languageserviceModule from '../src'; import {protobuf} from 'google-gax'; function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = (instance.constructor as typeof protobuf.Message).toObject( + instance as protobuf.Message, + {defaults: true} + ); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } describe('v1.LanguageServiceClient', () => { - it('has servicePath', () => { - const servicePath = languageserviceModule.v1.LanguageServiceClient.servicePath; - assert(servicePath); + it('has servicePath', () => { + const servicePath = + languageserviceModule.v1.LanguageServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + languageserviceModule.v1.LanguageServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = languageserviceModule.v1.LanguageServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new languageserviceModule.v1.LanguageServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + fallback: true, }); + assert(client); + }); - it('has apiEndpoint', () => { - const apiEndpoint = languageserviceModule.v1.LanguageServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has initialize method and supports deferred initialization', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', }); - - it('has port', () => { - const port = languageserviceModule.v1.LanguageServiceClient.port; - assert(port); - assert(typeof port === 'number'); + assert.strictEqual(client.languageServiceStub, undefined); + await client.initialize(); + assert(client.languageServiceStub); + }); + + it('has close method', () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('analyzeSentiment', () => { + it('invokes analyzeSentiment without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSentimentRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSentimentResponse() + ); + client.innerApiCalls.analyzeSentiment = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeSentiment(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.analyzeSentiment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - it('should create a client with no option', () => { - const client = new languageserviceModule.v1.LanguageServiceClient(); - assert(client); + it('invokes analyzeSentiment without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSentimentRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSentimentResponse() + ); + client.innerApiCalls.analyzeSentiment = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.analyzeSentiment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1.IAnalyzeSentimentResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.analyzeSentiment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - it('should create a client with gRPC fallback', () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - fallback: true, - }); - assert(client); + it('invokes analyzeSentiment with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSentimentRequest() + ); + const expectedOptions = {}; + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeSentiment = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.analyzeSentiment(request); + }, expectedError); + assert( + (client.innerApiCalls.analyzeSentiment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('analyzeEntities', () => { + it('invokes analyzeEntities without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitiesRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitiesResponse() + ); + client.innerApiCalls.analyzeEntities = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeEntities(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.analyzeEntities as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - it('has initialize method and supports deferred initialization', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - assert.strictEqual(client.languageServiceStub, undefined); - await client.initialize(); - assert(client.languageServiceStub); + it('invokes analyzeEntities without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitiesRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitiesResponse() + ); + client.innerApiCalls.analyzeEntities = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.analyzeEntities( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1.IAnalyzeEntitiesResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.analyzeEntities as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - it('has close method', () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.close(); + it('invokes analyzeEntities with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitiesRequest() + ); + const expectedOptions = {}; + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeEntities = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.analyzeEntities(request); + }, expectedError); + assert( + (client.innerApiCalls.analyzeEntities as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('analyzeEntitySentiment', () => { + it('invokes analyzeEntitySentiment without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitySentimentResponse() + ); + client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall( + expectedResponse + ); + const [response] = await client.analyzeEntitySentiment(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.analyzeEntitySentiment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + it('invokes analyzeEntitySentiment without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitySentimentResponse() + ); + client.innerApiCalls.analyzeEntitySentiment = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.analyzeEntitySentiment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.analyzeEntitySentiment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + it('invokes analyzeEntitySentiment with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest() + ); + const expectedOptions = {}; + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.analyzeEntitySentiment(request); + }, expectedError); + assert( + (client.innerApiCalls.analyzeEntitySentiment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('analyzeSyntax', () => { + it('invokes analyzeSyntax without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSyntaxRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSyntaxResponse() + ); + client.innerApiCalls.analyzeSyntax = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeSyntax(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.analyzeSyntax as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('analyzeSentiment', () => { - it('invokes analyzeSentiment without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSentimentRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSentimentResponse()); - client.innerApiCalls.analyzeSentiment = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeSentiment(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeSentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeSentiment without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSentimentRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSentimentResponse()); - client.innerApiCalls.analyzeSentiment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeSentiment( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IAnalyzeSentimentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeSentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes analyzeSentiment with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSentimentRequest()); - const expectedOptions = {}; - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeSentiment = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.analyzeSentiment(request); }, expectedError); - assert((client.innerApiCalls.analyzeSentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes analyzeSyntax without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSyntaxRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSyntaxResponse() + ); + client.innerApiCalls.analyzeSyntax = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.analyzeSyntax( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1.IAnalyzeSyntaxResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.analyzeSyntax as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - describe('analyzeEntities', () => { - it('invokes analyzeEntities without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitiesRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitiesResponse()); - client.innerApiCalls.analyzeEntities = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeEntities(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeEntities without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitiesRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitiesResponse()); - client.innerApiCalls.analyzeEntities = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeEntities( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IAnalyzeEntitiesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes analyzeEntities with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitiesRequest()); - const expectedOptions = {}; - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeEntities = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.analyzeEntities(request); }, expectedError); - assert((client.innerApiCalls.analyzeEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes analyzeSyntax with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSyntaxRequest() + ); + const expectedOptions = {}; + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeSyntax = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.analyzeSyntax(request); + }, expectedError); + assert( + (client.innerApiCalls.analyzeSyntax as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('classifyText', () => { + it('invokes classifyText without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.ClassifyTextRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.ClassifyTextResponse() + ); + client.innerApiCalls.classifyText = stubSimpleCall(expectedResponse); + const [response] = await client.classifyText(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.classifyText as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('analyzeEntitySentiment', () => { - it('invokes analyzeEntitySentiment without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitySentimentResponse()); - client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeEntitySentiment(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeEntitySentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeEntitySentiment without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitySentimentResponse()); - client.innerApiCalls.analyzeEntitySentiment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeEntitySentiment( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeEntitySentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes analyzeEntitySentiment with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest()); - const expectedOptions = {}; - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.analyzeEntitySentiment(request); }, expectedError); - assert((client.innerApiCalls.analyzeEntitySentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes classifyText without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.ClassifyTextRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.ClassifyTextResponse() + ); + client.innerApiCalls.classifyText = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.classifyText( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1.IClassifyTextResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.classifyText as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - describe('analyzeSyntax', () => { - it('invokes analyzeSyntax without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSyntaxRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSyntaxResponse()); - client.innerApiCalls.analyzeSyntax = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeSyntax(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeSyntax as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeSyntax without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSyntaxRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSyntaxResponse()); - client.innerApiCalls.analyzeSyntax = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeSyntax( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IAnalyzeSyntaxResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeSyntax as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes analyzeSyntax with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSyntaxRequest()); - const expectedOptions = {}; - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeSyntax = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.analyzeSyntax(request); }, expectedError); - assert((client.innerApiCalls.analyzeSyntax as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes classifyText with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.ClassifyTextRequest() + ); + const expectedOptions = {}; + const expectedError = new Error('expected'); + client.innerApiCalls.classifyText = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.classifyText(request); + }, expectedError); + assert( + (client.innerApiCalls.classifyText as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('annotateText', () => { + it('invokes annotateText without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnnotateTextRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnnotateTextResponse() + ); + client.innerApiCalls.annotateText = stubSimpleCall(expectedResponse); + const [response] = await client.annotateText(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.annotateText as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('classifyText', () => { - it('invokes classifyText without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.ClassifyTextRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.ClassifyTextResponse()); - client.innerApiCalls.classifyText = stubSimpleCall(expectedResponse); - const [response] = await client.classifyText(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.classifyText as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes classifyText without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.ClassifyTextRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.ClassifyTextResponse()); - client.innerApiCalls.classifyText = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.classifyText( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IClassifyTextResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.classifyText as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes classifyText with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.ClassifyTextRequest()); - const expectedOptions = {}; - const expectedError = new Error('expected'); - client.innerApiCalls.classifyText = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.classifyText(request); }, expectedError); - assert((client.innerApiCalls.classifyText as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes annotateText without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnnotateTextRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnnotateTextResponse() + ); + client.innerApiCalls.annotateText = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.annotateText( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1.IAnnotateTextResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.annotateText as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - describe('annotateText', () => { - it('invokes annotateText without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnnotateTextRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnnotateTextResponse()); - client.innerApiCalls.annotateText = stubSimpleCall(expectedResponse); - const [response] = await client.annotateText(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.annotateText as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes annotateText without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnnotateTextRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnnotateTextResponse()); - client.innerApiCalls.annotateText = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.annotateText( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IAnnotateTextResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.annotateText as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes annotateText with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnnotateTextRequest()); - const expectedOptions = {}; - const expectedError = new Error('expected'); - client.innerApiCalls.annotateText = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.annotateText(request); }, expectedError); - assert((client.innerApiCalls.annotateText as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes annotateText with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnnotateTextRequest() + ); + const expectedOptions = {}; + const expectedError = new Error('expected'); + client.innerApiCalls.annotateText = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.annotateText(request); + }, expectedError); + assert( + (client.innerApiCalls.annotateText as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); + }); }); diff --git a/packages/google-cloud-language/test/gapic_language_service_v1beta2.ts b/packages/google-cloud-language/test/gapic_language_service_v1beta2.ts index d66070bb18b..94377b9223e 100644 --- a/packages/google-cloud-language/test/gapic_language_service_v1beta2.ts +++ b/packages/google-cloud-language/test/gapic_language_service_v1beta2.ts @@ -20,461 +20,658 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; +import {describe, it} from 'mocha'; import * as languageserviceModule from '../src'; import {protobuf} from 'google-gax'; function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = (instance.constructor as typeof protobuf.Message).toObject( + instance as protobuf.Message, + {defaults: true} + ); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } describe('v1beta2.LanguageServiceClient', () => { - it('has servicePath', () => { - const servicePath = languageserviceModule.v1beta2.LanguageServiceClient.servicePath; - assert(servicePath); + it('has servicePath', () => { + const servicePath = + languageserviceModule.v1beta2.LanguageServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + languageserviceModule.v1beta2.LanguageServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = languageserviceModule.v1beta2.LanguageServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + fallback: true, }); + assert(client); + }); - it('has apiEndpoint', () => { - const apiEndpoint = languageserviceModule.v1beta2.LanguageServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has initialize method and supports deferred initialization', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', }); - - it('has port', () => { - const port = languageserviceModule.v1beta2.LanguageServiceClient.port; - assert(port); - assert(typeof port === 'number'); + assert.strictEqual(client.languageServiceStub, undefined); + await client.initialize(); + assert(client.languageServiceStub); + }); + + it('has close method', () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('analyzeSentiment', () => { + it('invokes analyzeSentiment without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSentimentResponse() + ); + client.innerApiCalls.analyzeSentiment = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeSentiment(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.analyzeSentiment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - it('should create a client with no option', () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient(); - assert(client); + it('invokes analyzeSentiment without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSentimentResponse() + ); + client.innerApiCalls.analyzeSentiment = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.analyzeSentiment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.analyzeSentiment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - it('should create a client with gRPC fallback', () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - fallback: true, - }); - assert(client); + it('invokes analyzeSentiment with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest() + ); + const expectedOptions = {}; + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeSentiment = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.analyzeSentiment(request); + }, expectedError); + assert( + (client.innerApiCalls.analyzeSentiment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('analyzeEntities', () => { + it('invokes analyzeEntities without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitiesResponse() + ); + client.innerApiCalls.analyzeEntities = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeEntities(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.analyzeEntities as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - it('has initialize method and supports deferred initialization', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - assert.strictEqual(client.languageServiceStub, undefined); - await client.initialize(); - assert(client.languageServiceStub); + it('invokes analyzeEntities without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitiesResponse() + ); + client.innerApiCalls.analyzeEntities = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.analyzeEntities( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.analyzeEntities as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - it('has close method', () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.close(); + it('invokes analyzeEntities with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest() + ); + const expectedOptions = {}; + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeEntities = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.analyzeEntities(request); + }, expectedError); + assert( + (client.innerApiCalls.analyzeEntities as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('analyzeEntitySentiment', () => { + it('invokes analyzeEntitySentiment without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse() + ); + client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall( + expectedResponse + ); + const [response] = await client.analyzeEntitySentiment(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.analyzeEntitySentiment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + it('invokes analyzeEntitySentiment without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse() + ); + client.innerApiCalls.analyzeEntitySentiment = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.analyzeEntitySentiment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.analyzeEntitySentiment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + it('invokes analyzeEntitySentiment with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest() + ); + const expectedOptions = {}; + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.analyzeEntitySentiment(request); + }, expectedError); + assert( + (client.innerApiCalls.analyzeEntitySentiment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('analyzeSyntax', () => { + it('invokes analyzeSyntax without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSyntaxResponse() + ); + client.innerApiCalls.analyzeSyntax = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeSyntax(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.analyzeSyntax as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('analyzeSentiment', () => { - it('invokes analyzeSentiment without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSentimentResponse()); - client.innerApiCalls.analyzeSentiment = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeSentiment(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeSentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeSentiment without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSentimentResponse()); - client.innerApiCalls.analyzeSentiment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeSentiment( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeSentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes analyzeSentiment with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest()); - const expectedOptions = {}; - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeSentiment = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.analyzeSentiment(request); }, expectedError); - assert((client.innerApiCalls.analyzeSentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes analyzeSyntax without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSyntaxResponse() + ); + client.innerApiCalls.analyzeSyntax = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.analyzeSyntax( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.analyzeSyntax as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - describe('analyzeEntities', () => { - it('invokes analyzeEntities without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitiesResponse()); - client.innerApiCalls.analyzeEntities = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeEntities(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeEntities without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitiesResponse()); - client.innerApiCalls.analyzeEntities = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeEntities( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes analyzeEntities with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest()); - const expectedOptions = {}; - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeEntities = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.analyzeEntities(request); }, expectedError); - assert((client.innerApiCalls.analyzeEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes analyzeSyntax with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest() + ); + const expectedOptions = {}; + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeSyntax = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.analyzeSyntax(request); + }, expectedError); + assert( + (client.innerApiCalls.analyzeSyntax as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('classifyText', () => { + it('invokes classifyText without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.ClassifyTextRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.ClassifyTextResponse() + ); + client.innerApiCalls.classifyText = stubSimpleCall(expectedResponse); + const [response] = await client.classifyText(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.classifyText as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('analyzeEntitySentiment', () => { - it('invokes analyzeEntitySentiment without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse()); - client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeEntitySentiment(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeEntitySentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeEntitySentiment without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse()); - client.innerApiCalls.analyzeEntitySentiment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeEntitySentiment( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeEntitySentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes analyzeEntitySentiment with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest()); - const expectedOptions = {}; - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.analyzeEntitySentiment(request); }, expectedError); - assert((client.innerApiCalls.analyzeEntitySentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes classifyText without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.ClassifyTextRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.ClassifyTextResponse() + ); + client.innerApiCalls.classifyText = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.classifyText( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1beta2.IClassifyTextResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.classifyText as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - describe('analyzeSyntax', () => { - it('invokes analyzeSyntax without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSyntaxResponse()); - client.innerApiCalls.analyzeSyntax = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeSyntax(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeSyntax as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeSyntax without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSyntaxResponse()); - client.innerApiCalls.analyzeSyntax = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeSyntax( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeSyntax as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes analyzeSyntax with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest()); - const expectedOptions = {}; - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeSyntax = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.analyzeSyntax(request); }, expectedError); - assert((client.innerApiCalls.analyzeSyntax as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes classifyText with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.ClassifyTextRequest() + ); + const expectedOptions = {}; + const expectedError = new Error('expected'); + client.innerApiCalls.classifyText = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.classifyText(request); + }, expectedError); + assert( + (client.innerApiCalls.classifyText as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('annotateText', () => { + it('invokes annotateText without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnnotateTextRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnnotateTextResponse() + ); + client.innerApiCalls.annotateText = stubSimpleCall(expectedResponse); + const [response] = await client.annotateText(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.annotateText as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('classifyText', () => { - it('invokes classifyText without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.ClassifyTextRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.ClassifyTextResponse()); - client.innerApiCalls.classifyText = stubSimpleCall(expectedResponse); - const [response] = await client.classifyText(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.classifyText as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes classifyText without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.ClassifyTextRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.ClassifyTextResponse()); - client.innerApiCalls.classifyText = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.classifyText( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IClassifyTextResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.classifyText as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes classifyText with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.ClassifyTextRequest()); - const expectedOptions = {}; - const expectedError = new Error('expected'); - client.innerApiCalls.classifyText = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.classifyText(request); }, expectedError); - assert((client.innerApiCalls.classifyText as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes annotateText without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnnotateTextRequest() + ); + const expectedOptions = {}; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnnotateTextResponse() + ); + client.innerApiCalls.annotateText = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.annotateText( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1beta2.IAnnotateTextResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.annotateText as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - describe('annotateText', () => { - it('invokes annotateText without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnnotateTextRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnnotateTextResponse()); - client.innerApiCalls.annotateText = stubSimpleCall(expectedResponse); - const [response] = await client.annotateText(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.annotateText as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes annotateText without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnnotateTextRequest()); - const expectedOptions = {}; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnnotateTextResponse()); - client.innerApiCalls.annotateText = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.annotateText( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnnotateTextResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.annotateText as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes annotateText with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnnotateTextRequest()); - const expectedOptions = {}; - const expectedError = new Error('expected'); - client.innerApiCalls.annotateText = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.annotateText(request); }, expectedError); - assert((client.innerApiCalls.annotateText as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes annotateText with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnnotateTextRequest() + ); + const expectedOptions = {}; + const expectedError = new Error('expected'); + client.innerApiCalls.annotateText = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.annotateText(request); + }, expectedError); + assert( + (client.innerApiCalls.annotateText as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); + }); }); diff --git a/packages/google-cloud-language/webpack.config.js b/packages/google-cloud-language/webpack.config.js index ea86f1d01be..e92ce835266 100644 --- a/packages/google-cloud-language/webpack.config.js +++ b/packages/google-cloud-language/webpack.config.js @@ -36,27 +36,27 @@ module.exports = { { test: /\.tsx?$/, use: 'ts-loader', - exclude: /node_modules/ + exclude: /node_modules/, }, { test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' + use: 'null-loader', }, { test: /node_modules[\\/]grpc/, - use: 'null-loader' + use: 'null-loader', }, { test: /node_modules[\\/]retry-request/, - use: 'null-loader' + use: 'null-loader', }, { test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' + use: 'null-loader', }, { test: /node_modules[\\/]gtoken/, - use: 'null-loader' + use: 'null-loader', }, ], },